@sprawlify/primitives 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (378) hide show
  1. package/dist/anatomy.cjs +3 -0
  2. package/dist/anatomy.d.cts +2 -0
  3. package/dist/anatomy.d.mts +2 -0
  4. package/dist/anatomy.mjs +3 -0
  5. package/dist/aria-hidden-DqYx0f_y.mjs +177 -0
  6. package/dist/aria-hidden-DtLU6hSU.cjs +182 -0
  7. package/dist/aria-hidden.cjs +4 -0
  8. package/dist/aria-hidden.d.cts +16 -0
  9. package/dist/aria-hidden.d.mts +16 -0
  10. package/dist/aria-hidden.mjs +4 -0
  11. package/dist/auto-resize-D3qHtFy1.mjs +114 -0
  12. package/dist/auto-resize-xzlPFDyD.cjs +125 -0
  13. package/dist/auto-resize.cjs +5 -0
  14. package/dist/auto-resize.d.cts +17 -0
  15. package/dist/auto-resize.d.mts +17 -0
  16. package/dist/auto-resize.mjs +4 -0
  17. package/dist/chunk-CbDLau6x.cjs +34 -0
  18. package/dist/collection-8XqaNHs_.mjs +1279 -0
  19. package/dist/collection-DIoIDISa.cjs +1326 -0
  20. package/dist/collection.cjs +11 -0
  21. package/dist/collection.d.cts +5 -0
  22. package/dist/collection.d.mts +5 -0
  23. package/dist/collection.mjs +4 -0
  24. package/dist/color-BkAP1Tkd.d.mts +60 -0
  25. package/dist/color-VKewNv2e.d.cts +60 -0
  26. package/dist/color-utils-Cc5GVXZh.mjs +657 -0
  27. package/dist/color-utils-LER_6Zwu.cjs +680 -0
  28. package/dist/color-utils.cjs +7 -0
  29. package/dist/color-utils.d.cts +19 -0
  30. package/dist/color-utils.d.mts +19 -0
  31. package/dist/color-utils.mjs +4 -0
  32. package/dist/core-30pJjyC2.d.mts +49 -0
  33. package/dist/core-CQFbMdTl.cjs +176 -0
  34. package/dist/core-CefBjbst.d.cts +49 -0
  35. package/dist/core-DCFNMTZF.mjs +129 -0
  36. package/dist/core.cjs +12 -0
  37. package/dist/core.d.cts +3 -0
  38. package/dist/core.d.mts +3 -0
  39. package/dist/core.mjs +5 -0
  40. package/dist/create-anatomy-B3XYc-qG.d.mts +70 -0
  41. package/dist/create-anatomy-BGQ8pv8J.d.cts +70 -0
  42. package/dist/create-anatomy-BbDZbHpC.mjs +39 -0
  43. package/dist/create-anatomy-CDsIFUXg.cjs +45 -0
  44. package/dist/create-props-BnF_vl-E.mjs +5 -0
  45. package/dist/create-props-YKy7JIKj.cjs +11 -0
  46. package/dist/data-url-C3ITPVRX.d.cts +10 -0
  47. package/dist/data-url-DLwZ9M77.d.mts +10 -0
  48. package/dist/date-utils-D2xPHa_I.cjs +738 -0
  49. package/dist/date-utils-wEa1hhpc.mjs +474 -0
  50. package/dist/date-utils.cjs +46 -0
  51. package/dist/date-utils.d.cts +101 -0
  52. package/dist/date-utils.d.mts +2 -0
  53. package/dist/date-utils.mjs +3 -0
  54. package/dist/defineProperty-BoUOT9Ie.cjs +49 -0
  55. package/dist/defineProperty-DrXfyjd4.mjs +43 -0
  56. package/dist/dismissable-CTfKZ4OG.cjs +282 -0
  57. package/dist/dismissable-DDrx0xnH.mjs +271 -0
  58. package/dist/dismissable-layer-C7pZU2wi.d.cts +39 -0
  59. package/dist/dismissable-layer-t_b0fk-p.d.mts +39 -0
  60. package/dist/dismissable.cjs +7 -0
  61. package/dist/dismissable.d.cts +3 -0
  62. package/dist/dismissable.d.mts +3 -0
  63. package/dist/dismissable.mjs +6 -0
  64. package/dist/dom-query-CWZdWUGp.cjs +2141 -0
  65. package/dist/dom-query-DFCRhyj1.mjs +1374 -0
  66. package/dist/dom-query.cjs +130 -0
  67. package/dist/dom-query.d.cts +307 -0
  68. package/dist/dom-query.d.mts +307 -0
  69. package/dist/dom-query.mjs +3 -0
  70. package/dist/file-utils.cjs +220 -0
  71. package/dist/file-utils.d.cts +51 -0
  72. package/dist/file-utils.d.mts +51 -0
  73. package/dist/file-utils.mjs +210 -0
  74. package/dist/focus-trap-D-bypQEJ.mjs +485 -0
  75. package/dist/focus-trap-D4i52S9A.cjs +496 -0
  76. package/dist/focus-trap.cjs +5 -0
  77. package/dist/focus-trap.d.cts +88 -0
  78. package/dist/focus-trap.d.mts +88 -0
  79. package/dist/focus-trap.mjs +4 -0
  80. package/dist/focus-visible-DYTWdWpa.cjs +210 -0
  81. package/dist/focus-visible-irppYatv.mjs +175 -0
  82. package/dist/focus-visible.cjs +9 -0
  83. package/dist/focus-visible.d.cts +31 -0
  84. package/dist/focus-visible.d.mts +31 -0
  85. package/dist/focus-visible.mjs +4 -0
  86. package/dist/functions-BOkTDEFM.d.cts +15 -0
  87. package/dist/functions-IZtWcC8Q.d.mts +15 -0
  88. package/dist/highlight-word.cjs +100 -0
  89. package/dist/highlight-word.d.cts +24 -0
  90. package/dist/highlight-word.d.mts +24 -0
  91. package/dist/highlight-word.mjs +99 -0
  92. package/dist/hotkeys.cjs +758 -0
  93. package/dist/hotkeys.d.cts +130 -0
  94. package/dist/hotkeys.d.mts +130 -0
  95. package/dist/hotkeys.mjs +754 -0
  96. package/dist/i18n-utils.cjs +450 -0
  97. package/dist/i18n-utils.d.cts +61 -0
  98. package/dist/i18n-utils.d.mts +61 -0
  99. package/dist/i18n-utils.mjs +440 -0
  100. package/dist/index-BkzYij2j.d.mts +25 -0
  101. package/dist/index-Bqw3r34-.d.cts +1383 -0
  102. package/dist/index-C0MKXQmE.d.mts +1383 -0
  103. package/dist/index-C9-feK5c.d.cts +25 -0
  104. package/dist/index-CD5FN7kY.d.mts +114 -0
  105. package/dist/index-CJji6wHl.d.cts +15 -0
  106. package/dist/index-CNi5FkPe.d.mts +15 -0
  107. package/dist/index-D96rs8B0.d.mts +115 -0
  108. package/dist/index.cjs +0 -0
  109. package/dist/index.d.cts +1 -0
  110. package/dist/index.d.mts +1 -0
  111. package/dist/index.mjs +1 -0
  112. package/dist/interact-outside-BplxR9cR.mjs +200 -0
  113. package/dist/interact-outside-C8-oFBpB.cjs +205 -0
  114. package/dist/interact-outside.cjs +5 -0
  115. package/dist/interact-outside.d.cts +2 -0
  116. package/dist/interact-outside.d.mts +2 -0
  117. package/dist/interact-outside.mjs +5 -0
  118. package/dist/json-tree-utils.cjs +1512 -0
  119. package/dist/json-tree-utils.d.cts +117 -0
  120. package/dist/json-tree-utils.d.mts +117 -0
  121. package/dist/json-tree-utils.mjs +1463 -0
  122. package/dist/list-collection-BIMJGQjn.d.cts +61 -0
  123. package/dist/list-collection-Db3eixRU.d.mts +61 -0
  124. package/dist/live-region-CcZPGo89.cjs +52 -0
  125. package/dist/live-region-CnPh21WH.mjs +46 -0
  126. package/dist/live-region.cjs +3 -0
  127. package/dist/live-region.d.cts +2 -0
  128. package/dist/live-region.d.mts +2 -0
  129. package/dist/live-region.mjs +3 -0
  130. package/dist/machines/accordion/index.cjs +328 -0
  131. package/dist/machines/accordion/index.d.cts +83 -0
  132. package/dist/machines/accordion/index.d.mts +83 -0
  133. package/dist/machines/accordion/index.mjs +322 -0
  134. package/dist/machines/async-list/index.cjs +311 -0
  135. package/dist/machines/async-list/index.d.cts +89 -0
  136. package/dist/machines/async-list/index.d.mts +89 -0
  137. package/dist/machines/async-list/index.mjs +310 -0
  138. package/dist/machines/avatar/index.cjs +169 -0
  139. package/dist/machines/avatar/index.d.cts +63 -0
  140. package/dist/machines/avatar/index.d.mts +63 -0
  141. package/dist/machines/avatar/index.mjs +165 -0
  142. package/dist/machines/bottom-sheet/index.cjs +676 -0
  143. package/dist/machines/bottom-sheet/index.d.cts +239 -0
  144. package/dist/machines/bottom-sheet/index.d.mts +239 -0
  145. package/dist/machines/bottom-sheet/index.mjs +672 -0
  146. package/dist/machines/carousel/index.cjs +859 -0
  147. package/dist/machines/carousel/index.d.cts +146 -0
  148. package/dist/machines/carousel/index.d.mts +146 -0
  149. package/dist/machines/carousel/index.mjs +851 -0
  150. package/dist/machines/checkbox/index.cjs +316 -0
  151. package/dist/machines/checkbox/index.d.cts +81 -0
  152. package/dist/machines/checkbox/index.d.mts +81 -0
  153. package/dist/machines/checkbox/index.mjs +312 -0
  154. package/dist/machines/clipboard/index.cjs +225 -0
  155. package/dist/machines/clipboard/index.d.cts +68 -0
  156. package/dist/machines/clipboard/index.d.mts +68 -0
  157. package/dist/machines/clipboard/index.mjs +219 -0
  158. package/dist/machines/collapsible/index.cjs +362 -0
  159. package/dist/machines/collapsible/index.d.cts +82 -0
  160. package/dist/machines/collapsible/index.d.mts +82 -0
  161. package/dist/machines/collapsible/index.mjs +358 -0
  162. package/dist/machines/color-picker/index.cjs +1529 -0
  163. package/dist/machines/color-picker/index.d.cts +205 -0
  164. package/dist/machines/color-picker/index.d.mts +205 -0
  165. package/dist/machines/color-picker/index.mjs +1514 -0
  166. package/dist/machines/combobox/index.cjs +1593 -0
  167. package/dist/machines/combobox/index.d.cts +214 -0
  168. package/dist/machines/combobox/index.d.mts +214 -0
  169. package/dist/machines/combobox/index.mjs +1582 -0
  170. package/dist/machines/date-picker/index.cjs +2177 -0
  171. package/dist/machines/date-picker/index.d.cts +350 -0
  172. package/dist/machines/date-picker/index.d.mts +350 -0
  173. package/dist/machines/date-picker/index.mjs +2161 -0
  174. package/dist/machines/dialog/index.cjs +325 -0
  175. package/dist/machines/dialog/index.d.cts +80 -0
  176. package/dist/machines/dialog/index.d.mts +80 -0
  177. package/dist/machines/dialog/index.mjs +321 -0
  178. package/dist/machines/editable/index.cjs +551 -0
  179. package/dist/machines/editable/index.d.cts +114 -0
  180. package/dist/machines/editable/index.d.mts +114 -0
  181. package/dist/machines/editable/index.mjs +547 -0
  182. package/dist/machines/floating-panel/index.cjs +995 -0
  183. package/dist/machines/floating-panel/index.d.cts +147 -0
  184. package/dist/machines/floating-panel/index.d.mts +147 -0
  185. package/dist/machines/floating-panel/index.mjs +988 -0
  186. package/dist/machines/hover-card/index.cjs +383 -0
  187. package/dist/machines/hover-card/index.d.cts +69 -0
  188. package/dist/machines/hover-card/index.d.mts +69 -0
  189. package/dist/machines/hover-card/index.mjs +379 -0
  190. package/dist/machines/image-cropper/index.cjs +1995 -0
  191. package/dist/machines/image-cropper/index.d.cts +182 -0
  192. package/dist/machines/image-cropper/index.d.mts +182 -0
  193. package/dist/machines/image-cropper/index.mjs +1990 -0
  194. package/dist/machines/listbox/index.cjs +794 -0
  195. package/dist/machines/listbox/index.d.cts +168 -0
  196. package/dist/machines/listbox/index.d.mts +168 -0
  197. package/dist/machines/listbox/index.mjs +782 -0
  198. package/dist/machines/marquee/index.cjs +395 -0
  199. package/dist/machines/marquee/index.d.cts +102 -0
  200. package/dist/machines/marquee/index.d.mts +102 -0
  201. package/dist/machines/marquee/index.mjs +391 -0
  202. package/dist/machines/menu/index.cjs +1298 -0
  203. package/dist/machines/menu/index.d.cts +175 -0
  204. package/dist/machines/menu/index.d.mts +175 -0
  205. package/dist/machines/menu/index.mjs +1286 -0
  206. package/dist/machines/navigation-menu/index.cjs +861 -0
  207. package/dist/machines/navigation-menu/index.d.cts +127 -0
  208. package/dist/machines/navigation-menu/index.d.mts +127 -0
  209. package/dist/machines/navigation-menu/index.mjs +857 -0
  210. package/dist/machines/number-input/index.cjs +996 -0
  211. package/dist/machines/number-input/index.d.cts +134 -0
  212. package/dist/machines/number-input/index.d.mts +134 -0
  213. package/dist/machines/number-input/index.mjs +991 -0
  214. package/dist/machines/pagination/index.cjs +419 -0
  215. package/dist/machines/pagination/index.d.cts +139 -0
  216. package/dist/machines/pagination/index.d.mts +139 -0
  217. package/dist/machines/pagination/index.mjs +411 -0
  218. package/dist/machines/password-input/index.cjs +228 -0
  219. package/dist/machines/password-input/index.d.cts +71 -0
  220. package/dist/machines/password-input/index.d.mts +71 -0
  221. package/dist/machines/password-input/index.mjs +224 -0
  222. package/dist/machines/pin-input/index.cjs +523 -0
  223. package/dist/machines/pin-input/index.d.cts +105 -0
  224. package/dist/machines/pin-input/index.d.mts +105 -0
  225. package/dist/machines/pin-input/index.mjs +519 -0
  226. package/dist/machines/popover/index.cjs +430 -0
  227. package/dist/machines/popover/index.d.cts +88 -0
  228. package/dist/machines/popover/index.d.mts +88 -0
  229. package/dist/machines/popover/index.mjs +426 -0
  230. package/dist/machines/presence/index.cjs +192 -0
  231. package/dist/machines/presence/index.d.cts +44 -0
  232. package/dist/machines/presence/index.d.mts +44 -0
  233. package/dist/machines/presence/index.mjs +190 -0
  234. package/dist/machines/progress/index.cjs +288 -0
  235. package/dist/machines/progress/index.d.cts +96 -0
  236. package/dist/machines/progress/index.d.mts +96 -0
  237. package/dist/machines/progress/index.mjs +284 -0
  238. package/dist/machines/qr-code/index.cjs +172 -0
  239. package/dist/machines/qr-code/index.d.cts +70 -0
  240. package/dist/machines/qr-code/index.d.mts +70 -0
  241. package/dist/machines/qr-code/index.mjs +167 -0
  242. package/dist/machines/radio-group/index.cjs +436 -0
  243. package/dist/machines/radio-group/index.d.cts +106 -0
  244. package/dist/machines/radio-group/index.d.mts +106 -0
  245. package/dist/machines/radio-group/index.mjs +430 -0
  246. package/dist/machines/rating-group/index.cjs +405 -0
  247. package/dist/machines/rating-group/index.d.cts +101 -0
  248. package/dist/machines/rating-group/index.d.mts +101 -0
  249. package/dist/machines/rating-group/index.mjs +399 -0
  250. package/dist/machines/scroll-area/index.cjs +857 -0
  251. package/dist/machines/scroll-area/index.d.cts +159 -0
  252. package/dist/machines/scroll-area/index.d.mts +159 -0
  253. package/dist/machines/scroll-area/index.mjs +853 -0
  254. package/dist/machines/select/index.cjs +1165 -0
  255. package/dist/machines/select/index.d.cts +183 -0
  256. package/dist/machines/select/index.d.mts +183 -0
  257. package/dist/machines/select/index.mjs +1154 -0
  258. package/dist/machines/signature-pad/index.cjs +334 -0
  259. package/dist/machines/signature-pad/index.d.cts +108 -0
  260. package/dist/machines/signature-pad/index.d.mts +108 -0
  261. package/dist/machines/signature-pad/index.mjs +328 -0
  262. package/dist/machines/slider/index.cjs +957 -0
  263. package/dist/machines/slider/index.d.cts +149 -0
  264. package/dist/machines/slider/index.d.mts +149 -0
  265. package/dist/machines/slider/index.mjs +949 -0
  266. package/dist/machines/splitter/index.cjs +1112 -0
  267. package/dist/machines/splitter/index.d.cts +155 -0
  268. package/dist/machines/splitter/index.d.mts +155 -0
  269. package/dist/machines/splitter/index.mjs +1103 -0
  270. package/dist/machines/steps/index.cjs +289 -0
  271. package/dist/machines/steps/index.d.cts +97 -0
  272. package/dist/machines/steps/index.d.mts +97 -0
  273. package/dist/machines/steps/index.mjs +285 -0
  274. package/dist/machines/switch/index.cjs +305 -0
  275. package/dist/machines/switch/index.d.cts +80 -0
  276. package/dist/machines/switch/index.d.mts +80 -0
  277. package/dist/machines/switch/index.mjs +301 -0
  278. package/dist/machines/tabs/index.cjs +508 -0
  279. package/dist/machines/tabs/index.d.cts +111 -0
  280. package/dist/machines/tabs/index.d.mts +111 -0
  281. package/dist/machines/tabs/index.mjs +500 -0
  282. package/dist/machines/tags-input/index.cjs +1127 -0
  283. package/dist/machines/tags-input/index.d.cts +179 -0
  284. package/dist/machines/tags-input/index.d.mts +179 -0
  285. package/dist/machines/tags-input/index.mjs +1121 -0
  286. package/dist/machines/timer/index.cjs +329 -0
  287. package/dist/machines/timer/index.d.cts +98 -0
  288. package/dist/machines/timer/index.d.mts +98 -0
  289. package/dist/machines/timer/index.mjs +324 -0
  290. package/dist/machines/toast/index.cjs +1155 -0
  291. package/dist/machines/toast/index.d.cts +195 -0
  292. package/dist/machines/toast/index.d.mts +195 -0
  293. package/dist/machines/toast/index.mjs +1151 -0
  294. package/dist/machines/toggle/index.cjs +103 -0
  295. package/dist/machines/toggle/index.d.cts +46 -0
  296. package/dist/machines/toggle/index.d.mts +46 -0
  297. package/dist/machines/toggle/index.mjs +99 -0
  298. package/dist/machines/toggle-group/index.cjs +328 -0
  299. package/dist/machines/toggle-group/index.d.cts +81 -0
  300. package/dist/machines/toggle-group/index.d.mts +81 -0
  301. package/dist/machines/toggle-group/index.mjs +322 -0
  302. package/dist/machines/tooltip/index.cjs +516 -0
  303. package/dist/machines/tooltip/index.d.cts +71 -0
  304. package/dist/machines/tooltip/index.d.mts +71 -0
  305. package/dist/machines/tooltip/index.mjs +512 -0
  306. package/dist/machines/tour/index.cjs +1108 -0
  307. package/dist/machines/tour/index.d.cts +206 -0
  308. package/dist/machines/tour/index.d.mts +206 -0
  309. package/dist/machines/tour/index.mjs +1101 -0
  310. package/dist/machines/tree-view/index.cjs +1271 -0
  311. package/dist/machines/tree-view/index.d.cts +215 -0
  312. package/dist/machines/tree-view/index.d.mts +215 -0
  313. package/dist/machines/tree-view/index.mjs +1263 -0
  314. package/dist/node-BctU8GXk.d.mts +24 -0
  315. package/dist/node-CSsuPZVZ.d.cts +24 -0
  316. package/dist/popper-BPJeAtcA.mjs +349 -0
  317. package/dist/popper-D0FAW_p7.cjs +373 -0
  318. package/dist/popper.cjs +8 -0
  319. package/dist/popper.d.cts +74 -0
  320. package/dist/popper.d.mts +2 -0
  321. package/dist/popper.mjs +5 -0
  322. package/dist/raf-BnlYUlDi.d.mts +15 -0
  323. package/dist/raf-Cd2FGy0z.d.cts +15 -0
  324. package/dist/rect-utils-0ellN0a_.mjs +854 -0
  325. package/dist/rect-utils-DKLRhP8G.cjs +1147 -0
  326. package/dist/rect-utils.cjs +51 -0
  327. package/dist/rect-utils.d.cts +198 -0
  328. package/dist/rect-utils.d.mts +198 -0
  329. package/dist/rect-utils.mjs +3 -0
  330. package/dist/remove-scroll-Lrfv79X_.mjs +58 -0
  331. package/dist/remove-scroll-Uvzg1L9r.cjs +63 -0
  332. package/dist/remove-scroll.cjs +0 -0
  333. package/dist/remove-scroll.d.cts +1 -0
  334. package/dist/remove-scroll.d.mts +1 -0
  335. package/dist/remove-scroll.mjs +1 -0
  336. package/dist/scroll-snap-CrTmQRzA.mjs +152 -0
  337. package/dist/scroll-snap-zyiZLv7W.cjs +175 -0
  338. package/dist/scroll-snap.cjs +7 -0
  339. package/dist/scroll-snap.d.cts +14 -0
  340. package/dist/scroll-snap.d.mts +14 -0
  341. package/dist/scroll-snap.mjs +4 -0
  342. package/dist/selection-BIhSzkF7.d.mts +50 -0
  343. package/dist/selection-CS1GBp8e.d.cts +50 -0
  344. package/dist/store-BZcXv49B.cjs +305 -0
  345. package/dist/store-DEojWy9H.mjs +263 -0
  346. package/dist/store.cjs +9 -0
  347. package/dist/store.d.cts +26 -0
  348. package/dist/store.d.mts +26 -0
  349. package/dist/store.mjs +3 -0
  350. package/dist/stringify-state.cjs +49 -0
  351. package/dist/stringify-state.d.cts +8 -0
  352. package/dist/stringify-state.d.mts +8 -0
  353. package/dist/stringify-state.mjs +46 -0
  354. package/dist/tree-collection-BwU5WhGQ.d.mts +78 -0
  355. package/dist/tree-collection-DP_eznnI.d.cts +78 -0
  356. package/dist/typeahead-BdNwVP09.d.cts +45 -0
  357. package/dist/typeahead-XN6lZ7G9.d.mts +45 -0
  358. package/dist/types-BivBkYg9.d.cts +57 -0
  359. package/dist/types-Bl_6JtPQ.d.mts +57 -0
  360. package/dist/types-CPUMVt7c.d.mts +54 -0
  361. package/dist/types-CT_W6HWr.d.cts +54 -0
  362. package/dist/types-DDTcG99l.d.mts +201 -0
  363. package/dist/types-DejIu60O.d.cts +201 -0
  364. package/dist/types-DiIdKZ3K.d.cts +45 -0
  365. package/dist/types-GxLIgJib.d.cts +17 -0
  366. package/dist/types.cjs +15 -0
  367. package/dist/types.d.cts +2 -0
  368. package/dist/types.d.mts +2 -0
  369. package/dist/types.mjs +14 -0
  370. package/dist/utils-BZyrxWWR.mjs +525 -0
  371. package/dist/utils-_6frwjgJ.cjs +1040 -0
  372. package/dist/utils.cjs +88 -0
  373. package/dist/utils.d.cts +144 -0
  374. package/dist/utils.d.mts +144 -0
  375. package/dist/utils.mjs +3 -0
  376. package/dist/wait-for-CMjPsqWk.d.cts +10 -0
  377. package/dist/wait-for-D2nkdD4z.d.mts +10 -0
  378. package/package.json +399 -0
