@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
@@ -6,7 +6,9 @@ import { cn } from "../../utils/cn.js";
6
6
  import { useControllableState } from "../../hooks/use-controllable-state.js";
7
7
  import { createCollection } from "../../internal/collection/index.js";
8
8
  import { DismissableLayer } from "../../internal/dismissable-layer/index.js";
9
+ import { placementFromSideAlign, placementParts } from "../../internal/floating/placement-aliases.js";
9
10
  import { Portal } from "../../internal/portal/index.js";
11
+ import { Slot } from "../../internal/slot/index.js";
10
12
  const ContextMenuContext = React.createContext(null);
11
13
  function useContextMenuContext(calledBy) {
12
14
  const context = React.useContext(ContextMenuContext);
@@ -15,6 +17,18 @@ function useContextMenuContext(calledBy) {
15
17
  }
16
18
  return context;
17
19
  }
20
+ function setComposedRef(internalRef, externalRef, node) {
21
+ internalRef.current = node;
22
+ if (typeof externalRef === "function") {
23
+ externalRef(node);
24
+ }
25
+ else if (externalRef !== undefined && externalRef !== null) {
26
+ externalRef.current = node;
27
+ }
28
+ }
29
+ function isActivationKey(key) {
30
+ return key === "Enter" || key === " " || key === "Space" || key === "Spacebar";
31
+ }
18
32
  function ContextMenuRoot({ children, className, defaultOpen = false, onOpenChange, open: openProp, ref, ...props }) {
19
33
  const [open, setOpen] = useControllableState({
20
34
  ...(openProp !== undefined ? { value: openProp } : {}),
@@ -56,21 +70,37 @@ function ContextMenuRoot({ children, className, defaultOpen = false, onOpenChang
56
70
  registerItem,
57
71
  unregisterItem
58
72
  }), [close, contentId, getItems, open, openAt, point, registerItem, unregisterItem]);
59
- return (_jsx(ContextMenuContext.Provider, { value: contextValue, children: _jsx("div", { ...props, ref: ref, className: cn("liano-context-menu", className), "data-state": open ? "open" : "closed", children: children }) }));
73
+ return (_jsx(ContextMenuContext.Provider, { value: contextValue, children: _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-context-menu", className), "data-state": open ? "open" : "closed", children: children }) }));
60
74
  }
61
- function ContextMenuTrigger({ children, className, onContextMenu, onKeyDown, ref, ...props }) {
75
+ function ContextMenuTrigger({ asChild = false, children, className, onContextMenu, onKeyDown, ref, ...props }) {
62
76
  const { contentId, open, openAt } = useContextMenuContext("ContextMenu.Trigger");
63
- return (_jsx("span", { ...props, ref: ref, "aria-controls": contentId, "aria-expanded": open ? "true" : "false", className: cn("liano-context-menu__trigger", className), "data-state": open ? "open" : "closed", onContextMenu: composeEventHandlers(onContextMenu, (event) => {
77
+ const openFromPoint = (point, restoreFocusTo) => {
78
+ openAt(point, restoreFocusTo);
79
+ };
80
+ const triggerProps = {
81
+ ...props,
82
+ ref: ref,
83
+ "aria-controls": contentId,
84
+ "aria-expanded": open,
85
+ className: cn("zvk-ui-context-menu__trigger", className),
86
+ "data-state": open ? "open" : "closed",
87
+ onContextMenu: composeEventHandlers(onContextMenu, (event) => {
64
88
  event.preventDefault();
65
- openAt({ x: event.clientX, y: event.clientY }, document.activeElement instanceof HTMLElement ? document.activeElement : event.currentTarget);
66
- }), onKeyDown: composeEventHandlers(onKeyDown, (event) => {
89
+ openFromPoint({ x: event.clientX, y: event.clientY }, document.activeElement instanceof HTMLElement ? document.activeElement : event.currentTarget);
90
+ }),
91
+ onKeyDown: composeEventHandlers(onKeyDown, (event) => {
67
92
  if ((event.shiftKey && event.key === "F10") || event.key === "ContextMenu") {
68
93
  event.preventDefault();
69
94
  const target = document.activeElement instanceof HTMLElement ? document.activeElement : event.currentTarget;
70
95
  const rect = target.getBoundingClientRect();
71
- openAt({ x: rect.left, y: rect.bottom }, target);
96
+ openFromPoint({ x: rect.left, y: rect.bottom }, target);
72
97
  }
73
- }), children: children }));
98
+ })
99
+ };
100
+ if (asChild) {
101
+ return _jsx(Slot, { ...triggerProps, children: children });
102
+ }
103
+ return (_jsx("span", { ...props, ref: ref, "aria-controls": triggerProps["aria-controls"], "aria-expanded": triggerProps["aria-expanded"], className: triggerProps.className, "data-state": triggerProps["data-state"], onContextMenu: triggerProps.onContextMenu, onKeyDown: triggerProps.onKeyDown, children: children }));
74
104
  }
75
105
  function focusItem(items, index) {
76
106
  const enabled = items.filter((item) => item.data.disabled !== true && item.data.ref !== null);
@@ -84,8 +114,10 @@ function currentIndex(items) {
84
114
  const enabled = items.filter((item) => item.data.disabled !== true && item.data.ref !== null);
85
115
  return enabled.findIndex((item) => item.data.ref === document.activeElement);
86
116
  }
87
- function ContextMenuContent({ children, className, onKeyDown, ref, style, ...props }) {
117
+ function ContextMenuContent({ align, alignOffset: _alignOffset, children, className, onKeyDown, ref, side, style, ...props }) {
88
118
  const { close, contentId, getItems, open, point } = useContextMenuContext("ContextMenu.Content");
119
+ const contentPlacement = placementFromSideAlign(side, align, "bottom-start");
120
+ const contentPlacementParts = placementParts(contentPlacement);
89
121
  React.useLayoutEffect(() => {
90
122
  if (!open) {
91
123
  return;
@@ -95,7 +127,7 @@ function ContextMenuContent({ children, className, onKeyDown, ref, style, ...pro
95
127
  if (!open) {
96
128
  return null;
97
129
  }
98
- return (_jsx(Portal, { children: _jsx(DismissableLayer, { open: open, onDismiss: close, children: _jsx("div", { ...props, ref: ref, id: contentId, role: "menu", className: cn("liano-context-menu__content", className), style: { ...style, left: `${point.x}px`, top: `${point.y}px` }, onKeyDown: composeEventHandlers(onKeyDown, (event) => {
130
+ return (_jsx(Portal, { children: _jsx(DismissableLayer, { open: open, onDismiss: close, children: _jsx("div", { ...props, ref: ref, id: contentId, role: "menu", className: cn("zvk-ui-context-menu__content", className), "data-align": contentPlacementParts.align, "data-side": contentPlacementParts.side, style: { ...style, left: `${point.x}px`, top: `${point.y}px` }, onKeyDown: composeEventHandlers(onKeyDown, (event) => {
99
131
  const items = getItems();
100
132
  const index = currentIndex(items);
101
133
  if (event.key === "ArrowDown") {
@@ -113,7 +145,7 @@ function ContextMenuContent({ children, className, onKeyDown, ref, style, ...pro
113
145
  }
114
146
  }), children: children }) }) }));
115
147
  }
116
- function ContextMenuItem({ children, className, disabled, onClick, onKeyDown, onSelect, ref, tone = "default", type = "button", ...props }) {
148
+ function ContextMenuItem({ asChild = false, children, className, disabled, onClick, onKeyDown, onSelect, ref, tone = "default", type = "button", ...props }) {
117
149
  const { close, registerItem, unregisterItem } = useContextMenuContext("ContextMenu.Item");
118
150
  const itemId = React.useId();
119
151
  const itemRef = React.useRef(null);
@@ -126,27 +158,39 @@ function ContextMenuItem({ children, className, disabled, onClick, onKeyDown, on
126
158
  return;
127
159
  }
128
160
  onSelect?.(event);
129
- close();
161
+ if (!event.defaultPrevented) {
162
+ close();
163
+ }
130
164
  };
131
- return (_jsx("button", { ...props, ref: (node) => {
132
- itemRef.current = node;
133
- if (typeof ref === "function") {
134
- ref(node);
135
- }
136
- else if (ref) {
137
- ref.current = node;
138
- }
139
- }, type: type, role: "menuitem", disabled: disabled, "aria-disabled": disabled ? "true" : undefined, className: cn("liano-context-menu__item", className), "data-disabled": disabled ? "true" : undefined, "data-tone": tone, onClick: composeEventHandlers(onClick, select), onKeyDown: composeEventHandlers(onKeyDown, (event) => {
140
- if (event.key === "Enter" || event.key === " ") {
141
- event.preventDefault();
165
+ const itemProps = {
166
+ ...props,
167
+ ref: (node) => {
168
+ setComposedRef(itemRef, ref, node);
169
+ },
170
+ role: "menuitem",
171
+ "aria-disabled": disabled ? true : undefined,
172
+ className: cn("zvk-ui-context-menu__item", className),
173
+ "data-disabled": disabled ? "true" : undefined,
174
+ "data-tone": tone,
175
+ onClick: composeEventHandlers(onClick, select),
176
+ onKeyDown: composeEventHandlers(onKeyDown, (event) => {
177
+ if (isActivationKey(event.key)) {
142
178
  select(event);
179
+ event.preventDefault();
143
180
  }
144
- }), children: children }));
181
+ })
182
+ };
183
+ if (asChild) {
184
+ return _jsx(Slot, { ...itemProps, children: children });
185
+ }
186
+ return (_jsx("button", { ...props, ref: (node) => {
187
+ setComposedRef(itemRef, ref, node);
188
+ }, type: type, role: "menuitem", disabled: disabled, "aria-disabled": itemProps["aria-disabled"], className: itemProps.className, "data-disabled": itemProps["data-disabled"], "data-tone": itemProps["data-tone"], onClick: itemProps.onClick, onKeyDown: itemProps.onKeyDown, children: children }));
145
189
  }
146
190
  function ContextMenuLabel({ className, ref, ...props }) {
147
- return _jsx("div", { ...props, ref: ref, className: cn("liano-context-menu__label", className) });
191
+ return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-context-menu__label", className) });
148
192
  }
149
- function ContextMenuCheckboxItem({ checked, children, className, defaultChecked = false, disabled, onCheckedChange, onClick, onKeyDown, onSelect, ref, tone = "default", type = "button", ...props }) {
193
+ function ContextMenuCheckboxItem({ asChild = false, checked, children, className, defaultChecked = false, disabled, onCheckedChange, onClick, onKeyDown, onSelect, ref, tone = "default", type = "button", ...props }) {
150
194
  const { close, registerItem, unregisterItem } = useContextMenuContext("ContextMenu.CheckboxItem");
151
195
  const itemId = React.useId();
152
196
  const itemRef = React.useRef(null);
@@ -163,33 +207,92 @@ function ContextMenuCheckboxItem({ checked, children, className, defaultChecked
163
207
  if (disabled) {
164
208
  return;
165
209
  }
166
- setCurrentChecked((value) => !value);
167
210
  onSelect?.(event);
168
- close();
211
+ if (!event.defaultPrevented) {
212
+ setCurrentChecked((value) => !value);
213
+ close();
214
+ }
169
215
  };
170
- return (_jsxs("button", { ...props, ref: (node) => {
171
- itemRef.current = node;
172
- if (typeof ref === "function") {
173
- ref(node);
174
- }
175
- else if (ref) {
176
- ref.current = node;
177
- }
178
- }, type: type, role: "menuitemcheckbox", disabled: disabled, "aria-checked": currentChecked ? "true" : "false", "aria-disabled": disabled ? "true" : undefined, className: cn("liano-context-menu__item", "liano-context-menu__checkbox-item", className), "data-checked": currentChecked ? "true" : undefined, "data-disabled": disabled ? "true" : undefined, "data-tone": tone, onClick: composeEventHandlers(onClick, select), onKeyDown: composeEventHandlers(onKeyDown, (event) => {
179
- if (event.key === "Enter" || event.key === " ") {
216
+ const itemProps = {
217
+ ...props,
218
+ ref: (node) => {
219
+ setComposedRef(itemRef, ref, node);
220
+ },
221
+ role: "menuitemcheckbox",
222
+ "aria-checked": currentChecked,
223
+ "aria-disabled": disabled ? true : undefined,
224
+ className: cn("zvk-ui-context-menu__item", "zvk-ui-context-menu__checkbox-item", className),
225
+ "data-checked": currentChecked ? "true" : undefined,
226
+ "data-disabled": disabled ? "true" : undefined,
227
+ "data-tone": tone,
228
+ onClick: composeEventHandlers(onClick, select),
229
+ onKeyDown: composeEventHandlers(onKeyDown, (event) => {
230
+ if (isActivationKey(event.key)) {
231
+ select(event);
180
232
  event.preventDefault();
233
+ }
234
+ })
235
+ };
236
+ if (asChild) {
237
+ return _jsx(Slot, { ...itemProps, children: children });
238
+ }
239
+ return (_jsxs("button", { ...props, ref: (node) => {
240
+ setComposedRef(itemRef, ref, node);
241
+ }, type: type, role: "menuitemcheckbox", disabled: disabled, "aria-checked": itemProps["aria-checked"], "aria-disabled": itemProps["aria-disabled"], className: itemProps.className, "data-checked": itemProps["data-checked"], "data-disabled": itemProps["data-disabled"], "data-tone": itemProps["data-tone"], onClick: itemProps.onClick, onKeyDown: itemProps.onKeyDown, children: [_jsx("span", { className: "zvk-ui-context-menu__item-indicator", "aria-hidden": "true", children: currentChecked ? "✓" : "" }), _jsx("span", { className: "zvk-ui-context-menu__item-label", children: children })] }));
242
+ }
243
+ function ContextMenuRadioItem({ asChild = false, checked = false, children, className, disabled, onClick, onKeyDown, onSelect, ref, tone = "default", type = "button", ...props }) {
244
+ const { close, registerItem, unregisterItem } = useContextMenuContext("ContextMenu.RadioItem");
245
+ const itemId = React.useId();
246
+ const itemRef = React.useRef(null);
247
+ React.useLayoutEffect(() => {
248
+ registerItem(itemId, { disabled, ref: itemRef.current });
249
+ return () => unregisterItem(itemId);
250
+ }, [disabled, itemId, registerItem, unregisterItem]);
251
+ const select = (event) => {
252
+ if (disabled) {
253
+ return;
254
+ }
255
+ onSelect?.(event);
256
+ if (!event.defaultPrevented) {
257
+ close();
258
+ }
259
+ };
260
+ const itemProps = {
261
+ ...props,
262
+ ref: (node) => {
263
+ setComposedRef(itemRef, ref, node);
264
+ },
265
+ role: "menuitemradio",
266
+ "aria-checked": checked,
267
+ "aria-disabled": disabled ? true : undefined,
268
+ className: cn("zvk-ui-context-menu__item", "zvk-ui-context-menu__radio-item", className),
269
+ "data-checked": checked ? "true" : undefined,
270
+ "data-disabled": disabled ? "true" : undefined,
271
+ "data-tone": tone,
272
+ onClick: composeEventHandlers(onClick, select),
273
+ onKeyDown: composeEventHandlers(onKeyDown, (event) => {
274
+ if (isActivationKey(event.key)) {
181
275
  select(event);
276
+ event.preventDefault();
182
277
  }
183
- }), children: [_jsx("span", { className: "liano-context-menu__item-indicator", "aria-hidden": "true", children: currentChecked ? "✓" : "" }), _jsx("span", { className: "liano-context-menu__item-label", children: children })] }));
278
+ })
279
+ };
280
+ if (asChild) {
281
+ return _jsx(Slot, { ...itemProps, children: children });
282
+ }
283
+ return (_jsxs("button", { ...props, ref: (node) => {
284
+ setComposedRef(itemRef, ref, node);
285
+ }, type: type, role: "menuitemradio", disabled: disabled, "aria-checked": itemProps["aria-checked"], "aria-disabled": itemProps["aria-disabled"], className: itemProps.className, "data-checked": itemProps["data-checked"], "data-disabled": itemProps["data-disabled"], "data-tone": itemProps["data-tone"], onClick: itemProps.onClick, onKeyDown: itemProps.onKeyDown, children: [_jsx("span", { className: "zvk-ui-context-menu__item-indicator", "aria-hidden": "true", children: checked ? "●" : "" }), _jsx("span", { className: "zvk-ui-context-menu__item-label", children: children })] }));
184
286
  }
185
287
  function ContextMenuSeparator({ className, ref, ...props }) {
186
- return _jsx("div", { ...props, ref: ref, role: "separator", "aria-hidden": "true", className: cn("liano-context-menu__separator", className) });
288
+ return _jsx("div", { ...props, ref: ref, role: "separator", "aria-hidden": "true", className: cn("zvk-ui-context-menu__separator", className) });
187
289
  }
188
290
  export const ContextMenu = Object.assign(ContextMenuRoot, {
189
291
  CheckboxItem: ContextMenuCheckboxItem,
190
292
  Content: ContextMenuContent,
191
293
  Item: ContextMenuItem,
192
294
  Label: ContextMenuLabel,
295
+ RadioItem: ContextMenuRadioItem,
193
296
  Separator: ContextMenuSeparator,
194
297
  Trigger: ContextMenuTrigger
195
298
  });
@@ -2,38 +2,38 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import { cn } from "../../utils/cn.js";
4
4
  function ConversationRoot({ className, ref, ...props }) {
5
- return _jsx("div", { ...props, ref: ref, className: cn("liano-conversation", className) });
5
+ return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-conversation", className) });
6
6
  }
7
7
  function ConversationList({ className, ref, ...props }) {
8
- return (_jsx("div", { ...props, ref: ref, "aria-label": props["aria-label"] ?? "Conversation", className: cn("liano-conversation__list", className), role: "log" }));
8
+ return (_jsx("div", { ...props, ref: ref, "aria-label": props["aria-label"] ?? "Conversation", className: cn("zvk-ui-conversation__list", className), role: "log" }));
9
9
  }
10
10
  function ConversationMessage({ className, ref, role, ...props }) {
11
- return (_jsx("div", { ...props, ref: ref, className: cn("liano-conversation__message", className), "data-role": role }));
11
+ return (_jsx("div", { ...props, ref: ref, className: cn("zvk-ui-conversation__message", className), "data-role": role }));
12
12
  }
13
13
  function ConversationMessageAvatar({ className, ref, ...props }) {
14
- return _jsx("div", { ...props, ref: ref, className: cn("liano-conversation__message-avatar", className) });
14
+ return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-conversation__message-avatar", className) });
15
15
  }
16
16
  function ConversationMessageContent({ className, ref, ...props }) {
17
- return _jsx("div", { ...props, ref: ref, className: cn("liano-conversation__message-content", className) });
17
+ return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-conversation__message-content", className) });
18
18
  }
19
19
  function ConversationResponse({ className, ref, ...props }) {
20
- return _jsx("div", { ...props, ref: ref, className: cn("liano-conversation__response", className) });
20
+ return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-conversation__response", className) });
21
21
  }
22
22
  function ConversationReasoning({ children, className, ref, title = "Reasoning", ...props }) {
23
- return (_jsxs("details", { ...props, ref: ref, className: cn("liano-conversation__reasoning", className), children: [_jsx("summary", { className: "liano-conversation__reasoning-summary", children: title }), _jsx("div", { className: "liano-conversation__reasoning-content", children: children })] }));
23
+ return (_jsxs("details", { ...props, ref: ref, className: cn("zvk-ui-conversation__reasoning", className), children: [_jsx("summary", { className: "zvk-ui-conversation__reasoning-summary", children: title }), _jsx("div", { className: "zvk-ui-conversation__reasoning-content", children: children })] }));
24
24
  }
25
25
  function ConversationTool({ children, className, ref, status = "pending", title, ...props }) {
26
- return (_jsxs("div", { ...props, ref: ref, className: cn("liano-conversation__tool", className), "data-status": status, children: [title ? _jsx("div", { className: "liano-conversation__tool-title", children: title }) : null, children ? _jsx("div", { className: "liano-conversation__tool-content", children: children }) : null] }));
26
+ return (_jsxs("div", { ...props, ref: ref, className: cn("zvk-ui-conversation__tool", className), "data-status": status, children: [title ? _jsx("div", { className: "zvk-ui-conversation__tool-title", children: title }) : null, children ? _jsx("div", { className: "zvk-ui-conversation__tool-content", children: children }) : null] }));
27
27
  }
28
28
  function ConversationPromptInput({ className, ref, ...props }) {
29
- return _jsx("form", { ...props, ref: ref, className: cn("liano-conversation__prompt-input", className) });
29
+ return _jsx("form", { ...props, ref: ref, className: cn("zvk-ui-conversation__prompt-input", className) });
30
30
  }
31
31
  function ConversationPromptInputTextarea({ className, ref, rows = 3, ...props }) {
32
- return (_jsx("textarea", { ...props, ref: ref, className: cn("liano-conversation__prompt-textarea", className), rows: rows }));
32
+ return (_jsx("textarea", { ...props, ref: ref, className: cn("zvk-ui-conversation__prompt-textarea", className), rows: rows }));
33
33
  }
34
34
  function ConversationPromptInputSubmit({ className, disabled, loading = false, ref, type = "submit", ...props }) {
35
35
  const isDisabled = disabled || loading;
36
- return (_jsx("button", { ...props, ref: ref, "aria-busy": loading ? true : undefined, className: cn("liano-conversation__prompt-submit", className), "data-disabled": isDisabled ? "true" : undefined, "data-loading": loading ? "true" : undefined, disabled: isDisabled, type: type }));
36
+ return (_jsx("button", { ...props, ref: ref, "aria-busy": loading ? true : undefined, className: cn("zvk-ui-conversation__prompt-submit", className), "data-disabled": isDisabled ? "true" : undefined, "data-loading": loading ? "true" : undefined, disabled: isDisabled, type: type }));
37
37
  }
38
38
  export const Conversation = Object.assign(ConversationRoot, {
39
39
  List: ConversationList,
@@ -43,8 +43,8 @@ export function CopyButton({ className, copiedLabel = "Copied", disabled, errorL
43
43
  }
44
44
  }
45
45
  const label = status === "copied" ? copiedLabel : status === "error" ? errorLabel : idleLabel;
46
- return (_jsx("button", { ...props, ref: ref, className: cn("liano-copy-button", className), "data-size": size, "data-status": status, disabled: disabled, onClick: handleClick, type: type, children: label }));
46
+ return (_jsx("button", { ...props, ref: ref, className: cn("zvk-ui-copy-button", className), "data-size": size, "data-status": status, disabled: disabled, onClick: handleClick, type: type, children: label }));
47
47
  }
48
48
  export function CopyableText({ className, copyLabel, label, ref, truncate, value, ...props }) {
49
- return (_jsxs("div", { ...props, ref: ref, className: cn("liano-copyable-text", className), children: [label ? _jsx("span", { className: "liano-copyable-text__label", children: label }) : null, _jsx("code", { className: "liano-copyable-text__value", "data-truncate": truncate ? "true" : undefined, children: value }), _jsx(CopyButton, { idleLabel: copyLabel ?? "Copy", value: value })] }));
49
+ return (_jsxs("div", { ...props, ref: ref, className: cn("zvk-ui-copyable-text", className), children: [label ? _jsx("span", { className: "zvk-ui-copyable-text__label", children: label }) : null, _jsx("code", { className: "zvk-ui-copyable-text__value", "data-truncate": truncate ? "true" : undefined, children: value }), _jsx(CopyButton, { idleLabel: copyLabel ?? "Copy", value: value })] }));
50
50
  }
@@ -46,5 +46,5 @@ export function DatePicker({ defaultValue = null, description, disabledDate, err
46
46
  onValueChange?.(date);
47
47
  setOpen(false);
48
48
  };
49
- return (_jsxs(Field, { className: "liano-date-picker", invalid: hasError, ...fieldRefProps, children: [hasLabel ? _jsx(Field.Label, { htmlFor: triggerId, children: label }) : null, _jsxs(Popover, { open: open, onOpenChange: setOpen, placement: "bottom-start", children: [_jsx(Popover.Trigger, { "aria-describedby": describedBy, "aria-invalid": hasError ? true : undefined, "aria-label": hasLabel ? undefined : "Selected date", className: cn("liano-date-picker__trigger", !currentValue && "liano-date-picker__trigger--placeholder"), id: triggerId, children: _jsx("span", { className: "liano-date-picker__value", children: currentValue ? formatDate(currentValue) : placeholder }) }), _jsx(Popover.Content, { className: "liano-date-picker__content", matchTriggerWidth: false, sideOffset: 4, children: _jsx(Calendar, { ...calendarProps, selected: currentValue, onSelect: handleSelect }) })] }), hasRenderableNode(description) ? _jsx(Field.Description, { id: descriptionId, children: description }) : null, hasError ? _jsx(Field.Error, { id: errorId, children: error }) : null] }));
49
+ return (_jsxs(Field, { className: "zvk-ui-date-picker", invalid: hasError, ...fieldRefProps, children: [hasLabel ? _jsx(Field.Label, { htmlFor: triggerId, children: label }) : null, _jsxs(Popover, { open: open, onOpenChange: setOpen, placement: "bottom-start", children: [_jsx(Popover.Trigger, { "aria-describedby": describedBy, "aria-invalid": hasError ? true : undefined, "aria-label": hasLabel ? undefined : "Selected date", className: cn("zvk-ui-date-picker__trigger", !currentValue && "zvk-ui-date-picker__trigger--placeholder"), id: triggerId, children: _jsx("span", { className: "zvk-ui-date-picker__value", children: currentValue ? formatDate(currentValue) : placeholder }) }), _jsx(Popover.Content, { className: "zvk-ui-date-picker__content", matchTriggerWidth: false, sideOffset: 4, children: _jsx(Calendar, { ...calendarProps, selected: currentValue, onSelect: handleSelect }) })] }), hasRenderableNode(description) ? _jsx(Field.Description, { id: descriptionId, children: description }) : null, hasError ? _jsx(Field.Error, { id: errorId, children: error }) : null] }));
50
50
  }
@@ -10,7 +10,8 @@ export interface DialogProps extends React.HTMLAttributes<HTMLDivElement> {
10
10
  ref?: React.Ref<HTMLDivElement>;
11
11
  }
12
12
  export interface DialogTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
13
- ref?: React.Ref<HTMLButtonElement>;
13
+ asChild?: boolean;
14
+ ref?: React.Ref<HTMLButtonElement | HTMLElement>;
14
15
  }
15
16
  export interface DialogContentProps extends React.HTMLAttributes<HTMLDivElement> {
16
17
  forceMount?: boolean;
@@ -32,7 +33,8 @@ export interface DialogOverlayProps extends React.HTMLAttributes<HTMLDivElement>
32
33
  ref?: React.Ref<HTMLDivElement>;
33
34
  }
34
35
  export interface DialogCloseProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
35
- ref?: React.Ref<HTMLButtonElement>;
36
+ asChild?: boolean;
37
+ ref?: React.Ref<HTMLButtonElement | HTMLElement>;
36
38
  }
37
39
  interface DialogPortalProps {
38
40
  children: React.ReactNode;
@@ -46,8 +48,8 @@ declare function DialogHeader({ className, ref, ...props }: DialogHeaderProps):
46
48
  declare function DialogTitle({ className, ref, ...props }: DialogTitleProps): React.JSX.Element;
47
49
  declare function DialogDescription({ className, ref, ...props }: DialogDescriptionProps): React.JSX.Element;
48
50
  declare function DialogFooter({ className, ref, ...props }: DialogFooterProps): React.JSX.Element;
49
- declare function DialogTrigger({ className, disabled, onClick, ref, type, ...props }: DialogTriggerProps): React.JSX.Element;
50
- declare function DialogClose({ className, onClick, ref, type, ...props }: DialogCloseProps): React.JSX.Element;
51
+ declare function DialogTrigger({ asChild, className, disabled, onClick, ref, type, ...props }: DialogTriggerProps): React.JSX.Element;
52
+ declare function DialogClose({ asChild, className, disabled, onClick, ref, type, ...props }: DialogCloseProps): React.JSX.Element;
51
53
  type DialogComponent = typeof DialogRoot & {
52
54
  Close: typeof DialogClose;
53
55
  Content: typeof DialogContent;
@@ -8,6 +8,7 @@ import { DismissableLayer } from "../../internal/dismissable-layer/dismissable-l
8
8
  import { FocusScope } from "../../internal/focus/focus-scope.js";
9
9
  import { lockScroll, unlockScroll } from "../../internal/scroll-lock/scroll-lock.js";
10
10
  import { Portal } from "../../internal/portal/index.js";
11
+ import { Slot } from "../../internal/slot/index.js";
11
12
  const DialogContext = React.createContext(null);
12
13
  function useDialogContext(calledBy) {
13
14
  const context = React.useContext(DialogContext);
@@ -76,7 +77,7 @@ function DialogRoot({ children, className, container, defaultOpen = false, disab
76
77
  triggerRef,
77
78
  disableOutsidePointerDown,
78
79
  disableEscapeKeyDown
79
- }, children: _jsx("div", { ...props, ref: ref, className: cn("liano-dialog", className), "data-state": open ? "open" : "closed", children: children }) }));
80
+ }, children: _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-dialog", className), "data-state": open ? "open" : "closed", children: children }) }));
80
81
  }
81
82
  function DialogPortal({ container, children }) {
82
83
  if (container === undefined) {
@@ -85,38 +86,38 @@ function DialogPortal({ container, children }) {
85
86
  return _jsx(Portal, { container: container, children: children });
86
87
  }
87
88
  function DialogOverlay({ className, ref, ...props }) {
88
- return _jsx("div", { ...props, ref: ref, className: cn("liano-dialog__overlay", className) });
89
+ return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-dialog__overlay", className) });
89
90
  }
90
91
  function DialogContent({ className, children, forceMount = false, ref, ...props }) {
91
92
  const { close, container, contentId, describedBy, disableEscapeKeyDown, disableOutsidePointerDown, labelledBy, open } = useDialogContext("Dialog.Content");
92
93
  if (!open && !forceMount) {
93
94
  return null;
94
95
  }
95
- const content = (_jsx("div", { ...props, ref: ref, id: contentId, role: "dialog", "aria-modal": true, "aria-labelledby": labelledBy, "aria-describedby": describedBy, className: cn("liano-dialog__content", className), "data-state": open ? "open" : "closed", hidden: open ? undefined : true, children: children }));
96
+ const content = (_jsx("div", { ...props, ref: ref, id: contentId, role: "dialog", "aria-modal": true, "aria-labelledby": labelledBy, "aria-describedby": describedBy, className: cn("zvk-ui-dialog__content", className), "data-state": open ? "open" : "closed", hidden: open ? undefined : true, children: children }));
96
97
  if (!open) {
97
98
  return (_jsxs(DialogPortal, { container: container, children: [_jsx(DialogOverlay, { "aria-hidden": true, hidden: true }), content] }));
98
99
  }
99
100
  return (_jsxs(DialogPortal, { container: container, children: [_jsx(DialogOverlay, { "aria-hidden": true }), _jsx(DismissableLayer, { open: open, disableEscapeKeyDown: disableEscapeKeyDown, disableOutsidePointerDown: disableOutsidePointerDown, onDismiss: close, children: _jsx(FocusScope, { trapped: true, active: open, children: content }) })] }));
100
101
  }
101
102
  function DialogHeader({ className, ref, ...props }) {
102
- return _jsx("div", { ...props, ref: ref, className: cn("liano-dialog__header", className) });
103
+ return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-dialog__header", className) });
103
104
  }
104
105
  function DialogTitle({ className, ref, ...props }) {
105
106
  const { registerTitle, titleId } = useDialogContext("Dialog.Title");
106
107
  const resolvedId = props.id ?? titleId;
107
108
  React.useLayoutEffect(() => registerTitle(resolvedId), [registerTitle, resolvedId]);
108
- return _jsx("h2", { ...props, ref: ref, id: resolvedId, className: cn("liano-dialog__title", className) });
109
+ return _jsx("h2", { ...props, ref: ref, id: resolvedId, className: cn("zvk-ui-dialog__title", className) });
109
110
  }
110
111
  function DialogDescription({ className, ref, ...props }) {
111
112
  const { descriptionId, registerDescription } = useDialogContext("Dialog.Description");
112
113
  const resolvedId = props.id ?? descriptionId;
113
114
  React.useLayoutEffect(() => registerDescription(resolvedId), [registerDescription, resolvedId]);
114
- return (_jsx("p", { ...props, ref: ref, id: resolvedId, className: cn("liano-dialog__description", className) }));
115
+ return (_jsx("p", { ...props, ref: ref, id: resolvedId, className: cn("zvk-ui-dialog__description", className) }));
115
116
  }
116
117
  function DialogFooter({ className, ref, ...props }) {
117
- return _jsx("div", { ...props, ref: ref, className: cn("liano-dialog__footer", className) });
118
+ return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-dialog__footer", className) });
118
119
  }
119
- function DialogTrigger({ className, disabled, onClick, ref, type = "button", ...props }) {
120
+ function DialogTrigger({ asChild = false, className, disabled, onClick, ref, type = "button", ...props }) {
120
121
  const { open, setOpen, contentId, triggerRef } = useDialogContext("Dialog.Trigger");
121
122
  const handleClick = () => {
122
123
  if (disabled) {
@@ -124,13 +125,22 @@ function DialogTrigger({ className, disabled, onClick, ref, type = "button", ...
124
125
  }
125
126
  setOpen(true);
126
127
  };
127
- return (_jsx("button", { ...props, ref: composeRefs(ref, triggerRef), type: type, disabled: disabled, "aria-controls": contentId, "aria-expanded": open ? "true" : "false", "data-state": open ? "open" : "closed", className: cn("liano-dialog__trigger", className), onClick: composeEventHandlers(onClick, handleClick) }));
128
+ if (asChild) {
129
+ return (_jsx(Slot, { ...props, ref: composeRefs(ref, triggerRef), "aria-controls": contentId, "aria-disabled": disabled ? true : undefined, "aria-expanded": open ? "true" : "false", className: cn("zvk-ui-dialog__trigger", className), "data-disabled": disabled ? "true" : undefined, "data-state": open ? "open" : "closed", onClick: composeEventHandlers(onClick, handleClick), children: props.children }));
130
+ }
131
+ return (_jsx("button", { ...props, ref: composeRefs(ref, triggerRef), type: type, disabled: disabled, "aria-controls": contentId, "aria-expanded": open ? "true" : "false", "data-state": open ? "open" : "closed", className: cn("zvk-ui-dialog__trigger", className), onClick: composeEventHandlers(onClick, handleClick) }));
128
132
  }
129
- function DialogClose({ className, onClick, ref, type = "button", ...props }) {
133
+ function DialogClose({ asChild = false, className, disabled, onClick, ref, type = "button", ...props }) {
130
134
  const { close } = useDialogContext("Dialog.Close");
131
- return (_jsx("button", { ...props, ref: ref, type: type, className: cn("liano-dialog__close", className), onClick: composeEventHandlers(onClick, () => {
135
+ const handleClick = () => {
136
+ if (!disabled) {
132
137
  close();
133
- }) }));
138
+ }
139
+ };
140
+ if (asChild) {
141
+ return (_jsx(Slot, { ...props, ref: ref, "aria-disabled": disabled ? true : undefined, className: cn("zvk-ui-dialog__close", className), "data-disabled": disabled ? "true" : undefined, onClick: composeEventHandlers(onClick, handleClick), children: props.children }));
142
+ }
143
+ return (_jsx("button", { ...props, ref: ref, type: type, disabled: disabled, className: cn("zvk-ui-dialog__close", className), onClick: composeEventHandlers(onClick, handleClick) }));
134
144
  }
135
145
  export const Dialog = Object.assign(DialogRoot, {
136
146
  Close: DialogClose,
@@ -1,6 +1,7 @@
1
1
  import * as React from "react";
2
2
  import type { PortalProps } from "../../internal/portal/index.js";
3
3
  import type { FloatingPlacement } from "../../internal/floating/floating-types.js";
4
+ import type { FloatingAlign, FloatingSide } from "../../internal/floating/placement-aliases.js";
4
5
  export interface DropdownMenuProps extends React.HTMLAttributes<HTMLDivElement> {
5
6
  container?: PortalProps["container"];
6
7
  open?: boolean;
@@ -12,9 +13,13 @@ export interface DropdownMenuProps extends React.HTMLAttributes<HTMLDivElement>
12
13
  matchTriggerWidth?: boolean;
13
14
  }
14
15
  export interface DropdownMenuTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
15
- ref?: React.Ref<HTMLButtonElement>;
16
+ asChild?: boolean;
17
+ ref?: React.Ref<HTMLButtonElement | HTMLElement>;
16
18
  }
17
19
  export interface DropdownMenuContentProps extends React.HTMLAttributes<HTMLDivElement> {
20
+ side?: FloatingSide;
21
+ align?: FloatingAlign;
22
+ alignOffset?: number;
18
23
  sideOffset?: number;
19
24
  collisionPadding?: number;
20
25
  matchTriggerWidth?: boolean;
@@ -22,8 +27,9 @@ export interface DropdownMenuContentProps extends React.HTMLAttributes<HTMLDivEl
22
27
  ref?: React.Ref<HTMLDivElement>;
23
28
  }
24
29
  export interface DropdownMenuItemProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
30
+ asChild?: boolean;
25
31
  onSelect?: (event: React.SyntheticEvent<HTMLElement>) => void;
26
- ref?: React.Ref<HTMLButtonElement>;
32
+ ref?: React.Ref<HTMLButtonElement | HTMLElement>;
27
33
  }
28
34
  export interface DropdownMenuSeparatorProps extends React.HTMLAttributes<HTMLDivElement> {
29
35
  ref?: React.Ref<HTMLDivElement>;
@@ -51,15 +57,15 @@ export interface DropdownMenuSubProps extends React.HTMLAttributes<HTMLDivElemen
51
57
  ref?: React.Ref<HTMLDivElement>;
52
58
  }
53
59
  declare function DropdownMenuRoot({ children, className, container, defaultOpen, onOpenChange, open: openProp, placement, sideOffset, collisionPadding, matchTriggerWidth, ...props }: DropdownMenuProps): React.JSX.Element;
54
- declare function DropdownMenuTrigger({ className, disabled, onClick, ref, type, ...props }: DropdownMenuTriggerProps): React.JSX.Element;
55
- declare function DropdownMenuContent({ children, className, forceMount, sideOffset, collisionPadding, matchTriggerWidth, ref, onKeyDown, ...props }: DropdownMenuContentProps): React.JSX.Element | null;
56
- declare function DropdownMenuItem({ children, className, disabled, onClick, onSelect, onKeyDown, ref, ...props }: DropdownMenuItemProps): React.JSX.Element;
60
+ declare function DropdownMenuTrigger({ asChild, className, disabled, onClick, ref, type, ...props }: DropdownMenuTriggerProps): React.JSX.Element;
61
+ declare function DropdownMenuContent({ align, alignOffset, children, className, forceMount, side, sideOffset, collisionPadding, matchTriggerWidth, ref, onKeyDown, ...props }: DropdownMenuContentProps): React.JSX.Element | null;
62
+ declare function DropdownMenuItem({ asChild, children, className, disabled, onClick, onSelect, onKeyDown, ref, ...props }: DropdownMenuItemProps): React.JSX.Element;
57
63
  declare function DropdownMenuSeparator({ className, ref, ...props }: DropdownMenuSeparatorProps): React.JSX.Element;
58
64
  declare function DropdownMenuLabel({ className, ref, ...props }: DropdownMenuLabelProps): React.JSX.Element;
59
65
  declare function DropdownMenuShortcut({ className, ref, ...props }: DropdownMenuShortcutProps): React.JSX.Element;
60
- declare function DropdownMenuCheckboxItem({ checked, children, className, defaultChecked, disabled, onCheckedChange, onClick, onKeyDown, onSelect, ref, ...props }: DropdownMenuCheckboxItemProps): React.JSX.Element;
66
+ declare function DropdownMenuCheckboxItem({ asChild, checked, children, className, defaultChecked, disabled, onCheckedChange, onClick, onKeyDown, onSelect, ref, ...props }: DropdownMenuCheckboxItemProps): React.JSX.Element;
61
67
  declare function DropdownMenuRadioGroup({ children, className, onValueChange, ref, value, ...props }: DropdownMenuRadioGroupProps): React.JSX.Element;
62
- declare function DropdownMenuRadioItem({ children, className, disabled, onClick, onKeyDown, onSelect, ref, value, ...props }: DropdownMenuRadioItemProps): React.JSX.Element;
68
+ declare function DropdownMenuRadioItem({ asChild, children, className, disabled, onClick, onKeyDown, onSelect, ref, value, ...props }: DropdownMenuRadioItemProps): React.JSX.Element;
63
69
  declare function DropdownMenuSub({ children, className, ref, ...props }: DropdownMenuSubProps): React.JSX.Element;
64
70
  type DropdownMenuComponent = typeof DropdownMenuRoot & {
65
71
  CheckboxItem: typeof DropdownMenuCheckboxItem;