@zvk/ui 0.1.3 → 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 (42) 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 +40 -5
  6. package/dist/components/calendar/calendar.js +17 -5
  7. package/dist/components/calendar/index.d.ts +1 -1
  8. package/dist/components/collapsible/collapsible.d.ts +3 -2
  9. package/dist/components/collapsible/collapsible.js +5 -1
  10. package/dist/components/command/command.d.ts +11 -4
  11. package/dist/components/command/command.js +27 -16
  12. package/dist/components/command/index.d.ts +1 -1
  13. package/dist/components/context-menu/context-menu.d.ts +17 -6
  14. package/dist/components/context-menu/context-menu.js +139 -36
  15. package/dist/components/dialog/dialog.d.ts +6 -4
  16. package/dist/components/dialog/dialog.js +14 -4
  17. package/dist/components/dropdown-menu/dropdown-menu.d.ts +13 -7
  18. package/dist/components/dropdown-menu/dropdown-menu.js +127 -72
  19. package/dist/components/hover-card/hover-card.d.ts +8 -2
  20. package/dist/components/hover-card/hover-card.js +8 -5
  21. package/dist/components/index.d.ts +7 -7
  22. package/dist/components/index.js +1 -1
  23. package/dist/components/menubar/menubar.d.ts +24 -5
  24. package/dist/components/menubar/menubar.js +182 -33
  25. package/dist/components/popover/popover.d.ts +8 -3
  26. package/dist/components/popover/popover.js +14 -5
  27. package/dist/components/sheet/sheet.d.ts +6 -4
  28. package/dist/components/sheet/sheet.js +21 -8
  29. package/dist/components/toast/index.d.ts +2 -2
  30. package/dist/components/toast/index.js +1 -1
  31. package/dist/components/toast/toast.d.ts +16 -2
  32. package/dist/components/toast/toast.js +44 -2
  33. package/dist/components/tooltip/tooltip.d.ts +8 -2
  34. package/dist/components/tooltip/tooltip.js +8 -5
  35. package/dist/internal/floating/placement-aliases.d.ts +7 -0
  36. package/dist/internal/floating/placement-aliases.js +13 -0
  37. package/dist/internal/slot/index.d.ts +2 -0
  38. package/dist/internal/slot/index.js +1 -0
  39. package/dist/internal/slot/slot.d.ts +6 -0
  40. package/dist/internal/slot/slot.js +53 -0
  41. package/dist/styles.css +21 -1
  42. package/package.json +2 -2
@@ -6,7 +6,8 @@ export interface AlertDialogProps extends React.HTMLAttributes<HTMLDivElement> {
6
6
  ref?: React.Ref<HTMLDivElement>;
7
7
  }
8
8
  export interface AlertDialogTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
9
- ref?: React.Ref<HTMLButtonElement>;
9
+ asChild?: boolean;
10
+ ref?: React.Ref<HTMLButtonElement | HTMLElement>;
10
11
  }
11
12
  export interface AlertDialogContentProps extends React.HTMLAttributes<HTMLDivElement> {
12
13
  ref?: React.Ref<HTMLDivElement>;
@@ -21,18 +22,20 @@ export interface AlertDialogFooterProps extends React.HTMLAttributes<HTMLDivElem
21
22
  ref?: React.Ref<HTMLDivElement>;
22
23
  }
23
24
  export interface AlertDialogActionProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
24
- ref?: React.Ref<HTMLButtonElement>;
25
+ asChild?: boolean;
26
+ ref?: React.Ref<HTMLButtonElement | HTMLElement>;
25
27
  }
26
28
  export interface AlertDialogCancelProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
27
- ref?: React.Ref<HTMLButtonElement>;
29
+ asChild?: boolean;
30
+ ref?: React.Ref<HTMLButtonElement | HTMLElement>;
28
31
  }
29
32
  declare function AlertDialogRoot({ children, className, defaultOpen, onOpenChange, open: openProp, ref, ...props }: AlertDialogProps): React.JSX.Element;
30
- declare function AlertDialogTrigger({ className, disabled, onClick, ref, type, ...props }: AlertDialogTriggerProps): React.JSX.Element;
33
+ declare function AlertDialogTrigger({ asChild, className, disabled, onClick, ref, type, ...props }: AlertDialogTriggerProps): React.JSX.Element;
31
34
  declare function AlertDialogContent({ children, className, ref, ...props }: AlertDialogContentProps): React.JSX.Element | null;
