@vertz/ui-primitives 0.2.38 → 0.2.42

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 (233) hide show
  1. package/dist/shared/chunk-06m8prfg.js +52 -0
  2. package/dist/shared/chunk-0n9jj8xr.js +24 -0
  3. package/dist/shared/chunk-1ben27xq.js +317 -0
  4. package/dist/shared/chunk-1j2mj0sa.js +45 -0
  5. package/dist/shared/chunk-250hj18f.js +243 -0
  6. package/dist/shared/chunk-2h4m9c71.js +38 -0
  7. package/dist/shared/chunk-2sbx20hv.js +128 -0
  8. package/dist/shared/chunk-2ye674gr.js +70 -0
  9. package/dist/shared/chunk-34d8385y.js +15 -0
  10. package/dist/shared/chunk-4d7bm8h0.js +113 -0
  11. package/dist/shared/chunk-4zjgxr7x.js +157 -0
  12. package/dist/shared/chunk-5c150wvr.js +140 -0
  13. package/dist/shared/chunk-5gycdypd.js +58 -0
  14. package/dist/shared/chunk-6mm7fhp8.js +105 -0
  15. package/dist/shared/chunk-6zmnqvh6.js +109 -0
  16. package/dist/shared/{chunk-yy3ft5mb.js → chunk-7amn5d71.js} +2 -2
  17. package/dist/shared/chunk-7pbff2hg.js +118 -0
  18. package/dist/shared/chunk-7zpjshwz.js +194 -0
  19. package/dist/shared/chunk-993ff51d.js +155 -0
  20. package/dist/shared/chunk-9pdt5aw7.js +24 -0
  21. package/dist/shared/chunk-a71m4xkv.js +106 -0
  22. package/dist/shared/chunk-aj8m39pk.js +127 -0
  23. package/dist/shared/chunk-ajawpc05.js +305 -0
  24. package/dist/shared/chunk-b7mzwqhj.js +125 -0
  25. package/dist/shared/chunk-bb887de4.js +200 -0
  26. package/dist/shared/chunk-bfsmbrxc.js +111 -0
  27. package/dist/shared/chunk-c2f63m5n.js +56 -0
  28. package/dist/shared/chunk-c5r3s5km.js +263 -0
  29. package/dist/shared/chunk-caba5bhd.js +427 -0
  30. package/dist/shared/chunk-crym07yc.js +264 -0
  31. package/dist/shared/{chunk-5964gmv0.js → chunk-csjtyvam.js} +62 -88
  32. package/dist/shared/chunk-d6rtejz3.js +128 -0
  33. package/dist/shared/chunk-dvaf0bmq.js +140 -0
  34. package/dist/shared/chunk-dwkv9ya6.js +22 -0
  35. package/dist/shared/chunk-e0ckxrjg.js +41 -0
  36. package/dist/shared/chunk-ennxcymj.js +225 -0
  37. package/dist/shared/{chunk-1jd1n0dt.js → chunk-ey38de46.js} +19 -47
  38. package/dist/shared/chunk-f0v1gs5e.js +52 -0
  39. package/dist/shared/chunk-f86rsf84.js +231 -0
  40. package/dist/shared/chunk-fdse46x5.js +21 -0
  41. package/dist/shared/chunk-gj4hrssn.js +135 -0
  42. package/dist/shared/chunk-gyvq4gk9.js +24 -0
  43. package/dist/shared/chunk-hbnps9sq.js +229 -0
  44. package/dist/shared/{chunk-fhss32ya.js → chunk-hdmpyeq9.js} +43 -132
  45. package/dist/shared/chunk-hgnkd4he.js +256 -0
  46. package/dist/shared/chunk-hpcyffm7.js +185 -0
  47. package/dist/shared/chunk-hpmvwx0h.js +99 -0
  48. package/dist/shared/chunk-hz0e504p.js +69 -0
  49. package/dist/shared/chunk-hzk4wfq9.js +43 -0
  50. package/dist/shared/chunk-j7znzkpa.js +48 -0
  51. package/dist/shared/chunk-j9kxgrnn.js +167 -0
  52. package/dist/shared/chunk-jetwnv0w.js +130 -0
  53. package/dist/shared/chunk-jjdg26c1.js +155 -0
  54. package/dist/shared/chunk-k0m4yh86.js +123 -0
  55. package/dist/shared/chunk-k43q9cjr.js +82 -0
  56. package/dist/shared/chunk-k9k8tbr5.js +119 -0
  57. package/dist/shared/chunk-meaj7br1.js +232 -0
  58. package/dist/shared/chunk-mgj0n08k.js +34 -0
  59. package/dist/shared/chunk-mjz4rp6c.js +46 -0
  60. package/dist/shared/chunk-n4rr5gme.js +239 -0
  61. package/dist/shared/chunk-nk55etpp.js +65 -0
  62. package/dist/shared/chunk-nkh1ks3k.js +264 -0
  63. package/dist/shared/chunk-pgvpvbpe.js +26 -0
  64. package/dist/shared/chunk-pma8gnv7.js +178 -0
  65. package/dist/shared/chunk-q7xv6xze.js +131 -0
  66. package/dist/shared/chunk-qey801nq.js +22 -0
  67. package/dist/shared/chunk-s6b4c3tj.js +58 -0
  68. package/dist/shared/chunk-sq27a4h0.js +36 -0
  69. package/dist/shared/chunk-taa5pj15.js +103 -0
  70. package/dist/shared/chunk-tc5rpvyx.js +127 -0
  71. package/dist/shared/chunk-tescm0b3.js +192 -0
  72. package/dist/shared/chunk-tkftdwnq.js +71 -0
  73. package/dist/shared/chunk-tqhnjcfp.js +116 -0
  74. package/dist/shared/chunk-vfknb5ht.js +183 -0
  75. package/dist/shared/chunk-vsc369w3.js +185 -0
  76. package/dist/shared/chunk-whq9s8v5.js +301 -0
  77. package/dist/shared/{chunk-hze1f32t.js → chunk-wrqddgaj.js} +1 -1
  78. package/dist/shared/chunk-yzbmkx4r.js +155 -0
  79. package/dist/shared/chunk-zaen0ajc.js +347 -0
  80. package/dist/src/accordion/accordion-composed.js +1 -1
  81. package/dist/src/accordion/accordion.js +1 -1
  82. package/dist/src/alert/alert-composed.js +1 -1
  83. package/dist/src/alert-dialog/alert-dialog-composed.js +1 -1
  84. package/dist/src/alert-dialog/alert-dialog.js +1 -1
  85. package/dist/src/avatar/avatar-composed.js +1 -1
  86. package/dist/src/badge/badge-composed.js +1 -1
  87. package/dist/src/badge/badge.js +1 -1
  88. package/dist/src/breadcrumb/breadcrumb-composed.js +1 -1
  89. package/dist/src/button/button-composed.js +1 -1
  90. package/dist/src/button/button.js +1 -1
  91. package/dist/src/calendar/calendar-composed.js +1 -1
  92. package/dist/src/calendar/calendar.js +1 -1
  93. package/dist/src/card/card-composed.js +1 -1
  94. package/dist/src/carousel/carousel-composed.js +1 -1
  95. package/dist/src/carousel/carousel.js +1 -1
  96. package/dist/src/checkbox/checkbox-composed.js +1 -1
  97. package/dist/src/checkbox/checkbox.js +1 -1
  98. package/dist/src/collapsible/collapsible-composed.js +1 -1
  99. package/dist/src/collapsible/collapsible.js +1 -1
  100. package/dist/src/combobox/combobox-composed.js +1 -1
  101. package/dist/src/combobox/combobox.js +1 -1
  102. package/dist/src/command/command-composed.js +1 -1
  103. package/dist/src/command/command.js +1 -1
  104. package/dist/src/composed/with-styles.js +1 -1
  105. package/dist/src/context-menu/context-menu-composed.js +1 -1
  106. package/dist/src/context-menu/context-menu.js +1 -1
  107. package/dist/src/date-picker/date-picker-composed.js +1 -1
  108. package/dist/src/date-picker/date-picker.js +1 -1
  109. package/dist/src/dialog/dialog-composed.js +1 -1
  110. package/dist/src/dialog/dialog-stack-parts.js +1 -1
  111. package/dist/src/dialog/dialog.js +1 -1
  112. package/dist/src/dropdown-menu/dropdown-menu-composed.js +1 -1
  113. package/dist/src/dropdown-menu/dropdown-menu.js +1 -1
  114. package/dist/src/empty-state/empty-state-composed.js +1 -1
  115. package/dist/src/form-group/form-group-composed.js +1 -1
  116. package/dist/src/hover-card/hover-card-composed.js +1 -1
  117. package/dist/src/hover-card/hover-card.js +1 -1
  118. package/dist/src/input/input-composed.js +1 -1
  119. package/dist/src/label/label-composed.js +1 -1
  120. package/dist/src/list/list-composed.js +1 -1
  121. package/dist/src/menu/menu-composed.js +1 -1
  122. package/dist/src/menu/menu.js +1 -1
  123. package/dist/src/menubar/menubar-composed.js +1 -1
  124. package/dist/src/menubar/menubar.js +1 -1
  125. package/dist/src/navigation-menu/navigation-menu-composed.js +1 -1
  126. package/dist/src/navigation-menu/navigation-menu.js +1 -1
  127. package/dist/src/pagination/pagination-composed.js +1 -1
  128. package/dist/src/popover/popover-composed.js +1 -1
  129. package/dist/src/popover/popover.js +1 -1
  130. package/dist/src/progress/progress-composed.js +1 -1
  131. package/dist/src/progress/progress.js +1 -1
  132. package/dist/src/radio/radio-composed.js +1 -1
  133. package/dist/src/radio/radio.js +1 -1
  134. package/dist/src/resizable-panel/resizable-panel-composed.js +1 -1
  135. package/dist/src/resizable-panel/resizable-panel.js +1 -1
  136. package/dist/src/scroll-area/scroll-area-composed.js +1 -1
  137. package/dist/src/scroll-area/scroll-area.js +1 -1
  138. package/dist/src/select/select-composed.js +1 -1
  139. package/dist/src/select/select.js +1 -1
  140. package/dist/src/separator/separator-composed.js +1 -1
  141. package/dist/src/sheet/sheet-composed.js +1 -1
  142. package/dist/src/sheet/sheet.js +1 -1
  143. package/dist/src/skeleton/skeleton-composed.js +1 -1
  144. package/dist/src/slider/slider-composed.js +1 -1
  145. package/dist/src/slider/slider.js +1 -1
  146. package/dist/src/switch/switch-composed.js +1 -1
  147. package/dist/src/switch/switch.js +1 -1
  148. package/dist/src/table/table-composed.js +1 -1
  149. package/dist/src/tabs/tabs-composed.js +1 -1
  150. package/dist/src/tabs/tabs.js +1 -1
  151. package/dist/src/textarea/textarea-composed.js +1 -1
  152. package/dist/src/toast/toast.js +1 -1
  153. package/dist/src/toggle/toggle-composed.js +1 -1
  154. package/dist/src/toggle/toggle.js +1 -1
  155. package/dist/src/toggle-group/toggle-group-composed.js +1 -1
  156. package/dist/src/toggle-group/toggle-group.js +1 -1
  157. package/dist/src/tooltip/tooltip-composed.js +1 -1
  158. package/dist/src/tooltip/tooltip.js +1 -1
  159. package/package.json +3 -3
  160. package/dist/shared/chunk-144kbnmx.js +0 -95
  161. package/dist/shared/chunk-1ewxfgsa.js +0 -167
  162. package/dist/shared/chunk-1hm0mbke.js +0 -258
  163. package/dist/shared/chunk-22rt6ws9.js +0 -69
  164. package/dist/shared/chunk-2ssqz188.js +0 -162
  165. package/dist/shared/chunk-33he7ay9.js +0 -218
  166. package/dist/shared/chunk-3jack97k.js +0 -509
  167. package/dist/shared/chunk-75pegjs7.js +0 -26
  168. package/dist/shared/chunk-862x7dja.js +0 -398
  169. package/dist/shared/chunk-8pk1pn5h.js +0 -215
  170. package/dist/shared/chunk-8t0nm721.js +0 -152
  171. package/dist/shared/chunk-94twh4s4.js +0 -28
  172. package/dist/shared/chunk-9yb26c0w.js +0 -232
  173. package/dist/shared/chunk-a82r2pnq.js +0 -67
  174. package/dist/shared/chunk-axpbdpgx.js +0 -177
  175. package/dist/shared/chunk-b3j6mym6.js +0 -203
  176. package/dist/shared/chunk-b4zzg457.js +0 -410
  177. package/dist/shared/chunk-b9qxfcsy.js +0 -60
  178. package/dist/shared/chunk-bc2qqkhr.js +0 -194
  179. package/dist/shared/chunk-bv12nkdm.js +0 -149
  180. package/dist/shared/chunk-bvxc1ww4.js +0 -164
  181. package/dist/shared/chunk-czv0kqj4.js +0 -107
  182. package/dist/shared/chunk-d83ag07h.js +0 -189
  183. package/dist/shared/chunk-de18ashk.js +0 -134
  184. package/dist/shared/chunk-dvk4h36t.js +0 -140
  185. package/dist/shared/chunk-dxvnerw2.js +0 -353
  186. package/dist/shared/chunk-e399pzdq.js +0 -241
  187. package/dist/shared/chunk-e4qha9as.js +0 -180
  188. package/dist/shared/chunk-eb2d9v6k.js +0 -68
  189. package/dist/shared/chunk-ect26sp5.js +0 -353
  190. package/dist/shared/chunk-ev367pq3.js +0 -102
  191. package/dist/shared/chunk-fjykbv0v.js +0 -214
  192. package/dist/shared/chunk-gdddk6nh.js +0 -96
  193. package/dist/shared/chunk-ghkw5bjq.js +0 -55
  194. package/dist/shared/chunk-hfjtkytb.js +0 -310
  195. package/dist/shared/chunk-hpvjfj0j.js +0 -31
  196. package/dist/shared/chunk-jpyjk616.js +0 -52
  197. package/dist/shared/chunk-k6d53tne.js +0 -206
  198. package/dist/shared/chunk-knzg86am.js +0 -168
  199. package/dist/shared/chunk-ktbf6xrt.js +0 -179
  200. package/dist/shared/chunk-m8y2p66x.js +0 -252
  201. package/dist/shared/chunk-metxdt5x.js +0 -28
  202. package/dist/shared/chunk-mgae1d93.js +0 -157
  203. package/dist/shared/chunk-mtx2cfbx.js +0 -175
  204. package/dist/shared/chunk-n436p5cb.js +0 -260
  205. package/dist/shared/chunk-nj420k31.js +0 -54
  206. package/dist/shared/chunk-nsmvdxgp.js +0 -213
  207. package/dist/shared/chunk-pcms04vq.js +0 -162
  208. package/dist/shared/chunk-pqskzq8t.js +0 -79
  209. package/dist/shared/chunk-pwr60kyd.js +0 -321
  210. package/dist/shared/chunk-pzknpa1y.js +0 -327
  211. package/dist/shared/chunk-q77y3rg4.js +0 -189
  212. package/dist/shared/chunk-qhnany7w.js +0 -179
  213. package/dist/shared/chunk-r3pffzss.js +0 -13
  214. package/dist/shared/chunk-rdr0rtpr.js +0 -131
  215. package/dist/shared/chunk-rj52ty6r.js +0 -147
  216. package/dist/shared/chunk-rnqc7735.js +0 -125
  217. package/dist/shared/chunk-rtk30950.js +0 -202
  218. package/dist/shared/chunk-s0xgd8vg.js +0 -266
  219. package/dist/shared/chunk-s415735j.js +0 -357
  220. package/dist/shared/chunk-s62e7jf4.js +0 -30
  221. package/dist/shared/chunk-snd8e6r8.js +0 -418
  222. package/dist/shared/chunk-spng4yb9.js +0 -73
  223. package/dist/shared/chunk-t887wwjc.js +0 -168
  224. package/dist/shared/chunk-tn0m98j8.js +0 -42
  225. package/dist/shared/chunk-v0b5pkcq.js +0 -30
  226. package/dist/shared/chunk-v5tj7veh.js +0 -284
  227. package/dist/shared/chunk-vkscwzpr.js +0 -294
  228. package/dist/shared/chunk-vv187snj.js +0 -112
  229. package/dist/shared/chunk-xv4wd0kf.js +0 -293
  230. package/dist/shared/chunk-y1hpsqzy.js +0 -185
  231. package/dist/shared/chunk-yfzddvxc.js +0 -71
  232. package/dist/shared/chunk-yzgzx2dh.js +0 -311
  233. package/dist/shared/chunk-z5j7ztf2.js +0 -467
