@vertz/ui-primitives 0.2.16 → 0.2.17
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-18y8gfk0.js +308 -0
- package/dist/shared/chunk-4085nbdq.js +196 -0
- package/dist/shared/chunk-4da5zksy.js +46 -0
- package/dist/shared/chunk-7ffg0caj.js +265 -0
- package/dist/shared/{chunk-w06tst6x.js → chunk-7kpsyjd7.js} +9 -5
- package/dist/shared/chunk-7krvqrwq.js +177 -0
- package/dist/shared/chunk-8ak7vdk1.js +151 -0
- package/dist/shared/chunk-8nk0ya7a.js +163 -0
- package/dist/shared/chunk-8tvzqry6.js +218 -0
- package/dist/shared/{chunk-qpfqyrc5.js → chunk-96d9nr7y.js} +1 -1
- package/dist/shared/chunk-9hj9p7s2.js +95 -0
- package/dist/shared/chunk-avxcmmk6.js +178 -0
- package/dist/shared/chunk-bew4bjgf.js +165 -0
- package/dist/shared/chunk-dpsgb1xw.js +18 -0
- package/dist/shared/chunk-g9qvd20g.js +133 -0
- package/dist/shared/chunk-gkddsbmh.js +73 -0
- package/dist/shared/chunk-gt0wth9h.js +128 -0
- package/dist/shared/chunk-hr9hx58m.js +71 -0
- package/dist/shared/{chunk-n92bvn5d.js → chunk-j4cm8avr.js} +85 -59
- package/dist/shared/chunk-jz0s6srh.js +161 -0
- package/dist/shared/chunk-kg27s15c.js +282 -0
- package/dist/shared/chunk-m1ptgp1s.js +142 -0
- package/dist/shared/{chunk-9cqe2q6e.js → chunk-n9nwx58j.js} +9 -5
- package/dist/shared/chunk-ppcv3ehd.js +85 -0
- package/dist/shared/{chunk-vq9tfzh8.js → chunk-rnjm61t0.js} +5 -1
- package/dist/shared/chunk-sqs8kyb2.js +288 -0
- package/dist/shared/chunk-tfyg0qrp.js +117 -0
- package/dist/shared/chunk-ttsyf6ma.js +239 -0
- package/dist/shared/chunk-x0we8gcy.js +219 -0
- package/dist/shared/{chunk-6pnjrst7.js → chunk-x2hz98qn.js} +2 -2
- package/dist/shared/chunk-yr9yzpvq.js +107 -0
- package/dist/src/accordion/accordion.d.ts +14 -2
- package/dist/src/accordion/accordion.js +2 -1
- package/dist/src/badge/badge.d.ts +13 -1
- package/dist/src/badge/badge.js +2 -1
- package/dist/src/button/button.d.ts +16 -14
- package/dist/src/button/button.js +2 -2
- package/dist/src/calendar/calendar.d.ts +14 -2
- package/dist/src/calendar/calendar.js +2 -1
- package/dist/src/carousel/carousel.d.ts +14 -2
- package/dist/src/carousel/carousel.js +2 -1
- package/dist/src/checkbox/checkbox.d.ts +15 -13
- package/dist/src/checkbox/checkbox.js +2 -2
- package/dist/src/collapsible/collapsible.d.ts +14 -2
- package/dist/src/collapsible/collapsible.js +2 -1
- package/dist/src/combobox/combobox.d.ts +14 -2
- package/dist/src/combobox/combobox.js +2 -1
- package/dist/src/command/command.d.ts +14 -2
- package/dist/src/command/command.js +2 -1
- package/dist/src/context-menu/context-menu.d.ts +14 -2
- package/dist/src/context-menu/context-menu.js +2 -1
- package/dist/src/date-picker/date-picker.js +4 -3
- package/dist/src/dialog/dialog.d.ts +14 -2
- package/dist/src/dialog/dialog.js +2 -1
- package/dist/src/dropdown-menu/dropdown-menu.d.ts +13 -1
- package/dist/src/dropdown-menu/dropdown-menu.js +3 -2
- package/dist/src/hover-card/hover-card.d.ts +14 -2
- package/dist/src/hover-card/hover-card.js +2 -1
- package/dist/src/index.d.ts +132 -140
- package/dist/src/index.js +31 -30
- package/dist/src/menu/menu.d.ts +14 -2
- package/dist/src/menu/menu.js +2 -1
- package/dist/src/menubar/menubar.d.ts +14 -2
- package/dist/src/menubar/menubar.js +2 -1
- package/dist/src/navigation-menu/navigation-menu.d.ts +14 -2
- package/dist/src/navigation-menu/navigation-menu.js +2 -1
- package/dist/src/popover/popover.d.ts +14 -2
- package/dist/src/popover/popover.js +2 -1
- package/dist/src/progress/progress.d.ts +14 -2
- package/dist/src/progress/progress.js +2 -1
- package/dist/src/radio/radio.d.ts +14 -2
- package/dist/src/radio/radio.js +2 -1
- package/dist/src/resizable-panel/resizable-panel.d.ts +14 -2
- package/dist/src/resizable-panel/resizable-panel.js +2 -1
- package/dist/src/scroll-area/scroll-area.d.ts +14 -2
- package/dist/src/scroll-area/scroll-area.js +2 -1
- package/dist/src/select/select.d.ts +14 -2
- package/dist/src/select/select.js +2 -1
- package/dist/src/slider/slider.d.ts +14 -2
- package/dist/src/slider/slider.js +2 -1
- package/dist/src/switch/switch.d.ts +13 -1
- package/dist/src/switch/switch.js +2 -1
- package/dist/src/tabs/tabs.d.ts +14 -2
- package/dist/src/tabs/tabs.js +2 -1
- package/dist/src/toast/toast.d.ts +14 -2
- package/dist/src/toast/toast.js +2 -1
- package/dist/src/toggle/toggle.d.ts +13 -1
- package/dist/src/toggle/toggle.js +2 -1
- package/dist/src/toggle-group/toggle-group.d.ts +14 -2
- package/dist/src/toggle-group/toggle-group.js +2 -1
- package/dist/src/tooltip/tooltip.d.ts +14 -2
- package/dist/src/tooltip/tooltip.js +2 -1
- package/package.json +3 -3
- package/dist/shared/chunk-2h5qpc00.js +0 -98
- package/dist/shared/chunk-31yptvbf.js +0 -151
- package/dist/shared/chunk-3pantb0p.js +0 -108
- package/dist/shared/chunk-3s6s6f06.js +0 -61
- package/dist/shared/chunk-48v8j0vh.js +0 -267
- package/dist/shared/chunk-6dmt4513.js +0 -78
- package/dist/shared/chunk-6sqwjfg8.js +0 -169
- package/dist/shared/chunk-8qfeqrrz.js +0 -179
- package/dist/shared/chunk-bcfzteh0.js +0 -148
- package/dist/shared/chunk-cr9sbwns.js +0 -235
- package/dist/shared/chunk-cvbf1js1.js +0 -52
- package/dist/shared/chunk-dkhst4wv.js +0 -97
- package/dist/shared/chunk-e3aj5yw4.js +0 -115
- package/dist/shared/chunk-fv1y77tn.js +0 -225
- package/dist/shared/chunk-h42bk324.js +0 -58
- package/dist/shared/chunk-h9m9x5my.js +0 -119
- package/dist/shared/chunk-qq0e0gym.js +0 -73
- package/dist/shared/chunk-tk1k1bet.js +0 -93
- package/dist/shared/chunk-tvpgeswh.js +0 -216
- package/dist/shared/chunk-vcp10kne.js +0 -175
- package/dist/shared/chunk-ve006hmy.js +0 -51
- package/dist/shared/chunk-vx1ajy2z.js +0 -115
- package/dist/shared/chunk-wnttq0gv.js +0 -49
- package/dist/shared/chunk-x6qzr3g6.js +0 -100
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Keys,
|
|
3
|
+
isKey
|
|
4
|
+
} from "./chunk-jctqs9m4.js";
|
|
5
|
+
import {
|
|
6
|
+
setHidden
|
|
7
|
+
} from "./chunk-vvjyx7fe.js";
|
|
8
|
+
import {
|
|
9
|
+
applyAttrs
|
|
10
|
+
} from "./chunk-dpsgb1xw.js";
|
|
11
|
+
import {
|
|
12
|
+
uniqueId
|
|
13
|
+
} from "./chunk-8y1jf6xr.js";
|
|
14
|
+
|
|
15
|
+
// src/command/command.tsx
|
|
16
|
+
import { __element, __enterChildren, __exitChildren, __insert, __on } from "@vertz/ui/internals";
|
|
17
|
+
import { signal } from "@vertz/ui";
|
|
18
|
+
function CommandRoot(options = {}) {
|
|
19
|
+
const { filter: customFilter, onSelect, onInputChange, placeholder, ...attrs } = options;
|
|
20
|
+
const listId = uniqueId("command-list");
|
|
21
|
+
const state = {
|
|
22
|
+
inputValue: signal(""),
|
|
23
|
+
activeIndex: signal(0)
|
|
24
|
+
};
|
|
25
|
+
const allItems = [];
|
|
26
|
+
const groups = new Map;
|
|
27
|
+
const defaultFilter = (value, search) => {
|
|
28
|
+
return value.toLowerCase().includes(search.toLowerCase());
|
|
29
|
+
};
|
|
30
|
+
const filterFn = customFilter ?? defaultFilter;
|
|
31
|
+
function getVisibleItems() {
|
|
32
|
+
return allItems.filter((item) => item.getAttribute("aria-hidden") !== "true");
|
|
33
|
+
}
|
|
34
|
+
function updateActiveItem() {
|
|
35
|
+
const visible = getVisibleItems();
|
|
36
|
+
const activeIdx = state.activeIndex.peek();
|
|
37
|
+
for (const item of allItems) {
|
|
38
|
+
item.setAttribute("aria-selected", "false");
|
|
39
|
+
}
|
|
40
|
+
if (visible.length > 0 && activeIdx >= 0 && activeIdx < visible.length) {
|
|
41
|
+
visible[activeIdx]?.setAttribute("aria-selected", "true");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function runFilter() {
|
|
45
|
+
const search = state.inputValue.peek();
|
|
46
|
+
let visibleCount = 0;
|
|
47
|
+
for (const item of allItems) {
|
|
48
|
+
const value = item.getAttribute("data-value") ?? "";
|
|
49
|
+
const text = item.textContent ?? "";
|
|
50
|
+
const keywords = item.getAttribute("data-keywords") ?? "";
|
|
51
|
+
const searchable = `${value} ${text} ${keywords}`;
|
|
52
|
+
const matches = search === "" || filterFn(searchable, search);
|
|
53
|
+
setHidden(item, !matches);
|
|
54
|
+
if (matches)
|
|
55
|
+
visibleCount++;
|
|
56
|
+
}
|
|
57
|
+
for (const [groupEl, group] of groups) {
|
|
58
|
+
const hasVisible = group.items.some((item) => item.getAttribute("aria-hidden") !== "true");
|
|
59
|
+
setHidden(group.heading, !hasVisible);
|
|
60
|
+
if (!hasVisible) {
|
|
61
|
+
groupEl.style.display = "none";
|
|
62
|
+
} else {
|
|
63
|
+
groupEl.style.display = "";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
setHidden(empty, visibleCount > 0);
|
|
67
|
+
state.activeIndex.value = 0;
|
|
68
|
+
updateActiveItem();
|
|
69
|
+
}
|
|
70
|
+
const input = (() => {
|
|
71
|
+
const __el0 = __element("input");
|
|
72
|
+
__el0.setAttribute("type", "text");
|
|
73
|
+
__el0.setAttribute("role", "combobox");
|
|
74
|
+
__el0.setAttribute("aria-autocomplete", "list");
|
|
75
|
+
__el0.setAttribute("aria-expanded", "true");
|
|
76
|
+
{
|
|
77
|
+
const __v = listId;
|
|
78
|
+
if (__v != null && __v !== false)
|
|
79
|
+
__el0.setAttribute("aria-controls", __v === true ? "" : __v);
|
|
80
|
+
}
|
|
81
|
+
{
|
|
82
|
+
const __v = placeholder;
|
|
83
|
+
if (__v != null && __v !== false)
|
|
84
|
+
__el0.setAttribute("placeholder", __v === true ? "" : __v);
|
|
85
|
+
}
|
|
86
|
+
__on(__el0, "input", () => {
|
|
87
|
+
state.inputValue.value = input.value;
|
|
88
|
+
onInputChange?.(input.value);
|
|
89
|
+
runFilter();
|
|
90
|
+
});
|
|
91
|
+
__on(__el0, "keydown", (event) => {
|
|
92
|
+
const visible = getVisibleItems();
|
|
93
|
+
if (isKey(event, Keys.ArrowDown)) {
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
const next = Math.min(state.activeIndex.peek() + 1, visible.length - 1);
|
|
96
|
+
state.activeIndex.value = next;
|
|
97
|
+
updateActiveItem();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (isKey(event, Keys.ArrowUp)) {
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
const prev = Math.max(state.activeIndex.peek() - 1, 0);
|
|
103
|
+
state.activeIndex.value = prev;
|
|
104
|
+
updateActiveItem();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (isKey(event, Keys.Enter)) {
|
|
108
|
+
event.preventDefault();
|
|
109
|
+
const active = visible[state.activeIndex.peek()];
|
|
110
|
+
if (active) {
|
|
111
|
+
const val = active.getAttribute("data-value");
|
|
112
|
+
if (val !== null) {
|
|
113
|
+
onSelect?.(val);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (isKey(event, Keys.Escape)) {
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
input.value = "";
|
|
121
|
+
state.inputValue.value = "";
|
|
122
|
+
onInputChange?.("");
|
|
123
|
+
runFilter();
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
return __el0;
|
|
127
|
+
})();
|
|
128
|
+
const list = (() => {
|
|
129
|
+
const __el1 = __element("div");
|
|
130
|
+
__el1.setAttribute("role", "listbox");
|
|
131
|
+
{
|
|
132
|
+
const __v = listId;
|
|
133
|
+
if (__v != null && __v !== false)
|
|
134
|
+
__el1.setAttribute("id", __v === true ? "" : __v);
|
|
135
|
+
}
|
|
136
|
+
return __el1;
|
|
137
|
+
})();
|
|
138
|
+
const empty = (() => {
|
|
139
|
+
const __el2 = __element("div");
|
|
140
|
+
__el2.setAttribute("aria-hidden", "true");
|
|
141
|
+
__el2.setAttribute("style", "display: none");
|
|
142
|
+
return __el2;
|
|
143
|
+
})();
|
|
144
|
+
const root = (() => {
|
|
145
|
+
const __el3 = __element("div");
|
|
146
|
+
__enterChildren(__el3);
|
|
147
|
+
__insert(__el3, input);
|
|
148
|
+
__insert(__el3, list);
|
|
149
|
+
__insert(__el3, empty);
|
|
150
|
+
__exitChildren();
|
|
151
|
+
return __el3;
|
|
152
|
+
})();
|
|
153
|
+
applyAttrs(root, attrs);
|
|
154
|
+
function createItem(value, label, keywords, parent) {
|
|
155
|
+
const item = (() => {
|
|
156
|
+
const __el4 = __element("div");
|
|
157
|
+
__el4.setAttribute("role", "option");
|
|
158
|
+
{
|
|
159
|
+
const __v = value;
|
|
160
|
+
if (__v != null && __v !== false)
|
|
161
|
+
__el4.setAttribute("data-value", __v === true ? "" : __v);
|
|
162
|
+
}
|
|
163
|
+
__el4.setAttribute("aria-selected", "false");
|
|
164
|
+
{
|
|
165
|
+
const __v = keywords && keywords.length > 0 ? keywords.join(" ") : undefined;
|
|
166
|
+
if (__v != null && __v !== false)
|
|
167
|
+
__el4.setAttribute("data-keywords", __v === true ? "" : __v);
|
|
168
|
+
}
|
|
169
|
+
__on(__el4, "click", () => {
|
|
170
|
+
onSelect?.(value);
|
|
171
|
+
});
|
|
172
|
+
__enterChildren(__el4);
|
|
173
|
+
__insert(__el4, label ?? value);
|
|
174
|
+
__exitChildren();
|
|
175
|
+
return __el4;
|
|
176
|
+
})();
|
|
177
|
+
allItems.push(item);
|
|
178
|
+
(parent ?? list).appendChild(item);
|
|
179
|
+
updateActiveItem();
|
|
180
|
+
return item;
|
|
181
|
+
}
|
|
182
|
+
function Item(value, label, keywords) {
|
|
183
|
+
return createItem(value, label, keywords);
|
|
184
|
+
}
|
|
185
|
+
function Group(label) {
|
|
186
|
+
const headingId = uniqueId("command-group");
|
|
187
|
+
const heading = (() => {
|
|
188
|
+
const __el5 = __element("div");
|
|
189
|
+
{
|
|
190
|
+
const __v = headingId;
|
|
191
|
+
if (__v != null && __v !== false)
|
|
192
|
+
__el5.setAttribute("id", __v === true ? "" : __v);
|
|
193
|
+
}
|
|
194
|
+
__enterChildren(__el5);
|
|
195
|
+
__insert(__el5, label);
|
|
196
|
+
__exitChildren();
|
|
197
|
+
return __el5;
|
|
198
|
+
})();
|
|
199
|
+
const el = (() => {
|
|
200
|
+
const __el6 = __element("div");
|
|
201
|
+
__el6.setAttribute("role", "group");
|
|
202
|
+
{
|
|
203
|
+
const __v = headingId;
|
|
204
|
+
if (__v != null && __v !== false)
|
|
205
|
+
__el6.setAttribute("aria-labelledby", __v === true ? "" : __v);
|
|
206
|
+
}
|
|
207
|
+
__enterChildren(__el6);
|
|
208
|
+
__insert(__el6, heading);
|
|
209
|
+
__exitChildren();
|
|
210
|
+
return __el6;
|
|
211
|
+
})();
|
|
212
|
+
const groupItems = [];
|
|
213
|
+
groups.set(el, { heading, items: groupItems });
|
|
214
|
+
list.appendChild(el);
|
|
215
|
+
return {
|
|
216
|
+
el,
|
|
217
|
+
Item: (value, itemLabel, keywords) => {
|
|
218
|
+
const item = createItem(value, itemLabel, keywords, el);
|
|
219
|
+
groupItems.push(item);
|
|
220
|
+
return item;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function Separator() {
|
|
225
|
+
const hr = (() => {
|
|
226
|
+
const __el7 = __element("hr");
|
|
227
|
+
__el7.setAttribute("role", "separator");
|
|
228
|
+
return __el7;
|
|
229
|
+
})();
|
|
230
|
+
list.appendChild(hr);
|
|
231
|
+
return hr;
|
|
232
|
+
}
|
|
233
|
+
return { root, input, list, empty, state, Item, Group, Separator };
|
|
234
|
+
}
|
|
235
|
+
var Command = {
|
|
236
|
+
Root: CommandRoot
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
export { Command };
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createDismiss
|
|
3
|
+
} from "./chunk-a6wp8c32.js";
|
|
4
|
+
import {
|
|
5
|
+
createFloatingPosition,
|
|
6
|
+
virtualElement
|
|
7
|
+
} from "./chunk-0mcr52hc.js";
|
|
8
|
+
import {
|
|
9
|
+
Keys,
|
|
10
|
+
handleListNavigation,
|
|
11
|
+
isKey
|
|
12
|
+
} from "./chunk-jctqs9m4.js";
|
|
13
|
+
import {
|
|
14
|
+
setDataState,
|
|
15
|
+
setHidden,
|
|
16
|
+
setHiddenAnimated
|
|
17
|
+
} from "./chunk-vvjyx7fe.js";
|
|
18
|
+
import {
|
|
19
|
+
applyAttrs
|
|
20
|
+
} from "./chunk-dpsgb1xw.js";
|
|
21
|
+
import {
|
|
22
|
+
uniqueId
|
|
23
|
+
} from "./chunk-8y1jf6xr.js";
|
|
24
|
+
|
|
25
|
+
// src/context-menu/context-menu.tsx
|
|
26
|
+
import { __element, __enterChildren, __exitChildren, __insert, __on } from "@vertz/ui/internals";
|
|
27
|
+
import { signal } from "@vertz/ui";
|
|
28
|
+
function ContextMenuRoot(options = {}) {
|
|
29
|
+
const { onSelect, positioning, ...attrs } = options;
|
|
30
|
+
const state = {
|
|
31
|
+
open: signal(false),
|
|
32
|
+
activeIndex: signal(-1)
|
|
33
|
+
};
|
|
34
|
+
const items = [];
|
|
35
|
+
let floatingCleanup = null;
|
|
36
|
+
let dismissCleanup = null;
|
|
37
|
+
function handleClickOutside(event) {
|
|
38
|
+
const target = event.target;
|
|
39
|
+
if (!trigger.contains(target) && !content.contains(target)) {
|
|
40
|
+
close();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function updateActiveItem(index) {
|
|
44
|
+
for (let i = 0;i < items.length; i++) {
|
|
45
|
+
items[i]?.setAttribute("tabindex", i === index ? "0" : "-1");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function openMenu(x, y) {
|
|
49
|
+
state.open.value = true;
|
|
50
|
+
setHidden(content, false);
|
|
51
|
+
setDataState(content, "open");
|
|
52
|
+
if (positioning) {
|
|
53
|
+
const result = createFloatingPosition(virtualElement(x, y), content, {
|
|
54
|
+
strategy: "fixed",
|
|
55
|
+
...positioning
|
|
56
|
+
});
|
|
57
|
+
floatingCleanup = result.cleanup;
|
|
58
|
+
dismissCleanup = createDismiss({
|
|
59
|
+
onDismiss: close,
|
|
60
|
+
insideElements: [trigger, content],
|
|
61
|
+
escapeKey: false
|
|
62
|
+
});
|
|
63
|
+
} else {
|
|
64
|
+
content.style.left = `${x}px`;
|
|
65
|
+
content.style.top = `${y}px`;
|
|
66
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
67
|
+
}
|
|
68
|
+
state.activeIndex.value = 0;
|
|
69
|
+
updateActiveItem(0);
|
|
70
|
+
items[0]?.focus();
|
|
71
|
+
}
|
|
72
|
+
function close() {
|
|
73
|
+
state.open.value = false;
|
|
74
|
+
setDataState(content, "closed");
|
|
75
|
+
setHiddenAnimated(content, true);
|
|
76
|
+
if (positioning) {
|
|
77
|
+
floatingCleanup?.();
|
|
78
|
+
floatingCleanup = null;
|
|
79
|
+
dismissCleanup?.();
|
|
80
|
+
dismissCleanup = null;
|
|
81
|
+
} else {
|
|
82
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const trigger = (() => {
|
|
86
|
+
const __el0 = __element("div");
|
|
87
|
+
__on(__el0, "contextmenu", (event) => {
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
if (state.open.peek()) {
|
|
90
|
+
close();
|
|
91
|
+
}
|
|
92
|
+
openMenu(event.clientX, event.clientY);
|
|
93
|
+
});
|
|
94
|
+
return __el0;
|
|
95
|
+
})();
|
|
96
|
+
const contentId = uniqueId("ctx-menu");
|
|
97
|
+
const content = (() => {
|
|
98
|
+
const __el1 = __element("div");
|
|
99
|
+
__el1.setAttribute("role", "menu");
|
|
100
|
+
{
|
|
101
|
+
const __v = contentId;
|
|
102
|
+
if (__v != null && __v !== false)
|
|
103
|
+
__el1.setAttribute("id", __v === true ? "" : __v);
|
|
104
|
+
}
|
|
105
|
+
__el1.setAttribute("style", "position: fixed; display: none;");
|
|
106
|
+
__el1.setAttribute("aria-hidden", "true");
|
|
107
|
+
__el1.setAttribute("data-state", "closed");
|
|
108
|
+
__on(__el1, "keydown", (event) => {
|
|
109
|
+
if (isKey(event, Keys.Escape)) {
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
close();
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (isKey(event, Keys.Enter, Keys.Space)) {
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
const active = items[state.activeIndex.peek()];
|
|
117
|
+
if (active) {
|
|
118
|
+
const val = active.getAttribute("data-value");
|
|
119
|
+
if (val !== null) {
|
|
120
|
+
onSelect?.(val);
|
|
121
|
+
close();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const result = handleListNavigation(event, items, { orientation: "vertical" });
|
|
127
|
+
if (result) {
|
|
128
|
+
const idx = items.indexOf(result);
|
|
129
|
+
if (idx >= 0) {
|
|
130
|
+
state.activeIndex.value = idx;
|
|
131
|
+
updateActiveItem(idx);
|
|
132
|
+
}
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {
|
|
136
|
+
const char = event.key.toLowerCase();
|
|
137
|
+
const match = items.find((item) => item.textContent?.toLowerCase().startsWith(char));
|
|
138
|
+
if (match) {
|
|
139
|
+
const idx = items.indexOf(match);
|
|
140
|
+
state.activeIndex.value = idx;
|
|
141
|
+
updateActiveItem(idx);
|
|
142
|
+
match.focus();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
return __el1;
|
|
147
|
+
})();
|
|
148
|
+
function createItem(value, label, parent) {
|
|
149
|
+
const item = (() => {
|
|
150
|
+
const __el2 = __element("div");
|
|
151
|
+
__el2.setAttribute("role", "menuitem");
|
|
152
|
+
{
|
|
153
|
+
const __v = value;
|
|
154
|
+
if (__v != null && __v !== false)
|
|
155
|
+
__el2.setAttribute("data-value", __v === true ? "" : __v);
|
|
156
|
+
}
|
|
157
|
+
__el2.setAttribute("tabindex", "-1");
|
|
158
|
+
__on(__el2, "click", () => {
|
|
159
|
+
onSelect?.(value);
|
|
160
|
+
close();
|
|
161
|
+
});
|
|
162
|
+
__enterChildren(__el2);
|
|
163
|
+
__insert(__el2, label ?? value);
|
|
164
|
+
__exitChildren();
|
|
165
|
+
return __el2;
|
|
166
|
+
})();
|
|
167
|
+
items.push(item);
|
|
168
|
+
(parent ?? content).appendChild(item);
|
|
169
|
+
return item;
|
|
170
|
+
}
|
|
171
|
+
function Item(value, label) {
|
|
172
|
+
return createItem(value, label);
|
|
173
|
+
}
|
|
174
|
+
function Group(label) {
|
|
175
|
+
const el = (() => {
|
|
176
|
+
const __el3 = __element("div");
|
|
177
|
+
__el3.setAttribute("role", "group");
|
|
178
|
+
{
|
|
179
|
+
const __v = label;
|
|
180
|
+
if (__v != null && __v !== false)
|
|
181
|
+
__el3.setAttribute("aria-label", __v === true ? "" : __v);
|
|
182
|
+
}
|
|
183
|
+
return __el3;
|
|
184
|
+
})();
|
|
185
|
+
content.appendChild(el);
|
|
186
|
+
return {
|
|
187
|
+
el,
|
|
188
|
+
Item: (value, itemLabel) => createItem(value, itemLabel, el)
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function Separator() {
|
|
192
|
+
const hr = (() => {
|
|
193
|
+
const __el4 = __element("hr");
|
|
194
|
+
__el4.setAttribute("role", "separator");
|
|
195
|
+
return __el4;
|
|
196
|
+
})();
|
|
197
|
+
content.appendChild(hr);
|
|
198
|
+
return hr;
|
|
199
|
+
}
|
|
200
|
+
function Label(text) {
|
|
201
|
+
const el = (() => {
|
|
202
|
+
const __el5 = __element("div");
|
|
203
|
+
__el5.setAttribute("role", "none");
|
|
204
|
+
__enterChildren(__el5);
|
|
205
|
+
__insert(__el5, text);
|
|
206
|
+
__exitChildren();
|
|
207
|
+
return __el5;
|
|
208
|
+
})();
|
|
209
|
+
content.appendChild(el);
|
|
210
|
+
return el;
|
|
211
|
+
}
|
|
212
|
+
applyAttrs(trigger, attrs);
|
|
213
|
+
return { trigger, content, state, Item, Group, Separator, Label };
|
|
214
|
+
}
|
|
215
|
+
var ContextMenu = {
|
|
216
|
+
Root: ContextMenuRoot
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export { ContextMenu };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import {
|
|
2
|
+
setRovingTabindex
|
|
3
|
+
} from "./chunk-e2v1c9ex.js";
|
|
4
|
+
import {
|
|
5
|
+
handleListNavigation
|
|
6
|
+
} from "./chunk-jctqs9m4.js";
|
|
7
|
+
import {
|
|
8
|
+
setChecked,
|
|
9
|
+
setDataState
|
|
10
|
+
} from "./chunk-vvjyx7fe.js";
|
|
11
|
+
import {
|
|
12
|
+
applyAttrs
|
|
13
|
+
} from "./chunk-dpsgb1xw.js";
|
|
14
|
+
import {
|
|
15
|
+
uniqueId
|
|
16
|
+
} from "./chunk-8y1jf6xr.js";
|
|
17
|
+
|
|
18
|
+
// src/radio/radio.tsx
|
|
19
|
+
import { __element, __enterChildren, __exitChildren, __insert, __on } from "@vertz/ui/internals";
|
|
20
|
+
import { signal } from "@vertz/ui";
|
|
21
|
+
function RadioRoot(options = {}) {
|
|
22
|
+
const { defaultValue = "", onValueChange, ...attrs } = options;
|
|
23
|
+
const state = { value: signal(defaultValue) };
|
|
24
|
+
const items = [];
|
|
25
|
+
const itemValues = [];
|
|
26
|
+
function selectItem(value) {
|
|
27
|
+
state.value.value = value;
|
|
28
|
+
for (let i = 0;i < items.length; i++) {
|
|
29
|
+
const item = items[i];
|
|
30
|
+
if (!item)
|
|
31
|
+
continue;
|
|
32
|
+
const isActive = itemValues[i] === value;
|
|
33
|
+
setChecked(item, isActive);
|
|
34
|
+
setDataState(item, isActive ? "checked" : "unchecked");
|
|
35
|
+
}
|
|
36
|
+
setRovingTabindex(items, itemValues.indexOf(value));
|
|
37
|
+
onValueChange?.(value);
|
|
38
|
+
}
|
|
39
|
+
const root = (() => {
|
|
40
|
+
const __el0 = __element("div");
|
|
41
|
+
__el0.setAttribute("role", "radiogroup");
|
|
42
|
+
{
|
|
43
|
+
const __v = uniqueId("radiogroup");
|
|
44
|
+
if (__v != null && __v !== false)
|
|
45
|
+
__el0.setAttribute("id", __v === true ? "" : __v);
|
|
46
|
+
}
|
|
47
|
+
__on(__el0, "keydown", (event) => {
|
|
48
|
+
const result = handleListNavigation(event, items, { orientation: "vertical" });
|
|
49
|
+
if (result) {
|
|
50
|
+
const idx = items.indexOf(result);
|
|
51
|
+
if (idx >= 0) {
|
|
52
|
+
const val = itemValues[idx];
|
|
53
|
+
if (val !== undefined)
|
|
54
|
+
selectItem(val);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return __el0;
|
|
59
|
+
})();
|
|
60
|
+
function Item(value, label) {
|
|
61
|
+
const isActive = value === state.value.peek();
|
|
62
|
+
const item = (() => {
|
|
63
|
+
const __el1 = __element("div");
|
|
64
|
+
__el1.setAttribute("role", "radio");
|
|
65
|
+
{
|
|
66
|
+
const __v = uniqueId("radio");
|
|
67
|
+
if (__v != null && __v !== false)
|
|
68
|
+
__el1.setAttribute("id", __v === true ? "" : __v);
|
|
69
|
+
}
|
|
70
|
+
{
|
|
71
|
+
const __v = value;
|
|
72
|
+
if (__v != null && __v !== false)
|
|
73
|
+
__el1.setAttribute("data-value", __v === true ? "" : __v);
|
|
74
|
+
}
|
|
75
|
+
{
|
|
76
|
+
const __v = isActive ? "true" : "false";
|
|
77
|
+
if (__v != null && __v !== false)
|
|
78
|
+
__el1.setAttribute("aria-checked", __v === true ? "" : __v);
|
|
79
|
+
}
|
|
80
|
+
{
|
|
81
|
+
const __v = isActive ? "checked" : "unchecked";
|
|
82
|
+
if (__v != null && __v !== false)
|
|
83
|
+
__el1.setAttribute("data-state", __v === true ? "" : __v);
|
|
84
|
+
}
|
|
85
|
+
__on(__el1, "click", () => {
|
|
86
|
+
selectItem(value);
|
|
87
|
+
item.focus();
|
|
88
|
+
});
|
|
89
|
+
__enterChildren(__el1);
|
|
90
|
+
__insert(__el1, label ?? value);
|
|
91
|
+
__exitChildren();
|
|
92
|
+
return __el1;
|
|
93
|
+
})();
|
|
94
|
+
items.push(item);
|
|
95
|
+
itemValues.push(value);
|
|
96
|
+
root.appendChild(item);
|
|
97
|
+
setRovingTabindex(items, itemValues.indexOf(state.value.peek()));
|
|
98
|
+
return item;
|
|
99
|
+
}
|
|
100
|
+
applyAttrs(root, attrs);
|
|
101
|
+
return { root, state, Item };
|
|
102
|
+
}
|
|
103
|
+
var Radio = {
|
|
104
|
+
Root: RadioRoot
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export { Radio };
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { Signal } from "@vertz/ui";
|
|
2
|
-
interface
|
|
2
|
+
interface ElementAttrs {
|
|
3
|
+
class?: string;
|
|
4
|
+
id?: string;
|
|
5
|
+
style?: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
role?: string;
|
|
8
|
+
tabindex?: number | string;
|
|
9
|
+
hidden?: boolean | string;
|
|
10
|
+
autofocus?: boolean;
|
|
11
|
+
[key: `data-${string}`]: string | undefined;
|
|
12
|
+
[key: `aria-${string}`]: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
interface AccordionOptions extends ElementAttrs {
|
|
3
15
|
multiple?: boolean;
|
|
4
16
|
defaultValue?: string[];
|
|
5
17
|
onValueChange?: (value: string[]) => void;
|
|
@@ -11,7 +23,7 @@ interface AccordionElements {
|
|
|
11
23
|
root: HTMLDivElement;
|
|
12
24
|
}
|
|
13
25
|
declare const Accordion: {
|
|
14
|
-
Root(options?: AccordionOptions)
|
|
26
|
+
Root: (options?: AccordionOptions) => AccordionElements & {
|
|
15
27
|
state: AccordionState;
|
|
16
28
|
Item: (value: string) => {
|
|
17
29
|
item: HTMLDivElement;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Accordion
|
|
3
|
-
} from "../../shared/chunk-
|
|
3
|
+
} from "../../shared/chunk-avxcmmk6.js";
|
|
4
4
|
import"../../shared/chunk-jctqs9m4.js";
|
|
5
5
|
import"../../shared/chunk-vvjyx7fe.js";
|
|
6
|
+
import"../../shared/chunk-dpsgb1xw.js";
|
|
6
7
|
import"../../shared/chunk-8y1jf6xr.js";
|
|
7
8
|
export {
|
|
8
9
|
Accordion
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
interface
|
|
1
|
+
interface ElementAttrs {
|
|
2
|
+
class?: string;
|
|
3
|
+
id?: string;
|
|
4
|
+
style?: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
role?: string;
|
|
7
|
+
tabindex?: number | string;
|
|
8
|
+
hidden?: boolean | string;
|
|
9
|
+
autofocus?: boolean;
|
|
10
|
+
[key: `data-${string}`]: string | undefined;
|
|
11
|
+
[key: `aria-${string}`]: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
interface BadgeOptions extends ElementAttrs {
|
|
2
14
|
variant?: "default" | "secondary" | "outline" | "destructive";
|
|
3
15
|
}
|
|
4
16
|
interface BadgeElements {
|
package/dist/src/badge/badge.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
interface ElementAttrs {
|
|
2
|
+
class?: string;
|
|
3
|
+
id?: string;
|
|
4
|
+
style?: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
role?: string;
|
|
7
|
+
tabindex?: number | string;
|
|
8
|
+
hidden?: boolean | string;
|
|
9
|
+
autofocus?: boolean;
|
|
10
|
+
[key: `data-${string}`]: string | undefined;
|
|
11
|
+
[key: `aria-${string}`]: string | undefined;
|
|
8
12
|
}
|
|
9
|
-
interface
|
|
10
|
-
disabled
|
|
11
|
-
|
|
13
|
+
interface ButtonOptions extends ElementAttrs {
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
onClick?: () => void;
|
|
12
16
|
}
|
|
13
17
|
declare const Button: {
|
|
14
|
-
Root(options?: ButtonOptions)
|
|
15
|
-
state: ButtonState;
|
|
16
|
-
};
|
|
18
|
+
Root: (options?: ButtonOptions) => HTMLButtonElement;
|
|
17
19
|
};
|
|
18
|
-
export {
|
|
20
|
+
export { ButtonOptions, Button };
|