@zvk/ui 0.1.3 → 0.1.6

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.
Files changed (108) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +5 -5
  3. package/dist/components/accordion/accordion.js +4 -4
  4. package/dist/components/alert/alert.d.ts +5 -0
  5. package/dist/components/alert/alert.js +8 -4
  6. package/dist/components/alert/index.d.ts +1 -1
  7. package/dist/components/alert-dialog/alert-dialog.d.ts +8 -5
  8. package/dist/components/alert-dialog/alert-dialog.js +26 -13
  9. package/dist/components/avatar/avatar.js +1 -1
  10. package/dist/components/badge/badge.js +1 -1
  11. package/dist/components/breadcrumbs/breadcrumbs.js +3 -3
  12. package/dist/components/button/button.d.ts +3 -2
  13. package/dist/components/button/button.js +50 -2
  14. package/dist/components/calendar/calendar.d.ts +40 -5
  15. package/dist/components/calendar/calendar.js +17 -5
  16. package/dist/components/calendar/index.d.ts +1 -1
  17. package/dist/components/card/card.d.ts +5 -0
  18. package/dist/components/card/card.js +11 -7
  19. package/dist/components/card/index.d.ts +1 -1
  20. package/dist/components/carousel/carousel.js +7 -7
  21. package/dist/components/checkbox/checkbox.js +4 -4
  22. package/dist/components/code-block/code-block.js +2 -2
  23. package/dist/components/collapsible/collapsible.d.ts +3 -2
  24. package/dist/components/collapsible/collapsible.js +8 -4
  25. package/dist/components/combobox/combobox.js +6 -5
  26. package/dist/components/command/command-filter.d.ts +0 -1
  27. package/dist/components/command/command-filter.js +0 -3
  28. package/dist/components/command/command.d.ts +11 -4
  29. package/dist/components/command/command.js +28 -17
  30. package/dist/components/command/index.d.ts +1 -1
  31. package/dist/components/context-menu/context-menu.d.ts +17 -6
  32. package/dist/components/context-menu/context-menu.js +142 -39
  33. package/dist/components/conversation/conversation.js +11 -11
  34. package/dist/components/copy-button/copy-button.js +2 -2
  35. package/dist/components/date-picker/date-picker.js +1 -1
  36. package/dist/components/dialog/dialog.d.ts +6 -4
  37. package/dist/components/dialog/dialog.js +22 -12
  38. package/dist/components/dropdown-menu/dropdown-menu.d.ts +13 -7
  39. package/dist/components/dropdown-menu/dropdown-menu.js +137 -78
  40. package/dist/components/empty-state/empty-state.js +1 -1
  41. package/dist/components/error-boundary/error-boundary.js +1 -1
  42. package/dist/components/field/field.js +4 -4
  43. package/dist/components/file-upload-input/file-upload-input.js +2 -2
  44. package/dist/components/form/form.js +6 -6
  45. package/dist/components/hover-card/hover-card.d.ts +8 -2
  46. package/dist/components/hover-card/hover-card.js +13 -7
  47. package/dist/components/icon-button/icon-button.js +19 -1
  48. package/dist/components/index.d.ts +10 -10
  49. package/dist/components/index.js +1 -1
  50. package/dist/components/input/input.js +1 -1
  51. package/dist/components/label/label.js +1 -1
  52. package/dist/components/menubar/menubar.d.ts +24 -5
  53. package/dist/components/menubar/menubar.js +186 -37
  54. package/dist/components/pagination/pagination.js +12 -12
  55. package/dist/components/popover/popover.d.ts +8 -3
  56. package/dist/components/popover/popover.js +40 -8
  57. package/dist/components/progress/progress.js +3 -3
  58. package/dist/components/radio-group/radio-group.js +3 -3
  59. package/dist/components/responsive-container/responsive-container.js +1 -1
  60. package/dist/components/scroll-area/scroll-area.js +4 -4
  61. package/dist/components/sectioned-sidebar-nav/sectioned-sidebar-nav.js +7 -7
  62. package/dist/components/select/select.js +66 -13
  63. package/dist/components/separator/separator.js +1 -1
  64. package/dist/components/sheet/sheet.d.ts +6 -4
  65. package/dist/components/sheet/sheet.js +29 -16
  66. package/dist/components/sidebar-shell/sidebar-shell.js +6 -6
  67. package/dist/components/skeleton/skeleton.js +1 -1
  68. package/dist/components/slider/slider.js +1 -1
  69. package/dist/components/spinner/spinner.js +1 -1
  70. package/dist/components/stat/stat.js +1 -1
  71. package/dist/components/switch/switch.js +3 -3
  72. package/dist/components/table/index.d.ts +1 -1
  73. package/dist/components/table/table.d.ts +5 -0
  74. package/dist/components/table/table.js +12 -8
  75. package/dist/components/tabs/tabs.js +4 -4
  76. package/dist/components/tabs-with-sidebar/tabs-with-sidebar.js +3 -3
  77. package/dist/components/textarea/textarea.js +1 -1
  78. package/dist/components/toast/index.d.ts +2 -2
  79. package/dist/components/toast/index.js +1 -1
  80. package/dist/components/toast/toast.d.ts +16 -2
  81. package/dist/components/toast/toast.js +49 -7
  82. package/dist/components/toggle/toggle.js +1 -1
  83. package/dist/components/toggle-group/toggle-group.js +1 -1
  84. package/dist/components/tooltip/tooltip.d.ts +8 -2
  85. package/dist/components/tooltip/tooltip.js +12 -6
  86. package/dist/hooks/index.d.ts +2 -2
  87. package/dist/hooks/use-composed-refs.d.ts +2 -2
  88. package/dist/hooks/use-controllable-state.d.ts +2 -2
  89. package/dist/internal/floating/compute-position.js +13 -8
  90. package/dist/internal/floating/floating-types.d.ts +1 -0
  91. package/dist/internal/floating/index.d.ts +1 -0
  92. package/dist/internal/floating/placement-aliases.d.ts +7 -0
  93. package/dist/internal/floating/placement-aliases.js +13 -0
  94. package/dist/internal/floating/use-floating-position.js +6 -4
  95. package/dist/internal/overlay-stack/overlay-stack.js +4 -1
  96. package/dist/internal/slot/index.d.ts +2 -0
  97. package/dist/internal/slot/index.js +1 -0
  98. package/dist/internal/slot/slot.d.ts +6 -0
  99. package/dist/internal/slot/slot.js +53 -0
  100. package/dist/styles.css +2079 -2015
  101. package/dist/tokens/index.d.ts +2 -2
  102. package/dist/tokens/index.js +1 -1
  103. package/dist/tokens/token-types.d.ts +5 -5
  104. package/dist/tokens/tokens.d.ts +16 -10
  105. package/dist/tokens/tokens.js +16 -10
  106. package/dist/utils/cn.d.ts +2 -2
  107. package/dist/utils/index.d.ts +1 -1
  108. package/package.json +13 -12
