@vertz/ui-primitives 0.2.23 → 0.2.25

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 (191) hide show
  1. package/dist/shared/{chunk-pzx0vpq1.js → chunk-00fqgnq1.js} +6 -11
  2. package/dist/shared/chunk-1dx23qnr.js +232 -0
  3. package/dist/shared/chunk-1hm0mbke.js +258 -0
  4. package/dist/shared/{chunk-ww7k2azn.js → chunk-20kwns82.js} +5 -9
  5. package/dist/shared/chunk-3jack97k.js +509 -0
  6. package/dist/shared/{chunk-xs6gp369.js → chunk-455p0jbk.js} +3 -7
  7. package/dist/shared/chunk-4z006v1j.js +467 -0
  8. package/dist/shared/{chunk-b25npqer.js → chunk-585ysr70.js} +1 -1
  9. package/dist/shared/chunk-5964gmv0.js +416 -0
  10. package/dist/shared/chunk-75pegjs7.js +26 -0
  11. package/dist/shared/{chunk-mr1tb0dp.js → chunk-7a2nqmeh.js} +1 -1
  12. package/dist/shared/chunk-7wem1bhb.js +252 -0
  13. package/dist/shared/{chunk-7cb3z0s8.js → chunk-8evj43jn.js} +5 -8
  14. package/dist/shared/chunk-8t0nm721.js +152 -0
  15. package/dist/shared/chunk-94twh4s4.js +28 -0
  16. package/dist/shared/chunk-98y1sw9y.js +398 -0
  17. package/dist/shared/chunk-9eedsnnk.js +164 -0
  18. package/dist/shared/{chunk-8c01c8mb.js → chunk-9hv3vc72.js} +0 -2
  19. package/dist/shared/{chunk-4894pmy6.js → chunk-9ydd4pn3.js} +6 -1
  20. package/dist/shared/chunk-aa3w85hn.js +321 -0
  21. package/dist/shared/chunk-axpbdpgx.js +177 -0
  22. package/dist/shared/chunk-b4zzg457.js +410 -0
  23. package/dist/shared/chunk-bc2qqkhr.js +194 -0
  24. package/dist/shared/chunk-brk0drrk.js +202 -0
  25. package/dist/shared/chunk-czv0kqj4.js +107 -0
  26. package/dist/shared/chunk-d83ag07h.js +189 -0
  27. package/dist/shared/{chunk-3kwh27dv.js → chunk-de18ashk.js} +0 -1
  28. package/dist/shared/{chunk-cgb2j94g.js → chunk-dvk4h36t.js} +0 -1
  29. package/dist/shared/chunk-e6660g7e.js +179 -0
  30. package/dist/shared/{chunk-3h1mxp95.js → chunk-eq4d9b0w.js} +0 -1
  31. package/dist/shared/chunk-ev367pq3.js +102 -0
  32. package/dist/shared/chunk-fjykbv0v.js +214 -0
  33. package/dist/shared/chunk-ghkw5bjq.js +55 -0
  34. package/dist/shared/chunk-gqb1n1hj.js +60 -0
  35. package/dist/shared/chunk-hfjtkytb.js +310 -0
  36. package/dist/shared/chunk-hpvjfj0j.js +31 -0
  37. package/dist/shared/chunk-hxmxvp56.js +67 -0
  38. package/dist/shared/chunk-j9m2f0rd.js +162 -0
  39. package/dist/shared/chunk-jpyjk616.js +52 -0
  40. package/dist/shared/{chunk-ttb2tt03.js → chunk-jsa3byag.js} +1 -1
  41. package/dist/shared/{chunk-9gfp3ffv.js → chunk-jzy1bkdk.js} +0 -1
  42. package/dist/shared/{chunk-f2vx4tpw.js → chunk-knzg86am.js} +5 -5
  43. package/dist/shared/chunk-metxdt5x.js +28 -0
  44. package/dist/shared/chunk-mhn2aazf.js +353 -0
  45. package/dist/shared/chunk-mtx2cfbx.js +175 -0
  46. package/dist/shared/chunk-nsmvdxgp.js +213 -0
  47. package/dist/shared/{chunk-pn6shbcs.js → chunk-pdzmg245.js} +1 -5
  48. package/dist/shared/chunk-pzknpa1y.js +327 -0
  49. package/dist/shared/chunk-q1ff3xp3.js +95 -0
  50. package/dist/shared/chunk-q7xbcj9q.js +7 -0
  51. package/dist/shared/{chunk-p0x7hgv6.js → chunk-qhnany7w.js} +0 -2
  52. package/dist/shared/chunk-qrm43tr3.js +357 -0
  53. package/dist/shared/{chunk-xa1b96mb.js → chunk-qsp7sfhp.js} +2 -2
  54. package/dist/shared/{chunk-j902w020.js → chunk-qwqnjjg8.js} +1 -1
  55. package/dist/shared/{chunk-h3v10x04.js → chunk-r0rz7z03.js} +6 -11
  56. package/dist/shared/chunk-r3ngaa64.js +418 -0
  57. package/dist/shared/chunk-r3pffzss.js +13 -0
  58. package/dist/shared/chunk-rrt62bp0.js +353 -0
  59. package/dist/shared/chunk-s24gkmna.js +131 -0
  60. package/dist/shared/chunk-s62e7jf4.js +30 -0
  61. package/dist/shared/chunk-spng4yb9.js +73 -0
  62. package/dist/shared/chunk-v0b5pkcq.js +30 -0
  63. package/dist/shared/chunk-v11kd39k.js +162 -0
  64. package/dist/shared/{chunk-0mcr52hc.js → chunk-vef3sepw.js} +17 -1
  65. package/dist/shared/chunk-vkscwzpr.js +294 -0
  66. package/dist/shared/chunk-vv187snj.js +112 -0
  67. package/dist/shared/chunk-wqsek87j.js +311 -0
  68. package/dist/shared/chunk-wtkxz2te.js +157 -0
  69. package/dist/shared/chunk-y1hpsqzy.js +185 -0
  70. package/dist/shared/chunk-yfzddvxc.js +71 -0
  71. package/dist/src/accordion/accordion-composed.d.ts +30 -0
  72. package/dist/src/accordion/accordion-composed.js +6 -0
  73. package/dist/src/accordion/accordion.js +1 -1
  74. package/dist/src/alert/alert-composed.d.ts +26 -0
  75. package/dist/src/alert/alert-composed.js +6 -0
  76. package/dist/src/alert-dialog/alert-dialog-composed.d.ts +40 -0
  77. package/dist/src/alert-dialog/alert-dialog-composed.js +6 -0
  78. package/dist/src/avatar/avatar-composed.d.ts +33 -0
  79. package/dist/src/avatar/avatar-composed.js +6 -0
  80. package/dist/src/badge/badge-composed.d.ts +33 -0
  81. package/dist/src/badge/badge-composed.js +6 -0
  82. package/dist/src/breadcrumb/breadcrumb-composed.d.ts +34 -0
  83. package/dist/src/breadcrumb/breadcrumb-composed.js +6 -0
  84. package/dist/src/button/button-composed.d.ts +34 -0
  85. package/dist/src/button/button-composed.js +6 -0
  86. package/dist/src/calendar/calendar-composed.d.ts +42 -0
  87. package/dist/src/calendar/calendar-composed.js +6 -0
  88. package/dist/src/calendar/calendar.js +1 -1
  89. package/dist/src/card/card-composed.d.ts +34 -0
  90. package/dist/src/card/card-composed.js +6 -0
  91. package/dist/src/carousel/carousel-composed.d.ts +32 -0
  92. package/dist/src/carousel/carousel-composed.js +6 -0
  93. package/dist/src/carousel/carousel.js +1 -1
  94. package/dist/src/checkbox/checkbox-composed.d.ts +18 -0
  95. package/dist/src/checkbox/checkbox-composed.js +6 -0
  96. package/dist/src/collapsible/collapsible-composed.d.ts +26 -0
  97. package/dist/src/collapsible/collapsible-composed.js +6 -0
  98. package/dist/src/combobox/combobox-composed.d.ts +30 -0
  99. package/dist/src/combobox/combobox-composed.js +6 -0
  100. package/dist/src/combobox/combobox.js +1 -1
  101. package/dist/src/command/command-composed.d.ts +67 -0
  102. package/dist/src/command/command-composed.js +6 -0
  103. package/dist/src/command/command.js +1 -1
  104. package/dist/src/composed/with-styles.d.ts +38 -0
  105. package/dist/src/composed/with-styles.js +6 -0
  106. package/dist/src/context-menu/context-menu-composed.d.ts +51 -0
  107. package/dist/src/context-menu/context-menu-composed.js +6 -0
  108. package/dist/src/context-menu/context-menu.js +1 -1
  109. package/dist/src/date-picker/date-picker-composed.d.ts +77 -0
  110. package/dist/src/date-picker/date-picker-composed.js +6 -0
  111. package/dist/src/date-picker/date-picker.js +1 -1
  112. package/dist/src/dialog/dialog-composed.d.ts +36 -0
  113. package/dist/src/dialog/dialog-composed.js +6 -0
  114. package/dist/src/dialog/dialog-stack-parts.d.ts +16 -0
  115. package/dist/src/dialog/dialog-stack-parts.js +18 -0
  116. package/dist/src/dropdown-menu/dropdown-menu-composed.d.ts +51 -0
  117. package/dist/src/dropdown-menu/dropdown-menu-composed.js +6 -0
  118. package/dist/src/dropdown-menu/dropdown-menu.js +1 -1
  119. package/dist/src/empty-state/empty-state-composed.d.ts +30 -0
  120. package/dist/src/empty-state/empty-state-composed.js +6 -0
  121. package/dist/src/form-group/form-group-composed.d.ts +24 -0
  122. package/dist/src/form-group/form-group-composed.js +6 -0
  123. package/dist/src/hover-card/hover-card-composed.d.ts +38 -0
  124. package/dist/src/hover-card/hover-card-composed.js +6 -0
  125. package/dist/src/hover-card/hover-card.js +1 -1
  126. package/dist/src/index.d.ts +1312 -812
  127. package/dist/src/index.js +79 -6566
  128. package/dist/src/input/input-composed.d.ts +35 -0
  129. package/dist/src/input/input-composed.js +6 -0
  130. package/dist/src/label/label-composed.d.ts +32 -0
  131. package/dist/src/label/label-composed.js +6 -0
  132. package/dist/src/list/list-composed.d.ts +34 -0
  133. package/dist/src/list/list-composed.js +6 -0
  134. package/dist/src/menu/menu-composed.d.ts +51 -0
  135. package/dist/src/menu/menu-composed.js +6 -0
  136. package/dist/src/menu/menu.js +1 -1
  137. package/dist/src/menubar/menubar-composed.d.ts +56 -0
  138. package/dist/src/menubar/menubar-composed.js +6 -0
  139. package/dist/src/menubar/menubar.js +1 -1
  140. package/dist/src/navigation-menu/navigation-menu-composed.d.ts +56 -0
  141. package/dist/src/navigation-menu/navigation-menu-composed.js +6 -0
  142. package/dist/src/navigation-menu/navigation-menu.js +1 -1
  143. package/dist/src/pagination/pagination-composed.d.ts +30 -0
  144. package/dist/src/pagination/pagination-composed.js +6 -0
  145. package/dist/src/popover/popover-composed.d.ts +36 -0
  146. package/dist/src/popover/popover-composed.js +6 -0
  147. package/dist/src/popover/popover.js +1 -1
  148. package/dist/src/progress/progress-composed.d.ts +17 -0
  149. package/dist/src/progress/progress-composed.js +6 -0
  150. package/dist/src/radio/radio-composed.d.ts +24 -0
  151. package/dist/src/radio/radio-composed.js +6 -0
  152. package/dist/src/radio/radio.js +1 -1
  153. package/dist/src/resizable-panel/resizable-panel-composed.d.ts +33 -0
  154. package/dist/src/resizable-panel/resizable-panel-composed.js +6 -0
  155. package/dist/src/resizable-panel/resizable-panel.js +1 -1
  156. package/dist/src/scroll-area/scroll-area-composed.d.ts +17 -0
  157. package/dist/src/scroll-area/scroll-area-composed.js +6 -0
  158. package/dist/src/scroll-area/scroll-area.js +1 -1
  159. package/dist/src/select/select-composed.d.ts +53 -0
  160. package/dist/src/select/select-composed.js +6 -0
  161. package/dist/src/select/select.js +1 -1
  162. package/dist/src/separator/separator-composed.d.ts +32 -0
  163. package/dist/src/separator/separator-composed.js +6 -0
  164. package/dist/src/sheet/sheet-composed.d.ts +34 -0
  165. package/dist/src/sheet/sheet-composed.js +6 -0
  166. package/dist/src/skeleton/skeleton-composed.d.ts +65 -0
  167. package/dist/src/skeleton/skeleton-composed.js +6 -0
  168. package/dist/src/slider/slider-composed.d.ts +22 -0
  169. package/dist/src/slider/slider-composed.js +6 -0
  170. package/dist/src/switch/switch-composed.d.ts +17 -0
  171. package/dist/src/switch/switch-composed.js +6 -0
  172. package/dist/src/table/table-composed.d.ts +34 -0
  173. package/dist/src/table/table-composed.js +6 -0
  174. package/dist/src/tabs/tabs-composed.d.ts +33 -0
  175. package/dist/src/tabs/tabs-composed.js +6 -0
  176. package/dist/src/tabs/tabs.js +1 -1
  177. package/dist/src/textarea/textarea-composed.d.ts +35 -0
  178. package/dist/src/textarea/textarea-composed.js +6 -0
  179. package/dist/src/toast/toast.js +1 -1
  180. package/dist/src/toggle/toggle-composed.d.ts +16 -0
  181. package/dist/src/toggle/toggle-composed.js +6 -0
  182. package/dist/src/toggle-group/toggle-group-composed.d.ts +24 -0
  183. package/dist/src/toggle-group/toggle-group-composed.js +6 -0
  184. package/dist/src/toggle-group/toggle-group.js +1 -1
  185. package/dist/src/tooltip/tooltip-composed.d.ts +36 -0
  186. package/dist/src/tooltip/tooltip-composed.js +6 -0
  187. package/dist/src/tooltip/tooltip.js +1 -1
  188. package/dist/src/utils.js +1 -1
  189. package/package.json +3 -3
  190. package/dist/shared/chunk-56reyd5r.js +0 -64
  191. package/dist/shared/chunk-mgr904ap.js +0 -370
