@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,1974 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_create_anatomy = require("../../create-anatomy-BwDn25ph.cjs");
|
|
3
|
+
const require_dom_query = require("../../dom-query-CQzY93XU.cjs");
|
|
4
|
+
const require_event = require("../../event-DDz-mMhM.cjs");
|
|
5
|
+
const require_raf = require("../../raf-BSDcY4UD.cjs");
|
|
6
|
+
const require_visually_hidden = require("../../visually-hidden-BgSCFLz_.cjs");
|
|
7
|
+
const require_utils = require("../../utils-BH-oBBz2.cjs");
|
|
8
|
+
const require_core = require("../../core-BNMw-JId.cjs");
|
|
9
|
+
const require_date_utils = require("../../date-utils-D-JJHedx.cjs");
|
|
10
|
+
const require_live_region = require("../../live-region-BD0OgmrH.cjs");
|
|
11
|
+
const require_create_props = require("../../create-props-CjLx2oS8.cjs");
|
|
12
|
+
let _internationalized_date = require("@internationalized/date");
|
|
13
|
+
//#region src/machines/date-input/anatomy.ts
|
|
14
|
+
const anatomy = require_create_anatomy.createAnatomy("date-input").parts("root", "label", "control", "segmentGroup", "segment", "hiddenInput");
|
|
15
|
+
const parts = anatomy.build();
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/machines/date-input/dom.ts
|
|
18
|
+
const getRootId = (ctx) => ctx.ids?.root ?? `date-input:${ctx.id}`;
|
|
19
|
+
const getLabelId = (ctx, index) => ctx.ids?.label?.(index) ?? `date-input:${ctx.id}:label:${index}`;
|
|
20
|
+
const getControlId = (ctx) => ctx.ids?.control ?? `date-input:${ctx.id}:control`;
|
|
21
|
+
const getSegmentGroupId = (ctx, index) => ctx.ids?.segmentGroup?.(index) ?? `date-input:${ctx.id}:segment-group:${index}`;
|
|
22
|
+
const getHiddenInputId = (ctx, index) => ctx.ids?.hiddenInput?.(index) ?? `date-input:${ctx.id}:hidden-input:${index}`;
|
|
23
|
+
const getControlEl = (ctx) => ctx.getById(getControlId(ctx));
|
|
24
|
+
const getSegmentEls = (ctx) => require_dom_query.queryAll(getControlEl(ctx), `[data-part=segment]`);
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/machines/date-input/utils/segments.ts
|
|
27
|
+
function needsTimeGranularity(granularity) {
|
|
28
|
+
return granularity === "hour" || granularity === "minute" || granularity === "second";
|
|
29
|
+
}
|
|
30
|
+
function getFormatterOptions(opts) {
|
|
31
|
+
const { granularity, digitStyle, hourCycle, timeZone, hasTimeZone, hideTimeZone } = opts;
|
|
32
|
+
const options = {
|
|
33
|
+
timeZone,
|
|
34
|
+
day: digitStyle,
|
|
35
|
+
month: digitStyle,
|
|
36
|
+
year: "numeric",
|
|
37
|
+
hourCycle
|
|
38
|
+
};
|
|
39
|
+
if (needsTimeGranularity(granularity)) options.hour = digitStyle;
|
|
40
|
+
if (granularity === "minute" || granularity === "second") options.minute = "2-digit";
|
|
41
|
+
if (granularity === "second") options.second = "2-digit";
|
|
42
|
+
if (hasTimeZone && !hideTimeZone) options.timeZoneName = "short";
|
|
43
|
+
return options;
|
|
44
|
+
}
|
|
45
|
+
function resolveAllSegments(formatter) {
|
|
46
|
+
const segs = formatter.formatToParts(/* @__PURE__ */ new Date()).filter((seg) => EDITABLE_SEGMENTS[seg.type]).reduce((p, seg) => {
|
|
47
|
+
const key = TYPE_MAPPING[seg.type] || seg.type;
|
|
48
|
+
p[key] = true;
|
|
49
|
+
return p;
|
|
50
|
+
}, {});
|
|
51
|
+
if (segs.year) segs.era = true;
|
|
52
|
+
return segs;
|
|
53
|
+
}
|
|
54
|
+
const EDITABLE_SEGMENTS = {
|
|
55
|
+
year: true,
|
|
56
|
+
month: true,
|
|
57
|
+
day: true,
|
|
58
|
+
hour: true,
|
|
59
|
+
minute: true,
|
|
60
|
+
second: true,
|
|
61
|
+
dayPeriod: true,
|
|
62
|
+
era: true,
|
|
63
|
+
literal: false,
|
|
64
|
+
timeZoneName: false,
|
|
65
|
+
weekday: false,
|
|
66
|
+
unknown: false,
|
|
67
|
+
fractionalSecond: false
|
|
68
|
+
};
|
|
69
|
+
const PAGE_STEP = {
|
|
70
|
+
year: 5,
|
|
71
|
+
month: 2,
|
|
72
|
+
day: 7,
|
|
73
|
+
hour: 2,
|
|
74
|
+
minute: 15,
|
|
75
|
+
second: 15,
|
|
76
|
+
dayPeriod: void 0,
|
|
77
|
+
era: void 0,
|
|
78
|
+
literal: void 0,
|
|
79
|
+
timeZoneName: void 0,
|
|
80
|
+
weekday: void 0,
|
|
81
|
+
unknown: void 0,
|
|
82
|
+
fractionalSecond: void 0
|
|
83
|
+
};
|
|
84
|
+
const SEGMENT_LABELS = {
|
|
85
|
+
era: "Era",
|
|
86
|
+
year: "Year",
|
|
87
|
+
month: "Month",
|
|
88
|
+
day: "Day",
|
|
89
|
+
hour: "Hour",
|
|
90
|
+
minute: "Minute",
|
|
91
|
+
second: "Second",
|
|
92
|
+
dayPeriod: "AM/PM",
|
|
93
|
+
timeZoneName: "Time zone"
|
|
94
|
+
};
|
|
95
|
+
function getSegmentLabel(type) {
|
|
96
|
+
return SEGMENT_LABELS[type] ?? type;
|
|
97
|
+
}
|
|
98
|
+
const TYPE_MAPPING = {
|
|
99
|
+
dayperiod: "dayPeriod",
|
|
100
|
+
relatedYear: "year",
|
|
101
|
+
yearName: "literal",
|
|
102
|
+
unknown: "literal"
|
|
103
|
+
};
|
|
104
|
+
function getSafeType(type) {
|
|
105
|
+
return TYPE_MAPPING[type] ?? type;
|
|
106
|
+
}
|
|
107
|
+
function getPlaceholder(type, translations, locale) {
|
|
108
|
+
return translations.placeholder(locale)[type];
|
|
109
|
+
}
|
|
110
|
+
function isEditableSegment(type) {
|
|
111
|
+
return EDITABLE_SEGMENTS[type] === true;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Calls formatter.formatToParts(dateValue), with a fallback for environments
|
|
115
|
+
* where very old dates (e.g. year < 100 CE) throw RangeError in Intl.DateTimeFormat.
|
|
116
|
+
*/
|
|
117
|
+
function getSafeFormatParts(formatter, dateValue, displayValue) {
|
|
118
|
+
try {
|
|
119
|
+
return formatter.formatToParts(dateValue);
|
|
120
|
+
} catch {
|
|
121
|
+
return formatter.formatToParts(/* @__PURE__ */ new Date()).map((part) => {
|
|
122
|
+
switch (part.type) {
|
|
123
|
+
case "year":
|
|
124
|
+
case "relatedYear": return {
|
|
125
|
+
...part,
|
|
126
|
+
value: String(displayValue.year ?? 0)
|
|
127
|
+
};
|
|
128
|
+
case "month": return {
|
|
129
|
+
...part,
|
|
130
|
+
value: String(displayValue.month ?? 0)
|
|
131
|
+
};
|
|
132
|
+
case "day": return {
|
|
133
|
+
...part,
|
|
134
|
+
value: String(displayValue.day ?? 0)
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return part;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function processSegments({ dateValue, displayValue, formatter, locale, translations, granularity }) {
|
|
142
|
+
const timeValue = [
|
|
143
|
+
"hour",
|
|
144
|
+
"minute",
|
|
145
|
+
"second"
|
|
146
|
+
];
|
|
147
|
+
const segments = getSafeFormatParts(formatter, dateValue, displayValue);
|
|
148
|
+
const processedSegments = [];
|
|
149
|
+
for (const segment of segments) {
|
|
150
|
+
const type = getSafeType(segment.type);
|
|
151
|
+
let isEditable = isEditableSegment(type);
|
|
152
|
+
if (type === "era" && displayValue.calendar.getEras().length === 1) isEditable = false;
|
|
153
|
+
const isPlaceholder = isEditable && displayValue[type] == null;
|
|
154
|
+
let placeholder = isEditableSegment(type) ? getPlaceholder(type, translations, locale) : null;
|
|
155
|
+
if ((type === "dayPeriod" || type === "era") && segment.value) placeholder = segment.value;
|
|
156
|
+
const dateSegment = {
|
|
157
|
+
type,
|
|
158
|
+
text: isPlaceholder ? placeholder : segment.value,
|
|
159
|
+
...displayValue.getSegmentLimits(type),
|
|
160
|
+
isPlaceholder,
|
|
161
|
+
placeholder,
|
|
162
|
+
isEditable
|
|
163
|
+
};
|
|
164
|
+
if (type === "hour") {
|
|
165
|
+
processedSegments.push({
|
|
166
|
+
type: "literal",
|
|
167
|
+
text: "",
|
|
168
|
+
isPlaceholder: false,
|
|
169
|
+
placeholder: "",
|
|
170
|
+
isEditable: false
|
|
171
|
+
});
|
|
172
|
+
processedSegments.push(dateSegment);
|
|
173
|
+
if (type === granularity) processedSegments.push({
|
|
174
|
+
type: "literal",
|
|
175
|
+
text: "",
|
|
176
|
+
isPlaceholder: false,
|
|
177
|
+
placeholder: "",
|
|
178
|
+
isEditable: false
|
|
179
|
+
});
|
|
180
|
+
} else if (timeValue.includes(type) && type === granularity) {
|
|
181
|
+
processedSegments.push(dateSegment);
|
|
182
|
+
processedSegments.push({
|
|
183
|
+
type: "literal",
|
|
184
|
+
text: "",
|
|
185
|
+
isPlaceholder: false,
|
|
186
|
+
placeholder: "",
|
|
187
|
+
isEditable: false
|
|
188
|
+
});
|
|
189
|
+
} else processedSegments.push(dateSegment);
|
|
190
|
+
}
|
|
191
|
+
return processedSegments;
|
|
192
|
+
}
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/machines/date-input/utils/validity.ts
|
|
195
|
+
const isFocusableSegment = (segment) => segment.type !== "literal";
|
|
196
|
+
function getGroupCount(selectionMode) {
|
|
197
|
+
return selectionMode === "range" ? 2 : 1;
|
|
198
|
+
}
|
|
199
|
+
function getGroupOffset(allSegments, index) {
|
|
200
|
+
return allSegments.slice(0, index).reduce((acc, segs) => acc + segs.length, 0);
|
|
201
|
+
}
|
|
202
|
+
function resolveActiveSegment(ctx) {
|
|
203
|
+
const { context, computed } = ctx;
|
|
204
|
+
const index = context.get("activeIndex");
|
|
205
|
+
const activeSegmentIndex = context.get("activeSegmentIndex");
|
|
206
|
+
const allSegments = computed("segments");
|
|
207
|
+
const offset = getGroupOffset(allSegments, index);
|
|
208
|
+
return {
|
|
209
|
+
allSegments,
|
|
210
|
+
segments: allSegments[index],
|
|
211
|
+
offset,
|
|
212
|
+
localIndex: activeSegmentIndex - offset
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function getActiveSegment(ctx) {
|
|
216
|
+
const { allSegments, localIndex } = resolveActiveSegment(ctx);
|
|
217
|
+
return allSegments[ctx.context.get("activeIndex")]?.[localIndex];
|
|
218
|
+
}
|
|
219
|
+
function goToNextSegment(ctx, predicate = isFocusableSegment) {
|
|
220
|
+
const { context } = ctx;
|
|
221
|
+
const index = context.get("activeIndex");
|
|
222
|
+
const { allSegments, segments, offset, localIndex } = resolveActiveSegment(ctx);
|
|
223
|
+
const nextLocalIndex = segments.findIndex((s, i) => i > localIndex && predicate(s));
|
|
224
|
+
if (nextLocalIndex !== -1) {
|
|
225
|
+
context.set("activeSegmentIndex", offset + nextLocalIndex);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const nextGroupSegments = allSegments[index + 1];
|
|
229
|
+
if (!nextGroupSegments) return;
|
|
230
|
+
const firstNextGroupLocalIndex = nextGroupSegments.findIndex(predicate);
|
|
231
|
+
if (firstNextGroupLocalIndex === -1) return;
|
|
232
|
+
context.set("activeIndex", index + 1);
|
|
233
|
+
context.set("activeSegmentIndex", offset + segments.length + firstNextGroupLocalIndex);
|
|
234
|
+
}
|
|
235
|
+
function goToPreviousSegment(ctx, predicate = isFocusableSegment) {
|
|
236
|
+
const { context } = ctx;
|
|
237
|
+
const index = context.get("activeIndex");
|
|
238
|
+
const { allSegments, segments, offset, localIndex } = resolveActiveSegment(ctx);
|
|
239
|
+
const prevLocalIndex = segments.findLastIndex((s, i) => i < localIndex && predicate(s));
|
|
240
|
+
if (prevLocalIndex !== -1) {
|
|
241
|
+
context.set("activeSegmentIndex", offset + prevLocalIndex);
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
const prevGroupIndex = index - 1;
|
|
245
|
+
if (prevGroupIndex < 0) return;
|
|
246
|
+
const prevGroupSegments = allSegments[prevGroupIndex];
|
|
247
|
+
if (!prevGroupSegments) return;
|
|
248
|
+
const lastPrevGroupLocalIndex = prevGroupSegments.findLastIndex(predicate);
|
|
249
|
+
if (lastPrevGroupLocalIndex === -1) return;
|
|
250
|
+
context.set("activeIndex", prevGroupIndex);
|
|
251
|
+
context.set("activeSegmentIndex", getGroupOffset(allSegments, prevGroupIndex) + lastPrevGroupLocalIndex);
|
|
252
|
+
}
|
|
253
|
+
function getActiveDisplayValue(ctx) {
|
|
254
|
+
const index = ctx.context.get("activeIndex");
|
|
255
|
+
return ctx.context.get("displayValues")[index];
|
|
256
|
+
}
|
|
257
|
+
function setDisplayValue(ctx, index, dv) {
|
|
258
|
+
const displayValues = [...ctx.context.get("displayValues")];
|
|
259
|
+
displayValues[index] = dv;
|
|
260
|
+
ctx.context.set("displayValues", displayValues);
|
|
261
|
+
}
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region src/machines/date-input/connect.ts
|
|
264
|
+
function connect(service, normalize) {
|
|
265
|
+
const { state, context, prop, send, computed, scope } = service;
|
|
266
|
+
const disabled = Boolean(prop("disabled"));
|
|
267
|
+
const readOnly = Boolean(prop("readOnly"));
|
|
268
|
+
const isDateUnavailableFn = prop("isDateUnavailable");
|
|
269
|
+
const value = context.get("value");
|
|
270
|
+
const valueAsDate = value.filter((date) => date != null).map((date) => date.toDate(prop("timeZone")));
|
|
271
|
+
const isDateUnavailable = isDateUnavailableFn ? value.some((date) => date != null && isDateUnavailableFn(date, prop("locale"))) : false;
|
|
272
|
+
const invalid = prop("invalid") ?? isDateUnavailable;
|
|
273
|
+
const focused = state.matches("focused");
|
|
274
|
+
const locale = prop("locale");
|
|
275
|
+
const separator = require_date_utils.getLocaleSeparator(locale);
|
|
276
|
+
function getSegmentState(props) {
|
|
277
|
+
const { segment, index = 0 } = props;
|
|
278
|
+
const isEditable = !disabled && !readOnly && segment.isEditable;
|
|
279
|
+
const activeIndex = context.get("activeIndex");
|
|
280
|
+
return {
|
|
281
|
+
editable: isEditable,
|
|
282
|
+
focused: focused && activeIndex === index,
|
|
283
|
+
readonly: !segment.isEditable || readOnly
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
focused,
|
|
288
|
+
disabled,
|
|
289
|
+
invalid,
|
|
290
|
+
value,
|
|
291
|
+
valueAsDate,
|
|
292
|
+
valueAsString: computed("valueAsString"),
|
|
293
|
+
placeholderValue: context.get("placeholderValue"),
|
|
294
|
+
displayValues: context.get("displayValues"),
|
|
295
|
+
focus() {
|
|
296
|
+
getSegmentEls(scope)[0]?.focus();
|
|
297
|
+
},
|
|
298
|
+
setValue(values) {
|
|
299
|
+
send({
|
|
300
|
+
type: "VALUE.SET",
|
|
301
|
+
value: values
|
|
302
|
+
});
|
|
303
|
+
},
|
|
304
|
+
clearValue() {
|
|
305
|
+
send({ type: "VALUE.CLEAR" });
|
|
306
|
+
},
|
|
307
|
+
getSegments(props = {}) {
|
|
308
|
+
const { index = 0 } = props;
|
|
309
|
+
const allSegments = computed("segments");
|
|
310
|
+
const segments = allSegments[index] ?? [];
|
|
311
|
+
const enteredKeys = context.get("enteredKeys");
|
|
312
|
+
const activeIndex = context.get("activeIndex");
|
|
313
|
+
const activeSegmentIndex = context.get("activeSegmentIndex");
|
|
314
|
+
if (focused && enteredKeys && index === activeIndex && activeSegmentIndex >= 0) {
|
|
315
|
+
const localActiveSegmentIndex = activeSegmentIndex - getGroupOffset(allSegments, index);
|
|
316
|
+
return segments.map((segment, index) => {
|
|
317
|
+
if (index !== localActiveSegmentIndex) return segment;
|
|
318
|
+
return {
|
|
319
|
+
...segment,
|
|
320
|
+
text: enteredKeys,
|
|
321
|
+
isPlaceholder: false
|
|
322
|
+
};
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
return segments;
|
|
326
|
+
},
|
|
327
|
+
getSegmentState,
|
|
328
|
+
getRootProps() {
|
|
329
|
+
return normalize.element({
|
|
330
|
+
...parts.root.attrs,
|
|
331
|
+
dir: prop("dir"),
|
|
332
|
+
id: getRootId(scope),
|
|
333
|
+
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
334
|
+
"data-readonly": require_dom_query.dataAttr(readOnly),
|
|
335
|
+
"data-invalid": require_dom_query.dataAttr(invalid)
|
|
336
|
+
});
|
|
337
|
+
},
|
|
338
|
+
getLabelProps(props = {}) {
|
|
339
|
+
const { index = 0 } = props;
|
|
340
|
+
return normalize.label({
|
|
341
|
+
...parts.label.attrs,
|
|
342
|
+
id: getLabelId(scope, index),
|
|
343
|
+
dir: prop("dir"),
|
|
344
|
+
htmlFor: getHiddenInputId(scope, index),
|
|
345
|
+
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
346
|
+
"data-readonly": require_dom_query.dataAttr(readOnly),
|
|
347
|
+
"data-invalid": require_dom_query.dataAttr(invalid),
|
|
348
|
+
onClick() {
|
|
349
|
+
if (disabled) return;
|
|
350
|
+
getSegmentEls(scope)[0]?.focus();
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
},
|
|
354
|
+
getControlProps() {
|
|
355
|
+
return normalize.element({
|
|
356
|
+
...parts.control.attrs,
|
|
357
|
+
dir: prop("dir"),
|
|
358
|
+
id: getControlId(scope),
|
|
359
|
+
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
360
|
+
"data-readonly": require_dom_query.dataAttr(readOnly),
|
|
361
|
+
"data-invalid": require_dom_query.dataAttr(invalid),
|
|
362
|
+
"data-focus": require_dom_query.dataAttr(focused)
|
|
363
|
+
});
|
|
364
|
+
},
|
|
365
|
+
getSegmentGroupProps(props = {}) {
|
|
366
|
+
const { index = 0 } = props;
|
|
367
|
+
const activeIndex = context.get("activeIndex");
|
|
368
|
+
return normalize.element({
|
|
369
|
+
...parts.segmentGroup.attrs,
|
|
370
|
+
id: getSegmentGroupId(scope, index),
|
|
371
|
+
dir: prop("dir"),
|
|
372
|
+
role: "group",
|
|
373
|
+
"aria-labelledby": getLabelId(scope, index),
|
|
374
|
+
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
375
|
+
"data-readonly": require_dom_query.dataAttr(readOnly),
|
|
376
|
+
"data-invalid": require_dom_query.dataAttr(invalid),
|
|
377
|
+
"data-focus": require_dom_query.dataAttr(focused && activeIndex === index),
|
|
378
|
+
style: { unicodeBidi: "isolate" }
|
|
379
|
+
});
|
|
380
|
+
},
|
|
381
|
+
getSegmentProps(props) {
|
|
382
|
+
const { segment, index = 0 } = props;
|
|
383
|
+
const segmentState = getSegmentState(props);
|
|
384
|
+
if (segment.type === "literal") return normalize.element({
|
|
385
|
+
...parts.segment.attrs,
|
|
386
|
+
dir: prop("dir"),
|
|
387
|
+
"aria-hidden": true,
|
|
388
|
+
"data-type": segment.type,
|
|
389
|
+
"data-readonly": "",
|
|
390
|
+
"data-disabled": ""
|
|
391
|
+
});
|
|
392
|
+
return normalize.element({
|
|
393
|
+
...parts.segment.attrs,
|
|
394
|
+
dir: prop("dir"),
|
|
395
|
+
role: "spinbutton",
|
|
396
|
+
tabIndex: disabled ? void 0 : 0,
|
|
397
|
+
autoComplete: "off",
|
|
398
|
+
spellCheck: segmentState.editable ? "false" : void 0,
|
|
399
|
+
autoCorrect: segmentState.editable ? "off" : void 0,
|
|
400
|
+
contentEditable: segmentState.editable,
|
|
401
|
+
suppressContentEditableWarning: segmentState.editable,
|
|
402
|
+
inputMode: disabled || segment.type === "dayPeriod" || segment.type === "era" || !segmentState.editable ? void 0 : "numeric",
|
|
403
|
+
enterKeyHint: "next",
|
|
404
|
+
"aria-label": getSegmentLabel(segment.type),
|
|
405
|
+
"aria-valuenow": segment.isPlaceholder ? void 0 : segment.value,
|
|
406
|
+
"aria-valuetext": segment.isPlaceholder ? segment.placeholder : segment.text,
|
|
407
|
+
"aria-valuemin": segment.minValue,
|
|
408
|
+
"aria-valuemax": segment.maxValue,
|
|
409
|
+
"aria-invalid": require_dom_query.ariaAttr(invalid),
|
|
410
|
+
"aria-readonly": require_dom_query.ariaAttr(segmentState.readonly),
|
|
411
|
+
"aria-disabled": require_dom_query.ariaAttr(disabled),
|
|
412
|
+
"data-value": segment.value,
|
|
413
|
+
"data-type": segment.type,
|
|
414
|
+
"data-readonly": require_dom_query.dataAttr(segmentState.readonly),
|
|
415
|
+
"data-disabled": require_dom_query.dataAttr(disabled),
|
|
416
|
+
"data-editable": require_dom_query.dataAttr(segment.isEditable && !readOnly && !disabled),
|
|
417
|
+
"data-placeholder-shown": require_dom_query.dataAttr(segment.isPlaceholder),
|
|
418
|
+
style: { caretColor: "transparent" },
|
|
419
|
+
onFocus(event) {
|
|
420
|
+
const segmentEls = getSegmentEls(scope);
|
|
421
|
+
const target = event.currentTarget;
|
|
422
|
+
const segmentIndex = segmentEls.indexOf(target);
|
|
423
|
+
send({
|
|
424
|
+
type: "SEGMENT.FOCUS",
|
|
425
|
+
dateIndex: index,
|
|
426
|
+
segmentIndex
|
|
427
|
+
});
|
|
428
|
+
const selection = target.ownerDocument?.getSelection?.();
|
|
429
|
+
if (selection && target) selection.collapse(target);
|
|
430
|
+
},
|
|
431
|
+
onBlur(event) {
|
|
432
|
+
const next = event.relatedTarget;
|
|
433
|
+
if (require_dom_query.contains(getControlEl(scope), next)) return;
|
|
434
|
+
send({
|
|
435
|
+
type: "SEGMENT.BLUR",
|
|
436
|
+
index: -1
|
|
437
|
+
});
|
|
438
|
+
},
|
|
439
|
+
onKeyDown(event) {
|
|
440
|
+
if (event.defaultPrevented || event.ctrlKey || event.metaKey || event.shiftKey || event.altKey || readOnly || require_event.isComposingEvent(event)) return;
|
|
441
|
+
const exec = {
|
|
442
|
+
ArrowLeft() {
|
|
443
|
+
send({ type: "SEGMENT.ARROW_LEFT" });
|
|
444
|
+
},
|
|
445
|
+
ArrowRight() {
|
|
446
|
+
send({ type: "SEGMENT.ARROW_RIGHT" });
|
|
447
|
+
},
|
|
448
|
+
ArrowUp() {
|
|
449
|
+
send({
|
|
450
|
+
type: "SEGMENT.ADJUST",
|
|
451
|
+
segment,
|
|
452
|
+
amount: 1
|
|
453
|
+
});
|
|
454
|
+
},
|
|
455
|
+
ArrowDown() {
|
|
456
|
+
send({
|
|
457
|
+
type: "SEGMENT.ADJUST",
|
|
458
|
+
segment,
|
|
459
|
+
amount: -1
|
|
460
|
+
});
|
|
461
|
+
},
|
|
462
|
+
PageUp() {
|
|
463
|
+
send({
|
|
464
|
+
type: "SEGMENT.ADJUST",
|
|
465
|
+
segment,
|
|
466
|
+
amount: PAGE_STEP[segment.type] ?? 1
|
|
467
|
+
});
|
|
468
|
+
},
|
|
469
|
+
PageDown() {
|
|
470
|
+
send({
|
|
471
|
+
type: "SEGMENT.ADJUST",
|
|
472
|
+
segment,
|
|
473
|
+
amount: -(PAGE_STEP[segment.type] ?? 1)
|
|
474
|
+
});
|
|
475
|
+
},
|
|
476
|
+
Backspace() {
|
|
477
|
+
send({
|
|
478
|
+
type: "SEGMENT.BACKSPACE",
|
|
479
|
+
segment
|
|
480
|
+
});
|
|
481
|
+
},
|
|
482
|
+
Delete() {
|
|
483
|
+
send({
|
|
484
|
+
type: "SEGMENT.BACKSPACE",
|
|
485
|
+
segment
|
|
486
|
+
});
|
|
487
|
+
},
|
|
488
|
+
Home() {
|
|
489
|
+
send({
|
|
490
|
+
type: "SEGMENT.HOME",
|
|
491
|
+
segment
|
|
492
|
+
});
|
|
493
|
+
},
|
|
494
|
+
End() {
|
|
495
|
+
send({
|
|
496
|
+
type: "SEGMENT.END",
|
|
497
|
+
segment
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
}[require_event.getEventKey(event, { dir: prop("dir") })];
|
|
501
|
+
if (exec) {
|
|
502
|
+
exec(event);
|
|
503
|
+
event.preventDefault();
|
|
504
|
+
event.stopPropagation();
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
onPointerDown(event) {
|
|
508
|
+
event.stopPropagation();
|
|
509
|
+
},
|
|
510
|
+
onMouseDown(event) {
|
|
511
|
+
event.stopPropagation();
|
|
512
|
+
},
|
|
513
|
+
onBeforeInput(event) {
|
|
514
|
+
const { data, inputType } = require_event.getNativeEvent(event);
|
|
515
|
+
if (ALLOWED_INPUT_TYPES.includes(inputType)) {
|
|
516
|
+
event.preventDefault();
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
if (inputType === "insertFromPaste") {
|
|
520
|
+
event.preventDefault();
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
if (inputType === "insertCompositionText") {
|
|
524
|
+
if (event.currentTarget || event.target) {
|
|
525
|
+
event.preventDefault();
|
|
526
|
+
if (data != null) send({
|
|
527
|
+
type: "SEGMENT.INPUT",
|
|
528
|
+
segment,
|
|
529
|
+
input: data
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
const isTextSegment = segment.type === "dayPeriod" || segment.type === "era";
|
|
535
|
+
if (data && (isTextSegment || require_date_utils.isValidCharacter(data, separator, locale))) {
|
|
536
|
+
event.preventDefault();
|
|
537
|
+
send({
|
|
538
|
+
type: "SEGMENT.INPUT",
|
|
539
|
+
segment,
|
|
540
|
+
input: data
|
|
541
|
+
});
|
|
542
|
+
} else event.preventDefault();
|
|
543
|
+
},
|
|
544
|
+
onPaste(event) {
|
|
545
|
+
event.preventDefault();
|
|
546
|
+
const text = event.clipboardData?.getData("text/plain")?.trim();
|
|
547
|
+
if (text) send({
|
|
548
|
+
type: "SEGMENT.PASTE",
|
|
549
|
+
value: text
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
},
|
|
554
|
+
getHiddenInputProps(props = {}) {
|
|
555
|
+
const { index = 0, name } = props;
|
|
556
|
+
const value = context.get("value");
|
|
557
|
+
const inputName = name || prop("name");
|
|
558
|
+
return normalize.input({
|
|
559
|
+
...parts.hiddenInput.attrs,
|
|
560
|
+
type: "hidden",
|
|
561
|
+
id: getHiddenInputId(scope, index),
|
|
562
|
+
name: inputName ? value.length > 1 ? `${inputName}[${index}]` : inputName : void 0,
|
|
563
|
+
form: prop("form"),
|
|
564
|
+
required: prop("required"),
|
|
565
|
+
disabled,
|
|
566
|
+
readOnly,
|
|
567
|
+
value: computed("valueAsString")[index] ?? "",
|
|
568
|
+
style: require_visually_hidden.visuallyHiddenStyle
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
const ALLOWED_INPUT_TYPES = [
|
|
574
|
+
"deleteContentBackward",
|
|
575
|
+
"deleteContentForward",
|
|
576
|
+
"deleteByCut",
|
|
577
|
+
"deleteByDrag"
|
|
578
|
+
];
|
|
579
|
+
//#endregion
|
|
580
|
+
//#region src/machines/date-input/parse.ts
|
|
581
|
+
function parse(value) {
|
|
582
|
+
if (Array.isArray(value)) return value.map((v) => parse(v));
|
|
583
|
+
if (value instanceof Date) return new _internationalized_date.CalendarDate(value.getFullYear(), value.getMonth() + 1, value.getDate());
|
|
584
|
+
return (0, _internationalized_date.parseDate)(value);
|
|
585
|
+
}
|
|
586
|
+
//#endregion
|
|
587
|
+
//#region src/machines/date-input/utils/formatting.ts
|
|
588
|
+
function toFormatterDate(date, formatter) {
|
|
589
|
+
return date.toDate(formatter.resolvedOptions().timeZone);
|
|
590
|
+
}
|
|
591
|
+
function getValueAsString(value, prop) {
|
|
592
|
+
return value.map((date) => {
|
|
593
|
+
if (date == null) return "";
|
|
594
|
+
try {
|
|
595
|
+
return prop("format")(date, {
|
|
596
|
+
locale: prop("locale"),
|
|
597
|
+
timeZone: prop("timeZone")
|
|
598
|
+
});
|
|
599
|
+
} catch {
|
|
600
|
+
return "";
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
function resolveHourCycleProp(hourCycle) {
|
|
605
|
+
if (hourCycle === 12) return "h12";
|
|
606
|
+
if (hourCycle === 24) return "h23";
|
|
607
|
+
}
|
|
608
|
+
function resolvePlaceholderValue(options, timeZone, granularity, value, defaultValue, calendar) {
|
|
609
|
+
let placeholder = options.placeholderValue || options.defaultPlaceholderValue || value?.[0] || defaultValue?.[0] || require_date_utils.getTodayDate(timeZone, calendar);
|
|
610
|
+
placeholder = require_date_utils.constrainSegments(placeholder, options.min, options.max);
|
|
611
|
+
if (needsTimeGranularity(granularity) && !("hour" in placeholder)) placeholder = (0, _internationalized_date.toCalendarDateTime)(placeholder);
|
|
612
|
+
return placeholder;
|
|
613
|
+
}
|
|
614
|
+
function createFormatFn(formatter) {
|
|
615
|
+
return (date) => {
|
|
616
|
+
if (date.calendar?.identifier === "gregory" && date.era === "BC") {
|
|
617
|
+
const jsd = date.toDate("UTC");
|
|
618
|
+
const prolYear = jsd.getUTCFullYear();
|
|
619
|
+
const safeDate = new Date(Date.UTC(2e3, jsd.getUTCMonth(), jsd.getUTCDate()));
|
|
620
|
+
return formatter.formatToParts(safeDate).map((p) => p.type === "year" ? String(prolYear) : p.value).join("");
|
|
621
|
+
}
|
|
622
|
+
return formatter.format(toFormatterDate(date, formatter));
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
//#endregion
|
|
626
|
+
//#region src/machines/date-input/utils/incomplete-date.ts
|
|
627
|
+
function resolvedHourCycle(formatter) {
|
|
628
|
+
const hc = formatter.resolvedOptions().hourCycle;
|
|
629
|
+
if (hc === "h11" || hc === "h12" || hc === "h23" || hc === "h24") return hc;
|
|
630
|
+
return "h23";
|
|
631
|
+
}
|
|
632
|
+
function incompleteDateHash(dv) {
|
|
633
|
+
return `${dv.year}|${dv.month}|${dv.day}|${dv.hour}|${dv.dayPeriod}|${dv.minute}|${dv.second}|${dv.era}`;
|
|
634
|
+
}
|
|
635
|
+
function incompleteDateEqual(a, b) {
|
|
636
|
+
return incompleteDateHash(a) === incompleteDateHash(b);
|
|
637
|
+
}
|
|
638
|
+
function initDisplayValues(value, placeholderValue, hourCycle, count) {
|
|
639
|
+
const calendar = placeholderValue.calendar;
|
|
640
|
+
if (value?.length) return Array.from({ length: count }, (_, i) => value[i] ? new IncompleteDate(calendar, hourCycle, value[i]) : new IncompleteDate(calendar, hourCycle));
|
|
641
|
+
return Array.from({ length: count }, () => new IncompleteDate(calendar, hourCycle));
|
|
642
|
+
}
|
|
643
|
+
var IncompleteDate = class IncompleteDate {
|
|
644
|
+
calendar;
|
|
645
|
+
era;
|
|
646
|
+
year;
|
|
647
|
+
month;
|
|
648
|
+
day;
|
|
649
|
+
hour;
|
|
650
|
+
hourCycle;
|
|
651
|
+
dayPeriod;
|
|
652
|
+
minute;
|
|
653
|
+
second;
|
|
654
|
+
millisecond;
|
|
655
|
+
offset;
|
|
656
|
+
constructor(calendar, hourCycle, dateValue) {
|
|
657
|
+
this.era = dateValue?.era ?? null;
|
|
658
|
+
this.calendar = calendar;
|
|
659
|
+
this.year = dateValue?.year ?? null;
|
|
660
|
+
this.month = dateValue?.month ?? null;
|
|
661
|
+
this.day = dateValue?.day ?? null;
|
|
662
|
+
this.hour = dateValue?.hour ?? null;
|
|
663
|
+
this.hourCycle = hourCycle;
|
|
664
|
+
this.dayPeriod = null;
|
|
665
|
+
this.minute = dateValue?.minute ?? null;
|
|
666
|
+
this.second = dateValue?.second ?? null;
|
|
667
|
+
this.millisecond = dateValue?.millisecond ?? null;
|
|
668
|
+
this.offset = "offset" in (dateValue ?? {}) ? dateValue.offset : null;
|
|
669
|
+
if (this.hour != null) {
|
|
670
|
+
const [dayPeriod, hour] = toHourCycle(this.hour, hourCycle);
|
|
671
|
+
this.dayPeriod = dayPeriod;
|
|
672
|
+
this.hour = hour;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
copy() {
|
|
676
|
+
const res = new IncompleteDate(this.calendar, this.hourCycle);
|
|
677
|
+
res.era = this.era;
|
|
678
|
+
res.year = this.year;
|
|
679
|
+
res.month = this.month;
|
|
680
|
+
res.day = this.day;
|
|
681
|
+
res.hour = this.hour;
|
|
682
|
+
res.dayPeriod = this.dayPeriod;
|
|
683
|
+
res.minute = this.minute;
|
|
684
|
+
res.second = this.second;
|
|
685
|
+
res.millisecond = this.millisecond;
|
|
686
|
+
res.offset = this.offset;
|
|
687
|
+
return res;
|
|
688
|
+
}
|
|
689
|
+
withHourCycle(nextHourCycle) {
|
|
690
|
+
if (nextHourCycle === this.hourCycle) return this;
|
|
691
|
+
const hour24 = this.hour != null ? fromHourCycle(this.hour, this.dayPeriod ?? 0, this.hourCycle) : null;
|
|
692
|
+
const res = new IncompleteDate(this.calendar, nextHourCycle, {
|
|
693
|
+
era: this.era,
|
|
694
|
+
year: this.year,
|
|
695
|
+
month: this.month,
|
|
696
|
+
day: this.day,
|
|
697
|
+
hour: hour24,
|
|
698
|
+
minute: this.minute,
|
|
699
|
+
second: this.second,
|
|
700
|
+
millisecond: this.millisecond
|
|
701
|
+
});
|
|
702
|
+
res.offset = this.offset;
|
|
703
|
+
if (this.hour == null && this.dayPeriod != null && (nextHourCycle === "h12" || nextHourCycle === "h11")) res.dayPeriod = this.dayPeriod;
|
|
704
|
+
return res;
|
|
705
|
+
}
|
|
706
|
+
isComplete(segments) {
|
|
707
|
+
return segments.every((segment) => this[segment] != null);
|
|
708
|
+
}
|
|
709
|
+
isCleared(segments) {
|
|
710
|
+
return segments.every((segment) => this[segment] === null);
|
|
711
|
+
}
|
|
712
|
+
set(field, value, placeholder) {
|
|
713
|
+
const result = this.copy();
|
|
714
|
+
result[field] = value;
|
|
715
|
+
if (field === "hour" && result.dayPeriod == null && "hour" in placeholder) result.dayPeriod = toHourCycle(placeholder.hour, this.hourCycle)[0];
|
|
716
|
+
if (field === "year" && result.era == null) result.era = placeholder.era;
|
|
717
|
+
if (field !== "second" && field !== "literal" && field !== "timeZoneName") result.offset = null;
|
|
718
|
+
return result;
|
|
719
|
+
}
|
|
720
|
+
clear(field) {
|
|
721
|
+
const result = this.copy();
|
|
722
|
+
result[field] = null;
|
|
723
|
+
if (field === "year") result.era = null;
|
|
724
|
+
result.offset = null;
|
|
725
|
+
return result;
|
|
726
|
+
}
|
|
727
|
+
cycle(field, amount, placeholder, displaySegments) {
|
|
728
|
+
const res = this.copy();
|
|
729
|
+
if (res[field] == null && field !== "dayPeriod" && field !== "era") {
|
|
730
|
+
if (field === "hour" && "hour" in placeholder) {
|
|
731
|
+
const [dayPeriod, hour] = toHourCycle(placeholder.hour, this.hourCycle);
|
|
732
|
+
res.dayPeriod = dayPeriod;
|
|
733
|
+
res.hour = hour;
|
|
734
|
+
} else res[field] = placeholder[field];
|
|
735
|
+
if (field === "year" && res.era == null) res.era = placeholder.era;
|
|
736
|
+
return res;
|
|
737
|
+
}
|
|
738
|
+
switch (field) {
|
|
739
|
+
case "era": {
|
|
740
|
+
const eras = this.calendar.getEras();
|
|
741
|
+
let index = eras.indexOf(res.era);
|
|
742
|
+
index = cycleValue(index, amount, 0, eras.length - 1);
|
|
743
|
+
res.era = eras[index];
|
|
744
|
+
break;
|
|
745
|
+
}
|
|
746
|
+
case "year": {
|
|
747
|
+
let date = new _internationalized_date.CalendarDate(this.calendar, this.era ?? placeholder.era, this.year ?? placeholder.year, this.month ?? 1, this.day ?? 1);
|
|
748
|
+
date = date.cycle(field, amount, { round: field === "year" });
|
|
749
|
+
res.era = date.era;
|
|
750
|
+
res.year = date.year;
|
|
751
|
+
break;
|
|
752
|
+
}
|
|
753
|
+
case "month":
|
|
754
|
+
res.month = cycleValue(res.month ?? 1, amount, 1, this.calendar.getMaximumMonthsInYear());
|
|
755
|
+
break;
|
|
756
|
+
case "day":
|
|
757
|
+
res.day = cycleValue(res.day ?? 1, amount, 1, this.calendar.getMaximumDaysInMonth());
|
|
758
|
+
break;
|
|
759
|
+
case "hour": {
|
|
760
|
+
const hasDateSegments = displaySegments.some((s) => [
|
|
761
|
+
"year",
|
|
762
|
+
"month",
|
|
763
|
+
"day"
|
|
764
|
+
].includes(s));
|
|
765
|
+
if ("timeZone" in placeholder && (!hasDateSegments || res.year != null && res.month != null && res.day != null)) {
|
|
766
|
+
let date = this.toValue(placeholder);
|
|
767
|
+
date = date.cycle("hour", amount, {
|
|
768
|
+
hourCycle: this.hourCycle === "h12" ? 12 : 24,
|
|
769
|
+
round: false
|
|
770
|
+
});
|
|
771
|
+
const [dayPeriod, adjustedHour] = toHourCycle(date.hour, this.hourCycle);
|
|
772
|
+
res.hour = adjustedHour;
|
|
773
|
+
res.dayPeriod = dayPeriod;
|
|
774
|
+
res.offset = date.offset;
|
|
775
|
+
} else {
|
|
776
|
+
const hours = res.hour ?? 0;
|
|
777
|
+
const limits = this.getSegmentLimits("hour");
|
|
778
|
+
res.hour = cycleValue(hours, amount, limits.minValue, limits.maxValue);
|
|
779
|
+
if (res.dayPeriod == null && "hour" in placeholder) res.dayPeriod = toHourCycle(placeholder.hour, this.hourCycle)[0];
|
|
780
|
+
}
|
|
781
|
+
break;
|
|
782
|
+
}
|
|
783
|
+
case "dayPeriod":
|
|
784
|
+
res.dayPeriod = cycleValue(res.dayPeriod ?? 0, amount, 0, 1);
|
|
785
|
+
break;
|
|
786
|
+
case "minute":
|
|
787
|
+
res.minute = cycleValue(res.minute ?? 0, amount, 0, 59, true);
|
|
788
|
+
break;
|
|
789
|
+
case "second":
|
|
790
|
+
res.second = cycleValue(res.second ?? 0, amount, 0, 59, true);
|
|
791
|
+
break;
|
|
792
|
+
}
|
|
793
|
+
return res;
|
|
794
|
+
}
|
|
795
|
+
toValue(value) {
|
|
796
|
+
if ("hour" in value) {
|
|
797
|
+
let hour = this.hour;
|
|
798
|
+
if (hour != null) hour = fromHourCycle(hour, this.dayPeriod ?? 0, this.hourCycle);
|
|
799
|
+
else if (this.hourCycle === "h12" || this.hourCycle === "h11") hour = this.dayPeriod === 1 ? 12 : 0;
|
|
800
|
+
const res = value.set({
|
|
801
|
+
era: this.era ?? value.era,
|
|
802
|
+
year: this.year ?? value.year,
|
|
803
|
+
month: this.month ?? value.month,
|
|
804
|
+
day: this.day ?? value.day,
|
|
805
|
+
hour: hour ?? value.hour,
|
|
806
|
+
minute: this.minute ?? value.minute,
|
|
807
|
+
second: this.second ?? value.second,
|
|
808
|
+
millisecond: this.millisecond ?? value.millisecond
|
|
809
|
+
});
|
|
810
|
+
if ("offset" in res && this.offset != null && res.offset !== this.offset) return res.add({ milliseconds: res.offset - this.offset });
|
|
811
|
+
return res;
|
|
812
|
+
} else return value.set({
|
|
813
|
+
era: this.era ?? value.era,
|
|
814
|
+
year: this.year ?? value.year,
|
|
815
|
+
month: this.month ?? value.month,
|
|
816
|
+
day: this.day ?? value.day
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
getSegmentLimits(type) {
|
|
820
|
+
switch (type) {
|
|
821
|
+
case "era": {
|
|
822
|
+
const eras = this.calendar.getEras();
|
|
823
|
+
return {
|
|
824
|
+
value: this.era != null ? eras.indexOf(this.era) : eras.length - 1,
|
|
825
|
+
minValue: 0,
|
|
826
|
+
maxValue: eras.length - 1
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
case "year": return {
|
|
830
|
+
value: this.year,
|
|
831
|
+
minValue: 1,
|
|
832
|
+
maxValue: 9999
|
|
833
|
+
};
|
|
834
|
+
case "month": return {
|
|
835
|
+
value: this.month,
|
|
836
|
+
minValue: 1,
|
|
837
|
+
maxValue: this.calendar.getMaximumMonthsInYear()
|
|
838
|
+
};
|
|
839
|
+
case "day": return {
|
|
840
|
+
value: this.day,
|
|
841
|
+
minValue: 1,
|
|
842
|
+
maxValue: this.calendar.getMaximumDaysInMonth()
|
|
843
|
+
};
|
|
844
|
+
case "dayPeriod": return {
|
|
845
|
+
value: this.dayPeriod,
|
|
846
|
+
minValue: 0,
|
|
847
|
+
maxValue: 1
|
|
848
|
+
};
|
|
849
|
+
case "hour": {
|
|
850
|
+
let minValue = 0;
|
|
851
|
+
let maxValue = 23;
|
|
852
|
+
if (this.hourCycle === "h12") {
|
|
853
|
+
minValue = 1;
|
|
854
|
+
maxValue = 12;
|
|
855
|
+
} else if (this.hourCycle === "h11") {
|
|
856
|
+
minValue = 0;
|
|
857
|
+
maxValue = 11;
|
|
858
|
+
}
|
|
859
|
+
return {
|
|
860
|
+
value: this.hour,
|
|
861
|
+
minValue,
|
|
862
|
+
maxValue
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
case "minute": return {
|
|
866
|
+
value: this.minute,
|
|
867
|
+
minValue: 0,
|
|
868
|
+
maxValue: 59
|
|
869
|
+
};
|
|
870
|
+
case "second": return {
|
|
871
|
+
value: this.second,
|
|
872
|
+
minValue: 0,
|
|
873
|
+
maxValue: 59
|
|
874
|
+
};
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
toString() {
|
|
878
|
+
const fields = {
|
|
879
|
+
era: this.era,
|
|
880
|
+
year: this.year,
|
|
881
|
+
month: this.month,
|
|
882
|
+
day: this.day,
|
|
883
|
+
hour: this.hour,
|
|
884
|
+
dayPeriod: this.dayPeriod,
|
|
885
|
+
minute: this.minute,
|
|
886
|
+
second: this.second
|
|
887
|
+
};
|
|
888
|
+
const parts = Object.entries(fields).filter(([, v]) => v != null).map(([k, v]) => `${k}=${v}`);
|
|
889
|
+
return parts.length > 0 ? parts.join(",") : "-";
|
|
890
|
+
}
|
|
891
|
+
};
|
|
892
|
+
function cycleValue(value, amount, min, max, round = false) {
|
|
893
|
+
if (round) {
|
|
894
|
+
value += Math.sign(amount);
|
|
895
|
+
if (value < min) value = max;
|
|
896
|
+
const div = Math.abs(amount);
|
|
897
|
+
if (amount > 0) value = Math.ceil(value / div) * div;
|
|
898
|
+
else value = Math.floor(value / div) * div;
|
|
899
|
+
if (value > max) value = min;
|
|
900
|
+
} else {
|
|
901
|
+
value += amount;
|
|
902
|
+
if (value < min) value = max - (min - value - 1);
|
|
903
|
+
else if (value > max) value = min + (value - max - 1);
|
|
904
|
+
}
|
|
905
|
+
return value;
|
|
906
|
+
}
|
|
907
|
+
function toHourCycle(hour, hourCycle) {
|
|
908
|
+
let dayPeriod = hour >= 12 ? 1 : 0;
|
|
909
|
+
switch (hourCycle) {
|
|
910
|
+
case "h11":
|
|
911
|
+
if (hour >= 12) hour -= 12;
|
|
912
|
+
break;
|
|
913
|
+
case "h12":
|
|
914
|
+
if (hour === 0) hour = 12;
|
|
915
|
+
else if (hour > 12) hour -= 12;
|
|
916
|
+
break;
|
|
917
|
+
case "h23":
|
|
918
|
+
dayPeriod = null;
|
|
919
|
+
break;
|
|
920
|
+
case "h24":
|
|
921
|
+
hour += 1;
|
|
922
|
+
dayPeriod = null;
|
|
923
|
+
}
|
|
924
|
+
return [dayPeriod, hour];
|
|
925
|
+
}
|
|
926
|
+
function fromHourCycle(hour, dayPeriod, hourCycle) {
|
|
927
|
+
switch (hourCycle) {
|
|
928
|
+
case "h11":
|
|
929
|
+
if (dayPeriod === 1) hour += 12;
|
|
930
|
+
break;
|
|
931
|
+
case "h12":
|
|
932
|
+
if (hour === 12) hour = 0;
|
|
933
|
+
if (dayPeriod === 1) hour += 12;
|
|
934
|
+
break;
|
|
935
|
+
case "h24":
|
|
936
|
+
hour -= 1;
|
|
937
|
+
break;
|
|
938
|
+
}
|
|
939
|
+
return hour;
|
|
940
|
+
}
|
|
941
|
+
//#endregion
|
|
942
|
+
//#region src/machines/date-input/utils/input.ts
|
|
943
|
+
function isNumberString(value) {
|
|
944
|
+
return !Number.isNaN(Number.parseInt(value));
|
|
945
|
+
}
|
|
946
|
+
function updateSegmentValue(ctx, segment, input) {
|
|
947
|
+
const { context, prop } = ctx;
|
|
948
|
+
const type = segment.type;
|
|
949
|
+
const index = context.get("activeIndex");
|
|
950
|
+
const formatter = prop("formatter");
|
|
951
|
+
const enteredKeys = context.get("enteredKeys");
|
|
952
|
+
const placeholderValue = context.get("placeholderValue");
|
|
953
|
+
let dv = getActiveDisplayValue(ctx);
|
|
954
|
+
let next;
|
|
955
|
+
switch (type) {
|
|
956
|
+
case "dayPeriod": {
|
|
957
|
+
if (!("hour" in dv.toValue(placeholderValue))) return;
|
|
958
|
+
const amPmFormatter = new _internationalized_date.DateFormatter(prop("locale"), {
|
|
959
|
+
hour: "numeric",
|
|
960
|
+
hour12: true
|
|
961
|
+
});
|
|
962
|
+
const amDate = /* @__PURE__ */ new Date();
|
|
963
|
+
amDate.setHours(0);
|
|
964
|
+
const pmDate = /* @__PURE__ */ new Date();
|
|
965
|
+
pmDate.setHours(12);
|
|
966
|
+
const am = amPmFormatter.formatToParts(amDate).find((p) => p.type === "dayPeriod")?.value || "AM";
|
|
967
|
+
const pm = amPmFormatter.formatToParts(pmDate).find((p) => p.type === "dayPeriod")?.value || "PM";
|
|
968
|
+
const lowerInput = input.toLowerCase();
|
|
969
|
+
if (am.toLowerCase().startsWith(lowerInput)) next = dv.set("dayPeriod", 0, placeholderValue);
|
|
970
|
+
else if (pm.toLowerCase().startsWith(lowerInput)) next = dv.set("dayPeriod", 1, placeholderValue);
|
|
971
|
+
else break;
|
|
972
|
+
setDisplayValue(ctx, index, next);
|
|
973
|
+
goToNextSegment(ctx);
|
|
974
|
+
break;
|
|
975
|
+
}
|
|
976
|
+
case "era": {
|
|
977
|
+
const eras = dv.calendar.getEras();
|
|
978
|
+
const eraFormatter = new _internationalized_date.DateFormatter(prop("locale"), { era: "short" });
|
|
979
|
+
const lowerInput = input.toLowerCase();
|
|
980
|
+
for (let i = 0; i < eras.length; i++) {
|
|
981
|
+
const eraDate = dv.toValue(placeholderValue).set({ year: 1 }).toDate(prop("timeZone"));
|
|
982
|
+
const formattedEra = eraFormatter.formatToParts(eraDate).find((p) => p.type === "era")?.value;
|
|
983
|
+
if (formattedEra && formattedEra.toLowerCase().startsWith(lowerInput)) {
|
|
984
|
+
next = dv.set("era", eras[i], placeholderValue);
|
|
985
|
+
setDisplayValue(ctx, index, next);
|
|
986
|
+
goToNextSegment(ctx);
|
|
987
|
+
break;
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
break;
|
|
991
|
+
}
|
|
992
|
+
case "day":
|
|
993
|
+
case "hour":
|
|
994
|
+
case "minute":
|
|
995
|
+
case "second":
|
|
996
|
+
case "month":
|
|
997
|
+
case "year": {
|
|
998
|
+
let newValue = enteredKeys + input;
|
|
999
|
+
let numberValue = Number.parseInt(newValue);
|
|
1000
|
+
let segmentValue = numberValue;
|
|
1001
|
+
let allowsZero = segment.minValue === 0;
|
|
1002
|
+
if (!isNumberString(input)) return;
|
|
1003
|
+
if (segment.type === "hour" && formatter.resolvedOptions().hour12) {
|
|
1004
|
+
switch (formatter.resolvedOptions().hourCycle) {
|
|
1005
|
+
case "h11":
|
|
1006
|
+
if (numberValue > 11) segmentValue = Number.parseInt(input);
|
|
1007
|
+
break;
|
|
1008
|
+
case "h12":
|
|
1009
|
+
allowsZero = false;
|
|
1010
|
+
if (numberValue > 12) segmentValue = Number.parseInt(input);
|
|
1011
|
+
break;
|
|
1012
|
+
}
|
|
1013
|
+
if (segment.value !== void 0 && segment.value >= 12 && numberValue > 1) numberValue += 12;
|
|
1014
|
+
} else if (segment.maxValue !== void 0 && numberValue > segment.maxValue) segmentValue = Number.parseInt(input);
|
|
1015
|
+
if (isNaN(numberValue)) return;
|
|
1016
|
+
const shouldSetValue = segmentValue !== 0 || allowsZero;
|
|
1017
|
+
if (shouldSetValue) {
|
|
1018
|
+
dv = dv.set(type, segmentValue, placeholderValue);
|
|
1019
|
+
next = dv;
|
|
1020
|
+
setDisplayValue(ctx, index, dv);
|
|
1021
|
+
}
|
|
1022
|
+
if (segment.maxValue !== void 0 && (Number(numberValue + "0") > segment.maxValue || newValue.length >= String(segment.maxValue).length)) {
|
|
1023
|
+
context.set("enteredKeys", "");
|
|
1024
|
+
if (shouldSetValue) goToNextSegment(ctx);
|
|
1025
|
+
} else context.set("enteredKeys", newValue);
|
|
1026
|
+
break;
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
return next;
|
|
1030
|
+
}
|
|
1031
|
+
//#endregion
|
|
1032
|
+
//#region src/machines/date-input/utils/placeholders.ts
|
|
1033
|
+
const LOCALE_PLACEHOLDERS = {
|
|
1034
|
+
ach: [
|
|
1035
|
+
"mwaka",
|
|
1036
|
+
"dwe",
|
|
1037
|
+
"nino"
|
|
1038
|
+
],
|
|
1039
|
+
af: [
|
|
1040
|
+
"jjjj",
|
|
1041
|
+
"mm",
|
|
1042
|
+
"dd"
|
|
1043
|
+
],
|
|
1044
|
+
am: [
|
|
1045
|
+
"ዓዓዓዓ",
|
|
1046
|
+
"ሚሜ",
|
|
1047
|
+
"ቀቀ"
|
|
1048
|
+
],
|
|
1049
|
+
an: [
|
|
1050
|
+
"aaaa",
|
|
1051
|
+
"mm",
|
|
1052
|
+
"dd"
|
|
1053
|
+
],
|
|
1054
|
+
ar: [
|
|
1055
|
+
"سنة",
|
|
1056
|
+
"شهر",
|
|
1057
|
+
"يوم"
|
|
1058
|
+
],
|
|
1059
|
+
ast: [
|
|
1060
|
+
"aaaa",
|
|
1061
|
+
"mm",
|
|
1062
|
+
"dd"
|
|
1063
|
+
],
|
|
1064
|
+
az: [
|
|
1065
|
+
"iiii",
|
|
1066
|
+
"aa",
|
|
1067
|
+
"gg"
|
|
1068
|
+
],
|
|
1069
|
+
be: [
|
|
1070
|
+
"гггг",
|
|
1071
|
+
"мм",
|
|
1072
|
+
"дд"
|
|
1073
|
+
],
|
|
1074
|
+
bg: [
|
|
1075
|
+
"гггг",
|
|
1076
|
+
"мм",
|
|
1077
|
+
"дд"
|
|
1078
|
+
],
|
|
1079
|
+
bn: [
|
|
1080
|
+
"yyyy",
|
|
1081
|
+
"মিমি",
|
|
1082
|
+
"dd"
|
|
1083
|
+
],
|
|
1084
|
+
br: [
|
|
1085
|
+
"bbbb",
|
|
1086
|
+
"mm",
|
|
1087
|
+
"dd"
|
|
1088
|
+
],
|
|
1089
|
+
bs: [
|
|
1090
|
+
"gggg",
|
|
1091
|
+
"mm",
|
|
1092
|
+
"dd"
|
|
1093
|
+
],
|
|
1094
|
+
ca: [
|
|
1095
|
+
"aaaa",
|
|
1096
|
+
"mm",
|
|
1097
|
+
"dd"
|
|
1098
|
+
],
|
|
1099
|
+
cak: [
|
|
1100
|
+
"jjjj",
|
|
1101
|
+
"ii",
|
|
1102
|
+
"q'q'"
|
|
1103
|
+
],
|
|
1104
|
+
ckb: [
|
|
1105
|
+
"ساڵ",
|
|
1106
|
+
"مانگ",
|
|
1107
|
+
"ڕۆژ"
|
|
1108
|
+
],
|
|
1109
|
+
cs: [
|
|
1110
|
+
"rrrr",
|
|
1111
|
+
"mm",
|
|
1112
|
+
"dd"
|
|
1113
|
+
],
|
|
1114
|
+
cy: [
|
|
1115
|
+
"bbbb",
|
|
1116
|
+
"mm",
|
|
1117
|
+
"dd"
|
|
1118
|
+
],
|
|
1119
|
+
da: [
|
|
1120
|
+
"åååå",
|
|
1121
|
+
"mm",
|
|
1122
|
+
"dd"
|
|
1123
|
+
],
|
|
1124
|
+
de: [
|
|
1125
|
+
"jjjj",
|
|
1126
|
+
"mm",
|
|
1127
|
+
"tt"
|
|
1128
|
+
],
|
|
1129
|
+
dsb: [
|
|
1130
|
+
"llll",
|
|
1131
|
+
"mm",
|
|
1132
|
+
"źź"
|
|
1133
|
+
],
|
|
1134
|
+
el: [
|
|
1135
|
+
"εεεε",
|
|
1136
|
+
"μμ",
|
|
1137
|
+
"ηη"
|
|
1138
|
+
],
|
|
1139
|
+
en: [
|
|
1140
|
+
"yyyy",
|
|
1141
|
+
"mm",
|
|
1142
|
+
"dd"
|
|
1143
|
+
],
|
|
1144
|
+
eo: [
|
|
1145
|
+
"jjjj",
|
|
1146
|
+
"mm",
|
|
1147
|
+
"tt"
|
|
1148
|
+
],
|
|
1149
|
+
es: [
|
|
1150
|
+
"aaaa",
|
|
1151
|
+
"mm",
|
|
1152
|
+
"dd"
|
|
1153
|
+
],
|
|
1154
|
+
et: [
|
|
1155
|
+
"aaaa",
|
|
1156
|
+
"kk",
|
|
1157
|
+
"pp"
|
|
1158
|
+
],
|
|
1159
|
+
eu: [
|
|
1160
|
+
"uuuu",
|
|
1161
|
+
"hh",
|
|
1162
|
+
"ee"
|
|
1163
|
+
],
|
|
1164
|
+
fa: [
|
|
1165
|
+
"سال",
|
|
1166
|
+
"ماه",
|
|
1167
|
+
"روز"
|
|
1168
|
+
],
|
|
1169
|
+
ff: [
|
|
1170
|
+
"hhhh",
|
|
1171
|
+
"ll",
|
|
1172
|
+
"ññ"
|
|
1173
|
+
],
|
|
1174
|
+
fi: [
|
|
1175
|
+
"vvvv",
|
|
1176
|
+
"kk",
|
|
1177
|
+
"pp"
|
|
1178
|
+
],
|
|
1179
|
+
fr: [
|
|
1180
|
+
"aaaa",
|
|
1181
|
+
"mm",
|
|
1182
|
+
"jj"
|
|
1183
|
+
],
|
|
1184
|
+
fy: [
|
|
1185
|
+
"jjjj",
|
|
1186
|
+
"mm",
|
|
1187
|
+
"dd"
|
|
1188
|
+
],
|
|
1189
|
+
ga: [
|
|
1190
|
+
"bbbb",
|
|
1191
|
+
"mm",
|
|
1192
|
+
"ll"
|
|
1193
|
+
],
|
|
1194
|
+
gd: [
|
|
1195
|
+
"bbbb",
|
|
1196
|
+
"mm",
|
|
1197
|
+
"ll"
|
|
1198
|
+
],
|
|
1199
|
+
gl: [
|
|
1200
|
+
"aaaa",
|
|
1201
|
+
"mm",
|
|
1202
|
+
"dd"
|
|
1203
|
+
],
|
|
1204
|
+
he: [
|
|
1205
|
+
"שנה",
|
|
1206
|
+
"חודש",
|
|
1207
|
+
"יום"
|
|
1208
|
+
],
|
|
1209
|
+
hr: [
|
|
1210
|
+
"gggg",
|
|
1211
|
+
"mm",
|
|
1212
|
+
"dd"
|
|
1213
|
+
],
|
|
1214
|
+
hsb: [
|
|
1215
|
+
"llll",
|
|
1216
|
+
"mm",
|
|
1217
|
+
"dd"
|
|
1218
|
+
],
|
|
1219
|
+
hu: [
|
|
1220
|
+
"éééé",
|
|
1221
|
+
"hh",
|
|
1222
|
+
"nn"
|
|
1223
|
+
],
|
|
1224
|
+
ia: [
|
|
1225
|
+
"aaaa",
|
|
1226
|
+
"mm",
|
|
1227
|
+
"dd"
|
|
1228
|
+
],
|
|
1229
|
+
id: [
|
|
1230
|
+
"tttt",
|
|
1231
|
+
"bb",
|
|
1232
|
+
"hh"
|
|
1233
|
+
],
|
|
1234
|
+
it: [
|
|
1235
|
+
"aaaa",
|
|
1236
|
+
"mm",
|
|
1237
|
+
"gg"
|
|
1238
|
+
],
|
|
1239
|
+
ja: [
|
|
1240
|
+
"年",
|
|
1241
|
+
"月",
|
|
1242
|
+
"日"
|
|
1243
|
+
],
|
|
1244
|
+
ka: [
|
|
1245
|
+
"წწწწ",
|
|
1246
|
+
"თთ",
|
|
1247
|
+
"რრ"
|
|
1248
|
+
],
|
|
1249
|
+
kk: [
|
|
1250
|
+
"жжжж",
|
|
1251
|
+
"аа",
|
|
1252
|
+
"кк"
|
|
1253
|
+
],
|
|
1254
|
+
kn: [
|
|
1255
|
+
"ವವವವ",
|
|
1256
|
+
"ಮಿಮೀ",
|
|
1257
|
+
"ದಿದಿ"
|
|
1258
|
+
],
|
|
1259
|
+
ko: [
|
|
1260
|
+
"연도",
|
|
1261
|
+
"월",
|
|
1262
|
+
"일"
|
|
1263
|
+
],
|
|
1264
|
+
lb: [
|
|
1265
|
+
"jjjj",
|
|
1266
|
+
"mm",
|
|
1267
|
+
"dd"
|
|
1268
|
+
],
|
|
1269
|
+
lo: [
|
|
1270
|
+
"ປປປປ",
|
|
1271
|
+
"ດດ",
|
|
1272
|
+
"ວວ"
|
|
1273
|
+
],
|
|
1274
|
+
lt: [
|
|
1275
|
+
"mmmm",
|
|
1276
|
+
"mm",
|
|
1277
|
+
"dd"
|
|
1278
|
+
],
|
|
1279
|
+
lv: [
|
|
1280
|
+
"gggg",
|
|
1281
|
+
"mm",
|
|
1282
|
+
"dd"
|
|
1283
|
+
],
|
|
1284
|
+
meh: [
|
|
1285
|
+
"aaaa",
|
|
1286
|
+
"mm",
|
|
1287
|
+
"dd"
|
|
1288
|
+
],
|
|
1289
|
+
ml: [
|
|
1290
|
+
"വർഷം",
|
|
1291
|
+
"മാസം",
|
|
1292
|
+
"തീയതി"
|
|
1293
|
+
],
|
|
1294
|
+
ms: [
|
|
1295
|
+
"tttt",
|
|
1296
|
+
"mm",
|
|
1297
|
+
"hh"
|
|
1298
|
+
],
|
|
1299
|
+
nl: [
|
|
1300
|
+
"jjjj",
|
|
1301
|
+
"mm",
|
|
1302
|
+
"dd"
|
|
1303
|
+
],
|
|
1304
|
+
nn: [
|
|
1305
|
+
"åååå",
|
|
1306
|
+
"mm",
|
|
1307
|
+
"dd"
|
|
1308
|
+
],
|
|
1309
|
+
no: [
|
|
1310
|
+
"åååå",
|
|
1311
|
+
"mm",
|
|
1312
|
+
"dd"
|
|
1313
|
+
],
|
|
1314
|
+
oc: [
|
|
1315
|
+
"aaaa",
|
|
1316
|
+
"mm",
|
|
1317
|
+
"jj"
|
|
1318
|
+
],
|
|
1319
|
+
pl: [
|
|
1320
|
+
"rrrr",
|
|
1321
|
+
"mm",
|
|
1322
|
+
"dd"
|
|
1323
|
+
],
|
|
1324
|
+
pt: [
|
|
1325
|
+
"aaaa",
|
|
1326
|
+
"mm",
|
|
1327
|
+
"dd"
|
|
1328
|
+
],
|
|
1329
|
+
rm: [
|
|
1330
|
+
"oooo",
|
|
1331
|
+
"mm",
|
|
1332
|
+
"dd"
|
|
1333
|
+
],
|
|
1334
|
+
ro: [
|
|
1335
|
+
"aaaa",
|
|
1336
|
+
"ll",
|
|
1337
|
+
"zz"
|
|
1338
|
+
],
|
|
1339
|
+
ru: [
|
|
1340
|
+
"гггг",
|
|
1341
|
+
"мм",
|
|
1342
|
+
"дд"
|
|
1343
|
+
],
|
|
1344
|
+
sc: [
|
|
1345
|
+
"aaaa",
|
|
1346
|
+
"mm",
|
|
1347
|
+
"dd"
|
|
1348
|
+
],
|
|
1349
|
+
scn: [
|
|
1350
|
+
"aaaa",
|
|
1351
|
+
"mm",
|
|
1352
|
+
"jj"
|
|
1353
|
+
],
|
|
1354
|
+
sk: [
|
|
1355
|
+
"rrrr",
|
|
1356
|
+
"mm",
|
|
1357
|
+
"dd"
|
|
1358
|
+
],
|
|
1359
|
+
sl: [
|
|
1360
|
+
"llll",
|
|
1361
|
+
"mm",
|
|
1362
|
+
"dd"
|
|
1363
|
+
],
|
|
1364
|
+
sr: [
|
|
1365
|
+
"гггг",
|
|
1366
|
+
"мм",
|
|
1367
|
+
"дд"
|
|
1368
|
+
],
|
|
1369
|
+
sv: [
|
|
1370
|
+
"åååå",
|
|
1371
|
+
"mm",
|
|
1372
|
+
"dd"
|
|
1373
|
+
],
|
|
1374
|
+
szl: [
|
|
1375
|
+
"rrrr",
|
|
1376
|
+
"mm",
|
|
1377
|
+
"dd"
|
|
1378
|
+
],
|
|
1379
|
+
tg: [
|
|
1380
|
+
"сссс",
|
|
1381
|
+
"мм",
|
|
1382
|
+
"рр"
|
|
1383
|
+
],
|
|
1384
|
+
th: [
|
|
1385
|
+
"ปปปป",
|
|
1386
|
+
"ดด",
|
|
1387
|
+
"วว"
|
|
1388
|
+
],
|
|
1389
|
+
tr: [
|
|
1390
|
+
"yyyy",
|
|
1391
|
+
"aa",
|
|
1392
|
+
"gg"
|
|
1393
|
+
],
|
|
1394
|
+
uk: [
|
|
1395
|
+
"рррр",
|
|
1396
|
+
"мм",
|
|
1397
|
+
"дд"
|
|
1398
|
+
],
|
|
1399
|
+
"sr-Latn": [
|
|
1400
|
+
"gggg",
|
|
1401
|
+
"mm",
|
|
1402
|
+
"dd"
|
|
1403
|
+
],
|
|
1404
|
+
"zh-CN": [
|
|
1405
|
+
"年",
|
|
1406
|
+
"月",
|
|
1407
|
+
"日"
|
|
1408
|
+
],
|
|
1409
|
+
"zh-TW": [
|
|
1410
|
+
"年",
|
|
1411
|
+
"月",
|
|
1412
|
+
"日"
|
|
1413
|
+
]
|
|
1414
|
+
};
|
|
1415
|
+
function getLocaleLanguage(locale) {
|
|
1416
|
+
if (typeof Intl !== "undefined" && Intl.Locale) return new Intl.Locale(locale).language;
|
|
1417
|
+
return locale.split("-")[0];
|
|
1418
|
+
}
|
|
1419
|
+
function getLocaleScript(locale) {
|
|
1420
|
+
if (typeof Intl !== "undefined" && Intl.Locale) return new Intl.Locale(locale).script || void 0;
|
|
1421
|
+
const script = locale.split("-").find((part) => part.length === 4);
|
|
1422
|
+
if (!script) return void 0;
|
|
1423
|
+
return script.charAt(0).toUpperCase() + script.slice(1).toLowerCase();
|
|
1424
|
+
}
|
|
1425
|
+
function getLocalePlaceholders(locale) {
|
|
1426
|
+
const exact = LOCALE_PLACEHOLDERS[locale];
|
|
1427
|
+
if (exact) return exact;
|
|
1428
|
+
const lang = getLocaleLanguage(locale);
|
|
1429
|
+
const script = getLocaleScript(locale);
|
|
1430
|
+
if (script) {
|
|
1431
|
+
const langScript = `${lang}-${script}`;
|
|
1432
|
+
const langScriptPlaceholder = LOCALE_PLACEHOLDERS[langScript];
|
|
1433
|
+
if (langScriptPlaceholder) return langScriptPlaceholder;
|
|
1434
|
+
}
|
|
1435
|
+
return LOCALE_PLACEHOLDERS[lang] || LOCALE_PLACEHOLDERS.en;
|
|
1436
|
+
}
|
|
1437
|
+
const defaultTranslations = { placeholder(locale) {
|
|
1438
|
+
const [year, month, day] = getLocalePlaceholders(locale);
|
|
1439
|
+
return {
|
|
1440
|
+
day,
|
|
1441
|
+
month,
|
|
1442
|
+
year,
|
|
1443
|
+
hour: "––",
|
|
1444
|
+
minute: "––",
|
|
1445
|
+
second: "––",
|
|
1446
|
+
dayPeriod: "AM/PM",
|
|
1447
|
+
era: "era",
|
|
1448
|
+
timeZoneName: "timeZone",
|
|
1449
|
+
weekday: "weekday",
|
|
1450
|
+
unknown: "unknown",
|
|
1451
|
+
fractionalSecond: "ff"
|
|
1452
|
+
};
|
|
1453
|
+
} };
|
|
1454
|
+
//#endregion
|
|
1455
|
+
//#region src/machines/date-input/machine.ts
|
|
1456
|
+
const machine = require_core.createMachine({
|
|
1457
|
+
props({ props }) {
|
|
1458
|
+
const locale = props.locale || "en-US";
|
|
1459
|
+
const timeZone = props.timeZone || "UTC";
|
|
1460
|
+
const selectionMode = props.selectionMode || "single";
|
|
1461
|
+
const granularity = props.granularity || "day";
|
|
1462
|
+
const translations = {
|
|
1463
|
+
...defaultTranslations,
|
|
1464
|
+
...props.translations
|
|
1465
|
+
};
|
|
1466
|
+
const calendar = resolveCalendar(locale, props.createCalendar);
|
|
1467
|
+
const defaultValue = props.defaultValue ? props.defaultValue.map((date) => require_date_utils.constrainSegments(toTargetCalendar(date, calendar), props.min, props.max)) : [];
|
|
1468
|
+
const value = props.value ? props.value.map((date) => require_date_utils.constrainSegments(toTargetCalendar(date, calendar), props.min, props.max)) : void 0;
|
|
1469
|
+
const placeholderValue = resolvePlaceholderValue(props, timeZone, granularity, value, defaultValue, calendar);
|
|
1470
|
+
const hourCycle = resolveHourCycleProp(props.hourCycle);
|
|
1471
|
+
const shouldForceLeadingZeros = props.shouldForceLeadingZeros ?? false;
|
|
1472
|
+
const digitStyle = shouldForceLeadingZeros ? "2-digit" : "numeric";
|
|
1473
|
+
const firstValue = value?.[0] ?? defaultValue?.[0] ?? placeholderValue;
|
|
1474
|
+
const hasTimeZone = firstValue != null && "timeZone" in firstValue;
|
|
1475
|
+
const formatter = props.formatter ?? new _internationalized_date.DateFormatter(locale, getFormatterOptions({
|
|
1476
|
+
granularity,
|
|
1477
|
+
digitStyle,
|
|
1478
|
+
hourCycle,
|
|
1479
|
+
timeZone,
|
|
1480
|
+
hasTimeZone,
|
|
1481
|
+
hideTimeZone: props.hideTimeZone
|
|
1482
|
+
}));
|
|
1483
|
+
const allSegments = props.allSegments ?? resolveAllSegments(formatter);
|
|
1484
|
+
return {
|
|
1485
|
+
locale,
|
|
1486
|
+
timeZone,
|
|
1487
|
+
selectionMode,
|
|
1488
|
+
format: createFormatFn(formatter),
|
|
1489
|
+
...props,
|
|
1490
|
+
translations,
|
|
1491
|
+
value,
|
|
1492
|
+
defaultValue,
|
|
1493
|
+
granularity,
|
|
1494
|
+
shouldForceLeadingZeros,
|
|
1495
|
+
formatter,
|
|
1496
|
+
placeholderValue: typeof props.placeholderValue === "undefined" ? void 0 : placeholderValue,
|
|
1497
|
+
defaultPlaceholderValue: placeholderValue,
|
|
1498
|
+
allSegments
|
|
1499
|
+
};
|
|
1500
|
+
},
|
|
1501
|
+
initialState() {
|
|
1502
|
+
return "idle";
|
|
1503
|
+
},
|
|
1504
|
+
refs() {
|
|
1505
|
+
return {
|
|
1506
|
+
announcer: null,
|
|
1507
|
+
segmentToAnnounceIndex: null
|
|
1508
|
+
};
|
|
1509
|
+
},
|
|
1510
|
+
effects: ["setupLiveRegion"],
|
|
1511
|
+
context({ prop, bindable }) {
|
|
1512
|
+
const hourCycle = resolvedHourCycle(prop("formatter"));
|
|
1513
|
+
const placeholderValue = prop("defaultPlaceholderValue");
|
|
1514
|
+
const initialValue = prop("value") || prop("defaultValue");
|
|
1515
|
+
const groupCount = getGroupCount(prop("selectionMode"));
|
|
1516
|
+
return {
|
|
1517
|
+
value: bindable(() => ({
|
|
1518
|
+
defaultValue: prop("defaultValue"),
|
|
1519
|
+
value: prop("value"),
|
|
1520
|
+
isEqual(a, b) {
|
|
1521
|
+
if (a?.length !== b?.length) return false;
|
|
1522
|
+
const len = Math.max(a.length, b.length);
|
|
1523
|
+
for (let i = 0; i < len; i++) if (!require_date_utils.isDateEqual(a[i], b[i])) return false;
|
|
1524
|
+
return true;
|
|
1525
|
+
},
|
|
1526
|
+
hash: (v) => v.map((date) => date?.toString() ?? "").join(","),
|
|
1527
|
+
onChange(value) {
|
|
1528
|
+
const valueAsString = getValueAsString(value, prop);
|
|
1529
|
+
prop("onValueChange")?.({
|
|
1530
|
+
value,
|
|
1531
|
+
valueAsString
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
})),
|
|
1535
|
+
activeIndex: bindable(() => ({
|
|
1536
|
+
defaultValue: 0,
|
|
1537
|
+
sync: true
|
|
1538
|
+
})),
|
|
1539
|
+
activeSegmentIndex: bindable(() => ({
|
|
1540
|
+
defaultValue: -1,
|
|
1541
|
+
sync: true
|
|
1542
|
+
})),
|
|
1543
|
+
placeholderValue: bindable(() => ({
|
|
1544
|
+
defaultValue: prop("defaultPlaceholderValue"),
|
|
1545
|
+
isEqual: require_date_utils.isDateEqual,
|
|
1546
|
+
hash: (v) => v.toString(),
|
|
1547
|
+
onChange(placeholderValue) {
|
|
1548
|
+
prop("onPlaceholderChange")?.({
|
|
1549
|
+
value: prop("value") ?? [],
|
|
1550
|
+
valueAsString: [],
|
|
1551
|
+
placeholderValue
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
})),
|
|
1555
|
+
displayValues: bindable(() => ({
|
|
1556
|
+
defaultValue: initDisplayValues(initialValue, placeholderValue ?? require_date_utils.getTodayDate(prop("timeZone")), hourCycle, groupCount),
|
|
1557
|
+
isEqual: (a, b) => b != null && a.length === b.length && a.every((d, i) => incompleteDateEqual(d, b[i])),
|
|
1558
|
+
hash: (v) => v.map(incompleteDateHash).join("||")
|
|
1559
|
+
})),
|
|
1560
|
+
enteredKeys: bindable(() => ({
|
|
1561
|
+
defaultValue: "",
|
|
1562
|
+
sync: true
|
|
1563
|
+
}))
|
|
1564
|
+
};
|
|
1565
|
+
},
|
|
1566
|
+
computed: {
|
|
1567
|
+
isInteractive: ({ prop }) => !prop("disabled") && !prop("readOnly"),
|
|
1568
|
+
groupCount: ({ prop }) => getGroupCount(prop("selectionMode")),
|
|
1569
|
+
valueAsString: ({ context, prop }) => getValueAsString(context.get("value"), prop),
|
|
1570
|
+
segments: require_core.memo(({ context, prop }) => [
|
|
1571
|
+
context.hash("value"),
|
|
1572
|
+
prop("selectionMode"),
|
|
1573
|
+
context.hash("placeholderValue"),
|
|
1574
|
+
context.hash("displayValues"),
|
|
1575
|
+
prop("allSegments"),
|
|
1576
|
+
prop("timeZone"),
|
|
1577
|
+
prop("translations"),
|
|
1578
|
+
prop("granularity"),
|
|
1579
|
+
JSON.stringify(prop("formatter").resolvedOptions()),
|
|
1580
|
+
prop("locale")
|
|
1581
|
+
], (_deps, { context, prop, computed }) => {
|
|
1582
|
+
const value = context.get("value");
|
|
1583
|
+
const placeholderValue = context.get("placeholderValue");
|
|
1584
|
+
const displayValues = context.get("displayValues");
|
|
1585
|
+
const allSegments = prop("allSegments");
|
|
1586
|
+
const translations = prop("translations") || defaultTranslations;
|
|
1587
|
+
const granularity = prop("granularity");
|
|
1588
|
+
const formatter = prop("formatter");
|
|
1589
|
+
const locale = prop("locale");
|
|
1590
|
+
const allSegmentTypes = Object.keys(allSegments);
|
|
1591
|
+
return Array.from({ length: computed("groupCount") }, (_, i) => {
|
|
1592
|
+
const displayValue = displayValues[i] ?? new IncompleteDate(placeholderValue.calendar, resolvedHourCycle(formatter));
|
|
1593
|
+
const committedValue = value?.[i];
|
|
1594
|
+
const displayDate = committedValue && displayValue.isComplete(allSegmentTypes) ? committedValue : displayValue.toValue(placeholderValue);
|
|
1595
|
+
const segmentFormatter = displayValue.era === "BC" && displayValue.calendar.identifier === "gregory" ? new _internationalized_date.DateFormatter(locale, {
|
|
1596
|
+
...formatter.resolvedOptions(),
|
|
1597
|
+
era: "short"
|
|
1598
|
+
}) : formatter;
|
|
1599
|
+
return processSegments({
|
|
1600
|
+
dateValue: toFormatterDate(displayDate, segmentFormatter),
|
|
1601
|
+
displayValue,
|
|
1602
|
+
formatter: segmentFormatter,
|
|
1603
|
+
locale,
|
|
1604
|
+
translations,
|
|
1605
|
+
granularity
|
|
1606
|
+
});
|
|
1607
|
+
});
|
|
1608
|
+
})
|
|
1609
|
+
},
|
|
1610
|
+
watch({ track, context, prop, action }) {
|
|
1611
|
+
track([() => context.hash("value")], () => {
|
|
1612
|
+
action(["syncDisplayValues"]);
|
|
1613
|
+
});
|
|
1614
|
+
track([() => resolvedHourCycle(prop("formatter"))], () => {
|
|
1615
|
+
action(["syncDisplayValueHourCycle"]);
|
|
1616
|
+
});
|
|
1617
|
+
track([() => context.get("activeSegmentIndex")], () => {
|
|
1618
|
+
action(["focusActiveSegment"]);
|
|
1619
|
+
});
|
|
1620
|
+
track([() => prop("placeholderValue")?.toString()], () => {
|
|
1621
|
+
action(["syncPlaceholderProp"]);
|
|
1622
|
+
});
|
|
1623
|
+
track([() => prop("defaultPlaceholderValue")?.toString()], () => {
|
|
1624
|
+
action(["syncDefaultPlaceholderValue"]);
|
|
1625
|
+
});
|
|
1626
|
+
},
|
|
1627
|
+
on: {
|
|
1628
|
+
"VALUE.SET": { actions: ["setDateValue"] },
|
|
1629
|
+
"VALUE.CLEAR": { actions: [
|
|
1630
|
+
"clearDateValue",
|
|
1631
|
+
"clearDisplayValues",
|
|
1632
|
+
"clearEnteredKeys"
|
|
1633
|
+
] }
|
|
1634
|
+
},
|
|
1635
|
+
states: {
|
|
1636
|
+
idle: { on: { "SEGMENT.FOCUS": {
|
|
1637
|
+
target: "focused",
|
|
1638
|
+
actions: ["setActiveSegmentIndex", "invokeOnFocus"]
|
|
1639
|
+
} } },
|
|
1640
|
+
focused: { on: {
|
|
1641
|
+
"SEGMENT.FOCUS": { actions: ["setActiveSegmentIndex", "clearEnteredKeys"] },
|
|
1642
|
+
"SEGMENT.BLUR": {
|
|
1643
|
+
target: "idle",
|
|
1644
|
+
actions: [
|
|
1645
|
+
"confirmPlaceholder",
|
|
1646
|
+
"clearEnteredKeys",
|
|
1647
|
+
"invokeOnBlur"
|
|
1648
|
+
]
|
|
1649
|
+
},
|
|
1650
|
+
"SEGMENT.INPUT": { actions: ["setSegmentValue", "announceSegmentValue"] },
|
|
1651
|
+
"SEGMENT.ADJUST": { actions: [
|
|
1652
|
+
"invokeOnSegmentAdjust",
|
|
1653
|
+
"clearEnteredKeys",
|
|
1654
|
+
"announceSegmentValue"
|
|
1655
|
+
] },
|
|
1656
|
+
"SEGMENT.ARROW_LEFT": { actions: ["setPreviousActiveSegmentIndex", "clearEnteredKeys"] },
|
|
1657
|
+
"SEGMENT.ARROW_RIGHT": { actions: ["setNextActiveSegmentIndex", "clearEnteredKeys"] },
|
|
1658
|
+
"SEGMENT.BACKSPACE": [{
|
|
1659
|
+
guard: "isActiveSegmentPlaceholder",
|
|
1660
|
+
actions: ["setPreviousActiveSegmentIndex", "clearEnteredKeys"]
|
|
1661
|
+
}, { actions: ["clearSegmentValue", "announceSegmentValue"] }],
|
|
1662
|
+
"SEGMENT.HOME": { actions: [
|
|
1663
|
+
"setSegmentToLowestValue",
|
|
1664
|
+
"clearEnteredKeys",
|
|
1665
|
+
"announceSegmentValue"
|
|
1666
|
+
] },
|
|
1667
|
+
"SEGMENT.END": { actions: [
|
|
1668
|
+
"setSegmentToHighestValue",
|
|
1669
|
+
"clearEnteredKeys",
|
|
1670
|
+
"announceSegmentValue"
|
|
1671
|
+
] },
|
|
1672
|
+
"SEGMENT.PASTE": { actions: ["setPastedValue", "clearEnteredKeys"] }
|
|
1673
|
+
} }
|
|
1674
|
+
},
|
|
1675
|
+
implementations: {
|
|
1676
|
+
effects: { setupLiveRegion({ scope, refs }) {
|
|
1677
|
+
const liveRegion = require_live_region.createLiveRegion({
|
|
1678
|
+
level: "assertive",
|
|
1679
|
+
document: scope.getDoc()
|
|
1680
|
+
});
|
|
1681
|
+
refs.set("announcer", liveRegion);
|
|
1682
|
+
return () => liveRegion.destroy();
|
|
1683
|
+
} },
|
|
1684
|
+
guards: { isActiveSegmentPlaceholder: (ctx) => {
|
|
1685
|
+
if (ctx.context.get("enteredKeys") !== "") return false;
|
|
1686
|
+
return getActiveSegment(ctx)?.isPlaceholder === true;
|
|
1687
|
+
} },
|
|
1688
|
+
actions: {
|
|
1689
|
+
invokeOnFocus({ prop }) {
|
|
1690
|
+
prop("onFocusChange")?.({ focused: true });
|
|
1691
|
+
},
|
|
1692
|
+
invokeOnBlur({ prop }) {
|
|
1693
|
+
prop("onFocusChange")?.({ focused: false });
|
|
1694
|
+
},
|
|
1695
|
+
setActiveSegmentIndex({ context, event }) {
|
|
1696
|
+
if (event.dateIndex != null) context.set("activeIndex", event.dateIndex);
|
|
1697
|
+
context.set("activeSegmentIndex", event.segmentIndex);
|
|
1698
|
+
},
|
|
1699
|
+
clearDisplayValues({ context, prop, computed }) {
|
|
1700
|
+
const hourCycle = resolvedHourCycle(prop("formatter"));
|
|
1701
|
+
const placeholderValue = context.get("placeholderValue");
|
|
1702
|
+
context.set("displayValues", Array.from({ length: computed("groupCount") }, () => new IncompleteDate(placeholderValue.calendar, hourCycle)));
|
|
1703
|
+
},
|
|
1704
|
+
clearEnteredKeys({ context }) {
|
|
1705
|
+
context.set("enteredKeys", "");
|
|
1706
|
+
},
|
|
1707
|
+
setPreviousActiveSegmentIndex(ctx) {
|
|
1708
|
+
goToPreviousSegment(ctx);
|
|
1709
|
+
},
|
|
1710
|
+
setNextActiveSegmentIndex(ctx) {
|
|
1711
|
+
goToNextSegment(ctx);
|
|
1712
|
+
},
|
|
1713
|
+
focusActiveSegment({ scope, context }) {
|
|
1714
|
+
require_raf.raf(() => {
|
|
1715
|
+
getSegmentEls(scope)[context.get("activeSegmentIndex")]?.focus({ preventScroll: true });
|
|
1716
|
+
});
|
|
1717
|
+
},
|
|
1718
|
+
clearSegmentValue(params) {
|
|
1719
|
+
const { context, prop, event } = params;
|
|
1720
|
+
const index = context.get("activeIndex");
|
|
1721
|
+
const allSegments = prop("allSegments");
|
|
1722
|
+
const allSegmentTypes = Object.keys(allSegments);
|
|
1723
|
+
const placeholderValue = context.get("placeholderValue");
|
|
1724
|
+
const segment = getActiveSegment(params) ?? event.segment;
|
|
1725
|
+
const type = segment.type;
|
|
1726
|
+
let displayValue = getActiveDisplayValue(params);
|
|
1727
|
+
if (type === "dayPeriod") {
|
|
1728
|
+
const cleared = displayValue.clear(type);
|
|
1729
|
+
setDisplayValue(params, index, cleared);
|
|
1730
|
+
if (cleared.isCleared(allSegmentTypes)) commitClear(params, index);
|
|
1731
|
+
return;
|
|
1732
|
+
}
|
|
1733
|
+
if (type === "hour") {
|
|
1734
|
+
const cleared = displayValue.clear(type);
|
|
1735
|
+
setDisplayValue(params, index, cleared);
|
|
1736
|
+
if (cleared.isCleared(allSegmentTypes)) commitClear(params, index);
|
|
1737
|
+
return;
|
|
1738
|
+
}
|
|
1739
|
+
const enteredKeys = context.get("enteredKeys");
|
|
1740
|
+
const newValue = (enteredKeys !== "" ? enteredKeys : segment.text).slice(0, -1);
|
|
1741
|
+
if (newValue === "" || newValue === "0") {
|
|
1742
|
+
context.set("enteredKeys", "");
|
|
1743
|
+
const cleared = displayValue.clear(type);
|
|
1744
|
+
setDisplayValue(params, index, cleared);
|
|
1745
|
+
if (cleared.isCleared(allSegmentTypes)) commitClear(params, index);
|
|
1746
|
+
} else {
|
|
1747
|
+
context.set("enteredKeys", newValue);
|
|
1748
|
+
displayValue = displayValue.set(type, Number(newValue), placeholderValue);
|
|
1749
|
+
setDisplayValue(params, index, displayValue);
|
|
1750
|
+
}
|
|
1751
|
+
},
|
|
1752
|
+
invokeOnSegmentAdjust(params) {
|
|
1753
|
+
const { context, prop, event } = params;
|
|
1754
|
+
const { segment, amount } = event;
|
|
1755
|
+
const type = segment.type;
|
|
1756
|
+
const index = context.get("activeIndex");
|
|
1757
|
+
const allSegments = prop("allSegments");
|
|
1758
|
+
const allSegmentTypes = Object.keys(allSegments);
|
|
1759
|
+
const placeholderValue = context.get("placeholderValue");
|
|
1760
|
+
const displaySegmentTypes = allSegmentTypes;
|
|
1761
|
+
const next = getActiveDisplayValue(params).cycle(type, amount, placeholderValue, displaySegmentTypes);
|
|
1762
|
+
setDisplayValue(params, index, next);
|
|
1763
|
+
if (next.isComplete(allSegmentTypes)) commitValue(params, index, next);
|
|
1764
|
+
},
|
|
1765
|
+
setSegmentValue(params) {
|
|
1766
|
+
const { event, context, refs } = params;
|
|
1767
|
+
const { segment, input } = event;
|
|
1768
|
+
refs.set("segmentToAnnounceIndex", context.get("activeSegmentIndex"));
|
|
1769
|
+
const index = context.get("activeIndex");
|
|
1770
|
+
const displayValue = updateSegmentValue(params, segment, input);
|
|
1771
|
+
const allSegmentTypes = Object.keys(params.prop("allSegments"));
|
|
1772
|
+
if (displayValue && displayValue.isComplete(allSegmentTypes) && context.get("enteredKeys") === "") commitValue(params, index, displayValue);
|
|
1773
|
+
},
|
|
1774
|
+
setSegmentToLowestValue(params) {
|
|
1775
|
+
const { event, context, prop } = params;
|
|
1776
|
+
const { segment } = event;
|
|
1777
|
+
const index = context.get("activeIndex");
|
|
1778
|
+
const allSegmentTypes = Object.keys(prop("allSegments"));
|
|
1779
|
+
const placeholderValue = context.get("placeholderValue");
|
|
1780
|
+
if (segment.minValue == null) return;
|
|
1781
|
+
const displayValue = getActiveDisplayValue(params).set(segment.type, segment.minValue, placeholderValue);
|
|
1782
|
+
setDisplayValue(params, index, displayValue);
|
|
1783
|
+
if (displayValue.isComplete(allSegmentTypes)) commitValue(params, index, displayValue);
|
|
1784
|
+
},
|
|
1785
|
+
setSegmentToHighestValue(params) {
|
|
1786
|
+
const { event, context, prop } = params;
|
|
1787
|
+
const { segment } = event;
|
|
1788
|
+
const index = context.get("activeIndex");
|
|
1789
|
+
const allSegmentTypes = Object.keys(prop("allSegments"));
|
|
1790
|
+
const placeholderValue = context.get("placeholderValue");
|
|
1791
|
+
if (segment.maxValue == null) return;
|
|
1792
|
+
const displayValue = getActiveDisplayValue(params).set(segment.type, segment.maxValue, placeholderValue);
|
|
1793
|
+
setDisplayValue(params, index, displayValue);
|
|
1794
|
+
if (displayValue.isComplete(allSegmentTypes)) commitValue(params, index, displayValue);
|
|
1795
|
+
},
|
|
1796
|
+
setDateValue({ context, event, prop }) {
|
|
1797
|
+
if (!Array.isArray(event.value)) return;
|
|
1798
|
+
const value = event.value.map((date) => require_date_utils.constrainSegments(date, prop("min"), prop("max")));
|
|
1799
|
+
context.set("value", value);
|
|
1800
|
+
},
|
|
1801
|
+
clearDateValue({ context }) {
|
|
1802
|
+
context.set("value", []);
|
|
1803
|
+
},
|
|
1804
|
+
setPastedValue({ context, event, prop }) {
|
|
1805
|
+
try {
|
|
1806
|
+
const constrained = require_date_utils.constrainSegments(parse(event.value), prop("min"), prop("max"));
|
|
1807
|
+
const index = context.get("activeIndex");
|
|
1808
|
+
const values = Array.from(context.get("value"));
|
|
1809
|
+
values[index] = constrained;
|
|
1810
|
+
context.set("value", values);
|
|
1811
|
+
} catch {}
|
|
1812
|
+
},
|
|
1813
|
+
syncDisplayValues({ context, prop, computed }) {
|
|
1814
|
+
const value = context.get("value");
|
|
1815
|
+
const hourCycle = resolvedHourCycle(prop("formatter"));
|
|
1816
|
+
const placeholderValue = context.get("placeholderValue");
|
|
1817
|
+
context.set("displayValues", initDisplayValues(value?.length ? value : void 0, placeholderValue, hourCycle, computed("groupCount")));
|
|
1818
|
+
},
|
|
1819
|
+
syncDisplayValueHourCycle({ context, prop }) {
|
|
1820
|
+
const hourCycle = resolvedHourCycle(prop("formatter"));
|
|
1821
|
+
const dvs = context.get("displayValues");
|
|
1822
|
+
context.set("displayValues", dvs.map((dv) => dv.withHourCycle(hourCycle)));
|
|
1823
|
+
},
|
|
1824
|
+
syncDefaultPlaceholderValue({ prop, context }) {
|
|
1825
|
+
if (prop("placeholderValue") != null) return;
|
|
1826
|
+
const defaultPlaceholder = prop("defaultPlaceholderValue");
|
|
1827
|
+
if (!defaultPlaceholder) return;
|
|
1828
|
+
context.set("placeholderValue", defaultPlaceholder);
|
|
1829
|
+
},
|
|
1830
|
+
syncPlaceholderProp({ prop, context, computed }) {
|
|
1831
|
+
const propValue = prop("placeholderValue");
|
|
1832
|
+
if (propValue) {
|
|
1833
|
+
context.set("placeholderValue", propValue);
|
|
1834
|
+
const value = context.get("value");
|
|
1835
|
+
if (value?.length) {
|
|
1836
|
+
const hourCycle = resolvedHourCycle(prop("formatter"));
|
|
1837
|
+
context.set("displayValues", initDisplayValues(value, propValue, hourCycle, computed("groupCount")));
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
},
|
|
1841
|
+
announceSegmentValue({ refs, computed, context }) {
|
|
1842
|
+
const announcer = refs.get("announcer");
|
|
1843
|
+
if (!announcer) return;
|
|
1844
|
+
const index = context.get("activeIndex");
|
|
1845
|
+
const activeSegmentIndex = context.get("activeSegmentIndex");
|
|
1846
|
+
const segmentIndexToUse = refs.get("segmentToAnnounceIndex") ?? activeSegmentIndex;
|
|
1847
|
+
refs.set("segmentToAnnounceIndex", null);
|
|
1848
|
+
const allSegments = computed("segments");
|
|
1849
|
+
const segment = allSegments[index]?.[segmentIndexToUse - getGroupOffset(allSegments, index)];
|
|
1850
|
+
if (!segment || segment.type === "literal") return;
|
|
1851
|
+
const valueText = segment.isPlaceholder ? "Empty" : segment.text;
|
|
1852
|
+
announcer.announce(`${getSegmentLabel(segment.type)}, ${valueText}`);
|
|
1853
|
+
},
|
|
1854
|
+
confirmPlaceholder(params) {
|
|
1855
|
+
const { context, prop, computed } = params;
|
|
1856
|
+
const allSegments = prop("allSegments");
|
|
1857
|
+
const allSegmentTypes = Object.keys(allSegments);
|
|
1858
|
+
const dateCount = computed("groupCount");
|
|
1859
|
+
const placeholderValue = context.get("placeholderValue");
|
|
1860
|
+
let values = Array.from(context.get("value"));
|
|
1861
|
+
let shouldUpdateValue = false;
|
|
1862
|
+
for (let i = 0; i < dateCount; i++) {
|
|
1863
|
+
const displayValue = context.get("displayValues")[i];
|
|
1864
|
+
if (!displayValue) continue;
|
|
1865
|
+
const allExceptDayPeriod = allSegmentTypes.filter((s) => s !== "dayPeriod");
|
|
1866
|
+
if (allSegments.dayPeriod && displayValue.isComplete(allExceptDayPeriod) && displayValue.dayPeriod == null) {
|
|
1867
|
+
const filled = displayValue.set("dayPeriod", placeholderValue && "hour" in placeholderValue ? placeholderValue.hour >= 12 ? 1 : 0 : 0, placeholderValue);
|
|
1868
|
+
setDisplayValue(params, i, filled);
|
|
1869
|
+
values[i] = filled.toValue(placeholderValue);
|
|
1870
|
+
shouldUpdateValue = true;
|
|
1871
|
+
} else if (displayValue.isComplete(allSegmentTypes)) {
|
|
1872
|
+
values[i] = displayValue.toValue(placeholderValue);
|
|
1873
|
+
shouldUpdateValue = true;
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
const min = prop("min");
|
|
1877
|
+
const max = prop("max");
|
|
1878
|
+
if ((min || max) && values.length > 0) {
|
|
1879
|
+
values = values.map((d) => require_date_utils.constrainSegments(d, min, max));
|
|
1880
|
+
shouldUpdateValue = true;
|
|
1881
|
+
}
|
|
1882
|
+
if (shouldUpdateValue) context.set("value", values);
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
});
|
|
1887
|
+
function commitValue(params, index, displayValue) {
|
|
1888
|
+
const { context } = params;
|
|
1889
|
+
const placeholderValue = context.get("placeholderValue");
|
|
1890
|
+
const date = displayValue.toValue(placeholderValue);
|
|
1891
|
+
const values = Array.from(context.get("value"));
|
|
1892
|
+
values[index] = date;
|
|
1893
|
+
context.set("value", values);
|
|
1894
|
+
}
|
|
1895
|
+
function commitClear(params, index) {
|
|
1896
|
+
const { context } = params;
|
|
1897
|
+
const values = context.get("value");
|
|
1898
|
+
if (index < values.length) context.set("value", values.slice(0, index));
|
|
1899
|
+
}
|
|
1900
|
+
function toTargetCalendar(date, calendar) {
|
|
1901
|
+
if (!calendar) return date;
|
|
1902
|
+
if (date.calendar.identifier === calendar.identifier) return date;
|
|
1903
|
+
return (0, _internationalized_date.toCalendar)(date, calendar);
|
|
1904
|
+
}
|
|
1905
|
+
function resolveCalendar(locale, createCalendar) {
|
|
1906
|
+
if (!createCalendar) return void 0;
|
|
1907
|
+
const calendarId = new Intl.DateTimeFormat(locale).resolvedOptions().calendar;
|
|
1908
|
+
if (calendarId === "gregory" || calendarId === "iso8601") return void 0;
|
|
1909
|
+
return createCalendar(calendarId);
|
|
1910
|
+
}
|
|
1911
|
+
//#endregion
|
|
1912
|
+
//#region src/machines/date-input/props.ts
|
|
1913
|
+
const props = require_create_props.createProps()([
|
|
1914
|
+
"createCalendar",
|
|
1915
|
+
"dir",
|
|
1916
|
+
"disabled",
|
|
1917
|
+
"format",
|
|
1918
|
+
"getRootNode",
|
|
1919
|
+
"id",
|
|
1920
|
+
"ids",
|
|
1921
|
+
"invalid",
|
|
1922
|
+
"isDateUnavailable",
|
|
1923
|
+
"locale",
|
|
1924
|
+
"max",
|
|
1925
|
+
"min",
|
|
1926
|
+
"name",
|
|
1927
|
+
"form",
|
|
1928
|
+
"onFocusChange",
|
|
1929
|
+
"onPlaceholderChange",
|
|
1930
|
+
"onValueChange",
|
|
1931
|
+
"readOnly",
|
|
1932
|
+
"required",
|
|
1933
|
+
"selectionMode",
|
|
1934
|
+
"timeZone",
|
|
1935
|
+
"translations",
|
|
1936
|
+
"value",
|
|
1937
|
+
"defaultValue",
|
|
1938
|
+
"hourCycle",
|
|
1939
|
+
"hideTimeZone",
|
|
1940
|
+
"granularity",
|
|
1941
|
+
"shouldForceLeadingZeros",
|
|
1942
|
+
"allSegments",
|
|
1943
|
+
"formatter",
|
|
1944
|
+
"placeholderValue",
|
|
1945
|
+
"defaultPlaceholderValue"
|
|
1946
|
+
]);
|
|
1947
|
+
const splitProps = require_utils.createSplitProps(props);
|
|
1948
|
+
const segmentProps = require_create_props.createProps()(["segment", "index"]);
|
|
1949
|
+
const splitSegmentProps = require_utils.createSplitProps(segmentProps);
|
|
1950
|
+
const segmentGroupProps = require_create_props.createProps()(["index"]);
|
|
1951
|
+
const splitSegmentGroupProps = require_utils.createSplitProps(segmentGroupProps);
|
|
1952
|
+
const segmentsProps = require_create_props.createProps()(["index"]);
|
|
1953
|
+
const splitSegmentsProps = require_utils.createSplitProps(segmentsProps);
|
|
1954
|
+
const labelProps = require_create_props.createProps()(["index"]);
|
|
1955
|
+
const splitLabelProps = require_utils.createSplitProps(labelProps);
|
|
1956
|
+
const hiddenInputProps = require_create_props.createProps()(["index", "name"]);
|
|
1957
|
+
const splitHiddenInputProps = require_utils.createSplitProps(hiddenInputProps);
|
|
1958
|
+
//#endregion
|
|
1959
|
+
exports.anatomy = anatomy;
|
|
1960
|
+
exports.connect = connect;
|
|
1961
|
+
exports.hiddenInputProps = hiddenInputProps;
|
|
1962
|
+
exports.labelProps = labelProps;
|
|
1963
|
+
exports.machine = machine;
|
|
1964
|
+
exports.parse = parse;
|
|
1965
|
+
exports.props = props;
|
|
1966
|
+
exports.segmentGroupProps = segmentGroupProps;
|
|
1967
|
+
exports.segmentProps = segmentProps;
|
|
1968
|
+
exports.segmentsProps = segmentsProps;
|
|
1969
|
+
exports.splitHiddenInputProps = splitHiddenInputProps;
|
|
1970
|
+
exports.splitLabelProps = splitLabelProps;
|
|
1971
|
+
exports.splitProps = splitProps;
|
|
1972
|
+
exports.splitSegmentGroupProps = splitSegmentGroupProps;
|
|
1973
|
+
exports.splitSegmentProps = splitSegmentProps;
|
|
1974
|
+
exports.splitSegmentsProps = splitSegmentsProps;
|