@vertz/ui-primitives 0.2.21 → 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.
Files changed (97) hide show
  1. package/dist/shared/{chunk-q8dm19a5.js → chunk-2db2dnp3.js} +0 -1
  2. package/dist/shared/chunk-3h1mxp95.js +148 -0
  3. package/dist/shared/chunk-3kwh27dv.js +135 -0
  4. package/dist/shared/chunk-4894pmy6.js +184 -0
  5. package/dist/shared/{chunk-v9qddmh9.js → chunk-56reyd5r.js} +20 -29
  6. package/dist/shared/chunk-67sn29eh.js +125 -0
  7. package/dist/shared/chunk-7cb3z0s8.js +287 -0
  8. package/dist/shared/chunk-8c01c8mb.js +217 -0
  9. package/dist/shared/chunk-99tk72t3.js +69 -0
  10. package/dist/shared/chunk-9gfp3ffv.js +204 -0
  11. package/dist/shared/chunk-b25npqer.js +149 -0
  12. package/dist/shared/chunk-cgb2j94g.js +141 -0
  13. package/dist/shared/chunk-e1jcf22s.js +79 -0
  14. package/dist/shared/chunk-e3h0ddmx.js +168 -0
  15. package/dist/shared/chunk-f2vx4tpw.js +168 -0
  16. package/dist/shared/chunk-h3v10x04.js +271 -0
  17. package/dist/shared/chunk-hdvdfd1c.js +96 -0
  18. package/dist/shared/{chunk-zf0rhm9e.js → chunk-j902w020.js} +1 -1
  19. package/dist/shared/chunk-jdygp28a.js +260 -0
  20. package/dist/shared/chunk-jqre4qtw.js +180 -0
  21. package/dist/shared/{chunk-pvy0tcd7.js → chunk-mgr904ap.js} +75 -35
  22. package/dist/shared/chunk-mr1tb0dp.js +167 -0
  23. package/dist/shared/chunk-nj420k31.js +54 -0
  24. package/dist/shared/chunk-p0x7hgv6.js +181 -0
  25. package/dist/shared/{chunk-gzgyfhz6.js → chunk-pn6shbcs.js} +134 -82
  26. package/dist/shared/chunk-pzx0vpq1.js +223 -0
  27. package/dist/shared/chunk-tn0m98j8.js +42 -0
  28. package/dist/shared/{chunk-g67tnd19.js → chunk-ttb2tt03.js} +49 -29
  29. package/dist/shared/{chunk-vvjyx7fe.js → chunk-vevfhpc9.js} +1 -1
  30. package/dist/shared/chunk-vy874zxe.js +68 -0
  31. package/dist/shared/chunk-ww7k2azn.js +297 -0
  32. package/dist/shared/{chunk-f501vw7e.js → chunk-xa1b96mb.js} +2 -2
  33. package/dist/shared/chunk-xs6gp369.js +245 -0
  34. package/dist/shared/chunk-y4mmmayp.js +206 -0
  35. package/dist/src/accordion/accordion.js +1 -1
  36. package/dist/src/alert-dialog/alert-dialog.js +1 -1
  37. package/dist/src/badge/badge.js +1 -1
  38. package/dist/src/button/button.js +1 -1
  39. package/dist/src/calendar/calendar.js +1 -1
  40. package/dist/src/carousel/carousel.js +1 -1
  41. package/dist/src/checkbox/checkbox.js +1 -1
  42. package/dist/src/collapsible/collapsible.js +1 -1
  43. package/dist/src/combobox/combobox.js +1 -1
  44. package/dist/src/command/command.js +1 -1
  45. package/dist/src/context-menu/context-menu.js +1 -1
  46. package/dist/src/date-picker/date-picker.js +1 -1
  47. package/dist/src/dialog/dialog.js +1 -1
  48. package/dist/src/dropdown-menu/dropdown-menu.js +1 -1
  49. package/dist/src/hover-card/hover-card.js +1 -1
  50. package/dist/src/index.d.ts +281 -106
  51. package/dist/src/index.js +5779 -4266
  52. package/dist/src/menu/menu.js +1 -1
  53. package/dist/src/menubar/menubar.js +1 -1
  54. package/dist/src/navigation-menu/navigation-menu.js +1 -1
  55. package/dist/src/popover/popover.js +1 -1
  56. package/dist/src/progress/progress.js +1 -1
  57. package/dist/src/radio/radio.js +1 -1
  58. package/dist/src/resizable-panel/resizable-panel.js +1 -1
  59. package/dist/src/scroll-area/scroll-area.js +1 -1
  60. package/dist/src/select/select.js +1 -1
  61. package/dist/src/sheet/sheet.js +1 -1
  62. package/dist/src/slider/slider.js +1 -1
  63. package/dist/src/switch/switch.js +1 -1
  64. package/dist/src/tabs/tabs.js +1 -1
  65. package/dist/src/toast/toast.js +1 -1
  66. package/dist/src/toggle/toggle.js +1 -1
  67. package/dist/src/toggle-group/toggle-group.js +1 -1
  68. package/dist/src/tooltip/tooltip.js +1 -1
  69. package/dist/src/utils.d.ts +1 -1
  70. package/dist/src/utils.js +3 -3
  71. package/package.json +3 -3
  72. package/dist/shared/chunk-0gn67thm.js +0 -88
  73. package/dist/shared/chunk-1dzcjmfq.js +0 -46
  74. package/dist/shared/chunk-1hv9yd28.js +0 -178
  75. package/dist/shared/chunk-2d05qxdw.js +0 -282
  76. package/dist/shared/chunk-4jnweh3m.js +0 -165
  77. package/dist/shared/chunk-90hmpm0w.js +0 -34
  78. package/dist/shared/chunk-ac86qw7a.js +0 -71
  79. package/dist/shared/chunk-b02fkvts.js +0 -128
  80. package/dist/shared/chunk-bsx59bv9.js +0 -61
  81. package/dist/shared/chunk-cm2akzrm.js +0 -161
  82. package/dist/shared/chunk-cvms20w3.js +0 -132
  83. package/dist/shared/chunk-d8n8mggh.js +0 -239
  84. package/dist/shared/chunk-er9625ar.js +0 -204
  85. package/dist/shared/chunk-ewxzhtej.js +0 -117
  86. package/dist/shared/chunk-ey4485fh.js +0 -196
  87. package/dist/shared/chunk-gbxbkmte.js +0 -175
  88. package/dist/shared/chunk-je7tqf67.js +0 -133
  89. package/dist/shared/chunk-kr5qg80z.js +0 -288
  90. package/dist/shared/chunk-kytkmdpc.js +0 -199
  91. package/dist/shared/chunk-q2q20y9a.js +0 -60
  92. package/dist/shared/chunk-q9fgfgh9.js +0 -267
  93. package/dist/shared/chunk-qfk1ycfw.js +0 -142
  94. package/dist/shared/chunk-te4pdqnh.js +0 -219
  95. package/dist/shared/chunk-vm37m55w.js +0 -175
  96. package/dist/shared/chunk-y5vdb6br.js +0 -151
  97. package/dist/shared/chunk-ztvj60xp.js +0 -185
