@wirekyt/dom 0.0.1 → 0.0.2

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 (476) hide show
  1. package/dist/anatomy-DMuSMbOP.d.cts +18 -0
  2. package/dist/anatomy-DMuSMbOP.d.ts +18 -0
  3. package/dist/anatomy.cjs +3 -0
  4. package/dist/anatomy.d.cts +2 -0
  5. package/dist/anatomy.d.ts +2 -0
  6. package/dist/anatomy.js +2 -0
  7. package/dist/angle-3hqP0Mp5.cjs +13 -0
  8. package/dist/angle-oNt8uGHQ.js +8 -0
  9. package/dist/aria-hidden-CEXexb2I.js +127 -0
  10. package/dist/aria-hidden-Y7iJHPMr.cjs +132 -0
  11. package/dist/aria-hidden.cjs +3 -0
  12. package/dist/aria-hidden.d.cts +10 -0
  13. package/dist/aria-hidden.d.ts +10 -0
  14. package/dist/aria-hidden.js +2 -0
  15. package/dist/array-BGtygd0o.cjs +198 -0
  16. package/dist/array-C4KbHsha.js +73 -0
  17. package/dist/auto-resize-5F5iiKZb.cjs +106 -0
  18. package/dist/auto-resize-KkNfCcBt.js +95 -0
  19. package/dist/auto-resize.cjs +4 -0
  20. package/dist/auto-resize.d.cts +7 -0
  21. package/dist/auto-resize.d.ts +7 -0
  22. package/dist/auto-resize.js +2 -0
  23. package/dist/caret-CHqaP4XG.cjs +30 -0
  24. package/dist/caret-aiDJ6mAS.js +19 -0
  25. package/dist/closest-Clo6ODcK.js +117 -0
  26. package/dist/closest-IiRz1GIJ.cjs +176 -0
  27. package/dist/collection-CJU0oDtX.js +1295 -0
  28. package/dist/collection-CwzUJwBJ.cjs +1342 -0
  29. package/dist/collection.cjs +15 -0
  30. package/dist/collection.d.cts +34 -0
  31. package/dist/collection.d.ts +34 -0
  32. package/dist/collection.js +3 -0
  33. package/dist/color-CsugZjq6.d.cts +60 -0
  34. package/dist/color-CsugZjq6.d.ts +60 -0
  35. package/dist/color-utils-DzeOVYlL.cjs +662 -0
  36. package/dist/color-utils-lDDg9FEh.js +639 -0
  37. package/dist/color-utils.cjs +6 -0
  38. package/dist/color-utils.d.cts +18 -0
  39. package/dist/color-utils.d.ts +18 -0
  40. package/dist/color-utils.js +2 -0
  41. package/dist/computed-style-B1MKlCoo.js +9 -0
  42. package/dist/computed-style-DLArEFNw.cjs +14 -0
  43. package/dist/controller-B8E8ZJCI.cjs +133 -0
  44. package/dist/controller-Dv7lWHDr.js +92 -0
  45. package/dist/core-BF6G2RiC.d.cts +1 -0
  46. package/dist/core-BNMw-JId.cjs +372 -0
  47. package/dist/core-BdeZuSX6.d.ts +1 -0
  48. package/dist/core-CJ0MZr3D.js +289 -0
  49. package/dist/core.cjs +19 -0
  50. package/dist/core.d.cts +3 -0
  51. package/dist/core.d.ts +3 -0
  52. package/dist/core.js +3 -0
  53. package/dist/create-anatomy-B2q3wiaw.js +22 -0
  54. package/dist/create-anatomy-BwDn25ph.cjs +27 -0
  55. package/dist/create-props-CgtcN_Qu.js +4 -0
  56. package/dist/create-props-CjLx2oS8.cjs +9 -0
  57. package/dist/data-url-C-Uk31Q9.cjs +42 -0
  58. package/dist/data-url-DHUHj7UF.js +37 -0
  59. package/dist/data-url-Gx_SWG-k.d.cts +10 -0
  60. package/dist/data-url-Gx_SWG-k.d.ts +10 -0
  61. package/dist/date-utils-D-JJHedx.cjs +868 -0
  62. package/dist/date-utils-D5zXW-Cs.js +569 -0
  63. package/dist/date-utils.cjs +52 -0
  64. package/dist/date-utils.d.cts +7 -0
  65. package/dist/date-utils.d.ts +7 -0
  66. package/dist/date-utils.js +2 -0
  67. package/dist/dismissable-C0bixtzl.cjs +348 -0
  68. package/dist/dismissable-KM1jPtNQ.js +337 -0
  69. package/dist/dismissable-layer-BTX5EvXw.d.ts +40 -0
  70. package/dist/dismissable-layer-Ch5niVaq.d.cts +40 -0
  71. package/dist/dismissable.cjs +4 -0
  72. package/dist/dismissable.d.cts +3 -0
  73. package/dist/dismissable.d.ts +3 -0
  74. package/dist/dismissable.js +2 -0
  75. package/dist/dom-query-CQzY93XU.cjs +488 -0
  76. package/dist/dom-query-e7fh0TEH.js +243 -0
  77. package/dist/dom-query.cjs +180 -0
  78. package/dist/dom-query.d.cts +142 -0
  79. package/dist/dom-query.d.ts +142 -0
  80. package/dist/dom-query.js +43 -0
  81. package/dist/equal-C927y7MN.cjs +30 -0
  82. package/dist/equal-DtrP8DPh.js +25 -0
  83. package/dist/event-DDz-mMhM.cjs +242 -0
  84. package/dist/event-bTItRgiw.js +117 -0
  85. package/dist/file-utils-6EXCdfHx.js +116 -0
  86. package/dist/file-utils-B7OJigQq.cjs +151 -0
  87. package/dist/file-utils.cjs +92 -0
  88. package/dist/file-utils.d.cts +40 -0
  89. package/dist/file-utils.d.ts +40 -0
  90. package/dist/file-utils.js +82 -0
  91. package/dist/focus-trap-89E5I9nm.js +487 -0
  92. package/dist/focus-trap-D7jKsfHW.cjs +498 -0
  93. package/dist/focus-trap.cjs +4 -0
  94. package/dist/focus-trap.d.cts +89 -0
  95. package/dist/focus-trap.d.ts +89 -0
  96. package/dist/focus-trap.js +2 -0
  97. package/dist/focus-visible-DWdQf__4.js +176 -0
  98. package/dist/focus-visible-G4cmlWqq.cjs +217 -0
  99. package/dist/focus-visible.cjs +9 -0
  100. package/dist/focus-visible.d.cts +32 -0
  101. package/dist/focus-visible.d.ts +32 -0
  102. package/dist/focus-visible.js +2 -0
  103. package/dist/form-B1DW_w_3.js +89 -0
  104. package/dist/form-CoupKpuP.cjs +130 -0
  105. package/dist/from-window-5ZhzSURC.js +68 -0
  106. package/dist/from-window-B9DKtaoR.cjs +115 -0
  107. package/dist/functions-isw5Ovcx.d.cts +16 -0
  108. package/dist/functions-isw5Ovcx.d.ts +16 -0
  109. package/dist/highlight-word.cjs +95 -0
  110. package/dist/highlight-word.d.cts +24 -0
  111. package/dist/highlight-word.d.ts +24 -0
  112. package/dist/highlight-word.js +94 -0
  113. package/dist/hotkeys.cjs +1183 -0
  114. package/dist/hotkeys.d.cts +199 -0
  115. package/dist/hotkeys.d.ts +199 -0
  116. package/dist/hotkeys.js +1173 -0
  117. package/dist/i18n-utils-BD4VtonY.cjs +345 -0
  118. package/dist/i18n-utils-C4FQZ39m.js +280 -0
  119. package/dist/i18n-utils.cjs +216 -0
  120. package/dist/i18n-utils.d.cts +71 -0
  121. package/dist/i18n-utils.d.ts +71 -0
  122. package/dist/i18n-utils.js +204 -0
  123. package/dist/index-3tNJficI.d.cts +117 -0
  124. package/dist/index-3tNJficI.d.ts +117 -0
  125. package/dist/index-BEfvdGE2.d.cts +116 -0
  126. package/dist/index-BEfvdGE2.d.ts +116 -0
  127. package/dist/index-BF6G2RiC.d.cts +1 -0
  128. package/dist/index-BKgxIVbE.d.cts +285 -0
  129. package/dist/index-BMtpmaRD.d.cts +16 -0
  130. package/dist/index-BMtpmaRD.d.ts +16 -0
  131. package/dist/index-BWiYePx8.d.cts +216 -0
  132. package/dist/index-BXfunVyD.d.cts +1342 -0
  133. package/dist/index-BXfunVyD.d.ts +1342 -0
  134. package/dist/index-BdeZuSX6.d.ts +1 -0
  135. package/dist/index-C2865AJq.d.cts +25 -0
  136. package/dist/index-C2865AJq.d.ts +25 -0
  137. package/dist/index-CFoN0L3C.d.ts +285 -0
  138. package/dist/index-vPrqYDHu.d.ts +216 -0
  139. package/dist/index.cjs +19 -0
  140. package/dist/index.d.cts +3 -0
  141. package/dist/index.d.ts +3 -0
  142. package/dist/index.js +3 -0
  143. package/dist/initial-focus-BQxRRFPa.cjs +37 -0
  144. package/dist/initial-focus-BrN5tT2X.js +26 -0
  145. package/dist/interact-outside-BjqIunFx.js +211 -0
  146. package/dist/interact-outside-Dphjr2Zh.cjs +216 -0
  147. package/dist/interact-outside.cjs +3 -0
  148. package/dist/interact-outside.d.cts +2 -0
  149. package/dist/interact-outside.d.ts +2 -0
  150. package/dist/interact-outside.js +2 -0
  151. package/dist/json-tree-utils.cjs +1518 -0
  152. package/dist/json-tree-utils.d.cts +117 -0
  153. package/dist/json-tree-utils.d.ts +117 -0
  154. package/dist/json-tree-utils.js +1469 -0
  155. package/dist/list-collection-D_eNKrot.d.cts +60 -0
  156. package/dist/list-collection-RqYEWHb4.d.ts +60 -0
  157. package/dist/live-region-BD0OgmrH.cjs +68 -0
  158. package/dist/live-region-F8YMmbrY.js +63 -0
  159. package/dist/live-region.cjs +3 -0
  160. package/dist/live-region.d.cts +2 -0
  161. package/dist/live-region.d.ts +2 -0
  162. package/dist/live-region.js +2 -0
  163. package/dist/machines/accordion/index.cjs +328 -0
  164. package/dist/machines/accordion/index.d.cts +83 -0
  165. package/dist/machines/accordion/index.d.ts +83 -0
  166. package/dist/machines/accordion/index.js +321 -0
  167. package/dist/machines/angle-slider/index.cjs +420 -0
  168. package/dist/machines/angle-slider/index.d.cts +84 -0
  169. package/dist/machines/angle-slider/index.d.ts +84 -0
  170. package/dist/machines/angle-slider/index.js +415 -0
  171. package/dist/machines/async-list/index.cjs +310 -0
  172. package/dist/machines/async-list/index.d.cts +90 -0
  173. package/dist/machines/async-list/index.d.ts +90 -0
  174. package/dist/machines/async-list/index.js +308 -0
  175. package/dist/machines/avatar/index.cjs +165 -0
  176. package/dist/machines/avatar/index.d.cts +63 -0
  177. package/dist/machines/avatar/index.d.ts +63 -0
  178. package/dist/machines/avatar/index.js +160 -0
  179. package/dist/machines/carousel/index.cjs +929 -0
  180. package/dist/machines/carousel/index.d.cts +146 -0
  181. package/dist/machines/carousel/index.d.ts +146 -0
  182. package/dist/machines/carousel/index.js +920 -0
  183. package/dist/machines/cascade-select/index.cjs +1426 -0
  184. package/dist/machines/cascade-select/index.d.cts +167 -0
  185. package/dist/machines/cascade-select/index.d.ts +167 -0
  186. package/dist/machines/cascade-select/index.js +1419 -0
  187. package/dist/machines/checkbox/index.cjs +316 -0
  188. package/dist/machines/checkbox/index.d.cts +81 -0
  189. package/dist/machines/checkbox/index.d.ts +81 -0
  190. package/dist/machines/checkbox/index.js +311 -0
  191. package/dist/machines/clipboard/index.cjs +228 -0
  192. package/dist/machines/clipboard/index.d.cts +72 -0
  193. package/dist/machines/clipboard/index.d.ts +72 -0
  194. package/dist/machines/clipboard/index.js +221 -0
  195. package/dist/machines/collapsible/index.cjs +363 -0
  196. package/dist/machines/collapsible/index.d.cts +82 -0
  197. package/dist/machines/collapsible/index.d.ts +82 -0
  198. package/dist/machines/collapsible/index.js +358 -0
  199. package/dist/machines/color-picker/index.cjs +1534 -0
  200. package/dist/machines/color-picker/index.d.cts +207 -0
  201. package/dist/machines/color-picker/index.d.ts +207 -0
  202. package/dist/machines/color-picker/index.js +1518 -0
  203. package/dist/machines/combobox/index.cjs +1554 -0
  204. package/dist/machines/combobox/index.d.cts +219 -0
  205. package/dist/machines/combobox/index.d.ts +219 -0
  206. package/dist/machines/combobox/index.js +1542 -0
  207. package/dist/machines/date-input/index.cjs +1974 -0
  208. package/dist/machines/date-input/index.d.cts +230 -0
  209. package/dist/machines/date-input/index.d.ts +230 -0
  210. package/dist/machines/date-input/index.js +1958 -0
  211. package/dist/machines/date-picker/index.cjs +2424 -0
  212. package/dist/machines/date-picker/index.d.cts +378 -0
  213. package/dist/machines/date-picker/index.d.ts +378 -0
  214. package/dist/machines/date-picker/index.js +2408 -0
  215. package/dist/machines/dialog/index.cjs +378 -0
  216. package/dist/machines/dialog/index.d.cts +94 -0
  217. package/dist/machines/dialog/index.d.ts +94 -0
  218. package/dist/machines/dialog/index.js +373 -0
  219. package/dist/machines/drawer/index.cjs +2066 -0
  220. package/dist/machines/drawer/index.d.cts +334 -0
  221. package/dist/machines/drawer/index.d.ts +334 -0
  222. package/dist/machines/drawer/index.js +2059 -0
  223. package/dist/machines/editable/index.cjs +550 -0
  224. package/dist/machines/editable/index.d.cts +114 -0
  225. package/dist/machines/editable/index.d.ts +114 -0
  226. package/dist/machines/editable/index.js +545 -0
  227. package/dist/machines/file-upload/index.cjs +648 -0
  228. package/dist/machines/file-upload/index.d.cts +150 -0
  229. package/dist/machines/file-upload/index.d.ts +150 -0
  230. package/dist/machines/file-upload/index.js +641 -0
  231. package/dist/machines/floating-panel/index.cjs +1020 -0
  232. package/dist/machines/floating-panel/index.d.cts +149 -0
  233. package/dist/machines/floating-panel/index.d.ts +149 -0
  234. package/dist/machines/floating-panel/index.js +1012 -0
  235. package/dist/machines/hover-card/index.cjs +441 -0
  236. package/dist/machines/hover-card/index.d.cts +82 -0
  237. package/dist/machines/hover-card/index.d.ts +82 -0
  238. package/dist/machines/hover-card/index.js +436 -0
  239. package/dist/machines/image-cropper/index.cjs +2082 -0
  240. package/dist/machines/image-cropper/index.d.cts +182 -0
  241. package/dist/machines/image-cropper/index.d.ts +182 -0
  242. package/dist/machines/image-cropper/index.js +2076 -0
  243. package/dist/machines/listbox/index.cjs +873 -0
  244. package/dist/machines/listbox/index.d.cts +175 -0
  245. package/dist/machines/listbox/index.d.ts +175 -0
  246. package/dist/machines/listbox/index.js +860 -0
  247. package/dist/machines/marquee/index.cjs +387 -0
  248. package/dist/machines/marquee/index.d.cts +102 -0
  249. package/dist/machines/marquee/index.d.ts +102 -0
  250. package/dist/machines/marquee/index.js +382 -0
  251. package/dist/machines/menu/index.cjs +1562 -0
  252. package/dist/machines/menu/index.d.cts +188 -0
  253. package/dist/machines/menu/index.d.ts +188 -0
  254. package/dist/machines/menu/index.js +1549 -0
  255. package/dist/machines/navigation-menu/index.cjs +860 -0
  256. package/dist/machines/navigation-menu/index.d.cts +131 -0
  257. package/dist/machines/navigation-menu/index.d.ts +131 -0
  258. package/dist/machines/navigation-menu/index.js +855 -0
  259. package/dist/machines/number-input/index.cjs +1014 -0
  260. package/dist/machines/number-input/index.d.cts +136 -0
  261. package/dist/machines/number-input/index.d.ts +136 -0
  262. package/dist/machines/number-input/index.js +1009 -0
  263. package/dist/machines/pagination/index.cjs +413 -0
  264. package/dist/machines/pagination/index.d.cts +139 -0
  265. package/dist/machines/pagination/index.d.ts +139 -0
  266. package/dist/machines/pagination/index.js +404 -0
  267. package/dist/machines/password-input/index.cjs +224 -0
  268. package/dist/machines/password-input/index.d.cts +71 -0
  269. package/dist/machines/password-input/index.d.ts +71 -0
  270. package/dist/machines/password-input/index.js +219 -0
  271. package/dist/machines/pin-input/index.cjs +595 -0
  272. package/dist/machines/pin-input/index.d.cts +107 -0
  273. package/dist/machines/pin-input/index.d.ts +107 -0
  274. package/dist/machines/pin-input/index.js +590 -0
  275. package/dist/machines/popover/index.cjs +516 -0
  276. package/dist/machines/popover/index.d.cts +107 -0
  277. package/dist/machines/popover/index.d.ts +107 -0
  278. package/dist/machines/popover/index.js +511 -0
  279. package/dist/machines/presence/index.cjs +193 -0
  280. package/dist/machines/presence/index.d.cts +44 -0
  281. package/dist/machines/presence/index.d.ts +44 -0
  282. package/dist/machines/presence/index.js +190 -0
  283. package/dist/machines/progress/index.cjs +282 -0
  284. package/dist/machines/progress/index.d.cts +96 -0
  285. package/dist/machines/progress/index.d.ts +96 -0
  286. package/dist/machines/progress/index.js +277 -0
  287. package/dist/machines/qr-code/index.cjs +167 -0
  288. package/dist/machines/qr-code/index.d.cts +71 -0
  289. package/dist/machines/qr-code/index.d.ts +71 -0
  290. package/dist/machines/qr-code/index.js +162 -0
  291. package/dist/machines/radio-group/index.cjs +465 -0
  292. package/dist/machines/radio-group/index.d.cts +218 -0
  293. package/dist/machines/radio-group/index.d.ts +218 -0
  294. package/dist/machines/radio-group/index.js +458 -0
  295. package/dist/machines/rating-group/index.cjs +405 -0
  296. package/dist/machines/rating-group/index.d.cts +101 -0
  297. package/dist/machines/rating-group/index.d.ts +101 -0
  298. package/dist/machines/rating-group/index.js +398 -0
  299. package/dist/machines/scroll-area/index.cjs +865 -0
  300. package/dist/machines/scroll-area/index.d.cts +126 -0
  301. package/dist/machines/scroll-area/index.d.ts +126 -0
  302. package/dist/machines/scroll-area/index.js +860 -0
  303. package/dist/machines/select/index.cjs +1226 -0
  304. package/dist/machines/select/index.d.cts +190 -0
  305. package/dist/machines/select/index.d.ts +190 -0
  306. package/dist/machines/select/index.js +1214 -0
  307. package/dist/machines/signature-pad/index.cjs +337 -0
  308. package/dist/machines/signature-pad/index.d.cts +108 -0
  309. package/dist/machines/signature-pad/index.d.ts +108 -0
  310. package/dist/machines/signature-pad/index.js +330 -0
  311. package/dist/machines/slider/index.cjs +1103 -0
  312. package/dist/machines/slider/index.d.cts +154 -0
  313. package/dist/machines/slider/index.d.ts +154 -0
  314. package/dist/machines/slider/index.js +1094 -0
  315. package/dist/machines/splitter/index.cjs +1686 -0
  316. package/dist/machines/splitter/index.d.cts +282 -0
  317. package/dist/machines/splitter/index.d.ts +282 -0
  318. package/dist/machines/splitter/index.js +1675 -0
  319. package/dist/machines/steps/index.cjs +330 -0
  320. package/dist/machines/steps/index.d.cts +109 -0
  321. package/dist/machines/steps/index.d.ts +109 -0
  322. package/dist/machines/steps/index.js +325 -0
  323. package/dist/machines/switch/index.cjs +307 -0
  324. package/dist/machines/switch/index.d.cts +80 -0
  325. package/dist/machines/switch/index.d.ts +80 -0
  326. package/dist/machines/switch/index.js +302 -0
  327. package/dist/machines/tabs/index.cjs +542 -0
  328. package/dist/machines/tabs/index.d.cts +113 -0
  329. package/dist/machines/tabs/index.d.ts +113 -0
  330. package/dist/machines/tabs/index.js +533 -0
  331. package/dist/machines/tags-input/index.cjs +1151 -0
  332. package/dist/machines/tags-input/index.d.cts +182 -0
  333. package/dist/machines/tags-input/index.d.ts +182 -0
  334. package/dist/machines/tags-input/index.js +1144 -0
  335. package/dist/machines/timer/index.cjs +329 -0
  336. package/dist/machines/timer/index.d.cts +102 -0
  337. package/dist/machines/timer/index.d.ts +102 -0
  338. package/dist/machines/timer/index.js +323 -0
  339. package/dist/machines/toast/index.cjs +1185 -0
  340. package/dist/machines/toast/index.d.cts +204 -0
  341. package/dist/machines/toast/index.d.ts +204 -0
  342. package/dist/machines/toast/index.js +1180 -0
  343. package/dist/machines/toc/index.cjs +358 -0
  344. package/dist/machines/toc/index.d.cts +98 -0
  345. package/dist/machines/toc/index.d.ts +98 -0
  346. package/dist/machines/toc/index.js +351 -0
  347. package/dist/machines/toggle/index.cjs +99 -0
  348. package/dist/machines/toggle/index.d.cts +46 -0
  349. package/dist/machines/toggle/index.d.ts +46 -0
  350. package/dist/machines/toggle/index.js +94 -0
  351. package/dist/machines/toggle-group/index.cjs +329 -0
  352. package/dist/machines/toggle-group/index.d.cts +81 -0
  353. package/dist/machines/toggle-group/index.d.ts +81 -0
  354. package/dist/machines/toggle-group/index.js +322 -0
  355. package/dist/machines/tooltip/index.cjs +638 -0
  356. package/dist/machines/tooltip/index.d.cts +84 -0
  357. package/dist/machines/tooltip/index.d.ts +84 -0
  358. package/dist/machines/tooltip/index.js +633 -0
  359. package/dist/machines/tour/index.cjs +1123 -0
  360. package/dist/machines/tour/index.d.cts +207 -0
  361. package/dist/machines/tour/index.d.ts +207 -0
  362. package/dist/machines/tour/index.js +1115 -0
  363. package/dist/machines/tree-view/index.cjs +1288 -0
  364. package/dist/machines/tree-view/index.d.cts +221 -0
  365. package/dist/machines/tree-view/index.d.ts +221 -0
  366. package/dist/machines/tree-view/index.js +1279 -0
  367. package/dist/mutation-observer-_LbwtN3W.cjs +61 -0
  368. package/dist/mutation-observer-qObPUo3D.js +50 -0
  369. package/dist/navigate-CJOaL3vx.js +31 -0
  370. package/dist/navigate-uJG-006f.cjs +42 -0
  371. package/dist/overflow-BBihfMxX.cjs +67 -0
  372. package/dist/overflow-C-zO1CWA.js +44 -0
  373. package/dist/platform-BDB0wXUk.js +26 -0
  374. package/dist/platform-BZS-dkZN.cjs +109 -0
  375. package/dist/point-C9A4dk1i.js +27 -0
  376. package/dist/point-DxnCrJBy.cjs +32 -0
  377. package/dist/pointer-lock-BvfSjt_s.cjs +31 -0
  378. package/dist/pointer-lock-WezxTqu-.js +26 -0
  379. package/dist/pointer-move-CGzan38r.cjs +42 -0
  380. package/dist/pointer-move-Tijb8Ptk.js +37 -0
  381. package/dist/polygon-BvdwYRBw.js +76 -0
  382. package/dist/polygon-CTR1kEoU.cjs +93 -0
  383. package/dist/popper-DkAAS9VE.cjs +487 -0
  384. package/dist/popper-DzBZzAe4.js +464 -0
  385. package/dist/popper.cjs +6 -0
  386. package/dist/popper.d.cts +2 -0
  387. package/dist/popper.d.ts +2 -0
  388. package/dist/popper.js +2 -0
  389. package/dist/press-B7XLrLGR.js +65 -0
  390. package/dist/press-BdD5suLQ.cjs +70 -0
  391. package/dist/proxy-tab-focus-DWMXvAfO.js +54 -0
  392. package/dist/proxy-tab-focus-NthYgHdY.cjs +59 -0
  393. package/dist/raf-BSDcY4UD.cjs +85 -0
  394. package/dist/raf-DgINgykK.d.cts +15 -0
  395. package/dist/raf-DgINgykK.d.ts +15 -0
  396. package/dist/raf-Dhvm7f1e.js +62 -0
  397. package/dist/rect-utils-DiT4k3jS.cjs +548 -0
  398. package/dist/rect-utils-d_3gZVsc.js +459 -0
  399. package/dist/rect-utils.cjs +165 -0
  400. package/dist/rect-utils.d.cts +197 -0
  401. package/dist/rect-utils.d.ts +197 -0
  402. package/dist/rect-utils.js +116 -0
  403. package/dist/remove-scroll-DTVA5f4w.cjs +86 -0
  404. package/dist/remove-scroll-WEheFCiq.js +81 -0
  405. package/dist/remove-scroll.cjs +3 -0
  406. package/dist/remove-scroll.d.cts +4 -0
  407. package/dist/remove-scroll.d.ts +4 -0
  408. package/dist/remove-scroll.js +2 -0
  409. package/dist/rolldown-runtime-D6vf50IK.cjs +28 -0
  410. package/dist/scale-C5BBHVgH.js +17 -0
  411. package/dist/scale-C7iiUGhS.cjs +22 -0
  412. package/dist/scope-CysKlKe9.cjs +28 -0
  413. package/dist/scope-D1873Mzi.js +23 -0
  414. package/dist/scroll-CVJ40w2e.js +46 -0
  415. package/dist/scroll-Dyd1QLrc.cjs +63 -0
  416. package/dist/scroll-snap-Cuaqdevf.cjs +224 -0
  417. package/dist/scroll-snap-DqMiFASa.js +201 -0
  418. package/dist/scroll-snap.cjs +6 -0
  419. package/dist/scroll-snap.d.cts +14 -0
  420. package/dist/scroll-snap.d.ts +14 -0
  421. package/dist/scroll-snap.js +2 -0
  422. package/dist/selection-ClKhnWit.d.cts +49 -0
  423. package/dist/selection-DzLiSVkg.d.ts +49 -0
  424. package/dist/selection-map-962WvX2k.js +45 -0
  425. package/dist/selection-map-BwlZr1LH.cjs +68 -0
  426. package/dist/set-CFNGOW5W.js +50 -0
  427. package/dist/set-DrtWCLFb.cjs +73 -0
  428. package/dist/store-BLpJlMxz.js +257 -0
  429. package/dist/store-Btfrm2bs.cjs +47 -0
  430. package/dist/store-C5HvdLyc.js +42 -0
  431. package/dist/store-Wg8KVwNv.cjs +298 -0
  432. package/dist/store.cjs +9 -0
  433. package/dist/store.d.cts +26 -0
  434. package/dist/store.d.ts +26 -0
  435. package/dist/store.js +2 -0
  436. package/dist/stringify-state.cjs +48 -0
  437. package/dist/stringify-state.d.cts +8 -0
  438. package/dist/stringify-state.d.ts +8 -0
  439. package/dist/stringify-state.js +44 -0
  440. package/dist/tabbable-Bz1-1GAY.cjs +206 -0
  441. package/dist/tabbable-CDA1YMjZ.js +147 -0
  442. package/dist/text-selection-B3OQpQGy.cjs +75 -0
  443. package/dist/text-selection-DXvWvm6k.js +64 -0
  444. package/dist/timers-BRyPrXIX.js +82 -0
  445. package/dist/timers-Beu4SfAj.cjs +99 -0
  446. package/dist/tree-collection-3QX3EIhq.d.ts +77 -0
  447. package/dist/tree-collection-C6oDQGUJ.d.cts +77 -0
  448. package/dist/typeahead-DremEgML.d.cts +45 -0
  449. package/dist/typeahead-DremEgML.d.ts +45 -0
  450. package/dist/types-BFuHIo7S.js +10 -0
  451. package/dist/types-CczqoQLL.d.cts +57 -0
  452. package/dist/types-CczqoQLL.d.ts +57 -0
  453. package/dist/types-CjocssbC.d.cts +13 -0
  454. package/dist/types-CjocssbC.d.ts +13 -0
  455. package/dist/types-D7oF7eWh.d.cts +54 -0
  456. package/dist/types-D7oF7eWh.d.ts +54 -0
  457. package/dist/types-HCvp3Bhv.cjs +21 -0
  458. package/dist/types.cjs +14 -0
  459. package/dist/types.d.cts +6 -0
  460. package/dist/types.d.ts +6 -0
  461. package/dist/types.js +12 -0
  462. package/dist/utils-BH-oBBz2.cjs +614 -0
  463. package/dist/utils-Cht5XaHf.js +267 -0
  464. package/dist/utils.cjs +95 -0
  465. package/dist/utils.d.cts +144 -0
  466. package/dist/utils.d.ts +144 -0
  467. package/dist/utils.js +7 -0
  468. package/dist/visually-hidden-BgSCFLz_.cjs +29 -0
  469. package/dist/visually-hidden-yDJ517KZ.js +18 -0
  470. package/dist/wait-for-3n85JcCU.d.cts +15 -0
  471. package/dist/wait-for-3n85JcCU.d.ts +15 -0
  472. package/dist/wait-for-CI5Ye-Lo.js +69 -0
  473. package/dist/wait-for-Db73VpZQ.cjs +86 -0
  474. package/dist/warning-CrzBpWT1.js +19 -0
  475. package/dist/warning-HAmFXLHm.cjs +42 -0
  476. package/package.json +349 -6
