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