@vertz/ui-primitives 0.2.22 → 0.2.24

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 (236) hide show
  1. package/dist/shared/chunk-00fqgnq1.js +218 -0
  2. package/dist/shared/chunk-1hm0mbke.js +258 -0
  3. package/dist/shared/chunk-20kwns82.js +293 -0
  4. package/dist/shared/chunk-3jack97k.js +509 -0
  5. package/dist/shared/chunk-455p0jbk.js +241 -0
  6. package/dist/shared/chunk-4gyg71bn.js +178 -0
  7. package/dist/shared/chunk-4z006v1j.js +467 -0
  8. package/dist/shared/chunk-585ysr70.js +149 -0
  9. package/dist/shared/chunk-67sn29eh.js +125 -0
  10. package/dist/shared/chunk-75pegjs7.js +26 -0
  11. package/dist/shared/chunk-7a2nqmeh.js +167 -0
  12. package/dist/shared/chunk-7wem1bhb.js +252 -0
  13. package/dist/shared/chunk-8evj43jn.js +284 -0
  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-99tk72t3.js +69 -0
  18. package/dist/shared/chunk-9eedsnnk.js +164 -0
  19. package/dist/shared/chunk-9hv3vc72.js +215 -0
  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-brk0drrk.js +202 -0
  24. package/dist/shared/chunk-czv0kqj4.js +107 -0
  25. package/dist/shared/chunk-d83ag07h.js +189 -0
  26. package/dist/shared/chunk-de18ashk.js +134 -0
  27. package/dist/shared/chunk-dvk4h36t.js +140 -0
  28. package/dist/shared/chunk-e1jcf22s.js +79 -0
  29. package/dist/shared/chunk-e3h0ddmx.js +168 -0
  30. package/dist/shared/chunk-e6660g7e.js +179 -0
  31. package/dist/shared/chunk-eq4d9b0w.js +147 -0
  32. package/dist/shared/chunk-ev367pq3.js +102 -0
  33. package/dist/shared/chunk-f0wy7k56.js +183 -0
  34. package/dist/shared/chunk-fjykbv0v.js +214 -0
  35. package/dist/shared/chunk-ghkw5bjq.js +55 -0
  36. package/dist/shared/chunk-gqb1n1hj.js +60 -0
  37. package/dist/shared/chunk-hdvdfd1c.js +96 -0
  38. package/dist/shared/chunk-hfjtkytb.js +310 -0
  39. package/dist/shared/chunk-hpvjfj0j.js +31 -0
  40. package/dist/shared/chunk-hxmxvp56.js +67 -0
  41. package/dist/shared/chunk-j9m2f0rd.js +162 -0
  42. package/dist/shared/chunk-jdygp28a.js +260 -0
  43. package/dist/shared/chunk-jpyjk616.js +52 -0
  44. package/dist/shared/chunk-jqre4qtw.js +180 -0
  45. package/dist/shared/{chunk-myq79qew.js → chunk-jsa3byag.js} +48 -28
  46. package/dist/shared/chunk-jzy1bkdk.js +203 -0
  47. package/dist/shared/chunk-knzg86am.js +168 -0
  48. package/dist/shared/chunk-kskxxc2q.js +228 -0
  49. package/dist/shared/chunk-metxdt5x.js +28 -0
  50. package/dist/shared/chunk-mhn2aazf.js +353 -0
  51. package/dist/shared/chunk-mtx2cfbx.js +175 -0
  52. package/dist/shared/chunk-nj420k31.js +54 -0
  53. package/dist/shared/chunk-nsmvdxgp.js +213 -0
  54. package/dist/shared/{chunk-w9dag6ce.js → chunk-pdzmg245.js} +133 -85
  55. package/dist/shared/chunk-pzknpa1y.js +327 -0
  56. package/dist/shared/chunk-q1ff3xp3.js +95 -0
  57. package/dist/shared/chunk-q7xbcj9q.js +7 -0
  58. package/dist/shared/chunk-qhnany7w.js +179 -0
  59. package/dist/shared/chunk-qrm43tr3.js +357 -0
  60. package/dist/shared/{chunk-jda3v59q.js → chunk-qsp7sfhp.js} +2 -2
  61. package/dist/shared/{chunk-dhyr0s9n.js → chunk-qwqnjjg8.js} +1 -1
  62. package/dist/shared/chunk-r0rz7z03.js +266 -0
  63. package/dist/shared/chunk-r3ngaa64.js +418 -0
  64. package/dist/shared/chunk-r3pffzss.js +13 -0
  65. package/dist/shared/chunk-rrt62bp0.js +353 -0
  66. package/dist/shared/chunk-s24gkmna.js +131 -0
  67. package/dist/shared/chunk-s62e7jf4.js +30 -0
  68. package/dist/shared/chunk-spng4yb9.js +73 -0
  69. package/dist/shared/chunk-tn0m98j8.js +42 -0
  70. package/dist/shared/chunk-v0b5pkcq.js +30 -0
  71. package/dist/shared/chunk-v11kd39k.js +162 -0
  72. package/dist/shared/{chunk-0mcr52hc.js → chunk-vef3sepw.js} +17 -1
  73. package/dist/shared/chunk-vkscwzpr.js +294 -0
  74. package/dist/shared/chunk-vv187snj.js +112 -0
  75. package/dist/shared/chunk-vy874zxe.js +68 -0
  76. package/dist/shared/chunk-wqsek87j.js +311 -0
  77. package/dist/shared/chunk-wtkxz2te.js +157 -0
  78. package/dist/shared/chunk-y1hpsqzy.js +185 -0
  79. package/dist/shared/chunk-y4mmmayp.js +206 -0
  80. package/dist/shared/chunk-yfzddvxc.js +71 -0
  81. package/dist/src/accordion/accordion-composed.d.ts +30 -0
  82. package/dist/src/accordion/accordion-composed.js +6 -0
  83. package/dist/src/accordion/accordion.js +1 -1
  84. package/dist/src/alert/alert-composed.d.ts +26 -0
  85. package/dist/src/alert/alert-composed.js +6 -0
  86. package/dist/src/alert-dialog/alert-dialog-composed.d.ts +40 -0
  87. package/dist/src/alert-dialog/alert-dialog-composed.js +6 -0
  88. package/dist/src/alert-dialog/alert-dialog.js +1 -1
  89. package/dist/src/avatar/avatar-composed.d.ts +33 -0
  90. package/dist/src/avatar/avatar-composed.js +6 -0
  91. package/dist/src/badge/badge-composed.d.ts +33 -0
  92. package/dist/src/badge/badge-composed.js +6 -0
  93. package/dist/src/badge/badge.js +1 -1
  94. package/dist/src/breadcrumb/breadcrumb-composed.d.ts +34 -0
  95. package/dist/src/breadcrumb/breadcrumb-composed.js +6 -0
  96. package/dist/src/button/button-composed.d.ts +34 -0
  97. package/dist/src/button/button-composed.js +6 -0
  98. package/dist/src/button/button.js +1 -1
  99. package/dist/src/calendar/calendar-composed.d.ts +42 -0
  100. package/dist/src/calendar/calendar-composed.js +6 -0
  101. package/dist/src/calendar/calendar.js +1 -1
  102. package/dist/src/card/card-composed.d.ts +34 -0
  103. package/dist/src/card/card-composed.js +6 -0
  104. package/dist/src/carousel/carousel-composed.d.ts +32 -0
  105. package/dist/src/carousel/carousel-composed.js +6 -0
  106. package/dist/src/carousel/carousel.js +1 -1
  107. package/dist/src/checkbox/checkbox-composed.d.ts +18 -0
  108. package/dist/src/checkbox/checkbox-composed.js +6 -0
  109. package/dist/src/checkbox/checkbox.js +1 -1
  110. package/dist/src/collapsible/collapsible-composed.d.ts +26 -0
  111. package/dist/src/collapsible/collapsible-composed.js +6 -0
  112. package/dist/src/collapsible/collapsible.js +1 -1
  113. package/dist/src/combobox/combobox-composed.d.ts +30 -0
  114. package/dist/src/combobox/combobox-composed.js +6 -0
  115. package/dist/src/combobox/combobox.js +1 -1
  116. package/dist/src/command/command-composed.d.ts +67 -0
  117. package/dist/src/command/command-composed.js +6 -0
  118. package/dist/src/command/command.js +1 -1
  119. package/dist/src/composed/with-styles.d.ts +38 -0
  120. package/dist/src/composed/with-styles.js +6 -0
  121. package/dist/src/context-menu/context-menu-composed.d.ts +51 -0
  122. package/dist/src/context-menu/context-menu-composed.js +6 -0
  123. package/dist/src/context-menu/context-menu.js +1 -1
  124. package/dist/src/date-picker/date-picker-composed.d.ts +77 -0
  125. package/dist/src/date-picker/date-picker-composed.js +6 -0
  126. package/dist/src/date-picker/date-picker.js +1 -1
  127. package/dist/src/dialog/dialog-composed.d.ts +36 -0
  128. package/dist/src/dialog/dialog-composed.js +6 -0
  129. package/dist/src/dialog/dialog-stack-parts.d.ts +16 -0
  130. package/dist/src/dialog/dialog-stack-parts.js +18 -0
  131. package/dist/src/dialog/dialog.js +1 -1
  132. package/dist/src/dropdown-menu/dropdown-menu-composed.d.ts +51 -0
  133. package/dist/src/dropdown-menu/dropdown-menu-composed.js +6 -0
  134. package/dist/src/dropdown-menu/dropdown-menu.js +1 -1
  135. package/dist/src/empty-state/empty-state-composed.d.ts +30 -0
  136. package/dist/src/empty-state/empty-state-composed.js +6 -0
  137. package/dist/src/form-group/form-group-composed.d.ts +24 -0
  138. package/dist/src/form-group/form-group-composed.js +6 -0
  139. package/dist/src/hover-card/hover-card-composed.d.ts +38 -0
  140. package/dist/src/hover-card/hover-card-composed.js +6 -0
  141. package/dist/src/hover-card/hover-card.js +1 -1
  142. package/dist/src/index.d.ts +1284 -804
  143. package/dist/src/index.js +78 -5281
  144. package/dist/src/input/input-composed.d.ts +35 -0
  145. package/dist/src/input/input-composed.js +6 -0
  146. package/dist/src/label/label-composed.d.ts +32 -0
  147. package/dist/src/label/label-composed.js +6 -0
  148. package/dist/src/menu/menu-composed.d.ts +51 -0
  149. package/dist/src/menu/menu-composed.js +6 -0
  150. package/dist/src/menu/menu.js +1 -1
  151. package/dist/src/menubar/menubar-composed.d.ts +56 -0
  152. package/dist/src/menubar/menubar-composed.js +6 -0
  153. package/dist/src/menubar/menubar.js +1 -1
  154. package/dist/src/navigation-menu/navigation-menu-composed.d.ts +56 -0
  155. package/dist/src/navigation-menu/navigation-menu-composed.js +6 -0
  156. package/dist/src/navigation-menu/navigation-menu.js +1 -1
  157. package/dist/src/pagination/pagination-composed.d.ts +30 -0
  158. package/dist/src/pagination/pagination-composed.js +6 -0
  159. package/dist/src/popover/popover-composed.d.ts +36 -0
  160. package/dist/src/popover/popover-composed.js +6 -0
  161. package/dist/src/popover/popover.js +1 -1
  162. package/dist/src/progress/progress-composed.d.ts +17 -0
  163. package/dist/src/progress/progress-composed.js +6 -0
  164. package/dist/src/progress/progress.js +1 -1
  165. package/dist/src/radio/radio-composed.d.ts +24 -0
  166. package/dist/src/radio/radio-composed.js +6 -0
  167. package/dist/src/radio/radio.js +1 -1
  168. package/dist/src/resizable-panel/resizable-panel-composed.d.ts +33 -0
  169. package/dist/src/resizable-panel/resizable-panel-composed.js +6 -0
  170. package/dist/src/resizable-panel/resizable-panel.js +1 -1
  171. package/dist/src/scroll-area/scroll-area-composed.d.ts +17 -0
  172. package/dist/src/scroll-area/scroll-area-composed.js +6 -0
  173. package/dist/src/scroll-area/scroll-area.js +1 -1
  174. package/dist/src/select/select-composed.d.ts +53 -0
  175. package/dist/src/select/select-composed.js +6 -0
  176. package/dist/src/select/select.js +1 -1
  177. package/dist/src/separator/separator-composed.d.ts +32 -0
  178. package/dist/src/separator/separator-composed.js +6 -0
  179. package/dist/src/sheet/sheet-composed.d.ts +34 -0
  180. package/dist/src/sheet/sheet-composed.js +6 -0
  181. package/dist/src/sheet/sheet.js +1 -1
  182. package/dist/src/skeleton/skeleton-composed.d.ts +65 -0
  183. package/dist/src/skeleton/skeleton-composed.js +6 -0
  184. package/dist/src/slider/slider-composed.d.ts +22 -0
  185. package/dist/src/slider/slider-composed.js +6 -0
  186. package/dist/src/slider/slider.js +1 -1
  187. package/dist/src/switch/switch-composed.d.ts +17 -0
  188. package/dist/src/switch/switch-composed.js +6 -0
  189. package/dist/src/switch/switch.js +1 -1
  190. package/dist/src/table/table-composed.d.ts +34 -0
  191. package/dist/src/table/table-composed.js +6 -0
  192. package/dist/src/tabs/tabs-composed.d.ts +33 -0
  193. package/dist/src/tabs/tabs-composed.js +6 -0
  194. package/dist/src/tabs/tabs.js +1 -1
  195. package/dist/src/textarea/textarea-composed.d.ts +35 -0
  196. package/dist/src/textarea/textarea-composed.js +6 -0
  197. package/dist/src/toast/toast.js +1 -1
  198. package/dist/src/toggle/toggle-composed.d.ts +16 -0
  199. package/dist/src/toggle/toggle-composed.js +6 -0
  200. package/dist/src/toggle/toggle.js +1 -1
  201. package/dist/src/toggle-group/toggle-group-composed.d.ts +24 -0
  202. package/dist/src/toggle-group/toggle-group-composed.js +6 -0
  203. package/dist/src/toggle-group/toggle-group.js +1 -1
  204. package/dist/src/tooltip/tooltip-composed.d.ts +36 -0
  205. package/dist/src/tooltip/tooltip-composed.js +6 -0
  206. package/dist/src/tooltip/tooltip.js +1 -1
  207. package/dist/src/utils.js +1 -1
  208. package/package.json +3 -3
  209. package/dist/shared/chunk-07yzsaaw.js +0 -165
  210. package/dist/shared/chunk-279bzynx.js +0 -132
  211. package/dist/shared/chunk-27xs9apd.js +0 -288
  212. package/dist/shared/chunk-2k8gxzdf.js +0 -151
  213. package/dist/shared/chunk-3rp73gkd.js +0 -175
  214. package/dist/shared/chunk-4rf1m34c.js +0 -267
  215. package/dist/shared/chunk-56reyd5r.js +0 -64
  216. package/dist/shared/chunk-7bxsf80c.js +0 -60
  217. package/dist/shared/chunk-8qtexw5s.js +0 -199
  218. package/dist/shared/chunk-9ezgd78r.js +0 -142
  219. package/dist/shared/chunk-ajpj10z0.js +0 -282
  220. package/dist/shared/chunk-c46v0fsw.js +0 -117
  221. package/dist/shared/chunk-e4mm5e59.js +0 -178
  222. package/dist/shared/chunk-fqa5bwn1.js +0 -128
  223. package/dist/shared/chunk-g8hnc95b.js +0 -219
  224. package/dist/shared/chunk-j2tdpxgc.js +0 -185
  225. package/dist/shared/chunk-k8nabsxm.js +0 -330
  226. package/dist/shared/chunk-kcnq15je.js +0 -175
  227. package/dist/shared/chunk-mqs4qq0b.js +0 -46
  228. package/dist/shared/chunk-pg2yjn8f.js +0 -88
  229. package/dist/shared/chunk-rb53v045.js +0 -71
  230. package/dist/shared/chunk-s6a2yph8.js +0 -239
  231. package/dist/shared/chunk-vhx3sqw6.js +0 -196
  232. package/dist/shared/chunk-w318par6.js +0 -204
  233. package/dist/shared/chunk-wcdq7bew.js +0 -133
  234. package/dist/shared/chunk-z0gwkzgp.js +0 -34
  235. package/dist/shared/chunk-z850et33.js +0 -161
  236. package/dist/shared/chunk-zyfc6cx3.js +0 -61
