@zvk/ui 0.1.5 → 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.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.js +10 -10
- 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 +3 -3
- package/dist/components/input/input.js +1 -1
- package/dist/components/label/label.js +1 -1
- package/dist/components/menubar/menubar.js +12 -12
- 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/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 +2066 -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 +12 -11
|
@@ -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) {
|
|
@@ -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
|
}
|
|
@@ -21,7 +21,7 @@ export function Switch({ "aria-describedby": ariaDescribedBy, className, descrip
|
|
|
21
21
|
const descriptionId = hasDescription ? `${switchId}-description` : undefined;
|
|
22
22
|
const errorId = hasError ? `${switchId}-error` : undefined;
|
|
23
23
|
const describedBy = joinIds(ariaDescribedBy, descriptionId, errorId);
|
|
24
|
-
const input = (_jsx("input", { ...props, ref: ref, "aria-describedby": describedBy, "aria-invalid": invalidState ? true : undefined, className: "
|
|
25
|
-
const content = (_jsxs(_Fragment, { children: [input, _jsx("span", { className: "
|
|
26
|
-
return (_jsxs(Field, { disabled: Boolean(disabled), invalid: invalidState, required: Boolean(required), children: [_jsx("label", { className: cn("
|
|
24
|
+
const input = (_jsx("input", { ...props, ref: ref, "aria-describedby": describedBy, "aria-invalid": invalidState ? true : undefined, className: "zvk-ui-switch__input", "data-disabled": disabled ? "true" : undefined, "data-invalid": invalidState ? "true" : undefined, "data-required": required ? "true" : undefined, disabled: disabled, id: switchId, required: required, role: "switch", type: "checkbox" }));
|
|
25
|
+
const content = (_jsxs(_Fragment, { children: [input, _jsx("span", { className: "zvk-ui-switch__track", "aria-hidden": "true", children: _jsx("span", { className: "zvk-ui-switch__thumb" }) }), hasLabel ? _jsx("span", { className: "zvk-ui-switch__label", children: label }) : null] }));
|
|
26
|
+
return (_jsxs(Field, { disabled: Boolean(disabled), invalid: invalidState, required: Boolean(required), children: [_jsx("label", { className: cn("zvk-ui-switch", className), "data-size": size, "data-disabled": disabled ? "true" : undefined, "data-invalid": invalidState ? "true" : undefined, "data-required": required ? "true" : undefined, children: content }), hasDescription ? _jsx(Field.Description, { id: descriptionId, children: description }) : null, hasError ? _jsx(Field.Error, { id: errorId, children: error }) : null] }));
|
|
27
27
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Table } from "./table.js";
|
|
2
|
-
export type { TableBodyProps, TableCaptionProps, TableCellProps, TableFooterProps, TableHeadProps, TableHeaderProps, TableProps, TableRowProps } from "./table.js";
|
|
2
|
+
export type { TableBodyProps, TableCaptionProps, TableCellProps, TableContainerProps, TableFooterProps, TableHeadProps, TableHeaderProps, TableProps, TableRowProps } from "./table.js";
|
|
@@ -4,6 +4,9 @@ export interface TableProps extends React.TableHTMLAttributes<HTMLTableElement>
|
|
|
4
4
|
variant?: "plain" | "surface";
|
|
5
5
|
ref?: React.Ref<HTMLTableElement>;
|
|
6
6
|
}
|
|
7
|
+
export interface TableContainerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
8
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
9
|
+
}
|
|
7
10
|
export interface TableCaptionProps extends React.HTMLAttributes<HTMLTableCaptionElement> {
|
|
8
11
|
ref?: React.Ref<HTMLTableCaptionElement>;
|
|
9
12
|
}
|
|
@@ -33,7 +36,9 @@ declare function TableFooter({ className, ref, ...props }: TableFooterProps): Re
|
|
|
33
36
|
declare function TableRow({ className, ref, ...props }: TableRowProps): React.JSX.Element;
|
|
34
37
|
declare function TableHead({ className, ref, scope, ...props }: TableHeadProps): React.JSX.Element;
|
|
35
38
|
declare function TableCell({ className, ref, ...props }: TableCellProps): React.JSX.Element;
|
|
39
|
+
declare function TableContainer({ className, ref, ...props }: TableContainerProps): React.JSX.Element;
|
|
36
40
|
export declare const Table: typeof TableRoot & {
|
|
41
|
+
Container: typeof TableContainer;
|
|
37
42
|
Caption: typeof TableCaption;
|
|
38
43
|
Header: typeof TableHeader;
|
|
39
44
|
Body: typeof TableBody;
|
|
@@ -2,30 +2,34 @@ 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 TableRoot({ className, density = "default", ref, variant = "plain", ...props }) {
|
|
5
|
-
return (_jsx("table", { ...props, ref: ref, className: cn("
|
|
5
|
+
return (_jsx("table", { ...props, ref: ref, className: cn("zvk-ui-table", className), "data-density": density, "data-variant": variant }));
|
|
6
6
|
}
|
|
7
7
|
function TableCaption({ className, ref, ...props }) {
|
|
8
|
-
return _jsx("caption", { ...props, ref: ref, className: cn("
|
|
8
|
+
return _jsx("caption", { ...props, ref: ref, className: cn("zvk-ui-table__caption", className) });
|
|
9
9
|
}
|
|
10
10
|
function TableHeader({ className, ref, ...props }) {
|
|
11
|
-
return _jsx("thead", { ...props, ref: ref, className: cn("
|
|
11
|
+
return _jsx("thead", { ...props, ref: ref, className: cn("zvk-ui-table__header", className) });
|
|
12
12
|
}
|
|
13
13
|
function TableBody({ className, ref, ...props }) {
|
|
14
|
-
return _jsx("tbody", { ...props, ref: ref, className: cn("
|
|
14
|
+
return _jsx("tbody", { ...props, ref: ref, className: cn("zvk-ui-table__body", className) });
|
|
15
15
|
}
|
|
16
16
|
function TableFooter({ className, ref, ...props }) {
|
|
17
|
-
return _jsx("tfoot", { ...props, ref: ref, className: cn("
|
|
17
|
+
return _jsx("tfoot", { ...props, ref: ref, className: cn("zvk-ui-table__footer", className) });
|
|
18
18
|
}
|
|
19
19
|
function TableRow({ className, ref, ...props }) {
|
|
20
|
-
return _jsx("tr", { ...props, ref: ref, className: cn("
|
|
20
|
+
return _jsx("tr", { ...props, ref: ref, className: cn("zvk-ui-table__row", className) });
|
|
21
21
|
}
|
|
22
22
|
function TableHead({ className, ref, scope = "col", ...props }) {
|
|
23
|
-
return _jsx("th", { ...props, ref: ref, scope: scope, className: cn("
|
|
23
|
+
return _jsx("th", { ...props, ref: ref, scope: scope, className: cn("zvk-ui-table__head", className) });
|
|
24
24
|
}
|
|
25
25
|
function TableCell({ className, ref, ...props }) {
|
|
26
|
-
return _jsx("td", { ...props, ref: ref, className: cn("
|
|
26
|
+
return _jsx("td", { ...props, ref: ref, className: cn("zvk-ui-table__cell", className) });
|
|
27
|
+
}
|
|
28
|
+
function TableContainer({ className, ref, ...props }) {
|
|
29
|
+
return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-table-container", className) });
|
|
27
30
|
}
|
|
28
31
|
export const Table = Object.assign(TableRoot, {
|
|
32
|
+
Container: TableContainer,
|
|
29
33
|
Caption: TableCaption,
|
|
30
34
|
Header: TableHeader,
|
|
31
35
|
Body: TableBody,
|
|
@@ -127,11 +127,11 @@ function TabsRoot({ children, className, defaultValue = "", disabled = false, re
|
|
|
127
127
|
setValue: setCurrentValue,
|
|
128
128
|
unregisterTrigger,
|
|
129
129
|
value: currentValue
|
|
130
|
-
}, children: _jsx("div", { ...props, ref: ref, className: cn("
|
|
130
|
+
}, children: _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-tabs", className), "data-orientation": orientation, "data-state": activationMode, "data-disabled": disabled ? "true" : undefined, children: children }) }));
|
|
131
131
|
}
|
|
132
132
|
function TabsList({ className, ref, ...props }) {
|
|
133
133
|
const context = useTabsContext("Tabs.List");
|
|
134
|
-
return (_jsx("div", { ...props, ref: ref, role: "tablist", className: cn("
|
|
134
|
+
return (_jsx("div", { ...props, ref: ref, role: "tablist", className: cn("zvk-ui-tabs__list", className), "aria-orientation": context.orientation === "vertical" ? "vertical" : "horizontal" }));
|
|
135
135
|
}
|
|
136
136
|
function TabsTrigger({ className, onClick, onKeyDown, ref, value, ...props }) {
|
|
137
137
|
const context = useTabsContext("Tabs.Trigger");
|
|
@@ -200,7 +200,7 @@ function TabsTrigger({ className, onClick, onKeyDown, ref, value, ...props }) {
|
|
|
200
200
|
else if (ref) {
|
|
201
201
|
ref.current = node;
|
|
202
202
|
}
|
|
203
|
-
}, id: triggerId, role: "tab", "aria-controls": contentId, "aria-selected": isSelected, className: cn("
|
|
203
|
+
}, id: triggerId, role: "tab", "aria-controls": contentId, "aria-selected": isSelected, className: cn("zvk-ui-tabs__trigger", className), "data-state": isSelected ? "active" : "inactive", "data-disabled": isDisabled ? "true" : undefined, disabled: isDisabled, onClick: composeEventHandlers(onClick, () => {
|
|
204
204
|
if (!isDisabled && !context.disabled) {
|
|
205
205
|
context.setValue(value);
|
|
206
206
|
}
|
|
@@ -224,7 +224,7 @@ function TabsContent({ className, forceMount = false, ref, value, ...props }) {
|
|
|
224
224
|
if (!forceMount && !isSelected) {
|
|
225
225
|
return null;
|
|
226
226
|
}
|
|
227
|
-
return (_jsx(TabsTriggerContext.Provider, { value: { value }, children: _jsx("div", { ...props, id: props.id ?? contentId, ref: ref, role: "tabpanel", "aria-labelledby": triggerId, className: cn("
|
|
227
|
+
return (_jsx(TabsTriggerContext.Provider, { value: { value }, children: _jsx("div", { ...props, id: props.id ?? contentId, ref: ref, role: "tabpanel", "aria-labelledby": triggerId, className: cn("zvk-ui-tabs__content", className), "data-state": isSelected ? "open" : "closed", hidden: !isSelected ? true : undefined }) }));
|
|
228
228
|
}
|
|
229
229
|
export const Tabs = Object.assign(TabsRoot, {
|
|
230
230
|
List: TabsList,
|
|
@@ -4,13 +4,13 @@ import * as React from "react";
|
|
|
4
4
|
import { Tabs } from "../tabs/tabs.js";
|
|
5
5
|
import { cn } from "../../utils/cn.js";
|
|
6
6
|
function TabsWithSidebarRoot({ className, orientation = "vertical", ref, sidebarWidth = "md", ...props }) {
|
|
7
|
-
return (_jsx(Tabs, { ...props, ...(ref ? { ref } : {}), className: cn("
|
|
7
|
+
return (_jsx(Tabs, { ...props, ...(ref ? { ref } : {}), className: cn("zvk-ui-tabs-with-sidebar", className), "data-sidebar-width": sidebarWidth, orientation: orientation }));
|
|
8
8
|
}
|
|
9
9
|
function TabsWithSidebarSidebar({ className, ref, sidebarWidth = "md", ...props }) {
|
|
10
|
-
return (_jsx("div", { ...props, ref: ref, className: cn("
|
|
10
|
+
return (_jsx("div", { ...props, ref: ref, className: cn("zvk-ui-tabs-with-sidebar__sidebar", className), "data-sidebar-width": sidebarWidth }));
|
|
11
11
|
}
|
|
12
12
|
function TabsWithSidebarPanel({ className, ref, ...props }) {
|
|
13
|
-
return _jsx("div", { ...props, ref: ref, className: cn("
|
|
13
|
+
return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-tabs-with-sidebar__panel", className) });
|
|
14
14
|
}
|
|
15
15
|
export const TabsWithSidebar = Object.assign(TabsWithSidebarRoot, {
|
|
16
16
|
Sidebar: TabsWithSidebarSidebar,
|
|
@@ -20,7 +20,7 @@ export function Textarea({ "aria-describedby": ariaDescribedBy, className, descr
|
|
|
20
20
|
const descriptionId = hasDescription ? `${inputId}-description` : undefined;
|
|
21
21
|
const errorId = hasError ? `${inputId}-error` : undefined;
|
|
22
22
|
const describedBy = joinIds(ariaDescribedBy, descriptionId, errorId);
|
|
23
|
-
const textarea = (_jsx("textarea", { ...props, ref: ref, "aria-describedby": describedBy, "aria-invalid": invalidState ? true : undefined, className: cn("
|
|
23
|
+
const textarea = (_jsx("textarea", { ...props, ref: ref, "aria-describedby": describedBy, "aria-invalid": invalidState ? true : undefined, className: cn("zvk-ui-textarea", className), "data-disabled": disabled ? "true" : undefined, "data-invalid": invalidState ? "true" : undefined, "data-required": required ? "true" : undefined, "data-size": size, disabled: disabled, id: inputId, required: required, rows: rows }));
|
|
24
24
|
if (!hasLabel && !hasDescription && !hasError) {
|
|
25
25
|
return textarea;
|
|
26
26
|
}
|
|
@@ -58,7 +58,7 @@ function renderToastControl(input) {
|
|
|
58
58
|
return input;
|
|
59
59
|
}
|
|
60
60
|
export function ToastViewport({ className, placement = "top-right", ref, ...props }) {
|
|
61
|
-
return (_jsx("div", { ...props, ref: ref, "aria-label": props["aria-label"] ?? "Notifications", className: cn("
|
|
61
|
+
return (_jsx("div", { ...props, ref: ref, "aria-label": props["aria-label"] ?? "Notifications", className: cn("zvk-ui-toast-viewport", className), "data-placement": placement, role: "region" }));
|
|
62
62
|
}
|
|
63
63
|
export function createToastController() {
|
|
64
64
|
const listeners = new Set();
|
|
@@ -131,7 +131,7 @@ export function Toaster({ controller = toast, expand: _expand, offset, position
|
|
|
131
131
|
? style
|
|
132
132
|
: {
|
|
133
133
|
...style,
|
|
134
|
-
"--
|
|
134
|
+
"--zvk-ui-toast-viewport-inset": typeof offset === "number" ? `${offset}px` : offset
|
|
135
135
|
};
|
|
136
136
|
return (_jsx(ToastProvider, { ...props, controller: controller, placement: placement, ...(offsetStyle === undefined ? {} : { style: offsetStyle }) }));
|
|
137
137
|
}
|
|
@@ -143,23 +143,23 @@ function ToastProviderItem({ onDismiss, toast }) {
|
|
|
143
143
|
const timeout = window.setTimeout(() => onDismiss(toast.id), toast.duration);
|
|
144
144
|
return () => window.clearTimeout(timeout);
|
|
145
145
|
}, [onDismiss, toast.duration, toast.id, toast.version]);
|
|
146
|
-
return (_jsxs(Toast, { tone: toast.tone, children: [(toast.title || toast.description) && (_jsxs("div", { className: "
|
|
146
|
+
return (_jsxs(Toast, { tone: toast.tone, children: [(toast.title || toast.description) && (_jsxs("div", { className: "zvk-ui-toast__content", children: [toast.title && _jsx(Toast.Title, { children: toast.title }), toast.description && _jsx(Toast.Description, { children: toast.description })] })), (toast.action || toast.cancel) && (_jsxs("div", { className: "zvk-ui-toast__controls", children: [renderToastControl(toast.action), renderToastControl(toast.cancel)] })), _jsx(Toast.Close, { "aria-label": "Dismiss notification", onClick: () => onDismiss(toast.id) })] }));
|
|
147
147
|
}
|
|
148
148
|
function ToastRoot({ className, ref, role, tone = "neutral", ...props }) {
|
|
149
149
|
const toastType = toastTypeFromTone(tone);
|
|
150
|
-
return (_jsx("div", { ...props, ref: ref, className: cn("
|
|
150
|
+
return (_jsx("div", { ...props, ref: ref, className: cn("zvk-ui-toast", className), "data-sonner-toast": "", "data-tone": tone, "data-type": toastType, "data-visible": "true", role: role ?? (tone === "destructive" ? "alert" : "status") }));
|
|
151
151
|
}
|
|
152
152
|
function ToastTitle({ className, ref, ...props }) {
|
|
153
|
-
return _jsx("div", { ...props, ref: ref, className: cn("
|
|
153
|
+
return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-toast__title", className) });
|
|
154
154
|
}
|
|
155
155
|
function ToastDescription({ className, ref, ...props }) {
|
|
156
|
-
return _jsx("div", { ...props, ref: ref, className: cn("
|
|
156
|
+
return _jsx("div", { ...props, ref: ref, className: cn("zvk-ui-toast__description", className) });
|
|
157
157
|
}
|
|
158
158
|
function ToastAction({ className, ref, type = "button", ...props }) {
|
|
159
|
-
return _jsx("button", { ...props, ref: ref, className: cn("
|
|
159
|
+
return _jsx("button", { ...props, ref: ref, className: cn("zvk-ui-toast__action", className), type: type });
|
|
160
160
|
}
|
|
161
161
|
function ToastClose({ children = "×", className, ref, type = "button", ...props }) {
|
|
162
|
-
return (_jsx("button", { ...props, ref: ref, className: cn("
|
|
162
|
+
return (_jsx("button", { ...props, ref: ref, className: cn("zvk-ui-toast__close", className), type: type, children: children }));
|
|
163
163
|
}
|
|
164
164
|
export const Toast = Object.assign(ToastRoot, {
|
|
165
165
|
Title: ToastTitle,
|
|
@@ -10,7 +10,7 @@ export function Toggle({ "aria-pressed": ariaPressed, className, defaultPressed
|
|
|
10
10
|
defaultValue: defaultPressed,
|
|
11
11
|
...(onPressedChange ? { onChange: onPressedChange } : {})
|
|
12
12
|
});
|
|
13
|
-
return (_jsx("button", { ...props, ref: ref, "aria-pressed": ariaPressed ?? currentPressed, className: cn("
|
|
13
|
+
return (_jsx("button", { ...props, ref: ref, "aria-pressed": ariaPressed ?? currentPressed, className: cn("zvk-ui-toggle", className), "data-disabled": disabled ? "true" : undefined, "data-size": size, "data-state": currentPressed ? "on" : "off", "data-variant": variant, disabled: disabled, onClick: composeEventHandlers(onClick, () => {
|
|
14
14
|
if (!disabled) {
|
|
15
15
|
setPressed((value) => !value);
|
|
16
16
|
}
|
|
@@ -50,7 +50,7 @@ function ToggleGroupRoot(props) {
|
|
|
50
50
|
toggleValue
|
|
51
51
|
}), [disabled, isPressed, orientation, toggleValue]);
|
|
52
52
|
const { children: _children, className: _className, defaultValue: _defaultValue, disabled: _disabled, onValueChange: _onValueChange, orientation: _orientation, type: _type, value: _value, ...domProps } = props;
|
|
53
|
-
return (_jsx(ToggleGroupContext.Provider, { value: context, children: _jsx("div", { ...domProps, className: cn("
|
|
53
|
+
return (_jsx(ToggleGroupContext.Provider, { value: context, children: _jsx("div", { ...domProps, className: cn("zvk-ui-toggle-group", className), "data-disabled": disabled ? "true" : undefined, "data-orientation": orientation, role: "group", children: children }) }));
|
|
54
54
|
}
|
|
55
55
|
function ToggleGroupItem({ disabled, onClick, value, ...props }) {
|
|
56
56
|
const context = useToggleGroupContext("ToggleGroup.Item");
|
|
@@ -41,7 +41,7 @@ export interface TooltipContentProps extends React.HTMLAttributes<HTMLSpanElemen
|
|
|
41
41
|
declare function TooltipProvider({ children, delayDuration }: TooltipProviderProps): React.JSX.Element;
|
|
42
42
|
declare function TooltipRoot({ children, defaultOpen, delay, disabled, onOpenChange, open: openProp, placement }: TooltipRootProps): React.JSX.Element;
|
|
43
43
|
declare function TooltipTrigger({ children, asChild: _asChild }: TooltipTriggerProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
44
|
-
declare function TooltipContent({ align, alignOffset
|
|
44
|
+
declare function TooltipContent({ align, alignOffset, children, className, collisionPadding, container, forceMount, placement, ref, side, sideOffset, style, ...props }: TooltipContentProps): React.JSX.Element | null;
|
|
45
45
|
declare function TooltipWrapper({ children, content, delay, disabled, placement }: TooltipProps): React.JSX.Element;
|
|
46
46
|
export declare const Tooltip: typeof TooltipWrapper & {
|
|
47
47
|
Content: typeof TooltipContent;
|