mirror of
https://github.com/lensapp/lens.git
synced 2024-09-11 09:25:26 +03:00
chore: Remove unnecessary use of SingleOrMany<SafeReactNode>
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
adb288e48a
commit
e88de58b5d
@ -1,11 +1,11 @@
|
||||
import type { SafeReactNode, SingleOrMany } from "@k8slens/utilities";
|
||||
import type { SafeReactNode } from "@k8slens/utilities";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import React, { useEffect } from "react";
|
||||
|
||||
import invokeShortcutInjectable, { InvokeShortcut } from "./invoke-shortcut.injectable";
|
||||
|
||||
export interface KeyboardShortcutListenerProps {
|
||||
children: SingleOrMany<SafeReactNode>;
|
||||
children: SafeReactNode;
|
||||
}
|
||||
|
||||
interface Dependencies {
|
||||
|
@ -1,9 +1,9 @@
|
||||
import type { SafeReactNode, SingleOrMany } from "@k8slens/utilities";
|
||||
import type { SafeReactNode } from "@k8slens/utilities";
|
||||
import React from "react";
|
||||
|
||||
export interface KeyboardShortcutScopeProps {
|
||||
id: string;
|
||||
children: SingleOrMany<SafeReactNode>;
|
||||
children: SafeReactNode;
|
||||
}
|
||||
|
||||
export const KeyboardShortcutScope = ({ id, children }: KeyboardShortcutScopeProps) => (
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
import "./animate.scss";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import type { SafeReactNode, SingleOrMany } from "@k8slens/utilities";
|
||||
import type { SafeReactNode } from "@k8slens/utilities";
|
||||
import { cssNames, noop } from "@k8slens/utilities";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import type { RequestAnimationFrame } from "./request-animation-frame.injectable";
|
||||
@ -22,7 +22,7 @@ export interface AnimateProps {
|
||||
onLeave?: () => void;
|
||||
enterDuration?: number;
|
||||
leaveDuration?: number;
|
||||
children?: SingleOrMany<SafeReactNode>;
|
||||
children?: SafeReactNode;
|
||||
}
|
||||
|
||||
interface Dependencies {
|
||||
|
@ -8,7 +8,7 @@ import styles from "./avatar.module.scss";
|
||||
import type { ImgHTMLAttributes, MouseEventHandler } from "react";
|
||||
import React from "react";
|
||||
import randomColor from "randomcolor";
|
||||
import type { SafeReactNode, SingleOrMany } from "@k8slens/utilities";
|
||||
import type { SafeReactNode } from "@k8slens/utilities";
|
||||
import { cssNames } from "@k8slens/utilities";
|
||||
import { computeDefaultShortName } from "../../../common/catalog/helpers";
|
||||
|
||||
@ -21,7 +21,7 @@ export interface AvatarProps {
|
||||
variant?: "circle" | "rounded" | "square";
|
||||
imgProps?: ImgHTMLAttributes<HTMLImageElement>;
|
||||
disabled?: boolean;
|
||||
children?: SingleOrMany<SafeReactNode>;
|
||||
children?: SafeReactNode;
|
||||
className?: string;
|
||||
id?: string;
|
||||
onClick?: MouseEventHandler<HTMLDivElement>;
|
||||
|
@ -8,7 +8,7 @@ import styles from "./badge.module.scss";
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import { action, observable } from "mobx";
|
||||
import { observer } from "mobx-react";
|
||||
import type { SafeReactNode, SingleOrMany } from "@k8slens/utilities";
|
||||
import type { SafeReactNode } from "@k8slens/utilities";
|
||||
import { cssNames } from "@k8slens/utilities";
|
||||
import { withTooltip } from "@k8slens/tooltip";
|
||||
|
||||
@ -19,7 +19,7 @@ export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
expandable?: boolean;
|
||||
disabled?: boolean;
|
||||
scrollable?: boolean;
|
||||
children?: SingleOrMany<SafeReactNode>;
|
||||
children?: SafeReactNode;
|
||||
}
|
||||
|
||||
// Common handler for all Badge instances
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
import "./checkbox.scss";
|
||||
import React from "react";
|
||||
import type { SafeReactNode, SingleOrMany } from "@k8slens/utilities";
|
||||
import type { SafeReactNode } from "@k8slens/utilities";
|
||||
import { cssNames, noop } from "@k8slens/utilities";
|
||||
|
||||
export interface CheckboxProps {
|
||||
@ -15,7 +15,7 @@ export interface CheckboxProps {
|
||||
disabled?: boolean;
|
||||
value?: boolean;
|
||||
onChange?(value: boolean, evt: React.ChangeEvent<HTMLInputElement>): void;
|
||||
children?: SingleOrMany<SafeReactNode>;
|
||||
children?: SafeReactNode;
|
||||
}
|
||||
|
||||
export function Checkbox({ label, inline, className, value, children, onChange = noop, disabled, ...inputProps }: CheckboxProps) {
|
||||
|
@ -10,7 +10,7 @@ import { createPortal } from "react-dom";
|
||||
import { disposeOnUnmount, observer } from "mobx-react";
|
||||
import { reaction } from "mobx";
|
||||
import { Animate } from "../animate";
|
||||
import type { SafeReactNode, SingleOrMany } from "@k8slens/utilities";
|
||||
import type { SafeReactNode } from "@k8slens/utilities";
|
||||
import { cssNames, noop, stopPropagation } from "@k8slens/utilities";
|
||||
import type { ObservableHistory } from "mobx-observable-history";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
@ -30,7 +30,7 @@ export interface DialogProps {
|
||||
pinned?: boolean;
|
||||
animated?: boolean;
|
||||
"data-testid"?: string;
|
||||
children?: SingleOrMany<SafeReactNode>;
|
||||
children?: SafeReactNode;
|
||||
}
|
||||
|
||||
interface DialogState {
|
||||
|
@ -6,12 +6,12 @@
|
||||
import "./drawer-param-toggler.scss";
|
||||
import React from "react";
|
||||
import { Icon } from "../icon";
|
||||
import type { SafeReactNode, SingleOrMany } from "@k8slens/utilities";
|
||||
import type { SafeReactNode } from "@k8slens/utilities";
|
||||
import { cssNames } from "@k8slens/utilities";
|
||||
|
||||
export interface DrawerParamTogglerProps {
|
||||
label: string | number;
|
||||
children: SingleOrMany<SafeReactNode>;
|
||||
children: SafeReactNode;
|
||||
}
|
||||
|
||||
interface State {
|
||||
|
@ -8,7 +8,7 @@ import "./drawer.scss";
|
||||
import React from "react";
|
||||
import { clipboard } from "electron";
|
||||
import { createPortal } from "react-dom";
|
||||
import type { SafeReactNode, SingleOrMany } from "@k8slens/utilities";
|
||||
import type { SafeReactNode } from "@k8slens/utilities";
|
||||
import { cssNames, noop } from "@k8slens/utilities";
|
||||
import { Icon } from "../icon";
|
||||
import type { AnimateName } from "../animate";
|
||||
@ -39,7 +39,7 @@ export interface DrawerProps {
|
||||
animation?: AnimateName;
|
||||
onClose?: () => void;
|
||||
toolbar?: SafeReactNode;
|
||||
children?: SingleOrMany<SafeReactNode>;
|
||||
children?: SafeReactNode;
|
||||
"data-testid"?: string;
|
||||
testIdForClose?: string;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { SafeReactNode, SingleOrMany } from "@k8slens/utilities";
|
||||
import type { SafeReactNode } from "@k8slens/utilities";
|
||||
import { toSafeReactChildrenArray } from "@k8slens/utilities";
|
||||
import type { HTMLAttributes } from "react";
|
||||
import React, { useState } from "react";
|
||||
@ -11,7 +11,7 @@ import { Menu } from "../menu";
|
||||
|
||||
interface DropdownProps extends HTMLAttributes<HTMLDivElement> {
|
||||
contentForToggle: SafeReactNode;
|
||||
children?: SingleOrMany<SafeReactNode>;
|
||||
children?: SafeReactNode;
|
||||
}
|
||||
|
||||
export function Dropdown(props: DropdownProps) {
|
||||
|
@ -5,11 +5,11 @@
|
||||
import "./hotbar-menu.scss";
|
||||
|
||||
import React, { useState } from "react";
|
||||
import type { SafeReactNode, SingleOrMany } from "@k8slens/utilities";
|
||||
import type { SafeReactNode } from "@k8slens/utilities";
|
||||
import { cssNames } from "@k8slens/utilities";
|
||||
|
||||
export interface HotbarCellProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
children?: SingleOrMany<SafeReactNode>;
|
||||
children?: SafeReactNode;
|
||||
index: number;
|
||||
innerRef?: React.Ref<HTMLDivElement>;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ import Workloads from "./workloads.svg";
|
||||
import type { Logger } from "@k8slens/logger";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import { loggerInjectionToken } from "@k8slens/logger";
|
||||
import type { SingleOrMany, SafeReactNode } from "@k8slens/utilities";
|
||||
import type { SafeReactNode } from "@k8slens/utilities";
|
||||
|
||||
const hrefValidation = /https?:\/\//;
|
||||
|
||||
@ -159,7 +159,7 @@ export interface BaseIconProps {
|
||||
}
|
||||
|
||||
export interface IconProps extends React.HTMLAttributes<any>, BaseIconProps {
|
||||
children?: SingleOrMany<SafeReactNode>;
|
||||
children?: SafeReactNode;
|
||||
}
|
||||
|
||||
export function isSvg(content: string): boolean {
|
||||
|
@ -7,7 +7,7 @@ import styles from "./main-layout.module.scss";
|
||||
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import type { SafeReactNode, SingleOrMany } from "@k8slens/utilities";
|
||||
import type { SafeReactNode } from "@k8slens/utilities";
|
||||
import { cssNames } from "@k8slens/utilities";
|
||||
import { ErrorBoundary } from "@k8slens/error-boundary";
|
||||
import { ResizeDirection, ResizeGrowthDirection, ResizeSide, ResizingAnchor } from "@k8slens/resizing-anchor";
|
||||
@ -20,7 +20,7 @@ export interface MainLayoutProps {
|
||||
sidebar: SafeReactNode;
|
||||
className?: string;
|
||||
footer?: SafeReactNode;
|
||||
children?: SingleOrMany<SafeReactNode>;
|
||||
children?: SafeReactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,14 +5,14 @@
|
||||
|
||||
import "./sub-header.scss";
|
||||
import React from "react";
|
||||
import type { SafeReactNode, SingleOrMany } from "@k8slens/utilities";
|
||||
import type { SafeReactNode } from "@k8slens/utilities";
|
||||
import { cssNames } from "@k8slens/utilities";
|
||||
|
||||
export interface SubHeaderProps {
|
||||
className?: string;
|
||||
withLine?: boolean; // add bottom line
|
||||
compact?: boolean; // no extra padding around content
|
||||
children: SingleOrMany<SafeReactNode>;
|
||||
children: SafeReactNode;
|
||||
}
|
||||
|
||||
export class SubHeader extends React.Component<SubHeaderProps> {
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
import "./sub-title.scss";
|
||||
import React from "react";
|
||||
import type { SafeReactNode, SingleOrMany } from "@k8slens/utilities";
|
||||
import type { SafeReactNode } from "@k8slens/utilities";
|
||||
import { cssNames } from "@k8slens/utilities";
|
||||
|
||||
export interface SubTitleProps {
|
||||
@ -13,7 +13,7 @@ export interface SubTitleProps {
|
||||
title: SafeReactNode;
|
||||
compact?: boolean; // no bottom padding
|
||||
id?: string;
|
||||
children?: SingleOrMany<SafeReactNode>;
|
||||
children?: SafeReactNode;
|
||||
}
|
||||
|
||||
export class SubTitle extends React.Component<SubTitleProps> {
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
import "./line-progress.scss";
|
||||
import React from "react";
|
||||
import type { SafeReactNode, SingleOrMany } from "@k8slens/utilities";
|
||||
import type { SafeReactNode } from "@k8slens/utilities";
|
||||
import { cssNames } from "@k8slens/utilities";
|
||||
import { withTooltip } from "@k8slens/tooltip";
|
||||
|
||||
@ -15,7 +15,7 @@ export interface LineProgressProps extends React.HTMLProps<HTMLDivElement> {
|
||||
max?: number;
|
||||
className?: any;
|
||||
precise?: number;
|
||||
children?: SingleOrMany<SafeReactNode>;
|
||||
children?: SafeReactNode;
|
||||
}
|
||||
|
||||
function valuePercent({ value, min, max, precise }: Required<Pick<LineProgressProps, "value" | "min" | "max" | "precise">>) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import type { SafeReactNode, SingleOrMany } from "@k8slens/utilities";
|
||||
import type { SafeReactNode } from "@k8slens/utilities";
|
||||
import type { RequestIdleCallback } from "./request-idle-callback.injectable";
|
||||
import type { CancelIdleCallback } from "./cancel-idle-callback.injectable";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
@ -14,7 +14,7 @@ import idleCallbackTimeoutInjectable from "./idle-callback-timeout.injectable";
|
||||
|
||||
export interface RenderDelayProps {
|
||||
placeholder?: SafeReactNode;
|
||||
children: SingleOrMany<SafeReactNode>;
|
||||
children: SafeReactNode;
|
||||
}
|
||||
|
||||
interface Dependencies {
|
||||
|
@ -6,12 +6,12 @@
|
||||
import "./status-brick.scss";
|
||||
|
||||
import React from "react";
|
||||
import type { SafeReactNode, SingleOrMany } from "@k8slens/utilities";
|
||||
import type { SafeReactNode } from "@k8slens/utilities";
|
||||
import { cssNames } from "@k8slens/utilities";
|
||||
import { withTooltip } from "@k8slens/tooltip";
|
||||
|
||||
export interface StatusBrickProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
children?: SingleOrMany<SafeReactNode>;
|
||||
children?: SafeReactNode;
|
||||
}
|
||||
|
||||
export const StatusBrick = withTooltip(({ className, ...elemProps }: StatusBrickProps) => (
|
||||
|
@ -6,7 +6,7 @@
|
||||
import "./button.scss";
|
||||
import type { ButtonHTMLAttributes } from "react";
|
||||
import React from "react";
|
||||
import { cssNames, SafeReactNode, SingleOrMany } from "@k8slens/utilities";
|
||||
import { cssNames, SafeReactNode } from "@k8slens/utilities";
|
||||
import { withTooltip } from "@k8slens/tooltip";
|
||||
|
||||
export interface ButtonProps extends ButtonHTMLAttributes<any> {
|
||||
@ -23,7 +23,7 @@ export interface ButtonProps extends ButtonHTMLAttributes<any> {
|
||||
round?: boolean;
|
||||
href?: string; // render as hyperlink
|
||||
target?: "_blank"; // in case of using @href
|
||||
children?: SingleOrMany<SafeReactNode>;
|
||||
children?: SafeReactNode;
|
||||
}
|
||||
|
||||
export const Button = withTooltip((props: ButtonProps) => {
|
||||
|
@ -9,7 +9,7 @@ import type { ErrorInfo } from "react";
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { Button } from "@k8slens/button";
|
||||
import type { SafeReactNode, SingleOrMany } from "@k8slens/utilities";
|
||||
import type { SafeReactNode } from "@k8slens/utilities";
|
||||
import type { ObservableHistory } from "mobx-observable-history";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import { observableHistoryInjectionToken } from "@k8slens/routing";
|
||||
@ -18,7 +18,7 @@ const issuesTrackerUrl = "https://github.com/lensapp/lens/issues";
|
||||
const forumsUrl = "https://forums.k8slens.dev";
|
||||
|
||||
export interface ErrorBoundaryProps {
|
||||
children?: SingleOrMany<SafeReactNode>;
|
||||
children?: SafeReactNode;
|
||||
}
|
||||
|
||||
interface State {
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { SafeReactNode, SingleOrMany } from "@k8slens/utilities";
|
||||
import type { SafeReactNode } from "@k8slens/utilities";
|
||||
import { render, RenderResult } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import React from "react";
|
||||
@ -12,7 +12,7 @@ import { withTooltip } from "./withTooltip";
|
||||
type MyComponentProps = {
|
||||
text: string;
|
||||
id?: string;
|
||||
children?: SingleOrMany<SafeReactNode>;
|
||||
children?: SafeReactNode;
|
||||
"data-testid"?: string;
|
||||
};
|
||||
|
||||
|
@ -18,7 +18,7 @@ export interface TooltipDecoratorProps {
|
||||
*/
|
||||
tooltipOverrideDisabled?: boolean;
|
||||
id?: string;
|
||||
children?: SingleOrMany<SafeReactNode>;
|
||||
children?: SafeReactNode;
|
||||
}
|
||||
|
||||
export function withTooltip<TargetProps>(
|
||||
|
@ -9,7 +9,7 @@ import type { SingleOrMany } from "./types";
|
||||
|
||||
export type SafeReactNode = React.ReactElement | React.ReactText | boolean | null | undefined | Iterable<SafeReactNode>;
|
||||
|
||||
export function toSafeReactChildrenArray(children: SingleOrMany<SafeReactNode>) {
|
||||
export function toSafeReactChildrenArray(children: SafeReactNode) {
|
||||
return React.Children.toArray(children) as (Exclude<SafeReactNode, boolean | null | undefined>)[];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user