@zvk/ui 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/README.md +5 -5
- package/dist/components/accordion/accordion.js +4 -4
- package/dist/components/alert/alert.d.ts +5 -0
- package/dist/components/alert/alert.js +8 -4
- package/dist/components/alert/index.d.ts +1 -1
- package/dist/components/alert-dialog/alert-dialog.js +9 -9
- package/dist/components/avatar/avatar.js +1 -1
- package/dist/components/badge/badge.js +1 -1
- package/dist/components/breadcrumbs/breadcrumbs.js +3 -3
- package/dist/components/button/button.js +46 -2
- package/dist/components/calendar/calendar.js +3 -3
- package/dist/components/card/card.d.ts +5 -0
- package/dist/components/card/card.js +11 -7
- package/dist/components/card/index.d.ts +1 -1
- package/dist/components/carousel/carousel.js +7 -7
- package/dist/components/checkbox/checkbox.js +4 -4
- package/dist/components/code-block/code-block.js +2 -2
- package/dist/components/collapsible/collapsible.js +4 -4
- package/dist/components/combobox/combobox.js +6 -5
- package/dist/components/command/command-filter.d.ts +0 -1
- package/dist/components/command/command-filter.js +0 -3
- package/dist/components/command/command.js +9 -9
- package/dist/components/context-menu/context-menu.d.ts +3 -1
- package/dist/components/context-menu/context-menu.js +66 -12
- package/dist/components/context-menu/index.d.ts +1 -1
- package/dist/components/conversation/conversation.js +11 -11
- package/dist/components/copy-button/copy-button.js +2 -2
- package/dist/components/date-picker/date-picker.js +1 -1
- package/dist/components/dialog/dialog.js +11 -11
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +1 -1
- package/dist/components/dropdown-menu/dropdown-menu.js +20 -16
- package/dist/components/empty-state/empty-state.js +1 -1
- package/dist/components/error-boundary/error-boundary.js +1 -1
- package/dist/components/field/field.js +4 -4
- package/dist/components/file-upload-input/file-upload-input.js +2 -2
- package/dist/components/form/form.js +6 -6
- package/dist/components/hover-card/hover-card.d.ts +1 -1
- package/dist/components/hover-card/hover-card.js +7 -4
- package/dist/components/icon-button/icon-button.js +19 -1
- package/dist/components/index.d.ts +5 -5
- package/dist/components/input/input.js +1 -1
- package/dist/components/label/label.js +1 -1
- package/dist/components/menubar/index.d.ts +1 -1
- package/dist/components/menubar/menubar.d.ts +1 -1
- package/dist/components/menubar/menubar.js +42 -14
- package/dist/components/pagination/pagination.js +12 -12
- package/dist/components/popover/popover.d.ts +1 -1
- package/dist/components/popover/popover.js +30 -7
- package/dist/components/progress/progress.js +3 -3
- package/dist/components/radio-group/radio-group.js +3 -3
- package/dist/components/responsive-container/responsive-container.js +1 -1
- package/dist/components/scroll-area/scroll-area.js +4 -4
- package/dist/components/sectioned-sidebar-nav/sectioned-sidebar-nav.js +7 -7
- package/dist/components/select/select.js +66 -13
- package/dist/components/separator/separator.js +1 -1
- package/dist/components/sheet/sheet.js +12 -12
- package/dist/components/sidebar-shell/sidebar-shell.js +6 -6
- package/dist/components/skeleton/skeleton.js +1 -1
- package/dist/components/slider/slider.js +1 -1
- package/dist/components/spinner/spinner.js +1 -1
- package/dist/components/stat/stat.js +1 -1
- package/dist/components/switch/switch.js +3 -3
- package/dist/components/table/index.d.ts +1 -1
- package/dist/components/table/table.d.ts +5 -0
- package/dist/components/table/table.js +12 -8
- package/dist/components/tabs/tabs.js +4 -4
- package/dist/components/tabs-with-sidebar/tabs-with-sidebar.js +3 -3
- package/dist/components/textarea/textarea.js +1 -1
- package/dist/components/toast/toast.js +8 -8
- package/dist/components/toggle/toggle.js +1 -1
- package/dist/components/toggle-group/toggle-group.js +1 -1
- package/dist/components/tooltip/tooltip.d.ts +1 -1
- package/dist/components/tooltip/tooltip.js +6 -3
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/use-composed-refs.d.ts +2 -2
- package/dist/hooks/use-controllable-state.d.ts +2 -2
- package/dist/internal/floating/auto-update.js +21 -9
- package/dist/internal/floating/compute-position.js +13 -8
- package/dist/internal/floating/floating-types.d.ts +1 -0
- package/dist/internal/floating/index.d.ts +1 -0
- package/dist/internal/floating/use-floating-position.js +6 -4
- package/dist/internal/overlay-stack/overlay-stack.js +4 -1
- package/dist/styles.css +2065 -2022
- package/dist/tokens/index.d.ts +2 -2
- package/dist/tokens/index.js +1 -1
- package/dist/tokens/token-types.d.ts +5 -5
- package/dist/tokens/tokens.d.ts +16 -10
- package/dist/tokens/tokens.js +16 -10
- package/dist/utils/cn.d.ts +2 -2
- package/dist/utils/index.d.ts +1 -1
- package/package.json +14 -11
|
@@ -11,6 +11,7 @@ import { placementFromSideAlign, placementParts } from "../../internal/floating/
|
|
|
11
11
|
import { Slot } from "../../internal/slot/index.js";
|
|
12
12
|
const defaultContentPositioning = {
|
|
13
13
|
sideOffset: 8,
|
|
14
|
+
alignOffset: 0,
|
|
14
15
|
collisionPadding: 0,
|
|
15
16
|
matchTriggerWidth: false
|
|
16
17
|
};
|
|
@@ -65,6 +66,7 @@ function DropdownMenuRoot({ children, className, container, defaultOpen = false,
|
|
|
65
66
|
const wasOpenRef = React.useRef(false);
|
|
66
67
|
const [contentPositioning, setContentPositioning] = React.useState({
|
|
67
68
|
sideOffset,
|
|
69
|
+
alignOffset: defaultContentPositioning.alignOffset,
|
|
68
70
|
collisionPadding,
|
|
69
71
|
matchTriggerWidth
|
|
70
72
|
});
|
|
@@ -73,6 +75,7 @@ function DropdownMenuRoot({ children, className, container, defaultOpen = false,
|
|
|
73
75
|
placement: contentPositioning.placement ?? placement,
|
|
74
76
|
strategy: "absolute",
|
|
75
77
|
offset: contentPositioning.sideOffset,
|
|
78
|
+
alignmentOffset: contentPositioning.alignOffset,
|
|
76
79
|
collisionPadding: contentPositioning.collisionPadding,
|
|
77
80
|
matchReferenceWidth: contentPositioning.matchTriggerWidth
|
|
78
81
|
});
|
|
@@ -136,7 +139,7 @@ function DropdownMenuRoot({ children, className, container, defaultOpen = false,
|
|
|
136
139
|
registerItem,
|
|
137
140
|
unregisterItem,
|
|
138
141
|
...(container === undefined ? {} : { container })
|
|
139
|
-
}, children: _jsx("div", { ...props, className: cn("
|
|
142
|
+
}, children: _jsx("div", { ...props, className: cn("zvk-ui-dropdown-menu", className), "data-state": open ? "open" : "closed", children: children }) }));
|
|
140
143
|
}
|
|
141
144
|
function DropdownMenuTrigger({ asChild = false, className, disabled, onClick, ref, type = "button", ...props }) {
|
|
142
145
|
const { contentId, open, setOpen, triggerRef, triggerId, referenceRef, getEnabledItems } = useDropdownMenuContext("DropdownMenu.Trigger");
|
|
@@ -155,11 +158,11 @@ function DropdownMenuTrigger({ asChild = false, className, disabled, onClick, re
|
|
|
155
158
|
});
|
|
156
159
|
};
|
|
157
160
|
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("
|
|
161
|
+
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("zvk-ui-dropdown-menu__trigger", className), "data-disabled": disabled ? "true" : undefined, "data-state": open ? "open" : "closed", onClick: composeEventHandlers(onClick, handleClick), children: props.children }));
|
|
159
162
|
}
|
|
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("
|
|
163
|
+
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("zvk-ui-dropdown-menu__trigger", className), "data-state": open ? "open" : "closed", onClick: composeEventHandlers(onClick, handleClick) }));
|
|
161
164
|
}
|
|
162
|
-
function DropdownMenuContent({ align, alignOffset
|
|
165
|
+
function DropdownMenuContent({ align, alignOffset = defaultContentPositioning.alignOffset, children, className, forceMount = false, side, sideOffset = defaultContentPositioning.sideOffset, collisionPadding = defaultContentPositioning.collisionPadding, matchTriggerWidth = defaultContentPositioning.matchTriggerWidth, ref, onKeyDown, ...props }) {
|
|
163
166
|
const { container, contentId, open, setOpen, updateContentPositioning, triggerId, floatingRef, floatingPlacement, floatingStyle, getEnabledItems } = useDropdownMenuContext("DropdownMenu.Content");
|
|
164
167
|
const focusItem = React.useCallback((index, items) => {
|
|
165
168
|
if (items.length === 0) {
|
|
@@ -202,13 +205,14 @@ function DropdownMenuContent({ align, alignOffset: _alignOffset, children, class
|
|
|
202
205
|
updateContentPositioning({
|
|
203
206
|
...(side === undefined ? {} : { placement: placementFromSideAlign(side, align, "bottom") }),
|
|
204
207
|
sideOffset,
|
|
208
|
+
alignOffset,
|
|
205
209
|
collisionPadding,
|
|
206
210
|
matchTriggerWidth
|
|
207
211
|
});
|
|
208
212
|
return () => {
|
|
209
213
|
updateContentPositioning(defaultContentPositioning);
|
|
210
214
|
};
|
|
211
|
-
}, [align, collisionPadding, matchTriggerWidth, side, sideOffset, updateContentPositioning]);
|
|
215
|
+
}, [align, alignOffset, collisionPadding, matchTriggerWidth, side, sideOffset, updateContentPositioning]);
|
|
212
216
|
if (!open && !forceMount) {
|
|
213
217
|
return null;
|
|
214
218
|
}
|
|
@@ -220,7 +224,7 @@ function DropdownMenuContent({ align, alignOffset: _alignOffset, children, class
|
|
|
220
224
|
else if (ref) {
|
|
221
225
|
ref.current = node;
|
|
222
226
|
}
|
|
223
|
-
}, id: contentId, role: "menu", "aria-labelledby": triggerId, className: cn("
|
|
227
|
+
}, id: contentId, role: "menu", "aria-labelledby": triggerId, className: cn("zvk-ui-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) => {
|
|
224
228
|
if (event.key === "ArrowDown") {
|
|
225
229
|
event.preventDefault();
|
|
226
230
|
moveFocus("next");
|
|
@@ -287,7 +291,7 @@ function DropdownMenuItem({ asChild = false, children, className, disabled, onCl
|
|
|
287
291
|
},
|
|
288
292
|
role: "menuitem",
|
|
289
293
|
"aria-disabled": isDisabled ? true : undefined,
|
|
290
|
-
className: cn("
|
|
294
|
+
className: cn("zvk-ui-dropdown-menu__item", className),
|
|
291
295
|
"data-disabled": isDisabled ? "true" : undefined,
|
|
292
296
|
"data-state": isDisabled ? "disabled" : "enabled",
|
|
293
297
|
onClick: composeEventHandlers(onClick, select),
|
|
@@ -306,13 +310,13 @@ function DropdownMenuItem({ asChild = false, children, className, disabled, onCl
|
|
|
306
310
|
}, 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 }));
|
|
307
311
|
}
|
|
308
312
|
function DropdownMenuSeparator({ className, ref, ...props }) {
|
|
309
|
-
return (_jsx("div", { ...props, ref: ref, role: "separator", "aria-hidden": "true", className: cn("
|
|
313
|
+
return (_jsx("div", { ...props, ref: ref, role: "separator", "aria-hidden": "true", className: cn("zvk-ui-dropdown-menu__separator", className) }));
|
|
310
314
|
}
|
|
311
315
|
function DropdownMenuLabel({ className, ref, ...props }) {
|
|
312
|
-
return (_jsx("div", { ...props, ref: ref, className: cn("
|
|
316
|
+
return (_jsx("div", { ...props, ref: ref, className: cn("zvk-ui-dropdown-menu__label", className) }));
|
|
313
317
|
}
|
|
314
318
|
function DropdownMenuShortcut({ className, ref, ...props }) {
|
|
315
|
-
return (_jsx("span", { ...props, ref: ref, className: cn("
|
|
319
|
+
return (_jsx("span", { ...props, ref: ref, className: cn("zvk-ui-dropdown-menu__shortcut", className) }));
|
|
316
320
|
}
|
|
317
321
|
function DropdownMenuCheckboxItem({ asChild = false, checked, children, className, defaultChecked = false, disabled, onCheckedChange, onClick, onKeyDown, onSelect, ref, ...props }) {
|
|
318
322
|
const context = useDropdownMenuContext("DropdownMenu.CheckboxItem");
|
|
@@ -351,7 +355,7 @@ function DropdownMenuCheckboxItem({ asChild = false, checked, children, classNam
|
|
|
351
355
|
role: "menuitemcheckbox",
|
|
352
356
|
"aria-checked": currentChecked,
|
|
353
357
|
"aria-disabled": isDisabled ? true : undefined,
|
|
354
|
-
className: cn("
|
|
358
|
+
className: cn("zvk-ui-dropdown-menu__item", "zvk-ui-dropdown-menu__checkbox-item", className),
|
|
355
359
|
"data-checked": currentChecked ? "true" : undefined,
|
|
356
360
|
"data-disabled": isDisabled ? "true" : undefined,
|
|
357
361
|
onClick: composeEventHandlers(onClick, select),
|
|
@@ -367,14 +371,14 @@ function DropdownMenuCheckboxItem({ asChild = false, checked, children, classNam
|
|
|
367
371
|
}
|
|
368
372
|
return (_jsxs("button", { ...props, ref: (node) => {
|
|
369
373
|
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: "
|
|
374
|
+
}, 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: "zvk-ui-dropdown-menu__item-indicator", "aria-hidden": "true", children: currentChecked ? "✓" : "" }), _jsx("span", { className: "zvk-ui-dropdown-menu__item-label", children: children })] }));
|
|
371
375
|
}
|
|
372
376
|
function DropdownMenuRadioGroup({ children, className, onValueChange, ref, value, ...props }) {
|
|
373
377
|
const contextValue = React.useMemo(() => ({
|
|
374
378
|
...(value !== undefined ? { value } : {}),
|
|
375
379
|
...(onValueChange ? { onValueChange } : {})
|
|
376
380
|
}), [onValueChange, value]);
|
|
377
|
-
return (_jsx(DropdownMenuRadioGroupContext.Provider, { value: contextValue, children: _jsx("div", { ...props, ref: ref, className: cn("
|
|
381
|
+
return (_jsx(DropdownMenuRadioGroupContext.Provider, { value: contextValue, children: _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-dropdown-menu__radio-group", className), role: "group", children: children }) }));
|
|
378
382
|
}
|
|
379
383
|
function DropdownMenuRadioItem({ asChild = false, children, className, disabled, onClick, onKeyDown, onSelect, ref, value, ...props }) {
|
|
380
384
|
const context = useDropdownMenuContext("DropdownMenu.RadioItem");
|
|
@@ -410,7 +414,7 @@ function DropdownMenuRadioItem({ asChild = false, children, className, disabled,
|
|
|
410
414
|
role: "menuitemradio",
|
|
411
415
|
"aria-checked": checked,
|
|
412
416
|
"aria-disabled": isDisabled ? true : undefined,
|
|
413
|
-
className: cn("
|
|
417
|
+
className: cn("zvk-ui-dropdown-menu__item", "zvk-ui-dropdown-menu__radio-item", className),
|
|
414
418
|
"data-checked": checked ? "true" : undefined,
|
|
415
419
|
"data-disabled": isDisabled ? "true" : undefined,
|
|
416
420
|
onClick: composeEventHandlers(onClick, select),
|
|
@@ -426,10 +430,10 @@ function DropdownMenuRadioItem({ asChild = false, children, className, disabled,
|
|
|
426
430
|
}
|
|
427
431
|
return (_jsxs("button", { ...props, ref: (node) => {
|
|
428
432
|
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: "
|
|
433
|
+
}, 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: "zvk-ui-dropdown-menu__item-indicator", "aria-hidden": "true", children: checked ? "●" : "" }), _jsx("span", { className: "zvk-ui-dropdown-menu__item-label", children: children })] }));
|
|
430
434
|
}
|
|
431
435
|
function DropdownMenuSub({ children, className, ref, ...props }) {
|
|
432
|
-
return (_jsx("div", { ...props, ref: ref, className: cn("
|
|
436
|
+
return (_jsx("div", { ...props, ref: ref, className: cn("zvk-ui-dropdown-menu__sub", className), children: children }));
|
|
433
437
|
}
|
|
434
438
|
export const DropdownMenu = Object.assign(DropdownMenuRoot, {
|
|
435
439
|
CheckboxItem: DropdownMenuCheckboxItem,
|
|
@@ -30,5 +30,5 @@ export function EmptyState({ actions, align = "center", children: _children, cla
|
|
|
30
30
|
const hasIcon = hasRenderableNode(icon);
|
|
31
31
|
const showDescription = description !== null && description !== undefined;
|
|
32
32
|
const showActions = actions !== null && actions !== undefined;
|
|
33
|
-
return (_jsxs("div", { ...props, ref: ref, className: cn("
|
|
33
|
+
return (_jsxs("div", { ...props, ref: ref, className: cn("zvk-ui-empty-state", className), "data-align": align, "data-size": size, children: [icon ? _jsx("div", { "aria-hidden": hasIcon ? undefined : true, className: "zvk-ui-empty-state__icon", children: icon }) : null, _jsx("h3", { className: "zvk-ui-empty-state__title", children: title }), showDescription ? _jsx("p", { className: "zvk-ui-empty-state__description", children: description }) : null, showActions ? _jsx("div", { className: "zvk-ui-empty-state__actions", children: actions }) : null] }));
|
|
34
34
|
}
|
|
@@ -39,5 +39,5 @@ export class ErrorBoundary extends React.Component {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
export function ErrorFallback({ action, className, error, ref, title = "Something went wrong", ...props }) {
|
|
42
|
-
return (_jsxs("div", { ...props, ref: ref, "aria-label": typeof title === "string" ? title : undefined, className: cn("
|
|
42
|
+
return (_jsxs("div", { ...props, ref: ref, "aria-label": typeof title === "string" ? title : undefined, className: cn("zvk-ui-error-fallback", className), role: "alert", children: [_jsx("h3", { className: "zvk-ui-error-fallback__title", children: title }), error ? _jsx("p", { className: "zvk-ui-error-fallback__message", children: error.message }) : null, action ? _jsx("div", { className: "zvk-ui-error-fallback__action", children: action }) : null] }));
|
|
43
43
|
}
|
|
@@ -2,16 +2,16 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { cn } from "../../utils/cn.js";
|
|
4
4
|
function FieldRoot({ className, disabled, invalid, ref, required, ...props }) {
|
|
5
|
-
return (_jsx("div", { ...props, ref: ref, className: cn("
|
|
5
|
+
return (_jsx("div", { ...props, ref: ref, className: cn("zvk-ui-field", className), "data-disabled": disabled ? "true" : undefined, "data-invalid": invalid ? "true" : undefined, "data-required": required ? "true" : undefined }));
|
|
6
6
|
}
|
|
7
7
|
function FieldLabel({ className, ref, ...props }) {
|
|
8
|
-
return _jsx("label", { ...props, ref: ref, className: cn("
|
|
8
|
+
return _jsx("label", { ...props, ref: ref, className: cn("zvk-ui-field__label", className) });
|
|
9
9
|
}
|
|
10
10
|
function FieldDescription({ className, ref, ...props }) {
|
|
11
|
-
return _jsx("p", { ...props, ref: ref, className: cn("
|
|
11
|
+
return _jsx("p", { ...props, ref: ref, className: cn("zvk-ui-field__description", className) });
|
|
12
12
|
}
|
|
13
13
|
function FieldError({ className, ref, role = "alert", ...props }) {
|
|
14
|
-
return _jsx("p", { ...props, ref: ref, className: cn("
|
|
14
|
+
return _jsx("p", { ...props, ref: ref, className: cn("zvk-ui-field__error", className), role: role });
|
|
15
15
|
}
|
|
16
16
|
export const Field = Object.assign(FieldRoot, {
|
|
17
17
|
Label: FieldLabel,
|
|
@@ -28,12 +28,12 @@ export function FileUploadInput({ "aria-describedby": ariaDescribedBy, buttonLab
|
|
|
28
28
|
const descriptionId = hasDescription ? `${inputId}-description` : undefined;
|
|
29
29
|
const errorId = hasError ? `${inputId}-error` : undefined;
|
|
30
30
|
const summaryId = `${inputId}-summary`;
|
|
31
|
-
const describedBy = joinIds(ariaDescribedBy, descriptionId, errorId);
|
|
31
|
+
const describedBy = joinIds(ariaDescribedBy, descriptionId, errorId, summaryId);
|
|
32
32
|
function handleChange(event) {
|
|
33
33
|
setFiles(event.currentTarget.files);
|
|
34
34
|
onChange?.(event);
|
|
35
35
|
}
|
|
36
|
-
const input = (_jsxs("div", { className: "
|
|
36
|
+
const input = (_jsxs("div", { className: "zvk-ui-file-upload-input", children: [_jsx("span", { "aria-hidden": "true", className: "zvk-ui-file-upload-input__button", children: buttonLabel }), _jsx("input", { ...props, ref: ref, "aria-describedby": describedBy, "aria-invalid": invalidState ? true : undefined, className: cn("zvk-ui-file-upload-input__control", className), "data-disabled": disabled ? "true" : undefined, "data-invalid": invalidState ? "true" : undefined, "data-required": required ? "true" : undefined, "data-size": size, disabled: disabled, id: inputId, onChange: handleChange, required: required, type: "file" }), _jsx("span", { className: "zvk-ui-file-upload-input__summary", id: summaryId, children: getFileSummary(files, emptyLabel) })] }));
|
|
37
37
|
if (!hasRenderableNode(label) && !hasDescription && !hasError) {
|
|
38
38
|
return input;
|
|
39
39
|
}
|
|
@@ -15,7 +15,7 @@ function joinIds(ids) {
|
|
|
15
15
|
return value.length > 0 ? value : undefined;
|
|
16
16
|
}
|
|
17
17
|
export function Form({ className, ref, ...props }) {
|
|
18
|
-
return _jsx("form", { ...props, ref: ref, className: cn("
|
|
18
|
+
return _jsx("form", { ...props, ref: ref, className: cn("zvk-ui-form", className) });
|
|
19
19
|
}
|
|
20
20
|
export function FormField({ children, className, disabled, id, invalid, required, ...props }) {
|
|
21
21
|
const generatedId = React.useId();
|
|
@@ -36,14 +36,14 @@ export function FormField({ children, className, disabled, id, invalid, required
|
|
|
36
36
|
registerDescription,
|
|
37
37
|
unregisterDescription
|
|
38
38
|
}), [controlId, descriptionIds, disabled, invalid, registerDescription, required, unregisterDescription]);
|
|
39
|
-
return (_jsx(FormFieldContext.Provider, { value: context, children: _jsx("div", { ...props, className: cn("
|
|
39
|
+
return (_jsx(FormFieldContext.Provider, { value: context, children: _jsx("div", { ...props, className: cn("zvk-ui-form-field", className), "data-disabled": disabled ? "true" : undefined, "data-invalid": invalid ? "true" : undefined, "data-required": required ? "true" : undefined, children: children }) }));
|
|
40
40
|
}
|
|
41
41
|
export function FormItem({ className, ref, ...props }) {
|
|
42
|
-
return _jsx("div", { ...props, ref: ref, className: cn("
|
|
42
|
+
return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-form-item", className) });
|
|
43
43
|
}
|
|
44
44
|
export function FormLabel({ className, htmlFor, ref, ...props }) {
|
|
45
45
|
const context = useFormFieldContext("FormLabel");
|
|
46
|
-
return _jsx("label", { ...props, ref: ref, className: cn("
|
|
46
|
+
return _jsx("label", { ...props, ref: ref, className: cn("zvk-ui-form-label", className), htmlFor: htmlFor ?? context.controlId });
|
|
47
47
|
}
|
|
48
48
|
export function FormControl({ children }) {
|
|
49
49
|
const context = useFormFieldContext("FormControl");
|
|
@@ -81,8 +81,8 @@ function FormText({ className, id, ref, role, textRole, ...props }) {
|
|
|
81
81
|
return _jsx("p", { ...props, ref: ref, id: textId, role: role, className: className });
|
|
82
82
|
}
|
|
83
83
|
export function FormDescription({ className, ...props }) {
|
|
84
|
-
return _jsx(FormText, { ...props, className: cn("
|
|
84
|
+
return _jsx(FormText, { ...props, className: cn("zvk-ui-form-description", className), textRole: "FormDescription" });
|
|
85
85
|
}
|
|
86
86
|
export function FormMessage({ className, role = "alert", ...props }) {
|
|
87
|
-
return _jsx(FormText, { ...props, className: cn("
|
|
87
|
+
return _jsx(FormText, { ...props, className: cn("zvk-ui-form-message", className), role: role, textRole: "FormMessage" });
|
|
88
88
|
}
|
|
@@ -29,7 +29,7 @@ export interface HoverCardContentProps extends React.HTMLAttributes<HTMLDivEleme
|
|
|
29
29
|
}
|
|
30
30
|
declare function HoverCardRoot({ children, closeDelay, defaultOpen, disabled, onOpenChange, open: openProp, openDelay, placement }: HoverCardProps): React.JSX.Element;
|
|
31
31
|
declare function HoverCardTrigger({ children, asChild: _asChild }: HoverCardTriggerProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
32
|
-
declare function HoverCardContent({ align, alignOffset
|
|
32
|
+
declare function HoverCardContent({ align, 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
33
|
export declare const HoverCard: typeof HoverCardRoot & {
|
|
34
34
|
Trigger: typeof HoverCardTrigger;
|
|
35
35
|
Content: typeof HoverCardContent;
|
|
@@ -10,6 +10,7 @@ import { cn } from "../../utils/cn.js";
|
|
|
10
10
|
import { composeEventHandlers } from "../../utils/compose-event-handlers.js";
|
|
11
11
|
const defaultContentPositioning = {
|
|
12
12
|
sideOffset: 8,
|
|
13
|
+
alignOffset: 0,
|
|
13
14
|
collisionPadding: 0
|
|
14
15
|
};
|
|
15
16
|
const HoverCardContext = React.createContext(null);
|
|
@@ -58,6 +59,7 @@ function HoverCardRoot({ children, closeDelay = 300, defaultOpen = false, disabl
|
|
|
58
59
|
open,
|
|
59
60
|
placement: contentPositioning.placement ?? placement,
|
|
60
61
|
offset: contentPositioning.sideOffset,
|
|
62
|
+
alignmentOffset: contentPositioning.alignOffset,
|
|
61
63
|
collisionPadding: contentPositioning.collisionPadding,
|
|
62
64
|
flip: true,
|
|
63
65
|
shift: true
|
|
@@ -222,7 +224,7 @@ function HoverCardTrigger({ children, asChild: _asChild = false }) {
|
|
|
222
224
|
"aria-describedby": joinIds(typeof childAriaDescribedBy === "string" ? childAriaDescribedBy : undefined, context.open ? context.contentId : undefined),
|
|
223
225
|
"aria-expanded": context.open,
|
|
224
226
|
"aria-haspopup": "dialog",
|
|
225
|
-
className: cn("
|
|
227
|
+
className: cn("zvk-ui-hover-card__trigger", childClassName),
|
|
226
228
|
"data-state": context.open ? "open" : "closed",
|
|
227
229
|
onBlur: composeEventHandlers(childProps.onBlur, (event) => {
|
|
228
230
|
context.closeAfterFocusLeaves(event.relatedTarget);
|
|
@@ -234,7 +236,7 @@ function HoverCardTrigger({ children, asChild: _asChild = false }) {
|
|
|
234
236
|
onPointerLeave: composeEventHandlers(childProps.onPointerLeave, context.closeWithDelay)
|
|
235
237
|
});
|
|
236
238
|
}
|
|
237
|
-
function HoverCardContent({ align, alignOffset
|
|
239
|
+
function HoverCardContent({ align, alignOffset = defaultContentPositioning.alignOffset, children, className, collisionPadding = defaultContentPositioning.collisionPadding, container, forceMount = false, id, onBlur, onFocus, onMouseEnter, onMouseLeave, onPointerEnter, onPointerLeave, placement, ref, side, sideOffset = defaultContentPositioning.sideOffset, style, ...props }) {
|
|
238
240
|
const context = useHoverCardContext("HoverCard.Content");
|
|
239
241
|
const contentId = id ?? context.contentId;
|
|
240
242
|
const placementParts = getPlacementParts(context.resolvedPlacement);
|
|
@@ -244,14 +246,15 @@ function HoverCardContent({ align, alignOffset: _alignOffset, children, classNam
|
|
|
244
246
|
setContentPositioning({
|
|
245
247
|
...(resolvedPlacement === undefined ? {} : { placement: resolvedPlacement }),
|
|
246
248
|
sideOffset,
|
|
249
|
+
alignOffset,
|
|
247
250
|
collisionPadding
|
|
248
251
|
});
|
|
249
252
|
return () => setContentPositioning(defaultContentPositioning);
|
|
250
|
-
}, [align, collisionPadding, placement, setContentPositioning, side, sideOffset]);
|
|
253
|
+
}, [align, alignOffset, collisionPadding, placement, setContentPositioning, side, sideOffset]);
|
|
251
254
|
if (!context.open && !forceMount) {
|
|
252
255
|
return null;
|
|
253
256
|
}
|
|
254
|
-
const content = (_jsx("div", { ...props, ref: composeRefs(ref, context.floatingRef), id: contentId, role: "dialog", className: cn("
|
|
257
|
+
const content = (_jsx("div", { ...props, ref: composeRefs(ref, context.floatingRef), id: contentId, role: "dialog", className: cn("zvk-ui-hover-card__content", className), "data-align": placementParts.align, "data-side": placementParts.side, "data-state": context.open ? "open" : "closed", hidden: context.open ? undefined : true, onBlur: composeEventHandlers(onBlur, (event) => {
|
|
255
258
|
context.closeAfterFocusLeaves(event.relatedTarget);
|
|
256
259
|
}), onFocus: composeEventHandlers(onFocus, context.openImmediately), onMouseEnter: composeEventHandlers(onMouseEnter, context.cancelClose), onMouseLeave: composeEventHandlers(onMouseLeave, context.closeWithDelay), onPointerEnter: composeEventHandlers(onPointerEnter, context.cancelClose), onPointerLeave: composeEventHandlers(onPointerLeave, context.closeWithDelay), style: { ...context.floatingStyle, ...style }, children: children }));
|
|
257
260
|
if (!context.open) {
|
|
@@ -2,7 +2,25 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { Spinner } from "../spinner/spinner.js";
|
|
4
4
|
import { cn } from "../../utils/cn.js";
|
|
5
|
+
function isDevelopmentEnvironment() {
|
|
6
|
+
const runtimeProcess = globalThis.process;
|
|
7
|
+
if (runtimeProcess?.env?.NODE_ENV) {
|
|
8
|
+
return runtimeProcess.env.NODE_ENV !== "production";
|
|
9
|
+
}
|
|
10
|
+
const metaEnv = import.meta.env;
|
|
11
|
+
if (typeof metaEnv?.DEV === "boolean") {
|
|
12
|
+
return metaEnv.DEV;
|
|
13
|
+
}
|
|
14
|
+
if (typeof metaEnv?.PROD === "boolean") {
|
|
15
|
+
return !metaEnv.PROD;
|
|
16
|
+
}
|
|
17
|
+
return typeof metaEnv?.MODE === "string" && metaEnv.MODE !== "production";
|
|
18
|
+
}
|
|
5
19
|
export function IconButton({ children, className, disabled, loading = false, ref, size = "md", type = "button", variant = "secondary", ...props }) {
|
|
6
20
|
const isDisabled = disabled || loading;
|
|
7
|
-
|
|
21
|
+
const hasAccessibleName = props["aria-label"] !== undefined || props["aria-labelledby"] !== undefined;
|
|
22
|
+
if (!hasAccessibleName && isDevelopmentEnvironment()) {
|
|
23
|
+
console.warn("IconButton requires an accessible name. Provide aria-label or aria-labelledby.");
|
|
24
|
+
}
|
|
25
|
+
return (_jsx("button", { ...props, ref: ref, "aria-busy": loading ? true : undefined, className: cn("zvk-ui-icon-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(Spinner, { size: "sm" }) : children }));
|
|
8
26
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Accordion } from "./accordion/index.js";
|
|
2
2
|
export type { AccordionContentProps, AccordionItemProps, AccordionProps, AccordionTriggerProps, AccordionType, AccordionValue } from "./accordion/index.js";
|
|
3
3
|
export { Alert } from "./alert/index.js";
|
|
4
|
-
export type { AlertDescriptionProps, AlertProps, AlertRoot, AlertTitleProps, AlertTone } from "./alert/index.js";
|
|
4
|
+
export type { AlertActionProps, AlertDescriptionProps, AlertProps, AlertRoot, AlertTitleProps, AlertTone } from "./alert/index.js";
|
|
5
5
|
export { Avatar } from "./avatar/index.js";
|
|
6
6
|
export type { AvatarProps, AvatarShape, AvatarSize } from "./avatar/index.js";
|
|
7
7
|
export { Badge } from "./badge/index.js";
|
|
@@ -11,7 +11,7 @@ export type { BreadcrumbsItemProps, BreadcrumbsProps } from "./breadcrumbs/index
|
|
|
11
11
|
export { Button } from "./button/index.js";
|
|
12
12
|
export type { ButtonProps, ButtonSize, ButtonVariant } from "./button/index.js";
|
|
13
13
|
export { Card } from "./card/index.js";
|
|
14
|
-
export type { CardDescriptionProps, CardPadding, CardProps, CardSlotProps, CardTitleProps, CardVariant } from "./card/index.js";
|
|
14
|
+
export type { CardActionProps, CardDescriptionProps, CardPadding, CardProps, CardSlotProps, CardTitleProps, CardVariant } from "./card/index.js";
|
|
15
15
|
export { Calendar } from "./calendar/index.js";
|
|
16
16
|
export type { CalendarClassNames, CalendarMode, CalendarNativeProps, CalendarProps, CalendarSingleProps } from "./calendar/index.js";
|
|
17
17
|
export { Carousel } from "./carousel/index.js";
|
|
@@ -41,9 +41,9 @@ export type { CommandDialogProps, CommandEmptyProps, CommandGroupProps, CommandI
|
|
|
41
41
|
export { Combobox } from "./combobox/index.js";
|
|
42
42
|
export type { ComboboxOption, ComboboxProps } from "./combobox/index.js";
|
|
43
43
|
export { ContextMenu } from "./context-menu/index.js";
|
|
44
|
-
export type { ContextMenuCheckboxItemProps, ContextMenuContentProps, ContextMenuItemProps, ContextMenuLabelProps, ContextMenuProps, ContextMenuSeparatorProps, ContextMenuTriggerProps } from "./context-menu/index.js";
|
|
44
|
+
export type { ContextMenuCheckboxItemProps, ContextMenuContentProps, ContextMenuItemProps, ContextMenuLabelProps, ContextMenuProps, ContextMenuRadioItemProps, ContextMenuSeparatorProps, ContextMenuTriggerProps } from "./context-menu/index.js";
|
|
45
45
|
export { Menubar } from "./menubar/index.js";
|
|
46
|
-
export type { MenubarContentProps, MenubarItemProps, MenubarLabelProps, MenubarMenuProps, MenubarProps, MenubarSeparatorProps, MenubarShortcutProps, MenubarTriggerProps } from "./menubar/index.js";
|
|
46
|
+
export type { MenubarCheckboxItemProps, MenubarContentProps, MenubarItemProps, MenubarLabelProps, MenubarMenuProps, MenubarProps, MenubarRadioItemProps, MenubarSeparatorProps, MenubarShortcutProps, MenubarTriggerProps } from "./menubar/index.js";
|
|
47
47
|
export { EmptyState } from "./empty-state/index.js";
|
|
48
48
|
export type { EmptyStateAlign, EmptyStateProps, EmptyStateSize } from "./empty-state/index.js";
|
|
49
49
|
export { ErrorBoundary, ErrorFallback } from "./error-boundary/index.js";
|
|
@@ -91,7 +91,7 @@ export type { StatProps, StatSize, StatTone } from "./stat/index.js";
|
|
|
91
91
|
export { Switch } from "./switch/index.js";
|
|
92
92
|
export type { SwitchProps, SwitchSize } from "./switch/index.js";
|
|
93
93
|
export { Table } from "./table/index.js";
|
|
94
|
-
export type { TableBodyProps, TableCaptionProps, TableCellProps, TableFooterProps, TableHeadProps, TableHeaderProps, TableProps, TableRowProps } from "./table/index.js";
|
|
94
|
+
export type { TableBodyProps, TableCaptionProps, TableCellProps, TableContainerProps, TableFooterProps, TableHeadProps, TableHeaderProps, TableProps, TableRowProps } from "./table/index.js";
|
|
95
95
|
export { Tabs } from "./tabs/index.js";
|
|
96
96
|
export type { TabsActivationMode, TabsContentProps, TabsListProps, TabsOrientation, TabsProps, TabsTriggerProps } from "./tabs/index.js";
|
|
97
97
|
export { TabsWithSidebar } from "./tabs-with-sidebar/index.js";
|
|
@@ -19,7 +19,7 @@ export function Input({ "aria-describedby": ariaDescribedBy, className, descript
|
|
|
19
19
|
const descriptionId = hasDescription ? `${inputId}-description` : undefined;
|
|
20
20
|
const errorId = hasError ? `${inputId}-error` : undefined;
|
|
21
21
|
const describedBy = joinIds(ariaDescribedBy, descriptionId, errorId);
|
|
22
|
-
const input = (_jsx("input", { ...props, ref: ref, "aria-describedby": describedBy, "aria-invalid": invalidState ? true : undefined, className: cn("
|
|
22
|
+
const input = (_jsx("input", { ...props, ref: ref, "aria-describedby": describedBy, "aria-invalid": invalidState ? true : undefined, className: cn("zvk-ui-input", className), "data-disabled": disabled ? "true" : undefined, "data-invalid": invalidState ? "true" : undefined, "data-required": required ? "true" : undefined, "data-size": size, disabled: disabled, id: inputId, required: required }));
|
|
23
23
|
if (!hasLabel && !hasDescription && !hasError) {
|
|
24
24
|
return input;
|
|
25
25
|
}
|
|
@@ -2,5 +2,5 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { cn } from "../../utils/cn.js";
|
|
4
4
|
export function Label({ children, className, disabled, ref, required, size = "md", ...props }) {
|
|
5
|
-
return (_jsx("label", { ...props, ref: ref, className: cn("
|
|
5
|
+
return (_jsx("label", { ...props, ref: ref, className: cn("zvk-ui-label", className), "data-disabled": disabled ? "true" : undefined, "data-required": required ? "true" : undefined, "data-size": size, children: children }));
|
|
6
6
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Menubar } from "./menubar.js";
|
|
2
|
-
export type { MenubarContentProps, MenubarItemProps, MenubarLabelProps, MenubarMenuProps, MenubarProps, MenubarSeparatorProps, MenubarShortcutProps, MenubarTriggerProps } from "./menubar.js";
|
|
2
|
+
export type { MenubarCheckboxItemProps, MenubarContentProps, MenubarItemProps, MenubarLabelProps, MenubarMenuProps, MenubarProps, MenubarRadioItemProps, MenubarSeparatorProps, MenubarShortcutProps, MenubarTriggerProps } from "./menubar.js";
|
|
@@ -46,7 +46,7 @@ export interface MenubarShortcutProps extends React.HTMLAttributes<HTMLSpanEleme
|
|
|
46
46
|
declare function MenubarRoot({ children, className, defaultValue, onKeyDown, onValueChange, ref, value, ...props }: MenubarProps): React.JSX.Element;
|
|
47
47
|
declare function MenubarMenu({ children, value }: MenubarMenuProps): React.JSX.Element;
|
|
48
48
|
declare function MenubarTrigger({ asChild, children, className, disabled, onClick, onKeyDown, ref, type, ...props }: MenubarTriggerProps): React.JSX.Element;
|
|
49
|
-
declare function MenubarContent({ align, alignOffset
|
|
49
|
+
declare function MenubarContent({ align, alignOffset, children, className, onKeyDown, ref, side, sideOffset, style, ...props }: MenubarContentProps): React.JSX.Element | null;
|
|
50
50
|
declare function MenubarItem({ asChild, children, className, disabled, onClick, onKeyDown, onSelect, ref, type, ...props }: MenubarItemProps): React.JSX.Element;
|
|
51
51
|
declare function MenubarCheckboxItem({ asChild, checked, children, className, defaultChecked, disabled, onCheckedChange, onClick, onKeyDown, onSelect, ref, type, ...props }: MenubarCheckboxItemProps): React.JSX.Element;
|
|
52
52
|
declare function MenubarRadioItem({ asChild, checked, children, className, disabled, onClick, onKeyDown, onSelect, ref, type, ...props }: MenubarRadioItemProps): React.JSX.Element;
|
|
@@ -6,6 +6,7 @@ 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 { useFloatingPosition } from "../../internal/floating/index.js";
|
|
9
10
|
import { placementFromSideAlign, placementParts } from "../../internal/floating/placement-aliases.js";
|
|
10
11
|
import { Portal } from "../../internal/portal/index.js";
|
|
11
12
|
import { Slot } from "../../internal/slot/index.js";
|
|
@@ -55,6 +56,14 @@ function setComposedRef(internalRef, externalRef, node) {
|
|
|
55
56
|
externalRef.current = node;
|
|
56
57
|
}
|
|
57
58
|
}
|
|
59
|
+
function setForwardedRef(externalRef, node) {
|
|
60
|
+
if (typeof externalRef === "function") {
|
|
61
|
+
externalRef(node);
|
|
62
|
+
}
|
|
63
|
+
else if (externalRef !== undefined && externalRef !== null) {
|
|
64
|
+
externalRef.current = node;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
58
67
|
function isActivationKey(key) {
|
|
59
68
|
return key === "Enter" || key === " " || key === "Space" || key === "Spacebar";
|
|
60
69
|
}
|
|
@@ -79,7 +88,7 @@ function MenubarRoot({ children, className, defaultValue, onKeyDown, onValueChan
|
|
|
79
88
|
setOpenValue,
|
|
80
89
|
unregisterTrigger
|
|
81
90
|
}), [getTriggers, openValue, registerTrigger, setOpenValue, unregisterTrigger]);
|
|
82
|
-
return (_jsx(MenubarContext.Provider, { value: contextValue, children: _jsx("div", { ...props, ref: ref, role: "menubar", className: cn("
|
|
91
|
+
return (_jsx(MenubarContext.Provider, { value: contextValue, children: _jsx("div", { ...props, ref: ref, role: "menubar", className: cn("zvk-ui-menubar", className), onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
83
92
|
const triggers = getTriggers();
|
|
84
93
|
const index = activeIndex(triggers);
|
|
85
94
|
if (event.key === "ArrowRight") {
|
|
@@ -159,7 +168,7 @@ function MenubarTrigger({ asChild = false, children, className, disabled, onClic
|
|
|
159
168
|
"aria-disabled": disabled ? true : undefined,
|
|
160
169
|
"aria-expanded": menu.open,
|
|
161
170
|
"aria-haspopup": "menu",
|
|
162
|
-
className: cn("
|
|
171
|
+
className: cn("zvk-ui-menubar__trigger", className),
|
|
163
172
|
"data-disabled": disabled ? "true" : undefined,
|
|
164
173
|
"data-state": menu.open ? "open" : "closed",
|
|
165
174
|
onClick: composeEventHandlers(onClick, handleClick),
|
|
@@ -170,17 +179,36 @@ function MenubarTrigger({ asChild = false, children, className, disabled, onClic
|
|
|
170
179
|
}
|
|
171
180
|
return (_jsx("button", { ...props, ref: (node) => {
|
|
172
181
|
setComposedRef(triggerRef, ref, node);
|
|
173
|
-
}, id: menu.triggerId, type: type, role: "menuitem", disabled: disabled, "aria-controls": menu.contentId, "aria-expanded": menu.open ? "true" : "false", "aria-haspopup": "menu", className: cn("
|
|
182
|
+
}, id: menu.triggerId, type: type, role: "menuitem", disabled: disabled, "aria-controls": menu.contentId, "aria-expanded": menu.open ? "true" : "false", "aria-haspopup": "menu", className: cn("zvk-ui-menubar__trigger", className), "data-disabled": disabled ? "true" : undefined, "data-state": menu.open ? "open" : "closed", onClick: triggerProps.onClick, onKeyDown: triggerProps.onKeyDown, children: children }));
|
|
174
183
|
}
|
|
175
|
-
function MenubarContent({ align, alignOffset
|
|
184
|
+
function MenubarContent({ align, alignOffset = 0, children, className, onKeyDown, ref, side, sideOffset = 4, style, ...props }) {
|
|
176
185
|
const menubar = useMenubarContext("Menubar.Content");
|
|
177
186
|
const menu = useMenuContext("Menubar.Content");
|
|
178
187
|
const contentPlacement = placementFromSideAlign(side, align, "bottom-start");
|
|
179
|
-
const
|
|
188
|
+
const { floatingRef, floatingStyle, placement: resolvedPlacement, referenceRef } = useFloatingPosition({
|
|
189
|
+
open: menu.open,
|
|
190
|
+
placement: contentPlacement,
|
|
191
|
+
strategy: "fixed",
|
|
192
|
+
offset: sideOffset,
|
|
193
|
+
alignmentOffset: alignOffset,
|
|
194
|
+
collisionPadding: 4
|
|
195
|
+
});
|
|
196
|
+
React.useLayoutEffect(() => {
|
|
197
|
+
if (!menu.open) {
|
|
198
|
+
referenceRef(null);
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const activeTrigger = menubar.getTriggers().find((trigger) => trigger.data.value === menu.value);
|
|
202
|
+
referenceRef(activeTrigger?.data.ref ?? null);
|
|
203
|
+
return () => referenceRef(null);
|
|
204
|
+
}, [menubar, menu.open, menu.value, referenceRef]);
|
|
180
205
|
if (!menu.open) {
|
|
181
206
|
return null;
|
|
182
207
|
}
|
|
183
|
-
return (_jsx(Portal, { children: _jsx(DismissableLayer, { open: menu.open, onDismiss: () => menubar.setOpenValue(undefined), children: _jsx("div", { ...props, ref:
|
|
208
|
+
return (_jsx(Portal, { children: _jsx(DismissableLayer, { open: menu.open, onDismiss: () => menubar.setOpenValue(undefined), children: _jsx("div", { ...props, ref: (node) => {
|
|
209
|
+
floatingRef(node);
|
|
210
|
+
setForwardedRef(ref, node);
|
|
211
|
+
}, id: menu.contentId, role: "menu", "aria-label": menu.label, "aria-labelledby": menu.triggerId, className: cn("zvk-ui-menubar__content", className), style: { ...style, ...floatingStyle }, "data-align": placementParts(resolvedPlacement).align, "data-side": placementParts(resolvedPlacement).side, onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
184
212
|
const items = menu.getItems();
|
|
185
213
|
const index = activeIndex(items);
|
|
186
214
|
if (event.key === "ArrowDown") {
|
|
@@ -228,7 +256,7 @@ function MenubarItem({ asChild = false, children, className, disabled, onClick,
|
|
|
228
256
|
},
|
|
229
257
|
role: "menuitem",
|
|
230
258
|
"aria-disabled": disabled ? true : undefined,
|
|
231
|
-
className: cn("
|
|
259
|
+
className: cn("zvk-ui-menubar__item", className),
|
|
232
260
|
"data-disabled": disabled ? "true" : undefined,
|
|
233
261
|
onClick: composeEventHandlers(onClick, select),
|
|
234
262
|
onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
@@ -282,7 +310,7 @@ function MenubarCheckboxItem({ asChild = false, checked, children, className, de
|
|
|
282
310
|
role: "menuitemcheckbox",
|
|
283
311
|
"aria-checked": currentChecked,
|
|
284
312
|
"aria-disabled": disabled ? true : undefined,
|
|
285
|
-
className: cn("
|
|
313
|
+
className: cn("zvk-ui-menubar__item", "zvk-ui-menubar__checkbox-item", className),
|
|
286
314
|
"data-checked": currentChecked ? "true" : undefined,
|
|
287
315
|
"data-disabled": disabled ? "true" : undefined,
|
|
288
316
|
onClick: composeEventHandlers(onClick, select),
|
|
@@ -298,7 +326,7 @@ function MenubarCheckboxItem({ asChild = false, checked, children, className, de
|
|
|
298
326
|
}
|
|
299
327
|
return (_jsxs("button", { ...props, ref: (node) => {
|
|
300
328
|
setComposedRef(itemRef, ref, node);
|
|
301
|
-
}, 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"], onClick: itemProps.onClick, onKeyDown: itemProps.onKeyDown, children: [_jsx("span", { className: "
|
|
329
|
+
}, 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"], onClick: itemProps.onClick, onKeyDown: itemProps.onKeyDown, children: [_jsx("span", { className: "zvk-ui-menubar__item-indicator", "aria-hidden": "true", children: currentChecked ? "✓" : "" }), _jsx("span", { className: "zvk-ui-menubar__item-label", children: children })] }));
|
|
302
330
|
}
|
|
303
331
|
function MenubarRadioItem({ asChild = false, checked = false, children, className, disabled, onClick, onKeyDown, onSelect, ref, type = "button", ...props }) {
|
|
304
332
|
const menubar = useMenubarContext("Menubar.RadioItem");
|
|
@@ -331,7 +359,7 @@ function MenubarRadioItem({ asChild = false, checked = false, children, classNam
|
|
|
331
359
|
role: "menuitemradio",
|
|
332
360
|
"aria-checked": checked,
|
|
333
361
|
"aria-disabled": disabled ? true : undefined,
|
|
334
|
-
className: cn("
|
|
362
|
+
className: cn("zvk-ui-menubar__item", "zvk-ui-menubar__radio-item", className),
|
|
335
363
|
"data-checked": checked ? "true" : undefined,
|
|
336
364
|
"data-disabled": disabled ? "true" : undefined,
|
|
337
365
|
onClick: composeEventHandlers(onClick, select),
|
|
@@ -347,16 +375,16 @@ function MenubarRadioItem({ asChild = false, checked = false, children, classNam
|
|
|
347
375
|
}
|
|
348
376
|
return (_jsxs("button", { ...props, ref: (node) => {
|
|
349
377
|
setComposedRef(itemRef, ref, node);
|
|
350
|
-
}, 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"], onClick: itemProps.onClick, onKeyDown: itemProps.onKeyDown, children: [_jsx("span", { className: "
|
|
378
|
+
}, 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"], onClick: itemProps.onClick, onKeyDown: itemProps.onKeyDown, children: [_jsx("span", { className: "zvk-ui-menubar__item-indicator", "aria-hidden": "true", children: checked ? "●" : "" }), _jsx("span", { className: "zvk-ui-menubar__item-label", children: children })] }));
|
|
351
379
|
}
|
|
352
380
|
function MenubarSeparator({ className, ref, ...props }) {
|
|
353
|
-
return _jsx("div", { ...props, ref: ref, role: "separator", "aria-hidden": "true", className: cn("
|
|
381
|
+
return _jsx("div", { ...props, ref: ref, role: "separator", "aria-hidden": "true", className: cn("zvk-ui-menubar__separator", className) });
|
|
354
382
|
}
|
|
355
383
|
function MenubarLabel({ className, ref, ...props }) {
|
|
356
|
-
return _jsx("div", { ...props, ref: ref, className: cn("
|
|
384
|
+
return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-menubar__label", className) });
|
|
357
385
|
}
|
|
358
386
|
function MenubarShortcut({ className, ref, ...props }) {
|
|
359
|
-
return _jsx("span", { ...props, ref: ref, className: cn("
|
|
387
|
+
return _jsx("span", { ...props, ref: ref, className: cn("zvk-ui-menubar__shortcut", className) });
|
|
360
388
|
}
|
|
361
389
|
export const Menubar = Object.assign(MenubarRoot, {
|
|
362
390
|
CheckboxItem: MenubarCheckboxItem,
|