@k8slens/lds 0.58.1 → 0.58.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/Avatar/Avatar.d.ts +3 -1
- package/lib/cjs/Badge/Badge.d.ts +6 -4
- package/lib/cjs/Button/Button.d.ts +34 -6
- package/lib/cjs/Button/shared.d.ts +30 -1
- package/lib/cjs/ButtonBar/ButtonBar.d.ts +17 -0
- package/lib/cjs/Checkbox/Checkbox.d.ts +7 -0
- package/lib/cjs/ConfirmDialog/ConfirmDialog.d.ts +16 -0
- package/lib/cjs/ContextMenu/ContextMenu.d.ts +40 -0
- package/lib/cjs/ContextMenu/ContextMenu.js +1 -0
- package/lib/cjs/ContextMenu/ContextMenu.module.css.js +1 -0
- package/lib/cjs/ContextMenu/ContextMenuItem.d.ts +30 -0
- package/lib/cjs/ContextMenu/ContextMenuItem.js +1 -0
- package/lib/cjs/DrawerTransition/DrawerTransition.d.ts +20 -0
- package/lib/cjs/Input/Input.d.ts +8 -0
- package/lib/cjs/LinkButton/LinkButton.d.ts +7 -0
- package/lib/cjs/LoadingIndicator/LoadingIndicator.d.ts +8 -2
- package/lib/cjs/Lozenge/Lozenge.d.ts +4 -2
- package/lib/cjs/Modal/Modal.d.ts +26 -0
- package/lib/cjs/Notification/Notification.d.ts +18 -2
- package/lib/cjs/NumberBadge/NumberBadge.d.ts +1 -1
- package/lib/cjs/Panel/Panel.d.ts +28 -0
- package/lib/cjs/ProfileBlock/ProfileBlock.d.ts +8 -0
- package/lib/cjs/ProgressBar/ProgressBar.d.ts +11 -0
- package/lib/cjs/ProgressBar/ProgressBar.js +1 -1
- package/lib/cjs/RadioCard/RadioCard.d.ts +27 -1
- package/lib/cjs/Select/MultiOption.d.ts +14 -4
- package/lib/cjs/Select/Option.d.ts +6 -0
- package/lib/cjs/Select/Select.d.ts +39 -5
- package/lib/cjs/SideNav/SideNav.d.ts +9 -3
- package/lib/cjs/SideNav/SideNavGroup.d.ts +13 -5
- package/lib/cjs/SideNav/SideNavItem.d.ts +22 -5
- package/lib/cjs/Switch/Switch.d.ts +2 -0
- package/lib/cjs/Tooltip/Tooltip.d.ts +15 -3
- package/lib/cjs/UserMenu/UserMenu.d.ts +9 -2
- package/lib/cjs/UserMenu/UserMenuDropdown.d.ts +10 -6
- package/lib/cjs/UserMenu/UserMenuItem.d.ts +22 -1
- package/lib/cjs/components.d.ts +1 -0
- package/lib/cjs/index.css +1 -1
- package/lib/cjs/index.electron.js +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/es/Avatar/Avatar.d.ts +3 -1
- package/lib/es/Badge/Badge.d.ts +6 -4
- package/lib/es/Button/Button.d.ts +34 -6
- package/lib/es/Button/shared.d.ts +30 -1
- package/lib/es/ButtonBar/ButtonBar.d.ts +17 -0
- package/lib/es/Checkbox/Checkbox.d.ts +7 -0
- package/lib/es/ConfirmDialog/ConfirmDialog.d.ts +16 -0
- package/lib/es/ContextMenu/ContextMenu.d.ts +40 -0
- package/lib/es/ContextMenu/ContextMenu.js +1 -0
- package/lib/es/ContextMenu/ContextMenu.module.css.js +1 -0
- package/lib/es/ContextMenu/ContextMenuItem.d.ts +30 -0
- package/lib/es/ContextMenu/ContextMenuItem.js +1 -0
- package/lib/es/DrawerTransition/DrawerTransition.d.ts +20 -0
- package/lib/es/Input/Input.d.ts +8 -0
- package/lib/es/LinkButton/LinkButton.d.ts +7 -0
- package/lib/es/LoadingIndicator/LoadingIndicator.d.ts +8 -2
- package/lib/es/Lozenge/Lozenge.d.ts +4 -2
- package/lib/es/Modal/Modal.d.ts +26 -0
- package/lib/es/Notification/Notification.d.ts +18 -2
- package/lib/es/NumberBadge/NumberBadge.d.ts +1 -1
- package/lib/es/Panel/Panel.d.ts +28 -0
- package/lib/es/ProfileBlock/ProfileBlock.d.ts +8 -0
- package/lib/es/ProgressBar/ProgressBar.d.ts +11 -0
- package/lib/es/ProgressBar/ProgressBar.js +1 -1
- package/lib/es/RadioCard/RadioCard.d.ts +27 -1
- package/lib/es/Select/MultiOption.d.ts +14 -4
- package/lib/es/Select/Option.d.ts +6 -0
- package/lib/es/Select/Select.d.ts +39 -5
- package/lib/es/SideNav/SideNav.d.ts +9 -3
- package/lib/es/SideNav/SideNavGroup.d.ts +13 -5
- package/lib/es/SideNav/SideNavItem.d.ts +22 -5
- package/lib/es/Switch/Switch.d.ts +2 -0
- package/lib/es/Tooltip/Tooltip.d.ts +15 -3
- package/lib/es/UserMenu/UserMenu.d.ts +9 -2
- package/lib/es/UserMenu/UserMenuDropdown.d.ts +10 -6
- package/lib/es/UserMenu/UserMenuItem.d.ts +22 -1
- package/lib/es/components.d.ts +1 -0
- package/lib/es/index.css +1 -1
- package/lib/es/index.electron.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/web/{lds-v0-58-0 → lds-v0-58-2}/index.css +1 -1
- package/lib/web/lds-v0-58-2/index.js +28 -0
- package/llms.txt +290 -100
- package/package.json +3 -3
- package/lib/web/lds-v0-58-0/index.js +0 -28
- /package/lib/web/{lds-v0-58-0 → lds-v0-58-2}/typography.css +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../_virtual/_tslib.js"),a=require("react"),t=require("./ProgressBar.module.css.js")
|
|
1
|
+
"use strict";var e=require("../_virtual/_tslib.js"),a=require("react"),t=require("clsx"),r=require("./ProgressBar.module.css.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=s(a),l=s(t);module.exports=function(a){var t,s=a.value,i=a.type,o=void 0===i?"default":i,c=a.max,n=void 0===c?1:c,d=a.title,m=a.className,v=e.__rest(a,["value","type","max","title","className"]),f=isNaN(s)?0:Math.max(0,s),x=isNaN(n)||n<=0?1:n,N=Math.min(100,Math.round(f/x*100)),p=d||"".concat(N,"%");return u.default.createElement("progress",e.__assign({},v,{className:l.default(r.progressBar,m,(t={},t[r[o]]="default"!==o,t)),value:f,max:x,"aria-valuetext":p,title:d}),p)};
|
|
@@ -10,16 +10,33 @@ declare type ItemState = {
|
|
|
10
10
|
selected?: boolean;
|
|
11
11
|
disabled?: boolean;
|
|
12
12
|
};
|
|
13
|
+
/** Props for the RadioCard component. */
|
|
13
14
|
export interface RadioCardProps<T> {
|
|
15
|
+
/** HTML `id` attribute for the radio group. */
|
|
14
16
|
id?: string;
|
|
17
|
+
/** Accessible label for the radio group. */
|
|
15
18
|
"aria-label"?: string;
|
|
19
|
+
/** Array of options to render as radio cards. */
|
|
16
20
|
options: Array<T>;
|
|
21
|
+
/** Currently selected option. */
|
|
17
22
|
value: T | undefined;
|
|
23
|
+
/** Change handler receiving the selected option. */
|
|
18
24
|
onChange(d: T): void;
|
|
25
|
+
/** Name attribute for the radio group. */
|
|
19
26
|
name: string;
|
|
27
|
+
/** Optional class name for the radio group container. */
|
|
20
28
|
className?: string;
|
|
29
|
+
/** Optional class name applied to each radio card item. */
|
|
21
30
|
itemClassName?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the entire radio group is disabled.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
22
35
|
disabled?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Whether the radio group is in an invalid state.
|
|
38
|
+
* @default false
|
|
39
|
+
*/
|
|
23
40
|
invalid?: boolean;
|
|
24
41
|
/**
|
|
25
42
|
* Function to render the content of card item.
|
|
@@ -30,9 +47,18 @@ export interface RadioCardProps<T> {
|
|
|
30
47
|
renderItem?(d: T | undefined, state: ItemState): ReactNode;
|
|
31
48
|
}
|
|
32
49
|
/**
|
|
33
|
-
* A
|
|
50
|
+
* A card-based radio group for visual option selection. Renders each option as a styled card with a radio indicator.
|
|
34
51
|
*
|
|
35
52
|
* Usage: `import { RadioCard } from "@k8slens/lds"`
|
|
53
|
+
*
|
|
54
|
+
* ```tsx
|
|
55
|
+
* <RadioCard
|
|
56
|
+
* name="plan"
|
|
57
|
+
* options={[{ id: "1", label: "Free" }, { id: "2", label: "Pro" }]}
|
|
58
|
+
* value={selected}
|
|
59
|
+
* onChange={setSelected}
|
|
60
|
+
* />
|
|
61
|
+
* ```
|
|
36
62
|
*/
|
|
37
63
|
export default function RadioCard<T extends DefaultOption>({ id, "aria-label": ariaLabel, value, options, onChange, name, invalid, disabled, itemClassName, className, renderItem, ...radioGroupProps }: RadioCardProps<T>): React.JSX.Element;
|
|
38
64
|
export {};
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import React, { type ReactNode } from "react";
|
|
2
|
-
|
|
2
|
+
/** Props for the MultiOption component. */
|
|
3
|
+
interface MultiOptionProps {
|
|
4
|
+
/** Display text of the option, used for the accessible label. */
|
|
3
5
|
label: string;
|
|
4
|
-
|
|
6
|
+
/** Optional class name for the multi-option pill. */
|
|
7
|
+
className?: string;
|
|
8
|
+
/** Content rendered inside the option pill. */
|
|
5
9
|
children: ReactNode;
|
|
10
|
+
/** Called when the remove button is clicked or activated via keyboard. */
|
|
6
11
|
onRemove: (e: React.MouseEvent | React.KeyboardEvent) => void;
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
/** Called on arrow key press for keyboard navigation between pills. */
|
|
13
|
+
onArrowNavigate?: (direction: "next" | "prev") => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Removable pill for selected values in a multi-select. Supports keyboard navigation and accessible removal.
|
|
17
|
+
*/
|
|
18
|
+
declare const MultiOption: React.ForwardRefExoticComponent<MultiOptionProps & React.RefAttributes<HTMLSpanElement>>;
|
|
9
19
|
export default MultiOption;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { type DefaultOption, type SelectProps } from "./Select";
|
|
3
|
+
/** Props for the Option component. */
|
|
3
4
|
export declare type OptionProps<T> = Pick<SelectProps<T>, "size" | "itemClassName" | "placeholder"> & NonNullable<Pick<SelectProps<T>, "renderContent">> & {
|
|
5
|
+
/** Currently selected values, used to determine selection state. */
|
|
4
6
|
currentValues?: T[] | null;
|
|
7
|
+
/** The option data to render. */
|
|
5
8
|
option: T;
|
|
6
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Individual option item rendered within a Select dropdown. Handles active, selected, and custom render states.
|
|
12
|
+
*/
|
|
7
13
|
export default function Option<T extends DefaultOption>({ option, currentValues, size, itemClassName, renderContent, placeholder, }: OptionProps<T>): React.JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
|
+
/** Default shape for select options. */
|
|
2
3
|
export declare type DefaultOption = {
|
|
3
4
|
id: string;
|
|
4
5
|
label: string;
|
|
@@ -8,17 +9,28 @@ declare type ItemState = {
|
|
|
8
9
|
selected?: boolean;
|
|
9
10
|
disabled?: boolean;
|
|
10
11
|
};
|
|
12
|
+
/** A labelled group of options within a Select dropdown. */
|
|
11
13
|
export declare type Group<T> = {
|
|
12
14
|
id: string;
|
|
13
15
|
label: string;
|
|
14
16
|
options: Array<T>;
|
|
15
17
|
};
|
|
18
|
+
/** Base props shared by single and multi Select variants. */
|
|
16
19
|
interface BaseProps<T> {
|
|
20
|
+
/** HTML `id` for the select button. */
|
|
17
21
|
id?: string;
|
|
22
|
+
/** Accessible label for the select element. */
|
|
18
23
|
"aria-label"?: string;
|
|
24
|
+
/** List of selectable options or option groups. */
|
|
19
25
|
options: Array<T | Group<T>>;
|
|
26
|
+
/**
|
|
27
|
+
* Placeholder text shown when no value is selected.
|
|
28
|
+
* @default ""
|
|
29
|
+
*/
|
|
20
30
|
placeholder?: string;
|
|
31
|
+
/** HTML `name` attribute passed to the underlying Listbox. */
|
|
21
32
|
name?: string;
|
|
33
|
+
/** Additional class name for the select wrapper. */
|
|
22
34
|
className?: string;
|
|
23
35
|
/** `className` to be passed (and merged with default className) to `<Listbox.Options />` */
|
|
24
36
|
dropdownClassName?: string;
|
|
@@ -29,9 +41,11 @@ interface BaseProps<T> {
|
|
|
29
41
|
disabled?: boolean;
|
|
30
42
|
invalid?: boolean;
|
|
31
43
|
}) => string);
|
|
44
|
+
/** Whether the select element is disabled. */
|
|
32
45
|
disabled?: boolean;
|
|
46
|
+
/** Whether the select element is in an invalid state. */
|
|
33
47
|
invalid?: boolean;
|
|
34
|
-
/**
|
|
48
|
+
/** Tooltip of the select element. */
|
|
35
49
|
title?: string;
|
|
36
50
|
/**
|
|
37
51
|
* Function to render the content of the select element.
|
|
@@ -43,43 +57,63 @@ interface BaseProps<T> {
|
|
|
43
57
|
renderContent?(d: T | undefined | null, state: ItemState, placeholder?: string): ReactNode;
|
|
44
58
|
/**
|
|
45
59
|
* Loading state of the select element.
|
|
60
|
+
* @default false
|
|
46
61
|
*/
|
|
47
62
|
loading?: boolean;
|
|
48
63
|
/**
|
|
49
|
-
* Define which way the dropdown should open
|
|
64
|
+
* Define which way the dropdown should open.
|
|
50
65
|
*
|
|
51
66
|
* @default "auto"
|
|
52
67
|
*/
|
|
53
68
|
openingDirection?: "above" | "below" | "auto";
|
|
54
69
|
/**
|
|
55
|
-
* Maximum height of the dropdown in pixels
|
|
70
|
+
* Maximum height of the dropdown in pixels.
|
|
56
71
|
*/
|
|
57
72
|
maxHeight?: number;
|
|
58
73
|
/**
|
|
59
|
-
* Size of the select element
|
|
74
|
+
* Size of the select element.
|
|
60
75
|
*
|
|
61
76
|
* @default "md"
|
|
62
77
|
*/
|
|
63
78
|
size?: "md" | "lg";
|
|
64
79
|
}
|
|
80
|
+
/** Props for a single-value Select. */
|
|
65
81
|
interface SingleSelectionProps<T> extends BaseProps<T> {
|
|
82
|
+
/** Currently selected value. */
|
|
66
83
|
value: T | undefined | null;
|
|
84
|
+
/** Called when the selected value changes. */
|
|
67
85
|
onChange(d: T): void;
|
|
86
|
+
/** Must be `false` or omitted for single selection. */
|
|
68
87
|
multiple?: false;
|
|
69
88
|
}
|
|
89
|
+
/** Props for a multi-value Select. */
|
|
70
90
|
interface MultiSelectionProps<T> extends BaseProps<T> {
|
|
91
|
+
/** Currently selected values. */
|
|
71
92
|
value: T[] | undefined | null;
|
|
93
|
+
/** Called when the selected values change. */
|
|
72
94
|
onChange(d: T[]): void;
|
|
95
|
+
/** Must be `true` for multi selection. */
|
|
73
96
|
multiple: true;
|
|
97
|
+
/** Additional class name for multi-option pills. */
|
|
74
98
|
multiOptionClassName?: string;
|
|
75
99
|
}
|
|
100
|
+
/** Props for the Select component. */
|
|
76
101
|
export declare type SelectProps<T> = (SingleSelectionProps<T> | MultiSelectionProps<T>) & {
|
|
102
|
+
/** Ref forwarded to the select button element. */
|
|
77
103
|
buttonRef?: React.MutableRefObject<HTMLButtonElement | null>;
|
|
78
104
|
};
|
|
79
105
|
/**
|
|
80
|
-
* A
|
|
106
|
+
* A dropdown select with single and multi-value modes, grouped options, custom renderers, and keyboard navigation.
|
|
81
107
|
*
|
|
82
108
|
* Usage: `import { Select } from "@k8slens/lds"`
|
|
109
|
+
*
|
|
110
|
+
* ```tsx
|
|
111
|
+
* <Select
|
|
112
|
+
* options={[{ id: "1", label: "Option 1" }]}
|
|
113
|
+
* value={selected}
|
|
114
|
+
* onChange={setSelected}
|
|
115
|
+
* />
|
|
116
|
+
* ```
|
|
83
117
|
*/
|
|
84
118
|
export default function Select<T extends DefaultOption>({ id, "aria-label": ariaLabel, value, options, onChange, placeholder, name, invalid, disabled, className, dropdownClassName, itemClassName, renderContent, loading, title, openingDirection, maxHeight, multiple, size, ...selectProps }: SelectProps<T>): React.JSX.Element;
|
|
85
119
|
export {};
|
|
@@ -4,16 +4,22 @@ import React, { HTMLProps } from "react";
|
|
|
4
4
|
*/
|
|
5
5
|
export declare type ChildKey = "__isChildOfSideNav";
|
|
6
6
|
export declare const CHILD_KEY: ChildKey;
|
|
7
|
+
/** Props for the SideNav component. */
|
|
7
8
|
export declare type SideNavProps = Omit<HTMLProps<HTMLDivElement>, "className"> & {
|
|
9
|
+
/** Optional class name. */
|
|
8
10
|
className?: string;
|
|
9
11
|
};
|
|
10
12
|
/**
|
|
11
|
-
* Side navigation
|
|
13
|
+
* Side navigation container. Use `SideNavGroup` with `SideNavItem` as direct children.
|
|
12
14
|
*
|
|
13
|
-
*
|
|
15
|
+
* Usage: `import { SideNav } from "@k8slens/lds"`
|
|
14
16
|
*
|
|
15
17
|
* ```tsx
|
|
16
|
-
*
|
|
18
|
+
* <SideNav>
|
|
19
|
+
* <SideNavGroup label="Settings">
|
|
20
|
+
* <SideNavItem active>General</SideNavItem>
|
|
21
|
+
* </SideNavGroup>
|
|
22
|
+
* </SideNav>
|
|
17
23
|
* ```
|
|
18
24
|
*/
|
|
19
25
|
declare const SideNav: React.FC<SideNavProps>;
|
|
@@ -5,17 +5,20 @@ import type { ExtractProps } from "../types/ExtractProps.d";
|
|
|
5
5
|
*/
|
|
6
6
|
export declare type ChildKey = "__isChildOfSideNavGroup";
|
|
7
7
|
export declare const CHILD_KEY: ChildKey;
|
|
8
|
+
/** Props for the SideNavGroup component. */
|
|
8
9
|
export interface SideNavGroupProps<Component extends React.ElementType | keyof JSX.IntrinsicElements = "nav"> {
|
|
9
10
|
/**
|
|
10
|
-
* Component to be used instead of nav
|
|
11
|
+
* Component to be used instead of nav.
|
|
12
|
+
* @default "nav"
|
|
11
13
|
*/
|
|
12
14
|
component?: Component;
|
|
13
|
-
/**
|
|
14
|
-
* Props for the component passed as `component` prop
|
|
15
|
-
*/
|
|
15
|
+
/** Props forwarded to the component passed as `component` prop. */
|
|
16
16
|
componentProps?: Omit<ExtractProps<Component>, "id" | "className" | "children" | "aria-labelledby" | "aria-label">;
|
|
17
|
+
/** HTML `id` attribute. */
|
|
17
18
|
id?: string;
|
|
19
|
+
/** Optional class name. */
|
|
18
20
|
className?: string;
|
|
21
|
+
/** Child elements, should be `SideNavItem` components. */
|
|
19
22
|
children?: React.ReactNode;
|
|
20
23
|
}
|
|
21
24
|
export interface SideNavGroupPropsWithLabel<Component extends React.ElementType | keyof JSX.IntrinsicElements = "nav"> extends SideNavGroupProps<Component> {
|
|
@@ -27,8 +30,13 @@ export interface SideNavGroupPropsWithoutLabel<Component extends React.ElementTy
|
|
|
27
30
|
/**
|
|
28
31
|
* Side navigation group, use as a direct child of `SideNav`.
|
|
29
32
|
*
|
|
33
|
+
* Usage: `import { SideNavGroup } from "@k8slens/lds"`
|
|
34
|
+
*
|
|
30
35
|
* ```tsx
|
|
31
|
-
*
|
|
36
|
+
* <SideNavGroup label="Settings">
|
|
37
|
+
* <SideNavItem href="/general">General</SideNavItem>
|
|
38
|
+
* <SideNavItem href="/security">Security</SideNavItem>
|
|
39
|
+
* </SideNavGroup>
|
|
32
40
|
* ```
|
|
33
41
|
*/
|
|
34
42
|
declare function SideNavGroup<C extends keyof JSX.IntrinsicElements | React.ElementType = "nav">({ component, componentProps, id, className, children, ...props }: SideNavGroupPropsWithLabel<C> | SideNavGroupPropsWithoutLabel<C>): React.JSX.Element;
|
|
@@ -1,30 +1,47 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { ExtractProps } from "../types/ExtractProps.d";
|
|
3
3
|
export declare type Type = "default" | "danger";
|
|
4
|
+
/** Props for the SideNavItem component. */
|
|
4
5
|
export interface SideNavItemProps<Component extends React.ElementType | keyof JSX.IntrinsicElements = "a"> {
|
|
5
6
|
/**
|
|
6
|
-
* Component to be used instead of anchor, for example `Link` when used with [react-router](https://reactrouter.com/en/main/components/link)
|
|
7
|
+
* Component to be used instead of anchor, for example `Link` when used with [react-router](https://reactrouter.com/en/main/components/link).
|
|
8
|
+
* @default "a"
|
|
7
9
|
*/
|
|
8
10
|
component?: Component;
|
|
11
|
+
/** Props forwarded to the component passed as `component` prop. */
|
|
12
|
+
componentProps?: Omit<ExtractProps<Component>, "children" | "className" | "aria-disabled">;
|
|
9
13
|
/**
|
|
10
|
-
*
|
|
14
|
+
* Whether the item is disabled.
|
|
15
|
+
* @default false
|
|
11
16
|
*/
|
|
12
|
-
componentProps?: Omit<ExtractProps<Component>, "children" | "className" | "aria-disabled">;
|
|
13
17
|
disabled?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the item is currently active (sets `aria-current="page"`).
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
14
22
|
active?: boolean;
|
|
23
|
+
/** Child content. */
|
|
15
24
|
children?: React.ReactNode;
|
|
25
|
+
/** Optional class name. */
|
|
16
26
|
className?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Visual style type.
|
|
29
|
+
* @default "default"
|
|
30
|
+
*/
|
|
17
31
|
type?: Type;
|
|
18
32
|
/**
|
|
19
|
-
* If true, renders a visual indication of an external link
|
|
33
|
+
* If true, renders a visual indication of an external link.
|
|
34
|
+
* @default false
|
|
20
35
|
*/
|
|
21
36
|
externalLink?: boolean;
|
|
22
37
|
}
|
|
23
38
|
/**
|
|
24
39
|
* Side navigation item, use as a direct child of `SideNavGroup`.
|
|
25
40
|
*
|
|
41
|
+
* Usage: `import { SideNavItem } from "@k8slens/lds"`
|
|
42
|
+
*
|
|
26
43
|
* ```tsx
|
|
27
|
-
*
|
|
44
|
+
* <SideNavItem active href="/settings">Settings</SideNavItem>
|
|
28
45
|
* ```
|
|
29
46
|
*/
|
|
30
47
|
declare function SideNavItem<C extends keyof JSX.IntrinsicElements | React.ElementType = "a">({ component, componentProps, active, disabled, className, children, type, externalLink, ...props }: SideNavItemProps<C>): React.JSX.Element;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ChangeEvent, HTMLProps } from "react";
|
|
2
2
|
import React from "react";
|
|
3
|
+
/** Props for the Switch component. */
|
|
3
4
|
export interface SwitchProps extends Omit<HTMLProps<HTMLInputElement>, "onChange"> {
|
|
5
|
+
/** Change handler receiving the new checked state and the original event. */
|
|
4
6
|
onChange?: (checked: boolean, event: ChangeEvent<HTMLInputElement>) => void;
|
|
5
7
|
}
|
|
6
8
|
/**
|
|
@@ -1,25 +1,37 @@
|
|
|
1
1
|
import React, { type HTMLAttributes, type ReactElement } from "react";
|
|
2
2
|
import { type Placement } from "@popperjs/core";
|
|
3
|
+
/** Props for the Tooltip component. */
|
|
3
4
|
export interface TooltipProps {
|
|
4
5
|
/**
|
|
5
|
-
* Popper placement
|
|
6
|
+
* Popper placement of the tooltip popup.
|
|
7
|
+
* @default "auto"
|
|
6
8
|
*/
|
|
7
9
|
placement?: Placement;
|
|
8
10
|
/**
|
|
9
|
-
* Which element to listen for mutations on
|
|
11
|
+
* Which element to listen for DOM mutations on to reposition the tooltip.
|
|
12
|
+
* @default document.body
|
|
10
13
|
*/
|
|
11
14
|
mutationsListenerElement?: HTMLElement;
|
|
12
15
|
/**
|
|
13
|
-
* Wrapper element type
|
|
16
|
+
* Wrapper element type used around the children.
|
|
17
|
+
* @default "span"
|
|
14
18
|
*/
|
|
15
19
|
wrapper?: "span" | "div";
|
|
20
|
+
/** Additional class name for the tooltip popup element. */
|
|
16
21
|
popupClassName?: string;
|
|
22
|
+
/** Content displayed inside the tooltip popup. */
|
|
17
23
|
text?: ReactElement | string;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the tooltip is always visible (ignores hover/focus).
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
18
28
|
alwaysVisible?: boolean;
|
|
19
29
|
}
|
|
30
|
+
/** Props when the Tooltip wrapper is a `<span>` element (default). */
|
|
20
31
|
export interface SpanTooltipProps extends Omit<HTMLAttributes<HTMLSpanElement>, "onFocus" | "onBlur" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "aria-describedby">, TooltipProps {
|
|
21
32
|
wrapper?: "span";
|
|
22
33
|
}
|
|
34
|
+
/** Props when the Tooltip wrapper is a `<div>` element. */
|
|
23
35
|
export interface DivTooltipProps extends Omit<HTMLAttributes<HTMLDivElement>, "onFocus" | "onBlur" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "aria-describedby">, TooltipProps {
|
|
24
36
|
wrapper: "div";
|
|
25
37
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
2
|
import { type MenuItemGroup } from "./default-items";
|
|
3
3
|
import type { MenuItem } from "./UserMenuItem";
|
|
4
|
+
/** Base props shared by default and custom UserMenu variants. */
|
|
4
5
|
export interface BaseUserMenuProps {
|
|
5
6
|
/**
|
|
6
7
|
* Optional header to display in the User Menu.
|
|
@@ -23,21 +24,26 @@ export interface BaseUserMenuProps {
|
|
|
23
24
|
*/
|
|
24
25
|
className?: string;
|
|
25
26
|
/**
|
|
26
|
-
* Origin of the menu item hrefs.
|
|
27
|
+
* Origin of the menu item hrefs.
|
|
28
|
+
* @default "https://app.k8slens.dev"
|
|
27
29
|
*/
|
|
28
30
|
origin?: string;
|
|
31
|
+
/** Ref forwarded to the menu trigger button. */
|
|
29
32
|
buttonRef?: React.MutableRefObject<HTMLButtonElement | null>;
|
|
30
33
|
/**
|
|
31
|
-
* Loading state of the User Menu.
|
|
34
|
+
* Loading state of the User Menu.
|
|
35
|
+
* @default false
|
|
32
36
|
*/
|
|
33
37
|
loading?: boolean;
|
|
34
38
|
}
|
|
39
|
+
/** Props for UserMenu when using built-in default menu items. */
|
|
35
40
|
export interface DefaultUserMenuProps extends BaseUserMenuProps {
|
|
36
41
|
/**
|
|
37
42
|
* Callback to call when the user clicks the Logout button. Required if using the default items.
|
|
38
43
|
*/
|
|
39
44
|
onLogoutClick: MenuItem["onClick"];
|
|
40
45
|
}
|
|
46
|
+
/** Props for UserMenu when providing custom menu items. */
|
|
41
47
|
export interface CustomUserMenuProps extends BaseUserMenuProps {
|
|
42
48
|
/**
|
|
43
49
|
* Data to display in the User Menu
|
|
@@ -48,6 +54,7 @@ export interface CustomUserMenuProps extends BaseUserMenuProps {
|
|
|
48
54
|
*/
|
|
49
55
|
onLogoutClick?: MenuItem["onClick"];
|
|
50
56
|
}
|
|
57
|
+
/** Props for the UserMenu component (discriminated union of default and custom variants). */
|
|
51
58
|
export declare type UserMenuProps = DefaultUserMenuProps | CustomUserMenuProps;
|
|
52
59
|
/**
|
|
53
60
|
* Displays user info with dropdown menu for account actions. Uses default menu items if `items` prop is not provided.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode, RefObject } from "react";
|
|
2
2
|
import { MenuItemGroup } from "./default-items";
|
|
3
|
+
/** Props for the UserMenuDropdown component. */
|
|
3
4
|
export interface UserMenuDropdownProps {
|
|
4
5
|
/**
|
|
5
6
|
* Optional header to display in the User Menu.
|
|
@@ -10,27 +11,30 @@ export interface UserMenuDropdownProps {
|
|
|
10
11
|
*/
|
|
11
12
|
footer?: ReactNode;
|
|
12
13
|
/**
|
|
13
|
-
*
|
|
14
|
+
* Whether the User Menu dropdown is open.
|
|
14
15
|
*/
|
|
15
16
|
open: boolean;
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
+
* Menu item groups to display in the dropdown.
|
|
18
19
|
*/
|
|
19
20
|
groups: Array<MenuItemGroup>;
|
|
20
21
|
/**
|
|
21
|
-
* Optional class name to apply to the
|
|
22
|
+
* Optional class name to apply to the dropdown wrapper.
|
|
22
23
|
*/
|
|
23
24
|
className?: string;
|
|
24
25
|
/**
|
|
25
|
-
* Origin of the menu item hrefs.
|
|
26
|
+
* Origin of the menu item hrefs.
|
|
27
|
+
* @default "https://app.k8slens.dev"
|
|
26
28
|
*/
|
|
27
29
|
origin?: string;
|
|
28
30
|
/**
|
|
29
|
-
* Ref to the button that opens the dropdown
|
|
31
|
+
* Ref to the button that opens the dropdown, used for Popper positioning.
|
|
30
32
|
*/
|
|
31
33
|
buttonRef?: RefObject<HTMLButtonElement>;
|
|
32
34
|
}
|
|
33
35
|
/**
|
|
34
|
-
*
|
|
36
|
+
* Dropdown panel for the UserMenu that displays grouped menu items. Uses Popper.js for positioning.
|
|
37
|
+
*
|
|
38
|
+
* Usage: `import { UserMenuDropdown } from "@k8slens/lds"`
|
|
35
39
|
*/
|
|
36
40
|
export default function UserMenuDropdown({ header, footer, origin, className, groups, open, buttonRef, }: UserMenuDropdownProps): React.JSX.Element;
|
|
@@ -1,22 +1,43 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { MouseEvent } from "react";
|
|
3
3
|
import { type Icon } from "@k8slens/lds-icons/lib/es/Icon/Icon";
|
|
4
|
+
/** Data shape for a single menu item in UserMenu. */
|
|
4
5
|
export declare type MenuItem = {
|
|
6
|
+
/** Unique key for the menu item, used for identification (e.g. "logout"). */
|
|
5
7
|
key?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Visual style of the menu item.
|
|
10
|
+
* @default "default"
|
|
11
|
+
*/
|
|
6
12
|
type?: "default" | "danger";
|
|
13
|
+
/** Icon component rendered before the title. */
|
|
7
14
|
icon?: Icon;
|
|
15
|
+
/** Display text of the menu item. */
|
|
8
16
|
title: string;
|
|
17
|
+
/** Whether the menu item is disabled. */
|
|
9
18
|
disabled?: boolean;
|
|
19
|
+
/** Whether the link opens in a new tab. */
|
|
10
20
|
external?: boolean;
|
|
21
|
+
/** URL or path the menu item links to. */
|
|
11
22
|
href?: string;
|
|
23
|
+
/** Click handler for the menu item. */
|
|
12
24
|
onClick?: (e: MouseEvent<HTMLAnchorElement | HTMLButtonElement>) => void;
|
|
13
25
|
};
|
|
26
|
+
/** Props for the UserMenuItem component. */
|
|
14
27
|
export interface UserMenuItemProps extends MenuItem {
|
|
28
|
+
/** Base URL prepended to relative `href` values. */
|
|
15
29
|
origin?: string;
|
|
30
|
+
/** Whether the menu item is visually selected. */
|
|
16
31
|
selected?: boolean;
|
|
17
32
|
/**
|
|
18
|
-
* Optional class name to apply to the
|
|
33
|
+
* Optional class name to apply to the menu item.
|
|
19
34
|
*/
|
|
20
35
|
className?: string;
|
|
21
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Individual menu item rendered within a UserMenuDropdown. Renders as a link, button, or disabled span
|
|
39
|
+
* depending on `href`, `onClick`, and `disabled` props.
|
|
40
|
+
*
|
|
41
|
+
* Usage: `import { UserMenuItem } from "@k8slens/lds"`
|
|
42
|
+
*/
|
|
22
43
|
export default function UserMenuItem({ type, title, icon: Icon, disabled, external, onClick, selected, href: path, origin, className: cls, }: UserMenuItemProps): React.JSX.Element;
|
package/lib/cjs/components.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { default as Button } from "./Button/Button";
|
|
|
4
4
|
export { default as ButtonBar } from "./ButtonBar/ButtonBar";
|
|
5
5
|
export { default as Checkbox } from "./Checkbox/Checkbox";
|
|
6
6
|
export { default as ConfirmDialog, useConfirmDialog } from "./ConfirmDialog/ConfirmDialog";
|
|
7
|
+
export { default as ContextMenu } from "./ContextMenu/ContextMenu";
|
|
7
8
|
export { default as DrawerTransition } from "./DrawerTransition/DrawerTransition";
|
|
8
9
|
export { default as Input } from "./Input/Input";
|
|
9
10
|
export { default as LinkButton } from "./LinkButton/LinkButton";
|