@@ -0,0 +1,1419 @@
1
+ import { t as createAnatomy } from "../../create-anatomy-B2q3wiaw.js";
2
+ import { E as isEditableElement, L as ariaAttr, f as queryAll, z as dataAttr } from "../../dom-query-e7fh0TEH.js";
3
+ import { r as getEventKey, v as isSelfTarget } from "../../event-bTItRgiw.js";
4
+ import { n as dispatchInputValueEvent, o as setElementValue, s as trackFormControl } from "../../form-B1DW_w_3.js";
5
+ import { n as isValidTabEvent } from "../../initial-focus-BrN5tT2X.js";
6
+ import { i as raf } from "../../raf-Dhvm7f1e.js";
7
+ import { t as observeAttributes } from "../../mutation-observer-qObPUo3D.js";
8
+ import { t as createScope } from "../../scope-D1873Mzi.js";
9
+ import { n as scrollIntoView } from "../../scroll-CVJ40w2e.js";
10
+ import { d as isEmpty, f as last } from "../../array-C4KbHsha.js";
11
+ import { t as isEqual } from "../../equal-DtrP8DPh.js";
12
+ import { n as createSplitProps } from "../../utils-Cht5XaHf.js";
13
+ import { t as TreeCollection } from "../../collection-CJU0oDtX.js";
14
+ import { n as createGuards, r as createMachine } from "../../core-CJ0MZr3D.js";
15
+ import { n as trackDismissableElement } from "../../dismissable-KM1jPtNQ.js";
16
+ import { a as setInteractionModality, o as trackFocusVisible, t as getInteractionModality } from "../../focus-visible-DWdQf__4.js";
17
+ import { n as getPlacement, r as getPlacementSide, t as getPlacementStyles } from "../../popper-DzBZzAe4.js";
18
+ import { c as createRect, s as createPoint, u as getRectCorners } from "../../rect-utils-d_3gZVsc.js";
19
+ import { n as closestSideToPoint } from "../../closest-Clo6ODcK.js";
20
+ import { r as isPointInPolygon } from "../../polygon-BvdwYRBw.js";
21
+ import { t as createProps } from "../../create-props-CgtcN_Qu.js";
22
+ //#region src/machines/cascade-select/anatomy.ts
23
+ const anatomy = createAnatomy("cascade-select").parts("root", "label", "control", "trigger", "indicator", "valueText", "clearTrigger", "positioner", "content", "list", "item", "itemText", "itemIndicator");
24
+ const parts = anatomy.build();
25
+ //#endregion
26
+ //#region src/machines/cascade-select/collection.ts
27
+ const collection = (options) => {
28
+ return new TreeCollection(options);
29
+ };
30
+ collection.empty = () => {
31
+ return new TreeCollection({ rootNode: {
32
+ value: "ROOT",
33
+ children: []
34
+ } });
35
+ };
36
+ //#endregion
37
+ //#region src/machines/cascade-select/dom.ts
38
+ const dom = createScope({
39
+ getRootId: (ctx) => ctx.ids?.root ?? `cascade-select:${ctx.id}`,
40
+ getLabelId: (ctx) => ctx.ids?.label ?? `cascade-select:${ctx.id}:label`,
41
+ getControlId: (ctx) => ctx.ids?.control ?? `cascade-select:${ctx.id}:control`,
42
+ getTriggerId: (ctx) => ctx.ids?.trigger ?? `cascade-select:${ctx.id}:trigger`,
43
+ getIndicatorId: (ctx) => ctx.ids?.indicator ?? `cascade-select:${ctx.id}:indicator`,
44
+ getClearTriggerId: (ctx) => ctx.ids?.clearTrigger ?? `cascade-select:${ctx.id}:clear-trigger`,
45
+ getPositionerId: (ctx) => ctx.ids?.positioner ?? `cascade-select:${ctx.id}:positioner`,
46
+ getContentId: (ctx) => ctx.ids?.content ?? `cascade-select:${ctx.id}:content`,
47
+ getHiddenInputId: (ctx) => ctx.ids?.hiddenInput ?? `cascade-select:${ctx.id}:hidden-input`,
48
+ getListId: (ctx, value) => ctx.ids?.list?.(value) ?? `cascade-select:${ctx.id}:list:${value}`,
49
+ getItemId: (ctx, value) => ctx.ids?.item?.(value) ?? `cascade-select:${ctx.id}:item:${value}`,
50
+ getRootEl: (ctx) => dom.getById(ctx, dom.getRootId(ctx)),
51
+ getLabelEl: (ctx) => dom.getById(ctx, dom.getLabelId(ctx)),
52
+ getControlEl: (ctx) => dom.getById(ctx, dom.getControlId(ctx)),
53
+ getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
54
+ getIndicatorEl: (ctx) => dom.getById(ctx, dom.getIndicatorId(ctx)),
55
+ getClearTriggerEl: (ctx) => dom.getById(ctx, dom.getClearTriggerId(ctx)),
56
+ getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
57
+ getContentEl: (ctx) => dom.getById(ctx, dom.getContentId(ctx)),
58
+ getHiddenInputEl: (ctx) => dom.getById(ctx, dom.getHiddenInputId(ctx)),
59
+ getListEl: (ctx, value) => dom.getById(ctx, dom.getListId(ctx, value)),
60
+ getListEls: (ctx) => queryAll(dom.getContentEl(ctx), `[data-part="list"]`),
61
+ getItemEl: (ctx, value) => dom.getById(ctx, dom.getItemId(ctx, value)),
62
+ dispatchInputEvent: (ctx, value) => {
63
+ const inputEl = dom.getHiddenInputEl(ctx);
64
+ if (!inputEl) return;
65
+ dispatchInputValueEvent(inputEl, { value });
66
+ }
67
+ });
68
+ //#endregion
69
+ //#region src/machines/cascade-select/connect.ts
70
+ function connect(service, normalize) {
71
+ const { send, context, prop, scope, computed, state } = service;
72
+ const collection = prop("collection");
73
+ const value = context.get("value");
74
+ const open = state.hasTag("open");
75
+ const focused = state.matches("focused");
76
+ const highlightedIndexPath = context.get("highlightedIndexPath");
77
+ const highlightedValue = context.get("highlightedValue");
78
+ const currentPlacement = context.get("currentPlacement");
79
+ const currentPlacementSide = currentPlacement ? getPlacementSide(currentPlacement) : void 0;
80
+ const disabled = prop("disabled") || context.get("fieldsetDisabled");
81
+ const interactive = computed("isInteractive");
82
+ const valueAsString = computed("valueAsString");
83
+ const highlightedItems = context.get("highlightedItems");
84
+ const selectedItems = context.get("selectedItems");
85
+ const popperStyles = getPlacementStyles({
86
+ ...prop("positioning"),
87
+ placement: currentPlacement
88
+ });
89
+ const getItemState = (props) => {
90
+ const { item, indexPath, value: itemValue } = props;
91
+ const depth = indexPath ? indexPath.length : 0;
92
+ const highlighted = itemValue.every((v, i) => v === highlightedValue[i]);
93
+ const selected = value.some((v) => isEqual(v, itemValue));
94
+ const highlightedChild = collection.getNodeChildren(collection.at(indexPath))[highlightedIndexPath[depth]];
95
+ const highlightedIndex = highlightedIndexPath[depth];
96
+ return {
97
+ value: itemValue,
98
+ disabled: collection.getNodeDisabled(item),
99
+ highlighted,
100
+ selected,
101
+ hasChildren: collection.isBranchNode(item),
102
+ depth,
103
+ highlightedChild,
104
+ highlightedIndex
105
+ };
106
+ };
107
+ const hasSelectedItems = value.length > 0;
108
+ const empty = value.length === 0;
109
+ return {
110
+ collection,
111
+ open,
112
+ focused,
113
+ multiple: !!prop("multiple"),
114
+ disabled,
115
+ value,
116
+ highlightedValue,
117
+ highlightedItems,
118
+ selectedItems,
119
+ hasSelectedItems,
120
+ empty,
121
+ valueAsString,
122
+ reposition(options = {}) {
123
+ send({
124
+ type: "POSITIONING.SET",
125
+ options
126
+ });
127
+ },
128
+ focus() {
129
+ dom.getTriggerEl(scope)?.focus({ preventScroll: true });
130
+ },
131
+ setOpen(nextOpen) {
132
+ if (nextOpen === open) return;
133
+ send({ type: nextOpen ? "OPEN" : "CLOSE" });
134
+ },
135
+ setHighlightValue(value) {
136
+ send({
137
+ type: "HIGHLIGHTED_VALUE.SET",
138
+ value
139
+ });
140
+ },
141
+ clearHighlightValue() {
142
+ send({ type: "HIGHLIGHTED_VALUE.CLEAR" });
143
+ },
144
+ setValue(value) {
145
+ send({
146
+ type: "VALUE.SET",
147
+ value
148
+ });
149
+ },
150
+ selectValue(value) {
151
+ send({
152
+ type: "ITEM.SELECT",
153
+ value
154
+ });
155
+ },
156
+ clearValue(value) {
157
+ if (value) send({
158
+ type: "ITEM.CLEAR",
159
+ value
160
+ });
161
+ else send({ type: "VALUE.CLEAR" });
162
+ },
163
+ getItemState,
164
+ getRootProps() {
165
+ return normalize.element({
166
+ ...parts.root.attrs,
167
+ id: dom.getRootId(scope),
168
+ dir: prop("dir"),
169
+ "data-disabled": dataAttr(disabled),
170
+ "data-readonly": dataAttr(prop("readOnly")),
171
+ "data-invalid": dataAttr(prop("invalid")),
172
+ "data-state": open ? "open" : "closed"
173
+ });
174
+ },
175
+ getLabelProps() {
176
+ return normalize.label({
177
+ ...parts.label.attrs,
178
+ id: dom.getLabelId(scope),
179
+ dir: prop("dir"),
180
+ htmlFor: dom.getHiddenInputId(scope),
181
+ "data-disabled": dataAttr(disabled),
182
+ "data-readonly": dataAttr(prop("readOnly")),
183
+ "data-invalid": dataAttr(prop("invalid")),
184
+ onClick(event) {
185
+ if (event.defaultPrevented) return;
186
+ if (disabled) return;
187
+ dom.getTriggerEl(scope)?.focus({ preventScroll: true });
188
+ }
189
+ });
190
+ },
191
+ getControlProps() {
192
+ return normalize.element({
193
+ ...parts.control.attrs,
194
+ dir: prop("dir"),
195
+ id: dom.getControlId(scope),
196
+ "data-disabled": dataAttr(disabled),
197
+ "data-focus": dataAttr(focused),
198
+ "data-readonly": dataAttr(prop("readOnly")),
199
+ "data-invalid": dataAttr(prop("invalid")),
200
+ "data-state": open ? "open" : "closed"
201
+ });
202
+ },
203
+ getTriggerProps() {
204
+ return normalize.button({
205
+ ...parts.trigger.attrs,
206
+ dir: prop("dir"),
207
+ id: dom.getTriggerId(scope),
208
+ type: "button",
209
+ role: "combobox",
210
+ "aria-controls": dom.getContentId(scope),
211
+ "aria-expanded": open,
212
+ "aria-haspopup": "listbox",
213
+ "aria-labelledby": dom.getLabelId(scope),
214
+ "data-state": open ? "open" : "closed",
215
+ "data-disabled": dataAttr(disabled),
216
+ "data-readonly": dataAttr(prop("readOnly")),
217
+ "data-invalid": dataAttr(prop("invalid")),
218
+ "data-focus": dataAttr(focused),
219
+ "data-placement": currentPlacement,
220
+ "data-side": currentPlacementSide,
221
+ "data-placeholder-shown": dataAttr(!hasSelectedItems),
222
+ disabled,
223
+ onClick(event) {
224
+ if (event.defaultPrevented) return;
225
+ if (!interactive) return;
226
+ send({ type: "TRIGGER.CLICK" });
227
+ },
228
+ onFocus() {
229
+ send({ type: "TRIGGER.FOCUS" });
230
+ },
231
+ onBlur() {
232
+ send({ type: "TRIGGER.BLUR" });
233
+ },
234
+ onKeyDown(event) {
235
+ if (event.defaultPrevented) return;
236
+ if (!interactive) return;
237
+ const exec = {
238
+ ArrowUp() {
239
+ send({ type: "TRIGGER.ARROW_UP" });
240
+ },
241
+ ArrowDown(event) {
242
+ send({ type: event.altKey ? "OPEN" : "TRIGGER.ARROW_DOWN" });
243
+ },
244
+ ArrowLeft() {
245
+ send({ type: "TRIGGER.ARROW_LEFT" });
246
+ },
247
+ ArrowRight() {
248
+ send({ type: "TRIGGER.ARROW_RIGHT" });
249
+ },
250
+ Enter() {
251
+ send({ type: "TRIGGER.ENTER" });
252
+ },
253
+ Space() {
254
+ send({ type: "TRIGGER.ENTER" });
255
+ }
256
+ }[getEventKey(event, { dir: prop("dir") })];
257
+ if (exec) {
258
+ exec(event);
259
+ event.preventDefault();
260
+ }
261
+ }
262
+ });
263
+ },
264
+ getClearTriggerProps() {
265
+ return normalize.button({
266
+ ...parts.clearTrigger.attrs,
267
+ dir: prop("dir"),
268
+ id: dom.getClearTriggerId(scope),
269
+ type: "button",
270
+ "aria-label": "Clear value",
271
+ hidden: !hasSelectedItems,
272
+ "data-disabled": dataAttr(disabled),
273
+ "data-readonly": dataAttr(prop("readOnly")),
274
+ "data-invalid": dataAttr(prop("invalid")),
275
+ disabled,
276
+ onClick(event) {
277
+ if (event.defaultPrevented) return;
278
+ send({ type: "CLEAR_TRIGGER.CLICK" });
279
+ }
280
+ });
281
+ },
282
+ getPositionerProps() {
283
+ return normalize.element({
284
+ ...parts.positioner.attrs,
285
+ dir: prop("dir"),
286
+ id: dom.getPositionerId(scope),
287
+ style: popperStyles.floating
288
+ });
289
+ },
290
+ getContentProps() {
291
+ const highlightedItemId = highlightedValue ? dom.getItemId(scope, highlightedValue.toString()) : void 0;
292
+ return normalize.element({
293
+ ...parts.content.attrs,
294
+ id: dom.getContentId(scope),
295
+ role: "listbox",
296
+ "aria-labelledby": dom.getLabelId(scope),
297
+ "aria-activedescendant": highlightedItemId,
298
+ "data-activedescendant": highlightedItemId,
299
+ "data-state": open ? "open" : "closed",
300
+ "aria-multiselectable": prop("multiple"),
301
+ "aria-required": prop("required"),
302
+ "aria-readonly": prop("readOnly"),
303
+ hidden: !open,
304
+ tabIndex: 0,
305
+ onKeyDown(event) {
306
+ if (!interactive) return;
307
+ if (!isSelfTarget(event)) return;
308
+ if (event.key === "Tab") {
309
+ if (!isValidTabEvent(event)) {
310
+ event.preventDefault();
311
+ return;
312
+ }
313
+ }
314
+ const exec = {
315
+ ArrowDown() {
316
+ send({ type: "CONTENT.ARROW_DOWN" });
317
+ },
318
+ ArrowUp() {
319
+ send({ type: "CONTENT.ARROW_UP" });
320
+ },
321
+ ArrowRight() {
322
+ send({ type: "CONTENT.ARROW_RIGHT" });
323
+ },
324
+ ArrowLeft() {
325
+ send({ type: "CONTENT.ARROW_LEFT" });
326
+ },
327
+ Home() {
328
+ send({ type: "CONTENT.HOME" });
329
+ },
330
+ End() {
331
+ send({ type: "CONTENT.END" });
332
+ },
333
+ Enter() {
334
+ send({ type: "CONTENT.ENTER" });
335
+ },
336
+ " "() {
337
+ send({ type: "CONTENT.ENTER" });
338
+ }
339
+ }[getEventKey(event, { dir: prop("dir") })];
340
+ if (exec) {
341
+ exec();
342
+ event.preventDefault();
343
+ return;
344
+ }
345
+ if (isEditableElement(event.target)) return;
346
+ },
347
+ onPointerMove(event) {
348
+ if (!interactive) return;
349
+ send({
350
+ type: "POINTER_MOVE",
351
+ clientX: event.clientX,
352
+ clientY: event.clientY,
353
+ target: event.target
354
+ });
355
+ }
356
+ });
357
+ },
358
+ getListProps(props) {
359
+ const itemState = getItemState(props);
360
+ return normalize.element({
361
+ ...parts.list.attrs,
362
+ id: dom.getListId(scope, itemState.value.toString()),
363
+ dir: prop("dir"),
364
+ "data-depth": itemState.depth,
365
+ "aria-level": itemState.depth,
366
+ role: "group"
367
+ });
368
+ },
369
+ getIndicatorProps() {
370
+ return normalize.element({
371
+ ...parts.indicator.attrs,
372
+ id: dom.getIndicatorId(scope),
373
+ dir: prop("dir"),
374
+ "aria-hidden": true,
375
+ "data-state": open ? "open" : "closed",
376
+ "data-disabled": dataAttr(disabled),
377
+ "data-readonly": dataAttr(prop("readOnly")),
378
+ "data-invalid": dataAttr(prop("invalid"))
379
+ });
380
+ },
381
+ getItemProps(props) {
382
+ const { indexPath } = props;
383
+ const itemState = getItemState(props);
384
+ return normalize.element({
385
+ ...parts.item.attrs,
386
+ id: dom.getItemId(scope, itemState.value.toString()),
387
+ dir: prop("dir"),
388
+ role: "treeitem",
389
+ "aria-haspopup": itemState.hasChildren ? "menu" : void 0,
390
+ "aria-expanded": itemState.hasChildren ? itemState.highlighted : false,
391
+ "aria-controls": itemState.hasChildren ? dom.getListId(scope, itemState.value.toString()) : void 0,
392
+ "aria-owns": itemState.hasChildren ? dom.getListId(scope, itemState.value.toString()) : void 0,
393
+ "aria-disabled": ariaAttr(itemState.disabled),
394
+ "data-value": itemState.value.toString(),
395
+ "data-disabled": dataAttr(itemState.disabled),
396
+ "data-highlighted": dataAttr(itemState.highlighted),
397
+ "data-selected": dataAttr(itemState.selected),
398
+ "data-depth": itemState.depth,
399
+ "data-state": itemState.selected ? "checked" : "unchecked",
400
+ "data-type": itemState.hasChildren ? "branch" : "leaf",
401
+ "data-index-path": indexPath.toString(),
402
+ onDoubleClick() {
403
+ if (itemState.disabled) return;
404
+ send({ type: "CLOSE" });
405
+ },
406
+ onClick(event) {
407
+ if (event.defaultPrevented) return;
408
+ if (!interactive) return;
409
+ if (itemState.disabled) return;
410
+ send({
411
+ type: "ITEM.CLICK",
412
+ value: itemState.value,
413
+ indexPath
414
+ });
415
+ },
416
+ onPointerEnter(event) {
417
+ if (!interactive) return;
418
+ if (itemState.disabled) return;
419
+ send({
420
+ type: "ITEM.POINTER_ENTER",
421
+ value: itemState.value,
422
+ indexPath,
423
+ clientX: event.clientX,
424
+ clientY: event.clientY
425
+ });
426
+ },
427
+ onPointerLeave(event) {
428
+ if (!interactive) return;
429
+ if (itemState.disabled) return;
430
+ if (event.pointerType !== "mouse") return;
431
+ if (!service.event.previous()?.type.includes("POINTER")) return;
432
+ send({
433
+ type: "ITEM.POINTER_LEAVE",
434
+ value: itemState.value,
435
+ indexPath,
436
+ clientX: event.clientX,
437
+ clientY: event.clientY
438
+ });
439
+ }
440
+ });
441
+ },
442
+ getItemTextProps(props) {
443
+ const { item } = props;
444
+ const itemValue = collection.getNodeValue(item);
445
+ const itemState = getItemState(props);
446
+ return normalize.element({
447
+ dir: prop("dir"),
448
+ ...parts.itemText.attrs,
449
+ "data-value": itemValue,
450
+ "data-highlighted": dataAttr(itemState.highlighted),
451
+ "data-state": itemState.selected ? "checked" : "unchecked",
452
+ "data-disabled": dataAttr(itemState.disabled)
453
+ });
454
+ },
455
+ getItemIndicatorProps(props) {
456
+ const { item } = props;
457
+ const itemValue = collection.getNodeValue(item);
458
+ const itemState = getItemState(props);
459
+ return normalize.element({
460
+ ...parts.itemIndicator.attrs,
461
+ dir: prop("dir"),
462
+ "data-value": itemValue,
463
+ "data-highlighted": dataAttr(itemState.highlighted),
464
+ "data-type": itemState.hasChildren ? "branch" : "leaf",
465
+ "data-state": itemState.selected ? "checked" : "unchecked",
466
+ hidden: !itemState.selected
467
+ });
468
+ },
469
+ getValueTextProps() {
470
+ return normalize.element({
471
+ ...parts.valueText.attrs,
472
+ dir: prop("dir"),
473
+ "data-disabled": dataAttr(disabled),
474
+ "data-invalid": dataAttr(prop("invalid")),
475
+ "data-focus": dataAttr(focused)
476
+ });
477
+ },
478
+ getHiddenInputProps() {
479
+ const defaultValue = context.hash("value");
480
+ return normalize.input({
481
+ name: prop("name"),
482
+ form: prop("form"),
483
+ disabled,
484
+ multiple: prop("multiple"),
485
+ required: prop("required"),
486
+ readOnly: prop("readOnly"),
487
+ hidden: true,
488
+ "aria-hidden": true,
489
+ id: dom.getHiddenInputId(scope),
490
+ defaultValue,
491
+ "aria-labelledby": dom.getLabelId(scope)
492
+ });
493
+ }
494
+ };
495
+ }
496
+ //#endregion
497
+ //#region src/machines/cascade-select/utils.ts
498
+ function createGraceArea(exitPoint, triggerRect, targetRect, options = {}) {
499
+ const { padding = 5 } = options;
500
+ const paddedExitPoints = getPaddedExitPoints(exitPoint, closestSideToPoint(createRect({
501
+ x: triggerRect.left,
502
+ y: triggerRect.top,
503
+ width: triggerRect.width,
504
+ height: triggerRect.height
505
+ }), exitPoint), padding);
506
+ const targetPoints = domRectToPoints(targetRect);
507
+ return getConvexHull([...paddedExitPoints, ...targetPoints]);
508
+ }
509
+ function isPointerInGraceArea(point, graceArea) {
510
+ return isPointInPolygon(graceArea, point);
511
+ }
512
+ function getPaddedExitPoints(exitPoint, exitSide, padding) {
513
+ const { x, y } = exitPoint;
514
+ switch (exitSide) {
515
+ case "top": return [createPoint(x - padding, y + padding), createPoint(x + padding, y + padding)];
516
+ case "bottom": return [createPoint(x - padding, y - padding), createPoint(x + padding, y - padding)];
517
+ case "left": return [createPoint(x + padding, y - padding), createPoint(x + padding, y + padding)];
518
+ case "right": return [createPoint(x - padding, y - padding), createPoint(x - padding, y + padding)];
519
+ default: return [];
520
+ }
521
+ }
522
+ function domRectToPoints(rect) {
523
+ const corners = getRectCorners(createRect({
524
+ x: rect.left,
525
+ y: rect.top,
526
+ width: rect.width,
527
+ height: rect.height
528
+ }));
529
+ return [
530
+ corners.top,
531
+ corners.right,
532
+ corners.bottom,
533
+ corners.left
534
+ ];
535
+ }
536
+ function getConvexHull(points) {
537
+ if (points.length <= 1) return points.slice();
538
+ const sortedPoints = points.slice().sort((a, b) => {
539
+ if (a.x !== b.x) return a.x - b.x;
540
+ return a.y - b.y;
541
+ });
542
+ const lower = [];
543
+ for (const point of sortedPoints) {
544
+ while (lower.length >= 2 && crossProduct(lower[lower.length - 2], lower[lower.length - 1], point) <= 0) lower.pop();
545
+ lower.push(point);
546
+ }
547
+ const upper = [];
548
+ for (let i = sortedPoints.length - 1; i >= 0; i--) {
549
+ const point = sortedPoints[i];
550
+ while (upper.length >= 2 && crossProduct(upper[upper.length - 2], upper[upper.length - 1], point) <= 0) upper.pop();
551
+ upper.push(point);
552
+ }
553
+ lower.pop();
554
+ upper.pop();
555
+ return lower.concat(upper);
556
+ }
557
+ function crossProduct(o, a, b) {
558
+ return (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
559
+ }
560
+ //#endregion
561
+ //#region src/machines/cascade-select/machine.ts
562
+ const { or, and, not } = createGuards();
563
+ const machine = createMachine({
564
+ props({ props }) {
565
+ return {
566
+ closeOnSelect: true,
567
+ loopFocus: false,
568
+ defaultValue: [],
569
+ defaultHighlightedValue: [],
570
+ defaultOpen: false,
571
+ multiple: false,
572
+ highlightTrigger: "click",
573
+ allowParentSelection: false,
574
+ positioning: {
575
+ placement: "bottom-start",
576
+ gutter: 8,
577
+ ...props.positioning
578
+ },
579
+ ...props,
580
+ collection: props.collection ?? collection.empty()
581
+ };
582
+ },
583
+ context({ prop, bindable }) {
584
+ return {
585
+ value: bindable(() => ({
586
+ defaultValue: prop("defaultValue"),
587
+ value: prop("value"),
588
+ isEqual,
589
+ hash(value) {
590
+ return value.join(", ");
591
+ }
592
+ })),
593
+ highlightedValue: bindable(() => ({
594
+ defaultValue: prop("defaultHighlightedValue"),
595
+ value: prop("highlightedValue"),
596
+ isEqual
597
+ })),
598
+ valueIndexPath: bindable(() => {
599
+ return { defaultValue: (prop("value") ?? prop("defaultValue") ?? []).map((v) => prop("collection").getIndexPath(v)) };
600
+ }),
601
+ highlightedIndexPath: bindable(() => {
602
+ const value = prop("highlightedValue") ?? prop("defaultHighlightedValue") ?? null;
603
+ return { defaultValue: value ? prop("collection").getIndexPath(value) : [] };
604
+ }),
605
+ highlightedItems: bindable(() => ({ defaultValue: [] })),
606
+ selectedItems: bindable(() => ({ defaultValue: [] })),
607
+ currentPlacement: bindable(() => ({ defaultValue: void 0 })),
608
+ fieldsetDisabled: bindable(() => ({ defaultValue: false })),
609
+ graceArea: bindable(() => ({ defaultValue: null })),
610
+ isPointerInTransit: bindable(() => ({ defaultValue: false }))
611
+ };
612
+ },
613
+ computed: {
614
+ isInteractive: ({ prop }) => !(prop("disabled") || prop("readOnly")),
615
+ valueAsString: ({ prop, context }) => {
616
+ const collection = prop("collection");
617
+ const items = context.get("selectedItems");
618
+ const multiple = prop("multiple");
619
+ const formatMultipleMode = (items) => collection.stringifyNode(items.at(-1)) ?? collection.getNodeValue(items.at(-1));
620
+ const formatSingleMode = (items) => {
621
+ return items.map((item) => {
622
+ return collection.stringifyNode(item) ?? collection.getNodeValue(item);
623
+ }).join(" / ");
624
+ };
625
+ const defaultFormatValue = (items) => items.map(multiple ? formatMultipleMode : formatSingleMode).join(", ");
626
+ return (prop("formatValue") ?? defaultFormatValue)(items);
627
+ }
628
+ },
629
+ initialState({ prop }) {
630
+ return prop("open") || prop("defaultOpen") ? "open" : "idle";
631
+ },
632
+ watch({ context, prop, track, action }) {
633
+ track([() => context.get("value")?.toString()], () => {
634
+ action(["syncInputValue", "dispatchChangeEvent"]);
635
+ });
636
+ track([() => prop("open")], () => {
637
+ action(["toggleVisibility"]);
638
+ });
639
+ },
640
+ on: {
641
+ "VALUE.SET": { actions: ["setValue"] },
642
+ "VALUE.CLEAR": { actions: ["clearValue"] },
643
+ "CLEAR_TRIGGER.CLICK": { actions: ["clearValue", "focusTriggerEl"] },
644
+ "HIGHLIGHTED_VALUE.SET": { actions: ["setHighlightedValue"] },
645
+ "HIGHLIGHTED_VALUE.CLEAR": { actions: ["clearHighlightedValue"] },
646
+ "ITEM.SELECT": { actions: ["selectItem"] },
647
+ "ITEM.CLEAR": { actions: ["clearItem"] }
648
+ },
649
+ effects: ["trackFormControlState"],
650
+ states: {
651
+ idle: {
652
+ tags: ["closed"],
653
+ on: {
654
+ "CONTROLLED.OPEN": [{
655
+ guard: "isTriggerClickEvent",
656
+ target: "open",
657
+ actions: ["setInitialFocus", "highlightFirstSelectedItem"]
658
+ }, {
659
+ target: "open",
660
+ actions: ["setInitialFocus"]
661
+ }],
662
+ "TRIGGER.CLICK": [{
663
+ guard: "isOpenControlled",
664
+ actions: ["invokeOnOpen"]
665
+ }, {
666
+ target: "open",
667
+ actions: [
668
+ "invokeOnOpen",
669
+ "setInitialFocus",
670
+ "highlightFirstSelectedItem"
671
+ ]
672
+ }],
673
+ "TRIGGER.FOCUS": { target: "focused" },
674
+ OPEN: [{
675
+ guard: "isOpenControlled",
676
+ actions: ["invokeOnOpen"]
677
+ }, {
678
+ target: "open",
679
+ actions: ["setInitialFocus", "invokeOnOpen"]
680
+ }]
681
+ }
682
+ },
683
+ focused: {
684
+ tags: ["closed"],
685
+ on: {
686
+ "CONTROLLED.OPEN": [
687
+ {
688
+ guard: "isTriggerClickEvent",
689
+ target: "open",
690
+ actions: ["setInitialFocus", "highlightFirstSelectedItem"]
691
+ },
692
+ {
693
+ guard: "isTriggerArrowUpEvent",
694
+ target: "open",
695
+ actions: ["setInitialFocus", "highlightLastItem"]
696
+ },
697
+ {
698
+ guard: or("isTriggerArrowDownEvent", "isTriggerEnterEvent", ""),
699
+ target: "open",
700
+ actions: ["setInitialFocus", "highlightFirstItem"]
701
+ },
702
+ {
703
+ target: "open",
704
+ actions: ["setInitialFocus"]
705
+ }
706
+ ],
707
+ OPEN: [{
708
+ guard: "isOpenControlled",
709
+ actions: ["invokeOnOpen"]
710
+ }, {
711
+ target: "open",
712
+ actions: ["setInitialFocus", "invokeOnOpen"]
713
+ }],
714
+ "TRIGGER.BLUR": { target: "idle" },
715
+ "TRIGGER.CLICK": [{
716
+ guard: "isOpenControlled",
717
+ actions: ["invokeOnOpen"]
718
+ }, {
719
+ target: "open",
720
+ actions: [
721
+ "setInitialFocus",
722
+ "invokeOnOpen",
723
+ "highlightFirstSelectedItem"
724
+ ]
725
+ }],
726
+ "TRIGGER.ENTER": [{
727
+ guard: "isOpenControlled",
728
+ actions: ["invokeOnOpen"]
729
+ }, {
730
+ target: "open",
731
+ actions: [
732
+ "setInitialFocus",
733
+ "invokeOnOpen",
734
+ "highlightFirstItem"
735
+ ]
736
+ }],
737
+ "TRIGGER.ARROW_UP": [{
738
+ guard: "isOpenControlled",
739
+ actions: ["invokeOnOpen"]
740
+ }, {
741
+ target: "open",
742
+ actions: [
743
+ "setInitialFocus",
744
+ "invokeOnOpen",
745
+ "highlightLastItem"
746
+ ]
747
+ }],
748
+ "TRIGGER.ARROW_DOWN": [{
749
+ guard: "isOpenControlled",
750
+ actions: ["invokeOnOpen"]
751
+ }, {
752
+ target: "open",
753
+ actions: [
754
+ "setInitialFocus",
755
+ "invokeOnOpen",
756
+ "highlightFirstItem"
757
+ ]
758
+ }],
759
+ "TRIGGER.ARROW_LEFT": [{
760
+ guard: "isOpenControlled",
761
+ actions: ["invokeOnOpen"]
762
+ }, {
763
+ target: "open",
764
+ actions: ["invokeOnOpen"]
765
+ }],
766
+ "TRIGGER.ARROW_RIGHT": [{
767
+ guard: "isOpenControlled",
768
+ actions: ["invokeOnOpen"]
769
+ }, {
770
+ target: "open",
771
+ actions: ["invokeOnOpen", "highlightFirstItem"]
772
+ }]
773
+ }
774
+ },
775
+ open: {
776
+ tags: ["open"],
777
+ exit: ["scrollContentToTop"],
778
+ effects: [
779
+ "trackDismissableElement",
780
+ "trackFocusVisible",
781
+ "computePlacement",
782
+ "scrollToHighlightedItems"
783
+ ],
784
+ on: {
785
+ "CONTROLLED.CLOSE": [{
786
+ guard: "restoreFocus",
787
+ target: "focused",
788
+ actions: ["focusTriggerEl", "clearHighlightedValue"]
789
+ }, {
790
+ target: "idle",
791
+ actions: ["clearHighlightedValue"]
792
+ }],
793
+ CLOSE: [
794
+ {
795
+ guard: "isOpenControlled",
796
+ actions: ["invokeOnClose"]
797
+ },
798
+ {
799
+ guard: "restoreFocus",
800
+ target: "focused",
801
+ actions: [
802
+ "invokeOnClose",
803
+ "focusTriggerEl",
804
+ "clearHighlightedValue"
805
+ ]
806
+ },
807
+ {
808
+ target: "idle",
809
+ actions: ["invokeOnClose", "clearHighlightedValue"]
810
+ }
811
+ ],
812
+ "TRIGGER.CLICK": [{
813
+ guard: "isOpenControlled",
814
+ actions: ["invokeOnClose"]
815
+ }, {
816
+ target: "focused",
817
+ actions: [
818
+ "invokeOnClose",
819
+ "focusTriggerEl",
820
+ "clearHighlightedValue"
821
+ ]
822
+ }],
823
+ "ITEM.CLICK": [
824
+ {
825
+ guard: and("canSelectItem", and("shouldCloseOnSelect", not("multiple")), "isOpenControlled"),
826
+ actions: ["selectItem", "invokeOnClose"]
827
+ },
828
+ {
829
+ guard: and("canSelectItem", and("shouldCloseOnSelect", not("multiple"))),
830
+ target: "focused",
831
+ actions: [
832
+ "selectItem",
833
+ "invokeOnClose",
834
+ "focusTriggerEl",
835
+ "clearHighlightedValue"
836
+ ]
837
+ },
838
+ {
839
+ guard: "canSelectItem",
840
+ actions: ["selectItem"]
841
+ },
842
+ { actions: ["setHighlightedValue"] }
843
+ ],
844
+ "ITEM.POINTER_ENTER": [{
845
+ guard: "isHoverHighlight",
846
+ actions: ["setHighlightingForHoveredItem"]
847
+ }],
848
+ "ITEM.POINTER_LEAVE": [{
849
+ guard: and("isHoverHighlight", "shouldHighlightOnHover"),
850
+ actions: ["createGraceArea"]
851
+ }],
852
+ POINTER_MOVE: [{
853
+ guard: and("isHoverHighlight", "hasGraceArea", "isPointerOutsideGraceArea", "isPointerNotInAnyItem", "hasHighlightedValue"),
854
+ actions: ["clearGraceArea"]
855
+ }],
856
+ "GRACE_AREA.CLEAR": [{
857
+ guard: "isHoverHighlight",
858
+ actions: ["clearGraceArea"]
859
+ }],
860
+ "CONTENT.HOME": { actions: ["highlightFirstItem"] },
861
+ "CONTENT.END": { actions: ["highlightLastItem"] },
862
+ "CONTENT.ARROW_DOWN": [{
863
+ guard: or(not("hasHighlightedValue"), and("loop", "isHighlightedLastItem")),
864
+ actions: ["highlightFirstItem"]
865
+ }, { actions: ["highlightNextItem"] }],
866
+ "CONTENT.ARROW_UP": [{
867
+ guard: or(not("hasHighlightedValue"), and("loop", "isHighlightedFirstItem")),
868
+ actions: ["highlightLastItem"]
869
+ }, { actions: ["highlightPreviousItem"] }],
870
+ "CONTENT.ARROW_RIGHT": [{
871
+ guard: "canNavigateToChild",
872
+ actions: ["highlightFirstChild"]
873
+ }],
874
+ "CONTENT.ARROW_LEFT": [
875
+ {
876
+ guard: and("isAtRootLevel", "isOpenControlled"),
877
+ actions: ["invokeOnClose", "focusTriggerEl"]
878
+ },
879
+ {
880
+ guard: and("isAtRootLevel", "restoreFocus"),
881
+ target: "focused",
882
+ actions: [
883
+ "invokeOnClose",
884
+ "focusTriggerEl",
885
+ "clearHighlightedValue"
886
+ ]
887
+ },
888
+ {
889
+ guard: "isAtRootLevel",
890
+ target: "idle",
891
+ actions: ["invokeOnClose", "clearHighlightedValue"]
892
+ },
893
+ {
894
+ guard: "canNavigateToParent",
895
+ actions: ["highlightParent"]
896
+ }
897
+ ],
898
+ "CONTENT.ENTER": [
899
+ {
900
+ guard: and("canSelectHighlightedItem", and("shouldCloseOnSelectHighlighted", not("multiple")), "isOpenControlled"),
901
+ actions: ["selectHighlightedItem", "invokeOnClose"]
902
+ },
903
+ {
904
+ guard: and("canSelectHighlightedItem", and("shouldCloseOnSelectHighlighted", not("multiple"))),
905
+ target: "focused",
906
+ actions: [
907
+ "selectHighlightedItem",
908
+ "invokeOnClose",
909
+ "focusTriggerEl",
910
+ "clearHighlightedValue"
911
+ ]
912
+ },
913
+ {
914
+ guard: "canSelectHighlightedItem",
915
+ actions: ["selectHighlightedItem"]
916
+ }
917
+ ],
918
+ "POSITIONING.SET": { actions: ["reposition"] }
919
+ }
920
+ }
921
+ },
922
+ implementations: {
923
+ guards: {
924
+ restoreFocus: ({ event }) => restoreFocusFn(event),
925
+ multiple: ({ prop }) => !!prop("multiple"),
926
+ loop: ({ prop }) => !!prop("loopFocus"),
927
+ isOpenControlled: ({ prop }) => !!prop("open"),
928
+ isTriggerClickEvent: ({ event }) => event.previousEvent?.type === "TRIGGER.CLICK",
929
+ isTriggerArrowUpEvent: ({ event }) => event.previousEvent?.type === "TRIGGER.ARROW_UP",
930
+ isTriggerArrowDownEvent: ({ event }) => event.previousEvent?.type === "TRIGGER.ARROW_DOWN",
931
+ isTriggerEnterEvent: ({ event }) => event.previousEvent?.type === "TRIGGER.ENTER",
932
+ isTriggerArrowRightEvent: ({ event }) => event.previousEvent?.type === "TRIGGER.ARROW_RIGHT",
933
+ hasHighlightedValue: ({ context }) => context.get("highlightedValue").length > 0,
934
+ isHighlightedFirstItem: ({ context }) => context.get("highlightedIndexPath").at(-1) === 0,
935
+ isHighlightedLastItem: ({ prop, context }) => {
936
+ const path = context.get("highlightedIndexPath");
937
+ const itemIndex = path.at(-1);
938
+ if (!itemIndex && itemIndex !== 0) return false;
939
+ const parentIndexPath = path.slice(0, -1);
940
+ return !prop("collection").at([...parentIndexPath, itemIndex + 1]);
941
+ },
942
+ shouldCloseOnSelect: ({ prop, event }) => {
943
+ const collection = prop("collection");
944
+ const node = collection.at(event.indexPath);
945
+ return prop("closeOnSelect") && node && !collection.isBranchNode(node);
946
+ },
947
+ shouldCloseOnSelectHighlighted: ({ prop, context }) => {
948
+ const collection = prop("collection");
949
+ const node = last(context.get("highlightedItems"));
950
+ return prop("closeOnSelect") && node != null && !collection.isBranchNode(node);
951
+ },
952
+ canSelectItem: ({ prop, event }) => {
953
+ const collection = prop("collection");
954
+ const node = collection.at(event.indexPath);
955
+ if (!node) return false;
956
+ return prop("allowParentSelection") || !collection.isBranchNode(node);
957
+ },
958
+ canSelectHighlightedItem: ({ prop, context }) => {
959
+ const collection = prop("collection");
960
+ const node = collection.at(context.get("highlightedIndexPath"));
961
+ if (!node) return false;
962
+ return prop("allowParentSelection") || !collection.isBranchNode(node);
963
+ },
964
+ canNavigateToChild: ({ prop, context }) => {
965
+ const highlightedIndexPath = context.get("highlightedIndexPath");
966
+ if (!highlightedIndexPath.length) return false;
967
+ const collection = prop("collection");
968
+ const node = collection.at(highlightedIndexPath);
969
+ return node && collection.isBranchNode(node);
970
+ },
971
+ canNavigateToParent: ({ context }) => context.get("highlightedIndexPath").length > 1,
972
+ isAtRootLevel: ({ context }) => context.get("highlightedIndexPath").length <= 1,
973
+ isHoverHighlight: ({ prop }) => prop("highlightTrigger") === "hover",
974
+ shouldHighlightOnHover: ({ prop, event }) => {
975
+ const collection = prop("collection");
976
+ const node = collection.at(event.indexPath);
977
+ return node && collection.isBranchNode(node);
978
+ },
979
+ shouldUpdateHighlightedIndexPath: ({ prop, context, event }) => {
980
+ const collection = prop("collection");
981
+ const currentHighlightedIndexPath = context.get("highlightedIndexPath");
982
+ if (!currentHighlightedIndexPath || currentHighlightedIndexPath.length === 0) return false;
983
+ const node = collection.at(event.indexPath);
984
+ if (!node || collection.isBranchNode(node)) return false;
985
+ const indexPath = event.indexPath;
986
+ if (!indexPath) return false;
987
+ const minLength = Math.min(indexPath.length, currentHighlightedIndexPath.length);
988
+ let commonPrefixLength = 0;
989
+ for (let i = 0; i < minLength; i++) if (indexPath[i] === currentHighlightedIndexPath[i]) commonPrefixLength = i + 1;
990
+ else break;
991
+ return commonPrefixLength > 0 && (commonPrefixLength < currentHighlightedIndexPath.length || commonPrefixLength < indexPath.length);
992
+ },
993
+ hasGraceArea: ({ context }) => {
994
+ return context.get("graceArea") != null;
995
+ },
996
+ isPointerOutsideGraceArea: ({ context, event }) => {
997
+ const graceArea = context.get("graceArea");
998
+ if (!graceArea) return false;
999
+ return !isPointerInGraceArea({
1000
+ x: event.clientX,
1001
+ y: event.clientY
1002
+ }, graceArea);
1003
+ },
1004
+ isPointerNotInAnyItem: ({ event }) => {
1005
+ const target = event.target;
1006
+ const itemElement = target.closest("[data-part=\"item\"]");
1007
+ const contentElement = target.closest("[data-part=\"content\"]");
1008
+ return !contentElement || !itemElement && !!contentElement;
1009
+ }
1010
+ },
1011
+ effects: {
1012
+ trackFormControlState({ context, scope, prop }) {
1013
+ return trackFormControl(dom.getTriggerEl(scope), {
1014
+ onFieldsetDisabledChange(disabled) {
1015
+ context.set("fieldsetDisabled", disabled);
1016
+ },
1017
+ onFormReset() {
1018
+ context.set("value", prop("defaultValue") ?? []);
1019
+ }
1020
+ });
1021
+ },
1022
+ trackFocusVisible({ scope }) {
1023
+ return trackFocusVisible({ root: scope.getRootNode?.() });
1024
+ },
1025
+ trackDismissableElement({ scope, send, prop }) {
1026
+ const contentEl = () => dom.getContentEl(scope);
1027
+ let restoreFocus = true;
1028
+ return trackDismissableElement(contentEl, {
1029
+ defer: true,
1030
+ exclude: [dom.getTriggerEl(scope), dom.getClearTriggerEl(scope)],
1031
+ onFocusOutside: prop("onFocusOutside"),
1032
+ onPointerDownOutside: prop("onPointerDownOutside"),
1033
+ onInteractOutside(event) {
1034
+ prop("onInteractOutside")?.(event);
1035
+ restoreFocus = !(event.detail.focusable || event.detail.contextmenu);
1036
+ },
1037
+ onDismiss() {
1038
+ send({
1039
+ type: "CLOSE",
1040
+ src: "interact-outside",
1041
+ restoreFocus
1042
+ });
1043
+ }
1044
+ });
1045
+ },
1046
+ computePlacement({ context, prop, scope }) {
1047
+ const triggerEl = () => dom.getTriggerEl(scope);
1048
+ const positionerEl = () => dom.getPositionerEl(scope);
1049
+ return getPlacement(triggerEl, positionerEl, {
1050
+ ...prop("positioning"),
1051
+ onComplete(data) {
1052
+ context.set("currentPlacement", data.placement);
1053
+ }
1054
+ });
1055
+ },
1056
+ scrollToHighlightedItems({ context, prop, scope }) {
1057
+ let cleanups = [];
1058
+ const exec = (immediate) => {
1059
+ const highlightedValue = context.get("highlightedValue");
1060
+ const highlightedIndexPath = context.get("highlightedIndexPath");
1061
+ if (!highlightedIndexPath.length) return;
1062
+ if (getInteractionModality() === "pointer") return;
1063
+ dom.getListEls(scope).forEach((listEl, index) => {
1064
+ const itemPath = highlightedIndexPath.slice(0, index + 1);
1065
+ const itemEl = dom.getItemEl(scope, highlightedValue.toString());
1066
+ const scrollToIndexFn = prop("scrollToIndexFn");
1067
+ if (scrollToIndexFn) {
1068
+ const itemIndexInList = itemPath[itemPath.length - 1];
1069
+ scrollToIndexFn({
1070
+ index: itemIndexInList,
1071
+ immediate,
1072
+ depth: index
1073
+ });
1074
+ return;
1075
+ }
1076
+ const raf_cleanup = raf(() => {
1077
+ scrollIntoView(itemEl, {
1078
+ rootEl: listEl,
1079
+ block: "nearest"
1080
+ });
1081
+ });
1082
+ cleanups.push(raf_cleanup);
1083
+ });
1084
+ };
1085
+ raf(() => {
1086
+ setInteractionModality("virtual");
1087
+ exec(true);
1088
+ });
1089
+ const rafCleanup = raf(() => exec(true));
1090
+ cleanups.push(rafCleanup);
1091
+ const observerCleanup = observeAttributes(dom.getContentEl(scope), {
1092
+ attributes: ["data-activedescendant"],
1093
+ callback: () => exec(false)
1094
+ });
1095
+ cleanups.push(observerCleanup);
1096
+ return () => {
1097
+ cleanups.forEach((cleanup) => cleanup());
1098
+ };
1099
+ }
1100
+ },
1101
+ actions: {
1102
+ setValue(params) {
1103
+ set.value(params, params.event.value);
1104
+ },
1105
+ clearValue(params) {
1106
+ set.value(params, []);
1107
+ },
1108
+ setHighlightedValue(params) {
1109
+ const { event } = params;
1110
+ set.highlightedValue(params, event.value);
1111
+ },
1112
+ clearHighlightedValue(params) {
1113
+ set.highlightedValue(params, []);
1114
+ },
1115
+ reposition({ context, prop, scope, event }) {
1116
+ const positionerEl = () => dom.getPositionerEl(scope);
1117
+ getPlacement(dom.getTriggerEl(scope), positionerEl, {
1118
+ ...prop("positioning"),
1119
+ ...event.options,
1120
+ defer: true,
1121
+ listeners: false,
1122
+ onComplete(data) {
1123
+ context.set("currentPlacement", data.placement);
1124
+ }
1125
+ });
1126
+ },
1127
+ selectItem(params) {
1128
+ const { context, prop, event } = params;
1129
+ const collection = prop("collection");
1130
+ const multiple = prop("multiple");
1131
+ const value = context.get("value");
1132
+ const itemValue = event.value;
1133
+ const indexPath = event.indexPath ?? collection.getIndexPath(itemValue);
1134
+ const node = collection.at(indexPath);
1135
+ const hasChildren = collection.isBranchNode(node);
1136
+ if (prop("allowParentSelection")) {
1137
+ if (multiple) {
1138
+ const filteredValue = value.filter((v) => {
1139
+ const shortPath = v.length < itemValue.length ? v : itemValue;
1140
+ return !(v.length < itemValue.length ? itemValue : v).slice(0, shortPath.length).every((val, i) => val === shortPath[i]) && !isEqual(v, itemValue);
1141
+ });
1142
+ set.value(params, [...filteredValue, itemValue]);
1143
+ } else set.value(params, [itemValue]);
1144
+ if (hasChildren) set.highlightedValue(params, itemValue);
1145
+ } else if (hasChildren) {
1146
+ if (multiple && value.length > 0) set.value(params, [...value.slice(0, -1), itemValue]);
1147
+ else set.value(params, [itemValue]);
1148
+ set.highlightedValue(params, itemValue);
1149
+ } else if (multiple) {
1150
+ const existingIndex = value.findIndex((path) => isEqual(path, itemValue));
1151
+ if (existingIndex >= 0) {
1152
+ const newValues = [...value];
1153
+ newValues.splice(existingIndex, 1);
1154
+ set.value(params, newValues);
1155
+ } else set.value(params, [...value, itemValue]);
1156
+ } else set.value(params, [itemValue]);
1157
+ },
1158
+ clearItem(params) {
1159
+ const { context, event } = params;
1160
+ const newValue = context.get("value").filter((v) => !isEqual(v, event.value));
1161
+ set.value(params, newValue);
1162
+ },
1163
+ selectHighlightedItem({ context, send }) {
1164
+ const indexPath = context.get("highlightedIndexPath");
1165
+ const value = context.get("highlightedValue");
1166
+ if (value) send({
1167
+ type: "ITEM.SELECT",
1168
+ value,
1169
+ indexPath
1170
+ });
1171
+ },
1172
+ highlightFirstItem(params) {
1173
+ const { context, prop } = params;
1174
+ const collection = prop("collection");
1175
+ const highlightedValue = context.get("highlightedValue");
1176
+ let parentNode;
1177
+ if (!highlightedValue.length) parentNode = collection.rootNode;
1178
+ else {
1179
+ const indexPath = context.get("highlightedIndexPath");
1180
+ parentNode = collection.getParentNode(indexPath) ?? collection.rootNode;
1181
+ }
1182
+ const firstChild = collection.getNodeChildren(parentNode).find((child) => !collection.getNodeDisabled(child));
1183
+ if (!firstChild) return;
1184
+ const firstValue = collection.getNodeValue(firstChild);
1185
+ if (!highlightedValue.length) set.highlightedValue(params, [firstValue]);
1186
+ else {
1187
+ const parentPath = highlightedValue.slice(0, -1);
1188
+ set.highlightedValue(params, [...parentPath, firstValue]);
1189
+ }
1190
+ },
1191
+ highlightLastItem(params) {
1192
+ const { context, prop } = params;
1193
+ const collection = prop("collection");
1194
+ const highlightedValue = context.get("highlightedValue");
1195
+ let parentNode;
1196
+ if (!highlightedValue.length) parentNode = collection.rootNode;
1197
+ else {
1198
+ const indexPath = context.get("highlightedIndexPath");
1199
+ parentNode = collection.getParentNode(indexPath) ?? collection.rootNode;
1200
+ }
1201
+ const lastChild = collection.getNodeChildren(parentNode).findLast((child) => !collection.getNodeDisabled(child));
1202
+ if (!lastChild) return;
1203
+ const lastValue = collection.getNodeValue(lastChild);
1204
+ if (!highlightedValue.length) set.highlightedValue(params, [lastValue]);
1205
+ else {
1206
+ const parentPath = highlightedValue.slice(0, -1);
1207
+ set.highlightedValue(params, [...parentPath, lastValue]);
1208
+ }
1209
+ },
1210
+ highlightNextItem(params) {
1211
+ const { context, prop } = params;
1212
+ const collection = prop("collection");
1213
+ const highlightedValue = context.get("highlightedValue");
1214
+ if (!highlightedValue.length) return;
1215
+ const indexPath = context.get("highlightedIndexPath");
1216
+ const nextSibling = collection.getNextSibling(indexPath);
1217
+ if (!nextSibling) return;
1218
+ const nextValue = collection.getNodeValue(nextSibling);
1219
+ if (highlightedValue.length === 1) set.highlightedValue(params, [nextValue]);
1220
+ else {
1221
+ const parentPath = highlightedValue.slice(0, -1);
1222
+ set.highlightedValue(params, [...parentPath, nextValue]);
1223
+ }
1224
+ },
1225
+ highlightPreviousItem(params) {
1226
+ const { context, prop } = params;
1227
+ const collection = prop("collection");
1228
+ const highlightedValue = context.get("highlightedValue");
1229
+ if (!highlightedValue.length) return;
1230
+ const indexPath = context.get("highlightedIndexPath");
1231
+ const previousSibling = collection.getPreviousSibling(indexPath);
1232
+ if (!previousSibling) return;
1233
+ const prevValue = collection.getNodeValue(previousSibling);
1234
+ if (highlightedValue.length === 1) set.highlightedValue(params, [prevValue]);
1235
+ else {
1236
+ const parentPath = highlightedValue.slice(0, -1);
1237
+ set.highlightedValue(params, [...parentPath, prevValue]);
1238
+ }
1239
+ },
1240
+ highlightFirstChild(params) {
1241
+ const { context, prop } = params;
1242
+ const collection = prop("collection");
1243
+ const highlightedValue = context.get("highlightedValue");
1244
+ if (!highlightedValue.length) return;
1245
+ const indexPath = context.get("highlightedIndexPath");
1246
+ const node = collection.getFirstNode(collection.at(indexPath));
1247
+ if (!node) return;
1248
+ const childValue = collection.getNodeValue(node);
1249
+ set.highlightedValue(params, [...highlightedValue, childValue]);
1250
+ },
1251
+ highlightParent(params) {
1252
+ const { context } = params;
1253
+ const highlightedValue = context.get("highlightedValue");
1254
+ if (!highlightedValue.length) return;
1255
+ const parentPath = highlightedValue.slice(0, -1);
1256
+ set.highlightedValue(params, parentPath);
1257
+ },
1258
+ setInitialFocus({ scope }) {
1259
+ raf(() => {
1260
+ dom.getContentEl(scope)?.focus({ preventScroll: true });
1261
+ });
1262
+ },
1263
+ focusTriggerEl({ event, scope }) {
1264
+ if (!restoreFocusFn(event)) return;
1265
+ raf(() => {
1266
+ dom.getTriggerEl(scope)?.focus({ preventScroll: true });
1267
+ });
1268
+ },
1269
+ invokeOnOpen({ prop, context }) {
1270
+ prop("onOpenChange")?.({
1271
+ open: true,
1272
+ value: context.get("value")
1273
+ });
1274
+ },
1275
+ invokeOnClose({ prop, context }) {
1276
+ prop("onOpenChange")?.({
1277
+ open: false,
1278
+ value: context.get("value")
1279
+ });
1280
+ },
1281
+ toggleVisibility({ send, prop }) {
1282
+ if (prop("open") != null) send({ type: prop("open") ? "CONTROLLED.OPEN" : "CONTROLLED.CLOSE" });
1283
+ },
1284
+ highlightFirstSelectedItem(params) {
1285
+ const { context } = params;
1286
+ const value = context.get("value");
1287
+ if (isEmpty(value)) return;
1288
+ const mostRecentSelection = last(value);
1289
+ if (mostRecentSelection) set.highlightedValue(params, mostRecentSelection);
1290
+ },
1291
+ createGraceArea({ context, event, scope }) {
1292
+ const value = event.value.toString();
1293
+ const triggerElement = dom.getItemEl(scope, value);
1294
+ if (!triggerElement) return;
1295
+ const exitPoint = {
1296
+ x: event.clientX,
1297
+ y: event.clientY
1298
+ };
1299
+ const triggerRect = triggerElement.getBoundingClientRect();
1300
+ const nextLevelEl = dom.getListEl(scope, value);
1301
+ if (!nextLevelEl) return;
1302
+ const graceArea = createGraceArea(exitPoint, triggerRect, nextLevelEl.getBoundingClientRect());
1303
+ context.set("graceArea", graceArea);
1304
+ setTimeout(() => {
1305
+ context.set("graceArea", null);
1306
+ }, 300);
1307
+ },
1308
+ clearGraceArea({ context }) {
1309
+ context.set("graceArea", null);
1310
+ },
1311
+ setHighlightingForHoveredItem(params) {
1312
+ const { prop, event } = params;
1313
+ const collection = prop("collection");
1314
+ const node = collection.at(event.indexPath);
1315
+ let newHighlightedValue;
1316
+ if (node && collection.isBranchNode(node)) newHighlightedValue = event.value;
1317
+ else newHighlightedValue = event.value.slice(0, -1);
1318
+ set.highlightedValue(params, newHighlightedValue);
1319
+ },
1320
+ syncInputValue({ context, scope }) {
1321
+ const inputEl = dom.getHiddenInputEl(scope);
1322
+ if (!inputEl) return;
1323
+ setElementValue(inputEl, context.hash("value"));
1324
+ },
1325
+ dispatchChangeEvent({ scope, context }) {
1326
+ dispatchInputValueEvent(dom.getHiddenInputEl(scope), { value: context.hash("value") });
1327
+ },
1328
+ scrollContentToTop({ scope, prop }) {
1329
+ const scrollToIndexFn = prop("scrollToIndexFn");
1330
+ raf(() => {
1331
+ (dom.getContentEl(scope)?.querySelectorAll("[data-part=\"list\"]"))?.forEach((listEl, index) => {
1332
+ if (scrollToIndexFn) scrollToIndexFn({
1333
+ index: 0,
1334
+ immediate: true,
1335
+ depth: index
1336
+ });
1337
+ else listEl.scrollTop = 0;
1338
+ });
1339
+ });
1340
+ }
1341
+ }
1342
+ }
1343
+ });
1344
+ const set = {
1345
+ value({ context, prop }, value) {
1346
+ const collection = prop("collection");
1347
+ context.set("value", value);
1348
+ const valueIndexPath = value.map((v) => collection.getIndexPath(v));
1349
+ context.set("valueIndexPath", valueIndexPath);
1350
+ const selectedItems = valueIndexPath.map((indexPath) => {
1351
+ return indexPath.map((_, index) => {
1352
+ const partialPath = indexPath.slice(0, index + 1);
1353
+ return collection.at(partialPath);
1354
+ });
1355
+ });
1356
+ context.set("selectedItems", selectedItems);
1357
+ prop("onValueChange")?.({
1358
+ value,
1359
+ items: selectedItems
1360
+ });
1361
+ },
1362
+ highlightedValue({ context, prop }, value) {
1363
+ const collection = prop("collection");
1364
+ context.set("highlightedValue", value);
1365
+ const highlightedIndexPath = (value == null ? [] : collection.getIndexPath(value)) ?? [];
1366
+ context.set("highlightedIndexPath", highlightedIndexPath);
1367
+ const highlightedItems = highlightedIndexPath.map((_, index) => {
1368
+ const partialPath = highlightedIndexPath.slice(0, index + 1);
1369
+ return collection.at(partialPath);
1370
+ });
1371
+ context.set("highlightedItems", highlightedItems);
1372
+ prop("onHighlightChange")?.({
1373
+ highlightedValue: value,
1374
+ highlightedItems
1375
+ });
1376
+ }
1377
+ };
1378
+ function restoreFocusFn(event) {
1379
+ const v = event.restoreFocus ?? event.previousEvent?.restoreFocus;
1380
+ return v == null || !!v;
1381
+ }
1382
+ //#endregion
1383
+ //#region src/machines/cascade-select/props.ts
1384
+ const props = createProps()([
1385
+ "allowParentSelection",
1386
+ "closeOnSelect",
1387
+ "collection",
1388
+ "defaultOpen",
1389
+ "defaultValue",
1390
+ "defaultHighlightedValue",
1391
+ "dir",
1392
+ "disabled",
1393
+ "formatValue",
1394
+ "form",
1395
+ "getRootNode",
1396
+ "highlightedValue",
1397
+ "highlightTrigger",
1398
+ "id",
1399
+ "ids",
1400
+ "invalid",
1401
+ "loopFocus",
1402
+ "multiple",
1403
+ "name",
1404
+ "onFocusOutside",
1405
+ "onHighlightChange",
1406
+ "onInteractOutside",
1407
+ "onOpenChange",
1408
+ "onPointerDownOutside",
1409
+ "onValueChange",
1410
+ "open",
1411
+ "positioning",
1412
+ "readOnly",
1413
+ "required",
1414
+ "scrollToIndexFn",
1415
+ "value"
1416
+ ]);
1417
+ const splitProps = createSplitProps(props);
1418
+ //#endregion
1419
+ export { anatomy, collection, connect, machine, parts, props, splitProps };