@@ -157,15 +157,15 @@ function CarouselRoot({ children, className, defaultIndex = 0, index, onApiChang
157
157
  slideCount,
158
158
  unregisterSlide
159
159
  ]);
160
- return (_jsx(CarouselContext.Provider, { value: context, children: _jsx("div", { ...props, ref: ref, "aria-roledescription": "carousel", className: cn("liano-carousel", className), "data-orientation": orientation, onKeyDown: composeEventHandlers(onKeyDown, handleKeyDown), role: props.role ?? "region", tabIndex: tabIndex ?? 0, children: children }) }));
160
+ return (_jsx(CarouselContext.Provider, { value: context, children: _jsx("div", { ...props, ref: ref, "aria-roledescription": "carousel", className: cn("zvk-ui-carousel", className), "data-orientation": orientation, onKeyDown: composeEventHandlers(onKeyDown, handleKeyDown), role: props.role ?? "region", tabIndex: tabIndex ?? 0, children: children }) }));
161
161
  }
162
162
  function CarouselViewport({ className, ref, ...props }) {
163
163
  const context = useCarouselContext("Carousel.Viewport");
164
- return (_jsx("div", { ...props, ref: ref, className: cn("liano-carousel__viewport", className), "data-orientation": context.orientation }));
164
+ return (_jsx("div", { ...props, ref: ref, className: cn("zvk-ui-carousel__viewport", className), "data-orientation": context.orientation }));
165
165
  }
166
166
  function CarouselTrack({ className, ref, ...props }) {
167
167
  const context = useCarouselContext("Carousel.Track");
168
- return (_jsx("div", { ...props, ref: ref, className: cn("liano-carousel__track", className), "data-orientation": context.orientation }));
168
+ return (_jsx("div", { ...props, ref: ref, className: cn("zvk-ui-carousel__track", className), "data-orientation": context.orientation }));
169
169
  }
170
170
  function CarouselSlide({ className, ref, ...props }) {
171
171
  const context = useCarouselContext("Carousel.Slide");
@@ -183,22 +183,22 @@ function CarouselSlide({ className, ref, ...props }) {
183
183
  return (_jsx("div", { ...props, ref: (node) => {
184
184
  slideRef.current = node;
185
185
  setRef(ref, node);
186
- }, "aria-label": props["aria-label"] ?? `${safeIndex + 1} of ${context.slideCount}`, "aria-roledescription": "slide", className: cn("liano-carousel__slide", className), "data-orientation": context.orientation, "data-selected": isSelected ? "true" : undefined, role: props.role ?? "group" }));
186
+ }, "aria-label": props["aria-label"] ?? `${safeIndex + 1} of ${context.slideCount}`, "aria-roledescription": "slide", className: cn("zvk-ui-carousel__slide", className), "data-orientation": context.orientation, "data-selected": isSelected ? "true" : undefined, role: props.role ?? "group" }));
187
187
  }
188
188
  function CarouselPrevious({ className, disabled, onClick, ref, type = "button", ...props }) {
189
189
  const context = useCarouselContext("Carousel.Previous");
190
190
  const isDisabled = disabled === true || !context.canScrollPrev;
191
- return (_jsx("button", { ...props, ref: ref, "aria-label": props["aria-label"] ?? "Previous slide", className: cn("liano-carousel__button liano-carousel__button--previous", className), "data-disabled": isDisabled ? "true" : undefined, disabled: isDisabled, onClick: composeEventHandlers(onClick, () => context.scrollPrev()), type: type }));
191
+ return (_jsx("button", { ...props, ref: ref, "aria-label": props["aria-label"] ?? "Previous slide", className: cn("zvk-ui-carousel__button zvk-ui-carousel__button--previous", className), "data-disabled": isDisabled ? "true" : undefined, disabled: isDisabled, onClick: composeEventHandlers(onClick, () => context.scrollPrev()), type: type }));
192
192
  }