@@ -1,203 +0,0 @@
1
- import {
2
- linkedIds
3
- } from "./chunk-8y1jf6xr.js";
4
- import {
5
- Keys,
6
- isKey
7
- } from "./chunk-7867pr13.js";
8
- import {
9
- setDataState,
10
- setExpanded,
11
- setHidden,
12
- setHiddenAnimated,
13
- setSelected
14
- } from "./chunk-vevfhpc9.js";
15
- import {
16
- applyAttrs
17
- } from "./chunk-2db2dnp3.js";
18
-
19
- // src/combobox/combobox.tsx
20
- import { __discardMountFrame, __element, __enterChildren, __exitChildren, __flushMountFrame, __insert, __on, __pushMountFrame, __styleStr } from "@vertz/ui/internals";
21
- import { signal } from "@vertz/ui";
22
- function ComboboxRoot(options = {}) {
23
- const __mfDepth = __pushMountFrame();
24
- try {
25
- let open = function() {
26
- state.open.value = true;
27
- setExpanded(input, true);
28
- setHidden(listbox, false);
29
- setDataState(listbox, "open");
30
- }, close = function() {
31
- state.open.value = false;
32
- state.activeIndex.value = -1;
33
- setExpanded(input, false);
34
- setDataState(listbox, "closed");
35
- setHiddenAnimated(listbox, true);
36
- updateActiveDescendant(-1);
37
- }, selectOption = function(value) {
38
- state.value.value = value;
39
- state.inputValue.value = value;
40
- input.value = value;
41
- for (const opt of optionElements) {
42
- const isActive = opt.getAttribute("data-value") === value;
43
- setSelected(opt, isActive);
44
- setDataState(opt, isActive ? "active" : "inactive");
45
- }
46
- onValueChange?.(value);
47
- close();
48
- input.focus();
49
- }, updateActiveDescendant = function(index) {
50
- const opt = optionElements[index];
51
- if (index >= 0 && opt) {
52
- input.setAttribute("aria-activedescendant", opt.id);
53
- for (let i = 0;i < optionElements.length; i++) {
54
- const el = optionElements[i];
55
- if (el)
56
- setDataState(el, i === index ? "active" : "inactive");
57
- }
58
- } else {
59
- input.removeAttribute("aria-activedescendant");
60
- }
61
- }, Option = function(value, label) {
62
- const optId = `${ids.contentId}-opt-${optionElements.length}`;
63
- const isSelectedOpt = value === defaultValue;
64
- const opt = (() => {
65
- const __el2 = __element("div");
66
- __el2.setAttribute("role", "option");
67
- {
68
- const __v = optId;
69
- if (__v != null && __v !== false)
70
- __el2.setAttribute("id", __v === true ? "" : __v);
71
- }
72
- {
73
- const __v = value;
74
- if (__v != null && __v !== false)
75
- __el2.setAttribute("data-value", __v === true ? "" : __v);
76
- }
77
- {
78
- const __v = isSelectedOpt ? "true" : "false";
79
- if (__v != null && __v !== false)
80
- __el2.setAttribute("aria-selected", __v === true ? "" : __v);
81
- }
82
- {
83
- const __v = isSelectedOpt ? "active" : "inactive";
84
- if (__v != null && __v !== false)
85
- __el2.setAttribute("data-state", __v === true ? "" : __v);
86
- }
87
- __on(__el2, "click", () => selectOption(value));
88
- __enterChildren(__el2);
89
- __insert(__el2, label ?? value);
90
- __exitChildren();
91
- return __el2;
92
- })();
93
- optionElements.push(opt);
94
- return opt;
95
- };
96
- const { defaultValue = "", onValueChange, onInputChange, ...attrs } = options;
97
- const ids = linkedIds("combobox");
98
- const state = {
99
- open: signal(false),
100
- value: signal(defaultValue),
101
- inputValue: signal(defaultValue),
102
- activeIndex: signal(-1)
103
- };
104
- const optionElements = [];
105
- const input = (() => {
106
- const __el0 = __element("input");
107
- __el0.setAttribute("type", "text");
108
- __el0.setAttribute("role", "combobox");
109
- __el0.setAttribute("aria-autocomplete", "list");
110
- {
111
- const __v = ids.contentId;
112
- if (__v != null && __v !== false)
113
- __el0.setAttribute("aria-controls", __v === true ? "" : __v);
114
- }
115
- __el0.setAttribute("aria-haspopup", "listbox");
116
- {
117
- const __v = ids.triggerId;
118
- if (__v != null && __v !== false)
119
- __el0.setAttribute("id", __v === true ? "" : __v);
120
- }
121
- {
122
- const __v = defaultValue;
123
- if (__v != null)
124
- __el0.value = __v;
125
- }
126
- __el0.setAttribute("aria-expanded", "false");
127
- __on(__el0, "input", () => {
128
- state.inputValue.value = input.value;
129
- onInputChange?.(input.value);
130
- if (!state.open.peek())
131
- open();
132
- });
133
- __on(__el0, "focus", () => {
134
- if (!state.open.peek() && input.value.length > 0)
135
- open();
136
- });
137
- __on(__el0, "keydown", (event) => {
138
- if (isKey(event, Keys.Escape)) {
139
- event.preventDefault();
140
- close();
141
- return;
142
- }
143
- if (isKey(event, Keys.ArrowDown)) {
144
- event.preventDefault();
145
- if (!state.open.peek()) {
146
- open();
147
- }
148
- const next = Math.min(state.activeIndex.peek() + 1, optionElements.length - 1);
149
- state.activeIndex.value = next;
150
- updateActiveDescendant(next);
151
- return;
152
- }
153
- if (isKey(event, Keys.ArrowUp)) {
154
- event.preventDefault();
155
- const prev = Math.max(state.activeIndex.peek() - 1, 0);
156
- state.activeIndex.value = prev;
157
- updateActiveDescendant(prev);
158
- return;
159
- }
160
- if (isKey(event, Keys.Enter)) {
161
- event.preventDefault();
162
- const idx = state.activeIndex.peek();
163
- if (idx >= 0 && idx < optionElements.length) {
164
- const val = optionElements[idx]?.getAttribute("data-value");
165
- if (val != null)
166
- selectOption(val);
167
- }
168
- return;
169
- }
170
- });
171
- return __el0;
172
- })();
173
- const listbox = (() => {
174
- const __el1 = __element("div");
175
- __el1.setAttribute("role", "listbox");
176
- {
177
- const __v = ids.contentId;
178
- if (__v != null && __v !== false)
179
- __el1.setAttribute("id", __v === true ? "" : __v);
180
- }
181
- __el1.setAttribute("aria-hidden", "true");
182
- __el1.setAttribute("data-state", "closed");
183
- {
184
- const __v = { display: "none" };
185
- if (__v != null && __v !== false)
186
- __el1.setAttribute("style", typeof __v === "object" ? __styleStr(__v) : __v === true ? "" : String(__v));
187
- }
188
- return __el1;
189
- })();
190
- applyAttrs(input, attrs);
191
- const __mfResult0 = { input, listbox, state, Option };
192
- __flushMountFrame();
193
- return __mfResult0;
194
- } catch (__mfErr) {
195
- __discardMountFrame(__mfDepth);
196
- throw __mfErr;
197
- }
198
- }
199
- var Combobox = {
200
- Root: ComboboxRoot
201
- };
202
-
203
- export { Combobox };
@@ -1,410 +0,0 @@
1
- import {
2
- applyAttrs
3
- } from "./chunk-2db2dnp3.js";
4
-
5
- // src/calendar/calendar.tsx
6
- import { __append, __discardMountFrame, __element, __enterChildren, __exitChildren, __flushMountFrame, __insert, __list, __on, __pushMountFrame } from "@vertz/ui/internals";
7
- import { signal } from "@vertz/ui";
8
- var MONTH_NAMES = [
9
- "January",
10
- "February",
11
- "March",
12
- "April",
13
- "May",
14
- "June",
15
- "July",
16
- "August",
17
- "September",
18
- "October",
19
- "November",
20
- "December"
21
- ];
22
- var DAY_NAMES = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
23
- function getDaysInMonth(year, month) {
24
- return new Date(year, month + 1, 0).getDate();
25
- }
26
- function isSameDay(a, b) {
27
- return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
28
- }
29
- function addDays(date, days) {
30
- const result = new Date(date);
31
- result.setDate(result.getDate() + days);
32
- return result;
33
- }
34
- function addMonths(date, months) {
35
- const result = new Date(date);
36
- result.setMonth(result.getMonth() + months);
37
- return result;
38
- }
39
- function CalendarTitleEl() {
40
- const __mfDepth = __pushMountFrame();
41
- try {
42
- const __mfResult0 = (() => {
43
- const __el0 = __element("div");
44
- return __el0;
45
- })();
46
- __flushMountFrame();
47
- return __mfResult0;
48
- } catch (__mfErr) {
49
- __discardMountFrame(__mfDepth);
50
- throw __mfErr;
51
- }
52
- }
53
- function CalendarNavButton(onClick) {
54
- const __mfDepth = __pushMountFrame();
55
- try {
56
- const __mfResult0 = (() => {
57
- const __el0 = __element("button");
58
- __el0.setAttribute("type", "button");
59
- __on(__el0, "click", onClick);
60
- return __el0;
61
- })();
62
- __flushMountFrame();
63
- return __mfResult0;
64
- } catch (__mfErr) {
65
- __discardMountFrame(__mfDepth);
66
- throw __mfErr;
67
- }
68
- }
69
- function CalendarHeaderEl(prevButton, title, nextButton) {
70
- const __mfDepth = __pushMountFrame();
71
- try {
72
- const __mfResult0 = (() => {
73
- const __el0 = __element("div");
74
- __enterChildren(__el0);
75
- __insert(__el0, prevButton);
76
- __insert(__el0, title);
77
- __insert(__el0, nextButton);
78
- __exitChildren();
79
- return __el0;
80
- })();
81
- __flushMountFrame();
82
- return __mfResult0;
83
- } catch (__mfErr) {
84
- __discardMountFrame(__mfDepth);
85
- throw __mfErr;
86
- }
87
- }
88
- function CalendarGridEl(onKeydown) {
89
- const __mfDepth = __pushMountFrame();
90
- try {
91
- const __mfResult0 = (() => {
92
- const __el0 = __element("table");
93
- __el0.setAttribute("role", "grid");
94
- __on(__el0, "keydown", onKeydown);
95
- return __el0;
96
- })();
97
- __flushMountFrame();
98
- return __mfResult0;
99
- } catch (__mfErr) {
100
- __discardMountFrame(__mfDepth);
101
- throw __mfErr;
102
- }
103
- }
104
- function CalendarRootEl(header, grid) {
105
- const __mfDepth = __pushMountFrame();
106
- try {
107
- const __mfResult0 = (() => {
108
- const __el0 = __element("div");
109
- __enterChildren(__el0);
110
- __insert(__el0, header);
111
- __insert(__el0, grid);
112
- __exitChildren();
113
- return __el0;
114
- })();
115
- __flushMountFrame();
116
- return __mfResult0;
117
- } catch (__mfErr) {
118
- __discardMountFrame(__mfDepth);
119
- throw __mfErr;
120
- }
121
- }
122
- function CalendarRoot(options = {}) {
123
- const __mfDepth = __pushMountFrame();
124
- try {
125
- let updateTitle = function() {
126
- const month = state.displayMonth.peek();
127
- title.textContent = `${MONTH_NAMES[month.getMonth()]} ${month.getFullYear()}`;
128
- }, isDateDisabled = function(date) {
129
- if (disabled?.(date))
130
- return true;
131
- if (minDate && date < minDate && !isSameDay(date, minDate)) {
132
- return true;
133
- }
134
- if (maxDate && date > maxDate && !isSameDay(date, maxDate)) {
135
- return true;
136
- }
137
- return false;
138
- }, isSelected = function(date) {
139
- const val = state.value.peek();
140
- if (val === null)
141
- return false;
142
- if (val instanceof Date)
143
- return isSameDay(val, date);
144
- if (Array.isArray(val))
145
- return val.some((d) => isSameDay(d, date));
146
- if ("from" in val && "to" in val) {
147
- return isSameDay(val.from, date) || isSameDay(val.to, date);
148
- }
149
- return false;
150
- }, isInRange = function(date) {
151
- const val = state.value.peek();
152
- if (val === null || !("from" in val))
153
- return false;
154
- const range = val;
155
- return date > range.from && date < range.to;
156
- }, selectDate = function(date) {
157
- if (isDateDisabled(date))
158
- return;
159
- if (mode === "single") {
160
- state.value.value = date;
161
- } else if (mode === "multiple") {
162
- const current = state.value.peek() ?? [];
163
- const existing = current.findIndex((d) => isSameDay(d, date));
164
- if (existing >= 0) {
165
- const next = [...current];
166
- next.splice(existing, 1);
167
- state.value.value = next;
168
- } else {
169
- state.value.value = [...current, date];
170
- }
171
- } else if (mode === "range") {
172
- const current = state.value.peek();
173
- if (!current || "to" in current && current.to) {
174
- state.value.value = { from: date, to: date };
175
- } else {
176
- if (date < current.from) {
177
- state.value.value = { from: date, to: current.from };
178
- } else {
179
- state.value.value = { from: current.from, to: date };
180
- }
181
- }
182
- }
183
- onValueChange?.(state.value.peek());
184
- }, computeGridRows = function(year, month) {
185
- const daysInMonth = getDaysInMonth(year, month);
186
- const firstDay = new Date(year, month, 1);
187
- const firstDayOfWeek = firstDay.getDay();
188
- const offset = (firstDayOfWeek - weekStartsOn + 7) % 7;
189
- const startDate = addDays(firstDay, -offset);
190
- const totalCells = offset + daysInMonth;
191
- const totalRows = Math.ceil(totalCells / 7);
192
- const rows = [];
193
- let current = startDate;
194
- for (let row = 0;row < totalRows; row++) {
195
- const rowDates = [];
196
- for (let col = 0;col < 7; col++) {
197
- rowDates.push(new Date(current));
198
- current = addDays(current, 1);
199
- }
200
- rows.push(rowDates);
201
- }
202
- return rows;
203
- }, buildDayButton = function(cellDate, month) {
204
- const dateStr = cellDate.toISOString().split("T")[0] ?? "";
205
- const isOutside = cellDate.getMonth() !== month;
206
- const rangeVal = mode === "range" ? state.value.peek() : null;
207
- return (() => {
208
- const __el0 = __element("button");
209
- __el0.setAttribute("type", "button");
210
- {
211
- const __v = dateStr;
212
- if (__v != null && __v !== false)
213
- __el0.setAttribute("data-date", __v === true ? "" : __v);
214
- }
215
- {
216
- const __v = isOutside ? "true" : undefined;
217
- if (__v != null && __v !== false)
218
- __el0.setAttribute("data-outside-month", __v === true ? "" : __v);
219
- }
220
- {
221
- const __v = isSameDay(cellDate, now) ? "true" : undefined;
222
- if (__v != null && __v !== false)
223
- __el0.setAttribute("data-today", __v === true ? "" : __v);
224
- }
225
- {
226
- const __v = isDateDisabled(cellDate) ? "true" : undefined;
227
- if (__v != null && __v !== false)
228
- __el0.setAttribute("aria-disabled", __v === true ? "" : __v);
229
- }
230
- {
231
- const __v = isSelected(cellDate) ? "true" : undefined;
232
- if (__v != null && __v !== false)
233
- __el0.setAttribute("aria-selected", __v === true ? "" : __v);
234
- }
235
- {
236
- const __v = rangeVal && "from" in rangeVal && isSameDay(cellDate, rangeVal.from) ? "true" : undefined;
237
- if (__v != null && __v !== false)
238
- __el0.setAttribute("data-range-start", __v === true ? "" : __v);
239
- }
240
- {
241
- const __v = rangeVal && "to" in rangeVal && isSameDay(cellDate, rangeVal.to) ? "true" : undefined;
242
- if (__v != null && __v !== false)
243
- __el0.setAttribute("data-range-end", __v === true ? "" : __v);
244
- }
245
- {
246
- const __v = rangeVal && isInRange(cellDate) ? "true" : undefined;
247
- if (__v != null && __v !== false)
248
- __el0.setAttribute("data-in-range", __v === true ? "" : __v);
249
- }
250
- __on(__el0, "click", () => {
251
- selectDate(cellDate);
252
- rebuildGrid();
253
- });
254
- __enterChildren(__el0);
255
- __insert(__el0, cellDate.getDate());
256
- __exitChildren();
257
- return __el0;
258
- })();
259
- }, buildGrid = function() {
260
- const display = state.displayMonth.peek();
261
- const year = display.getFullYear();
262
- const month = display.getMonth();
263
- const rows = computeGridRows(year, month);
264
- const thead = (() => {
265
- const __el1 = __element("thead");
266
- __enterChildren(__el1);
267
- __append(__el1, (() => {
268
- const __el2 = __element("tr");
269
- __enterChildren(__el2);
270
- __insert(__el2, Array.from({ length: 7 }, (_, i) => {
271
- const dayIndex = (weekStartsOn + i) % 7;
272
- return (() => {
273
- const __el3 = __element("th");
274
- __el3.setAttribute("scope", "col");
275
- __enterChildren(__el3);
276
- __insert(__el3, DAY_NAMES[dayIndex] ?? "");
277
- __exitChildren();
278
- return __el3;
279
- })();
280
- }));
281
- __exitChildren();
282
- return __el2;
283
- })());
284
- __exitChildren();
285
- return __el1;
286
- })();
287
- const tbody = (() => {
288
- const __el4 = __element("tbody");
289
- __enterChildren(__el4);
290
- __list(__el4, () => rows, null, (rowDates) => (() => {
291
- const __el5 = __element("tr");
292
- __enterChildren(__el5);
293
- __list(__el5, () => rowDates, null, (cellDate) => (() => {
294
- const __el6 = __element("td");
295
- __el6.setAttribute("role", "gridcell");
296
- __enterChildren(__el6);
297
- __insert(__el6, buildDayButton(cellDate, month));
298
- __exitChildren();
299
- return __el6;
300
- })());
301
- __exitChildren();
302
- return __el5;
303
- })());
304
- __exitChildren();
305
- return __el4;
306
- })();
307
- grid.replaceChildren(thead, tbody);
308
- }, rebuildGrid = function() {
309
- updateTitle();
310
- buildGrid();
311
- }, navigateMonth = function(delta) {
312
- state.displayMonth.value = addMonths(state.displayMonth.peek(), delta);
313
- onMonthChange?.(state.displayMonth.peek());
314
- rebuildGrid();
315
- }, destroy = function() {};
316
- const {
317
- mode: modeOpt,
318
- defaultValue,
319
- defaultMonth: defaultMonthOpt,
320
- minDate,
321
- maxDate,
322
- disabled,
323
- weekStartsOn: weekStartsOnOpt,
324
- onValueChange,
325
- onMonthChange,
326
- ...attrs
327
- } = options;
328
- const now = new Date;
329
- const defaultMonth = defaultMonthOpt ?? now;
330
- const weekStartsOn = weekStartsOnOpt ?? 0;
331
- const mode = modeOpt ?? "single";
332
- const state = {
333
- value: signal(defaultValue ?? null),
334
- focusedDate: signal(defaultMonth),
335
- displayMonth: signal(defaultMonth)
336
- };
337
- const title = CalendarTitleEl();
338
- const prevButton = CalendarNavButton(() => navigateMonth(-1));
339
- const nextButton = CalendarNavButton(() => navigateMonth(1));
340
- const header = CalendarHeaderEl(prevButton, title, nextButton);
341
- const grid = CalendarGridEl((event) => {
342
- const active = document.activeElement;
343
- if (!active || active.tagName !== "BUTTON")
344
- return;
345
- const dateStr = active.getAttribute("data-date");
346
- if (!dateStr)
347
- return;
348
- const focused = new Date(`${dateStr}T00:00:00`);
349
- let next = null;
350
- if (event.key === "ArrowLeft") {
351
- event.preventDefault();
352
- next = addDays(focused, -1);
353
- } else if (event.key === "ArrowRight") {
354
- event.preventDefault();
355
- next = addDays(focused, 1);
356
- } else if (event.key === "ArrowUp") {
357
- event.preventDefault();
358
- next = addDays(focused, -7);
359
- } else if (event.key === "ArrowDown") {
360
- event.preventDefault();
361
- next = addDays(focused, 7);
362
- } else if (event.key === "Home") {
363
- event.preventDefault();
364
- const dayOfWeek = (focused.getDay() - weekStartsOn + 7) % 7;
365
- next = addDays(focused, -dayOfWeek);
366
- } else if (event.key === "End") {
367
- event.preventDefault();
368
- const dayOfWeek = (focused.getDay() - weekStartsOn + 7) % 7;
369
- next = addDays(focused, 6 - dayOfWeek);
370
- } else if (event.key === "PageUp") {
371
- event.preventDefault();
372
- next = event.shiftKey ? addMonths(focused, -12) : addMonths(focused, -1);
373
- } else if (event.key === "PageDown") {
374
- event.preventDefault();
375
- next = event.shiftKey ? addMonths(focused, 12) : addMonths(focused, 1);
376
- } else if (event.key === "Enter" || event.key === " ") {
377
- event.preventDefault();
378
- selectDate(focused);
379
- rebuildGrid();
380
- return;
381
- }
382
- if (next) {
383
- state.focusedDate.value = next;
384
- if (next.getMonth() !== state.displayMonth.peek().getMonth() || next.getFullYear() !== state.displayMonth.peek().getFullYear()) {
385
- state.displayMonth.value = new Date(next.getFullYear(), next.getMonth(), 1);
386
- onMonthChange?.(state.displayMonth.peek());
387
- rebuildGrid();
388
- }
389
- const dateKey = next.toISOString().split("T")[0];
390
- const btn = grid.querySelector(`button[data-date="${dateKey}"]`);
391
- btn?.focus();
392
- }
393
- });
394
- updateTitle();
395
- buildGrid();
396
- const root = CalendarRootEl(header, grid);
397
- applyAttrs(root, attrs);
398
- const __mfResult0 = { root, header, title, prevButton, nextButton, grid, state, destroy };
399
- __flushMountFrame();
400
- return __mfResult0;
401
- } catch (__mfErr) {
402
- __discardMountFrame(__mfDepth);
403
- throw __mfErr;
404
- }
405
- }
406
- var Calendar = {
407
- Root: CalendarRoot
408
- };
409
-
410
- export { Calendar };
@@ -1,60 +0,0 @@
1
- import {
2
- cn
3
- } from "./chunk-q7xbcj9q.js";
4
- import {
5
- uniqueId
6
- } from "./chunk-8y1jf6xr.js";
7
- import {
8
- Keys,
9
- isKey
10
- } from "./chunk-7867pr13.js";
11
-
12
- // src/toggle/toggle-composed.tsx
13
- import { signal } from "@vertz/ui";
14
- import { __append, __attr, __child, __discardMountFrame, __element, __enterChildren, __exitChildren, __flushMountFrame, __on, __pushMountFrame } from "@vertz/ui/internals";
15
- function ComposedToggleRoot(__props) {
16
- const __mfDepth = __pushMountFrame();
17
- try {
18
- let toggle = function() {
19
- if (__props.disabled ?? false)
20
- return;
21
- pressed.value = !pressed.value;
22
- __props.onPressedChange?.(pressed.value);
23
- };
24
- const pressed = signal(__props.defaultPressed ?? false, "pressed");
25
- const __mfResult0 = (() => {
26
- const __el0 = __element("button");
27
- __el0.setAttribute("data-v-id", "ComposedToggleRoot");
28
- __el0.setAttribute("type", "button");
29
- {
30
- const __v = uniqueId("toggle");
31
- if (__v != null && __v !== false)
32
- __el0.setAttribute("id", __v === true ? "" : __v);
33
- }
34
- __attr(__el0, "aria-pressed", () => pressed.value ? "true" : "false");
35
- __attr(__el0, "data-state", () => pressed.value ? "on" : "off");
36
- __attr(__el0, "disabled", () => __props.disabled ?? false);
37
- __attr(__el0, "aria-disabled", () => __props.disabled ?? false ? "true" : undefined);
38
- __attr(__el0, "class", () => cn(__props.classes?.root));
39
- __on(__el0, "click", toggle);
40
- __on(__el0, "keydown", (e) => {
41
- if (isKey(e, Keys.Space)) {
42
- e.preventDefault();
43
- toggle();
44
- }
45
- });
46
- __enterChildren(__el0);
47
- __append(__el0, __child(() => __props.children));
48
- __exitChildren();
49
- return __el0;
50
- })();
51
- __flushMountFrame();
52
- return __mfResult0;
53
- } catch (__mfErr) {
54
- __discardMountFrame(__mfDepth);
55
- throw __mfErr;
56
- }
57
- }
58
- var ComposedToggle = ComposedToggleRoot;
59
-
60
- export { ComposedToggle };