@sprawlify/primitives 0.0.1

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 (378) hide show
  1. package/dist/anatomy.cjs +3 -0
  2. package/dist/anatomy.d.cts +2 -0
  3. package/dist/anatomy.d.mts +2 -0
  4. package/dist/anatomy.mjs +3 -0
  5. package/dist/aria-hidden-DqYx0f_y.mjs +177 -0
  6. package/dist/aria-hidden-DtLU6hSU.cjs +182 -0
  7. package/dist/aria-hidden.cjs +4 -0
  8. package/dist/aria-hidden.d.cts +16 -0
  9. package/dist/aria-hidden.d.mts +16 -0
  10. package/dist/aria-hidden.mjs +4 -0
  11. package/dist/auto-resize-D3qHtFy1.mjs +114 -0
  12. package/dist/auto-resize-xzlPFDyD.cjs +125 -0
  13. package/dist/auto-resize.cjs +5 -0
  14. package/dist/auto-resize.d.cts +17 -0
  15. package/dist/auto-resize.d.mts +17 -0
  16. package/dist/auto-resize.mjs +4 -0
  17. package/dist/chunk-CbDLau6x.cjs +34 -0
  18. package/dist/collection-8XqaNHs_.mjs +1279 -0
  19. package/dist/collection-DIoIDISa.cjs +1326 -0
  20. package/dist/collection.cjs +11 -0
  21. package/dist/collection.d.cts +5 -0
  22. package/dist/collection.d.mts +5 -0
  23. package/dist/collection.mjs +4 -0
  24. package/dist/color-BkAP1Tkd.d.mts +60 -0
  25. package/dist/color-VKewNv2e.d.cts +60 -0
  26. package/dist/color-utils-Cc5GVXZh.mjs +657 -0
  27. package/dist/color-utils-LER_6Zwu.cjs +680 -0
  28. package/dist/color-utils.cjs +7 -0
  29. package/dist/color-utils.d.cts +19 -0
  30. package/dist/color-utils.d.mts +19 -0
  31. package/dist/color-utils.mjs +4 -0
  32. package/dist/core-30pJjyC2.d.mts +49 -0
  33. package/dist/core-CQFbMdTl.cjs +176 -0
  34. package/dist/core-CefBjbst.d.cts +49 -0
  35. package/dist/core-DCFNMTZF.mjs +129 -0
  36. package/dist/core.cjs +12 -0
  37. package/dist/core.d.cts +3 -0
  38. package/dist/core.d.mts +3 -0
  39. package/dist/core.mjs +5 -0
  40. package/dist/create-anatomy-B3XYc-qG.d.mts +70 -0
  41. package/dist/create-anatomy-BGQ8pv8J.d.cts +70 -0
  42. package/dist/create-anatomy-BbDZbHpC.mjs +39 -0
  43. package/dist/create-anatomy-CDsIFUXg.cjs +45 -0
  44. package/dist/create-props-BnF_vl-E.mjs +5 -0
  45. package/dist/create-props-YKy7JIKj.cjs +11 -0
  46. package/dist/data-url-C3ITPVRX.d.cts +10 -0
  47. package/dist/data-url-DLwZ9M77.d.mts +10 -0
  48. package/dist/date-utils-D2xPHa_I.cjs +738 -0
  49. package/dist/date-utils-wEa1hhpc.mjs +474 -0
  50. package/dist/date-utils.cjs +46 -0
  51. package/dist/date-utils.d.cts +101 -0
  52. package/dist/date-utils.d.mts +2 -0
  53. package/dist/date-utils.mjs +3 -0
  54. package/dist/defineProperty-BoUOT9Ie.cjs +49 -0
  55. package/dist/defineProperty-DrXfyjd4.mjs +43 -0
  56. package/dist/dismissable-CTfKZ4OG.cjs +282 -0
  57. package/dist/dismissable-DDrx0xnH.mjs +271 -0
  58. package/dist/dismissable-layer-C7pZU2wi.d.cts +39 -0
  59. package/dist/dismissable-layer-t_b0fk-p.d.mts +39 -0
  60. package/dist/dismissable.cjs +7 -0
  61. package/dist/dismissable.d.cts +3 -0
  62. package/dist/dismissable.d.mts +3 -0
  63. package/dist/dismissable.mjs +6 -0
  64. package/dist/dom-query-CWZdWUGp.cjs +2141 -0
  65. package/dist/dom-query-DFCRhyj1.mjs +1374 -0
  66. package/dist/dom-query.cjs +130 -0
  67. package/dist/dom-query.d.cts +307 -0
  68. package/dist/dom-query.d.mts +307 -0
  69. package/dist/dom-query.mjs +3 -0
  70. package/dist/file-utils.cjs +220 -0
  71. package/dist/file-utils.d.cts +51 -0
  72. package/dist/file-utils.d.mts +51 -0
  73. package/dist/file-utils.mjs +210 -0
  74. package/dist/focus-trap-D-bypQEJ.mjs +485 -0
  75. package/dist/focus-trap-D4i52S9A.cjs +496 -0
  76. package/dist/focus-trap.cjs +5 -0
  77. package/dist/focus-trap.d.cts +88 -0
  78. package/dist/focus-trap.d.mts +88 -0
  79. package/dist/focus-trap.mjs +4 -0
  80. package/dist/focus-visible-DYTWdWpa.cjs +210 -0
  81. package/dist/focus-visible-irppYatv.mjs +175 -0
  82. package/dist/focus-visible.cjs +9 -0
  83. package/dist/focus-visible.d.cts +31 -0
  84. package/dist/focus-visible.d.mts +31 -0
  85. package/dist/focus-visible.mjs +4 -0
  86. package/dist/functions-BOkTDEFM.d.cts +15 -0
  87. package/dist/functions-IZtWcC8Q.d.mts +15 -0
  88. package/dist/highlight-word.cjs +100 -0
  89. package/dist/highlight-word.d.cts +24 -0
  90. package/dist/highlight-word.d.mts +24 -0
  91. package/dist/highlight-word.mjs +99 -0
  92. package/dist/hotkeys.cjs +758 -0
  93. package/dist/hotkeys.d.cts +130 -0
  94. package/dist/hotkeys.d.mts +130 -0
  95. package/dist/hotkeys.mjs +754 -0
  96. package/dist/i18n-utils.cjs +450 -0
  97. package/dist/i18n-utils.d.cts +61 -0
  98. package/dist/i18n-utils.d.mts +61 -0
  99. package/dist/i18n-utils.mjs +440 -0
  100. package/dist/index-BkzYij2j.d.mts +25 -0
  101. package/dist/index-Bqw3r34-.d.cts +1383 -0
  102. package/dist/index-C0MKXQmE.d.mts +1383 -0
  103. package/dist/index-C9-feK5c.d.cts +25 -0
  104. package/dist/index-CD5FN7kY.d.mts +114 -0
  105. package/dist/index-CJji6wHl.d.cts +15 -0
  106. package/dist/index-CNi5FkPe.d.mts +15 -0
  107. package/dist/index-D96rs8B0.d.mts +115 -0
  108. package/dist/index.cjs +0 -0
  109. package/dist/index.d.cts +1 -0
  110. package/dist/index.d.mts +1 -0
  111. package/dist/index.mjs +1 -0
  112. package/dist/interact-outside-BplxR9cR.mjs +200 -0
  113. package/dist/interact-outside-C8-oFBpB.cjs +205 -0
  114. package/dist/interact-outside.cjs +5 -0
  115. package/dist/interact-outside.d.cts +2 -0
  116. package/dist/interact-outside.d.mts +2 -0
  117. package/dist/interact-outside.mjs +5 -0
  118. package/dist/json-tree-utils.cjs +1512 -0
  119. package/dist/json-tree-utils.d.cts +117 -0
  120. package/dist/json-tree-utils.d.mts +117 -0
  121. package/dist/json-tree-utils.mjs +1463 -0
  122. package/dist/list-collection-BIMJGQjn.d.cts +61 -0
  123. package/dist/list-collection-Db3eixRU.d.mts +61 -0
  124. package/dist/live-region-CcZPGo89.cjs +52 -0
  125. package/dist/live-region-CnPh21WH.mjs +46 -0
  126. package/dist/live-region.cjs +3 -0
  127. package/dist/live-region.d.cts +2 -0
  128. package/dist/live-region.d.mts +2 -0
  129. package/dist/live-region.mjs +3 -0
  130. package/dist/machines/accordion/index.cjs +328 -0
  131. package/dist/machines/accordion/index.d.cts +83 -0
  132. package/dist/machines/accordion/index.d.mts +83 -0
  133. package/dist/machines/accordion/index.mjs +322 -0
  134. package/dist/machines/async-list/index.cjs +311 -0
  135. package/dist/machines/async-list/index.d.cts +89 -0
  136. package/dist/machines/async-list/index.d.mts +89 -0
  137. package/dist/machines/async-list/index.mjs +310 -0
  138. package/dist/machines/avatar/index.cjs +169 -0
  139. package/dist/machines/avatar/index.d.cts +63 -0
  140. package/dist/machines/avatar/index.d.mts +63 -0
  141. package/dist/machines/avatar/index.mjs +165 -0
  142. package/dist/machines/bottom-sheet/index.cjs +676 -0
  143. package/dist/machines/bottom-sheet/index.d.cts +239 -0
  144. package/dist/machines/bottom-sheet/index.d.mts +239 -0
  145. package/dist/machines/bottom-sheet/index.mjs +672 -0
  146. package/dist/machines/carousel/index.cjs +859 -0
  147. package/dist/machines/carousel/index.d.cts +146 -0
  148. package/dist/machines/carousel/index.d.mts +146 -0
  149. package/dist/machines/carousel/index.mjs +851 -0
  150. package/dist/machines/checkbox/index.cjs +316 -0
  151. package/dist/machines/checkbox/index.d.cts +81 -0
  152. package/dist/machines/checkbox/index.d.mts +81 -0
  153. package/dist/machines/checkbox/index.mjs +312 -0
  154. package/dist/machines/clipboard/index.cjs +225 -0
  155. package/dist/machines/clipboard/index.d.cts +68 -0
  156. package/dist/machines/clipboard/index.d.mts +68 -0
  157. package/dist/machines/clipboard/index.mjs +219 -0
  158. package/dist/machines/collapsible/index.cjs +362 -0
  159. package/dist/machines/collapsible/index.d.cts +82 -0
  160. package/dist/machines/collapsible/index.d.mts +82 -0
  161. package/dist/machines/collapsible/index.mjs +358 -0
  162. package/dist/machines/color-picker/index.cjs +1529 -0
  163. package/dist/machines/color-picker/index.d.cts +205 -0
  164. package/dist/machines/color-picker/index.d.mts +205 -0
  165. package/dist/machines/color-picker/index.mjs +1514 -0
  166. package/dist/machines/combobox/index.cjs +1593 -0
  167. package/dist/machines/combobox/index.d.cts +214 -0
  168. package/dist/machines/combobox/index.d.mts +214 -0
  169. package/dist/machines/combobox/index.mjs +1582 -0
  170. package/dist/machines/date-picker/index.cjs +2177 -0
  171. package/dist/machines/date-picker/index.d.cts +350 -0
  172. package/dist/machines/date-picker/index.d.mts +350 -0
  173. package/dist/machines/date-picker/index.mjs +2161 -0
  174. package/dist/machines/dialog/index.cjs +325 -0
  175. package/dist/machines/dialog/index.d.cts +80 -0
  176. package/dist/machines/dialog/index.d.mts +80 -0
  177. package/dist/machines/dialog/index.mjs +321 -0
  178. package/dist/machines/editable/index.cjs +551 -0
  179. package/dist/machines/editable/index.d.cts +114 -0
  180. package/dist/machines/editable/index.d.mts +114 -0
  181. package/dist/machines/editable/index.mjs +547 -0
  182. package/dist/machines/floating-panel/index.cjs +995 -0
  183. package/dist/machines/floating-panel/index.d.cts +147 -0
  184. package/dist/machines/floating-panel/index.d.mts +147 -0
  185. package/dist/machines/floating-panel/index.mjs +988 -0
  186. package/dist/machines/hover-card/index.cjs +383 -0
  187. package/dist/machines/hover-card/index.d.cts +69 -0
  188. package/dist/machines/hover-card/index.d.mts +69 -0
  189. package/dist/machines/hover-card/index.mjs +379 -0
  190. package/dist/machines/image-cropper/index.cjs +1995 -0
  191. package/dist/machines/image-cropper/index.d.cts +182 -0
  192. package/dist/machines/image-cropper/index.d.mts +182 -0
  193. package/dist/machines/image-cropper/index.mjs +1990 -0
  194. package/dist/machines/listbox/index.cjs +794 -0
  195. package/dist/machines/listbox/index.d.cts +168 -0
  196. package/dist/machines/listbox/index.d.mts +168 -0
  197. package/dist/machines/listbox/index.mjs +782 -0
  198. package/dist/machines/marquee/index.cjs +395 -0
  199. package/dist/machines/marquee/index.d.cts +102 -0
  200. package/dist/machines/marquee/index.d.mts +102 -0
  201. package/dist/machines/marquee/index.mjs +391 -0
  202. package/dist/machines/menu/index.cjs +1298 -0
  203. package/dist/machines/menu/index.d.cts +175 -0
  204. package/dist/machines/menu/index.d.mts +175 -0
  205. package/dist/machines/menu/index.mjs +1286 -0
  206. package/dist/machines/navigation-menu/index.cjs +861 -0
  207. package/dist/machines/navigation-menu/index.d.cts +127 -0
  208. package/dist/machines/navigation-menu/index.d.mts +127 -0
  209. package/dist/machines/navigation-menu/index.mjs +857 -0
  210. package/dist/machines/number-input/index.cjs +996 -0
  211. package/dist/machines/number-input/index.d.cts +134 -0
  212. package/dist/machines/number-input/index.d.mts +134 -0
  213. package/dist/machines/number-input/index.mjs +991 -0
  214. package/dist/machines/pagination/index.cjs +419 -0
  215. package/dist/machines/pagination/index.d.cts +139 -0
  216. package/dist/machines/pagination/index.d.mts +139 -0
  217. package/dist/machines/pagination/index.mjs +411 -0
  218. package/dist/machines/password-input/index.cjs +228 -0
  219. package/dist/machines/password-input/index.d.cts +71 -0
  220. package/dist/machines/password-input/index.d.mts +71 -0
  221. package/dist/machines/password-input/index.mjs +224 -0
  222. package/dist/machines/pin-input/index.cjs +523 -0
  223. package/dist/machines/pin-input/index.d.cts +105 -0
  224. package/dist/machines/pin-input/index.d.mts +105 -0
  225. package/dist/machines/pin-input/index.mjs +519 -0
  226. package/dist/machines/popover/index.cjs +430 -0
  227. package/dist/machines/popover/index.d.cts +88 -0
  228. package/dist/machines/popover/index.d.mts +88 -0
  229. package/dist/machines/popover/index.mjs +426 -0
  230. package/dist/machines/presence/index.cjs +192 -0
  231. package/dist/machines/presence/index.d.cts +44 -0
  232. package/dist/machines/presence/index.d.mts +44 -0
  233. package/dist/machines/presence/index.mjs +190 -0
  234. package/dist/machines/progress/index.cjs +288 -0
  235. package/dist/machines/progress/index.d.cts +96 -0
  236. package/dist/machines/progress/index.d.mts +96 -0
  237. package/dist/machines/progress/index.mjs +284 -0
  238. package/dist/machines/qr-code/index.cjs +172 -0
  239. package/dist/machines/qr-code/index.d.cts +70 -0
  240. package/dist/machines/qr-code/index.d.mts +70 -0
  241. package/dist/machines/qr-code/index.mjs +167 -0
  242. package/dist/machines/radio-group/index.cjs +436 -0
  243. package/dist/machines/radio-group/index.d.cts +106 -0
  244. package/dist/machines/radio-group/index.d.mts +106 -0
  245. package/dist/machines/radio-group/index.mjs +430 -0
  246. package/dist/machines/rating-group/index.cjs +405 -0
  247. package/dist/machines/rating-group/index.d.cts +101 -0
  248. package/dist/machines/rating-group/index.d.mts +101 -0
  249. package/dist/machines/rating-group/index.mjs +399 -0
  250. package/dist/machines/scroll-area/index.cjs +857 -0
  251. package/dist/machines/scroll-area/index.d.cts +159 -0
  252. package/dist/machines/scroll-area/index.d.mts +159 -0
  253. package/dist/machines/scroll-area/index.mjs +853 -0
  254. package/dist/machines/select/index.cjs +1165 -0
  255. package/dist/machines/select/index.d.cts +183 -0
  256. package/dist/machines/select/index.d.mts +183 -0
  257. package/dist/machines/select/index.mjs +1154 -0
  258. package/dist/machines/signature-pad/index.cjs +334 -0
  259. package/dist/machines/signature-pad/index.d.cts +108 -0
  260. package/dist/machines/signature-pad/index.d.mts +108 -0
  261. package/dist/machines/signature-pad/index.mjs +328 -0
  262. package/dist/machines/slider/index.cjs +957 -0
  263. package/dist/machines/slider/index.d.cts +149 -0
  264. package/dist/machines/slider/index.d.mts +149 -0
  265. package/dist/machines/slider/index.mjs +949 -0
  266. package/dist/machines/splitter/index.cjs +1112 -0
  267. package/dist/machines/splitter/index.d.cts +155 -0
  268. package/dist/machines/splitter/index.d.mts +155 -0
  269. package/dist/machines/splitter/index.mjs +1103 -0
  270. package/dist/machines/steps/index.cjs +289 -0
  271. package/dist/machines/steps/index.d.cts +97 -0
  272. package/dist/machines/steps/index.d.mts +97 -0
  273. package/dist/machines/steps/index.mjs +285 -0
  274. package/dist/machines/switch/index.cjs +305 -0
  275. package/dist/machines/switch/index.d.cts +80 -0
  276. package/dist/machines/switch/index.d.mts +80 -0
  277. package/dist/machines/switch/index.mjs +301 -0
  278. package/dist/machines/tabs/index.cjs +508 -0
  279. package/dist/machines/tabs/index.d.cts +111 -0
  280. package/dist/machines/tabs/index.d.mts +111 -0
  281. package/dist/machines/tabs/index.mjs +500 -0
  282. package/dist/machines/tags-input/index.cjs +1127 -0
  283. package/dist/machines/tags-input/index.d.cts +179 -0
  284. package/dist/machines/tags-input/index.d.mts +179 -0
  285. package/dist/machines/tags-input/index.mjs +1121 -0
  286. package/dist/machines/timer/index.cjs +329 -0
  287. package/dist/machines/timer/index.d.cts +98 -0
  288. package/dist/machines/timer/index.d.mts +98 -0
  289. package/dist/machines/timer/index.mjs +324 -0
  290. package/dist/machines/toast/index.cjs +1155 -0
  291. package/dist/machines/toast/index.d.cts +195 -0
  292. package/dist/machines/toast/index.d.mts +195 -0
  293. package/dist/machines/toast/index.mjs +1151 -0
  294. package/dist/machines/toggle/index.cjs +103 -0
  295. package/dist/machines/toggle/index.d.cts +46 -0
  296. package/dist/machines/toggle/index.d.mts +46 -0
  297. package/dist/machines/toggle/index.mjs +99 -0
  298. package/dist/machines/toggle-group/index.cjs +328 -0
  299. package/dist/machines/toggle-group/index.d.cts +81 -0
  300. package/dist/machines/toggle-group/index.d.mts +81 -0
  301. package/dist/machines/toggle-group/index.mjs +322 -0
  302. package/dist/machines/tooltip/index.cjs +516 -0
  303. package/dist/machines/tooltip/index.d.cts +71 -0
  304. package/dist/machines/tooltip/index.d.mts +71 -0
  305. package/dist/machines/tooltip/index.mjs +512 -0
  306. package/dist/machines/tour/index.cjs +1108 -0
  307. package/dist/machines/tour/index.d.cts +206 -0
  308. package/dist/machines/tour/index.d.mts +206 -0
  309. package/dist/machines/tour/index.mjs +1101 -0
  310. package/dist/machines/tree-view/index.cjs +1271 -0
  311. package/dist/machines/tree-view/index.d.cts +215 -0
  312. package/dist/machines/tree-view/index.d.mts +215 -0
  313. package/dist/machines/tree-view/index.mjs +1263 -0
  314. package/dist/node-BctU8GXk.d.mts +24 -0
  315. package/dist/node-CSsuPZVZ.d.cts +24 -0
  316. package/dist/popper-BPJeAtcA.mjs +349 -0
  317. package/dist/popper-D0FAW_p7.cjs +373 -0
  318. package/dist/popper.cjs +8 -0
  319. package/dist/popper.d.cts +74 -0
  320. package/dist/popper.d.mts +2 -0
  321. package/dist/popper.mjs +5 -0
  322. package/dist/raf-BnlYUlDi.d.mts +15 -0
  323. package/dist/raf-Cd2FGy0z.d.cts +15 -0
  324. package/dist/rect-utils-0ellN0a_.mjs +854 -0
  325. package/dist/rect-utils-DKLRhP8G.cjs +1147 -0
  326. package/dist/rect-utils.cjs +51 -0
  327. package/dist/rect-utils.d.cts +198 -0
  328. package/dist/rect-utils.d.mts +198 -0
  329. package/dist/rect-utils.mjs +3 -0
  330. package/dist/remove-scroll-Lrfv79X_.mjs +58 -0
  331. package/dist/remove-scroll-Uvzg1L9r.cjs +63 -0
  332. package/dist/remove-scroll.cjs +0 -0
  333. package/dist/remove-scroll.d.cts +1 -0
  334. package/dist/remove-scroll.d.mts +1 -0
  335. package/dist/remove-scroll.mjs +1 -0
  336. package/dist/scroll-snap-CrTmQRzA.mjs +152 -0
  337. package/dist/scroll-snap-zyiZLv7W.cjs +175 -0
  338. package/dist/scroll-snap.cjs +7 -0
  339. package/dist/scroll-snap.d.cts +14 -0
  340. package/dist/scroll-snap.d.mts +14 -0
  341. package/dist/scroll-snap.mjs +4 -0
  342. package/dist/selection-BIhSzkF7.d.mts +50 -0
  343. package/dist/selection-CS1GBp8e.d.cts +50 -0
  344. package/dist/store-BZcXv49B.cjs +305 -0
  345. package/dist/store-DEojWy9H.mjs +263 -0
  346. package/dist/store.cjs +9 -0
  347. package/dist/store.d.cts +26 -0
  348. package/dist/store.d.mts +26 -0
  349. package/dist/store.mjs +3 -0
  350. package/dist/stringify-state.cjs +49 -0
  351. package/dist/stringify-state.d.cts +8 -0
  352. package/dist/stringify-state.d.mts +8 -0
  353. package/dist/stringify-state.mjs +46 -0
  354. package/dist/tree-collection-BwU5WhGQ.d.mts +78 -0
  355. package/dist/tree-collection-DP_eznnI.d.cts +78 -0
  356. package/dist/typeahead-BdNwVP09.d.cts +45 -0
  357. package/dist/typeahead-XN6lZ7G9.d.mts +45 -0
  358. package/dist/types-BivBkYg9.d.cts +57 -0
  359. package/dist/types-Bl_6JtPQ.d.mts +57 -0
  360. package/dist/types-CPUMVt7c.d.mts +54 -0
  361. package/dist/types-CT_W6HWr.d.cts +54 -0
  362. package/dist/types-DDTcG99l.d.mts +201 -0
  363. package/dist/types-DejIu60O.d.cts +201 -0
  364. package/dist/types-DiIdKZ3K.d.cts +45 -0
  365. package/dist/types-GxLIgJib.d.cts +17 -0
  366. package/dist/types.cjs +15 -0
  367. package/dist/types.d.cts +2 -0
  368. package/dist/types.d.mts +2 -0
  369. package/dist/types.mjs +14 -0
  370. package/dist/utils-BZyrxWWR.mjs +525 -0
  371. package/dist/utils-_6frwjgJ.cjs +1040 -0
  372. package/dist/utils.cjs +88 -0
  373. package/dist/utils.d.cts +144 -0
  374. package/dist/utils.d.mts +144 -0
  375. package/dist/utils.mjs +3 -0
  376. package/dist/wait-for-CMjPsqWk.d.cts +10 -0
  377. package/dist/wait-for-D2nkdD4z.d.mts +10 -0
  378. package/package.json +399 -0