193
193
  function CarouselNext({ className, disabled, onClick, ref, type = "button", ...props }) {
194
194
  const context = useCarouselContext("Carousel.Next");
195
195
  const isDisabled = disabled === true || !context.canScrollNext;
196
- return (_jsx("button", { ...props, ref: ref, "aria-label": props["aria-label"] ?? "Next slide", className: cn("liano-carousel__button liano-carousel__button--next", className), "data-disabled": isDisabled ? "true" : undefined, disabled: isDisabled, onClick: composeEventHandlers(onClick, () => context.scrollNext()), type: type }));
196
+ return (_jsx("button", { ...props, ref: ref, "aria-label": props["aria-label"] ?? "Next slide", className: cn("zvk-ui-carousel__button zvk-ui-carousel__button--next", className), "data-disabled": isDisabled ? "true" : undefined, disabled: isDisabled, onClick: composeEventHandlers(onClick, () => context.scrollNext()), type: type }));
197
197
  }
198
198
  function CarouselPage({ children, className, ref, ...props }) {
199
199
  const context = useCarouselContext("Carousel.Page");
200
200
  const label = context.slideCount === 0 ? "0 / 0" : `${context.selectedIndex + 1} / ${context.slideCount}`;
201
- return (_jsx("output", { ...props, ref: ref, "aria-live": props["aria-live"] ?? "polite", className: cn("liano-carousel__page", className), children: children ?? label }));
201
+ return (_jsx("output", { ...props, ref: ref, "aria-live": props["aria-live"] ?? "polite", className: cn("zvk-ui-carousel__page", className), children: children ?? label }));
202
202
  }
203
203
  export const Carousel = Object.assign(CarouselRoot, {
204
204
  Next: CarouselNext,
@@ -21,10 +21,10 @@ export function Checkbox({ "aria-describedby": ariaDescribedBy, className, descr
21
21
  const descriptionId = hasDescription ? `${checkboxId}-description` : undefined;
22
22
  const errorId = hasError ? `${checkboxId}-error` : undefined;
23
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] }));
24
+ const input = (_jsx("input", { ...props, ref: ref, "aria-describedby": describedBy, "aria-invalid": invalidState ? true : undefined, className: "zvk-ui-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: "zvk-ui-checkbox__control", "aria-hidden": "true", children: _jsx("span", { className: "zvk-ui-checkbox__indicator" }) }), hasLabel ? _jsx("span", { className: "zvk-ui-checkbox__label", children: label }) : null] }));
26
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 }));
27
+ return (_jsx("span", { className: cn("zvk-ui-checkbox", className), "data-size": size, "data-disabled": disabled ? "true" : undefined, "data-invalid": invalidState ? "true" : undefined, "data-required": required ? "true" : undefined, children: content }));
28
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] }));
29
+ return (_jsxs(Field, { disabled: Boolean(disabled), invalid: invalidState, required: Boolean(required), children: [_jsx("label", { className: cn("zvk-ui-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
30
  }
@@ -11,6 +11,6 @@ function toLanguageClass(value) {
11
11
  export function CodeBlock({ className, code, filename, language, ref, size = "md", ...props }) {
12
12
  const hasMetadata = (filename !== undefined && filename !== null) ||
13
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 })] }));
14
+ const codeClassName = cn("zvk-ui-code-block__code", toLanguageClass(language));
15
+ return (_jsxs("pre", { ...props, ref: ref, className: cn("zvk-ui-code-block", className), "data-size": size, children: [hasMetadata ? (_jsxs("span", { className: "zvk-ui-code-block__header", children: [filename !== undefined && filename !== null ? _jsx("span", { className: "zvk-ui-code-block__filename", children: filename }) : null, language ? _jsx("span", { className: "zvk-ui-code-block__language", children: language }) : null] })) : null, _jsx("code", { className: codeClassName, children: code })] }));
16
16
  }
@@ -7,14 +7,15 @@ export interface CollapsibleProps extends React.HTMLAttributes<HTMLDivElement> {
7
7
  ref?: React.Ref<HTMLDivElement>;
8
8
  }
9
9
  export interface CollapsibleTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
10
- ref?: React.Ref<HTMLButtonElement>;
10
+ asChild?: boolean;
11
+ ref?: React.Ref<HTMLButtonElement | HTMLElement>;
11
12
  }
12
13
  export interface CollapsibleContentProps extends React.HTMLAttributes<HTMLDivElement> {
13
14
  forceMount?: boolean;
14
15
  ref?: React.Ref<HTMLDivElement>;
15
16
  }
16
17
  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 CollapsibleTrigger({ asChild, className, disabled, onClick, ref, type, ...props }: CollapsibleTriggerProps): React.JSX.Element;
18
19
  declare function CollapsibleContent({ className, forceMount, ref, ...props }: CollapsibleContentProps): React.JSX.Element | null;
