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