@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
|
@@ -48,45 +48,45 @@ export function getPaginationRange({ page, pageCount, siblingCount = 1, boundary
|
|
|
48
48
|
function renderPrevious({ hasHrefMode, page, label, pageCount, onPageChange, getPageHref }) {
|
|
49
49
|
const targetPage = page - 1;
|
|
50
50
|
if (hasHrefMode && targetPage >= 1) {
|
|
51
|
-
return (_jsx("a", { className: "
|
|
51
|
+
return (_jsx("a", { className: "zvk-ui-pagination__item", href: getPageHref?.(targetPage), children: label }));
|
|
52
52
|
}
|
|
53
53
|
if (hasHrefMode && targetPage < 1) {
|
|
54
|
-
return (_jsx("span", { className: "
|
|
54
|
+
return (_jsx("span", { className: "zvk-ui-pagination__item zvk-ui-pagination__item--disabled", "aria-hidden": "true", children: label }));
|
|
55
55
|
}
|
|
56
|
-
return (_jsx("button", { className: "
|
|
56
|
+
return (_jsx("button", { className: "zvk-ui-pagination__item", disabled: targetPage < 1, onClick: () => onPageChange?.(Math.max(1, targetPage)), type: "button", children: label }));
|
|
57
57
|
}
|
|
58
58
|
function renderNext({ hasHrefMode, page, label, pageCount, onPageChange, getPageHref }) {
|
|
59
59
|
const targetPage = page + 1;
|
|
60
60
|
if (hasHrefMode && targetPage <= pageCount) {
|
|
61
|
-
return (_jsx("a", { className: "
|
|
61
|
+
return (_jsx("a", { className: "zvk-ui-pagination__item", href: getPageHref?.(targetPage), children: label }));
|
|
62
62
|
}
|
|
63
63
|
if (hasHrefMode && targetPage > pageCount) {
|
|
64
|
-
return (_jsx("span", { className: "
|
|
64
|
+
return (_jsx("span", { className: "zvk-ui-pagination__item zvk-ui-pagination__item--disabled", "aria-hidden": "true", children: label }));
|
|
65
65
|
}
|
|
66
|
-
return (_jsx("button", { className: "
|
|
66
|
+
return (_jsx("button", { className: "zvk-ui-pagination__item", disabled: targetPage > pageCount, onClick: () => onPageChange?.(Math.min(pageCount, targetPage)), type: "button", children: label }));
|
|
67
67
|
}
|
|
68
68
|
function renderPageItem({ hasHrefMode, item, page, onPageChange, getPageHref }) {
|
|
69
69
|
if (item === page) {
|
|
70
70
|
if (hasHrefMode) {
|
|
71
|
-
return (_jsx("a", { "aria-current": "page", className: "
|
|
71
|
+
return (_jsx("a", { "aria-current": "page", className: "zvk-ui-pagination__item zvk-ui-pagination__item--current", href: getPageHref?.(item), children: item }));
|
|
72
72
|
}
|
|
73
|
-
return (_jsx("button", { "aria-current": "page", className: "
|
|
73
|
+
return (_jsx("button", { "aria-current": "page", className: "zvk-ui-pagination__item zvk-ui-pagination__item--current", disabled: true, type: "button", children: item }));
|
|
74
74
|
}
|
|
75
75
|
if (hasHrefMode) {
|
|
76
|
-
return (_jsx("a", { className: "
|
|
76
|
+
return (_jsx("a", { className: "zvk-ui-pagination__item", href: getPageHref?.(item), children: item }));
|
|
77
77
|
}
|
|
78
|
-
return (_jsx("button", { className: "
|
|
78
|
+
return (_jsx("button", { className: "zvk-ui-pagination__item", onClick: () => onPageChange?.(item), type: "button", children: item }));
|
|
79
79
|
}
|
|
80
80
|
export function Pagination({ className, label = "Pagination", onPageChange, getPageHref, page, pageCount, siblingCount = 1, boundaryCount = 1, previousLabel = "Previous", nextLabel = "Next", ref, ...props }) {
|
|
81
81
|
const safePageCount = Math.max(normalizeCount(pageCount, 1), 0);
|
|
82
82
|
const safePage = Math.max(1, Math.min(clamp(page), safePageCount || 1));
|
|
83
83
|
const range = getPaginationRange({ page, pageCount, siblingCount, boundaryCount });
|
|
84
84
|
const isLinkMode = typeof getPageHref === "function";
|
|
85
|
-
return (_jsx("nav", { ...props, ref: ref, "aria-label": props["aria-label"] ?? label, className: cn("
|
|
85
|
+
return (_jsx("nav", { ...props, ref: ref, "aria-label": props["aria-label"] ?? label, className: cn("zvk-ui-pagination", className), children: _jsxs("ol", { className: "zvk-ui-pagination__list", children: [_jsx("li", { children: renderPrevious({ hasHrefMode: isLinkMode, label: previousLabel, onPageChange, page: safePage, pageCount: safePageCount, getPageHref }) }), range.map((item) => (_jsx("li", { children: typeof item === "number" ? (renderPageItem({
|
|
86
86
|
getPageHref,
|
|
87
87
|
hasHrefMode: isLinkMode,
|
|
88
88
|
item,
|
|
89
89
|
onPageChange,
|
|
90
90
|
page: safePage
|
|
91
|
-
})) : (_jsx("span", { "aria-hidden": "true", className: "
|
|
91
|
+
})) : (_jsx("span", { "aria-hidden": "true", className: "zvk-ui-pagination__ellipsis", children: "\u2026" })) }, `${item}-${typeof item === "number" ? item : item}`))), _jsx("li", { children: renderNext({ hasHrefMode: isLinkMode, label: nextLabel, onPageChange, page: safePage, pageCount: safePageCount, getPageHref }) })] }) }));
|
|
92
92
|
}
|
|
@@ -30,7 +30,7 @@ export interface PopoverContentProps extends React.HTMLAttributes<HTMLDivElement
|
|
|
30
30
|
}
|
|
31
31
|
declare function PopoverRoot({ children, className, defaultOpen, modal, onOpenChange, open, placement, ref, ...props }: PopoverProps): React.JSX.Element;
|
|
32
32
|
declare function PopoverTrigger({ asChild, className, disabled, onClick, ref, type, ...props }: PopoverTriggerProps): React.JSX.Element;
|
|
33
|
-
declare function PopoverContent({ align, alignOffset
|
|
33
|
+
declare function PopoverContent({ align, alignOffset, className, container, forceMount, id, disableEscapeKeyDown, disableOutsidePointerDown, ref, placement, side, sideOffset, collisionPadding, matchTriggerWidth, style, ...props }: PopoverContentProps): React.JSX.Element | null;
|
|
34
34
|
export declare const Popover: typeof PopoverRoot & {
|
|
35
35
|
Trigger: typeof PopoverTrigger;
|
|
36
36
|
Content: typeof PopoverContent;
|
|
@@ -11,6 +11,7 @@ import { placementFromSideAlign } from "../../internal/floating/placement-aliase
|
|
|
11
11
|
import { Slot } from "../../internal/slot/index.js";
|
|
12
12
|
const defaultPositioning = {
|
|
13
13
|
sideOffset: 0,
|
|
14
|
+
alignOffset: 0,
|
|
14
15
|
collisionPadding: 0,
|
|
15
16
|
matchTriggerWidth: false
|
|
16
17
|
};
|
|
@@ -55,6 +56,20 @@ function getPlacementParts(placement) {
|
|
|
55
56
|
const [side, align = "center"] = placement.split("-");
|
|
56
57
|
return { side, align };
|
|
57
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
|
+
}
|
|
58
73
|
function PopoverRoot({ children, className, defaultOpen = false, modal = false, onOpenChange, open, placement = "bottom", ref, ...props }) {
|
|
59
74
|
const defaultContentId = `${React.useId()}-content`;
|
|
60
75
|
const [contentId, setContentId] = React.useState(defaultContentId);
|
|
@@ -72,6 +87,7 @@ function PopoverRoot({ children, className, defaultOpen = false, modal = false,
|
|
|
72
87
|
open: isOpen,
|
|
73
88
|
placement: contentPositioning.placement ?? placement,
|
|
74
89
|
offset: contentPositioning.sideOffset,
|
|
90
|
+
alignmentOffset: contentPositioning.alignOffset,
|
|
75
91
|
collisionPadding: contentPositioning.collisionPadding,
|
|
76
92
|
matchReferenceWidth: contentPositioning.matchTriggerWidth
|
|
77
93
|
});
|
|
@@ -97,7 +113,7 @@ function PopoverRoot({ children, className, defaultOpen = false, modal = false,
|
|
|
97
113
|
floatingPlacement: resolvedPlacement,
|
|
98
114
|
updatePosition,
|
|
99
115
|
updateContentPositioning
|
|
100
|
-
}, 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 }) }));
|
|
101
117
|
}
|
|
102
118
|
function PopoverTrigger({ asChild = false, className, disabled, onClick, ref, type = "button", ...props }) {
|
|
103
119
|
const context = usePopoverContext("Popover.Trigger");
|
|
@@ -112,11 +128,11 @@ function PopoverTrigger({ asChild = false, className, disabled, onClick, ref, ty
|
|
|
112
128
|
mergeRef(ref, node);
|
|
113
129
|
}, [context.referenceRef, ref]);
|
|
114
130
|
if (asChild) {
|
|
115
|
-
return (_jsx(Slot, { ...props, ref: handleRef, "aria-controls": context.contentId, "aria-disabled": disabled ? true : undefined, "aria-expanded": context.open, "aria-haspopup": "dialog", className: cn("
|
|
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 }));
|
|
116
132
|
}
|
|
117
|
-
return (_jsx("button", { ...props, ref: handleRef, type: type, disabled: disabled, className: cn("
|
|
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) }));
|
|
118
134
|
}
|
|
119
|
-
function PopoverContent({ align, alignOffset
|
|
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 }) {
|
|
120
136
|
const context = usePopoverContext("Popover.Content");
|
|
121
137
|
const { defaultContentId, setContentId } = context;
|
|
122
138
|
const transformOrigin = getTransformOrigin(context.floatingPlacement);
|
|
@@ -129,7 +145,7 @@ function PopoverContent({ align, alignOffset: _alignOffset, className, container
|
|
|
129
145
|
const contentStyle = React.useMemo(() => ({
|
|
130
146
|
...context.floatingStyle,
|
|
131
147
|
...style,
|
|
132
|
-
"--
|
|
148
|
+
"--zvk-ui-popover-transform-origin": transformOrigin
|
|
133
149
|
}), [context.floatingStyle, style, transformOrigin]);
|
|
134
150
|
React.useLayoutEffect(() => {
|
|
135
151
|
setContentId(contentId);
|
|
@@ -152,17 +168,24 @@ function PopoverContent({ align, alignOffset: _alignOffset, className, container
|
|
|
152
168
|
context.updateContentPositioning({
|
|
153
169
|
...(resolvedPlacement === undefined ? {} : { placement: resolvedPlacement }),
|
|
154
170
|
sideOffset,
|
|
171
|
+
alignOffset,
|
|
155
172
|
collisionPadding,
|
|
156
173
|
matchTriggerWidth
|
|
157
174
|
});
|
|
158
175
|
return () => {
|
|
159
176
|
context.updateContentPositioning(defaultPositioning);
|
|
160
177
|
};
|
|
161
|
-
}, [align, context.updateContentPositioning, collisionPadding, matchTriggerWidth, placement, side, sideOffset]);
|
|
178
|
+
}, [align, alignOffset, context.updateContentPositioning, collisionPadding, matchTriggerWidth, placement, side, sideOffset]);
|
|
162
179
|
if (!forceMount && !context.open) {
|
|
163
180
|
return null;
|
|
164
181
|
}
|
|
165
|
-
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
|
+
}
|
|
166
189
|
if (!context.open) {
|
|
167
190
|
return _jsx(Portal, { ...(container === undefined ? {} : { container }), children: content });
|
|
168
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
|
}
|
|
@@ -70,7 +70,7 @@ function SheetRoot({ children, className, container, defaultOpen = false, disabl
|
|
|
70
70
|
side,
|
|
71
71
|
titleId: `${instanceId}-title`,
|
|
72
72
|
triggerRef
|
|
73
|
-
}, 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 }) }));
|
|
74
74
|
}
|
|
75
75
|
function SheetTrigger({ asChild = false, className, disabled, onClick, ref, type = "button", ...props }) {
|
|
76
76
|
const { contentId, open, setOpen, triggerRef } = useSheetContext("Sheet.Trigger");
|
|
@@ -80,38 +80,38 @@ function SheetTrigger({ asChild = false, className, disabled, onClick, ref, type
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
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("
|
|
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
84
|
}
|
|
85
|
-
return (_jsx("button", { ...props, ref: composeRefs(ref, triggerRef), type: type, disabled: disabled, "aria-controls": contentId, "aria-expanded": open ? "true" : "false", className: cn("
|
|
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) }));
|
|
86
86
|
}
|
|
87
87
|
function SheetContent({ children, className, forceMount = false, ref, ...props }) {
|
|
88
88
|
const { close, container, contentId, describedBy, disableEscapeKeyDown, disableOutsidePointerDown, labelledBy, open, side } = useSheetContext("Sheet.Content");
|
|
89
89
|
if (!open && !forceMount) {
|
|
90
90
|
return null;
|
|
91
91
|
}
|
|
92
|
-
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 }));
|
|
93
93
|
if (!open) {
|
|
94
|
-
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] }));
|
|
95
95
|
}
|
|
96
|
-
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 }) })] }));
|
|
97
97
|
}
|
|
98
98
|
function SheetHeader({ className, ref, ...props }) {
|
|
99
|
-
return _jsx("div", { ...props, ref: ref, className: cn("
|
|
99
|
+
return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-sheet__header", className) });
|
|
100
100
|
}
|
|
101
101
|
function SheetTitle({ className, ref, ...props }) {
|
|
102
102
|
const { registerTitle, titleId } = useSheetContext("Sheet.Title");
|
|
103
103
|
const id = props.id ?? titleId;
|
|
104
104
|
React.useLayoutEffect(() => registerTitle(id), [id, registerTitle]);
|
|
105
|
-
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) });
|
|
106
106
|
}
|
|
107
107
|
function SheetDescription({ className, ref, ...props }) {
|
|
108
108
|
const { descriptionId, registerDescription } = useSheetContext("Sheet.Description");
|
|
109
109
|
const id = props.id ?? descriptionId;
|
|
110
110
|
React.useLayoutEffect(() => registerDescription(id), [id, registerDescription]);
|
|
111
|
-
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) });
|
|
112
112
|
}
|
|
113
113
|
function SheetFooter({ className, ref, ...props }) {
|
|
114
|
-
return _jsx("div", { ...props, ref: ref, className: cn("
|
|
114
|
+
return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-sheet__footer", className) });
|
|
115
115
|
}
|
|
116
116
|
function SheetClose({ asChild = false, className, disabled, onClick, ref, type = "button", ...props }) {
|
|
117
117
|
const { close } = useSheetContext("Sheet.Close");
|
|
@@ -121,9 +121,9 @@ function SheetClose({ asChild = false, className, disabled, onClick, ref, type =
|
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
123
|
if (asChild) {
|
|
124
|
-
return (_jsx(Slot, { ...props, ref: ref, "aria-disabled": disabled ? true : undefined, className: cn("
|
|
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
125
|
}
|
|
126
|
-
return (_jsx("button", { ...props, ref: ref, type: type, disabled: disabled, className: cn("
|
|
126
|
+
return (_jsx("button", { ...props, ref: ref, type: type, disabled: disabled, className: cn("zvk-ui-sheet__close", className), onClick: composeEventHandlers(onClick, handleClick) }));
|
|
127
127
|
}
|
|
128
128
|
export const Sheet = Object.assign(SheetRoot, {
|
|
129
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) {
|