32
35
  declare function AlertDialogTitle({ className, ref, ...props }: AlertDialogTitleProps): React.JSX.Element;
33
36
  declare function AlertDialogDescription({ className, ref, ...props }: AlertDialogDescriptionProps): React.JSX.Element;
34
37
  declare function AlertDialogFooter({ className, ref, ...props }: AlertDialogFooterProps): React.JSX.Element;
35
- declare function AlertDialogCloseButton({ className, onClick, ref, type, ...props }: AlertDialogActionProps | AlertDialogCancelProps): React.JSX.Element;
38
+ declare function AlertDialogCloseButton({ asChild, className, disabled, onClick, ref, type, ...props }: AlertDialogActionProps | AlertDialogCancelProps): React.JSX.Element;
36
39
  type AlertDialogComponent = typeof AlertDialogRoot & {
37
40
  Action: typeof AlertDialogCloseButton;
38
41
  Cancel: typeof AlertDialogCloseButton;
@@ -8,6 +8,7 @@ import { DismissableLayer } from "../../internal/dismissable-layer/index.js";
8
8
  import { FocusScope } from "../../internal/focus/index.js";
9
9
  import { Portal } from "../../internal/portal/index.js";
10
10
  import { lockScroll, unlockScroll } from "../../internal/scroll-lock/index.js";
11
+ import { Slot } from "../../internal/slot/index.js";
11
12
  const AlertDialogContext = React.createContext(null);
12
13
  function useAlertDialogContext(calledBy) {
13
14
  const context = React.useContext(AlertDialogContext);
@@ -67,13 +68,17 @@ function AlertDialogRoot({ children, className, defaultOpen = false, onOpenChang
67
68
  triggerRef
68
69
  }, children: _jsx("div", { ...props, ref: ref, className: cn("liano-alert-dialog", className), "data-state": open ? "open" : "closed", children: children }) }));
69
70
  }
