@vertz/ui-primitives 0.2.22 → 0.2.23
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/dist/shared/chunk-3h1mxp95.js +148 -0
- package/dist/shared/chunk-3kwh27dv.js +135 -0
- package/dist/shared/chunk-4894pmy6.js +184 -0
- package/dist/shared/chunk-67sn29eh.js +125 -0
- package/dist/shared/chunk-7cb3z0s8.js +287 -0
- package/dist/shared/chunk-8c01c8mb.js +217 -0
- package/dist/shared/chunk-99tk72t3.js +69 -0
- package/dist/shared/chunk-9gfp3ffv.js +204 -0
- package/dist/shared/chunk-b25npqer.js +149 -0
- package/dist/shared/chunk-cgb2j94g.js +141 -0
- package/dist/shared/chunk-e1jcf22s.js +79 -0
- package/dist/shared/chunk-e3h0ddmx.js +168 -0
- package/dist/shared/chunk-f2vx4tpw.js +168 -0
- package/dist/shared/chunk-h3v10x04.js +271 -0
- package/dist/shared/chunk-hdvdfd1c.js +96 -0
- package/dist/shared/{chunk-dhyr0s9n.js → chunk-j902w020.js} +1 -1
- package/dist/shared/chunk-jdygp28a.js +260 -0
- package/dist/shared/chunk-jqre4qtw.js +180 -0
- package/dist/shared/{chunk-k8nabsxm.js → chunk-mgr904ap.js} +74 -34
- package/dist/shared/chunk-mr1tb0dp.js +167 -0
- package/dist/shared/chunk-nj420k31.js +54 -0
- package/dist/shared/chunk-p0x7hgv6.js +181 -0
- package/dist/shared/{chunk-w9dag6ce.js → chunk-pn6shbcs.js} +132 -80
- package/dist/shared/chunk-pzx0vpq1.js +223 -0
- package/dist/shared/chunk-tn0m98j8.js +42 -0
- package/dist/shared/{chunk-myq79qew.js → chunk-ttb2tt03.js} +47 -27
- package/dist/shared/chunk-vy874zxe.js +68 -0
- package/dist/shared/chunk-ww7k2azn.js +297 -0
- package/dist/shared/{chunk-jda3v59q.js → chunk-xa1b96mb.js} +2 -2
- package/dist/shared/chunk-xs6gp369.js +245 -0
- package/dist/shared/chunk-y4mmmayp.js +206 -0
- package/dist/src/accordion/accordion.js +1 -1
- package/dist/src/alert-dialog/alert-dialog.js +1 -1
- package/dist/src/badge/badge.js +1 -1
- package/dist/src/button/button.js +1 -1
- package/dist/src/calendar/calendar.js +1 -1
- package/dist/src/carousel/carousel.js +1 -1
- package/dist/src/checkbox/checkbox.js +1 -1
- package/dist/src/collapsible/collapsible.js +1 -1
- package/dist/src/combobox/combobox.js +1 -1
- package/dist/src/command/command.js +1 -1
- package/dist/src/context-menu/context-menu.js +1 -1
- package/dist/src/date-picker/date-picker.js +1 -1
- package/dist/src/dialog/dialog.js +1 -1
- package/dist/src/dropdown-menu/dropdown-menu.js +1 -1
- package/dist/src/hover-card/hover-card.js +1 -1
- package/dist/src/index.d.ts +14 -1
- package/dist/src/index.js +5595 -4310
- package/dist/src/menu/menu.js +1 -1
- package/dist/src/menubar/menubar.js +1 -1
- package/dist/src/navigation-menu/navigation-menu.js +1 -1
- package/dist/src/popover/popover.js +1 -1
- package/dist/src/progress/progress.js +1 -1
- package/dist/src/radio/radio.js +1 -1
- package/dist/src/resizable-panel/resizable-panel.js +1 -1
- package/dist/src/scroll-area/scroll-area.js +1 -1
- package/dist/src/select/select.js +1 -1
- package/dist/src/sheet/sheet.js +1 -1
- package/dist/src/slider/slider.js +1 -1
- package/dist/src/switch/switch.js +1 -1
- package/dist/src/tabs/tabs.js +1 -1
- package/dist/src/toggle/toggle.js +1 -1
- package/dist/src/toggle-group/toggle-group.js +1 -1
- package/dist/src/tooltip/tooltip.js +1 -1
- package/package.json +3 -3
- package/dist/shared/chunk-07yzsaaw.js +0 -165
- package/dist/shared/chunk-279bzynx.js +0 -132
- package/dist/shared/chunk-27xs9apd.js +0 -288
- package/dist/shared/chunk-2k8gxzdf.js +0 -151
- package/dist/shared/chunk-3rp73gkd.js +0 -175
- package/dist/shared/chunk-4rf1m34c.js +0 -267
- package/dist/shared/chunk-7bxsf80c.js +0 -60
- package/dist/shared/chunk-8qtexw5s.js +0 -199
- package/dist/shared/chunk-9ezgd78r.js +0 -142
- package/dist/shared/chunk-ajpj10z0.js +0 -282
- package/dist/shared/chunk-c46v0fsw.js +0 -117
- package/dist/shared/chunk-e4mm5e59.js +0 -178
- package/dist/shared/chunk-fqa5bwn1.js +0 -128
- package/dist/shared/chunk-g8hnc95b.js +0 -219
- package/dist/shared/chunk-j2tdpxgc.js +0 -185
- package/dist/shared/chunk-kcnq15je.js +0 -175
- package/dist/shared/chunk-mqs4qq0b.js +0 -46
- package/dist/shared/chunk-pg2yjn8f.js +0 -88
- package/dist/shared/chunk-rb53v045.js +0 -71
- package/dist/shared/chunk-s6a2yph8.js +0 -239
- package/dist/shared/chunk-vhx3sqw6.js +0 -196
- package/dist/shared/chunk-w318par6.js +0 -204
- package/dist/shared/chunk-wcdq7bew.js +0 -133
- package/dist/shared/chunk-z0gwkzgp.js +0 -34
- package/dist/shared/chunk-z850et33.js +0 -161
- package/dist/shared/chunk-zyfc6cx3.js +0 -61
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setRovingTabindex
|
|
3
|
+
} from "./chunk-e2v1c9ex.js";
|
|
4
|
+
import {
|
|
5
|
+
handleListNavigation
|
|
6
|
+
} from "./chunk-7867pr13.js";
|
|
7
|
+
import {
|
|
8
|
+
setChecked,
|
|
9
|
+
setDataState,
|
|
10
|
+
setDisabled
|
|
11
|
+
} from "./chunk-vevfhpc9.js";
|
|
12
|
+
import {
|
|
13
|
+
uniqueId
|
|
14
|
+
} from "./chunk-8y1jf6xr.js";
|
|
15
|
+
import {
|
|
16
|
+
applyAttrs
|
|
17
|
+
} from "./chunk-2db2dnp3.js";
|
|
18
|
+
|
|
19
|
+
// src/radio/radio.tsx
|
|
20
|
+
import { __discardMountFrame, __element, __enterChildren, __exitChildren, __flushMountFrame, __insert, __on, __pushMountFrame } from "@vertz/ui/internals";
|
|
21
|
+
import { signal } from "@vertz/ui";
|
|
22
|
+
function RadioGroup(items, itemValues, selectItem) {
|
|
23
|
+
const __mfDepth = __pushMountFrame();
|
|
24
|
+
try {
|
|
25
|
+
const __mfResult0 = (() => {
|
|
26
|
+
const __el0 = __element("div");
|
|
27
|
+
__el0.setAttribute("role", "radiogroup");
|
|
28
|
+
{
|
|
29
|
+
const __v = uniqueId("radiogroup");
|
|
30
|
+
if (__v != null && __v !== false)
|
|
31
|
+
__el0.setAttribute("id", __v === true ? "" : __v);
|
|
32
|
+
}
|
|
33
|
+
__on(__el0, "keydown", (event) => {
|
|
34
|
+
const result = handleListNavigation(event, items, { orientation: "vertical" });
|
|
35
|
+
if (result) {
|
|
36
|
+
const idx = items.indexOf(result);
|
|
37
|
+
if (idx >= 0) {
|
|
38
|
+
const val = itemValues[idx];
|
|
39
|
+
if (val !== undefined)
|
|
40
|
+
selectItem(val);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return __el0;
|
|
45
|
+
})();
|
|
46
|
+
__flushMountFrame();
|
|
47
|
+
return __mfResult0;
|
|
48
|
+
} catch (__mfErr) {
|
|
49
|
+
__discardMountFrame(__mfDepth);
|
|
50
|
+
throw __mfErr;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function RadioItem(value, label, isActive, disabled, selectItem) {
|
|
54
|
+
const __mfDepth = __pushMountFrame();
|
|
55
|
+
try {
|
|
56
|
+
const el = (() => {
|
|
57
|
+
const __el0 = __element("div");
|
|
58
|
+
__el0.setAttribute("role", "radio");
|
|
59
|
+
{
|
|
60
|
+
const __v = uniqueId("radio");
|
|
61
|
+
if (__v != null && __v !== false)
|
|
62
|
+
__el0.setAttribute("id", __v === true ? "" : __v);
|
|
63
|
+
}
|
|
64
|
+
{
|
|
65
|
+
const __v = value;
|
|
66
|
+
if (__v != null && __v !== false)
|
|
67
|
+
__el0.setAttribute("data-value", __v === true ? "" : __v);
|
|
68
|
+
}
|
|
69
|
+
{
|
|
70
|
+
const __v = isActive ? "true" : "false";
|
|
71
|
+
if (__v != null && __v !== false)
|
|
72
|
+
__el0.setAttribute("aria-checked", __v === true ? "" : __v);
|
|
73
|
+
}
|
|
74
|
+
{
|
|
75
|
+
const __v = isActive ? "checked" : "unchecked";
|
|
76
|
+
if (__v != null && __v !== false)
|
|
77
|
+
__el0.setAttribute("data-state", __v === true ? "" : __v);
|
|
78
|
+
}
|
|
79
|
+
__on(__el0, "click", () => {
|
|
80
|
+
if (!disabled)
|
|
81
|
+
selectItem(value);
|
|
82
|
+
});
|
|
83
|
+
__enterChildren(__el0);
|
|
84
|
+
__insert(__el0, label ?? value);
|
|
85
|
+
__exitChildren();
|
|
86
|
+
return __el0;
|
|
87
|
+
})();
|
|
88
|
+
if (disabled) {
|
|
89
|
+
setDisabled(el, true);
|
|
90
|
+
el.setAttribute("data-disabled", "");
|
|
91
|
+
}
|
|
92
|
+
const __mfResult0 = el;
|
|
93
|
+
__flushMountFrame();
|
|
94
|
+
return __mfResult0;
|
|
95
|
+
} catch (__mfErr) {
|
|
96
|
+
__discardMountFrame(__mfDepth);
|
|
97
|
+
throw __mfErr;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function RadioRoot(options = {}) {
|
|
101
|
+
const { defaultValue = "", onValueChange, ...attrs } = options;
|
|
102
|
+
const state = { value: signal(defaultValue) };
|
|
103
|
+
const items = [];
|
|
104
|
+
const itemValues = [];
|
|
105
|
+
function selectItem(value) {
|
|
106
|
+
state.value.value = value;
|
|
107
|
+
for (let i = 0;i < items.length; i++) {
|
|
108
|
+
const item = items[i];
|
|
109
|
+
if (!item)
|
|
110
|
+
continue;
|
|
111
|
+
const isActive = itemValues[i] === value;
|
|
112
|
+
setChecked(item, isActive);
|
|
113
|
+
setDataState(item, isActive ? "checked" : "unchecked");
|
|
114
|
+
}
|
|
115
|
+
setRovingTabindex(items, itemValues.indexOf(value));
|
|
116
|
+
onValueChange?.(value);
|
|
117
|
+
}
|
|
118
|
+
const root = RadioGroup(items, itemValues, selectItem);
|
|
119
|
+
const cleanups = [];
|
|
120
|
+
function Item(value, label, itemOptions) {
|
|
121
|
+
const isActive = value === state.value.peek();
|
|
122
|
+
const disabled = itemOptions?.disabled ?? false;
|
|
123
|
+
const item = RadioItem(value, label, isActive, disabled, selectItem);
|
|
124
|
+
const handleClick = () => {
|
|
125
|
+
if (!disabled)
|
|
126
|
+
item.focus();
|
|
127
|
+
};
|
|
128
|
+
item.addEventListener("click", handleClick);
|
|
129
|
+
cleanups.push(() => item.removeEventListener("click", handleClick));
|
|
130
|
+
items.push(item);
|
|
131
|
+
itemValues.push(value);
|
|
132
|
+
root.appendChild(item);
|
|
133
|
+
setRovingTabindex(items, itemValues.indexOf(state.value.peek()));
|
|
134
|
+
return item;
|
|
135
|
+
}
|
|
136
|
+
function destroy() {
|
|
137
|
+
for (const cleanup of cleanups)
|
|
138
|
+
cleanup();
|
|
139
|
+
cleanups.length = 0;
|
|
140
|
+
}
|
|
141
|
+
applyAttrs(root, attrs);
|
|
142
|
+
return { root, state, Item, destroy };
|
|
143
|
+
}
|
|
144
|
+
var Radio = {
|
|
145
|
+
Root: RadioRoot
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export { Radio };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setRovingTabindex
|
|
3
|
+
} from "./chunk-e2v1c9ex.js";
|
|
4
|
+
import {
|
|
5
|
+
Keys,
|
|
6
|
+
handleListNavigation,
|
|
7
|
+
isKey
|
|
8
|
+
} from "./chunk-7867pr13.js";
|
|
9
|
+
import {
|
|
10
|
+
setDataState,
|
|
11
|
+
setPressed
|
|
12
|
+
} from "./chunk-vevfhpc9.js";
|
|
13
|
+
import {
|
|
14
|
+
applyAttrs
|
|
15
|
+
} from "./chunk-2db2dnp3.js";
|
|
16
|
+
|
|
17
|
+
// src/toggle-group/toggle-group.tsx
|
|
18
|
+
import { __discardMountFrame, __element, __flushMountFrame, __on, __pushMountFrame } from "@vertz/ui/internals";
|
|
19
|
+
import { signal } from "@vertz/ui";
|
|
20
|
+
function ToggleGroupRoot(options = {}) {
|
|
21
|
+
const __mfDepth = __pushMountFrame();
|
|
22
|
+
try {
|
|
23
|
+
let toggleValue = function(itemValue) {
|
|
24
|
+
if (state.disabled.peek())
|
|
25
|
+
return;
|
|
26
|
+
const current = [...state.value.peek()];
|
|
27
|
+
const idx = current.indexOf(itemValue);
|
|
28
|
+
if (type === "single") {
|
|
29
|
+
if (idx >= 0) {
|
|
30
|
+
current.length = 0;
|
|
31
|
+
} else {
|
|
32
|
+
current.length = 0;
|
|
33
|
+
current.push(itemValue);
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
if (idx >= 0) {
|
|
37
|
+
current.splice(idx, 1);
|
|
38
|
+
} else {
|
|
39
|
+
current.push(itemValue);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
state.value.value = current;
|
|
43
|
+
onValueChange?.(current);
|
|
44
|
+
for (const item of items) {
|
|
45
|
+
const val = item.getAttribute("data-value") ?? "";
|
|
46
|
+
const isOn = current.includes(val);
|
|
47
|
+
setPressed(item, isOn);
|
|
48
|
+
setDataState(item, isOn ? "on" : "off");
|
|
49
|
+
}
|
|
50
|
+
}, Item = function(value) {
|
|
51
|
+
const isOn = state.value.peek().includes(value);
|
|
52
|
+
const item = (() => {
|
|
53
|
+
const __el1 = __element("button");
|
|
54
|
+
__el1.setAttribute("type", "button");
|
|
55
|
+
{
|
|
56
|
+
const __v = value;
|
|
57
|
+
if (__v != null && __v !== false)
|
|
58
|
+
__el1.setAttribute("data-value", __v === true ? "" : __v);
|
|
59
|
+
}
|
|
60
|
+
{
|
|
61
|
+
const __v = isOn ? "true" : "false";
|
|
62
|
+
if (__v != null && __v !== false)
|
|
63
|
+
__el1.setAttribute("aria-pressed", __v === true ? "" : __v);
|
|
64
|
+
}
|
|
65
|
+
{
|
|
66
|
+
const __v = isOn ? "on" : "off";
|
|
67
|
+
if (__v != null && __v !== false)
|
|
68
|
+
__el1.setAttribute("data-state", __v === true ? "" : __v);
|
|
69
|
+
}
|
|
70
|
+
{
|
|
71
|
+
const __v = state.disabled.peek();
|
|
72
|
+
if (__v != null && __v !== false)
|
|
73
|
+
__el1.setAttribute("disabled", __v === true ? "" : __v);
|
|
74
|
+
}
|
|
75
|
+
{
|
|
76
|
+
const __v = state.disabled.peek() ? "true" : undefined;
|
|
77
|
+
if (__v != null && __v !== false)
|
|
78
|
+
__el1.setAttribute("aria-disabled", __v === true ? "" : __v);
|
|
79
|
+
}
|
|
80
|
+
__on(__el1, "click", () => toggleValue(value));
|
|
81
|
+
return __el1;
|
|
82
|
+
})();
|
|
83
|
+
items.push(item);
|
|
84
|
+
setRovingTabindex(items, 0);
|
|
85
|
+
root.appendChild(item);
|
|
86
|
+
return item;
|
|
87
|
+
};
|
|
88
|
+
const {
|
|
89
|
+
type = "single",
|
|
90
|
+
defaultValue = [],
|
|
91
|
+
orientation = "horizontal",
|
|
92
|
+
disabled = false,
|
|
93
|
+
onValueChange,
|
|
94
|
+
...attrs
|
|
95
|
+
} = options;
|
|
96
|
+
const state = {
|
|
97
|
+
value: signal([...defaultValue]),
|
|
98
|
+
disabled: signal(disabled)
|
|
99
|
+
};
|
|
100
|
+
const items = [];
|
|
101
|
+
const root = (() => {
|
|
102
|
+
const __el0 = __element("div");
|
|
103
|
+
__el0.setAttribute("role", "group");
|
|
104
|
+
{
|
|
105
|
+
const __v = orientation;
|
|
106
|
+
if (__v != null && __v !== false)
|
|
107
|
+
__el0.setAttribute("data-orientation", __v === true ? "" : __v);
|
|
108
|
+
}
|
|
109
|
+
__on(__el0, "keydown", (event) => {
|
|
110
|
+
if (isKey(event, Keys.ArrowLeft, Keys.ArrowRight, Keys.ArrowUp, Keys.ArrowDown, Keys.Home, Keys.End)) {
|
|
111
|
+
const result = handleListNavigation(event, items, { orientation });
|
|
112
|
+
if (result) {
|
|
113
|
+
const idx = items.indexOf(result);
|
|
114
|
+
if (idx >= 0) {
|
|
115
|
+
setRovingTabindex(items, idx);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
return __el0;
|
|
121
|
+
})();
|
|
122
|
+
applyAttrs(root, attrs);
|
|
123
|
+
const __mfResult0 = { root, state, Item };
|
|
124
|
+
__flushMountFrame();
|
|
125
|
+
return __mfResult0;
|
|
126
|
+
} catch (__mfErr) {
|
|
127
|
+
__discardMountFrame(__mfDepth);
|
|
128
|
+
throw __mfErr;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
var ToggleGroup = {
|
|
132
|
+
Root: ToggleGroupRoot
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export { ToggleGroup };
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Keys,
|
|
3
|
+
handleListNavigation,
|
|
4
|
+
isKey
|
|
5
|
+
} from "./chunk-7867pr13.js";
|
|
6
|
+
import {
|
|
7
|
+
setDataState,
|
|
8
|
+
setExpanded,
|
|
9
|
+
setHidden,
|
|
10
|
+
setHiddenAnimated
|
|
11
|
+
} from "./chunk-vevfhpc9.js";
|
|
12
|
+
import {
|
|
13
|
+
uniqueId
|
|
14
|
+
} from "./chunk-8y1jf6xr.js";
|
|
15
|
+
import {
|
|
16
|
+
applyAttrs
|
|
17
|
+
} from "./chunk-2db2dnp3.js";
|
|
18
|
+
|
|
19
|
+
// src/accordion/accordion.tsx
|
|
20
|
+
import { __discardMountFrame, __element, __enterChildren, __exitChildren, __flushMountFrame, __insert, __on, __pushMountFrame, __styleStr } from "@vertz/ui/internals";
|
|
21
|
+
import { signal } from "@vertz/ui";
|
|
22
|
+
function AccordionRoot(options = {}) {
|
|
23
|
+
const __mfDepth = __pushMountFrame();
|
|
24
|
+
try {
|
|
25
|
+
let updateItemState = function(val, open) {
|
|
26
|
+
const entry = itemMap.get(val);
|
|
27
|
+
if (!entry)
|
|
28
|
+
return;
|
|
29
|
+
const { trigger: t, content: c } = entry;
|
|
30
|
+
if (open) {
|
|
31
|
+
setHidden(c, false);
|
|
32
|
+
}
|
|
33
|
+
const height = c.scrollHeight;
|
|
34
|
+
c.style.setProperty("--accordion-content-height", `${height}px`);
|
|
35
|
+
setExpanded(t, open);
|
|
36
|
+
setDataState(t, open ? "open" : "closed");
|
|
37
|
+
setDataState(c, open ? "open" : "closed");
|
|
38
|
+
if (!open) {
|
|
39
|
+
setHiddenAnimated(c, true);
|
|
40
|
+
}
|
|
41
|
+
}, toggleItem = function(value) {
|
|
42
|
+
const prev = [...state.value.peek()];
|
|
43
|
+
const current = [...prev];
|
|
44
|
+
const idx = current.indexOf(value);
|
|
45
|
+
if (idx >= 0) {
|
|
46
|
+
current.splice(idx, 1);
|
|
47
|
+
} else {
|
|
48
|
+
if (multiple) {
|
|
49
|
+
current.push(value);
|
|
50
|
+
} else {
|
|
51
|
+
current.length = 0;
|
|
52
|
+
current.push(value);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
state.value.value = current;
|
|
56
|
+
onValueChange?.(current);
|
|
57
|
+
for (const v of prev) {
|
|
58
|
+
if (!current.includes(v)) {
|
|
59
|
+
updateItemState(v, false);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
for (const v of current) {
|
|
63
|
+
if (!prev.includes(v)) {
|
|
64
|
+
updateItemState(v, true);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}, Item = function(value) {
|
|
68
|
+
const baseId = uniqueId("accordion");
|
|
69
|
+
const triggerId = `${baseId}-trigger`;
|
|
70
|
+
const contentId = `${baseId}-content`;
|
|
71
|
+
const isOpen = state.value.peek().includes(value);
|
|
72
|
+
const trigger = (() => {
|
|
73
|
+
const __el1 = __element("button");
|
|
74
|
+
__el1.setAttribute("type", "button");
|
|
75
|
+
{
|
|
76
|
+
const __v = triggerId;
|
|
77
|
+
if (__v != null && __v !== false)
|
|
78
|
+
__el1.setAttribute("id", __v === true ? "" : __v);
|
|
79
|
+
}
|
|
80
|
+
{
|
|
81
|
+
const __v = contentId;
|
|
82
|
+
if (__v != null && __v !== false)
|
|
83
|
+
__el1.setAttribute("aria-controls", __v === true ? "" : __v);
|
|
84
|
+
}
|
|
85
|
+
{
|
|
86
|
+
const __v = value;
|
|
87
|
+
if (__v != null && __v !== false)
|
|
88
|
+
__el1.setAttribute("data-value", __v === true ? "" : __v);
|
|
89
|
+
}
|
|
90
|
+
{
|
|
91
|
+
const __v = isOpen ? "true" : "false";
|
|
92
|
+
if (__v != null && __v !== false)
|
|
93
|
+
__el1.setAttribute("aria-expanded", __v === true ? "" : __v);
|
|
94
|
+
}
|
|
95
|
+
{
|
|
96
|
+
const __v = isOpen ? "open" : "closed";
|
|
97
|
+
if (__v != null && __v !== false)
|
|
98
|
+
__el1.setAttribute("data-state", __v === true ? "" : __v);
|
|
99
|
+
}
|
|
100
|
+
__on(__el1, "click", () => toggleItem(value));
|
|
101
|
+
return __el1;
|
|
102
|
+
})();
|
|
103
|
+
const content = (() => {
|
|
104
|
+
const __el2 = __element("div");
|
|
105
|
+
__el2.setAttribute("role", "region");
|
|
106
|
+
{
|
|
107
|
+
const __v = contentId;
|
|
108
|
+
if (__v != null && __v !== false)
|
|
109
|
+
__el2.setAttribute("id", __v === true ? "" : __v);
|
|
110
|
+
}
|
|
111
|
+
{
|
|
112
|
+
const __v = triggerId;
|
|
113
|
+
if (__v != null && __v !== false)
|
|
114
|
+
__el2.setAttribute("aria-labelledby", __v === true ? "" : __v);
|
|
115
|
+
}
|
|
116
|
+
{
|
|
117
|
+
const __v = isOpen ? "false" : "true";
|
|
118
|
+
if (__v != null && __v !== false)
|
|
119
|
+
__el2.setAttribute("aria-hidden", __v === true ? "" : __v);
|
|
120
|
+
}
|
|
121
|
+
{
|
|
122
|
+
const __v = isOpen ? "open" : "closed";
|
|
123
|
+
if (__v != null && __v !== false)
|
|
124
|
+
__el2.setAttribute("data-state", __v === true ? "" : __v);
|
|
125
|
+
}
|
|
126
|
+
{
|
|
127
|
+
const __v = { display: isOpen ? "" : "none" };
|
|
128
|
+
if (__v != null && __v !== false)
|
|
129
|
+
__el2.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
|
|
130
|
+
}
|
|
131
|
+
return __el2;
|
|
132
|
+
})();
|
|
133
|
+
const item = (() => {
|
|
134
|
+
const __el3 = __element("div");
|
|
135
|
+
{
|
|
136
|
+
const __v = value;
|
|
137
|
+
if (__v != null && __v !== false)
|
|
138
|
+
__el3.setAttribute("data-value", __v === true ? "" : __v);
|
|
139
|
+
}
|
|
140
|
+
__enterChildren(__el3);
|
|
141
|
+
__insert(__el3, trigger);
|
|
142
|
+
__insert(__el3, content);
|
|
143
|
+
__exitChildren();
|
|
144
|
+
return __el3;
|
|
145
|
+
})();
|
|
146
|
+
itemMap.set(value, { trigger, content });
|
|
147
|
+
triggers.push(trigger);
|
|
148
|
+
root.appendChild(item);
|
|
149
|
+
if (isOpen) {
|
|
150
|
+
requestAnimationFrame(() => {
|
|
151
|
+
const height = content.scrollHeight;
|
|
152
|
+
content.style.setProperty("--accordion-content-height", `${height}px`);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return { item, trigger, content };
|
|
156
|
+
};
|
|
157
|
+
const { multiple = false, defaultValue = [], onValueChange, ...attrs } = options;
|
|
158
|
+
const state = { value: signal([...defaultValue]) };
|
|
159
|
+
const triggers = [];
|
|
160
|
+
const itemMap = new Map;
|
|
161
|
+
const root = (() => {
|
|
162
|
+
const __el0 = __element("div");
|
|
163
|
+
__el0.setAttribute("data-orientation", "vertical");
|
|
164
|
+
__on(__el0, "keydown", (event) => {
|
|
165
|
+
if (isKey(event, Keys.ArrowUp, Keys.ArrowDown, Keys.Home, Keys.End)) {
|
|
166
|
+
handleListNavigation(event, triggers, { orientation: "vertical" });
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
return __el0;
|
|
170
|
+
})();
|
|
171
|
+
applyAttrs(root, attrs);
|
|
172
|
+
const __mfResult0 = { root, state, Item };
|
|
173
|
+
__flushMountFrame();
|
|
174
|
+
return __mfResult0;
|
|
175
|
+
} catch (__mfErr) {
|
|
176
|
+
__discardMountFrame(__mfDepth);
|
|
177
|
+
throw __mfErr;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
var Accordion = {
|
|
181
|
+
Root: AccordionRoot
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export { Accordion };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setDataState,
|
|
3
|
+
setExpanded,
|
|
4
|
+
setHidden,
|
|
5
|
+
setHiddenAnimated
|
|
6
|
+
} from "./chunk-vevfhpc9.js";
|
|
7
|
+
import {
|
|
8
|
+
linkedIds
|
|
9
|
+
} from "./chunk-8y1jf6xr.js";
|
|
10
|
+
import {
|
|
11
|
+
applyAttrs
|
|
12
|
+
} from "./chunk-2db2dnp3.js";
|
|
13
|
+
|
|
14
|
+
// src/collapsible/collapsible.tsx
|
|
15
|
+
import { __discardMountFrame, __element, __enterChildren, __exitChildren, __flushMountFrame, __insert, __on, __pushMountFrame, __styleStr } from "@vertz/ui/internals";
|
|
16
|
+
import { signal } from "@vertz/ui";
|
|
17
|
+
function CollapsibleRoot(options = {}) {
|
|
18
|
+
const __mfDepth = __pushMountFrame();
|
|
19
|
+
try {
|
|
20
|
+
let toggle = function() {
|
|
21
|
+
if (state.disabled.peek())
|
|
22
|
+
return;
|
|
23
|
+
const next = !state.open.peek();
|
|
24
|
+
state.open.value = next;
|
|
25
|
+
if (next) {
|
|
26
|
+
setHidden(content, false);
|
|
27
|
+
}
|
|
28
|
+
const height = content.scrollHeight;
|
|
29
|
+
content.style.setProperty("--collapsible-content-height", `${height}px`);
|
|
30
|
+
setExpanded(trigger, next);
|
|
31
|
+
setDataState(trigger, next ? "open" : "closed");
|
|
32
|
+
setDataState(content, next ? "open" : "closed");
|
|
33
|
+
if (!next) {
|
|
34
|
+
setHiddenAnimated(content, true);
|
|
35
|
+
}
|
|
36
|
+
onOpenChange?.(next);
|
|
37
|
+
};
|
|
38
|
+
const { defaultOpen = false, disabled = false, onOpenChange, ...attrs } = options;
|
|
39
|
+
const ids = linkedIds("collapsible");
|
|
40
|
+
const state = {
|
|
41
|
+
open: signal(defaultOpen),
|
|
42
|
+
disabled: signal(disabled)
|
|
43
|
+
};
|
|
44
|
+
const trigger = (() => {
|
|
45
|
+
const __el0 = __element("button");
|
|
46
|
+
__el0.setAttribute("type", "button");
|
|
47
|
+
{
|
|
48
|
+
const __v = ids.triggerId;
|
|
49
|
+
if (__v != null && __v !== false)
|
|
50
|
+
__el0.setAttribute("id", __v === true ? "" : __v);
|
|
51
|
+
}
|
|
52
|
+
{
|
|
53
|
+
const __v = ids.contentId;
|
|
54
|
+
if (__v != null && __v !== false)
|
|
55
|
+
__el0.setAttribute("aria-controls", __v === true ? "" : __v);
|
|
56
|
+
}
|
|
57
|
+
{
|
|
58
|
+
const __v = defaultOpen ? "true" : "false";
|
|
59
|
+
if (__v != null && __v !== false)
|
|
60
|
+
__el0.setAttribute("aria-expanded", __v === true ? "" : __v);
|
|
61
|
+
}
|
|
62
|
+
{
|
|
63
|
+
const __v = defaultOpen ? "open" : "closed";
|
|
64
|
+
if (__v != null && __v !== false)
|
|
65
|
+
__el0.setAttribute("data-state", __v === true ? "" : __v);
|
|
66
|
+
}
|
|
67
|
+
{
|
|
68
|
+
const __v = disabled;
|
|
69
|
+
if (__v != null && __v !== false)
|
|
70
|
+
__el0.setAttribute("disabled", __v === true ? "" : __v);
|
|
71
|
+
}
|
|
72
|
+
{
|
|
73
|
+
const __v = disabled ? "true" : undefined;
|
|
74
|
+
if (__v != null && __v !== false)
|
|
75
|
+
__el0.setAttribute("aria-disabled", __v === true ? "" : __v);
|
|
76
|
+
}
|
|
77
|
+
__on(__el0, "click", toggle);
|
|
78
|
+
return __el0;
|
|
79
|
+
})();
|
|
80
|
+
const content = (() => {
|
|
81
|
+
const __el1 = __element("div");
|
|
82
|
+
{
|
|
83
|
+
const __v = ids.contentId;
|
|
84
|
+
if (__v != null && __v !== false)
|
|
85
|
+
__el1.setAttribute("id", __v === true ? "" : __v);
|
|
86
|
+
}
|
|
87
|
+
{
|
|
88
|
+
const __v = defaultOpen ? "false" : "true";
|
|
89
|
+
if (__v != null && __v !== false)
|
|
90
|
+
__el1.setAttribute("aria-hidden", __v === true ? "" : __v);
|
|
91
|
+
}
|
|
92
|
+
{
|
|
93
|
+
const __v = defaultOpen ? "open" : "closed";
|
|
94
|
+
if (__v != null && __v !== false)
|
|
95
|
+
__el1.setAttribute("data-state", __v === true ? "" : __v);
|
|
96
|
+
}
|
|
97
|
+
{
|
|
98
|
+
const __v = { display: defaultOpen ? "" : "none" };
|
|
99
|
+
if (__v != null && __v !== false)
|
|
100
|
+
__el1.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
|
|
101
|
+
}
|
|
102
|
+
return __el1;
|
|
103
|
+
})();
|
|
104
|
+
const root = (() => {
|
|
105
|
+
const __el2 = __element("div");
|
|
106
|
+
__enterChildren(__el2);
|
|
107
|
+
__insert(__el2, trigger);
|
|
108
|
+
__insert(__el2, content);
|
|
109
|
+
__exitChildren();
|
|
110
|
+
return __el2;
|
|
111
|
+
})();
|
|
112
|
+
applyAttrs(root, attrs);
|
|
113
|
+
const __mfResult0 = { root, trigger, content, state };
|
|
114
|
+
__flushMountFrame();
|
|
115
|
+
return __mfResult0;
|
|
116
|
+
} catch (__mfErr) {
|
|
117
|
+
__discardMountFrame(__mfDepth);
|
|
118
|
+
throw __mfErr;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
var Collapsible = {
|
|
122
|
+
Root: CollapsibleRoot
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export { Collapsible };
|