@zvk/ui 0.1.2 → 0.1.5

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 (53) hide show
  1. package/dist/components/alert-dialog/alert-dialog.d.ts +8 -5
  2. package/dist/components/alert-dialog/alert-dialog.js +21 -8
  3. package/dist/components/button/button.d.ts +3 -2
  4. package/dist/components/button/button.js +5 -1
  5. package/dist/components/calendar/calendar.d.ts +51 -0
  6. package/dist/components/calendar/calendar.js +190 -0
  7. package/dist/components/calendar/index.d.ts +2 -0
  8. package/dist/components/calendar/index.js +2 -0
  9. package/dist/components/carousel/carousel.d.ts +51 -0
  10. package/dist/components/carousel/carousel.js +210 -0
  11. package/dist/components/carousel/index.d.ts +2 -0
  12. package/dist/components/carousel/index.js +2 -0
  13. package/dist/components/collapsible/collapsible.d.ts +3 -2
  14. package/dist/components/collapsible/collapsible.js +5 -1
  15. package/dist/components/command/command.d.ts +11 -4
  16. package/dist/components/command/command.js +27 -16
  17. package/dist/components/command/index.d.ts +1 -1
  18. package/dist/components/context-menu/context-menu.d.ts +17 -6
  19. package/dist/components/context-menu/context-menu.js +139 -36
  20. package/dist/components/date-picker/date-picker.d.ts +16 -0
  21. package/dist/components/date-picker/date-picker.js +50 -0
  22. package/dist/components/date-picker/index.d.ts +2 -0
  23. package/dist/components/date-picker/index.js +2 -0
  24. package/dist/components/dialog/dialog.d.ts +6 -4
  25. package/dist/components/dialog/dialog.js +14 -4
  26. package/dist/components/dropdown-menu/dropdown-menu.d.ts +13 -7
  27. package/dist/components/dropdown-menu/dropdown-menu.js +127 -72
  28. package/dist/components/hover-card/hover-card.d.ts +37 -0
  29. package/dist/components/hover-card/hover-card.js +271 -0
  30. package/dist/components/hover-card/index.d.ts +2 -0
  31. package/dist/components/hover-card/index.js +2 -0
  32. package/dist/components/index.d.ts +14 -6
  33. package/dist/components/index.js +5 -1
  34. package/dist/components/menubar/menubar.d.ts +24 -5
  35. package/dist/components/menubar/menubar.js +182 -33
  36. package/dist/components/popover/popover.d.ts +9 -3
  37. package/dist/components/popover/popover.js +15 -5
  38. package/dist/components/sheet/sheet.d.ts +6 -4
  39. package/dist/components/sheet/sheet.js +21 -8
  40. package/dist/components/toast/index.d.ts +2 -2
  41. package/dist/components/toast/index.js +2 -1
  42. package/dist/components/toast/toast.d.ts +40 -0
  43. package/dist/components/toast/toast.js +144 -2
  44. package/dist/components/tooltip/tooltip.d.ts +8 -2
  45. package/dist/components/tooltip/tooltip.js +8 -5
  46. package/dist/internal/floating/placement-aliases.d.ts +7 -0
  47. package/dist/internal/floating/placement-aliases.js +13 -0
  48. package/dist/internal/slot/index.d.ts +2 -0
  49. package/dist/internal/slot/index.js +1 -0
  50. package/dist/internal/slot/slot.d.ts +6 -0
  51. package/dist/internal/slot/slot.js +53 -0
  52. package/dist/styles.css +356 -4
  53. package/package.json +18 -2