@@ -0,0 +1,1582 @@
1
+ import { t as createAnatomy } from "../../create-anatomy-BbDZbHpC.mjs";
2
+ import { F as scrollIntoView, I as clickIfLink, R as observeAttributes, U as raf, V as nextTick, _n as ariaAttr, _t as isDownloadingEvent, an as isAnchorElement, bn as setCaretToEnd, ht as isContextMenuEvent, lt as getEventKey, mt as isComposingEvent, vn as dataAttr, x as query, xt as isOpeningInNewTab, yt as isLeftClick } from "../../dom-query-DFCRhyj1.mjs";
3
+ import { J as match, dt as isEqual, kt as remove, nt as isBoolean, pt as addOrRemove, t as ensure, u as createSplitProps } from "../../utils-BZyrxWWR.mjs";
4
+ import { s as ListCollection } from "../../collection-8XqaNHs_.mjs";
5
+ import { o as setup } from "../../core-DCFNMTZF.mjs";
6
+ import "../../interact-outside-BplxR9cR.mjs";
7
+ import { n as trackDismissableElement } from "../../dismissable-DDrx0xnH.mjs";
8
+ import { n as getPlacement, t as getPlacementStyles } from "../../popper-BPJeAtcA.mjs";
9
+ import { t as createProps } from "../../create-props-BnF_vl-E.mjs";
10
+
11
+ //#region src/machines/combobox/combobox.anatomy.ts
12
+ const anatomy = createAnatomy("combobox").parts("root", "clearTrigger", "content", "control", "input", "item", "itemGroup", "itemGroupLabel", "itemIndicator", "itemText", "label", "list", "positioner", "trigger");
13
+ const parts = anatomy.build();
14
+
15
+ //#endregion
16
+ //#region src/machines/combobox/combobox.collection.ts
17
+ const collection = (options) => {
18
+ return new ListCollection(options);
19
+ };
20
+ collection.empty = () => {
21
+ return new ListCollection({ items: [] });
22
+ };
23
+
24
+ //#endregion
25
+ //#region src/machines/combobox/combobox.dom.ts
26
+ const getRootId = (ctx) => ctx.ids?.root ?? `combobox:${ctx.id}`;
27
+ const getLabelId = (ctx) => ctx.ids?.label ?? `combobox:${ctx.id}:label`;
28
+ const getControlId = (ctx) => ctx.ids?.control ?? `combobox:${ctx.id}:control`;
29
+ const getInputId = (ctx) => ctx.ids?.input ?? `combobox:${ctx.id}:input`;
30
+ const getContentId = (ctx) => ctx.ids?.content ?? `combobox:${ctx.id}:content`;
31
+ const getPositionerId = (ctx) => ctx.ids?.positioner ?? `combobox:${ctx.id}:popper`;
32
+ const getTriggerId = (ctx) => ctx.ids?.trigger ?? `combobox:${ctx.id}:toggle-btn`;
33
+ const getClearTriggerId = (ctx) => ctx.ids?.clearTrigger ?? `combobox:${ctx.id}:clear-btn`;
34
+ const getItemGroupId = (ctx, id) => ctx.ids?.itemGroup?.(id) ?? `combobox:${ctx.id}:optgroup:${id}`;
35
+ const getItemGroupLabelId = (ctx, id) => ctx.ids?.itemGroupLabel?.(id) ?? `combobox:${ctx.id}:optgroup-label:${id}`;
36
+ const getItemId = (ctx, id) => ctx.ids?.item?.(id) ?? `combobox:${ctx.id}:option:${id}`;
37
+ const getContentEl = (ctx) => ctx.getById(getContentId(ctx));
38
+ const getInputEl = (ctx) => ctx.getById(getInputId(ctx));
39
+ const getPositionerEl = (ctx) => ctx.getById(getPositionerId(ctx));
40
+ const getControlEl = (ctx) => ctx.getById(getControlId(ctx));
41
+ const getTriggerEl = (ctx) => ctx.getById(getTriggerId(ctx));
42
+ const getClearTriggerEl = (ctx) => ctx.getById(getClearTriggerId(ctx));
43
+ const getItemEl = (ctx, value) => {
44
+ if (value == null) return null;
45
+ const selector = `[role=option][data-value="${CSS.escape(value)}"]`;
46
+ return query(getContentEl(ctx), selector);
47
+ };
48
+ const focusInputEl = (ctx) => {
49
+ const inputEl = getInputEl(ctx);
50
+ if (ctx.isActiveElement(inputEl)) return;
51
+ inputEl?.focus({ preventScroll: true });
52
+ };
53
+ const focusTriggerEl = (ctx) => {
54
+ const triggerEl = getTriggerEl(ctx);
55
+ if (ctx.isActiveElement(triggerEl)) return;
56
+ triggerEl?.focus({ preventScroll: true });
57
+ };
58
+
59
+ //#endregion
60
+ //#region src/machines/combobox/combobox.connect.ts
61
+ function connect(service, normalize) {
62
+ const { context, prop, state, send, scope, computed, event } = service;
63
+ const translations = prop("translations");
64
+ const collection$1 = prop("collection");
65
+ const disabled = !!prop("disabled");
66
+ const interactive = computed("isInteractive");
67
+ const invalid = !!prop("invalid");
68
+ const required = !!prop("required");
69
+ const readOnly = !!prop("readOnly");
70
+ const open = state.hasTag("open");
71
+ const focused = state.hasTag("focused");
72
+ const composite = prop("composite");
73
+ const highlightedValue = context.get("highlightedValue");
74
+ const popperStyles = getPlacementStyles({
75
+ ...prop("positioning"),
76
+ placement: context.get("currentPlacement")
77
+ });
78
+ function getItemState(props$1) {
79
+ const disabled$1 = collection$1.getItemDisabled(props$1.item);
80
+ const value = collection$1.getItemValue(props$1.item);
81
+ ensure(value, () => `[sprawlify-js] No value found for item ${JSON.stringify(props$1.item)}`);
82
+ return {
83
+ value,
84
+ disabled: Boolean(disabled$1 || disabled$1),
85
+ highlighted: highlightedValue === value,
86
+ selected: context.get("value").includes(value)
87
+ };
88
+ }
89
+ return {
90
+ focused,
91
+ open,
92
+ inputValue: context.get("inputValue"),
93
+ highlightedValue,
94
+ highlightedItem: context.get("highlightedItem"),
95
+ value: context.get("value"),
96
+ valueAsString: computed("valueAsString"),
97
+ hasSelectedItems: computed("hasSelectedItems"),
98
+ selectedItems: context.get("selectedItems"),
99
+ collection: prop("collection"),
100
+ multiple: !!prop("multiple"),
101
+ disabled: !!disabled,
102
+ syncSelectedItems() {
103
+ send({ type: "SELECTED_ITEMS.SYNC" });
104
+ },
105
+ reposition(options = {}) {
106
+ send({
107
+ type: "POSITIONING.SET",
108
+ options
109
+ });
110
+ },
111
+ setHighlightValue(value) {
112
+ send({
113
+ type: "HIGHLIGHTED_VALUE.SET",
114
+ value
115
+ });
116
+ },
117
+ clearHighlightValue() {
118
+ send({ type: "HIGHLIGHTED_VALUE.CLEAR" });
119
+ },
120
+ selectValue(value) {
121
+ send({
122
+ type: "ITEM.SELECT",
123
+ value
124
+ });
125
+ },
126
+ setValue(value) {
127
+ send({
128
+ type: "VALUE.SET",
129
+ value
130
+ });
131
+ },
132
+ setInputValue(value, reason = "script") {
133
+ send({
134
+ type: "INPUT_VALUE.SET",
135
+ value,
136
+ src: reason
137
+ });
138
+ },
139
+ clearValue(value) {
140
+ if (value != null) send({
141
+ type: "ITEM.CLEAR",
142
+ value
143
+ });
144
+ else send({ type: "VALUE.CLEAR" });
145
+ },
146
+ focus() {
147
+ getInputEl(scope)?.focus();
148
+ },
149
+ setOpen(nextOpen, reason = "script") {
150
+ if (state.hasTag("open") === nextOpen) return;
151
+ send({
152
+ type: nextOpen ? "OPEN" : "CLOSE",
153
+ src: reason
154
+ });
155
+ },
156
+ getRootProps() {
157
+ return normalize.element({
158
+ ...parts.root.attrs,
159
+ dir: prop("dir"),
160
+ id: getRootId(scope),
161
+ "data-invalid": dataAttr(invalid),
162
+ "data-readonly": dataAttr(readOnly)
163
+ });
164
+ },
165
+ getLabelProps() {
166
+ return normalize.label({
167
+ ...parts.label.attrs,
168
+ dir: prop("dir"),
169
+ htmlFor: getInputId(scope),
170
+ id: getLabelId(scope),
171
+ "data-readonly": dataAttr(readOnly),
172
+ "data-disabled": dataAttr(disabled),
173
+ "data-invalid": dataAttr(invalid),
174
+ "data-required": dataAttr(required),
175
+ "data-focus": dataAttr(focused),
176
+ onClick(event$1) {
177
+ if (composite) return;
178
+ event$1.preventDefault();
179
+ getTriggerEl(scope)?.focus({ preventScroll: true });
180
+ }
181
+ });
182
+ },
183
+ getControlProps() {
184
+ return normalize.element({
185
+ ...parts.control.attrs,
186
+ dir: prop("dir"),
187
+ id: getControlId(scope),
188
+ "data-state": open ? "open" : "closed",
189
+ "data-focus": dataAttr(focused),
190
+ "data-disabled": dataAttr(disabled),
191
+ "data-invalid": dataAttr(invalid)
192
+ });
193
+ },
194
+ getPositionerProps() {
195
+ return normalize.element({
196
+ ...parts.positioner.attrs,
197
+ dir: prop("dir"),
198
+ id: getPositionerId(scope),
199
+ style: popperStyles.floating
200
+ });
201
+ },
202
+ getInputProps() {
203
+ return normalize.input({
204
+ ...parts.input.attrs,
205
+ dir: prop("dir"),
206
+ "aria-invalid": ariaAttr(invalid),
207
+ "data-invalid": dataAttr(invalid),
208
+ "data-autofocus": dataAttr(prop("autoFocus")),
209
+ name: prop("name"),
210
+ form: prop("form"),
211
+ disabled,
212
+ required: prop("required"),
213
+ autoComplete: "off",
214
+ autoCorrect: "off",
215
+ autoCapitalize: "none",
216
+ spellCheck: "false",
217
+ readOnly,
218
+ placeholder: prop("placeholder"),
219
+ id: getInputId(scope),
220
+ type: "text",
221
+ role: "combobox",
222
+ defaultValue: context.get("inputValue"),
223
+ "aria-autocomplete": computed("autoComplete") ? "both" : "list",
224
+ "aria-controls": getContentId(scope),
225
+ "aria-expanded": open,
226
+ "data-state": open ? "open" : "closed",
227
+ "aria-activedescendant": highlightedValue ? getItemId(scope, highlightedValue) : void 0,
228
+ onClick(event$1) {
229
+ if (event$1.defaultPrevented) return;
230
+ if (!prop("openOnClick")) return;
231
+ if (!interactive) return;
232
+ send({
233
+ type: "INPUT.CLICK",
234
+ src: "input-click"
235
+ });
236
+ },
237
+ onFocus() {
238
+ if (disabled) return;
239
+ send({ type: "INPUT.FOCUS" });
240
+ },
241
+ onBlur() {
242
+ if (disabled) return;
243
+ send({ type: "INPUT.BLUR" });
244
+ },
245
+ onChange(event$1) {
246
+ send({
247
+ type: "INPUT.CHANGE",
248
+ value: event$1.currentTarget.value,
249
+ src: "input-change"
250
+ });
251
+ },
252
+ onKeyDown(event$1) {
253
+ if (event$1.defaultPrevented) return;
254
+ if (!interactive) return;
255
+ if (event$1.ctrlKey || event$1.shiftKey || isComposingEvent(event$1)) return;
256
+ const openOnKeyPress = prop("openOnKeyPress");
257
+ const isModifierKey = event$1.ctrlKey || event$1.metaKey || event$1.shiftKey;
258
+ const keypress = true;
259
+ const exec = {
260
+ ArrowDown(event$2) {
261
+ if (!openOnKeyPress && !open) return;
262
+ send({
263
+ type: event$2.altKey ? "OPEN" : "INPUT.ARROW_DOWN",
264
+ keypress,
265
+ src: "arrow-key"
266
+ });
267
+ event$2.preventDefault();
268
+ },
269
+ ArrowUp() {
270
+ if (!openOnKeyPress && !open) return;
271
+ send({
272
+ type: event$1.altKey ? "CLOSE" : "INPUT.ARROW_UP",
273
+ keypress,
274
+ src: "arrow-key"
275
+ });
276
+ event$1.preventDefault();
277
+ },
278
+ Home(event$2) {
279
+ if (isModifierKey) return;
280
+ send({
281
+ type: "INPUT.HOME",
282
+ keypress
283
+ });
284
+ if (open) event$2.preventDefault();
285
+ },
286
+ End(event$2) {
287
+ if (isModifierKey) return;
288
+ send({
289
+ type: "INPUT.END",
290
+ keypress
291
+ });
292
+ if (open) event$2.preventDefault();
293
+ },
294
+ Enter(event$2) {
295
+ send({
296
+ type: "INPUT.ENTER",
297
+ keypress,
298
+ src: "item-select"
299
+ });
300
+ const submittable = computed("isCustomValue") && prop("allowCustomValue");
301
+ const hasHighlight = highlightedValue != null;
302
+ const alwaysSubmit = prop("alwaysSubmitOnEnter");
303
+ if (open && !submittable && !alwaysSubmit && hasHighlight) event$2.preventDefault();
304
+ if (highlightedValue == null) return;
305
+ const itemEl = getItemEl(scope, highlightedValue);
306
+ if (isAnchorElement(itemEl)) prop("navigate")?.({
307
+ value: highlightedValue,
308
+ node: itemEl,
309
+ href: itemEl.href
310
+ });
311
+ },
312
+ Escape() {
313
+ send({
314
+ type: "INPUT.ESCAPE",
315
+ keypress,
316
+ src: "escape-key"
317
+ });
318
+ event$1.preventDefault();
319
+ }
320
+ }[getEventKey(event$1, { dir: prop("dir") })];
321
+ exec?.(event$1);
322
+ }
323
+ });
324
+ },
325
+ getTriggerProps(props$1 = {}) {
326
+ return normalize.button({
327
+ ...parts.trigger.attrs,
328
+ dir: prop("dir"),
329
+ id: getTriggerId(scope),
330
+ "aria-haspopup": composite ? "listbox" : "dialog",
331
+ type: "button",
332
+ tabIndex: props$1.focusable ? void 0 : -1,
333
+ "aria-label": translations.triggerLabel,
334
+ "aria-expanded": open,
335
+ "data-state": open ? "open" : "closed",
336
+ "aria-controls": open ? getContentId(scope) : void 0,
337
+ disabled,
338
+ "data-invalid": dataAttr(invalid),
339
+ "data-focusable": dataAttr(props$1.focusable),
340
+ "data-readonly": dataAttr(readOnly),
341
+ "data-disabled": dataAttr(disabled),
342
+ onFocus() {
343
+ if (!props$1.focusable) return;
344
+ send({
345
+ type: "INPUT.FOCUS",
346
+ src: "trigger"
347
+ });
348
+ },
349
+ onClick(event$1) {
350
+ if (event$1.defaultPrevented) return;
351
+ if (!interactive) return;
352
+ if (!isLeftClick(event$1)) return;
353
+ send({
354
+ type: "TRIGGER.CLICK",
355
+ src: "trigger-click"
356
+ });
357
+ },
358
+ onPointerDown(event$1) {
359
+ if (!interactive) return;
360
+ if (event$1.pointerType === "touch") return;
361
+ if (!isLeftClick(event$1)) return;
362
+ event$1.preventDefault();
363
+ queueMicrotask(() => {
364
+ getInputEl(scope)?.focus({ preventScroll: true });
365
+ });
366
+ },
367
+ onKeyDown(event$1) {
368
+ if (event$1.defaultPrevented) return;
369
+ if (composite) return;
370
+ const exec = {
371
+ ArrowDown() {
372
+ send({
373
+ type: "INPUT.ARROW_DOWN",
374
+ src: "arrow-key"
375
+ });
376
+ },
377
+ ArrowUp() {
378
+ send({
379
+ type: "INPUT.ARROW_UP",
380
+ src: "arrow-key"
381
+ });
382
+ }
383
+ }[getEventKey(event$1, { dir: prop("dir") })];
384
+ if (exec) {
385
+ exec(event$1);
386
+ event$1.preventDefault();
387
+ }
388
+ }
389
+ });
390
+ },
391
+ getContentProps() {
392
+ return normalize.element({
393
+ ...parts.content.attrs,
394
+ dir: prop("dir"),
395
+ id: getContentId(scope),
396
+ role: !composite ? "dialog" : "listbox",
397
+ tabIndex: -1,
398
+ hidden: !open,
399
+ "data-state": open ? "open" : "closed",
400
+ "data-placement": context.get("currentPlacement"),
401
+ "aria-labelledby": getLabelId(scope),
402
+ "aria-multiselectable": prop("multiple") && composite ? true : void 0,
403
+ "data-empty": dataAttr(collection$1.size === 0),
404
+ onPointerDown(event$1) {
405
+ if (!isLeftClick(event$1)) return;
406
+ event$1.preventDefault();
407
+ }
408
+ });
409
+ },
410
+ getListProps() {
411
+ return normalize.element({
412
+ ...parts.list.attrs,
413
+ role: !composite ? "listbox" : void 0,
414
+ "data-empty": dataAttr(collection$1.size === 0),
415
+ "aria-labelledby": getLabelId(scope),
416
+ "aria-multiselectable": prop("multiple") && !composite ? true : void 0
417
+ });
418
+ },
419
+ getClearTriggerProps() {
420
+ return normalize.button({
421
+ ...parts.clearTrigger.attrs,
422
+ dir: prop("dir"),
423
+ id: getClearTriggerId(scope),
424
+ type: "button",
425
+ tabIndex: -1,
426
+ disabled,
427
+ "data-invalid": dataAttr(invalid),
428
+ "aria-label": translations.clearTriggerLabel,
429
+ "aria-controls": getInputId(scope),
430
+ hidden: !context.get("value").length,
431
+ onPointerDown(event$1) {
432
+ if (!isLeftClick(event$1)) return;
433
+ event$1.preventDefault();
434
+ },
435
+ onClick(event$1) {
436
+ if (event$1.defaultPrevented) return;
437
+ if (!interactive) return;
438
+ send({
439
+ type: "VALUE.CLEAR",
440
+ src: "clear-trigger"
441
+ });
442
+ }
443
+ });
444
+ },
445
+ getItemState,
446
+ getItemProps(props$1) {
447
+ const itemState = getItemState(props$1);
448
+ const value = itemState.value;
449
+ return normalize.element({
450
+ ...parts.item.attrs,
451
+ dir: prop("dir"),
452
+ id: getItemId(scope, value),
453
+ role: "option",
454
+ tabIndex: -1,
455
+ "data-highlighted": dataAttr(itemState.highlighted),
456
+ "data-state": itemState.selected ? "checked" : "unchecked",
457
+ "aria-selected": ariaAttr(itemState.highlighted),
458
+ "aria-disabled": ariaAttr(itemState.disabled),
459
+ "data-disabled": dataAttr(itemState.disabled),
460
+ "data-value": itemState.value,
461
+ onPointerMove() {
462
+ if (itemState.disabled) return;
463
+ if (itemState.highlighted) return;
464
+ send({
465
+ type: "ITEM.POINTER_MOVE",
466
+ value
467
+ });
468
+ },
469
+ onPointerLeave() {
470
+ if (props$1.persistFocus) return;
471
+ if (itemState.disabled) return;
472
+ if (!event.previous()?.type.includes("POINTER")) return;
473
+ send({
474
+ type: "ITEM.POINTER_LEAVE",
475
+ value
476
+ });
477
+ },
478
+ onClick(event$1) {
479
+ if (isDownloadingEvent(event$1)) return;
480
+ if (isOpeningInNewTab(event$1)) return;
481
+ if (isContextMenuEvent(event$1)) return;
482
+ if (itemState.disabled) return;
483
+ send({
484
+ type: "ITEM.CLICK",
485
+ src: "item-select",
486
+ value
487
+ });
488
+ }
489
+ });
490
+ },
491
+ getItemTextProps(props$1) {
492
+ const itemState = getItemState(props$1);
493
+ return normalize.element({
494
+ ...parts.itemText.attrs,
495
+ dir: prop("dir"),
496
+ "data-state": itemState.selected ? "checked" : "unchecked",
497
+ "data-disabled": dataAttr(itemState.disabled),
498
+ "data-highlighted": dataAttr(itemState.highlighted)
499
+ });
500
+ },
501
+ getItemIndicatorProps(props$1) {
502
+ const itemState = getItemState(props$1);
503
+ return normalize.element({
504
+ "aria-hidden": true,
505
+ ...parts.itemIndicator.attrs,
506
+ dir: prop("dir"),
507
+ "data-state": itemState.selected ? "checked" : "unchecked",
508
+ hidden: !itemState.selected
509
+ });
510
+ },
511
+ getItemGroupProps(props$1) {
512
+ const { id } = props$1;
513
+ return normalize.element({
514
+ ...parts.itemGroup.attrs,
515
+ dir: prop("dir"),
516
+ id: getItemGroupId(scope, id),
517
+ "aria-labelledby": getItemGroupLabelId(scope, id),
518
+ "data-empty": dataAttr(collection$1.size === 0),
519
+ role: "group"
520
+ });
521
+ },
522
+ getItemGroupLabelProps(props$1) {
523
+ const { htmlFor } = props$1;
524
+ return normalize.element({
525
+ ...parts.itemGroupLabel.attrs,
526
+ dir: prop("dir"),
527
+ id: getItemGroupLabelId(scope, htmlFor),
528
+ role: "presentation"
529
+ });
530
+ }
531
+ };
532
+ }
533
+
534
+ //#endregion
535
+ //#region src/machines/combobox/combobox.machine.ts
536
+ const { guards, createMachine, choose } = setup();
537
+ const { and, not } = guards;
538
+ const machine = createMachine({
539
+ props({ props: props$1 }) {
540
+ return {
541
+ loopFocus: true,
542
+ openOnClick: false,
543
+ defaultValue: [],
544
+ defaultInputValue: "",
545
+ closeOnSelect: !props$1.multiple,
546
+ allowCustomValue: false,
547
+ alwaysSubmitOnEnter: false,
548
+ inputBehavior: "none",
549
+ selectionBehavior: props$1.multiple ? "clear" : "replace",
550
+ openOnKeyPress: true,
551
+ openOnChange: true,
552
+ composite: true,
553
+ navigate({ node }) {
554
+ clickIfLink(node);
555
+ },
556
+ collection: collection.empty(),
557
+ ...props$1,
558
+ positioning: {
559
+ placement: "bottom",
560
+ sameWidth: true,
561
+ ...props$1.positioning
562
+ },
563
+ translations: {
564
+ triggerLabel: "Toggle suggestions",
565
+ clearTriggerLabel: "Clear value",
566
+ ...props$1.translations
567
+ }
568
+ };
569
+ },
570
+ initialState({ prop }) {
571
+ return prop("open") || prop("defaultOpen") ? "suggesting" : "idle";
572
+ },
573
+ context({ prop, bindable, getContext, getEvent }) {
574
+ return {
575
+ currentPlacement: bindable(() => ({ defaultValue: void 0 })),
576
+ value: bindable(() => ({
577
+ defaultValue: prop("defaultValue"),
578
+ value: prop("value"),
579
+ isEqual,
580
+ hash(value) {
581
+ return value.join(",");
582
+ },
583
+ onChange(value) {
584
+ const context = getContext();
585
+ const prevSelectedItems = context.get("selectedItems");
586
+ const collection$1 = prop("collection");
587
+ const nextItems = value.map((v) => {
588
+ return prevSelectedItems.find((item) => collection$1.getItemValue(item) === v) || collection$1.find(v);
589
+ });
590
+ context.set("selectedItems", nextItems);
591
+ prop("onValueChange")?.({
592
+ value,
593
+ items: nextItems
594
+ });
595
+ }
596
+ })),
597
+ highlightedValue: bindable(() => ({
598
+ defaultValue: prop("defaultHighlightedValue") || null,
599
+ value: prop("highlightedValue"),
600
+ onChange(value) {
601
+ const item = prop("collection").find(value);
602
+ prop("onHighlightChange")?.({
603
+ highlightedValue: value,
604
+ highlightedItem: item
605
+ });
606
+ }
607
+ })),
608
+ inputValue: bindable(() => {
609
+ let inputValue = prop("inputValue") || prop("defaultInputValue");
610
+ const value = prop("value") || prop("defaultValue");
611
+ if (!inputValue.trim() && !prop("multiple")) {
612
+ const valueAsString = prop("collection").stringifyMany(value);
613
+ inputValue = match(prop("selectionBehavior"), {
614
+ preserve: inputValue || valueAsString,
615
+ replace: valueAsString,
616
+ clear: ""
617
+ });
618
+ }
619
+ return {
620
+ defaultValue: inputValue,
621
+ value: prop("inputValue"),
622
+ onChange(value$1) {
623
+ const event = getEvent();
624
+ const reason = (event.previousEvent || event).src;
625
+ prop("onInputValueChange")?.({
626
+ inputValue: value$1,
627
+ reason
628
+ });
629
+ }
630
+ };
631
+ }),
632
+ highlightedItem: bindable(() => {
633
+ const highlightedValue = prop("highlightedValue");
634
+ return { defaultValue: prop("collection").find(highlightedValue) };
635
+ }),
636
+ selectedItems: bindable(() => {
637
+ const value = prop("value") || prop("defaultValue") || [];
638
+ return { defaultValue: prop("collection").findMany(value) };
639
+ })
640
+ };
641
+ },
642
+ computed: {
643
+ isInputValueEmpty: ({ context }) => context.get("inputValue").length === 0,
644
+ isInteractive: ({ prop }) => !(prop("readOnly") || prop("disabled")),
645
+ autoComplete: ({ prop }) => prop("inputBehavior") === "autocomplete",
646
+ autoHighlight: ({ prop }) => prop("inputBehavior") === "autohighlight",
647
+ hasSelectedItems: ({ context }) => context.get("value").length > 0,
648
+ valueAsString: ({ context, prop }) => prop("collection").stringifyItems(context.get("selectedItems")),
649
+ isCustomValue: ({ context, computed }) => context.get("inputValue") !== computed("valueAsString")
650
+ },
651
+ watch({ context, prop, track, action, send }) {
652
+ track([() => context.hash("value")], () => {
653
+ action(["syncSelectedItems"]);
654
+ });
655
+ track([() => context.get("inputValue")], () => {
656
+ action(["syncInputValue"]);
657
+ });
658
+ track([() => context.get("highlightedValue")], () => {
659
+ action(["syncHighlightedItem", "autofillInputValue"]);
660
+ });
661
+ track([() => prop("open")], () => {
662
+ action(["toggleVisibility"]);
663
+ });
664
+ track([() => prop("collection").toString()], () => {
665
+ send({ type: "CHILDREN_CHANGE" });
666
+ });
667
+ },
668
+ on: {
669
+ "SELECTED_ITEMS.SYNC": { actions: ["syncSelectedItems"] },
670
+ "HIGHLIGHTED_VALUE.SET": { actions: ["setHighlightedValue"] },
671
+ "HIGHLIGHTED_VALUE.CLEAR": { actions: ["clearHighlightedValue"] },
672
+ "ITEM.SELECT": { actions: ["selectItem"] },
673
+ "ITEM.CLEAR": { actions: ["clearItem"] },
674
+ "VALUE.SET": { actions: ["setValue"] },
675
+ "INPUT_VALUE.SET": { actions: ["setInputValue"] },
676
+ "POSITIONING.SET": { actions: ["reposition"] }
677
+ },
678
+ entry: choose([{
679
+ guard: "autoFocus",
680
+ actions: ["setInitialFocus"]
681
+ }]),
682
+ states: {
683
+ idle: {
684
+ tags: ["idle", "closed"],
685
+ entry: ["scrollContentToTop", "clearHighlightedValue"],
686
+ on: {
687
+ "CONTROLLED.OPEN": { target: "interacting" },
688
+ "TRIGGER.CLICK": [{
689
+ guard: "isOpenControlled",
690
+ actions: [
691
+ "setInitialFocus",
692
+ "highlightFirstSelectedItem",
693
+ "invokeOnOpen"
694
+ ]
695
+ }, {
696
+ target: "interacting",
697
+ actions: [
698
+ "setInitialFocus",
699
+ "highlightFirstSelectedItem",
700
+ "invokeOnOpen"
701
+ ]
702
+ }],
703
+ "INPUT.CLICK": [{
704
+ guard: "isOpenControlled",
705
+ actions: ["highlightFirstSelectedItem", "invokeOnOpen"]
706
+ }, {
707
+ target: "interacting",
708
+ actions: ["highlightFirstSelectedItem", "invokeOnOpen"]
709
+ }],
710
+ "INPUT.FOCUS": { target: "focused" },
711
+ OPEN: [{
712
+ guard: "isOpenControlled",
713
+ actions: ["invokeOnOpen"]
714
+ }, {
715
+ target: "interacting",
716
+ actions: ["invokeOnOpen"]
717
+ }],
718
+ "VALUE.CLEAR": {
719
+ target: "focused",
720
+ actions: [
721
+ "clearInputValue",
722
+ "clearSelectedItems",
723
+ "setInitialFocus"
724
+ ]
725
+ }
726
+ }
727
+ },
728
+ focused: {
729
+ tags: ["focused", "closed"],
730
+ entry: ["scrollContentToTop", "clearHighlightedValue"],
731
+ on: {
732
+ "CONTROLLED.OPEN": [{
733
+ guard: "isChangeEvent",
734
+ target: "suggesting"
735
+ }, { target: "interacting" }],
736
+ "INPUT.CHANGE": [
737
+ {
738
+ guard: and("isOpenControlled", "openOnChange"),
739
+ actions: [
740
+ "setInputValue",
741
+ "invokeOnOpen",
742
+ "highlightFirstItemIfNeeded"
743
+ ]
744
+ },
745
+ {
746
+ guard: "openOnChange",
747
+ target: "suggesting",
748
+ actions: [
749
+ "setInputValue",
750
+ "invokeOnOpen",
751
+ "highlightFirstItemIfNeeded"
752
+ ]
753
+ },
754
+ { actions: ["setInputValue"] }
755
+ ],
756
+ "LAYER.INTERACT_OUTSIDE": { target: "idle" },
757
+ "INPUT.ESCAPE": {
758
+ guard: and("isCustomValue", not("allowCustomValue")),
759
+ actions: ["revertInputValue"]
760
+ },
761
+ "INPUT.BLUR": { target: "idle" },
762
+ "INPUT.CLICK": [{
763
+ guard: "isOpenControlled",
764
+ actions: ["highlightFirstSelectedItem", "invokeOnOpen"]
765
+ }, {
766
+ target: "interacting",
767
+ actions: ["highlightFirstSelectedItem", "invokeOnOpen"]
768
+ }],
769
+ "TRIGGER.CLICK": [{
770
+ guard: "isOpenControlled",
771
+ actions: [
772
+ "setInitialFocus",
773
+ "highlightFirstSelectedItem",
774
+ "invokeOnOpen"
775
+ ]
776
+ }, {
777
+ target: "interacting",
778
+ actions: [
779
+ "setInitialFocus",
780
+ "highlightFirstSelectedItem",
781
+ "invokeOnOpen"
782
+ ]
783
+ }],
784
+ "INPUT.ARROW_DOWN": [
785
+ {
786
+ guard: and("isOpenControlled", "autoComplete"),
787
+ actions: ["invokeOnOpen"]
788
+ },
789
+ {
790
+ guard: "autoComplete",
791
+ target: "interacting",
792
+ actions: ["invokeOnOpen"]
793
+ },
794
+ {
795
+ guard: "isOpenControlled",
796
+ actions: ["highlightFirstOrSelectedItem", "invokeOnOpen"]
797
+ },
798
+ {
799
+ target: "interacting",
800
+ actions: ["highlightFirstOrSelectedItem", "invokeOnOpen"]
801
+ }
802
+ ],
803
+ "INPUT.ARROW_UP": [
804
+ {
805
+ guard: "autoComplete",
806
+ target: "interacting",
807
+ actions: ["invokeOnOpen"]
808
+ },
809
+ {
810
+ guard: "autoComplete",
811
+ target: "interacting",
812
+ actions: ["invokeOnOpen"]
813
+ },
814
+ {
815
+ target: "interacting",
816
+ actions: ["highlightLastOrSelectedItem", "invokeOnOpen"]
817
+ },
818
+ {
819
+ target: "interacting",
820
+ actions: ["highlightLastOrSelectedItem", "invokeOnOpen"]
821
+ }
822
+ ],
823
+ OPEN: [{
824
+ guard: "isOpenControlled",
825
+ actions: ["invokeOnOpen"]
826
+ }, {
827
+ target: "interacting",
828
+ actions: ["invokeOnOpen"]
829
+ }],
830
+ "VALUE.CLEAR": { actions: ["clearInputValue", "clearSelectedItems"] }
831
+ }
832
+ },
833
+ interacting: {
834
+ tags: ["open", "focused"],
835
+ entry: ["setInitialFocus"],
836
+ effects: [
837
+ "scrollToHighlightedItem",
838
+ "trackDismissableLayer",
839
+ "trackPlacement"
840
+ ],
841
+ on: {
842
+ "CONTROLLED.CLOSE": [{
843
+ guard: "restoreFocus",
844
+ target: "focused",
845
+ actions: ["setFinalFocus"]
846
+ }, { target: "idle" }],
847
+ CHILDREN_CHANGE: [{
848
+ guard: "isHighlightedItemRemoved",
849
+ actions: ["clearHighlightedValue"]
850
+ }, { actions: ["scrollToHighlightedItem"] }],
851
+ "INPUT.HOME": { actions: ["highlightFirstItem"] },
852
+ "INPUT.END": { actions: ["highlightLastItem"] },
853
+ "INPUT.ARROW_DOWN": [{
854
+ guard: and("autoComplete", "isLastItemHighlighted"),
855
+ actions: ["clearHighlightedValue", "scrollContentToTop"]
856
+ }, { actions: ["highlightNextItem"] }],
857
+ "INPUT.ARROW_UP": [{
858
+ guard: and("autoComplete", "isFirstItemHighlighted"),
859
+ actions: ["clearHighlightedValue"]
860
+ }, { actions: ["highlightPrevItem"] }],
861
+ "INPUT.ENTER": [
862
+ {
863
+ guard: and("isOpenControlled", "isCustomValue", not("hasHighlightedItem"), not("allowCustomValue")),
864
+ actions: ["revertInputValue", "invokeOnClose"]
865
+ },
866
+ {
867
+ guard: and("isCustomValue", not("hasHighlightedItem"), not("allowCustomValue")),
868
+ target: "focused",
869
+ actions: ["revertInputValue", "invokeOnClose"]
870
+ },
871
+ {
872
+ guard: and("isOpenControlled", "closeOnSelect"),
873
+ actions: ["selectHighlightedItem", "invokeOnClose"]
874
+ },
875
+ {
876
+ guard: "closeOnSelect",
877
+ target: "focused",
878
+ actions: [
879
+ "selectHighlightedItem",
880
+ "invokeOnClose",
881
+ "setFinalFocus"
882
+ ]
883
+ },
884
+ { actions: ["selectHighlightedItem"] }
885
+ ],
886
+ "INPUT.CHANGE": [{
887
+ guard: "autoComplete",
888
+ target: "suggesting",
889
+ actions: ["setInputValue"]
890
+ }, {
891
+ target: "suggesting",
892
+ actions: ["clearHighlightedValue", "setInputValue"]
893
+ }],
894
+ "ITEM.POINTER_MOVE": { actions: ["setHighlightedValue"] },
895
+ "ITEM.POINTER_LEAVE": { actions: ["clearHighlightedValue"] },
896
+ "ITEM.CLICK": [
897
+ {
898
+ guard: and("isOpenControlled", "closeOnSelect"),
899
+ actions: ["selectItem", "invokeOnClose"]
900
+ },
901
+ {
902
+ guard: "closeOnSelect",
903
+ target: "focused",
904
+ actions: [
905
+ "selectItem",
906
+ "invokeOnClose",
907
+ "setFinalFocus"
908
+ ]
909
+ },
910
+ { actions: ["selectItem"] }
911
+ ],
912
+ "LAYER.ESCAPE": [
913
+ {
914
+ guard: and("isOpenControlled", "autoComplete"),
915
+ actions: ["syncInputValue", "invokeOnClose"]
916
+ },
917
+ {
918
+ guard: "autoComplete",
919
+ target: "focused",
920
+ actions: ["syncInputValue", "invokeOnClose"]
921
+ },
922
+ {
923
+ guard: "isOpenControlled",
924
+ actions: ["invokeOnClose"]
925
+ },
926
+ {
927
+ target: "focused",
928
+ actions: ["invokeOnClose", "setFinalFocus"]
929
+ }
930
+ ],
931
+ "TRIGGER.CLICK": [{
932
+ guard: "isOpenControlled",
933
+ actions: ["invokeOnClose"]
934
+ }, {
935
+ target: "focused",
936
+ actions: ["invokeOnClose"]
937
+ }],
938
+ "LAYER.INTERACT_OUTSIDE": [
939
+ {
940
+ guard: and("isOpenControlled", "isCustomValue", not("allowCustomValue")),
941
+ actions: ["revertInputValue", "invokeOnClose"]
942
+ },
943
+ {
944
+ guard: and("isCustomValue", not("allowCustomValue")),
945
+ target: "idle",
946
+ actions: ["revertInputValue", "invokeOnClose"]
947
+ },
948
+ {
949
+ guard: "isOpenControlled",
950
+ actions: ["invokeOnClose"]
951
+ },
952
+ {
953
+ target: "idle",
954
+ actions: ["invokeOnClose"]
955
+ }
956
+ ],
957
+ CLOSE: [{
958
+ guard: "isOpenControlled",
959
+ actions: ["invokeOnClose"]
960
+ }, {
961
+ target: "focused",
962
+ actions: ["invokeOnClose", "setFinalFocus"]
963
+ }],
964
+ "VALUE.CLEAR": [{
965
+ guard: "isOpenControlled",
966
+ actions: [
967
+ "clearInputValue",
968
+ "clearSelectedItems",
969
+ "invokeOnClose"
970
+ ]
971
+ }, {
972
+ target: "focused",
973
+ actions: [
974
+ "clearInputValue",
975
+ "clearSelectedItems",
976
+ "invokeOnClose",
977
+ "setFinalFocus"
978
+ ]
979
+ }]
980
+ }
981
+ },
982
+ suggesting: {
983
+ tags: ["open", "focused"],
984
+ effects: [
985
+ "trackDismissableLayer",
986
+ "scrollToHighlightedItem",
987
+ "trackPlacement"
988
+ ],
989
+ entry: ["setInitialFocus"],
990
+ on: {
991
+ "CONTROLLED.CLOSE": [{
992
+ guard: "restoreFocus",
993
+ target: "focused",
994
+ actions: ["setFinalFocus"]
995
+ }, { target: "idle" }],
996
+ CHILDREN_CHANGE: [
997
+ {
998
+ guard: and("isHighlightedItemRemoved", "hasCollectionItems", "autoHighlight"),
999
+ actions: ["clearHighlightedValue", "highlightFirstItem"]
1000
+ },
1001
+ {
1002
+ guard: "isHighlightedItemRemoved",
1003
+ actions: ["clearHighlightedValue"]
1004
+ },
1005
+ {
1006
+ guard: "autoHighlight",
1007
+ actions: ["highlightFirstItem"]
1008
+ }
1009
+ ],
1010
+ "INPUT.ARROW_DOWN": {
1011
+ target: "interacting",
1012
+ actions: ["highlightNextItem"]
1013
+ },
1014
+ "INPUT.ARROW_UP": {
1015
+ target: "interacting",
1016
+ actions: ["highlightPrevItem"]
1017
+ },
1018
+ "INPUT.HOME": {
1019
+ target: "interacting",
1020
+ actions: ["highlightFirstItem"]
1021
+ },
1022
+ "INPUT.END": {
1023
+ target: "interacting",
1024
+ actions: ["highlightLastItem"]
1025
+ },
1026
+ "INPUT.ENTER": [
1027
+ {
1028
+ guard: and("isOpenControlled", "isCustomValue", not("hasHighlightedItem"), not("allowCustomValue")),
1029
+ actions: ["revertInputValue", "invokeOnClose"]
1030
+ },
1031
+ {
1032
+ guard: and("isCustomValue", not("hasHighlightedItem"), not("allowCustomValue")),
1033
+ target: "focused",
1034
+ actions: ["revertInputValue", "invokeOnClose"]
1035
+ },
1036
+ {
1037
+ guard: and("isOpenControlled", "closeOnSelect"),
1038
+ actions: ["selectHighlightedItem", "invokeOnClose"]
1039
+ },
1040
+ {
1041
+ guard: "closeOnSelect",
1042
+ target: "focused",
1043
+ actions: [
1044
+ "selectHighlightedItem",
1045
+ "invokeOnClose",
1046
+ "setFinalFocus"
1047
+ ]
1048
+ },
1049
+ { actions: ["selectHighlightedItem"] }
1050
+ ],
1051
+ "INPUT.CHANGE": { actions: ["setInputValue"] },
1052
+ "LAYER.ESCAPE": [{
1053
+ guard: "isOpenControlled",
1054
+ actions: ["invokeOnClose"]
1055
+ }, {
1056
+ target: "focused",
1057
+ actions: ["invokeOnClose"]
1058
+ }],
1059
+ "ITEM.POINTER_MOVE": {
1060
+ target: "interacting",
1061
+ actions: ["setHighlightedValue"]
1062
+ },
1063
+ "ITEM.POINTER_LEAVE": { actions: ["clearHighlightedValue"] },
1064
+ "LAYER.INTERACT_OUTSIDE": [
1065
+ {
1066
+ guard: and("isOpenControlled", "isCustomValue", not("allowCustomValue")),
1067
+ actions: ["revertInputValue", "invokeOnClose"]
1068
+ },
1069
+ {
1070
+ guard: and("isCustomValue", not("allowCustomValue")),
1071
+ target: "idle",
1072
+ actions: ["revertInputValue", "invokeOnClose"]
1073
+ },
1074
+ {
1075
+ guard: "isOpenControlled",
1076
+ actions: ["invokeOnClose"]
1077
+ },
1078
+ {
1079
+ target: "idle",
1080
+ actions: ["invokeOnClose"]
1081
+ }
1082
+ ],
1083
+ "TRIGGER.CLICK": [{
1084
+ guard: "isOpenControlled",
1085
+ actions: ["invokeOnClose"]
1086
+ }, {
1087
+ target: "focused",
1088
+ actions: ["invokeOnClose"]
1089
+ }],
1090
+ "ITEM.CLICK": [
1091
+ {
1092
+ guard: and("isOpenControlled", "closeOnSelect"),
1093
+ actions: ["selectItem", "invokeOnClose"]
1094
+ },
1095
+ {
1096
+ guard: "closeOnSelect",
1097
+ target: "focused",
1098
+ actions: [
1099
+ "selectItem",
1100
+ "invokeOnClose",
1101
+ "setFinalFocus"
1102
+ ]
1103
+ },
1104
+ { actions: ["selectItem"] }
1105
+ ],
1106
+ CLOSE: [{
1107
+ guard: "isOpenControlled",
1108
+ actions: ["invokeOnClose"]
1109
+ }, {
1110
+ target: "focused",
1111
+ actions: ["invokeOnClose", "setFinalFocus"]
1112
+ }],
1113
+ "VALUE.CLEAR": [{
1114
+ guard: "isOpenControlled",
1115
+ actions: [
1116
+ "clearInputValue",
1117
+ "clearSelectedItems",
1118
+ "invokeOnClose"
1119
+ ]
1120
+ }, {
1121
+ target: "focused",
1122
+ actions: [
1123
+ "clearInputValue",
1124
+ "clearSelectedItems",
1125
+ "invokeOnClose",
1126
+ "setFinalFocus"
1127
+ ]
1128
+ }]
1129
+ }
1130
+ }
1131
+ },
1132
+ implementations: {
1133
+ guards: {
1134
+ isInputValueEmpty: ({ computed }) => computed("isInputValueEmpty"),
1135
+ autoComplete: ({ computed, prop }) => computed("autoComplete") && !prop("multiple"),
1136
+ autoHighlight: ({ computed }) => computed("autoHighlight"),
1137
+ isFirstItemHighlighted: ({ prop, context }) => prop("collection").firstValue === context.get("highlightedValue"),
1138
+ isLastItemHighlighted: ({ prop, context }) => prop("collection").lastValue === context.get("highlightedValue"),
1139
+ isCustomValue: ({ computed }) => computed("isCustomValue"),
1140
+ allowCustomValue: ({ prop }) => !!prop("allowCustomValue"),
1141
+ hasHighlightedItem: ({ context }) => context.get("highlightedValue") != null,
1142
+ closeOnSelect: ({ prop }) => !!prop("closeOnSelect"),
1143
+ isOpenControlled: ({ prop }) => prop("open") != null,
1144
+ openOnChange: ({ prop, context }) => {
1145
+ const openOnChange = prop("openOnChange");
1146
+ if (isBoolean(openOnChange)) return openOnChange;
1147
+ return !!openOnChange?.({ inputValue: context.get("inputValue") });
1148
+ },
1149
+ restoreFocus: ({ event }) => {
1150
+ const restoreFocus = event.restoreFocus ?? event.previousEvent?.restoreFocus;
1151
+ return restoreFocus == null ? true : !!restoreFocus;
1152
+ },
1153
+ isChangeEvent: ({ event }) => event.previousEvent?.type === "INPUT.CHANGE",
1154
+ autoFocus: ({ prop }) => !!prop("autoFocus"),
1155
+ isHighlightedItemRemoved: ({ prop, context }) => !prop("collection").has(context.get("highlightedValue")),
1156
+ hasCollectionItems: ({ prop }) => prop("collection").size > 0
1157
+ },
1158
+ effects: {
1159
+ trackDismissableLayer({ send, prop, scope }) {
1160
+ if (prop("disableLayer")) return;
1161
+ const contentEl = () => getContentEl(scope);
1162
+ return trackDismissableElement(contentEl, {
1163
+ type: "listbox",
1164
+ defer: true,
1165
+ exclude: () => [
1166
+ getInputEl(scope),
1167
+ getTriggerEl(scope),
1168
+ getClearTriggerEl(scope)
1169
+ ],
1170
+ onFocusOutside: prop("onFocusOutside"),
1171
+ onPointerDownOutside: prop("onPointerDownOutside"),
1172
+ onInteractOutside: prop("onInteractOutside"),
1173
+ onEscapeKeyDown(event) {
1174
+ event.preventDefault();
1175
+ event.stopPropagation();
1176
+ send({
1177
+ type: "LAYER.ESCAPE",
1178
+ src: "escape-key"
1179
+ });
1180
+ },
1181
+ onDismiss() {
1182
+ send({
1183
+ type: "LAYER.INTERACT_OUTSIDE",
1184
+ src: "interact-outside",
1185
+ restoreFocus: false
1186
+ });
1187
+ }
1188
+ });
1189
+ },
1190
+ trackPlacement({ context, prop, scope }) {
1191
+ const anchorEl = () => getControlEl(scope) || getTriggerEl(scope);
1192
+ const positionerEl = () => getPositionerEl(scope);
1193
+ context.set("currentPlacement", prop("positioning").placement);
1194
+ return getPlacement(anchorEl, positionerEl, {
1195
+ ...prop("positioning"),
1196
+ defer: true,
1197
+ onComplete(data) {
1198
+ context.set("currentPlacement", data.placement);
1199
+ }
1200
+ });
1201
+ },
1202
+ scrollToHighlightedItem({ context, prop, scope, event }) {
1203
+ const inputEl = getInputEl(scope);
1204
+ let cleanups = [];
1205
+ const exec = (immediate) => {
1206
+ const pointer = event.current().type.includes("POINTER");
1207
+ const highlightedValue = context.get("highlightedValue");
1208
+ if (pointer || !highlightedValue) return;
1209
+ const contentEl = getContentEl(scope);
1210
+ const scrollToIndexFn = prop("scrollToIndexFn");
1211
+ if (scrollToIndexFn) {
1212
+ scrollToIndexFn({
1213
+ index: prop("collection").indexOf(highlightedValue),
1214
+ immediate,
1215
+ getElement: () => getItemEl(scope, highlightedValue)
1216
+ });
1217
+ return;
1218
+ }
1219
+ const itemEl = getItemEl(scope, highlightedValue);
1220
+ const raf_cleanup = raf(() => {
1221
+ scrollIntoView(itemEl, {
1222
+ rootEl: contentEl,
1223
+ block: "nearest"
1224
+ });
1225
+ });
1226
+ cleanups.push(raf_cleanup);
1227
+ };
1228
+ const rafCleanup = raf(() => exec(true));
1229
+ cleanups.push(rafCleanup);
1230
+ const observerCleanup = observeAttributes(inputEl, {
1231
+ attributes: ["aria-activedescendant"],
1232
+ callback: () => exec(false)
1233
+ });
1234
+ cleanups.push(observerCleanup);
1235
+ return () => {
1236
+ cleanups.forEach((cleanup) => cleanup());
1237
+ };
1238
+ }
1239
+ },
1240
+ actions: {
1241
+ reposition({ context, prop, scope, event }) {
1242
+ const controlEl = () => getControlEl(scope);
1243
+ const positionerEl = () => getPositionerEl(scope);
1244
+ getPlacement(controlEl, positionerEl, {
1245
+ ...prop("positioning"),
1246
+ ...event.options,
1247
+ defer: true,
1248
+ listeners: false,
1249
+ onComplete(data) {
1250
+ context.set("currentPlacement", data.placement);
1251
+ }
1252
+ });
1253
+ },
1254
+ setHighlightedValue({ context, event }) {
1255
+ if (event.value == null) return;
1256
+ context.set("highlightedValue", event.value);
1257
+ },
1258
+ clearHighlightedValue({ context }) {
1259
+ context.set("highlightedValue", null);
1260
+ },
1261
+ selectHighlightedItem(params) {
1262
+ const { context, prop } = params;
1263
+ const collection$1 = prop("collection");
1264
+ const highlightedValue = context.get("highlightedValue");
1265
+ if (!highlightedValue || !collection$1.has(highlightedValue)) return;
1266
+ const nextValue = prop("multiple") ? addOrRemove(context.get("value"), highlightedValue) : [highlightedValue];
1267
+ prop("onSelect")?.({
1268
+ value: nextValue,
1269
+ itemValue: highlightedValue
1270
+ });
1271
+ context.set("value", nextValue);
1272
+ const inputValue = match(prop("selectionBehavior"), {
1273
+ preserve: context.get("inputValue"),
1274
+ replace: collection$1.stringifyMany(nextValue),
1275
+ clear: ""
1276
+ });
1277
+ context.set("inputValue", inputValue);
1278
+ },
1279
+ scrollToHighlightedItem({ context, prop, scope }) {
1280
+ nextTick(() => {
1281
+ const highlightedValue = context.get("highlightedValue");
1282
+ if (highlightedValue == null) return;
1283
+ const itemEl = getItemEl(scope, highlightedValue);
1284
+ const contentEl = getContentEl(scope);
1285
+ const scrollToIndexFn = prop("scrollToIndexFn");
1286
+ if (scrollToIndexFn) {
1287
+ scrollToIndexFn({
1288
+ index: prop("collection").indexOf(highlightedValue),
1289
+ immediate: true,
1290
+ getElement: () => getItemEl(scope, highlightedValue)
1291
+ });
1292
+ return;
1293
+ }
1294
+ scrollIntoView(itemEl, {
1295
+ rootEl: contentEl,
1296
+ block: "nearest"
1297
+ });
1298
+ });
1299
+ },
1300
+ selectItem(params) {
1301
+ const { context, event, flush, prop } = params;
1302
+ if (event.value == null) return;
1303
+ flush(() => {
1304
+ const nextValue = prop("multiple") ? addOrRemove(context.get("value"), event.value) : [event.value];
1305
+ prop("onSelect")?.({
1306
+ value: nextValue,
1307
+ itemValue: event.value
1308
+ });
1309
+ context.set("value", nextValue);
1310
+ const inputValue = match(prop("selectionBehavior"), {
1311
+ preserve: context.get("inputValue"),
1312
+ replace: prop("collection").stringifyMany(nextValue),
1313
+ clear: ""
1314
+ });
1315
+ context.set("inputValue", inputValue);
1316
+ });
1317
+ },
1318
+ clearItem(params) {
1319
+ const { context, event, flush, prop } = params;
1320
+ if (event.value == null) return;
1321
+ flush(() => {
1322
+ const nextValue = remove(context.get("value"), event.value);
1323
+ context.set("value", nextValue);
1324
+ const inputValue = match(prop("selectionBehavior"), {
1325
+ preserve: context.get("inputValue"),
1326
+ replace: prop("collection").stringifyMany(nextValue),
1327
+ clear: ""
1328
+ });
1329
+ context.set("inputValue", inputValue);
1330
+ });
1331
+ },
1332
+ setInitialFocus({ scope }) {
1333
+ raf(() => {
1334
+ focusInputEl(scope);
1335
+ });
1336
+ },
1337
+ setFinalFocus({ scope }) {
1338
+ raf(() => {
1339
+ if (getTriggerEl(scope)?.dataset.focusable == null) focusInputEl(scope);
1340
+ else focusTriggerEl(scope);
1341
+ });
1342
+ },
1343
+ syncInputValue({ context, scope, event }) {
1344
+ const inputEl = getInputEl(scope);
1345
+ if (!inputEl) return;
1346
+ inputEl.value = context.get("inputValue");
1347
+ queueMicrotask(() => {
1348
+ if (event.current().type === "INPUT.CHANGE") return;
1349
+ setCaretToEnd(inputEl);
1350
+ });
1351
+ },
1352
+ setInputValue({ context, event }) {
1353
+ context.set("inputValue", event.value);
1354
+ },
1355
+ clearInputValue({ context }) {
1356
+ context.set("inputValue", "");
1357
+ },
1358
+ revertInputValue({ context, prop, computed }) {
1359
+ const inputValue = match(prop("selectionBehavior"), {
1360
+ replace: computed("hasSelectedItems") ? computed("valueAsString") : "",
1361
+ preserve: context.get("inputValue"),
1362
+ clear: ""
1363
+ });
1364
+ context.set("inputValue", inputValue);
1365
+ },
1366
+ setValue(params) {
1367
+ const { context, flush, event, prop } = params;
1368
+ flush(() => {
1369
+ context.set("value", event.value);
1370
+ const inputValue = match(prop("selectionBehavior"), {
1371
+ preserve: context.get("inputValue"),
1372
+ replace: prop("collection").stringifyMany(event.value),
1373
+ clear: ""
1374
+ });
1375
+ context.set("inputValue", inputValue);
1376
+ });
1377
+ },
1378
+ clearSelectedItems(params) {
1379
+ const { context, flush, prop } = params;
1380
+ flush(() => {
1381
+ context.set("value", []);
1382
+ const inputValue = match(prop("selectionBehavior"), {
1383
+ preserve: context.get("inputValue"),
1384
+ replace: prop("collection").stringifyMany([]),
1385
+ clear: ""
1386
+ });
1387
+ context.set("inputValue", inputValue);
1388
+ });
1389
+ },
1390
+ scrollContentToTop({ prop, scope }) {
1391
+ const scrollToIndexFn = prop("scrollToIndexFn");
1392
+ if (scrollToIndexFn) {
1393
+ const firstValue = prop("collection").firstValue;
1394
+ scrollToIndexFn({
1395
+ index: 0,
1396
+ immediate: true,
1397
+ getElement: () => getItemEl(scope, firstValue)
1398
+ });
1399
+ } else {
1400
+ const contentEl = getContentEl(scope);
1401
+ if (!contentEl) return;
1402
+ contentEl.scrollTop = 0;
1403
+ }
1404
+ },
1405
+ invokeOnOpen({ prop, event, context }) {
1406
+ const reason = getOpenChangeReason(event);
1407
+ prop("onOpenChange")?.({
1408
+ open: true,
1409
+ reason,
1410
+ value: context.get("value")
1411
+ });
1412
+ },
1413
+ invokeOnClose({ prop, event, context }) {
1414
+ const reason = getOpenChangeReason(event);
1415
+ prop("onOpenChange")?.({
1416
+ open: false,
1417
+ reason,
1418
+ value: context.get("value")
1419
+ });
1420
+ },
1421
+ highlightFirstItem({ context, prop, scope }) {
1422
+ (getContentEl(scope) ? queueMicrotask : raf)(() => {
1423
+ const value = prop("collection").firstValue;
1424
+ if (value) context.set("highlightedValue", value);
1425
+ });
1426
+ },
1427
+ highlightFirstItemIfNeeded({ computed, action }) {
1428
+ if (!computed("autoHighlight")) return;
1429
+ action(["highlightFirstItem"]);
1430
+ },
1431
+ highlightLastItem({ context, prop, scope }) {
1432
+ (getContentEl(scope) ? queueMicrotask : raf)(() => {
1433
+ const value = prop("collection").lastValue;
1434
+ if (value) context.set("highlightedValue", value);
1435
+ });
1436
+ },
1437
+ highlightNextItem({ context, prop }) {
1438
+ let value = null;
1439
+ const highlightedValue = context.get("highlightedValue");
1440
+ const collection$1 = prop("collection");
1441
+ if (highlightedValue) {
1442
+ value = collection$1.getNextValue(highlightedValue);
1443
+ if (!value && prop("loopFocus")) value = collection$1.firstValue;
1444
+ } else value = collection$1.firstValue;
1445
+ if (value) context.set("highlightedValue", value);
1446
+ },
1447
+ highlightPrevItem({ context, prop }) {
1448
+ let value = null;
1449
+ const highlightedValue = context.get("highlightedValue");
1450
+ const collection$1 = prop("collection");
1451
+ if (highlightedValue) {
1452
+ value = collection$1.getPreviousValue(highlightedValue);
1453
+ if (!value && prop("loopFocus")) value = collection$1.lastValue;
1454
+ } else value = collection$1.lastValue;
1455
+ if (value) context.set("highlightedValue", value);
1456
+ },
1457
+ highlightFirstSelectedItem({ context, prop }) {
1458
+ raf(() => {
1459
+ const [value] = prop("collection").sort(context.get("value"));
1460
+ if (value) context.set("highlightedValue", value);
1461
+ });
1462
+ },
1463
+ highlightFirstOrSelectedItem({ context, prop, computed }) {
1464
+ raf(() => {
1465
+ let value = null;
1466
+ if (computed("hasSelectedItems")) value = prop("collection").sort(context.get("value"))[0];
1467
+ else value = prop("collection").firstValue;
1468
+ if (value) context.set("highlightedValue", value);
1469
+ });
1470
+ },
1471
+ highlightLastOrSelectedItem({ context, prop, computed }) {
1472
+ raf(() => {
1473
+ const collection$1 = prop("collection");
1474
+ let value = null;
1475
+ if (computed("hasSelectedItems")) value = collection$1.sort(context.get("value"))[0];
1476
+ else value = collection$1.lastValue;
1477
+ if (value) context.set("highlightedValue", value);
1478
+ });
1479
+ },
1480
+ autofillInputValue({ context, computed, prop, event, scope }) {
1481
+ const inputEl = getInputEl(scope);
1482
+ const collection$1 = prop("collection");
1483
+ if (!computed("autoComplete") || !inputEl || !event.keypress) return;
1484
+ const valueText = collection$1.stringify(context.get("highlightedValue"));
1485
+ raf(() => {
1486
+ inputEl.value = valueText || context.get("inputValue");
1487
+ });
1488
+ },
1489
+ syncSelectedItems(params) {
1490
+ queueMicrotask(() => {
1491
+ const { context, prop } = params;
1492
+ const collection$1 = prop("collection");
1493
+ const value = context.get("value");
1494
+ const selectedItems = value.map((v) => {
1495
+ return context.get("selectedItems").find((item) => collection$1.getItemValue(item) === v) || collection$1.find(v);
1496
+ });
1497
+ context.set("selectedItems", selectedItems);
1498
+ const inputValue = match(prop("selectionBehavior"), {
1499
+ preserve: context.get("inputValue"),
1500
+ replace: collection$1.stringifyMany(value),
1501
+ clear: ""
1502
+ });
1503
+ context.set("inputValue", inputValue);
1504
+ });
1505
+ },
1506
+ syncHighlightedItem({ context, prop }) {
1507
+ const item = prop("collection").find(context.get("highlightedValue"));
1508
+ context.set("highlightedItem", item);
1509
+ },
1510
+ toggleVisibility({ event, send, prop }) {
1511
+ send({
1512
+ type: prop("open") ? "CONTROLLED.OPEN" : "CONTROLLED.CLOSE",
1513
+ previousEvent: event
1514
+ });
1515
+ }
1516
+ }
1517
+ }
1518
+ });
1519
+ function getOpenChangeReason(event) {
1520
+ return (event.previousEvent || event).src;
1521
+ }
1522
+
1523
+ //#endregion
1524
+ //#region src/machines/combobox/combobox.props.ts
1525
+ const props = createProps()([
1526
+ "allowCustomValue",
1527
+ "autoFocus",
1528
+ "closeOnSelect",
1529
+ "collection",
1530
+ "composite",
1531
+ "defaultHighlightedValue",
1532
+ "defaultInputValue",
1533
+ "defaultOpen",
1534
+ "defaultValue",
1535
+ "dir",
1536
+ "disabled",
1537
+ "disableLayer",
1538
+ "form",
1539
+ "getRootNode",
1540
+ "highlightedValue",
1541
+ "id",
1542
+ "ids",
1543
+ "inputBehavior",
1544
+ "inputValue",
1545
+ "invalid",
1546
+ "loopFocus",
1547
+ "multiple",
1548
+ "name",
1549
+ "navigate",
1550
+ "onFocusOutside",
1551
+ "onHighlightChange",
1552
+ "onInputValueChange",
1553
+ "onInteractOutside",
1554
+ "onOpenChange",
1555
+ "onOpenChange",
1556
+ "onPointerDownOutside",
1557
+ "onSelect",
1558
+ "onValueChange",
1559
+ "open",
1560
+ "openOnChange",
1561
+ "openOnClick",
1562
+ "openOnKeyPress",
1563
+ "placeholder",
1564
+ "positioning",
1565
+ "readOnly",
1566
+ "required",
1567
+ "scrollToIndexFn",
1568
+ "selectionBehavior",
1569
+ "translations",
1570
+ "value",
1571
+ "alwaysSubmitOnEnter"
1572
+ ]);
1573
+ const splitProps = createSplitProps(props);
1574
+ const itemGroupLabelProps = createProps()(["htmlFor"]);
1575
+ const splitItemGroupLabelProps = createSplitProps(itemGroupLabelProps);
1576
+ const itemGroupProps = createProps()(["id"]);
1577
+ const splitItemGroupProps = createSplitProps(itemGroupProps);
1578
+ const itemProps = createProps()(["item", "persistFocus"]);
1579
+ const splitItemProps = createSplitProps(itemProps);
1580
+
1581
+ //#endregion
1582
+ export { anatomy, collection, connect, itemGroupLabelProps, itemGroupProps, itemProps, machine, props, splitItemGroupLabelProps, splitItemGroupProps, splitItemProps, splitProps };