@@ -0,0 +1,218 @@
1
+ import {
2
+ createDismiss
3
+ } from "./chunk-a6wp8c32.js";
4
+ import {
5
+ createFloatingPosition,
6
+ virtualElement
7
+ } from "./chunk-vef3sepw.js";
8
+ import {
9
+ Keys,
10
+ handleListNavigation,
11
+ isKey
12
+ } from "./chunk-7867pr13.js";
13
+ import {
14
+ setDataState,
15
+ setHidden,
16
+ setHiddenAnimated
17
+ } from "./chunk-vevfhpc9.js";
18
+ import {
19
+ uniqueId
20
+ } from "./chunk-8y1jf6xr.js";
21
+ import {
22
+ applyAttrs
23
+ } from "./chunk-2db2dnp3.js";
24
+
25
+ // src/context-menu/context-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 ContextMenuRoot(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
+ }, updateActiveItem = function(index) {
37
+ for (let i = 0;i < items.length; i++) {
38
+ items[i]?.setAttribute("tabindex", i === index ? "0" : "-1");
39
+ }
40
+ }, openMenu = function(x, y) {
41
+ state.open.value = true;
42
+ setHidden(content, false);
43
+ setDataState(content, "open");
44
+ if (positioning) {
45
+ const result = createFloatingPosition(virtualElement(x, y), content, {
46
+ strategy: "fixed",
47
+ ...positioning
48
+ });
49
+ floatingCleanup = result.cleanup;
50
+ dismissCleanup = createDismiss({
51
+ onDismiss: close,
52
+ insideElements: [trigger, content],
53
+ escapeKey: false
54
+ });
55
+ } else {
56
+ content.style.left = `${x}px`;
57
+ content.style.top = `${y}px`;
58
+ document.addEventListener("mousedown", handleClickOutside);
59
+ }
60
+ state.activeIndex.value = 0;
61
+ updateActiveItem(0);
62
+ items[0]?.focus();
63
+ }, close = function() {
64
+ state.open.value = false;
65
+ setDataState(content, "closed");
66
+ setHiddenAnimated(content, true);
67
+ if (positioning) {
68
+ floatingCleanup?.();
69
+ floatingCleanup = null;
70
+ dismissCleanup?.();
71
+ dismissCleanup = null;
72
+ } else {
73
+ document.removeEventListener("mousedown", handleClickOutside);
74
+ }
75
+ }, createItem = function(value, label) {
76
+ const item = (() => {
77
+ const __el2 = __element("div");
78
+ __el2.setAttribute("role", "menuitem");
79
+ {
80
+ const __v = value;
81
+ if (__v != null && __v !== false)
82
+ __el2.setAttribute("data-value", __v === true ? "" : __v);
83
+ }
84
+ __el2.setAttribute("tabindex", "-1");
85
+ __on(__el2, "click", () => {
86
+ onSelect?.(value);
87
+ close();
88
+ });
89
+ __enterChildren(__el2);
90
+ __insert(__el2, label ?? value);
91
+ __exitChildren();
92
+ return __el2;
93
+ })();
94
+ items.push(item);
95
+ return item;
96
+ }, Item = function(value, label) {
97
+ return createItem(value, label);
98
+ }, Group = function(label) {
99
+ const el = (() => {
100
+ const __el3 = __element("div");
101
+ __el3.setAttribute("role", "group");
102
+ {
103
+ const __v = label;
104
+ if (__v != null && __v !== false)
105
+ __el3.setAttribute("aria-label", __v === true ? "" : __v);
106
+ }
107
+ return __el3;
108
+ })();
109
+ return {
110
+ el,
111
+ Item: (value, itemLabel) => createItem(value, itemLabel)
112
+ };
113
+ }, Separator = function() {
114
+ return (() => {
115
+ const __el4 = __element("hr");
116
+ __el4.setAttribute("data-v-id", "ContextMenuRoot");
117
+ __el4.setAttribute("role", "separator");
118
+ return __el4;
119
+ })();
120
+ }, Label = function(text) {
121
+ return (() => {
122
+ const __el5 = __element("div");
123
+ __el5.setAttribute("role", "none");
124
+ __enterChildren(__el5);
125
+ __insert(__el5, text);
126
+ __exitChildren();
127
+ return __el5;
128
+ })();
129
+ };
130
+ const { onSelect, positioning, ...attrs } = options;
131
+ const state = {
132
+ open: signal(false),
133
+ activeIndex: signal(-1)
134
+ };
135
+ const items = [];
136
+ let floatingCleanup = null;
137
+ let dismissCleanup = null;
138
+ const trigger = (() => {
139
+ const __el0 = __element("div");
140
+ __on(__el0, "contextmenu", (event) => {
141
+ event.preventDefault();
142
+ if (state.open.peek()) {
143
+ close();
144
+ }
145
+ openMenu(event.clientX, event.clientY);
146
+ });
147
+ return __el0;
148
+ })();
149
+ const contentId = uniqueId("ctx-menu");
150
+ const content = (() => {
151
+ const __el1 = __element("div");
152
+ __el1.setAttribute("role", "menu");
153
+ {
154
+ const __v = contentId;
155
+ if (__v != null && __v !== false)
156
+ __el1.setAttribute("id", __v === true ? "" : __v);
157
+ }
158
+ {
159
+ const __v = { position: "fixed", display: "none" };
160
+ if (__v != null && __v !== false)
161
+ __el1.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
162
+ }
163
+ __el1.setAttribute("aria-hidden", "true");
164
+ __el1.setAttribute("data-state", "closed");
165
+ __on(__el1, "keydown", (event) => {
166
+ if (isKey(event, Keys.Escape)) {
167
+ event.preventDefault();
168
+ close();
169
+ return;
170
+ }
171
+ if (isKey(event, Keys.Enter, Keys.Space)) {
172
+ event.preventDefault();
173
+ const active = items[state.activeIndex.peek()];
174
+ if (active) {
175
+ const val = active.getAttribute("data-value");
176
+ if (val !== null) {
177
+ onSelect?.(val);
178
+ close();
179
+ }
180
+ }
181
+ return;
182
+ }
183
+ const result = handleListNavigation(event, items, { orientation: "vertical" });
184
+ if (result) {
185
+ const idx = items.indexOf(result);
186
+ if (idx >= 0) {
187
+ state.activeIndex.value = idx;
188
+ updateActiveItem(idx);
189
+ }
190
+ return;
191
+ }
192
+ if (event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey) {
193
+ const char = event.key.toLowerCase();
194
+ const match = items.find((item) => item.textContent?.toLowerCase().startsWith(char));
195
+ if (match) {
196
+ const idx = items.indexOf(match);
197
+ state.activeIndex.value = idx;
198
+ updateActiveItem(idx);
199
+ match.focus();
200
+ }
201
+ }
202
+ });
203
+ return __el1;
204
+ })();
205
+ applyAttrs(trigger, attrs);
206
+ const __mfResult0 = { trigger, content, state, Item, Group, Separator, Label };
207
+ __flushMountFrame();
208
+ return __mfResult0;
209
+ } catch (__mfErr) {
210
+ __discardMountFrame(__mfDepth);
211
+ throw __mfErr;
212
+ }
213
+ }
214
+ var ContextMenu = {
215
+ Root: ContextMenuRoot
216
+ };
217
+
218
+ export { ContextMenu };
@@ -0,0 +1,258 @@
1
+ import {
2
+ cn
3
+ } from "./chunk-q7xbcj9q.js";
4
+
5
+ // src/resizable-panel/resizable-panel-composed.tsx
6
+ import { computed, signal } from "@vertz/ui";
7
+ import { __append, __attr, __child, __discardMountFrame, __element, __enterChildren, __exitChildren, __flushMountFrame, __on, __pushMountFrame, __styleStr } from "@vertz/ui/internals";
8
+ import { createContext, useContext } from "@vertz/ui";
9
+ var _groupCounter = { value: 0 };
10
+ var ResizablePanelContext = createContext(undefined, "@vertz/ui-primitives::ResizablePanelContext");
11
+ function ResizablePanelPanel(__props) {
12
+ const __mfDepth = __pushMountFrame();
13
+ try {
14
+ const ctx = useContext(ResizablePanelContext);
15
+ if (!ctx) {
16
+ throw new Error("<ResizablePanel.Panel> must be used inside <ResizablePanel>. " + "Ensure it is a direct or nested child of the ResizablePanel root component.");
17
+ }
18
+ const index = computed(() => ctx.registerPanel({ defaultSize: __props.defaultSize, minSize: __props.minSize, maxSize: __props.maxSize }));
19
+ const __mfResult0 = (() => {
20
+ const __el0 = __element("div");
21
+ __el0.setAttribute("data-part", "panel");
22
+ __attr(__el0, "data-group", () => ctx.groupId);
23
+ __attr(__el0, "style", () => ({ flex: `${ctx.getSizeForPanel(index.value)} 1 0`, minWidth: 0, minHeight: 0 }));
24
+ __attr(__el0, "class", () => cn(ctx.classes?.panel, __props.className ?? __props.class));
25
+ __enterChildren(__el0);
26
+ __append(__el0, __child(() => __props.children));
27
+ __exitChildren();
28
+ return __el0;
29
+ })();
30
+ __flushMountFrame();
31
+ return __mfResult0;
32
+ } catch (__mfErr) {
33
+ __discardMountFrame(__mfDepth);
34
+ throw __mfErr;
35
+ }
36
+ }
37
+ function ResizablePanelHandle(__props) {
38
+ const __mfDepth = __pushMountFrame();
39
+ try {
40
+ const ctx = useContext(ResizablePanelContext);
41
+ if (!ctx) {
42
+ throw new Error("<ResizablePanel.Handle> must be used inside <ResizablePanel>. " + "Ensure it is a direct or nested child of the ResizablePanel root component.");
43
+ }
44
+ const handleIndex = computed(() => ctx.registerHandle());
45
+ const __mfResult0 = (() => {
46
+ const __el0 = __element("div");
47
+ __el0.setAttribute("role", "separator");
48
+ __el0.setAttribute("tabindex", "0");
49
+ {
50
+ const __v = { flexShrink: 0 };
51
+ if (__v != null && __v !== false)
52
+ __el0.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
53
+ }
54
+ __attr(__el0, "data-group", () => ctx.groupId);
55
+ __attr(__el0, "data-handle-index", () => String(handleIndex.value));
56
+ __attr(__el0, "data-orientation", () => ctx.orientation);
57
+ __el0.setAttribute("data-state", "idle");
58
+ __attr(__el0, "aria-valuenow", () => String(ctx.getAriaForHandle(handleIndex.value).valuenow));
59
+ __attr(__el0, "aria-valuemin", () => String(ctx.getAriaForHandle(handleIndex.value).valuemin));
60
+ __attr(__el0, "aria-valuemax", () => String(ctx.getAriaForHandle(handleIndex.value).valuemax));
61
+ __attr(__el0, "class", () => cn(ctx.classes?.handle, __props.className ?? __props.class));
62
+ return __el0;
63
+ })();
64
+ __flushMountFrame();
65
+ return __mfResult0;
66
+ } catch (__mfErr) {
67
+ __discardMountFrame(__mfDepth);
68
+ throw __mfErr;
69
+ }
70
+ }
71
+ function ComposedResizablePanelRoot(__props) {
72
+ const __mfDepth = __pushMountFrame();
73
+ try {
74
+ let recomputeSizes = function() {
75
+ const configs = _reg.panelConfigs;
76
+ const panelCount = configs.length;
77
+ if (panelCount === 0)
78
+ return;
79
+ const newSizes = new Array(panelCount).fill(0);
80
+ const explicitIndices = new Set;
81
+ for (let i = 0;i < panelCount; i++) {
82
+ const config = configs[i];
83
+ if (config && config.defaultSize != null) {
84
+ newSizes[i] = config.defaultSize;
85
+ explicitIndices.add(i);
86
+ }
87
+ }
88
+ if (explicitIndices.size === 0) {
89
+ const equal = 100 / panelCount;
90
+ for (let i = 0;i < panelCount; i++)
91
+ newSizes[i] = equal;
92
+ } else {
93
+ const used = [...explicitIndices].reduce((sum, i) => sum + (newSizes[i] ?? 0), 0);
94
+ const unsetCount = panelCount - explicitIndices.size;
95
+ const each = unsetCount > 0 ? (100 - used) / unsetCount : 0;
96
+ for (let i = 0;i < newSizes.length; i++) {
97
+ if (!explicitIndices.has(i))
98
+ newSizes[i] = each;
99
+ }
100
+ }
101
+ sizes.value = newSizes;
102
+ }, registerPanel = function(opts) {
103
+ const idx = _reg.nextPanelIdx++;
104
+ _reg.panelConfigs.push({
105
+ defaultSize: opts.defaultSize,
106
+ minSize: opts.minSize ?? 0,
107
+ maxSize: opts.maxSize ?? 100
108
+ });
109
+ recomputeSizes();
110
+ return idx;
111
+ }, registerHandle = function() {
112
+ return _reg.nextHandleIdx++;
113
+ }, getSizeForPanel = function(index) {
114
+ return sizes.value[index] ?? 0;
115
+ }, getAriaForHandle = function(handleIndex) {
116
+ const config = _reg.panelConfigs[handleIndex];
117
+ return {
118
+ valuenow: Math.round(sizes.value[handleIndex] ?? 0),
119
+ valuemin: Math.round(config?.minSize ?? 0),
120
+ valuemax: Math.round(config?.maxSize ?? 100)
121
+ };
122
+ }, updateSizes = function(newSizes) {
123
+ sizes.value = [...newSizes];
124
+ __props.onResize?.(newSizes);
125
+ }, handleKeydown = function(e) {
126
+ const ke = e;
127
+ const target = ke.target;
128
+ if (target.getAttribute("role") !== "separator")
129
+ return;
130
+ if (target.dataset.group !== groupId)
131
+ return;
132
+ const handleIndex = Number(target.dataset.handleIndex ?? -1);
133
+ if (handleIndex < 0)
134
+ return;
135
+ const leftIdx = handleIndex;
136
+ const rightIdx = handleIndex + 1;
137
+ const leftConfig = _reg.panelConfigs[leftIdx];
138
+ const rightConfig = _reg.panelConfigs[rightIdx];
139
+ if (!leftConfig || !rightConfig)
140
+ return;
141
+ const leftStart = sizes.value[leftIdx] ?? 0;
142
+ const rightStart = sizes.value[rightIdx] ?? 0;
143
+ const STEP = 5;
144
+ const growKey = (__props.orientation ?? "horizontal") === "horizontal" ? "ArrowRight" : "ArrowDown";
145
+ const shrinkKey = (__props.orientation ?? "horizontal") === "horizontal" ? "ArrowLeft" : "ArrowUp";
146
+ let newLeft = leftStart;
147
+ let newRight = rightStart;
148
+ if (ke.key === growKey) {
149
+ ke.preventDefault();
150
+ const delta = Math.min(STEP, rightStart - rightConfig.minSize, leftConfig.maxSize - leftStart);
151
+ newLeft += delta;
152
+ newRight -= delta;
153
+ } else if (ke.key === shrinkKey) {
154
+ ke.preventDefault();
155
+ const delta = Math.min(STEP, leftStart - leftConfig.minSize, rightConfig.maxSize - rightStart);
156
+ newLeft -= delta;
157
+ newRight += delta;
158
+ } else if (ke.key === "Home") {
159
+ ke.preventDefault();
160
+ const delta = leftStart - leftConfig.minSize;
161
+ newLeft -= delta;
162
+ newRight += delta;
163
+ } else if (ke.key === "End") {
164
+ ke.preventDefault();
165
+ const delta = rightStart - rightConfig.minSize;
166
+ newLeft += delta;
167
+ newRight -= delta;
168
+ } else {
169
+ return;
170
+ }
171
+ const newSizes = sizes.value.slice();
172
+ newSizes[leftIdx] = newLeft;
173
+ newSizes[rightIdx] = newRight;
174
+ updateSizes(newSizes);
175
+ }, handlePointerdown = function(e) {
176
+ const pe = e;
177
+ const target = pe.target;
178
+ if (target.getAttribute("role") !== "separator")
179
+ return;
180
+ if (target.dataset.group !== groupId)
181
+ return;
182
+ pe.preventDefault();
183
+ target.setPointerCapture(pe.pointerId);
184
+ target.setAttribute("data-state", "dragging");
185
+ const handleIndex = Number(target.dataset.handleIndex ?? -1);
186
+ const rootEl = pe.currentTarget;
187
+ const startPos = (__props.orientation ?? "horizontal") === "horizontal" ? pe.clientX : pe.clientY;
188
+ const rootSize = (__props.orientation ?? "horizontal") === "horizontal" ? rootEl.offsetWidth : rootEl.offsetHeight;
189
+ const startSizes = sizes.value.slice();
190
+ function onMove(ev) {
191
+ const currentPos = (__props.orientation ?? "horizontal") === "horizontal" ? ev.clientX : ev.clientY;
192
+ const delta = (currentPos - startPos) / rootSize * 100;
193
+ const moveSizes = startSizes.slice();
194
+ const leftIdx = handleIndex;
195
+ const rightIdx = handleIndex + 1;
196
+ const leftConfig = _reg.panelConfigs[leftIdx];
197
+ const rightConfig = _reg.panelConfigs[rightIdx];
198
+ if (!leftConfig || !rightConfig)
199
+ return;
200
+ const rawLeft = Math.max(leftConfig.minSize, Math.min(leftConfig.maxSize, (startSizes[leftIdx] ?? 0) + delta));
201
+ const rawRight = Math.max(rightConfig.minSize, Math.min(rightConfig.maxSize, (startSizes[rightIdx] ?? 0) - delta));
202
+ moveSizes[leftIdx] = rawLeft;
203
+ moveSizes[rightIdx] = rawRight;
204
+ updateSizes(moveSizes);
205
+ }
206
+ function onUp(ev) {
207
+ target.releasePointerCapture(ev.pointerId);
208
+ target.setAttribute("data-state", "idle");
209
+ target.removeEventListener("pointermove", onMove);
210
+ target.removeEventListener("pointerup", onUp);
211
+ }
212
+ target.addEventListener("pointermove", onMove);
213
+ target.addEventListener("pointerup", onUp);
214
+ };
215
+ const groupId = String(_groupCounter.value++);
216
+ const _reg = {
217
+ nextPanelIdx: 0,
218
+ nextHandleIdx: 0,
219
+ panelConfigs: []
220
+ };
221
+ const sizes = signal([], "sizes");
222
+ const ctx = {
223
+ groupId,
224
+ orientation: __props.orientation ?? "horizontal",
225
+ classes: __props.classes,
226
+ registerPanel,
227
+ registerHandle,
228
+ getSizeForPanel,
229
+ getAriaForHandle
230
+ };
231
+ const __mfResult0 = ResizablePanelContext.Provider({ get value() {
232
+ return ctx;
233
+ }, children: () => (() => {
234
+ const __el0 = __element("div");
235
+ __attr(__el0, "style", () => ({ display: "flex", flexDirection: (__props.orientation ?? "horizontal") === "horizontal" ? "row" : "column" }));
236
+ __attr(__el0, "data-orientation", () => __props.orientation ?? "horizontal");
237
+ __attr(__el0, "data-panel-count", () => sizes.value.length);
238
+ __attr(__el0, "class", () => __props.classes?.root);
239
+ __on(__el0, "keydown", handleKeydown);
240
+ __on(__el0, "pointerdown", handlePointerdown);
241
+ __enterChildren(__el0);
242
+ __append(__el0, __child(() => __props.children));
243
+ __exitChildren();
244
+ return __el0;
245
+ })() });
246
+ __flushMountFrame();
247
+ return __mfResult0;
248
+ } catch (__mfErr) {
249
+ __discardMountFrame(__mfDepth);
250
+ throw __mfErr;
251
+ }
252
+ }
253
+ var ComposedResizablePanel = Object.assign(ComposedResizablePanelRoot, {
254
+ Panel: ResizablePanelPanel,
255
+ Handle: ResizablePanelHandle
256
+ });
257
+
258
+ export { ComposedResizablePanel };