@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
@@ -0,0 +1,168 @@
1
+ import {
2
+ Keys,
3
+ isKey
4
+ } from "./chunk-7867pr13.js";
5
+ import {
6
+ setDataState,
7
+ setValueRange
8
+ } from "./chunk-vevfhpc9.js";
9
+ import {
10
+ uniqueId
11
+ } from "./chunk-8y1jf6xr.js";
12
+ import {
13
+ applyAttrs
14
+ } from "./chunk-2db2dnp3.js";
15
+
16
+ // src/slider/slider.tsx
17
+ import { __discardMountFrame, __element, __enterChildren, __exitChildren, __flushMountFrame, __insert, __on, __pushMountFrame, __styleStr } from "@vertz/ui/internals";
18
+ import { signal } from "@vertz/ui";
19
+ function SliderRoot(options = {}) {
20
+ const __mfDepth = __pushMountFrame();
21
+ try {
22
+ let clamp = function(val) {
23
+ return Math.min(max, Math.max(min, val));
24
+ }, updatePosition = function(pct2) {
25
+ thumb.style.left = `${pct2}%`;
26
+ fill.style.width = `${pct2}%`;
27
+ }, setValue = function(val) {
28
+ if (state.disabled.peek())
29
+ return;
30
+ const clamped = clamp(val);
31
+ state.value.value = clamped;
32
+ setValueRange(thumb, clamped, min, max);
33
+ const pct2 = (clamped - min) / (max - min) * 100;
34
+ updatePosition(pct2);
35
+ setDataState(root, "active");
36
+ onValueChange?.(clamped);
37
+ }, valueFromPointer = function(event) {
38
+ const rect = track.getBoundingClientRect();
39
+ const pct2 = Math.max(0, Math.min(1, (event.clientX - rect.left) / rect.width));
40
+ const raw = min + pct2 * (max - min);
41
+ return Math.round(raw / step) * step;
42
+ };
43
+ const {
44
+ defaultValue = 0,
45
+ min = 0,
46
+ max = 100,
47
+ step = 1,
48
+ disabled = false,
49
+ onValueChange,
50
+ ...attrs
51
+ } = options;
52
+ const state = {
53
+ value: signal(defaultValue),
54
+ disabled: signal(disabled)
55
+ };
56
+ const fill = (() => {
57
+ const __el0 = __element("div");
58
+ __el0.setAttribute("data-part", "fill");
59
+ {
60
+ const __v = { position: "absolute", height: "100%", borderRadius: "inherit" };
61
+ if (__v != null && __v !== false)
62
+ __el0.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
63
+ }
64
+ return __el0;
65
+ })();
66
+ const thumb = (() => {
67
+ const __el1 = __element("div");
68
+ __el1.setAttribute("role", "slider");
69
+ {
70
+ const __v = disabled ? "-1" : "0";
71
+ if (__v != null && __v !== false)
72
+ __el1.setAttribute("tabindex", __v === true ? "" : __v);
73
+ }
74
+ __el1.setAttribute("data-part", "thumb");
75
+ {
76
+ const __v = disabled ? "true" : undefined;
77
+ if (__v != null && __v !== false)
78
+ __el1.setAttribute("aria-disabled", __v === true ? "" : __v);
79
+ }
80
+ {
81
+ const __v = { position: "absolute", transform: "translate(-50%, -50%)" };
82
+ if (__v != null && __v !== false)
83
+ __el1.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
84
+ }
85
+ __on(__el1, "keydown", (event) => {
86
+ if (state.disabled.peek())
87
+ return;
88
+ const current = state.value.peek();
89
+ if (isKey(event, Keys.ArrowRight, Keys.ArrowUp)) {
90
+ event.preventDefault();
91
+ setValue(current + step);
92
+ } else if (isKey(event, Keys.ArrowLeft, Keys.ArrowDown)) {
93
+ event.preventDefault();
94
+ setValue(current - step);
95
+ } else if (isKey(event, Keys.Home)) {
96
+ event.preventDefault();
97
+ setValue(min);
98
+ } else if (isKey(event, Keys.End)) {
99
+ event.preventDefault();
100
+ setValue(max);
101
+ }
102
+ });
103
+ return __el1;
104
+ })();
105
+ setValueRange(thumb, defaultValue, min, max);
106
+ const track = (() => {
107
+ const __el2 = __element("div");
108
+ __el2.setAttribute("data-part", "track");
109
+ {
110
+ const __v = { position: "relative" };
111
+ if (__v != null && __v !== false)
112
+ __el2.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
113
+ }
114
+ __enterChildren(__el2);
115
+ __insert(__el2, fill);
116
+ __insert(__el2, thumb);
117
+ __exitChildren();
118
+ return __el2;
119
+ })();
120
+ const root = (() => {
121
+ const __el3 = __element("div");
122
+ {
123
+ const __v = uniqueId("slider");
124
+ if (__v != null && __v !== false)
125
+ __el3.setAttribute("id", __v === true ? "" : __v);
126
+ }
127
+ {
128
+ const __v = disabled ? "disabled" : "active";
129
+ if (__v != null && __v !== false)
130
+ __el3.setAttribute("data-state", __v === true ? "" : __v);
131
+ }
132
+ __on(__el3, "pointerdown", (event) => {
133
+ if (state.disabled.peek())
134
+ return;
135
+ event.preventDefault();
136
+ setValue(valueFromPointer(event));
137
+ thumb.focus();
138
+ function onMove(e) {
139
+ setValue(valueFromPointer(e));
140
+ }
141
+ function onUp() {
142
+ document.removeEventListener("pointermove", onMove);
143
+ document.removeEventListener("pointerup", onUp);
144
+ }
145
+ document.addEventListener("pointermove", onMove);
146
+ document.addEventListener("pointerup", onUp);
147
+ });
148
+ __enterChildren(__el3);
149
+ __insert(__el3, track);
150
+ __exitChildren();
151
+ return __el3;
152
+ })();
153
+ const pct = (defaultValue - min) / (max - min) * 100;
154
+ updatePosition(pct);
155
+ applyAttrs(root, attrs);
156
+ const __mfResult0 = { root, thumb, track, state };
157
+ __flushMountFrame();
158
+ return __mfResult0;
159
+ } catch (__mfErr) {
160
+ __discardMountFrame(__mfDepth);
161
+ throw __mfErr;
162
+ }
163
+ }
164
+ var Slider = {
165
+ Root: SliderRoot
166
+ };
167
+
168
+ export { Slider };
@@ -0,0 +1,168 @@
1
+ import {
2
+ applyAttrs
3
+ } from "./chunk-2db2dnp3.js";
4
+
5
+ // src/scroll-area/scroll-area.tsx
6
+ import { __discardMountFrame, __element, __enterChildren, __exitChildren, __flushMountFrame, __insert, __on, __pushMountFrame, __styleStr } from "@vertz/ui/internals";
7
+ import { signal } from "@vertz/ui";
8
+ function ScrollAreaRoot(options = {}) {
9
+ const __mfDepth = __pushMountFrame();
10
+ try {
11
+ let syncThumbY = function() {
12
+ const { scrollTop, scrollHeight, clientHeight } = viewport;
13
+ if (scrollHeight <= clientHeight) {
14
+ thumbY.style.height = "0";
15
+ return;
16
+ }
17
+ const ratio = clientHeight / scrollHeight;
18
+ thumbY.style.height = `${ratio * 100}%`;
19
+ const scrollRatio = scrollTop / (scrollHeight - clientHeight);
20
+ thumbY.style.transform = `translateY(${scrollRatio * (1 / ratio - 1) * 100}%)`;
21
+ state.scrollTop.value = scrollTop;
22
+ }, syncThumbX = function() {
23
+ const { scrollLeft, scrollWidth, clientWidth } = viewport;
24
+ if (scrollWidth <= clientWidth) {
25
+ thumbX.style.width = "0";
26
+ return;
27
+ }
28
+ const ratio = clientWidth / scrollWidth;
29
+ thumbX.style.width = `${ratio * 100}%`;
30
+ const scrollRatio = scrollLeft / (scrollWidth - clientWidth);
31
+ thumbX.style.transform = `translateX(${scrollRatio * (1 / ratio - 1) * 100}%)`;
32
+ state.scrollLeft.value = scrollLeft;
33
+ }, update = function() {
34
+ syncThumbY();
35
+ syncThumbX();
36
+ }, handleViewportScroll = function() {
37
+ if (orientation === "vertical" || orientation === "both")
38
+ syncThumbY();
39
+ if (orientation === "horizontal" || orientation === "both")
40
+ syncThumbX();
41
+ }, handleThumbYDown = function(e) {
42
+ isDraggingY = true;
43
+ startY = e.clientY;
44
+ startScrollTop = viewport.scrollTop;
45
+ thumbY.setPointerCapture(e.pointerId);
46
+ e.preventDefault();
47
+ }, handleThumbYMove = function(e) {
48
+ if (!isDraggingY)
49
+ return;
50
+ const delta = e.clientY - startY;
51
+ const scrollbarHeight = scrollbarY.clientHeight;
52
+ const scrollRange = viewport.scrollHeight - viewport.clientHeight;
53
+ if (scrollbarHeight > 0) {
54
+ viewport.scrollTop = startScrollTop + delta / scrollbarHeight * scrollRange;
55
+ }
56
+ }, handleThumbYUp = function(e) {
57
+ isDraggingY = false;
58
+ thumbY.releasePointerCapture(e.pointerId);
59
+ }, handleThumbXDown = function(e) {
60
+ isDraggingX = true;
61
+ startX = e.clientX;
62
+ startScrollLeft = viewport.scrollLeft;
63
+ thumbX.setPointerCapture(e.pointerId);
64
+ e.preventDefault();
65
+ }, handleThumbXMove = function(e) {
66
+ if (!isDraggingX)
67
+ return;
68
+ const delta = e.clientX - startX;
69
+ const scrollbarWidth = scrollbarX.clientWidth;
70
+ const scrollRange = viewport.scrollWidth - viewport.clientWidth;
71
+ if (scrollbarWidth > 0) {
72
+ viewport.scrollLeft = startScrollLeft + delta / scrollbarWidth * scrollRange;
73
+ }
74
+ }, handleThumbXUp = function(e) {
75
+ isDraggingX = false;
76
+ thumbX.releasePointerCapture(e.pointerId);
77
+ };
78
+ const { orientation = "vertical", type: _type, ...attrs } = options;
79
+ const state = {
80
+ scrollTop: signal(0),
81
+ scrollLeft: signal(0)
82
+ };
83
+ let isDraggingY = false;
84
+ let startY = 0;
85
+ let startScrollTop = 0;
86
+ let isDraggingX = false;
87
+ let startX = 0;
88
+ let startScrollLeft = 0;
89
+ const thumbY = (() => {
90
+ const __el0 = __element("div");
91
+ __on(__el0, "pointerdown", handleThumbYDown);
92
+ __on(__el0, "pointermove", handleThumbYMove);
93
+ __on(__el0, "pointerup", handleThumbYUp);
94
+ return __el0;
95
+ })();
96
+ const scrollbarY = (() => {
97
+ const __el1 = __element("div");
98
+ __el1.setAttribute("aria-hidden", "true");
99
+ __el1.setAttribute("data-orientation", "vertical");
100
+ __enterChildren(__el1);
101
+ __insert(__el1, thumbY);
102
+ __exitChildren();
103
+ return __el1;
104
+ })();
105
+ const thumbX = (() => {
106
+ const __el2 = __element("div");
107
+ __on(__el2, "pointerdown", handleThumbXDown);
108
+ __on(__el2, "pointermove", handleThumbXMove);
109
+ __on(__el2, "pointerup", handleThumbXUp);
110
+ return __el2;
111
+ })();
112
+ const scrollbarX = (() => {
113
+ const __el3 = __element("div");
114
+ __el3.setAttribute("aria-hidden", "true");
115
+ __el3.setAttribute("data-orientation", "horizontal");
116
+ __enterChildren(__el3);
117
+ __insert(__el3, thumbX);
118
+ __exitChildren();
119
+ return __el3;
120
+ })();
121
+ const content = (() => {
122
+ const __el4 = __element("div");
123
+ return __el4;
124
+ })();
125
+ const viewport = (() => {
126
+ const __el5 = __element("div");
127
+ {
128
+ const __v = { overflow: "scroll" };
129
+ if (__v != null && __v !== false)
130
+ __el5.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
131
+ }
132
+ __on(__el5, "scroll", handleViewportScroll);
133
+ __enterChildren(__el5);
134
+ __insert(__el5, content);
135
+ __exitChildren();
136
+ return __el5;
137
+ })();
138
+ viewport.style.scrollbarWidth = "none";
139
+ const root = (() => {
140
+ const __el6 = __element("div");
141
+ {
142
+ const __v = { position: "relative", overflow: "hidden" };
143
+ if (__v != null && __v !== false)
144
+ __el6.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
145
+ }
146
+ __enterChildren(__el6);
147
+ __insert(__el6, viewport);
148
+ __exitChildren();
149
+ return __el6;
150
+ })();
151
+ if (orientation === "vertical" || orientation === "both")
152
+ root.appendChild(scrollbarY);
153
+ if (orientation === "horizontal" || orientation === "both")
154
+ root.appendChild(scrollbarX);
155
+ applyAttrs(root, attrs);
156
+ const __mfResult0 = { root, viewport, content, scrollbarY, thumbY, scrollbarX, thumbX, state, update };
157
+ __flushMountFrame();
158
+ return __mfResult0;
159
+ } catch (__mfErr) {
160
+ __discardMountFrame(__mfDepth);
161
+ throw __mfErr;
162
+ }
163
+ }
164
+ var ScrollArea = {
165
+ Root: ScrollAreaRoot
166
+ };
167
+
168
+ export { ScrollArea };
@@ -0,0 +1,271 @@
1
+ import {
2
+ createDismiss
3
+ } from "./chunk-a6wp8c32.js";
4
+ import {
5
+ createFloatingPosition
6
+ } from "./chunk-0mcr52hc.js";
7
+ import {
8
+ Keys,
9
+ handleListNavigation,
10
+ isKey
11
+ } from "./chunk-7867pr13.js";
12
+ import {
13
+ setDataState,
14
+ setExpanded,
15
+ setHidden,
16
+ setHiddenAnimated
17
+ } from "./chunk-vevfhpc9.js";
18
+ import {
19
+ linkedIds
20
+ } from "./chunk-8y1jf6xr.js";
21
+ import {
22
+ applyAttrs
23
+ } from "./chunk-2db2dnp3.js";
24
+
25
+ // src/menu/menu.tsx
26
+ import { __discardMountFrame, __element, __enterChildren, __exitChildren, __flushMountFrame, __insert, __on, __pushMountFrame, __styleStr } from "@vertz/ui/internals";
27
+ import { signal } from "@vertz/ui";
28
+ function MenuRoot(options = {}) {
29
+ const __mfDepth = __pushMountFrame();
30
+ try {
31
+ let handleClickOutside = function(event) {
32
+ const target = event.target;
33
+ if (!trigger.contains(target) && !content.contains(target)) {
34
+ close();
35
+ }
36
+ }, open = function(activateFirst = false) {
37
+ state.open.value = true;
38
+ setExpanded(trigger, true);
39
+ setHidden(content, false);
40
+ setDataState(trigger, "open");
41
+ setDataState(content, "open");
42
+ onOpenChange?.(true);
43
+ if (positioning) {
44
+ const ref = positioning.referenceElement ?? trigger;
45
+ const result = createFloatingPosition(ref, content, positioning);
46
+ floatingCleanup = result.cleanup;
47
+ dismissCleanup = createDismiss({
48
+ onDismiss: close,
49
+ insideElements: [ref, trigger, content],
50
+ escapeKey: false
51
+ });
52
+ } else {
53
+ document.addEventListener("mousedown", handleClickOutside);
54
+ }
55
+ if (activateFirst && items.length > 0) {
56
+ state.activeIndex.value = 0;
57
+ updateActiveItem(0);
58
+ items[0]?.focus();
59
+ } else {
60
+ state.activeIndex.value = -1;
61
+ updateActiveItem(-1);
62
+ content.focus();
63
+ }
64
+ }, close = function() {
65
+ state.open.value = false;
66
+ setExpanded(trigger, false);
67
+ setDataState(trigger, "closed");
68
+ setDataState(content, "closed");
69
+ setHiddenAnimated(content, true);
70
+ onOpenChange?.(false);
71
+ if (positioning) {
72
+ floatingCleanup?.();
73
+ floatingCleanup = null;
74
+ dismissCleanup?.();
75
+ dismissCleanup = null;
76
+ } else {
77
+ document.removeEventListener("mousedown", handleClickOutside);
78
+ }
79
+ trigger.focus();
80
+ }, updateActiveItem = function(index) {
81
+ for (let i = 0;i < items.length; i++) {
82
+ items[i]?.setAttribute("tabindex", i === index ? "0" : "-1");
83
+ }
84
+ }, createItem = function(value, label, parent) {
85
+ const item = (() => {
86
+ const __el2 = __element("div");
87
+ __el2.setAttribute("role", "menuitem");
88
+ {
89
+ const __v = value;
90
+ if (__v != null && __v !== false)
91
+ __el2.setAttribute("data-value", __v === true ? "" : __v);
92
+ }
93
+ __el2.setAttribute("tabindex", "-1");
94
+ __on(__el2, "click", () => {
95
+ onSelect?.(value);
96
+ close();
97
+ });
98
+ __enterChildren(__el2);
99
+ __insert(__el2, label ?? value);
100
+ __exitChildren();
101
+ return __el2;
102
+ })();
103
+ items.push(item);
104
+ (parent ?? content).appendChild(item);
105
+ return item;
106
+ }, Item = function(value, label) {
107
+ return createItem(value, label);
108
+ }, Group = function(label) {
109
+ const el = (() => {
110
+ const __el3 = __element("div");
111
+ __el3.setAttribute("role", "group");
112
+ {
113
+ const __v = label;
114
+ if (__v != null && __v !== false)
115
+ __el3.setAttribute("aria-label", __v === true ? "" : __v);
116
+ }
117
+ return __el3;
118
+ })();
119
+ content.appendChild(el);
120
+ return {
121
+ el,
122
+ Item: (value, itemLabel) => createItem(value, itemLabel, el)
123
+ };
124
+ }, Separator = function() {
125
+ const hr = (() => {
126
+ const __el4 = __element("hr");
127
+ __el4.setAttribute("role", "separator");
128
+ return __el4;
129
+ })();
130
+ content.appendChild(hr);
131
+ return hr;
132
+ }, Label = function(text) {
133
+ const el = (() => {
134
+ const __el5 = __element("div");
135
+ __el5.setAttribute("role", "none");
136
+ __enterChildren(__el5);
137
+ __insert(__el5, text);
138
+ __exitChildren();
139
+ return __el5;
140
+ })();
141
+ content.appendChild(el);
142
+ return el;
143
+ };
144
+ const { onSelect, onOpenChange, positioning, ...attrs } = options;
145
+ const ids = linkedIds("menu");
146
+ const state = {
147
+ open: signal(false),
148
+ activeIndex: signal(-1)
149
+ };
150
+ const items = [];
151
+ let floatingCleanup = null;
152
+ let dismissCleanup = null;
153
+ const trigger = (() => {
154
+ const __el0 = __element("button");
155
+ __el0.setAttribute("type", "button");
156
+ {
157
+ const __v = ids.triggerId;
158
+ if (__v != null && __v !== false)
159
+ __el0.setAttribute("id", __v === true ? "" : __v);
160
+ }
161
+ {
162
+ const __v = ids.contentId;
163
+ if (__v != null && __v !== false)
164
+ __el0.setAttribute("aria-controls", __v === true ? "" : __v);
165
+ }
166
+ __el0.setAttribute("aria-haspopup", "menu");
167
+ __el0.setAttribute("aria-expanded", "false");
168
+ __el0.setAttribute("data-state", "closed");
169
+ __on(__el0, "click", () => {
170
+ if (state.open.peek()) {
171
+ close();
172
+ } else {
173
+ open();
174
+ }
175
+ });
176
+ __on(__el0, "keydown", (event) => {
177
+ if (isKey(event, Keys.ArrowDown, Keys.Enter, Keys.Space)) {
178
+ event.preventDefault();
179
+ if (!state.open.peek())
180
+ open(true);
181
+ }
182
+ });
183
+ return __el0;
184
+ })();
185
+ const content = (() => {
186
+ const __el1 = __element("div");
187
+ __el1.setAttribute("role", "menu");
188
+ __el1.setAttribute("tabindex", "-1");
189
+ {
190
+ const __v = ids.contentId;
191
+ if (__v != null && __v !== false)
192
+ __el1.setAttribute("id", __v === true ? "" : __v);
193
+ }
194
+ __el1.setAttribute("aria-hidden", "true");
195
+ __el1.setAttribute("data-state", "closed");
196
+ {
197
+ const __v = { display: "none" };
198
+ if (__v != null && __v !== false)
199
+ __el1.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
200
+ }
201
+ __on(__el1, "keydown", (event) => {
202
+ if (isKey(event, Keys.Escape)) {
203
+ event.preventDefault();
204
+ close();
205
+ return;
206
+ }
207
+ if (isKey(event, Keys.Enter, Keys.Space)) {
208
+ event.preventDefault();
209
+ const active = items[state.activeIndex.peek()];
210
+ if (active) {
211
+ const val = active.getAttribute("data-value");
212
+ if (val !== null) {
213
+ onSelect?.(val);
214
+ close();
215
+ }
216
+ }
217
+ return;
218
+ }
219
+ if (state.activeIndex.peek() === -1) {
220
+ if (isKey(event, Keys.ArrowDown)) {
221
+ event.preventDefault();
222
+ state.activeIndex.value = 0;
223
+ updateActiveItem(0);
224
+ items[0]?.focus();
225
+ return;
226
+ }
227
+ if (isKey(event, Keys.ArrowUp)) {
228
+ event.preventDefault();
229
+ const last = items.length - 1;
230
+ state.activeIndex.value = last;
231
+ updateActiveItem(last);
232
+ items[last]?.focus();
233
+ return;
234
+ }
235
+ }
236
+ const result = handleListNavigation(event, items, { orientation: "vertical" });
237
+ if (result) {
238
+ const idx = items.indexOf(result);
239
+ if (idx >= 0) {
240
+ state.activeIndex.value = idx;
241
+ updateActiveItem(idx);
242
+ }
243
+ return;
244
+ }
245
+ if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {
246
+ const char = event.key.toLowerCase();
247
+ const match = items.find((item) => item.textContent?.toLowerCase().startsWith(char));
248
+ if (match) {
249
+ const idx = items.indexOf(match);
250
+ state.activeIndex.value = idx;
251
+ updateActiveItem(idx);
252
+ match.focus();
253
+ }
254
+ }
255
+ });
256
+ return __el1;
257
+ })();
258
+ applyAttrs(trigger, attrs);
259
+ const __mfResult0 = { trigger, content, state, Item, Group, Separator, Label };
260
+ __flushMountFrame();
261
+ return __mfResult0;
262
+ } catch (__mfErr) {
263
+ __discardMountFrame(__mfDepth);
264
+ throw __mfErr;
265
+ }
266
+ }
267
+ var Menu = {
268
+ Root: MenuRoot
269
+ };
270
+
271
+ export { Menu };
@@ -0,0 +1,96 @@
1
+ import {
2
+ setDataState
3
+ } from "./chunk-vevfhpc9.js";
4
+ import {
5
+ uniqueId
6
+ } from "./chunk-8y1jf6xr.js";
7
+ import {
8
+ applyAttrs
9
+ } from "./chunk-2db2dnp3.js";
10
+
11
+ // src/progress/progress.tsx
12
+ import { __append, __discardMountFrame, __element, __enterChildren, __exitChildren, __flushMountFrame, __pushMountFrame, __styleStr } from "@vertz/ui/internals";
13
+ import { ref, signal } from "@vertz/ui";
14
+ function dataStateFor(pct) {
15
+ if (pct >= 100)
16
+ return "complete";
17
+ if (pct > 0)
18
+ return "loading";
19
+ return "idle";
20
+ }
21
+ function ProgressBar(defaultValue, min, max, initialPct, indicatorRef) {
22
+ const __mfDepth = __pushMountFrame();
23
+ try {
24
+ const __mfResult0 = (() => {
25
+ const __el0 = __element("div");
26
+ __el0.setAttribute("role", "progressbar");
27
+ {
28
+ const __v = uniqueId("progress");
29
+ if (__v != null && __v !== false)
30
+ __el0.setAttribute("id", __v === true ? "" : __v);
31
+ }
32
+ {
33
+ const __v = String(defaultValue);
34
+ if (__v != null && __v !== false)
35
+ __el0.setAttribute("aria-valuenow", __v === true ? "" : __v);
36
+ }
37
+ {
38
+ const __v = String(min);
39
+ if (__v != null && __v !== false)
40
+ __el0.setAttribute("aria-valuemin", __v === true ? "" : __v);
41
+ }
42
+ {
43
+ const __v = String(max);
44
+ if (__v != null && __v !== false)
45
+ __el0.setAttribute("aria-valuemax", __v === true ? "" : __v);
46
+ }
47
+ {
48
+ const __v = dataStateFor(initialPct);
49
+ if (__v != null && __v !== false)
50
+ __el0.setAttribute("data-state", __v === true ? "" : __v);
51
+ }
52
+ __enterChildren(__el0);
53
+ __append(__el0, (() => {
54
+ const __el1 = __element("div");
55
+ indicatorRef.current = __el1;
56
+ __el1.setAttribute("data-part", "indicator");
57
+ {
58
+ const __v = { width: `${initialPct}%` };
59
+ if (__v != null && __v !== false)
60
+ __el1.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
61
+ }
62
+ return __el1;
63
+ })());
64
+ __exitChildren();
65
+ return __el0;
66
+ })();
67
+ __flushMountFrame();
68
+ return __mfResult0;
69
+ } catch (__mfErr) {
70
+ __discardMountFrame(__mfDepth);
71
+ throw __mfErr;
72
+ }
73
+ }
74
+ function ProgressRoot(options = {}) {
75
+ const { defaultValue = 0, min = 0, max = 100, ...attrs } = options;
76
+ const state = { value: signal(defaultValue) };
77
+ const indicatorRef = ref();
78
+ const initialPct = (defaultValue - min) / (max - min) * 100;
79
+ const root = ProgressBar(defaultValue, min, max, initialPct, indicatorRef);
80
+ const indicator = indicatorRef.current;
81
+ applyAttrs(root, attrs);
82
+ function setValue(val) {
83
+ const clamped = Math.min(max, Math.max(min, val));
84
+ state.value.value = clamped;
85
+ root.setAttribute("aria-valuenow", String(clamped));
86
+ const pct = (clamped - min) / (max - min) * 100;
87
+ indicator.style.width = `${pct}%`;
88
+ setDataState(root, dataStateFor(pct));
89
+ }
90
+ return { root, indicator, state, setValue };
91
+ }
92
+ var Progress = {
93
+ Root: ProgressRoot
94
+ };
95
+
96
+ export { Progress };