@@ -0,0 +1,2161 @@
1
+ import { t as createAnatomy } from "../../create-anatomy-BbDZbHpC.mjs";
2
+ import { D as restoreTextSelection, E as disableTextSelection, S as queryAll, U as raf, _n as ariaAttr, at as setElementValue, lt as getEventKey, mt as isComposingEvent, pt as getNativeEvent, vn as dataAttr, x as query } from "../../dom-query-DFCRhyj1.mjs";
3
+ import { J as match, N as isValueWithinRange, g as clampValue, mt as chunk, u as createSplitProps } from "../../utils-BZyrxWWR.mjs";
4
+ import { a as createMachine, i as createGuards } from "../../core-DCFNMTZF.mjs";
5
+ import { A as getMonthFormatter, D as formatSelectedDate, F as isDateUnavailable, I as isNextRangeInvalid, L as isPreviousRangeInvalid, M as getUnitDuration, N as isDateEqual, P as isDateOutsideRange, R as alignDate, S as getMonthNames, W as constrainValue, _ as getYearsRange, g as getDecadeRange, i as getNextPage, j as getEndDate, k as getDayFormatter, l as getPreviousSection, n as parseDateString, o as getNextSection, p as getTodayDate, r as getAdjustedDateFn, s as getPreviousPage, t as getDateRangePreset, w as getWeekDays, x as getMonthDays, y as getDaysInWeek } from "../../date-utils-wEa1hhpc.mjs";
6
+ import "../../interact-outside-BplxR9cR.mjs";
7
+ import { n as trackDismissableElement } from "../../dismissable-DDrx0xnH.mjs";
8
+ import { t as createLiveRegion } from "../../live-region-CnPh21WH.mjs";
9
+ import { n as getPlacement, t as getPlacementStyles } from "../../popper-BPJeAtcA.mjs";
10
+ import { t as createProps } from "../../create-props-BnF_vl-E.mjs";
11
+ import { CalendarDate, DateFormatter, isEqualDay, isEqualMonth, isEqualYear, isToday, isWeekend, parseDate } from "@internationalized/date";
12
+
13
+ //#region src/machines/date-picker/date-picker.anatomy.ts
14
+ const anatomy = createAnatomy("date-picker").parts("clearTrigger", "content", "control", "input", "label", "monthSelect", "nextTrigger", "positioner", "presetTrigger", "prevTrigger", "rangeText", "root", "table", "tableBody", "tableCell", "tableCellTrigger", "tableHead", "tableHeader", "tableRow", "trigger", "view", "viewControl", "viewTrigger", "yearSelect");
15
+ const parts = anatomy.build();
16
+
17
+ //#endregion
18
+ //#region src/machines/date-picker/date-picker.dom.ts
19
+ const getLabelId = (ctx, index) => ctx.ids?.label?.(index) ?? `datepicker:${ctx.id}:label:${index}`;
20
+ const getRootId = (ctx) => ctx.ids?.root ?? `datepicker:${ctx.id}`;
21
+ const getTableId = (ctx, id) => ctx.ids?.table?.(id) ?? `datepicker:${ctx.id}:table:${id}`;
22
+ const getContentId = (ctx) => ctx.ids?.content ?? `datepicker:${ctx.id}:content`;
23
+ const getCellTriggerId = (ctx, id) => ctx.ids?.cellTrigger?.(id) ?? `datepicker:${ctx.id}:cell-trigger:${id}`;
24
+ const getPrevTriggerId = (ctx, view) => ctx.ids?.prevTrigger?.(view) ?? `datepicker:${ctx.id}:prev:${view}`;
25
+ const getNextTriggerId = (ctx, view) => ctx.ids?.nextTrigger?.(view) ?? `datepicker:${ctx.id}:next:${view}`;
26
+ const getViewTriggerId = (ctx, view) => ctx.ids?.viewTrigger?.(view) ?? `datepicker:${ctx.id}:view:${view}`;
27
+ const getClearTriggerId = (ctx) => ctx.ids?.clearTrigger ?? `datepicker:${ctx.id}:clear`;
28
+ const getControlId = (ctx) => ctx.ids?.control ?? `datepicker:${ctx.id}:control`;
29
+ const getInputId = (ctx, index) => ctx.ids?.input?.(index) ?? `datepicker:${ctx.id}:input:${index}`;
30
+ const getTriggerId = (ctx) => ctx.ids?.trigger ?? `datepicker:${ctx.id}:trigger`;
31
+ const getPositionerId = (ctx) => ctx.ids?.positioner ?? `datepicker:${ctx.id}:positioner`;
32
+ const getMonthSelectId = (ctx) => ctx.ids?.monthSelect ?? `datepicker:${ctx.id}:month-select`;
33
+ const getYearSelectId = (ctx) => ctx.ids?.yearSelect ?? `datepicker:${ctx.id}:year-select`;
34
+ const getFocusedCell = (ctx, view) => query(getContentEl(ctx), `[data-part=table-cell-trigger][data-view=${view}][data-focus]:not([data-outside-range])`);
35
+ const getTriggerEl = (ctx) => ctx.getById(getTriggerId(ctx));
36
+ const getContentEl = (ctx) => ctx.getById(getContentId(ctx));
37
+ const getInputEls = (ctx) => queryAll(getControlEl(ctx), `[data-part=input]`);
38
+ const getYearSelectEl = (ctx) => ctx.getById(getYearSelectId(ctx));
39
+ const getMonthSelectEl = (ctx) => ctx.getById(getMonthSelectId(ctx));
40
+ const getClearTriggerEl = (ctx) => ctx.getById(getClearTriggerId(ctx));
41
+ const getPositionerEl = (ctx) => ctx.getById(getPositionerId(ctx));
42
+ const getControlEl = (ctx) => ctx.getById(getControlId(ctx));
43
+
44
+ //#endregion
45
+ //#region src/machines/date-picker/date-picker.utils.ts
46
+ function adjustStartAndEndDate(value) {
47
+ const [startDate, endDate] = value;
48
+ let result;
49
+ if (!startDate || !endDate) result = value;
50
+ else result = startDate.compare(endDate) <= 0 ? value : [endDate, startDate];
51
+ return result;
52
+ }
53
+ function isDateWithinRange(date, value) {
54
+ const [startDate, endDate] = value;
55
+ if (!startDate || !endDate) return false;
56
+ return startDate.compare(date) <= 0 && endDate.compare(date) >= 0;
57
+ }
58
+ function sortDates(values) {
59
+ return values.slice().filter((date) => date != null).sort((a, b) => a.compare(b));
60
+ }
61
+ function getRoleDescription(view) {
62
+ return match(view, {
63
+ year: "calendar decade",
64
+ month: "calendar year",
65
+ day: "calendar month"
66
+ });
67
+ }
68
+ const PLACEHOLDERS = {
69
+ day: "dd",
70
+ month: "mm",
71
+ year: "yyyy"
72
+ };
73
+ function getInputPlaceholder(locale) {
74
+ return new DateFormatter(locale).formatToParts(/* @__PURE__ */ new Date()).map((item) => PLACEHOLDERS[item.type] ?? item.value).join("");
75
+ }
76
+ const isValidCharacter = (char, separator) => {
77
+ if (!char) return true;
78
+ return /\d/.test(char) || char === separator || char.length !== 1;
79
+ };
80
+ const isValidDate = (value) => {
81
+ return !Number.isNaN(value.day) && !Number.isNaN(value.month) && !Number.isNaN(value.year);
82
+ };
83
+ const ensureValidCharacters = (value, separator) => {
84
+ return value.split("").filter((char) => isValidCharacter(char, separator)).join("");
85
+ };
86
+ function getLocaleSeparator(locale) {
87
+ const literalPart = new Intl.DateTimeFormat(locale).formatToParts(/* @__PURE__ */ new Date()).find((part) => part.type === "literal");
88
+ return literalPart ? literalPart.value : "/";
89
+ }
90
+ const defaultTranslations = {
91
+ dayCell(state) {
92
+ if (state.unavailable) return `Not available. ${state.formattedDate}`;
93
+ if (state.selected) return `Selected date. ${state.formattedDate}`;
94
+ return `Choose ${state.formattedDate}`;
95
+ },
96
+ trigger(open) {
97
+ return open ? "Close calendar" : "Open calendar";
98
+ },
99
+ viewTrigger(view) {
100
+ return match(view, {
101
+ year: "Switch to month view",
102
+ month: "Switch to day view",
103
+ day: "Switch to year view"
104
+ });
105
+ },
106
+ presetTrigger(value) {
107
+ const [start = "", end = ""] = value;
108
+ return `select ${start} to ${end}`;
109
+ },
110
+ prevTrigger(view) {
111
+ return match(view, {
112
+ year: "Switch to previous decade",
113
+ month: "Switch to previous year",
114
+ day: "Switch to previous month"
115
+ });
116
+ },
117
+ nextTrigger(view) {
118
+ return match(view, {
119
+ year: "Switch to next decade",
120
+ month: "Switch to next year",
121
+ day: "Switch to next month"
122
+ });
123
+ },
124
+ placeholder() {
125
+ return {
126
+ day: "dd",
127
+ month: "mm",
128
+ year: "yyyy"
129
+ };
130
+ },
131
+ content: "calendar",
132
+ monthSelect: "Select month",
133
+ yearSelect: "Select year",
134
+ clearTrigger: "Clear selected dates"
135
+ };
136
+ function viewToNumber(view, fallback) {
137
+ if (!view) return fallback || 0;
138
+ return view === "day" ? 0 : view === "month" ? 1 : 2;
139
+ }
140
+ function viewNumberToView(viewNumber) {
141
+ return viewNumber === 0 ? "day" : viewNumber === 1 ? "month" : "year";
142
+ }
143
+ function clampView(view, minView, maxView) {
144
+ return viewNumberToView(clampValue(viewToNumber(view, 0), viewToNumber(minView, 0), viewToNumber(maxView, 2)));
145
+ }
146
+ function isAboveMinView(view, minView) {
147
+ return viewToNumber(view, 0) > viewToNumber(minView, 0);
148
+ }
149
+ function isBelowMinView(view, minView) {
150
+ return viewToNumber(view, 0) < viewToNumber(minView, 0);
151
+ }
152
+ function getNextView(view, minView, maxView) {
153
+ return clampView(viewNumberToView(viewToNumber(view, 0) + 1), minView, maxView);
154
+ }
155
+ function getPreviousView(view, minView, maxView) {
156
+ return clampView(viewNumberToView(viewToNumber(view, 0) - 1), minView, maxView);
157
+ }
158
+ const views = [
159
+ "day",
160
+ "month",
161
+ "year"
162
+ ];
163
+ function eachView(cb) {
164
+ views.forEach((view) => cb(view));
165
+ }
166
+
167
+ //#endregion
168
+ //#region src/machines/date-picker/date-picker.connect.ts
169
+ function connect(service, normalize) {
170
+ const { state, context, prop, send, computed, scope } = service;
171
+ const startValue = context.get("startValue");
172
+ const endValue = computed("endValue");
173
+ const selectedValue = context.get("value");
174
+ const focusedValue = context.get("focusedValue");
175
+ const hoveredValue = context.get("hoveredValue");
176
+ const hoveredRangeValue = hoveredValue ? adjustStartAndEndDate([selectedValue[0], hoveredValue]) : [];
177
+ const disabled = Boolean(prop("disabled"));
178
+ const readOnly = Boolean(prop("readOnly"));
179
+ const invalid = Boolean(prop("invalid"));
180
+ const interactive = computed("isInteractive");
181
+ const min = prop("min");
182
+ const max = prop("max");
183
+ const locale = prop("locale");
184
+ const timeZone = prop("timeZone");
185
+ const startOfWeek$1 = prop("startOfWeek");
186
+ const focused = state.matches("focused");
187
+ const open = state.matches("open");
188
+ const isRangePicker = prop("selectionMode") === "range";
189
+ const isDateUnavailableFn = prop("isDateUnavailable");
190
+ const currentPlacement = context.get("currentPlacement");
191
+ const popperStyles = getPlacementStyles({
192
+ ...prop("positioning"),
193
+ placement: currentPlacement
194
+ });
195
+ const separator = getLocaleSeparator(locale);
196
+ const translations = {
197
+ ...defaultTranslations,
198
+ ...prop("translations")
199
+ };
200
+ function getMonthWeeks(from = startValue) {
201
+ return getMonthDays(from, locale, prop("fixedWeeks") ? 6 : void 0, startOfWeek$1);
202
+ }
203
+ function getMonths(props$1 = {}) {
204
+ const { format } = props$1;
205
+ return getMonthNames(locale, format).map((label, index) => {
206
+ const value = index + 1;
207
+ return {
208
+ label,
209
+ value,
210
+ disabled: isDateOutsideRange(focusedValue.set({ month: value }), min, max)
211
+ };
212
+ });
213
+ }
214
+ function getYears() {
215
+ return getYearsRange({
216
+ from: min?.year ?? 1900,
217
+ to: max?.year ?? 2100
218
+ }).map((year) => ({
219
+ label: year.toString(),
220
+ value: year,
221
+ disabled: !isValueWithinRange(year, min?.year, max?.year)
222
+ }));
223
+ }
224
+ function getDecadeYears(year) {
225
+ return getDecadeRange(year ?? startValue.year).map((year$1) => ({
226
+ label: year$1.toString(),
227
+ value: year$1,
228
+ disabled: !isValueWithinRange(year$1, min?.year, max?.year)
229
+ }));
230
+ }
231
+ function isUnavailable(date) {
232
+ return isDateUnavailable(date, isDateUnavailableFn, locale, min, max);
233
+ }
234
+ function focusMonth(month) {
235
+ send({
236
+ type: "FOCUS.SET",
237
+ value: (startValue ?? getTodayDate(timeZone)).set({ month })
238
+ });
239
+ }
240
+ function focusYear(year) {
241
+ send({
242
+ type: "FOCUS.SET",
243
+ value: (startValue ?? getTodayDate(timeZone)).set({ year })
244
+ });
245
+ }
246
+ function getYearTableCellState(props$1) {
247
+ const { value, disabled: disabled$1 } = props$1;
248
+ const dateValue = focusedValue.set({ year: value });
249
+ const isOutsideVisibleRange = !getDecadeRange(startValue.year, { strict: true }).includes(value);
250
+ const isOutsideRange = isValueWithinRange(value, min?.year, max?.year);
251
+ const cellState = {
252
+ focused: focusedValue.year === props$1.value,
253
+ selectable: isOutsideVisibleRange || isOutsideRange,
254
+ outsideRange: isOutsideVisibleRange,
255
+ selected: !!selectedValue.find((date) => date && date.year === value),
256
+ valueText: value.toString(),
257
+ inRange: isRangePicker && (isDateWithinRange(dateValue, selectedValue) || isDateWithinRange(dateValue, hoveredRangeValue)),
258
+ value: dateValue,
259
+ get disabled() {
260
+ return disabled$1 || !cellState.selectable;
261
+ }
262
+ };
263
+ return cellState;
264
+ }
265
+ function getMonthTableCellState(props$1) {
266
+ const { value, disabled: disabled$1 } = props$1;
267
+ const dateValue = focusedValue.set({ month: value });
268
+ const formatter = getMonthFormatter(locale, timeZone);
269
+ const cellState = {
270
+ focused: focusedValue.month === props$1.value,
271
+ selectable: !isDateOutsideRange(dateValue, min, max),
272
+ selected: !!selectedValue.find((date) => date && date.month === value && date.year === focusedValue.year),
273
+ valueText: formatter.format(dateValue.toDate(timeZone)),
274
+ inRange: isRangePicker && (isDateWithinRange(dateValue, selectedValue) || isDateWithinRange(dateValue, hoveredRangeValue)),
275
+ value: dateValue,
276
+ get disabled() {
277
+ return disabled$1 || !cellState.selectable;
278
+ }
279
+ };
280
+ return cellState;
281
+ }
282
+ function getDayTableCellState(props$1) {
283
+ const { value, disabled: disabled$1, visibleRange = computed("visibleRange") } = props$1;
284
+ const formatter = getDayFormatter(locale, timeZone);
285
+ const unitDuration = getUnitDuration(computed("visibleDuration"));
286
+ const outsideDaySelectable = prop("outsideDaySelectable");
287
+ const end = visibleRange.start.add(unitDuration).subtract({ days: 1 });
288
+ const isOutsideRange = isDateOutsideRange(value, visibleRange.start, end);
289
+ const isInSelectedRange = isRangePicker && isDateWithinRange(value, selectedValue);
290
+ const isFirstInSelectedRange = isRangePicker && isDateEqual(value, selectedValue[0]);
291
+ const isLastInSelectedRange = isRangePicker && isDateEqual(value, selectedValue[1]);
292
+ const hasHoveredRange = isRangePicker && hoveredRangeValue.length > 0;
293
+ const isInHoveredRange = hasHoveredRange && isDateWithinRange(value, hoveredRangeValue);
294
+ const isFirstInHoveredRange = hasHoveredRange && isDateEqual(value, hoveredRangeValue[0]);
295
+ const isLastInHoveredRange = hasHoveredRange && isDateEqual(value, hoveredRangeValue[1]);
296
+ const cellState = {
297
+ invalid: isDateOutsideRange(value, min, max),
298
+ disabled: disabled$1 || !outsideDaySelectable && isOutsideRange || isDateOutsideRange(value, min, max),
299
+ selected: selectedValue.some((date) => isDateEqual(value, date)),
300
+ unavailable: isDateUnavailable(value, isDateUnavailableFn, locale, min, max) && !disabled$1,
301
+ outsideRange: isOutsideRange,
302
+ today: isToday(value, timeZone),
303
+ weekend: isWeekend(value, locale),
304
+ formattedDate: formatter.format(value.toDate(timeZone)),
305
+ get focused() {
306
+ return isDateEqual(value, focusedValue) && (!cellState.outsideRange || outsideDaySelectable);
307
+ },
308
+ get ariaLabel() {
309
+ return translations.dayCell(cellState);
310
+ },
311
+ get selectable() {
312
+ return !cellState.disabled && !cellState.unavailable;
313
+ },
314
+ inRange: isInSelectedRange || isInHoveredRange,
315
+ firstInRange: isFirstInSelectedRange,
316
+ lastInRange: isLastInSelectedRange,
317
+ inHoveredRange: isInHoveredRange,
318
+ firstInHoveredRange: isFirstInHoveredRange,
319
+ lastInHoveredRange: isLastInHoveredRange
320
+ };
321
+ return cellState;
322
+ }
323
+ function getTableId$1(props$1) {
324
+ const { view = "day", id } = props$1;
325
+ return [view, id].filter(Boolean).join(" ");
326
+ }
327
+ return {
328
+ focused,
329
+ open,
330
+ disabled,
331
+ invalid,
332
+ inline: !!prop("inline"),
333
+ view: context.get("view"),
334
+ getRangePresetValue(preset) {
335
+ return getDateRangePreset(preset, locale, timeZone);
336
+ },
337
+ getDaysInWeek(week, from = startValue) {
338
+ return getDaysInWeek(week, from, locale, startOfWeek$1);
339
+ },
340
+ getOffset(duration) {
341
+ const from = startValue.add(duration);
342
+ const end = endValue.add(duration);
343
+ const formatter = getMonthFormatter(locale, timeZone);
344
+ return {
345
+ visibleRange: {
346
+ start: from,
347
+ end
348
+ },
349
+ weeks: getMonthWeeks(from),
350
+ visibleRangeText: {
351
+ start: formatter.format(from.toDate(timeZone)),
352
+ end: formatter.format(end.toDate(timeZone))
353
+ }
354
+ };
355
+ },
356
+ getMonthWeeks,
357
+ isUnavailable,
358
+ weeks: getMonthWeeks(),
359
+ weekDays: getWeekDays(getTodayDate(timeZone), startOfWeek$1, timeZone, locale),
360
+ visibleRangeText: computed("visibleRangeText"),
361
+ value: selectedValue,
362
+ valueAsDate: selectedValue.filter((date) => date != null).map((date) => date.toDate(timeZone)),
363
+ valueAsString: computed("valueAsString"),
364
+ focusedValue,
365
+ focusedValueAsDate: focusedValue?.toDate(timeZone),
366
+ focusedValueAsString: prop("format")(focusedValue, {
367
+ locale,
368
+ timeZone
369
+ }),
370
+ visibleRange: computed("visibleRange"),
371
+ selectToday() {
372
+ send({
373
+ type: "VALUE.SET",
374
+ value: constrainValue(getTodayDate(timeZone), min, max)
375
+ });
376
+ },
377
+ setValue(values) {
378
+ send({
379
+ type: "VALUE.SET",
380
+ value: values.map((date) => constrainValue(date, min, max))
381
+ });
382
+ },
383
+ clearValue() {
384
+ send({ type: "VALUE.CLEAR" });
385
+ },
386
+ setFocusedValue(value) {
387
+ send({
388
+ type: "FOCUS.SET",
389
+ value
390
+ });
391
+ },
392
+ setOpen(nextOpen) {
393
+ if (prop("inline")) return;
394
+ if (state.matches("open") === nextOpen) return;
395
+ send({ type: nextOpen ? "OPEN" : "CLOSE" });
396
+ },
397
+ focusMonth,
398
+ focusYear,
399
+ getYears,
400
+ getMonths,
401
+ getYearsGrid(props$1 = {}) {
402
+ const { columns = 1 } = props$1;
403
+ return chunk(getDecadeYears(), columns);
404
+ },
405
+ getDecade() {
406
+ const years = getDecadeRange(focusedValue.year);
407
+ return {
408
+ start: years.at(0),
409
+ end: years.at(-1)
410
+ };
411
+ },
412
+ getMonthsGrid(props$1 = {}) {
413
+ const { columns = 1, format } = props$1;
414
+ return chunk(getMonths({ format }), columns);
415
+ },
416
+ format(value, opts = {
417
+ month: "long",
418
+ year: "numeric"
419
+ }) {
420
+ return new DateFormatter(locale, opts).format(value.toDate(timeZone));
421
+ },
422
+ setView(view) {
423
+ send({
424
+ type: "VIEW.SET",
425
+ view
426
+ });
427
+ },
428
+ goToNext() {
429
+ send({
430
+ type: "GOTO.NEXT",
431
+ view: context.get("view")
432
+ });
433
+ },
434
+ goToPrev() {
435
+ send({
436
+ type: "GOTO.PREV",
437
+ view: context.get("view")
438
+ });
439
+ },
440
+ getRootProps() {
441
+ return normalize.element({
442
+ ...parts.root.attrs,
443
+ dir: prop("dir"),
444
+ id: getRootId(scope),
445
+ "data-state": open ? "open" : "closed",
446
+ "data-disabled": dataAttr(disabled),
447
+ "data-readonly": dataAttr(readOnly)
448
+ });
449
+ },
450
+ getLabelProps(props$1 = {}) {
451
+ const { index = 0 } = props$1;
452
+ return normalize.label({
453
+ ...parts.label.attrs,
454
+ id: getLabelId(scope, index),
455
+ dir: prop("dir"),
456
+ htmlFor: getInputId(scope, index),
457
+ "data-state": open ? "open" : "closed",
458
+ "data-index": index,
459
+ "data-disabled": dataAttr(disabled),
460
+ "data-readonly": dataAttr(readOnly)
461
+ });
462
+ },
463
+ getControlProps() {
464
+ return normalize.element({
465
+ ...parts.control.attrs,
466
+ dir: prop("dir"),
467
+ id: getControlId(scope),
468
+ "data-disabled": dataAttr(disabled)
469
+ });
470
+ },
471
+ getRangeTextProps() {
472
+ return normalize.element({
473
+ ...parts.rangeText.attrs,
474
+ dir: prop("dir")
475
+ });
476
+ },
477
+ getContentProps() {
478
+ return normalize.element({
479
+ ...parts.content.attrs,
480
+ hidden: !open,
481
+ dir: prop("dir"),
482
+ "data-state": open ? "open" : "closed",
483
+ "data-placement": currentPlacement,
484
+ "data-inline": dataAttr(prop("inline")),
485
+ id: getContentId(scope),
486
+ tabIndex: -1,
487
+ role: "application",
488
+ "aria-roledescription": "datepicker",
489
+ "aria-label": translations.content
490
+ });
491
+ },
492
+ getTableProps(props$1 = {}) {
493
+ const { view = "day", columns = view === "day" ? 7 : 4 } = props$1;
494
+ const uid = getTableId$1(props$1);
495
+ return normalize.element({
496
+ ...parts.table.attrs,
497
+ role: "grid",
498
+ "data-columns": columns,
499
+ "aria-roledescription": getRoleDescription(view),
500
+ id: getTableId(scope, uid),
501
+ "aria-readonly": ariaAttr(readOnly),
502
+ "aria-disabled": ariaAttr(disabled),
503
+ "aria-multiselectable": ariaAttr(prop("selectionMode") !== "single"),
504
+ "data-view": view,
505
+ dir: prop("dir"),
506
+ tabIndex: -1,
507
+ onKeyDown(event) {
508
+ if (event.defaultPrevented) return;
509
+ const exec = {
510
+ Enter() {
511
+ if (view === "day" && isUnavailable(focusedValue)) return;
512
+ if (view === "month") {
513
+ if (!getMonthTableCellState({ value: focusedValue.month }).selectable) return;
514
+ }
515
+ if (view === "year") {
516
+ if (!getYearTableCellState({ value: focusedValue.year }).selectable) return;
517
+ }
518
+ send({
519
+ type: "TABLE.ENTER",
520
+ view,
521
+ columns,
522
+ focus: true
523
+ });
524
+ },
525
+ ArrowLeft() {
526
+ send({
527
+ type: "TABLE.ARROW_LEFT",
528
+ view,
529
+ columns,
530
+ focus: true
531
+ });
532
+ },
533
+ ArrowRight() {
534
+ send({
535
+ type: "TABLE.ARROW_RIGHT",
536
+ view,
537
+ columns,
538
+ focus: true
539
+ });
540
+ },
541
+ ArrowUp() {
542
+ send({
543
+ type: "TABLE.ARROW_UP",
544
+ view,
545
+ columns,
546
+ focus: true
547
+ });
548
+ },
549
+ ArrowDown() {
550
+ send({
551
+ type: "TABLE.ARROW_DOWN",
552
+ view,
553
+ columns,
554
+ focus: true
555
+ });
556
+ },
557
+ PageUp(event$1) {
558
+ send({
559
+ type: "TABLE.PAGE_UP",
560
+ larger: event$1.shiftKey,
561
+ view,
562
+ columns,
563
+ focus: true
564
+ });
565
+ },
566
+ PageDown(event$1) {
567
+ send({
568
+ type: "TABLE.PAGE_DOWN",
569
+ larger: event$1.shiftKey,
570
+ view,
571
+ columns,
572
+ focus: true
573
+ });
574
+ },
575
+ Home() {
576
+ send({
577
+ type: "TABLE.HOME",
578
+ view,
579
+ columns,
580
+ focus: true
581
+ });
582
+ },
583
+ End() {
584
+ send({
585
+ type: "TABLE.END",
586
+ view,
587
+ columns,
588
+ focus: true
589
+ });
590
+ }
591
+ }[getEventKey(event, { dir: prop("dir") })];
592
+ if (exec) {
593
+ exec(event);
594
+ event.preventDefault();
595
+ event.stopPropagation();
596
+ }
597
+ },
598
+ onPointerLeave() {
599
+ send({ type: "TABLE.POINTER_LEAVE" });
600
+ },
601
+ onPointerDown() {
602
+ send({
603
+ type: "TABLE.POINTER_DOWN",
604
+ view
605
+ });
606
+ },
607
+ onPointerUp() {
608
+ send({
609
+ type: "TABLE.POINTER_UP",
610
+ view
611
+ });
612
+ }
613
+ });
614
+ },
615
+ getTableHeadProps(props$1 = {}) {
616
+ const { view = "day" } = props$1;
617
+ return normalize.element({
618
+ ...parts.tableHead.attrs,
619
+ "aria-hidden": true,
620
+ dir: prop("dir"),
621
+ "data-view": view,
622
+ "data-disabled": dataAttr(disabled)
623
+ });
624
+ },
625
+ getTableHeaderProps(props$1 = {}) {
626
+ const { view = "day" } = props$1;
627
+ return normalize.element({
628
+ ...parts.tableHeader.attrs,
629
+ dir: prop("dir"),
630
+ "data-view": view,
631
+ "data-disabled": dataAttr(disabled)
632
+ });
633
+ },
634
+ getTableBodyProps(props$1 = {}) {
635
+ const { view = "day" } = props$1;
636
+ return normalize.element({
637
+ ...parts.tableBody.attrs,
638
+ "data-view": view,
639
+ "data-disabled": dataAttr(disabled)
640
+ });
641
+ },
642
+ getTableRowProps(props$1 = {}) {
643
+ const { view = "day" } = props$1;
644
+ return normalize.element({
645
+ ...parts.tableRow.attrs,
646
+ "aria-disabled": ariaAttr(disabled),
647
+ "data-disabled": dataAttr(disabled),
648
+ "data-view": view
649
+ });
650
+ },
651
+ getDayTableCellState,
652
+ getDayTableCellProps(props$1) {
653
+ const { value } = props$1;
654
+ const cellState = getDayTableCellState(props$1);
655
+ return normalize.element({
656
+ ...parts.tableCell.attrs,
657
+ role: "gridcell",
658
+ "aria-disabled": ariaAttr(!cellState.selectable),
659
+ "aria-selected": cellState.selected || cellState.inRange,
660
+ "aria-invalid": ariaAttr(cellState.invalid),
661
+ "aria-current": cellState.today ? "date" : void 0,
662
+ "data-value": value.toString()
663
+ });
664
+ },
665
+ getDayTableCellTriggerProps(props$1) {
666
+ const { value } = props$1;
667
+ const cellState = getDayTableCellState(props$1);
668
+ return normalize.element({
669
+ ...parts.tableCellTrigger.attrs,
670
+ id: getCellTriggerId(scope, value.toString()),
671
+ role: "button",
672
+ dir: prop("dir"),
673
+ tabIndex: cellState.focused ? 0 : -1,
674
+ "aria-label": cellState.ariaLabel,
675
+ "aria-disabled": ariaAttr(!cellState.selectable),
676
+ "aria-invalid": ariaAttr(cellState.invalid),
677
+ "data-disabled": dataAttr(!cellState.selectable),
678
+ "data-selected": dataAttr(cellState.selected),
679
+ "data-value": value.toString(),
680
+ "data-view": "day",
681
+ "data-today": dataAttr(cellState.today),
682
+ "data-focus": dataAttr(cellState.focused),
683
+ "data-unavailable": dataAttr(cellState.unavailable),
684
+ "data-range-start": dataAttr(cellState.firstInRange),
685
+ "data-range-end": dataAttr(cellState.lastInRange),
686
+ "data-in-range": dataAttr(cellState.inRange),
687
+ "data-outside-range": dataAttr(cellState.outsideRange),
688
+ "data-weekend": dataAttr(cellState.weekend),
689
+ "data-in-hover-range": dataAttr(cellState.inHoveredRange),
690
+ "data-hover-range-start": dataAttr(cellState.firstInHoveredRange),
691
+ "data-hover-range-end": dataAttr(cellState.lastInHoveredRange),
692
+ onClick(event) {
693
+ if (event.defaultPrevented) return;
694
+ if (!cellState.selectable) return;
695
+ send({
696
+ type: "CELL.CLICK",
697
+ cell: "day",
698
+ value
699
+ });
700
+ },
701
+ onPointerMove: isRangePicker ? (event) => {
702
+ if (event.pointerType === "touch") return;
703
+ if (!cellState.selectable) return;
704
+ const focus = !scope.isActiveElement(event.currentTarget);
705
+ if (hoveredValue && isEqualDay(value, hoveredValue)) return;
706
+ send({
707
+ type: "CELL.POINTER_MOVE",
708
+ cell: "day",
709
+ value,
710
+ focus
711
+ });
712
+ } : void 0
713
+ });
714
+ },
715
+ getMonthTableCellState,
716
+ getMonthTableCellProps(props$1) {
717
+ const { value, columns } = props$1;
718
+ const cellState = getMonthTableCellState(props$1);
719
+ return normalize.element({
720
+ ...parts.tableCell.attrs,
721
+ dir: prop("dir"),
722
+ colSpan: columns,
723
+ role: "gridcell",
724
+ "aria-selected": ariaAttr(cellState.selected || cellState.inRange),
725
+ "data-selected": dataAttr(cellState.selected),
726
+ "aria-disabled": ariaAttr(!cellState.selectable),
727
+ "data-value": value
728
+ });
729
+ },
730
+ getMonthTableCellTriggerProps(props$1) {
731
+ const { value } = props$1;
732
+ const cellState = getMonthTableCellState(props$1);
733
+ return normalize.element({
734
+ ...parts.tableCellTrigger.attrs,
735
+ dir: prop("dir"),
736
+ role: "button",
737
+ id: getCellTriggerId(scope, value.toString()),
738
+ "data-selected": dataAttr(cellState.selected),
739
+ "aria-disabled": ariaAttr(!cellState.selectable),
740
+ "data-disabled": dataAttr(!cellState.selectable),
741
+ "data-focus": dataAttr(cellState.focused),
742
+ "data-in-range": dataAttr(cellState.inRange),
743
+ "data-outside-range": dataAttr(cellState.outsideRange),
744
+ "aria-label": cellState.valueText,
745
+ "data-view": "month",
746
+ "data-value": value,
747
+ tabIndex: cellState.focused ? 0 : -1,
748
+ onClick(event) {
749
+ if (event.defaultPrevented) return;
750
+ if (!cellState.selectable) return;
751
+ send({
752
+ type: "CELL.CLICK",
753
+ cell: "month",
754
+ value
755
+ });
756
+ },
757
+ onPointerMove: isRangePicker ? (event) => {
758
+ if (event.pointerType === "touch") return;
759
+ if (!cellState.selectable) return;
760
+ const focus = !scope.isActiveElement(event.currentTarget);
761
+ if (hoveredValue && cellState.value && isEqualMonth(cellState.value, hoveredValue)) return;
762
+ send({
763
+ type: "CELL.POINTER_MOVE",
764
+ cell: "month",
765
+ value: cellState.value,
766
+ focus
767
+ });
768
+ } : void 0
769
+ });
770
+ },
771
+ getYearTableCellState,
772
+ getYearTableCellProps(props$1) {
773
+ const { value, columns } = props$1;
774
+ const cellState = getYearTableCellState(props$1);
775
+ return normalize.element({
776
+ ...parts.tableCell.attrs,
777
+ dir: prop("dir"),
778
+ colSpan: columns,
779
+ role: "gridcell",
780
+ "aria-selected": ariaAttr(cellState.selected),
781
+ "data-selected": dataAttr(cellState.selected),
782
+ "aria-disabled": ariaAttr(!cellState.selectable),
783
+ "data-value": value
784
+ });
785
+ },
786
+ getYearTableCellTriggerProps(props$1) {
787
+ const { value } = props$1;
788
+ const cellState = getYearTableCellState(props$1);
789
+ return normalize.element({
790
+ ...parts.tableCellTrigger.attrs,
791
+ dir: prop("dir"),
792
+ role: "button",
793
+ id: getCellTriggerId(scope, value.toString()),
794
+ "data-selected": dataAttr(cellState.selected),
795
+ "data-focus": dataAttr(cellState.focused),
796
+ "data-in-range": dataAttr(cellState.inRange),
797
+ "aria-disabled": ariaAttr(!cellState.selectable),
798
+ "data-disabled": dataAttr(!cellState.selectable),
799
+ "aria-label": cellState.valueText,
800
+ "data-outside-range": dataAttr(cellState.outsideRange),
801
+ "data-value": value,
802
+ "data-view": "year",
803
+ tabIndex: cellState.focused ? 0 : -1,
804
+ onClick(event) {
805
+ if (event.defaultPrevented) return;
806
+ if (!cellState.selectable) return;
807
+ send({
808
+ type: "CELL.CLICK",
809
+ cell: "year",
810
+ value
811
+ });
812
+ },
813
+ onPointerMove: isRangePicker ? (event) => {
814
+ if (event.pointerType === "touch") return;
815
+ if (!cellState.selectable) return;
816
+ const focus = !scope.isActiveElement(event.currentTarget);
817
+ if (hoveredValue && cellState.value && isEqualYear(cellState.value, hoveredValue)) return;
818
+ send({
819
+ type: "CELL.POINTER_MOVE",
820
+ cell: "year",
821
+ value: cellState.value,
822
+ focus
823
+ });
824
+ } : void 0
825
+ });
826
+ },
827
+ getNextTriggerProps(props$1 = {}) {
828
+ const { view = "day" } = props$1;
829
+ const isDisabled = disabled || !computed("isNextVisibleRangeValid");
830
+ return normalize.button({
831
+ ...parts.nextTrigger.attrs,
832
+ dir: prop("dir"),
833
+ id: getNextTriggerId(scope, view),
834
+ type: "button",
835
+ "aria-label": translations.nextTrigger(view),
836
+ disabled: isDisabled,
837
+ "data-disabled": dataAttr(isDisabled),
838
+ onClick(event) {
839
+ if (event.defaultPrevented) return;
840
+ send({
841
+ type: "GOTO.NEXT",
842
+ view
843
+ });
844
+ }
845
+ });
846
+ },
847
+ getPrevTriggerProps(props$1 = {}) {
848
+ const { view = "day" } = props$1;
849
+ const isDisabled = disabled || !computed("isPrevVisibleRangeValid");
850
+ return normalize.button({
851
+ ...parts.prevTrigger.attrs,
852
+ dir: prop("dir"),
853
+ id: getPrevTriggerId(scope, view),
854
+ type: "button",
855
+ "aria-label": translations.prevTrigger(view),
856
+ disabled: isDisabled,
857
+ "data-disabled": dataAttr(isDisabled),
858
+ onClick(event) {
859
+ if (event.defaultPrevented) return;
860
+ send({
861
+ type: "GOTO.PREV",
862
+ view
863
+ });
864
+ }
865
+ });
866
+ },
867
+ getClearTriggerProps() {
868
+ return normalize.button({
869
+ ...parts.clearTrigger.attrs,
870
+ id: getClearTriggerId(scope),
871
+ dir: prop("dir"),
872
+ type: "button",
873
+ "aria-label": translations.clearTrigger,
874
+ hidden: !selectedValue.length,
875
+ onClick(event) {
876
+ if (event.defaultPrevented) return;
877
+ send({ type: "VALUE.CLEAR" });
878
+ }
879
+ });
880
+ },
881
+ getTriggerProps() {
882
+ return normalize.button({
883
+ ...parts.trigger.attrs,
884
+ id: getTriggerId(scope),
885
+ dir: prop("dir"),
886
+ type: "button",
887
+ "data-placement": currentPlacement,
888
+ "aria-label": translations.trigger(open),
889
+ "aria-controls": getContentId(scope),
890
+ "data-state": open ? "open" : "closed",
891
+ "aria-haspopup": "grid",
892
+ disabled,
893
+ onClick(event) {
894
+ if (event.defaultPrevented) return;
895
+ if (!interactive) return;
896
+ send({ type: "TRIGGER.CLICK" });
897
+ }
898
+ });
899
+ },
900
+ getViewProps(props$1 = {}) {
901
+ const { view = "day" } = props$1;
902
+ return normalize.element({
903
+ ...parts.view.attrs,
904
+ "data-view": view,
905
+ hidden: context.get("view") !== view
906
+ });
907
+ },
908
+ getViewTriggerProps(props$1 = {}) {
909
+ const { view = "day" } = props$1;
910
+ return normalize.button({
911
+ ...parts.viewTrigger.attrs,
912
+ "data-view": view,
913
+ dir: prop("dir"),
914
+ id: getViewTriggerId(scope, view),
915
+ type: "button",
916
+ disabled,
917
+ "aria-label": translations.viewTrigger(view),
918
+ onClick(event) {
919
+ if (event.defaultPrevented) return;
920
+ if (!interactive) return;
921
+ send({
922
+ type: "VIEW.TOGGLE",
923
+ src: "viewTrigger"
924
+ });
925
+ }
926
+ });
927
+ },
928
+ getViewControlProps(props$1 = {}) {
929
+ const { view = "day" } = props$1;
930
+ return normalize.element({
931
+ ...parts.viewControl.attrs,
932
+ "data-view": view,
933
+ dir: prop("dir")
934
+ });
935
+ },
936
+ getInputProps(props$1 = {}) {
937
+ const { index = 0, fixOnBlur = true } = props$1;
938
+ return normalize.input({
939
+ ...parts.input.attrs,
940
+ id: getInputId(scope, index),
941
+ autoComplete: "off",
942
+ autoCorrect: "off",
943
+ spellCheck: "false",
944
+ dir: prop("dir"),
945
+ name: prop("name"),
946
+ "data-index": index,
947
+ "data-state": open ? "open" : "closed",
948
+ readOnly,
949
+ disabled,
950
+ required: prop("required"),
951
+ "aria-invalid": ariaAttr(invalid),
952
+ "data-invalid": dataAttr(invalid),
953
+ placeholder: prop("placeholder") || getInputPlaceholder(locale),
954
+ defaultValue: computed("valueAsString")[index],
955
+ onBeforeInput(event) {
956
+ const { data } = getNativeEvent(event);
957
+ if (!isValidCharacter(data, separator)) event.preventDefault();
958
+ },
959
+ onFocus() {
960
+ send({
961
+ type: "INPUT.FOCUS",
962
+ index
963
+ });
964
+ },
965
+ onBlur(event) {
966
+ send({
967
+ type: "INPUT.BLUR",
968
+ value: event.currentTarget.value.trim(),
969
+ index,
970
+ fixOnBlur
971
+ });
972
+ },
973
+ onKeyDown(event) {
974
+ if (event.defaultPrevented) return;
975
+ if (!interactive) return;
976
+ const exec = { Enter(event$1) {
977
+ if (isComposingEvent(event$1)) return;
978
+ if (isUnavailable(focusedValue)) return;
979
+ if (event$1.currentTarget.value.trim() === "") return;
980
+ send({
981
+ type: "INPUT.ENTER",
982
+ value: event$1.currentTarget.value,
983
+ index
984
+ });
985
+ } }[event.key];
986
+ if (exec) {
987
+ exec(event);
988
+ event.preventDefault();
989
+ }
990
+ },
991
+ onInput(event) {
992
+ const value = event.currentTarget.value;
993
+ send({
994
+ type: "INPUT.CHANGE",
995
+ value: ensureValidCharacters(value, separator),
996
+ index
997
+ });
998
+ }
999
+ });
1000
+ },
1001
+ getMonthSelectProps() {
1002
+ return normalize.select({
1003
+ ...parts.monthSelect.attrs,
1004
+ id: getMonthSelectId(scope),
1005
+ "aria-label": translations.monthSelect,
1006
+ disabled,
1007
+ dir: prop("dir"),
1008
+ defaultValue: startValue.month,
1009
+ onChange(event) {
1010
+ focusMonth(Number(event.currentTarget.value));
1011
+ }
1012
+ });
1013
+ },
1014
+ getYearSelectProps() {
1015
+ return normalize.select({
1016
+ ...parts.yearSelect.attrs,
1017
+ id: getYearSelectId(scope),
1018
+ disabled,
1019
+ "aria-label": translations.yearSelect,
1020
+ dir: prop("dir"),
1021
+ defaultValue: startValue.year,
1022
+ onChange(event) {
1023
+ focusYear(Number(event.currentTarget.value));
1024
+ }
1025
+ });
1026
+ },
1027
+ getPositionerProps() {
1028
+ return normalize.element({
1029
+ id: getPositionerId(scope),
1030
+ ...parts.positioner.attrs,
1031
+ dir: prop("dir"),
1032
+ style: popperStyles.floating
1033
+ });
1034
+ },
1035
+ getPresetTriggerProps(props$1) {
1036
+ const value = Array.isArray(props$1.value) ? props$1.value : getDateRangePreset(props$1.value, locale, timeZone);
1037
+ const valueAsString = value.filter((item) => item != null).map((item) => item.toDate(timeZone).toDateString());
1038
+ return normalize.button({
1039
+ ...parts.presetTrigger.attrs,
1040
+ "aria-label": translations.presetTrigger(valueAsString),
1041
+ type: "button",
1042
+ onClick(event) {
1043
+ if (event.defaultPrevented) return;
1044
+ send({
1045
+ type: "PRESET.CLICK",
1046
+ value
1047
+ });
1048
+ }
1049
+ });
1050
+ }
1051
+ };
1052
+ }
1053
+
1054
+ //#endregion
1055
+ //#region src/machines/date-picker/date-picker.machine.ts
1056
+ const { and } = createGuards();
1057
+ function isDateArrayEqual(a, b) {
1058
+ if (a?.length !== b?.length) return false;
1059
+ const len = Math.max(a.length, b.length);
1060
+ for (let i = 0; i < len; i++) if (!isDateEqual(a[i], b[i])) return false;
1061
+ return true;
1062
+ }
1063
+ function getValueAsString(value, prop) {
1064
+ return value.map((date) => {
1065
+ if (date == null) return "";
1066
+ return prop("format")(date, {
1067
+ locale: prop("locale"),
1068
+ timeZone: prop("timeZone")
1069
+ });
1070
+ });
1071
+ }
1072
+ const machine = createMachine({
1073
+ props({ props: props$1 }) {
1074
+ const locale = props$1.locale || "en-US";
1075
+ const timeZone = props$1.timeZone || "UTC";
1076
+ const selectionMode = props$1.selectionMode || "single";
1077
+ const numOfMonths = props$1.numOfMonths || 1;
1078
+ const defaultValue = props$1.defaultValue ? sortDates(props$1.defaultValue).map((date) => constrainValue(date, props$1.min, props$1.max)) : void 0;
1079
+ const value = props$1.value ? sortDates(props$1.value).map((date) => constrainValue(date, props$1.min, props$1.max)) : void 0;
1080
+ let focusedValue = props$1.focusedValue || props$1.defaultFocusedValue || value?.[0] || defaultValue?.[0] || getTodayDate(timeZone);
1081
+ focusedValue = constrainValue(focusedValue, props$1.min, props$1.max);
1082
+ const minView = "day";
1083
+ const maxView = "year";
1084
+ return {
1085
+ locale,
1086
+ numOfMonths,
1087
+ timeZone,
1088
+ selectionMode,
1089
+ defaultView: clampView(props$1.view || minView, minView, maxView),
1090
+ minView,
1091
+ maxView,
1092
+ outsideDaySelectable: false,
1093
+ closeOnSelect: true,
1094
+ format(date, { locale: locale$1, timeZone: timeZone$1 }) {
1095
+ return new DateFormatter(locale$1, {
1096
+ timeZone: timeZone$1,
1097
+ day: "2-digit",
1098
+ month: "2-digit",
1099
+ year: "numeric"
1100
+ }).format(date.toDate(timeZone$1));
1101
+ },
1102
+ parse(value$1, { locale: locale$1, timeZone: timeZone$1 }) {
1103
+ return parseDateString(value$1, locale$1, timeZone$1);
1104
+ },
1105
+ ...props$1,
1106
+ focusedValue: typeof props$1.focusedValue === "undefined" ? void 0 : focusedValue,
1107
+ defaultFocusedValue: focusedValue,
1108
+ value,
1109
+ defaultValue: defaultValue ?? [],
1110
+ positioning: {
1111
+ placement: "bottom",
1112
+ ...props$1.positioning
1113
+ }
1114
+ };
1115
+ },
1116
+ initialState({ prop }) {
1117
+ return prop("open") || prop("defaultOpen") || prop("inline") ? "open" : "idle";
1118
+ },
1119
+ refs() {
1120
+ return { announcer: void 0 };
1121
+ },
1122
+ context({ prop, bindable, getContext }) {
1123
+ return {
1124
+ focusedValue: bindable(() => ({
1125
+ defaultValue: prop("defaultFocusedValue"),
1126
+ value: prop("focusedValue"),
1127
+ isEqual: isDateEqual,
1128
+ hash: (v) => v.toString(),
1129
+ sync: true,
1130
+ onChange(focusedValue) {
1131
+ const context = getContext();
1132
+ const view = context.get("view");
1133
+ const value = context.get("value");
1134
+ const valueAsString = getValueAsString(value, prop);
1135
+ prop("onFocusChange")?.({
1136
+ value,
1137
+ valueAsString,
1138
+ view,
1139
+ focusedValue
1140
+ });
1141
+ }
1142
+ })),
1143
+ value: bindable(() => ({
1144
+ defaultValue: prop("defaultValue"),
1145
+ value: prop("value"),
1146
+ isEqual: isDateArrayEqual,
1147
+ hash: (v) => v.map((date) => date?.toString() ?? "").join(","),
1148
+ onChange(value) {
1149
+ const context = getContext();
1150
+ const valueAsString = getValueAsString(value, prop);
1151
+ prop("onValueChange")?.({
1152
+ value,
1153
+ valueAsString,
1154
+ view: context.get("view")
1155
+ });
1156
+ }
1157
+ })),
1158
+ inputValue: bindable(() => ({ defaultValue: "" })),
1159
+ activeIndex: bindable(() => ({
1160
+ defaultValue: 0,
1161
+ sync: true
1162
+ })),
1163
+ hoveredValue: bindable(() => ({
1164
+ defaultValue: null,
1165
+ isEqual: isDateEqual
1166
+ })),
1167
+ view: bindable(() => ({
1168
+ defaultValue: prop("defaultView"),
1169
+ value: prop("view"),
1170
+ onChange(value) {
1171
+ prop("onViewChange")?.({ view: value });
1172
+ }
1173
+ })),
1174
+ startValue: bindable(() => {
1175
+ return {
1176
+ defaultValue: alignDate(prop("focusedValue") || prop("defaultFocusedValue"), "start", { months: prop("numOfMonths") }, prop("locale")),
1177
+ isEqual: isDateEqual,
1178
+ hash: (v) => v.toString()
1179
+ };
1180
+ }),
1181
+ currentPlacement: bindable(() => ({ defaultValue: void 0 })),
1182
+ restoreFocus: bindable(() => ({ defaultValue: false }))
1183
+ };
1184
+ },
1185
+ computed: {
1186
+ isInteractive: ({ prop }) => !prop("disabled") && !prop("readOnly"),
1187
+ visibleDuration: ({ prop }) => ({ months: prop("numOfMonths") }),
1188
+ endValue: ({ context, computed }) => getEndDate(context.get("startValue"), computed("visibleDuration")),
1189
+ visibleRange: ({ context, computed }) => ({
1190
+ start: context.get("startValue"),
1191
+ end: computed("endValue")
1192
+ }),
1193
+ visibleRangeText({ context, prop, computed }) {
1194
+ const timeZone = prop("timeZone");
1195
+ const formatter = new DateFormatter(prop("locale"), {
1196
+ month: "long",
1197
+ year: "numeric",
1198
+ timeZone
1199
+ });
1200
+ const start = formatter.format(context.get("startValue").toDate(timeZone));
1201
+ const end = formatter.format(computed("endValue").toDate(timeZone));
1202
+ return {
1203
+ start,
1204
+ end,
1205
+ formatted: prop("selectionMode") === "range" ? `${start} - ${end}` : start
1206
+ };
1207
+ },
1208
+ isPrevVisibleRangeValid: ({ context, prop }) => !isPreviousRangeInvalid(context.get("startValue"), prop("min"), prop("max")),
1209
+ isNextVisibleRangeValid: ({ prop, computed }) => !isNextRangeInvalid(computed("endValue"), prop("min"), prop("max")),
1210
+ valueAsString: ({ context, prop }) => getValueAsString(context.get("value"), prop)
1211
+ },
1212
+ effects: ["setupLiveRegion"],
1213
+ watch({ track, prop, context, action, computed }) {
1214
+ track([() => prop("locale")], () => {
1215
+ action(["setStartValue", "syncInputElement"]);
1216
+ });
1217
+ track([() => context.hash("focusedValue")], () => {
1218
+ action([
1219
+ "setStartValue",
1220
+ "focusActiveCellIfNeeded",
1221
+ "setHoveredValueIfKeyboard"
1222
+ ]);
1223
+ });
1224
+ track([() => context.hash("startValue")], () => {
1225
+ action(["syncMonthSelectElement", "syncYearSelectElement"]);
1226
+ });
1227
+ track([() => context.get("inputValue")], () => {
1228
+ action(["syncInputValue"]);
1229
+ });
1230
+ track([() => context.hash("value")], () => {
1231
+ action(["syncInputElement"]);
1232
+ });
1233
+ track([() => computed("valueAsString").toString()], () => {
1234
+ action(["announceValueText"]);
1235
+ });
1236
+ track([() => context.get("view")], () => {
1237
+ action(["focusActiveCell"]);
1238
+ });
1239
+ track([() => prop("open")], () => {
1240
+ action(["toggleVisibility"]);
1241
+ });
1242
+ },
1243
+ on: {
1244
+ "VALUE.SET": { actions: ["setDateValue", "setFocusedDate"] },
1245
+ "VIEW.SET": { actions: ["setView"] },
1246
+ "FOCUS.SET": { actions: ["setFocusedDate"] },
1247
+ "VALUE.CLEAR": { actions: [
1248
+ "clearDateValue",
1249
+ "clearFocusedDate",
1250
+ "focusFirstInputElement"
1251
+ ] },
1252
+ "INPUT.CHANGE": [{
1253
+ guard: "isInputValueEmpty",
1254
+ actions: [
1255
+ "setInputValue",
1256
+ "clearDateValue",
1257
+ "clearFocusedDate"
1258
+ ]
1259
+ }, { actions: ["setInputValue", "focusParsedDate"] }],
1260
+ "INPUT.ENTER": { actions: ["focusParsedDate", "selectFocusedDate"] },
1261
+ "INPUT.FOCUS": { actions: ["setActiveIndex"] },
1262
+ "INPUT.BLUR": [{
1263
+ guard: "shouldFixOnBlur",
1264
+ actions: ["setActiveIndexToStart", "selectParsedDate"]
1265
+ }, { actions: ["setActiveIndexToStart"] }],
1266
+ "PRESET.CLICK": [{
1267
+ guard: "isOpenControlled",
1268
+ actions: [
1269
+ "setDateValue",
1270
+ "setFocusedDate",
1271
+ "invokeOnClose"
1272
+ ]
1273
+ }, {
1274
+ target: "focused",
1275
+ actions: [
1276
+ "setDateValue",
1277
+ "setFocusedDate",
1278
+ "focusInputElement"
1279
+ ]
1280
+ }],
1281
+ "GOTO.NEXT": [
1282
+ {
1283
+ guard: "isYearView",
1284
+ actions: ["focusNextDecade", "announceVisibleRange"]
1285
+ },
1286
+ {
1287
+ guard: "isMonthView",
1288
+ actions: ["focusNextYear", "announceVisibleRange"]
1289
+ },
1290
+ { actions: ["focusNextPage"] }
1291
+ ],
1292
+ "GOTO.PREV": [
1293
+ {
1294
+ guard: "isYearView",
1295
+ actions: ["focusPreviousDecade", "announceVisibleRange"]
1296
+ },
1297
+ {
1298
+ guard: "isMonthView",
1299
+ actions: ["focusPreviousYear", "announceVisibleRange"]
1300
+ },
1301
+ { actions: ["focusPreviousPage"] }
1302
+ ]
1303
+ },
1304
+ states: {
1305
+ idle: {
1306
+ tags: ["closed"],
1307
+ on: {
1308
+ "CONTROLLED.OPEN": {
1309
+ target: "open",
1310
+ actions: ["focusFirstSelectedDate", "focusActiveCell"]
1311
+ },
1312
+ "TRIGGER.CLICK": [{
1313
+ guard: "isOpenControlled",
1314
+ actions: ["invokeOnOpen"]
1315
+ }, {
1316
+ target: "open",
1317
+ actions: [
1318
+ "focusFirstSelectedDate",
1319
+ "focusActiveCell",
1320
+ "invokeOnOpen"
1321
+ ]
1322
+ }],
1323
+ OPEN: [{
1324
+ guard: "isOpenControlled",
1325
+ actions: ["invokeOnOpen"]
1326
+ }, {
1327
+ target: "open",
1328
+ actions: [
1329
+ "focusFirstSelectedDate",
1330
+ "focusActiveCell",
1331
+ "invokeOnOpen"
1332
+ ]
1333
+ }]
1334
+ }
1335
+ },
1336
+ focused: {
1337
+ tags: ["closed"],
1338
+ on: {
1339
+ "CONTROLLED.OPEN": {
1340
+ target: "open",
1341
+ actions: ["focusFirstSelectedDate", "focusActiveCell"]
1342
+ },
1343
+ "TRIGGER.CLICK": [{
1344
+ guard: "isOpenControlled",
1345
+ actions: ["invokeOnOpen"]
1346
+ }, {
1347
+ target: "open",
1348
+ actions: [
1349
+ "focusFirstSelectedDate",
1350
+ "focusActiveCell",
1351
+ "invokeOnOpen"
1352
+ ]
1353
+ }],
1354
+ OPEN: [{
1355
+ guard: "isOpenControlled",
1356
+ actions: ["invokeOnOpen"]
1357
+ }, {
1358
+ target: "open",
1359
+ actions: [
1360
+ "focusFirstSelectedDate",
1361
+ "focusActiveCell",
1362
+ "invokeOnOpen"
1363
+ ]
1364
+ }]
1365
+ }
1366
+ },
1367
+ open: {
1368
+ tags: ["open"],
1369
+ effects: ["trackDismissableElement", "trackPositioning"],
1370
+ exit: ["clearHoveredDate", "resetView"],
1371
+ on: {
1372
+ "CONTROLLED.CLOSE": [
1373
+ {
1374
+ guard: and("shouldRestoreFocus", "isInteractOutsideEvent"),
1375
+ target: "focused",
1376
+ actions: ["focusTriggerElement"]
1377
+ },
1378
+ {
1379
+ guard: "shouldRestoreFocus",
1380
+ target: "focused",
1381
+ actions: ["focusInputElement"]
1382
+ },
1383
+ { target: "idle" }
1384
+ ],
1385
+ "CELL.CLICK": [
1386
+ {
1387
+ guard: "isAboveMinView",
1388
+ actions: ["setFocusedValueForView", "setPreviousView"]
1389
+ },
1390
+ {
1391
+ guard: and("isRangePicker", "hasSelectedRange"),
1392
+ actions: [
1393
+ "setActiveIndexToStart",
1394
+ "resetSelection",
1395
+ "setActiveIndexToEnd"
1396
+ ]
1397
+ },
1398
+ {
1399
+ guard: and("isRangePicker", "isSelectingEndDate", "closeOnSelect", "isOpenControlled"),
1400
+ actions: [
1401
+ "setFocusedDate",
1402
+ "setSelectedDate",
1403
+ "setActiveIndexToStart",
1404
+ "clearHoveredDate",
1405
+ "invokeOnClose",
1406
+ "setRestoreFocus"
1407
+ ]
1408
+ },
1409
+ {
1410
+ guard: and("isRangePicker", "isSelectingEndDate", "closeOnSelect"),
1411
+ target: "focused",
1412
+ actions: [
1413
+ "setFocusedDate",
1414
+ "setSelectedDate",
1415
+ "setActiveIndexToStart",
1416
+ "clearHoveredDate",
1417
+ "invokeOnClose",
1418
+ "focusInputElement"
1419
+ ]
1420
+ },
1421
+ {
1422
+ guard: and("isRangePicker", "isSelectingEndDate"),
1423
+ actions: [
1424
+ "setFocusedDate",
1425
+ "setSelectedDate",
1426
+ "setActiveIndexToStart",
1427
+ "clearHoveredDate"
1428
+ ]
1429
+ },
1430
+ {
1431
+ guard: "isRangePicker",
1432
+ actions: [
1433
+ "setFocusedDate",
1434
+ "setSelectedDate",
1435
+ "setActiveIndexToEnd"
1436
+ ]
1437
+ },
1438
+ {
1439
+ guard: "isMultiPicker",
1440
+ actions: ["setFocusedDate", "toggleSelectedDate"]
1441
+ },
1442
+ {
1443
+ guard: and("closeOnSelect", "isOpenControlled"),
1444
+ actions: [
1445
+ "setFocusedDate",
1446
+ "setSelectedDate",
1447
+ "invokeOnClose"
1448
+ ]
1449
+ },
1450
+ {
1451
+ guard: "closeOnSelect",
1452
+ target: "focused",
1453
+ actions: [
1454
+ "setFocusedDate",
1455
+ "setSelectedDate",
1456
+ "invokeOnClose",
1457
+ "focusInputElement"
1458
+ ]
1459
+ },
1460
+ { actions: ["setFocusedDate", "setSelectedDate"] }
1461
+ ],
1462
+ "CELL.POINTER_MOVE": {
1463
+ guard: and("isRangePicker", "isSelectingEndDate"),
1464
+ actions: ["setHoveredDate", "setFocusedDate"]
1465
+ },
1466
+ "TABLE.POINTER_LEAVE": {
1467
+ guard: "isRangePicker",
1468
+ actions: ["clearHoveredDate"]
1469
+ },
1470
+ "TABLE.POINTER_DOWN": { actions: ["disableTextSelection"] },
1471
+ "TABLE.POINTER_UP": { actions: ["enableTextSelection"] },
1472
+ "TABLE.ESCAPE": [{
1473
+ guard: "isOpenControlled",
1474
+ actions: ["focusFirstSelectedDate", "invokeOnClose"]
1475
+ }, {
1476
+ target: "focused",
1477
+ actions: [
1478
+ "focusFirstSelectedDate",
1479
+ "invokeOnClose",
1480
+ "focusTriggerElement"
1481
+ ]
1482
+ }],
1483
+ "TABLE.ENTER": [
1484
+ {
1485
+ guard: "isAboveMinView",
1486
+ actions: ["setPreviousView"]
1487
+ },
1488
+ {
1489
+ guard: and("isRangePicker", "hasSelectedRange"),
1490
+ actions: [
1491
+ "setActiveIndexToStart",
1492
+ "clearDateValue",
1493
+ "setSelectedDate",
1494
+ "setActiveIndexToEnd"
1495
+ ]
1496
+ },
1497
+ {
1498
+ guard: and("isRangePicker", "isSelectingEndDate", "closeOnSelect", "isOpenControlled"),
1499
+ actions: [
1500
+ "setSelectedDate",
1501
+ "setActiveIndexToStart",
1502
+ "clearHoveredDate",
1503
+ "invokeOnClose"
1504
+ ]
1505
+ },
1506
+ {
1507
+ guard: and("isRangePicker", "isSelectingEndDate", "closeOnSelect"),
1508
+ target: "focused",
1509
+ actions: [
1510
+ "setSelectedDate",
1511
+ "setActiveIndexToStart",
1512
+ "clearHoveredDate",
1513
+ "invokeOnClose",
1514
+ "focusInputElement"
1515
+ ]
1516
+ },
1517
+ {
1518
+ guard: and("isRangePicker", "isSelectingEndDate"),
1519
+ actions: [
1520
+ "setSelectedDate",
1521
+ "setActiveIndexToStart",
1522
+ "clearHoveredDate"
1523
+ ]
1524
+ },
1525
+ {
1526
+ guard: "isRangePicker",
1527
+ actions: [
1528
+ "setSelectedDate",
1529
+ "setActiveIndexToEnd",
1530
+ "focusNextDay"
1531
+ ]
1532
+ },
1533
+ {
1534
+ guard: "isMultiPicker",
1535
+ actions: ["toggleSelectedDate"]
1536
+ },
1537
+ {
1538
+ guard: and("closeOnSelect", "isOpenControlled"),
1539
+ actions: ["selectFocusedDate", "invokeOnClose"]
1540
+ },
1541
+ {
1542
+ guard: "closeOnSelect",
1543
+ target: "focused",
1544
+ actions: [
1545
+ "selectFocusedDate",
1546
+ "invokeOnClose",
1547
+ "focusInputElement"
1548
+ ]
1549
+ },
1550
+ { actions: ["selectFocusedDate"] }
1551
+ ],
1552
+ "TABLE.ARROW_RIGHT": [
1553
+ {
1554
+ guard: "isMonthView",
1555
+ actions: ["focusNextMonth"]
1556
+ },
1557
+ {
1558
+ guard: "isYearView",
1559
+ actions: ["focusNextYear"]
1560
+ },
1561
+ { actions: ["focusNextDay", "setHoveredDate"] }
1562
+ ],
1563
+ "TABLE.ARROW_LEFT": [
1564
+ {
1565
+ guard: "isMonthView",
1566
+ actions: ["focusPreviousMonth"]
1567
+ },
1568
+ {
1569
+ guard: "isYearView",
1570
+ actions: ["focusPreviousYear"]
1571
+ },
1572
+ { actions: ["focusPreviousDay"] }
1573
+ ],
1574
+ "TABLE.ARROW_UP": [
1575
+ {
1576
+ guard: "isMonthView",
1577
+ actions: ["focusPreviousMonthColumn"]
1578
+ },
1579
+ {
1580
+ guard: "isYearView",
1581
+ actions: ["focusPreviousYearColumn"]
1582
+ },
1583
+ { actions: ["focusPreviousWeek"] }
1584
+ ],
1585
+ "TABLE.ARROW_DOWN": [
1586
+ {
1587
+ guard: "isMonthView",
1588
+ actions: ["focusNextMonthColumn"]
1589
+ },
1590
+ {
1591
+ guard: "isYearView",
1592
+ actions: ["focusNextYearColumn"]
1593
+ },
1594
+ { actions: ["focusNextWeek"] }
1595
+ ],
1596
+ "TABLE.PAGE_UP": { actions: ["focusPreviousSection"] },
1597
+ "TABLE.PAGE_DOWN": { actions: ["focusNextSection"] },
1598
+ "TABLE.HOME": [
1599
+ {
1600
+ guard: "isMonthView",
1601
+ actions: ["focusFirstMonth"]
1602
+ },
1603
+ {
1604
+ guard: "isYearView",
1605
+ actions: ["focusFirstYear"]
1606
+ },
1607
+ { actions: ["focusSectionStart"] }
1608
+ ],
1609
+ "TABLE.END": [
1610
+ {
1611
+ guard: "isMonthView",
1612
+ actions: ["focusLastMonth"]
1613
+ },
1614
+ {
1615
+ guard: "isYearView",
1616
+ actions: ["focusLastYear"]
1617
+ },
1618
+ { actions: ["focusSectionEnd"] }
1619
+ ],
1620
+ "TRIGGER.CLICK": [{
1621
+ guard: "isOpenControlled",
1622
+ actions: ["invokeOnClose"]
1623
+ }, {
1624
+ target: "focused",
1625
+ actions: ["invokeOnClose"]
1626
+ }],
1627
+ "VIEW.TOGGLE": { actions: ["setNextView"] },
1628
+ INTERACT_OUTSIDE: [
1629
+ {
1630
+ guard: "isOpenControlled",
1631
+ actions: ["setActiveIndexToStart", "invokeOnClose"]
1632
+ },
1633
+ {
1634
+ guard: "shouldRestoreFocus",
1635
+ target: "focused",
1636
+ actions: [
1637
+ "setActiveIndexToStart",
1638
+ "invokeOnClose",
1639
+ "focusTriggerElement"
1640
+ ]
1641
+ },
1642
+ {
1643
+ target: "idle",
1644
+ actions: ["setActiveIndexToStart", "invokeOnClose"]
1645
+ }
1646
+ ],
1647
+ CLOSE: [{
1648
+ guard: "isOpenControlled",
1649
+ actions: ["setActiveIndexToStart", "invokeOnClose"]
1650
+ }, {
1651
+ target: "idle",
1652
+ actions: ["setActiveIndexToStart", "invokeOnClose"]
1653
+ }]
1654
+ }
1655
+ }
1656
+ },
1657
+ implementations: {
1658
+ guards: {
1659
+ isAboveMinView: ({ context, prop }) => isAboveMinView(context.get("view"), prop("minView")),
1660
+ isDayView: ({ context, event }) => (event.view || context.get("view")) === "day",
1661
+ isMonthView: ({ context, event }) => (event.view || context.get("view")) === "month",
1662
+ isYearView: ({ context, event }) => (event.view || context.get("view")) === "year",
1663
+ isRangePicker: ({ prop }) => prop("selectionMode") === "range",
1664
+ hasSelectedRange: ({ context }) => context.get("value").length === 2,
1665
+ isMultiPicker: ({ prop }) => prop("selectionMode") === "multiple",
1666
+ shouldRestoreFocus: ({ context }) => !!context.get("restoreFocus"),
1667
+ isSelectingEndDate: ({ context }) => context.get("activeIndex") === 1,
1668
+ closeOnSelect: ({ prop }) => !!prop("closeOnSelect"),
1669
+ isOpenControlled: ({ prop }) => prop("open") != void 0 || !!prop("inline"),
1670
+ isInteractOutsideEvent: ({ event }) => event.previousEvent?.type === "INTERACT_OUTSIDE",
1671
+ isInputValueEmpty: ({ event }) => event.value.trim() === "",
1672
+ shouldFixOnBlur: ({ event }) => !!event.fixOnBlur
1673
+ },
1674
+ effects: {
1675
+ trackPositioning({ context, prop, scope }) {
1676
+ if (prop("inline")) return;
1677
+ if (!context.get("currentPlacement")) context.set("currentPlacement", prop("positioning").placement);
1678
+ const anchorEl = getControlEl(scope);
1679
+ const getPositionerEl$1 = () => getPositionerEl(scope);
1680
+ return getPlacement(anchorEl, getPositionerEl$1, {
1681
+ ...prop("positioning"),
1682
+ defer: true,
1683
+ onComplete(data) {
1684
+ context.set("currentPlacement", data.placement);
1685
+ }
1686
+ });
1687
+ },
1688
+ setupLiveRegion({ scope, refs }) {
1689
+ const doc = scope.getDoc();
1690
+ refs.set("announcer", createLiveRegion({
1691
+ level: "assertive",
1692
+ document: doc
1693
+ }));
1694
+ return () => refs.get("announcer")?.destroy?.();
1695
+ },
1696
+ trackDismissableElement({ scope, send, context, prop }) {
1697
+ if (prop("inline")) return;
1698
+ const getContentEl$1 = () => getContentEl(scope);
1699
+ return trackDismissableElement(getContentEl$1, {
1700
+ type: "popover",
1701
+ defer: true,
1702
+ exclude: [
1703
+ ...getInputEls(scope),
1704
+ getTriggerEl(scope),
1705
+ getClearTriggerEl(scope)
1706
+ ],
1707
+ onInteractOutside(event) {
1708
+ context.set("restoreFocus", !event.detail.focusable);
1709
+ },
1710
+ onDismiss() {
1711
+ send({ type: "INTERACT_OUTSIDE" });
1712
+ },
1713
+ onEscapeKeyDown(event) {
1714
+ event.preventDefault();
1715
+ send({
1716
+ type: "TABLE.ESCAPE",
1717
+ src: "dismissable"
1718
+ });
1719
+ }
1720
+ });
1721
+ }
1722
+ },
1723
+ actions: {
1724
+ setNextView({ context, prop }) {
1725
+ const nextView = getNextView(context.get("view"), prop("minView"), prop("maxView"));
1726
+ context.set("view", nextView);
1727
+ },
1728
+ setPreviousView({ context, prop }) {
1729
+ const prevView = getPreviousView(context.get("view"), prop("minView"), prop("maxView"));
1730
+ context.set("view", prevView);
1731
+ },
1732
+ setView({ context, event }) {
1733
+ context.set("view", event.view);
1734
+ },
1735
+ setRestoreFocus({ context }) {
1736
+ context.set("restoreFocus", true);
1737
+ },
1738
+ announceValueText({ context, prop, refs }) {
1739
+ const value = context.get("value");
1740
+ const locale = prop("locale");
1741
+ const timeZone = prop("timeZone");
1742
+ let announceText;
1743
+ if (prop("selectionMode") === "range") {
1744
+ const [startDate, endDate] = value;
1745
+ if (startDate && endDate) announceText = formatSelectedDate(startDate, endDate, locale, timeZone);
1746
+ else if (startDate) announceText = formatSelectedDate(startDate, null, locale, timeZone);
1747
+ else if (endDate) announceText = formatSelectedDate(endDate, null, locale, timeZone);
1748
+ else announceText = "";
1749
+ } else announceText = value.map((date) => formatSelectedDate(date, null, locale, timeZone)).filter(Boolean).join(",");
1750
+ refs.get("announcer")?.announce(announceText, 3e3);
1751
+ },
1752
+ announceVisibleRange({ computed, refs }) {
1753
+ const { formatted } = computed("visibleRangeText");
1754
+ refs.get("announcer")?.announce(formatted);
1755
+ },
1756
+ disableTextSelection({ scope }) {
1757
+ disableTextSelection({
1758
+ target: getContentEl(scope),
1759
+ doc: scope.getDoc()
1760
+ });
1761
+ },
1762
+ enableTextSelection({ scope }) {
1763
+ restoreTextSelection({
1764
+ doc: scope.getDoc(),
1765
+ target: getContentEl(scope)
1766
+ });
1767
+ },
1768
+ focusFirstSelectedDate(params) {
1769
+ const { context } = params;
1770
+ if (!context.get("value").length) return;
1771
+ setFocusedValue(params, context.get("value")[0]);
1772
+ },
1773
+ syncInputElement({ scope, computed }) {
1774
+ raf(() => {
1775
+ getInputEls(scope).forEach((inputEl, index) => {
1776
+ setElementValue(inputEl, computed("valueAsString")[index] || "");
1777
+ });
1778
+ });
1779
+ },
1780
+ setFocusedDate(params) {
1781
+ const { event } = params;
1782
+ setFocusedValue(params, Array.isArray(event.value) ? event.value[0] : event.value);
1783
+ },
1784
+ setFocusedValueForView(params) {
1785
+ const { context, event } = params;
1786
+ setFocusedValue(params, context.get("focusedValue").set({ [context.get("view")]: event.value }));
1787
+ },
1788
+ focusNextMonth(params) {
1789
+ const { context } = params;
1790
+ setFocusedValue(params, context.get("focusedValue").add({ months: 1 }));
1791
+ },
1792
+ focusPreviousMonth(params) {
1793
+ const { context } = params;
1794
+ setFocusedValue(params, context.get("focusedValue").subtract({ months: 1 }));
1795
+ },
1796
+ setDateValue({ context, event, prop }) {
1797
+ if (!Array.isArray(event.value)) return;
1798
+ const value = event.value.map((date) => constrainValue(date, prop("min"), prop("max")));
1799
+ context.set("value", value);
1800
+ },
1801
+ clearDateValue({ context }) {
1802
+ context.set("value", []);
1803
+ },
1804
+ setSelectedDate(params) {
1805
+ const { context, event } = params;
1806
+ const values = Array.from(context.get("value"));
1807
+ values[context.get("activeIndex")] = normalizeValue(params, event.value ?? context.get("focusedValue"));
1808
+ context.set("value", adjustStartAndEndDate(values));
1809
+ },
1810
+ resetSelection(params) {
1811
+ const { context, event } = params;
1812
+ const value = normalizeValue(params, event.value ?? context.get("focusedValue"));
1813
+ context.set("value", [value]);
1814
+ },
1815
+ toggleSelectedDate(params) {
1816
+ const { context, event } = params;
1817
+ const currentValue = normalizeValue(params, event.value ?? context.get("focusedValue"));
1818
+ const index = context.get("value").findIndex((date) => isDateEqual(date, currentValue));
1819
+ if (index === -1) {
1820
+ const values = [...context.get("value"), currentValue];
1821
+ context.set("value", sortDates(values));
1822
+ } else {
1823
+ const values = Array.from(context.get("value"));
1824
+ values.splice(index, 1);
1825
+ context.set("value", sortDates(values));
1826
+ }
1827
+ },
1828
+ setHoveredDate({ context, event }) {
1829
+ context.set("hoveredValue", event.value);
1830
+ },
1831
+ clearHoveredDate({ context }) {
1832
+ context.set("hoveredValue", null);
1833
+ },
1834
+ selectFocusedDate({ context, computed }) {
1835
+ const values = Array.from(context.get("value"));
1836
+ const activeIndex = context.get("activeIndex");
1837
+ values[activeIndex] = context.get("focusedValue").copy();
1838
+ context.set("value", adjustStartAndEndDate(values));
1839
+ const valueAsString = computed("valueAsString");
1840
+ context.set("inputValue", valueAsString[activeIndex]);
1841
+ },
1842
+ focusPreviousDay(params) {
1843
+ const { context } = params;
1844
+ setFocusedValue(params, context.get("focusedValue").subtract({ days: 1 }));
1845
+ },
1846
+ focusNextDay(params) {
1847
+ const { context } = params;
1848
+ setFocusedValue(params, context.get("focusedValue").add({ days: 1 }));
1849
+ },
1850
+ focusPreviousWeek(params) {
1851
+ const { context } = params;
1852
+ setFocusedValue(params, context.get("focusedValue").subtract({ weeks: 1 }));
1853
+ },
1854
+ focusNextWeek(params) {
1855
+ const { context } = params;
1856
+ setFocusedValue(params, context.get("focusedValue").add({ weeks: 1 }));
1857
+ },
1858
+ focusNextPage(params) {
1859
+ const { context, computed, prop } = params;
1860
+ setAdjustedValue(params, getNextPage(context.get("focusedValue"), context.get("startValue"), computed("visibleDuration"), prop("locale"), prop("min"), prop("max")));
1861
+ },
1862
+ focusPreviousPage(params) {
1863
+ const { context, computed, prop } = params;
1864
+ setAdjustedValue(params, getPreviousPage(context.get("focusedValue"), context.get("startValue"), computed("visibleDuration"), prop("locale"), prop("min"), prop("max")));
1865
+ },
1866
+ focusSectionStart(params) {
1867
+ const { context } = params;
1868
+ setFocusedValue(params, context.get("startValue").copy());
1869
+ },
1870
+ focusSectionEnd(params) {
1871
+ const { computed } = params;
1872
+ setFocusedValue(params, computed("endValue").copy());
1873
+ },
1874
+ focusNextSection(params) {
1875
+ const { context, event, computed, prop } = params;
1876
+ const nextSection = getNextSection(context.get("focusedValue"), context.get("startValue"), event.larger, computed("visibleDuration"), prop("locale"), prop("min"), prop("max"));
1877
+ if (!nextSection) return;
1878
+ setAdjustedValue(params, nextSection);
1879
+ },
1880
+ focusPreviousSection(params) {
1881
+ const { context, event, computed, prop } = params;
1882
+ const previousSection = getPreviousSection(context.get("focusedValue"), context.get("startValue"), event.larger, computed("visibleDuration"), prop("locale"), prop("min"), prop("max"));
1883
+ if (!previousSection) return;
1884
+ setAdjustedValue(params, previousSection);
1885
+ },
1886
+ focusNextYear(params) {
1887
+ const { context } = params;
1888
+ setFocusedValue(params, context.get("focusedValue").add({ years: 1 }));
1889
+ },
1890
+ focusPreviousYear(params) {
1891
+ const { context } = params;
1892
+ setFocusedValue(params, context.get("focusedValue").subtract({ years: 1 }));
1893
+ },
1894
+ focusNextDecade(params) {
1895
+ const { context } = params;
1896
+ setFocusedValue(params, context.get("focusedValue").add({ years: 10 }));
1897
+ },
1898
+ focusPreviousDecade(params) {
1899
+ const { context } = params;
1900
+ setFocusedValue(params, context.get("focusedValue").subtract({ years: 10 }));
1901
+ },
1902
+ clearFocusedDate(params) {
1903
+ const { prop } = params;
1904
+ setFocusedValue(params, getTodayDate(prop("timeZone")));
1905
+ },
1906
+ focusPreviousMonthColumn(params) {
1907
+ const { context, event } = params;
1908
+ setFocusedValue(params, context.get("focusedValue").subtract({ months: event.columns }));
1909
+ },
1910
+ focusNextMonthColumn(params) {
1911
+ const { context, event } = params;
1912
+ setFocusedValue(params, context.get("focusedValue").add({ months: event.columns }));
1913
+ },
1914
+ focusPreviousYearColumn(params) {
1915
+ const { context, event } = params;
1916
+ setFocusedValue(params, context.get("focusedValue").subtract({ years: event.columns }));
1917
+ },
1918
+ focusNextYearColumn(params) {
1919
+ const { context, event } = params;
1920
+ setFocusedValue(params, context.get("focusedValue").add({ years: event.columns }));
1921
+ },
1922
+ focusFirstMonth(params) {
1923
+ const { context } = params;
1924
+ setFocusedValue(params, context.get("focusedValue").set({ month: 1 }));
1925
+ },
1926
+ focusLastMonth(params) {
1927
+ const { context } = params;
1928
+ setFocusedValue(params, context.get("focusedValue").set({ month: 12 }));
1929
+ },
1930
+ focusFirstYear(params) {
1931
+ const { context } = params;
1932
+ const range = getDecadeRange(context.get("focusedValue").year);
1933
+ setFocusedValue(params, context.get("focusedValue").set({ year: range[0] }));
1934
+ },
1935
+ focusLastYear(params) {
1936
+ const { context } = params;
1937
+ const range = getDecadeRange(context.get("focusedValue").year);
1938
+ setFocusedValue(params, context.get("focusedValue").set({ year: range[range.length - 1] }));
1939
+ },
1940
+ setActiveIndex({ context, event }) {
1941
+ context.set("activeIndex", event.index);
1942
+ },
1943
+ setActiveIndexToEnd({ context }) {
1944
+ context.set("activeIndex", 1);
1945
+ },
1946
+ setActiveIndexToStart({ context }) {
1947
+ context.set("activeIndex", 0);
1948
+ },
1949
+ focusActiveCell({ scope, context }) {
1950
+ raf(() => {
1951
+ const view = context.get("view");
1952
+ getFocusedCell(scope, view)?.focus({ preventScroll: true });
1953
+ });
1954
+ },
1955
+ focusActiveCellIfNeeded({ scope, context, event }) {
1956
+ if (!event.focus) return;
1957
+ raf(() => {
1958
+ const view = context.get("view");
1959
+ getFocusedCell(scope, view)?.focus({ preventScroll: true });
1960
+ });
1961
+ },
1962
+ setHoveredValueIfKeyboard({ context, event, prop }) {
1963
+ if (!event.type.startsWith("TABLE.ARROW") || prop("selectionMode") !== "range" || context.get("activeIndex") === 0) return;
1964
+ context.set("hoveredValue", context.get("focusedValue").copy());
1965
+ },
1966
+ focusTriggerElement({ scope }) {
1967
+ raf(() => {
1968
+ getTriggerEl(scope)?.focus({ preventScroll: true });
1969
+ });
1970
+ },
1971
+ focusFirstInputElement({ scope }) {
1972
+ raf(() => {
1973
+ const [inputEl] = getInputEls(scope);
1974
+ inputEl?.focus({ preventScroll: true });
1975
+ });
1976
+ },
1977
+ focusInputElement({ scope }) {
1978
+ raf(() => {
1979
+ const inputEls = getInputEls(scope);
1980
+ const lastIndexWithValue = inputEls.findLastIndex((inputEl$1) => inputEl$1.value !== "");
1981
+ const inputEl = inputEls[Math.max(lastIndexWithValue, 0)];
1982
+ inputEl?.focus({ preventScroll: true });
1983
+ inputEl?.setSelectionRange(inputEl.value.length, inputEl.value.length);
1984
+ });
1985
+ },
1986
+ syncMonthSelectElement({ scope, context }) {
1987
+ setElementValue(getMonthSelectEl(scope), context.get("startValue").month.toString());
1988
+ },
1989
+ syncYearSelectElement({ scope, context }) {
1990
+ setElementValue(getYearSelectEl(scope), context.get("startValue").year.toString());
1991
+ },
1992
+ setInputValue({ context, event }) {
1993
+ if (context.get("activeIndex") !== event.index) return;
1994
+ context.set("inputValue", event.value);
1995
+ },
1996
+ syncInputValue({ scope, context, event }) {
1997
+ queueMicrotask(() => {
1998
+ setElementValue(getInputEls(scope)[event.index ?? context.get("activeIndex")], context.get("inputValue"));
1999
+ });
2000
+ },
2001
+ focusParsedDate(params) {
2002
+ const { event, prop } = params;
2003
+ if (event.index == null) return;
2004
+ const date = prop("parse")(event.value, {
2005
+ locale: prop("locale"),
2006
+ timeZone: prop("timeZone")
2007
+ });
2008
+ if (!date || !isValidDate(date)) return;
2009
+ setFocusedValue(params, date);
2010
+ },
2011
+ selectParsedDate({ context, event, prop }) {
2012
+ if (event.index == null) return;
2013
+ let date = prop("parse")(event.value, {
2014
+ locale: prop("locale"),
2015
+ timeZone: prop("timeZone")
2016
+ });
2017
+ if (!date || !isValidDate(date)) {
2018
+ if (event.value) date = context.get("focusedValue").copy();
2019
+ }
2020
+ if (!date) return;
2021
+ date = constrainValue(date, prop("min"), prop("max"));
2022
+ const values = Array.from(context.get("value"));
2023
+ values[event.index] = date;
2024
+ context.set("value", values);
2025
+ const valueAsString = getValueAsString(values, prop);
2026
+ context.set("inputValue", valueAsString[event.index]);
2027
+ },
2028
+ resetView({ context }) {
2029
+ context.set("view", context.initial("view"));
2030
+ },
2031
+ setStartValue({ context, computed, prop }) {
2032
+ const focusedValue = context.get("focusedValue");
2033
+ if (!isDateOutsideRange(focusedValue, context.get("startValue"), computed("endValue"))) return;
2034
+ const startValue = alignDate(focusedValue, "start", { months: prop("numOfMonths") }, prop("locale"));
2035
+ context.set("startValue", startValue);
2036
+ },
2037
+ invokeOnOpen({ prop, context }) {
2038
+ if (prop("inline")) return;
2039
+ prop("onOpenChange")?.({
2040
+ open: true,
2041
+ value: context.get("value")
2042
+ });
2043
+ },
2044
+ invokeOnClose({ prop, context }) {
2045
+ if (prop("inline")) return;
2046
+ prop("onOpenChange")?.({
2047
+ open: false,
2048
+ value: context.get("value")
2049
+ });
2050
+ },
2051
+ toggleVisibility({ event, send, prop }) {
2052
+ send({
2053
+ type: prop("open") ? "CONTROLLED.OPEN" : "CONTROLLED.CLOSE",
2054
+ previousEvent: event
2055
+ });
2056
+ }
2057
+ }
2058
+ }
2059
+ });
2060
+ const normalizeValue = (ctx, value) => {
2061
+ const { context, prop } = ctx;
2062
+ const view = context.get("view");
2063
+ let dateValue = typeof value === "number" ? context.get("focusedValue").set({ [view]: value }) : value;
2064
+ eachView((view$1) => {
2065
+ if (isBelowMinView(view$1, prop("minView"))) dateValue = dateValue.set({ [view$1]: view$1 === "day" ? 1 : 0 });
2066
+ });
2067
+ return dateValue;
2068
+ };
2069
+ function setFocusedValue(ctx, mixedValue) {
2070
+ const { context, prop, computed } = ctx;
2071
+ if (!mixedValue) return;
2072
+ const value = normalizeValue(ctx, mixedValue);
2073
+ if (isDateEqual(context.get("focusedValue"), value)) return;
2074
+ const adjustedValue = getAdjustedDateFn(computed("visibleDuration"), prop("locale"), prop("min"), prop("max"))({
2075
+ focusedDate: value,
2076
+ startDate: context.get("startValue")
2077
+ });
2078
+ context.set("startValue", adjustedValue.startDate);
2079
+ context.set("focusedValue", adjustedValue.focusedDate);
2080
+ }
2081
+ function setAdjustedValue(ctx, value) {
2082
+ const { context } = ctx;
2083
+ context.set("startValue", value.startDate);
2084
+ if (isDateEqual(context.get("focusedValue"), value.focusedDate)) return;
2085
+ context.set("focusedValue", value.focusedDate);
2086
+ }
2087
+
2088
+ //#endregion
2089
+ //#region src/machines/date-picker/date-picker.parse.ts
2090
+ function parse(value) {
2091
+ if (Array.isArray(value)) return value.map((v) => parse(v));
2092
+ if (value instanceof Date) return new CalendarDate(value.getFullYear(), value.getMonth() + 1, value.getDate());
2093
+ return parseDate(value);
2094
+ }
2095
+
2096
+ //#endregion
2097
+ //#region src/machines/date-picker/date-picker.props.ts
2098
+ const props = createProps()([
2099
+ "closeOnSelect",
2100
+ "dir",
2101
+ "disabled",
2102
+ "fixedWeeks",
2103
+ "focusedValue",
2104
+ "format",
2105
+ "parse",
2106
+ "placeholder",
2107
+ "getRootNode",
2108
+ "id",
2109
+ "ids",
2110
+ "inline",
2111
+ "invalid",
2112
+ "isDateUnavailable",
2113
+ "locale",
2114
+ "max",
2115
+ "min",
2116
+ "name",
2117
+ "numOfMonths",
2118
+ "onFocusChange",
2119
+ "onOpenChange",
2120
+ "onValueChange",
2121
+ "onViewChange",
2122
+ "open",
2123
+ "defaultOpen",
2124
+ "positioning",
2125
+ "readOnly",
2126
+ "required",
2127
+ "selectionMode",
2128
+ "startOfWeek",
2129
+ "timeZone",
2130
+ "translations",
2131
+ "value",
2132
+ "defaultView",
2133
+ "defaultValue",
2134
+ "view",
2135
+ "defaultFocusedValue",
2136
+ "outsideDaySelectable",
2137
+ "minView",
2138
+ "maxView"
2139
+ ]);
2140
+ const splitProps = createSplitProps(props);
2141
+ const inputProps = createProps()(["index", "fixOnBlur"]);
2142
+ const splitInputProps = createSplitProps(inputProps);
2143
+ const presetTriggerProps = createProps()(["value"]);
2144
+ const splitPresetTriggerProps = createSplitProps(presetTriggerProps);
2145
+ const tableProps = createProps()([
2146
+ "columns",
2147
+ "id",
2148
+ "view"
2149
+ ]);
2150
+ const splitTableProps = createSplitProps(tableProps);
2151
+ const tableCellProps = createProps()([
2152
+ "disabled",
2153
+ "value",
2154
+ "columns"
2155
+ ]);
2156
+ const splitTableCellProps = createSplitProps(tableCellProps);
2157
+ const viewProps = createProps()(["view"]);
2158
+ const splitViewProps = createSplitProps(viewProps);
2159
+
2160
+ //#endregion
2161
+ export { anatomy, connect, inputProps, machine, parse, presetTriggerProps, props, splitInputProps, splitPresetTriggerProps, splitProps, splitTableCellProps, splitTableProps, splitViewProps, tableCellProps, tableProps, viewProps };