@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,474 @@
|
|
|
1
|
+
import { CalendarDate, DateFormatter, endOfMonth, endOfWeek, endOfYear, getLocalTimeZone, getWeeksInMonth, isSameDay, maxDate, minDate, now, startOfMonth, startOfWeek, startOfYear, toCalendar, toCalendarDate, toCalendarDateTime, today } from "@internationalized/date";
|
|
2
|
+
|
|
3
|
+
//#region src/shared/date-utils/constrain.ts
|
|
4
|
+
function alignCenter(date, duration, locale, min, max) {
|
|
5
|
+
const halfDuration = {};
|
|
6
|
+
for (let prop in duration) {
|
|
7
|
+
const key = prop;
|
|
8
|
+
const value = duration[key];
|
|
9
|
+
if (value == null) continue;
|
|
10
|
+
halfDuration[key] = Math.floor(value / 2);
|
|
11
|
+
if (halfDuration[key] > 0 && value % 2 === 0) halfDuration[key]--;
|
|
12
|
+
}
|
|
13
|
+
return constrainStart(date, alignStart(date, duration, locale).subtract(halfDuration), duration, locale, min, max);
|
|
14
|
+
}
|
|
15
|
+
function alignStart(date, duration, locale, min, max) {
|
|
16
|
+
let aligned = date;
|
|
17
|
+
if (duration.years) aligned = startOfYear(date);
|
|
18
|
+
else if (duration.months) aligned = startOfMonth(date);
|
|
19
|
+
else if (duration.weeks) aligned = startOfWeek(date, locale);
|
|
20
|
+
return constrainStart(date, aligned, duration, locale, min, max);
|
|
21
|
+
}
|
|
22
|
+
function alignEnd(date, duration, locale, min, max) {
|
|
23
|
+
let d = { ...duration };
|
|
24
|
+
if (d.days) d.days--;
|
|
25
|
+
else if (d.weeks) d.weeks--;
|
|
26
|
+
else if (d.months) d.months--;
|
|
27
|
+
else if (d.years) d.years--;
|
|
28
|
+
return constrainStart(date, alignStart(date, duration, locale).subtract(d), duration, locale, min, max);
|
|
29
|
+
}
|
|
30
|
+
function constrainStart(date, aligned, duration, locale, min, max) {
|
|
31
|
+
if (min && date.compare(min) >= 0) aligned = maxDate(aligned, alignStart(toCalendarDate(min), duration, locale));
|
|
32
|
+
if (max && date.compare(max) <= 0) aligned = minDate(aligned, alignEnd(toCalendarDate(max), duration, locale));
|
|
33
|
+
return aligned;
|
|
34
|
+
}
|
|
35
|
+
function constrainValue(date, minValue, maxValue) {
|
|
36
|
+
let constrainedDate = toCalendarDate(date);
|
|
37
|
+
if (minValue) constrainedDate = maxDate(constrainedDate, toCalendarDate(minValue));
|
|
38
|
+
if (maxValue) constrainedDate = minDate(constrainedDate, toCalendarDate(maxValue));
|
|
39
|
+
return constrainedDate;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/shared/date-utils/align.ts
|
|
44
|
+
function alignDate(date, alignment, duration, locale, min, max) {
|
|
45
|
+
switch (alignment) {
|
|
46
|
+
case "start": return alignStart(date, duration, locale, min, max);
|
|
47
|
+
case "end": return alignEnd(date, duration, locale, min, max);
|
|
48
|
+
case "center":
|
|
49
|
+
default: return alignCenter(date, duration, locale, min, max);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
function alignStartDate(date, startDate, endDate, duration, locale, min, max) {
|
|
53
|
+
if (date.compare(startDate) < 0) return alignEnd(date, duration, locale, min, max);
|
|
54
|
+
if (date.compare(endDate) > 0) return alignStart(date, duration, locale, min, max);
|
|
55
|
+
return startDate;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/shared/date-utils/assertion.ts
|
|
60
|
+
function isDateEqual(dateA, dateB) {
|
|
61
|
+
if (dateA == null || dateB == null) return dateA === dateB;
|
|
62
|
+
return isSameDay(dateA, dateB);
|
|
63
|
+
}
|
|
64
|
+
function isDateUnavailable(date, isUnavailable, locale, minValue, maxValue) {
|
|
65
|
+
if (!date) return false;
|
|
66
|
+
if (isUnavailable?.(date, locale)) return true;
|
|
67
|
+
return isDateOutsideRange(date, minValue, maxValue);
|
|
68
|
+
}
|
|
69
|
+
function isDateOutsideRange(date, startDate, endDate) {
|
|
70
|
+
return startDate != null && date.compare(startDate) < 0 || endDate != null && date.compare(endDate) > 0;
|
|
71
|
+
}
|
|
72
|
+
function isPreviousRangeInvalid(startDate, minValue, maxValue) {
|
|
73
|
+
const prevDate = startDate.subtract({ days: 1 });
|
|
74
|
+
return isSameDay(prevDate, startDate) || isDateOutsideRange(prevDate, minValue, maxValue);
|
|
75
|
+
}
|
|
76
|
+
function isNextRangeInvalid(endDate, minValue, maxValue) {
|
|
77
|
+
const nextDate = endDate.add({ days: 1 });
|
|
78
|
+
return isSameDay(nextDate, endDate) || isDateOutsideRange(nextDate, minValue, maxValue);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/shared/date-utils/duration.ts
|
|
83
|
+
function getUnitDuration(duration) {
|
|
84
|
+
let clone = { ...duration };
|
|
85
|
+
for (let key in clone) clone[key] = 1;
|
|
86
|
+
return clone;
|
|
87
|
+
}
|
|
88
|
+
function getEndDate(startDate, duration) {
|
|
89
|
+
let clone = { ...duration };
|
|
90
|
+
if (clone.days) clone.days--;
|
|
91
|
+
else clone.days = -1;
|
|
92
|
+
return startDate.add(clone);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/shared/date-utils/get-era-format.ts
|
|
97
|
+
function getEraFormat(date) {
|
|
98
|
+
return date?.calendar.identifier === "gregory" && date.era === "BC" ? "short" : void 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/shared/date-utils/formatter.ts
|
|
103
|
+
function getDayFormatter(locale, timeZone) {
|
|
104
|
+
return new DateFormatter(locale, {
|
|
105
|
+
weekday: "long",
|
|
106
|
+
month: "long",
|
|
107
|
+
year: "numeric",
|
|
108
|
+
day: "numeric",
|
|
109
|
+
era: getEraFormat(toCalendarDateTime(today(timeZone))),
|
|
110
|
+
timeZone
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function getMonthFormatter(locale, timeZone) {
|
|
114
|
+
const date = today(timeZone);
|
|
115
|
+
return new DateFormatter(locale, {
|
|
116
|
+
month: "long",
|
|
117
|
+
year: "numeric",
|
|
118
|
+
era: getEraFormat(date),
|
|
119
|
+
calendar: date?.calendar.identifier,
|
|
120
|
+
timeZone
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/shared/date-utils/format.ts
|
|
126
|
+
function formatRange(startDate, endDate, formatter, toString, timeZone) {
|
|
127
|
+
let parts = formatter.formatRangeToParts(startDate.toDate(timeZone), endDate.toDate(timeZone));
|
|
128
|
+
let separatorIndex = -1;
|
|
129
|
+
for (let i = 0; i < parts.length; i++) {
|
|
130
|
+
let part = parts[i];
|
|
131
|
+
if (part.source === "shared" && part.type === "literal") separatorIndex = i;
|
|
132
|
+
else if (part.source === "endRange") break;
|
|
133
|
+
}
|
|
134
|
+
let start = "";
|
|
135
|
+
let end = "";
|
|
136
|
+
for (let i = 0; i < parts.length; i++) if (i < separatorIndex) start += parts[i].value;
|
|
137
|
+
else if (i > separatorIndex) end += parts[i].value;
|
|
138
|
+
return toString(start, end);
|
|
139
|
+
}
|
|
140
|
+
function formatSelectedDate(startDate, endDate, locale, timeZone) {
|
|
141
|
+
if (!startDate) return "";
|
|
142
|
+
let start = startDate;
|
|
143
|
+
let end = endDate ?? startDate;
|
|
144
|
+
let formatter = getDayFormatter(locale, timeZone);
|
|
145
|
+
if (isSameDay(start, end)) return formatter.format(start.toDate(timeZone));
|
|
146
|
+
return formatRange(start, end, formatter, (start$1, end$1) => `${start$1} – ${end$1}`, timeZone);
|
|
147
|
+
}
|
|
148
|
+
function formatVisibleRange(startDate, endDate, locale, timeZone) {
|
|
149
|
+
const start = startDate;
|
|
150
|
+
const end = endDate ?? startDate;
|
|
151
|
+
const dayFormatter = getDayFormatter(locale, timeZone);
|
|
152
|
+
if (!isSameDay(start, startOfMonth(start))) return dayFormatter.formatRange(start.toDate(timeZone), end.toDate(timeZone));
|
|
153
|
+
const monthFormatter = getMonthFormatter(locale, timeZone);
|
|
154
|
+
if (isSameDay(end, endOfMonth(start))) return monthFormatter.format(start.toDate(timeZone));
|
|
155
|
+
if (isSameDay(end, endOfMonth(end))) return monthFormatter.formatRange(start.toDate(timeZone), end.toDate(timeZone));
|
|
156
|
+
return "";
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/shared/date-utils/date-month.ts
|
|
161
|
+
const daysOfTheWeek = [
|
|
162
|
+
"sun",
|
|
163
|
+
"mon",
|
|
164
|
+
"tue",
|
|
165
|
+
"wed",
|
|
166
|
+
"thu",
|
|
167
|
+
"fri",
|
|
168
|
+
"sat"
|
|
169
|
+
];
|
|
170
|
+
function normalizeFirstDayOfWeek(firstDayOfWeek) {
|
|
171
|
+
return firstDayOfWeek != null ? daysOfTheWeek[firstDayOfWeek] : void 0;
|
|
172
|
+
}
|
|
173
|
+
function getStartOfWeek(date, locale, firstDayOfWeek) {
|
|
174
|
+
return startOfWeek(date, locale, normalizeFirstDayOfWeek(firstDayOfWeek));
|
|
175
|
+
}
|
|
176
|
+
function getEndOfWeek(date, locale, firstDayOfWeek = 0) {
|
|
177
|
+
return endOfWeek(date, locale, normalizeFirstDayOfWeek(firstDayOfWeek));
|
|
178
|
+
}
|
|
179
|
+
function getDaysInWeek(weekIndex, from, locale, firstDayOfWeek) {
|
|
180
|
+
const weekDate = from.add({ weeks: weekIndex });
|
|
181
|
+
const dates = [];
|
|
182
|
+
let date = getStartOfWeek(weekDate, locale, firstDayOfWeek);
|
|
183
|
+
while (dates.length < 7) {
|
|
184
|
+
dates.push(date);
|
|
185
|
+
let nextDate = date.add({ days: 1 });
|
|
186
|
+
if (isSameDay(date, nextDate)) break;
|
|
187
|
+
date = nextDate;
|
|
188
|
+
}
|
|
189
|
+
return dates;
|
|
190
|
+
}
|
|
191
|
+
function getMonthDays(from, locale, numOfWeeks, firstDayOfWeek) {
|
|
192
|
+
const firstDay = normalizeFirstDayOfWeek(firstDayOfWeek);
|
|
193
|
+
const monthWeeks = numOfWeeks ?? getWeeksInMonth(from, locale, firstDay);
|
|
194
|
+
return [...new Array(monthWeeks).keys()].map((week) => getDaysInWeek(week, from, locale, firstDayOfWeek));
|
|
195
|
+
}
|
|
196
|
+
function getWeekdayFormats(locale, timeZone) {
|
|
197
|
+
const longFormat = new DateFormatter(locale, {
|
|
198
|
+
weekday: "long",
|
|
199
|
+
timeZone
|
|
200
|
+
});
|
|
201
|
+
const shortFormat = new DateFormatter(locale, {
|
|
202
|
+
weekday: "short",
|
|
203
|
+
timeZone
|
|
204
|
+
});
|
|
205
|
+
const narrowFormat = new DateFormatter(locale, {
|
|
206
|
+
weekday: "narrow",
|
|
207
|
+
timeZone
|
|
208
|
+
});
|
|
209
|
+
return (value) => {
|
|
210
|
+
const date = value instanceof Date ? value : value.toDate(timeZone);
|
|
211
|
+
return {
|
|
212
|
+
value,
|
|
213
|
+
short: shortFormat.format(date),
|
|
214
|
+
long: longFormat.format(date),
|
|
215
|
+
narrow: narrowFormat.format(date)
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function getWeekDays(date, startOfWeekProp, timeZone, locale) {
|
|
220
|
+
const firstDayOfWeek = getStartOfWeek(date, locale, startOfWeekProp);
|
|
221
|
+
const weeks = [...new Array(7).keys()];
|
|
222
|
+
const format = getWeekdayFormats(locale, timeZone);
|
|
223
|
+
return weeks.map((index) => format(firstDayOfWeek.add({ days: index })));
|
|
224
|
+
}
|
|
225
|
+
function getMonthNames(locale, format = "long") {
|
|
226
|
+
const date = new Date(2021, 0, 1);
|
|
227
|
+
const monthNames = [];
|
|
228
|
+
for (let i = 0; i < 12; i++) {
|
|
229
|
+
monthNames.push(date.toLocaleString(locale, { month: format }));
|
|
230
|
+
date.setMonth(date.getMonth() + 1);
|
|
231
|
+
}
|
|
232
|
+
return monthNames;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region src/shared/date-utils/date-year.ts
|
|
237
|
+
function getYearsRange(range) {
|
|
238
|
+
const years = [];
|
|
239
|
+
for (let year = range.from; year <= range.to; year += 1) years.push(year);
|
|
240
|
+
return years;
|
|
241
|
+
}
|
|
242
|
+
const FUTURE_YEAR_COERCION = 10;
|
|
243
|
+
function normalizeYear(year) {
|
|
244
|
+
if (!year) return;
|
|
245
|
+
if (year.length === 3) return year.padEnd(4, "0");
|
|
246
|
+
if (year.length === 2) {
|
|
247
|
+
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
248
|
+
const fullYear = Math.floor(currentYear / 100) * 100 + parseInt(year.slice(-2), 10);
|
|
249
|
+
return fullYear > currentYear + FUTURE_YEAR_COERCION ? (fullYear - 100).toString() : fullYear.toString();
|
|
250
|
+
}
|
|
251
|
+
return year;
|
|
252
|
+
}
|
|
253
|
+
function getDecadeRange(year, opts) {
|
|
254
|
+
const chunkSize = opts?.strict ? 10 : 12;
|
|
255
|
+
const computedYear = year - year % 10;
|
|
256
|
+
const years = [];
|
|
257
|
+
for (let i = 0; i < chunkSize; i += 1) {
|
|
258
|
+
const value = computedYear + i;
|
|
259
|
+
years.push(value);
|
|
260
|
+
}
|
|
261
|
+
return years;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
//#endregion
|
|
265
|
+
//#region src/shared/date-utils/mutation.ts
|
|
266
|
+
function getTodayDate(timeZone) {
|
|
267
|
+
return today(timeZone ?? getLocalTimeZone());
|
|
268
|
+
}
|
|
269
|
+
function setCalendar(date, calendar) {
|
|
270
|
+
return toCalendar(toCalendarDateTime(date), calendar);
|
|
271
|
+
}
|
|
272
|
+
function setDate(date, startDate, isDateUnavailable$1, locale, minValue, maxValue) {
|
|
273
|
+
let result;
|
|
274
|
+
result = constrainValue(date, minValue, maxValue);
|
|
275
|
+
result = getPreviousAvailableDate(date, startDate, locale, isDateUnavailable$1);
|
|
276
|
+
return result;
|
|
277
|
+
}
|
|
278
|
+
function getPreviousAvailableDate(date, minValue, locale, isDateUnavailable$1) {
|
|
279
|
+
if (!isDateUnavailable$1) return date;
|
|
280
|
+
while (date.compare(minValue) >= 0 && isDateUnavailable$1(date, locale)) date = date.subtract({ days: 1 });
|
|
281
|
+
if (date.compare(minValue) >= 0) return date;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region src/shared/date-utils/pagination.ts
|
|
286
|
+
function getAdjustedDateFn(visibleDuration, locale, minValue, maxValue) {
|
|
287
|
+
return function getDate(options) {
|
|
288
|
+
const { startDate, focusedDate } = options;
|
|
289
|
+
const endDate = getEndDate(startDate, visibleDuration);
|
|
290
|
+
if (isDateOutsideRange(focusedDate, minValue, maxValue)) return {
|
|
291
|
+
startDate,
|
|
292
|
+
focusedDate: constrainValue(focusedDate, minValue, maxValue),
|
|
293
|
+
endDate
|
|
294
|
+
};
|
|
295
|
+
if (focusedDate.compare(startDate) < 0) return {
|
|
296
|
+
startDate: alignEnd(focusedDate, visibleDuration, locale, minValue, maxValue),
|
|
297
|
+
focusedDate: constrainValue(focusedDate, minValue, maxValue),
|
|
298
|
+
endDate
|
|
299
|
+
};
|
|
300
|
+
if (focusedDate.compare(endDate) > 0) return {
|
|
301
|
+
startDate: alignStart(focusedDate, visibleDuration, locale, minValue, maxValue),
|
|
302
|
+
endDate,
|
|
303
|
+
focusedDate: constrainValue(focusedDate, minValue, maxValue)
|
|
304
|
+
};
|
|
305
|
+
return {
|
|
306
|
+
startDate,
|
|
307
|
+
endDate,
|
|
308
|
+
focusedDate: constrainValue(focusedDate, minValue, maxValue)
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
function getNextPage(focusedDate, startDate, visibleDuration, locale, minValue, maxValue) {
|
|
313
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
314
|
+
const start = startDate.add(visibleDuration);
|
|
315
|
+
return adjust({
|
|
316
|
+
focusedDate: focusedDate.add(visibleDuration),
|
|
317
|
+
startDate: alignStart(constrainStart(focusedDate, start, visibleDuration, locale, minValue, maxValue), visibleDuration, locale)
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
function getPreviousPage(focusedDate, startDate, visibleDuration, locale, minValue, maxValue) {
|
|
321
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
322
|
+
let start = startDate.subtract(visibleDuration);
|
|
323
|
+
return adjust({
|
|
324
|
+
focusedDate: focusedDate.subtract(visibleDuration),
|
|
325
|
+
startDate: alignStart(constrainStart(focusedDate, start, visibleDuration, locale, minValue, maxValue), visibleDuration, locale)
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
function getNextRow(focusedDate, startDate, visibleDuration, locale, minValue, maxValue) {
|
|
329
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
330
|
+
if (visibleDuration.days) return getNextPage(focusedDate, startDate, visibleDuration, locale, minValue, maxValue);
|
|
331
|
+
if (visibleDuration.weeks || visibleDuration.months || visibleDuration.years) return adjust({
|
|
332
|
+
focusedDate: focusedDate.add({ weeks: 1 }),
|
|
333
|
+
startDate
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
function getPreviousRow(focusedDate, startDate, visibleDuration, locale, minValue, maxValue) {
|
|
337
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
338
|
+
if (visibleDuration.days) return getPreviousPage(focusedDate, startDate, visibleDuration, locale, minValue, maxValue);
|
|
339
|
+
if (visibleDuration.weeks || visibleDuration.months || visibleDuration.years) return adjust({
|
|
340
|
+
focusedDate: focusedDate.subtract({ weeks: 1 }),
|
|
341
|
+
startDate
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
function getSectionStart(focusedDate, startDate, visibleDuration, locale, minValue, maxValue) {
|
|
345
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
346
|
+
if (visibleDuration.days) return adjust({
|
|
347
|
+
focusedDate: startDate,
|
|
348
|
+
startDate
|
|
349
|
+
});
|
|
350
|
+
if (visibleDuration.weeks) return adjust({
|
|
351
|
+
focusedDate: startOfWeek(focusedDate, locale),
|
|
352
|
+
startDate
|
|
353
|
+
});
|
|
354
|
+
if (visibleDuration.months || visibleDuration.years) return adjust({
|
|
355
|
+
focusedDate: startOfMonth(focusedDate),
|
|
356
|
+
startDate
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
function getSectionEnd(focusedDate, startDate, visibleDuration, locale, minValue, maxValue) {
|
|
360
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
361
|
+
const endDate = getEndDate(startDate, visibleDuration);
|
|
362
|
+
if (visibleDuration.days) return adjust({
|
|
363
|
+
focusedDate: endDate,
|
|
364
|
+
startDate
|
|
365
|
+
});
|
|
366
|
+
if (visibleDuration.weeks) return adjust({
|
|
367
|
+
focusedDate: endOfWeek(focusedDate, locale),
|
|
368
|
+
startDate
|
|
369
|
+
});
|
|
370
|
+
if (visibleDuration.months || visibleDuration.years) return adjust({
|
|
371
|
+
focusedDate: endOfMonth(focusedDate),
|
|
372
|
+
startDate
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
function getNextSection(focusedDate, startDate, larger, visibleDuration, locale, minValue, maxValue) {
|
|
376
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
377
|
+
if (!larger && !visibleDuration.days) return adjust({
|
|
378
|
+
focusedDate: focusedDate.add(getUnitDuration(visibleDuration)),
|
|
379
|
+
startDate
|
|
380
|
+
});
|
|
381
|
+
if (visibleDuration.days) return getNextPage(focusedDate, startDate, visibleDuration, locale, minValue, maxValue);
|
|
382
|
+
if (visibleDuration.weeks) return adjust({
|
|
383
|
+
focusedDate: focusedDate.add({ months: 1 }),
|
|
384
|
+
startDate
|
|
385
|
+
});
|
|
386
|
+
if (visibleDuration.months || visibleDuration.years) return adjust({
|
|
387
|
+
focusedDate: focusedDate.add({ years: 1 }),
|
|
388
|
+
startDate
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
function getPreviousSection(focusedDate, startDate, larger, visibleDuration, locale, minValue, maxValue) {
|
|
392
|
+
const adjust = getAdjustedDateFn(visibleDuration, locale, minValue, maxValue);
|
|
393
|
+
if (!larger && !visibleDuration.days) return adjust({
|
|
394
|
+
focusedDate: focusedDate.subtract(getUnitDuration(visibleDuration)),
|
|
395
|
+
startDate
|
|
396
|
+
});
|
|
397
|
+
if (visibleDuration.days) return getPreviousPage(focusedDate, startDate, visibleDuration, locale, minValue, maxValue);
|
|
398
|
+
if (visibleDuration.weeks) return adjust({
|
|
399
|
+
focusedDate: focusedDate.subtract({ months: 1 }),
|
|
400
|
+
startDate
|
|
401
|
+
});
|
|
402
|
+
if (visibleDuration.months || visibleDuration.years) return adjust({
|
|
403
|
+
focusedDate: focusedDate.subtract({ years: 1 }),
|
|
404
|
+
startDate
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region src/shared/date-utils/parse-date.ts
|
|
410
|
+
const isValidYear = (year) => year != null && year.length === 4;
|
|
411
|
+
const isValidMonth = (month) => month != null && parseFloat(month) <= 12;
|
|
412
|
+
const isValidDay = (day) => day != null && parseFloat(day) <= 31;
|
|
413
|
+
function parseDateString(date, locale, timeZone) {
|
|
414
|
+
let { year, month, day } = extract(createRegex(locale, timeZone), date) ?? {};
|
|
415
|
+
if (year != null || month != null || day != null) {
|
|
416
|
+
const curr = /* @__PURE__ */ new Date();
|
|
417
|
+
year || (year = curr.getFullYear().toString());
|
|
418
|
+
month || (month = (curr.getMonth() + 1).toString());
|
|
419
|
+
day || (day = curr.getDate().toString());
|
|
420
|
+
}
|
|
421
|
+
if (!isValidYear(year)) year = normalizeYear(year);
|
|
422
|
+
if (isValidYear(year) && isValidMonth(month) && isValidDay(day)) return new CalendarDate(+year, +month, +day);
|
|
423
|
+
const time = Date.parse(date);
|
|
424
|
+
if (!isNaN(time)) {
|
|
425
|
+
const date$1 = new Date(time);
|
|
426
|
+
return new CalendarDate(date$1.getFullYear(), date$1.getMonth() + 1, date$1.getDate());
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
function createRegex(locale, timeZone) {
|
|
430
|
+
return new DateFormatter(locale, {
|
|
431
|
+
day: "numeric",
|
|
432
|
+
month: "numeric",
|
|
433
|
+
year: "numeric",
|
|
434
|
+
timeZone
|
|
435
|
+
}).formatToParts(new Date(2e3, 11, 25)).map(({ type, value }) => type === "literal" ? `${value}?` : `((?!=<${type}>)\\d+)?`).join("");
|
|
436
|
+
}
|
|
437
|
+
function extract(pattern, str) {
|
|
438
|
+
const matches = str.match(pattern);
|
|
439
|
+
return pattern.toString().match(/<(.+?)>/g)?.map((group) => {
|
|
440
|
+
const groupMatches = group.match(/<(.+)>/);
|
|
441
|
+
if (!groupMatches || groupMatches.length <= 0) return null;
|
|
442
|
+
return group.match(/<(.+)>/)?.[1];
|
|
443
|
+
}).reduce((acc, curr, index) => {
|
|
444
|
+
if (!curr) return acc;
|
|
445
|
+
if (matches && matches.length > index) acc[curr] = matches[index + 1];
|
|
446
|
+
else acc[curr] = null;
|
|
447
|
+
return acc;
|
|
448
|
+
}, {});
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
//#endregion
|
|
452
|
+
//#region src/shared/date-utils/preset.ts
|
|
453
|
+
function getDateRangePreset(preset, locale, timeZone) {
|
|
454
|
+
const today$1 = toCalendarDate(now(timeZone));
|
|
455
|
+
switch (preset) {
|
|
456
|
+
case "thisWeek": return [startOfWeek(today$1, locale), endOfWeek(today$1, locale)];
|
|
457
|
+
case "thisMonth": return [startOfMonth(today$1), today$1];
|
|
458
|
+
case "thisQuarter": return [startOfMonth(today$1).add({ months: -((today$1.month - 1) % 3) }), today$1];
|
|
459
|
+
case "thisYear": return [startOfYear(today$1), today$1];
|
|
460
|
+
case "last3Days": return [today$1.add({ days: -2 }), today$1];
|
|
461
|
+
case "last7Days": return [today$1.add({ days: -6 }), today$1];
|
|
462
|
+
case "last14Days": return [today$1.add({ days: -13 }), today$1];
|
|
463
|
+
case "last30Days": return [today$1.add({ days: -29 }), today$1];
|
|
464
|
+
case "last90Days": return [today$1.add({ days: -89 }), today$1];
|
|
465
|
+
case "lastMonth": return [startOfMonth(today$1.add({ months: -1 })), endOfMonth(today$1.add({ months: -1 }))];
|
|
466
|
+
case "lastQuarter": return [startOfMonth(today$1.add({ months: -((today$1.month - 1) % 3) - 3 })), endOfMonth(today$1.add({ months: -((today$1.month - 1) % 3) - 1 }))];
|
|
467
|
+
case "lastWeek": return [startOfWeek(today$1, locale).add({ weeks: -1 }), endOfWeek(today$1, locale).add({ weeks: -1 })];
|
|
468
|
+
case "lastYear": return [startOfYear(today$1.add({ years: -1 })), endOfYear(today$1.add({ years: -1 }))];
|
|
469
|
+
default: throw new Error(`Invalid date range preset: ${preset}`);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
//#endregion
|
|
474
|
+
export { getMonthFormatter as A, alignCenter as B, getStartOfWeek as C, formatSelectedDate as D, formatRange as E, isDateUnavailable as F, alignStart as H, isNextRangeInvalid as I, isPreviousRangeInvalid as L, getUnitDuration as M, isDateEqual as N, formatVisibleRange as O, isDateOutsideRange as P, alignDate as R, getMonthNames as S, getWeekdayFormats as T, constrainStart as U, alignEnd as V, constrainValue as W, getYearsRange as _, getNextRow as a, getEndOfWeek as b, getPreviousRow as c, getSectionStart as d, getPreviousAvailableDate as f, getDecadeRange as g, setDate as h, getNextPage as i, getEndDate as j, getDayFormatter as k, getPreviousSection as l, setCalendar as m, parseDateString as n, getNextSection as o, getTodayDate as p, getAdjustedDateFn as r, getPreviousPage as s, getDateRangePreset as t, getSectionEnd as u, normalizeYear as v, getWeekDays as w, getMonthDays as x, getDaysInWeek as y, alignStartDate as z };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const require_date_utils = require('./date-utils-D2xPHa_I.cjs');
|
|
2
|
+
|
|
3
|
+
exports.alignCenter = require_date_utils.alignCenter;
|
|
4
|
+
exports.alignDate = require_date_utils.alignDate;
|
|
5
|
+
exports.alignEnd = require_date_utils.alignEnd;
|
|
6
|
+
exports.alignStart = require_date_utils.alignStart;
|
|
7
|
+
exports.alignStartDate = require_date_utils.alignStartDate;
|
|
8
|
+
exports.constrainStart = require_date_utils.constrainStart;
|
|
9
|
+
exports.constrainValue = require_date_utils.constrainValue;
|
|
10
|
+
exports.formatRange = require_date_utils.formatRange;
|
|
11
|
+
exports.formatSelectedDate = require_date_utils.formatSelectedDate;
|
|
12
|
+
exports.formatVisibleRange = require_date_utils.formatVisibleRange;
|
|
13
|
+
exports.getAdjustedDateFn = require_date_utils.getAdjustedDateFn;
|
|
14
|
+
exports.getDateRangePreset = require_date_utils.getDateRangePreset;
|
|
15
|
+
exports.getDayFormatter = require_date_utils.getDayFormatter;
|
|
16
|
+
exports.getDaysInWeek = require_date_utils.getDaysInWeek;
|
|
17
|
+
exports.getDecadeRange = require_date_utils.getDecadeRange;
|
|
18
|
+
exports.getEndDate = require_date_utils.getEndDate;
|
|
19
|
+
exports.getEndOfWeek = require_date_utils.getEndOfWeek;
|
|
20
|
+
exports.getMonthDays = require_date_utils.getMonthDays;
|
|
21
|
+
exports.getMonthFormatter = require_date_utils.getMonthFormatter;
|
|
22
|
+
exports.getMonthNames = require_date_utils.getMonthNames;
|
|
23
|
+
exports.getNextPage = require_date_utils.getNextPage;
|
|
24
|
+
exports.getNextRow = require_date_utils.getNextRow;
|
|
25
|
+
exports.getNextSection = require_date_utils.getNextSection;
|
|
26
|
+
exports.getPreviousAvailableDate = require_date_utils.getPreviousAvailableDate;
|
|
27
|
+
exports.getPreviousPage = require_date_utils.getPreviousPage;
|
|
28
|
+
exports.getPreviousRow = require_date_utils.getPreviousRow;
|
|
29
|
+
exports.getPreviousSection = require_date_utils.getPreviousSection;
|
|
30
|
+
exports.getSectionEnd = require_date_utils.getSectionEnd;
|
|
31
|
+
exports.getSectionStart = require_date_utils.getSectionStart;
|
|
32
|
+
exports.getStartOfWeek = require_date_utils.getStartOfWeek;
|
|
33
|
+
exports.getTodayDate = require_date_utils.getTodayDate;
|
|
34
|
+
exports.getUnitDuration = require_date_utils.getUnitDuration;
|
|
35
|
+
exports.getWeekDays = require_date_utils.getWeekDays;
|
|
36
|
+
exports.getWeekdayFormats = require_date_utils.getWeekdayFormats;
|
|
37
|
+
exports.getYearsRange = require_date_utils.getYearsRange;
|
|
38
|
+
exports.isDateEqual = require_date_utils.isDateEqual;
|
|
39
|
+
exports.isDateOutsideRange = require_date_utils.isDateOutsideRange;
|
|
40
|
+
exports.isDateUnavailable = require_date_utils.isDateUnavailable;
|
|
41
|
+
exports.isNextRangeInvalid = require_date_utils.isNextRangeInvalid;
|
|
42
|
+
exports.isPreviousRangeInvalid = require_date_utils.isPreviousRangeInvalid;
|
|
43
|
+
exports.normalizeYear = require_date_utils.normalizeYear;
|
|
44
|
+
exports.parseDateString = require_date_utils.parseDateString;
|
|
45
|
+
exports.setCalendar = require_date_utils.setCalendar;
|
|
46
|
+
exports.setDate = require_date_utils.setDate;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { a as DateRangePreset, i as DateGranularity, n as DateAlignment, r as DateAvailableFn, t as DateAdjustFn } from "./types-GxLIgJib.cjs";
|
|
2
|
+
import * as _internationalized_date0 from "@internationalized/date";
|
|
3
|
+
import { Calendar, DateDuration, DateFormatter, DateValue } from "@internationalized/date";
|
|
4
|
+
|
|
5
|
+
//#region src/shared/date-utils/align.d.ts
|
|
6
|
+
declare function alignDate(date: DateValue, alignment: DateAlignment, duration: DateDuration, locale: string, min?: DateValue | undefined, max?: DateValue | undefined): DateValue;
|
|
7
|
+
declare function alignStartDate(date: DateValue, startDate: DateValue, endDate: DateValue, duration: DateDuration, locale: string, min?: DateValue | undefined, max?: DateValue | undefined): DateValue;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/shared/date-utils/assertion.d.ts
|
|
10
|
+
declare function isDateEqual(dateA: DateValue | null | undefined, dateB?: DateValue | null): boolean;
|
|
11
|
+
declare function isDateUnavailable(date: DateValue | null, isUnavailable: DateAvailableFn | undefined, locale: string, minValue?: DateValue | null, maxValue?: DateValue | null): boolean;
|
|
12
|
+
declare function isDateOutsideRange(date: DateValue, startDate?: DateValue | null, endDate?: DateValue | null): boolean;
|
|
13
|
+
declare function isPreviousRangeInvalid(startDate: DateValue, minValue?: DateValue | null, maxValue?: DateValue | null): boolean;
|
|
14
|
+
declare function isNextRangeInvalid(endDate: DateValue, minValue?: DateValue | null, maxValue?: DateValue | null): boolean;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/shared/date-utils/constrain.d.ts
|
|
17
|
+
declare function alignCenter(date: DateValue, duration: DateDuration, locale: string, min?: DateValue, max?: DateValue): DateValue;
|
|
18
|
+
declare function alignStart(date: DateValue, duration: DateDuration, locale: string, min?: DateValue, max?: DateValue): DateValue;
|
|
19
|
+
declare function alignEnd(date: DateValue, duration: DateDuration, locale: string, min?: DateValue, max?: DateValue): DateValue;
|
|
20
|
+
declare function constrainStart(date: DateValue, aligned: DateValue, duration: DateDuration, locale: string, min?: DateValue, max?: DateValue): DateValue;
|
|
21
|
+
declare function constrainValue(date: DateValue, minValue?: DateValue, maxValue?: DateValue): DateValue;
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/shared/date-utils/duration.d.ts
|
|
24
|
+
declare function getUnitDuration(duration: DateDuration): {
|
|
25
|
+
years?: number;
|
|
26
|
+
months?: number;
|
|
27
|
+
weeks?: number;
|
|
28
|
+
days?: number;
|
|
29
|
+
};
|
|
30
|
+
declare function getEndDate(startDate: DateValue, duration: DateDuration): _internationalized_date0.CalendarDate | _internationalized_date0.CalendarDateTime | _internationalized_date0.ZonedDateTime;
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/shared/date-utils/format.d.ts
|
|
33
|
+
declare function formatRange(startDate: DateValue, endDate: DateValue, formatter: DateFormatter, toString: (start: string, end: string) => string, timeZone: string): string;
|
|
34
|
+
declare function formatSelectedDate(startDate: DateValue | null | undefined, endDate: DateValue | null, locale: string, timeZone: string): string;
|
|
35
|
+
declare function formatVisibleRange(startDate: DateValue, endDate: DateValue | null, locale: string, timeZone: string): string;
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/shared/date-utils/formatter.d.ts
|
|
38
|
+
declare function getDayFormatter(locale: string, timeZone: string): DateFormatter;
|
|
39
|
+
declare function getMonthFormatter(locale: string, timeZone: string): DateFormatter;
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/shared/date-utils/date-month.d.ts
|
|
42
|
+
declare function getStartOfWeek(date: DateValue, locale: string, firstDayOfWeek?: number): DateValue;
|
|
43
|
+
declare function getEndOfWeek(date: DateValue, locale: string, firstDayOfWeek?: number): DateValue;
|
|
44
|
+
declare function getDaysInWeek(weekIndex: number, from: DateValue, locale: string, firstDayOfWeek?: number): DateValue[];
|
|
45
|
+
declare function getMonthDays(from: DateValue, locale: string, numOfWeeks?: number, firstDayOfWeek?: number): DateValue[][];
|
|
46
|
+
declare function getWeekdayFormats(locale: string, timeZone: string): <T extends DateValue | Date>(value: T) => {
|
|
47
|
+
value: T;
|
|
48
|
+
short: string;
|
|
49
|
+
long: string;
|
|
50
|
+
narrow: string;
|
|
51
|
+
};
|
|
52
|
+
declare function getWeekDays(date: DateValue, startOfWeekProp: number | undefined, timeZone: string, locale: string): {
|
|
53
|
+
value: _internationalized_date0.CalendarDate | _internationalized_date0.CalendarDateTime | _internationalized_date0.ZonedDateTime;
|
|
54
|
+
short: string;
|
|
55
|
+
long: string;
|
|
56
|
+
narrow: string;
|
|
57
|
+
}[];
|
|
58
|
+
declare function getMonthNames(locale: string, format?: Intl.DateTimeFormatOptions["month"]): string[];
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/shared/date-utils/date-year.d.ts
|
|
61
|
+
interface YearsRange {
|
|
62
|
+
from: number;
|
|
63
|
+
to: number;
|
|
64
|
+
}
|
|
65
|
+
declare function getYearsRange(range: YearsRange): number[];
|
|
66
|
+
declare function normalizeYear(year: string | null | undefined): string | undefined;
|
|
67
|
+
declare function getDecadeRange(year: number, opts?: {
|
|
68
|
+
strict?: boolean;
|
|
69
|
+
}): number[];
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/shared/date-utils/mutation.d.ts
|
|
72
|
+
declare function getTodayDate(timeZone?: string): _internationalized_date0.CalendarDate;
|
|
73
|
+
declare function setCalendar(date: DateValue, calendar: Calendar): _internationalized_date0.CalendarDateTime;
|
|
74
|
+
declare function setDate(date: DateValue, startDate: DateValue, isDateUnavailable: DateAvailableFn, locale: string, minValue: DateValue, maxValue: DateValue): DateValue | undefined;
|
|
75
|
+
declare function getPreviousAvailableDate(date: DateValue, minValue: DateValue, locale: string, isDateUnavailable?: DateAvailableFn): DateValue | undefined;
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/shared/date-utils/pagination.d.ts
|
|
78
|
+
interface AdjustDateParams {
|
|
79
|
+
startDate: DateValue;
|
|
80
|
+
focusedDate: DateValue;
|
|
81
|
+
}
|
|
82
|
+
interface AdjustDateReturn extends AdjustDateParams {
|
|
83
|
+
endDate: DateValue;
|
|
84
|
+
}
|
|
85
|
+
declare function getAdjustedDateFn(visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): (options: AdjustDateParams) => AdjustDateReturn;
|
|
86
|
+
declare function getNextPage(focusedDate: DateValue, startDate: DateValue, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn;
|
|
87
|
+
declare function getPreviousPage(focusedDate: DateValue, startDate: DateValue, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn;
|
|
88
|
+
declare function getNextRow(focusedDate: DateValue, startDate: DateValue, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn | undefined;
|
|
89
|
+
declare function getPreviousRow(focusedDate: DateValue, startDate: DateValue, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn | undefined;
|
|
90
|
+
declare function getSectionStart(focusedDate: DateValue, startDate: DateValue, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn | undefined;
|
|
91
|
+
declare function getSectionEnd(focusedDate: DateValue, startDate: DateValue, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn | undefined;
|
|
92
|
+
declare function getNextSection(focusedDate: DateValue, startDate: DateValue, larger: boolean, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn | undefined;
|
|
93
|
+
declare function getPreviousSection(focusedDate: DateValue, startDate: DateValue, larger: boolean, visibleDuration: DateDuration, locale: string, minValue?: DateValue, maxValue?: DateValue): AdjustDateReturn | undefined;
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/shared/date-utils/parse-date.d.ts
|
|
96
|
+
declare function parseDateString(date: string, locale: string, timeZone: string): DateValue | undefined;
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/shared/date-utils/preset.d.ts
|
|
99
|
+
declare function getDateRangePreset(preset: DateRangePreset, locale: string, timeZone: string): [DateValue, DateValue];
|
|
100
|
+
//#endregion
|
|
101
|
+
export { AdjustDateParams, AdjustDateReturn, DateAdjustFn, DateGranularity, DateRangePreset, YearsRange, alignCenter, alignDate, alignEnd, alignStart, alignStartDate, constrainStart, constrainValue, formatRange, formatSelectedDate, formatVisibleRange, getAdjustedDateFn, getDateRangePreset, getDayFormatter, getDaysInWeek, getDecadeRange, getEndDate, getEndOfWeek, getMonthDays, getMonthFormatter, getMonthNames, getNextPage, getNextRow, getNextSection, getPreviousAvailableDate, getPreviousPage, getPreviousRow, getPreviousSection, getSectionEnd, getSectionStart, getStartOfWeek, getTodayDate, getUnitDuration, getWeekDays, getWeekdayFormats, getYearsRange, isDateEqual, isDateOutsideRange, isDateUnavailable, isNextRangeInvalid, isPreviousRangeInvalid, normalizeYear, parseDateString, setCalendar, setDate };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as getMonthFormatter, B as constrainValue, C as getEndOfWeek, D as getWeekDays, E as getStartOfWeek, F as getUnitDuration, G as isPreviousRangeInvalid, H as isDateOutsideRange, I as alignCenter, J as DateAdjustFn, K as alignDate, L as alignEnd, M as formatSelectedDate, N as formatVisibleRange, O as getWeekdayFormats, P as getEndDate, R as alignStart, S as getDaysInWeek, T as getMonthNames, U as isDateUnavailable, V as isDateEqual, W as isNextRangeInvalid, X as DateRangePreset, Y as DateGranularity, _ as setDate, a as getAdjustedDateFn, b as getYearsRange, c as getNextSection, d as getPreviousSection, f as getSectionEnd, g as setCalendar, h as getTodayDate, i as AdjustDateReturn, j as formatRange, k as getDayFormatter, l as getPreviousPage, m as getPreviousAvailableDate, n as parseDateString, o as getNextPage, p as getSectionStart, q as alignStartDate, r as AdjustDateParams, s as getNextRow, t as getDateRangePreset, u as getPreviousRow, v as YearsRange, w as getMonthDays, x as normalizeYear, y as getDecadeRange, z as constrainStart } from "./index-CD5FN7kY.mjs";
|
|
2
|
+
export { AdjustDateParams, AdjustDateReturn, DateAdjustFn, DateGranularity, DateRangePreset, YearsRange, alignCenter, alignDate, alignEnd, alignStart, alignStartDate, constrainStart, constrainValue, formatRange, formatSelectedDate, formatVisibleRange, getAdjustedDateFn, getDateRangePreset, getDayFormatter, getDaysInWeek, getDecadeRange, getEndDate, getEndOfWeek, getMonthDays, getMonthFormatter, getMonthNames, getNextPage, getNextRow, getNextSection, getPreviousAvailableDate, getPreviousPage, getPreviousRow, getPreviousSection, getSectionEnd, getSectionStart, getStartOfWeek, getTodayDate, getUnitDuration, getWeekDays, getWeekdayFormats, getYearsRange, isDateEqual, isDateOutsideRange, isDateUnavailable, isNextRangeInvalid, isPreviousRangeInvalid, normalizeYear, parseDateString, setCalendar, setDate };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { A as getMonthFormatter, B as alignCenter, C as getStartOfWeek, D as formatSelectedDate, E as formatRange, F as isDateUnavailable, H as alignStart, I as isNextRangeInvalid, L as isPreviousRangeInvalid, M as getUnitDuration, N as isDateEqual, O as formatVisibleRange, P as isDateOutsideRange, R as alignDate, S as getMonthNames, T as getWeekdayFormats, U as constrainStart, V as alignEnd, W as constrainValue, _ as getYearsRange, a as getNextRow, b as getEndOfWeek, c as getPreviousRow, d as getSectionStart, f as getPreviousAvailableDate, g as getDecadeRange, h as setDate, i as getNextPage, j as getEndDate, k as getDayFormatter, l as getPreviousSection, m as setCalendar, n as parseDateString, o as getNextSection, p as getTodayDate, r as getAdjustedDateFn, s as getPreviousPage, t as getDateRangePreset, u as getSectionEnd, v as normalizeYear, w as getWeekDays, x as getMonthDays, y as getDaysInWeek, z as alignStartDate } from "./date-utils-wEa1hhpc.mjs";
|
|
2
|
+
|
|
3
|
+
export { alignCenter, alignDate, alignEnd, alignStart, alignStartDate, constrainStart, constrainValue, formatRange, formatSelectedDate, formatVisibleRange, getAdjustedDateFn, getDateRangePreset, getDayFormatter, getDaysInWeek, getDecadeRange, getEndDate, getEndOfWeek, getMonthDays, getMonthFormatter, getMonthNames, getNextPage, getNextRow, getNextSection, getPreviousAvailableDate, getPreviousPage, getPreviousRow, getPreviousSection, getSectionEnd, getSectionStart, getStartOfWeek, getTodayDate, getUnitDuration, getWeekDays, getWeekdayFormats, getYearsRange, isDateEqual, isDateOutsideRange, isDateUnavailable, isNextRangeInvalid, isPreviousRangeInvalid, normalizeYear, parseDateString, setCalendar, setDate };
|