19
20
  export declare const Collapsible: typeof CollapsibleRoot & {
20
21
  Trigger: typeof CollapsibleTrigger;
@@ -4,6 +4,7 @@ import * as React from "react";
4
4
  import { composeEventHandlers } from "../../utils/compose-event-handlers.js";
5
5
  import { useDisclosure } from "../../hooks/use-disclosure.js";
6
6
  import { cn } from "../../utils/cn.js";
7
+ import { Slot } from "../../internal/slot/index.js";
7
8
  const CollapsibleContext = React.createContext(null);
8
9
  function useCollapsibleContext(calledBy) {
9
10
  const context = React.useContext(CollapsibleContext);
@@ -21,15 +22,18 @@ function CollapsibleRoot({ children, className, defaultOpen = false, disabled =
21
22
  defaultOpen,
22
23
  ...(onOpenChange ? { onOpenChange } : {})
23
24
  });
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
+ return (_jsx(CollapsibleContext.Provider, { value: { open: isOpen, setOpen, disabled, contentId, defaultContentId, setContentId }, children: _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-collapsible", className), "data-state": isOpen ? "open" : "closed", "data-disabled": disabled ? "true" : undefined, children: children }) }));
25
26
  }
26
- function CollapsibleTrigger({ className, disabled, onClick, ref, type = "button", ...props }) {
27
+ function CollapsibleTrigger({ asChild = false, className, disabled, onClick, ref, type = "button", ...props }) {
27
28
  const context = useCollapsibleContext("Collapsible.Trigger");
28
29
  const isDisabled = disabled || context.disabled;
29
30
  const handleClick = () => {
30
31
  context.setOpen((previous) => !previous);
31
32
  };
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
+ if (asChild) {
34
+ return (_jsx(Slot, { ...props, ref: ref, "aria-controls": context.contentId, "aria-disabled": isDisabled ? true : undefined, "aria-expanded": context.open, className: cn("zvk-ui-collapsible__trigger", className), "data-disabled": isDisabled ? "true" : undefined, "data-state": context.open ? "open" : "closed", onClick: composeEventHandlers(onClick, isDisabled ? undefined : handleClick), children: props.children }));
35
+ }
36
+ return (_jsx("button", { ...props, ref: ref, className: cn("zvk-ui-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
37
  }
34
38
  function CollapsibleContent({ className, forceMount = false, ref, ...props }) {
35
39
  const context = useCollapsibleContext("Collapsible.Content");
@@ -44,7 +48,7 @@ function CollapsibleContent({ className, forceMount = false, ref, ...props }) {
44
48
  if (!forceMount && !open) {
45
49
  return null;
46
50
  }
47
- return (_jsx("div", { ...props, id: resolvedId, ref: ref, className: cn("liano-collapsible__content", className), "data-state": open ? "open" : "closed", hidden: open ? undefined : true }));
51
+ return (_jsx("div", { ...props, id: resolvedId, ref: ref, className: cn("zvk-ui-collapsible__content", className), "data-state": open ? "open" : "closed", hidden: open ? undefined : true }));
48
52
  }
49
53
  export const Collapsible = Object.assign(CollapsibleRoot, {
50
54
  Trigger: CollapsibleTrigger,
@@ -15,8 +15,8 @@ function joinIds(...ids) {
15
15
  const value = ids.filter(Boolean).join(" ");
16
16
  return value.length > 0 ? value : undefined;
17
17
  }
18
- function optionId(baseId, value) {
19
- return `${baseId}-option-${value.replace(/[^a-zA-Z0-9_-]/g, "-")}`;
18
+ function optionId(baseId, index) {
19
+ return `${baseId}-option-${index}`;
20
20
  }
21
21
  function composeRefs(...refs) {
22
22
  return (node) => {
@@ -75,6 +75,7 @@ export function Combobox({ "aria-describedby": ariaDescribedBy, className, clear
75
75
  const filteredOptions = options.filter((option) => commandItemMatches(option, query));
76
76
  const activeOption = filteredOptions.find((option) => option.value === activeValue && option.disabled !== true) ??
77
77
  firstEnabled(filteredOptions);
78
+ const activeOptionIndex = activeOption === undefined ? -1 : filteredOptions.findIndex((option) => option.value === activeOption.value);
78
79
  React.useEffect(() => {
79
80
  if (!open) {
80
81
  setQuery(selectedOption?.label ?? "");
@@ -106,7 +107,7 @@ export function Combobox({ "aria-describedby": ariaDescribedBy, className, clear
106
107
  const next = nextEnabled(filteredOptions, activeOption?.value, direction);
107
108
  setActiveValue(next?.value);
108
109
  }, [activeOption?.value, filteredOptions]);
109
- const input = (_jsx("input", { ...props, ref: composeRefs(ref, inputRef, floating.referenceRef), 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) => {
110
+ const input = (_jsx("input", { ...props, ref: composeRefs(ref, inputRef, floating.referenceRef), id: inputId, role: "combobox", "aria-activedescendant": open && activeOptionIndex >= 0 ? optionId(inputId, activeOptionIndex) : undefined, "aria-autocomplete": "list", "aria-controls": listboxId, "aria-describedby": describedBy, "aria-expanded": open ? "true" : "false", "aria-invalid": invalid ? "true" : undefined, className: cn("zvk-ui-combobox__input", className), "data-invalid": invalid ? "true" : undefined, "data-size": size, disabled: disabled, onBlur: onBlur, onChange: (event) => {
110
111
  if (!open) {
111
112
  setOpen(true);
112
113
  }
@@ -144,9 +145,9 @@ export function Combobox({ "aria-describedby": ariaDescribedBy, className, clear
144
145
  setOpen(false);
145
146
  }
146
147
  }), placeholder: placeholder, required: required, value: open ? query : selectedOption?.label ?? query }));
147
- 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, _jsxs("div", { className: "liano-combobox__control", children: [input, clearable && selectedValue !== null ? (_jsx("button", { type: "button", className: "liano-combobox__clear", "aria-label": "Clear selection", disabled: disabled, onMouseDown: (event) => event.preventDefault(), onClick: clearSelection, children: "Clear" })) : null] }), 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(Portal, { ...(container === undefined ? {} : { container }), children: _jsx(DismissableLayer, { open: open, onDismiss: () => setOpen(false), children: _jsx("div", { id: listboxId, role: "listbox", className: "liano-combobox__popup", ref: floating.floatingRef, style: floating.floatingStyle, children: filteredOptions.map((option) => {
148
+ return (_jsxs("div", { className: "zvk-ui-combobox", "data-disabled": disabled ? "true" : undefined, "data-invalid": invalid ? "true" : undefined, children: [hasLabel ? _jsx("label", { className: "zvk-ui-combobox__label", htmlFor: inputId, children: label }) : null, _jsxs("div", { className: "zvk-ui-combobox__control", children: [input, clearable && selectedValue !== null ? (_jsx("button", { type: "button", className: "zvk-ui-combobox__clear", "aria-label": "Clear selection", disabled: disabled, onMouseDown: (event) => event.preventDefault(), onClick: clearSelection, children: "Clear" })) : null] }), hasDescription ? _jsx("div", { className: "zvk-ui-combobox__description", id: descriptionId, children: description }) : null, hasError ? _jsx("div", { className: "zvk-ui-combobox__error", id: errorId, children: error }) : null, open ? (_jsx(Portal, { ...(container === undefined ? {} : { container }), children: _jsx(DismissableLayer, { open: open, onDismiss: () => setOpen(false), children: _jsx("div", { id: listboxId, role: "listbox", className: "zvk-ui-combobox__popup", ref: floating.floatingRef, style: floating.floatingStyle, children: filteredOptions.map((option, index) => {
148
149
  const isActive = activeOption?.value === option.value;
149
150
  const isSelected = selectedValue === option.value;
150
- 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));
151
+ return (_jsx("div", { id: optionId(inputId, index), role: "option", "aria-disabled": option.disabled ? "true" : undefined, "aria-selected": isSelected ? "true" : "false", className: "zvk-ui-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));
151
152
  }) }) }) })) : null] }));
152
153
  }
@@ -4,4 +4,3 @@ export interface CommandFilterItem {
4
4
  keywords?: readonly string[] | undefined;
5
5
  }
6
6
  export declare function commandItemMatches(item: CommandFilterItem, query: string): boolean;
7
- export declare function filterCommandItems<Item extends CommandFilterItem>(items: readonly Item[], query: string): Item[];
@@ -9,6 +9,3 @@ export function commandItemMatches(item, query) {
9
9
  const haystacks = [item.value, item.label, ...(item.keywords ?? [])];
10
10
  return haystacks.some((value) => normalized(value).includes(needle));
11
11
  }
12
- export function filterCommandItems(items, query) {
13
- return items.filter((item) => commandItemMatches(item, query));
14
- }
@@ -5,9 +5,11 @@ export interface CommandProps extends React.HTMLAttributes<HTMLDivElement> {
5
5
  defaultValue?: string;
6
6
  onValueChange?: (value: string) => void;
7
7
  onItemSelect?: (value: string) => void;
8
+ shouldFilter?: boolean;
8
9
  ref?: React.Ref<HTMLDivElement>;
9
10
  }
10
- export interface CommandInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange"> {
11
+ export interface CommandInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "defaultValue" | "onChange"> {
12
+ onValueChange?: (value: string) => void;
11
13
  ref?: React.Ref<HTMLInputElement>;
12
14
  }
13
15
  export interface CommandListProps extends React.HTMLAttributes<HTMLDivElement> {
@@ -24,23 +26,27 @@ export interface CommandItemProps extends Omit<React.HTMLAttributes<HTMLDivEleme
24
26
  disabled?: boolean;
25
27
  keywords?: readonly string[];
26
28
  onSelect?: (value: string) => void;
27
- value: string;
29
+ value?: string;
28
30
  ref?: React.Ref<HTMLDivElement>;
29
31
  }
30
32
  export interface CommandSeparatorProps extends React.HTMLAttributes<HTMLDivElement> {
31
33
  ref?: React.Ref<HTMLDivElement>;
32
34
  }
35
+ export interface CommandShortcutProps extends React.HTMLAttributes<HTMLSpanElement> {
36
+ ref?: React.Ref<HTMLSpanElement>;
37
+ }
33
38
  export interface CommandDialogProps extends Omit<React.ComponentProps<typeof Dialog>, "defaultValue" | "onChange"> {
34
39
  closeOnSelect?: boolean;
35
40
  commandLabel?: string;
36
41
  }
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;
42
+ declare function CommandRoot({ children, className, defaultValue, onItemSelect, onValueChange, ref, shouldFilter, value, ...props }: CommandProps): React.JSX.Element;
43
+ declare function CommandInput({ className, onKeyDown, onValueChange, placeholder, ref, value, ...props }: CommandInputProps): React.JSX.Element;
39
44
  declare function CommandList({ className, ref, ...props }: CommandListProps): React.JSX.Element;
40
45
  declare function CommandEmpty({ className, ref, ...props }: CommandEmptyProps): React.JSX.Element | null;
41
46
  declare function CommandGroup({ children, className, heading, ref, ...props }: CommandGroupProps): React.JSX.Element;
42
47
  declare function CommandItem({ children, className, disabled, keywords, onClick, onSelect, ref, value, ...props }: CommandItemProps): React.JSX.Element | null;
43
48
  declare function CommandSeparator({ className, ref, ...props }: CommandSeparatorProps): React.JSX.Element;
49
+ declare function CommandShortcut({ className, ref, ...props }: CommandShortcutProps): React.JSX.Element;
44
50
  export declare function CommandDialog({ children, className, closeOnSelect, commandLabel, onOpenChange, ...props }: CommandDialogProps): React.JSX.Element;
45
51
  type CommandComponent = typeof CommandRoot & {
46
52
  Dialog: typeof CommandDialog;
@@ -50,6 +56,7 @@ type CommandComponent = typeof CommandRoot & {
50
56
  Item: typeof CommandItem;
51
57
  List: typeof CommandList;
52
58
  Separator: typeof CommandSeparator;
59
+ Shortcut: typeof CommandShortcut;
53
60
  };
54
61
  export declare const Command: CommandComponent;
55
62
  export {};
@@ -24,7 +24,7 @@ function textFromNode(node) {
24
24
  }
25
25
  return "";
26
26
  }
27
- function CommandRoot({ children, className, defaultValue = "", onItemSelect, onValueChange, ref, value, ...props }) {
27
+ function CommandRoot({ children, className, defaultValue = "", onItemSelect, onValueChange, ref, shouldFilter = true, value, ...props }) {
28
28
  const [query, setQuery] = useControllableState({
29
29
  ...(value !== undefined ? { value } : {}),
30
30
  defaultValue,
@@ -103,12 +103,18 @@ function CommandRoot({ children, className, defaultValue = "", onItemSelect, onV
103
103
  selectActive,
104
104
  selectItem,
105
105
  setQuery,
106
+ shouldFilter,
106
107
  unregisterItem
107
- }, children: _jsx("div", { ...props, ref: ref, className: cn("liano-command", className), children: children }) }));
108
+ }, children: _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-command", className), "cmdk-root": "", children: children }) }));
108
109
  }
109
- function CommandInput({ className, onKeyDown, placeholder, ref, ...props }) {
110
+ function CommandInput({ className, onKeyDown, onValueChange, placeholder, ref, value, ...props }) {
110
111
  const { activeId, inputId, listId, moveActive, query, selectActive, setQuery } = useCommandContext("Command.Input");
111
- return (_jsx("input", { ...props, ref: ref, id: props.id ?? inputId, role: "searchbox", "aria-activedescendant": activeId, "aria-controls": listId, "aria-autocomplete": "list", className: cn("liano-command__input", className), onChange: (event) => setQuery(event.currentTarget.value), onKeyDown: composeEventHandlers(onKeyDown, (event) => {
112
+ const inputValue = value ?? query;
113
+ return (_jsx("input", { ...props, ref: ref, id: props.id ?? inputId, role: "searchbox", "aria-activedescendant": activeId, "aria-controls": listId, "aria-autocomplete": "list", className: cn("zvk-ui-command__input", className), "cmdk-input": "", onChange: (event) => {
114
+ const nextValue = event.currentTarget.value;
115
+ onValueChange?.(nextValue);
116
+ setQuery(nextValue);
117
+ }, onKeyDown: composeEventHandlers(onKeyDown, (event) => {
112
118
  if (event.key === "ArrowDown") {
113
119
  event.preventDefault();
114
120
  moveActive("next");
@@ -133,30 +139,31 @@ function CommandInput({ className, onKeyDown, placeholder, ref, ...props }) {
133
139
  event.preventDefault();
134
140
  selectActive();
135
141
  }
136
- }), placeholder: placeholder, value: query }));
142
+ }), placeholder: placeholder, value: inputValue }));
137
143
  }
138
144
  function CommandList({ className, ref, ...props }) {
139
145
  const { listId } = useCommandContext("Command.List");
140
- return _jsx("div", { ...props, ref: ref, id: props.id ?? listId, role: "listbox", className: cn("liano-command__list", className) });
146
+ return (_jsx("div", { ...props, ref: ref, id: props.id ?? listId, role: "listbox", className: cn("zvk-ui-command__list", className), "cmdk-list": "" }));
141
147
  }
142
148
  function CommandEmpty({ className, ref, ...props }) {
143
149
  const { empty } = useCommandContext("Command.Empty");
144
150
  if (!empty) {
145
151
  return null;
146
152
  }
147
- return _jsx("div", { ...props, ref: ref, className: cn("liano-command__empty", className) });
153
+ return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-command__empty", className), "cmdk-empty": "" });
148
154
  }
149
155
  function CommandGroup({ children, className, heading, ref, ...props }) {
150
156
  const headingId = React.useId();
151
- return (_jsxs("div", { ...props, ref: ref, role: "group", "aria-labelledby": heading ? headingId : undefined, className: cn("liano-command__group", className), children: [heading ? _jsx("div", { id: headingId, className: "liano-command__group-heading", children: heading }) : null, children] }));
157
+ return (_jsxs("div", { ...props, ref: ref, role: "group", "aria-labelledby": heading ? headingId : undefined, className: cn("zvk-ui-command__group", className), "cmdk-group": "", children: [heading ? _jsx("div", { id: headingId, className: "zvk-ui-command__group-heading", "cmdk-group-heading": "", children: heading }) : null, children] }));
152
158
  }
153
159
  function CommandItem({ children, className, disabled, keywords, onClick, onSelect, ref, value, ...props }) {
154
160
  const context = useCommandContext("Command.Item");
155
- const { activeId, query, registerItem, selectItem, unregisterItem } = context;
161
+ const { activeId, query, registerItem, selectItem, shouldFilter, unregisterItem } = context;
156
162
  const generatedId = React.useId();
157
163
  const id = props.id ?? generatedId;
158
- const label = textFromNode(children) || value;
159
- const visible = commandItemMatches({ label, value, keywords }, query);
164
+ const label = textFromNode(children) || (value ?? "");
165
+ const itemValue = value ?? label;
166
+ const visible = shouldFilter ? commandItemMatches({ label, value: itemValue, keywords }, query) : true;
160
167
  const isActive = activeId === id;
161
168
  React.useLayoutEffect(() => {
162
169
  registerItem(id, {
@@ -164,22 +171,25 @@ function CommandItem({ children, className, disabled, keywords, onClick, onSelec
164
171
  keywords,
165
172
  label,
166
173
  onSelect,
167
- value,
174
+ value: itemValue,
168
175
  visible
169
176
  });
170
177
  return () => unregisterItem(id);
171
- }, [disabled, id, keywords, label, onSelect, registerItem, unregisterItem, value, visible]);
178
+ }, [disabled, id, itemValue, keywords, label, onSelect, registerItem, unregisterItem, visible]);
172
179
  if (!visible) {
173
180
  return null;
174
181
  }
175
- return (_jsx("div", { ...props, ref: ref, id: id, role: "option", "aria-disabled": disabled ? "true" : undefined, "aria-selected": isActive ? "true" : "false", className: cn("liano-command__item", className), "data-disabled": disabled ? "true" : undefined, "data-highlighted": isActive ? "true" : undefined, onClick: composeEventHandlers(onClick, () => {
182
+ return (_jsx("div", { ...props, ref: ref, id: id, role: "option", "aria-disabled": disabled ? "true" : undefined, "aria-selected": isActive ? "true" : "false", className: cn("zvk-ui-command__item", className), "cmdk-item": "", "data-disabled": disabled ? "true" : undefined, "data-highlighted": isActive ? "true" : undefined, onClick: composeEventHandlers(onClick, () => {
176
183
  if (!disabled) {
177
184
  selectItem(id);
178
185
  }
179
186
  }), children: children }));
180
187
  }
181
188
  function CommandSeparator({ className, ref, ...props }) {
182
- return _jsx("div", { ...props, ref: ref, role: "separator", "aria-hidden": "true", className: cn("liano-command__separator", className) });
189
+ return (_jsx("div", { ...props, ref: ref, role: "separator", "aria-hidden": "true", className: cn("zvk-ui-command__separator", className), "cmdk-separator": "" }));
190
+ }
191
+ function CommandShortcut({ className, ref, ...props }) {
192
+ return _jsx("span", { ...props, ref: ref, className: cn("zvk-ui-command__shortcut", className) });
183
193
  }
184
194
  export function CommandDialog({ children, className, closeOnSelect = false, commandLabel = "Command menu", onOpenChange, ...props }) {
185
195
  const handleItemSelect = React.useCallback(() => {
@@ -187,7 +197,7 @@ export function CommandDialog({ children, className, closeOnSelect = false, comm
187
197
  onOpenChange?.(false);
188
198
  }
189
199
  }, [closeOnSelect, onOpenChange]);
190
- return (_jsx(Dialog, { ...props, ...(onOpenChange ? { onOpenChange } : {}), children: _jsxs(Dialog.Content, { className: cn("liano-command-dialog", className), children: [_jsx(Dialog.Title, { className: "liano-command-dialog__title", children: commandLabel }), _jsx(Command, { onItemSelect: handleItemSelect, children: children })] }) }));
200
+ return (_jsx(Dialog, { ...props, ...(onOpenChange ? { onOpenChange } : {}), children: _jsxs(Dialog.Content, { className: cn("zvk-ui-command-dialog", className), children: [_jsx(Dialog.Title, { className: "zvk-ui-command-dialog__title", children: commandLabel }), _jsx(Command, { onItemSelect: handleItemSelect, children: children })] }) }));
191
201
  }
192
202
  export const Command = Object.assign(CommandRoot, {
193
203
  Dialog: CommandDialog,
@@ -196,5 +206,6 @@ export const Command = Object.assign(CommandRoot, {
196
206
  Input: CommandInput,
197
207
  Item: CommandItem,
198
208
  List: CommandList,
199
- Separator: CommandSeparator
209
+ Separator: CommandSeparator,
210
+ Shortcut: CommandShortcut
200
211
  });
@@ -1,2 +1,2 @@
1
1
  export { Command, CommandDialog } from "./command.js";
2
- export type { CommandDialogProps, CommandEmptyProps, CommandGroupProps, CommandInputProps, CommandItemProps, CommandListProps, CommandProps, CommandSeparatorProps } from "./command.js";
2
+ export type { CommandDialogProps, CommandEmptyProps, CommandGroupProps, CommandInputProps, CommandItemProps, CommandListProps, CommandProps, CommandSeparatorProps, CommandShortcutProps } from "./command.js";
@@ -1,4 +1,5 @@
1
1
  import * as React from "react";
2
+ import type { FloatingAlign, FloatingSide } from "../../internal/floating/placement-aliases.js";
2
3
  export interface ContextMenuProps extends React.HTMLAttributes<HTMLDivElement> {
3
4
  defaultOpen?: boolean;
4
5
  onOpenChange?: (open: boolean) => void;
@@ -6,15 +7,20 @@ export interface ContextMenuProps extends React.HTMLAttributes<HTMLDivElement> {
6
7
  ref?: React.Ref<HTMLDivElement>;
7
8
  }
8
9
  export interface ContextMenuTriggerProps extends React.HTMLAttributes<HTMLSpanElement> {
9
- ref?: React.Ref<HTMLSpanElement>;
10
+ asChild?: boolean;
11
+ ref?: React.Ref<HTMLSpanElement | HTMLElement>;
10
12
  }
11
13
  export interface ContextMenuContentProps extends React.HTMLAttributes<HTMLDivElement> {
14
+ side?: FloatingSide;
15
+ align?: FloatingAlign;
16
+ alignOffset?: number;
12
17
  ref?: React.Ref<HTMLDivElement>;
13
18
  }
14
19
  export interface ContextMenuItemProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
20
+ asChild?: boolean;
15
21
  onSelect?: (event: React.SyntheticEvent<HTMLElement>) => void;
16
22
  tone?: "default" | "danger";
17
- ref?: React.Ref<HTMLButtonElement>;
23
+ ref?: React.Ref<HTMLButtonElement | HTMLElement>;
18
24
  }
19
25
  export interface ContextMenuSeparatorProps extends React.HTMLAttributes<HTMLDivElement> {
20
26
  ref?: React.Ref<HTMLDivElement>;
@@ -27,18 +33,23 @@ export interface ContextMenuCheckboxItemProps extends ContextMenuItemProps {
27
33
  defaultChecked?: boolean;
28
34
  onCheckedChange?: (checked: boolean) => void;
29
35
  }
36
+ export interface ContextMenuRadioItemProps extends ContextMenuItemProps {
37
+ checked?: boolean;
38
+ }
30
39
  declare function ContextMenuRoot({ children, className, defaultOpen, onOpenChange, open: openProp, ref, ...props }: ContextMenuProps): React.JSX.Element;
31
- declare function ContextMenuTrigger({ children, className, onContextMenu, onKeyDown, ref, ...props }: ContextMenuTriggerProps): React.JSX.Element;
32
- declare function ContextMenuContent({ children, className, onKeyDown, ref, style, ...props }: ContextMenuContentProps): React.JSX.Element | null;
33
- declare function ContextMenuItem({ children, className, disabled, onClick, onKeyDown, onSelect, ref, tone, type, ...props }: ContextMenuItemProps): React.JSX.Element;
40
+ declare function ContextMenuTrigger({ asChild, children, className, onContextMenu, onKeyDown, ref, ...props }: ContextMenuTriggerProps): React.JSX.Element;
41
+ declare function ContextMenuContent({ align, alignOffset: _alignOffset, children, className, onKeyDown, ref, side, style, ...props }: ContextMenuContentProps): React.JSX.Element | null;
42
+ declare function ContextMenuItem({ asChild, children, className, disabled, onClick, onKeyDown, onSelect, ref, tone, type, ...props }: ContextMenuItemProps): React.JSX.Element;
34
43
  declare function ContextMenuLabel({ className, ref, ...props }: ContextMenuLabelProps): React.JSX.Element;
35
- declare function ContextMenuCheckboxItem({ checked, children, className, defaultChecked, disabled, onCheckedChange, onClick, onKeyDown, onSelect, ref, tone, type, ...props }: ContextMenuCheckboxItemProps): React.JSX.Element;
44
+ declare function ContextMenuCheckboxItem({ asChild, checked, children, className, defaultChecked, disabled, onCheckedChange, onClick, onKeyDown, onSelect, ref, tone, type, ...props }: ContextMenuCheckboxItemProps): React.JSX.Element;
45
+ declare function ContextMenuRadioItem({ asChild, checked, children, className, disabled, onClick, onKeyDown, onSelect, ref, tone, type, ...props }: ContextMenuRadioItemProps): React.JSX.Element;
36
46
  declare function ContextMenuSeparator({ className, ref, ...props }: ContextMenuSeparatorProps): React.JSX.Element;
37
47
  type ContextMenuComponent = typeof ContextMenuRoot & {
38
48
  CheckboxItem: typeof ContextMenuCheckboxItem;
39
49
  Content: typeof ContextMenuContent;
40
50
  Item: typeof ContextMenuItem;
41
51
  Label: typeof ContextMenuLabel;
52
+ RadioItem: typeof ContextMenuRadioItem;
42
53
  Separator: typeof ContextMenuSeparator;
43
54
  Trigger: typeof ContextMenuTrigger;
44
55
  };