@zvk/ui 0.1.3 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -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.d.ts +8 -5
- package/dist/components/alert-dialog/alert-dialog.js +26 -13
- 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.d.ts +3 -2
- package/dist/components/button/button.js +50 -2
- package/dist/components/calendar/calendar.d.ts +40 -5
- package/dist/components/calendar/calendar.js +17 -5
- package/dist/components/calendar/index.d.ts +1 -1
- 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.d.ts +3 -2
- package/dist/components/collapsible/collapsible.js +8 -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.d.ts +11 -4
- package/dist/components/command/command.js +28 -17
- package/dist/components/command/index.d.ts +1 -1
- package/dist/components/context-menu/context-menu.d.ts +17 -6
- package/dist/components/context-menu/context-menu.js +142 -39
- 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.d.ts +6 -4
- package/dist/components/dialog/dialog.js +22 -12
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +13 -7
- package/dist/components/dropdown-menu/dropdown-menu.js +137 -78
- 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 +8 -2
- package/dist/components/hover-card/hover-card.js +13 -7
- package/dist/components/icon-button/icon-button.js +19 -1
- package/dist/components/index.d.ts +10 -10
- package/dist/components/index.js +1 -1
- package/dist/components/input/input.js +1 -1
- package/dist/components/label/label.js +1 -1
- package/dist/components/menubar/menubar.d.ts +24 -5
- package/dist/components/menubar/menubar.js +186 -37
- package/dist/components/pagination/pagination.js +12 -12
- package/dist/components/popover/popover.d.ts +8 -3
- package/dist/components/popover/popover.js +40 -8
- 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.d.ts +6 -4
- package/dist/components/sheet/sheet.js +29 -16
- 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/index.d.ts +2 -2
- package/dist/components/toast/index.js +1 -1
- package/dist/components/toast/toast.d.ts +16 -2
- package/dist/components/toast/toast.js +49 -7
- 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 +8 -2
- package/dist/components/tooltip/tooltip.js +12 -6
- 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/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/placement-aliases.d.ts +7 -0
- package/dist/internal/floating/placement-aliases.js +13 -0
- package/dist/internal/floating/use-floating-position.js +6 -4
- package/dist/internal/overlay-stack/overlay-stack.js +4 -1
- package/dist/internal/slot/index.d.ts +2 -0
- package/dist/internal/slot/index.js +1 -0
- package/dist/internal/slot/slot.d.ts +6 -0
- package/dist/internal/slot/slot.js +53 -0
- package/dist/styles.css +2079 -2015
- 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 +13 -12
|
@@ -7,8 +7,11 @@ import { cn } from "../../utils/cn.js";
|
|
|
7
7
|
import { Portal } from "../../internal/portal/index.js";
|
|
8
8
|
import { DismissableLayer } from "../../internal/dismissable-layer/index.js";
|
|
9
9
|
import { useFloatingPosition } from "../../internal/floating/index.js";
|
|
10
|
+
import { placementFromSideAlign } from "../../internal/floating/placement-aliases.js";
|
|
11
|
+
import { Slot } from "../../internal/slot/index.js";
|
|
10
12
|
const defaultPositioning = {
|
|
11
13
|
sideOffset: 0,
|
|
14
|
+
alignOffset: 0,
|
|
12
15
|
collisionPadding: 0,
|
|
13
16
|
matchTriggerWidth: false
|
|
14
17
|
};
|
|
@@ -53,6 +56,20 @@ function getPlacementParts(placement) {
|
|
|
53
56
|
const [side, align = "center"] = placement.split("-");
|
|
54
57
|
return { side, align };
|
|
55
58
|
}
|
|
59
|
+
function isDevelopmentEnvironment() {
|
|
60
|
+
const runtimeProcess = globalThis.process;
|
|
61
|
+
if (runtimeProcess?.env?.NODE_ENV) {
|
|
62
|
+
return runtimeProcess.env.NODE_ENV !== "production";
|
|
63
|
+
}
|
|
64
|
+
const metaEnv = import.meta.env;
|
|
65
|
+
if (typeof metaEnv?.DEV === "boolean") {
|
|
66
|
+
return metaEnv.DEV;
|
|
67
|
+
}
|
|
68
|
+
if (typeof metaEnv?.PROD === "boolean") {
|
|
69
|
+
return !metaEnv.PROD;
|
|
70
|
+
}
|
|
71
|
+
return typeof metaEnv?.MODE === "string" && metaEnv.MODE !== "production";
|
|
72
|
+
}
|
|
56
73
|
function PopoverRoot({ children, className, defaultOpen = false, modal = false, onOpenChange, open, placement = "bottom", ref, ...props }) {
|
|
57
74
|
const defaultContentId = `${React.useId()}-content`;
|
|
58
75
|
const [contentId, setContentId] = React.useState(defaultContentId);
|
|
@@ -70,6 +87,7 @@ function PopoverRoot({ children, className, defaultOpen = false, modal = false,
|
|
|
70
87
|
open: isOpen,
|
|
71
88
|
placement: contentPositioning.placement ?? placement,
|
|
72
89
|
offset: contentPositioning.sideOffset,
|
|
90
|
+
alignmentOffset: contentPositioning.alignOffset,
|
|
73
91
|
collisionPadding: contentPositioning.collisionPadding,
|
|
74
92
|
matchReferenceWidth: contentPositioning.matchTriggerWidth
|
|
75
93
|
});
|
|
@@ -95,20 +113,26 @@ function PopoverRoot({ children, className, defaultOpen = false, modal = false,
|
|
|
95
113
|
floatingPlacement: resolvedPlacement,
|
|
96
114
|
updatePosition,
|
|
97
115
|
updateContentPositioning
|
|
98
|
-
}, children: _jsx("div", { ...props, ref: handleRef, className: cn("
|
|
116
|
+
}, children: _jsx("div", { ...props, ref: handleRef, className: cn("zvk-ui-popover", className), "data-state": isOpen ? "open" : "closed", children: children }) }));
|
|
99
117
|
}
|
|
100
|
-
function PopoverTrigger({ className, onClick, ref, type = "button", ...props }) {
|
|
118
|
+
function PopoverTrigger({ asChild = false, className, disabled, onClick, ref, type = "button", ...props }) {
|
|
101
119
|
const context = usePopoverContext("Popover.Trigger");
|
|
102
120
|
const handleClick = () => {
|
|
121
|
+
if (disabled) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
103
124
|
context.setOpen((value) => !value);
|
|
104
125
|
};
|
|
105
126
|
const handleRef = React.useCallback((node) => {
|
|
106
127
|
context.referenceRef(node);
|
|
107
128
|
mergeRef(ref, node);
|
|
108
129
|
}, [context.referenceRef, ref]);
|
|
109
|
-
|
|
130
|
+
if (asChild) {
|
|
131
|
+
return (_jsx(Slot, { ...props, ref: handleRef, "aria-controls": context.contentId, "aria-disabled": disabled ? true : undefined, "aria-expanded": context.open, "aria-haspopup": "dialog", className: cn("zvk-ui-popover__trigger", className), "data-disabled": disabled ? "true" : undefined, "data-state": context.open ? "open" : "closed", onClick: composeEventHandlers(onClick, handleClick), children: props.children }));
|
|
132
|
+
}
|
|
133
|
+
return (_jsx("button", { ...props, ref: handleRef, type: type, disabled: disabled, className: cn("zvk-ui-popover__trigger", className), "aria-expanded": context.open, "aria-controls": context.contentId, "aria-haspopup": "dialog", "data-state": context.open ? "open" : "closed", onClick: composeEventHandlers(onClick, handleClick) }));
|
|
110
134
|
}
|
|
111
|
-
function PopoverContent({ className, container, forceMount = false, id, disableEscapeKeyDown = false, disableOutsidePointerDown = false, ref, placement, sideOffset = 0, collisionPadding = 0, matchTriggerWidth = false, style, ...props }) {
|
|
135
|
+
function PopoverContent({ align, alignOffset = defaultPositioning.alignOffset, className, container, forceMount = false, id, disableEscapeKeyDown = false, disableOutsidePointerDown = false, ref, placement, side, sideOffset = 0, collisionPadding = 0, matchTriggerWidth = false, style, ...props }) {
|
|
112
136
|
const context = usePopoverContext("Popover.Content");
|
|
113
137
|
const { defaultContentId, setContentId } = context;
|
|
114
138
|
const transformOrigin = getTransformOrigin(context.floatingPlacement);
|
|
@@ -121,7 +145,7 @@ function PopoverContent({ className, container, forceMount = false, id, disableE
|
|
|
121
145
|
const contentStyle = React.useMemo(() => ({
|
|
122
146
|
...context.floatingStyle,
|
|
123
147
|
...style,
|
|
124
|
-
"--
|
|
148
|
+
"--zvk-ui-popover-transform-origin": transformOrigin
|
|
125
149
|
}), [context.floatingStyle, style, transformOrigin]);
|
|
126
150
|
React.useLayoutEffect(() => {
|
|
127
151
|
setContentId(contentId);
|
|
@@ -140,20 +164,28 @@ function PopoverContent({ className, container, forceMount = false, id, disableE
|
|
|
140
164
|
}
|
|
141
165
|
}, [context.referenceElement]);
|
|
142
166
|
React.useEffect(() => {
|
|
167
|
+
const resolvedPlacement = side === undefined ? placement : placementFromSideAlign(side, align, placement ?? "bottom");
|
|
143
168
|
context.updateContentPositioning({
|
|
144
|
-
...(
|
|
169
|
+
...(resolvedPlacement === undefined ? {} : { placement: resolvedPlacement }),
|
|
145
170
|
sideOffset,
|
|
171
|
+
alignOffset,
|
|
146
172
|
collisionPadding,
|
|
147
173
|
matchTriggerWidth
|
|
148
174
|
});
|
|
149
175
|
return () => {
|
|
150
176
|
context.updateContentPositioning(defaultPositioning);
|
|
151
177
|
};
|
|
152
|
-
}, [context.updateContentPositioning, collisionPadding, matchTriggerWidth, placement, sideOffset]);
|
|
178
|
+
}, [align, alignOffset, context.updateContentPositioning, collisionPadding, matchTriggerWidth, placement, side, sideOffset]);
|
|
153
179
|
if (!forceMount && !context.open) {
|
|
154
180
|
return null;
|
|
155
181
|
}
|
|
156
|
-
const content = (_jsx("div", { ...props, ref: handleRef, id: contentId, role: "dialog", className: cn("
|
|
182
|
+
const content = (_jsx("div", { ...props, ref: handleRef, id: contentId, role: "dialog", className: cn("zvk-ui-popover__content", className), "data-align": placementParts.align, "data-side": placementParts.side, "data-state": context.open ? "open" : "closed", hidden: context.open ? undefined : true, style: contentStyle }));
|
|
183
|
+
if (context.open &&
|
|
184
|
+
props["aria-label"] === undefined &&
|
|
185
|
+
props["aria-labelledby"] === undefined &&
|
|
186
|
+
isDevelopmentEnvironment()) {
|
|
187
|
+
console.warn("Popover.Content renders role=\"dialog\" and requires an accessible name. Provide aria-label or aria-labelledby.");
|
|
188
|
+
}
|
|
157
189
|
if (!context.open) {
|
|
158
190
|
return _jsx(Portal, { ...(container === undefined ? {} : { container }), children: content });
|
|
159
191
|
}
|
|
@@ -22,8 +22,8 @@ export function getProgressState({ max = 100, value }) {
|
|
|
22
22
|
export function Progress({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, className, label, max, ref, showValue, size = "md", tone = "primary", value, ...props }) {
|
|
23
23
|
const state = getProgressState({ max, value });
|
|
24
24
|
const valueText = state.percentage === undefined ? undefined : `${Math.round(state.percentage)}%`;
|
|
25
|
-
return (_jsxs("div", { className: "
|
|
25
|
+
return (_jsxs("div", { className: "zvk-ui-progress-group", children: [label ? _jsx("span", { className: "zvk-ui-progress__label", children: label }) : null, _jsx("div", { ...props, ref: ref, "aria-label": ariaLabel ?? (typeof label === "string" ? label : undefined), "aria-labelledby": ariaLabelledBy, "aria-valuemax": state.indeterminate ? undefined : state.max, "aria-valuemin": state.indeterminate ? undefined : 0, "aria-valuenow": state.value, className: cn("zvk-ui-progress", className), "data-indeterminate": state.indeterminate ? "true" : undefined, "data-size": size, "data-tone": tone, role: "progressbar", style: {
|
|
26
26
|
...props.style,
|
|
27
|
-
"--
|
|
28
|
-
}, children: _jsx("span", { className: "
|
|
27
|
+
"--zvk-ui-progress-value": state.percentage === undefined ? undefined : `${state.percentage}%`
|
|
28
|
+
}, children: _jsx("span", { className: "zvk-ui-progress__track", children: _jsx("span", { className: "zvk-ui-progress__indicator" }) }) }), showValue && valueText ? _jsx("span", { className: "zvk-ui-progress__value", children: valueText }) : null] }));
|
|
29
29
|
}
|
|
@@ -28,8 +28,8 @@ function NativeRadioItem({ "aria-describedby": ariaDescribedBy, checked, classNa
|
|
|
28
28
|
const inputId = id ?? generatedId;
|
|
29
29
|
const descriptionId = hasRenderableNode(description) ? `${inputId}-description` : undefined;
|
|
30
30
|
const describedBy = joinIds(ariaDescribedBy, descriptionId);
|
|
31
|
-
const input = (_jsx("input", { ...props, ref: ref, "aria-describedby": describedBy, "aria-invalid": invalid ? true : undefined, checked: checked, className: "
|
|
32
|
-
return (_jsxs("div", { className: cn("
|
|
31
|
+
const input = (_jsx("input", { ...props, ref: ref, "aria-describedby": describedBy, "aria-invalid": invalid ? true : undefined, checked: checked, className: "zvk-ui-radio-group__input", defaultChecked: defaultChecked, disabled: disabled, id: inputId, name: name, onChange: onChange, required: required, type: "radio", value: value }));
|
|
32
|
+
return (_jsxs("div", { className: cn("zvk-ui-radio-group__item", className), children: [_jsxs("label", { className: "zvk-ui-radio-group__option", children: [input, _jsx("span", { className: "zvk-ui-radio-group__control", "aria-hidden": "true" }), hasRenderableNode(label) ? _jsx("span", { className: "zvk-ui-radio-group__label", children: label }) : null] }), hasRenderableNode(description) ? (_jsx("p", { className: "zvk-ui-radio-group__option-description", id: descriptionId, children: description })) : null] }));
|
|
33
33
|
}
|
|
34
34
|
export function RadioGroupItem({ disabled, value, ...props }) {
|
|
35
35
|
const context = useRadioGroupContext("RadioGroup.Item");
|
|
@@ -62,7 +62,7 @@ function RadioGroupRoot({ "aria-describedby": ariaDescribedBy, children, classNa
|
|
|
62
62
|
...(required !== undefined ? { required } : {}),
|
|
63
63
|
...(value !== undefined ? { value } : {})
|
|
64
64
|
}), [baseId, defaultValue, disabled, invalidState, name, onValueChange, required, value]);
|
|
65
|
-
return (_jsx(RadioGroupContext.Provider, { value: context, children: _jsxs("fieldset", { ...props, ref: ref, "aria-describedby": describedBy, className: cn("
|
|
65
|
+
return (_jsx(RadioGroupContext.Provider, { value: context, children: _jsxs("fieldset", { ...props, ref: ref, "aria-describedby": describedBy, className: cn("zvk-ui-radio-group", className), "data-disabled": disabled ? "true" : undefined, "data-invalid": invalidState ? "true" : undefined, "data-orientation": orientation, "data-required": required ? "true" : undefined, "data-size": size, id: id, disabled: disabled, children: [_jsx("legend", { className: "zvk-ui-radio-group__legend", children: label }), _jsxs("div", { className: "zvk-ui-radio-group__items", children: [optionItems, children] }), hasRenderableNode(description) ? _jsx("p", { className: "zvk-ui-radio-group__description", id: descriptionId, children: description }) : null, hasRenderableNode(error) ? _jsx("p", { className: "zvk-ui-radio-group__error", id: errorId, children: error }) : null] }) }));
|
|
66
66
|
}
|
|
67
67
|
export const RadioGroup = Object.assign(RadioGroupRoot, {
|
|
68
68
|
Item: RadioGroupItem
|
|
@@ -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 ResponsiveContainer({ center = true, className, gutter = "md", ref, size = "lg", ...props }) {
|
|
5
|
-
return (_jsx("div", { ...props, ref: ref, className: cn("
|
|
5
|
+
return (_jsx("div", { ...props, ref: ref, className: cn("zvk-ui-responsive-container", className), "data-center": center ? "true" : "false", "data-gutter": gutter, "data-size": size }));
|
|
6
6
|
}
|
|
@@ -10,13 +10,13 @@ function sizeValue(value) {
|
|
|
10
10
|
function ScrollAreaRoot({ className, maxHeight, maxWidth, orientation = "vertical", ref, style, tabIndex = 0, type = "auto", ...props }) {
|
|
11
11
|
const resolvedStyle = {
|
|
12
12
|
...style,
|
|
13
|
-
...(maxHeight !== undefined ? { "--
|
|
14
|
-
...(maxWidth !== undefined ? { "--
|
|
13
|
+
...(maxHeight !== undefined ? { "--zvk-ui-scroll-area-max-height": sizeValue(maxHeight) } : {}),
|
|
14
|
+
...(maxWidth !== undefined ? { "--zvk-ui-scroll-area-max-width": sizeValue(maxWidth) } : {})
|
|
15
15
|
};
|
|
16
|
-
return (_jsx("div", { ...props, ref: ref, className: cn("
|
|
16
|
+
return (_jsx("div", { ...props, ref: ref, className: cn("zvk-ui-scroll-area", className), "data-orientation": orientation, "data-type": type, style: resolvedStyle, tabIndex: tabIndex }));
|
|
17
17
|
}
|
|
18
18
|
function ScrollBar({ className, orientation = "vertical", ref, ...props }) {
|
|
19
|
-
return (_jsx("div", { ...props, ref: ref, "aria-hidden": "true", className: cn("
|
|
19
|
+
return (_jsx("div", { ...props, ref: ref, "aria-hidden": "true", className: cn("zvk-ui-scroll-area__scrollbar", className), "data-orientation": orientation }));
|
|
20
20
|
}
|
|
21
21
|
export const ScrollArea = Object.assign(ScrollAreaRoot, {
|
|
22
22
|
ScrollBar
|
|
@@ -2,23 +2,23 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { cn } from "../../utils/cn.js";
|
|
4
4
|
function SectionedSidebarNavRoot({ className, label = "Sidebar navigation", ref, ...props }) {
|
|
5
|
-
return (_jsx("nav", { ...props, ref: ref, "aria-label": props["aria-label"] ?? label, className: cn("
|
|
5
|
+
return (_jsx("nav", { ...props, ref: ref, "aria-label": props["aria-label"] ?? label, className: cn("zvk-ui-sectioned-sidebar-nav", className) }));
|
|
6
6
|
}
|
|
7
7
|
function SectionedSidebarNavSection({ className, ref, ...props }) {
|
|
8
|
-
return _jsx("section", { ...props, ref: ref, className: cn("
|
|
8
|
+
return _jsx("section", { ...props, ref: ref, className: cn("zvk-ui-sectioned-sidebar-nav__section", className) });
|
|
9
9
|
}
|
|
10
10
|
function SectionedSidebarNavSectionTitle({ className, ref, ...props }) {
|
|
11
|
-
return _jsx("h2", { ...props, ref: ref, className: cn("
|
|
11
|
+
return _jsx("h2", { ...props, ref: ref, className: cn("zvk-ui-sectioned-sidebar-nav__section-title", className) });
|
|
12
12
|
}
|
|
13
13
|
function SectionedSidebarNavList({ className, ref, ...props }) {
|
|
14
|
-
return _jsx("ul", { ...props, ref: ref, className: cn("
|
|
14
|
+
return _jsx("ul", { ...props, ref: ref, className: cn("zvk-ui-sectioned-sidebar-nav__list", className) });
|
|
15
15
|
}
|
|
16
16
|
function SectionedSidebarNavItem(props) {
|
|
17
17
|
const { active = false, badge, className, disabled = false, icon, ...itemProps } = props;
|
|
18
|
-
const content = (_jsxs(_Fragment, { children: [icon ? (_jsx("span", { "aria-hidden": "true", className: "
|
|
18
|
+
const content = (_jsxs(_Fragment, { children: [icon ? (_jsx("span", { "aria-hidden": "true", className: "zvk-ui-sectioned-sidebar-nav__item-icon", children: icon })) : null, _jsx("span", { className: "zvk-ui-sectioned-sidebar-nav__item-label", children: props.children }), badge ? _jsx("span", { className: "zvk-ui-sectioned-sidebar-nav__item-badge", children: badge }) : null] }));
|
|
19
19
|
if ("href" in itemProps && typeof itemProps.href === "string") {
|
|
20
20
|
const { onClick, ref, ...anchorProps } = itemProps;
|
|
21
|
-
return (_jsx("li", { className: "
|
|
21
|
+
return (_jsx("li", { className: "zvk-ui-sectioned-sidebar-nav__item", children: _jsx("a", { ...anchorProps, ref: ref, "aria-current": active ? "page" : undefined, "aria-disabled": disabled ? true : undefined, className: cn("zvk-ui-sectioned-sidebar-nav__item-control", className), "data-disabled": disabled ? "true" : undefined, "data-state": active ? "active" : "inactive", onClick: (event) => {
|
|
22
22
|
if (disabled) {
|
|
23
23
|
event.preventDefault();
|
|
24
24
|
return;
|
|
@@ -27,7 +27,7 @@ function SectionedSidebarNavItem(props) {
|
|
|
27
27
|
}, tabIndex: disabled ? -1 : anchorProps.tabIndex, children: content }) }));
|
|
28
28
|
}
|
|
29
29
|
const { ref, type = "button", ...buttonProps } = itemProps;
|
|
30
|
-
return (_jsx("li", { className: "
|
|
30
|
+
return (_jsx("li", { className: "zvk-ui-sectioned-sidebar-nav__item", children: _jsx("button", { ...buttonProps, ref: ref, className: cn("zvk-ui-sectioned-sidebar-nav__item-control", className), "data-disabled": disabled ? "true" : undefined, "data-state": active ? "active" : "inactive", disabled: disabled, type: type, children: content }) }));
|
|
31
31
|
}
|
|
32
32
|
export const SectionedSidebarNav = Object.assign(SectionedSidebarNavRoot, {
|
|
33
33
|
Section: SectionedSidebarNavSection,
|
|
@@ -7,6 +7,14 @@ import { cn } from "../../utils/cn.js";
|
|
|
7
7
|
import { Portal } from "../../internal/portal/index.js";
|
|
8
8
|
import { DismissableLayer } from "../../internal/dismissable-layer/index.js";
|
|
9
9
|
import { useFloatingPosition } from "../../internal/floating/index.js";
|
|
10
|
+
const nativeSelectStyle = {
|
|
11
|
+
position: "absolute",
|
|
12
|
+
width: 1,
|
|
13
|
+
height: 1,
|
|
14
|
+
margin: -1,
|
|
15
|
+
opacity: 0,
|
|
16
|
+
pointerEvents: "none"
|
|
17
|
+
};
|
|
10
18
|
const defaultContentPositioning = {
|
|
11
19
|
sideOffset: 4,
|
|
12
20
|
collisionPadding: 0,
|
|
@@ -35,6 +43,33 @@ function composeRefs(...refs) {
|
|
|
35
43
|
function getTextLabel(node) {
|
|
36
44
|
return node;
|
|
37
45
|
}
|
|
46
|
+
function getNativeOptionLabel(label, value) {
|
|
47
|
+
if (typeof label === "string" || typeof label === "number") {
|
|
48
|
+
return String(label);
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
function collectNativeOptions(children) {
|
|
53
|
+
const options = [];
|
|
54
|
+
function visit(node) {
|
|
55
|
+
React.Children.forEach(node, (child) => {
|
|
56
|
+
if (!React.isValidElement(child)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (child.type === SelectItem && typeof child.props.value === "string") {
|
|
60
|
+
options.push({
|
|
61
|
+
disabled: child.props.disabled === true,
|
|
62
|
+
label: getNativeOptionLabel(child.props.children, child.props.value),
|
|
63
|
+
value: child.props.value
|
|
64
|
+
});
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
visit(child.props.children);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
visit(children);
|
|
71
|
+
return options;
|
|
72
|
+
}
|
|
38
73
|
function SelectRoot({ children, className, defaultOpen = false, defaultValue = null, disabled, invalid, name, onOpenChange, onValueChange, open: openProp, placeholder, placement = "bottom-start", required, size = "md", value, ...props }) {
|
|
39
74
|
const instanceId = React.useId();
|
|
40
75
|
const triggerId = `${instanceId}-trigger`;
|
|
@@ -54,6 +89,8 @@ function SelectRoot({ children, className, defaultOpen = false, defaultValue = n
|
|
|
54
89
|
defaultValue,
|
|
55
90
|
...(onValueChange ? { onChange: onValueChange } : {})
|
|
56
91
|
});
|
|
92
|
+
const [nativeInvalid, setNativeInvalid] = React.useState(false);
|
|
93
|
+
const nativeOptions = React.useMemo(() => collectNativeOptions(children), [children]);
|
|
57
94
|
const [contentPositioning, setContentPositioning] = React.useState(defaultContentPositioning);
|
|
58
95
|
const floating = useFloatingPosition({
|
|
59
96
|
open,
|
|
@@ -85,18 +122,34 @@ function SelectRoot({ children, className, defaultOpen = false, defaultValue = n
|
|
|
85
122
|
setCurrentValue(nextValue);
|
|
86
123
|
setOpen(false);
|
|
87
124
|
}, [setCurrentValue, setOpen]);
|
|
88
|
-
const
|
|
125
|
+
const orderedItems = React.useMemo(() => getOrderedItems(), [getOrderedItems, itemsVersion]);
|
|
126
|
+
const selectedLabel = React.useMemo(() => orderedItems.find((item) => item.value === currentValue)?.label ??
|
|
127
|
+
nativeOptions.find((item) => item.value === currentValue)?.label, [currentValue, nativeOptions, orderedItems]);
|
|
128
|
+
const resolvedInvalid = Boolean(invalid) || nativeInvalid;
|
|
129
|
+
const nativeValue = currentValue !== null && nativeOptions.some((option) => option.value === currentValue)
|
|
130
|
+
? currentValue
|
|
131
|
+
: "";
|
|
89
132
|
React.useEffect(() => {
|
|
90
133
|
if (wasOpenRef.current && !open) {
|
|
91
134
|
triggerRef.current?.focus();
|
|
92
135
|
}
|
|
93
136
|
wasOpenRef.current = open;
|
|
94
137
|
}, [open]);
|
|
138
|
+
React.useEffect(() => {
|
|
139
|
+
if (!required || currentValue !== null) {
|
|
140
|
+
setNativeInvalid(false);
|
|
141
|
+
}
|
|
142
|
+
}, [currentValue, required]);
|
|
143
|
+
const handleNativeInvalid = React.useCallback((event) => {
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
setNativeInvalid(true);
|
|
146
|
+
triggerRef.current?.focus();
|
|
147
|
+
}, []);
|
|
95
148
|
const context = React.useMemo(() => ({
|
|
96
149
|
contentId,
|
|
97
150
|
...(disabled !== undefined ? { disabled } : {}),
|
|
98
151
|
getEnabledItems,
|
|
99
|
-
...(
|
|
152
|
+
...(resolvedInvalid ? { invalid: true } : {}),
|
|
100
153
|
open,
|
|
101
154
|
...(placeholder !== undefined ? { placeholder } : {}),
|
|
102
155
|
registerItem,
|
|
@@ -112,8 +165,8 @@ function SelectRoot({ children, className, defaultOpen = false, defaultValue = n
|
|
|
112
165
|
referenceRef: floating.referenceRef,
|
|
113
166
|
floatingRef: floating.floatingRef,
|
|
114
167
|
floatingStyle: floating.floatingStyle
|
|
115
|
-
}), [contentId, currentValue, disabled, floating.floatingRef, floating.floatingStyle, floating.referenceRef, getEnabledItems,
|
|
116
|
-
return (_jsx(SelectContext.Provider, { value: context, children: _jsxs("div", { ...props, className: cn("
|
|
168
|
+
}), [contentId, currentValue, disabled, floating.floatingRef, floating.floatingStyle, floating.referenceRef, getEnabledItems, open, placeholder, registerItem, required, resolvedInvalid, selectValue, selectedLabel, setOpen, triggerId, unregisterItem]);
|
|
169
|
+
return (_jsx(SelectContext.Provider, { value: context, children: _jsxs("div", { ...props, className: cn("zvk-ui-select", className), "data-disabled": disabled ? "true" : undefined, "data-invalid": resolvedInvalid ? "true" : undefined, "data-required": required ? "true" : undefined, "data-size": size, "data-state": open ? "open" : "closed", children: [name ? (_jsxs("select", { "aria-hidden": "true", disabled: disabled, name: name, onChange: () => undefined, onInvalid: handleNativeInvalid, required: required, style: nativeSelectStyle, tabIndex: -1, value: nativeValue, children: [_jsx("option", { value: "" }), nativeOptions.map((item) => (_jsx("option", { disabled: item.disabled, value: item.value, children: item.label }, item.value)))] })) : null, children] }) }));
|
|
117
170
|
}
|
|
118
171
|
function focusItem(items, index) {
|
|
119
172
|
if (items.length === 0) {
|
|
@@ -137,7 +190,7 @@ function SelectTrigger({ children, className, disabled, onClick, onKeyDown, ref,
|
|
|
137
190
|
focusItem(items, selectedIndex >= 0 ? selectedIndex : 0);
|
|
138
191
|
});
|
|
139
192
|
}, [context]);
|
|
140
|
-
return (_jsx("button", { ...props, ref: composeRefs(ref, context.triggerRef, context.referenceRef), "aria-controls": context.contentId, "aria-expanded": context.open ? "true" : "false", "aria-haspopup": "listbox", "aria-invalid": context.invalid ? "true" : undefined, "aria-required": context.required ? "true" : undefined, className: cn("
|
|
193
|
+
return (_jsx("button", { ...props, ref: composeRefs(ref, context.triggerRef, context.referenceRef), "aria-controls": context.contentId, "aria-expanded": context.open ? "true" : "false", "aria-haspopup": "listbox", "aria-invalid": context.invalid ? "true" : undefined, "aria-required": context.required ? "true" : undefined, className: cn("zvk-ui-select__trigger", className), "data-disabled": isDisabled ? "true" : undefined, "data-invalid": context.invalid ? "true" : undefined, "data-state": context.open ? "open" : "closed", disabled: isDisabled, id: context.triggerId, onClick: composeEventHandlers(onClick, () => {
|
|
141
194
|
if (!isDisabled) {
|
|
142
195
|
context.setOpen(!context.open);
|
|
143
196
|
}
|
|
@@ -158,7 +211,7 @@ function SelectTrigger({ children, className, disabled, onClick, onKeyDown, ref,
|
|
|
158
211
|
function SelectValue({ className, placeholder, ref, ...props }) {
|
|
159
212
|
const context = useSelectContext("Select.Value");
|
|
160
213
|
const displayPlaceholder = context.selectedLabel === undefined;
|
|
161
|
-
return (_jsx("span", { ...props, ref: ref, className: cn("
|
|
214
|
+
return (_jsx("span", { ...props, ref: ref, className: cn("zvk-ui-select__value", className), "data-placeholder": displayPlaceholder ? "true" : undefined, children: displayPlaceholder ? placeholder ?? context.placeholder : context.selectedLabel }));
|
|
162
215
|
}
|
|
163
216
|
function SelectContent({ children, className, collisionPadding = defaultContentPositioning.collisionPadding, container, forceMount = false, matchTriggerWidth = defaultContentPositioning.matchTriggerWidth, onKeyDown, ref, sideOffset = defaultContentPositioning.sideOffset, style, ...props }) {
|
|
164
217
|
const context = useSelectContext("Select.Content");
|
|
@@ -182,7 +235,7 @@ function SelectContent({ children, className, collisionPadding = defaultContentP
|
|
|
182
235
|
if (!context.open && !forceMount) {
|
|
183
236
|
return null;
|
|
184
237
|
}
|
|
185
|
-
const content = (_jsx("div", { ...props, ref: composeRefs(ref, context.floatingRef), "aria-labelledby": context.triggerId, className: cn("
|
|
238
|
+
const content = (_jsx("div", { ...props, ref: composeRefs(ref, context.floatingRef), "aria-labelledby": context.triggerId, className: cn("zvk-ui-select__content", className), "data-state": context.open ? "open" : "closed", hidden: context.open ? undefined : true, id: context.contentId, onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
186
239
|
if (event.key === "ArrowDown") {
|
|
187
240
|
event.preventDefault();
|
|
188
241
|
moveFocus("next");
|
|
@@ -228,26 +281,26 @@ function SelectItem({ children, className, disabled = false, onClick, onKeyDown,
|
|
|
228
281
|
context.selectValue(value);
|
|
229
282
|
}
|
|
230
283
|
};
|
|
231
|
-
return (_jsxs("div", { ...props, ref: composeRefs(ref, itemRef), "aria-disabled": disabled ? "true" : undefined, "aria-selected": selected ? "true" : "false", className: cn("
|
|
284
|
+
return (_jsxs("div", { ...props, ref: composeRefs(ref, itemRef), "aria-disabled": disabled ? "true" : undefined, "aria-selected": selected ? "true" : "false", className: cn("zvk-ui-select__item", className), "data-disabled": disabled ? "true" : undefined, "data-state": selected ? "checked" : "unchecked", id: itemId, onClick: composeEventHandlers(onClick, select), onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
232
285
|
if (event.key === "Enter" || event.key === " " || event.key === "Space" || event.key === "Spacebar") {
|
|
233
286
|
event.preventDefault();
|
|
234
287
|
select();
|
|
235
288
|
}
|
|
236
|
-
}), role: "option", tabIndex: disabled ? undefined : -1, children: [_jsx("span", { className: "
|
|
289
|
+
}), role: "option", tabIndex: disabled ? undefined : -1, children: [_jsx("span", { className: "zvk-ui-select__item-indicator", "aria-hidden": "true", children: selected ? "✓" : "" }), _jsx("span", { className: "zvk-ui-select__item-label", children: children })] }));
|
|
237
290
|
}
|
|
238
291
|
function SelectGroup({ children, className, ref, ...props }) {
|
|
239
|
-
return (_jsx("div", { ...props, ref: ref, className: cn("
|
|
292
|
+
return (_jsx("div", { ...props, ref: ref, className: cn("zvk-ui-select__group", className), role: "group", children: children }));
|
|
240
293
|
}
|
|
241
294
|
function SelectLabel({ className, ref, ...props }) {
|
|
242
|
-
return (_jsx("div", { ...props, ref: ref, className: cn("
|
|
295
|
+
return (_jsx("div", { ...props, ref: ref, className: cn("zvk-ui-select__label", className) }));
|
|
243
296
|
}
|
|
244
297
|
function SelectSeparator({ className, ref, ...props }) {
|
|
245
|
-
return (_jsx("div", { ...props, ref: ref, "aria-hidden": "true", className: cn("
|
|
298
|
+
return (_jsx("div", { ...props, ref: ref, "aria-hidden": "true", className: cn("zvk-ui-select__separator", className), role: "separator" }));
|
|
246
299
|
}
|
|
247
300
|
function SelectClear({ className, disabled, onClick, ref, type = "button", ...props }) {
|
|
248
301
|
const context = useSelectContext("Select.Clear");
|
|
249
302
|
const isDisabled = Boolean(context.disabled) || Boolean(disabled);
|
|
250
|
-
return (_jsx("button", { ...props, ref: ref, type: type, className: cn("
|
|
303
|
+
return (_jsx("button", { ...props, ref: ref, type: type, className: cn("zvk-ui-select__clear", className), "data-disabled": isDisabled ? "true" : undefined, disabled: isDisabled, onClick: composeEventHandlers(onClick, () => {
|
|
251
304
|
if (!isDisabled) {
|
|
252
305
|
context.selectValue(null);
|
|
253
306
|
}
|
|
@@ -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 Separator({ className, decorative = true, orientation = "horizontal", ref, ...props }) {
|
|
5
|
-
return (_jsx("div", { ...props, ref: ref, "aria-orientation": decorative ? undefined : orientation, className: cn("
|
|
5
|
+
return (_jsx("div", { ...props, ref: ref, "aria-orientation": decorative ? undefined : orientation, className: cn("zvk-ui-separator", className), "data-orientation": orientation, role: decorative ? "none" : "separator" }));
|
|
6
6
|
}
|
|
@@ -12,7 +12,8 @@ export interface SheetProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
12
12
|
ref?: React.Ref<HTMLDivElement>;
|
|
13
13
|
}
|
|
14
14
|
export interface SheetTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
15
|
-
|
|
15
|
+
asChild?: boolean;
|
|
16
|
+
ref?: React.Ref<HTMLButtonElement | HTMLElement>;
|
|
16
17
|
}
|
|
17
18
|
export interface SheetContentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
18
19
|
forceMount?: boolean;
|
|
@@ -31,16 +32,17 @@ export interface SheetFooterProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
31
32
|
ref?: React.Ref<HTMLDivElement>;
|
|
32
33
|
}
|
|
33
34
|
export interface SheetCloseProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
34
|
-
|
|
35
|
+
asChild?: boolean;
|
|
36
|
+
ref?: React.Ref<HTMLButtonElement | HTMLElement>;
|
|
35
37
|
}
|
|
36
38
|
declare function SheetRoot({ children, className, container, defaultOpen, disableEscapeKeyDown, disableOutsidePointerDown, onOpenChange, open: openProp, ref, side, ...props }: SheetProps): React.JSX.Element;
|
|
37
|
-
declare function SheetTrigger({ className, disabled, onClick, ref, type, ...props }: SheetTriggerProps): React.JSX.Element;
|
|
39
|
+
declare function SheetTrigger({ asChild, className, disabled, onClick, ref, type, ...props }: SheetTriggerProps): React.JSX.Element;
|
|
38
40
|
declare function SheetContent({ children, className, forceMount, ref, ...props }: SheetContentProps): React.JSX.Element | null;
|
|
39
41
|
declare function SheetHeader({ className, ref, ...props }: SheetHeaderProps): React.JSX.Element;
|
|
40
42
|
declare function SheetTitle({ className, ref, ...props }: SheetTitleProps): React.JSX.Element;
|
|
41
43
|
declare function SheetDescription({ className, ref, ...props }: SheetDescriptionProps): React.JSX.Element;
|
|
42
44
|
declare function SheetFooter({ className, ref, ...props }: SheetFooterProps): React.JSX.Element;
|
|
43
|
-
declare function SheetClose({ className, onClick, ref, type, ...props }: SheetCloseProps): React.JSX.Element;
|
|
45
|
+
declare function SheetClose({ asChild, className, disabled, onClick, ref, type, ...props }: SheetCloseProps): React.JSX.Element;
|
|
44
46
|
type SheetComponent = typeof SheetRoot & {
|
|
45
47
|
Close: typeof SheetClose;
|
|
46
48
|
Content: typeof SheetContent;
|
|
@@ -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 SheetContext = React.createContext(null);
|
|
12
13
|
function useSheetContext(calledBy) {
|
|
13
14
|
const context = React.useContext(SheetContext);
|
|
@@ -69,48 +70,60 @@ function SheetRoot({ children, className, container, defaultOpen = false, disabl
|
|
|
69
70
|
side,
|
|
70
71
|
titleId: `${instanceId}-title`,
|
|
71
72
|
triggerRef
|
|
72
|
-
}, children: _jsx("div", { ...props, ref: ref, className: cn("
|
|
73
|
+
}, children: _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-sheet", className), "data-state": open ? "open" : "closed", children: children }) }));
|
|
73
74
|
}
|
|
74
|
-
function SheetTrigger({ className, disabled, onClick, ref, type = "button", ...props }) {
|
|
75
|
+
function SheetTrigger({ asChild = false, className, disabled, onClick, ref, type = "button", ...props }) {
|
|
75
76
|
const { contentId, open, setOpen, triggerRef } = useSheetContext("Sheet.Trigger");
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
const handleClick = () => {
|
|
78
|
+
if (!disabled) {
|
|
79
|
+
setOpen(true);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
if (asChild) {
|
|
83
|
+
return (_jsx(Slot, { ...props, ref: composeRefs(ref, triggerRef), "aria-controls": contentId, "aria-disabled": disabled ? true : undefined, "aria-expanded": open ? "true" : "false", className: cn("zvk-ui-sheet__trigger", className), "data-disabled": disabled ? "true" : undefined, "data-state": open ? "open" : "closed", onClick: composeEventHandlers(onClick, handleClick), children: props.children }));
|
|
84
|
+
}
|
|
85
|
+
return (_jsx("button", { ...props, ref: composeRefs(ref, triggerRef), type: type, disabled: disabled, "aria-controls": contentId, "aria-expanded": open ? "true" : "false", className: cn("zvk-ui-sheet__trigger", className), "data-state": open ? "open" : "closed", onClick: composeEventHandlers(onClick, handleClick) }));
|
|
81
86
|
}
|
|
82
87
|
function SheetContent({ children, className, forceMount = false, ref, ...props }) {
|
|
83
88
|
const { close, container, contentId, describedBy, disableEscapeKeyDown, disableOutsidePointerDown, labelledBy, open, side } = useSheetContext("Sheet.Content");
|
|
84
89
|
if (!open && !forceMount) {
|
|
85
90
|
return null;
|
|
86
91
|
}
|
|
87
|
-
const content = (_jsx("div", { ...props, ref: ref, id: contentId, role: "dialog", "aria-modal": "true", "aria-describedby": describedBy, "aria-labelledby": labelledBy, className: cn("
|
|
92
|
+
const content = (_jsx("div", { ...props, ref: ref, id: contentId, role: "dialog", "aria-modal": "true", "aria-describedby": describedBy, "aria-labelledby": labelledBy, className: cn("zvk-ui-sheet__content", className), "data-side": side, "data-state": open ? "open" : "closed", hidden: open ? undefined : true, children: children }));
|
|
88
93
|
if (!open) {
|
|
89
|
-
return (_jsxs(Portal, { ...(container === undefined ? {} : { container }), children: [_jsx("div", { "aria-hidden": "true", className: "
|
|
94
|
+
return (_jsxs(Portal, { ...(container === undefined ? {} : { container }), children: [_jsx("div", { "aria-hidden": "true", className: "zvk-ui-sheet__overlay", hidden: true }), content] }));
|
|
90
95
|
}
|
|
91
|
-
return (_jsxs(Portal, { ...(container === undefined ? {} : { container }), children: [_jsx("div", { "aria-hidden": "true", className: "
|
|
96
|
+
return (_jsxs(Portal, { ...(container === undefined ? {} : { container }), children: [_jsx("div", { "aria-hidden": "true", className: "zvk-ui-sheet__overlay" }), _jsx(DismissableLayer, { open: open, disableEscapeKeyDown: disableEscapeKeyDown, disableOutsidePointerDown: disableOutsidePointerDown, onDismiss: close, children: _jsx(FocusScope, { active: open, trapped: true, children: content }) })] }));
|
|
92
97
|
}
|
|
93
98
|
function SheetHeader({ className, ref, ...props }) {
|
|
94
|
-
return _jsx("div", { ...props, ref: ref, className: cn("
|
|
99
|
+
return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-sheet__header", className) });
|
|
95
100
|
}
|
|
96
101
|
function SheetTitle({ className, ref, ...props }) {
|
|
97
102
|
const { registerTitle, titleId } = useSheetContext("Sheet.Title");
|
|
98
103
|
const id = props.id ?? titleId;
|
|
99
104
|
React.useLayoutEffect(() => registerTitle(id), [id, registerTitle]);
|
|
100
|
-
return _jsx("h2", { ...props, ref: ref, id: id, className: cn("
|
|
105
|
+
return _jsx("h2", { ...props, ref: ref, id: id, className: cn("zvk-ui-sheet__title", className) });
|
|
101
106
|
}
|
|
102
107
|
function SheetDescription({ className, ref, ...props }) {
|
|
103
108
|
const { descriptionId, registerDescription } = useSheetContext("Sheet.Description");
|
|
104
109
|
const id = props.id ?? descriptionId;
|
|
105
110
|
React.useLayoutEffect(() => registerDescription(id), [id, registerDescription]);
|
|
106
|
-
return _jsx("p", { ...props, ref: ref, id: id, className: cn("
|
|
111
|
+
return _jsx("p", { ...props, ref: ref, id: id, className: cn("zvk-ui-sheet__description", className) });
|
|
107
112
|
}
|
|
108
113
|
function SheetFooter({ className, ref, ...props }) {
|
|
109
|
-
return _jsx("div", { ...props, ref: ref, className: cn("
|
|
114
|
+
return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-sheet__footer", className) });
|
|
110
115
|
}
|
|
111
|
-
function SheetClose({ className, onClick, ref, type = "button", ...props }) {
|
|
116
|
+
function SheetClose({ asChild = false, className, disabled, onClick, ref, type = "button", ...props }) {
|
|
112
117
|
const { close } = useSheetContext("Sheet.Close");
|
|
113
|
-
|
|
118
|
+
const handleClick = () => {
|
|
119
|
+
if (!disabled) {
|
|
120
|
+
close();
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
if (asChild) {
|
|
124
|
+
return (_jsx(Slot, { ...props, ref: ref, "aria-disabled": disabled ? true : undefined, className: cn("zvk-ui-sheet__close", className), "data-disabled": disabled ? "true" : undefined, onClick: composeEventHandlers(onClick, handleClick), children: props.children }));
|
|
125
|
+
}
|
|
126
|
+
return (_jsx("button", { ...props, ref: ref, type: type, disabled: disabled, className: cn("zvk-ui-sheet__close", className), onClick: composeEventHandlers(onClick, handleClick) }));
|
|
114
127
|
}
|
|
115
128
|
export const Sheet = Object.assign(SheetRoot, {
|
|
116
129
|
Close: SheetClose,
|
|
@@ -2,22 +2,22 @@ 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 SidebarShellRoot({ className, collapsed = false, ref, side = "left", width = "md", ...props }) {
|
|
5
|
-
return (_jsx("div", { ...props, ref: ref, className: cn("
|
|
5
|
+
return (_jsx("div", { ...props, ref: ref, className: cn("zvk-ui-sidebar-shell", className), "data-collapsed": collapsed ? "true" : "false", "data-side": side, "data-width": width }));
|
|
6
6
|
}
|
|
7
7
|
function SidebarShellSidebar({ className, ref, ...props }) {
|
|
8
|
-
return _jsx("aside", { ...props, ref: ref, className: cn("
|
|
8
|
+
return _jsx("aside", { ...props, ref: ref, className: cn("zvk-ui-sidebar-shell__sidebar", className) });
|
|
9
9
|
}
|
|
10
10
|
function SidebarShellHeader({ className, ref, ...props }) {
|
|
11
|
-
return _jsx("header", { ...props, ref: ref, className: cn("
|
|
11
|
+
return _jsx("header", { ...props, ref: ref, className: cn("zvk-ui-sidebar-shell__header", className) });
|
|
12
12
|
}
|
|
13
13
|
function SidebarShellMain({ className, ref, ...props }) {
|
|
14
|
-
return _jsx("main", { ...props, ref: ref, className: cn("
|
|
14
|
+
return _jsx("main", { ...props, ref: ref, className: cn("zvk-ui-sidebar-shell__main", className) });
|
|
15
15
|
}
|
|
16
16
|
function SidebarShellContent({ className, ref, ...props }) {
|
|
17
|
-
return _jsx("div", { ...props, ref: ref, className: cn("
|
|
17
|
+
return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-sidebar-shell__content", className) });
|
|
18
18
|
}
|
|
19
19
|
function SidebarShellFooter({ className, ref, ...props }) {
|
|
20
|
-
return _jsx("footer", { ...props, ref: ref, className: cn("
|
|
20
|
+
return _jsx("footer", { ...props, ref: ref, className: cn("zvk-ui-sidebar-shell__footer", className) });
|
|
21
21
|
}
|
|
22
22
|
export const SidebarShell = Object.assign(SidebarShellRoot, {
|
|
23
23
|
Sidebar: SidebarShellSidebar,
|
|
@@ -12,5 +12,5 @@ export function Skeleton({ animate = true, className, height, ref, rounded = "md
|
|
|
12
12
|
if (height !== undefined) {
|
|
13
13
|
dimensionStyle.height = toCssSize(height);
|
|
14
14
|
}
|
|
15
|
-
return (_jsx("span", { ...props, ref: ref, "aria-hidden": props["aria-hidden"] ?? true, className: cn("
|
|
15
|
+
return (_jsx("span", { ...props, ref: ref, "aria-hidden": props["aria-hidden"] ?? true, className: cn("zvk-ui-skeleton", className), "data-animate": animate ? "true" : "false", "data-rounded": rounded, style: { ...dimensionStyle, ...style } }));
|
|
16
16
|
}
|
|
@@ -20,7 +20,7 @@ export function Slider({ "aria-describedby": ariaDescribedBy, className, descrip
|
|
|
20
20
|
const descriptionId = hasDescription ? `${sliderId}-description` : undefined;
|
|
21
21
|
const errorId = hasError ? `${sliderId}-error` : undefined;
|
|
22
22
|
const describedBy = joinIds(ariaDescribedBy, descriptionId, errorId);
|
|
23
|
-
const slider = (_jsx("input", { ...props, ref: ref, "aria-describedby": describedBy, "aria-invalid": invalidState ? true : undefined, className: cn("
|
|
23
|
+
const slider = (_jsx("input", { ...props, ref: ref, "aria-describedby": describedBy, "aria-invalid": invalidState ? true : undefined, className: cn("zvk-ui-slider", className), "data-disabled": disabled ? "true" : undefined, "data-invalid": invalidState ? "true" : undefined, "data-required": required ? "true" : undefined, "data-size": size, disabled: disabled, id: sliderId, onChange: (event) => {
|
|
24
24
|
onValueChange?.(event.currentTarget.valueAsNumber, event);
|
|
25
25
|
}, required: required, type: "range" }));
|
|
26
26
|
if (!hasLabel && !hasDescription && !hasError) {
|
|
@@ -3,5 +3,5 @@ import * as React from "react";
|
|
|
3
3
|
import { cn } from "../../utils/cn.js";
|
|
4
4
|
export function Spinner({ className, label, ref, size = "md", tone = "primary", ...props }) {
|
|
5
5
|
const hasLabel = label !== undefined && label !== null && label !== false;
|
|
6
|
-
return (_jsx("span", { ...props, ref: ref, "aria-hidden": hasLabel ? undefined : true, "aria-live": hasLabel ? "polite" : undefined, className: cn("
|
|
6
|
+
return (_jsx("span", { ...props, ref: ref, "aria-hidden": hasLabel ? undefined : true, "aria-live": hasLabel ? "polite" : undefined, className: cn("zvk-ui-spinner", className), "data-size": size, "data-tone": tone, role: hasLabel ? "status" : undefined, children: hasLabel ? _jsx("span", { className: "zvk-ui-sr-only", children: label }) : null }));
|
|
7
7
|
}
|
|
@@ -4,5 +4,5 @@ import { cn } from "../../utils/cn.js";
|
|
|
4
4
|
export function Stat({ className, description, label, ref, size = "md", tone = "neutral", trend, value, ...props }) {
|
|
5
5
|
const showDescription = description !== undefined && description !== null && description !== false;
|
|
6
6
|
const showTrend = trend !== undefined && trend !== null && trend !== false;
|
|
7
|
-
return (_jsxs("div", { ...props, ref: ref, className: cn("
|
|
7
|
+
return (_jsxs("div", { ...props, ref: ref, className: cn("zvk-ui-stat", className), "data-size": size, "data-tone": tone, children: [_jsx("p", { className: "zvk-ui-stat__label", children: label }), _jsx("div", { className: "zvk-ui-stat__value", children: value }), showDescription ? _jsx("p", { className: "zvk-ui-stat__description", children: description }) : null, showTrend ? _jsx("div", { className: "zvk-ui-stat__trend", children: trend }) : null] }));
|
|
8
8
|
}
|