@zvk/ui 0.1.0
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/LICENSE.md +26 -0
- package/README.md +31 -0
- package/dist/components/accordion/accordion.d.ts +43 -0
- package/dist/components/accordion/accordion.js +207 -0
- package/dist/components/accordion/index.d.ts +2 -0
- package/dist/components/accordion/index.js +2 -0
- package/dist/components/alert/alert.d.ts +24 -0
- package/dist/components/alert/alert.js +17 -0
- package/dist/components/alert/index.d.ts +2 -0
- package/dist/components/alert/index.js +1 -0
- package/dist/components/alert-dialog/alert-dialog.d.ts +46 -0
- package/dist/components/alert-dialog/alert-dialog.js +112 -0
- package/dist/components/alert-dialog/index.d.ts +2 -0
- package/dist/components/alert-dialog/index.js +2 -0
- package/dist/components/avatar/avatar.d.ts +14 -0
- package/dist/components/avatar/avatar.js +22 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/avatar/index.js +2 -0
- package/dist/components/badge/badge.d.ts +11 -0
- package/dist/components/badge/badge.js +6 -0
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/badge/index.js +1 -0
- package/dist/components/breadcrumbs/breadcrumbs.d.ts +24 -0
- package/dist/components/breadcrumbs/breadcrumbs.js +18 -0
- package/dist/components/breadcrumbs/index.d.ts +2 -0
- package/dist/components/breadcrumbs/index.js +1 -0
- package/dist/components/button/button.d.ts +13 -0
- package/dist/components/button/button.js +8 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button/index.js +1 -0
- package/dist/components/card/card.d.ts +31 -0
- package/dist/components/card/card.js +28 -0
- package/dist/components/card/index.d.ts +2 -0
- package/dist/components/card/index.js +1 -0
- package/dist/components/checkbox/checkbox.d.ts +11 -0
- package/dist/components/checkbox/checkbox.js +30 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/checkbox/index.js +2 -0
- package/dist/components/code-block/code-block.d.ts +10 -0
- package/dist/components/code-block/code-block.js +16 -0
- package/dist/components/code-block/index.d.ts +2 -0
- package/dist/components/code-block/index.js +1 -0
- package/dist/components/collapsible/collapsible.d.ts +23 -0
- package/dist/components/collapsible/collapsible.js +52 -0
- package/dist/components/collapsible/index.d.ts +2 -0
- package/dist/components/collapsible/index.js +2 -0
- package/dist/components/combobox/combobox.d.ts +20 -0
- package/dist/components/combobox/combobox.js +121 -0
- package/dist/components/combobox/index.d.ts +2 -0
- package/dist/components/combobox/index.js +2 -0
- package/dist/components/command/command-dialog.d.ts +2 -0
- package/dist/components/command/command-dialog.js +1 -0
- package/dist/components/command/command-filter.d.ts +7 -0
- package/dist/components/command/command-filter.js +14 -0
- package/dist/components/command/command.d.ts +55 -0
- package/dist/components/command/command.js +200 -0
- package/dist/components/command/index.d.ts +2 -0
- package/dist/components/command/index.js +2 -0
- package/dist/components/context-menu/context-menu.d.ts +34 -0
- package/dist/components/context-menu/context-menu.js +154 -0
- package/dist/components/context-menu/index.d.ts +2 -0
- package/dist/components/context-menu/index.js +2 -0
- package/dist/components/conversation/conversation.d.ts +60 -0
- package/dist/components/conversation/conversation.js +49 -0
- package/dist/components/conversation/index.d.ts +2 -0
- package/dist/components/conversation/index.js +1 -0
- package/dist/components/copy-button/copy-button.d.ts +23 -0
- package/dist/components/copy-button/copy-button.js +50 -0
- package/dist/components/copy-button/index.d.ts +2 -0
- package/dist/components/copy-button/index.js +2 -0
- package/dist/components/dialog/dialog.d.ts +62 -0
- package/dist/components/dialog/dialog.js +141 -0
- package/dist/components/dialog/index.d.ts +2 -0
- package/dist/components/dialog/index.js +2 -0
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +43 -0
- package/dist/components/dropdown-menu/dropdown-menu.js +286 -0
- package/dist/components/dropdown-menu/index.d.ts +2 -0
- package/dist/components/dropdown-menu/index.js +2 -0
- package/dist/components/empty-state/empty-state.d.ts +13 -0
- package/dist/components/empty-state/empty-state.js +34 -0
- package/dist/components/empty-state/index.d.ts +2 -0
- package/dist/components/empty-state/index.js +1 -0
- package/dist/components/error-boundary/error-boundary.d.ts +29 -0
- package/dist/components/error-boundary/error-boundary.js +43 -0
- package/dist/components/error-boundary/index.d.ts +2 -0
- package/dist/components/error-boundary/index.js +2 -0
- package/dist/components/field/field.d.ts +23 -0
- package/dist/components/field/field.js +20 -0
- package/dist/components/field/index.d.ts +2 -0
- package/dist/components/field/index.js +1 -0
- package/dist/components/file-upload-input/file-upload-input.d.ts +13 -0
- package/dist/components/file-upload-input/file-upload-input.js +41 -0
- package/dist/components/file-upload-input/index.d.ts +2 -0
- package/dist/components/file-upload-input/index.js +2 -0
- package/dist/components/form/form.d.ts +30 -0
- package/dist/components/form/form.js +88 -0
- package/dist/components/form/index.d.ts +2 -0
- package/dist/components/form/index.js +2 -0
- package/dist/components/icon-button/icon-button.d.ts +10 -0
- package/dist/components/icon-button/icon-button.js +8 -0
- package/dist/components/icon-button/index.d.ts +2 -0
- package/dist/components/icon-button/index.js +1 -0
- package/dist/components/index.d.ts +102 -0
- package/dist/components/index.js +51 -0
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/input/index.js +1 -0
- package/dist/components/input/input.d.ts +11 -0
- package/dist/components/input/input.js +27 -0
- package/dist/components/label/index.d.ts +2 -0
- package/dist/components/label/index.js +1 -0
- package/dist/components/label/label.d.ts +9 -0
- package/dist/components/label/label.js +6 -0
- package/dist/components/menubar/index.d.ts +2 -0
- package/dist/components/menubar/index.js +2 -0
- package/dist/components/menubar/menubar.d.ts +39 -0
- package/dist/components/menubar/menubar.js +214 -0
- package/dist/components/pagination/index.d.ts +2 -0
- package/dist/components/pagination/index.js +1 -0
- package/dist/components/pagination/pagination.d.ts +21 -0
- package/dist/components/pagination/pagination.js +92 -0
- package/dist/components/popover/index.d.ts +2 -0
- package/dist/components/popover/index.js +2 -0
- package/dist/components/popover/popover.d.ts +28 -0
- package/dist/components/popover/popover.js +164 -0
- package/dist/components/progress/index.d.ts +2 -0
- package/dist/components/progress/index.js +1 -0
- package/dist/components/progress/progress.d.ts +24 -0
- package/dist/components/progress/progress.js +29 -0
- package/dist/components/radio-group/index.d.ts +2 -0
- package/dist/components/radio-group/index.js +2 -0
- package/dist/components/radio-group/radio-group.d.ts +42 -0
- package/dist/components/radio-group/radio-group.js +69 -0
- package/dist/components/responsive-container/index.d.ts +2 -0
- package/dist/components/responsive-container/index.js +1 -0
- package/dist/components/responsive-container/responsive-container.d.ts +10 -0
- package/dist/components/responsive-container/responsive-container.js +6 -0
- package/dist/components/scroll-area/index.d.ts +2 -0
- package/dist/components/scroll-area/index.js +2 -0
- package/dist/components/scroll-area/scroll-area.d.ts +21 -0
- package/dist/components/scroll-area/scroll-area.js +23 -0
- package/dist/components/sectioned-sidebar-nav/index.d.ts +2 -0
- package/dist/components/sectioned-sidebar-nav/index.js +1 -0
- package/dist/components/sectioned-sidebar-nav/sectioned-sidebar-nav.d.ts +39 -0
- package/dist/components/sectioned-sidebar-nav/sectioned-sidebar-nav.js +37 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.js +2 -0
- package/dist/components/select/select.d.ts +46 -0
- package/dist/components/select/select.js +239 -0
- package/dist/components/separator/index.d.ts +2 -0
- package/dist/components/separator/index.js +1 -0
- package/dist/components/separator/separator.d.ts +8 -0
- package/dist/components/separator/separator.js +6 -0
- package/dist/components/sheet/index.d.ts +2 -0
- package/dist/components/sheet/index.js +2 -0
- package/dist/components/sheet/sheet.d.ts +49 -0
- package/dist/components/sheet/sheet.js +116 -0
- package/dist/components/sidebar-shell/index.d.ts +2 -0
- package/dist/components/sidebar-shell/index.js +1 -0
- package/dist/components/sidebar-shell/sidebar-shell.d.ts +35 -0
- package/dist/components/sidebar-shell/sidebar-shell.js +28 -0
- package/dist/components/skeleton/index.d.ts +2 -0
- package/dist/components/skeleton/index.js +1 -0
- package/dist/components/skeleton/skeleton.d.ts +10 -0
- package/dist/components/skeleton/skeleton.js +16 -0
- package/dist/components/slider/index.d.ts +2 -0
- package/dist/components/slider/index.js +2 -0
- package/dist/components/slider/slider.d.ts +12 -0
- package/dist/components/slider/slider.js +30 -0
- package/dist/components/spinner/index.d.ts +2 -0
- package/dist/components/spinner/index.js +1 -0
- package/dist/components/spinner/spinner.d.ts +10 -0
- package/dist/components/spinner/spinner.js +7 -0
- package/dist/components/stat/index.d.ts +2 -0
- package/dist/components/stat/index.js +1 -0
- package/dist/components/stat/stat.d.ts +13 -0
- package/dist/components/stat/stat.js +8 -0
- package/dist/components/switch/index.d.ts +2 -0
- package/dist/components/switch/index.js +2 -0
- package/dist/components/switch/switch.d.ts +11 -0
- package/dist/components/switch/switch.js +27 -0
- package/dist/components/table/index.d.ts +2 -0
- package/dist/components/table/index.js +1 -0
- package/dist/components/table/table.d.ts +45 -0
- package/dist/components/table/table.js +36 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/components/tabs/index.js +2 -0
- package/dist/components/tabs/tabs.d.ts +34 -0
- package/dist/components/tabs/tabs.js +233 -0
- package/dist/components/tabs-with-sidebar/index.d.ts +2 -0
- package/dist/components/tabs-with-sidebar/index.js +2 -0
- package/dist/components/tabs-with-sidebar/tabs-with-sidebar.d.ts +21 -0
- package/dist/components/tabs-with-sidebar/tabs-with-sidebar.js +18 -0
- package/dist/components/textarea/index.d.ts +2 -0
- package/dist/components/textarea/index.js +2 -0
- package/dist/components/textarea/textarea.d.ts +11 -0
- package/dist/components/textarea/textarea.js +28 -0
- package/dist/components/toast/index.d.ts +2 -0
- package/dist/components/toast/index.js +1 -0
- package/dist/components/toast/toast.d.ts +33 -0
- package/dist/components/toast/toast.js +27 -0
- package/dist/components/toggle/index.d.ts +2 -0
- package/dist/components/toggle/index.js +2 -0
- package/dist/components/toggle/toggle.d.ts +12 -0
- package/dist/components/toggle/toggle.js +18 -0
- package/dist/components/toggle-group/index.d.ts +2 -0
- package/dist/components/toggle-group/index.js +2 -0
- package/dist/components/toggle-group/toggle-group.d.ts +28 -0
- package/dist/components/toggle-group/toggle-group.js +67 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/index.js +2 -0
- package/dist/components/tooltip/tooltip.d.ts +10 -0
- package/dist/components/tooltip/tooltip.js +100 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/use-composed-refs.d.ts +3 -0
- package/dist/hooks/use-composed-refs.js +18 -0
- package/dist/hooks/use-controllable-state.d.ts +7 -0
- package/dist/hooks/use-controllable-state.js +30 -0
- package/dist/hooks/use-disclosure.d.ts +13 -0
- package/dist/hooks/use-disclosure.js +20 -0
- package/dist/hooks/use-event.d.ts +1 -0
- package/dist/hooks/use-event.js +11 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/internal/collection/collection.d.ts +18 -0
- package/dist/internal/collection/collection.js +54 -0
- package/dist/internal/collection/index.d.ts +2 -0
- package/dist/internal/collection/index.js +1 -0
- package/dist/internal/dismissable-layer/dismissable-layer.d.ts +13 -0
- package/dist/internal/dismissable-layer/dismissable-layer.js +73 -0
- package/dist/internal/dismissable-layer/index.d.ts +2 -0
- package/dist/internal/dismissable-layer/index.js +1 -0
- package/dist/internal/floating/auto-update.d.ts +9 -0
- package/dist/internal/floating/auto-update.js +48 -0
- package/dist/internal/floating/compute-position.d.ts +2 -0
- package/dist/internal/floating/compute-position.js +96 -0
- package/dist/internal/floating/detect-overflow.d.ts +13 -0
- package/dist/internal/floating/detect-overflow.js +13 -0
- package/dist/internal/floating/floating-types.d.ts +42 -0
- package/dist/internal/floating/floating-types.js +1 -0
- package/dist/internal/floating/index.d.ts +27 -0
- package/dist/internal/floating/index.js +5 -0
- package/dist/internal/floating/middleware.d.ts +11 -0
- package/dist/internal/floating/middleware.js +42 -0
- package/dist/internal/floating/use-floating-position.d.ts +2 -0
- package/dist/internal/floating/use-floating-position.js +113 -0
- package/dist/internal/focus/focus-scope.d.ts +10 -0
- package/dist/internal/focus/focus-scope.js +68 -0
- package/dist/internal/focus/focus-utils.d.ts +9 -0
- package/dist/internal/focus/focus-utils.js +94 -0
- package/dist/internal/focus/index.d.ts +3 -0
- package/dist/internal/focus/index.js +2 -0
- package/dist/internal/overlay-stack/index.d.ts +1 -0
- package/dist/internal/overlay-stack/index.js +1 -0
- package/dist/internal/overlay-stack/overlay-stack.d.ts +12 -0
- package/dist/internal/overlay-stack/overlay-stack.js +41 -0
- package/dist/internal/portal/index.d.ts +2 -0
- package/dist/internal/portal/index.js +1 -0
- package/dist/internal/portal/portal.d.ts +7 -0
- package/dist/internal/portal/portal.js +19 -0
- package/dist/internal/scroll-lock/index.d.ts +1 -0
- package/dist/internal/scroll-lock/index.js +1 -0
- package/dist/internal/scroll-lock/scroll-lock.d.ts +4 -0
- package/dist/internal/scroll-lock/scroll-lock.js +69 -0
- package/dist/styles.css +3852 -0
- package/dist/tokens/index.d.ts +2 -0
- package/dist/tokens/index.js +1 -0
- package/dist/tokens/token-types.d.ts +23 -0
- package/dist/tokens/token-types.js +1 -0
- package/dist/tokens/tokens.d.ts +139 -0
- package/dist/tokens/tokens.js +139 -0
- package/dist/utils/cn.d.ts +2 -0
- package/dist/utils/cn.js +3 -0
- package/dist/utils/compose-event-handlers.d.ts +6 -0
- package/dist/utils/compose-event-handlers.js +8 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +2 -0
- package/package.json +282 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
function BreadcrumbsRoot({ className, children, label = "Breadcrumb", separator = "/", ref, ...props }) {
|
|
5
|
+
const items = React.Children.toArray(children).filter(React.isValidElement);
|
|
6
|
+
return (_jsx("nav", { ...props, ref: ref, "aria-label": props["aria-label"] ?? label, className: cn("liano-breadcrumbs", className), children: _jsx("ol", { className: "liano-breadcrumbs__list", children: items.map((item, index) => (_jsx(Breadcrumbs.Item, { ...item.props, hasSeparator: index < items.length - 1, separator: separator }, item.key))) }) }));
|
|
7
|
+
}
|
|
8
|
+
function BreadcrumbsItem({ children, className, current, href, hasSeparator = false, linkProps = {}, ref, separator = "/", ...props }) {
|
|
9
|
+
const renderedSeparator = React.isValidElement(separator)
|
|
10
|
+
? React.cloneElement(separator, {
|
|
11
|
+
...separator.props,
|
|
12
|
+
"aria-hidden": true
|
|
13
|
+
})
|
|
14
|
+
: React.createElement("span", null, separator);
|
|
15
|
+
const content = current || !href ? (_jsx("span", { className: "liano-breadcrumbs__text", children: children })) : (_jsx("a", { href: href, ...linkProps, className: cn("liano-breadcrumbs__link", linkProps.className), children: children }));
|
|
16
|
+
return (_jsxs("li", { ...props, ref: ref, "aria-current": current ? "page" : undefined, className: cn("liano-breadcrumbs__item", className), children: [content, hasSeparator ? (_jsx("span", { "aria-hidden": "true", className: "liano-breadcrumbs__separator", children: renderedSeparator })) : null] }));
|
|
17
|
+
}
|
|
18
|
+
export const Breadcrumbs = Object.assign(BreadcrumbsRoot, { Item: BreadcrumbsItem });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Breadcrumbs } from "./breadcrumbs.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type ButtonVariant = "primary" | "secondary" | "outline" | "ghost" | "destructive";
|
|
3
|
+
export type ButtonSize = "sm" | "md" | "lg";
|
|
4
|
+
export interface ButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "disabled"> {
|
|
5
|
+
variant?: ButtonVariant;
|
|
6
|
+
size?: ButtonSize;
|
|
7
|
+
loading?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
leadingIcon?: React.ReactNode;
|
|
10
|
+
trailingIcon?: React.ReactNode;
|
|
11
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
12
|
+
}
|
|
13
|
+
export declare function Button({ children, className, disabled, leadingIcon, loading, ref, size, trailingIcon, type, variant, ...props }: ButtonProps): React.JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Spinner } from "../spinner/spinner.js";
|
|
4
|
+
import { cn } from "../../utils/cn.js";
|
|
5
|
+
export function Button({ children, className, disabled, leadingIcon, loading = false, ref, size = "md", trailingIcon, type = "button", variant = "primary", ...props }) {
|
|
6
|
+
const isDisabled = disabled || loading;
|
|
7
|
+
return (_jsxs("button", { ...props, ref: ref, "aria-busy": loading ? true : undefined, className: cn("liano-button", className), "data-disabled": isDisabled ? "true" : undefined, "data-loading": loading ? "true" : undefined, "data-size": size, "data-variant": variant, disabled: isDisabled, type: type, children: [loading ? (_jsx("span", { "aria-hidden": "true", className: "liano-button__spinner", children: _jsx(Spinner, { size: "sm" }) })) : null, leadingIcon ? (_jsx("span", { "aria-hidden": "true", className: "liano-button__icon", children: leadingIcon })) : null, _jsx("span", { className: "liano-button__content", children: children }), trailingIcon ? (_jsx("span", { "aria-hidden": "true", className: "liano-button__icon", children: trailingIcon })) : null] }));
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Button } from "./button.js";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type CardVariant = "elevated" | "outline" | "ghost";
|
|
3
|
+
export type CardPadding = "none" | "sm" | "md" | "lg";
|
|
4
|
+
export interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
variant?: CardVariant;
|
|
6
|
+
padding?: CardPadding;
|
|
7
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
8
|
+
}
|
|
9
|
+
export interface CardSlotProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
10
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
11
|
+
}
|
|
12
|
+
export interface CardTitleProps extends React.HTMLAttributes<HTMLHeadingElement> {
|
|
13
|
+
ref?: React.Ref<HTMLHeadingElement>;
|
|
14
|
+
}
|
|
15
|
+
export interface CardDescriptionProps extends React.HTMLAttributes<HTMLParagraphElement> {
|
|
16
|
+
ref?: React.Ref<HTMLParagraphElement>;
|
|
17
|
+
}
|
|
18
|
+
declare function CardRoot({ className, padding, ref, variant, ...props }: CardProps): React.JSX.Element;
|
|
19
|
+
declare function CardHeader({ className, ref, ...props }: CardSlotProps): React.JSX.Element;
|
|
20
|
+
declare function CardTitle({ className, ref, ...props }: CardTitleProps): React.JSX.Element;
|
|
21
|
+
declare function CardDescription({ className, ref, ...props }: CardDescriptionProps): React.JSX.Element;
|
|
22
|
+
declare function CardContent({ className, ref, ...props }: CardSlotProps): React.JSX.Element;
|
|
23
|
+
declare function CardFooter({ className, ref, ...props }: CardSlotProps): React.JSX.Element;
|
|
24
|
+
export declare const Card: typeof CardRoot & {
|
|
25
|
+
Header: typeof CardHeader;
|
|
26
|
+
Title: typeof CardTitle;
|
|
27
|
+
Description: typeof CardDescription;
|
|
28
|
+
Content: typeof CardContent;
|
|
29
|
+
Footer: typeof CardFooter;
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
function CardRoot({ className, padding = "md", ref, variant = "elevated", ...props }) {
|
|
5
|
+
return _jsx("div", { ...props, ref: ref, className: cn("liano-card", className), "data-padding": padding, "data-variant": variant });
|
|
6
|
+
}
|
|
7
|
+
function CardHeader({ className, ref, ...props }) {
|
|
8
|
+
return _jsx("div", { ...props, ref: ref, className: cn("liano-card__header", className) });
|
|
9
|
+
}
|
|
10
|
+
function CardTitle({ className, ref, ...props }) {
|
|
11
|
+
return _jsx("h3", { ...props, ref: ref, className: cn("liano-card__title", className) });
|
|
12
|
+
}
|
|
13
|
+
function CardDescription({ className, ref, ...props }) {
|
|
14
|
+
return _jsx("p", { ...props, ref: ref, className: cn("liano-card__description", className) });
|
|
15
|
+
}
|
|
16
|
+
function CardContent({ className, ref, ...props }) {
|
|
17
|
+
return _jsx("div", { ...props, ref: ref, className: cn("liano-card__content", className) });
|
|
18
|
+
}
|
|
19
|
+
function CardFooter({ className, ref, ...props }) {
|
|
20
|
+
return _jsx("div", { ...props, ref: ref, className: cn("liano-card__footer", className) });
|
|
21
|
+
}
|
|
22
|
+
export const Card = Object.assign(CardRoot, {
|
|
23
|
+
Header: CardHeader,
|
|
24
|
+
Title: CardTitle,
|
|
25
|
+
Description: CardDescription,
|
|
26
|
+
Content: CardContent,
|
|
27
|
+
Footer: CardFooter
|
|
28
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Card } from "./card.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type CheckboxSize = "sm" | "md" | "lg";
|
|
3
|
+
export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size" | "type"> {
|
|
4
|
+
label?: React.ReactNode;
|
|
5
|
+
description?: React.ReactNode;
|
|
6
|
+
error?: React.ReactNode;
|
|
7
|
+
invalid?: boolean;
|
|
8
|
+
size?: CheckboxSize;
|
|
9
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
10
|
+
}
|
|
11
|
+
export declare function Checkbox({ "aria-describedby": ariaDescribedBy, className, description, disabled, error, id, invalid, label, ref, required, size, ...props }: CheckboxProps): React.JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Field } from "../field/field.js";
|
|
5
|
+
import { cn } from "../../utils/cn.js";
|
|
6
|
+
function hasRenderableNode(value) {
|
|
7
|
+
return value !== undefined && value !== null && value !== false;
|
|
8
|
+
}
|
|
9
|
+
function joinIds(...ids) {
|
|
10
|
+
const value = ids.filter(Boolean).join(" ");
|
|
11
|
+
return value.length > 0 ? value : undefined;
|
|
12
|
+
}
|
|
13
|
+
export function Checkbox({ "aria-describedby": ariaDescribedBy, className, description, disabled, error, id, invalid, label, ref, required, size = "md", ...props }) {
|
|
14
|
+
const generatedId = React.useId();
|
|
15
|
+
const hasLabel = hasRenderableNode(label);
|
|
16
|
+
const hasDescription = hasRenderableNode(description);
|
|
17
|
+
const hasError = hasRenderableNode(error);
|
|
18
|
+
const shouldUseWrapperId = hasLabel || hasDescription || hasError;
|
|
19
|
+
const checkboxId = id ?? (shouldUseWrapperId ? generatedId : undefined);
|
|
20
|
+
const invalidState = invalid || Boolean(hasError);
|
|
21
|
+
const descriptionId = hasDescription ? `${checkboxId}-description` : undefined;
|
|
22
|
+
const errorId = hasError ? `${checkboxId}-error` : undefined;
|
|
23
|
+
const describedBy = joinIds(ariaDescribedBy, descriptionId, errorId);
|
|
24
|
+
const input = (_jsx("input", { ...props, ref: ref, "aria-describedby": describedBy, "aria-invalid": invalidState ? true : undefined, className: "liano-checkbox__input", "data-disabled": disabled ? "true" : undefined, "data-invalid": invalidState ? "true" : undefined, "data-required": required ? "true" : undefined, disabled: disabled, id: checkboxId, required: required, type: "checkbox" }));
|
|
25
|
+
const content = (_jsxs(_Fragment, { children: [input, _jsx("span", { className: "liano-checkbox__control", "aria-hidden": "true", children: _jsx("span", { className: "liano-checkbox__indicator" }) }), hasLabel ? _jsx("span", { className: "liano-checkbox__label", children: label }) : null] }));
|
|
26
|
+
if (!hasLabel && !hasDescription && !hasError) {
|
|
27
|
+
return (_jsx("span", { className: cn("liano-checkbox", className), "data-size": size, "data-disabled": disabled ? "true" : undefined, "data-invalid": invalidState ? "true" : undefined, "data-required": required ? "true" : undefined, children: content }));
|
|
28
|
+
}
|
|
29
|
+
return (_jsxs(Field, { disabled: Boolean(disabled), invalid: invalidState, required: Boolean(required), children: [_jsx("label", { className: cn("liano-checkbox", className), "data-size": size, "data-disabled": disabled ? "true" : undefined, "data-invalid": invalidState ? "true" : undefined, "data-required": required ? "true" : undefined, children: content }), hasDescription ? _jsx(Field.Description, { id: descriptionId, children: description }) : null, hasError ? _jsx(Field.Error, { id: errorId, children: error }) : null] }));
|
|
30
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type CodeBlockSize = "sm" | "md";
|
|
3
|
+
export interface CodeBlockProps extends React.HTMLAttributes<HTMLPreElement> {
|
|
4
|
+
code: string;
|
|
5
|
+
language?: string;
|
|
6
|
+
filename?: React.ReactNode;
|
|
7
|
+
size?: CodeBlockSize;
|
|
8
|
+
ref?: React.Ref<HTMLPreElement>;
|
|
9
|
+
}
|
|
10
|
+
export declare function CodeBlock({ className, code, filename, language, ref, size, ...props }: CodeBlockProps): React.JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../../utils/cn.js";
|
|
4
|
+
function toLanguageClass(value) {
|
|
5
|
+
if (value === undefined || value === null) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
const normalized = value.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
9
|
+
return normalized.length > 0 ? `language-${normalized}` : undefined;
|
|
10
|
+
}
|
|
11
|
+
export function CodeBlock({ className, code, filename, language, ref, size = "md", ...props }) {
|
|
12
|
+
const hasMetadata = (filename !== undefined && filename !== null) ||
|
|
13
|
+
(language !== undefined && language !== null && language.trim().length > 0);
|
|
14
|
+
const codeClassName = cn("liano-code-block__code", toLanguageClass(language));
|
|
15
|
+
return (_jsxs("pre", { ...props, ref: ref, className: cn("liano-code-block", className), "data-size": size, children: [hasMetadata ? (_jsxs("span", { className: "liano-code-block__header", children: [filename !== undefined && filename !== null ? _jsx("span", { className: "liano-code-block__filename", children: filename }) : null, language ? _jsx("span", { className: "liano-code-block__language", children: language }) : null] })) : null, _jsx("code", { className: codeClassName, children: code })] }));
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CodeBlock } from "./code-block.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface CollapsibleProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
open?: boolean;
|
|
4
|
+
defaultOpen?: boolean;
|
|
5
|
+
onOpenChange?: (open: boolean) => void;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
8
|
+
}
|
|
9
|
+
export interface CollapsibleTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
10
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
11
|
+
}
|
|
12
|
+
export interface CollapsibleContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
13
|
+
forceMount?: boolean;
|
|
14
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
15
|
+
}
|
|
16
|
+
declare function CollapsibleRoot({ children, className, defaultOpen, disabled, onOpenChange, open, ref, ...props }: CollapsibleProps): React.JSX.Element;
|
|
17
|
+
declare function CollapsibleTrigger({ className, disabled, onClick, ref, type, ...props }: CollapsibleTriggerProps): React.JSX.Element;
|
|
18
|
+
declare function CollapsibleContent({ className, forceMount, ref, ...props }: CollapsibleContentProps): React.JSX.Element | null;
|
|
19
|
+
export declare const Collapsible: typeof CollapsibleRoot & {
|
|
20
|
+
Trigger: typeof CollapsibleTrigger;
|
|
21
|
+
Content: typeof CollapsibleContent;
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { composeEventHandlers } from "../../utils/compose-event-handlers.js";
|
|
5
|
+
import { useDisclosure } from "../../hooks/use-disclosure.js";
|
|
6
|
+
import { cn } from "../../utils/cn.js";
|
|
7
|
+
const CollapsibleContext = React.createContext(null);
|
|
8
|
+
function useCollapsibleContext(calledBy) {
|
|
9
|
+
const context = React.useContext(CollapsibleContext);
|
|
10
|
+
if (!context) {
|
|
11
|
+
throw new Error(`"${calledBy}" must be used within a <Collapsible />`);
|
|
12
|
+
}
|
|
13
|
+
return context;
|
|
14
|
+
}
|
|
15
|
+
function CollapsibleRoot({ children, className, defaultOpen = false, disabled = false, onOpenChange, open, ref, ...props }) {
|
|
16
|
+
const generatedId = React.useId();
|
|
17
|
+
const defaultContentId = `${generatedId}-content`;
|
|
18
|
+
const [contentId, setContentId] = React.useState(defaultContentId);
|
|
19
|
+
const { open: isOpen, setOpen } = useDisclosure({
|
|
20
|
+
...(open !== undefined ? { open } : {}),
|
|
21
|
+
defaultOpen,
|
|
22
|
+
...(onOpenChange ? { onOpenChange } : {})
|
|
23
|
+
});
|
|
24
|
+
return (_jsx(CollapsibleContext.Provider, { value: { open: isOpen, setOpen, disabled, contentId, defaultContentId, setContentId }, children: _jsx("div", { ...props, ref: ref, className: cn("liano-collapsible", className), "data-state": isOpen ? "open" : "closed", "data-disabled": disabled ? "true" : undefined, children: children }) }));
|
|
25
|
+
}
|
|
26
|
+
function CollapsibleTrigger({ className, disabled, onClick, ref, type = "button", ...props }) {
|
|
27
|
+
const context = useCollapsibleContext("Collapsible.Trigger");
|
|
28
|
+
const isDisabled = disabled || context.disabled;
|
|
29
|
+
const handleClick = () => {
|
|
30
|
+
context.setOpen((previous) => !previous);
|
|
31
|
+
};
|
|
32
|
+
return (_jsx("button", { ...props, ref: ref, className: cn("liano-collapsible__trigger", className), "aria-controls": context.contentId, "aria-expanded": context.open, "data-state": context.open ? "open" : "closed", "data-disabled": isDisabled ? "true" : undefined, disabled: isDisabled, onClick: composeEventHandlers(onClick, isDisabled ? undefined : handleClick), type: type }));
|
|
33
|
+
}
|
|
34
|
+
function CollapsibleContent({ className, forceMount = false, ref, ...props }) {
|
|
35
|
+
const context = useCollapsibleContext("Collapsible.Content");
|
|
36
|
+
const { defaultContentId, open, setContentId } = context;
|
|
37
|
+
const resolvedId = props.id ?? defaultContentId;
|
|
38
|
+
React.useLayoutEffect(() => {
|
|
39
|
+
setContentId(resolvedId);
|
|
40
|
+
return () => {
|
|
41
|
+
setContentId(defaultContentId);
|
|
42
|
+
};
|
|
43
|
+
}, [defaultContentId, resolvedId, setContentId]);
|
|
44
|
+
if (!forceMount && !open) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return (_jsx("div", { ...props, id: resolvedId, ref: ref, className: cn("liano-collapsible__content", className), "data-state": open ? "open" : "closed", hidden: open ? undefined : true }));
|
|
48
|
+
}
|
|
49
|
+
export const Collapsible = Object.assign(CollapsibleRoot, {
|
|
50
|
+
Trigger: CollapsibleTrigger,
|
|
51
|
+
Content: CollapsibleContent
|
|
52
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface ComboboxOption {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
keywords?: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
export interface ComboboxProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange" | "size"> {
|
|
9
|
+
label?: React.ReactNode;
|
|
10
|
+
description?: React.ReactNode;
|
|
11
|
+
error?: React.ReactNode;
|
|
12
|
+
options: readonly ComboboxOption[];
|
|
13
|
+
value?: string;
|
|
14
|
+
defaultValue?: string;
|
|
15
|
+
onValueChange?: (value: string) => void;
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
size?: "sm" | "md" | "lg";
|
|
18
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
19
|
+
}
|
|
20
|
+
export declare function Combobox({ "aria-describedby": ariaDescribedBy, className, defaultValue, description, disabled, error, id, label, onBlur, onFocus, onKeyDown, onValueChange, options, placeholder, ref, required, size, value, ...props }: ComboboxProps): React.JSX.Element;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { commandItemMatches } from "../command/command-filter.js";
|
|
5
|
+
import { composeEventHandlers } from "../../utils/compose-event-handlers.js";
|
|
6
|
+
import { cn } from "../../utils/cn.js";
|
|
7
|
+
import { useControllableState } from "../../hooks/use-controllable-state.js";
|
|
8
|
+
function hasRenderableNode(value) {
|
|
9
|
+
return value !== undefined && value !== null && value !== false;
|
|
10
|
+
}
|
|
11
|
+
function joinIds(...ids) {
|
|
12
|
+
const value = ids.filter(Boolean).join(" ");
|
|
13
|
+
return value.length > 0 ? value : undefined;
|
|
14
|
+
}
|
|
15
|
+
function optionId(baseId, value) {
|
|
16
|
+
return `${baseId}-option-${value.replace(/[^a-zA-Z0-9_-]/g, "-")}`;
|
|
17
|
+
}
|
|
18
|
+
function firstEnabled(options) {
|
|
19
|
+
return options.find((option) => option.disabled !== true);
|
|
20
|
+
}
|
|
21
|
+
function nextEnabled(options, currentValue, direction) {
|
|
22
|
+
const enabled = options.filter((option) => option.disabled !== true);
|
|
23
|
+
if (enabled.length === 0) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
const currentIndex = currentValue === undefined ? -1 : enabled.findIndex((option) => option.value === currentValue);
|
|
27
|
+
const nextIndex = direction === "next" ? currentIndex + 1 : currentIndex - 1;
|
|
28
|
+
const wrapped = ((nextIndex % enabled.length) + enabled.length) % enabled.length;
|
|
29
|
+
return enabled[wrapped];
|
|
30
|
+
}
|
|
31
|
+
export function Combobox({ "aria-describedby": ariaDescribedBy, className, defaultValue = "", description, disabled, error, id, label, onBlur, onFocus, onKeyDown, onValueChange, options, placeholder, ref, required, size = "md", value, ...props }) {
|
|
32
|
+
const generatedId = React.useId();
|
|
33
|
+
const inputId = id ?? generatedId;
|
|
34
|
+
const listboxId = `${inputId}-listbox`;
|
|
35
|
+
const hasLabel = hasRenderableNode(label);
|
|
36
|
+
const hasDescription = hasRenderableNode(description);
|
|
37
|
+
const hasError = hasRenderableNode(error);
|
|
38
|
+
const descriptionId = hasDescription ? `${inputId}-description` : undefined;
|
|
39
|
+
const errorId = hasError ? `${inputId}-error` : undefined;
|
|
40
|
+
const describedBy = joinIds(ariaDescribedBy, descriptionId, errorId);
|
|
41
|
+
const invalid = hasError || props["aria-invalid"] === true || props["aria-invalid"] === "true";
|
|
42
|
+
const [selectedValue, setSelectedValue] = useControllableState({
|
|
43
|
+
...(value !== undefined ? { value } : {}),
|
|
44
|
+
defaultValue,
|
|
45
|
+
...(onValueChange ? { onChange: onValueChange } : {})
|
|
46
|
+
});
|
|
47
|
+
const selectedOption = options.find((option) => option.value === selectedValue);
|
|
48
|
+
const [open, setOpen] = React.useState(false);
|
|
49
|
+
const [query, setQuery] = React.useState(selectedOption?.label ?? "");
|
|
50
|
+
const [activeValue, setActiveValue] = React.useState(selectedOption?.value);
|
|
51
|
+
const filteredOptions = options.filter((option) => commandItemMatches(option, query));
|
|
52
|
+
const activeOption = filteredOptions.find((option) => option.value === activeValue && option.disabled !== true) ??
|
|
53
|
+
firstEnabled(filteredOptions);
|
|
54
|
+
React.useEffect(() => {
|
|
55
|
+
if (!open) {
|
|
56
|
+
setQuery(selectedOption?.label ?? "");
|
|
57
|
+
setActiveValue(selectedOption?.value);
|
|
58
|
+
}
|
|
59
|
+
}, [open, selectedOption?.label, selectedOption?.value]);
|
|
60
|
+
const openListbox = React.useCallback(() => {
|
|
61
|
+
setOpen(true);
|
|
62
|
+
setQuery("");
|
|
63
|
+
setActiveValue(firstEnabled(options)?.value);
|
|
64
|
+
}, [options]);
|
|
65
|
+
const selectOption = React.useCallback((option) => {
|
|
66
|
+
if (!option || option.disabled) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
setSelectedValue(option.value);
|
|
70
|
+
setQuery(option.label);
|
|
71
|
+
setActiveValue(option.value);
|
|
72
|
+
setOpen(false);
|
|
73
|
+
}, [setSelectedValue]);
|
|
74
|
+
const moveActive = React.useCallback((direction) => {
|
|
75
|
+
const next = nextEnabled(filteredOptions, activeOption?.value, direction);
|
|
76
|
+
setActiveValue(next?.value);
|
|
77
|
+
}, [activeOption?.value, filteredOptions]);
|
|
78
|
+
const input = (_jsx("input", { ...props, ref: ref, id: inputId, role: "combobox", "aria-activedescendant": open && activeOption ? optionId(inputId, activeOption.value) : undefined, "aria-autocomplete": "list", "aria-controls": listboxId, "aria-describedby": describedBy, "aria-expanded": open ? "true" : "false", "aria-invalid": invalid ? "true" : undefined, className: cn("liano-combobox__input", className), "data-invalid": invalid ? "true" : undefined, "data-size": size, disabled: disabled, onBlur: onBlur, onChange: (event) => {
|
|
79
|
+
if (!open) {
|
|
80
|
+
setOpen(true);
|
|
81
|
+
}
|
|
82
|
+
setQuery(event.currentTarget.value);
|
|
83
|
+
setActiveValue(firstEnabled(options.filter((option) => commandItemMatches(option, event.currentTarget.value)))?.value);
|
|
84
|
+
}, onClick: () => {
|
|
85
|
+
if (!disabled) {
|
|
86
|
+
openListbox();
|
|
87
|
+
}
|
|
88
|
+
}, onFocus: composeEventHandlers(onFocus, () => {
|
|
89
|
+
if (!disabled) {
|
|
90
|
+
openListbox();
|
|
91
|
+
}
|
|
92
|
+
}), onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
93
|
+
if (event.key === "ArrowDown") {
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
if (!open) {
|
|
96
|
+
openListbox();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
moveActive("next");
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (event.key === "ArrowUp") {
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
moveActive("previous");
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (event.key === "Enter") {
|
|
108
|
+
event.preventDefault();
|
|
109
|
+
selectOption(activeOption);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (event.key === "Escape") {
|
|
113
|
+
setOpen(false);
|
|
114
|
+
}
|
|
115
|
+
}), placeholder: placeholder, required: required, value: open ? query : selectedOption?.label ?? query }));
|
|
116
|
+
return (_jsxs("div", { className: "liano-combobox", "data-disabled": disabled ? "true" : undefined, "data-invalid": invalid ? "true" : undefined, children: [hasLabel ? _jsx("label", { className: "liano-combobox__label", htmlFor: inputId, children: label }) : null, input, hasDescription ? _jsx("div", { className: "liano-combobox__description", id: descriptionId, children: description }) : null, hasError ? _jsx("div", { className: "liano-combobox__error", id: errorId, children: error }) : null, open ? (_jsx("div", { className: "liano-combobox__popup", children: _jsx("div", { id: listboxId, role: "listbox", className: "liano-combobox__list", children: filteredOptions.map((option) => {
|
|
117
|
+
const isActive = activeOption?.value === option.value;
|
|
118
|
+
const isSelected = selectedValue === option.value;
|
|
119
|
+
return (_jsx("div", { id: optionId(inputId, option.value), role: "option", "aria-disabled": option.disabled ? "true" : undefined, "aria-selected": isSelected ? "true" : "false", className: "liano-combobox__option", "data-disabled": option.disabled ? "true" : undefined, "data-highlighted": isActive ? "true" : undefined, "data-selected": isSelected ? "true" : undefined, onMouseDown: (event) => event.preventDefault(), onClick: () => selectOption(option), children: option.label }, option.value));
|
|
120
|
+
}) }) })) : null] }));
|
|
121
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CommandDialog } from "./command.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface CommandFilterItem {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
keywords?: readonly string[] | undefined;
|
|
5
|
+
}
|
|
6
|
+
export declare function commandItemMatches(item: CommandFilterItem, query: string): boolean;
|
|
7
|
+
export declare function filterCommandItems<Item extends CommandFilterItem>(items: readonly Item[], query: string): Item[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function normalized(value) {
|
|
2
|
+
return value.trim().toLocaleLowerCase();
|
|
3
|
+
}
|
|
4
|
+
export function commandItemMatches(item, query) {
|
|
5
|
+
const needle = normalized(query);
|
|
6
|
+
if (needle.length === 0) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
const haystacks = [item.value, item.label, ...(item.keywords ?? [])];
|
|
10
|
+
return haystacks.some((value) => normalized(value).includes(needle));
|
|
11
|
+
}
|
|
12
|
+
export function filterCommandItems(items, query) {
|
|
13
|
+
return items.filter((item) => commandItemMatches(item, query));
|
|
14
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Dialog } from "../dialog/index.js";
|
|
3
|
+
export interface CommandProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
value?: string;
|
|
5
|
+
defaultValue?: string;
|
|
6
|
+
onValueChange?: (value: string) => void;
|
|
7
|
+
onItemSelect?: (value: string) => void;
|
|
8
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
9
|
+
}
|
|
10
|
+
export interface CommandInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange"> {
|
|
11
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
12
|
+
}
|
|
13
|
+
export interface CommandListProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
14
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
15
|
+
}
|
|
16
|
+
export interface CommandEmptyProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
17
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
18
|
+
}
|
|
19
|
+
export interface CommandGroupProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
20
|
+
heading?: React.ReactNode;
|
|
21
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
22
|
+
}
|
|
23
|
+
export interface CommandItemProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onSelect"> {
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
keywords?: readonly string[];
|
|
26
|
+
onSelect?: (value: string) => void;
|
|
27
|
+
value: string;
|
|
28
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
29
|
+
}
|
|
30
|
+
export interface CommandSeparatorProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
31
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
32
|
+
}
|
|
33
|
+
export interface CommandDialogProps extends Omit<React.ComponentProps<typeof Dialog>, "defaultValue" | "onChange"> {
|
|
34
|
+
closeOnSelect?: boolean;
|
|
35
|
+
commandLabel?: string;
|
|
36
|
+
}
|
|
37
|
+
declare function CommandRoot({ children, className, defaultValue, onItemSelect, onValueChange, ref, value, ...props }: CommandProps): React.JSX.Element;
|
|
38
|
+
declare function CommandInput({ className, onKeyDown, placeholder, ref, ...props }: CommandInputProps): React.JSX.Element;
|
|
39
|
+
declare function CommandList({ className, ref, ...props }: CommandListProps): React.JSX.Element;
|
|
40
|
+
declare function CommandEmpty({ className, ref, ...props }: CommandEmptyProps): React.JSX.Element | null;
|
|
41
|
+
declare function CommandGroup({ children, className, heading, ref, ...props }: CommandGroupProps): React.JSX.Element;
|
|
42
|
+
declare function CommandItem({ children, className, disabled, keywords, onClick, onSelect, ref, value, ...props }: CommandItemProps): React.JSX.Element | null;
|
|
43
|
+
declare function CommandSeparator({ className, ref, ...props }: CommandSeparatorProps): React.JSX.Element;
|
|
44
|
+
export declare function CommandDialog({ children, className, closeOnSelect, commandLabel, onOpenChange, ...props }: CommandDialogProps): React.JSX.Element;
|
|
45
|
+
type CommandComponent = typeof CommandRoot & {
|
|
46
|
+
Dialog: typeof CommandDialog;
|
|
47
|
+
Empty: typeof CommandEmpty;
|
|
48
|
+
Group: typeof CommandGroup;
|
|
49
|
+
Input: typeof CommandInput;
|
|
50
|
+
Item: typeof CommandItem;
|
|
51
|
+
List: typeof CommandList;
|
|
52
|
+
Separator: typeof CommandSeparator;
|
|
53
|
+
};
|
|
54
|
+
export declare const Command: CommandComponent;
|
|
55
|
+
export {};
|