@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,1279 @@
1
+ import { t as createAnatomy } from "../../create-anatomy-B2q3wiaw.js";
2
+ import { E as isEditableElement, L as ariaAttr, t as getByTypeahead, w as isAnchorElement, z as dataAttr } from "../../dom-query-e7fh0TEH.js";
3
+ import { h as isModifierKey, l as isComposingEvent, m as isLeftClick, r as getEventKey, s as getEventTarget } from "../../event-bTItRgiw.js";
4
+ import { o as setElementValue } from "../../form-B1DW_w_3.js";
5
+ import { i as raf } from "../../raf-Dhvm7f1e.js";
6
+ import { a as diff, b as toArray, f as last, h as partition, n as addOrRemove, o as first, t as add, v as remove, x as uniq } from "../../array-C4KbHsha.js";
7
+ import { t as isEqual } from "../../equal-DtrP8DPh.js";
8
+ import { Y as isArray, n as createSplitProps } from "../../utils-Cht5XaHf.js";
9
+ import { t as ensure } from "../../warning-CrzBpWT1.js";
10
+ import { n as filePathToTree, t as TreeCollection } from "../../collection-CJU0oDtX.js";
11
+ import { n as createGuards, r as createMachine } from "../../core-CJ0MZr3D.js";
12
+ import { t as createProps } from "../../create-props-CgtcN_Qu.js";
13
+ //#region src/machines/tree-view/anatomy.ts
14
+ const anatomy = createAnatomy("tree-view").parts("branch", "branchContent", "branchControl", "branchIndentGuide", "branchIndicator", "branchText", "branchTrigger", "item", "itemIndicator", "itemText", "label", "nodeCheckbox", "nodeRenameInput", "root", "tree");
15
+ const parts = anatomy.build();
16
+ //#endregion
17
+ //#region src/machines/tree-view/collection.ts
18
+ const collection = (options) => {
19
+ return new TreeCollection(options);
20
+ };
21
+ collection.empty = () => {
22
+ return new TreeCollection({ rootNode: { children: [] } });
23
+ };
24
+ function filePathCollection(paths) {
25
+ return filePathToTree(paths);
26
+ }
27
+ //#endregion
28
+ //#region src/machines/tree-view/dom.ts
29
+ const getRootId = (ctx) => ctx.ids?.root ?? `tree-view:${ctx.id}:root`;
30
+ const getLabelId = (ctx) => ctx.ids?.label ?? `tree-view:${ctx.id}:label`;
31
+ const getNodeId = (ctx, value) => ctx.ids?.node?.(value) ?? `tree-view:${ctx.id}:node:${value}`;
32
+ const getTreeId = (ctx) => ctx.ids?.tree ?? `tree-view:${ctx.id}:tree`;
33
+ const getRenameInputId = (ctx, value) => `tree-view:${ctx.id}:rename-input:${value}`;
34
+ const focusNode = (ctx, value) => {
35
+ if (value == null) return;
36
+ ctx.getById(getNodeId(ctx, value))?.focus();
37
+ };
38
+ const getRenameInputEl = (ctx, value) => {
39
+ return ctx.getById(getRenameInputId(ctx, value));
40
+ };
41
+ //#endregion
42
+ //#region src/machines/tree-view/utils/checked-state.ts
43
+ function getCheckedState(collection, node, checkedValue) {
44
+ const value = collection.getNodeValue(node);
45
+ if (!collection.isBranchNode(node)) return checkedValue.includes(value);
46
+ const childValues = collection.getDescendantValues(value);
47
+ const allChecked = childValues.every((v) => checkedValue.includes(v));
48
+ const someChecked = childValues.some((v) => checkedValue.includes(v));
49
+ return allChecked ? true : someChecked ? "indeterminate" : false;
50
+ }
51
+ function toggleBranchChecked(collection, value, checkedValue) {
52
+ const childValues = collection.getDescendantValues(value);
53
+ return uniq(childValues.every((child) => checkedValue.includes(child)) ? remove(checkedValue, ...childValues) : add(checkedValue, ...childValues));
54
+ }
55
+ function getCheckedValueMap(collection, checkedValue) {
56
+ const map = /* @__PURE__ */ new Map();
57
+ collection.visit({ onEnter: (node) => {
58
+ const value = collection.getNodeValue(node);
59
+ const isBranch = collection.isBranchNode(node);
60
+ const checked = getCheckedState(collection, node, checkedValue);
61
+ map.set(value, {
62
+ type: isBranch ? "branch" : "leaf",
63
+ checked
64
+ });
65
+ } });
66
+ return map;
67
+ }
68
+ //#endregion
69
+ //#region src/machines/tree-view/connect.ts
70
+ function connect(service, normalize) {
71
+ const { context, scope, computed, prop, send } = service;
72
+ const collection = prop("collection");
73
+ const translations = prop("translations");
74
+ const expandedValue = Array.from(context.get("expandedValue"));
75
+ const selectedValue = Array.from(context.get("selectedValue"));
76
+ const checkedValue = Array.from(context.get("checkedValue"));
77
+ const isTypingAhead = computed("isTypingAhead");
78
+ const focusedValue = context.get("focusedValue");
79
+ const loadingStatus = context.get("loadingStatus");
80
+ const renamingValue = context.get("renamingValue");
81
+ const skip = ({ indexPath }) => {
82
+ return collection.getValuePath(indexPath).slice(0, -1).some((value) => !expandedValue.includes(value));
83
+ };
84
+ const firstNode = collection.getFirstNode(void 0, { skip });
85
+ const firstNodeValue = firstNode ? collection.getNodeValue(firstNode) : null;
86
+ function getNodeState(props) {
87
+ const { node, indexPath } = props;
88
+ const value = collection.getNodeValue(node);
89
+ return {
90
+ id: getNodeId(scope, value),
91
+ value,
92
+ indexPath,
93
+ valuePath: collection.getValuePath(indexPath),
94
+ disabled: Boolean(node.disabled),
95
+ focused: focusedValue == null ? firstNodeValue === value : focusedValue === value,
96
+ selected: selectedValue.includes(value),
97
+ expanded: expandedValue.includes(value),
98
+ loading: loadingStatus[value] === "loading",
99
+ depth: indexPath.length,
100
+ isBranch: collection.isBranchNode(node),
101
+ renaming: renamingValue === value,
102
+ get checked() {
103
+ return getCheckedState(collection, node, checkedValue);
104
+ }
105
+ };
106
+ }
107
+ return {
108
+ collection,
109
+ expandedValue,
110
+ selectedValue,
111
+ checkedValue,
112
+ toggleChecked(value, isBranch) {
113
+ send({
114
+ type: "CHECKED.TOGGLE",
115
+ value,
116
+ isBranch
117
+ });
118
+ },
119
+ setChecked(value) {
120
+ send({
121
+ type: "CHECKED.SET",
122
+ value
123
+ });
124
+ },
125
+ clearChecked() {
126
+ send({ type: "CHECKED.CLEAR" });
127
+ },
128
+ getCheckedMap() {
129
+ return getCheckedValueMap(collection, checkedValue);
130
+ },
131
+ expand(value) {
132
+ send({
133
+ type: value ? "BRANCH.EXPAND" : "EXPANDED.ALL",
134
+ value
135
+ });
136
+ },
137
+ collapse(value) {
138
+ send({
139
+ type: value ? "BRANCH.COLLAPSE" : "EXPANDED.CLEAR",
140
+ value
141
+ });
142
+ },
143
+ deselect(value) {
144
+ send({
145
+ type: value ? "NODE.DESELECT" : "SELECTED.CLEAR",
146
+ value
147
+ });
148
+ },
149
+ select(value) {
150
+ send({
151
+ type: value ? "NODE.SELECT" : "SELECTED.ALL",
152
+ value,
153
+ isTrusted: false
154
+ });
155
+ },
156
+ getVisibleNodes() {
157
+ return computed("visibleNodes");
158
+ },
159
+ focus(value) {
160
+ focusNode(scope, value);
161
+ },
162
+ selectParent(value) {
163
+ const parentNode = collection.getParentNode(value);
164
+ if (!parentNode) return;
165
+ const _selectedValue = add(selectedValue, collection.getNodeValue(parentNode));
166
+ send({
167
+ type: "SELECTED.SET",
168
+ value: _selectedValue,
169
+ src: "select.parent"
170
+ });
171
+ },
172
+ expandParent(value) {
173
+ const parentNode = collection.getParentNode(value);
174
+ if (!parentNode) return;
175
+ const _expandedValue = add(expandedValue, collection.getNodeValue(parentNode));
176
+ send({
177
+ type: "EXPANDED.SET",
178
+ value: _expandedValue,
179
+ src: "expand.parent"
180
+ });
181
+ },
182
+ setExpandedValue(value) {
183
+ const _expandedValue = uniq(value);
184
+ send({
185
+ type: "EXPANDED.SET",
186
+ value: _expandedValue
187
+ });
188
+ },
189
+ setSelectedValue(value) {
190
+ const _selectedValue = uniq(value);
191
+ send({
192
+ type: "SELECTED.SET",
193
+ value: _selectedValue
194
+ });
195
+ },
196
+ startRenaming(value) {
197
+ send({
198
+ type: "NODE.RENAME",
199
+ value
200
+ });
201
+ },
202
+ submitRenaming(value, label) {
203
+ send({
204
+ type: "RENAME.SUBMIT",
205
+ value,
206
+ label
207
+ });
208
+ },
209
+ cancelRenaming() {
210
+ send({ type: "RENAME.CANCEL" });
211
+ },
212
+ getRootProps() {
213
+ return normalize.element({
214
+ ...parts.root.attrs,
215
+ id: getRootId(scope),
216
+ dir: prop("dir")
217
+ });
218
+ },
219
+ getLabelProps() {
220
+ return normalize.element({
221
+ ...parts.label.attrs,
222
+ id: getLabelId(scope),
223
+ dir: prop("dir")
224
+ });
225
+ },
226
+ getTreeProps() {
227
+ return normalize.element({
228
+ ...parts.tree.attrs,
229
+ id: getTreeId(scope),
230
+ dir: prop("dir"),
231
+ role: "tree",
232
+ "aria-label": translations.treeLabel,
233
+ "aria-labelledby": getLabelId(scope),
234
+ "aria-multiselectable": prop("selectionMode") === "multiple" || void 0,
235
+ tabIndex: -1,
236
+ onKeyDown(event) {
237
+ if (event.defaultPrevented) return;
238
+ if (isComposingEvent(event)) return;
239
+ const target = getEventTarget(event);
240
+ if (isEditableElement(target)) return;
241
+ const node = target?.closest("[data-part=branch-control], [data-part=item]");
242
+ if (!node) return;
243
+ const nodeId = node.dataset.value;
244
+ if (nodeId == null) {
245
+ console.warn(`[wirekyt/tree-view] Node id not found for node`, node);
246
+ return;
247
+ }
248
+ const isBranchNode = node.matches("[data-part=branch-control]");
249
+ const keyMap = {
250
+ ArrowDown(event) {
251
+ if (isModifierKey(event)) return;
252
+ event.preventDefault();
253
+ send({
254
+ type: "NODE.ARROW_DOWN",
255
+ id: nodeId,
256
+ shiftKey: event.shiftKey
257
+ });
258
+ },
259
+ ArrowUp(event) {
260
+ if (isModifierKey(event)) return;
261
+ event.preventDefault();
262
+ send({
263
+ type: "NODE.ARROW_UP",
264
+ id: nodeId,
265
+ shiftKey: event.shiftKey
266
+ });
267
+ },
268
+ ArrowLeft(event) {
269
+ if (isModifierKey(event) || node.dataset.disabled) return;
270
+ event.preventDefault();
271
+ send({
272
+ type: isBranchNode ? "BRANCH_NODE.ARROW_LEFT" : "NODE.ARROW_LEFT",
273
+ id: nodeId
274
+ });
275
+ },
276
+ ArrowRight(event) {
277
+ if (!isBranchNode || node.dataset.disabled) return;
278
+ event.preventDefault();
279
+ send({
280
+ type: "BRANCH_NODE.ARROW_RIGHT",
281
+ id: nodeId
282
+ });
283
+ },
284
+ Home(event) {
285
+ if (isModifierKey(event)) return;
286
+ event.preventDefault();
287
+ send({
288
+ type: "NODE.HOME",
289
+ id: nodeId,
290
+ shiftKey: event.shiftKey
291
+ });
292
+ },
293
+ End(event) {
294
+ if (isModifierKey(event)) return;
295
+ event.preventDefault();
296
+ send({
297
+ type: "NODE.END",
298
+ id: nodeId,
299
+ shiftKey: event.shiftKey
300
+ });
301
+ },
302
+ Space(event) {
303
+ if (node.dataset.disabled) return;
304
+ if (isTypingAhead) send({
305
+ type: "TREE.TYPEAHEAD",
306
+ key: event.key
307
+ });
308
+ else keyMap.Enter?.(event);
309
+ },
310
+ Enter(event) {
311
+ if (node.dataset.disabled) return;
312
+ if (isAnchorElement(target) && isModifierKey(event)) return;
313
+ send({
314
+ type: isBranchNode ? "BRANCH_NODE.CLICK" : "NODE.CLICK",
315
+ id: nodeId,
316
+ src: "keyboard"
317
+ });
318
+ if (!isAnchorElement(target)) event.preventDefault();
319
+ },
320
+ "*"(event) {
321
+ if (node.dataset.disabled) return;
322
+ event.preventDefault();
323
+ send({
324
+ type: "SIBLINGS.EXPAND",
325
+ id: nodeId
326
+ });
327
+ },
328
+ a(event) {
329
+ if (!event.metaKey || node.dataset.disabled) return;
330
+ event.preventDefault();
331
+ send({
332
+ type: "SELECTED.ALL",
333
+ moveFocus: true
334
+ });
335
+ },
336
+ F2(event) {
337
+ if (node.dataset.disabled) return;
338
+ const canRenameFn = prop("canRename");
339
+ if (!canRenameFn) return;
340
+ const indexPath = collection.getIndexPath(nodeId);
341
+ if (indexPath) {
342
+ const node = collection.at(indexPath);
343
+ if (node && !canRenameFn(node, indexPath)) return;
344
+ }
345
+ event.preventDefault();
346
+ send({
347
+ type: "NODE.RENAME",
348
+ value: nodeId
349
+ });
350
+ }
351
+ };
352
+ const exec = keyMap[getEventKey(event, { dir: prop("dir") })];
353
+ if (exec) {
354
+ exec(event);
355
+ return;
356
+ }
357
+ if (!getByTypeahead.isValidEvent(event)) return;
358
+ send({
359
+ type: "TREE.TYPEAHEAD",
360
+ key: event.key,
361
+ id: nodeId
362
+ });
363
+ event.preventDefault();
364
+ }
365
+ });
366
+ },
367
+ getNodeState,
368
+ getItemProps(props) {
369
+ const nodeState = getNodeState(props);
370
+ return normalize.element({
371
+ ...parts.item.attrs,
372
+ id: nodeState.id,
373
+ dir: prop("dir"),
374
+ "data-ownedby": getTreeId(scope),
375
+ "data-path": props.indexPath.join("/"),
376
+ "data-value": nodeState.value,
377
+ tabIndex: nodeState.focused ? 0 : -1,
378
+ "data-focus": dataAttr(nodeState.focused),
379
+ role: "treeitem",
380
+ "aria-current": nodeState.selected ? "true" : void 0,
381
+ "aria-selected": nodeState.disabled ? void 0 : nodeState.selected,
382
+ "data-selected": dataAttr(nodeState.selected),
383
+ "aria-disabled": ariaAttr(nodeState.disabled),
384
+ "data-disabled": dataAttr(nodeState.disabled),
385
+ "data-renaming": dataAttr(nodeState.renaming),
386
+ "data-checked": dataAttr(nodeState.checked === true),
387
+ "data-indeterminate": dataAttr(nodeState.checked === "indeterminate"),
388
+ "aria-level": nodeState.depth,
389
+ "data-depth": nodeState.depth,
390
+ style: { "--depth": nodeState.depth },
391
+ onFocus(event) {
392
+ event.stopPropagation();
393
+ send({
394
+ type: "NODE.FOCUS",
395
+ id: nodeState.value
396
+ });
397
+ },
398
+ onClick(event) {
399
+ if (nodeState.disabled) return;
400
+ if (!isLeftClick(event)) return;
401
+ if (isAnchorElement(event.currentTarget) && isModifierKey(event)) return;
402
+ const isMetaKey = event.metaKey || event.ctrlKey;
403
+ send({
404
+ type: "NODE.CLICK",
405
+ id: nodeState.value,
406
+ shiftKey: event.shiftKey,
407
+ ctrlKey: isMetaKey
408
+ });
409
+ event.stopPropagation();
410
+ if (!isAnchorElement(event.currentTarget)) event.preventDefault();
411
+ }
412
+ });
413
+ },
414
+ getItemTextProps(props) {
415
+ const itemState = getNodeState(props);
416
+ return normalize.element({
417
+ ...parts.itemText.attrs,
418
+ "data-disabled": dataAttr(itemState.disabled),
419
+ "data-selected": dataAttr(itemState.selected),
420
+ "data-focus": dataAttr(itemState.focused)
421
+ });
422
+ },
423
+ getItemIndicatorProps(props) {
424
+ const itemState = getNodeState(props);
425
+ return normalize.element({
426
+ ...parts.itemIndicator.attrs,
427
+ "aria-hidden": true,
428
+ "data-disabled": dataAttr(itemState.disabled),
429
+ "data-selected": dataAttr(itemState.selected),
430
+ "data-focus": dataAttr(itemState.focused),
431
+ hidden: !itemState.selected
432
+ });
433
+ },
434
+ getBranchProps(props) {
435
+ const nodeState = getNodeState(props);
436
+ return normalize.element({
437
+ ...parts.branch.attrs,
438
+ "data-depth": nodeState.depth,
439
+ dir: prop("dir"),
440
+ "data-branch": nodeState.value,
441
+ role: "treeitem",
442
+ "data-ownedby": getTreeId(scope),
443
+ "data-value": nodeState.value,
444
+ "aria-level": nodeState.depth,
445
+ "aria-selected": nodeState.disabled ? void 0 : nodeState.selected,
446
+ "data-path": props.indexPath.join("/"),
447
+ "data-selected": dataAttr(nodeState.selected),
448
+ "aria-expanded": nodeState.expanded,
449
+ "data-state": nodeState.expanded ? "open" : "closed",
450
+ "aria-disabled": ariaAttr(nodeState.disabled),
451
+ "data-disabled": dataAttr(nodeState.disabled),
452
+ "data-loading": dataAttr(nodeState.loading),
453
+ "aria-busy": ariaAttr(nodeState.loading),
454
+ style: { "--depth": nodeState.depth }
455
+ });
456
+ },
457
+ getBranchIndicatorProps(props) {
458
+ const nodeState = getNodeState(props);
459
+ return normalize.element({
460
+ ...parts.branchIndicator.attrs,
461
+ "aria-hidden": true,
462
+ "data-state": nodeState.expanded ? "open" : "closed",
463
+ "data-disabled": dataAttr(nodeState.disabled),
464
+ "data-selected": dataAttr(nodeState.selected),
465
+ "data-focus": dataAttr(nodeState.focused),
466
+ "data-loading": dataAttr(nodeState.loading)
467
+ });
468
+ },
469
+ getBranchTriggerProps(props) {
470
+ const nodeState = getNodeState(props);
471
+ return normalize.element({
472
+ ...parts.branchTrigger.attrs,
473
+ role: "button",
474
+ dir: prop("dir"),
475
+ "data-disabled": dataAttr(nodeState.disabled),
476
+ "data-state": nodeState.expanded ? "open" : "closed",
477
+ "data-value": nodeState.value,
478
+ "data-loading": dataAttr(nodeState.loading),
479
+ disabled: nodeState.loading,
480
+ onClick(event) {
481
+ if (nodeState.disabled || nodeState.loading) return;
482
+ send({
483
+ type: "BRANCH_TOGGLE.CLICK",
484
+ id: nodeState.value
485
+ });
486
+ event.stopPropagation();
487
+ }
488
+ });
489
+ },
490
+ getBranchControlProps(props) {
491
+ const nodeState = getNodeState(props);
492
+ return normalize.element({
493
+ ...parts.branchControl.attrs,
494
+ role: "button",
495
+ id: nodeState.id,
496
+ dir: prop("dir"),
497
+ tabIndex: nodeState.focused ? 0 : -1,
498
+ "data-path": props.indexPath.join("/"),
499
+ "data-state": nodeState.expanded ? "open" : "closed",
500
+ "data-disabled": dataAttr(nodeState.disabled),
501
+ "data-selected": dataAttr(nodeState.selected),
502
+ "data-focus": dataAttr(nodeState.focused),
503
+ "data-renaming": dataAttr(nodeState.renaming),
504
+ "data-checked": dataAttr(nodeState.checked === true),
505
+ "data-indeterminate": dataAttr(nodeState.checked === "indeterminate"),
506
+ "data-value": nodeState.value,
507
+ "data-depth": nodeState.depth,
508
+ "data-loading": dataAttr(nodeState.loading),
509
+ "aria-busy": ariaAttr(nodeState.loading),
510
+ onFocus(event) {
511
+ send({
512
+ type: "NODE.FOCUS",
513
+ id: nodeState.value
514
+ });
515
+ event.stopPropagation();
516
+ },
517
+ onClick(event) {
518
+ if (nodeState.disabled) return;
519
+ if (nodeState.loading) return;
520
+ if (!isLeftClick(event)) return;
521
+ if (isAnchorElement(event.currentTarget) && isModifierKey(event)) return;
522
+ const isMetaKey = event.metaKey || event.ctrlKey;
523
+ send({
524
+ type: "BRANCH_NODE.CLICK",
525
+ id: nodeState.value,
526
+ shiftKey: event.shiftKey,
527
+ ctrlKey: isMetaKey
528
+ });
529
+ event.stopPropagation();
530
+ }
531
+ });
532
+ },
533
+ getBranchTextProps(props) {
534
+ const nodeState = getNodeState(props);
535
+ return normalize.element({
536
+ ...parts.branchText.attrs,
537
+ dir: prop("dir"),
538
+ "data-disabled": dataAttr(nodeState.disabled),
539
+ "data-state": nodeState.expanded ? "open" : "closed",
540
+ "data-loading": dataAttr(nodeState.loading)
541
+ });
542
+ },
543
+ getBranchContentProps(props) {
544
+ const nodeState = getNodeState(props);
545
+ return normalize.element({
546
+ ...parts.branchContent.attrs,
547
+ role: "group",
548
+ dir: prop("dir"),
549
+ "data-state": nodeState.expanded ? "open" : "closed",
550
+ "data-depth": nodeState.depth,
551
+ "data-path": props.indexPath.join("/"),
552
+ "data-value": nodeState.value,
553
+ hidden: !nodeState.expanded
554
+ });
555
+ },
556
+ getBranchIndentGuideProps(props) {
557
+ const nodeState = getNodeState(props);
558
+ return normalize.element({
559
+ ...parts.branchIndentGuide.attrs,
560
+ "data-depth": nodeState.depth
561
+ });
562
+ },
563
+ getNodeCheckboxProps(props) {
564
+ const nodeState = getNodeState(props);
565
+ const checkedState = nodeState.checked;
566
+ return normalize.element({
567
+ ...parts.nodeCheckbox.attrs,
568
+ tabIndex: -1,
569
+ role: "checkbox",
570
+ "data-state": checkedState === true ? "checked" : checkedState === false ? "unchecked" : "indeterminate",
571
+ "aria-checked": checkedState === true ? "true" : checkedState === false ? "false" : "mixed",
572
+ "data-disabled": dataAttr(nodeState.disabled),
573
+ onClick(event) {
574
+ if (event.defaultPrevented) return;
575
+ if (nodeState.disabled) return;
576
+ if (!isLeftClick(event)) return;
577
+ send({
578
+ type: "CHECKED.TOGGLE",
579
+ value: nodeState.value,
580
+ isBranch: nodeState.isBranch
581
+ });
582
+ event.stopPropagation();
583
+ event.currentTarget.closest("[role=treeitem]")?.focus({ preventScroll: true });
584
+ }
585
+ });
586
+ },
587
+ getNodeRenameInputProps(props) {
588
+ const nodeState = getNodeState(props);
589
+ return normalize.input({
590
+ ...parts.nodeRenameInput.attrs,
591
+ id: getRenameInputId(scope, nodeState.value),
592
+ type: "text",
593
+ "aria-label": translations.renameInputLabel,
594
+ hidden: !nodeState.renaming,
595
+ onKeyDown(event) {
596
+ if (isComposingEvent(event)) return;
597
+ if (event.key === "Escape") {
598
+ send({ type: "RENAME.CANCEL" });
599
+ event.preventDefault();
600
+ }
601
+ if (event.key === "Enter") {
602
+ send({
603
+ type: "RENAME.SUBMIT",
604
+ label: event.currentTarget.value
605
+ });
606
+ event.preventDefault();
607
+ }
608
+ event.stopPropagation();
609
+ },
610
+ onBlur(event) {
611
+ send({
612
+ type: "RENAME.SUBMIT",
613
+ label: event.currentTarget.value
614
+ });
615
+ }
616
+ });
617
+ }
618
+ };
619
+ }
620
+ //#endregion
621
+ //#region src/machines/tree-view/utils/expand-branch.ts
622
+ function expandBranches(params, values) {
623
+ const { context, prop, refs } = params;
624
+ if (!prop("loadChildren")) {
625
+ context.set("expandedValue", (prev) => uniq(add(prev, ...values)));
626
+ return;
627
+ }
628
+ const loadingStatus = context.get("loadingStatus");
629
+ const [loadedValues, loadingValues] = partition(values, (value) => loadingStatus[value] === "loaded");
630
+ if (loadedValues.length > 0) context.set("expandedValue", (prev) => uniq(add(prev, ...loadedValues)));
631
+ if (loadingValues.length === 0) return;
632
+ const collection = prop("collection");
633
+ const [nodeWithChildren, nodeWithoutChildren] = partition(loadingValues, (id) => {
634
+ const node = collection.findNode(id);
635
+ return collection.getNodeChildren(node).length > 0;
636
+ });
637
+ if (nodeWithChildren.length > 0) context.set("expandedValue", (prev) => uniq(add(prev, ...nodeWithChildren)));
638
+ if (nodeWithoutChildren.length === 0) return;
639
+ context.set("loadingStatus", (prev) => ({
640
+ ...prev,
641
+ ...nodeWithoutChildren.reduce((acc, id) => ({
642
+ ...acc,
643
+ [id]: "loading"
644
+ }), {})
645
+ }));
646
+ const nodesToLoad = nodeWithoutChildren.map((id) => {
647
+ const indexPath = collection.getIndexPath(id);
648
+ return {
649
+ id,
650
+ indexPath,
651
+ valuePath: collection.getValuePath(indexPath),
652
+ node: collection.findNode(id)
653
+ };
654
+ });
655
+ const pendingAborts = refs.get("pendingAborts");
656
+ const loadChildren = prop("loadChildren");
657
+ ensure(loadChildren, () => "[wirekyt/tree-view] `loadChildren` is required for async expansion");
658
+ const proms = nodesToLoad.map(({ id, indexPath, valuePath, node }) => {
659
+ const existingAbort = pendingAborts.get(id);
660
+ if (existingAbort) {
661
+ existingAbort.abort();
662
+ pendingAborts.delete(id);
663
+ }
664
+ const abortController = new AbortController();
665
+ pendingAborts.set(id, abortController);
666
+ return loadChildren({
667
+ valuePath,
668
+ indexPath,
669
+ node,
670
+ signal: abortController.signal
671
+ });
672
+ });
673
+ Promise.allSettled(proms).then((results) => {
674
+ const loadedValues = [];
675
+ const nodeWithErrors = [];
676
+ const nextLoadingStatus = context.get("loadingStatus");
677
+ let collection = prop("collection");
678
+ results.forEach((result, index) => {
679
+ const { id, indexPath, node, valuePath } = nodesToLoad[index];
680
+ if (result.status === "fulfilled") {
681
+ nextLoadingStatus[id] = "loaded";
682
+ loadedValues.push(id);
683
+ collection = collection.replace(indexPath, {
684
+ ...node,
685
+ children: result.value
686
+ });
687
+ } else {
688
+ pendingAborts.delete(id);
689
+ Reflect.deleteProperty(nextLoadingStatus, id);
690
+ nodeWithErrors.push({
691
+ node,
692
+ error: result.reason,
693
+ indexPath,
694
+ valuePath
695
+ });
696
+ }
697
+ });
698
+ context.set("loadingStatus", nextLoadingStatus);
699
+ if (loadedValues.length) {
700
+ context.set("expandedValue", (prev) => uniq(add(prev, ...loadedValues)));
701
+ prop("onLoadChildrenComplete")?.({ collection });
702
+ }
703
+ if (nodeWithErrors.length) prop("onLoadChildrenError")?.({ nodes: nodeWithErrors });
704
+ });
705
+ }
706
+ //#endregion
707
+ //#region src/machines/tree-view/utils/visit-skip.ts
708
+ function skipFn(params) {
709
+ const { prop, context } = params;
710
+ return function skip({ indexPath }) {
711
+ return prop("collection").getValuePath(indexPath).slice(0, -1).some((value) => !context.get("expandedValue").includes(value));
712
+ };
713
+ }
714
+ //#endregion
715
+ //#region src/machines/tree-view/machine.ts
716
+ const { and } = createGuards();
717
+ const machine = createMachine({
718
+ props({ props }) {
719
+ return {
720
+ selectionMode: "single",
721
+ collection: collection.empty(),
722
+ typeahead: true,
723
+ expandOnClick: true,
724
+ defaultExpandedValue: [],
725
+ defaultSelectedValue: [],
726
+ ...props,
727
+ translations: {
728
+ treeLabel: "Tree View",
729
+ renameInputLabel: "Rename tree item",
730
+ ...props.translations
731
+ }
732
+ };
733
+ },
734
+ initialState() {
735
+ return "idle";
736
+ },
737
+ context({ prop, bindable, getContext }) {
738
+ return {
739
+ expandedValue: bindable(() => ({
740
+ defaultValue: prop("defaultExpandedValue"),
741
+ value: prop("expandedValue"),
742
+ isEqual,
743
+ onChange(expandedValue) {
744
+ const focusedValue = getContext().get("focusedValue");
745
+ prop("onExpandedChange")?.({
746
+ expandedValue,
747
+ focusedValue,
748
+ get expandedNodes() {
749
+ return prop("collection").findNodes(expandedValue);
750
+ }
751
+ });
752
+ }
753
+ })),
754
+ selectedValue: bindable(() => ({
755
+ defaultValue: prop("defaultSelectedValue"),
756
+ value: prop("selectedValue"),
757
+ isEqual,
758
+ onChange(selectedValue) {
759
+ const focusedValue = getContext().get("focusedValue");
760
+ prop("onSelectionChange")?.({
761
+ selectedValue,
762
+ focusedValue,
763
+ get selectedNodes() {
764
+ return prop("collection").findNodes(selectedValue);
765
+ }
766
+ });
767
+ }
768
+ })),
769
+ focusedValue: bindable(() => ({
770
+ defaultValue: prop("defaultFocusedValue") || null,
771
+ value: prop("focusedValue"),
772
+ onChange(focusedValue) {
773
+ prop("onFocusChange")?.({
774
+ focusedValue,
775
+ get focusedNode() {
776
+ return focusedValue ? prop("collection").findNode(focusedValue) : null;
777
+ }
778
+ });
779
+ }
780
+ })),
781
+ loadingStatus: bindable(() => ({ defaultValue: {} })),
782
+ checkedValue: bindable(() => ({
783
+ defaultValue: prop("defaultCheckedValue") || [],
784
+ value: prop("checkedValue"),
785
+ isEqual,
786
+ onChange(value) {
787
+ prop("onCheckedChange")?.({ checkedValue: value });
788
+ }
789
+ })),
790
+ renamingValue: bindable(() => ({
791
+ sync: true,
792
+ defaultValue: null
793
+ }))
794
+ };
795
+ },
796
+ refs() {
797
+ return {
798
+ typeaheadState: { ...getByTypeahead.defaultOptions },
799
+ pendingAborts: /* @__PURE__ */ new Map()
800
+ };
801
+ },
802
+ computed: {
803
+ isMultipleSelection: ({ prop }) => prop("selectionMode") === "multiple",
804
+ isTypingAhead: ({ refs }) => refs.get("typeaheadState").keysSoFar.length > 0,
805
+ visibleNodes: ({ prop, context }) => {
806
+ const nodes = [];
807
+ prop("collection").visit({
808
+ skip: skipFn({
809
+ prop,
810
+ context
811
+ }),
812
+ onEnter: (node, indexPath) => {
813
+ nodes.push({
814
+ node,
815
+ indexPath
816
+ });
817
+ }
818
+ });
819
+ return nodes;
820
+ }
821
+ },
822
+ on: {
823
+ "EXPANDED.SET": { actions: ["setExpanded"] },
824
+ "EXPANDED.CLEAR": { actions: ["clearExpanded"] },
825
+ "EXPANDED.ALL": { actions: ["expandAllBranches"] },
826
+ "BRANCH.EXPAND": { actions: ["expandBranches"] },
827
+ "BRANCH.COLLAPSE": { actions: ["collapseBranches"] },
828
+ "SELECTED.SET": { actions: ["setSelected"] },
829
+ "SELECTED.ALL": [{
830
+ guard: and("isMultipleSelection", "moveFocus"),
831
+ actions: ["selectAllNodes", "focusTreeLastNode"]
832
+ }, {
833
+ guard: "isMultipleSelection",
834
+ actions: ["selectAllNodes"]
835
+ }],
836
+ "SELECTED.CLEAR": { actions: ["clearSelected"] },
837
+ "NODE.SELECT": { actions: ["selectNode"] },
838
+ "NODE.DESELECT": { actions: ["deselectNode"] },
839
+ "CHECKED.TOGGLE": { actions: ["toggleChecked"] },
840
+ "CHECKED.SET": { actions: ["setChecked"] },
841
+ "CHECKED.CLEAR": { actions: ["clearChecked"] },
842
+ "NODE.FOCUS": { actions: ["setFocusedNode"] },
843
+ "NODE.ARROW_DOWN": [{
844
+ guard: and("isShiftKey", "isMultipleSelection"),
845
+ actions: ["focusTreeNextNode", "extendSelectionToNextNode"]
846
+ }, { actions: ["focusTreeNextNode"] }],
847
+ "NODE.ARROW_UP": [{
848
+ guard: and("isShiftKey", "isMultipleSelection"),
849
+ actions: ["focusTreePrevNode", "extendSelectionToPrevNode"]
850
+ }, { actions: ["focusTreePrevNode"] }],
851
+ "NODE.ARROW_LEFT": { actions: ["focusBranchNode"] },
852
+ "BRANCH_NODE.ARROW_LEFT": [{
853
+ guard: "isBranchExpanded",
854
+ actions: ["collapseBranch"]
855
+ }, { actions: ["focusBranchNode"] }],
856
+ "BRANCH_NODE.ARROW_RIGHT": [{
857
+ guard: and("isBranchFocused", "isBranchExpanded"),
858
+ actions: ["focusBranchFirstNode"]
859
+ }, { actions: ["expandBranch"] }],
860
+ "SIBLINGS.EXPAND": { actions: ["expandSiblingBranches"] },
861
+ "NODE.HOME": [{
862
+ guard: and("isShiftKey", "isMultipleSelection"),
863
+ actions: ["extendSelectionToFirstNode", "focusTreeFirstNode"]
864
+ }, { actions: ["focusTreeFirstNode"] }],
865
+ "NODE.END": [{
866
+ guard: and("isShiftKey", "isMultipleSelection"),
867
+ actions: ["extendSelectionToLastNode", "focusTreeLastNode"]
868
+ }, { actions: ["focusTreeLastNode"] }],
869
+ "NODE.CLICK": [
870
+ {
871
+ guard: and("isCtrlKey", "isMultipleSelection"),
872
+ actions: ["toggleNodeSelection"]
873
+ },
874
+ {
875
+ guard: and("isShiftKey", "isMultipleSelection"),
876
+ actions: ["extendSelectionToNode"]
877
+ },
878
+ { actions: ["selectNode"] }
879
+ ],
880
+ "BRANCH_NODE.CLICK": [
881
+ {
882
+ guard: and("isCtrlKey", "isMultipleSelection"),
883
+ actions: ["toggleNodeSelection"]
884
+ },
885
+ {
886
+ guard: and("isShiftKey", "isMultipleSelection"),
887
+ actions: ["extendSelectionToNode"]
888
+ },
889
+ {
890
+ guard: "expandOnClick",
891
+ actions: ["selectNode", "toggleBranchNode"]
892
+ },
893
+ { actions: ["selectNode"] }
894
+ ],
895
+ "BRANCH_TOGGLE.CLICK": { actions: ["toggleBranchNode"] },
896
+ "TREE.TYPEAHEAD": { actions: ["focusMatchedNode"] }
897
+ },
898
+ exit: ["clearPendingAborts"],
899
+ states: {
900
+ idle: { on: { "NODE.RENAME": {
901
+ target: "renaming",
902
+ actions: ["setRenamingValue"]
903
+ } } },
904
+ renaming: {
905
+ entry: ["syncRenameInput", "focusRenameInput"],
906
+ on: {
907
+ "RENAME.SUBMIT": {
908
+ guard: "isRenameLabelValid",
909
+ target: "idle",
910
+ actions: ["submitRenaming"]
911
+ },
912
+ "RENAME.CANCEL": {
913
+ target: "idle",
914
+ actions: ["cancelRenaming"]
915
+ }
916
+ }
917
+ }
918
+ },
919
+ implementations: {
920
+ guards: {
921
+ isBranchFocused: ({ context, event }) => context.get("focusedValue") === event.id,
922
+ isBranchExpanded: ({ context, event }) => context.get("expandedValue").includes(event.id),
923
+ isShiftKey: ({ event }) => event.shiftKey,
924
+ isCtrlKey: ({ event }) => event.ctrlKey,
925
+ hasSelectedItems: ({ context }) => context.get("selectedValue").length > 0,
926
+ isMultipleSelection: ({ prop }) => prop("selectionMode") === "multiple",
927
+ moveFocus: ({ event }) => !!event.moveFocus,
928
+ expandOnClick: ({ prop }) => !!prop("expandOnClick"),
929
+ isRenameLabelValid: ({ event }) => event.label.trim() !== ""
930
+ },
931
+ actions: {
932
+ selectNode({ context, event }) {
933
+ const value = event.id || event.value;
934
+ context.set("selectedValue", (prev) => {
935
+ if (value == null) return prev;
936
+ if (!event.isTrusted && isArray(value)) return prev.concat(...value);
937
+ return [isArray(value) ? last(value) : value].filter(Boolean);
938
+ });
939
+ },
940
+ deselectNode({ context, event }) {
941
+ const value = toArray(event.id || event.value);
942
+ context.set("selectedValue", (prev) => remove(prev, ...value));
943
+ },
944
+ setFocusedNode({ context, event }) {
945
+ context.set("focusedValue", event.id);
946
+ },
947
+ clearFocusedNode({ context }) {
948
+ context.set("focusedValue", null);
949
+ },
950
+ clearSelectedItem({ context }) {
951
+ context.set("selectedValue", []);
952
+ },
953
+ toggleBranchNode({ context, event, action }) {
954
+ action(context.get("expandedValue").includes(event.id) ? ["collapseBranch"] : ["expandBranch"]);
955
+ },
956
+ expandBranch(params) {
957
+ const { event } = params;
958
+ expandBranches(params, [event.id]);
959
+ },
960
+ expandBranches(params) {
961
+ const { context, event } = params;
962
+ expandBranches(params, diff(toArray(event.value), context.get("expandedValue")));
963
+ },
964
+ collapseBranch({ context, event }) {
965
+ context.set("expandedValue", (prev) => remove(prev, event.id));
966
+ },
967
+ collapseBranches(params) {
968
+ const { context, event } = params;
969
+ const value = toArray(event.value);
970
+ context.set("expandedValue", (prev) => remove(prev, ...value));
971
+ },
972
+ setExpanded({ context, event }) {
973
+ if (!isArray(event.value)) return;
974
+ context.set("expandedValue", event.value);
975
+ },
976
+ clearExpanded({ context }) {
977
+ context.set("expandedValue", []);
978
+ },
979
+ setSelected({ context, event }) {
980
+ if (!isArray(event.value)) return;
981
+ context.set("selectedValue", event.value);
982
+ },
983
+ clearSelected({ context }) {
984
+ context.set("selectedValue", []);
985
+ },
986
+ focusTreeFirstNode(params) {
987
+ const { prop, scope } = params;
988
+ const collection = prop("collection");
989
+ const firstNode = collection.getFirstNode(void 0, { skip: skipFn(params) });
990
+ if (!firstNode) return;
991
+ const firstValue = collection.getNodeValue(firstNode);
992
+ if (scrollToNode(params, firstValue)) raf(() => focusNode(scope, firstValue));
993
+ else focusNode(scope, firstValue);
994
+ },
995
+ focusTreeLastNode(params) {
996
+ const { prop, scope } = params;
997
+ const collection = prop("collection");
998
+ const lastNode = collection.getLastNode(void 0, { skip: skipFn(params) });
999
+ const lastValue = collection.getNodeValue(lastNode);
1000
+ if (scrollToNode(params, lastValue)) raf(() => focusNode(scope, lastValue));
1001
+ else focusNode(scope, lastValue);
1002
+ },
1003
+ focusBranchFirstNode(params) {
1004
+ const { event, prop, scope } = params;
1005
+ const collection = prop("collection");
1006
+ const branchNode = collection.findNode(event.id);
1007
+ const firstNode = collection.getFirstNode(branchNode, { skip: skipFn(params) });
1008
+ if (!firstNode) return;
1009
+ const firstValue = collection.getNodeValue(firstNode);
1010
+ if (scrollToNode(params, firstValue)) raf(() => focusNode(scope, firstValue));
1011
+ else focusNode(scope, firstValue);
1012
+ },
1013
+ focusTreeNextNode(params) {
1014
+ const { event, prop, scope } = params;
1015
+ const collection = prop("collection");
1016
+ const nextNode = collection.getNextNode(event.id, { skip: skipFn(params) });
1017
+ if (!nextNode) return;
1018
+ const nextValue = collection.getNodeValue(nextNode);
1019
+ if (scrollToNode(params, nextValue)) raf(() => focusNode(scope, nextValue));
1020
+ else focusNode(scope, nextValue);
1021
+ },
1022
+ focusTreePrevNode(params) {
1023
+ const { event, prop, scope } = params;
1024
+ const collection = prop("collection");
1025
+ const prevNode = collection.getPreviousNode(event.id, { skip: skipFn(params) });
1026
+ if (!prevNode) return;
1027
+ const prevValue = collection.getNodeValue(prevNode);
1028
+ if (scrollToNode(params, prevValue)) raf(() => focusNode(scope, prevValue));
1029
+ else focusNode(scope, prevValue);
1030
+ },
1031
+ focusBranchNode(params) {
1032
+ const { event, prop, scope } = params;
1033
+ const collection = prop("collection");
1034
+ const parentNode = collection.getParentNode(event.id);
1035
+ const parentValue = parentNode ? collection.getNodeValue(parentNode) : void 0;
1036
+ if (!parentValue) return;
1037
+ if (scrollToNode(params, parentValue)) raf(() => focusNode(scope, parentValue));
1038
+ else focusNode(scope, parentValue);
1039
+ },
1040
+ selectAllNodes({ context, prop }) {
1041
+ context.set("selectedValue", prop("collection").getValues());
1042
+ },
1043
+ focusMatchedNode(params) {
1044
+ const { context, prop, refs, event, scope, computed } = params;
1045
+ const node = getByTypeahead(computed("visibleNodes").map(({ node }) => ({
1046
+ textContent: prop("collection").stringifyNode(node),
1047
+ id: prop("collection").getNodeValue(node)
1048
+ })), {
1049
+ state: refs.get("typeaheadState"),
1050
+ activeId: context.get("focusedValue"),
1051
+ key: event.key
1052
+ });
1053
+ if (!node?.id) return;
1054
+ if (scrollToNode(params, node.id)) raf(() => focusNode(scope, node.id));
1055
+ else focusNode(scope, node.id);
1056
+ },
1057
+ toggleNodeSelection({ context, event }) {
1058
+ const selectedValue = addOrRemove(context.get("selectedValue"), event.id);
1059
+ context.set("selectedValue", selectedValue);
1060
+ },
1061
+ expandAllBranches(params) {
1062
+ const { context, prop } = params;
1063
+ expandBranches(params, diff(prop("collection").getBranchValues(), context.get("expandedValue")));
1064
+ },
1065
+ expandSiblingBranches(params) {
1066
+ const { context, event, prop } = params;
1067
+ const collection = prop("collection");
1068
+ const indexPath = collection.getIndexPath(event.id);
1069
+ if (!indexPath) return;
1070
+ expandBranches(params, diff(collection.getSiblingNodes(indexPath).map((node) => collection.getNodeValue(node)), context.get("expandedValue")));
1071
+ },
1072
+ extendSelectionToNode(params) {
1073
+ const { context, event, prop, computed } = params;
1074
+ const collection = prop("collection");
1075
+ const anchorValue = first(context.get("selectedValue")) || collection.getNodeValue(collection.getFirstNode());
1076
+ const targetValue = event.id;
1077
+ let values = [anchorValue, targetValue];
1078
+ let hits = 0;
1079
+ computed("visibleNodes").forEach(({ node }) => {
1080
+ const nodeValue = collection.getNodeValue(node);
1081
+ if (hits === 1) values.push(nodeValue);
1082
+ if (nodeValue === anchorValue || nodeValue === targetValue) hits++;
1083
+ });
1084
+ context.set("selectedValue", uniq(values));
1085
+ },
1086
+ extendSelectionToNextNode(params) {
1087
+ const { context, event, prop } = params;
1088
+ const collection = prop("collection");
1089
+ const nextNode = collection.getNextNode(event.id, { skip: skipFn(params) });
1090
+ if (!nextNode) return;
1091
+ const values = new Set(context.get("selectedValue"));
1092
+ const nextValue = collection.getNodeValue(nextNode);
1093
+ if (nextValue == null) return;
1094
+ if (values.has(event.id) && values.has(nextValue)) values.delete(event.id);
1095
+ else if (!values.has(nextValue)) values.add(nextValue);
1096
+ context.set("selectedValue", Array.from(values));
1097
+ },
1098
+ extendSelectionToPrevNode(params) {
1099
+ const { context, event, prop } = params;
1100
+ const collection = prop("collection");
1101
+ const prevNode = collection.getPreviousNode(event.id, { skip: skipFn(params) });
1102
+ if (!prevNode) return;
1103
+ const values = new Set(context.get("selectedValue"));
1104
+ const prevValue = collection.getNodeValue(prevNode);
1105
+ if (prevValue == null) return;
1106
+ if (values.has(event.id) && values.has(prevValue)) values.delete(event.id);
1107
+ else if (!values.has(prevValue)) values.add(prevValue);
1108
+ context.set("selectedValue", Array.from(values));
1109
+ },
1110
+ extendSelectionToFirstNode(params) {
1111
+ const { context, prop } = params;
1112
+ const collection = prop("collection");
1113
+ const currentSelection = first(context.get("selectedValue"));
1114
+ const values = [];
1115
+ collection.visit({
1116
+ skip: skipFn(params),
1117
+ onEnter: (node) => {
1118
+ const nodeValue = collection.getNodeValue(node);
1119
+ values.push(nodeValue);
1120
+ if (nodeValue === currentSelection) return "stop";
1121
+ }
1122
+ });
1123
+ context.set("selectedValue", values);
1124
+ },
1125
+ extendSelectionToLastNode(params) {
1126
+ const { context, prop } = params;
1127
+ const collection = prop("collection");
1128
+ const currentSelection = first(context.get("selectedValue"));
1129
+ const values = [];
1130
+ let current = false;
1131
+ collection.visit({
1132
+ skip: skipFn(params),
1133
+ onEnter: (node) => {
1134
+ const nodeValue = collection.getNodeValue(node);
1135
+ if (nodeValue === currentSelection) current = true;
1136
+ if (current) values.push(nodeValue);
1137
+ }
1138
+ });
1139
+ context.set("selectedValue", values);
1140
+ },
1141
+ clearPendingAborts({ refs }) {
1142
+ const aborts = refs.get("pendingAborts");
1143
+ aborts.forEach((abort) => abort.abort());
1144
+ aborts.clear();
1145
+ },
1146
+ toggleChecked({ context, event, prop }) {
1147
+ const collection = prop("collection");
1148
+ context.set("checkedValue", (prev) => event.isBranch ? toggleBranchChecked(collection, event.value, prev) : addOrRemove(prev, event.value));
1149
+ },
1150
+ setChecked({ context, event }) {
1151
+ context.set("checkedValue", event.value);
1152
+ },
1153
+ clearChecked({ context }) {
1154
+ context.set("checkedValue", []);
1155
+ },
1156
+ setRenamingValue({ context, event, prop }) {
1157
+ context.set("renamingValue", event.value);
1158
+ const onRenameStartFn = prop("onRenameStart");
1159
+ if (onRenameStartFn) {
1160
+ const collection = prop("collection");
1161
+ const indexPath = collection.getIndexPath(event.value);
1162
+ if (indexPath) {
1163
+ const node = collection.at(indexPath);
1164
+ if (node) onRenameStartFn({
1165
+ value: event.value,
1166
+ node,
1167
+ indexPath
1168
+ });
1169
+ }
1170
+ }
1171
+ },
1172
+ submitRenaming({ context, event, prop, scope }) {
1173
+ const renamingValue = context.get("renamingValue");
1174
+ if (!renamingValue) return;
1175
+ const indexPath = prop("collection").getIndexPath(renamingValue);
1176
+ if (!indexPath) return;
1177
+ const trimmedLabel = event.label.trim();
1178
+ const onBeforeRenameFn = prop("onBeforeRename");
1179
+ if (onBeforeRenameFn) {
1180
+ if (!onBeforeRenameFn({
1181
+ value: renamingValue,
1182
+ label: trimmedLabel,
1183
+ indexPath
1184
+ })) {
1185
+ context.set("renamingValue", null);
1186
+ focusNode(scope, renamingValue);
1187
+ return;
1188
+ }
1189
+ }
1190
+ prop("onRenameComplete")?.({
1191
+ value: renamingValue,
1192
+ label: trimmedLabel,
1193
+ indexPath
1194
+ });
1195
+ context.set("renamingValue", null);
1196
+ focusNode(scope, renamingValue);
1197
+ },
1198
+ cancelRenaming({ context, scope }) {
1199
+ const renamingValue = context.get("renamingValue");
1200
+ context.set("renamingValue", null);
1201
+ if (renamingValue) focusNode(scope, renamingValue);
1202
+ },
1203
+ syncRenameInput({ context, scope, prop }) {
1204
+ const renamingValue = context.get("renamingValue");
1205
+ if (!renamingValue) return;
1206
+ const collection = prop("collection");
1207
+ const node = collection.findNode(renamingValue);
1208
+ if (!node) return;
1209
+ const label = collection.stringifyNode(node);
1210
+ setElementValue(getRenameInputEl(scope, renamingValue), label);
1211
+ },
1212
+ focusRenameInput({ context, scope }) {
1213
+ const renamingValue = context.get("renamingValue");
1214
+ if (!renamingValue) return;
1215
+ const inputEl = getRenameInputEl(scope, renamingValue);
1216
+ if (!inputEl) return;
1217
+ inputEl.focus();
1218
+ inputEl.select();
1219
+ }
1220
+ }
1221
+ }
1222
+ });
1223
+ function scrollToNode(params, value) {
1224
+ const { prop, scope, computed } = params;
1225
+ const scrollToIndexFn = prop("scrollToIndexFn");
1226
+ if (!scrollToIndexFn) return false;
1227
+ const collection = prop("collection");
1228
+ const visibleNodes = computed("visibleNodes");
1229
+ for (let i = 0; i < visibleNodes.length; i++) {
1230
+ const { node, indexPath } = visibleNodes[i];
1231
+ if (collection.getNodeValue(node) !== value) continue;
1232
+ scrollToIndexFn({
1233
+ index: i,
1234
+ node,
1235
+ indexPath,
1236
+ getElement: () => scope.getById(getNodeId(scope, value))
1237
+ });
1238
+ return true;
1239
+ }
1240
+ return false;
1241
+ }
1242
+ //#endregion
1243
+ //#region src/machines/tree-view/props.ts
1244
+ const props = createProps()([
1245
+ "ids",
1246
+ "collection",
1247
+ "dir",
1248
+ "expandedValue",
1249
+ "expandOnClick",
1250
+ "defaultFocusedValue",
1251
+ "focusedValue",
1252
+ "getRootNode",
1253
+ "id",
1254
+ "onExpandedChange",
1255
+ "onFocusChange",
1256
+ "onSelectionChange",
1257
+ "checkedValue",
1258
+ "selectedValue",
1259
+ "selectionMode",
1260
+ "typeahead",
1261
+ "defaultExpandedValue",
1262
+ "defaultSelectedValue",
1263
+ "defaultCheckedValue",
1264
+ "onCheckedChange",
1265
+ "onLoadChildrenComplete",
1266
+ "onLoadChildrenError",
1267
+ "loadChildren",
1268
+ "canRename",
1269
+ "onRenameStart",
1270
+ "onBeforeRename",
1271
+ "onRenameComplete",
1272
+ "scrollToIndexFn",
1273
+ "translations"
1274
+ ]);
1275
+ const splitProps = createSplitProps(props);
1276
+ const itemProps = createProps()(["node", "indexPath"]);
1277
+ const splitItemProps = createSplitProps(itemProps);
1278
+ //#endregion
1279
+ export { anatomy, collection, connect, filePathCollection, itemProps, machine, props, splitItemProps, splitProps };