@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.
- package/dist/anatomy-DMuSMbOP.d.cts +18 -0
- package/dist/anatomy-DMuSMbOP.d.ts +18 -0
- package/dist/anatomy.cjs +3 -0
- package/dist/anatomy.d.cts +2 -0
- package/dist/anatomy.d.ts +2 -0
- package/dist/anatomy.js +2 -0
- package/dist/angle-3hqP0Mp5.cjs +13 -0
- package/dist/angle-oNt8uGHQ.js +8 -0
- package/dist/aria-hidden-CEXexb2I.js +127 -0
- package/dist/aria-hidden-Y7iJHPMr.cjs +132 -0
- package/dist/aria-hidden.cjs +3 -0
- package/dist/aria-hidden.d.cts +10 -0
- package/dist/aria-hidden.d.ts +10 -0
- package/dist/aria-hidden.js +2 -0
- package/dist/array-BGtygd0o.cjs +198 -0
- package/dist/array-C4KbHsha.js +73 -0
- package/dist/auto-resize-5F5iiKZb.cjs +106 -0
- package/dist/auto-resize-KkNfCcBt.js +95 -0
- package/dist/auto-resize.cjs +4 -0
- package/dist/auto-resize.d.cts +7 -0
- package/dist/auto-resize.d.ts +7 -0
- package/dist/auto-resize.js +2 -0
- package/dist/caret-CHqaP4XG.cjs +30 -0
- package/dist/caret-aiDJ6mAS.js +19 -0
- package/dist/closest-Clo6ODcK.js +117 -0
- package/dist/closest-IiRz1GIJ.cjs +176 -0
- package/dist/collection-CJU0oDtX.js +1295 -0
- package/dist/collection-CwzUJwBJ.cjs +1342 -0
- package/dist/collection.cjs +15 -0
- package/dist/collection.d.cts +34 -0
- package/dist/collection.d.ts +34 -0
- package/dist/collection.js +3 -0
- package/dist/color-CsugZjq6.d.cts +60 -0
- package/dist/color-CsugZjq6.d.ts +60 -0
- package/dist/color-utils-DzeOVYlL.cjs +662 -0
- package/dist/color-utils-lDDg9FEh.js +639 -0
- package/dist/color-utils.cjs +6 -0
- package/dist/color-utils.d.cts +18 -0
- package/dist/color-utils.d.ts +18 -0
- package/dist/color-utils.js +2 -0
- package/dist/computed-style-B1MKlCoo.js +9 -0
- package/dist/computed-style-DLArEFNw.cjs +14 -0
- package/dist/controller-B8E8ZJCI.cjs +133 -0
- package/dist/controller-Dv7lWHDr.js +92 -0
- package/dist/core-BF6G2RiC.d.cts +1 -0
- package/dist/core-BNMw-JId.cjs +372 -0
- package/dist/core-BdeZuSX6.d.ts +1 -0
- package/dist/core-CJ0MZr3D.js +289 -0
- package/dist/core.cjs +19 -0
- package/dist/core.d.cts +3 -0
- package/dist/core.d.ts +3 -0
- package/dist/core.js +3 -0
- package/dist/create-anatomy-B2q3wiaw.js +22 -0
- package/dist/create-anatomy-BwDn25ph.cjs +27 -0
- package/dist/create-props-CgtcN_Qu.js +4 -0
- package/dist/create-props-CjLx2oS8.cjs +9 -0
- package/dist/data-url-C-Uk31Q9.cjs +42 -0
- package/dist/data-url-DHUHj7UF.js +37 -0
- package/dist/data-url-Gx_SWG-k.d.cts +10 -0
- package/dist/data-url-Gx_SWG-k.d.ts +10 -0
- package/dist/date-utils-D-JJHedx.cjs +868 -0
- package/dist/date-utils-D5zXW-Cs.js +569 -0
- package/dist/date-utils.cjs +52 -0
- package/dist/date-utils.d.cts +7 -0
- package/dist/date-utils.d.ts +7 -0
- package/dist/date-utils.js +2 -0
- package/dist/dismissable-C0bixtzl.cjs +348 -0
- package/dist/dismissable-KM1jPtNQ.js +337 -0
- package/dist/dismissable-layer-BTX5EvXw.d.ts +40 -0
- package/dist/dismissable-layer-Ch5niVaq.d.cts +40 -0
- package/dist/dismissable.cjs +4 -0
- package/dist/dismissable.d.cts +3 -0
- package/dist/dismissable.d.ts +3 -0
- package/dist/dismissable.js +2 -0
- package/dist/dom-query-CQzY93XU.cjs +488 -0
- package/dist/dom-query-e7fh0TEH.js +243 -0
- package/dist/dom-query.cjs +180 -0
- package/dist/dom-query.d.cts +142 -0
- package/dist/dom-query.d.ts +142 -0
- package/dist/dom-query.js +43 -0
- package/dist/equal-C927y7MN.cjs +30 -0
- package/dist/equal-DtrP8DPh.js +25 -0
- package/dist/event-DDz-mMhM.cjs +242 -0
- package/dist/event-bTItRgiw.js +117 -0
- package/dist/file-utils-6EXCdfHx.js +116 -0
- package/dist/file-utils-B7OJigQq.cjs +151 -0
- package/dist/file-utils.cjs +92 -0
- package/dist/file-utils.d.cts +40 -0
- package/dist/file-utils.d.ts +40 -0
- package/dist/file-utils.js +82 -0
- package/dist/focus-trap-89E5I9nm.js +487 -0
- package/dist/focus-trap-D7jKsfHW.cjs +498 -0
- package/dist/focus-trap.cjs +4 -0
- package/dist/focus-trap.d.cts +89 -0
- package/dist/focus-trap.d.ts +89 -0
- package/dist/focus-trap.js +2 -0
- package/dist/focus-visible-DWdQf__4.js +176 -0
- package/dist/focus-visible-G4cmlWqq.cjs +217 -0
- package/dist/focus-visible.cjs +9 -0
- package/dist/focus-visible.d.cts +32 -0
- package/dist/focus-visible.d.ts +32 -0
- package/dist/focus-visible.js +2 -0
- package/dist/form-B1DW_w_3.js +89 -0
- package/dist/form-CoupKpuP.cjs +130 -0
- package/dist/from-window-5ZhzSURC.js +68 -0
- package/dist/from-window-B9DKtaoR.cjs +115 -0
- package/dist/functions-isw5Ovcx.d.cts +16 -0
- package/dist/functions-isw5Ovcx.d.ts +16 -0
- package/dist/highlight-word.cjs +95 -0
- package/dist/highlight-word.d.cts +24 -0
- package/dist/highlight-word.d.ts +24 -0
- package/dist/highlight-word.js +94 -0
- package/dist/hotkeys.cjs +1183 -0
- package/dist/hotkeys.d.cts +199 -0
- package/dist/hotkeys.d.ts +199 -0
- package/dist/hotkeys.js +1173 -0
- package/dist/i18n-utils-BD4VtonY.cjs +345 -0
- package/dist/i18n-utils-C4FQZ39m.js +280 -0
- package/dist/i18n-utils.cjs +216 -0
- package/dist/i18n-utils.d.cts +71 -0
- package/dist/i18n-utils.d.ts +71 -0
- package/dist/i18n-utils.js +204 -0
- package/dist/index-3tNJficI.d.cts +117 -0
- package/dist/index-3tNJficI.d.ts +117 -0
- package/dist/index-BEfvdGE2.d.cts +116 -0
- package/dist/index-BEfvdGE2.d.ts +116 -0
- package/dist/index-BF6G2RiC.d.cts +1 -0
- package/dist/index-BKgxIVbE.d.cts +285 -0
- package/dist/index-BMtpmaRD.d.cts +16 -0
- package/dist/index-BMtpmaRD.d.ts +16 -0
- package/dist/index-BWiYePx8.d.cts +216 -0
- package/dist/index-BXfunVyD.d.cts +1342 -0
- package/dist/index-BXfunVyD.d.ts +1342 -0
- package/dist/index-BdeZuSX6.d.ts +1 -0
- package/dist/index-C2865AJq.d.cts +25 -0
- package/dist/index-C2865AJq.d.ts +25 -0
- package/dist/index-CFoN0L3C.d.ts +285 -0
- package/dist/index-vPrqYDHu.d.ts +216 -0
- package/dist/index.cjs +19 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/initial-focus-BQxRRFPa.cjs +37 -0
- package/dist/initial-focus-BrN5tT2X.js +26 -0
- package/dist/interact-outside-BjqIunFx.js +211 -0
- package/dist/interact-outside-Dphjr2Zh.cjs +216 -0
- package/dist/interact-outside.cjs +3 -0
- package/dist/interact-outside.d.cts +2 -0
- package/dist/interact-outside.d.ts +2 -0
- package/dist/interact-outside.js +2 -0
- package/dist/json-tree-utils.cjs +1518 -0
- package/dist/json-tree-utils.d.cts +117 -0
- package/dist/json-tree-utils.d.ts +117 -0
- package/dist/json-tree-utils.js +1469 -0
- package/dist/list-collection-D_eNKrot.d.cts +60 -0
- package/dist/list-collection-RqYEWHb4.d.ts +60 -0
- package/dist/live-region-BD0OgmrH.cjs +68 -0
- package/dist/live-region-F8YMmbrY.js +63 -0
- package/dist/live-region.cjs +3 -0
- package/dist/live-region.d.cts +2 -0
- package/dist/live-region.d.ts +2 -0
- package/dist/live-region.js +2 -0
- package/dist/machines/accordion/index.cjs +328 -0
- package/dist/machines/accordion/index.d.cts +83 -0
- package/dist/machines/accordion/index.d.ts +83 -0
- package/dist/machines/accordion/index.js +321 -0
- package/dist/machines/angle-slider/index.cjs +420 -0
- package/dist/machines/angle-slider/index.d.cts +84 -0
- package/dist/machines/angle-slider/index.d.ts +84 -0
- package/dist/machines/angle-slider/index.js +415 -0
- package/dist/machines/async-list/index.cjs +310 -0
- package/dist/machines/async-list/index.d.cts +90 -0
- package/dist/machines/async-list/index.d.ts +90 -0
- package/dist/machines/async-list/index.js +308 -0
- package/dist/machines/avatar/index.cjs +165 -0
- package/dist/machines/avatar/index.d.cts +63 -0
- package/dist/machines/avatar/index.d.ts +63 -0
- package/dist/machines/avatar/index.js +160 -0
- package/dist/machines/carousel/index.cjs +929 -0
- package/dist/machines/carousel/index.d.cts +146 -0
- package/dist/machines/carousel/index.d.ts +146 -0
- package/dist/machines/carousel/index.js +920 -0
- package/dist/machines/cascade-select/index.cjs +1426 -0
- package/dist/machines/cascade-select/index.d.cts +167 -0
- package/dist/machines/cascade-select/index.d.ts +167 -0
- package/dist/machines/cascade-select/index.js +1419 -0
- package/dist/machines/checkbox/index.cjs +316 -0
- package/dist/machines/checkbox/index.d.cts +81 -0
- package/dist/machines/checkbox/index.d.ts +81 -0
- package/dist/machines/checkbox/index.js +311 -0
- package/dist/machines/clipboard/index.cjs +228 -0
- package/dist/machines/clipboard/index.d.cts +72 -0
- package/dist/machines/clipboard/index.d.ts +72 -0
- package/dist/machines/clipboard/index.js +221 -0
- package/dist/machines/collapsible/index.cjs +363 -0
- package/dist/machines/collapsible/index.d.cts +82 -0
- package/dist/machines/collapsible/index.d.ts +82 -0
- package/dist/machines/collapsible/index.js +358 -0
- package/dist/machines/color-picker/index.cjs +1534 -0
- package/dist/machines/color-picker/index.d.cts +207 -0
- package/dist/machines/color-picker/index.d.ts +207 -0
- package/dist/machines/color-picker/index.js +1518 -0
- package/dist/machines/combobox/index.cjs +1554 -0
- package/dist/machines/combobox/index.d.cts +219 -0
- package/dist/machines/combobox/index.d.ts +219 -0
- package/dist/machines/combobox/index.js +1542 -0
- package/dist/machines/date-input/index.cjs +1974 -0
- package/dist/machines/date-input/index.d.cts +230 -0
- package/dist/machines/date-input/index.d.ts +230 -0
- package/dist/machines/date-input/index.js +1958 -0
- package/dist/machines/date-picker/index.cjs +2424 -0
- package/dist/machines/date-picker/index.d.cts +378 -0
- package/dist/machines/date-picker/index.d.ts +378 -0
- package/dist/machines/date-picker/index.js +2408 -0
- package/dist/machines/dialog/index.cjs +378 -0
- package/dist/machines/dialog/index.d.cts +94 -0
- package/dist/machines/dialog/index.d.ts +94 -0
- package/dist/machines/dialog/index.js +373 -0
- package/dist/machines/drawer/index.cjs +2066 -0
- package/dist/machines/drawer/index.d.cts +334 -0
- package/dist/machines/drawer/index.d.ts +334 -0
- package/dist/machines/drawer/index.js +2059 -0
- package/dist/machines/editable/index.cjs +550 -0
- package/dist/machines/editable/index.d.cts +114 -0
- package/dist/machines/editable/index.d.ts +114 -0
- package/dist/machines/editable/index.js +545 -0
- package/dist/machines/file-upload/index.cjs +648 -0
- package/dist/machines/file-upload/index.d.cts +150 -0
- package/dist/machines/file-upload/index.d.ts +150 -0
- package/dist/machines/file-upload/index.js +641 -0
- package/dist/machines/floating-panel/index.cjs +1020 -0
- package/dist/machines/floating-panel/index.d.cts +149 -0
- package/dist/machines/floating-panel/index.d.ts +149 -0
- package/dist/machines/floating-panel/index.js +1012 -0
- package/dist/machines/hover-card/index.cjs +441 -0
- package/dist/machines/hover-card/index.d.cts +82 -0
- package/dist/machines/hover-card/index.d.ts +82 -0
- package/dist/machines/hover-card/index.js +436 -0
- package/dist/machines/image-cropper/index.cjs +2082 -0
- package/dist/machines/image-cropper/index.d.cts +182 -0
- package/dist/machines/image-cropper/index.d.ts +182 -0
- package/dist/machines/image-cropper/index.js +2076 -0
- package/dist/machines/listbox/index.cjs +873 -0
- package/dist/machines/listbox/index.d.cts +175 -0
- package/dist/machines/listbox/index.d.ts +175 -0
- package/dist/machines/listbox/index.js +860 -0
- package/dist/machines/marquee/index.cjs +387 -0
- package/dist/machines/marquee/index.d.cts +102 -0
- package/dist/machines/marquee/index.d.ts +102 -0
- package/dist/machines/marquee/index.js +382 -0
- package/dist/machines/menu/index.cjs +1562 -0
- package/dist/machines/menu/index.d.cts +188 -0
- package/dist/machines/menu/index.d.ts +188 -0
- package/dist/machines/menu/index.js +1549 -0
- package/dist/machines/navigation-menu/index.cjs +860 -0
- package/dist/machines/navigation-menu/index.d.cts +131 -0
- package/dist/machines/navigation-menu/index.d.ts +131 -0
- package/dist/machines/navigation-menu/index.js +855 -0
- package/dist/machines/number-input/index.cjs +1014 -0
- package/dist/machines/number-input/index.d.cts +136 -0
- package/dist/machines/number-input/index.d.ts +136 -0
- package/dist/machines/number-input/index.js +1009 -0
- package/dist/machines/pagination/index.cjs +413 -0
- package/dist/machines/pagination/index.d.cts +139 -0
- package/dist/machines/pagination/index.d.ts +139 -0
- package/dist/machines/pagination/index.js +404 -0
- package/dist/machines/password-input/index.cjs +224 -0
- package/dist/machines/password-input/index.d.cts +71 -0
- package/dist/machines/password-input/index.d.ts +71 -0
- package/dist/machines/password-input/index.js +219 -0
- package/dist/machines/pin-input/index.cjs +595 -0
- package/dist/machines/pin-input/index.d.cts +107 -0
- package/dist/machines/pin-input/index.d.ts +107 -0
- package/dist/machines/pin-input/index.js +590 -0
- package/dist/machines/popover/index.cjs +516 -0
- package/dist/machines/popover/index.d.cts +107 -0
- package/dist/machines/popover/index.d.ts +107 -0
- package/dist/machines/popover/index.js +511 -0
- package/dist/machines/presence/index.cjs +193 -0
- package/dist/machines/presence/index.d.cts +44 -0
- package/dist/machines/presence/index.d.ts +44 -0
- package/dist/machines/presence/index.js +190 -0
- package/dist/machines/progress/index.cjs +282 -0
- package/dist/machines/progress/index.d.cts +96 -0
- package/dist/machines/progress/index.d.ts +96 -0
- package/dist/machines/progress/index.js +277 -0
- package/dist/machines/qr-code/index.cjs +167 -0
- package/dist/machines/qr-code/index.d.cts +71 -0
- package/dist/machines/qr-code/index.d.ts +71 -0
- package/dist/machines/qr-code/index.js +162 -0
- package/dist/machines/radio-group/index.cjs +465 -0
- package/dist/machines/radio-group/index.d.cts +218 -0
- package/dist/machines/radio-group/index.d.ts +218 -0
- package/dist/machines/radio-group/index.js +458 -0
- package/dist/machines/rating-group/index.cjs +405 -0
- package/dist/machines/rating-group/index.d.cts +101 -0
- package/dist/machines/rating-group/index.d.ts +101 -0
- package/dist/machines/rating-group/index.js +398 -0
- package/dist/machines/scroll-area/index.cjs +865 -0
- package/dist/machines/scroll-area/index.d.cts +126 -0
- package/dist/machines/scroll-area/index.d.ts +126 -0
- package/dist/machines/scroll-area/index.js +860 -0
- package/dist/machines/select/index.cjs +1226 -0
- package/dist/machines/select/index.d.cts +190 -0
- package/dist/machines/select/index.d.ts +190 -0
- package/dist/machines/select/index.js +1214 -0
- package/dist/machines/signature-pad/index.cjs +337 -0
- package/dist/machines/signature-pad/index.d.cts +108 -0
- package/dist/machines/signature-pad/index.d.ts +108 -0
- package/dist/machines/signature-pad/index.js +330 -0
- package/dist/machines/slider/index.cjs +1103 -0
- package/dist/machines/slider/index.d.cts +154 -0
- package/dist/machines/slider/index.d.ts +154 -0
- package/dist/machines/slider/index.js +1094 -0
- package/dist/machines/splitter/index.cjs +1686 -0
- package/dist/machines/splitter/index.d.cts +282 -0
- package/dist/machines/splitter/index.d.ts +282 -0
- package/dist/machines/splitter/index.js +1675 -0
- package/dist/machines/steps/index.cjs +330 -0
- package/dist/machines/steps/index.d.cts +109 -0
- package/dist/machines/steps/index.d.ts +109 -0
- package/dist/machines/steps/index.js +325 -0
- package/dist/machines/switch/index.cjs +307 -0
- package/dist/machines/switch/index.d.cts +80 -0
- package/dist/machines/switch/index.d.ts +80 -0
- package/dist/machines/switch/index.js +302 -0
- package/dist/machines/tabs/index.cjs +542 -0
- package/dist/machines/tabs/index.d.cts +113 -0
- package/dist/machines/tabs/index.d.ts +113 -0
- package/dist/machines/tabs/index.js +533 -0
- package/dist/machines/tags-input/index.cjs +1151 -0
- package/dist/machines/tags-input/index.d.cts +182 -0
- package/dist/machines/tags-input/index.d.ts +182 -0
- package/dist/machines/tags-input/index.js +1144 -0
- package/dist/machines/timer/index.cjs +329 -0
- package/dist/machines/timer/index.d.cts +102 -0
- package/dist/machines/timer/index.d.ts +102 -0
- package/dist/machines/timer/index.js +323 -0
- package/dist/machines/toast/index.cjs +1185 -0
- package/dist/machines/toast/index.d.cts +204 -0
- package/dist/machines/toast/index.d.ts +204 -0
- package/dist/machines/toast/index.js +1180 -0
- package/dist/machines/toc/index.cjs +358 -0
- package/dist/machines/toc/index.d.cts +98 -0
- package/dist/machines/toc/index.d.ts +98 -0
- package/dist/machines/toc/index.js +351 -0
- package/dist/machines/toggle/index.cjs +99 -0
- package/dist/machines/toggle/index.d.cts +46 -0
- package/dist/machines/toggle/index.d.ts +46 -0
- package/dist/machines/toggle/index.js +94 -0
- package/dist/machines/toggle-group/index.cjs +329 -0
- package/dist/machines/toggle-group/index.d.cts +81 -0
- package/dist/machines/toggle-group/index.d.ts +81 -0
- package/dist/machines/toggle-group/index.js +322 -0
- package/dist/machines/tooltip/index.cjs +638 -0
- package/dist/machines/tooltip/index.d.cts +84 -0
- package/dist/machines/tooltip/index.d.ts +84 -0
- package/dist/machines/tooltip/index.js +633 -0
- package/dist/machines/tour/index.cjs +1123 -0
- package/dist/machines/tour/index.d.cts +207 -0
- package/dist/machines/tour/index.d.ts +207 -0
- package/dist/machines/tour/index.js +1115 -0
- package/dist/machines/tree-view/index.cjs +1288 -0
- package/dist/machines/tree-view/index.d.cts +221 -0
- package/dist/machines/tree-view/index.d.ts +221 -0
- package/dist/machines/tree-view/index.js +1279 -0
- package/dist/mutation-observer-_LbwtN3W.cjs +61 -0
- package/dist/mutation-observer-qObPUo3D.js +50 -0
- package/dist/navigate-CJOaL3vx.js +31 -0
- package/dist/navigate-uJG-006f.cjs +42 -0
- package/dist/overflow-BBihfMxX.cjs +67 -0
- package/dist/overflow-C-zO1CWA.js +44 -0
- package/dist/platform-BDB0wXUk.js +26 -0
- package/dist/platform-BZS-dkZN.cjs +109 -0
- package/dist/point-C9A4dk1i.js +27 -0
- package/dist/point-DxnCrJBy.cjs +32 -0
- package/dist/pointer-lock-BvfSjt_s.cjs +31 -0
- package/dist/pointer-lock-WezxTqu-.js +26 -0
- package/dist/pointer-move-CGzan38r.cjs +42 -0
- package/dist/pointer-move-Tijb8Ptk.js +37 -0
- package/dist/polygon-BvdwYRBw.js +76 -0
- package/dist/polygon-CTR1kEoU.cjs +93 -0
- package/dist/popper-DkAAS9VE.cjs +487 -0
- package/dist/popper-DzBZzAe4.js +464 -0
- package/dist/popper.cjs +6 -0
- package/dist/popper.d.cts +2 -0
- package/dist/popper.d.ts +2 -0
- package/dist/popper.js +2 -0
- package/dist/press-B7XLrLGR.js +65 -0
- package/dist/press-BdD5suLQ.cjs +70 -0
- package/dist/proxy-tab-focus-DWMXvAfO.js +54 -0
- package/dist/proxy-tab-focus-NthYgHdY.cjs +59 -0
- package/dist/raf-BSDcY4UD.cjs +85 -0
- package/dist/raf-DgINgykK.d.cts +15 -0
- package/dist/raf-DgINgykK.d.ts +15 -0
- package/dist/raf-Dhvm7f1e.js +62 -0
- package/dist/rect-utils-DiT4k3jS.cjs +548 -0
- package/dist/rect-utils-d_3gZVsc.js +459 -0
- package/dist/rect-utils.cjs +165 -0
- package/dist/rect-utils.d.cts +197 -0
- package/dist/rect-utils.d.ts +197 -0
- package/dist/rect-utils.js +116 -0
- package/dist/remove-scroll-DTVA5f4w.cjs +86 -0
- package/dist/remove-scroll-WEheFCiq.js +81 -0
- package/dist/remove-scroll.cjs +3 -0
- package/dist/remove-scroll.d.cts +4 -0
- package/dist/remove-scroll.d.ts +4 -0
- package/dist/remove-scroll.js +2 -0
- package/dist/rolldown-runtime-D6vf50IK.cjs +28 -0
- package/dist/scale-C5BBHVgH.js +17 -0
- package/dist/scale-C7iiUGhS.cjs +22 -0
- package/dist/scope-CysKlKe9.cjs +28 -0
- package/dist/scope-D1873Mzi.js +23 -0
- package/dist/scroll-CVJ40w2e.js +46 -0
- package/dist/scroll-Dyd1QLrc.cjs +63 -0
- package/dist/scroll-snap-Cuaqdevf.cjs +224 -0
- package/dist/scroll-snap-DqMiFASa.js +201 -0
- package/dist/scroll-snap.cjs +6 -0
- package/dist/scroll-snap.d.cts +14 -0
- package/dist/scroll-snap.d.ts +14 -0
- package/dist/scroll-snap.js +2 -0
- package/dist/selection-ClKhnWit.d.cts +49 -0
- package/dist/selection-DzLiSVkg.d.ts +49 -0
- package/dist/selection-map-962WvX2k.js +45 -0
- package/dist/selection-map-BwlZr1LH.cjs +68 -0
- package/dist/set-CFNGOW5W.js +50 -0
- package/dist/set-DrtWCLFb.cjs +73 -0
- package/dist/store-BLpJlMxz.js +257 -0
- package/dist/store-Btfrm2bs.cjs +47 -0
- package/dist/store-C5HvdLyc.js +42 -0
- package/dist/store-Wg8KVwNv.cjs +298 -0
- package/dist/store.cjs +9 -0
- package/dist/store.d.cts +26 -0
- package/dist/store.d.ts +26 -0
- package/dist/store.js +2 -0
- package/dist/stringify-state.cjs +48 -0
- package/dist/stringify-state.d.cts +8 -0
- package/dist/stringify-state.d.ts +8 -0
- package/dist/stringify-state.js +44 -0
- package/dist/tabbable-Bz1-1GAY.cjs +206 -0
- package/dist/tabbable-CDA1YMjZ.js +147 -0
- package/dist/text-selection-B3OQpQGy.cjs +75 -0
- package/dist/text-selection-DXvWvm6k.js +64 -0
- package/dist/timers-BRyPrXIX.js +82 -0
- package/dist/timers-Beu4SfAj.cjs +99 -0
- package/dist/tree-collection-3QX3EIhq.d.ts +77 -0
- package/dist/tree-collection-C6oDQGUJ.d.cts +77 -0
- package/dist/typeahead-DremEgML.d.cts +45 -0
- package/dist/typeahead-DremEgML.d.ts +45 -0
- package/dist/types-BFuHIo7S.js +10 -0
- package/dist/types-CczqoQLL.d.cts +57 -0
- package/dist/types-CczqoQLL.d.ts +57 -0
- package/dist/types-CjocssbC.d.cts +13 -0
- package/dist/types-CjocssbC.d.ts +13 -0
- package/dist/types-D7oF7eWh.d.cts +54 -0
- package/dist/types-D7oF7eWh.d.ts +54 -0
- package/dist/types-HCvp3Bhv.cjs +21 -0
- package/dist/types.cjs +14 -0
- package/dist/types.d.cts +6 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.js +12 -0
- package/dist/utils-BH-oBBz2.cjs +614 -0
- package/dist/utils-Cht5XaHf.js +267 -0
- package/dist/utils.cjs +95 -0
- package/dist/utils.d.cts +144 -0
- package/dist/utils.d.ts +144 -0
- package/dist/utils.js +7 -0
- package/dist/visually-hidden-BgSCFLz_.cjs +29 -0
- package/dist/visually-hidden-yDJ517KZ.js +18 -0
- package/dist/wait-for-3n85JcCU.d.cts +15 -0
- package/dist/wait-for-3n85JcCU.d.ts +15 -0
- package/dist/wait-for-CI5Ye-Lo.js +69 -0
- package/dist/wait-for-Db73VpZQ.cjs +86 -0
- package/dist/warning-CrzBpWT1.js +19 -0
- package/dist/warning-HAmFXLHm.cjs +42 -0
- package/package.json +349 -6
|
@@ -0,0 +1,1214 @@
|
|
|
1
|
+
import { t as createAnatomy } from "../../create-anatomy-B2q3wiaw.js";
|
|
2
|
+
import { E as isEditableElement, L as ariaAttr, p as contains, t as getByTypeahead, z as dataAttr } from "../../dom-query-e7fh0TEH.js";
|
|
3
|
+
import { c as getNativeEvent, r as getEventKey, s as getEventTarget } from "../../event-bTItRgiw.js";
|
|
4
|
+
import { i as markAsInternalChangeEvent, r as isInternalChangeEvent, s as trackFormControl } from "../../form-B1DW_w_3.js";
|
|
5
|
+
import { n as isValidTabEvent, t as getInitialFocus } from "../../initial-focus-BrN5tT2X.js";
|
|
6
|
+
import { i as raf } from "../../raf-Dhvm7f1e.js";
|
|
7
|
+
import { t as observeAttributes } from "../../mutation-observer-qObPUo3D.js";
|
|
8
|
+
import { n as scrollIntoView } from "../../scroll-CVJ40w2e.js";
|
|
9
|
+
import { n as visuallyHiddenStyle } from "../../visually-hidden-yDJ517KZ.js";
|
|
10
|
+
import { n as addOrRemove } from "../../array-C4KbHsha.js";
|
|
11
|
+
import { t as isEqual } from "../../equal-DtrP8DPh.js";
|
|
12
|
+
import { n as createSplitProps } from "../../utils-Cht5XaHf.js";
|
|
13
|
+
import { t as ensure } from "../../warning-CrzBpWT1.js";
|
|
14
|
+
import { s as ListCollection } from "../../collection-CJU0oDtX.js";
|
|
15
|
+
import { n as deriveSelectionState, r as resolveSelectedItems, t as createSelectedItemMap } from "../../selection-map-962WvX2k.js";
|
|
16
|
+
import { n as createGuards, r as createMachine } from "../../core-CJ0MZr3D.js";
|
|
17
|
+
import { n as trackDismissableElement } from "../../dismissable-KM1jPtNQ.js";
|
|
18
|
+
import { a as setInteractionModality, o as trackFocusVisible, t as getInteractionModality } from "../../focus-visible-DWdQf__4.js";
|
|
19
|
+
import { n as getPlacement, r as getPlacementSide, t as getPlacementStyles } from "../../popper-DzBZzAe4.js";
|
|
20
|
+
import { t as createProps } from "../../create-props-CgtcN_Qu.js";
|
|
21
|
+
//#region src/machines/select/anatomy.ts
|
|
22
|
+
const anatomy = createAnatomy("select").parts("label", "positioner", "trigger", "indicator", "clearTrigger", "item", "itemText", "itemIndicator", "itemGroup", "itemGroupLabel", "list", "content", "root", "control", "valueText");
|
|
23
|
+
const parts = anatomy.build();
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/machines/select/collection.ts
|
|
26
|
+
const collection = (options) => {
|
|
27
|
+
return new ListCollection(options);
|
|
28
|
+
};
|
|
29
|
+
collection.empty = () => {
|
|
30
|
+
return new ListCollection({ items: [] });
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/machines/select/dom.ts
|
|
34
|
+
const getRootId = (ctx) => ctx.ids?.root ?? `select:${ctx.id}`;
|
|
35
|
+
const getContentId = (ctx) => ctx.ids?.content ?? `select:${ctx.id}:content`;
|
|
36
|
+
const getTriggerId = (ctx) => ctx.ids?.trigger ?? `select:${ctx.id}:trigger`;
|
|
37
|
+
const getClearTriggerId = (ctx) => ctx.ids?.clearTrigger ?? `select:${ctx.id}:clear-trigger`;
|
|
38
|
+
const getLabelId = (ctx) => ctx.ids?.label ?? `select:${ctx.id}:label`;
|
|
39
|
+
const getControlId = (ctx) => ctx.ids?.control ?? `select:${ctx.id}:control`;
|
|
40
|
+
const getItemId = (ctx, id) => ctx.ids?.item?.(id) ?? `select:${ctx.id}:option:${id}`;
|
|
41
|
+
const getHiddenSelectId = (ctx) => ctx.ids?.hiddenSelect ?? `select:${ctx.id}:select`;
|
|
42
|
+
const getPositionerId = (ctx) => ctx.ids?.positioner ?? `select:${ctx.id}:positioner`;
|
|
43
|
+
const getItemGroupId = (ctx, id) => ctx.ids?.itemGroup?.(id) ?? `select:${ctx.id}:optgroup:${id}`;
|
|
44
|
+
const getItemGroupLabelId = (ctx, id) => ctx.ids?.itemGroupLabel?.(id) ?? `select:${ctx.id}:optgroup-label:${id}`;
|
|
45
|
+
const getHiddenSelectEl = (ctx) => ctx.getById(getHiddenSelectId(ctx));
|
|
46
|
+
const getContentEl = (ctx) => ctx.getById(getContentId(ctx));
|
|
47
|
+
const getTriggerEl = (ctx) => ctx.getById(getTriggerId(ctx));
|
|
48
|
+
const getClearTriggerEl = (ctx) => ctx.getById(getClearTriggerId(ctx));
|
|
49
|
+
const getPositionerEl = (ctx) => ctx.getById(getPositionerId(ctx));
|
|
50
|
+
const getItemEl = (ctx, id) => {
|
|
51
|
+
if (id == null) return null;
|
|
52
|
+
return ctx.getById(getItemId(ctx, id));
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/machines/select/connect.ts
|
|
56
|
+
function connect(service, normalize) {
|
|
57
|
+
const { context, prop, scope, state, computed, send } = service;
|
|
58
|
+
const translations = prop("translations");
|
|
59
|
+
const disabled = prop("disabled") || context.get("fieldsetDisabled");
|
|
60
|
+
const invalid = !!prop("invalid");
|
|
61
|
+
const required = !!prop("required");
|
|
62
|
+
const readOnly = !!prop("readOnly");
|
|
63
|
+
const composite = prop("composite");
|
|
64
|
+
const collection = prop("collection");
|
|
65
|
+
const open = state.hasTag("open");
|
|
66
|
+
const focused = state.matches("focused");
|
|
67
|
+
const highlightedValue = context.get("highlightedValue");
|
|
68
|
+
const highlightedItem = context.get("highlightedItem");
|
|
69
|
+
const selectedItems = computed("selectedItems");
|
|
70
|
+
const currentPlacement = context.get("currentPlacement");
|
|
71
|
+
const currentPlacementSide = currentPlacement ? getPlacementSide(currentPlacement) : void 0;
|
|
72
|
+
const isTypingAhead = computed("isTypingAhead");
|
|
73
|
+
const interactive = computed("isInteractive");
|
|
74
|
+
const ariaActiveDescendant = highlightedValue ? getItemId(scope, highlightedValue) : void 0;
|
|
75
|
+
function getItemState(props) {
|
|
76
|
+
const _disabled = collection.getItemDisabled(props.item);
|
|
77
|
+
const value = collection.getItemValue(props.item);
|
|
78
|
+
ensure(value, () => `[wirekyt] No value found for item ${JSON.stringify(props.item)}`);
|
|
79
|
+
return {
|
|
80
|
+
value,
|
|
81
|
+
disabled: Boolean(disabled || _disabled),
|
|
82
|
+
highlighted: highlightedValue === value,
|
|
83
|
+
selected: context.get("value").includes(value)
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const popperStyles = getPlacementStyles({
|
|
87
|
+
...prop("positioning"),
|
|
88
|
+
placement: currentPlacement
|
|
89
|
+
});
|
|
90
|
+
return {
|
|
91
|
+
open,
|
|
92
|
+
focused,
|
|
93
|
+
empty: context.get("value").length === 0,
|
|
94
|
+
highlightedItem,
|
|
95
|
+
highlightedValue,
|
|
96
|
+
selectedItems,
|
|
97
|
+
hasSelectedItems: computed("hasSelectedItems"),
|
|
98
|
+
value: context.get("value"),
|
|
99
|
+
valueAsString: computed("valueAsString"),
|
|
100
|
+
collection,
|
|
101
|
+
multiple: !!prop("multiple"),
|
|
102
|
+
disabled: !!disabled,
|
|
103
|
+
reposition(options = {}) {
|
|
104
|
+
send({
|
|
105
|
+
type: "POSITIONING.SET",
|
|
106
|
+
options
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
focus() {
|
|
110
|
+
getTriggerEl(scope)?.focus({ preventScroll: true });
|
|
111
|
+
},
|
|
112
|
+
setOpen(nextOpen) {
|
|
113
|
+
if (state.hasTag("open") === nextOpen) return;
|
|
114
|
+
send({ type: nextOpen ? "OPEN" : "CLOSE" });
|
|
115
|
+
},
|
|
116
|
+
selectValue(value) {
|
|
117
|
+
send({
|
|
118
|
+
type: "ITEM.SELECT",
|
|
119
|
+
value
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
setValue(value) {
|
|
123
|
+
send({
|
|
124
|
+
type: "VALUE.SET",
|
|
125
|
+
value
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
selectAll() {
|
|
129
|
+
send({
|
|
130
|
+
type: "VALUE.SET",
|
|
131
|
+
value: collection.getValues()
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
setHighlightValue(value) {
|
|
135
|
+
send({
|
|
136
|
+
type: "HIGHLIGHTED_VALUE.SET",
|
|
137
|
+
value
|
|
138
|
+
});
|
|
139
|
+
},
|
|
140
|
+
clearHighlightValue() {
|
|
141
|
+
send({ type: "HIGHLIGHTED_VALUE.CLEAR" });
|
|
142
|
+
},
|
|
143
|
+
clearValue(value) {
|
|
144
|
+
if (value) send({
|
|
145
|
+
type: "ITEM.CLEAR",
|
|
146
|
+
value
|
|
147
|
+
});
|
|
148
|
+
else send({ type: "VALUE.CLEAR" });
|
|
149
|
+
},
|
|
150
|
+
getItemState,
|
|
151
|
+
getRootProps() {
|
|
152
|
+
return normalize.element({
|
|
153
|
+
...parts.root.attrs,
|
|
154
|
+
dir: prop("dir"),
|
|
155
|
+
id: getRootId(scope),
|
|
156
|
+
"data-invalid": dataAttr(invalid),
|
|
157
|
+
"data-readonly": dataAttr(readOnly)
|
|
158
|
+
});
|
|
159
|
+
},
|
|
160
|
+
getLabelProps() {
|
|
161
|
+
return normalize.label({
|
|
162
|
+
dir: prop("dir"),
|
|
163
|
+
id: getLabelId(scope),
|
|
164
|
+
...parts.label.attrs,
|
|
165
|
+
"data-disabled": dataAttr(disabled),
|
|
166
|
+
"data-invalid": dataAttr(invalid),
|
|
167
|
+
"data-readonly": dataAttr(readOnly),
|
|
168
|
+
"data-required": dataAttr(required),
|
|
169
|
+
htmlFor: getHiddenSelectId(scope),
|
|
170
|
+
onClick(event) {
|
|
171
|
+
if (event.defaultPrevented) return;
|
|
172
|
+
if (disabled) return;
|
|
173
|
+
getTriggerEl(scope)?.focus({ preventScroll: true });
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
getControlProps() {
|
|
178
|
+
return normalize.element({
|
|
179
|
+
...parts.control.attrs,
|
|
180
|
+
dir: prop("dir"),
|
|
181
|
+
id: getControlId(scope),
|
|
182
|
+
"data-state": open ? "open" : "closed",
|
|
183
|
+
"data-focus": dataAttr(focused),
|
|
184
|
+
"data-disabled": dataAttr(disabled),
|
|
185
|
+
"data-invalid": dataAttr(invalid)
|
|
186
|
+
});
|
|
187
|
+
},
|
|
188
|
+
getValueTextProps() {
|
|
189
|
+
return normalize.element({
|
|
190
|
+
...parts.valueText.attrs,
|
|
191
|
+
dir: prop("dir"),
|
|
192
|
+
"data-disabled": dataAttr(disabled),
|
|
193
|
+
"data-invalid": dataAttr(invalid),
|
|
194
|
+
"data-focus": dataAttr(focused)
|
|
195
|
+
});
|
|
196
|
+
},
|
|
197
|
+
getTriggerProps() {
|
|
198
|
+
return normalize.button({
|
|
199
|
+
id: getTriggerId(scope),
|
|
200
|
+
disabled,
|
|
201
|
+
dir: prop("dir"),
|
|
202
|
+
type: "button",
|
|
203
|
+
role: "combobox",
|
|
204
|
+
"aria-controls": getContentId(scope),
|
|
205
|
+
"aria-expanded": open,
|
|
206
|
+
"aria-haspopup": "listbox",
|
|
207
|
+
"data-state": open ? "open" : "closed",
|
|
208
|
+
"aria-invalid": invalid,
|
|
209
|
+
"aria-required": required,
|
|
210
|
+
"aria-labelledby": getLabelId(scope),
|
|
211
|
+
...parts.trigger.attrs,
|
|
212
|
+
"data-disabled": dataAttr(disabled),
|
|
213
|
+
"data-invalid": dataAttr(invalid),
|
|
214
|
+
"data-readonly": dataAttr(readOnly),
|
|
215
|
+
"data-placement": currentPlacement,
|
|
216
|
+
"data-side": currentPlacementSide,
|
|
217
|
+
"data-placeholder-shown": dataAttr(!computed("hasSelectedItems")),
|
|
218
|
+
onClick(event) {
|
|
219
|
+
if (!interactive) return;
|
|
220
|
+
if (event.defaultPrevented) return;
|
|
221
|
+
send({ type: "TRIGGER.CLICK" });
|
|
222
|
+
},
|
|
223
|
+
onFocus() {
|
|
224
|
+
send({ type: "TRIGGER.FOCUS" });
|
|
225
|
+
},
|
|
226
|
+
onBlur() {
|
|
227
|
+
send({ type: "TRIGGER.BLUR" });
|
|
228
|
+
},
|
|
229
|
+
onKeyDown(event) {
|
|
230
|
+
if (event.defaultPrevented) return;
|
|
231
|
+
if (!interactive) return;
|
|
232
|
+
const exec = {
|
|
233
|
+
ArrowUp() {
|
|
234
|
+
send({ type: "TRIGGER.ARROW_UP" });
|
|
235
|
+
},
|
|
236
|
+
ArrowDown(event) {
|
|
237
|
+
send({ type: event.altKey ? "OPEN" : "TRIGGER.ARROW_DOWN" });
|
|
238
|
+
},
|
|
239
|
+
ArrowLeft() {
|
|
240
|
+
send({ type: "TRIGGER.ARROW_LEFT" });
|
|
241
|
+
},
|
|
242
|
+
ArrowRight() {
|
|
243
|
+
send({ type: "TRIGGER.ARROW_RIGHT" });
|
|
244
|
+
},
|
|
245
|
+
Home() {
|
|
246
|
+
send({ type: "TRIGGER.HOME" });
|
|
247
|
+
},
|
|
248
|
+
End() {
|
|
249
|
+
send({ type: "TRIGGER.END" });
|
|
250
|
+
},
|
|
251
|
+
Enter() {
|
|
252
|
+
send({ type: "TRIGGER.ENTER" });
|
|
253
|
+
},
|
|
254
|
+
Space(event) {
|
|
255
|
+
if (isTypingAhead) send({
|
|
256
|
+
type: "TRIGGER.TYPEAHEAD",
|
|
257
|
+
key: event.key
|
|
258
|
+
});
|
|
259
|
+
else send({ type: "TRIGGER.ENTER" });
|
|
260
|
+
}
|
|
261
|
+
}[getEventKey(event, {
|
|
262
|
+
dir: prop("dir"),
|
|
263
|
+
orientation: "vertical"
|
|
264
|
+
})];
|
|
265
|
+
if (exec) {
|
|
266
|
+
exec(event);
|
|
267
|
+
event.preventDefault();
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (getByTypeahead.isValidEvent(event)) {
|
|
271
|
+
send({
|
|
272
|
+
type: "TRIGGER.TYPEAHEAD",
|
|
273
|
+
key: event.key
|
|
274
|
+
});
|
|
275
|
+
event.preventDefault();
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
},
|
|
280
|
+
getIndicatorProps() {
|
|
281
|
+
return normalize.element({
|
|
282
|
+
...parts.indicator.attrs,
|
|
283
|
+
dir: prop("dir"),
|
|
284
|
+
"aria-hidden": true,
|
|
285
|
+
"data-state": open ? "open" : "closed",
|
|
286
|
+
"data-disabled": dataAttr(disabled),
|
|
287
|
+
"data-invalid": dataAttr(invalid),
|
|
288
|
+
"data-readonly": dataAttr(readOnly)
|
|
289
|
+
});
|
|
290
|
+
},
|
|
291
|
+
getItemProps(props) {
|
|
292
|
+
const itemState = getItemState(props);
|
|
293
|
+
return normalize.element({
|
|
294
|
+
id: getItemId(scope, itemState.value),
|
|
295
|
+
role: "option",
|
|
296
|
+
...parts.item.attrs,
|
|
297
|
+
dir: prop("dir"),
|
|
298
|
+
"data-value": itemState.value,
|
|
299
|
+
"aria-selected": itemState.selected,
|
|
300
|
+
"data-state": itemState.selected ? "checked" : "unchecked",
|
|
301
|
+
"data-highlighted": dataAttr(itemState.highlighted),
|
|
302
|
+
"data-disabled": dataAttr(itemState.disabled),
|
|
303
|
+
"aria-disabled": ariaAttr(itemState.disabled),
|
|
304
|
+
onPointerMove(event) {
|
|
305
|
+
if (itemState.disabled || event.pointerType !== "mouse") return;
|
|
306
|
+
if (itemState.value === highlightedValue) return;
|
|
307
|
+
send({
|
|
308
|
+
type: "ITEM.POINTER_MOVE",
|
|
309
|
+
value: itemState.value
|
|
310
|
+
});
|
|
311
|
+
},
|
|
312
|
+
onClick(event) {
|
|
313
|
+
if (event.defaultPrevented) return;
|
|
314
|
+
if (itemState.disabled) return;
|
|
315
|
+
send({
|
|
316
|
+
type: "ITEM.CLICK",
|
|
317
|
+
src: "pointerup",
|
|
318
|
+
value: itemState.value
|
|
319
|
+
});
|
|
320
|
+
},
|
|
321
|
+
onPointerLeave(event) {
|
|
322
|
+
if (itemState.disabled) return;
|
|
323
|
+
if (props.persistFocus) return;
|
|
324
|
+
if (event.pointerType !== "mouse") return;
|
|
325
|
+
if (!service.event.previous()?.type.includes("POINTER")) return;
|
|
326
|
+
send({ type: "ITEM.POINTER_LEAVE" });
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
},
|
|
330
|
+
getItemTextProps(props) {
|
|
331
|
+
const itemState = getItemState(props);
|
|
332
|
+
return normalize.element({
|
|
333
|
+
...parts.itemText.attrs,
|
|
334
|
+
"data-state": itemState.selected ? "checked" : "unchecked",
|
|
335
|
+
"data-disabled": dataAttr(itemState.disabled),
|
|
336
|
+
"data-highlighted": dataAttr(itemState.highlighted)
|
|
337
|
+
});
|
|
338
|
+
},
|
|
339
|
+
getItemIndicatorProps(props) {
|
|
340
|
+
const itemState = getItemState(props);
|
|
341
|
+
return normalize.element({
|
|
342
|
+
"aria-hidden": true,
|
|
343
|
+
...parts.itemIndicator.attrs,
|
|
344
|
+
"data-state": itemState.selected ? "checked" : "unchecked",
|
|
345
|
+
hidden: !itemState.selected
|
|
346
|
+
});
|
|
347
|
+
},
|
|
348
|
+
getItemGroupLabelProps(props) {
|
|
349
|
+
const { htmlFor } = props;
|
|
350
|
+
return normalize.element({
|
|
351
|
+
...parts.itemGroupLabel.attrs,
|
|
352
|
+
id: getItemGroupLabelId(scope, htmlFor),
|
|
353
|
+
dir: prop("dir"),
|
|
354
|
+
role: "presentation"
|
|
355
|
+
});
|
|
356
|
+
},
|
|
357
|
+
getItemGroupProps(props) {
|
|
358
|
+
const { id } = props;
|
|
359
|
+
return normalize.element({
|
|
360
|
+
...parts.itemGroup.attrs,
|
|
361
|
+
"data-disabled": dataAttr(disabled),
|
|
362
|
+
id: getItemGroupId(scope, id),
|
|
363
|
+
"aria-labelledby": getItemGroupLabelId(scope, id),
|
|
364
|
+
role: "group",
|
|
365
|
+
dir: prop("dir")
|
|
366
|
+
});
|
|
367
|
+
},
|
|
368
|
+
getClearTriggerProps() {
|
|
369
|
+
return normalize.button({
|
|
370
|
+
...parts.clearTrigger.attrs,
|
|
371
|
+
id: getClearTriggerId(scope),
|
|
372
|
+
type: "button",
|
|
373
|
+
"aria-label": translations.clearTriggerLabel,
|
|
374
|
+
"data-invalid": dataAttr(invalid),
|
|
375
|
+
disabled,
|
|
376
|
+
hidden: !computed("hasSelectedItems"),
|
|
377
|
+
dir: prop("dir"),
|
|
378
|
+
onClick(event) {
|
|
379
|
+
if (event.defaultPrevented) return;
|
|
380
|
+
send({ type: "CLEAR.CLICK" });
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
},
|
|
384
|
+
getHiddenSelectProps() {
|
|
385
|
+
const value = context.get("value");
|
|
386
|
+
const defaultValue = prop("multiple") ? value : value?.[0];
|
|
387
|
+
const handleChange = (e) => {
|
|
388
|
+
if (isInternalChangeEvent(getNativeEvent(e))) return;
|
|
389
|
+
send({
|
|
390
|
+
type: "VALUE.SET",
|
|
391
|
+
value: getSelectedValues(e.currentTarget)
|
|
392
|
+
});
|
|
393
|
+
};
|
|
394
|
+
return normalize.select({
|
|
395
|
+
name: prop("name"),
|
|
396
|
+
form: prop("form"),
|
|
397
|
+
disabled,
|
|
398
|
+
multiple: prop("multiple"),
|
|
399
|
+
required: prop("required"),
|
|
400
|
+
"aria-hidden": true,
|
|
401
|
+
id: getHiddenSelectId(scope),
|
|
402
|
+
defaultValue,
|
|
403
|
+
style: visuallyHiddenStyle,
|
|
404
|
+
tabIndex: -1,
|
|
405
|
+
autoComplete: prop("autoComplete"),
|
|
406
|
+
onChange: handleChange,
|
|
407
|
+
onInput: handleChange,
|
|
408
|
+
onFocus() {
|
|
409
|
+
getTriggerEl(scope)?.focus({ preventScroll: true });
|
|
410
|
+
},
|
|
411
|
+
"aria-labelledby": getLabelId(scope)
|
|
412
|
+
});
|
|
413
|
+
},
|
|
414
|
+
getPositionerProps() {
|
|
415
|
+
return normalize.element({
|
|
416
|
+
...parts.positioner.attrs,
|
|
417
|
+
dir: prop("dir"),
|
|
418
|
+
id: getPositionerId(scope),
|
|
419
|
+
style: popperStyles.floating
|
|
420
|
+
});
|
|
421
|
+
},
|
|
422
|
+
getContentProps() {
|
|
423
|
+
return normalize.element({
|
|
424
|
+
hidden: !open,
|
|
425
|
+
dir: prop("dir"),
|
|
426
|
+
id: getContentId(scope),
|
|
427
|
+
role: composite ? "listbox" : "dialog",
|
|
428
|
+
...parts.content.attrs,
|
|
429
|
+
"data-state": open ? "open" : "closed",
|
|
430
|
+
"data-placement": currentPlacement,
|
|
431
|
+
"data-side": currentPlacementSide,
|
|
432
|
+
"data-activedescendant": ariaActiveDescendant,
|
|
433
|
+
"aria-activedescendant": composite ? ariaActiveDescendant : void 0,
|
|
434
|
+
"aria-multiselectable": prop("multiple") && composite ? true : void 0,
|
|
435
|
+
"aria-labelledby": getLabelId(scope),
|
|
436
|
+
tabIndex: 0,
|
|
437
|
+
onKeyDown(event) {
|
|
438
|
+
if (!interactive) return;
|
|
439
|
+
if (!contains(event.currentTarget, getEventTarget(event))) return;
|
|
440
|
+
if (event.key === "Tab") {
|
|
441
|
+
if (!isValidTabEvent(event)) {
|
|
442
|
+
event.preventDefault();
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
const keyMap = {
|
|
447
|
+
ArrowUp() {
|
|
448
|
+
send({ type: "CONTENT.ARROW_UP" });
|
|
449
|
+
},
|
|
450
|
+
ArrowDown() {
|
|
451
|
+
send({ type: "CONTENT.ARROW_DOWN" });
|
|
452
|
+
},
|
|
453
|
+
Home() {
|
|
454
|
+
send({ type: "CONTENT.HOME" });
|
|
455
|
+
},
|
|
456
|
+
End() {
|
|
457
|
+
send({ type: "CONTENT.END" });
|
|
458
|
+
},
|
|
459
|
+
Enter() {
|
|
460
|
+
send({
|
|
461
|
+
type: "ITEM.CLICK",
|
|
462
|
+
src: "keydown.enter"
|
|
463
|
+
});
|
|
464
|
+
},
|
|
465
|
+
Space(event) {
|
|
466
|
+
if (isTypingAhead) send({
|
|
467
|
+
type: "CONTENT.TYPEAHEAD",
|
|
468
|
+
key: event.key
|
|
469
|
+
});
|
|
470
|
+
else keyMap.Enter?.(event);
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
const exec = keyMap[getEventKey(event)];
|
|
474
|
+
if (exec) {
|
|
475
|
+
exec(event);
|
|
476
|
+
event.preventDefault();
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
if (isEditableElement(getEventTarget(event))) return;
|
|
480
|
+
if (getByTypeahead.isValidEvent(event)) {
|
|
481
|
+
send({
|
|
482
|
+
type: "CONTENT.TYPEAHEAD",
|
|
483
|
+
key: event.key
|
|
484
|
+
});
|
|
485
|
+
event.preventDefault();
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
},
|
|
490
|
+
getListProps() {
|
|
491
|
+
return normalize.element({
|
|
492
|
+
...parts.list.attrs,
|
|
493
|
+
tabIndex: 0,
|
|
494
|
+
role: !composite ? "listbox" : void 0,
|
|
495
|
+
"aria-labelledby": getTriggerId(scope),
|
|
496
|
+
"aria-activedescendant": !composite ? ariaActiveDescendant : void 0,
|
|
497
|
+
"aria-multiselectable": !composite && prop("multiple") ? true : void 0
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
const getSelectedValues = (el) => {
|
|
503
|
+
return el.multiple ? Array.from(el.selectedOptions, (o) => o.value) : el.value ? [el.value] : [];
|
|
504
|
+
};
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region src/machines/select/machine.ts
|
|
507
|
+
const { and, not, or } = createGuards();
|
|
508
|
+
const machine = createMachine({
|
|
509
|
+
props({ props }) {
|
|
510
|
+
return {
|
|
511
|
+
loopFocus: false,
|
|
512
|
+
closeOnSelect: !props.multiple,
|
|
513
|
+
composite: true,
|
|
514
|
+
defaultValue: [],
|
|
515
|
+
...props,
|
|
516
|
+
collection: props.collection ?? collection.empty(),
|
|
517
|
+
translations: {
|
|
518
|
+
clearTriggerLabel: "Clear value",
|
|
519
|
+
...props.translations
|
|
520
|
+
},
|
|
521
|
+
positioning: {
|
|
522
|
+
placement: "bottom-start",
|
|
523
|
+
gutter: 8,
|
|
524
|
+
...props.positioning
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
},
|
|
528
|
+
context({ prop, bindable, getContext }) {
|
|
529
|
+
const initialValue = prop("value") ?? prop("defaultValue") ?? [];
|
|
530
|
+
const initialSelectedItems = prop("collection").findMany(initialValue);
|
|
531
|
+
return {
|
|
532
|
+
value: bindable(() => ({
|
|
533
|
+
defaultValue: prop("defaultValue"),
|
|
534
|
+
value: prop("value"),
|
|
535
|
+
isEqual,
|
|
536
|
+
onChange(value) {
|
|
537
|
+
const context = getContext();
|
|
538
|
+
const collection = prop("collection");
|
|
539
|
+
const proposed = deriveSelectionState({
|
|
540
|
+
values: value,
|
|
541
|
+
collection,
|
|
542
|
+
selectedItemMap: context.get("selectedItemMap")
|
|
543
|
+
});
|
|
544
|
+
const effectiveValue = prop("value") ?? value;
|
|
545
|
+
const effective = effectiveValue === value ? proposed : deriveSelectionState({
|
|
546
|
+
values: effectiveValue,
|
|
547
|
+
collection,
|
|
548
|
+
selectedItemMap: proposed.nextSelectedItemMap
|
|
549
|
+
});
|
|
550
|
+
context.set("selectedItemMap", effective.nextSelectedItemMap);
|
|
551
|
+
return prop("onValueChange")?.({
|
|
552
|
+
value,
|
|
553
|
+
items: proposed.selectedItems
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
})),
|
|
557
|
+
highlightedValue: bindable(() => ({
|
|
558
|
+
defaultValue: prop("defaultHighlightedValue") || null,
|
|
559
|
+
value: prop("highlightedValue"),
|
|
560
|
+
onChange(value) {
|
|
561
|
+
prop("onHighlightChange")?.({
|
|
562
|
+
highlightedValue: value,
|
|
563
|
+
highlightedItem: prop("collection").find(value),
|
|
564
|
+
highlightedIndex: prop("collection").indexOf(value)
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
})),
|
|
568
|
+
currentPlacement: bindable(() => ({ defaultValue: void 0 })),
|
|
569
|
+
fieldsetDisabled: bindable(() => ({ defaultValue: false })),
|
|
570
|
+
highlightedItem: bindable(() => ({ defaultValue: null })),
|
|
571
|
+
selectedItemMap: bindable(() => {
|
|
572
|
+
return { defaultValue: createSelectedItemMap({
|
|
573
|
+
selectedItems: initialSelectedItems,
|
|
574
|
+
collection: prop("collection")
|
|
575
|
+
}) };
|
|
576
|
+
})
|
|
577
|
+
};
|
|
578
|
+
},
|
|
579
|
+
refs() {
|
|
580
|
+
return { typeahead: { ...getByTypeahead.defaultOptions } };
|
|
581
|
+
},
|
|
582
|
+
computed: {
|
|
583
|
+
hasSelectedItems: ({ context }) => context.get("value").length > 0,
|
|
584
|
+
isTypingAhead: ({ refs }) => refs.get("typeahead").keysSoFar !== "",
|
|
585
|
+
isDisabled: ({ prop, context }) => !!prop("disabled") || !!context.get("fieldsetDisabled"),
|
|
586
|
+
isInteractive: ({ prop }) => !(prop("disabled") || prop("readOnly")),
|
|
587
|
+
selectedItems: ({ context, prop }) => resolveSelectedItems({
|
|
588
|
+
values: context.get("value"),
|
|
589
|
+
collection: prop("collection"),
|
|
590
|
+
selectedItemMap: context.get("selectedItemMap")
|
|
591
|
+
}),
|
|
592
|
+
valueAsString: ({ computed, prop }) => prop("collection").stringifyItems(computed("selectedItems"))
|
|
593
|
+
},
|
|
594
|
+
initialState({ prop }) {
|
|
595
|
+
return prop("open") || prop("defaultOpen") ? "open" : "idle";
|
|
596
|
+
},
|
|
597
|
+
entry: ["syncSelectElement"],
|
|
598
|
+
watch({ context, prop, track, action }) {
|
|
599
|
+
track([() => context.get("value").toString()], () => {
|
|
600
|
+
action([
|
|
601
|
+
"syncSelectedItems",
|
|
602
|
+
"syncSelectElement",
|
|
603
|
+
"dispatchChangeEvent"
|
|
604
|
+
]);
|
|
605
|
+
});
|
|
606
|
+
track([() => prop("open")], () => {
|
|
607
|
+
action(["toggleVisibility"]);
|
|
608
|
+
});
|
|
609
|
+
track([() => context.get("highlightedValue")], () => {
|
|
610
|
+
action(["syncHighlightedItem"]);
|
|
611
|
+
});
|
|
612
|
+
track([() => prop("collection").toString()], () => {
|
|
613
|
+
action(["syncCollection"]);
|
|
614
|
+
});
|
|
615
|
+
},
|
|
616
|
+
on: {
|
|
617
|
+
"HIGHLIGHTED_VALUE.SET": { actions: ["setHighlightedItem"] },
|
|
618
|
+
"HIGHLIGHTED_VALUE.CLEAR": { actions: ["clearHighlightedItem"] },
|
|
619
|
+
"ITEM.SELECT": { actions: ["selectItem"] },
|
|
620
|
+
"ITEM.CLEAR": { actions: ["clearItem"] },
|
|
621
|
+
"VALUE.SET": { actions: ["setSelectedItems"] },
|
|
622
|
+
"VALUE.CLEAR": { actions: ["clearSelectedItems"] },
|
|
623
|
+
"CLEAR.CLICK": { actions: ["clearSelectedItems", "focusTriggerEl"] }
|
|
624
|
+
},
|
|
625
|
+
effects: ["trackFormControlState"],
|
|
626
|
+
states: {
|
|
627
|
+
idle: {
|
|
628
|
+
tags: ["closed"],
|
|
629
|
+
on: {
|
|
630
|
+
"CONTROLLED.OPEN": [{
|
|
631
|
+
guard: "isTriggerClickEvent",
|
|
632
|
+
target: "open",
|
|
633
|
+
actions: ["setInitialFocus", "highlightFirstSelectedItem"]
|
|
634
|
+
}, {
|
|
635
|
+
target: "open",
|
|
636
|
+
actions: ["setInitialFocus"]
|
|
637
|
+
}],
|
|
638
|
+
"TRIGGER.CLICK": [{
|
|
639
|
+
guard: "isOpenControlled",
|
|
640
|
+
actions: ["invokeOnOpen"]
|
|
641
|
+
}, {
|
|
642
|
+
target: "open",
|
|
643
|
+
actions: [
|
|
644
|
+
"invokeOnOpen",
|
|
645
|
+
"setInitialFocus",
|
|
646
|
+
"highlightFirstSelectedItem"
|
|
647
|
+
]
|
|
648
|
+
}],
|
|
649
|
+
"TRIGGER.FOCUS": { target: "focused" },
|
|
650
|
+
OPEN: [{
|
|
651
|
+
guard: "isOpenControlled",
|
|
652
|
+
actions: ["invokeOnOpen"]
|
|
653
|
+
}, {
|
|
654
|
+
target: "open",
|
|
655
|
+
actions: ["setInitialFocus", "invokeOnOpen"]
|
|
656
|
+
}]
|
|
657
|
+
}
|
|
658
|
+
},
|
|
659
|
+
focused: {
|
|
660
|
+
tags: ["closed"],
|
|
661
|
+
on: {
|
|
662
|
+
"CONTROLLED.OPEN": [
|
|
663
|
+
{
|
|
664
|
+
guard: "isTriggerClickEvent",
|
|
665
|
+
target: "open",
|
|
666
|
+
actions: ["setInitialFocus", "highlightFirstSelectedItem"]
|
|
667
|
+
},
|
|
668
|
+
{
|
|
669
|
+
guard: "isTriggerArrowUpEvent",
|
|
670
|
+
target: "open",
|
|
671
|
+
actions: ["setInitialFocus", "highlightComputedLastItem"]
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
guard: or("isTriggerArrowDownEvent", "isTriggerEnterEvent"),
|
|
675
|
+
target: "open",
|
|
676
|
+
actions: ["setInitialFocus", "highlightComputedFirstItem"]
|
|
677
|
+
},
|
|
678
|
+
{
|
|
679
|
+
target: "open",
|
|
680
|
+
actions: ["setInitialFocus"]
|
|
681
|
+
}
|
|
682
|
+
],
|
|
683
|
+
OPEN: [{
|
|
684
|
+
guard: "isOpenControlled",
|
|
685
|
+
actions: ["invokeOnOpen"]
|
|
686
|
+
}, {
|
|
687
|
+
target: "open",
|
|
688
|
+
actions: ["setInitialFocus", "invokeOnOpen"]
|
|
689
|
+
}],
|
|
690
|
+
"TRIGGER.BLUR": { target: "idle" },
|
|
691
|
+
"TRIGGER.CLICK": [{
|
|
692
|
+
guard: "isOpenControlled",
|
|
693
|
+
actions: ["invokeOnOpen"]
|
|
694
|
+
}, {
|
|
695
|
+
target: "open",
|
|
696
|
+
actions: [
|
|
697
|
+
"setInitialFocus",
|
|
698
|
+
"invokeOnOpen",
|
|
699
|
+
"highlightFirstSelectedItem"
|
|
700
|
+
]
|
|
701
|
+
}],
|
|
702
|
+
"TRIGGER.ENTER": [{
|
|
703
|
+
guard: "isOpenControlled",
|
|
704
|
+
actions: ["invokeOnOpen"]
|
|
705
|
+
}, {
|
|
706
|
+
target: "open",
|
|
707
|
+
actions: [
|
|
708
|
+
"setInitialFocus",
|
|
709
|
+
"invokeOnOpen",
|
|
710
|
+
"highlightComputedFirstItem"
|
|
711
|
+
]
|
|
712
|
+
}],
|
|
713
|
+
"TRIGGER.ARROW_UP": [{
|
|
714
|
+
guard: "isOpenControlled",
|
|
715
|
+
actions: ["invokeOnOpen"]
|
|
716
|
+
}, {
|
|
717
|
+
target: "open",
|
|
718
|
+
actions: [
|
|
719
|
+
"setInitialFocus",
|
|
720
|
+
"invokeOnOpen",
|
|
721
|
+
"highlightComputedLastItem"
|
|
722
|
+
]
|
|
723
|
+
}],
|
|
724
|
+
"TRIGGER.ARROW_DOWN": [{
|
|
725
|
+
guard: "isOpenControlled",
|
|
726
|
+
actions: ["invokeOnOpen"]
|
|
727
|
+
}, {
|
|
728
|
+
target: "open",
|
|
729
|
+
actions: [
|
|
730
|
+
"setInitialFocus",
|
|
731
|
+
"invokeOnOpen",
|
|
732
|
+
"highlightComputedFirstItem"
|
|
733
|
+
]
|
|
734
|
+
}],
|
|
735
|
+
"TRIGGER.ARROW_LEFT": [{
|
|
736
|
+
guard: and(not("multiple"), "hasSelectedItems"),
|
|
737
|
+
actions: ["selectPreviousItem"]
|
|
738
|
+
}, {
|
|
739
|
+
guard: not("multiple"),
|
|
740
|
+
actions: ["selectLastItem"]
|
|
741
|
+
}],
|
|
742
|
+
"TRIGGER.ARROW_RIGHT": [{
|
|
743
|
+
guard: and(not("multiple"), "hasSelectedItems"),
|
|
744
|
+
actions: ["selectNextItem"]
|
|
745
|
+
}, {
|
|
746
|
+
guard: not("multiple"),
|
|
747
|
+
actions: ["selectFirstItem"]
|
|
748
|
+
}],
|
|
749
|
+
"TRIGGER.HOME": {
|
|
750
|
+
guard: not("multiple"),
|
|
751
|
+
actions: ["selectFirstItem"]
|
|
752
|
+
},
|
|
753
|
+
"TRIGGER.END": {
|
|
754
|
+
guard: not("multiple"),
|
|
755
|
+
actions: ["selectLastItem"]
|
|
756
|
+
},
|
|
757
|
+
"TRIGGER.TYPEAHEAD": {
|
|
758
|
+
guard: not("multiple"),
|
|
759
|
+
actions: ["selectMatchingItem"]
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
},
|
|
763
|
+
open: {
|
|
764
|
+
tags: ["open"],
|
|
765
|
+
exit: ["scrollContentToTop"],
|
|
766
|
+
effects: [
|
|
767
|
+
"trackDismissableElement",
|
|
768
|
+
"trackFocusVisible",
|
|
769
|
+
"computePlacement",
|
|
770
|
+
"scrollToHighlightedItem"
|
|
771
|
+
],
|
|
772
|
+
on: {
|
|
773
|
+
"CONTROLLED.CLOSE": [{
|
|
774
|
+
guard: "restoreFocus",
|
|
775
|
+
target: "focused",
|
|
776
|
+
actions: ["focusTriggerEl", "clearHighlightedItem"]
|
|
777
|
+
}, {
|
|
778
|
+
target: "idle",
|
|
779
|
+
actions: ["clearHighlightedItem"]
|
|
780
|
+
}],
|
|
781
|
+
CLOSE: [
|
|
782
|
+
{
|
|
783
|
+
guard: "isOpenControlled",
|
|
784
|
+
actions: ["invokeOnClose"]
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
guard: "restoreFocus",
|
|
788
|
+
target: "focused",
|
|
789
|
+
actions: [
|
|
790
|
+
"invokeOnClose",
|
|
791
|
+
"focusTriggerEl",
|
|
792
|
+
"clearHighlightedItem"
|
|
793
|
+
]
|
|
794
|
+
},
|
|
795
|
+
{
|
|
796
|
+
target: "idle",
|
|
797
|
+
actions: ["invokeOnClose", "clearHighlightedItem"]
|
|
798
|
+
}
|
|
799
|
+
],
|
|
800
|
+
"TRIGGER.CLICK": [{
|
|
801
|
+
guard: "isOpenControlled",
|
|
802
|
+
actions: ["invokeOnClose"]
|
|
803
|
+
}, {
|
|
804
|
+
target: "focused",
|
|
805
|
+
actions: ["invokeOnClose", "clearHighlightedItem"]
|
|
806
|
+
}],
|
|
807
|
+
"ITEM.CLICK": [
|
|
808
|
+
{
|
|
809
|
+
guard: and("closeOnSelect", "isOpenControlled"),
|
|
810
|
+
actions: ["selectHighlightedItem", "invokeOnClose"]
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
guard: "closeOnSelect",
|
|
814
|
+
target: "focused",
|
|
815
|
+
actions: [
|
|
816
|
+
"selectHighlightedItem",
|
|
817
|
+
"invokeOnClose",
|
|
818
|
+
"focusTriggerEl",
|
|
819
|
+
"clearHighlightedItem"
|
|
820
|
+
]
|
|
821
|
+
},
|
|
822
|
+
{ actions: ["selectHighlightedItem"] }
|
|
823
|
+
],
|
|
824
|
+
"CONTENT.HOME": { actions: ["highlightFirstItem"] },
|
|
825
|
+
"CONTENT.END": { actions: ["highlightLastItem"] },
|
|
826
|
+
"CONTENT.ARROW_DOWN": [
|
|
827
|
+
{
|
|
828
|
+
guard: and("hasHighlightedItem", "loop", "isLastItemHighlighted"),
|
|
829
|
+
actions: ["highlightFirstItem"]
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
guard: "hasHighlightedItem",
|
|
833
|
+
actions: ["highlightNextItem"]
|
|
834
|
+
},
|
|
835
|
+
{ actions: ["highlightFirstItem"] }
|
|
836
|
+
],
|
|
837
|
+
"CONTENT.ARROW_UP": [
|
|
838
|
+
{
|
|
839
|
+
guard: and("hasHighlightedItem", "loop", "isFirstItemHighlighted"),
|
|
840
|
+
actions: ["highlightLastItem"]
|
|
841
|
+
},
|
|
842
|
+
{
|
|
843
|
+
guard: "hasHighlightedItem",
|
|
844
|
+
actions: ["highlightPreviousItem"]
|
|
845
|
+
},
|
|
846
|
+
{ actions: ["highlightLastItem"] }
|
|
847
|
+
],
|
|
848
|
+
"CONTENT.TYPEAHEAD": { actions: ["highlightMatchingItem"] },
|
|
849
|
+
"ITEM.POINTER_MOVE": { actions: ["highlightItem"] },
|
|
850
|
+
"ITEM.POINTER_LEAVE": { actions: ["clearHighlightedItem"] },
|
|
851
|
+
"POSITIONING.SET": { actions: ["reposition"] }
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
},
|
|
855
|
+
implementations: {
|
|
856
|
+
guards: {
|
|
857
|
+
loop: ({ prop }) => !!prop("loopFocus"),
|
|
858
|
+
multiple: ({ prop }) => !!prop("multiple"),
|
|
859
|
+
hasSelectedItems: ({ computed }) => !!computed("hasSelectedItems"),
|
|
860
|
+
hasHighlightedItem: ({ context }) => context.get("highlightedValue") != null,
|
|
861
|
+
isFirstItemHighlighted: ({ context, prop }) => context.get("highlightedValue") === prop("collection").firstValue,
|
|
862
|
+
isLastItemHighlighted: ({ context, prop }) => context.get("highlightedValue") === prop("collection").lastValue,
|
|
863
|
+
closeOnSelect: ({ prop, event }) => !!(event.closeOnSelect ?? prop("closeOnSelect")),
|
|
864
|
+
restoreFocus: ({ event }) => restoreFocusFn(event),
|
|
865
|
+
isOpenControlled: ({ prop }) => prop("open") !== void 0,
|
|
866
|
+
isTriggerClickEvent: ({ event }) => event.previousEvent?.type === "TRIGGER.CLICK",
|
|
867
|
+
isTriggerEnterEvent: ({ event }) => event.previousEvent?.type === "TRIGGER.ENTER",
|
|
868
|
+
isTriggerArrowUpEvent: ({ event }) => event.previousEvent?.type === "TRIGGER.ARROW_UP",
|
|
869
|
+
isTriggerArrowDownEvent: ({ event }) => event.previousEvent?.type === "TRIGGER.ARROW_DOWN"
|
|
870
|
+
},
|
|
871
|
+
effects: {
|
|
872
|
+
trackFocusVisible({ scope }) {
|
|
873
|
+
return trackFocusVisible({ root: scope.getRootNode?.() });
|
|
874
|
+
},
|
|
875
|
+
trackFormControlState({ context, scope }) {
|
|
876
|
+
return trackFormControl(getHiddenSelectEl(scope), {
|
|
877
|
+
onFieldsetDisabledChange(disabled) {
|
|
878
|
+
context.set("fieldsetDisabled", disabled);
|
|
879
|
+
},
|
|
880
|
+
onFormReset() {
|
|
881
|
+
const value = context.initial("value");
|
|
882
|
+
context.set("value", value);
|
|
883
|
+
}
|
|
884
|
+
});
|
|
885
|
+
},
|
|
886
|
+
trackDismissableElement({ scope, send, prop }) {
|
|
887
|
+
const contentEl = () => getContentEl(scope);
|
|
888
|
+
let restoreFocus = true;
|
|
889
|
+
return trackDismissableElement(contentEl, {
|
|
890
|
+
type: "listbox",
|
|
891
|
+
defer: true,
|
|
892
|
+
exclude: [getTriggerEl(scope), getClearTriggerEl(scope)],
|
|
893
|
+
onFocusOutside: prop("onFocusOutside"),
|
|
894
|
+
onPointerDownOutside: prop("onPointerDownOutside"),
|
|
895
|
+
onInteractOutside(event) {
|
|
896
|
+
prop("onInteractOutside")?.(event);
|
|
897
|
+
restoreFocus = !(event.detail.focusable || event.detail.contextmenu);
|
|
898
|
+
},
|
|
899
|
+
onDismiss() {
|
|
900
|
+
send({
|
|
901
|
+
type: "CLOSE",
|
|
902
|
+
src: "interact-outside",
|
|
903
|
+
restoreFocus
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
},
|
|
908
|
+
computePlacement({ context, prop, scope }) {
|
|
909
|
+
const positioning = prop("positioning");
|
|
910
|
+
context.set("currentPlacement", positioning.placement);
|
|
911
|
+
const triggerEl = () => getTriggerEl(scope);
|
|
912
|
+
const positionerEl = () => getPositionerEl(scope);
|
|
913
|
+
return getPlacement(triggerEl, positionerEl, {
|
|
914
|
+
defer: true,
|
|
915
|
+
...positioning,
|
|
916
|
+
onComplete(data) {
|
|
917
|
+
context.set("currentPlacement", data.placement);
|
|
918
|
+
}
|
|
919
|
+
});
|
|
920
|
+
},
|
|
921
|
+
scrollToHighlightedItem({ context, prop, scope }) {
|
|
922
|
+
const exec = (immediate) => {
|
|
923
|
+
const highlightedValue = context.get("highlightedValue");
|
|
924
|
+
if (highlightedValue == null) return;
|
|
925
|
+
if (getInteractionModality() === "pointer") return;
|
|
926
|
+
const contentEl = getContentEl(scope);
|
|
927
|
+
const scrollToIndexFn = prop("scrollToIndexFn");
|
|
928
|
+
if (scrollToIndexFn) {
|
|
929
|
+
const highlightedIndex = prop("collection").indexOf(highlightedValue);
|
|
930
|
+
scrollToIndexFn?.({
|
|
931
|
+
index: highlightedIndex,
|
|
932
|
+
immediate,
|
|
933
|
+
getElement: () => getItemEl(scope, highlightedValue)
|
|
934
|
+
});
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
937
|
+
scrollIntoView(getItemEl(scope, highlightedValue), {
|
|
938
|
+
rootEl: contentEl,
|
|
939
|
+
block: "nearest"
|
|
940
|
+
});
|
|
941
|
+
};
|
|
942
|
+
raf(() => {
|
|
943
|
+
setInteractionModality("virtual");
|
|
944
|
+
exec(true);
|
|
945
|
+
});
|
|
946
|
+
const contentEl = () => getContentEl(scope);
|
|
947
|
+
return observeAttributes(contentEl, {
|
|
948
|
+
defer: true,
|
|
949
|
+
attributes: ["data-activedescendant"],
|
|
950
|
+
callback() {
|
|
951
|
+
exec(false);
|
|
952
|
+
}
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
},
|
|
956
|
+
actions: {
|
|
957
|
+
reposition({ context, prop, scope, event }) {
|
|
958
|
+
const positionerEl = () => getPositionerEl(scope);
|
|
959
|
+
getPlacement(getTriggerEl(scope), positionerEl, {
|
|
960
|
+
...prop("positioning"),
|
|
961
|
+
...event.options,
|
|
962
|
+
defer: true,
|
|
963
|
+
listeners: false,
|
|
964
|
+
onComplete(data) {
|
|
965
|
+
context.set("currentPlacement", data.placement);
|
|
966
|
+
}
|
|
967
|
+
});
|
|
968
|
+
},
|
|
969
|
+
toggleVisibility({ send, prop, event }) {
|
|
970
|
+
send({
|
|
971
|
+
type: prop("open") ? "CONTROLLED.OPEN" : "CONTROLLED.CLOSE",
|
|
972
|
+
previousEvent: event
|
|
973
|
+
});
|
|
974
|
+
},
|
|
975
|
+
highlightPreviousItem({ context, prop }) {
|
|
976
|
+
const highlightedValue = context.get("highlightedValue");
|
|
977
|
+
if (highlightedValue == null) return;
|
|
978
|
+
const value = prop("collection").getPreviousValue(highlightedValue, 1, prop("loopFocus"));
|
|
979
|
+
if (value == null) return;
|
|
980
|
+
context.set("highlightedValue", value);
|
|
981
|
+
},
|
|
982
|
+
highlightNextItem({ context, prop }) {
|
|
983
|
+
const highlightedValue = context.get("highlightedValue");
|
|
984
|
+
if (highlightedValue == null) return;
|
|
985
|
+
const value = prop("collection").getNextValue(highlightedValue, 1, prop("loopFocus"));
|
|
986
|
+
if (value == null) return;
|
|
987
|
+
context.set("highlightedValue", value);
|
|
988
|
+
},
|
|
989
|
+
highlightFirstItem({ context, prop }) {
|
|
990
|
+
const value = prop("collection").firstValue;
|
|
991
|
+
context.set("highlightedValue", value);
|
|
992
|
+
},
|
|
993
|
+
highlightLastItem({ context, prop }) {
|
|
994
|
+
const value = prop("collection").lastValue;
|
|
995
|
+
context.set("highlightedValue", value);
|
|
996
|
+
},
|
|
997
|
+
setInitialFocus({ scope }) {
|
|
998
|
+
raf(() => {
|
|
999
|
+
getInitialFocus({ root: getContentEl(scope) })?.focus({ preventScroll: true });
|
|
1000
|
+
});
|
|
1001
|
+
},
|
|
1002
|
+
focusTriggerEl({ event, scope }) {
|
|
1003
|
+
if (!restoreFocusFn(event)) return;
|
|
1004
|
+
raf(() => {
|
|
1005
|
+
getTriggerEl(scope)?.focus({ preventScroll: true });
|
|
1006
|
+
});
|
|
1007
|
+
},
|
|
1008
|
+
selectHighlightedItem({ context, prop, event }) {
|
|
1009
|
+
let value = event.value ?? context.get("highlightedValue");
|
|
1010
|
+
if (value == null || !prop("collection").has(value)) return;
|
|
1011
|
+
prop("onSelect")?.({ value });
|
|
1012
|
+
value = prop("deselectable") && !prop("multiple") && context.get("value").includes(value) ? null : value;
|
|
1013
|
+
context.set("value", (prev) => {
|
|
1014
|
+
if (value == null) return [];
|
|
1015
|
+
if (prop("multiple")) return addOrRemove(prev, value);
|
|
1016
|
+
return [value];
|
|
1017
|
+
});
|
|
1018
|
+
},
|
|
1019
|
+
highlightComputedFirstItem({ context, prop, computed }) {
|
|
1020
|
+
const collection = prop("collection");
|
|
1021
|
+
const value = computed("hasSelectedItems") ? collection.sort(context.get("value"))[0] : collection.firstValue;
|
|
1022
|
+
context.set("highlightedValue", value);
|
|
1023
|
+
},
|
|
1024
|
+
highlightComputedLastItem({ context, prop, computed }) {
|
|
1025
|
+
const collection = prop("collection");
|
|
1026
|
+
const value = computed("hasSelectedItems") ? collection.sort(context.get("value"))[0] : collection.lastValue;
|
|
1027
|
+
context.set("highlightedValue", value);
|
|
1028
|
+
},
|
|
1029
|
+
highlightFirstSelectedItem({ context, prop, computed }) {
|
|
1030
|
+
if (!computed("hasSelectedItems")) return;
|
|
1031
|
+
const value = prop("collection").sort(context.get("value"))[0];
|
|
1032
|
+
context.set("highlightedValue", value);
|
|
1033
|
+
},
|
|
1034
|
+
highlightItem({ context, event }) {
|
|
1035
|
+
context.set("highlightedValue", event.value);
|
|
1036
|
+
},
|
|
1037
|
+
highlightMatchingItem({ context, prop, event, refs }) {
|
|
1038
|
+
const value = prop("collection").search(event.key, {
|
|
1039
|
+
state: refs.get("typeahead"),
|
|
1040
|
+
currentValue: context.get("highlightedValue")
|
|
1041
|
+
});
|
|
1042
|
+
if (value == null) return;
|
|
1043
|
+
context.set("highlightedValue", value);
|
|
1044
|
+
},
|
|
1045
|
+
setHighlightedItem({ context, event }) {
|
|
1046
|
+
context.set("highlightedValue", event.value);
|
|
1047
|
+
},
|
|
1048
|
+
clearHighlightedItem({ context }) {
|
|
1049
|
+
context.set("highlightedValue", null);
|
|
1050
|
+
},
|
|
1051
|
+
selectItem({ context, prop, event }) {
|
|
1052
|
+
prop("onSelect")?.({ value: event.value });
|
|
1053
|
+
const value = prop("deselectable") && !prop("multiple") && context.get("value").includes(event.value) ? null : event.value;
|
|
1054
|
+
context.set("value", (prev) => {
|
|
1055
|
+
if (value == null) return [];
|
|
1056
|
+
if (prop("multiple")) return addOrRemove(prev, value);
|
|
1057
|
+
return [value];
|
|
1058
|
+
});
|
|
1059
|
+
},
|
|
1060
|
+
clearItem({ context, event }) {
|
|
1061
|
+
context.set("value", (prev) => prev.filter((v) => v !== event.value));
|
|
1062
|
+
},
|
|
1063
|
+
setSelectedItems({ context, event }) {
|
|
1064
|
+
context.set("value", event.value);
|
|
1065
|
+
},
|
|
1066
|
+
clearSelectedItems({ context }) {
|
|
1067
|
+
context.set("value", []);
|
|
1068
|
+
},
|
|
1069
|
+
selectPreviousItem({ context, prop }) {
|
|
1070
|
+
const [firstItem] = context.get("value");
|
|
1071
|
+
const value = prop("collection").getPreviousValue(firstItem);
|
|
1072
|
+
if (value) context.set("value", [value]);
|
|
1073
|
+
},
|
|
1074
|
+
selectNextItem({ context, prop }) {
|
|
1075
|
+
const [firstItem] = context.get("value");
|
|
1076
|
+
const value = prop("collection").getNextValue(firstItem);
|
|
1077
|
+
if (value) context.set("value", [value]);
|
|
1078
|
+
},
|
|
1079
|
+
selectFirstItem({ context, prop }) {
|
|
1080
|
+
const value = prop("collection").firstValue;
|
|
1081
|
+
if (value) context.set("value", [value]);
|
|
1082
|
+
},
|
|
1083
|
+
selectLastItem({ context, prop }) {
|
|
1084
|
+
const value = prop("collection").lastValue;
|
|
1085
|
+
if (value) context.set("value", [value]);
|
|
1086
|
+
},
|
|
1087
|
+
selectMatchingItem({ context, prop, event, refs }) {
|
|
1088
|
+
const value = prop("collection").search(event.key, {
|
|
1089
|
+
state: refs.get("typeahead"),
|
|
1090
|
+
currentValue: context.get("value")[0]
|
|
1091
|
+
});
|
|
1092
|
+
if (value == null) return;
|
|
1093
|
+
context.set("value", [value]);
|
|
1094
|
+
},
|
|
1095
|
+
scrollContentToTop({ prop, scope }) {
|
|
1096
|
+
if (prop("scrollToIndexFn")) {
|
|
1097
|
+
const firstValue = prop("collection").firstValue;
|
|
1098
|
+
prop("scrollToIndexFn")?.({
|
|
1099
|
+
index: 0,
|
|
1100
|
+
immediate: true,
|
|
1101
|
+
getElement: () => getItemEl(scope, firstValue)
|
|
1102
|
+
});
|
|
1103
|
+
} else getContentEl(scope)?.scrollTo(0, 0);
|
|
1104
|
+
},
|
|
1105
|
+
invokeOnOpen({ prop, context }) {
|
|
1106
|
+
prop("onOpenChange")?.({
|
|
1107
|
+
open: true,
|
|
1108
|
+
value: context.get("value")
|
|
1109
|
+
});
|
|
1110
|
+
},
|
|
1111
|
+
invokeOnClose({ prop, context }) {
|
|
1112
|
+
prop("onOpenChange")?.({
|
|
1113
|
+
open: false,
|
|
1114
|
+
value: context.get("value")
|
|
1115
|
+
});
|
|
1116
|
+
},
|
|
1117
|
+
syncSelectElement({ context, prop, scope }) {
|
|
1118
|
+
const selectEl = getHiddenSelectEl(scope);
|
|
1119
|
+
if (!selectEl) return;
|
|
1120
|
+
if (context.get("value").length === 0 && !prop("multiple")) {
|
|
1121
|
+
selectEl.selectedIndex = -1;
|
|
1122
|
+
return;
|
|
1123
|
+
}
|
|
1124
|
+
for (const option of selectEl.options) option.selected = context.get("value").includes(option.value);
|
|
1125
|
+
},
|
|
1126
|
+
syncCollection({ context, prop }) {
|
|
1127
|
+
const collection = prop("collection");
|
|
1128
|
+
const highlightedItem = collection.find(context.get("highlightedValue"));
|
|
1129
|
+
if (highlightedItem) context.set("highlightedItem", highlightedItem);
|
|
1130
|
+
const next = deriveSelectionState({
|
|
1131
|
+
values: context.get("value"),
|
|
1132
|
+
collection,
|
|
1133
|
+
selectedItemMap: context.get("selectedItemMap")
|
|
1134
|
+
});
|
|
1135
|
+
context.set("selectedItemMap", next.nextSelectedItemMap);
|
|
1136
|
+
},
|
|
1137
|
+
syncSelectedItems({ context, prop }) {
|
|
1138
|
+
const next = deriveSelectionState({
|
|
1139
|
+
values: context.get("value"),
|
|
1140
|
+
collection: prop("collection"),
|
|
1141
|
+
selectedItemMap: context.get("selectedItemMap")
|
|
1142
|
+
});
|
|
1143
|
+
context.set("selectedItemMap", next.nextSelectedItemMap);
|
|
1144
|
+
},
|
|
1145
|
+
syncHighlightedItem({ context, prop }) {
|
|
1146
|
+
const collection = prop("collection");
|
|
1147
|
+
const highlightedValue = context.get("highlightedValue");
|
|
1148
|
+
const highlightedItem = highlightedValue ? collection.find(highlightedValue) : null;
|
|
1149
|
+
context.set("highlightedItem", highlightedItem);
|
|
1150
|
+
},
|
|
1151
|
+
dispatchChangeEvent({ scope }) {
|
|
1152
|
+
queueMicrotask(() => {
|
|
1153
|
+
const node = getHiddenSelectEl(scope);
|
|
1154
|
+
if (!node) return;
|
|
1155
|
+
const evt = new (scope.getWin()).Event("change", {
|
|
1156
|
+
bubbles: true,
|
|
1157
|
+
composed: true
|
|
1158
|
+
});
|
|
1159
|
+
node.dispatchEvent(markAsInternalChangeEvent(evt));
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
});
|
|
1165
|
+
function restoreFocusFn(event) {
|
|
1166
|
+
const v = event.restoreFocus ?? event.previousEvent?.restoreFocus;
|
|
1167
|
+
return v == null || !!v;
|
|
1168
|
+
}
|
|
1169
|
+
//#endregion
|
|
1170
|
+
//#region src/machines/select/props.ts
|
|
1171
|
+
const props = createProps()([
|
|
1172
|
+
"autoComplete",
|
|
1173
|
+
"closeOnSelect",
|
|
1174
|
+
"collection",
|
|
1175
|
+
"composite",
|
|
1176
|
+
"defaultHighlightedValue",
|
|
1177
|
+
"defaultOpen",
|
|
1178
|
+
"defaultValue",
|
|
1179
|
+
"deselectable",
|
|
1180
|
+
"dir",
|
|
1181
|
+
"disabled",
|
|
1182
|
+
"form",
|
|
1183
|
+
"getRootNode",
|
|
1184
|
+
"highlightedValue",
|
|
1185
|
+
"id",
|
|
1186
|
+
"ids",
|
|
1187
|
+
"invalid",
|
|
1188
|
+
"loopFocus",
|
|
1189
|
+
"multiple",
|
|
1190
|
+
"name",
|
|
1191
|
+
"onFocusOutside",
|
|
1192
|
+
"onHighlightChange",
|
|
1193
|
+
"onInteractOutside",
|
|
1194
|
+
"onOpenChange",
|
|
1195
|
+
"onPointerDownOutside",
|
|
1196
|
+
"onSelect",
|
|
1197
|
+
"onValueChange",
|
|
1198
|
+
"open",
|
|
1199
|
+
"positioning",
|
|
1200
|
+
"readOnly",
|
|
1201
|
+
"required",
|
|
1202
|
+
"scrollToIndexFn",
|
|
1203
|
+
"translations",
|
|
1204
|
+
"value"
|
|
1205
|
+
]);
|
|
1206
|
+
const splitProps = createSplitProps(props);
|
|
1207
|
+
const itemProps = createProps()(["item", "persistFocus"]);
|
|
1208
|
+
const splitItemProps = createSplitProps(itemProps);
|
|
1209
|
+
const itemGroupProps = createProps()(["id"]);
|
|
1210
|
+
const splitItemGroupProps = createSplitProps(itemGroupProps);
|
|
1211
|
+
const itemGroupLabelProps = createProps()(["htmlFor"]);
|
|
1212
|
+
const splitItemGroupLabelProps = createSplitProps(itemGroupLabelProps);
|
|
1213
|
+
//#endregion
|
|
1214
|
+
export { anatomy, collection, connect, itemGroupLabelProps, itemGroupProps, itemProps, machine, props, splitItemGroupLabelProps, splitItemGroupProps, splitItemProps, splitProps };
|