@@ -0,0 +1,416 @@
1
+ import {
2
+ cn
3
+ } from "./chunk-q7xbcj9q.js";
4
+
5
+ // src/list/list-composed.tsx
6
+ import { computed } from "@vertz/ui";
7
+ import { __append, __attr, __child, __discardMountFrame, __element, __enterChildren, __exitChildren, __flushMountFrame, __pushMountFrame } from "@vertz/ui/internals";
8
+ import { createContext, ListAnimationContext, onMount, ref, useContext } from "@vertz/ui";
9
+ var ListContext = createContext(undefined, "@vertz/ui-primitives::ListContext");
10
+ function useListContext(subComponent) {
11
+ const ctx = useContext(ListContext);
12
+ if (!ctx) {
13
+ throw new Error(`List.${subComponent} must be used inside a <List> component`);
14
+ }
15
+ return ctx;
16
+ }
17
+ function ListItem(__props) {
18
+ const __mfDepth = __pushMountFrame();
19
+ try {
20
+ const ctx = useListContext("Item");
21
+ const __mfResult0 = (() => {
22
+ const __el0 = __element("li");
23
+ __attr(__el0, "class", () => cn(ctx.classes?.item, __props.className ?? __props.class));
24
+ {
25
+ const __v = ctx.sortable ? "" : undefined;
26
+ if (__v != null && __v !== false)
27
+ __el0.setAttribute("data-sortable-item", __v === true ? "" : __v);
28
+ }
29
+ __enterChildren(__el0);
30
+ __append(__el0, __child(() => __props.children));
31
+ __exitChildren();
32
+ return __el0;
33
+ })();
34
+ __flushMountFrame();
35
+ return __mfResult0;
36
+ } catch (__mfErr) {
37
+ __discardMountFrame(__mfDepth);
38
+ throw __mfErr;
39
+ }
40
+ }
41
+ function ListDragHandle(__props) {
42
+ const __mfDepth = __pushMountFrame();
43
+ try {
44
+ const ctx = useListContext("DragHandle");
45
+ const __mfResult0 = (() => {
46
+ const __el0 = __element("div");
47
+ __el0.setAttribute("data-list-drag-handle", "");
48
+ {
49
+ const __v = ctx.sortable ? "" : undefined;
50
+ if (__v != null && __v !== false)
51
+ __el0.setAttribute("data-sortable", __v === true ? "" : __v);
52
+ }
53
+ __attr(__el0, "class", () => cn(ctx.classes?.dragHandle, __props.className ?? __props.class));
54
+ __enterChildren(__el0);
55
+ __append(__el0, __child(() => __props.children));
56
+ __exitChildren();
57
+ return __el0;
58
+ })();
59
+ __flushMountFrame();
60
+ return __mfResult0;
61
+ } catch (__mfErr) {
62
+ __discardMountFrame(__mfDepth);
63
+ throw __mfErr;
64
+ }
65
+ }
66
+ var DEFAULT_DURATION = 200;
67
+ var DEFAULT_EASING = "ease-out";
68
+ function resolveAnimateConfig(animate) {
69
+ if (typeof animate === "object") {
70
+ return {
71
+ duration: animate.duration ?? DEFAULT_DURATION,
72
+ easing: animate.easing ?? DEFAULT_EASING
73
+ };
74
+ }
75
+ return { duration: DEFAULT_DURATION, easing: DEFAULT_EASING };
76
+ }
77
+ function createAnimationHooks(animate) {
78
+ const { duration, easing } = resolveAnimateConfig(animate);
79
+ const itemRects = new Map;
80
+ const itemNodes = new Map;
81
+ return {
82
+ onBeforeReconcile() {
83
+ itemRects.clear();
84
+ for (const [key, el] of itemNodes) {
85
+ itemRects.set(key, el.getBoundingClientRect());
86
+ }
87
+ },
88
+ onAfterReconcile() {
89
+ if (globalThis.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches)
90
+ return;
91
+ for (const [key, el] of itemNodes) {
92
+ const firstRect = itemRects.get(key);
93
+ if (!firstRect)
94
+ continue;
95
+ const lastRect = el.getBoundingClientRect();
96
+ const deltaX = firstRect.left - lastRect.left;
97
+ const deltaY = firstRect.top - lastRect.top;
98
+ if (Math.abs(deltaX) < 0.5 && Math.abs(deltaY) < 0.5)
99
+ continue;
100
+ el.style.transform = `translate(${deltaX}px, ${deltaY}px)`;
101
+ el.style.transition = "none";
102
+ requestAnimationFrame(() => {
103
+ el.style.transition = `transform ${duration}ms ${easing}`;
104
+ el.style.transform = "";
105
+ el.addEventListener("transitionend", () => {
106
+ el.style.transition = "";
107
+ el.style.transform = "";
108
+ }, { once: true });
109
+ });
110
+ }
111
+ },
112
+ onItemEnter(node, key) {
113
+ if (node instanceof Element) {
114
+ itemNodes.set(key, node);
115
+ node.setAttribute("data-presence", "enter");
116
+ if ("offsetHeight" in node) {
117
+ node.offsetHeight;
118
+ }
119
+ if (typeof node.getAnimations === "function") {
120
+ const anims = node.getAnimations();
121
+ if (anims.length > 0) {
122
+ Promise.all(anims.map((a) => a.finished.catch(() => {}))).then(() => {
123
+ if (itemNodes.get(key) === node) {
124
+ node.removeAttribute("data-presence");
125
+ }
126
+ });
127
+ return;
128
+ }
129
+ }
130
+ node.removeAttribute("data-presence");
131
+ }
132
+ },
133
+ onItemExit(node, key, done) {
134
+ itemNodes.delete(key);
135
+ itemRects.delete(key);
136
+ if (node instanceof Element) {
137
+ const el = node;
138
+ const rect = node.getBoundingClientRect();
139
+ const reducedMotion = globalThis.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches;
140
+ const remainingRects = new Map;
141
+ for (const [k, n] of itemNodes) {
142
+ remainingRects.set(k, n.getBoundingClientRect());
143
+ }
144
+ el.style.overflow = "hidden";
145
+ el.style.pointerEvents = "none";
146
+ el.style.borderBottomWidth = "0";
147
+ node.setAttribute("data-presence", "exit");
148
+ if (!reducedMotion) {
149
+ el.style.height = `${rect.height}px`;
150
+ el.style.transition = "none";
151
+ el.style.opacity = "1";
152
+ el.offsetHeight;
153
+ el.style.transition = `height ${duration}ms ${easing}, opacity ${duration}ms ${easing}, ` + `padding ${duration}ms ${easing}`;
154
+ el.style.height = "0";
155
+ el.style.paddingTop = "0";
156
+ el.style.paddingBottom = "0";
157
+ el.style.opacity = "0";
158
+ el.addEventListener("transitionend", () => done(), { once: true });
159
+ setTimeout(() => done(), duration + 50);
160
+ } else {
161
+ done();
162
+ }
163
+ return;
164
+ }
165
+ done();
166
+ }
167
+ };
168
+ }
169
+ function findSortableItem(target, root) {
170
+ if (!(target instanceof HTMLElement))
171
+ return null;
172
+ const item = target.closest("[data-sortable-item]");
173
+ if (item instanceof HTMLElement && root.contains(item))
174
+ return item;
175
+ return null;
176
+ }
177
+ function createDropIndicator() {
178
+ let indicator = null;
179
+ function getOrCreate() {
180
+ if (!indicator) {
181
+ indicator = document.createElement("div");
182
+ indicator.setAttribute("data-drop-indicator", "");
183
+ indicator.style.height = "2px";
184
+ indicator.style.background = "var(--color-primary, #3b82f6)";
185
+ indicator.style.borderRadius = "1px";
186
+ indicator.style.position = "absolute";
187
+ indicator.style.left = "0";
188
+ indicator.style.right = "0";
189
+ indicator.style.pointerEvents = "none";
190
+ indicator.style.zIndex = "100";
191
+ }
192
+ return indicator;
193
+ }
194
+ return {
195
+ show(ulEl, beforeItem) {
196
+ const el = getOrCreate();
197
+ if (!el.parentNode)
198
+ ulEl.appendChild(el);
199
+ if (beforeItem) {
200
+ const ulRect = ulEl.getBoundingClientRect();
201
+ const itemRect = beforeItem.getBoundingClientRect();
202
+ el.style.top = `${itemRect.top - ulRect.top - 1}px`;
203
+ } else {
204
+ const items = ulEl.querySelectorAll("[data-sortable-item]");
205
+ if (items.length > 0) {
206
+ const last = items[items.length - 1];
207
+ const ulRect = ulEl.getBoundingClientRect();
208
+ const lastRect = last.getBoundingClientRect();
209
+ el.style.top = `${lastRect.bottom - ulRect.top - 1}px`;
210
+ }
211
+ }
212
+ },
213
+ hide() {
214
+ indicator?.parentNode?.removeChild(indicator);
215
+ }
216
+ };
217
+ }
218
+ function applyShiftTransforms(allItems, fromIndex, targetInsertionIndex, draggedHeight, animate) {
219
+ const { duration, easing } = resolveAnimateConfig(animate);
220
+ const reducedMotion = globalThis.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches;
221
+ for (let i = 0;i < allItems.length; i++) {
222
+ if (i === fromIndex)
223
+ continue;
224
+ let shift = 0;
225
+ if (targetInsertionIndex > fromIndex) {
226
+ if (i > fromIndex && i < targetInsertionIndex) {
227
+ shift = -draggedHeight;
228
+ }
229
+ } else if (targetInsertionIndex < fromIndex) {
230
+ if (i >= targetInsertionIndex && i < fromIndex) {
231
+ shift = draggedHeight;
232
+ }
233
+ }
234
+ const item = allItems[i];
235
+ const transition = reducedMotion ? "none" : `transform ${duration}ms ${easing}`;
236
+ if (shift !== 0) {
237
+ item.style.transition = transition;
238
+ item.style.transform = `translateY(${shift}px)`;
239
+ } else {
240
+ item.style.transition = transition;
241
+ item.style.transform = "";
242
+ }
243
+ }
244
+ }
245
+ function setupDragSort(ulEl, getSortable, getOnReorder, getAnimate) {
246
+ const dropIndicator = createDropIndicator();
247
+ ulEl.addEventListener("pointerdown", (e) => {
248
+ if (!getSortable())
249
+ return;
250
+ const target = e.target;
251
+ if (!target)
252
+ return;
253
+ const hasHandles = ulEl.querySelector("[data-list-drag-handle][data-sortable]") !== null;
254
+ if (hasHandles) {
255
+ const handle = target.closest("[data-list-drag-handle][data-sortable]");
256
+ if (!handle || !ulEl.contains(handle))
257
+ return;
258
+ } else {
259
+ const item = target.closest("[data-sortable-item]");
260
+ if (!item || !ulEl.contains(item))
261
+ return;
262
+ }
263
+ const draggedItem = findSortableItem(target, ulEl);
264
+ if (!draggedItem)
265
+ return;
266
+ e.preventDefault();
267
+ const animate = getAnimate();
268
+ const useAnimatedShift = !!animate;
269
+ const startY = e.clientY;
270
+ draggedItem.setAttribute("data-dragging", "");
271
+ const allItems = [...ulEl.querySelectorAll("[data-sortable-item]")];
272
+ const fromIndex = allItems.indexOf(draggedItem);
273
+ if (fromIndex === -1)
274
+ return;
275
+ const snapshotRects = allItems.map((item) => item.getBoundingClientRect());
276
+ const draggedRect = snapshotRects[fromIndex];
277
+ const draggedHeight = draggedRect.height;
278
+ const ulRect = ulEl.getBoundingClientRect();
279
+ let placeholder = null;
280
+ if (useAnimatedShift) {
281
+ for (const item of allItems) {
282
+ item.style.willChange = "transform";
283
+ }
284
+ const draggedWidth = draggedRect.width;
285
+ const initialTop = draggedRect.top - ulRect.top;
286
+ const initialLeft = draggedRect.left - ulRect.left;
287
+ placeholder = document.createElement("li");
288
+ placeholder.setAttribute("data-drag-placeholder", "");
289
+ placeholder.style.height = `${draggedHeight}px`;
290
+ placeholder.style.visibility = "hidden";
291
+ placeholder.style.pointerEvents = "none";
292
+ draggedItem.parentNode?.insertBefore(placeholder, draggedItem);
293
+ draggedItem.style.position = "absolute";
294
+ draggedItem.style.width = `${draggedWidth}px`;
295
+ draggedItem.style.top = `${initialTop}px`;
296
+ draggedItem.style.left = `${initialLeft}px`;
297
+ draggedItem.style.zIndex = "50";
298
+ }
299
+ function calcInsertionFromSnapshot(clientY) {
300
+ if (snapshotRects.length === 0)
301
+ return 0;
302
+ for (let i = 0;i < snapshotRects.length; i++) {
303
+ const rect = snapshotRects[i];
304
+ const midY = rect.top + rect.height / 2;
305
+ if (clientY <= midY)
306
+ return i;
307
+ }
308
+ return snapshotRects.length;
309
+ }
310
+ const onMove = (moveEvent) => {
311
+ moveEvent.preventDefault();
312
+ const deltaY = moveEvent.clientY - startY;
313
+ if (useAnimatedShift) {
314
+ const initialTop = draggedRect.top - ulRect.top;
315
+ draggedItem.style.top = `${initialTop + deltaY}px`;
316
+ } else {
317
+ draggedItem.style.transform = `translateY(${deltaY}px)`;
318
+ draggedItem.style.transition = "none";
319
+ }
320
+ const targetInsertionIndex = calcInsertionFromSnapshot(moveEvent.clientY);
321
+ if (useAnimatedShift) {
322
+ applyShiftTransforms(allItems, fromIndex, targetInsertionIndex, draggedHeight, animate);
323
+ } else {
324
+ const indicatorTarget = (targetInsertionIndex < allItems.length ? allItems[targetInsertionIndex] : null) ?? null;
325
+ if (indicatorTarget !== draggedItem) {
326
+ dropIndicator.show(ulEl, indicatorTarget);
327
+ } else {
328
+ dropIndicator.hide();
329
+ }
330
+ }
331
+ };
332
+ const onUp = (upEvent) => {
333
+ document.removeEventListener("pointermove", onMove);
334
+ document.removeEventListener("pointerup", onUp);
335
+ draggedItem.removeAttribute("data-dragging");
336
+ draggedItem.style.transform = "";
337
+ draggedItem.style.transition = "";
338
+ if (useAnimatedShift) {
339
+ if (placeholder?.parentNode) {
340
+ placeholder.parentNode.removeChild(placeholder);
341
+ placeholder = null;
342
+ }
343
+ draggedItem.style.position = "";
344
+ draggedItem.style.width = "";
345
+ draggedItem.style.top = "";
346
+ draggedItem.style.left = "";
347
+ draggedItem.style.zIndex = "";
348
+ for (const item of allItems) {
349
+ item.style.transition = "none";
350
+ item.style.transform = "";
351
+ item.style.willChange = "";
352
+ }
353
+ }
354
+ dropIndicator.hide();
355
+ const insertionIndex = calcInsertionFromSnapshot(upEvent.clientY);
356
+ const destIndex = insertionIndex > fromIndex ? insertionIndex - 1 : insertionIndex;
357
+ if (fromIndex !== destIndex) {
358
+ getOnReorder()?.(fromIndex, destIndex);
359
+ }
360
+ };
361
+ document.addEventListener("pointermove", onMove);
362
+ document.addEventListener("pointerup", onUp);
363
+ });
364
+ }
365
+ function ComposedListRoot(__props) {
366
+ const __mfDepth = __pushMountFrame();
367
+ try {
368
+ const ctx = {
369
+ classes: __props.classes,
370
+ animate: __props.animate ?? false,
371
+ sortable: __props.sortable ?? false,
372
+ onReorder: __props.onReorder
373
+ };
374
+ const animHooks = computed(() => __props.animate ?? false ? createAnimationHooks(__props.animate ?? false) : undefined);
375
+ const ulRef = ref();
376
+ if (__props.sortable ?? false) {
377
+ onMount(() => {
378
+ const ul = ulRef.current;
379
+ if (ul) {
380
+ setupDragSort(ul, () => __props.sortable ?? false, () => __props.onReorder, () => __props.animate ?? false);
381
+ }
382
+ });
383
+ }
384
+ const __mfResult0 = ListContext.Provider({ get value() {
385
+ return ctx;
386
+ }, children: () => ListAnimationContext.Provider({ get value() {
387
+ return animHooks.value;
388
+ }, children: () => (() => {
389
+ const __el0 = __element("ul");
390
+ ulRef.current = __el0;
391
+ __attr(__el0, "class", () => cn(__props.classes?.root, __props.className ?? __props.class));
392
+ __enterChildren(__el0);
393
+ __append(__el0, __child(() => __props.children));
394
+ __exitChildren();
395
+ return __el0;
396
+ })() }) });
397
+ __flushMountFrame();
398
+ return __mfResult0;
399
+ } catch (__mfErr) {
400
+ __discardMountFrame(__mfDepth);
401
+ throw __mfErr;
402
+ }
403
+ }
404
+ function reorder(arr, from, to) {
405
+ const result = [...arr];
406
+ const moved = result.splice(from, 1)[0];
407
+ result.splice(to, 0, moved);
408
+ return result;
409
+ }
410
+ var ComposedList = Object.assign(ComposedListRoot, {
411
+ Item: ListItem,
412
+ DragHandle: ListDragHandle,
413
+ reorder
414
+ });
415
+
416
+ export { ComposedList };
@@ -0,0 +1,26 @@
1
+ import {
2
+ cn
3
+ } from "./chunk-q7xbcj9q.js";
4
+
5
+ // src/input/input-composed.tsx
6
+ import { __attr, __discardMountFrame, __element, __flushMountFrame, __pushMountFrame, __spread } from "@vertz/ui/internals";
7
+ function ComposedInputRoot(__props) {
8
+ const { classes: __$drop_0, className: __$drop_1, class: __$drop_2, ...props } = __props;
9
+ const __mfDepth = __pushMountFrame();
10
+ try {
11
+ const __mfResult0 = (() => {
12
+ const __el0 = __element("input");
13
+ __attr(__el0, "class", () => cn(__props.classes?.base, __props.className ?? __props.class));
14
+ __spread(__el0, props);
15
+ return __el0;
16
+ })();
17
+ __flushMountFrame();
18
+ return __mfResult0;
19
+ } catch (__mfErr) {
20
+ __discardMountFrame(__mfDepth);
21
+ throw __mfErr;
22
+ }
23
+ }
24
+ var ComposedInput = ComposedInputRoot;
25
+
26
+ export { ComposedInput };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createFloatingPosition
3
- } from "./chunk-0mcr52hc.js";
3
+ } from "./chunk-vef3sepw.js";
4
4
  import {
5
5
  Keys,
6
6
  isKey
@@ -0,0 +1,252 @@
1
+ import {
2
+ ComposedCalendar
3
+ } from "./chunk-3jack97k.js";
4
+ import {
5
+ cn
6
+ } from "./chunk-q7xbcj9q.js";
7
+ import {
8
+ createDismiss
9
+ } from "./chunk-a6wp8c32.js";
10
+ import {
11
+ createFloatingPosition
12
+ } from "./chunk-vef3sepw.js";
13
+ import {
14
+ linkedIds
15
+ } from "./chunk-8y1jf6xr.js";
16
+
17
+ // src/date-picker/date-picker-composed.tsx
18
+ import { computed, signal } from "@vertz/ui";
19
+ import { __append, __attr, __child, __discardMountFrame, __element, __enterChildren, __exitChildren, __flushMountFrame, __on, __pushMountFrame, __styleStr } from "@vertz/ui/internals";
20
+ import { createContext, ref, useContext } from "@vertz/ui";
21
+ var DatePickerContext = createContext(undefined, "@vertz/ui-primitives::DatePickerContext");
22
+ function DatePickerTrigger(__props) {
23
+ const __mfDepth = __pushMountFrame();
24
+ try {
25
+ const ctx = useContext(DatePickerContext);
26
+ if (!ctx) {
27
+ throw new Error("<DatePicker.Trigger> must be used inside <DatePicker>. " + "Ensure it is a direct or nested child of the DatePicker root component.");
28
+ }
29
+ const isOpen = computed(() => ctx.isOpen());
30
+ const hasVal = computed(() => ctx.hasValue());
31
+ const text = computed(() => ctx.displayText());
32
+ const __mfResult0 = (() => {
33
+ const __el0 = __element("button");
34
+ ctx.triggerRef.current = __el0;
35
+ __el0.setAttribute("type", "button");
36
+ __el0.setAttribute("data-datepicker-trigger", "");
37
+ __el0.setAttribute("aria-haspopup", "dialog");
38
+ __attr(__el0, "aria-controls", () => ctx.contentId);
39
+ __attr(__el0, "aria-expanded", () => isOpen.value ? "true" : "false");
40
+ __attr(__el0, "data-state", () => isOpen.value ? "open" : "closed");
41
+ __attr(__el0, "data-placeholder", () => hasVal.value ? undefined : "true");
42
+ __attr(__el0, "class", () => cn(ctx.classes?.trigger, __props.className ?? __props.class));
43
+ __on(__el0, "click", () => ctx.toggle());
44
+ __enterChildren(__el0);
45
+ __append(__el0, __child(() => __props.children ?? text.value));
46
+ __exitChildren();
47
+ return __el0;
48
+ })();
49
+ __flushMountFrame();
50
+ return __mfResult0;
51
+ } catch (__mfErr) {
52
+ __discardMountFrame(__mfDepth);
53
+ throw __mfErr;
54
+ }
55
+ }
56
+ function DatePickerContent(__props) {
57
+ const __mfDepth = __pushMountFrame();
58
+ try {
59
+ const ctx = useContext(DatePickerContext);
60
+ if (!ctx) {
61
+ throw new Error("<DatePicker.Content> must be used inside <DatePicker>. " + "Ensure it is a direct or nested child of the DatePicker root component.");
62
+ }
63
+ const isOpen = computed(() => ctx.isOpen());
64
+ const __mfResult0 = (() => {
65
+ const __el0 = __element("div");
66
+ ctx.contentRef.current = __el0;
67
+ __el0.setAttribute("role", "dialog");
68
+ __attr(__el0, "id", () => ctx.contentId);
69
+ __el0.setAttribute("data-datepicker-content", "");
70
+ __attr(__el0, "aria-hidden", () => isOpen.value ? "false" : "true");
71
+ __attr(__el0, "data-state", () => isOpen.value ? "open" : "closed");
72
+ __attr(__el0, "style", () => ({
73
+ display: isOpen.value ? "" : "none",
74
+ zIndex: "50"
75
+ }));
76
+ __attr(__el0, "class", () => cn(ctx.classes?.content, __props.className ?? __props.class));
77
+ __enterChildren(__el0);
78
+ __append(__el0, __child(() => __props.children));
79
+ __exitChildren();
80
+ return __el0;
81
+ })();
82
+ __flushMountFrame();
83
+ return __mfResult0;
84
+ } catch (__mfErr) {
85
+ __discardMountFrame(__mfDepth);
86
+ throw __mfErr;
87
+ }
88
+ }
89
+ function _toRealDate(val) {
90
+ if (val instanceof Date)
91
+ return val;
92
+ if (val && typeof val === "object" && typeof val.getTime === "function") {
93
+ return new Date(val.getTime());
94
+ }
95
+ return null;
96
+ }
97
+ function _defaultFormatDate(date) {
98
+ return date.toLocaleDateString();
99
+ }
100
+ function _getDisplayText(value, placeholder, formatDate) {
101
+ if (value === null)
102
+ return placeholder;
103
+ if (value instanceof Date)
104
+ return formatDate(value);
105
+ if ("from" in value)
106
+ return `${formatDate(value.from)} – ${formatDate(value.to)}`;
107
+ return placeholder;
108
+ }
109
+ function _buildCalendar(props, onCalendarValueChange) {
110
+ const initValue = props.defaultValue ?? null;
111
+ const calendarMode = (props.mode ?? "single") === "range" ? "range" : "single";
112
+ const calendarDefaultValue = initValue instanceof Date ? initValue : initValue && ("from" in initValue) ? initValue : undefined;
113
+ const defaultMonth = props.defaultMonth ?? (initValue instanceof Date ? initValue : initValue && ("from" in initValue) ? initValue.from : new Date);
114
+ return ComposedCalendar({
115
+ classes: props.classes?.calendar,
116
+ mode: calendarMode,
117
+ defaultValue: calendarDefaultValue,
118
+ defaultMonth,
119
+ minDate: props.minDate,
120
+ maxDate: props.maxDate,
121
+ disabled: props.disabled,
122
+ captionLayout: props.captionLayout,
123
+ onValueChange: onCalendarValueChange
124
+ });
125
+ }
126
+ function ComposedDatePickerRoot(__props) {
127
+ const __mfDepth = __pushMountFrame();
128
+ try {
129
+ let open = function() {
130
+ isOpen.value = true;
131
+ const triggerEl = triggerRef.current;
132
+ const contentEl = contentRef.current;
133
+ if (triggerEl && contentEl) {
134
+ contentEl.style.position = "fixed";
135
+ const result = createFloatingPosition(triggerEl, contentEl, {
136
+ placement: "bottom-start",
137
+ offset: 4
138
+ });
139
+ state.floatingCleanup = result.cleanup;
140
+ state.dismissCleanup = createDismiss({
141
+ onDismiss: close,
142
+ insideElements: [triggerEl, contentEl],
143
+ escapeKey: true
144
+ });
145
+ }
146
+ __props.onOpenChange?.(true);
147
+ }, close = function() {
148
+ isOpen.value = false;
149
+ state.floatingCleanup?.();
150
+ state.floatingCleanup = null;
151
+ state.dismissCleanup?.();
152
+ state.dismissCleanup = null;
153
+ __props.onOpenChange?.(false);
154
+ }, toggle = function() {
155
+ if (isOpen.value)
156
+ close();
157
+ else
158
+ open();
159
+ }, handleCalendarValueChange = function(calValue) {
160
+ if (calValue === null)
161
+ return;
162
+ if ((__props.mode ?? "single") === "single") {
163
+ const realDate = _toRealDate(calValue);
164
+ if (realDate) {
165
+ state.value = realDate;
166
+ hasValue.value = true;
167
+ displayText.value = _getDisplayText(realDate, __props.placeholder ?? "Pick a date", __props.formatDate ?? _defaultFormatDate);
168
+ __props.onValueChange?.(realDate);
169
+ close();
170
+ }
171
+ } else if ((__props.mode ?? "single") === "range" && calValue && "from" in calValue) {
172
+ const raw = calValue;
173
+ const from = _toRealDate(raw.from);
174
+ const to = _toRealDate(raw.to);
175
+ if (from && to) {
176
+ const range = { from, to };
177
+ state.value = range;
178
+ hasValue.value = true;
179
+ displayText.value = _getDisplayText(range, __props.placeholder ?? "Pick a date", __props.formatDate ?? _defaultFormatDate);
180
+ __props.onValueChange?.(range);
181
+ if (from.getTime() !== to.getTime()) {
182
+ close();
183
+ }
184
+ }
185
+ }
186
+ };
187
+ const ids = linkedIds("datepicker");
188
+ const triggerRef = ref();
189
+ const contentRef = ref();
190
+ const isOpen = signal(false, "isOpen");
191
+ const hasValue = signal((__props.defaultValue ?? undefined) != null, "hasValue");
192
+ const displayText = signal(_getDisplayText(__props.defaultValue ?? undefined ?? null, __props.placeholder ?? "Pick a date", __props.formatDate ?? _defaultFormatDate), "displayText");
193
+ const state = {
194
+ value: __props.defaultValue ?? undefined ?? null,
195
+ dismissCleanup: null,
196
+ floatingCleanup: null
197
+ };
198
+ const calendarEl = computed(() => _buildCalendar({
199
+ mode: __props.mode ?? "single",
200
+ defaultValue: __props.defaultValue ?? undefined,
201
+ defaultMonth: __props.defaultMonth,
202
+ minDate: __props.minDate,
203
+ maxDate: __props.maxDate,
204
+ disabled: __props.disabled,
205
+ classes: __props.classes,
206
+ captionLayout: __props.captionLayout
207
+ }, handleCalendarValueChange));
208
+ const ctx = {
209
+ isOpen: () => isOpen.value,
210
+ hasValue: () => hasValue.value,
211
+ displayText: () => displayText.value,
212
+ contentId: ids.contentId,
213
+ triggerRef,
214
+ contentRef,
215
+ classes: __props.classes,
216
+ open,
217
+ close,
218
+ toggle
219
+ };
220
+ const __mfResult0 = DatePickerContext.Provider({ get value() {
221
+ return ctx;
222
+ }, children: () => (() => {
223
+ const __el0 = __element("span");
224
+ {
225
+ const __v = { position: "relative", display: "inline-block" };
226
+ if (__v != null && __v !== false)
227
+ __el0.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
228
+ }
229
+ __el0.setAttribute("data-datepicker-root", "");
230
+ __enterChildren(__el0);
231
+ __append(__el0, __child(() => __props.children ?? (() => {
232
+ const __el1 = document.createDocumentFragment();
233
+ __append(__el1, DatePickerTrigger({}));
234
+ __append(__el1, DatePickerContent({ children: () => __child(() => calendarEl.value) }));
235
+ return __el1;
236
+ })()));
237
+ __exitChildren();
238
+ return __el0;
239
+ })() });
240
+ __flushMountFrame();
241
+ return __mfResult0;
242
+ } catch (__mfErr) {
243
+ __discardMountFrame(__mfDepth);
244
+ throw __mfErr;
245
+ }
246
+ }
247
+ var ComposedDatePicker = Object.assign(ComposedDatePickerRoot, {
248
+ Trigger: DatePickerTrigger,
249
+ Content: DatePickerContent
250
+ });
251
+
252
+ export { ComposedDatePicker };