@@ -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);
@@ -116,7 +117,7 @@ function DialogDescription({ className, ref, ...props }) {
116
117
  function DialogFooter({ className, ref, ...props }) {
117
118
  return _jsx("div", { ...props, ref: ref, className: cn("liano-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
  };
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("liano-dialog__trigger", className), "data-disabled": disabled ? "true" : undefined, "data-state": open ? "open" : "closed", onClick: composeEventHandlers(onClick, handleClick), children: props.children }));
130
+ }
127
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("liano-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("liano-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("liano-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: _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;
@@ -7,6 +7,8 @@ import { useControllableState } from "../../hooks/use-controllable-state.js";
7
7
  import { Portal } from "../../internal/portal/index.js";
8
8
  import { DismissableLayer } from "../../internal/dismissable-layer/dismissable-layer.js";
9
9
  import { useFloatingPosition } from "../../internal/floating/index.js";
10
+ import { placementFromSideAlign, placementParts } from "../../internal/floating/placement-aliases.js";
11
+ import { Slot } from "../../internal/slot/index.js";
10
12
  const defaultContentPositioning = {
11
13
  sideOffset: 8,
12
14
  collisionPadding: 0,
@@ -35,6 +37,18 @@ function composeRefs(...refs) {
35
37
  function filterEnabledItems(items) {
36
38
  return items.filter((item) => !item.disabled && item.ref !== null);
37
39
  }
40
+ function setComposedRef(internalRef, externalRef, node) {
41
+ internalRef.current = node;
42
+ if (typeof externalRef === "function") {
43
+ externalRef(node);
44
+ }
45
+ else if (externalRef !== undefined && externalRef !== null) {
46
+ externalRef.current = node;
47
+ }
48
+ }
49
+ function isActivationKey(key) {
50
+ return key === " " || key === "Space" || key === "Enter" || key === "Spacebar";
51
+ }
38
52
  const DropdownMenuRadioGroupContext = React.createContext(null);
39
53
  function DropdownMenuRoot({ children, className, container, defaultOpen = false, onOpenChange, open: openProp, placement = "bottom", sideOffset = 8, collisionPadding = 0, matchTriggerWidth = false, ...props }) {
40
54
  const [open, setOpen] = useControllableState({
@@ -56,7 +70,7 @@ function DropdownMenuRoot({ children, className, container, defaultOpen = false,
56
70
  });
57
71
  const floating = useFloatingPosition({
58
72
  open,
59
- placement,
73
+ placement: contentPositioning.placement ?? placement,
60
74
  strategy: "absolute",
61
75
  offset: contentPositioning.sideOffset,
62
76
  collisionPadding: contentPositioning.collisionPadding,
@@ -116,6 +130,7 @@ function DropdownMenuRoot({ children, className, container, defaultOpen = false,
116
130
  triggerRef,
117
131
  referenceRef: floating.referenceRef,
118
132
  floatingRef: floating.floatingRef,
133
+ floatingPlacement: floating.placement,
119
134
  floatingStyle: floating.floatingStyle,
120
135
  getEnabledItems,
121
136
  registerItem,
@@ -123,25 +138,29 @@ function DropdownMenuRoot({ children, className, container, defaultOpen = false,
123
138
  ...(container === undefined ? {} : { container })
124
139
  }, children: _jsx("div", { ...props, className: cn("liano-dropdown-menu", className), "data-state": open ? "open" : "closed", children: children }) }));
125
140
  }
126
- function DropdownMenuTrigger({ className, disabled, onClick, ref, type = "button", ...props }) {
141
+ function DropdownMenuTrigger({ asChild = false, className, disabled, onClick, ref, type = "button", ...props }) {
127
142
  const { contentId, open, setOpen, triggerRef, triggerId, referenceRef, getEnabledItems } = useDropdownMenuContext("DropdownMenu.Trigger");
128
- return (_jsx("button", { ...props, ref: composeRefs(ref, triggerRef, referenceRef), type: type, disabled: disabled, id: triggerId, role: "button", "aria-haspopup": "menu", "aria-expanded": open ? "true" : "false", "aria-controls": contentId, className: cn("liano-dropdown-menu__trigger", className), onClick: composeEventHandlers(onClick, () => {
129
- if (disabled) {
130
- return;
131
- }
132
- const nextOpen = !open;
133
- setOpen(nextOpen);
134
- if (!nextOpen) {
135
- return;
136
- }
137
- queueMicrotask(() => {
138
- const first = getEnabledItems()[0];
139
- first?.ref?.focus();
140
- });
141
- }) }));
143
+ const handleClick = () => {
144
+ if (disabled) {
145
+ return;
146
+ }
147
+ const nextOpen = !open;
148
+ setOpen(nextOpen);
149
+ if (!nextOpen) {
150
+ return;
151
+ }
152
+ queueMicrotask(() => {
153
+ const first = getEnabledItems()[0];
154
+ first?.ref?.focus();
155
+ });
156
+ };
157
+ if (asChild) {
158
+ return (_jsx(Slot, { ...props, ref: composeRefs(ref, triggerRef, referenceRef), id: triggerId, "aria-controls": contentId, "aria-disabled": disabled ? true : undefined, "aria-expanded": open ? "true" : "false", "aria-haspopup": "menu", className: cn("liano-dropdown-menu__trigger", className), "data-disabled": disabled ? "true" : undefined, "data-state": open ? "open" : "closed", onClick: composeEventHandlers(onClick, handleClick), children: props.children }));
159
+ }
160
+ return (_jsx("button", { ...props, ref: composeRefs(ref, triggerRef, referenceRef), type: type, disabled: disabled, id: triggerId, role: "button", "aria-haspopup": "menu", "aria-expanded": open ? "true" : "false", "aria-controls": contentId, className: cn("liano-dropdown-menu__trigger", className), "data-state": open ? "open" : "closed", onClick: composeEventHandlers(onClick, handleClick) }));
142
161
  }
143
- function DropdownMenuContent({ children, className, forceMount = false, sideOffset = defaultContentPositioning.sideOffset, collisionPadding = defaultContentPositioning.collisionPadding, matchTriggerWidth = defaultContentPositioning.matchTriggerWidth, ref, onKeyDown, ...props }) {
144
- const { container, contentId, open, setOpen, updateContentPositioning, triggerId, floatingRef, floatingStyle, getEnabledItems } = useDropdownMenuContext("DropdownMenu.Content");
162
+ function DropdownMenuContent({ align, alignOffset: _alignOffset, children, className, forceMount = false, side, sideOffset = defaultContentPositioning.sideOffset, collisionPadding = defaultContentPositioning.collisionPadding, matchTriggerWidth = defaultContentPositioning.matchTriggerWidth, ref, onKeyDown, ...props }) {
163
+ const { container, contentId, open, setOpen, updateContentPositioning, triggerId, floatingRef, floatingPlacement, floatingStyle, getEnabledItems } = useDropdownMenuContext("DropdownMenu.Content");
145
164
  const focusItem = React.useCallback((index, items) => {
146
165
  if (items.length === 0) {
147
166
  return;
@@ -181,6 +200,7 @@ function DropdownMenuContent({ children, className, forceMount = false, sideOffs
181
200
  }, [getEnabledItems]);
182
201
  React.useEffect(() => {
183
202
  updateContentPositioning({
203
+ ...(side === undefined ? {} : { placement: placementFromSideAlign(side, align, "bottom") }),
184
204
  sideOffset,
185
205
  collisionPadding,
186
206
  matchTriggerWidth
@@ -188,7 +208,7 @@ function DropdownMenuContent({ children, className, forceMount = false, sideOffs
188
208
  return () => {
189
209
  updateContentPositioning(defaultContentPositioning);
190
210
  };
191
- }, [collisionPadding, matchTriggerWidth, sideOffset, updateContentPositioning]);
211
+ }, [align, collisionPadding, matchTriggerWidth, side, sideOffset, updateContentPositioning]);
192
212
  if (!open && !forceMount) {
193
213
  return null;
194
214
  }
@@ -200,7 +220,7 @@ function DropdownMenuContent({ children, className, forceMount = false, sideOffs
200
220
  else if (ref) {
201
221
  ref.current = node;
202
222
  }
203
- }, id: contentId, role: "menu", "aria-labelledby": triggerId, className: cn("liano-dropdown-menu__content", className), style: floatingStyle, "data-state": open ? "open" : "closed", hidden: open ? undefined : true, onKeyDown: composeEventHandlers(onKeyDown, (event) => {
223
+ }, id: contentId, role: "menu", "aria-labelledby": triggerId, className: cn("liano-dropdown-menu__content", className), style: floatingStyle, "data-align": placementParts(floatingPlacement).align, "data-side": placementParts(floatingPlacement).side, "data-state": open ? "open" : "closed", hidden: open ? undefined : true, onKeyDown: composeEventHandlers(onKeyDown, (event) => {
204
224
  if (event.key === "ArrowDown") {
205
225
  event.preventDefault();
206
226
  moveFocus("next");
@@ -236,7 +256,7 @@ function DropdownMenuContent({ children, className, forceMount = false, sideOffs
236
256
  setOpen(false);
237
257
  }, children: content }) }));
238
258
  }
239
- function DropdownMenuItem({ children, className, disabled, onClick, onSelect, onKeyDown, ref, ...props }) {
259
+ function DropdownMenuItem({ asChild = false, children, className, disabled, onClick, onSelect, onKeyDown, ref, ...props }) {
240
260
  const context = useDropdownMenuContext("DropdownMenu.Item");
241
261
  const itemRef = React.useRef(null);
242
262
  const itemId = React.useId();
@@ -251,30 +271,39 @@ function DropdownMenuItem({ children, className, disabled, onClick, onSelect, on
251
271
  context.registerItem(itemRecord);
252
272
  return () => context.unregisterItem(itemId);
253
273
  }, [context, isDisabled, itemId, onSelect]);
254
- return (_jsx("button", { ...props, ref: (node) => {
255
- itemRef.current = node;
256
- if (typeof ref === "function") {
257
- ref(node);
258
- }
259
- else if (ref) {
260
- ref.current = node;
261
- }
262
- }, type: "button", role: "menuitem", disabled: isDisabled, "aria-disabled": isDisabled ? "true" : undefined, className: cn("liano-dropdown-menu__item", className), "data-state": isDisabled ? "disabled" : "enabled", onClick: composeEventHandlers(onClick, (event) => {
263
- if (isDisabled) {
264
- return;
265
- }
266
- onSelect?.(event);
274
+ const select = (event) => {
275
+ if (isDisabled) {
276
+ return;
277
+ }
278
+ onSelect?.(event);
279
+ if (!event.defaultPrevented) {
267
280
  context.setOpen(false);
268
- }), onKeyDown: composeEventHandlers(onKeyDown, (event) => {
269
- if (event.key === " " || event.key === "Space" || event.key === "Enter" || event.key === "Spacebar") {
281
+ }
282
+ };
283
+ const itemProps = {
284
+ ...props,
285
+ ref: (node) => {
286
+ setComposedRef(itemRef, ref, node);
287
+ },
288
+ role: "menuitem",
289
+ "aria-disabled": isDisabled ? true : undefined,
290
+ className: cn("liano-dropdown-menu__item", className),
291
+ "data-disabled": isDisabled ? "true" : undefined,
292
+ "data-state": isDisabled ? "disabled" : "enabled",
293
+ onClick: composeEventHandlers(onClick, select),
294
+ onKeyDown: composeEventHandlers(onKeyDown, (event) => {
295
+ if (isActivationKey(event.key)) {
296
+ select(event);
270
297
  event.preventDefault();
271
- if (isDisabled) {
272
- return;
273
- }
274
- onSelect?.(event);
275
- context.setOpen(false);
276
298
  }
277
- }), children: children }));
299
+ })
300
+ };
301
+ if (asChild) {
302
+ return _jsx(Slot, { ...itemProps, children: children });
303
+ }
304
+ return (_jsx("button", { ...props, ref: (node) => {
305
+ setComposedRef(itemRef, ref, node);
306
+ }, type: "button", role: "menuitem", disabled: isDisabled, "aria-disabled": itemProps["aria-disabled"], className: itemProps.className, "data-disabled": itemProps["data-disabled"], "data-state": itemProps["data-state"], onClick: itemProps.onClick, onKeyDown: itemProps.onKeyDown, children: children }));
278
307
  }
279
308
  function DropdownMenuSeparator({ className, ref, ...props }) {
280
309
  return (_jsx("div", { ...props, ref: ref, role: "separator", "aria-hidden": "true", className: cn("liano-dropdown-menu__separator", className) }));
@@ -285,7 +314,7 @@ function DropdownMenuLabel({ className, ref, ...props }) {
285
314
  function DropdownMenuShortcut({ className, ref, ...props }) {
286
315
  return (_jsx("span", { ...props, ref: ref, className: cn("liano-dropdown-menu__shortcut", className) }));
287
316
  }
288
- function DropdownMenuCheckboxItem({ checked, children, className, defaultChecked = false, disabled, onCheckedChange, onClick, onKeyDown, onSelect, ref, ...props }) {
317
+ function DropdownMenuCheckboxItem({ asChild = false, checked, children, className, defaultChecked = false, disabled, onCheckedChange, onClick, onKeyDown, onSelect, ref, ...props }) {
289
318
  const context = useDropdownMenuContext("DropdownMenu.CheckboxItem");
290
319
  const itemRef = React.useRef(null);
291
320
  const itemId = React.useId();
@@ -308,24 +337,37 @@ function DropdownMenuCheckboxItem({ checked, children, className, defaultChecked
308
337
  if (isDisabled) {
309
338
  return;
310
339
  }
311
- setCurrentChecked((value) => !value);
312
340
  onSelect?.(event);
313
- context.setOpen(false);
341
+ if (!event.defaultPrevented) {
342
+ setCurrentChecked((value) => !value);
343
+ context.setOpen(false);
344
+ }
314
345
  };
315
- return (_jsxs("button", { ...props, ref: (node) => {
316
- itemRef.current = node;
317
- if (typeof ref === "function") {
318
- ref(node);
319
- }
320
- else if (ref) {
321
- ref.current = node;
322
- }
323
- }, type: "button", role: "menuitemcheckbox", disabled: isDisabled, "aria-checked": currentChecked ? "true" : "false", "aria-disabled": isDisabled ? "true" : undefined, className: cn("liano-dropdown-menu__item", "liano-dropdown-menu__checkbox-item", className), "data-checked": currentChecked ? "true" : undefined, "data-disabled": isDisabled ? "true" : undefined, onClick: composeEventHandlers(onClick, select), onKeyDown: composeEventHandlers(onKeyDown, (event) => {
324
- if (event.key === " " || event.key === "Space" || event.key === "Enter" || event.key === "Spacebar") {
325
- event.preventDefault();
346
+ const itemProps = {
347
+ ...props,
348
+ ref: (node) => {
349
+ setComposedRef(itemRef, ref, node);
350
+ },
351
+ role: "menuitemcheckbox",
352
+ "aria-checked": currentChecked,
353
+ "aria-disabled": isDisabled ? true : undefined,
354
+ className: cn("liano-dropdown-menu__item", "liano-dropdown-menu__checkbox-item", className),
355
+ "data-checked": currentChecked ? "true" : undefined,
356
+ "data-disabled": isDisabled ? "true" : undefined,
357
+ onClick: composeEventHandlers(onClick, select),
358
+ onKeyDown: composeEventHandlers(onKeyDown, (event) => {
359
+ if (isActivationKey(event.key)) {
326
360
  select(event);
361
+ event.preventDefault();
327
362
  }
328
- }), children: [_jsx("span", { className: "liano-dropdown-menu__item-indicator", "aria-hidden": "true", children: currentChecked ? "✓" : "" }), _jsx("span", { className: "liano-dropdown-menu__item-label", children: children })] }));
363
+ })
364
+ };
365
+ if (asChild) {
366
+ return _jsx(Slot, { ...itemProps, children: children });
367
+ }
368
+ return (_jsxs("button", { ...props, ref: (node) => {
369
+ setComposedRef(itemRef, ref, node);
370
+ }, type: "button", role: "menuitemcheckbox", disabled: isDisabled, "aria-checked": itemProps["aria-checked"], "aria-disabled": itemProps["aria-disabled"], className: itemProps.className, "data-checked": itemProps["data-checked"], "data-disabled": itemProps["data-disabled"], onClick: itemProps.onClick, onKeyDown: itemProps.onKeyDown, children: [_jsx("span", { className: "liano-dropdown-menu__item-indicator", "aria-hidden": "true", children: currentChecked ? "✓" : "" }), _jsx("span", { className: "liano-dropdown-menu__item-label", children: children })] }));
329
371
  }
330
372
  function DropdownMenuRadioGroup({ children, className, onValueChange, ref, value, ...props }) {
331
373
  const contextValue = React.useMemo(() => ({
@@ -334,7 +376,7 @@ function DropdownMenuRadioGroup({ children, className, onValueChange, ref, value
334
376
  }), [onValueChange, value]);
335
377
  return (_jsx(DropdownMenuRadioGroupContext.Provider, { value: contextValue, children: _jsx("div", { ...props, ref: ref, className: cn("liano-dropdown-menu__radio-group", className), role: "group", children: children }) }));
336
378
  }
337
- function DropdownMenuRadioItem({ children, className, disabled, onClick, onKeyDown, onSelect, ref, value, ...props }) {
379
+ function DropdownMenuRadioItem({ asChild = false, children, className, disabled, onClick, onKeyDown, onSelect, ref, value, ...props }) {
338
380
  const context = useDropdownMenuContext("DropdownMenu.RadioItem");
339
381
  const radioGroup = React.useContext(DropdownMenuRadioGroupContext);
340
382
  const itemRef = React.useRef(null);
@@ -354,24 +396,37 @@ function DropdownMenuRadioItem({ children, className, disabled, onClick, onKeyDo
354
396
  if (isDisabled) {
355
397
  return;
356
398
  }
357
- radioGroup?.onValueChange?.(value);
358
399
  onSelect?.(event);
359
- context.setOpen(false);
400
+ if (!event.defaultPrevented) {
401
+ radioGroup?.onValueChange?.(value);
402
+ context.setOpen(false);
403
+ }
360
404
  };
361
- return (_jsxs("button", { ...props, ref: (node) => {
362
- itemRef.current = node;
363
- if (typeof ref === "function") {
364
- ref(node);
365
- }
366
- else if (ref) {
367
- ref.current = node;
368
- }
369
- }, type: "button", role: "menuitemradio", disabled: isDisabled, "aria-checked": checked ? "true" : "false", "aria-disabled": isDisabled ? "true" : undefined, className: cn("liano-dropdown-menu__item", "liano-dropdown-menu__radio-item", className), "data-checked": checked ? "true" : undefined, "data-disabled": isDisabled ? "true" : undefined, onClick: composeEventHandlers(onClick, select), onKeyDown: composeEventHandlers(onKeyDown, (event) => {
370
- if (event.key === " " || event.key === "Space" || event.key === "Enter" || event.key === "Spacebar") {
371
- event.preventDefault();
405
+ const itemProps = {
406
+ ...props,
407
+ ref: (node) => {
408
+ setComposedRef(itemRef, ref, node);
409
+ },
410
+ role: "menuitemradio",
411
+ "aria-checked": checked,
412
+ "aria-disabled": isDisabled ? true : undefined,
413
+ className: cn("liano-dropdown-menu__item", "liano-dropdown-menu__radio-item", className),
414
+ "data-checked": checked ? "true" : undefined,
415
+ "data-disabled": isDisabled ? "true" : undefined,
416
+ onClick: composeEventHandlers(onClick, select),
417
+ onKeyDown: composeEventHandlers(onKeyDown, (event) => {
418
+ if (isActivationKey(event.key)) {
372
419
  select(event);
420
+ event.preventDefault();
373
421
  }
374
- }), children: [_jsx("span", { className: "liano-dropdown-menu__item-indicator", "aria-hidden": "true", children: checked ? "●" : "" }), _jsx("span", { className: "liano-dropdown-menu__item-label", children: children })] }));
422
+ })
423
+ };
424
+ if (asChild) {
425
+ return _jsx(Slot, { ...itemProps, children: children });
426
+ }
427
+ return (_jsxs("button", { ...props, ref: (node) => {
428
+ setComposedRef(itemRef, ref, node);
429
+ }, type: "button", role: "menuitemradio", disabled: isDisabled, "aria-checked": itemProps["aria-checked"], "aria-disabled": itemProps["aria-disabled"], className: itemProps.className, "data-checked": itemProps["data-checked"], "data-disabled": itemProps["data-disabled"], onClick: itemProps.onClick, onKeyDown: itemProps.onKeyDown, children: [_jsx("span", { className: "liano-dropdown-menu__item-indicator", "aria-hidden": "true", children: checked ? "●" : "" }), _jsx("span", { className: "liano-dropdown-menu__item-label", children: children })] }));
375
430
  }
376
431
  function DropdownMenuSub({ children, className, ref, ...props }) {
377
432
  return (_jsx("div", { ...props, ref: ref, className: cn("liano-dropdown-menu__sub", className), children: children }));
@@ -0,0 +1,37 @@
1
+ import * as React from "react";
2
+ import type { FloatingPlacement } from "../../internal/floating/index.js";
3
+ import type { FloatingAlign, FloatingSide } from "../../internal/floating/placement-aliases.js";
4
+ import type { PortalProps } from "../../internal/portal/index.js";
5
+ export interface HoverCardProps {
6
+ children?: React.ReactNode;
7
+ open?: boolean;
8
+ defaultOpen?: boolean;
9
+ onOpenChange?: (open: boolean) => void;
10
+ openDelay?: number;
11
+ closeDelay?: number;
12
+ placement?: FloatingPlacement;
13
+ disabled?: boolean;
14
+ }
15
+ export interface HoverCardTriggerProps {
16
+ asChild?: boolean;
17
+ children: React.ReactElement;
18
+ }
19
+ export interface HoverCardContentProps extends React.HTMLAttributes<HTMLDivElement> {
20
+ placement?: FloatingPlacement;
21
+ side?: FloatingSide;
22
+ align?: FloatingAlign;
23
+ alignOffset?: number;
24
+ sideOffset?: number;
25
+ collisionPadding?: number;
26
+ forceMount?: boolean;
27
+ container?: PortalProps["container"];
28
+ ref?: React.Ref<HTMLDivElement>;
29
+ }
30
+ declare function HoverCardRoot({ children, closeDelay, defaultOpen, disabled, onOpenChange, open: openProp, openDelay, placement }: HoverCardProps): React.JSX.Element;
31
+ declare function HoverCardTrigger({ children, asChild: _asChild }: HoverCardTriggerProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
32
+ declare function HoverCardContent({ align, alignOffset: _alignOffset, children, className, collisionPadding, container, forceMount, id, onBlur, onFocus, onMouseEnter, onMouseLeave, onPointerEnter, onPointerLeave, placement, ref, side, sideOffset, style, ...props }: HoverCardContentProps): React.JSX.Element | null;
33
+ export declare const HoverCard: typeof HoverCardRoot & {
34
+ Trigger: typeof HoverCardTrigger;
35
+ Content: typeof HoverCardContent;
36
+ };
37
+ export {};