@k8slens/lds 0.58.2 → 0.58.4
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/Avatar/Avatar.js +1 -1
- package/lib/cjs/Badge/Badge.d.ts +6 -4
- package/lib/cjs/Button/Button.d.ts +34 -6
- package/lib/cjs/Button/Button.js +1 -1
- package/lib/cjs/Button/shared.d.ts +30 -1
- package/lib/cjs/ButtonBar/ButtonBar.d.ts +17 -0
- package/lib/cjs/ButtonBar/ButtonBar.js +1 -1
- package/lib/cjs/Checkbox/Checkbox.d.ts +7 -0
- package/lib/cjs/ConfirmDialog/ConfirmDialog.d.ts +16 -0
- package/lib/cjs/ConfirmDialog/ConfirmDialog.js +1 -1
- package/lib/cjs/ContextMenu/ContextMenu.js +1 -1
- package/lib/cjs/DrawerTransition/DrawerTransition.d.ts +20 -0
- package/lib/cjs/DrawerTransition/DrawerTransition.js +1 -1
- package/lib/cjs/Input/Input.d.ts +8 -0
- package/lib/cjs/Input/Input.js +1 -1
- package/lib/cjs/LinkButton/LinkButton.d.ts +7 -0
- package/lib/cjs/LinkButton/LinkButton.js +1 -1
- package/lib/cjs/LoadingIndicator/LoadingIndicator.d.ts +8 -2
- package/lib/cjs/Lozenge/Lozenge.d.ts +4 -2
- package/lib/cjs/Lozenge/Lozenge.js +1 -1
- package/lib/cjs/Modal/Modal.d.ts +26 -0
- package/lib/cjs/Modal/Modal.js +1 -1
- package/lib/cjs/Notification/Notification.d.ts +18 -2
- package/lib/cjs/Notification/Notification.js +1 -1
- package/lib/cjs/NumberBadge/NumberBadge.d.ts +1 -1
- package/lib/cjs/Panel/Panel.d.ts +28 -0
- package/lib/cjs/Panel/Panel.js +1 -1
- 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/RadioCard/RadioCard.js +1 -1
- package/lib/cjs/Select/MultiOption.d.ts +14 -4
- package/lib/cjs/Select/MultiOption.js +1 -1
- package/lib/cjs/Select/Option.d.ts +6 -0
- package/lib/cjs/Select/Option.js +1 -1
- package/lib/cjs/Select/Select.d.ts +39 -5
- package/lib/cjs/Select/Select.js +1 -1
- package/lib/cjs/Select/SelectDropdown.js +1 -1
- package/lib/cjs/SideNav/SideNav.d.ts +9 -3
- package/lib/cjs/SideNav/SideNav.js +1 -1
- package/lib/cjs/SideNav/SideNavGroup.d.ts +13 -5
- package/lib/cjs/SideNav/SideNavGroup.js +1 -1
- package/lib/cjs/SideNav/SideNavItem.d.ts +22 -5
- package/lib/cjs/SideNav/SideNavItem.js +1 -1
- package/lib/cjs/Switch/Switch.d.ts +2 -0
- package/lib/cjs/Table/Table.js +1 -1
- package/lib/cjs/Textarea/Textarea.js +1 -1
- package/lib/cjs/Tooltip/Tooltip.d.ts +15 -3
- package/lib/cjs/Tooltip/Tooltip.js +1 -1
- package/lib/cjs/UserMenu/UserMenu.d.ts +9 -2
- package/lib/cjs/UserMenu/UserMenu.js +1 -1
- package/lib/cjs/UserMenu/UserMenuDropdown.d.ts +10 -6
- package/lib/cjs/UserMenu/UserMenuDropdown.js +1 -1
- package/lib/cjs/UserMenu/UserMenuItem.d.ts +22 -1
- package/lib/cjs/UserMenu/UserMenuItem.js +1 -1
- package/lib/cjs/_virtual/_tslib.js +1 -1
- package/lib/cjs/node_modules/lodash/_basePick.js +1 -1
- package/lib/cjs/node_modules/lodash/_baseToString.js +1 -1
- package/lib/cjs/node_modules/lodash/_memoizeCapped.js +1 -1
- package/lib/cjs/node_modules/lodash/_stringToPath.js +1 -1
- package/lib/cjs/node_modules/lodash/_toKey.js +1 -1
- package/lib/cjs/node_modules/lodash/pick.js +1 -1
- package/lib/es/Avatar/Avatar.d.ts +3 -1
- package/lib/es/Avatar/Avatar.js +1 -1
- package/lib/es/Badge/Badge.d.ts +6 -4
- package/lib/es/Button/Button.d.ts +34 -6
- package/lib/es/Button/Button.js +1 -1
- package/lib/es/Button/shared.d.ts +30 -1
- package/lib/es/ButtonBar/ButtonBar.d.ts +17 -0
- package/lib/es/ButtonBar/ButtonBar.js +1 -1
- package/lib/es/Checkbox/Checkbox.d.ts +7 -0
- package/lib/es/ConfirmDialog/ConfirmDialog.d.ts +16 -0
- package/lib/es/ConfirmDialog/ConfirmDialog.js +1 -1
- package/lib/es/ContextMenu/ContextMenu.js +1 -1
- package/lib/es/DrawerTransition/DrawerTransition.d.ts +20 -0
- package/lib/es/DrawerTransition/DrawerTransition.js +1 -1
- package/lib/es/Input/Input.d.ts +8 -0
- package/lib/es/Input/Input.js +1 -1
- package/lib/es/LinkButton/LinkButton.d.ts +7 -0
- package/lib/es/LinkButton/LinkButton.js +1 -1
- package/lib/es/LoadingIndicator/LoadingIndicator.d.ts +8 -2
- package/lib/es/Lozenge/Lozenge.d.ts +4 -2
- package/lib/es/Lozenge/Lozenge.js +1 -1
- package/lib/es/Modal/Modal.d.ts +26 -0
- package/lib/es/Modal/Modal.js +1 -1
- package/lib/es/Notification/Notification.d.ts +18 -2
- package/lib/es/Notification/Notification.js +1 -1
- package/lib/es/NumberBadge/NumberBadge.d.ts +1 -1
- package/lib/es/Panel/Panel.d.ts +28 -0
- package/lib/es/Panel/Panel.js +1 -1
- 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/RadioCard/RadioCard.js +1 -1
- package/lib/es/Select/MultiOption.d.ts +14 -4
- package/lib/es/Select/MultiOption.js +1 -1
- package/lib/es/Select/Option.d.ts +6 -0
- package/lib/es/Select/Option.js +1 -1
- package/lib/es/Select/Select.d.ts +39 -5
- package/lib/es/Select/Select.js +1 -1
- package/lib/es/Select/SelectDropdown.js +1 -1
- package/lib/es/SideNav/SideNav.d.ts +9 -3
- package/lib/es/SideNav/SideNav.js +1 -1
- package/lib/es/SideNav/SideNavGroup.d.ts +13 -5
- package/lib/es/SideNav/SideNavGroup.js +1 -1
- package/lib/es/SideNav/SideNavItem.d.ts +22 -5
- package/lib/es/SideNav/SideNavItem.js +1 -1
- package/lib/es/Switch/Switch.d.ts +2 -0
- package/lib/es/Table/Table.js +1 -1
- package/lib/es/Textarea/Textarea.js +1 -1
- package/lib/es/Tooltip/Tooltip.d.ts +15 -3
- package/lib/es/Tooltip/Tooltip.js +1 -1
- package/lib/es/UserMenu/UserMenu.d.ts +9 -2
- package/lib/es/UserMenu/UserMenu.js +1 -1
- package/lib/es/UserMenu/UserMenuDropdown.d.ts +10 -6
- package/lib/es/UserMenu/UserMenuDropdown.js +1 -1
- package/lib/es/UserMenu/UserMenuItem.d.ts +22 -1
- package/lib/es/UserMenu/UserMenuItem.js +1 -1
- package/lib/es/_virtual/_tslib.js +1 -1
- package/lib/es/node_modules/lodash/_basePick.js +1 -1
- package/lib/es/node_modules/lodash/_baseToString.js +1 -1
- package/lib/es/node_modules/lodash/_memoizeCapped.js +1 -1
- package/lib/es/node_modules/lodash/_stringToPath.js +1 -1
- package/lib/es/node_modules/lodash/_toKey.js +1 -1
- package/lib/es/node_modules/lodash/pick.js +1 -1
- package/lib/es/node_modules/lodash/throttle.js +1 -1
- package/lib/web/lds-v0-58-3/index.js +28 -0
- package/llms.txt +262 -102
- package/package.json +4 -4
- package/lib/web/lds-v0-58-1/index.js +0 -28
- /package/lib/web/{lds-v0-58-1 → lds-v0-58-3}/index.css +0 -0
- /package/lib/web/{lds-v0-58-1 → lds-v0-58-3}/typography.css +0 -0
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import React, { type AnchorHTMLAttributes } from "react";
|
|
2
2
|
export declare type Size = "sm" | "md";
|
|
3
3
|
export declare type TextTransform = "uppercase" | "capitalize";
|
|
4
|
+
/** Props for the LinkButton component. */
|
|
4
5
|
export interface LinkButtonProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "label"> {
|
|
6
|
+
/** Text label displayed in the link button. */
|
|
5
7
|
label: string;
|
|
8
|
+
/**
|
|
9
|
+
* Size of the link button.
|
|
10
|
+
* @default "md"
|
|
11
|
+
*/
|
|
6
12
|
size?: Size;
|
|
13
|
+
/** Text transformation applied to the label. */
|
|
7
14
|
textTransform?: TextTransform;
|
|
8
15
|
/**
|
|
9
16
|
* Leave `href` and `onClick` undefined to disable the button
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e,__assign as a}from"../_virtual/_tslib.js";import r,{forwardRef as l}from"react";import t from"clsx";import{navigation as i}from"@k8slens/lds-icons";import o from"./LinkButton.module.css.js";var s=i.ArrowForwardIcon,m=l(
|
|
1
|
+
import{__rest as e,__assign as a}from"../_virtual/_tslib.js";import r,{forwardRef as l}from"react";import t from"clsx";import{navigation as i}from"@k8slens/lds-icons";import o from"./LinkButton.module.css.js";var s=i.ArrowForwardIcon,m=l(function(l,i){var m,n=l.label,c=l.textTransform,f=l.className,p=l["aria-label"],d=l.size,u=void 0===d?"md":d,b=l.title,k=l.children,h=l.href,N=l.onClick,v=e(l,["label","textTransform","className","aria-label","size","title","children","href","onClick"]);return r.createElement("a",a({ref:i},v,{className:t(o.linkButton,f,(m={},m[o.uppercase]="uppercase"===c,m[o.capitalize]="capitalize"===c,m[o[u]]="md"!==u,m[o.disabled]=!h&&!N,m)),"aria-label":p||("string"==typeof n?n:""),title:b,href:h,onClick:N}),k||n,r.createElement(s,{className:o.arrow}))});m.displayName="LinkButton";export{m as default};
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { type Props as IconProps } from "@k8slens/lds-icons/lib/es/Icon/Icon.d";
|
|
3
|
+
/** Props for the LoadingIndicator component. */
|
|
3
4
|
export interface LoadingIndicatorProps {
|
|
4
5
|
/**
|
|
5
|
-
|
|
6
|
+
* `IconProps.size`, see [SVGIcon](/?path=/docs/icon-svgicon--default) for details.
|
|
6
7
|
* @default "md"
|
|
7
8
|
*/
|
|
8
9
|
size?: IconProps["size"];
|
|
10
|
+
/** Optional class name. */
|
|
9
11
|
className?: string;
|
|
10
12
|
}
|
|
11
13
|
/**
|
|
12
|
-
*
|
|
14
|
+
* Animated spinner for loading states. Wraps a SpinnerIcon with configurable size.
|
|
13
15
|
*
|
|
14
16
|
* Usage: `import { LoadingIndicator } from "@k8slens/lds"`
|
|
17
|
+
*
|
|
18
|
+
* ```tsx
|
|
19
|
+
* <LoadingIndicator size="md" />
|
|
20
|
+
* ```
|
|
15
21
|
*/
|
|
16
22
|
declare const LoadingIndicator: React.FC<LoadingIndicatorProps>;
|
|
17
23
|
export default LoadingIndicator;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React, { HTMLAttributes } from "react";
|
|
2
2
|
export declare type TextTransform = "uppercase" | "capitalize";
|
|
3
|
+
/** Props for the Lozenge component. */
|
|
3
4
|
export interface LozengeProps extends Omit<HTMLAttributes<HTMLSpanElement>, "type" | "size" | "textTransform"> {
|
|
4
5
|
/**
|
|
5
6
|
* Defines the color of the lozenge.
|
|
6
|
-
* @default secondary
|
|
7
|
+
* @default "secondary"
|
|
7
8
|
*/
|
|
8
9
|
type?: "primary" | "secondary" | "success" | "error" | "warning";
|
|
9
10
|
/**
|
|
@@ -11,7 +12,8 @@ export interface LozengeProps extends Omit<HTMLAttributes<HTMLSpanElement>, "typ
|
|
|
11
12
|
*/
|
|
12
13
|
textTransform?: TextTransform;
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
+
* Size of the lozenge.
|
|
16
|
+
* @default "sm"
|
|
15
17
|
*/
|
|
16
18
|
size?: "sm" | "md" | "lg";
|
|
17
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e,__assign as r}from"../_virtual/_tslib.js";import a,{forwardRef as s}from"react";import t from"clsx";import o from"./Lozenge.module.css.js";var i=s(
|
|
1
|
+
import{__rest as e,__assign as r}from"../_virtual/_tslib.js";import a,{forwardRef as s}from"react";import t from"clsx";import o from"./Lozenge.module.css.js";var i=s(function(s,i){var m,c=s.className,l=s.textTransform,p=s.type,n=void 0===p?"secondary":p,f=s.children,d=s.size,u=void 0===d?"sm":d,z=e(s,["className","textTransform","type","children","size"]);return a.createElement("span",r({ref:i},z,{className:t(o.lozenge,(m={},m[o[u]]="sm"!==u,m[o[n]]="secondary"!==n,m[o.uppercase]="uppercase"===l,m[o.capitalize]="capitalize"===l,m),c)}),f)});export{i as default};
|
package/lib/es/Modal/Modal.d.ts
CHANGED
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
import React, { PropsWithChildren, ReactNode } from "react";
|
|
2
2
|
import { PanelProps } from "../Panel/Panel";
|
|
3
3
|
import { ButtonBarProps } from "../ButtonBar/ButtonBar";
|
|
4
|
+
/** Props for the Modal component. */
|
|
4
5
|
export interface ModalProps<Component extends keyof JSX.IntrinsicElements | React.ElementType> {
|
|
6
|
+
/** Title displayed in the modal header. */
|
|
5
7
|
title: string;
|
|
8
|
+
/** Optional subtitle displayed below the title. */
|
|
6
9
|
subTitle?: string;
|
|
10
|
+
/** Whether the modal is currently open. */
|
|
7
11
|
isOpen: boolean;
|
|
12
|
+
/** Called when the modal is dismissed (overlay click or escape key). */
|
|
8
13
|
onClose: () => void;
|
|
14
|
+
/**
|
|
15
|
+
* Size of the modal.
|
|
16
|
+
* @default "md"
|
|
17
|
+
*/
|
|
9
18
|
size: "sm" | "md" | "lg" | "xl";
|
|
19
|
+
/** Element type or component used as the content wrapper (passed to Panel). */
|
|
10
20
|
contentComponent?: PanelProps<Component>["wrapperComponent"];
|
|
21
|
+
/** Props forwarded to the content wrapper component. */
|
|
11
22
|
contentProps?: PanelProps<Component>["wrapperProps"];
|
|
23
|
+
/**
|
|
24
|
+
* Props forwarded to the footer ButtonBar component.
|
|
25
|
+
* @default {}
|
|
26
|
+
*/
|
|
12
27
|
buttonBarProps?: Omit<ButtonBarProps<"footer">, "as">;
|
|
28
|
+
/**
|
|
29
|
+
* Additional class name for the modal Panel.
|
|
30
|
+
* @default ""
|
|
31
|
+
*/
|
|
13
32
|
className?: string;
|
|
33
|
+
/** Content rendered in the modal footer, wrapped by ButtonBar. */
|
|
14
34
|
footer?: ReactNode;
|
|
15
35
|
}
|
|
16
36
|
/**
|
|
@@ -24,6 +44,12 @@ export interface ModalProps<Component extends keyof JSX.IntrinsicElements | Reac
|
|
|
24
44
|
* To pass props to `ButtonBar` use the `buttonBarProps` prop.
|
|
25
45
|
*
|
|
26
46
|
* Usage: `import { Modal } from "@k8slens/lds"`
|
|
47
|
+
*
|
|
48
|
+
* ```tsx
|
|
49
|
+
* <Modal isOpen={open} onClose={close} title="Confirm" size="sm">
|
|
50
|
+
* <p>Are you sure?</p>
|
|
51
|
+
* </Modal>
|
|
52
|
+
* ```
|
|
27
53
|
*/
|
|
28
54
|
declare function Modal<Component extends keyof JSX.IntrinsicElements | React.ElementType>({ children, isOpen, onClose, title, subTitle, size, contentComponent, contentProps: _contentProps, buttonBarProps, className, footer, }: PropsWithChildren<ModalProps<Component>>): React.JSX.Element | null;
|
|
29
55
|
export default Modal;
|
package/lib/es/Modal/Modal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e}from"../_virtual/_tslib.js";import o,{useMemo as t}from"react";import r from"clsx";import{Dialog as a,DialogTitle as n}from"@headlessui/react";import s from"../Panel/Panel.js";import l from"../ButtonBar/ButtonBar.js";import m from"./Modal.module.css.js";function p(p){var i=p.children,c=p.isOpen,d=p.onClose,u=p.title,f=p.subTitle,h=p.size,v=void 0===h?"md":h,C=p.contentComponent,N=p.contentProps,P=p.buttonBarProps,B=void 0===P?{}:P,E=p.className,b=void 0===E?"":E,j=p.footer,w=t(
|
|
1
|
+
import{__assign as e}from"../_virtual/_tslib.js";import o,{useMemo as t}from"react";import r from"clsx";import{Dialog as a,DialogTitle as n}from"@headlessui/react";import s from"../Panel/Panel.js";import l from"../ButtonBar/ButtonBar.js";import m from"./Modal.module.css.js";function p(p){var i=p.children,c=p.isOpen,d=p.onClose,u=p.title,f=p.subTitle,h=p.size,v=void 0===h?"md":h,C=p.contentComponent,N=p.contentProps,P=p.buttonBarProps,B=void 0===P?{}:P,E=p.className,b=void 0===E?"":E,j=p.footer,w=t(function(){return e(e({},N||{}),{className:r(m.modalContent,(null==N?void 0:N.className)||"")})},[N]);return c?o.createElement(a,{open:c,onClose:d,className:r(m.modal,m[v])},o.createElement(s,{wrapperComponent:C||"div",wrapperProps:w,className:b,headerComponent:n,headerProps:{as:"header"},header:o.createElement(o.Fragment,null,o.createElement("h3",{className:"lds-h2"},u),f?o.createElement("p",{className:m.subTitle},f):null),footer:j,footerComponent:l,footerProps:e(e({},B),{as:"footer"})},i)):null}export{p as default};
|
|
@@ -1,22 +1,38 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
2
|
export declare type Type = "flash" | "closable" | "inline" | "default";
|
|
3
3
|
export declare type AlertLevel = "info" | "success" | "error" | "warning";
|
|
4
|
+
/** Props for the Notification component. */
|
|
4
5
|
export interface NotificationProps {
|
|
6
|
+
/** The notification body content. */
|
|
5
7
|
message: string | ReactNode;
|
|
8
|
+
/** Optional bold heading rendered above the message. */
|
|
6
9
|
title?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Behavior type of the notification.
|
|
12
|
+
* @default "default"
|
|
13
|
+
*/
|
|
7
14
|
type?: Type;
|
|
15
|
+
/**
|
|
16
|
+
* Visual severity level of the notification.
|
|
17
|
+
* @default "info"
|
|
18
|
+
*/
|
|
8
19
|
level?: AlertLevel;
|
|
20
|
+
/** @deprecated Use `type` prop instead. */
|
|
9
21
|
inline?: false;
|
|
22
|
+
/** @deprecated Use `type` prop instead. */
|
|
10
23
|
flash?: false;
|
|
11
24
|
/**
|
|
12
|
-
* Hide after `flashDuration` milliseconds, if type is set to "flash"
|
|
25
|
+
* Hide after `flashDuration` milliseconds, if type is set to "flash".
|
|
26
|
+
* @default 5000
|
|
13
27
|
*/
|
|
14
28
|
flashDuration?: number;
|
|
15
29
|
/**
|
|
16
|
-
* Can be set closable if not inline
|
|
30
|
+
* Can be set closable if not inline.
|
|
17
31
|
*/
|
|
18
32
|
closable?: boolean;
|
|
33
|
+
/** Called after the notification finishes its exit transition. */
|
|
19
34
|
onClose?(): void;
|
|
35
|
+
/** Additional class name for the notification wrapper. */
|
|
20
36
|
className?: string;
|
|
21
37
|
}
|
|
22
38
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e,{useState as t,useRef as r,useCallback as n}from"react";import l from"clsx";import{navigation as o,base as a}from"@k8slens/lds-icons";import i from"../DrawerTransition/DrawerTransition.js";import s from"./Notification.module.css.js";var c=o.CloseIcon,m=a.SuccessIcon,f=a.WarningIcon,u=a.InfoIcon,p=function(o){var a=o.level,p=void 0===a?"info":a,E=o.type,d=void 0===E?"default":E,v=o.title,x=o.message,h=o.flashDuration,I=void 0===h?5e3:h,b=o.onClose,g=o.className,w=t(!0),z=w[0],C=w[1],N=r(null),k="flash"===d?300:200,y=n(
|
|
1
|
+
import e,{useState as t,useRef as r,useCallback as n}from"react";import l from"clsx";import{navigation as o,base as a}from"@k8slens/lds-icons";import i from"../DrawerTransition/DrawerTransition.js";import s from"./Notification.module.css.js";var c=o.CloseIcon,m=a.SuccessIcon,f=a.WarningIcon,u=a.InfoIcon,p=function(o){var a=o.level,p=void 0===a?"info":a,E=o.type,d=void 0===E?"default":E,v=o.title,x=o.message,h=o.flashDuration,I=void 0===h?5e3:h,b=o.onClose,g=o.className,w=t(!0),z=w[0],C=w[1],N=r(null),k="flash"===d?300:200,y=n(function(){"flash"===d&&setTimeout(function(){try{C(!1)}catch(e){}},I)},[d,I]);return e.createElement(i,{open:z,role:"alert",className:l(g,s.wrapper,s[p],s[d]),afterEnter:y,afterExit:b,duration:k},e.createElement("div",{ref:N,className:s.alert},"success"===p&&e.createElement(m,{size:"xl"}),"info"===p&&e.createElement(u,{size:"xl"}),("error"===p||"warning"===p)&&e.createElement(f,{size:"xl"}),e.createElement("div",null,v&&e.createElement("h5",null,v),e.createElement("p",null,x)),"closable"===d&&e.createElement("button",{type:"button",onClick:function(){return C(!1)},"aria-label":"Close"},e.createElement(c,{size:"lg",color:"on-dark"}))))};export{p as default};
|
|
@@ -4,7 +4,7 @@ export declare const formatNumber: (n: number) => string;
|
|
|
4
4
|
interface BaseNumberBadgeProps extends Omit<LozengeProps, "role" | "children" | "title" | "textTransform" | "size"> {
|
|
5
5
|
value: number | null | undefined;
|
|
6
6
|
/**
|
|
7
|
-
* If no title
|
|
7
|
+
* If no title is provided, the badge will be hidden from screen readers.
|
|
8
8
|
*/
|
|
9
9
|
title?: string;
|
|
10
10
|
/**
|
package/lib/es/Panel/Panel.d.ts
CHANGED
|
@@ -1,17 +1,45 @@
|
|
|
1
1
|
import React, { Fragment, ReactNode } from "react";
|
|
2
2
|
import type { ExtractProps } from "../types/ExtractProps.d";
|
|
3
|
+
/** Props for the Panel component. */
|
|
3
4
|
export interface PanelProps<WrapperComponent extends keyof JSX.IntrinsicElements | React.ElementType = typeof Fragment, HeaderComponent extends keyof JSX.IntrinsicElements | React.ElementType = "header", ContentComponent extends keyof JSX.IntrinsicElements | React.ElementType = "div", FooterComponent extends keyof JSX.IntrinsicElements | React.ElementType = "footer"> {
|
|
5
|
+
/** Content rendered in the header section. */
|
|
4
6
|
header?: ReactNode;
|
|
7
|
+
/** Content rendered in the footer section. */
|
|
5
8
|
footer?: ReactNode;
|
|
9
|
+
/** Optional class name applied to header, content, and footer elements. */
|
|
6
10
|
className?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Component used to wrap the entire panel.
|
|
13
|
+
* @default Fragment
|
|
14
|
+
*/
|
|
7
15
|
wrapperComponent?: WrapperComponent;
|
|
16
|
+
/** Props forwarded to the wrapper component. */
|
|
8
17
|
wrapperProps?: ExtractProps<WrapperComponent>;
|
|
18
|
+
/**
|
|
19
|
+
* Component used for the header section.
|
|
20
|
+
* @default "header"
|
|
21
|
+
*/
|
|
9
22
|
headerComponent?: HeaderComponent;
|
|
23
|
+
/** Props forwarded to the header component. */
|
|
10
24
|
headerProps?: ExtractProps<HeaderComponent>;
|
|
25
|
+
/**
|
|
26
|
+
* Component used for the content section.
|
|
27
|
+
* @default "div"
|
|
28
|
+
*/
|
|
11
29
|
contentComponent?: ContentComponent | undefined;
|
|
30
|
+
/** Props forwarded to the content component. */
|
|
12
31
|
contentProps?: ExtractProps<ContentComponent>;
|
|
32
|
+
/**
|
|
33
|
+
* Component used for the footer section.
|
|
34
|
+
* @default "footer"
|
|
35
|
+
*/
|
|
13
36
|
footerComponent?: FooterComponent;
|
|
37
|
+
/** Props forwarded to the footer component. */
|
|
14
38
|
footerProps?: ExtractProps<FooterComponent>;
|
|
39
|
+
/**
|
|
40
|
+
* Whether to show a loading indicator overlay.
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
15
43
|
loading?: boolean;
|
|
16
44
|
}
|
|
17
45
|
/**
|
package/lib/es/Panel/Panel.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e}from"../_virtual/_tslib.js";import o,{useMemo as r,Fragment as n}from"react";import t from"clsx";import a from"../node_modules/lodash/pick.js";import l from"../LoadingIndicator/LoadingIndicator.js";import m from"./Panel.module.css.js";var i=function(e){return e===n||e&&e.$$typeof&&"Symbol(react.fragment)"===e.$$typeof.toString()};function s(s){var c=s.header,d=s.footer,p=s.className,f=s.wrapperComponent,u=s.wrapperProps,v=s.headerComponent,g=s.headerProps,N=s.contentComponent,h=s.contentProps,y=s.footerComponent,k=s.footerProps,E=s.loading,P=s.children,j=f||n,x=v||"header",C=N||"div",$=y||"footer",I=r(
|
|
1
|
+
import{__assign as e}from"../_virtual/_tslib.js";import o,{useMemo as r,Fragment as n}from"react";import t from"clsx";import a from"../node_modules/lodash/pick.js";import l from"../LoadingIndicator/LoadingIndicator.js";import m from"./Panel.module.css.js";var i=function(e){return e===n||e&&e.$$typeof&&"Symbol(react.fragment)"===e.$$typeof.toString()};function s(s){var c=s.header,d=s.footer,p=s.className,f=s.wrapperComponent,u=s.wrapperProps,v=s.headerComponent,g=s.headerProps,N=s.contentComponent,h=s.contentProps,y=s.footerComponent,k=s.footerProps,E=s.loading,P=s.children,j=f||n,x=v||"header",C=N||"div",$=y||"footer",I=r(function(){var e=u||{};return i(j)?a(e,"key"):e},[u,j]),_=r(function(){var o,r=g||{};return i(x)?a(r,"key"):e(e({},r),{className:t(m.panel,m.header,p,null==g?void 0:g.className,(o={},o[m.loading]=E,o))})},[g,x,p,E]),b=r(function(){var o,r=k||{};return i($)?a(r,"key"):e(e({},r),{className:t(m.panel,m.footer,p,null==k?void 0:k.className,(o={},o[m.loading]=E,o))})},[k,$,p,E]),w=r(function(){var o,r=h||{};return i(C)?a(r,"key"):e(e({},r),{className:t(m.panel,m.content,p,null==h?void 0:h.className,(o={},o[m.loading]=E,o))})},[h,C,p,E]);return o.createElement(j,e({},I),c&&o.createElement(x,e({},_),c),o.createElement(C,e({},w),P,E&&o.createElement(l,{size:"xxl",className:m.loadingIndicator})),d&&o.createElement($,e({},b),d))}export{s as default};
|
|
@@ -6,10 +6,18 @@ declare type Item = {
|
|
|
6
6
|
avatar?: AvatarProps["image"];
|
|
7
7
|
avatarTitle: string;
|
|
8
8
|
};
|
|
9
|
+
/** Props for the ProfileBlock component. */
|
|
9
10
|
export declare type ProfileBlockProps = HTMLProps<HTMLDivElement> & {
|
|
11
|
+
/**
|
|
12
|
+
* Whether to show a loading indicator instead of text content.
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
10
15
|
loading?: boolean;
|
|
16
|
+
/** User data to display (title, subtitle, avatar). */
|
|
11
17
|
item: Item;
|
|
18
|
+
/** Custom formatter for the title text. */
|
|
12
19
|
formatTitle?: (item: Item) => string | ReactElement;
|
|
20
|
+
/** Custom formatter for the subtitle text. */
|
|
13
21
|
formatSubtitle?: (item: Item) => string | ReactElement;
|
|
14
22
|
};
|
|
15
23
|
/**
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
/** Props for the ProgressBar component. */
|
|
2
3
|
export interface ProgressBarProps extends React.ProgressHTMLAttributes<HTMLProgressElement> {
|
|
4
|
+
/** Current progress value. */
|
|
3
5
|
value: number;
|
|
6
|
+
/**
|
|
7
|
+
* Maximum value for the progress bar.
|
|
8
|
+
* @default 1
|
|
9
|
+
*/
|
|
4
10
|
max?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Color of the progress bar.
|
|
13
|
+
* @default "default"
|
|
14
|
+
*/
|
|
5
15
|
type?: "default" | "ok" | "caution" | "danger";
|
|
16
|
+
/** Accessible title text. Falls back to percentage display if not provided. */
|
|
6
17
|
title?: string;
|
|
7
18
|
}
|
|
8
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as a,__assign as t}from"../_virtual/_tslib.js";import e from"react";import r from"./ProgressBar.module.css.js";
|
|
1
|
+
import{__rest as a,__assign as t}from"../_virtual/_tslib.js";import e from"react";import r from"clsx";import s from"./ProgressBar.module.css.js";function l(l){var m,o=l.value,i=l.type,u=void 0===i?"default":i,c=l.max,p=void 0===c?1:c,f=l.title,v=l.className,d=a(l,["value","type","max","title","className"]),n=isNaN(o)?0:Math.max(0,o),x=isNaN(p)||p<=0?1:p,N=Math.min(100,Math.round(n/x*100)),g=f||"".concat(N,"%");return e.createElement("progress",t({},d,{className:r(s.progressBar,v,(m={},m[s[u]]="default"!==u,m)),value:n,max:x,"aria-valuetext":g,title:f}),g)}export{l as default};
|
|
@@ -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 +1 @@
|
|
|
1
|
-
import{__rest as e,__assign as a}from"../_virtual/_tslib.js";import l from"react";import t from"clsx";import{RadioGroup as n,Radio as r}from"@headlessui/react";import s from"./RadioCard.module.css.js";function i(i){var m=i.id,d=i["aria-label"],c=i.value,o=i.options,u=i.onChange,b=i.name,p=i.invalid,v=i.disabled,f=i.itemClassName,N=i.className,E=i.renderItem,C=void 0===E?function(e){return l.createElement("span",{className:s.content},l.createElement("span",{className:s.label},e.label),l.createElement("span",{className:s.subtitle},e.subtitle))}:E,h=e(i,["id","aria-label","value","options","onChange","name","invalid","disabled","itemClassName","className","renderItem"]);return l.createElement(n,a({},h,{id:m,by:"id",value:c,onChange:u,"aria-label":d,className:t(s.radioCard,N),name:b}),o.map(
|
|
1
|
+
import{__rest as e,__assign as a}from"../_virtual/_tslib.js";import l from"react";import t from"clsx";import{RadioGroup as n,Radio as r}from"@headlessui/react";import s from"./RadioCard.module.css.js";function i(i){var m=i.id,d=i["aria-label"],c=i.value,o=i.options,u=i.onChange,b=i.name,p=i.invalid,v=i.disabled,f=i.itemClassName,N=i.className,E=i.renderItem,C=void 0===E?function(e){return l.createElement("span",{className:s.content},l.createElement("span",{className:s.label},e.label),l.createElement("span",{className:s.subtitle},e.subtitle))}:E,h=e(i,["id","aria-label","value","options","onChange","name","invalid","disabled","itemClassName","className","renderItem"]);return l.createElement(n,a({},h,{id:m,by:"id",value:c,onChange:u,"aria-label":d,className:t(s.radioCard,N),name:b}),o.map(function(e){return l.createElement(r,{key:e.id,value:e,disabled:v||e.disabled,className:function(e){var a,l=e.checked;return t(s.item,f,((a={})[s.selected]=l,a[s.invalid]=p,a))}},function(a){var t=a.checked;return l.createElement(l.Fragment,null,l.createElement("span",{className:s.dot},l.createElement("span",null)),C(e,{invalid:p,selected:t,disabled:v||e.disabled}))})}))}export{i as default};
|
|
@@ -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 +1 @@
|
|
|
1
|
-
import e,{forwardRef as o}from"react";import r from"clsx";import{navigation as t}from"@k8slens/lds-icons";import n from"../Lozenge/Lozenge.js";import a from"./Select.module.css.js";var l=t.CloseIcon,m=o(
|
|
1
|
+
import e,{forwardRef as o}from"react";import r from"clsx";import{navigation as t}from"@k8slens/lds-icons";import n from"../Lozenge/Lozenge.js";import a from"./Select.module.css.js";var l=t.CloseIcon,m=o(function(o,t){var m=o.label,i=o.className,s=o.children,c=o.onRemove,p=o.onArrowNavigate;return e.createElement(n,{ref:t,size:"lg",type:"primary",className:r(a.multiOption,i),onClick:c,onKeyDown:function(e){" "!==e.key&&"Spacebar"!==e.key&&"Enter"!==e.key||(e.preventDefault(),c(e)),"ArrowRight"===e.key&&p&&(e.preventDefault(),p("next")),"ArrowLeft"===e.key&&p&&(e.preventDefault(),p("prev"))},role:"button",tabIndex:0,"aria-label":"Remove option ".concat(m)},s,e.createElement(l,{size:"sm",color:"on-dark",className:a.multiOptionRemove}))});export{m as default};
|
|
@@ -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;
|
package/lib/es/Select/Option.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e}from"../_virtual/_tslib.js";import t from"react";import{ListboxOption as r}from"@headlessui/react";import i from"clsx";import o from"./Select.module.css.js";function l(l){var n=l.option,s=l.currentValues,c=l.size,u=l.itemClassName,m=l.renderContent,a=l.placeholder;return t.createElement(r,{value:n,className:function(t){var r,l;return i(o.item,((r={})[o.active]=t.active,r[o.selected]=t.selected||(s||[]).some(
|
|
1
|
+
import{__assign as e}from"../_virtual/_tslib.js";import t from"react";import{ListboxOption as r}from"@headlessui/react";import i from"clsx";import o from"./Select.module.css.js";function l(l){var n=l.option,s=l.currentValues,c=l.size,u=l.itemClassName,m=l.renderContent,a=l.placeholder;return t.createElement(r,{value:n,className:function(t){var r,l;return i(o.item,((r={})[o.active]=t.active,r[o.selected]=t.selected||(s||[]).some(function(e){return e.id===n.id}),r[o.lg]="lg"===c,r),null!==(l="function"==typeof u?u(e(e({},t),{selected:t.selected||(s||[]).some(function(e){return e.id===n.id})})):u)&&void 0!==l?l:"")}},m?m(n,{selected:(s||[]).some(function(e){return e.id===n.id})},a):null)}export{l as default};
|
|
@@ -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 {};
|
package/lib/es/Select/Select.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e,__assign as n}from"../_virtual/_tslib.js";import t,{useRef as r,useEffect as l,useMemo as a}from"react";import i from"clsx";import{Listbox as o,ListboxButton as s,ListboxOptions as u}from"@headlessui/react";import{navigation as c}from"@k8slens/lds-icons";import m from"../LoadingIndicator/LoadingIndicator.js";import d from"./SelectDropdown.js";import p from"./Option.js";import f from"./MultiOption.js";import v from"./Select.module.css.js";var g=c.ArrowDownIcon,b=c.ArrowUpIcon;function N(c){var N=c.id,h=c["aria-label"],C=c.value,E=c.options,y=c.onChange,A=c.placeholder,w=void 0===A?"":A,I=c.name,R=c.invalid,D=c.disabled,j=c.className,k=c.dropdownClassName,x=c.itemClassName,B=c.renderContent,O=void 0===B?function(e,n,t){return e?e.label:t}:B,z=c.loading,L=c.title,H=c.openingDirection,M=c.maxHeight,S=c.multiple,V=c.size,_=e(c,["id","aria-label","value","options","onChange","placeholder","name","invalid","disabled","className","dropdownClassName","itemClassName","renderContent","loading","title","openingDirection","maxHeight","multiple","size"]),P=r(null),T=r(null),U=r([]),q=1===E.length;l(
|
|
1
|
+
import{__rest as e,__assign as n}from"../_virtual/_tslib.js";import t,{useRef as r,useEffect as l,useMemo as a}from"react";import i from"clsx";import{Listbox as o,ListboxButton as s,ListboxOptions as u}from"@headlessui/react";import{navigation as c}from"@k8slens/lds-icons";import m from"../LoadingIndicator/LoadingIndicator.js";import d from"./SelectDropdown.js";import p from"./Option.js";import f from"./MultiOption.js";import v from"./Select.module.css.js";var g=c.ArrowDownIcon,b=c.ArrowUpIcon;function N(c){var N=c.id,h=c["aria-label"],C=c.value,E=c.options,y=c.onChange,A=c.placeholder,w=void 0===A?"":A,I=c.name,R=c.invalid,D=c.disabled,j=c.className,k=c.dropdownClassName,x=c.itemClassName,B=c.renderContent,O=void 0===B?function(e,n,t){return e?e.label:t}:B,z=c.loading,L=c.title,H=c.openingDirection,M=c.maxHeight,S=c.multiple,V=c.size,_=e(c,["id","aria-label","value","options","onChange","placeholder","name","invalid","disabled","className","dropdownClassName","itemClassName","renderContent","loading","title","openingDirection","maxHeight","multiple","size"]),P=r(null),T=r(null),U=r([]),q=1===E.length;l(function(){var e,n;(null===(e=_.buttonRef)||void 0===e?void 0:e.current)&&(P.current=null===(n=_.buttonRef)||void 0===n?void 0:n.current)},[_.buttonRef]);var F=a(function(){var e=function(e){return!S||!Array.isArray(C)||!C.some(function(n){return n.id===e.id})};return E.map(function(t){if("options"in t){var r=t.options.filter(function(n){return e(n)});return r.length>0?n(n({},t),{options:r}):null}return e(t)?t:null}).filter(function(e){return null!==e})},[S,E,C]),G=a(function(){return S?Array.isArray(C)?C:[]:null===C?void 0:C},[S,C]),J=function(e){var n,r,l,a=e.open;return t.createElement("div",{className:i(v.select,j,(n={},n[v.invalid]=R,n[v.locked]=q,n[v.disabled]=D||z,n[v.open]=a,n))},t.createElement(s,{id:N,ref:_.buttonRef?_.buttonRef:P,"aria-label":h,className:i(v.selectButton),title:L},t.createElement("span",{className:i(v.item,v.selectedItem,(r={},r[v.multiple]=S,r[v.disabled]=D||z,r[v.invalid]=R,r[v.placeholder]=!C,r[v.lg]="lg"===V,r),null!==(l="function"==typeof x?x({disabled:Boolean(D),invalid:Boolean(R)}):x)&&void 0!==l?l:"")},z?t.createElement(m,{className:v.loadingIndicator}):S&&Array.isArray(C)?t.createElement("span",{className:v.multiOptionContainer},C.map(function(e,n){return t.createElement(f,{ref:function(e){return U.current[n]=e},label:e.label,className:"multiOptionClassName"in _?_.multiOptionClassName:void 0,onRemove:function(t){t.stopPropagation();var r=C.filter(function(n){return n.id!==e.id});y(r),setTimeout(function(){var e,t,l=Math.min(n,r.length-1);r.length>0?null===(e=U.current[l])||void 0===e||e.focus():null===(t=P.current)||void 0===t||t.focus()},0)},onArrowNavigate:function(e){var t,r="next"===e?n+1:n-1;null===(t=U.current[r])||void 0===t||t.focus()},key:e.id},O(e,{invalid:R,disabled:D},w))})):O(C,{invalid:R,disabled:D},w)),a&&F.length>0?t.createElement(b,{className:v.dropDownIcon}):t.createElement(g,{className:v.dropDownIcon})),t.createElement(d,{listRef:T,buttonRef:P,openingDirection:H,maxHeight:M,grouped:E.some(function(e){return"options"in e})},t.createElement(u,{ref:T,className:i(v.dropdown,k)},F.length>0?F.map(function(e){var n;if("options"in e){var r="".concat(e.id,"-label");return t.createElement("li",{key:e.id,className:v.group,role:"group","aria-labelledby":r},t.createElement("span",{id:r,className:i(v.groupLabel,(n={},n[v.lg]="lg"===V,n))},e.label),t.createElement("ul",{className:v.groupList},e.options.map(function(e){return t.createElement(p,{key:e.id,option:e,currentValues:Array.isArray(C)?C:[C].filter(Boolean),size:V,itemClassName:x,renderContent:O,placeholder:w})})))}return t.createElement(p,{key:e.id,option:e,currentValues:Array.isArray(C)?C:[C].filter(Boolean),size:V,itemClassName:x,renderContent:O,placeholder:w})}):null)))};return S?t.createElement(o,{value:G,onChange:y,name:I,disabled:D,multiple:!0},J):t.createElement(o,{value:G,onChange:y,name:I,disabled:D,multiple:!1},J)}export{N as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import t,{useCallback as e,useEffect as n}from"react";import{Transition as r}from"@headlessui/react";import{SpacingMd as o}from"../node_modules/@k8slens/lds-tokens/lib/web/tokens.base.js";import{convertRemToPixels as a,getScrollableContainer as i}from"../helpers.js";var u=a(o)||0;function c(o){var a=o.buttonRef,c=o.listRef,l=o.openingDirection,d=void 0===l?"auto":l,s=o.maxHeight,m=o.children,v=o.grouped,p=e(
|
|
1
|
+
import t,{useCallback as e,useEffect as n}from"react";import{Transition as r}from"@headlessui/react";import{SpacingMd as o}from"../node_modules/@k8slens/lds-tokens/lib/web/tokens.base.js";import{convertRemToPixels as a,getScrollableContainer as i}from"../helpers.js";var u=a(o)||0;function c(o){var a=o.buttonRef,c=o.listRef,l=o.openingDirection,d=void 0===l?"auto":l,s=o.maxHeight,m=o.children,v=o.grouped,p=e(function(){var t;if((null==c?void 0:c.current)&&a.current&&null===c.current.getAttribute("data-placement")){var e=i(a.current),n=window.getComputedStyle(e),r=parseFloat(n.paddingTop),o=parseFloat(n.paddingBottom),l=a.current.getBoundingClientRect().height||0,m=a.current.getBoundingClientRect().width||0,v=(e.getBoundingClientRect().height||0)-r-o,p=e.getBoundingClientRect().top||0,g=(a.current.getBoundingClientRect().top||0)-p||p,f=g,b=v-g-l,h=(null===(t=c.current)||void 0===t?void 0:t.getBoundingClientRect().height)||0;if("auto"===d?"above"===(!(b>=h)&&f>1.5*b?"above":"below"):"above"===d){var y=f-u;c.current.setAttribute("data-placement","top"),c.current.style.top="auto",c.current.style.bottom="".concat(l,"px"),c.current.style.maxHeight="".concat(void 0!==s?Math.min(s,y):y,"px")}else{var x=b-u;c.current.setAttribute("data-placement","bottom"),c.current.style.bottom="auto",c.current.style.top="".concat(l,"px"),c.current.style.maxHeight="".concat(void 0!==s?Math.min(s,x):x,"px")}c.current.style.maxWidth="".concat(m,"px")}},[a,c,d,s]);n(function(){var t,e=c.current;if(e){var n=new MutationObserver(function(){var t;null===(t=null==c?void 0:c.current)||void 0===t||t.removeAttribute("data-placement"),p()});return n.observe(e,{childList:!0,subtree:null!=v&&v}),null===(t=null==c?void 0:c.current)||void 0===t||t.removeAttribute("data-placement"),p(),function(){n.disconnect()}}},[v,c,null==c?void 0:c.current,p]);return t.createElement(r,{beforeEnter:function(){p()},afterLeave:function(){var t;null===(t=null==c?void 0:c.current)||void 0===t||t.removeAttribute("data-placement")},enter:"transition duration-75 ease-in-out",enterFrom:"transform scale-95 opacity-0",enterTo:"transform scale-100 opacity-100",leave:"transition duration-100 ease-in-out",leaveFrom:"transform scale-100 opacity-100",leaveTo:"transform scale-95 opacity-0"},m)}export{c as default};
|
|
@@ -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>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e,{useMemo as r,isValidElement as a,cloneElement as i}from"react";import t from"clsx";import s from"./SideNav.module.css.js";var d="__isChildOfSideNav",m=function(m){var n=m.className,o=m.children,l=r(
|
|
1
|
+
import e,{useMemo as r,isValidElement as a,cloneElement as i}from"react";import t from"clsx";import s from"./SideNav.module.css.js";var d="__isChildOfSideNav",m=function(m){var n=m.className,o=m.children,l=r(function(){return"development"===process.env.NODE_ENV?e.Children.map(o,function(e){var r;return a(e)&&"SideNavGroup"===e.type.displayName?i(e,((r={})[d]=!0,r)):e}):o},[o]);return e.createElement("div",{className:t(s.sideNav,n)},l)};m.displayName="SideNav";export{d as CHILD_KEY,m as default};
|