70
- function AlertDialogTrigger({ className, disabled, onClick, ref, type = "button", ...props }) {
71
+ function AlertDialogTrigger({ asChild = false, className, disabled, onClick, ref, type = "button", ...props }) {
71
72
  const { contentId, open, setOpen, triggerRef } = useAlertDialogContext("AlertDialog.Trigger");
72
- return (_jsx("button", { ...props, ref: composeRefs(ref, triggerRef), type: type, disabled: disabled, "aria-controls": contentId, "aria-expanded": open ? "true" : "false", className: cn("liano-alert-dialog__trigger", className), "data-state": open ? "open" : "closed", onClick: composeEventHandlers(onClick, () => {
73
- if (!disabled) {
74
- setOpen(true);
75
- }
76
- }) }));
73
+ const handleClick = () => {
74
+ if (!disabled) {
75
+ setOpen(true);
76
+ }
77
+ };
78
+ if (asChild) {
79
+ return (_jsx(Slot, { ...props, ref: composeRefs(ref, triggerRef), "aria-controls": contentId, "aria-disabled": disabled ? true : undefined, "aria-expanded": open ? "true" : "false", className: cn("liano-alert-dialog__trigger", className), "data-disabled": disabled ? "true" : undefined, "data-state": open ? "open" : "closed", onClick: composeEventHandlers(onClick, handleClick), children: props.children }));
80
+ }
81
+ return (_jsx("button", { ...props, ref: composeRefs(ref, triggerRef), type: type, disabled: disabled, "aria-controls": contentId, "aria-expanded": open ? "true" : "false", className: cn("liano-alert-dialog__trigger", className), "data-state": open ? "open" : "closed", onClick: composeEventHandlers(onClick, handleClick) }));
77
82
  }
78
83
  function AlertDialogContent({ children, className, ref, ...props }) {
79
84
  const { close, contentId, describedBy, labelledBy, open } = useAlertDialogContext("AlertDialog.Content");
@@ -97,9 +102,17 @@ function AlertDialogDescription({ className, ref, ...props }) {
97
102
  function AlertDialogFooter({ className, ref, ...props }) {
98
103
  return _jsx("div", { ...props, ref: ref, className: cn("liano-alert-dialog__footer", className) });
99
104
  }
100
- function AlertDialogCloseButton({ className, onClick, ref, type = "button", ...props }) {
105
+ function AlertDialogCloseButton({ asChild = false, className, disabled, onClick, ref, type = "button", ...props }) {
101
106
  const { close } = useAlertDialogContext("AlertDialog.Action");
102
- return (_jsx("button", { ...props, ref: ref, type: type, className: cn("liano-alert-dialog__button", className), onClick: composeEventHandlers(onClick, close) }));
107
+ const handleClick = () => {
108
+ if (!disabled) {
109
+ close();
110
+ }
111
+ };
112
+ if (asChild) {
113
+ return (_jsx(Slot, { ...props, ref: ref, "aria-disabled": disabled ? true : undefined, className: cn("liano-alert-dialog__button", className), "data-disabled": disabled ? "true" : undefined, onClick: composeEventHandlers(onClick, handleClick), children: props.children }));
114
+ }
115
+ return (_jsx("button", { ...props, ref: ref, type: type, disabled: disabled, className: cn("liano-alert-dialog__button", className), onClick: composeEventHandlers(onClick, handleClick) }));
103
116
  }
104
117
  export const AlertDialog = Object.assign(AlertDialogRoot, {
105
118
  Action: AlertDialogCloseButton,
@@ -2,12 +2,13 @@ import * as React from "react";
2
2
  export type ButtonVariant = "primary" | "secondary" | "outline" | "ghost" | "destructive";
3
3
  export type ButtonSize = "sm" | "md" | "lg" | "icon";
4
4
  export interface ButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "disabled"> {
5
+ asChild?: boolean;
5
6
  variant?: ButtonVariant;
6
7
  size?: ButtonSize;
7
8
  loading?: boolean;
8
9
  disabled?: boolean;
9
10
  leadingIcon?: React.ReactNode;
10
11
  trailingIcon?: React.ReactNode;
11
- ref?: React.Ref<HTMLButtonElement>;
12
+ ref?: React.Ref<HTMLButtonElement | HTMLElement>;
12
13
  }
13
- export declare function Button({ children, className, disabled, leadingIcon, loading, ref, size, trailingIcon, type, variant, ...props }: ButtonProps): React.JSX.Element;
14
+ export declare function Button({ asChild, children, className, disabled, leadingIcon, loading, ref, size, trailingIcon, type, variant, ...props }: ButtonProps): React.JSX.Element;
@@ -1,8 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import * as React from "react";
3
3
  import { Spinner } from "../spinner/spinner.js";
4
+ import { Slot } from "../../internal/slot/index.js";
4
5
  import { cn } from "../../utils/cn.js";
5
- export function Button({ children, className, disabled, leadingIcon, loading = false, ref, size = "md", trailingIcon, type = "button", variant = "primary", ...props }) {
6
+ export function Button({ asChild = false, children, className, disabled, leadingIcon, loading = false, ref, size = "md", trailingIcon, type = "button", variant = "primary", ...props }) {
6
7
  const isDisabled = disabled || loading;
8
+ if (asChild) {
9
+ return (_jsx(Slot, { ...props, ref: ref, "aria-busy": loading ? true : undefined, "aria-disabled": isDisabled ? true : undefined, className: cn("liano-button", className), "data-disabled": isDisabled ? "true" : undefined, "data-loading": loading ? "true" : undefined, "data-size": size, "data-variant": variant, children: children }));
10
+ }
7
11
  return (_jsxs("button", { ...props, ref: ref, "aria-busy": loading ? true : undefined, className: cn("liano-button", className), "data-disabled": isDisabled ? "true" : undefined, "data-loading": loading ? "true" : undefined, "data-size": size, "data-variant": variant, disabled: isDisabled, type: type, children: [loading ? (_jsx("span", { "aria-hidden": "true", className: "liano-button__spinner", children: _jsx(Spinner, { size: "sm" }) })) : null, leadingIcon ? (_jsx("span", { "aria-hidden": "true", className: "liano-button__icon", children: leadingIcon })) : null, _jsx("span", { className: "liano-button__content", children: children }), trailingIcon ? (_jsx("span", { "aria-hidden": "true", className: "liano-button__icon", children: trailingIcon })) : null] }));
8
12
  }
@@ -1,16 +1,51 @@
1
1
  import * as React from "react";
2
- export interface CalendarProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onSelect"> {
3
- selected?: Date | null;
4
- defaultSelected?: Date | null;
5
- onSelect?: (date: Date | null) => void;
2
+ export type CalendarMode = "single";
3
+ export type CalendarClassNames = Partial<{
4
+ months: string;
5
+ month: string;
6
+ caption: string;
7
+ caption_label: string;
8
+ nav: string;
9
+ nav_button: string;
10
+ nav_button_previous: string;
11
+ nav_button_next: string;
12
+ table: string;
13
+ head_row: string;
14
+ head_cell: string;
15
+ row: string;
16
+ cell: string;
17
+ day: string;
18
+ day_selected: string;
19
+ day_today: string;
20
+ day_outside: string;
21
+ day_disabled: string;
22
+ }>;
23
+ interface CalendarBaseProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "onSelect"> {
6
24
  month?: Date;
7
25
  defaultMonth?: Date;
8
26
  onMonthChange?: (month: Date) => void;
9
27
  minDate?: Date;
10
28
  maxDate?: Date;
29
+ disabled?: (date: Date) => boolean;
11
30
  disabledDate?: (date: Date) => boolean;
31
+ showOutsideDays?: boolean;
32
+ classNames?: CalendarClassNames;
12
33
  weekStartsOn?: 0 | 1;
13
34
  locale?: string;
14
35
  ref?: React.Ref<HTMLDivElement>;
15
36
  }
16
- export declare function Calendar({ className, defaultMonth, defaultSelected, disabledDate, locale, maxDate, minDate, month, onKeyDown, onMonthChange, onSelect, ref, selected, weekStartsOn, ...props }: CalendarProps): React.JSX.Element;
37
+ export interface CalendarNativeProps extends CalendarBaseProps {
38
+ mode?: undefined;
39
+ selected?: Date | null;
40
+ defaultSelected?: Date | null;
41
+ onSelect?: (date: Date | null) => void;
42
+ }
43
+ export interface CalendarSingleProps extends CalendarBaseProps {
44
+ mode: CalendarMode;
45
+ selected?: Date | null | undefined;
46
+ defaultSelected?: Date | null;
47
+ onSelect?: (date: Date | undefined) => void;
48
+ }
49
+ export type CalendarProps = CalendarNativeProps | CalendarSingleProps;
50
+ export declare function Calendar({ classNames, className, defaultMonth, defaultSelected, disabled, disabledDate, locale, maxDate, minDate, mode, month, onKeyDown, onMonthChange, onSelect, ref, selected, showOutsideDays, weekStartsOn, ...props }: CalendarProps): React.JSX.Element;
51
+ export {};
@@ -52,7 +52,11 @@ function isDisabled(date, props) {
52
52
  if (props.maxDate && isAfterDay(date, props.maxDate)) {
53
53
  return true;
54
54
  }
55
- return props.disabledDate ? props.disabledDate(startOfDay(date)) : false;
55
+ const normalizedDate = startOfDay(date);
56
+ if (props.disabled?.(normalizedDate)) {
57
+ return true;
58
+ }
59
+ return props.disabledDate ? props.disabledDate(normalizedDate) : false;
56
60
  }
57
61
  function getMonthLabel(date, locale) {
58
62
  return new Intl.DateTimeFormat(locale, { month: "long", year: "numeric" }).format(date);
@@ -74,7 +78,7 @@ function getNearestEnabledDate(date, visibleMonth, props) {
74
78
  const days = getCalendarDays(visibleMonth, 0);
75
79
  return days.find((day) => !isDisabled(day, props)) ?? date;
76
80
  }
77
- export function Calendar({ className, defaultMonth, defaultSelected = null, disabledDate, locale, maxDate, minDate, month, onKeyDown, onMonthChange, onSelect, ref, selected, weekStartsOn = 0, ...props }) {
81
+ export function Calendar({ classNames, className, defaultMonth, defaultSelected = null, disabled, disabledDate, locale, maxDate, minDate, mode, month, onKeyDown, onMonthChange, onSelect, ref, selected, showOutsideDays = true, weekStartsOn = 0, ...props }) {
78
82
  const isSelectedControlled = selected !== undefined;
79
83
  const selectedDate = isSelectedControlled ? selected : defaultSelected;
80
84
  const [uncontrolledSelected, setUncontrolledSelected] = React.useState(defaultSelected);
@@ -84,7 +88,7 @@ export function Calendar({ className, defaultMonth, defaultSelected = null, disa
84
88
  const [focusedDate, setFocusedDate] = React.useState(() => startOfDay(currentSelected ?? visibleMonth));
85
89
  const headingId = React.useId();
86
90
  const dayButtonRefs = React.useRef(new Map());
87
- const disabledProps = React.useMemo(() => ({ disabledDate, maxDate, minDate }), [disabledDate, maxDate, minDate]);
91
+ const disabledProps = React.useMemo(() => ({ disabled, disabledDate, maxDate, minDate }), [disabled, disabledDate, maxDate, minDate]);
88
92
  const days = React.useMemo(() => getCalendarDays(visibleMonth, weekStartsOn), [visibleMonth, weekStartsOn]);
89
93
  const weekdays = React.useMemo(() => getWeekdayLabels(weekStartsOn, locale), [locale, weekStartsOn]);
90
94
  const monthLabel = getMonthLabel(visibleMonth, locale);
@@ -119,6 +123,10 @@ export function Calendar({ className, defaultMonth, defaultSelected = null, disa
119
123
  if (!isSelectedControlled) {
120
124
  setUncontrolledSelected(nextSelected);
121
125
  }
126
+ if (mode === "single") {
127
+ onSelect?.(nextSelected ?? undefined);
128
+ return;
129
+ }
122
130
  onSelect?.(nextSelected);
123
131
  };
124
132
  const handleKeyDown = (event) => {
@@ -159,14 +167,18 @@ export function Calendar({ className, defaultMonth, defaultSelected = null, disa
159
167
  }
160
168
  moveFocus(addDays(focusedDate, offset));
161
169
  };
162
- return (_jsxs("div", { ...props, ref: ref, className: cn("liano-calendar", className), onKeyDown: handleKeyDown, children: [_jsxs("div", { className: "liano-calendar__header", children: [_jsx("button", { "aria-label": "Previous month", className: "liano-calendar__nav", type: "button", onClick: () => setVisibleMonth(addMonths(visibleMonth, -1)), children: _jsx("span", { "aria-hidden": "true", children: "\u2039" }) }), _jsx("h2", { className: "liano-calendar__heading", id: headingId, children: monthLabel }), _jsx("button", { "aria-label": "Next month", className: "liano-calendar__nav", type: "button", onClick: () => setVisibleMonth(addMonths(visibleMonth, 1)), children: _jsx("span", { "aria-hidden": "true", children: "\u203A" }) })] }), _jsxs("div", { "aria-labelledby": headingId, className: "liano-calendar__grid", role: "grid", children: [_jsx("div", { className: "liano-calendar__weekdays", role: "row", children: weekdays.map((weekday) => (_jsx("span", { className: "liano-calendar__weekday", role: "columnheader", children: weekday }, weekday))) }), Array.from({ length: 6 }, (_, rowIndex) => (_jsx("div", { className: "liano-calendar__week", role: "row", children: days.slice(rowIndex * 7, rowIndex * 7 + 7).map((date) => {
170
+ return (_jsxs("div", { ...props, ref: ref, className: cn("liano-calendar", classNames?.months, classNames?.month, className), onKeyDown: handleKeyDown, children: [_jsxs("div", { className: cn("liano-calendar__header", classNames?.caption, classNames?.nav), children: [_jsx("button", { "aria-label": "Previous month", className: cn("liano-calendar__nav", classNames?.nav_button, classNames?.nav_button_previous), type: "button", onClick: () => setVisibleMonth(addMonths(visibleMonth, -1)), children: _jsx("span", { "aria-hidden": "true", children: "\u2039" }) }), _jsx("h2", { className: cn("liano-calendar__heading", classNames?.caption_label), id: headingId, children: monthLabel }), _jsx("button", { "aria-label": "Next month", className: cn("liano-calendar__nav", classNames?.nav_button, classNames?.nav_button_next), type: "button", onClick: () => setVisibleMonth(addMonths(visibleMonth, 1)), children: _jsx("span", { "aria-hidden": "true", children: "\u203A" }) })] }), _jsxs("div", { "aria-labelledby": headingId, className: cn("liano-calendar__grid", classNames?.table), role: "grid", children: [_jsx("div", { className: cn("liano-calendar__weekdays", classNames?.head_row), role: "row", children: weekdays.map((weekday) => (_jsx("span", { className: cn("liano-calendar__weekday", classNames?.head_cell), role: "columnheader", children: weekday }, weekday))) }), Array.from({ length: 6 }, (_, rowIndex) => (_jsx("div", { className: cn("liano-calendar__week", classNames?.row), role: "row", children: days.slice(rowIndex * 7, rowIndex * 7 + 7).map((date) => {
163
171
  const normalizedDate = startOfDay(date);
164
172
  const dateKey = normalizedDate.getTime();
165
173
  const outsideMonth = date.getMonth() !== visibleMonth.getMonth();
174
+ const hideOutsideDay = outsideMonth && !showOutsideDays;
166
175
  const disabled = isDisabled(date, disabledProps);
167
176
  const selectedDay = isSameDay(currentSelected, date);
168
177
  const focusedDay = isSameDay(focusedDate, date);
169
- return (_jsx("span", { className: "liano-calendar__cell", role: "gridcell", children: _jsx("button", { "aria-label": getDayLabel(date, locale), "aria-pressed": selectedDay, className: "liano-calendar__day", "data-disabled": disabled ? "true" : undefined, "data-outside-month": outsideMonth ? "true" : undefined, "data-selected": selectedDay ? "true" : undefined, "data-today": isSameDay(today, date) ? "true" : undefined, disabled: disabled, ref: (node) => {
178
+ if (hideOutsideDay) {
179
+ return (_jsx("span", { className: cn("liano-calendar__cell", classNames?.cell), role: "gridcell", children: _jsx("span", { "aria-hidden": "true", className: cn("liano-calendar__day", classNames?.day, classNames?.day_outside), "data-outside-month": "true" }) }, dateKey));
180
+ }
181
+ return (_jsx("span", { className: cn("liano-calendar__cell", classNames?.cell), role: "gridcell", children: _jsx("button", { "aria-label": getDayLabel(date, locale), "aria-pressed": selectedDay, className: cn("liano-calendar__day", classNames?.day, selectedDay ? classNames?.day_selected : undefined, outsideMonth ? classNames?.day_outside : undefined, disabled ? classNames?.day_disabled : undefined, isSameDay(today, date) ? classNames?.day_today : undefined), "data-disabled": disabled ? "true" : undefined, "data-outside-month": outsideMonth ? "true" : undefined, "data-selected": selectedDay ? "true" : undefined, "data-today": isSameDay(today, date) ? "true" : undefined, disabled: disabled, ref: (node) => {
170
182
  if (node) {
171
183
  dayButtonRefs.current.set(dateKey, node);
172
184
  }
@@ -1,2 +1,2 @@
1
1
  export { Calendar } from "./calendar.js";
2
- export type { CalendarProps } from "./calendar.js";
2
+ export type { CalendarClassNames, CalendarMode, CalendarNativeProps, CalendarProps, CalendarSingleProps } from "./calendar.js";
@@ -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);
@@ -23,12 +24,15 @@ function CollapsibleRoot({ children, className, defaultOpen = false, disabled =
23
24
  });
24
25
  return (_jsx(CollapsibleContext.Provider, { value: { open: isOpen, setOpen, disabled, contentId, defaultContentId, setContentId }, children: _jsx("div", { ...props, ref: ref, className: cn("liano-collapsible", className), "data-state": isOpen ? "open" : "closed", "data-disabled": disabled ? "true" : undefined, children: children }) }));
25
26
  }
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
  };
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("liano-collapsible__trigger", className), "data-disabled": isDisabled ? "true" : undefined, "data-state": context.open ? "open" : "closed", onClick: composeEventHandlers(onClick, isDisabled ? undefined : handleClick), children: props.children }));
35
+ }
32
36
  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
37
  }
34
38
  function CollapsibleContent({ className, forceMount = false, ref, ...props }) {
@@ -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("liano-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("liano-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("liano-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("liano-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("liano-command__group", className), "cmdk-group": "", children: [heading ? _jsx("div", { id: headingId, className: "liano-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("liano-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("liano-command__separator", className), "cmdk-separator": "" }));
190
+ }
191
+ function CommandShortcut({ className, ref, ...props }) {
192
+ return _jsx("span", { ...props, ref: ref, className: cn("liano-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(() => {
@@ -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
  };