@@ -1,133 +0,0 @@
1
- import {
2
- Keys,
3
- isKey
4
- } from "./chunk-7867pr13.js";
5
- import {
6
- setDataState
7
- } from "./chunk-vvjyx7fe.js";
8
- import {
9
- applyAttrs
10
- } from "./chunk-q8dm19a5.js";
11
-
12
- // src/carousel/carousel.tsx
13
- import { __element, __enterChildren, __exitChildren, __insert, __on } from "@vertz/ui/internals";
14
- import { signal } from "@vertz/ui";
15
- function CarouselRoot(options = {}) {
16
- const {
17
- orientation = "horizontal",
18
- loop = false,
19
- defaultIndex = 0,
20
- onSlideChange,
21
- ...attrs
22
- } = options;
23
- const state = {
24
- currentIndex: signal(defaultIndex),
25
- slideCount: signal(0)
26
- };
27
- const slides = [];
28
- function updateSlideVisibility() {
29
- const current = state.currentIndex.peek();
30
- for (let i = 0;i < slides.length; i++) {
31
- const slide = slides[i];
32
- if (!slide)
33
- continue;
34
- slide.setAttribute("aria-hidden", String(i !== current));
35
- slide.setAttribute("aria-label", `Slide ${i + 1} of ${slides.length}`);
36
- setDataState(slide, i === current ? "active" : "inactive");
37
- }
38
- if (!loop) {
39
- prevButton.disabled = current <= 0;
40
- nextButton.disabled = current >= slides.length - 1;
41
- }
42
- const translateProp = orientation === "horizontal" ? "translateX" : "translateY";
43
- viewport.style.transform = `${translateProp}(-${current * 100}%)`;
44
- }
45
- function goTo(index) {
46
- const total = slides.length;
47
- if (total === 0)
48
- return;
49
- let next = index;
50
- if (loop) {
51
- next = (index % total + total) % total;
52
- } else {
53
- next = Math.max(0, Math.min(total - 1, index));
54
- }
55
- if (next === state.currentIndex.peek())
56
- return;
57
- state.currentIndex.value = next;
58
- updateSlideVisibility();
59
- onSlideChange?.(next);
60
- }
61
- function goNext() {
62
- goTo(state.currentIndex.peek() + 1);
63
- }
64
- function goPrev() {
65
- goTo(state.currentIndex.peek() - 1);
66
- }
67
- const viewport = (() => {
68
- const __el0 = __element("div");
69
- __el0.setAttribute("style", "overflow: hidden;");
70
- return __el0;
71
- })();
72
- const prevButton = (() => {
73
- const __el1 = __element("button");
74
- __el1.setAttribute("type", "button");
75
- __el1.setAttribute("aria-label", "Previous slide");
76
- __on(__el1, "click", goPrev);
77
- return __el1;
78
- })();
79
- const nextButton = (() => {
80
- const __el2 = __element("button");
81
- __el2.setAttribute("type", "button");
82
- __el2.setAttribute("aria-label", "Next slide");
83
- __on(__el2, "click", goNext);
84
- return __el2;
85
- })();
86
- const root = (() => {
87
- const __el3 = __element("div");
88
- __el3.setAttribute("role", "region");
89
- __el3.setAttribute("aria-roledescription", "carousel");
90
- {
91
- const __v = orientation;
92
- if (__v != null && __v !== false)
93
- __el3.setAttribute("data-orientation", __v === true ? "" : __v);
94
- }
95
- __on(__el3, "keydown", (event) => {
96
- const prevKey = orientation === "horizontal" ? Keys.ArrowLeft : Keys.ArrowUp;
97
- const nextKey = orientation === "horizontal" ? Keys.ArrowRight : Keys.ArrowDown;
98
- if (isKey(event, prevKey)) {
99
- event.preventDefault();
100
- goPrev();
101
- }
102
- if (isKey(event, nextKey)) {
103
- event.preventDefault();
104
- goNext();
105
- }
106
- });
107
- __enterChildren(__el3);
108
- __insert(__el3, viewport);
109
- __exitChildren();
110
- return __el3;
111
- })();
112
- function Slide() {
113
- const slide = (() => {
114
- const __el4 = __element("div");
115
- __el4.setAttribute("role", "group");
116
- __el4.setAttribute("aria-roledescription", "slide");
117
- return __el4;
118
- })();
119
- slides.push(slide);
120
- state.slideCount.value = slides.length;
121
- viewport.appendChild(slide);
122
- updateSlideVisibility();
123
- return slide;
124
- }
125
- updateSlideVisibility();
126
- applyAttrs(root, attrs);
127
- return { root, viewport, prevButton, nextButton, state, Slide, goTo, goNext, goPrev };
128
- }
129
- var Carousel = {
130
- Root: CarouselRoot
131
- };
132
-
133
- export { Carousel };
@@ -1,288 +0,0 @@
1
- import {
2
- createDismiss
3
- } from "./chunk-a6wp8c32.js";
4
- import {
5
- setRovingTabindex
6
- } from "./chunk-e2v1c9ex.js";
7
- import {
8
- createFloatingPosition
9
- } from "./chunk-0mcr52hc.js";
10
- import {
11
- Keys,
12
- handleListNavigation,
13
- isKey
14
- } from "./chunk-7867pr13.js";
15
- import {
16
- setDataState,
17
- setExpanded,
18
- setHidden,
19
- setHiddenAnimated
20
- } from "./chunk-vvjyx7fe.js";
21
- import {
22
- linkedIds
23
- } from "./chunk-8y1jf6xr.js";
24
- import {
25
- applyAttrs
26
- } from "./chunk-q8dm19a5.js";
27
-
28
- // src/menubar/menubar.tsx
29
- import { __element, __enterChildren, __exitChildren, __insert, __on } from "@vertz/ui/internals";
30
- import { signal } from "@vertz/ui";
31
- function MenubarRoot(options = {}) {
32
- const { onSelect, positioning, ...attrs } = options;
33
- const state = { activeMenu: signal(null) };
34
- const triggers = [];
35
- const menus = new Map;
36
- let floatingCleanup = null;
37
- let dismissCleanup = null;
38
- function handleClickOutside(event) {
39
- const target = event.target;
40
- if (!root.contains(target)) {
41
- closeAll();
42
- }
43
- }
44
- function closeAll() {
45
- for (const [, menu] of menus) {
46
- setExpanded(menu.trigger, false);
47
- setDataState(menu.trigger, "closed");
48
- setDataState(menu.content, "closed");
49
- setHiddenAnimated(menu.content, true);
50
- }
51
- state.activeMenu.value = null;
52
- if (positioning) {
53
- floatingCleanup?.();
54
- floatingCleanup = null;
55
- dismissCleanup?.();
56
- dismissCleanup = null;
57
- } else {
58
- document.removeEventListener("mousedown", handleClickOutside);
59
- }
60
- }
61
- function openMenu(value) {
62
- const current = state.activeMenu.peek();
63
- if (current && current !== value) {
64
- const prev = menus.get(current);
65
- if (prev) {
66
- setExpanded(prev.trigger, false);
67
- setDataState(prev.trigger, "closed");
68
- setDataState(prev.content, "closed");
69
- setHiddenAnimated(prev.content, true);
70
- }
71
- if (positioning) {
72
- floatingCleanup?.();
73
- floatingCleanup = null;
74
- }
75
- }
76
- const menu = menus.get(value);
77
- if (!menu)
78
- return;
79
- state.activeMenu.value = value;
80
- setExpanded(menu.trigger, true);
81
- setHidden(menu.content, false);
82
- setDataState(menu.trigger, "open");
83
- setDataState(menu.content, "open");
84
- if (positioning) {
85
- const result = createFloatingPosition(menu.trigger, menu.content, positioning);
86
- floatingCleanup = result.cleanup;
87
- if (!dismissCleanup) {
88
- dismissCleanup = createDismiss({
89
- onDismiss: closeAll,
90
- insideElements: [root],
91
- escapeKey: false
92
- });
93
- }
94
- } else {
95
- document.addEventListener("mousedown", handleClickOutside);
96
- }
97
- const firstItem = menu.items[0];
98
- if (firstItem) {
99
- firstItem.setAttribute("tabindex", "0");
100
- firstItem.focus();
101
- }
102
- }
103
- const root = (() => {
104
- const __el0 = __element("div");
105
- __el0.setAttribute("role", "menubar");
106
- __on(__el0, "keydown", (event) => {
107
- if (isKey(event, Keys.ArrowLeft, Keys.ArrowRight, Keys.Home, Keys.End)) {
108
- const focused = document.activeElement;
109
- const triggerIndex = triggers.indexOf(focused);
110
- if (triggerIndex >= 0) {
111
- const result = handleListNavigation(event, triggers, { orientation: "horizontal" });
112
- if (result && state.activeMenu.peek()) {
113
- const newTrigger = result;
114
- const menuValue = newTrigger.getAttribute("data-value");
115
- if (menuValue)
116
- openMenu(menuValue);
117
- }
118
- }
119
- }
120
- });
121
- return __el0;
122
- })();
123
- function Menu(value, label) {
124
- const ids = linkedIds("menubar-menu");
125
- const menuItems = [];
126
- const trigger = (() => {
127
- const __el1 = __element("button");
128
- __el1.setAttribute("type", "button");
129
- __el1.setAttribute("role", "menuitem");
130
- {
131
- const __v = ids.triggerId;
132
- if (__v != null && __v !== false)
133
- __el1.setAttribute("id", __v === true ? "" : __v);
134
- }
135
- {
136
- const __v = ids.contentId;
137
- if (__v != null && __v !== false)
138
- __el1.setAttribute("aria-controls", __v === true ? "" : __v);
139
- }
140
- __el1.setAttribute("aria-haspopup", "menu");
141
- {
142
- const __v = value;
143
- if (__v != null && __v !== false)
144
- __el1.setAttribute("data-value", __v === true ? "" : __v);
145
- }
146
- __el1.setAttribute("aria-expanded", "false");
147
- __el1.setAttribute("data-state", "closed");
148
- __on(__el1, "click", () => {
149
- if (state.activeMenu.peek() === value) {
150
- closeAll();
151
- } else {
152
- openMenu(value);
153
- }
154
- });
155
- __on(__el1, "keydown", (event) => {
156
- if (isKey(event, Keys.ArrowDown, Keys.Enter, Keys.Space)) {
157
- event.preventDefault();
158
- openMenu(value);
159
- }
160
- });
161
- __enterChildren(__el1);
162
- __insert(__el1, label ?? value);
163
- __exitChildren();
164
- return __el1;
165
- })();
166
- setRovingTabindex(triggers.concat(trigger), triggers.length);
167
- const content = (() => {
168
- const __el2 = __element("div");
169
- __el2.setAttribute("role", "menu");
170
- {
171
- const __v = ids.contentId;
172
- if (__v != null && __v !== false)
173
- __el2.setAttribute("id", __v === true ? "" : __v);
174
- }
175
- __el2.setAttribute("aria-hidden", "true");
176
- __el2.setAttribute("data-state", "closed");
177
- __el2.setAttribute("style", "display: none");
178
- __on(__el2, "keydown", (event) => {
179
- if (isKey(event, Keys.Escape)) {
180
- event.preventDefault();
181
- event.stopPropagation();
182
- closeAll();
183
- trigger.focus();
184
- return;
185
- }
186
- if (isKey(event, Keys.Enter, Keys.Space)) {
187
- event.preventDefault();
188
- const active = document.activeElement;
189
- const activeItem = menuItems.find((item) => item === active);
190
- if (activeItem) {
191
- const val = activeItem.getAttribute("data-value");
192
- if (val !== null) {
193
- onSelect?.(val);
194
- closeAll();
195
- trigger.focus();
196
- }
197
- }
198
- return;
199
- }
200
- if (isKey(event, Keys.ArrowLeft, Keys.ArrowRight)) {
201
- event.preventDefault();
202
- const triggerIdx = triggers.indexOf(trigger);
203
- let nextIdx;
204
- if (isKey(event, Keys.ArrowRight)) {
205
- nextIdx = (triggerIdx + 1) % triggers.length;
206
- } else {
207
- nextIdx = (triggerIdx - 1 + triggers.length) % triggers.length;
208
- }
209
- const nextTrigger = triggers[nextIdx];
210
- if (nextTrigger) {
211
- nextTrigger.focus();
212
- const nextValue = nextTrigger.getAttribute("data-value");
213
- if (nextValue)
214
- openMenu(nextValue);
215
- }
216
- return;
217
- }
218
- handleListNavigation(event, menuItems, { orientation: "vertical" });
219
- });
220
- return __el2;
221
- })();
222
- function createItem(val, itemLabel, parent) {
223
- const item = (() => {
224
- const __el3 = __element("div");
225
- __el3.setAttribute("role", "menuitem");
226
- {
227
- const __v = val;
228
- if (__v != null && __v !== false)
229
- __el3.setAttribute("data-value", __v === true ? "" : __v);
230
- }
231
- __el3.setAttribute("tabindex", "-1");
232
- __on(__el3, "click", () => {
233
- onSelect?.(val);
234
- closeAll();
235
- trigger.focus();
236
- });
237
- __enterChildren(__el3);
238
- __insert(__el3, itemLabel ?? val);
239
- __exitChildren();
240
- return __el3;
241
- })();
242
- menuItems.push(item);
243
- (parent ?? content).appendChild(item);
244
- return item;
245
- }
246
- function Item(val, itemLabel) {
247
- return createItem(val, itemLabel);
248
- }
249
- function Group(groupLabel) {
250
- const el = (() => {
251
- const __el4 = __element("div");
252
- __el4.setAttribute("role", "group");
253
- {
254
- const __v = groupLabel;
255
- if (__v != null && __v !== false)
256
- __el4.setAttribute("aria-label", __v === true ? "" : __v);
257
- }
258
- return __el4;
259
- })();
260
- content.appendChild(el);
261
- return {
262
- el,
263
- Item: (val, l) => createItem(val, l, el)
264
- };
265
- }
266
- function Separator() {
267
- const hr = (() => {
268
- const __el5 = __element("hr");
269
- __el5.setAttribute("role", "separator");
270
- return __el5;
271
- })();
272
- content.appendChild(hr);
273
- return hr;
274
- }
275
- triggers.push(trigger);
276
- setRovingTabindex(triggers, 0);
277
- menus.set(value, { trigger, content, items: menuItems });
278
- root.appendChild(trigger);
279
- return { trigger, content, Item, Group, Separator };
280
- }
281
- applyAttrs(root, attrs);
282
- return { root, state, Menu };
283
- }
284
- var Menubar = {
285
- Root: MenubarRoot
286
- };
287
-
288
- export { Menubar };
@@ -1,199 +0,0 @@
1
- import {
2
- focusFirst,
3
- saveFocus,
4
- trapFocus
5
- } from "./chunk-e2v1c9ex.js";
6
- import {
7
- Keys,
8
- isKey
9
- } from "./chunk-7867pr13.js";
10
- import {
11
- setDataState,
12
- setDescribedBy,
13
- setExpanded,
14
- setHidden,
15
- setHiddenAnimated,
16
- setLabelledBy
17
- } from "./chunk-vvjyx7fe.js";
18
- import {
19
- linkedIds
20
- } from "./chunk-8y1jf6xr.js";
21
- import {
22
- applyAttrs
23
- } from "./chunk-q8dm19a5.js";
24
-
25
- // src/dialog/dialog.tsx
26
- import { __element, __on, __styleStr } from "@vertz/ui/internals";
27
- import { signal } from "@vertz/ui";
28
- function DialogRoot(options = {}) {
29
- const { modal = true, defaultOpen = false, onOpenChange, ...attrs } = options;
30
- const ids = linkedIds("dialog");
31
- const titleId = `${ids.contentId}-title`;
32
- const descriptionId = `${ids.contentId}-description`;
33
- const state = { open: signal(defaultOpen) };
34
- let restoreFocus = null;
35
- let removeTrap = null;
36
- function openDialog() {
37
- state.open.value = true;
38
- setExpanded(trigger, true);
39
- setHidden(overlay, false);
40
- setHidden(content, false);
41
- setDataState(trigger, "open");
42
- setDataState(overlay, "open");
43
- setDataState(content, "open");
44
- restoreFocus = saveFocus();
45
- if (modal) {
46
- removeTrap = trapFocus(content);
47
- }
48
- queueMicrotask(() => focusFirst(content));
49
- onOpenChange?.(true);
50
- }
51
- function closeDialog() {
52
- state.open.value = false;
53
- setExpanded(trigger, false);
54
- setDataState(trigger, "closed");
55
- setDataState(overlay, "closed");
56
- setDataState(content, "closed");
57
- setHiddenAnimated(overlay, true);
58
- setHiddenAnimated(content, true);
59
- removeTrap?.();
60
- removeTrap = null;
61
- restoreFocus?.();
62
- restoreFocus = null;
63
- onOpenChange?.(false);
64
- }
65
- const trigger = (() => {
66
- const __el0 = __element("button");
67
- __el0.setAttribute("type", "button");
68
- {
69
- const __v = ids.triggerId;
70
- if (__v != null && __v !== false)
71
- __el0.setAttribute("id", __v === true ? "" : __v);
72
- }
73
- {
74
- const __v = ids.contentId;
75
- if (__v != null && __v !== false)
76
- __el0.setAttribute("aria-controls", __v === true ? "" : __v);
77
- }
78
- {
79
- const __v = defaultOpen ? "true" : "false";
80
- if (__v != null && __v !== false)
81
- __el0.setAttribute("aria-expanded", __v === true ? "" : __v);
82
- }
83
- {
84
- const __v = defaultOpen ? "open" : "closed";
85
- if (__v != null && __v !== false)
86
- __el0.setAttribute("data-state", __v === true ? "" : __v);
87
- }
88
- __on(__el0, "click", () => {
89
- if (state.open.peek()) {
90
- closeDialog();
91
- } else {
92
- openDialog();
93
- }
94
- });
95
- return __el0;
96
- })();
97
- const overlay = (() => {
98
- const __el1 = __element("div");
99
- __el1.setAttribute("data-dialog-overlay", "");
100
- {
101
- const __v = defaultOpen ? "false" : "true";
102
- if (__v != null && __v !== false)
103
- __el1.setAttribute("aria-hidden", __v === true ? "" : __v);
104
- }
105
- {
106
- const __v = defaultOpen ? "open" : "closed";
107
- if (__v != null && __v !== false)
108
- __el1.setAttribute("data-state", __v === true ? "" : __v);
109
- }
110
- {
111
- const __v = defaultOpen ? "" : "display: none";
112
- if (__v != null && __v !== false)
113
- __el1.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
114
- }
115
- __on(__el1, "click", () => closeDialog());
116
- return __el1;
117
- })();
118
- const content = (() => {
119
- const __el2 = __element("div");
120
- __el2.setAttribute("role", "dialog");
121
- {
122
- const __v = ids.contentId;
123
- if (__v != null && __v !== false)
124
- __el2.setAttribute("id", __v === true ? "" : __v);
125
- }
126
- {
127
- const __v = modal ? "true" : undefined;
128
- if (__v != null && __v !== false)
129
- __el2.setAttribute("aria-modal", __v === true ? "" : __v);
130
- }
131
- {
132
- const __v = defaultOpen ? "false" : "true";
133
- if (__v != null && __v !== false)
134
- __el2.setAttribute("aria-hidden", __v === true ? "" : __v);
135
- }
136
- {
137
- const __v = defaultOpen ? "open" : "closed";
138
- if (__v != null && __v !== false)
139
- __el2.setAttribute("data-state", __v === true ? "" : __v);
140
- }
141
- {
142
- const __v = defaultOpen ? "" : "display: none";
143
- if (__v != null && __v !== false)
144
- __el2.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
145
- }
146
- __on(__el2, "keydown", (event) => {
147
- if (isKey(event, Keys.Escape)) {
148
- event.preventDefault();
149
- event.stopPropagation();
150
- closeDialog();
151
- }
152
- });
153
- return __el2;
154
- })();
155
- setLabelledBy(content, titleId);
156
- setDescribedBy(content, descriptionId);
157
- const title = (() => {
158
- const __el3 = __element("h2");
159
- {
160
- const __v = titleId;
161
- if (__v != null && __v !== false)
162
- __el3.setAttribute("id", __v === true ? "" : __v);
163
- }
164
- return __el3;
165
- })();
166
- const description = (() => {
167
- const __el4 = __element("p");
168
- {
169
- const __v = descriptionId;
170
- if (__v != null && __v !== false)
171
- __el4.setAttribute("id", __v === true ? "" : __v);
172
- }
173
- return __el4;
174
- })();
175
- const close = (() => {
176
- const __el5 = __element("button");
177
- __el5.setAttribute("type", "button");
178
- __el5.setAttribute("aria-label", "Close");
179
- __on(__el5, "click", () => closeDialog());
180
- return __el5;
181
- })();
182
- applyAttrs(content, attrs);
183
- return {
184
- trigger,
185
- overlay,
186
- content,
187
- title,
188
- description,
189
- close,
190
- state,
191
- show: openDialog,
192
- hide: closeDialog
193
- };
194
- }
195
- var Dialog = {
196
- Root: DialogRoot
197
- };
198
-
199
- export { Dialog };
@@ -1,60 +0,0 @@
1
- import {
2
- Keys,
3
- isKey
4
- } from "./chunk-7867pr13.js";
5
- import {
6
- uniqueId
7
- } from "./chunk-8y1jf6xr.js";
8
- import {
9
- applyAttrs
10
- } from "./chunk-q8dm19a5.js";
11
-
12
- // src/toggle/toggle.tsx
13
- import { computed, signal } from "@vertz/ui";
14
- import { __attr, __element, __on } from "@vertz/ui/internals";
15
- function ToggleRoot(options = {}) {
16
- const { defaultPressed = false, disabled = false, onPressedChange, ...attrs } = options;
17
- const pressed = signal(defaultPressed, "pressed");
18
- function toggle() {
19
- if (disabled)
20
- return;
21
- pressed.value = !pressed.value;
22
- onPressedChange?.(pressed.value);
23
- }
24
- const el = computed(() => (() => {
25
- const __el0 = __element("button");
26
- __el0.setAttribute("type", "button");
27
- {
28
- const __v = uniqueId("toggle");
29
- if (__v != null && __v !== false)
30
- __el0.setAttribute("id", __v === true ? "" : __v);
31
- }
32
- __attr(__el0, "aria-pressed", () => pressed.value ? "true" : "false");
33
- __attr(__el0, "data-state", () => pressed.value ? "on" : "off");
34
- {
35
- const __v = disabled;
36
- if (__v != null && __v !== false)
37
- __el0.setAttribute("disabled", __v === true ? "" : __v);
38
- }
39
- {
40
- const __v = disabled ? "true" : undefined;
41
- if (__v != null && __v !== false)
42
- __el0.setAttribute("aria-disabled", __v === true ? "" : __v);
43
- }
44
- __on(__el0, "click", toggle);
45
- __on(__el0, "keydown", (e) => {
46
- if (isKey(e, Keys.Space)) {
47
- e.preventDefault();
48
- toggle();
49
- }
50
- });
51
- return __el0;
52
- })());
53
- applyAttrs(el.value, attrs);
54
- return el.value;
55
- }
56
- var Toggle = {
57
- Root: ToggleRoot
58
- };
59
-
60
- export { Toggle };