@swisspost/design-system-components 10.0.0-next.65 → 10.0.0-next.67
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/cjs/{breakpoints-B81j4H4_.js → breakpoints-BTxzC_Qv.js} +4 -7
- package/dist/cjs/{get-focusable-children-SdEe5tt7.js → get-focusable-children-CL2gimr1.js} +4 -4
- package/dist/cjs/{get-root-CUAv4k4C.js → get-root-BIh00Adr.js} +2 -2
- package/dist/cjs/{index-CmbtQEJ0.js → index-Byyrsgop.js} +19 -11
- package/dist/cjs/{index-ChzLnSU8.js → index-qCzRmwgB.js} +2 -2
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{package-DJFRMOUR.js → package-BMq-R5Xi.js} +1 -1
- package/dist/cjs/post-accordion_2.cjs.entry.js +9 -10
- package/dist/cjs/post-autocomplete.cjs.entry.js +181 -0
- package/dist/cjs/post-avatar.cjs.entry.js +6 -7
- package/dist/cjs/post-back-to-top.cjs.entry.js +8 -9
- package/dist/cjs/post-banner.cjs.entry.js +5 -6
- package/dist/cjs/{post-breadcrumb-item_2.cjs.entry.js → post-breadcrumb-item.cjs.entry.js} +7 -22
- package/dist/cjs/post-breadcrumbs.cjs.entry.js +7 -8
- package/dist/cjs/{post-closebutton_13.cjs.entry.js → post-closebutton_14.cjs.entry.js} +88 -68
- package/dist/cjs/post-collapsible_2.cjs.entry.js +11 -12
- package/dist/cjs/post-components.cjs.js +2 -2
- package/dist/cjs/post-date-picker.cjs.entry.js +4619 -0
- package/dist/cjs/post-footer.cjs.entry.js +8 -9
- package/dist/cjs/post-linkarea.cjs.entry.js +3 -3
- package/dist/cjs/post-listbox-option.cjs.entry.js +26 -0
- package/dist/cjs/post-listbox.cjs.entry.js +151 -0
- package/dist/cjs/post-number-input.cjs.entry.js +20 -14
- package/dist/cjs/post-pagination.cjs.entry.js +10 -11
- package/dist/cjs/post-popover-trigger.cjs.entry.js +5 -6
- package/dist/cjs/post-popover.cjs.entry.js +7 -8
- package/dist/cjs/post-rating.cjs.entry.js +5 -6
- package/dist/cjs/post-stepper-item.cjs.entry.js +4 -4
- package/dist/cjs/post-stepper.cjs.entry.js +34 -14
- package/dist/cjs/post-tab-item.cjs.entry.js +5 -6
- package/dist/cjs/post-tab-panel.cjs.entry.js +5 -6
- package/dist/cjs/post-tabs.cjs.entry.js +8 -9
- package/dist/cjs/post-tooltip-trigger.cjs.entry.js +7 -10
- package/dist/cjs/post-tooltip.cjs.entry.js +5 -6
- package/dist/collection/animations/collapse.js +3 -2
- package/dist/collection/collection-manifest.json +5 -3
- package/dist/collection/components/post-accordion/post-accordion.js +3 -3
- package/dist/collection/components/post-accordion-item/post-accordion-item.css +1 -1
- package/dist/collection/components/post-accordion-item/post-accordion-item.js +3 -3
- package/dist/collection/components/post-autocomplete/post-autocomplete.css +1 -0
- package/dist/collection/components/post-autocomplete/post-autocomplete.js +271 -0
- package/dist/collection/components/post-avatar/post-avatar.js +2 -2
- package/dist/collection/components/post-back-to-top/post-back-to-top.js +4 -4
- package/dist/collection/components/post-banner/post-banner.js +1 -1
- package/dist/collection/components/post-breadcrumb-item/post-breadcrumb-item.js +3 -3
- package/dist/collection/components/post-breadcrumbs/post-breadcrumbs.js +3 -3
- package/dist/collection/components/post-closebutton/post-closebutton.js +1 -1
- package/dist/collection/components/post-collapsible/post-collapsible.css +1 -1
- package/dist/collection/components/post-collapsible/post-collapsible.js +4 -4
- package/dist/collection/components/post-collapsible-trigger/post-collapsible-trigger.js +1 -1
- package/dist/collection/components/post-date-picker/post-date-picker.css +5 -0
- package/dist/collection/components/{post-datepicker/post-datepicker.js → post-date-picker/post-date-picker.js} +139 -101
- package/dist/collection/components/post-footer/post-footer.css +1 -1
- package/dist/collection/components/post-footer/post-footer.js +3 -3
- package/dist/collection/components/post-header/post-header.js +13 -13
- package/dist/collection/components/post-icon/post-icon.js +16 -13
- package/dist/collection/components/post-language-menu/post-language-menu.css +1 -1
- package/dist/collection/components/post-language-menu/post-language-menu.js +1 -1
- package/dist/collection/components/post-language-menu-item/post-language-menu-item.css +1 -1
- package/dist/collection/components/post-language-menu-item/post-language-menu-item.js +2 -1
- package/dist/collection/components/post-linkarea/post-linkarea.js +1 -1
- package/dist/collection/components/post-listbox/post-listbox.css +1 -0
- package/dist/collection/components/post-listbox/post-listbox.js +293 -0
- package/dist/collection/components/post-listbox-option/post-listbox-option.css +1 -0
- package/dist/collection/components/post-listbox-option/post-listbox-option.js +109 -0
- package/dist/collection/components/post-logo/post-logo.js +1 -1
- package/dist/collection/components/post-mainnavigation/post-mainnavigation.js +1 -1
- package/dist/collection/components/post-megadropdown/post-megadropdown.js +5 -5
- package/dist/collection/components/post-megadropdown-trigger/post-megadropdown-trigger.js +1 -1
- package/dist/collection/components/post-menu/post-menu.js +2 -2
- package/dist/collection/components/post-menu-item/post-menu-item.js +1 -1
- package/dist/collection/components/post-menu-trigger/post-menu-trigger.js +1 -1
- package/dist/collection/components/post-number-input/post-number-input.css +4 -1
- package/dist/collection/components/post-number-input/post-number-input.js +12 -3
- package/dist/collection/components/post-pagination/post-pagination.js +6 -6
- package/dist/collection/components/post-popover/post-popover.js +1 -1
- package/dist/collection/components/post-popover-trigger/post-popover-trigger.js +1 -1
- package/dist/collection/components/post-popovercontainer/post-popovercontainer.js +45 -19
- package/dist/collection/components/post-rating/post-rating.js +1 -1
- package/dist/collection/components/post-stepper/post-stepper.js +50 -10
- package/dist/collection/components/post-stepper-item/post-stepper-item.css +1 -7
- package/dist/collection/components/post-stepper-item/post-stepper-item.js +1 -1
- package/dist/collection/components/post-tab-item/post-tab-item.js +1 -1
- package/dist/collection/components/post-tab-panel/post-tab-panel.js +1 -1
- package/dist/collection/components/post-tabs/post-tabs.js +4 -4
- package/dist/collection/components/post-togglebutton/post-togglebutton.js +1 -1
- package/dist/collection/components/post-tooltip/post-tooltip.js +1 -1
- package/dist/collection/components/post-tooltip-trigger/post-tooltip-trigger.js +6 -6
- package/dist/collection/utils/attribute-observer.js +2 -2
- package/dist/collection/utils/breakpoints.js +6 -5
- package/dist/collection/utils/get-focusable-children.js +3 -3
- package/dist/collection/utils/get-root.js +2 -2
- package/dist/collection/utils/index.js +1 -1
- package/dist/collection/utils/is-iso-date.js +14 -0
- package/dist/collection/utils/is-motion-reduced.js +2 -2
- package/dist/collection/utils/property-checkers/check-date.js +1 -1
- package/dist/collection/utils/property-checkers/check-iso-date.js +9 -0
- package/dist/collection/utils/property-checkers/constants.js +1 -1
- package/dist/collection/utils/property-checkers/index.js +1 -0
- package/dist/collection/utils/repeat-on-long-press.js +6 -6
- package/dist/collection/utils/sass-export.js +1 -1
- package/dist/collection/utils/tests/helpers/mock-match-media.js +11 -0
- package/dist/collection/utils/tests/helpers/mock-stencil-constants.js +12 -0
- package/dist/component-names.json +4 -1
- package/dist/components/breakpoints.js +1 -1
- package/dist/components/get-focusable-children.js +1 -1
- package/dist/components/get-root.js +1 -1
- package/dist/components/index.d.ts +8 -4
- package/dist/components/index.js +1 -1
- package/dist/components/package.js +1 -1
- package/dist/components/post-accordion-item2.js +1 -1
- package/dist/components/post-accordion2.js +1 -1
- package/dist/components/post-autocomplete.d.ts +11 -0
- package/dist/components/post-autocomplete.js +1 -0
- package/dist/components/post-avatar.js +1 -1
- package/dist/components/post-back-to-top.js +1 -1
- package/dist/components/post-banner.js +1 -1
- package/dist/components/post-breadcrumb-item2.js +1 -1
- package/dist/components/post-breadcrumbs.js +1 -1
- package/dist/components/post-closebutton2.js +1 -1
- package/dist/components/post-collapsible-trigger2.js +1 -1
- package/dist/components/post-collapsible2.js +1 -1
- package/dist/components/{post-datepicker.d.ts → post-date-picker.d.ts} +4 -4
- package/dist/components/post-date-picker.js +1 -0
- package/dist/components/post-footer.js +1 -1
- package/dist/components/post-header.js +1 -1
- package/dist/components/post-icon2.js +1 -1
- package/dist/components/post-language-menu-item.js +1 -1
- package/dist/components/post-language-menu.js +1 -1
- package/dist/components/post-linkarea.js +1 -1
- package/dist/components/post-listbox-option.d.ts +11 -0
- package/dist/components/post-listbox-option.js +1 -0
- package/dist/components/{post-env-test.d.ts → post-listbox.d.ts} +4 -4
- package/dist/components/post-listbox.js +1 -0
- package/dist/components/post-logo.js +1 -1
- package/dist/components/post-mainnavigation.js +1 -1
- package/dist/components/post-megadropdown-trigger.js +1 -1
- package/dist/components/post-megadropdown.js +1 -1
- package/dist/components/post-menu-item2.js +1 -1
- package/dist/components/post-menu-trigger2.js +1 -1
- package/dist/components/post-menu2.js +1 -1
- package/dist/components/post-number-input.js +1 -1
- package/dist/components/post-pagination.js +1 -1
- package/dist/components/post-popover-trigger.js +1 -1
- package/dist/components/post-popover.js +1 -1
- package/dist/components/post-popovercontainer2.js +1 -1
- package/dist/components/post-rating.js +1 -1
- package/dist/components/post-stepper-item.js +1 -1
- package/dist/components/post-stepper.js +1 -1
- package/dist/components/post-tab-item.js +1 -1
- package/dist/components/post-tab-panel.js +1 -1
- package/dist/components/post-tabs.js +1 -1
- package/dist/components/post-togglebutton2.js +1 -1
- package/dist/components/post-tooltip-trigger.js +1 -1
- package/dist/components/post-tooltip.js +1 -1
- package/dist/components/react/index.js +1 -1
- package/dist/components/react/{p-2xbmulgT.js → p-6dWji_Xt.js} +1 -1
- package/dist/components/react/p-BIQP_u-p.js +1 -0
- package/dist/components/react/p-BlBcIJe_.js +1 -0
- package/dist/components/react/{p-CVpHTlhD.js → p-Bq6Ye6Uc.js} +1 -1
- package/dist/components/react/p-BvY9Yl0A.js +1 -0
- package/dist/components/react/p-ByHBwvly.js +1 -0
- package/dist/components/react/{p-cien1JLp.js → p-C7drBbGl.js} +1 -1
- package/dist/components/react/p-CKkmf4_w.js +1 -0
- package/dist/components/react/p-CS77r1AS.js +1 -0
- package/dist/components/react/p-CY-_ZlW3.js +1 -0
- package/dist/components/react/p-D3Tx-0vM.js +1 -0
- package/dist/components/react/p-DVY9jsO7.js +1 -0
- package/dist/components/react/p-Djnfi-_S.js +1 -0
- package/dist/components/react/p-DlHbGhvD.js +1 -0
- package/dist/components/react/p-DxJ0OgPJ.js +1 -0
- package/dist/components/react/{p-NbS_MQaD.js → p-RpVuZS9R.js} +1 -1
- package/dist/components/react/post-accordion-item.js +1 -1
- package/dist/components/react/post-accordion.js +1 -1
- package/dist/components/react/post-autocomplete.d.ts +11 -0
- package/dist/components/react/post-autocomplete.js +1 -0
- package/dist/components/react/post-avatar.js +1 -1
- package/dist/components/react/post-back-to-top.js +1 -1
- package/dist/components/react/post-banner.js +1 -1
- package/dist/components/react/post-breadcrumb-item.js +1 -1
- package/dist/components/react/post-breadcrumbs.js +1 -1
- package/dist/components/react/post-closebutton.js +1 -1
- package/dist/components/react/post-collapsible-trigger.js +1 -1
- package/dist/components/react/post-collapsible.js +1 -1
- package/dist/components/react/{post-datepicker.d.ts → post-date-picker.d.ts} +4 -4
- package/dist/components/react/post-date-picker.js +1 -0
- package/dist/components/react/post-footer.js +1 -1
- package/dist/components/react/post-header.js +1 -1
- package/dist/components/react/post-icon.js +1 -1
- package/dist/components/react/post-language-menu-item.js +1 -1
- package/dist/components/react/post-language-menu.js +1 -1
- package/dist/components/react/post-linkarea.js +1 -1
- package/dist/components/react/post-listbox-option.d.ts +11 -0
- package/dist/components/react/post-listbox-option.js +1 -0
- package/dist/components/react/{post-env-test.d.ts → post-listbox.d.ts} +4 -4
- package/dist/components/react/post-listbox.js +1 -0
- package/dist/components/react/post-logo.js +1 -1
- package/dist/components/react/post-mainnavigation.js +1 -1
- package/dist/components/react/post-megadropdown-trigger.js +1 -1
- package/dist/components/react/post-megadropdown.js +1 -1
- package/dist/components/react/post-menu-item.js +1 -1
- package/dist/components/react/post-menu-trigger.js +1 -1
- package/dist/components/react/post-menu.js +1 -1
- package/dist/components/react/post-number-input.js +1 -1
- package/dist/components/react/post-pagination.js +1 -1
- package/dist/components/react/post-popover-trigger.js +1 -1
- package/dist/components/react/post-popover.js +1 -1
- package/dist/components/react/post-popovercontainer.js +1 -1
- package/dist/components/react/post-rating.js +1 -1
- package/dist/components/react/post-stepper-item.js +1 -1
- package/dist/components/react/post-stepper.js +1 -1
- package/dist/components/react/post-tab-item.js +1 -1
- package/dist/components/react/post-tab-panel.js +1 -1
- package/dist/components/react/post-tabs.js +1 -1
- package/dist/components/react/post-togglebutton.js +1 -1
- package/dist/components/react/post-tooltip-trigger.js +1 -1
- package/dist/components/react/post-tooltip.js +1 -1
- package/dist/docs.json +591 -111
- package/dist/esm/{breakpoints-_gmb7vUy.js → breakpoints-CZuqK5QS.js} +4 -7
- package/dist/esm/{get-focusable-children-CFWKPWu9.js → get-focusable-children-CckqSLu_.js} +4 -4
- package/dist/esm/{get-root-CXfAA093.js → get-root-gmtbd8C-.js} +2 -2
- package/dist/esm/{index-RRcOB_Q4.js → index-8Vx4ywJ4.js} +19 -11
- package/dist/esm/{index-CCMeku7U.js → index-D9bU2pIE.js} +3 -3
- package/dist/esm/loader.js +3 -3
- package/dist/esm/package-DVY9jsO7.js +3 -0
- package/dist/esm/post-accordion_2.entry.js +9 -10
- package/dist/esm/post-autocomplete.entry.js +179 -0
- package/dist/esm/post-avatar.entry.js +6 -7
- package/dist/esm/post-back-to-top.entry.js +8 -9
- package/dist/esm/post-banner.entry.js +5 -6
- package/dist/esm/{post-breadcrumb-item_2.entry.js → post-breadcrumb-item.entry.js} +8 -22
- package/dist/esm/post-breadcrumbs.entry.js +7 -8
- package/dist/esm/{post-closebutton_13.entry.js → post-closebutton_14.entry.js} +88 -69
- package/dist/esm/post-collapsible_2.entry.js +11 -12
- package/dist/esm/post-components.js +3 -3
- package/dist/esm/post-date-picker.entry.js +4617 -0
- package/dist/esm/post-footer.entry.js +8 -9
- package/dist/esm/post-linkarea.entry.js +3 -3
- package/dist/esm/post-listbox-option.entry.js +24 -0
- package/dist/esm/post-listbox.entry.js +149 -0
- package/dist/esm/post-number-input.entry.js +20 -14
- package/dist/esm/post-pagination.entry.js +10 -11
- package/dist/esm/post-popover-trigger.entry.js +5 -6
- package/dist/esm/post-popover.entry.js +7 -8
- package/dist/esm/post-rating.entry.js +5 -6
- package/dist/esm/post-stepper-item.entry.js +4 -4
- package/dist/esm/post-stepper.entry.js +34 -14
- package/dist/esm/post-tab-item.entry.js +5 -6
- package/dist/esm/post-tab-panel.entry.js +5 -6
- package/dist/esm/post-tabs.entry.js +8 -9
- package/dist/esm/post-tooltip-trigger.entry.js +7 -10
- package/dist/esm/post-tooltip.entry.js +5 -6
- package/dist/post-components/p-0962f02e.entry.js +1 -0
- package/dist/post-components/p-0c22b6cb.entry.js +1 -0
- package/dist/post-components/p-11dfed23.entry.js +1 -0
- package/dist/post-components/p-136052d8.entry.js +1 -0
- package/dist/post-components/p-15d519e6.entry.js +1 -0
- package/dist/post-components/p-16573e00.entry.js +1 -0
- package/dist/post-components/p-29859921.entry.js +1 -0
- package/dist/post-components/p-3a294f1a.entry.js +1 -0
- package/dist/post-components/p-44481053.entry.js +1 -0
- package/dist/post-components/p-61d99723.entry.js +1 -0
- package/dist/post-components/p-68196501.entry.js +1 -0
- package/dist/post-components/p-6badcfb3.entry.js +1 -0
- package/dist/post-components/p-6c2558a3.entry.js +1 -0
- package/dist/post-components/p-6debd1d3.entry.js +1 -0
- package/dist/post-components/p-7b44e7e5.entry.js +1 -0
- package/dist/post-components/p-81aca7ec.entry.js +1 -0
- package/dist/post-components/p-85af10b8.entry.js +1 -0
- package/dist/post-components/p-8Vx4ywJ4.js +2 -0
- package/dist/post-components/p-951b3be6.entry.js +1 -0
- package/dist/post-components/{p-71380a03.entry.js → p-9a3d4f38.entry.js} +1 -1
- package/dist/post-components/p-D81ozKs6.js +1 -0
- package/dist/post-components/p-D9bU2pIE.js +1 -0
- package/dist/post-components/p-DVY9jsO7.js +1 -0
- package/dist/post-components/p-DkA4Ai8j.js +1 -0
- package/dist/post-components/p-a4dd6a67.entry.js +1 -0
- package/dist/post-components/p-aFKnsRj1.js +1 -0
- package/dist/post-components/p-b13742e1.entry.js +1 -0
- package/dist/post-components/p-c5717005.entry.js +1 -0
- package/dist/post-components/p-ca7796c7.entry.js +1 -0
- package/dist/post-components/p-ce7bfb11.entry.js +1 -0
- package/dist/post-components/p-e14f0dd1.entry.js +1 -0
- package/dist/post-components/p-e5a2d0c3.entry.js +1 -0
- package/dist/post-components/post-components.css +6 -1
- package/dist/post-components/post-components.esm.js +1 -1
- package/dist/types/components/post-autocomplete/post-autocomplete.d.ts +34 -0
- package/dist/types/components/{post-datepicker/post-datepicker.d.ts → post-date-picker/post-date-picker.d.ts} +24 -14
- package/dist/types/components/post-listbox/post-listbox.d.ts +37 -0
- package/dist/types/components/post-listbox-option/post-listbox-option.d.ts +13 -0
- package/dist/types/components/post-number-input/post-number-input.d.ts +2 -0
- package/dist/types/components/post-popovercontainer/post-popovercontainer.d.ts +6 -0
- package/dist/types/components/post-stepper/post-stepper.d.ts +8 -1
- package/dist/types/components.d.ts +223 -45
- package/dist/types/utils/breakpoints.d.ts +1 -0
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/is-iso-date.d.ts +1 -0
- package/dist/types/utils/property-checkers/check-iso-date.d.ts +3 -0
- package/dist/types/utils/property-checkers/index.d.ts +1 -0
- package/dist/types/utils/tests/helpers/mock-match-media.d.ts +4 -0
- package/dist/types/utils/tests/helpers/mock-stencil-constants.d.ts +0 -0
- package/hydrate/index.js +744 -1425
- package/hydrate/index.mjs +744 -1425
- package/package.json +8 -6
- package/dist/cjs/environment-BQE9Unf_.js +0 -52
- package/dist/cjs/post-datepicker.cjs.entry.js +0 -4542
- package/dist/cjs/post-env-test.cjs.entry.js +0 -15
- package/dist/collection/components/post-datepicker/post-datepicker.css +0 -34
- package/dist/collection/utils/environment.js +0 -47
- package/dist/collection/utils/tests/environment/hydrate-app-helper.js +0 -16
- package/dist/collection/utils/tests/environment/post-env-test.js +0 -9
- package/dist/components/environment.js +0 -1
- package/dist/components/post-datepicker.js +0 -1
- package/dist/components/post-env-test.js +0 -1
- package/dist/components/react/p-BVGcVycs.js +0 -1
- package/dist/components/react/p-Bb0ejJa3.js +0 -1
- package/dist/components/react/p-CBB38gAg.js +0 -1
- package/dist/components/react/p-CEwsBpAR.js +0 -1
- package/dist/components/react/p-CL77OyqD.js +0 -1
- package/dist/components/react/p-CVM28gRr.js +0 -1
- package/dist/components/react/p-Cuxk8xu_.js +0 -1
- package/dist/components/react/p-D0kTIc3Y.js +0 -1
- package/dist/components/react/p-Dh2cMk5v.js +0 -1
- package/dist/components/react/p-Dl1nklBg.js +0 -1
- package/dist/components/react/p-DvTtC-0j.js +0 -1
- package/dist/components/react/p-Dw48xy24.js +0 -1
- package/dist/components/react/p-FxUVQ4Tx.js +0 -1
- package/dist/components/react/post-datepicker.js +0 -1
- package/dist/components/react/post-env-test.js +0 -1
- package/dist/esm/environment-CEmnRoA6.js +0 -49
- package/dist/esm/package-CBB38gAg.js +0 -3
- package/dist/esm/post-datepicker.entry.js +0 -4540
- package/dist/esm/post-env-test.entry.js +0 -13
- package/dist/post-components/p-04151002.entry.js +0 -1
- package/dist/post-components/p-07c80628.entry.js +0 -1
- package/dist/post-components/p-0e0e0009.entry.js +0 -1
- package/dist/post-components/p-241aa7cc.entry.js +0 -1
- package/dist/post-components/p-350a19e3.entry.js +0 -1
- package/dist/post-components/p-3a6ff125.entry.js +0 -1
- package/dist/post-components/p-4a257010.entry.js +0 -1
- package/dist/post-components/p-590f8dbc.entry.js +0 -1
- package/dist/post-components/p-5ef8eff1.entry.js +0 -1
- package/dist/post-components/p-62ac0e47.entry.js +0 -1
- package/dist/post-components/p-67f19828.entry.js +0 -1
- package/dist/post-components/p-821d479c.entry.js +0 -1
- package/dist/post-components/p-961e7f6b.entry.js +0 -1
- package/dist/post-components/p-96c560dd.entry.js +0 -1
- package/dist/post-components/p-CBB38gAg.js +0 -1
- package/dist/post-components/p-CCMeku7U.js +0 -1
- package/dist/post-components/p-CEmnRoA6.js +0 -1
- package/dist/post-components/p-DI-h_mEL.js +0 -1
- package/dist/post-components/p-DppMBmK1.js +0 -1
- package/dist/post-components/p-RRcOB_Q4.js +0 -2
- package/dist/post-components/p-Rr097A6n.js +0 -1
- package/dist/post-components/p-b09e2162.entry.js +0 -1
- package/dist/post-components/p-b8da1422.entry.js +0 -1
- package/dist/post-components/p-ba84aa42.entry.js +0 -1
- package/dist/post-components/p-c32285b8.entry.js +0 -1
- package/dist/post-components/p-cabfcd45.entry.js +0 -1
- package/dist/post-components/p-d7c5001b.entry.js +0 -1
- package/dist/post-components/p-da6a34db.entry.js +0 -1
- package/dist/post-components/p-e0558b08.entry.js +0 -1
- package/dist/post-components/p-f34600d5.entry.js +0 -1
- package/dist/types/utils/environment.d.ts +0 -26
- package/dist/types/utils/tests/environment/hydrate-app-helper.d.ts +0 -5
- package/dist/types/utils/tests/environment/post-env-test.d.ts +0 -3
- /package/dist/collection/components/{post-datepicker → post-date-picker}/locales.js +0 -0
- /package/dist/types/components/{post-datepicker → post-date-picker}/locales.d.ts +0 -0
|
@@ -0,0 +1,4619 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var index = require('./index-Byyrsgop.js');
|
|
4
|
+
var _commonjsHelpers = require('./_commonjsHelpers-BJu3ubxk.js');
|
|
5
|
+
var index$1 = require('./index-qCzRmwgB.js');
|
|
6
|
+
require('./breakpoints-BTxzC_Qv.js');
|
|
7
|
+
|
|
8
|
+
function isIsoDate(value) {
|
|
9
|
+
const ISO_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
10
|
+
if (!ISO_REGEX.test(value))
|
|
11
|
+
return false;
|
|
12
|
+
const date = new Date(value); // strict UTC parsing
|
|
13
|
+
if (Number.isNaN(date.getTime()))
|
|
14
|
+
return false;
|
|
15
|
+
// Roundtrip comparison to catch auto-corrected dates
|
|
16
|
+
// Use UTC getters to match the UTC parsing above - no timezone shift
|
|
17
|
+
const y = date.getUTCFullYear();
|
|
18
|
+
const m = String(date.getUTCMonth() + 1).padStart(2, '0');
|
|
19
|
+
const d = String(date.getUTCDate()).padStart(2, '0');
|
|
20
|
+
return `${y}-${m}-${d}` === value;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function checkIsoDate(component, prop) {
|
|
24
|
+
const value = component[prop];
|
|
25
|
+
if (!value)
|
|
26
|
+
return;
|
|
27
|
+
if (!isIsoDate(String(value))) {
|
|
28
|
+
console.error(`The prop \`${String(prop)}\` of the \`${component.host.localName}\` component must be in ISO format (YYYY-MM-DD).`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var airDatepicker$1 = {exports: {}};
|
|
33
|
+
|
|
34
|
+
var airDatepicker = airDatepicker$1.exports;
|
|
35
|
+
|
|
36
|
+
var hasRequiredAirDatepicker;
|
|
37
|
+
|
|
38
|
+
function requireAirDatepicker () {
|
|
39
|
+
if (hasRequiredAirDatepicker) return airDatepicker$1.exports;
|
|
40
|
+
hasRequiredAirDatepicker = 1;
|
|
41
|
+
(function (module, exports) {
|
|
42
|
+
!function(e,t){module.exports=t();}(airDatepicker,(function(){return function(){var e={d:function(t,i){for(var s in i)e.o(i,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:true,get:i[s]});},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t={};e.d(t,{default:function(){return R}});var i={days:"days",months:"months",years:"years",day:"day",month:"month",year:"year",eventChangeViewDate:"changeViewDate",eventChangeCurrentView:"changeCurrentView",eventChangeFocusDate:"changeFocusDate",eventChangeSelectedDate:"changeSelectedDate",eventChangeTime:"changeTime",eventChangeLastSelectedDate:"changeLastSelectedDate",actionSelectDate:"selectDate",actionUnselectDate:"unselectDate",cssClassWeekend:"-weekend-"},s={classes:"",inline:false,locale:{days:["Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота"],daysShort:["Вос","Пон","Вто","Сре","Чет","Пят","Суб"],daysMin:["Вс","Пн","Вт","Ср","Чт","Пт","Сб"],months:["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"],monthsShort:["Янв","Фев","Мар","Апр","Май","Июн","Июл","Авг","Сен","Окт","Ноя","Дек"],today:"Сегодня",clear:"Очистить",dateFormat:"dd.MM.yyyy",timeFormat:"HH:mm",firstDay:1},startDate:new Date,firstDay:"",weekends:[6,0],dateFormat:"",altField:"",altFieldDateFormat:"T",toggleSelected:true,keyboardNav:true,selectedDates:false,container:"",isMobile:false,visible:false,position:"bottom left",offset:12,view:i.days,minView:i.days,showOtherMonths:true,selectOtherMonths:true,moveToOtherMonthsOnSelect:true,showOtherYears:true,selectOtherYears:true,moveToOtherYearsOnSelect:true,minDate:"",maxDate:"",disableNavWhenOutOfRange:true,multipleDates:false,multipleDatesSeparator:", ",range:false,dynamicRange:true,buttons:false,monthsField:"monthsShort",showEvent:"focus",autoClose:false,fixedHeight:false,prevHtml:'<svg><path d="M 17,12 l -5,5 l 5,5"></path></svg>',nextHtml:'<svg><path d="M 14,12 l 5,5 l -5,5"></path></svg>',navTitles:{days:"MMMM, <i>yyyy</i>",months:"yyyy",years:"yyyy1 - yyyy2"},timepicker:false,onlyTimepicker:false,dateTimeSeparator:" ",timeFormat:"",minHours:0,maxHours:24,minMinutes:0,maxMinutes:59,hoursStep:1,minutesStep:1,onSelect:false,onChangeViewDate:false,onChangeView:false,onRenderCell:false,onShow:false,onHide:false,onClickDayName:false};function a(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:document;return "string"==typeof e?t.querySelector(e):e}function n(){let{tagName:e="div",className:t="",innerHtml:i="",id:s="",attrs:a={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=document.createElement(e);return t&&n.classList.add(...t.split(" ")),s&&(n.id=s),i&&(n.innerHTML=i),a&&r(n,a),n}function r(e,t){for(let[i,s]of Object.entries(t)) void 0!==s&&e.setAttribute(i,s);return e}function h(e){return new Date(e.getFullYear(),e.getMonth()+1,0).getDate()}function o(e){let t=e.getHours(),{hours:i,dayPeriod:s}=l(t);return {year:e.getFullYear(),month:e.getMonth(),fullMonth:e.getMonth()+1<10?"0"+(e.getMonth()+1):e.getMonth()+1,date:e.getDate(),fullDate:e.getDate()<10?"0"+e.getDate():e.getDate(),day:e.getDay(),hours:t,fullHours:d(t),hours12:i,dayPeriod:s,fullHours12:d(i),minutes:e.getMinutes(),fullMinutes:e.getMinutes()<10?"0"+e.getMinutes():e.getMinutes()}}function l(e){return {dayPeriod:e>11?"pm":"am",hours:e%12==0?12:e%12}}function d(e){return e<10?"0"+e:e}function c(e){let t=10*Math.floor(e.getFullYear()/10);return [t,t+9]}function u(){let e=[];for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];return i.forEach((t=>{if("object"==typeof t)for(let i in t)t[i]&&e.push(i);else t&&e.push(t);})),e.join(" ")}function p(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i.days;if(!e||!t)return false;let a=o(e),n=o(t);return {[i.days]:a.date===n.date&&a.month===n.month&&a.year===n.year,[i.months]:a.month===n.month&&a.year===n.year,[i.years]:a.year===n.year}[s]}function m(e,t,i){let s=g(e,false).getTime(),a=g(t,false).getTime();return i?s>=a:s>a}function v(e,t){return !m(e,t,true)}function g(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=new Date(e.getTime());return "boolean"!=typeof t||t||function(e){e.setHours(0,0,0,0);}(i),i}function D(e,t,i){e.length?e.forEach((e=>{e.addEventListener(t,i);})):e.addEventListener(t,i);}function y(e,t){return !(!e||e===document||e instanceof DocumentFragment)&&(e.matches(t)?e:y(e.parentNode,t))}function f(e,t,i){return e>i?i:e<t?t:e}function w(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];return i.filter((e=>e)).forEach((t=>{for(let[i,s]of Object.entries(t))if(void 0!==s&&"[object Object]"===s.toString()){let t=void 0!==e[i]?e[i].toString():void 0,a=s.toString(),n=Array.isArray(s)?[]:{};e[i]=e[i]?t!==a?n:e[i]:n,w(e[i],s);}else e[i]=s;})),e}function b(e){let t=e;return e instanceof Date||("string"==typeof e&&/^\d{4}-\d{2}-\d{2}$/.test(e)&&(e+="T00:00:00"),t=new Date(e)),isNaN(t.getTime())&&(console.log(`Unable to convert value "${e}" to Date object`),t=false),t}function $(e){let t="\\s|\\.|-|/|\\\\|,|\\$|\\!|\\?|:|;";return new RegExp("(^|>|"+t+")("+e+")($|<|"+t+")","g")}function k(e,t,i){return (t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var s=i.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return "symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:true,configurable:true,writable:true}):e[t]=i,e}class C{constructor(){let{type:e,date:t,dp:i,opts:s,body:a}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};k(this,"focus",(()=>{this.$cell.classList.add("-focus-"),this.focused=true;})),k(this,"removeFocus",(()=>{this.$cell.classList.remove("-focus-"),this.focused=false;})),k(this,"select",(()=>{this.$cell.classList.add("-selected-"),this.selected=true;})),k(this,"removeSelect",(()=>{this.$cell.classList.remove("-selected-","-range-from-","-range-to-"),this.selected=false;})),k(this,"onChangeSelectedDate",(()=>{this.isDisabled||(this._handleSelectedStatus(),this.opts.range&&this._handleRangeStatus());})),k(this,"onChangeFocusDate",(e=>{if(!e)return void(this.focused&&this.removeFocus());let t=p(e,this.date,this.type);t?this.focus():!t&&this.focused&&this.removeFocus(),this.opts.range&&this._handleRangeStatus();})),k(this,"render",(()=>(this.$cell.innerHTML=this._getHtml(),this._handleClasses(),this.$cell))),this.type=e,this.singleType=this.type.slice(0,-1),this.date=t,this.dp=i,this.opts=s,this.body=a,this.customData=false,this.init();}init(){var e,t;let{onRenderCell:i}=this.opts;i&&(this.customData=i({date:this.date,cellType:this.singleType,datepicker:this.dp})),this._createElement(),this._bindDatepickerEvents(),null!==(e=this.customData)&&void 0!==e&&e.disabled?this.dp.disableDate(this.date):false===(null===(t=this.customData)||void 0===t?void 0:t.disabled)&&this.dp.enableDate(this.date);}_bindDatepickerEvents(){this.dp.on(i.eventChangeSelectedDate,this.onChangeSelectedDate),this.dp.on(i.eventChangeFocusDate,this.onChangeFocusDate);}unbindDatepickerEvents(){this.dp.off(i.eventChangeSelectedDate,this.onChangeSelectedDate),this.dp.off(i.eventChangeFocusDate,this.onChangeFocusDate);}_createElement(){var e;let{year:t,month:i,fullMonth:s,date:a,fullDate:r}=o(this.date),h=(null===(e=this.customData)||void 0===e?void 0:e.attrs)||{};this.$cell=n({attrs:{"data-year":t,"data-month":i,"data-date":a,"data-iso-date":`${t}-${s}-${r}`,...h}}),this.$cell.adpCell=this;}_getClassName(){var e;let t=new Date,{selectOtherMonths:s,selectOtherYears:a}=this.opts,{minDate:n,maxDate:r,isDateDisabled:h}=this.dp,{day:l}=o(this.date),d=this._isOutOfMinMaxRange(),c=h(this.date),m=u("air-datepicker-cell",`-${this.singleType}-`,{"-current-":p(t,this.date,this.type),"-min-date-":n&&p(n,this.date,this.type),"-max-date-":r&&p(r,this.date,this.type)}),v="";switch(this.type){case i.days:v=u({"-weekend-":this.dp.isWeekend(l),"-other-month-":this.isOtherMonth,"-disabled-":this.isOtherMonth&&!s||d||c});break;case i.months:v=u({"-disabled-":d});break;case i.years:v=u({"-other-decade-":this.isOtherDecade,"-disabled-":d||this.isOtherDecade&&!a});}return u(m,v,null===(e=this.customData)||void 0===e?void 0:e.classes).split(" ")}_getHtml(){var e;let{year:t,month:s,date:a}=o(this.date),{showOtherMonths:n,showOtherYears:r}=this.opts;if(null!==(e=this.customData)&&void 0!==e&&e.html)return this.customData.html;switch(this.type){case i.days:return !n&&this.isOtherMonth?"":a;case i.months:return this.dp.locale[this.opts.monthsField][s];case i.years:return !r&&this.isOtherDecade?"":t}}_isOutOfMinMaxRange(){let{minDate:e,maxDate:t}=this.dp,{type:s,date:a}=this,{month:n,year:r,date:h}=o(a),l=s===i.days,d=s===i.years,c=!!e&&new Date(r,d?e.getMonth():n,l?h:e.getDate()),u=!!t&&new Date(r,d?t.getMonth():n,l?h:t.getDate());return e&&t?v(c,e)||m(u,t):e?v(c,e):t?m(u,t):void 0}destroy(){this.unbindDatepickerEvents();}_handleRangeStatus(){const{selectedDates:e,focusDate:t,rangeDateTo:i,rangeDateFrom:s}=this.dp,a=e.length;if(this.$cell.classList.remove("-range-from-","-range-to-","-in-range-"),!a)return;let n=s,r=i;if(1===a&&t){const i=m(t,e[0]);n=i?e[0]:t,r=i?t:e[0];}let h=u({"-in-range-":n&&r&&(o=this.date,l=n,d=r,m(o,l)&&v(o,d)),"-range-from-":n&&p(this.date,n,this.type),"-range-to-":r&&p(this.date,r,this.type)});var o,l,d;h&&this.$cell.classList.add(...h.split(" "));}_handleSelectedStatus(){let e=this.dp._checkIfDateIsSelected(this.date,this.type);e?this.select():!e&&this.selected&&this.removeSelect();}_handleInitialFocusStatus(){p(this.dp.focusDate,this.date,this.type)&&this.focus();}_handleClasses(){this.$cell.setAttribute("class",""),this._handleInitialFocusStatus(),this.dp.hasSelectedDates&&(this._handleSelectedStatus(),this.dp.opts.range&&this._handleRangeStatus()),this.$cell.classList.add(...this._getClassName());}get isDisabled(){return this.$cell.matches(".-disabled-")}get isOtherMonth(){return this.dp.isOtherMonth(this.date)}get isOtherDecade(){return this.dp.isOtherDecade(this.date)}}function _(e,t,i){return (t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var s=i.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return "symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:true,configurable:true,writable:true}):e[t]=i,e}let M={[i.days]:`<div class="air-datepicker-body--day-names"></div><div class="air-datepicker-body--cells -${i.days}-"></div>`,[i.months]:`<div class="air-datepicker-body--cells -${i.months}-"></div>`,[i.years]:`<div class="air-datepicker-body--cells -${i.years}-"></div>`};const S=".air-datepicker-cell";class T{constructor(e){let{dp:t,type:s,opts:a}=e;_(this,"handleClick",(e=>{let t=e.target.closest(S).adpCell;if(t.isDisabled)return;if(!this.dp.isMinViewReached)return void this.dp.down();let i=this.dp._checkIfDateIsSelected(t.date,t.type);i?this.dp._handleAlreadySelectedDates(i,t.date):this.dp.selectDate(t.date);})),_(this,"handleDayNameClick",(e=>{let t=e.target.getAttribute("data-day-index");this.opts.onClickDayName({dayIndex:Number(t),datepicker:this.dp});})),_(this,"onChangeCurrentView",(e=>{e!==this.type?this.hide():(this.show(),this.render());})),_(this,"onMouseOverCell",(e=>{let t=y(e.target,S);this.dp.setFocusDate(!!t&&t.adpCell.date);})),_(this,"onMouseOutCell",(()=>{this.dp.setFocusDate(false);})),_(this,"onClickBody",(e=>{let{onClickDayName:t}=this.opts,i=e.target;i.closest(S)&&this.handleClick(e),t&&i.closest(".air-datepicker-body--day-name")&&this.handleDayNameClick(e);})),_(this,"onMouseDown",(e=>{this.pressed=true;let t=y(e.target,S),i=t&&t.adpCell;p(i.date,this.dp.rangeDateFrom)&&(this.rangeFromFocused=true),p(i.date,this.dp.rangeDateTo)&&(this.rangeToFocused=true);})),_(this,"onMouseMove",(e=>{if(!this.pressed||!this.dp.isMinViewReached)return;e.preventDefault();let t=y(e.target,S),i=t&&t.adpCell,{selectedDates:s,rangeDateTo:a,rangeDateFrom:n}=this.dp;if(!i||i.isDisabled)return;let{date:r}=i;if(2===s.length){if(this.rangeFromFocused&&!m(r,a)){let{hours:e,minutes:t}=o(n);r.setHours(e),r.setMinutes(t),this.dp.rangeDateFrom=r,this.dp.replaceDate(n,r);}if(this.rangeToFocused&&!v(r,n)){let{hours:e,minutes:t}=o(a);r.setHours(e),r.setMinutes(t),this.dp.rangeDateTo=r,this.dp.replaceDate(a,r);}}})),_(this,"onMouseUp",(()=>{this.pressed=false,this.rangeFromFocused=false,this.rangeToFocused=false;})),_(this,"onChangeViewDate",((e,t)=>{if(!this.isVisible)return;let s=c(e),a=c(t);switch(this.dp.currentView){case i.days:if(p(e,t,i.months))return;break;case i.months:if(p(e,t,i.years))return;break;case i.years:if(s[0]===a[0]&&s[1]===a[1])return}this.render();})),_(this,"render",(()=>{this.destroyCells(),this._generateCells(),this.cells.forEach((e=>{this.$cells.appendChild(e.render());}));})),this.dp=t,this.type=s,this.opts=a,this.cells=[],this.$el="",this.pressed=false,this.isVisible=true,this.init();}init(){this._buildBaseHtml(),this.type===i.days&&this.renderDayNames(),this.render(),this._bindEvents(),this._bindDatepickerEvents();}_bindEvents(){let{range:e,dynamicRange:t}=this.opts;D(this.$el,"mouseover",this.onMouseOverCell),D(this.$el,"mouseout",this.onMouseOutCell),D(this.$el,"click",this.onClickBody),e&&t&&(D(this.$el,"mousedown",this.onMouseDown),D(this.$el,"mousemove",this.onMouseMove),D(window.document,"mouseup",this.onMouseUp));}_bindDatepickerEvents(){this.dp.on(i.eventChangeViewDate,this.onChangeViewDate),this.dp.on(i.eventChangeCurrentView,this.onChangeCurrentView);}_buildBaseHtml(){this.$el=n({className:`air-datepicker-body -${this.type}-`,innerHtml:M[this.type]}),this.$names=a(".air-datepicker-body--day-names",this.$el),this.$cells=a(".air-datepicker-body--cells",this.$el);}_getDayNamesHtml(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.dp.locale.firstDay,t="",s=this.dp.isWeekend,{onClickDayName:a}=this.opts,n=e,r=0;for(;r<7;){let e=n%7;t+=`<div class="${u("air-datepicker-body--day-name",{[i.cssClassWeekend]:s(e),"-clickable-":!!a})}" data-day-index='${e}'>${this.dp.locale.daysMin[e]}</div>`,r++,n++;}return t}renderDayNames(){this.$names.innerHTML=this._getDayNamesHtml();}_generateCell(e){let{type:t,dp:i,opts:s}=this;return new C({type:t,dp:i,opts:s,date:e,body:this})}_generateCells(){T.getDatesFunction(this.type)(this.dp,(e=>{this.cells.push(this._generateCell(e));}));}show(){this.isVisible=true,this.$el.classList.remove("-hidden-");}hide(){this.isVisible=false,this.$el.classList.add("-hidden-");}destroyCells(){this.cells.forEach((e=>e.destroy())),this.cells=[],this.$cells.innerHTML="";}destroy(){this.destroyCells(),this.dp.off(i.eventChangeViewDate,this.onChangeViewDate),this.dp.off(i.eventChangeCurrentView,this.onChangeCurrentView);}static getDaysDates(e,t){let{viewDate:i,opts:{fixedHeight:s},locale:{firstDay:a}}=e,n=h(i),{year:r,month:l}=o(i),d=new Date(r,l,1),c=new Date(r,l,n),u=d.getDay()-a,p=6-c.getDay()+a;u=u<0?u+7:u,p=p>6?p-7:p;let m=function(e,t){let{year:i,month:s,date:a}=o(e);return new Date(i,s,a-t)}(d,u),v=n+u+p,g=m.getDate(),{year:D,month:y}=o(m),f=0;s&&(v=42);const w=[];for(;f<v;){let e=new Date(D,y,g+f);t&&t(e),w.push(e),f++;}return w}static getMonthsDates(e,t){let{year:i}=e.parsedViewDate,s=0,a=[];for(;s<12;){const e=new Date(i,s);a.push(e),t&&t(e),s++;}return a}static getYearsDates(e,t){let i=c(e.viewDate),s=i[0]-1,a=i[1]+1,n=s,r=[];for(;n<=a;){const e=new Date(n,0);r.push(e),t&&t(e),n++;}return r}static getDatesFunction(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i.days;return {[i.days]:T.getDaysDates,[i.months]:T.getMonthsDates,[i.years]:T.getYearsDates}[e]}}function F(e,t,i){return (t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var s=i.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return "symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:true,configurable:true,writable:true}):e[t]=i,e}class V{constructor(e){let{dp:t,opts:i}=e;F(this,"onClickNav",(e=>{let t=y(e.target,".air-datepicker-nav--action");if(!t)return;let i=t.dataset.action;this.dp[i]();})),F(this,"onChangeViewDate",(()=>{this.render(),this._resetNavStatus(),this.handleNavStatus();})),F(this,"onChangeCurrentView",(()=>{this.render(),this._resetNavStatus(),this.handleNavStatus();})),F(this,"onClickNavTitle",(()=>{this.dp.isFinalView||this.dp.up();})),F(this,"update",(()=>{let{prevHtml:e,nextHtml:t}=this.opts;this.$prev.innerHTML=e,this.$next.innerHTML=t,this._resetNavStatus(),this.render(),this.handleNavStatus();})),F(this,"renderDelay",(()=>{setTimeout(this.render);})),F(this,"render",(()=>{this.$title.innerHTML=this._getTitle(),function(e,t){for(let i in t)t[i]?e.classList.add(i):e.classList.remove(i);}(this.$title,{"-disabled-":this.dp.isFinalView});})),this.dp=t,this.opts=i,this.init();}init(){this._createElement(),this._buildBaseHtml(),this._defineDOM(),this.render(),this.handleNavStatus(),this._bindEvents(),this._bindDatepickerEvents();}_defineDOM(){this.$title=a(".air-datepicker-nav--title",this.$el),this.$prev=a('[data-action="prev"]',this.$el),this.$next=a('[data-action="next"]',this.$el);}_bindEvents(){this.$el.addEventListener("click",this.onClickNav),this.$title.addEventListener("click",this.onClickNavTitle);}_bindDatepickerEvents(){this.dp.on(i.eventChangeViewDate,this.onChangeViewDate),this.dp.on(i.eventChangeCurrentView,this.onChangeCurrentView),this.isNavIsFunction&&(this.dp.on(i.eventChangeSelectedDate,this.renderDelay),this.dp.opts.timepicker&&this.dp.on(i.eventChangeTime,this.render));}destroy(){this.dp.off(i.eventChangeViewDate,this.onChangeViewDate),this.dp.off(i.eventChangeCurrentView,this.onChangeCurrentView),this.isNavIsFunction&&(this.dp.off(i.eventChangeSelectedDate,this.renderDelay),this.dp.opts.timepicker&&this.dp.off(i.eventChangeTime,this.render));}_createElement(){this.$el=n({tagName:"nav",className:"air-datepicker-nav"});}_getTitle(){let{dp:e,opts:t}=this,i=t.navTitles[e.currentView];return "function"==typeof i?i(e):e.formatDate(e.viewDate,i)}handleNavStatus(){let{disableNavWhenOutOfRange:e}=this.opts,{minDate:t,maxDate:s}=this.dp;if(!t&&!s||!e)return;let{year:a,month:n}=this.dp.parsedViewDate,r=!!t&&o(t),h=!!s&&o(s);switch(this.dp.currentView){case i.days:t&&r.month>=n&&r.year>=a&&this._disableNav("prev"),s&&h.month<=n&&h.year<=a&&this._disableNav("next");break;case i.months:t&&r.year>=a&&this._disableNav("prev"),s&&h.year<=a&&this._disableNav("next");break;case i.years:{let e=c(this.dp.viewDate);t&&r.year>=e[0]&&this._disableNav("prev"),s&&h.year<=e[1]&&this._disableNav("next");break}}}_disableNav(e){a('[data-action="'+e+'"]',this.$el).classList.add("-disabled-");}_resetNavStatus(){!function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];e.length?e.forEach((e=>{e.classList.remove(...i);})):e.classList.remove(...i);}(this.$el.querySelectorAll(".air-datepicker-nav--action"),"-disabled-");}_buildBaseHtml(){let{prevHtml:e,nextHtml:t}=this.opts;this.$el.innerHTML=`<div class="air-datepicker-nav--action" data-action="prev">${e}</div><div class="air-datepicker-nav--title"></div><div class="air-datepicker-nav--action" data-action="next">${t}</div>`;}get isNavIsFunction(){let{navTitles:e}=this.opts;return Object.keys(e).find((t=>"function"==typeof e[t]))}}var x={today:{content:e=>e.locale.today,onClick:e=>e.setViewDate(new Date)},clear:{content:e=>e.locale.clear,onClick:e=>e.clear()}};class H{constructor(e){let{dp:t,opts:i}=e;this.dp=t,this.opts=i,this.init();}init(){this.createElement(),this.render();}createElement(){this.$el=n({className:"air-datepicker-buttons"});}destroy(){this.$el.parentNode.removeChild(this.$el);}clearHtml(){return this.$el.innerHTML="",this}generateButtons(){let{buttons:e}=this.opts;Array.isArray(e)||(e=[e]),e.forEach((e=>{let t=e;"string"==typeof e&&x[e]&&(t=x[e]);let i=this.createButton(t);t.onClick&&this.attachEventToButton(i,t.onClick),this.$el.appendChild(i);}));}attachEventToButton(e,t){e.addEventListener("click",(()=>{t(this.dp);}));}createButton(e){let{content:t,className:i,tagName:s="button",attrs:a={}}=e;return n({tagName:s,innerHtml:`<span tabindex='-1'>${"function"==typeof t?t(this.dp):t}</span>`,className:u("air-datepicker-button",i),attrs:a})}render(){this.generateButtons();}}function E(e,t,i){return (t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var s=i.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return "symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:true,configurable:true,writable:true}):e[t]=i,e}class L{constructor(){let{opts:e,dp:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};E(this,"toggleTimepickerIsActive",(e=>{this.dp.timepickerIsActive=e;})),E(this,"onChangeSelectedDate",(e=>{let{date:t,updateTime:i=false}=e;t&&(this.setMinMaxTime(t),this.setCurrentTime(!!i&&t),this.addTimeToDate(t));})),E(this,"onChangeLastSelectedDate",(e=>{e&&(this.setTime(e),this.render());})),E(this,"onChangeInputRange",(e=>{let t=e.target;this[t.getAttribute("name")]=t.value,this.updateText(),this.dp.trigger(i.eventChangeTime,{hours:this.hours,minutes:this.minutes});})),E(this,"onMouseEnterLeave",(e=>{let t=e.target.getAttribute("name"),i=this.$minutesText;"hours"===t&&(i=this.$hoursText),i.classList.toggle("-focus-");})),E(this,"onFocus",(()=>{this.toggleTimepickerIsActive(true);})),E(this,"onBlur",(()=>{this.toggleTimepickerIsActive(false);})),this.opts=e,this.dp=t;let{timeFormat:s}=this.dp.locale;s&&(s.match($("h"))||s.match($("hh")))&&(this.ampm=true),this.init();}init(){this.setTime(this.dp.lastSelectedDate||this.dp.viewDate),this.createElement(),this.buildHtml(),this.defineDOM(),this.render(),this.bindDatepickerEvents(),this.bindDOMEvents();}bindDatepickerEvents(){this.dp.on(i.eventChangeSelectedDate,this.onChangeSelectedDate),this.dp.on(i.eventChangeLastSelectedDate,this.onChangeLastSelectedDate);}bindDOMEvents(){let e="input";navigator.userAgent.match(/trident/gi)&&(e="change"),D(this.$ranges,e,this.onChangeInputRange),D(this.$ranges,"mouseenter",this.onMouseEnterLeave),D(this.$ranges,"mouseleave",this.onMouseEnterLeave),D(this.$ranges,"focus",this.onFocus),D(this.$ranges,"mousedown",this.onFocus),D(this.$ranges,"blur",this.onBlur);}createElement(){this.$el=n({className:u("air-datepicker-time",{"-am-pm-":this.dp.ampm})});}destroy(){this.dp.off(i.eventChangeSelectedDate,this.onChangeSelectedDate),this.dp.off(i.eventChangeLastSelectedDate,this.onChangeLastSelectedDate),this.$el.parentNode.removeChild(this.$el);}buildHtml(){let{ampm:e,hours:t,displayHours:i,minutes:s,minHours:a,minMinutes:n,maxHours:r,maxMinutes:h,dayPeriod:o,opts:{hoursStep:l,minutesStep:c}}=this;this.$el.innerHTML=`<div class="air-datepicker-time--current"> <span class="air-datepicker-time--current-hours">${d(i)}</span> <span class="air-datepicker-time--current-colon">:</span> <span class="air-datepicker-time--current-minutes">${d(s)}</span> `+(e?`<span class='air-datepicker-time--current-ampm'>${o}</span>`:"")+'</div><div class="air-datepicker-time--sliders"> <div class="air-datepicker-time--row">'+` <input type="range" name="hours" value="${t}" min="${a}" max="${r}" step="${l}"/> </div> <div class="air-datepicker-time--row">`+` <input type="range" name="minutes" value="${s}" min="${n}" max="${h}" step="${c}"/> </div></div>`;}defineDOM(){let e=e=>a(e,this.$el);this.$ranges=this.$el.querySelectorAll('[type="range"]'),this.$hours=e('[name="hours"]'),this.$minutes=e('[name="minutes"]'),this.$hoursText=e(".air-datepicker-time--current-hours"),this.$minutesText=e(".air-datepicker-time--current-minutes"),this.$ampm=e(".air-datepicker-time--current-ampm");}setTime(e){this.setMinMaxTime(e),this.setCurrentTime(e);}addTimeToDate(e){e&&(e.setHours(this.hours),e.setMinutes(this.minutes));}setMinMaxTime(e){if(this.setMinMaxTimeFromOptions(),e){let{minDate:t,maxDate:i}=this.dp;t&&p(e,t)&&this.setMinTimeFromMinDate(t),i&&p(e,i)&&this.setMaxTimeFromMaxDate(i);}}setCurrentTime(e){let{hours:t,minutes:i}=e?o(e):this;this.hours=f(t,this.minHours,this.maxHours),this.minutes=f(i,this.minMinutes,this.maxMinutes);}setMinMaxTimeFromOptions(){let{minHours:e,minMinutes:t,maxHours:i,maxMinutes:s}=this.opts;this.minHours=f(e,0,23),this.minMinutes=f(t,0,59),this.maxHours=f(i,0,23),this.maxMinutes=f(s,0,59);}setMinTimeFromMinDate(e){let{lastSelectedDate:t}=this.dp;this.minHours=e.getHours(),t&&t.getHours()>e.getHours()?this.minMinutes=this.opts.minMinutes:this.minMinutes=e.getMinutes();}setMaxTimeFromMaxDate(e){let{lastSelectedDate:t}=this.dp;this.maxHours=e.getHours(),t&&t.getHours()<e.getHours()?this.maxMinutes=this.opts.maxMinutes:this.maxMinutes=e.getMinutes();}updateSliders(){r(this.$hours,{min:this.minHours,max:this.maxHours}).value=this.hours,r(this.$minutes,{min:this.minMinutes,max:this.maxMinutes}).value=this.minutes;}updateText(){this.$hoursText.innerHTML=d(this.displayHours),this.$minutesText.innerHTML=d(this.minutes),this.ampm&&(this.$ampm.innerHTML=this.dayPeriod);}set hours(e){this._hours=e;let{hours:t,dayPeriod:i}=l(e);this.displayHours=this.ampm?t:e,this.dayPeriod=i;}get hours(){return this._hours}render(){this.updateSliders(),this.updateText();}}function A(e,t,i){return (t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var s=i.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return "symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:true,configurable:true,writable:true}):e[t]=i,e}class O{constructor(e){let{dp:t,opts:i}=e;A(this,"pressedKeys",new Set),A(this,"hotKeys",new Map([[[["Control","ArrowRight"],["Control","ArrowUp"]],e=>e.month++],[[["Control","ArrowLeft"],["Control","ArrowDown"]],e=>e.month--],[[["Shift","ArrowRight"],["Shift","ArrowUp"]],e=>e.year++],[[["Shift","ArrowLeft"],["Shift","ArrowDown"]],e=>e.year--],[[["Alt","ArrowRight"],["Alt","ArrowUp"]],e=>e.year+=10],[[["Alt","ArrowLeft"],["Alt","ArrowDown"]],e=>e.year-=10],[["Control","Shift","ArrowUp"],(e,t)=>t.up()]])),A(this,"handleHotKey",(e=>{let t=this.hotKeys.get(e),i=o(this.getInitialFocusDate());t(i,this.dp);let{year:s,month:a,date:n}=i,r=h(new Date(s,a));r<n&&(n=r);let l=this.dp.getClampedDate(new Date(s,a,n));this.dp.setFocusDate(l,{viewDateTransition:true});})),A(this,"isHotKeyPressed",(()=>{let e=false,t=this.pressedKeys.size,i=e=>this.pressedKeys.has(e);for(let[s]of this.hotKeys){if(e)break;if(Array.isArray(s[0]))s.forEach((a=>{e||t!==a.length||(e=a.every(i)&&s);}));else {if(t!==s.length)continue;e=s.every(i)&&s;}}return e})),A(this,"isArrow",(e=>e>=37&&e<=40)),A(this,"onKeyDown",(e=>{if(!this.dp.visible&&!this.dp.treatAsInline)return;let{key:t,which:i}=e,{dp:s,dp:{focusDate:a},opts:n}=this;this.registerKey(t);let r=this.isHotKeyPressed();if(r)return e.preventDefault(),void this.handleHotKey(r);if(this.isArrow(i))return e.preventDefault(),void this.focusNextCell(t);if("Enter"===t){if(s.currentView!==n.minView)return void s.down();if(a){let e=s._checkIfDateIsSelected(a);return void(e?s._handleAlreadySelectedDates(e,a):s.selectDate(a))}}"Escape"===t&&this.dp.hide();})),A(this,"onKeyUp",(e=>{this.removeKey(e.key);})),this.dp=t,this.opts=i,this.init();}init(){this.bindKeyboardEvents();}bindKeyboardEvents(){let{$el:e}=this.dp;e.addEventListener("keydown",this.onKeyDown),e.addEventListener("keyup",this.onKeyUp);}destroy(){let{$el:e}=this.dp;e.removeEventListener("keydown",this.onKeyDown),e.removeEventListener("keyup",this.onKeyUp),this.hotKeys=null,this.pressedKeys=null;}getInitialFocusDate(){let{focusDate:e,currentView:t,selectedDates:s,parsedViewDate:{year:a,month:n}}=this.dp,r=e||s[s.length-1];if(!r)switch(t){case i.days:r=new Date(a,n,(new Date).getDate());break;case i.months:r=new Date(a,n,1);break;case i.years:r=new Date(a,0,1);}return r}focusNextCell(e){let t=this.getInitialFocusDate(),{currentView:s}=this.dp,{days:a,months:n,years:r}=i,h=o(t),l=h.year,d=h.month,c=h.date;switch(e){case "ArrowLeft":s===a&&(c-=1),s===n&&(d-=1),s===r&&(l-=1);break;case "ArrowUp":s===a&&(c-=7),s===n&&(d-=3),s===r&&(l-=4);break;case "ArrowRight":s===a&&(c+=1),s===n&&(d+=1),s===r&&(l+=1);break;case "ArrowDown":s===a&&(c+=7),s===n&&(d+=3),s===r&&(l+=4);}let u=this.dp.getClampedDate(new Date(l,d,c));this.dp.setFocusDate(u,{viewDateTransition:true});}registerKey(e){this.pressedKeys.add(e);}removeKey(e){this.pressedKeys.delete(e);}}let N={on(e,t){this.__events||(this.__events={}),this.__events[e]?this.__events[e].push(t):this.__events[e]=[t];},off(e,t){this.__events&&this.__events[e]&&(this.__events[e]=this.__events[e].filter((e=>e!==t)));},removeAllEvents(){this.__events={};},trigger(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];this.__events&&this.__events[e]&&this.__events[e].forEach((e=>{e(...i);}));}};function I(e,t,i){return (t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var s=i.call(e,"string");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return "symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:true,configurable:true,writable:true}):e[t]=i,e}let P="",j="",B=false;class R{static buildGlobalContainer(e){B=true,P=n({className:e,id:e}),a("body").appendChild(P);}constructor(e,t){var r=this;if(I(this,"viewIndexes",[i.days,i.months,i.years]),I(this,"next",(()=>{let{year:e,month:t}=this.parsedViewDate;switch(this.currentView){case i.days:this.setViewDate(new Date(e,t+1,1));break;case i.months:this.setViewDate(new Date(e+1,t,1));break;case i.years:this.setViewDate(new Date(e+10,0,1));}})),I(this,"prev",(()=>{let{year:e,month:t}=this.parsedViewDate;switch(this.currentView){case i.days:this.setViewDate(new Date(e,t-1,1));break;case i.months:this.setViewDate(new Date(e-1,t,1));break;case i.years:this.setViewDate(new Date(e-10,0,1));}})),I(this,"_finishHide",(()=>{this.hideAnimation=false,this._destroyComponents(),this.$container.removeChild(this.$datepicker);})),I(this,"setPosition",(function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if("function"==typeof(e=e||r.opts.position))return void(r.customHide=e({$datepicker:r.$datepicker,$target:r.$el,$pointer:r.$pointer,isViewChange:t,done:r._finishHide}));let i,s,{isMobile:a}=r.opts,n=r.$el.getBoundingClientRect(),h=r.$el.getBoundingClientRect(),o=r.$datepicker.offsetParent,l=r.$el.offsetParent,d=r.$datepicker.getBoundingClientRect(),c=e.split(" "),u=window.scrollY,p=window.scrollX,m=r.opts.offset,v=c[0],g=c[1];if(a)r.$datepicker.style.cssText="left: 50%; top: 50%";else {if(o===l&&o!==document.body&&(h={top:r.$el.offsetTop,left:r.$el.offsetLeft,width:n.width,height:r.$el.offsetHeight},u=0,p=0),o!==l&&o!==document.body){let e=o.getBoundingClientRect();h={top:n.top-e.top,left:n.left-e.left,width:n.width,height:n.height},u=0,p=0;}switch(v){case "top":i=h.top-d.height-m;break;case "right":s=h.left+h.width+m;break;case "bottom":i=h.top+h.height+m;break;case "left":s=h.left-d.width-m;}switch(g){case "top":i=h.top;break;case "right":s=h.left+h.width-d.width;break;case "bottom":i=h.top+h.height-d.height;break;case "left":s=h.left;break;case "center":/left|right/.test(v)?i=h.top+h.height/2-d.height/2:s=h.left+h.width/2-d.width/2;}r.$datepicker.style.cssText=`left: ${s+p}px; top: ${i+u}px`;}})),I(this,"_setInputValue",(()=>{let{opts:e,$altField:t,locale:{dateFormat:i}}=this,{altFieldDateFormat:s,altField:a}=e;a&&t&&(t.value=this._getInputValue(s)),this.$el.value=this._getInputValue(i),this.$el.dispatchEvent(new Event("change"));})),I(this,"_getInputValue",(e=>{let{selectedDates:t,opts:i}=this,{multipleDates:s,multipleDatesSeparator:a}=i;if(!t.length)return "";let n="function"==typeof e,r=n?e(s?t:t[0]):t.map((t=>this.formatDate(t,e)));return r=n?r:r.join(a),r})),I(this,"_checkIfDateIsSelected",(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.days,s=false;return r.selectedDates.some((i=>{let a=p(e,i,t);return s=a&&i,a})),s})),I(this,"_scheduleCallAfterTransition",(e=>{this._cancelScheduledCall(),e&&e(false),this._onTransitionEnd=()=>{e&&e(true);},this.$datepicker.addEventListener("transitionend",this._onTransitionEnd,{once:true});})),I(this,"_cancelScheduledCall",(()=>{this.$datepicker.removeEventListener("transitionend",this._onTransitionEnd);})),I(this,"setViewDate",(e=>{if(!((e=b(e))instanceof Date))return;if(p(e,this.viewDate))return;let t=this.viewDate;this.viewDate=e;let{onChangeViewDate:s}=this.opts;if(s){let{month:e,year:t}=this.parsedViewDate;s({month:e,year:t,decade:this.curDecade});}this.trigger(i.eventChangeViewDate,e,t);})),I(this,"setFocusDate",(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(!e||(e=b(e))instanceof Date)&&(r.focusDate=e,r.trigger(i.eventChangeFocusDate,e,t));})),I(this,"setCurrentView",(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(r.viewIndexes.includes(e)){if(r.currentView=e,r.elIsInput&&r.visible&&r.setPosition(void 0,true),r.trigger(i.eventChangeCurrentView,e),!r.views[e]){let t=r.views[e]=new T({dp:r,opts:r.opts,type:e});r.shouldUpdateDOM&&r.$content.appendChild(t.$el);}r.opts.onChangeView&&!t.silent&&r.opts.onChangeView(e);}})),I(this,"_updateLastSelectedDate",(e=>{this.lastSelectedDate=e,this.trigger(i.eventChangeLastSelectedDate,e);})),I(this,"destroy",(()=>{if(this.isDestroyed)return;let{showEvent:e,isMobile:t}=this.opts,i=this.$datepicker.parentNode;i&&i.removeChild(this.$datepicker),this.$el.removeEventListener(e,this._onFocus),this.$el.removeEventListener("blur",this._onBlur),window.removeEventListener("resize",this._onResize),t&&this._removeMobileAttributes(),this.keyboardNav&&this.keyboardNav.destroy(),this.views=null,this.nav=null,this.$datepicker=null,this.opts={},this.$customContainer=null,this.viewDate=null,this.focusDate=null,this.selectedDates=[],this.rangeDateFrom=null,this.rangeDateTo=null,this.isDestroyed=true;})),I(this,"update",(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=w({},r.opts),{silent:a}=t;w(r.opts,e);let{timepicker:n,buttons:h,range:o,selectedDates:l,isMobile:d}=r.opts,c=r.visible||r.treatAsInline;r._createMinMaxDates(),r._limitViewDateByMaxMinDates(),r._handleLocale(),l&&(r.selectedDates=[],r.selectDate(l,{silent:a})),e.view&&r.setCurrentView(e.view,{silent:a}),r._setInputValue(),s.range&&!o?(r.rangeDateTo=false,r.rangeDateFrom=false):!s.range&&o&&r.selectedDates.length&&(r.rangeDateFrom=r.selectedDates[0],r.rangeDateTo=r.selectedDates[1]),s.timepicker&&!n?(c&&r.timepicker.destroy(),r.timepicker=false,r.$timepicker.parentNode.removeChild(r.$timepicker)):!s.timepicker&&n&&r._addTimepicker(),!s.buttons&&h?r._addButtons():s.buttons&&!h?(r.buttons.destroy(),r.$buttons.parentNode.removeChild(r.$buttons)):c&&s.buttons&&h&&r.buttons.clearHtml().render(),!s.isMobile&&d?(r.treatAsInline||j||r._createMobileOverlay(),r._addMobileAttributes(),r.visible&&r._showMobileOverlay()):s.isMobile&&!d&&(r._removeMobileAttributes(),r.visible&&(j.classList.remove("-active-"),"function"!=typeof r.opts.position&&r.setPosition())),c&&(r.nav.update(),r.views[r.currentView].render(),r.currentView===i.days&&r.views[r.currentView].renderDayNames());})),I(this,"disableDate",((e,t)=>{(Array.isArray(e)?e:[e]).forEach((e=>{let i=b(e);if(!i)return;let s=t?"delete":"add";this.disabledDates[s](this.formatDate(i,"yyyy-MM-dd"));let a=this.getCell(i,this.currentViewSingular);a&&a.adpCell.render();}),[]);})),I(this,"enableDate",(e=>{this.disableDate(e,true);})),I(this,"isDateDisabled",(e=>{let t=b(e);return this.disabledDates.has(this.formatDate(t,"yyyy-MM-dd"))})),I(this,"isOtherMonth",(e=>{let{month:t}=o(e);return t!==this.parsedViewDate.month})),I(this,"isOtherYear",(e=>{let{year:t}=o(e);return t!==this.parsedViewDate.year})),I(this,"isOtherDecade",(e=>{let{year:t}=o(e),[i,s]=c(this.viewDate);return t<i||t>s})),I(this,"_onChangeSelectedDate",(e=>{let{silent:t}=e;setTimeout((()=>{this._setInputValue(),this.opts.onSelect&&!t&&this._triggerOnSelect();}));})),I(this,"_onChangeFocusedDate",(function(e){let{viewDateTransition:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)return;let i=false;t&&(i=r.isOtherMonth(e)||r.isOtherYear(e)||r.isOtherDecade(e)),i&&r.setViewDate(e),r.opts.onFocus&&r.opts.onFocus({datepicker:r,date:e});})),I(this,"_onChangeTime",(e=>{let{hours:t,minutes:i}=e,s=new Date,{lastSelectedDate:a,opts:{onSelect:n}}=this,r=a;a||(r=s);let h=this.getCell(r,this.currentViewSingular),o=h&&h.adpCell;o&&o.isDisabled||(r.setHours(t),r.setMinutes(i),a?(this._setInputValue(),n&&this._triggerOnSelect()):this.selectDate(r));})),I(this,"_onFocus",(e=>{this.visible||this.show();})),I(this,"_onBlur",(e=>{this.inFocus||!this.visible||this.opts.isMobile||this.hide();})),I(this,"_onMouseDown",(e=>{this.inFocus=true;})),I(this,"_onMouseUp",(e=>{this.inFocus=false,this.$el.focus();})),I(this,"_onResize",(()=>{this.visible&&"function"!=typeof this.opts.position&&this.setPosition();})),I(this,"_onClickOverlay",(()=>{this.visible&&this.hide();})),I(this,"getViewDates",(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i.days;return T.getDatesFunction(e)(r)})),I(this,"isWeekend",(e=>this.opts.weekends.includes(e))),I(this,"getClampedDate",(e=>{let{minDate:t,maxDate:i}=this,s=e;return i&&m(e,i)?s=i:t&&v(e,t)&&(s=t),s})),this.$el=a(e),!this.$el)return;this.$datepicker=n({className:"air-datepicker"}),this.opts=w({},s,t),this.$customContainer=!!this.opts.container&&a(this.opts.container),this.$altField=a(this.opts.altField||false);let{view:h,startDate:l}=this.opts;l||(this.opts.startDate=new Date),"INPUT"===this.$el.nodeName&&(this.elIsInput=true),this.inited=false,this.visible=false,this.viewDate=b(this.opts.startDate),this.focusDate=false,this.initialReadonly=this.$el.getAttribute("readonly"),this.customHide=false,this.currentView=h,this.selectedDates=[],this.disabledDates=new Set,this.isDestroyed=false,this.views={},this.keys=[],this.rangeDateFrom="",this.rangeDateTo="",this.timepickerIsActive=false,this.treatAsInline=this.opts.inline||!this.elIsInput,this.init();}init(){let{opts:e,treatAsInline:t,opts:{inline:i,isMobile:s,selectedDates:n,keyboardNav:r,onlyTimepicker:h}}=this,o=a("body");(!B||B&&P&&!o.contains(P))&&!i&&this.elIsInput&&!this.$customContainer&&R.buildGlobalContainer(R.defaultGlobalContainerId),!s||j||t||this._createMobileOverlay(),this._handleLocale(),this._bindSubEvents(),this._createMinMaxDates(),this._limitViewDateByMaxMinDates(),this.elIsInput&&(i||this._bindEvents(),r&&!h&&(this.keyboardNav=new O({dp:this,opts:e}))),n&&this.selectDate(n,{silent:true}),this.opts.visible&&!t&&this.show(),s&&!t&&this.$el.setAttribute("readonly",true),t&&this._createComponents();}_createMobileOverlay(){j=n({className:"air-datepicker-overlay"}),P.appendChild(j);}_createComponents(){let{opts:e,treatAsInline:t,opts:{inline:i,buttons:s,timepicker:a,position:n,classes:r,onlyTimepicker:h,isMobile:o}}=this;this._buildBaseHtml(),this.elIsInput&&(i||this._setPositionClasses(n)),!i&&this.elIsInput||this.$datepicker.classList.add("-inline-"),r&&this.$datepicker.classList.add(...r.split(" ")),h&&this.$datepicker.classList.add("-only-timepicker-"),o&&!t&&this._addMobileAttributes(),this.views[this.currentView]=new T({dp:this,type:this.currentView,opts:e}),this.nav=new V({dp:this,opts:e}),a&&this._addTimepicker(),s&&this._addButtons(),this.$content.appendChild(this.views[this.currentView].$el),this.$nav.appendChild(this.nav.$el);}_destroyComponents(){for(let e in this.views)this.views[e].destroy();this.views={},this.nav.destroy(),this.timepicker&&this.timepicker.destroy();}_addMobileAttributes(){j.addEventListener("click",this._onClickOverlay),this.$datepicker.classList.add("-is-mobile-"),this.$el.setAttribute("readonly",true);}_removeMobileAttributes(){j.removeEventListener("click",this._onClickOverlay),this.$datepicker.classList.remove("-is-mobile-"),this.initialReadonly||""===this.initialReadonly||this.$el.removeAttribute("readonly");}_createMinMaxDates(){let{minDate:e,maxDate:t}=this.opts;this.minDate=!!e&&b(e),this.maxDate=!!t&&b(t);}_addTimepicker(){this.$timepicker=n({className:"air-datepicker--time"}),this.$datepicker.appendChild(this.$timepicker),this.timepicker=new L({dp:this,opts:this.opts}),this.$timepicker.appendChild(this.timepicker.$el);}_addButtons(){this.$buttons=n({className:"air-datepicker--buttons"}),this.$datepicker.appendChild(this.$buttons),this.buttons=new H({dp:this,opts:this.opts}),this.$buttons.appendChild(this.buttons.$el);}_bindSubEvents(){this.on(i.eventChangeSelectedDate,this._onChangeSelectedDate),this.on(i.eventChangeFocusDate,this._onChangeFocusedDate),this.on(i.eventChangeTime,this._onChangeTime);}_buildBaseHtml(){let{inline:e}=this.opts;var t,i;this.elIsInput?e?(t=this.$datepicker,(i=this.$el).parentNode.insertBefore(t,i.nextSibling)):this.$container.appendChild(this.$datepicker):this.$el.appendChild(this.$datepicker),this.$datepicker.innerHTML='<i class="air-datepicker--pointer"></i><div class="air-datepicker--navigation"></div><div class="air-datepicker--content"></div>',this.$content=a(".air-datepicker--content",this.$datepicker),this.$pointer=a(".air-datepicker--pointer",this.$datepicker),this.$nav=a(".air-datepicker--navigation",this.$datepicker);}_handleLocale(){let{locale:e,dateFormat:t,firstDay:i,timepicker:s,onlyTimepicker:a,timeFormat:n,dateTimeSeparator:r}=this.opts;var h;this.locale=(h=e,JSON.parse(JSON.stringify(h))),t&&(this.locale.dateFormat=t),void 0!==n&&""!==n&&(this.locale.timeFormat=n);let{timeFormat:o}=this.locale;if(""!==i&&(this.locale.firstDay=i),s&&"function"!=typeof t){let e=o?r:"";this.locale.dateFormat=[this.locale.dateFormat,o||""].join(e);}a&&"function"!=typeof t&&(this.locale.dateFormat=this.locale.timeFormat);}_setPositionClasses(e){if("function"==typeof e)return void this.$datepicker.classList.add("-custom-position-");let t=(e=e.split(" "))[0],i=`air-datepicker -${t}-${e[1]}- -from-${t}-`;this.$datepicker.classList.add(...i.split(" "));}_bindEvents(){this.$el.addEventListener(this.opts.showEvent,this._onFocus),this.$el.addEventListener("blur",this._onBlur),this.$datepicker.addEventListener("mousedown",this._onMouseDown),this.$datepicker.addEventListener("mouseup",this._onMouseUp),window.addEventListener("resize",this._onResize);}_limitViewDateByMaxMinDates(){let{viewDate:e,minDate:t,maxDate:i}=this;i&&m(e,i)&&this.setViewDate(i),t&&v(e,t)&&this.setViewDate(t);}formatDate(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.viewDate,t=arguments.length>1?arguments[1]:void 0;if(e=b(e),!(e instanceof Date))return;let i=t,s=this.locale,a=o(e),n=a.dayPeriod,r=c(e),h=R.replacer,l={T:e.getTime(),m:a.minutes,mm:a.fullMinutes,h:a.hours12,hh:a.fullHours12,H:a.hours,HH:a.fullHours,aa:n,AA:n.toUpperCase(),E:s.daysShort[a.day],EEEE:s.days[a.day],d:a.date,dd:a.fullDate,M:a.month+1,MM:a.fullMonth,MMM:s.monthsShort[a.month],MMMM:s.months[a.month],yy:a.year.toString().slice(-2),yyyy:a.year,yyyy1:r[0],yyyy2:r[1]};for(let[e,t]of Object.entries(l))i=h(i,$(e),t);return i}down(e){this._handleUpDownActions(e,"down");}up(e){this._handleUpDownActions(e,"up");}selectDate(e){let t,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{currentView:a,parsedViewDate:n,selectedDates:r}=this,{updateTime:h,silent:o}=s,{moveToOtherMonthsOnSelect:l,moveToOtherYearsOnSelect:d,multipleDates:c,range:u,autoClose:p,onBeforeSelect:v}=this.opts,g=r.length;if(Array.isArray(e))return e.forEach((e=>{this.selectDate(e,s);})),new Promise((e=>{setTimeout(e);}));if((e=b(e))instanceof Date){if(v&&!o&&!v({date:e,datepicker:this}))return Promise.resolve();if(a===i.days&&e.getMonth()!==n.month&&l&&(t=new Date(e.getFullYear(),e.getMonth(),1)),a===i.years&&e.getFullYear()!==n.year&&d&&(t=new Date(e.getFullYear(),0,1)),t&&this.setViewDate(t),c&&!u){if(g===c)return;this._checkIfDateIsSelected(e)||r.push(e);}else if(u)switch(g){case 1:r.push(e),this.rangeDateTo||(this.rangeDateTo=e),m(this.rangeDateFrom,this.rangeDateTo)&&(this.rangeDateTo=this.rangeDateFrom,this.rangeDateFrom=e),this.selectedDates=[this.rangeDateFrom,this.rangeDateTo];break;case 2:this.selectedDates=[e],this.rangeDateFrom=e,this.rangeDateTo="";break;default:this.selectedDates=[e],this.rangeDateFrom=e;}else this.selectedDates=[e];return this.trigger(i.eventChangeSelectedDate,{action:i.actionSelectDate,silent:null==s?void 0:s.silent,date:e,updateTime:h}),this._updateLastSelectedDate(e),p&&!this.timepickerIsActive&&this.visible&&(c||u?u&&1===g&&this.hide():this.hide()),new Promise((e=>{setTimeout(e);}))}}unselectDate(e){let t=this.selectedDates,s=this;if((e=b(e))instanceof Date)return t.some(((a,n)=>{if(p(a,e))return t.splice(n,1),s.selectedDates.length?(s.rangeDateTo="",s.rangeDateFrom=t[0],s._updateLastSelectedDate(s.selectedDates[s.selectedDates.length-1])):(s.rangeDateFrom="",s.rangeDateTo="",s._updateLastSelectedDate(false)),this.trigger(i.eventChangeSelectedDate,{action:i.actionUnselectDate,date:e}),true}))}replaceDate(e,t){let s=this.selectedDates.find((t=>p(t,e,this.currentView))),a=this.selectedDates.indexOf(s);a<0||p(this.selectedDates[a],t,this.currentView)||(this.selectedDates[a]=t,this.trigger(i.eventChangeSelectedDate,{action:i.actionSelectDate,date:t,updateTime:true}),this._updateLastSelectedDate(t));}clear(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.selectedDates=[],this.rangeDateFrom=false,this.rangeDateTo=false,this.lastSelectedDate=false,this.trigger(i.eventChangeSelectedDate,{action:i.actionUnselectDate,silent:e.silent}),new Promise((e=>{setTimeout(e);}))}show(){let{onShow:e,isMobile:t}=this.opts;this._cancelScheduledCall(),this.visible||this.hideAnimation||this._createComponents(),this.setPosition(this.opts.position),this.$datepicker.classList.add("-active-"),this.visible=true,e&&this._scheduleCallAfterTransition(e),t&&this._showMobileOverlay();}hide(){let{onHide:e,isMobile:t}=this.opts,i=this._hasTransition();this.visible=false,this.hideAnimation=true,this.$datepicker.classList.remove("-active-"),this.customHide&&this.customHide(),this.elIsInput&&this.$el.blur(),this._scheduleCallAfterTransition((t=>{!this.customHide&&(t&&i||!t&&!i)&&this._finishHide(),e&&e(t);})),t&&j.classList.remove("-active-");}_triggerOnSelect(){let e=[],t=[],{selectedDates:i,locale:s,opts:{onSelect:a,multipleDates:n,range:r}}=this,h=n||r,o="function"==typeof s.dateFormat;i.length&&(e=i.map(g),t=o?n?s.dateFormat(e):e.map((e=>s.dateFormat(e))):e.map((e=>this.formatDate(e,s.dateFormat)))),a({date:h?e:e[0],formattedDate:h?t:t[0],datepicker:this});}_handleAlreadySelectedDates(e,t){let{selectedDates:i,rangeDateFrom:s,rangeDateTo:a}=this,{range:n,toggleSelected:r}=this.opts,h=i.length,o="function"==typeof r?r({datepicker:this,date:t}):r,l=Boolean(n&&1===h&&e),d=l?g(t):t;n&&!o&&(2!==h&&this.selectDate(d),2===h&&p(s,a))||(o?this.unselectDate(d):this._updateLastSelectedDate(l?d:e));}_handleUpDownActions(e,t){if(!((e=b(e||this.focusDate||this.viewDate))instanceof Date))return;let i="up"===t?this.viewIndex+1:this.viewIndex-1;i>2&&(i=2),i<0&&(i=0),this.setViewDate(new Date(e.getFullYear(),e.getMonth(),1)),this.setCurrentView(this.viewIndexes[i]);}getCell(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i.day;if(!((e=b(e))instanceof Date))return;let{year:s,month:a,date:n}=o(e),r=`[data-year="${s}"]`,h=`[data-month="${a}"]`,l={[i.day]:`${r}${h}[data-date="${n}"]`,[i.month]:`${r}${h}`,[i.year]:`${r}`};return this.views[this.currentView]?this.views[this.currentView].$el.querySelector(l[t]):void 0}_showMobileOverlay(){j.classList.add("-active-");}_hasTransition(){return window.getComputedStyle(this.$datepicker).getPropertyValue("transition-duration").split(", ").reduce(((e,t)=>parseFloat(t)+e),0)>0}get shouldUpdateDOM(){return this.visible||this.treatAsInline}get parsedViewDate(){return o(this.viewDate)}get currentViewSingular(){return this.currentView.slice(0,-1)}get curDecade(){return c(this.viewDate)}get viewIndex(){return this.viewIndexes.indexOf(this.currentView)}get isFinalView(){return this.currentView===i.years}get hasSelectedDates(){return this.selectedDates.length>0}get isMinViewReached(){return this.currentView===this.opts.minView||this.currentView===i.days}get $container(){return this.$customContainer||P}static replacer(e,t,i){return e.replace(t,(function(e,t,s,a){return t+i+a}))}}var K;return I(R,"defaults",s),I(R,"version","3.6.0"),I(R,"defaultGlobalContainerId","air-datepicker-global-container"),K=R.prototype,Object.assign(K,N),t.default}()}));
|
|
43
|
+
} (airDatepicker$1));
|
|
44
|
+
return airDatepicker$1.exports;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var airDatepickerExports = requireAirDatepicker();
|
|
48
|
+
var AirDatepicker = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(airDatepickerExports);
|
|
49
|
+
|
|
50
|
+
/** Checks if value is string */
|
|
51
|
+
function isString(str) {
|
|
52
|
+
return typeof str === 'string' || str instanceof String;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Checks if value is object */
|
|
56
|
+
function isObject(obj) {
|
|
57
|
+
var _obj$constructor;
|
|
58
|
+
return typeof obj === 'object' && obj != null && (obj == null || (_obj$constructor = obj.constructor) == null ? void 0 : _obj$constructor.name) === 'Object';
|
|
59
|
+
}
|
|
60
|
+
function pick(obj, keys) {
|
|
61
|
+
if (Array.isArray(keys)) return pick(obj, (_, k) => keys.includes(k));
|
|
62
|
+
return Object.entries(obj).reduce((acc, _ref) => {
|
|
63
|
+
let [k, v] = _ref;
|
|
64
|
+
if (keys(v, k)) acc[k] = v;
|
|
65
|
+
return acc;
|
|
66
|
+
}, {});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Direction */
|
|
70
|
+
const DIRECTION = {
|
|
71
|
+
NONE: 'NONE',
|
|
72
|
+
LEFT: 'LEFT',
|
|
73
|
+
FORCE_LEFT: 'FORCE_LEFT',
|
|
74
|
+
RIGHT: 'RIGHT',
|
|
75
|
+
FORCE_RIGHT: 'FORCE_RIGHT'
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/** Direction */
|
|
79
|
+
|
|
80
|
+
function forceDirection(direction) {
|
|
81
|
+
switch (direction) {
|
|
82
|
+
case DIRECTION.LEFT:
|
|
83
|
+
return DIRECTION.FORCE_LEFT;
|
|
84
|
+
case DIRECTION.RIGHT:
|
|
85
|
+
return DIRECTION.FORCE_RIGHT;
|
|
86
|
+
default:
|
|
87
|
+
return direction;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Escapes regular expression control chars */
|
|
92
|
+
function escapeRegExp(str) {
|
|
93
|
+
return str.replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// cloned from https://github.com/epoberezkin/fast-deep-equal with small changes
|
|
97
|
+
function objectIncludes(b, a) {
|
|
98
|
+
if (a === b) return true;
|
|
99
|
+
const arrA = Array.isArray(a),
|
|
100
|
+
arrB = Array.isArray(b);
|
|
101
|
+
let i;
|
|
102
|
+
if (arrA && arrB) {
|
|
103
|
+
if (a.length != b.length) return false;
|
|
104
|
+
for (i = 0; i < a.length; i++) if (!objectIncludes(a[i], b[i])) return false;
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
if (arrA != arrB) return false;
|
|
108
|
+
if (a && b && typeof a === 'object' && typeof b === 'object') {
|
|
109
|
+
const dateA = a instanceof Date,
|
|
110
|
+
dateB = b instanceof Date;
|
|
111
|
+
if (dateA && dateB) return a.getTime() == b.getTime();
|
|
112
|
+
if (dateA != dateB) return false;
|
|
113
|
+
const regexpA = a instanceof RegExp,
|
|
114
|
+
regexpB = b instanceof RegExp;
|
|
115
|
+
if (regexpA && regexpB) return a.toString() == b.toString();
|
|
116
|
+
if (regexpA != regexpB) return false;
|
|
117
|
+
const keys = Object.keys(a);
|
|
118
|
+
// if (keys.length !== Object.keys(b).length) return false;
|
|
119
|
+
|
|
120
|
+
for (i = 0; i < keys.length; i++) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
121
|
+
for (i = 0; i < keys.length; i++) if (!objectIncludes(b[keys[i]], a[keys[i]])) return false;
|
|
122
|
+
return true;
|
|
123
|
+
} else if (a && b && typeof a === 'function' && typeof b === 'function') {
|
|
124
|
+
return a.toString() === b.toString();
|
|
125
|
+
}
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Provides details of changing input */
|
|
130
|
+
class ActionDetails {
|
|
131
|
+
/** Current input value */
|
|
132
|
+
|
|
133
|
+
/** Current cursor position */
|
|
134
|
+
|
|
135
|
+
/** Old input value */
|
|
136
|
+
|
|
137
|
+
/** Old selection */
|
|
138
|
+
|
|
139
|
+
constructor(opts) {
|
|
140
|
+
Object.assign(this, opts);
|
|
141
|
+
|
|
142
|
+
// double check if left part was changed (autofilling, other non-standard input triggers)
|
|
143
|
+
while (this.value.slice(0, this.startChangePos) !== this.oldValue.slice(0, this.startChangePos)) {
|
|
144
|
+
--this.oldSelection.start;
|
|
145
|
+
}
|
|
146
|
+
if (this.insertedCount) {
|
|
147
|
+
// double check right part
|
|
148
|
+
while (this.value.slice(this.cursorPos) !== this.oldValue.slice(this.oldSelection.end)) {
|
|
149
|
+
if (this.value.length - this.cursorPos < this.oldValue.length - this.oldSelection.end) ++this.oldSelection.end;else ++this.cursorPos;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** Start changing position */
|
|
155
|
+
get startChangePos() {
|
|
156
|
+
return Math.min(this.cursorPos, this.oldSelection.start);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Inserted symbols count */
|
|
160
|
+
get insertedCount() {
|
|
161
|
+
return this.cursorPos - this.startChangePos;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** Inserted symbols */
|
|
165
|
+
get inserted() {
|
|
166
|
+
return this.value.substr(this.startChangePos, this.insertedCount);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Removed symbols count */
|
|
170
|
+
get removedCount() {
|
|
171
|
+
// Math.max for opposite operation
|
|
172
|
+
return Math.max(this.oldSelection.end - this.startChangePos ||
|
|
173
|
+
// for Delete
|
|
174
|
+
this.oldValue.length - this.value.length, 0);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Removed symbols */
|
|
178
|
+
get removed() {
|
|
179
|
+
return this.oldValue.substr(this.startChangePos, this.removedCount);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Unchanged head symbols */
|
|
183
|
+
get head() {
|
|
184
|
+
return this.value.substring(0, this.startChangePos);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Unchanged tail symbols */
|
|
188
|
+
get tail() {
|
|
189
|
+
return this.value.substring(this.startChangePos + this.insertedCount);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Remove direction */
|
|
193
|
+
get removeDirection() {
|
|
194
|
+
if (!this.removedCount || this.insertedCount) return DIRECTION.NONE;
|
|
195
|
+
|
|
196
|
+
// align right if delete at right
|
|
197
|
+
return (this.oldSelection.end === this.cursorPos || this.oldSelection.start === this.cursorPos) &&
|
|
198
|
+
// if not range removed (event with backspace)
|
|
199
|
+
this.oldSelection.end === this.oldSelection.start ? DIRECTION.RIGHT : DIRECTION.LEFT;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** Applies mask on element */
|
|
204
|
+
function IMask(el, opts) {
|
|
205
|
+
// currently available only for input-like elements
|
|
206
|
+
return new IMask.InputMask(el, opts);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// TODO can't use overloads here because of https://github.com/microsoft/TypeScript/issues/50754
|
|
210
|
+
// export function maskedClass(mask: string): typeof MaskedPattern;
|
|
211
|
+
// export function maskedClass(mask: DateConstructor): typeof MaskedDate;
|
|
212
|
+
// export function maskedClass(mask: NumberConstructor): typeof MaskedNumber;
|
|
213
|
+
// export function maskedClass(mask: Array<any> | ArrayConstructor): typeof MaskedDynamic;
|
|
214
|
+
// export function maskedClass(mask: MaskedDate): typeof MaskedDate;
|
|
215
|
+
// export function maskedClass(mask: MaskedNumber): typeof MaskedNumber;
|
|
216
|
+
// export function maskedClass(mask: MaskedEnum): typeof MaskedEnum;
|
|
217
|
+
// export function maskedClass(mask: MaskedRange): typeof MaskedRange;
|
|
218
|
+
// export function maskedClass(mask: MaskedRegExp): typeof MaskedRegExp;
|
|
219
|
+
// export function maskedClass(mask: MaskedFunction): typeof MaskedFunction;
|
|
220
|
+
// export function maskedClass(mask: MaskedPattern): typeof MaskedPattern;
|
|
221
|
+
// export function maskedClass(mask: MaskedDynamic): typeof MaskedDynamic;
|
|
222
|
+
// export function maskedClass(mask: Masked): typeof Masked;
|
|
223
|
+
// export function maskedClass(mask: typeof Masked): typeof Masked;
|
|
224
|
+
// export function maskedClass(mask: typeof MaskedDate): typeof MaskedDate;
|
|
225
|
+
// export function maskedClass(mask: typeof MaskedNumber): typeof MaskedNumber;
|
|
226
|
+
// export function maskedClass(mask: typeof MaskedEnum): typeof MaskedEnum;
|
|
227
|
+
// export function maskedClass(mask: typeof MaskedRange): typeof MaskedRange;
|
|
228
|
+
// export function maskedClass(mask: typeof MaskedRegExp): typeof MaskedRegExp;
|
|
229
|
+
// export function maskedClass(mask: typeof MaskedFunction): typeof MaskedFunction;
|
|
230
|
+
// export function maskedClass(mask: typeof MaskedPattern): typeof MaskedPattern;
|
|
231
|
+
// export function maskedClass(mask: typeof MaskedDynamic): typeof MaskedDynamic;
|
|
232
|
+
// export function maskedClass<Mask extends typeof Masked> (mask: Mask): Mask;
|
|
233
|
+
// export function maskedClass(mask: RegExp): typeof MaskedRegExp;
|
|
234
|
+
// export function maskedClass(mask: (value: string, ...args: any[]) => boolean): typeof MaskedFunction;
|
|
235
|
+
|
|
236
|
+
/** Get Masked class by mask type */
|
|
237
|
+
function maskedClass(mask) /* TODO */{
|
|
238
|
+
if (mask == null) throw new Error('mask property should be defined');
|
|
239
|
+
if (mask instanceof RegExp) return IMask.MaskedRegExp;
|
|
240
|
+
if (isString(mask)) return IMask.MaskedPattern;
|
|
241
|
+
if (mask === Date) return IMask.MaskedDate;
|
|
242
|
+
if (mask === Number) return IMask.MaskedNumber;
|
|
243
|
+
if (Array.isArray(mask) || mask === Array) return IMask.MaskedDynamic;
|
|
244
|
+
if (IMask.Masked && mask.prototype instanceof IMask.Masked) return mask;
|
|
245
|
+
if (IMask.Masked && mask instanceof IMask.Masked) return mask.constructor;
|
|
246
|
+
if (mask instanceof Function) return IMask.MaskedFunction;
|
|
247
|
+
console.warn('Mask not found for mask', mask); // eslint-disable-line no-console
|
|
248
|
+
return IMask.Masked;
|
|
249
|
+
}
|
|
250
|
+
function normalizeOpts(opts) {
|
|
251
|
+
if (!opts) throw new Error('Options in not defined');
|
|
252
|
+
if (IMask.Masked) {
|
|
253
|
+
if (opts.prototype instanceof IMask.Masked) return {
|
|
254
|
+
mask: opts
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
/*
|
|
258
|
+
handle cases like:
|
|
259
|
+
1) opts = Masked
|
|
260
|
+
2) opts = { mask: Masked, ...instanceOpts }
|
|
261
|
+
*/
|
|
262
|
+
const {
|
|
263
|
+
mask = undefined,
|
|
264
|
+
...instanceOpts
|
|
265
|
+
} = opts instanceof IMask.Masked ? {
|
|
266
|
+
mask: opts
|
|
267
|
+
} : isObject(opts) && opts.mask instanceof IMask.Masked ? opts : {};
|
|
268
|
+
if (mask) {
|
|
269
|
+
const _mask = mask.mask;
|
|
270
|
+
return {
|
|
271
|
+
...pick(mask, (_, k) => !k.startsWith('_')),
|
|
272
|
+
mask: mask.constructor,
|
|
273
|
+
_mask,
|
|
274
|
+
...instanceOpts
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (!isObject(opts)) return {
|
|
279
|
+
mask: opts
|
|
280
|
+
};
|
|
281
|
+
return {
|
|
282
|
+
...opts
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// TODO can't use overloads here because of https://github.com/microsoft/TypeScript/issues/50754
|
|
287
|
+
|
|
288
|
+
// From masked
|
|
289
|
+
// export default function createMask<Opts extends Masked, ReturnMasked=Opts> (opts: Opts): ReturnMasked;
|
|
290
|
+
// // From masked class
|
|
291
|
+
// export default function createMask<Opts extends MaskedOptions<typeof Masked>, ReturnMasked extends Masked=InstanceType<Opts['mask']>> (opts: Opts): ReturnMasked;
|
|
292
|
+
// export default function createMask<Opts extends MaskedOptions<typeof MaskedDate>, ReturnMasked extends MaskedDate=MaskedDate<Opts['parent']>> (opts: Opts): ReturnMasked;
|
|
293
|
+
// export default function createMask<Opts extends MaskedOptions<typeof MaskedNumber>, ReturnMasked extends MaskedNumber=MaskedNumber<Opts['parent']>> (opts: Opts): ReturnMasked;
|
|
294
|
+
// export default function createMask<Opts extends MaskedOptions<typeof MaskedEnum>, ReturnMasked extends MaskedEnum=MaskedEnum<Opts['parent']>> (opts: Opts): ReturnMasked;
|
|
295
|
+
// export default function createMask<Opts extends MaskedOptions<typeof MaskedRange>, ReturnMasked extends MaskedRange=MaskedRange<Opts['parent']>> (opts: Opts): ReturnMasked;
|
|
296
|
+
// export default function createMask<Opts extends MaskedOptions<typeof MaskedRegExp>, ReturnMasked extends MaskedRegExp=MaskedRegExp<Opts['parent']>> (opts: Opts): ReturnMasked;
|
|
297
|
+
// export default function createMask<Opts extends MaskedOptions<typeof MaskedFunction>, ReturnMasked extends MaskedFunction=MaskedFunction<Opts['parent']>> (opts: Opts): ReturnMasked;
|
|
298
|
+
// export default function createMask<Opts extends MaskedOptions<typeof MaskedPattern>, ReturnMasked extends MaskedPattern=MaskedPattern<Opts['parent']>> (opts: Opts): ReturnMasked;
|
|
299
|
+
// export default function createMask<Opts extends MaskedOptions<typeof MaskedDynamic>, ReturnMasked extends MaskedDynamic=MaskedDynamic<Opts['parent']>> (opts: Opts): ReturnMasked;
|
|
300
|
+
// // From mask opts
|
|
301
|
+
// export default function createMask<Opts extends MaskedOptions<Masked>, ReturnMasked=Opts extends MaskedOptions<infer M> ? M : never> (opts: Opts): ReturnMasked;
|
|
302
|
+
// export default function createMask<Opts extends MaskedNumberOptions, ReturnMasked extends MaskedNumber=MaskedNumber<Opts['parent']>> (opts: Opts): ReturnMasked;
|
|
303
|
+
// export default function createMask<Opts extends MaskedDateFactoryOptions, ReturnMasked extends MaskedDate=MaskedDate<Opts['parent']>> (opts: Opts): ReturnMasked;
|
|
304
|
+
// export default function createMask<Opts extends MaskedEnumOptions, ReturnMasked extends MaskedEnum=MaskedEnum<Opts['parent']>> (opts: Opts): ReturnMasked;
|
|
305
|
+
// export default function createMask<Opts extends MaskedRangeOptions, ReturnMasked extends MaskedRange=MaskedRange<Opts['parent']>> (opts: Opts): ReturnMasked;
|
|
306
|
+
// export default function createMask<Opts extends MaskedPatternOptions, ReturnMasked extends MaskedPattern=MaskedPattern<Opts['parent']>> (opts: Opts): ReturnMasked;
|
|
307
|
+
// export default function createMask<Opts extends MaskedDynamicOptions, ReturnMasked extends MaskedDynamic=MaskedDynamic<Opts['parent']>> (opts: Opts): ReturnMasked;
|
|
308
|
+
// export default function createMask<Opts extends MaskedOptions<RegExp>, ReturnMasked extends MaskedRegExp=MaskedRegExp<Opts['parent']>> (opts: Opts): ReturnMasked;
|
|
309
|
+
// export default function createMask<Opts extends MaskedOptions<Function>, ReturnMasked extends MaskedFunction=MaskedFunction<Opts['parent']>> (opts: Opts): ReturnMasked;
|
|
310
|
+
|
|
311
|
+
/** Creates new {@link Masked} depending on mask type */
|
|
312
|
+
function createMask(opts) {
|
|
313
|
+
if (IMask.Masked && opts instanceof IMask.Masked) return opts;
|
|
314
|
+
const nOpts = normalizeOpts(opts);
|
|
315
|
+
const MaskedClass = maskedClass(nOpts.mask);
|
|
316
|
+
if (!MaskedClass) throw new Error("Masked class is not found for provided mask " + nOpts.mask + ", appropriate module needs to be imported manually before creating mask.");
|
|
317
|
+
if (nOpts.mask === MaskedClass) delete nOpts.mask;
|
|
318
|
+
if (nOpts._mask) {
|
|
319
|
+
nOpts.mask = nOpts._mask;
|
|
320
|
+
delete nOpts._mask;
|
|
321
|
+
}
|
|
322
|
+
return new MaskedClass(nOpts);
|
|
323
|
+
}
|
|
324
|
+
IMask.createMask = createMask;
|
|
325
|
+
|
|
326
|
+
/** Generic element API to use with mask */
|
|
327
|
+
class MaskElement {
|
|
328
|
+
/** */
|
|
329
|
+
|
|
330
|
+
/** */
|
|
331
|
+
|
|
332
|
+
/** */
|
|
333
|
+
|
|
334
|
+
/** Safely returns selection start */
|
|
335
|
+
get selectionStart() {
|
|
336
|
+
let start;
|
|
337
|
+
try {
|
|
338
|
+
start = this._unsafeSelectionStart;
|
|
339
|
+
} catch {}
|
|
340
|
+
return start != null ? start : this.value.length;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** Safely returns selection end */
|
|
344
|
+
get selectionEnd() {
|
|
345
|
+
let end;
|
|
346
|
+
try {
|
|
347
|
+
end = this._unsafeSelectionEnd;
|
|
348
|
+
} catch {}
|
|
349
|
+
return end != null ? end : this.value.length;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/** Safely sets element selection */
|
|
353
|
+
select(start, end) {
|
|
354
|
+
if (start == null || end == null || start === this.selectionStart && end === this.selectionEnd) return;
|
|
355
|
+
try {
|
|
356
|
+
this._unsafeSelect(start, end);
|
|
357
|
+
} catch {}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/** */
|
|
361
|
+
get isActive() {
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
/** */
|
|
365
|
+
|
|
366
|
+
/** */
|
|
367
|
+
|
|
368
|
+
/** */
|
|
369
|
+
}
|
|
370
|
+
IMask.MaskElement = MaskElement;
|
|
371
|
+
|
|
372
|
+
const KEY_Z = 90;
|
|
373
|
+
const KEY_Y = 89;
|
|
374
|
+
|
|
375
|
+
/** Bridge between HTMLElement and {@link Masked} */
|
|
376
|
+
class HTMLMaskElement extends MaskElement {
|
|
377
|
+
/** HTMLElement to use mask on */
|
|
378
|
+
|
|
379
|
+
constructor(input) {
|
|
380
|
+
super();
|
|
381
|
+
this.input = input;
|
|
382
|
+
this._onKeydown = this._onKeydown.bind(this);
|
|
383
|
+
this._onInput = this._onInput.bind(this);
|
|
384
|
+
this._onBeforeinput = this._onBeforeinput.bind(this);
|
|
385
|
+
this._onCompositionEnd = this._onCompositionEnd.bind(this);
|
|
386
|
+
}
|
|
387
|
+
get rootElement() {
|
|
388
|
+
var _this$input$getRootNo, _this$input$getRootNo2, _this$input;
|
|
389
|
+
return (_this$input$getRootNo = (_this$input$getRootNo2 = (_this$input = this.input).getRootNode) == null ? void 0 : _this$input$getRootNo2.call(_this$input)) != null ? _this$input$getRootNo : document;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/** Is element in focus */
|
|
393
|
+
get isActive() {
|
|
394
|
+
return this.input === this.rootElement.activeElement;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/** Binds HTMLElement events to mask internal events */
|
|
398
|
+
bindEvents(handlers) {
|
|
399
|
+
this.input.addEventListener('keydown', this._onKeydown);
|
|
400
|
+
this.input.addEventListener('input', this._onInput);
|
|
401
|
+
this.input.addEventListener('beforeinput', this._onBeforeinput);
|
|
402
|
+
this.input.addEventListener('compositionend', this._onCompositionEnd);
|
|
403
|
+
this.input.addEventListener('drop', handlers.drop);
|
|
404
|
+
this.input.addEventListener('click', handlers.click);
|
|
405
|
+
this.input.addEventListener('focus', handlers.focus);
|
|
406
|
+
this.input.addEventListener('blur', handlers.commit);
|
|
407
|
+
this._handlers = handlers;
|
|
408
|
+
}
|
|
409
|
+
_onKeydown(e) {
|
|
410
|
+
if (this._handlers.redo && (e.keyCode === KEY_Z && e.shiftKey && (e.metaKey || e.ctrlKey) || e.keyCode === KEY_Y && e.ctrlKey)) {
|
|
411
|
+
e.preventDefault();
|
|
412
|
+
return this._handlers.redo(e);
|
|
413
|
+
}
|
|
414
|
+
if (this._handlers.undo && e.keyCode === KEY_Z && (e.metaKey || e.ctrlKey)) {
|
|
415
|
+
e.preventDefault();
|
|
416
|
+
return this._handlers.undo(e);
|
|
417
|
+
}
|
|
418
|
+
if (!e.isComposing) this._handlers.selectionChange(e);
|
|
419
|
+
}
|
|
420
|
+
_onBeforeinput(e) {
|
|
421
|
+
if (e.inputType === 'historyUndo' && this._handlers.undo) {
|
|
422
|
+
e.preventDefault();
|
|
423
|
+
return this._handlers.undo(e);
|
|
424
|
+
}
|
|
425
|
+
if (e.inputType === 'historyRedo' && this._handlers.redo) {
|
|
426
|
+
e.preventDefault();
|
|
427
|
+
return this._handlers.redo(e);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
_onCompositionEnd(e) {
|
|
431
|
+
this._handlers.input(e);
|
|
432
|
+
}
|
|
433
|
+
_onInput(e) {
|
|
434
|
+
if (!e.isComposing) this._handlers.input(e);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/** Unbinds HTMLElement events to mask internal events */
|
|
438
|
+
unbindEvents() {
|
|
439
|
+
this.input.removeEventListener('keydown', this._onKeydown);
|
|
440
|
+
this.input.removeEventListener('input', this._onInput);
|
|
441
|
+
this.input.removeEventListener('beforeinput', this._onBeforeinput);
|
|
442
|
+
this.input.removeEventListener('compositionend', this._onCompositionEnd);
|
|
443
|
+
this.input.removeEventListener('drop', this._handlers.drop);
|
|
444
|
+
this.input.removeEventListener('click', this._handlers.click);
|
|
445
|
+
this.input.removeEventListener('focus', this._handlers.focus);
|
|
446
|
+
this.input.removeEventListener('blur', this._handlers.commit);
|
|
447
|
+
this._handlers = {};
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
IMask.HTMLMaskElement = HTMLMaskElement;
|
|
451
|
+
|
|
452
|
+
/** Bridge between InputElement and {@link Masked} */
|
|
453
|
+
class HTMLInputMaskElement extends HTMLMaskElement {
|
|
454
|
+
/** InputElement to use mask on */
|
|
455
|
+
|
|
456
|
+
constructor(input) {
|
|
457
|
+
super(input);
|
|
458
|
+
this.input = input;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/** Returns InputElement selection start */
|
|
462
|
+
get _unsafeSelectionStart() {
|
|
463
|
+
return this.input.selectionStart != null ? this.input.selectionStart : this.value.length;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/** Returns InputElement selection end */
|
|
467
|
+
get _unsafeSelectionEnd() {
|
|
468
|
+
return this.input.selectionEnd;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/** Sets InputElement selection */
|
|
472
|
+
_unsafeSelect(start, end) {
|
|
473
|
+
this.input.setSelectionRange(start, end);
|
|
474
|
+
}
|
|
475
|
+
get value() {
|
|
476
|
+
return this.input.value;
|
|
477
|
+
}
|
|
478
|
+
set value(value) {
|
|
479
|
+
this.input.value = value;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
IMask.HTMLMaskElement = HTMLMaskElement;
|
|
483
|
+
|
|
484
|
+
class HTMLContenteditableMaskElement extends HTMLMaskElement {
|
|
485
|
+
/** Returns HTMLElement selection start */
|
|
486
|
+
get _unsafeSelectionStart() {
|
|
487
|
+
const root = this.rootElement;
|
|
488
|
+
const selection = root.getSelection && root.getSelection();
|
|
489
|
+
const anchorOffset = selection && selection.anchorOffset;
|
|
490
|
+
const focusOffset = selection && selection.focusOffset;
|
|
491
|
+
if (focusOffset == null || anchorOffset == null || anchorOffset < focusOffset) {
|
|
492
|
+
return anchorOffset;
|
|
493
|
+
}
|
|
494
|
+
return focusOffset;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/** Returns HTMLElement selection end */
|
|
498
|
+
get _unsafeSelectionEnd() {
|
|
499
|
+
const root = this.rootElement;
|
|
500
|
+
const selection = root.getSelection && root.getSelection();
|
|
501
|
+
const anchorOffset = selection && selection.anchorOffset;
|
|
502
|
+
const focusOffset = selection && selection.focusOffset;
|
|
503
|
+
if (focusOffset == null || anchorOffset == null || anchorOffset > focusOffset) {
|
|
504
|
+
return anchorOffset;
|
|
505
|
+
}
|
|
506
|
+
return focusOffset;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/** Sets HTMLElement selection */
|
|
510
|
+
_unsafeSelect(start, end) {
|
|
511
|
+
if (!this.rootElement.createRange) return;
|
|
512
|
+
const range = this.rootElement.createRange();
|
|
513
|
+
range.setStart(this.input.firstChild || this.input, start);
|
|
514
|
+
range.setEnd(this.input.lastChild || this.input, end);
|
|
515
|
+
const root = this.rootElement;
|
|
516
|
+
const selection = root.getSelection && root.getSelection();
|
|
517
|
+
if (selection) {
|
|
518
|
+
selection.removeAllRanges();
|
|
519
|
+
selection.addRange(range);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/** HTMLElement value */
|
|
524
|
+
get value() {
|
|
525
|
+
return this.input.textContent || '';
|
|
526
|
+
}
|
|
527
|
+
set value(value) {
|
|
528
|
+
this.input.textContent = value;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
IMask.HTMLContenteditableMaskElement = HTMLContenteditableMaskElement;
|
|
532
|
+
|
|
533
|
+
class InputHistory {
|
|
534
|
+
constructor() {
|
|
535
|
+
this.states = [];
|
|
536
|
+
this.currentIndex = 0;
|
|
537
|
+
}
|
|
538
|
+
get currentState() {
|
|
539
|
+
return this.states[this.currentIndex];
|
|
540
|
+
}
|
|
541
|
+
get isEmpty() {
|
|
542
|
+
return this.states.length === 0;
|
|
543
|
+
}
|
|
544
|
+
push(state) {
|
|
545
|
+
// if current index points before the last element then remove the future
|
|
546
|
+
if (this.currentIndex < this.states.length - 1) this.states.length = this.currentIndex + 1;
|
|
547
|
+
this.states.push(state);
|
|
548
|
+
if (this.states.length > InputHistory.MAX_LENGTH) this.states.shift();
|
|
549
|
+
this.currentIndex = this.states.length - 1;
|
|
550
|
+
}
|
|
551
|
+
go(steps) {
|
|
552
|
+
this.currentIndex = Math.min(Math.max(this.currentIndex + steps, 0), this.states.length - 1);
|
|
553
|
+
return this.currentState;
|
|
554
|
+
}
|
|
555
|
+
undo() {
|
|
556
|
+
return this.go(-1);
|
|
557
|
+
}
|
|
558
|
+
redo() {
|
|
559
|
+
return this.go(1);
|
|
560
|
+
}
|
|
561
|
+
clear() {
|
|
562
|
+
this.states.length = 0;
|
|
563
|
+
this.currentIndex = 0;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
InputHistory.MAX_LENGTH = 100;
|
|
567
|
+
|
|
568
|
+
/** Listens to element events and controls changes between element and {@link Masked} */
|
|
569
|
+
class InputMask {
|
|
570
|
+
/**
|
|
571
|
+
View element
|
|
572
|
+
*/
|
|
573
|
+
|
|
574
|
+
/** Internal {@link Masked} model */
|
|
575
|
+
|
|
576
|
+
constructor(el, opts) {
|
|
577
|
+
this.el = el instanceof MaskElement ? el : el.isContentEditable && el.tagName !== 'INPUT' && el.tagName !== 'TEXTAREA' ? new HTMLContenteditableMaskElement(el) : new HTMLInputMaskElement(el);
|
|
578
|
+
this.masked = createMask(opts);
|
|
579
|
+
this._listeners = {};
|
|
580
|
+
this._value = '';
|
|
581
|
+
this._unmaskedValue = '';
|
|
582
|
+
this._rawInputValue = '';
|
|
583
|
+
this.history = new InputHistory();
|
|
584
|
+
this._saveSelection = this._saveSelection.bind(this);
|
|
585
|
+
this._onInput = this._onInput.bind(this);
|
|
586
|
+
this._onChange = this._onChange.bind(this);
|
|
587
|
+
this._onDrop = this._onDrop.bind(this);
|
|
588
|
+
this._onFocus = this._onFocus.bind(this);
|
|
589
|
+
this._onClick = this._onClick.bind(this);
|
|
590
|
+
this._onUndo = this._onUndo.bind(this);
|
|
591
|
+
this._onRedo = this._onRedo.bind(this);
|
|
592
|
+
this.alignCursor = this.alignCursor.bind(this);
|
|
593
|
+
this.alignCursorFriendly = this.alignCursorFriendly.bind(this);
|
|
594
|
+
this._bindEvents();
|
|
595
|
+
|
|
596
|
+
// refresh
|
|
597
|
+
this.updateValue();
|
|
598
|
+
this._onChange();
|
|
599
|
+
}
|
|
600
|
+
maskEquals(mask) {
|
|
601
|
+
var _this$masked;
|
|
602
|
+
return mask == null || ((_this$masked = this.masked) == null ? void 0 : _this$masked.maskEquals(mask));
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/** Masked */
|
|
606
|
+
get mask() {
|
|
607
|
+
return this.masked.mask;
|
|
608
|
+
}
|
|
609
|
+
set mask(mask) {
|
|
610
|
+
if (this.maskEquals(mask)) return;
|
|
611
|
+
if (!(mask instanceof IMask.Masked) && this.masked.constructor === maskedClass(mask)) {
|
|
612
|
+
// TODO "any" no idea
|
|
613
|
+
this.masked.updateOptions({
|
|
614
|
+
mask
|
|
615
|
+
});
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
const masked = mask instanceof IMask.Masked ? mask : createMask({
|
|
619
|
+
mask
|
|
620
|
+
});
|
|
621
|
+
masked.unmaskedValue = this.masked.unmaskedValue;
|
|
622
|
+
this.masked = masked;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/** Raw value */
|
|
626
|
+
get value() {
|
|
627
|
+
return this._value;
|
|
628
|
+
}
|
|
629
|
+
set value(str) {
|
|
630
|
+
if (this.value === str) return;
|
|
631
|
+
this.masked.value = str;
|
|
632
|
+
this.updateControl('auto');
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/** Unmasked value */
|
|
636
|
+
get unmaskedValue() {
|
|
637
|
+
return this._unmaskedValue;
|
|
638
|
+
}
|
|
639
|
+
set unmaskedValue(str) {
|
|
640
|
+
if (this.unmaskedValue === str) return;
|
|
641
|
+
this.masked.unmaskedValue = str;
|
|
642
|
+
this.updateControl('auto');
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/** Raw input value */
|
|
646
|
+
get rawInputValue() {
|
|
647
|
+
return this._rawInputValue;
|
|
648
|
+
}
|
|
649
|
+
set rawInputValue(str) {
|
|
650
|
+
if (this.rawInputValue === str) return;
|
|
651
|
+
this.masked.rawInputValue = str;
|
|
652
|
+
this.updateControl();
|
|
653
|
+
this.alignCursor();
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/** Typed unmasked value */
|
|
657
|
+
get typedValue() {
|
|
658
|
+
return this.masked.typedValue;
|
|
659
|
+
}
|
|
660
|
+
set typedValue(val) {
|
|
661
|
+
if (this.masked.typedValueEquals(val)) return;
|
|
662
|
+
this.masked.typedValue = val;
|
|
663
|
+
this.updateControl('auto');
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
/** Display value */
|
|
667
|
+
get displayValue() {
|
|
668
|
+
return this.masked.displayValue;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/** Starts listening to element events */
|
|
672
|
+
_bindEvents() {
|
|
673
|
+
this.el.bindEvents({
|
|
674
|
+
selectionChange: this._saveSelection,
|
|
675
|
+
input: this._onInput,
|
|
676
|
+
drop: this._onDrop,
|
|
677
|
+
click: this._onClick,
|
|
678
|
+
focus: this._onFocus,
|
|
679
|
+
commit: this._onChange,
|
|
680
|
+
undo: this._onUndo,
|
|
681
|
+
redo: this._onRedo
|
|
682
|
+
});
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
/** Stops listening to element events */
|
|
686
|
+
_unbindEvents() {
|
|
687
|
+
if (this.el) this.el.unbindEvents();
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
/** Fires custom event */
|
|
691
|
+
_fireEvent(ev, e) {
|
|
692
|
+
const listeners = this._listeners[ev];
|
|
693
|
+
if (!listeners) return;
|
|
694
|
+
listeners.forEach(l => l(e));
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/** Current selection start */
|
|
698
|
+
get selectionStart() {
|
|
699
|
+
return this._cursorChanging ? this._changingCursorPos : this.el.selectionStart;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/** Current cursor position */
|
|
703
|
+
get cursorPos() {
|
|
704
|
+
return this._cursorChanging ? this._changingCursorPos : this.el.selectionEnd;
|
|
705
|
+
}
|
|
706
|
+
set cursorPos(pos) {
|
|
707
|
+
if (!this.el || !this.el.isActive) return;
|
|
708
|
+
this.el.select(pos, pos);
|
|
709
|
+
this._saveSelection();
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/** Stores current selection */
|
|
713
|
+
_saveSelection( /* ev */
|
|
714
|
+
) {
|
|
715
|
+
if (this.displayValue !== this.el.value) {
|
|
716
|
+
console.warn('Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly.'); // eslint-disable-line no-console
|
|
717
|
+
}
|
|
718
|
+
this._selection = {
|
|
719
|
+
start: this.selectionStart,
|
|
720
|
+
end: this.cursorPos
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
/** Syncronizes model value from view */
|
|
725
|
+
updateValue() {
|
|
726
|
+
this.masked.value = this.el.value;
|
|
727
|
+
this._value = this.masked.value;
|
|
728
|
+
this._unmaskedValue = this.masked.unmaskedValue;
|
|
729
|
+
this._rawInputValue = this.masked.rawInputValue;
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
/** Syncronizes view from model value, fires change events */
|
|
733
|
+
updateControl(cursorPos) {
|
|
734
|
+
const newUnmaskedValue = this.masked.unmaskedValue;
|
|
735
|
+
const newValue = this.masked.value;
|
|
736
|
+
const newRawInputValue = this.masked.rawInputValue;
|
|
737
|
+
const newDisplayValue = this.displayValue;
|
|
738
|
+
const isChanged = this.unmaskedValue !== newUnmaskedValue || this.value !== newValue || this._rawInputValue !== newRawInputValue;
|
|
739
|
+
this._unmaskedValue = newUnmaskedValue;
|
|
740
|
+
this._value = newValue;
|
|
741
|
+
this._rawInputValue = newRawInputValue;
|
|
742
|
+
if (this.el.value !== newDisplayValue) this.el.value = newDisplayValue;
|
|
743
|
+
if (cursorPos === 'auto') this.alignCursor();else if (cursorPos != null) this.cursorPos = cursorPos;
|
|
744
|
+
if (isChanged) this._fireChangeEvents();
|
|
745
|
+
if (!this._historyChanging && (isChanged || this.history.isEmpty)) this.history.push({
|
|
746
|
+
unmaskedValue: newUnmaskedValue,
|
|
747
|
+
selection: {
|
|
748
|
+
start: this.selectionStart,
|
|
749
|
+
end: this.cursorPos
|
|
750
|
+
}
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/** Updates options with deep equal check, recreates {@link Masked} model if mask type changes */
|
|
755
|
+
updateOptions(opts) {
|
|
756
|
+
const {
|
|
757
|
+
mask,
|
|
758
|
+
...restOpts
|
|
759
|
+
} = opts; // TODO types, yes, mask is optional
|
|
760
|
+
|
|
761
|
+
const updateMask = !this.maskEquals(mask);
|
|
762
|
+
const updateOpts = this.masked.optionsIsChanged(restOpts);
|
|
763
|
+
if (updateMask) this.mask = mask;
|
|
764
|
+
if (updateOpts) this.masked.updateOptions(restOpts); // TODO
|
|
765
|
+
|
|
766
|
+
if (updateMask || updateOpts) this.updateControl();
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/** Updates cursor */
|
|
770
|
+
updateCursor(cursorPos) {
|
|
771
|
+
if (cursorPos == null) return;
|
|
772
|
+
this.cursorPos = cursorPos;
|
|
773
|
+
|
|
774
|
+
// also queue change cursor for mobile browsers
|
|
775
|
+
this._delayUpdateCursor(cursorPos);
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
/** Delays cursor update to support mobile browsers */
|
|
779
|
+
_delayUpdateCursor(cursorPos) {
|
|
780
|
+
this._abortUpdateCursor();
|
|
781
|
+
this._changingCursorPos = cursorPos;
|
|
782
|
+
this._cursorChanging = setTimeout(() => {
|
|
783
|
+
if (!this.el) return; // if was destroyed
|
|
784
|
+
this.cursorPos = this._changingCursorPos;
|
|
785
|
+
this._abortUpdateCursor();
|
|
786
|
+
}, 10);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
/** Fires custom events */
|
|
790
|
+
_fireChangeEvents() {
|
|
791
|
+
this._fireEvent('accept', this._inputEvent);
|
|
792
|
+
if (this.masked.isComplete) this._fireEvent('complete', this._inputEvent);
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
/** Aborts delayed cursor update */
|
|
796
|
+
_abortUpdateCursor() {
|
|
797
|
+
if (this._cursorChanging) {
|
|
798
|
+
clearTimeout(this._cursorChanging);
|
|
799
|
+
delete this._cursorChanging;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
/** Aligns cursor to nearest available position */
|
|
804
|
+
alignCursor() {
|
|
805
|
+
this.cursorPos = this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos, DIRECTION.LEFT));
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/** Aligns cursor only if selection is empty */
|
|
809
|
+
alignCursorFriendly() {
|
|
810
|
+
if (this.selectionStart !== this.cursorPos) return; // skip if range is selected
|
|
811
|
+
this.alignCursor();
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
/** Adds listener on custom event */
|
|
815
|
+
on(ev, handler) {
|
|
816
|
+
if (!this._listeners[ev]) this._listeners[ev] = [];
|
|
817
|
+
this._listeners[ev].push(handler);
|
|
818
|
+
return this;
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
/** Removes custom event listener */
|
|
822
|
+
off(ev, handler) {
|
|
823
|
+
if (!this._listeners[ev]) return this;
|
|
824
|
+
if (!handler) {
|
|
825
|
+
delete this._listeners[ev];
|
|
826
|
+
return this;
|
|
827
|
+
}
|
|
828
|
+
const hIndex = this._listeners[ev].indexOf(handler);
|
|
829
|
+
if (hIndex >= 0) this._listeners[ev].splice(hIndex, 1);
|
|
830
|
+
return this;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
/** Handles view input event */
|
|
834
|
+
_onInput(e) {
|
|
835
|
+
this._inputEvent = e;
|
|
836
|
+
this._abortUpdateCursor();
|
|
837
|
+
const details = new ActionDetails({
|
|
838
|
+
// new state
|
|
839
|
+
value: this.el.value,
|
|
840
|
+
cursorPos: this.cursorPos,
|
|
841
|
+
// old state
|
|
842
|
+
oldValue: this.displayValue,
|
|
843
|
+
oldSelection: this._selection
|
|
844
|
+
});
|
|
845
|
+
const oldRawValue = this.masked.rawInputValue;
|
|
846
|
+
const offset = this.masked.splice(details.startChangePos, details.removed.length, details.inserted, details.removeDirection, {
|
|
847
|
+
input: true,
|
|
848
|
+
raw: true
|
|
849
|
+
}).offset;
|
|
850
|
+
|
|
851
|
+
// force align in remove direction only if no input chars were removed
|
|
852
|
+
// otherwise we still need to align with NONE (to get out from fixed symbols for instance)
|
|
853
|
+
const removeDirection = oldRawValue === this.masked.rawInputValue ? details.removeDirection : DIRECTION.NONE;
|
|
854
|
+
let cursorPos = this.masked.nearestInputPos(details.startChangePos + offset, removeDirection);
|
|
855
|
+
if (removeDirection !== DIRECTION.NONE) cursorPos = this.masked.nearestInputPos(cursorPos, DIRECTION.NONE);
|
|
856
|
+
this.updateControl(cursorPos);
|
|
857
|
+
delete this._inputEvent;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
/** Handles view change event and commits model value */
|
|
861
|
+
_onChange() {
|
|
862
|
+
if (this.displayValue !== this.el.value) this.updateValue();
|
|
863
|
+
this.masked.doCommit();
|
|
864
|
+
this.updateControl();
|
|
865
|
+
this._saveSelection();
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
/** Handles view drop event, prevents by default */
|
|
869
|
+
_onDrop(ev) {
|
|
870
|
+
ev.preventDefault();
|
|
871
|
+
ev.stopPropagation();
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
/** Restore last selection on focus */
|
|
875
|
+
_onFocus(ev) {
|
|
876
|
+
this.alignCursorFriendly();
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/** Restore last selection on focus */
|
|
880
|
+
_onClick(ev) {
|
|
881
|
+
this.alignCursorFriendly();
|
|
882
|
+
}
|
|
883
|
+
_onUndo() {
|
|
884
|
+
this._applyHistoryState(this.history.undo());
|
|
885
|
+
}
|
|
886
|
+
_onRedo() {
|
|
887
|
+
this._applyHistoryState(this.history.redo());
|
|
888
|
+
}
|
|
889
|
+
_applyHistoryState(state) {
|
|
890
|
+
if (!state) return;
|
|
891
|
+
this._historyChanging = true;
|
|
892
|
+
this.unmaskedValue = state.unmaskedValue;
|
|
893
|
+
this.el.select(state.selection.start, state.selection.end);
|
|
894
|
+
this._saveSelection();
|
|
895
|
+
this._historyChanging = false;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
/** Unbind view events and removes element reference */
|
|
899
|
+
destroy() {
|
|
900
|
+
this._unbindEvents();
|
|
901
|
+
this._listeners.length = 0;
|
|
902
|
+
delete this.el;
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
IMask.InputMask = InputMask;
|
|
906
|
+
|
|
907
|
+
/** Provides details of changing model value */
|
|
908
|
+
class ChangeDetails {
|
|
909
|
+
/** Inserted symbols */
|
|
910
|
+
|
|
911
|
+
/** Additional offset if any changes occurred before tail */
|
|
912
|
+
|
|
913
|
+
/** Raw inserted is used by dynamic mask */
|
|
914
|
+
|
|
915
|
+
/** Can skip chars */
|
|
916
|
+
|
|
917
|
+
static normalize(prep) {
|
|
918
|
+
return Array.isArray(prep) ? prep : [prep, new ChangeDetails()];
|
|
919
|
+
}
|
|
920
|
+
constructor(details) {
|
|
921
|
+
Object.assign(this, {
|
|
922
|
+
inserted: '',
|
|
923
|
+
rawInserted: '',
|
|
924
|
+
tailShift: 0,
|
|
925
|
+
skip: false
|
|
926
|
+
}, details);
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
/** Aggregate changes */
|
|
930
|
+
aggregate(details) {
|
|
931
|
+
this.inserted += details.inserted;
|
|
932
|
+
this.rawInserted += details.rawInserted;
|
|
933
|
+
this.tailShift += details.tailShift;
|
|
934
|
+
this.skip = this.skip || details.skip;
|
|
935
|
+
return this;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
/** Total offset considering all changes */
|
|
939
|
+
get offset() {
|
|
940
|
+
return this.tailShift + this.inserted.length;
|
|
941
|
+
}
|
|
942
|
+
get consumed() {
|
|
943
|
+
return Boolean(this.rawInserted) || this.skip;
|
|
944
|
+
}
|
|
945
|
+
equals(details) {
|
|
946
|
+
return this.inserted === details.inserted && this.tailShift === details.tailShift && this.rawInserted === details.rawInserted && this.skip === details.skip;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
IMask.ChangeDetails = ChangeDetails;
|
|
950
|
+
|
|
951
|
+
/** Provides details of continuous extracted tail */
|
|
952
|
+
class ContinuousTailDetails {
|
|
953
|
+
/** Tail value as string */
|
|
954
|
+
|
|
955
|
+
/** Tail start position */
|
|
956
|
+
|
|
957
|
+
/** Start position */
|
|
958
|
+
|
|
959
|
+
constructor(value, from, stop) {
|
|
960
|
+
if (value === void 0) {
|
|
961
|
+
value = '';
|
|
962
|
+
}
|
|
963
|
+
if (from === void 0) {
|
|
964
|
+
from = 0;
|
|
965
|
+
}
|
|
966
|
+
this.value = value;
|
|
967
|
+
this.from = from;
|
|
968
|
+
this.stop = stop;
|
|
969
|
+
}
|
|
970
|
+
toString() {
|
|
971
|
+
return this.value;
|
|
972
|
+
}
|
|
973
|
+
extend(tail) {
|
|
974
|
+
this.value += String(tail);
|
|
975
|
+
}
|
|
976
|
+
appendTo(masked) {
|
|
977
|
+
return masked.append(this.toString(), {
|
|
978
|
+
tail: true
|
|
979
|
+
}).aggregate(masked._appendPlaceholder());
|
|
980
|
+
}
|
|
981
|
+
get state() {
|
|
982
|
+
return {
|
|
983
|
+
value: this.value,
|
|
984
|
+
from: this.from,
|
|
985
|
+
stop: this.stop
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
set state(state) {
|
|
989
|
+
Object.assign(this, state);
|
|
990
|
+
}
|
|
991
|
+
unshift(beforePos) {
|
|
992
|
+
if (!this.value.length || beforePos != null && this.from >= beforePos) return '';
|
|
993
|
+
const shiftChar = this.value[0];
|
|
994
|
+
this.value = this.value.slice(1);
|
|
995
|
+
return shiftChar;
|
|
996
|
+
}
|
|
997
|
+
shift() {
|
|
998
|
+
if (!this.value.length) return '';
|
|
999
|
+
const shiftChar = this.value[this.value.length - 1];
|
|
1000
|
+
this.value = this.value.slice(0, -1);
|
|
1001
|
+
return shiftChar;
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
/** Append flags */
|
|
1006
|
+
|
|
1007
|
+
/** Extract flags */
|
|
1008
|
+
|
|
1009
|
+
// see https://github.com/microsoft/TypeScript/issues/6223
|
|
1010
|
+
|
|
1011
|
+
/** Provides common masking stuff */
|
|
1012
|
+
class Masked {
|
|
1013
|
+
/** */
|
|
1014
|
+
|
|
1015
|
+
/** */
|
|
1016
|
+
|
|
1017
|
+
/** Transforms value before mask processing */
|
|
1018
|
+
|
|
1019
|
+
/** Transforms each char before mask processing */
|
|
1020
|
+
|
|
1021
|
+
/** Validates if value is acceptable */
|
|
1022
|
+
|
|
1023
|
+
/** Does additional processing at the end of editing */
|
|
1024
|
+
|
|
1025
|
+
/** Format typed value to string */
|
|
1026
|
+
|
|
1027
|
+
/** Parse string to get typed value */
|
|
1028
|
+
|
|
1029
|
+
/** Enable characters overwriting */
|
|
1030
|
+
|
|
1031
|
+
/** */
|
|
1032
|
+
|
|
1033
|
+
/** */
|
|
1034
|
+
|
|
1035
|
+
/** */
|
|
1036
|
+
|
|
1037
|
+
/** */
|
|
1038
|
+
|
|
1039
|
+
constructor(opts) {
|
|
1040
|
+
this._value = '';
|
|
1041
|
+
this._update({
|
|
1042
|
+
...Masked.DEFAULTS,
|
|
1043
|
+
...opts
|
|
1044
|
+
});
|
|
1045
|
+
this._initialized = true;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
/** Sets and applies new options */
|
|
1049
|
+
updateOptions(opts) {
|
|
1050
|
+
if (!this.optionsIsChanged(opts)) return;
|
|
1051
|
+
this.withValueRefresh(this._update.bind(this, opts));
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
/** Sets new options */
|
|
1055
|
+
_update(opts) {
|
|
1056
|
+
Object.assign(this, opts);
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
/** Mask state */
|
|
1060
|
+
get state() {
|
|
1061
|
+
return {
|
|
1062
|
+
_value: this.value,
|
|
1063
|
+
_rawInputValue: this.rawInputValue
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
set state(state) {
|
|
1067
|
+
this._value = state._value;
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
/** Resets value */
|
|
1071
|
+
reset() {
|
|
1072
|
+
this._value = '';
|
|
1073
|
+
}
|
|
1074
|
+
get value() {
|
|
1075
|
+
return this._value;
|
|
1076
|
+
}
|
|
1077
|
+
set value(value) {
|
|
1078
|
+
this.resolve(value, {
|
|
1079
|
+
input: true
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
/** Resolve new value */
|
|
1084
|
+
resolve(value, flags) {
|
|
1085
|
+
if (flags === void 0) {
|
|
1086
|
+
flags = {
|
|
1087
|
+
input: true
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
this.reset();
|
|
1091
|
+
this.append(value, flags, '');
|
|
1092
|
+
this.doCommit();
|
|
1093
|
+
}
|
|
1094
|
+
get unmaskedValue() {
|
|
1095
|
+
return this.value;
|
|
1096
|
+
}
|
|
1097
|
+
set unmaskedValue(value) {
|
|
1098
|
+
this.resolve(value, {});
|
|
1099
|
+
}
|
|
1100
|
+
get typedValue() {
|
|
1101
|
+
return this.parse ? this.parse(this.value, this) : this.unmaskedValue;
|
|
1102
|
+
}
|
|
1103
|
+
set typedValue(value) {
|
|
1104
|
+
if (this.format) {
|
|
1105
|
+
this.value = this.format(value, this);
|
|
1106
|
+
} else {
|
|
1107
|
+
this.unmaskedValue = String(value);
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
/** Value that includes raw user input */
|
|
1112
|
+
get rawInputValue() {
|
|
1113
|
+
return this.extractInput(0, this.displayValue.length, {
|
|
1114
|
+
raw: true
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
set rawInputValue(value) {
|
|
1118
|
+
this.resolve(value, {
|
|
1119
|
+
raw: true
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
get displayValue() {
|
|
1123
|
+
return this.value;
|
|
1124
|
+
}
|
|
1125
|
+
get isComplete() {
|
|
1126
|
+
return true;
|
|
1127
|
+
}
|
|
1128
|
+
get isFilled() {
|
|
1129
|
+
return this.isComplete;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
/** Finds nearest input position in direction */
|
|
1133
|
+
nearestInputPos(cursorPos, direction) {
|
|
1134
|
+
return cursorPos;
|
|
1135
|
+
}
|
|
1136
|
+
totalInputPositions(fromPos, toPos) {
|
|
1137
|
+
if (fromPos === void 0) {
|
|
1138
|
+
fromPos = 0;
|
|
1139
|
+
}
|
|
1140
|
+
if (toPos === void 0) {
|
|
1141
|
+
toPos = this.displayValue.length;
|
|
1142
|
+
}
|
|
1143
|
+
return Math.min(this.displayValue.length, toPos - fromPos);
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
/** Extracts value in range considering flags */
|
|
1147
|
+
extractInput(fromPos, toPos, flags) {
|
|
1148
|
+
if (fromPos === void 0) {
|
|
1149
|
+
fromPos = 0;
|
|
1150
|
+
}
|
|
1151
|
+
if (toPos === void 0) {
|
|
1152
|
+
toPos = this.displayValue.length;
|
|
1153
|
+
}
|
|
1154
|
+
return this.displayValue.slice(fromPos, toPos);
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
/** Extracts tail in range */
|
|
1158
|
+
extractTail(fromPos, toPos) {
|
|
1159
|
+
if (fromPos === void 0) {
|
|
1160
|
+
fromPos = 0;
|
|
1161
|
+
}
|
|
1162
|
+
if (toPos === void 0) {
|
|
1163
|
+
toPos = this.displayValue.length;
|
|
1164
|
+
}
|
|
1165
|
+
return new ContinuousTailDetails(this.extractInput(fromPos, toPos), fromPos);
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
/** Appends tail */
|
|
1169
|
+
appendTail(tail) {
|
|
1170
|
+
if (isString(tail)) tail = new ContinuousTailDetails(String(tail));
|
|
1171
|
+
return tail.appendTo(this);
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
/** Appends char */
|
|
1175
|
+
_appendCharRaw(ch, flags) {
|
|
1176
|
+
if (!ch) return new ChangeDetails();
|
|
1177
|
+
this._value += ch;
|
|
1178
|
+
return new ChangeDetails({
|
|
1179
|
+
inserted: ch,
|
|
1180
|
+
rawInserted: ch
|
|
1181
|
+
});
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
/** Appends char */
|
|
1185
|
+
_appendChar(ch, flags, checkTail) {
|
|
1186
|
+
if (flags === void 0) {
|
|
1187
|
+
flags = {};
|
|
1188
|
+
}
|
|
1189
|
+
const consistentState = this.state;
|
|
1190
|
+
let details;
|
|
1191
|
+
[ch, details] = this.doPrepareChar(ch, flags);
|
|
1192
|
+
if (ch) {
|
|
1193
|
+
details = details.aggregate(this._appendCharRaw(ch, flags));
|
|
1194
|
+
|
|
1195
|
+
// TODO handle `skip`?
|
|
1196
|
+
|
|
1197
|
+
// try `autofix` lookahead
|
|
1198
|
+
if (!details.rawInserted && this.autofix === 'pad') {
|
|
1199
|
+
const noFixState = this.state;
|
|
1200
|
+
this.state = consistentState;
|
|
1201
|
+
let fixDetails = this.pad(flags);
|
|
1202
|
+
const chDetails = this._appendCharRaw(ch, flags);
|
|
1203
|
+
fixDetails = fixDetails.aggregate(chDetails);
|
|
1204
|
+
|
|
1205
|
+
// if fix was applied or
|
|
1206
|
+
// if details are equal use skip restoring state optimization
|
|
1207
|
+
if (chDetails.rawInserted || fixDetails.equals(details)) {
|
|
1208
|
+
details = fixDetails;
|
|
1209
|
+
} else {
|
|
1210
|
+
this.state = noFixState;
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
if (details.inserted) {
|
|
1215
|
+
let consistentTail;
|
|
1216
|
+
let appended = this.doValidate(flags) !== false;
|
|
1217
|
+
if (appended && checkTail != null) {
|
|
1218
|
+
// validation ok, check tail
|
|
1219
|
+
const beforeTailState = this.state;
|
|
1220
|
+
if (this.overwrite === true) {
|
|
1221
|
+
consistentTail = checkTail.state;
|
|
1222
|
+
for (let i = 0; i < details.rawInserted.length; ++i) {
|
|
1223
|
+
checkTail.unshift(this.displayValue.length - details.tailShift);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
let tailDetails = this.appendTail(checkTail);
|
|
1227
|
+
appended = tailDetails.rawInserted.length === checkTail.toString().length;
|
|
1228
|
+
|
|
1229
|
+
// not ok, try shift
|
|
1230
|
+
if (!(appended && tailDetails.inserted) && this.overwrite === 'shift') {
|
|
1231
|
+
this.state = beforeTailState;
|
|
1232
|
+
consistentTail = checkTail.state;
|
|
1233
|
+
for (let i = 0; i < details.rawInserted.length; ++i) {
|
|
1234
|
+
checkTail.shift();
|
|
1235
|
+
}
|
|
1236
|
+
tailDetails = this.appendTail(checkTail);
|
|
1237
|
+
appended = tailDetails.rawInserted.length === checkTail.toString().length;
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
// if ok, rollback state after tail
|
|
1241
|
+
if (appended && tailDetails.inserted) this.state = beforeTailState;
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
// revert all if something went wrong
|
|
1245
|
+
if (!appended) {
|
|
1246
|
+
details = new ChangeDetails();
|
|
1247
|
+
this.state = consistentState;
|
|
1248
|
+
if (checkTail && consistentTail) checkTail.state = consistentTail;
|
|
1249
|
+
}
|
|
1250
|
+
}
|
|
1251
|
+
return details;
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
/** Appends optional placeholder at the end */
|
|
1255
|
+
_appendPlaceholder() {
|
|
1256
|
+
return new ChangeDetails();
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
/** Appends optional eager placeholder at the end */
|
|
1260
|
+
_appendEager() {
|
|
1261
|
+
return new ChangeDetails();
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
/** Appends symbols considering flags */
|
|
1265
|
+
append(str, flags, tail) {
|
|
1266
|
+
if (!isString(str)) throw new Error('value should be string');
|
|
1267
|
+
const checkTail = isString(tail) ? new ContinuousTailDetails(String(tail)) : tail;
|
|
1268
|
+
if (flags != null && flags.tail) flags._beforeTailState = this.state;
|
|
1269
|
+
let details;
|
|
1270
|
+
[str, details] = this.doPrepare(str, flags);
|
|
1271
|
+
for (let ci = 0; ci < str.length; ++ci) {
|
|
1272
|
+
const d = this._appendChar(str[ci], flags, checkTail);
|
|
1273
|
+
if (!d.rawInserted && !this.doSkipInvalid(str[ci], flags, checkTail)) break;
|
|
1274
|
+
details.aggregate(d);
|
|
1275
|
+
}
|
|
1276
|
+
if ((this.eager === true || this.eager === 'append') && flags != null && flags.input && str) {
|
|
1277
|
+
details.aggregate(this._appendEager());
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
// append tail but aggregate only tailShift
|
|
1281
|
+
if (checkTail != null) {
|
|
1282
|
+
details.tailShift += this.appendTail(checkTail).tailShift;
|
|
1283
|
+
// TODO it's a good idea to clear state after appending ends
|
|
1284
|
+
// but it causes bugs when one append calls another (when dynamic dispatch set rawInputValue)
|
|
1285
|
+
// this._resetBeforeTailState();
|
|
1286
|
+
}
|
|
1287
|
+
return details;
|
|
1288
|
+
}
|
|
1289
|
+
remove(fromPos, toPos) {
|
|
1290
|
+
if (fromPos === void 0) {
|
|
1291
|
+
fromPos = 0;
|
|
1292
|
+
}
|
|
1293
|
+
if (toPos === void 0) {
|
|
1294
|
+
toPos = this.displayValue.length;
|
|
1295
|
+
}
|
|
1296
|
+
this._value = this.displayValue.slice(0, fromPos) + this.displayValue.slice(toPos);
|
|
1297
|
+
return new ChangeDetails();
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
/** Calls function and reapplies current value */
|
|
1301
|
+
withValueRefresh(fn) {
|
|
1302
|
+
if (this._refreshing || !this._initialized) return fn();
|
|
1303
|
+
this._refreshing = true;
|
|
1304
|
+
const rawInput = this.rawInputValue;
|
|
1305
|
+
const value = this.value;
|
|
1306
|
+
const ret = fn();
|
|
1307
|
+
this.rawInputValue = rawInput;
|
|
1308
|
+
// append lost trailing chars at the end
|
|
1309
|
+
if (this.value && this.value !== value && value.indexOf(this.value) === 0) {
|
|
1310
|
+
this.append(value.slice(this.displayValue.length), {}, '');
|
|
1311
|
+
this.doCommit();
|
|
1312
|
+
}
|
|
1313
|
+
delete this._refreshing;
|
|
1314
|
+
return ret;
|
|
1315
|
+
}
|
|
1316
|
+
runIsolated(fn) {
|
|
1317
|
+
if (this._isolated || !this._initialized) return fn(this);
|
|
1318
|
+
this._isolated = true;
|
|
1319
|
+
const state = this.state;
|
|
1320
|
+
const ret = fn(this);
|
|
1321
|
+
this.state = state;
|
|
1322
|
+
delete this._isolated;
|
|
1323
|
+
return ret;
|
|
1324
|
+
}
|
|
1325
|
+
doSkipInvalid(ch, flags, checkTail) {
|
|
1326
|
+
return Boolean(this.skipInvalid);
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
/** Prepares string before mask processing */
|
|
1330
|
+
doPrepare(str, flags) {
|
|
1331
|
+
if (flags === void 0) {
|
|
1332
|
+
flags = {};
|
|
1333
|
+
}
|
|
1334
|
+
return ChangeDetails.normalize(this.prepare ? this.prepare(str, this, flags) : str);
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
/** Prepares each char before mask processing */
|
|
1338
|
+
doPrepareChar(str, flags) {
|
|
1339
|
+
if (flags === void 0) {
|
|
1340
|
+
flags = {};
|
|
1341
|
+
}
|
|
1342
|
+
return ChangeDetails.normalize(this.prepareChar ? this.prepareChar(str, this, flags) : str);
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
/** Validates if value is acceptable */
|
|
1346
|
+
doValidate(flags) {
|
|
1347
|
+
return (!this.validate || this.validate(this.value, this, flags)) && (!this.parent || this.parent.doValidate(flags));
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
/** Does additional processing at the end of editing */
|
|
1351
|
+
doCommit() {
|
|
1352
|
+
if (this.commit) this.commit(this.value, this);
|
|
1353
|
+
}
|
|
1354
|
+
splice(start, deleteCount, inserted, removeDirection, flags) {
|
|
1355
|
+
if (inserted === void 0) {
|
|
1356
|
+
inserted = '';
|
|
1357
|
+
}
|
|
1358
|
+
if (removeDirection === void 0) {
|
|
1359
|
+
removeDirection = DIRECTION.NONE;
|
|
1360
|
+
}
|
|
1361
|
+
if (flags === void 0) {
|
|
1362
|
+
flags = {
|
|
1363
|
+
input: true
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
const tailPos = start + deleteCount;
|
|
1367
|
+
const tail = this.extractTail(tailPos);
|
|
1368
|
+
const eagerRemove = this.eager === true || this.eager === 'remove';
|
|
1369
|
+
let oldRawValue;
|
|
1370
|
+
if (eagerRemove) {
|
|
1371
|
+
removeDirection = forceDirection(removeDirection);
|
|
1372
|
+
oldRawValue = this.extractInput(0, tailPos, {
|
|
1373
|
+
raw: true
|
|
1374
|
+
});
|
|
1375
|
+
}
|
|
1376
|
+
let startChangePos = start;
|
|
1377
|
+
const details = new ChangeDetails();
|
|
1378
|
+
|
|
1379
|
+
// if it is just deletion without insertion
|
|
1380
|
+
if (removeDirection !== DIRECTION.NONE) {
|
|
1381
|
+
startChangePos = this.nearestInputPos(start, deleteCount > 1 && start !== 0 && !eagerRemove ? DIRECTION.NONE : removeDirection);
|
|
1382
|
+
|
|
1383
|
+
// adjust tailShift if start was aligned
|
|
1384
|
+
details.tailShift = startChangePos - start;
|
|
1385
|
+
}
|
|
1386
|
+
details.aggregate(this.remove(startChangePos));
|
|
1387
|
+
if (eagerRemove && removeDirection !== DIRECTION.NONE && oldRawValue === this.rawInputValue) {
|
|
1388
|
+
if (removeDirection === DIRECTION.FORCE_LEFT) {
|
|
1389
|
+
let valLength;
|
|
1390
|
+
while (oldRawValue === this.rawInputValue && (valLength = this.displayValue.length)) {
|
|
1391
|
+
details.aggregate(new ChangeDetails({
|
|
1392
|
+
tailShift: -1
|
|
1393
|
+
})).aggregate(this.remove(valLength - 1));
|
|
1394
|
+
}
|
|
1395
|
+
} else if (removeDirection === DIRECTION.FORCE_RIGHT) {
|
|
1396
|
+
tail.unshift();
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
return details.aggregate(this.append(inserted, flags, tail));
|
|
1400
|
+
}
|
|
1401
|
+
maskEquals(mask) {
|
|
1402
|
+
return this.mask === mask;
|
|
1403
|
+
}
|
|
1404
|
+
optionsIsChanged(opts) {
|
|
1405
|
+
return !objectIncludes(this, opts);
|
|
1406
|
+
}
|
|
1407
|
+
typedValueEquals(value) {
|
|
1408
|
+
const tval = this.typedValue;
|
|
1409
|
+
return value === tval || Masked.EMPTY_VALUES.includes(value) && Masked.EMPTY_VALUES.includes(tval) || (this.format ? this.format(value, this) === this.format(this.typedValue, this) : false);
|
|
1410
|
+
}
|
|
1411
|
+
pad(flags) {
|
|
1412
|
+
return new ChangeDetails();
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
Masked.DEFAULTS = {
|
|
1416
|
+
skipInvalid: true
|
|
1417
|
+
};
|
|
1418
|
+
Masked.EMPTY_VALUES = [undefined, null, ''];
|
|
1419
|
+
IMask.Masked = Masked;
|
|
1420
|
+
|
|
1421
|
+
class ChunksTailDetails {
|
|
1422
|
+
/** */
|
|
1423
|
+
|
|
1424
|
+
constructor(chunks, from) {
|
|
1425
|
+
if (chunks === void 0) {
|
|
1426
|
+
chunks = [];
|
|
1427
|
+
}
|
|
1428
|
+
if (from === void 0) {
|
|
1429
|
+
from = 0;
|
|
1430
|
+
}
|
|
1431
|
+
this.chunks = chunks;
|
|
1432
|
+
this.from = from;
|
|
1433
|
+
}
|
|
1434
|
+
toString() {
|
|
1435
|
+
return this.chunks.map(String).join('');
|
|
1436
|
+
}
|
|
1437
|
+
extend(tailChunk) {
|
|
1438
|
+
if (!String(tailChunk)) return;
|
|
1439
|
+
tailChunk = isString(tailChunk) ? new ContinuousTailDetails(String(tailChunk)) : tailChunk;
|
|
1440
|
+
const lastChunk = this.chunks[this.chunks.length - 1];
|
|
1441
|
+
const extendLast = lastChunk && (
|
|
1442
|
+
// if stops are same or tail has no stop
|
|
1443
|
+
lastChunk.stop === tailChunk.stop || tailChunk.stop == null) &&
|
|
1444
|
+
// if tail chunk goes just after last chunk
|
|
1445
|
+
tailChunk.from === lastChunk.from + lastChunk.toString().length;
|
|
1446
|
+
if (tailChunk instanceof ContinuousTailDetails) {
|
|
1447
|
+
// check the ability to extend previous chunk
|
|
1448
|
+
if (extendLast) {
|
|
1449
|
+
// extend previous chunk
|
|
1450
|
+
lastChunk.extend(tailChunk.toString());
|
|
1451
|
+
} else {
|
|
1452
|
+
// append new chunk
|
|
1453
|
+
this.chunks.push(tailChunk);
|
|
1454
|
+
}
|
|
1455
|
+
} else if (tailChunk instanceof ChunksTailDetails) {
|
|
1456
|
+
if (tailChunk.stop == null) {
|
|
1457
|
+
// unwrap floating chunks to parent, keeping `from` pos
|
|
1458
|
+
let firstTailChunk;
|
|
1459
|
+
while (tailChunk.chunks.length && tailChunk.chunks[0].stop == null) {
|
|
1460
|
+
firstTailChunk = tailChunk.chunks.shift(); // not possible to be `undefined` because length was checked above
|
|
1461
|
+
firstTailChunk.from += tailChunk.from;
|
|
1462
|
+
this.extend(firstTailChunk);
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
// if tail chunk still has value
|
|
1467
|
+
if (tailChunk.toString()) {
|
|
1468
|
+
// if chunks contains stops, then popup stop to container
|
|
1469
|
+
tailChunk.stop = tailChunk.blockIndex;
|
|
1470
|
+
this.chunks.push(tailChunk);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
appendTo(masked) {
|
|
1475
|
+
if (!(masked instanceof IMask.MaskedPattern)) {
|
|
1476
|
+
const tail = new ContinuousTailDetails(this.toString());
|
|
1477
|
+
return tail.appendTo(masked);
|
|
1478
|
+
}
|
|
1479
|
+
const details = new ChangeDetails();
|
|
1480
|
+
for (let ci = 0; ci < this.chunks.length; ++ci) {
|
|
1481
|
+
const chunk = this.chunks[ci];
|
|
1482
|
+
const lastBlockIter = masked._mapPosToBlock(masked.displayValue.length);
|
|
1483
|
+
const stop = chunk.stop;
|
|
1484
|
+
let chunkBlock;
|
|
1485
|
+
if (stop != null && (
|
|
1486
|
+
// if block not found or stop is behind lastBlock
|
|
1487
|
+
!lastBlockIter || lastBlockIter.index <= stop)) {
|
|
1488
|
+
if (chunk instanceof ChunksTailDetails ||
|
|
1489
|
+
// for continuous block also check if stop is exist
|
|
1490
|
+
masked._stops.indexOf(stop) >= 0) {
|
|
1491
|
+
details.aggregate(masked._appendPlaceholder(stop));
|
|
1492
|
+
}
|
|
1493
|
+
chunkBlock = chunk instanceof ChunksTailDetails && masked._blocks[stop];
|
|
1494
|
+
}
|
|
1495
|
+
if (chunkBlock) {
|
|
1496
|
+
const tailDetails = chunkBlock.appendTail(chunk);
|
|
1497
|
+
details.aggregate(tailDetails);
|
|
1498
|
+
|
|
1499
|
+
// get not inserted chars
|
|
1500
|
+
const remainChars = chunk.toString().slice(tailDetails.rawInserted.length);
|
|
1501
|
+
if (remainChars) details.aggregate(masked.append(remainChars, {
|
|
1502
|
+
tail: true
|
|
1503
|
+
}));
|
|
1504
|
+
} else {
|
|
1505
|
+
details.aggregate(masked.append(chunk.toString(), {
|
|
1506
|
+
tail: true
|
|
1507
|
+
}));
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
return details;
|
|
1511
|
+
}
|
|
1512
|
+
get state() {
|
|
1513
|
+
return {
|
|
1514
|
+
chunks: this.chunks.map(c => c.state),
|
|
1515
|
+
from: this.from,
|
|
1516
|
+
stop: this.stop,
|
|
1517
|
+
blockIndex: this.blockIndex
|
|
1518
|
+
};
|
|
1519
|
+
}
|
|
1520
|
+
set state(state) {
|
|
1521
|
+
const {
|
|
1522
|
+
chunks,
|
|
1523
|
+
...props
|
|
1524
|
+
} = state;
|
|
1525
|
+
Object.assign(this, props);
|
|
1526
|
+
this.chunks = chunks.map(cstate => {
|
|
1527
|
+
const chunk = "chunks" in cstate ? new ChunksTailDetails() : new ContinuousTailDetails();
|
|
1528
|
+
chunk.state = cstate;
|
|
1529
|
+
return chunk;
|
|
1530
|
+
});
|
|
1531
|
+
}
|
|
1532
|
+
unshift(beforePos) {
|
|
1533
|
+
if (!this.chunks.length || beforePos != null && this.from >= beforePos) return '';
|
|
1534
|
+
const chunkShiftPos = beforePos != null ? beforePos - this.from : beforePos;
|
|
1535
|
+
let ci = 0;
|
|
1536
|
+
while (ci < this.chunks.length) {
|
|
1537
|
+
const chunk = this.chunks[ci];
|
|
1538
|
+
const shiftChar = chunk.unshift(chunkShiftPos);
|
|
1539
|
+
if (chunk.toString()) {
|
|
1540
|
+
// chunk still contains value
|
|
1541
|
+
// but not shifted - means no more available chars to shift
|
|
1542
|
+
if (!shiftChar) break;
|
|
1543
|
+
++ci;
|
|
1544
|
+
} else {
|
|
1545
|
+
// clean if chunk has no value
|
|
1546
|
+
this.chunks.splice(ci, 1);
|
|
1547
|
+
}
|
|
1548
|
+
if (shiftChar) return shiftChar;
|
|
1549
|
+
}
|
|
1550
|
+
return '';
|
|
1551
|
+
}
|
|
1552
|
+
shift() {
|
|
1553
|
+
if (!this.chunks.length) return '';
|
|
1554
|
+
let ci = this.chunks.length - 1;
|
|
1555
|
+
while (0 <= ci) {
|
|
1556
|
+
const chunk = this.chunks[ci];
|
|
1557
|
+
const shiftChar = chunk.shift();
|
|
1558
|
+
if (chunk.toString()) {
|
|
1559
|
+
// chunk still contains value
|
|
1560
|
+
// but not shifted - means no more available chars to shift
|
|
1561
|
+
if (!shiftChar) break;
|
|
1562
|
+
--ci;
|
|
1563
|
+
} else {
|
|
1564
|
+
// clean if chunk has no value
|
|
1565
|
+
this.chunks.splice(ci, 1);
|
|
1566
|
+
}
|
|
1567
|
+
if (shiftChar) return shiftChar;
|
|
1568
|
+
}
|
|
1569
|
+
return '';
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
class PatternCursor {
|
|
1574
|
+
constructor(masked, pos) {
|
|
1575
|
+
this.masked = masked;
|
|
1576
|
+
this._log = [];
|
|
1577
|
+
const {
|
|
1578
|
+
offset,
|
|
1579
|
+
index
|
|
1580
|
+
} = masked._mapPosToBlock(pos) || (pos < 0 ?
|
|
1581
|
+
// first
|
|
1582
|
+
{
|
|
1583
|
+
index: 0,
|
|
1584
|
+
offset: 0
|
|
1585
|
+
} :
|
|
1586
|
+
// last
|
|
1587
|
+
{
|
|
1588
|
+
index: this.masked._blocks.length,
|
|
1589
|
+
offset: 0
|
|
1590
|
+
});
|
|
1591
|
+
this.offset = offset;
|
|
1592
|
+
this.index = index;
|
|
1593
|
+
this.ok = false;
|
|
1594
|
+
}
|
|
1595
|
+
get block() {
|
|
1596
|
+
return this.masked._blocks[this.index];
|
|
1597
|
+
}
|
|
1598
|
+
get pos() {
|
|
1599
|
+
return this.masked._blockStartPos(this.index) + this.offset;
|
|
1600
|
+
}
|
|
1601
|
+
get state() {
|
|
1602
|
+
return {
|
|
1603
|
+
index: this.index,
|
|
1604
|
+
offset: this.offset,
|
|
1605
|
+
ok: this.ok
|
|
1606
|
+
};
|
|
1607
|
+
}
|
|
1608
|
+
set state(s) {
|
|
1609
|
+
Object.assign(this, s);
|
|
1610
|
+
}
|
|
1611
|
+
pushState() {
|
|
1612
|
+
this._log.push(this.state);
|
|
1613
|
+
}
|
|
1614
|
+
popState() {
|
|
1615
|
+
const s = this._log.pop();
|
|
1616
|
+
if (s) this.state = s;
|
|
1617
|
+
return s;
|
|
1618
|
+
}
|
|
1619
|
+
bindBlock() {
|
|
1620
|
+
if (this.block) return;
|
|
1621
|
+
if (this.index < 0) {
|
|
1622
|
+
this.index = 0;
|
|
1623
|
+
this.offset = 0;
|
|
1624
|
+
}
|
|
1625
|
+
if (this.index >= this.masked._blocks.length) {
|
|
1626
|
+
this.index = this.masked._blocks.length - 1;
|
|
1627
|
+
this.offset = this.block.displayValue.length; // TODO this is stupid type error, `block` depends on index that was changed above
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
_pushLeft(fn) {
|
|
1631
|
+
this.pushState();
|
|
1632
|
+
for (this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((_this$block = this.block) == null ? void 0 : _this$block.displayValue.length) || 0) {
|
|
1633
|
+
var _this$block;
|
|
1634
|
+
if (fn()) return this.ok = true;
|
|
1635
|
+
}
|
|
1636
|
+
return this.ok = false;
|
|
1637
|
+
}
|
|
1638
|
+
_pushRight(fn) {
|
|
1639
|
+
this.pushState();
|
|
1640
|
+
for (this.bindBlock(); this.index < this.masked._blocks.length; ++this.index, this.offset = 0) {
|
|
1641
|
+
if (fn()) return this.ok = true;
|
|
1642
|
+
}
|
|
1643
|
+
return this.ok = false;
|
|
1644
|
+
}
|
|
1645
|
+
pushLeftBeforeFilled() {
|
|
1646
|
+
return this._pushLeft(() => {
|
|
1647
|
+
if (this.block.isFixed || !this.block.value) return;
|
|
1648
|
+
this.offset = this.block.nearestInputPos(this.offset, DIRECTION.FORCE_LEFT);
|
|
1649
|
+
if (this.offset !== 0) return true;
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
pushLeftBeforeInput() {
|
|
1653
|
+
// cases:
|
|
1654
|
+
// filled input: 00|
|
|
1655
|
+
// optional empty input: 00[]|
|
|
1656
|
+
// nested block: XX<[]>|
|
|
1657
|
+
return this._pushLeft(() => {
|
|
1658
|
+
if (this.block.isFixed) return;
|
|
1659
|
+
this.offset = this.block.nearestInputPos(this.offset, DIRECTION.LEFT);
|
|
1660
|
+
return true;
|
|
1661
|
+
});
|
|
1662
|
+
}
|
|
1663
|
+
pushLeftBeforeRequired() {
|
|
1664
|
+
return this._pushLeft(() => {
|
|
1665
|
+
if (this.block.isFixed || this.block.isOptional && !this.block.value) return;
|
|
1666
|
+
this.offset = this.block.nearestInputPos(this.offset, DIRECTION.LEFT);
|
|
1667
|
+
return true;
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
pushRightBeforeFilled() {
|
|
1671
|
+
return this._pushRight(() => {
|
|
1672
|
+
if (this.block.isFixed || !this.block.value) return;
|
|
1673
|
+
this.offset = this.block.nearestInputPos(this.offset, DIRECTION.FORCE_RIGHT);
|
|
1674
|
+
if (this.offset !== this.block.value.length) return true;
|
|
1675
|
+
});
|
|
1676
|
+
}
|
|
1677
|
+
pushRightBeforeInput() {
|
|
1678
|
+
return this._pushRight(() => {
|
|
1679
|
+
if (this.block.isFixed) return;
|
|
1680
|
+
|
|
1681
|
+
// const o = this.offset;
|
|
1682
|
+
this.offset = this.block.nearestInputPos(this.offset, DIRECTION.NONE);
|
|
1683
|
+
// HACK cases like (STILL DOES NOT WORK FOR NESTED)
|
|
1684
|
+
// aa|X
|
|
1685
|
+
// aa<X|[]>X_ - this will not work
|
|
1686
|
+
// if (o && o === this.offset && this.block instanceof PatternInputDefinition) continue;
|
|
1687
|
+
return true;
|
|
1688
|
+
});
|
|
1689
|
+
}
|
|
1690
|
+
pushRightBeforeRequired() {
|
|
1691
|
+
return this._pushRight(() => {
|
|
1692
|
+
if (this.block.isFixed || this.block.isOptional && !this.block.value) return;
|
|
1693
|
+
|
|
1694
|
+
// TODO check |[*]XX_
|
|
1695
|
+
this.offset = this.block.nearestInputPos(this.offset, DIRECTION.NONE);
|
|
1696
|
+
return true;
|
|
1697
|
+
});
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
|
|
1701
|
+
class PatternFixedDefinition {
|
|
1702
|
+
/** */
|
|
1703
|
+
|
|
1704
|
+
/** */
|
|
1705
|
+
|
|
1706
|
+
/** */
|
|
1707
|
+
|
|
1708
|
+
/** */
|
|
1709
|
+
|
|
1710
|
+
/** */
|
|
1711
|
+
|
|
1712
|
+
/** */
|
|
1713
|
+
|
|
1714
|
+
constructor(opts) {
|
|
1715
|
+
Object.assign(this, opts);
|
|
1716
|
+
this._value = '';
|
|
1717
|
+
this.isFixed = true;
|
|
1718
|
+
}
|
|
1719
|
+
get value() {
|
|
1720
|
+
return this._value;
|
|
1721
|
+
}
|
|
1722
|
+
get unmaskedValue() {
|
|
1723
|
+
return this.isUnmasking ? this.value : '';
|
|
1724
|
+
}
|
|
1725
|
+
get rawInputValue() {
|
|
1726
|
+
return this._isRawInput ? this.value : '';
|
|
1727
|
+
}
|
|
1728
|
+
get displayValue() {
|
|
1729
|
+
return this.value;
|
|
1730
|
+
}
|
|
1731
|
+
reset() {
|
|
1732
|
+
this._isRawInput = false;
|
|
1733
|
+
this._value = '';
|
|
1734
|
+
}
|
|
1735
|
+
remove(fromPos, toPos) {
|
|
1736
|
+
if (fromPos === void 0) {
|
|
1737
|
+
fromPos = 0;
|
|
1738
|
+
}
|
|
1739
|
+
if (toPos === void 0) {
|
|
1740
|
+
toPos = this._value.length;
|
|
1741
|
+
}
|
|
1742
|
+
this._value = this._value.slice(0, fromPos) + this._value.slice(toPos);
|
|
1743
|
+
if (!this._value) this._isRawInput = false;
|
|
1744
|
+
return new ChangeDetails();
|
|
1745
|
+
}
|
|
1746
|
+
nearestInputPos(cursorPos, direction) {
|
|
1747
|
+
if (direction === void 0) {
|
|
1748
|
+
direction = DIRECTION.NONE;
|
|
1749
|
+
}
|
|
1750
|
+
const minPos = 0;
|
|
1751
|
+
const maxPos = this._value.length;
|
|
1752
|
+
switch (direction) {
|
|
1753
|
+
case DIRECTION.LEFT:
|
|
1754
|
+
case DIRECTION.FORCE_LEFT:
|
|
1755
|
+
return minPos;
|
|
1756
|
+
case DIRECTION.NONE:
|
|
1757
|
+
case DIRECTION.RIGHT:
|
|
1758
|
+
case DIRECTION.FORCE_RIGHT:
|
|
1759
|
+
default:
|
|
1760
|
+
return maxPos;
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
totalInputPositions(fromPos, toPos) {
|
|
1764
|
+
if (fromPos === void 0) {
|
|
1765
|
+
fromPos = 0;
|
|
1766
|
+
}
|
|
1767
|
+
if (toPos === void 0) {
|
|
1768
|
+
toPos = this._value.length;
|
|
1769
|
+
}
|
|
1770
|
+
return this._isRawInput ? toPos - fromPos : 0;
|
|
1771
|
+
}
|
|
1772
|
+
extractInput(fromPos, toPos, flags) {
|
|
1773
|
+
if (fromPos === void 0) {
|
|
1774
|
+
fromPos = 0;
|
|
1775
|
+
}
|
|
1776
|
+
if (toPos === void 0) {
|
|
1777
|
+
toPos = this._value.length;
|
|
1778
|
+
}
|
|
1779
|
+
if (flags === void 0) {
|
|
1780
|
+
flags = {};
|
|
1781
|
+
}
|
|
1782
|
+
return flags.raw && this._isRawInput && this._value.slice(fromPos, toPos) || '';
|
|
1783
|
+
}
|
|
1784
|
+
get isComplete() {
|
|
1785
|
+
return true;
|
|
1786
|
+
}
|
|
1787
|
+
get isFilled() {
|
|
1788
|
+
return Boolean(this._value);
|
|
1789
|
+
}
|
|
1790
|
+
_appendChar(ch, flags) {
|
|
1791
|
+
if (flags === void 0) {
|
|
1792
|
+
flags = {};
|
|
1793
|
+
}
|
|
1794
|
+
if (this.isFilled) return new ChangeDetails();
|
|
1795
|
+
const appendEager = this.eager === true || this.eager === 'append';
|
|
1796
|
+
const appended = this.char === ch;
|
|
1797
|
+
const isResolved = appended && (this.isUnmasking || flags.input || flags.raw) && (!flags.raw || !appendEager) && !flags.tail;
|
|
1798
|
+
const details = new ChangeDetails({
|
|
1799
|
+
inserted: this.char,
|
|
1800
|
+
rawInserted: isResolved ? this.char : ''
|
|
1801
|
+
});
|
|
1802
|
+
this._value = this.char;
|
|
1803
|
+
this._isRawInput = isResolved && (flags.raw || flags.input);
|
|
1804
|
+
return details;
|
|
1805
|
+
}
|
|
1806
|
+
_appendEager() {
|
|
1807
|
+
return this._appendChar(this.char, {
|
|
1808
|
+
tail: true
|
|
1809
|
+
});
|
|
1810
|
+
}
|
|
1811
|
+
_appendPlaceholder() {
|
|
1812
|
+
const details = new ChangeDetails();
|
|
1813
|
+
if (this.isFilled) return details;
|
|
1814
|
+
this._value = details.inserted = this.char;
|
|
1815
|
+
return details;
|
|
1816
|
+
}
|
|
1817
|
+
extractTail() {
|
|
1818
|
+
return new ContinuousTailDetails('');
|
|
1819
|
+
}
|
|
1820
|
+
appendTail(tail) {
|
|
1821
|
+
if (isString(tail)) tail = new ContinuousTailDetails(String(tail));
|
|
1822
|
+
return tail.appendTo(this);
|
|
1823
|
+
}
|
|
1824
|
+
append(str, flags, tail) {
|
|
1825
|
+
const details = this._appendChar(str[0], flags);
|
|
1826
|
+
if (tail != null) {
|
|
1827
|
+
details.tailShift += this.appendTail(tail).tailShift;
|
|
1828
|
+
}
|
|
1829
|
+
return details;
|
|
1830
|
+
}
|
|
1831
|
+
doCommit() {}
|
|
1832
|
+
get state() {
|
|
1833
|
+
return {
|
|
1834
|
+
_value: this._value,
|
|
1835
|
+
_rawInputValue: this.rawInputValue
|
|
1836
|
+
};
|
|
1837
|
+
}
|
|
1838
|
+
set state(state) {
|
|
1839
|
+
this._value = state._value;
|
|
1840
|
+
this._isRawInput = Boolean(state._rawInputValue);
|
|
1841
|
+
}
|
|
1842
|
+
pad(flags) {
|
|
1843
|
+
return this._appendPlaceholder();
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
class PatternInputDefinition {
|
|
1848
|
+
/** */
|
|
1849
|
+
|
|
1850
|
+
/** */
|
|
1851
|
+
|
|
1852
|
+
/** */
|
|
1853
|
+
|
|
1854
|
+
/** */
|
|
1855
|
+
|
|
1856
|
+
/** */
|
|
1857
|
+
|
|
1858
|
+
/** */
|
|
1859
|
+
|
|
1860
|
+
/** */
|
|
1861
|
+
|
|
1862
|
+
/** */
|
|
1863
|
+
|
|
1864
|
+
constructor(opts) {
|
|
1865
|
+
const {
|
|
1866
|
+
parent,
|
|
1867
|
+
isOptional,
|
|
1868
|
+
placeholderChar,
|
|
1869
|
+
displayChar,
|
|
1870
|
+
lazy,
|
|
1871
|
+
eager,
|
|
1872
|
+
...maskOpts
|
|
1873
|
+
} = opts;
|
|
1874
|
+
this.masked = createMask(maskOpts);
|
|
1875
|
+
Object.assign(this, {
|
|
1876
|
+
parent,
|
|
1877
|
+
isOptional,
|
|
1878
|
+
placeholderChar,
|
|
1879
|
+
displayChar,
|
|
1880
|
+
lazy,
|
|
1881
|
+
eager
|
|
1882
|
+
});
|
|
1883
|
+
}
|
|
1884
|
+
reset() {
|
|
1885
|
+
this.isFilled = false;
|
|
1886
|
+
this.masked.reset();
|
|
1887
|
+
}
|
|
1888
|
+
remove(fromPos, toPos) {
|
|
1889
|
+
if (fromPos === void 0) {
|
|
1890
|
+
fromPos = 0;
|
|
1891
|
+
}
|
|
1892
|
+
if (toPos === void 0) {
|
|
1893
|
+
toPos = this.value.length;
|
|
1894
|
+
}
|
|
1895
|
+
if (fromPos === 0 && toPos >= 1) {
|
|
1896
|
+
this.isFilled = false;
|
|
1897
|
+
return this.masked.remove(fromPos, toPos);
|
|
1898
|
+
}
|
|
1899
|
+
return new ChangeDetails();
|
|
1900
|
+
}
|
|
1901
|
+
get value() {
|
|
1902
|
+
return this.masked.value || (this.isFilled && !this.isOptional ? this.placeholderChar : '');
|
|
1903
|
+
}
|
|
1904
|
+
get unmaskedValue() {
|
|
1905
|
+
return this.masked.unmaskedValue;
|
|
1906
|
+
}
|
|
1907
|
+
get rawInputValue() {
|
|
1908
|
+
return this.masked.rawInputValue;
|
|
1909
|
+
}
|
|
1910
|
+
get displayValue() {
|
|
1911
|
+
return this.masked.value && this.displayChar || this.value;
|
|
1912
|
+
}
|
|
1913
|
+
get isComplete() {
|
|
1914
|
+
return Boolean(this.masked.value) || this.isOptional;
|
|
1915
|
+
}
|
|
1916
|
+
_appendChar(ch, flags) {
|
|
1917
|
+
if (flags === void 0) {
|
|
1918
|
+
flags = {};
|
|
1919
|
+
}
|
|
1920
|
+
if (this.isFilled) return new ChangeDetails();
|
|
1921
|
+
const state = this.masked.state;
|
|
1922
|
+
// simulate input
|
|
1923
|
+
let details = this.masked._appendChar(ch, this.currentMaskFlags(flags));
|
|
1924
|
+
if (details.inserted && this.doValidate(flags) === false) {
|
|
1925
|
+
details = new ChangeDetails();
|
|
1926
|
+
this.masked.state = state;
|
|
1927
|
+
}
|
|
1928
|
+
if (!details.inserted && !this.isOptional && !this.lazy && !flags.input) {
|
|
1929
|
+
details.inserted = this.placeholderChar;
|
|
1930
|
+
}
|
|
1931
|
+
details.skip = !details.inserted && !this.isOptional;
|
|
1932
|
+
this.isFilled = Boolean(details.inserted);
|
|
1933
|
+
return details;
|
|
1934
|
+
}
|
|
1935
|
+
append(str, flags, tail) {
|
|
1936
|
+
// TODO probably should be done via _appendChar
|
|
1937
|
+
return this.masked.append(str, this.currentMaskFlags(flags), tail);
|
|
1938
|
+
}
|
|
1939
|
+
_appendPlaceholder() {
|
|
1940
|
+
if (this.isFilled || this.isOptional) return new ChangeDetails();
|
|
1941
|
+
this.isFilled = true;
|
|
1942
|
+
return new ChangeDetails({
|
|
1943
|
+
inserted: this.placeholderChar
|
|
1944
|
+
});
|
|
1945
|
+
}
|
|
1946
|
+
_appendEager() {
|
|
1947
|
+
return new ChangeDetails();
|
|
1948
|
+
}
|
|
1949
|
+
extractTail(fromPos, toPos) {
|
|
1950
|
+
return this.masked.extractTail(fromPos, toPos);
|
|
1951
|
+
}
|
|
1952
|
+
appendTail(tail) {
|
|
1953
|
+
return this.masked.appendTail(tail);
|
|
1954
|
+
}
|
|
1955
|
+
extractInput(fromPos, toPos, flags) {
|
|
1956
|
+
if (fromPos === void 0) {
|
|
1957
|
+
fromPos = 0;
|
|
1958
|
+
}
|
|
1959
|
+
if (toPos === void 0) {
|
|
1960
|
+
toPos = this.value.length;
|
|
1961
|
+
}
|
|
1962
|
+
return this.masked.extractInput(fromPos, toPos, flags);
|
|
1963
|
+
}
|
|
1964
|
+
nearestInputPos(cursorPos, direction) {
|
|
1965
|
+
if (direction === void 0) {
|
|
1966
|
+
direction = DIRECTION.NONE;
|
|
1967
|
+
}
|
|
1968
|
+
const minPos = 0;
|
|
1969
|
+
const maxPos = this.value.length;
|
|
1970
|
+
const boundPos = Math.min(Math.max(cursorPos, minPos), maxPos);
|
|
1971
|
+
switch (direction) {
|
|
1972
|
+
case DIRECTION.LEFT:
|
|
1973
|
+
case DIRECTION.FORCE_LEFT:
|
|
1974
|
+
return this.isComplete ? boundPos : minPos;
|
|
1975
|
+
case DIRECTION.RIGHT:
|
|
1976
|
+
case DIRECTION.FORCE_RIGHT:
|
|
1977
|
+
return this.isComplete ? boundPos : maxPos;
|
|
1978
|
+
case DIRECTION.NONE:
|
|
1979
|
+
default:
|
|
1980
|
+
return boundPos;
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
totalInputPositions(fromPos, toPos) {
|
|
1984
|
+
if (fromPos === void 0) {
|
|
1985
|
+
fromPos = 0;
|
|
1986
|
+
}
|
|
1987
|
+
if (toPos === void 0) {
|
|
1988
|
+
toPos = this.value.length;
|
|
1989
|
+
}
|
|
1990
|
+
return this.value.slice(fromPos, toPos).length;
|
|
1991
|
+
}
|
|
1992
|
+
doValidate(flags) {
|
|
1993
|
+
return this.masked.doValidate(this.currentMaskFlags(flags)) && (!this.parent || this.parent.doValidate(this.currentMaskFlags(flags)));
|
|
1994
|
+
}
|
|
1995
|
+
doCommit() {
|
|
1996
|
+
this.masked.doCommit();
|
|
1997
|
+
}
|
|
1998
|
+
get state() {
|
|
1999
|
+
return {
|
|
2000
|
+
_value: this.value,
|
|
2001
|
+
_rawInputValue: this.rawInputValue,
|
|
2002
|
+
masked: this.masked.state,
|
|
2003
|
+
isFilled: this.isFilled
|
|
2004
|
+
};
|
|
2005
|
+
}
|
|
2006
|
+
set state(state) {
|
|
2007
|
+
this.masked.state = state.masked;
|
|
2008
|
+
this.isFilled = state.isFilled;
|
|
2009
|
+
}
|
|
2010
|
+
currentMaskFlags(flags) {
|
|
2011
|
+
var _flags$_beforeTailSta;
|
|
2012
|
+
return {
|
|
2013
|
+
...flags,
|
|
2014
|
+
_beforeTailState: (flags == null || (_flags$_beforeTailSta = flags._beforeTailState) == null ? void 0 : _flags$_beforeTailSta.masked) || (flags == null ? void 0 : flags._beforeTailState)
|
|
2015
|
+
};
|
|
2016
|
+
}
|
|
2017
|
+
pad(flags) {
|
|
2018
|
+
return new ChangeDetails();
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
PatternInputDefinition.DEFAULT_DEFINITIONS = {
|
|
2022
|
+
'0': /\d/,
|
|
2023
|
+
'a': /[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,
|
|
2024
|
+
// http://stackoverflow.com/a/22075070
|
|
2025
|
+
'*': /./
|
|
2026
|
+
};
|
|
2027
|
+
|
|
2028
|
+
/** Masking by RegExp */
|
|
2029
|
+
class MaskedRegExp extends Masked {
|
|
2030
|
+
/** */
|
|
2031
|
+
|
|
2032
|
+
/** Enable characters overwriting */
|
|
2033
|
+
|
|
2034
|
+
/** */
|
|
2035
|
+
|
|
2036
|
+
/** */
|
|
2037
|
+
|
|
2038
|
+
/** */
|
|
2039
|
+
|
|
2040
|
+
updateOptions(opts) {
|
|
2041
|
+
super.updateOptions(opts);
|
|
2042
|
+
}
|
|
2043
|
+
_update(opts) {
|
|
2044
|
+
const mask = opts.mask;
|
|
2045
|
+
if (mask) opts.validate = value => value.search(mask) >= 0;
|
|
2046
|
+
super._update(opts);
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
IMask.MaskedRegExp = MaskedRegExp;
|
|
2050
|
+
|
|
2051
|
+
/** Pattern mask */
|
|
2052
|
+
class MaskedPattern extends Masked {
|
|
2053
|
+
/** */
|
|
2054
|
+
|
|
2055
|
+
/** */
|
|
2056
|
+
|
|
2057
|
+
/** Single char for empty input */
|
|
2058
|
+
|
|
2059
|
+
/** Single char for filled input */
|
|
2060
|
+
|
|
2061
|
+
/** Show placeholder only when needed */
|
|
2062
|
+
|
|
2063
|
+
/** Enable characters overwriting */
|
|
2064
|
+
|
|
2065
|
+
/** */
|
|
2066
|
+
|
|
2067
|
+
/** */
|
|
2068
|
+
|
|
2069
|
+
/** */
|
|
2070
|
+
|
|
2071
|
+
constructor(opts) {
|
|
2072
|
+
super({
|
|
2073
|
+
...MaskedPattern.DEFAULTS,
|
|
2074
|
+
...opts,
|
|
2075
|
+
definitions: Object.assign({}, PatternInputDefinition.DEFAULT_DEFINITIONS, opts == null ? void 0 : opts.definitions)
|
|
2076
|
+
});
|
|
2077
|
+
}
|
|
2078
|
+
updateOptions(opts) {
|
|
2079
|
+
super.updateOptions(opts);
|
|
2080
|
+
}
|
|
2081
|
+
_update(opts) {
|
|
2082
|
+
opts.definitions = Object.assign({}, this.definitions, opts.definitions);
|
|
2083
|
+
super._update(opts);
|
|
2084
|
+
this._rebuildMask();
|
|
2085
|
+
}
|
|
2086
|
+
_rebuildMask() {
|
|
2087
|
+
const defs = this.definitions;
|
|
2088
|
+
this._blocks = [];
|
|
2089
|
+
this.exposeBlock = undefined;
|
|
2090
|
+
this._stops = [];
|
|
2091
|
+
this._maskedBlocks = {};
|
|
2092
|
+
const pattern = this.mask;
|
|
2093
|
+
if (!pattern || !defs) return;
|
|
2094
|
+
let unmaskingBlock = false;
|
|
2095
|
+
let optionalBlock = false;
|
|
2096
|
+
for (let i = 0; i < pattern.length; ++i) {
|
|
2097
|
+
if (this.blocks) {
|
|
2098
|
+
const p = pattern.slice(i);
|
|
2099
|
+
const bNames = Object.keys(this.blocks).filter(bName => p.indexOf(bName) === 0);
|
|
2100
|
+
// order by key length
|
|
2101
|
+
bNames.sort((a, b) => b.length - a.length);
|
|
2102
|
+
// use block name with max length
|
|
2103
|
+
const bName = bNames[0];
|
|
2104
|
+
if (bName) {
|
|
2105
|
+
const {
|
|
2106
|
+
expose,
|
|
2107
|
+
repeat,
|
|
2108
|
+
...bOpts
|
|
2109
|
+
} = normalizeOpts(this.blocks[bName]); // TODO type Opts<Arg & Extra>
|
|
2110
|
+
const blockOpts = {
|
|
2111
|
+
lazy: this.lazy,
|
|
2112
|
+
eager: this.eager,
|
|
2113
|
+
placeholderChar: this.placeholderChar,
|
|
2114
|
+
displayChar: this.displayChar,
|
|
2115
|
+
overwrite: this.overwrite,
|
|
2116
|
+
autofix: this.autofix,
|
|
2117
|
+
...bOpts,
|
|
2118
|
+
repeat,
|
|
2119
|
+
parent: this
|
|
2120
|
+
};
|
|
2121
|
+
const maskedBlock = repeat != null ? new IMask.RepeatBlock(blockOpts /* TODO */) : createMask(blockOpts);
|
|
2122
|
+
if (maskedBlock) {
|
|
2123
|
+
this._blocks.push(maskedBlock);
|
|
2124
|
+
if (expose) this.exposeBlock = maskedBlock;
|
|
2125
|
+
|
|
2126
|
+
// store block index
|
|
2127
|
+
if (!this._maskedBlocks[bName]) this._maskedBlocks[bName] = [];
|
|
2128
|
+
this._maskedBlocks[bName].push(this._blocks.length - 1);
|
|
2129
|
+
}
|
|
2130
|
+
i += bName.length - 1;
|
|
2131
|
+
continue;
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
let char = pattern[i];
|
|
2135
|
+
let isInput = (char in defs);
|
|
2136
|
+
if (char === MaskedPattern.STOP_CHAR) {
|
|
2137
|
+
this._stops.push(this._blocks.length);
|
|
2138
|
+
continue;
|
|
2139
|
+
}
|
|
2140
|
+
if (char === '{' || char === '}') {
|
|
2141
|
+
unmaskingBlock = !unmaskingBlock;
|
|
2142
|
+
continue;
|
|
2143
|
+
}
|
|
2144
|
+
if (char === '[' || char === ']') {
|
|
2145
|
+
optionalBlock = !optionalBlock;
|
|
2146
|
+
continue;
|
|
2147
|
+
}
|
|
2148
|
+
if (char === MaskedPattern.ESCAPE_CHAR) {
|
|
2149
|
+
++i;
|
|
2150
|
+
char = pattern[i];
|
|
2151
|
+
if (!char) break;
|
|
2152
|
+
isInput = false;
|
|
2153
|
+
}
|
|
2154
|
+
const def = isInput ? new PatternInputDefinition({
|
|
2155
|
+
isOptional: optionalBlock,
|
|
2156
|
+
lazy: this.lazy,
|
|
2157
|
+
eager: this.eager,
|
|
2158
|
+
placeholderChar: this.placeholderChar,
|
|
2159
|
+
displayChar: this.displayChar,
|
|
2160
|
+
...normalizeOpts(defs[char]),
|
|
2161
|
+
parent: this
|
|
2162
|
+
}) : new PatternFixedDefinition({
|
|
2163
|
+
char,
|
|
2164
|
+
eager: this.eager,
|
|
2165
|
+
isUnmasking: unmaskingBlock
|
|
2166
|
+
});
|
|
2167
|
+
this._blocks.push(def);
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
get state() {
|
|
2171
|
+
return {
|
|
2172
|
+
...super.state,
|
|
2173
|
+
_blocks: this._blocks.map(b => b.state)
|
|
2174
|
+
};
|
|
2175
|
+
}
|
|
2176
|
+
set state(state) {
|
|
2177
|
+
if (!state) {
|
|
2178
|
+
this.reset();
|
|
2179
|
+
return;
|
|
2180
|
+
}
|
|
2181
|
+
const {
|
|
2182
|
+
_blocks,
|
|
2183
|
+
...maskedState
|
|
2184
|
+
} = state;
|
|
2185
|
+
this._blocks.forEach((b, bi) => b.state = _blocks[bi]);
|
|
2186
|
+
super.state = maskedState;
|
|
2187
|
+
}
|
|
2188
|
+
reset() {
|
|
2189
|
+
super.reset();
|
|
2190
|
+
this._blocks.forEach(b => b.reset());
|
|
2191
|
+
}
|
|
2192
|
+
get isComplete() {
|
|
2193
|
+
return this.exposeBlock ? this.exposeBlock.isComplete : this._blocks.every(b => b.isComplete);
|
|
2194
|
+
}
|
|
2195
|
+
get isFilled() {
|
|
2196
|
+
return this._blocks.every(b => b.isFilled);
|
|
2197
|
+
}
|
|
2198
|
+
get isFixed() {
|
|
2199
|
+
return this._blocks.every(b => b.isFixed);
|
|
2200
|
+
}
|
|
2201
|
+
get isOptional() {
|
|
2202
|
+
return this._blocks.every(b => b.isOptional);
|
|
2203
|
+
}
|
|
2204
|
+
doCommit() {
|
|
2205
|
+
this._blocks.forEach(b => b.doCommit());
|
|
2206
|
+
super.doCommit();
|
|
2207
|
+
}
|
|
2208
|
+
get unmaskedValue() {
|
|
2209
|
+
return this.exposeBlock ? this.exposeBlock.unmaskedValue : this._blocks.reduce((str, b) => str += b.unmaskedValue, '');
|
|
2210
|
+
}
|
|
2211
|
+
set unmaskedValue(unmaskedValue) {
|
|
2212
|
+
if (this.exposeBlock) {
|
|
2213
|
+
const tail = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
|
|
2214
|
+
this.exposeBlock.unmaskedValue = unmaskedValue;
|
|
2215
|
+
this.appendTail(tail);
|
|
2216
|
+
this.doCommit();
|
|
2217
|
+
} else super.unmaskedValue = unmaskedValue;
|
|
2218
|
+
}
|
|
2219
|
+
get value() {
|
|
2220
|
+
return this.exposeBlock ? this.exposeBlock.value :
|
|
2221
|
+
// TODO return _value when not in change?
|
|
2222
|
+
this._blocks.reduce((str, b) => str += b.value, '');
|
|
2223
|
+
}
|
|
2224
|
+
set value(value) {
|
|
2225
|
+
if (this.exposeBlock) {
|
|
2226
|
+
const tail = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
|
|
2227
|
+
this.exposeBlock.value = value;
|
|
2228
|
+
this.appendTail(tail);
|
|
2229
|
+
this.doCommit();
|
|
2230
|
+
} else super.value = value;
|
|
2231
|
+
}
|
|
2232
|
+
get typedValue() {
|
|
2233
|
+
return this.exposeBlock ? this.exposeBlock.typedValue : super.typedValue;
|
|
2234
|
+
}
|
|
2235
|
+
set typedValue(value) {
|
|
2236
|
+
if (this.exposeBlock) {
|
|
2237
|
+
const tail = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
|
|
2238
|
+
this.exposeBlock.typedValue = value;
|
|
2239
|
+
this.appendTail(tail);
|
|
2240
|
+
this.doCommit();
|
|
2241
|
+
} else super.typedValue = value;
|
|
2242
|
+
}
|
|
2243
|
+
get displayValue() {
|
|
2244
|
+
return this._blocks.reduce((str, b) => str += b.displayValue, '');
|
|
2245
|
+
}
|
|
2246
|
+
appendTail(tail) {
|
|
2247
|
+
return super.appendTail(tail).aggregate(this._appendPlaceholder());
|
|
2248
|
+
}
|
|
2249
|
+
_appendEager() {
|
|
2250
|
+
var _this$_mapPosToBlock;
|
|
2251
|
+
const details = new ChangeDetails();
|
|
2252
|
+
let startBlockIndex = (_this$_mapPosToBlock = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : _this$_mapPosToBlock.index;
|
|
2253
|
+
if (startBlockIndex == null) return details;
|
|
2254
|
+
|
|
2255
|
+
// TODO test if it works for nested pattern masks
|
|
2256
|
+
if (this._blocks[startBlockIndex].isFilled) ++startBlockIndex;
|
|
2257
|
+
for (let bi = startBlockIndex; bi < this._blocks.length; ++bi) {
|
|
2258
|
+
const d = this._blocks[bi]._appendEager();
|
|
2259
|
+
if (!d.inserted) break;
|
|
2260
|
+
details.aggregate(d);
|
|
2261
|
+
}
|
|
2262
|
+
return details;
|
|
2263
|
+
}
|
|
2264
|
+
_appendCharRaw(ch, flags) {
|
|
2265
|
+
if (flags === void 0) {
|
|
2266
|
+
flags = {};
|
|
2267
|
+
}
|
|
2268
|
+
const blockIter = this._mapPosToBlock(this.displayValue.length);
|
|
2269
|
+
const details = new ChangeDetails();
|
|
2270
|
+
if (!blockIter) return details;
|
|
2271
|
+
for (let bi = blockIter.index, block; block = this._blocks[bi]; ++bi) {
|
|
2272
|
+
var _flags$_beforeTailSta;
|
|
2273
|
+
const blockDetails = block._appendChar(ch, {
|
|
2274
|
+
...flags,
|
|
2275
|
+
_beforeTailState: (_flags$_beforeTailSta = flags._beforeTailState) == null || (_flags$_beforeTailSta = _flags$_beforeTailSta._blocks) == null ? void 0 : _flags$_beforeTailSta[bi]
|
|
2276
|
+
});
|
|
2277
|
+
details.aggregate(blockDetails);
|
|
2278
|
+
if (blockDetails.consumed) break; // go next char
|
|
2279
|
+
}
|
|
2280
|
+
return details;
|
|
2281
|
+
}
|
|
2282
|
+
extractTail(fromPos, toPos) {
|
|
2283
|
+
if (fromPos === void 0) {
|
|
2284
|
+
fromPos = 0;
|
|
2285
|
+
}
|
|
2286
|
+
if (toPos === void 0) {
|
|
2287
|
+
toPos = this.displayValue.length;
|
|
2288
|
+
}
|
|
2289
|
+
const chunkTail = new ChunksTailDetails();
|
|
2290
|
+
if (fromPos === toPos) return chunkTail;
|
|
2291
|
+
this._forEachBlocksInRange(fromPos, toPos, (b, bi, bFromPos, bToPos) => {
|
|
2292
|
+
const blockChunk = b.extractTail(bFromPos, bToPos);
|
|
2293
|
+
blockChunk.stop = this._findStopBefore(bi);
|
|
2294
|
+
blockChunk.from = this._blockStartPos(bi);
|
|
2295
|
+
if (blockChunk instanceof ChunksTailDetails) blockChunk.blockIndex = bi;
|
|
2296
|
+
chunkTail.extend(blockChunk);
|
|
2297
|
+
});
|
|
2298
|
+
return chunkTail;
|
|
2299
|
+
}
|
|
2300
|
+
extractInput(fromPos, toPos, flags) {
|
|
2301
|
+
if (fromPos === void 0) {
|
|
2302
|
+
fromPos = 0;
|
|
2303
|
+
}
|
|
2304
|
+
if (toPos === void 0) {
|
|
2305
|
+
toPos = this.displayValue.length;
|
|
2306
|
+
}
|
|
2307
|
+
if (flags === void 0) {
|
|
2308
|
+
flags = {};
|
|
2309
|
+
}
|
|
2310
|
+
if (fromPos === toPos) return '';
|
|
2311
|
+
let input = '';
|
|
2312
|
+
this._forEachBlocksInRange(fromPos, toPos, (b, _, fromPos, toPos) => {
|
|
2313
|
+
input += b.extractInput(fromPos, toPos, flags);
|
|
2314
|
+
});
|
|
2315
|
+
return input;
|
|
2316
|
+
}
|
|
2317
|
+
_findStopBefore(blockIndex) {
|
|
2318
|
+
let stopBefore;
|
|
2319
|
+
for (let si = 0; si < this._stops.length; ++si) {
|
|
2320
|
+
const stop = this._stops[si];
|
|
2321
|
+
if (stop <= blockIndex) stopBefore = stop;else break;
|
|
2322
|
+
}
|
|
2323
|
+
return stopBefore;
|
|
2324
|
+
}
|
|
2325
|
+
|
|
2326
|
+
/** Appends placeholder depending on laziness */
|
|
2327
|
+
_appendPlaceholder(toBlockIndex) {
|
|
2328
|
+
const details = new ChangeDetails();
|
|
2329
|
+
if (this.lazy && toBlockIndex == null) return details;
|
|
2330
|
+
const startBlockIter = this._mapPosToBlock(this.displayValue.length);
|
|
2331
|
+
if (!startBlockIter) return details;
|
|
2332
|
+
const startBlockIndex = startBlockIter.index;
|
|
2333
|
+
const endBlockIndex = toBlockIndex != null ? toBlockIndex : this._blocks.length;
|
|
2334
|
+
this._blocks.slice(startBlockIndex, endBlockIndex).forEach(b => {
|
|
2335
|
+
if (!b.lazy || toBlockIndex != null) {
|
|
2336
|
+
var _blocks2;
|
|
2337
|
+
details.aggregate(b._appendPlaceholder((_blocks2 = b._blocks) == null ? void 0 : _blocks2.length));
|
|
2338
|
+
}
|
|
2339
|
+
});
|
|
2340
|
+
return details;
|
|
2341
|
+
}
|
|
2342
|
+
|
|
2343
|
+
/** Finds block in pos */
|
|
2344
|
+
_mapPosToBlock(pos) {
|
|
2345
|
+
let accVal = '';
|
|
2346
|
+
for (let bi = 0; bi < this._blocks.length; ++bi) {
|
|
2347
|
+
const block = this._blocks[bi];
|
|
2348
|
+
const blockStartPos = accVal.length;
|
|
2349
|
+
accVal += block.displayValue;
|
|
2350
|
+
if (pos <= accVal.length) {
|
|
2351
|
+
return {
|
|
2352
|
+
index: bi,
|
|
2353
|
+
offset: pos - blockStartPos
|
|
2354
|
+
};
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
_blockStartPos(blockIndex) {
|
|
2359
|
+
return this._blocks.slice(0, blockIndex).reduce((pos, b) => pos += b.displayValue.length, 0);
|
|
2360
|
+
}
|
|
2361
|
+
_forEachBlocksInRange(fromPos, toPos, fn) {
|
|
2362
|
+
if (toPos === void 0) {
|
|
2363
|
+
toPos = this.displayValue.length;
|
|
2364
|
+
}
|
|
2365
|
+
const fromBlockIter = this._mapPosToBlock(fromPos);
|
|
2366
|
+
if (fromBlockIter) {
|
|
2367
|
+
const toBlockIter = this._mapPosToBlock(toPos);
|
|
2368
|
+
// process first block
|
|
2369
|
+
const isSameBlock = toBlockIter && fromBlockIter.index === toBlockIter.index;
|
|
2370
|
+
const fromBlockStartPos = fromBlockIter.offset;
|
|
2371
|
+
const fromBlockEndPos = toBlockIter && isSameBlock ? toBlockIter.offset : this._blocks[fromBlockIter.index].displayValue.length;
|
|
2372
|
+
fn(this._blocks[fromBlockIter.index], fromBlockIter.index, fromBlockStartPos, fromBlockEndPos);
|
|
2373
|
+
if (toBlockIter && !isSameBlock) {
|
|
2374
|
+
// process intermediate blocks
|
|
2375
|
+
for (let bi = fromBlockIter.index + 1; bi < toBlockIter.index; ++bi) {
|
|
2376
|
+
fn(this._blocks[bi], bi, 0, this._blocks[bi].displayValue.length);
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
// process last block
|
|
2380
|
+
fn(this._blocks[toBlockIter.index], toBlockIter.index, 0, toBlockIter.offset);
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
remove(fromPos, toPos) {
|
|
2385
|
+
if (fromPos === void 0) {
|
|
2386
|
+
fromPos = 0;
|
|
2387
|
+
}
|
|
2388
|
+
if (toPos === void 0) {
|
|
2389
|
+
toPos = this.displayValue.length;
|
|
2390
|
+
}
|
|
2391
|
+
const removeDetails = super.remove(fromPos, toPos);
|
|
2392
|
+
this._forEachBlocksInRange(fromPos, toPos, (b, _, bFromPos, bToPos) => {
|
|
2393
|
+
removeDetails.aggregate(b.remove(bFromPos, bToPos));
|
|
2394
|
+
});
|
|
2395
|
+
return removeDetails;
|
|
2396
|
+
}
|
|
2397
|
+
nearestInputPos(cursorPos, direction) {
|
|
2398
|
+
if (direction === void 0) {
|
|
2399
|
+
direction = DIRECTION.NONE;
|
|
2400
|
+
}
|
|
2401
|
+
if (!this._blocks.length) return 0;
|
|
2402
|
+
const cursor = new PatternCursor(this, cursorPos);
|
|
2403
|
+
if (direction === DIRECTION.NONE) {
|
|
2404
|
+
// -------------------------------------------------
|
|
2405
|
+
// NONE should only go out from fixed to the right!
|
|
2406
|
+
// -------------------------------------------------
|
|
2407
|
+
if (cursor.pushRightBeforeInput()) return cursor.pos;
|
|
2408
|
+
cursor.popState();
|
|
2409
|
+
if (cursor.pushLeftBeforeInput()) return cursor.pos;
|
|
2410
|
+
return this.displayValue.length;
|
|
2411
|
+
}
|
|
2412
|
+
|
|
2413
|
+
// FORCE is only about a|* otherwise is 0
|
|
2414
|
+
if (direction === DIRECTION.LEFT || direction === DIRECTION.FORCE_LEFT) {
|
|
2415
|
+
// try to break fast when *|a
|
|
2416
|
+
if (direction === DIRECTION.LEFT) {
|
|
2417
|
+
cursor.pushRightBeforeFilled();
|
|
2418
|
+
if (cursor.ok && cursor.pos === cursorPos) return cursorPos;
|
|
2419
|
+
cursor.popState();
|
|
2420
|
+
}
|
|
2421
|
+
|
|
2422
|
+
// forward flow
|
|
2423
|
+
cursor.pushLeftBeforeInput();
|
|
2424
|
+
cursor.pushLeftBeforeRequired();
|
|
2425
|
+
cursor.pushLeftBeforeFilled();
|
|
2426
|
+
|
|
2427
|
+
// backward flow
|
|
2428
|
+
if (direction === DIRECTION.LEFT) {
|
|
2429
|
+
cursor.pushRightBeforeInput();
|
|
2430
|
+
cursor.pushRightBeforeRequired();
|
|
2431
|
+
if (cursor.ok && cursor.pos <= cursorPos) return cursor.pos;
|
|
2432
|
+
cursor.popState();
|
|
2433
|
+
if (cursor.ok && cursor.pos <= cursorPos) return cursor.pos;
|
|
2434
|
+
cursor.popState();
|
|
2435
|
+
}
|
|
2436
|
+
if (cursor.ok) return cursor.pos;
|
|
2437
|
+
if (direction === DIRECTION.FORCE_LEFT) return 0;
|
|
2438
|
+
cursor.popState();
|
|
2439
|
+
if (cursor.ok) return cursor.pos;
|
|
2440
|
+
cursor.popState();
|
|
2441
|
+
if (cursor.ok) return cursor.pos;
|
|
2442
|
+
return 0;
|
|
2443
|
+
}
|
|
2444
|
+
if (direction === DIRECTION.RIGHT || direction === DIRECTION.FORCE_RIGHT) {
|
|
2445
|
+
// forward flow
|
|
2446
|
+
cursor.pushRightBeforeInput();
|
|
2447
|
+
cursor.pushRightBeforeRequired();
|
|
2448
|
+
if (cursor.pushRightBeforeFilled()) return cursor.pos;
|
|
2449
|
+
if (direction === DIRECTION.FORCE_RIGHT) return this.displayValue.length;
|
|
2450
|
+
|
|
2451
|
+
// backward flow
|
|
2452
|
+
cursor.popState();
|
|
2453
|
+
if (cursor.ok) return cursor.pos;
|
|
2454
|
+
cursor.popState();
|
|
2455
|
+
if (cursor.ok) return cursor.pos;
|
|
2456
|
+
return this.nearestInputPos(cursorPos, DIRECTION.LEFT);
|
|
2457
|
+
}
|
|
2458
|
+
return cursorPos;
|
|
2459
|
+
}
|
|
2460
|
+
totalInputPositions(fromPos, toPos) {
|
|
2461
|
+
if (fromPos === void 0) {
|
|
2462
|
+
fromPos = 0;
|
|
2463
|
+
}
|
|
2464
|
+
if (toPos === void 0) {
|
|
2465
|
+
toPos = this.displayValue.length;
|
|
2466
|
+
}
|
|
2467
|
+
let total = 0;
|
|
2468
|
+
this._forEachBlocksInRange(fromPos, toPos, (b, _, bFromPos, bToPos) => {
|
|
2469
|
+
total += b.totalInputPositions(bFromPos, bToPos);
|
|
2470
|
+
});
|
|
2471
|
+
return total;
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2474
|
+
/** Get block by name */
|
|
2475
|
+
maskedBlock(name) {
|
|
2476
|
+
return this.maskedBlocks(name)[0];
|
|
2477
|
+
}
|
|
2478
|
+
|
|
2479
|
+
/** Get all blocks by name */
|
|
2480
|
+
maskedBlocks(name) {
|
|
2481
|
+
const indices = this._maskedBlocks[name];
|
|
2482
|
+
if (!indices) return [];
|
|
2483
|
+
return indices.map(gi => this._blocks[gi]);
|
|
2484
|
+
}
|
|
2485
|
+
pad(flags) {
|
|
2486
|
+
const details = new ChangeDetails();
|
|
2487
|
+
this._forEachBlocksInRange(0, this.displayValue.length, b => details.aggregate(b.pad(flags)));
|
|
2488
|
+
return details;
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
MaskedPattern.DEFAULTS = {
|
|
2492
|
+
...Masked.DEFAULTS,
|
|
2493
|
+
lazy: true,
|
|
2494
|
+
placeholderChar: '_'
|
|
2495
|
+
};
|
|
2496
|
+
MaskedPattern.STOP_CHAR = '`';
|
|
2497
|
+
MaskedPattern.ESCAPE_CHAR = '\\';
|
|
2498
|
+
MaskedPattern.InputDefinition = PatternInputDefinition;
|
|
2499
|
+
MaskedPattern.FixedDefinition = PatternFixedDefinition;
|
|
2500
|
+
IMask.MaskedPattern = MaskedPattern;
|
|
2501
|
+
|
|
2502
|
+
/** Pattern which accepts ranges */
|
|
2503
|
+
class MaskedRange extends MaskedPattern {
|
|
2504
|
+
/**
|
|
2505
|
+
Optionally sets max length of pattern.
|
|
2506
|
+
Used when pattern length is longer then `to` param length. Pads zeros at start in this case.
|
|
2507
|
+
*/
|
|
2508
|
+
|
|
2509
|
+
/** Min bound */
|
|
2510
|
+
|
|
2511
|
+
/** Max bound */
|
|
2512
|
+
|
|
2513
|
+
get _matchFrom() {
|
|
2514
|
+
return this.maxLength - String(this.from).length;
|
|
2515
|
+
}
|
|
2516
|
+
constructor(opts) {
|
|
2517
|
+
super(opts); // mask will be created in _update
|
|
2518
|
+
}
|
|
2519
|
+
updateOptions(opts) {
|
|
2520
|
+
super.updateOptions(opts);
|
|
2521
|
+
}
|
|
2522
|
+
_update(opts) {
|
|
2523
|
+
const {
|
|
2524
|
+
to = this.to || 0,
|
|
2525
|
+
from = this.from || 0,
|
|
2526
|
+
maxLength = this.maxLength || 0,
|
|
2527
|
+
autofix = this.autofix,
|
|
2528
|
+
...patternOpts
|
|
2529
|
+
} = opts;
|
|
2530
|
+
this.to = to;
|
|
2531
|
+
this.from = from;
|
|
2532
|
+
this.maxLength = Math.max(String(to).length, maxLength);
|
|
2533
|
+
this.autofix = autofix;
|
|
2534
|
+
const fromStr = String(this.from).padStart(this.maxLength, '0');
|
|
2535
|
+
const toStr = String(this.to).padStart(this.maxLength, '0');
|
|
2536
|
+
let sameCharsCount = 0;
|
|
2537
|
+
while (sameCharsCount < toStr.length && toStr[sameCharsCount] === fromStr[sameCharsCount]) ++sameCharsCount;
|
|
2538
|
+
patternOpts.mask = toStr.slice(0, sameCharsCount).replace(/0/g, '\\0') + '0'.repeat(this.maxLength - sameCharsCount);
|
|
2539
|
+
super._update(patternOpts);
|
|
2540
|
+
}
|
|
2541
|
+
get isComplete() {
|
|
2542
|
+
return super.isComplete && Boolean(this.value);
|
|
2543
|
+
}
|
|
2544
|
+
boundaries(str) {
|
|
2545
|
+
let minstr = '';
|
|
2546
|
+
let maxstr = '';
|
|
2547
|
+
const [, placeholder, num] = str.match(/^(\D*)(\d*)(\D*)/) || [];
|
|
2548
|
+
if (num) {
|
|
2549
|
+
minstr = '0'.repeat(placeholder.length) + num;
|
|
2550
|
+
maxstr = '9'.repeat(placeholder.length) + num;
|
|
2551
|
+
}
|
|
2552
|
+
minstr = minstr.padEnd(this.maxLength, '0');
|
|
2553
|
+
maxstr = maxstr.padEnd(this.maxLength, '9');
|
|
2554
|
+
return [minstr, maxstr];
|
|
2555
|
+
}
|
|
2556
|
+
doPrepareChar(ch, flags) {
|
|
2557
|
+
if (flags === void 0) {
|
|
2558
|
+
flags = {};
|
|
2559
|
+
}
|
|
2560
|
+
let details;
|
|
2561
|
+
[ch, details] = super.doPrepareChar(ch.replace(/\D/g, ''), flags);
|
|
2562
|
+
if (!ch) details.skip = !this.isComplete;
|
|
2563
|
+
return [ch, details];
|
|
2564
|
+
}
|
|
2565
|
+
_appendCharRaw(ch, flags) {
|
|
2566
|
+
if (flags === void 0) {
|
|
2567
|
+
flags = {};
|
|
2568
|
+
}
|
|
2569
|
+
if (!this.autofix || this.value.length + 1 > this.maxLength) return super._appendCharRaw(ch, flags);
|
|
2570
|
+
const fromStr = String(this.from).padStart(this.maxLength, '0');
|
|
2571
|
+
const toStr = String(this.to).padStart(this.maxLength, '0');
|
|
2572
|
+
const [minstr, maxstr] = this.boundaries(this.value + ch);
|
|
2573
|
+
if (Number(maxstr) < this.from) return super._appendCharRaw(fromStr[this.value.length], flags);
|
|
2574
|
+
if (Number(minstr) > this.to) {
|
|
2575
|
+
if (!flags.tail && this.autofix === 'pad' && this.value.length + 1 < this.maxLength) {
|
|
2576
|
+
return super._appendCharRaw(fromStr[this.value.length], flags).aggregate(this._appendCharRaw(ch, flags));
|
|
2577
|
+
}
|
|
2578
|
+
return super._appendCharRaw(toStr[this.value.length], flags);
|
|
2579
|
+
}
|
|
2580
|
+
return super._appendCharRaw(ch, flags);
|
|
2581
|
+
}
|
|
2582
|
+
doValidate(flags) {
|
|
2583
|
+
const str = this.value;
|
|
2584
|
+
const firstNonZero = str.search(/[^0]/);
|
|
2585
|
+
if (firstNonZero === -1 && str.length <= this._matchFrom) return true;
|
|
2586
|
+
const [minstr, maxstr] = this.boundaries(str);
|
|
2587
|
+
return this.from <= Number(maxstr) && Number(minstr) <= this.to && super.doValidate(flags);
|
|
2588
|
+
}
|
|
2589
|
+
pad(flags) {
|
|
2590
|
+
const details = new ChangeDetails();
|
|
2591
|
+
if (this.value.length === this.maxLength) return details;
|
|
2592
|
+
const value = this.value;
|
|
2593
|
+
const padLength = this.maxLength - this.value.length;
|
|
2594
|
+
if (padLength) {
|
|
2595
|
+
this.reset();
|
|
2596
|
+
for (let i = 0; i < padLength; ++i) {
|
|
2597
|
+
details.aggregate(super._appendCharRaw('0', flags));
|
|
2598
|
+
}
|
|
2599
|
+
|
|
2600
|
+
// append tail
|
|
2601
|
+
value.split('').forEach(ch => this._appendCharRaw(ch));
|
|
2602
|
+
}
|
|
2603
|
+
return details;
|
|
2604
|
+
}
|
|
2605
|
+
}
|
|
2606
|
+
IMask.MaskedRange = MaskedRange;
|
|
2607
|
+
|
|
2608
|
+
const DefaultPattern = 'd{.}`m{.}`Y';
|
|
2609
|
+
|
|
2610
|
+
// Make format and parse required when pattern is provided
|
|
2611
|
+
|
|
2612
|
+
/** Date mask */
|
|
2613
|
+
class MaskedDate extends MaskedPattern {
|
|
2614
|
+
static extractPatternOptions(opts) {
|
|
2615
|
+
const {
|
|
2616
|
+
mask,
|
|
2617
|
+
pattern,
|
|
2618
|
+
...patternOpts
|
|
2619
|
+
} = opts;
|
|
2620
|
+
return {
|
|
2621
|
+
...patternOpts,
|
|
2622
|
+
mask: isString(mask) ? mask : pattern
|
|
2623
|
+
};
|
|
2624
|
+
}
|
|
2625
|
+
|
|
2626
|
+
/** Pattern mask for date according to {@link MaskedDate#format} */
|
|
2627
|
+
|
|
2628
|
+
/** Start date */
|
|
2629
|
+
|
|
2630
|
+
/** End date */
|
|
2631
|
+
|
|
2632
|
+
/** Format typed value to string */
|
|
2633
|
+
|
|
2634
|
+
/** Parse string to get typed value */
|
|
2635
|
+
|
|
2636
|
+
constructor(opts) {
|
|
2637
|
+
super(MaskedDate.extractPatternOptions({
|
|
2638
|
+
...MaskedDate.DEFAULTS,
|
|
2639
|
+
...opts
|
|
2640
|
+
}));
|
|
2641
|
+
}
|
|
2642
|
+
updateOptions(opts) {
|
|
2643
|
+
super.updateOptions(opts);
|
|
2644
|
+
}
|
|
2645
|
+
_update(opts) {
|
|
2646
|
+
const {
|
|
2647
|
+
mask,
|
|
2648
|
+
pattern,
|
|
2649
|
+
blocks,
|
|
2650
|
+
...patternOpts
|
|
2651
|
+
} = {
|
|
2652
|
+
...MaskedDate.DEFAULTS,
|
|
2653
|
+
...opts
|
|
2654
|
+
};
|
|
2655
|
+
const patternBlocks = Object.assign({}, MaskedDate.GET_DEFAULT_BLOCKS());
|
|
2656
|
+
// adjust year block
|
|
2657
|
+
if (opts.min) patternBlocks.Y.from = opts.min.getFullYear();
|
|
2658
|
+
if (opts.max) patternBlocks.Y.to = opts.max.getFullYear();
|
|
2659
|
+
if (opts.min && opts.max && patternBlocks.Y.from === patternBlocks.Y.to) {
|
|
2660
|
+
patternBlocks.m.from = opts.min.getMonth() + 1;
|
|
2661
|
+
patternBlocks.m.to = opts.max.getMonth() + 1;
|
|
2662
|
+
if (patternBlocks.m.from === patternBlocks.m.to) {
|
|
2663
|
+
patternBlocks.d.from = opts.min.getDate();
|
|
2664
|
+
patternBlocks.d.to = opts.max.getDate();
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
Object.assign(patternBlocks, this.blocks, blocks);
|
|
2668
|
+
super._update({
|
|
2669
|
+
...patternOpts,
|
|
2670
|
+
mask: isString(mask) ? mask : pattern,
|
|
2671
|
+
blocks: patternBlocks
|
|
2672
|
+
});
|
|
2673
|
+
}
|
|
2674
|
+
doValidate(flags) {
|
|
2675
|
+
const date = this.date;
|
|
2676
|
+
return super.doValidate(flags) && (!this.isComplete || this.isDateExist(this.value) && date != null && (this.min == null || this.min <= date) && (this.max == null || date <= this.max));
|
|
2677
|
+
}
|
|
2678
|
+
|
|
2679
|
+
/** Checks if date is exists */
|
|
2680
|
+
isDateExist(str) {
|
|
2681
|
+
return this.format(this.parse(str, this), this).indexOf(str) >= 0;
|
|
2682
|
+
}
|
|
2683
|
+
|
|
2684
|
+
/** Parsed Date */
|
|
2685
|
+
get date() {
|
|
2686
|
+
return this.typedValue;
|
|
2687
|
+
}
|
|
2688
|
+
set date(date) {
|
|
2689
|
+
this.typedValue = date;
|
|
2690
|
+
}
|
|
2691
|
+
get typedValue() {
|
|
2692
|
+
return this.isComplete ? super.typedValue : null;
|
|
2693
|
+
}
|
|
2694
|
+
set typedValue(value) {
|
|
2695
|
+
super.typedValue = value;
|
|
2696
|
+
}
|
|
2697
|
+
maskEquals(mask) {
|
|
2698
|
+
return mask === Date || super.maskEquals(mask);
|
|
2699
|
+
}
|
|
2700
|
+
optionsIsChanged(opts) {
|
|
2701
|
+
return super.optionsIsChanged(MaskedDate.extractPatternOptions(opts));
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
MaskedDate.GET_DEFAULT_BLOCKS = () => ({
|
|
2705
|
+
d: {
|
|
2706
|
+
mask: MaskedRange,
|
|
2707
|
+
from: 1,
|
|
2708
|
+
to: 31,
|
|
2709
|
+
maxLength: 2
|
|
2710
|
+
},
|
|
2711
|
+
m: {
|
|
2712
|
+
mask: MaskedRange,
|
|
2713
|
+
from: 1,
|
|
2714
|
+
to: 12,
|
|
2715
|
+
maxLength: 2
|
|
2716
|
+
},
|
|
2717
|
+
Y: {
|
|
2718
|
+
mask: MaskedRange,
|
|
2719
|
+
from: 1900,
|
|
2720
|
+
to: 9999
|
|
2721
|
+
}
|
|
2722
|
+
});
|
|
2723
|
+
MaskedDate.DEFAULTS = {
|
|
2724
|
+
...MaskedPattern.DEFAULTS,
|
|
2725
|
+
mask: Date,
|
|
2726
|
+
pattern: DefaultPattern,
|
|
2727
|
+
format: (date, masked) => {
|
|
2728
|
+
if (!date) return '';
|
|
2729
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
2730
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
2731
|
+
const year = date.getFullYear();
|
|
2732
|
+
return [day, month, year].join('.');
|
|
2733
|
+
},
|
|
2734
|
+
parse: (str, masked) => {
|
|
2735
|
+
const [day, month, year] = str.split('.').map(Number);
|
|
2736
|
+
return new Date(year, month - 1, day);
|
|
2737
|
+
}
|
|
2738
|
+
};
|
|
2739
|
+
IMask.MaskedDate = MaskedDate;
|
|
2740
|
+
|
|
2741
|
+
/** Dynamic mask for choosing appropriate mask in run-time */
|
|
2742
|
+
class MaskedDynamic extends Masked {
|
|
2743
|
+
constructor(opts) {
|
|
2744
|
+
super({
|
|
2745
|
+
...MaskedDynamic.DEFAULTS,
|
|
2746
|
+
...opts
|
|
2747
|
+
});
|
|
2748
|
+
this.currentMask = undefined;
|
|
2749
|
+
}
|
|
2750
|
+
updateOptions(opts) {
|
|
2751
|
+
super.updateOptions(opts);
|
|
2752
|
+
}
|
|
2753
|
+
_update(opts) {
|
|
2754
|
+
super._update(opts);
|
|
2755
|
+
if ('mask' in opts) {
|
|
2756
|
+
this.exposeMask = undefined;
|
|
2757
|
+
// mask could be totally dynamic with only `dispatch` option
|
|
2758
|
+
this.compiledMasks = Array.isArray(opts.mask) ? opts.mask.map(m => {
|
|
2759
|
+
const {
|
|
2760
|
+
expose,
|
|
2761
|
+
...maskOpts
|
|
2762
|
+
} = normalizeOpts(m);
|
|
2763
|
+
const masked = createMask({
|
|
2764
|
+
overwrite: this._overwrite,
|
|
2765
|
+
eager: this._eager,
|
|
2766
|
+
skipInvalid: this._skipInvalid,
|
|
2767
|
+
...maskOpts
|
|
2768
|
+
});
|
|
2769
|
+
if (expose) this.exposeMask = masked;
|
|
2770
|
+
return masked;
|
|
2771
|
+
}) : [];
|
|
2772
|
+
|
|
2773
|
+
// this.currentMask = this.doDispatch(''); // probably not needed but lets see
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
_appendCharRaw(ch, flags) {
|
|
2777
|
+
if (flags === void 0) {
|
|
2778
|
+
flags = {};
|
|
2779
|
+
}
|
|
2780
|
+
const details = this._applyDispatch(ch, flags);
|
|
2781
|
+
if (this.currentMask) {
|
|
2782
|
+
details.aggregate(this.currentMask._appendChar(ch, this.currentMaskFlags(flags)));
|
|
2783
|
+
}
|
|
2784
|
+
return details;
|
|
2785
|
+
}
|
|
2786
|
+
_applyDispatch(appended, flags, tail) {
|
|
2787
|
+
if (appended === void 0) {
|
|
2788
|
+
appended = '';
|
|
2789
|
+
}
|
|
2790
|
+
if (flags === void 0) {
|
|
2791
|
+
flags = {};
|
|
2792
|
+
}
|
|
2793
|
+
if (tail === void 0) {
|
|
2794
|
+
tail = '';
|
|
2795
|
+
}
|
|
2796
|
+
const prevValueBeforeTail = flags.tail && flags._beforeTailState != null ? flags._beforeTailState._value : this.value;
|
|
2797
|
+
const inputValue = this.rawInputValue;
|
|
2798
|
+
const insertValue = flags.tail && flags._beforeTailState != null ? flags._beforeTailState._rawInputValue : inputValue;
|
|
2799
|
+
const tailValue = inputValue.slice(insertValue.length);
|
|
2800
|
+
const prevMask = this.currentMask;
|
|
2801
|
+
const details = new ChangeDetails();
|
|
2802
|
+
const prevMaskState = prevMask == null ? void 0 : prevMask.state;
|
|
2803
|
+
|
|
2804
|
+
// clone flags to prevent overwriting `_beforeTailState`
|
|
2805
|
+
this.currentMask = this.doDispatch(appended, {
|
|
2806
|
+
...flags
|
|
2807
|
+
}, tail);
|
|
2808
|
+
|
|
2809
|
+
// restore state after dispatch
|
|
2810
|
+
if (this.currentMask) {
|
|
2811
|
+
if (this.currentMask !== prevMask) {
|
|
2812
|
+
// if mask changed reapply input
|
|
2813
|
+
this.currentMask.reset();
|
|
2814
|
+
if (insertValue) {
|
|
2815
|
+
this.currentMask.append(insertValue, {
|
|
2816
|
+
raw: true
|
|
2817
|
+
});
|
|
2818
|
+
details.tailShift = this.currentMask.value.length - prevValueBeforeTail.length;
|
|
2819
|
+
}
|
|
2820
|
+
if (tailValue) {
|
|
2821
|
+
details.tailShift += this.currentMask.append(tailValue, {
|
|
2822
|
+
raw: true,
|
|
2823
|
+
tail: true
|
|
2824
|
+
}).tailShift;
|
|
2825
|
+
}
|
|
2826
|
+
} else if (prevMaskState) {
|
|
2827
|
+
// Dispatch can do something bad with state, so
|
|
2828
|
+
// restore prev mask state
|
|
2829
|
+
this.currentMask.state = prevMaskState;
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
return details;
|
|
2833
|
+
}
|
|
2834
|
+
_appendPlaceholder() {
|
|
2835
|
+
const details = this._applyDispatch();
|
|
2836
|
+
if (this.currentMask) {
|
|
2837
|
+
details.aggregate(this.currentMask._appendPlaceholder());
|
|
2838
|
+
}
|
|
2839
|
+
return details;
|
|
2840
|
+
}
|
|
2841
|
+
_appendEager() {
|
|
2842
|
+
const details = this._applyDispatch();
|
|
2843
|
+
if (this.currentMask) {
|
|
2844
|
+
details.aggregate(this.currentMask._appendEager());
|
|
2845
|
+
}
|
|
2846
|
+
return details;
|
|
2847
|
+
}
|
|
2848
|
+
appendTail(tail) {
|
|
2849
|
+
const details = new ChangeDetails();
|
|
2850
|
+
if (tail) details.aggregate(this._applyDispatch('', {}, tail));
|
|
2851
|
+
return details.aggregate(this.currentMask ? this.currentMask.appendTail(tail) : super.appendTail(tail));
|
|
2852
|
+
}
|
|
2853
|
+
currentMaskFlags(flags) {
|
|
2854
|
+
var _flags$_beforeTailSta, _flags$_beforeTailSta2;
|
|
2855
|
+
return {
|
|
2856
|
+
...flags,
|
|
2857
|
+
_beforeTailState: ((_flags$_beforeTailSta = flags._beforeTailState) == null ? void 0 : _flags$_beforeTailSta.currentMaskRef) === this.currentMask && ((_flags$_beforeTailSta2 = flags._beforeTailState) == null ? void 0 : _flags$_beforeTailSta2.currentMask) || flags._beforeTailState
|
|
2858
|
+
};
|
|
2859
|
+
}
|
|
2860
|
+
doDispatch(appended, flags, tail) {
|
|
2861
|
+
if (flags === void 0) {
|
|
2862
|
+
flags = {};
|
|
2863
|
+
}
|
|
2864
|
+
if (tail === void 0) {
|
|
2865
|
+
tail = '';
|
|
2866
|
+
}
|
|
2867
|
+
return this.dispatch(appended, this, flags, tail);
|
|
2868
|
+
}
|
|
2869
|
+
doValidate(flags) {
|
|
2870
|
+
return super.doValidate(flags) && (!this.currentMask || this.currentMask.doValidate(this.currentMaskFlags(flags)));
|
|
2871
|
+
}
|
|
2872
|
+
doPrepare(str, flags) {
|
|
2873
|
+
if (flags === void 0) {
|
|
2874
|
+
flags = {};
|
|
2875
|
+
}
|
|
2876
|
+
let [s, details] = super.doPrepare(str, flags);
|
|
2877
|
+
if (this.currentMask) {
|
|
2878
|
+
let currentDetails;
|
|
2879
|
+
[s, currentDetails] = super.doPrepare(s, this.currentMaskFlags(flags));
|
|
2880
|
+
details = details.aggregate(currentDetails);
|
|
2881
|
+
}
|
|
2882
|
+
return [s, details];
|
|
2883
|
+
}
|
|
2884
|
+
doPrepareChar(str, flags) {
|
|
2885
|
+
if (flags === void 0) {
|
|
2886
|
+
flags = {};
|
|
2887
|
+
}
|
|
2888
|
+
let [s, details] = super.doPrepareChar(str, flags);
|
|
2889
|
+
if (this.currentMask) {
|
|
2890
|
+
let currentDetails;
|
|
2891
|
+
[s, currentDetails] = super.doPrepareChar(s, this.currentMaskFlags(flags));
|
|
2892
|
+
details = details.aggregate(currentDetails);
|
|
2893
|
+
}
|
|
2894
|
+
return [s, details];
|
|
2895
|
+
}
|
|
2896
|
+
reset() {
|
|
2897
|
+
var _this$currentMask;
|
|
2898
|
+
(_this$currentMask = this.currentMask) == null || _this$currentMask.reset();
|
|
2899
|
+
this.compiledMasks.forEach(m => m.reset());
|
|
2900
|
+
}
|
|
2901
|
+
get value() {
|
|
2902
|
+
return this.exposeMask ? this.exposeMask.value : this.currentMask ? this.currentMask.value : '';
|
|
2903
|
+
}
|
|
2904
|
+
set value(value) {
|
|
2905
|
+
if (this.exposeMask) {
|
|
2906
|
+
this.exposeMask.value = value;
|
|
2907
|
+
this.currentMask = this.exposeMask;
|
|
2908
|
+
this._applyDispatch();
|
|
2909
|
+
} else super.value = value;
|
|
2910
|
+
}
|
|
2911
|
+
get unmaskedValue() {
|
|
2912
|
+
return this.exposeMask ? this.exposeMask.unmaskedValue : this.currentMask ? this.currentMask.unmaskedValue : '';
|
|
2913
|
+
}
|
|
2914
|
+
set unmaskedValue(unmaskedValue) {
|
|
2915
|
+
if (this.exposeMask) {
|
|
2916
|
+
this.exposeMask.unmaskedValue = unmaskedValue;
|
|
2917
|
+
this.currentMask = this.exposeMask;
|
|
2918
|
+
this._applyDispatch();
|
|
2919
|
+
} else super.unmaskedValue = unmaskedValue;
|
|
2920
|
+
}
|
|
2921
|
+
get typedValue() {
|
|
2922
|
+
return this.exposeMask ? this.exposeMask.typedValue : this.currentMask ? this.currentMask.typedValue : '';
|
|
2923
|
+
}
|
|
2924
|
+
set typedValue(typedValue) {
|
|
2925
|
+
if (this.exposeMask) {
|
|
2926
|
+
this.exposeMask.typedValue = typedValue;
|
|
2927
|
+
this.currentMask = this.exposeMask;
|
|
2928
|
+
this._applyDispatch();
|
|
2929
|
+
return;
|
|
2930
|
+
}
|
|
2931
|
+
let unmaskedValue = String(typedValue);
|
|
2932
|
+
|
|
2933
|
+
// double check it
|
|
2934
|
+
if (this.currentMask) {
|
|
2935
|
+
this.currentMask.typedValue = typedValue;
|
|
2936
|
+
unmaskedValue = this.currentMask.unmaskedValue;
|
|
2937
|
+
}
|
|
2938
|
+
this.unmaskedValue = unmaskedValue;
|
|
2939
|
+
}
|
|
2940
|
+
get displayValue() {
|
|
2941
|
+
return this.currentMask ? this.currentMask.displayValue : '';
|
|
2942
|
+
}
|
|
2943
|
+
get isComplete() {
|
|
2944
|
+
var _this$currentMask2;
|
|
2945
|
+
return Boolean((_this$currentMask2 = this.currentMask) == null ? void 0 : _this$currentMask2.isComplete);
|
|
2946
|
+
}
|
|
2947
|
+
get isFilled() {
|
|
2948
|
+
var _this$currentMask3;
|
|
2949
|
+
return Boolean((_this$currentMask3 = this.currentMask) == null ? void 0 : _this$currentMask3.isFilled);
|
|
2950
|
+
}
|
|
2951
|
+
remove(fromPos, toPos) {
|
|
2952
|
+
const details = new ChangeDetails();
|
|
2953
|
+
if (this.currentMask) {
|
|
2954
|
+
details.aggregate(this.currentMask.remove(fromPos, toPos))
|
|
2955
|
+
// update with dispatch
|
|
2956
|
+
.aggregate(this._applyDispatch());
|
|
2957
|
+
}
|
|
2958
|
+
return details;
|
|
2959
|
+
}
|
|
2960
|
+
get state() {
|
|
2961
|
+
var _this$currentMask4;
|
|
2962
|
+
return {
|
|
2963
|
+
...super.state,
|
|
2964
|
+
_rawInputValue: this.rawInputValue,
|
|
2965
|
+
compiledMasks: this.compiledMasks.map(m => m.state),
|
|
2966
|
+
currentMaskRef: this.currentMask,
|
|
2967
|
+
currentMask: (_this$currentMask4 = this.currentMask) == null ? void 0 : _this$currentMask4.state
|
|
2968
|
+
};
|
|
2969
|
+
}
|
|
2970
|
+
set state(state) {
|
|
2971
|
+
const {
|
|
2972
|
+
compiledMasks,
|
|
2973
|
+
currentMaskRef,
|
|
2974
|
+
currentMask,
|
|
2975
|
+
...maskedState
|
|
2976
|
+
} = state;
|
|
2977
|
+
if (compiledMasks) this.compiledMasks.forEach((m, mi) => m.state = compiledMasks[mi]);
|
|
2978
|
+
if (currentMaskRef != null) {
|
|
2979
|
+
this.currentMask = currentMaskRef;
|
|
2980
|
+
this.currentMask.state = currentMask;
|
|
2981
|
+
}
|
|
2982
|
+
super.state = maskedState;
|
|
2983
|
+
}
|
|
2984
|
+
extractInput(fromPos, toPos, flags) {
|
|
2985
|
+
return this.currentMask ? this.currentMask.extractInput(fromPos, toPos, flags) : '';
|
|
2986
|
+
}
|
|
2987
|
+
extractTail(fromPos, toPos) {
|
|
2988
|
+
return this.currentMask ? this.currentMask.extractTail(fromPos, toPos) : super.extractTail(fromPos, toPos);
|
|
2989
|
+
}
|
|
2990
|
+
doCommit() {
|
|
2991
|
+
if (this.currentMask) this.currentMask.doCommit();
|
|
2992
|
+
super.doCommit();
|
|
2993
|
+
}
|
|
2994
|
+
nearestInputPos(cursorPos, direction) {
|
|
2995
|
+
return this.currentMask ? this.currentMask.nearestInputPos(cursorPos, direction) : super.nearestInputPos(cursorPos, direction);
|
|
2996
|
+
}
|
|
2997
|
+
get overwrite() {
|
|
2998
|
+
return this.currentMask ? this.currentMask.overwrite : this._overwrite;
|
|
2999
|
+
}
|
|
3000
|
+
set overwrite(overwrite) {
|
|
3001
|
+
this._overwrite = overwrite;
|
|
3002
|
+
}
|
|
3003
|
+
get eager() {
|
|
3004
|
+
return this.currentMask ? this.currentMask.eager : this._eager;
|
|
3005
|
+
}
|
|
3006
|
+
set eager(eager) {
|
|
3007
|
+
this._eager = eager;
|
|
3008
|
+
}
|
|
3009
|
+
get skipInvalid() {
|
|
3010
|
+
return this.currentMask ? this.currentMask.skipInvalid : this._skipInvalid;
|
|
3011
|
+
}
|
|
3012
|
+
set skipInvalid(skipInvalid) {
|
|
3013
|
+
this._skipInvalid = skipInvalid;
|
|
3014
|
+
}
|
|
3015
|
+
get autofix() {
|
|
3016
|
+
return this.currentMask ? this.currentMask.autofix : this._autofix;
|
|
3017
|
+
}
|
|
3018
|
+
set autofix(autofix) {
|
|
3019
|
+
this._autofix = autofix;
|
|
3020
|
+
}
|
|
3021
|
+
maskEquals(mask) {
|
|
3022
|
+
return Array.isArray(mask) ? this.compiledMasks.every((m, mi) => {
|
|
3023
|
+
if (!mask[mi]) return;
|
|
3024
|
+
const {
|
|
3025
|
+
mask: oldMask,
|
|
3026
|
+
...restOpts
|
|
3027
|
+
} = mask[mi];
|
|
3028
|
+
return objectIncludes(m, restOpts) && m.maskEquals(oldMask);
|
|
3029
|
+
}) : super.maskEquals(mask);
|
|
3030
|
+
}
|
|
3031
|
+
typedValueEquals(value) {
|
|
3032
|
+
var _this$currentMask5;
|
|
3033
|
+
return Boolean((_this$currentMask5 = this.currentMask) == null ? void 0 : _this$currentMask5.typedValueEquals(value));
|
|
3034
|
+
}
|
|
3035
|
+
}
|
|
3036
|
+
/** Currently chosen mask */
|
|
3037
|
+
/** Currently chosen mask */
|
|
3038
|
+
/** Compliled {@link Masked} options */
|
|
3039
|
+
/** Chooses {@link Masked} depending on input value */
|
|
3040
|
+
MaskedDynamic.DEFAULTS = {
|
|
3041
|
+
...Masked.DEFAULTS,
|
|
3042
|
+
dispatch: (appended, masked, flags, tail) => {
|
|
3043
|
+
if (!masked.compiledMasks.length) return;
|
|
3044
|
+
const inputValue = masked.rawInputValue;
|
|
3045
|
+
|
|
3046
|
+
// simulate input
|
|
3047
|
+
const inputs = masked.compiledMasks.map((m, index) => {
|
|
3048
|
+
const isCurrent = masked.currentMask === m;
|
|
3049
|
+
const startInputPos = isCurrent ? m.displayValue.length : m.nearestInputPos(m.displayValue.length, DIRECTION.FORCE_LEFT);
|
|
3050
|
+
if (m.rawInputValue !== inputValue) {
|
|
3051
|
+
m.reset();
|
|
3052
|
+
m.append(inputValue, {
|
|
3053
|
+
raw: true
|
|
3054
|
+
});
|
|
3055
|
+
} else if (!isCurrent) {
|
|
3056
|
+
m.remove(startInputPos);
|
|
3057
|
+
}
|
|
3058
|
+
m.append(appended, masked.currentMaskFlags(flags));
|
|
3059
|
+
m.appendTail(tail);
|
|
3060
|
+
return {
|
|
3061
|
+
index,
|
|
3062
|
+
weight: m.rawInputValue.length,
|
|
3063
|
+
totalInputPositions: m.totalInputPositions(0, Math.max(startInputPos, m.nearestInputPos(m.displayValue.length, DIRECTION.FORCE_LEFT)))
|
|
3064
|
+
};
|
|
3065
|
+
});
|
|
3066
|
+
|
|
3067
|
+
// pop masks with longer values first
|
|
3068
|
+
inputs.sort((i1, i2) => i2.weight - i1.weight || i2.totalInputPositions - i1.totalInputPositions);
|
|
3069
|
+
return masked.compiledMasks[inputs[0].index];
|
|
3070
|
+
}
|
|
3071
|
+
};
|
|
3072
|
+
IMask.MaskedDynamic = MaskedDynamic;
|
|
3073
|
+
|
|
3074
|
+
/** Pattern which validates enum values */
|
|
3075
|
+
class MaskedEnum extends MaskedPattern {
|
|
3076
|
+
constructor(opts) {
|
|
3077
|
+
super({
|
|
3078
|
+
...MaskedEnum.DEFAULTS,
|
|
3079
|
+
...opts
|
|
3080
|
+
}); // mask will be created in _update
|
|
3081
|
+
}
|
|
3082
|
+
updateOptions(opts) {
|
|
3083
|
+
super.updateOptions(opts);
|
|
3084
|
+
}
|
|
3085
|
+
_update(opts) {
|
|
3086
|
+
const {
|
|
3087
|
+
enum: enum_,
|
|
3088
|
+
...eopts
|
|
3089
|
+
} = opts;
|
|
3090
|
+
if (enum_) {
|
|
3091
|
+
const lengths = enum_.map(e => e.length);
|
|
3092
|
+
const requiredLength = Math.min(...lengths);
|
|
3093
|
+
const optionalLength = Math.max(...lengths) - requiredLength;
|
|
3094
|
+
eopts.mask = '*'.repeat(requiredLength);
|
|
3095
|
+
if (optionalLength) eopts.mask += '[' + '*'.repeat(optionalLength) + ']';
|
|
3096
|
+
this.enum = enum_;
|
|
3097
|
+
}
|
|
3098
|
+
super._update(eopts);
|
|
3099
|
+
}
|
|
3100
|
+
_appendCharRaw(ch, flags) {
|
|
3101
|
+
if (flags === void 0) {
|
|
3102
|
+
flags = {};
|
|
3103
|
+
}
|
|
3104
|
+
const matchFrom = Math.min(this.nearestInputPos(0, DIRECTION.FORCE_RIGHT), this.value.length);
|
|
3105
|
+
const matches = this.enum.filter(e => this.matchValue(e, this.unmaskedValue + ch, matchFrom));
|
|
3106
|
+
if (matches.length) {
|
|
3107
|
+
if (matches.length === 1) {
|
|
3108
|
+
this._forEachBlocksInRange(0, this.value.length, (b, bi) => {
|
|
3109
|
+
const mch = matches[0][bi];
|
|
3110
|
+
if (bi >= this.value.length || mch === b.value) return;
|
|
3111
|
+
b.reset();
|
|
3112
|
+
b._appendChar(mch, flags);
|
|
3113
|
+
});
|
|
3114
|
+
}
|
|
3115
|
+
const d = super._appendCharRaw(matches[0][this.value.length], flags);
|
|
3116
|
+
if (matches.length === 1) {
|
|
3117
|
+
matches[0].slice(this.unmaskedValue.length).split('').forEach(mch => d.aggregate(super._appendCharRaw(mch)));
|
|
3118
|
+
}
|
|
3119
|
+
return d;
|
|
3120
|
+
}
|
|
3121
|
+
return new ChangeDetails({
|
|
3122
|
+
skip: !this.isComplete
|
|
3123
|
+
});
|
|
3124
|
+
}
|
|
3125
|
+
extractTail(fromPos, toPos) {
|
|
3126
|
+
if (fromPos === void 0) {
|
|
3127
|
+
fromPos = 0;
|
|
3128
|
+
}
|
|
3129
|
+
// just drop tail
|
|
3130
|
+
return new ContinuousTailDetails('', fromPos);
|
|
3131
|
+
}
|
|
3132
|
+
remove(fromPos, toPos) {
|
|
3133
|
+
if (fromPos === void 0) {
|
|
3134
|
+
fromPos = 0;
|
|
3135
|
+
}
|
|
3136
|
+
if (toPos === void 0) {
|
|
3137
|
+
toPos = this.displayValue.length;
|
|
3138
|
+
}
|
|
3139
|
+
if (fromPos === toPos) return new ChangeDetails();
|
|
3140
|
+
const matchFrom = Math.min(super.nearestInputPos(0, DIRECTION.FORCE_RIGHT), this.value.length);
|
|
3141
|
+
let pos;
|
|
3142
|
+
for (pos = fromPos; pos >= 0; --pos) {
|
|
3143
|
+
const matches = this.enum.filter(e => this.matchValue(e, this.value.slice(matchFrom, pos), matchFrom));
|
|
3144
|
+
if (matches.length > 1) break;
|
|
3145
|
+
}
|
|
3146
|
+
const details = super.remove(pos, toPos);
|
|
3147
|
+
details.tailShift += pos - fromPos;
|
|
3148
|
+
return details;
|
|
3149
|
+
}
|
|
3150
|
+
get isComplete() {
|
|
3151
|
+
return this.enum.indexOf(this.value) >= 0;
|
|
3152
|
+
}
|
|
3153
|
+
}
|
|
3154
|
+
/** Match enum value */
|
|
3155
|
+
MaskedEnum.DEFAULTS = {
|
|
3156
|
+
...MaskedPattern.DEFAULTS,
|
|
3157
|
+
matchValue: (estr, istr, matchFrom) => estr.indexOf(istr, matchFrom) === matchFrom
|
|
3158
|
+
};
|
|
3159
|
+
IMask.MaskedEnum = MaskedEnum;
|
|
3160
|
+
|
|
3161
|
+
/** Masking by custom Function */
|
|
3162
|
+
class MaskedFunction extends Masked {
|
|
3163
|
+
/** */
|
|
3164
|
+
|
|
3165
|
+
/** Enable characters overwriting */
|
|
3166
|
+
|
|
3167
|
+
/** */
|
|
3168
|
+
|
|
3169
|
+
/** */
|
|
3170
|
+
|
|
3171
|
+
/** */
|
|
3172
|
+
|
|
3173
|
+
updateOptions(opts) {
|
|
3174
|
+
super.updateOptions(opts);
|
|
3175
|
+
}
|
|
3176
|
+
_update(opts) {
|
|
3177
|
+
super._update({
|
|
3178
|
+
...opts,
|
|
3179
|
+
validate: opts.mask
|
|
3180
|
+
});
|
|
3181
|
+
}
|
|
3182
|
+
}
|
|
3183
|
+
IMask.MaskedFunction = MaskedFunction;
|
|
3184
|
+
|
|
3185
|
+
var _MaskedNumber;
|
|
3186
|
+
/** Number mask */
|
|
3187
|
+
class MaskedNumber extends Masked {
|
|
3188
|
+
/** Single char */
|
|
3189
|
+
|
|
3190
|
+
/** Single char */
|
|
3191
|
+
|
|
3192
|
+
/** Array of single chars */
|
|
3193
|
+
|
|
3194
|
+
/** */
|
|
3195
|
+
|
|
3196
|
+
/** */
|
|
3197
|
+
|
|
3198
|
+
/** Digits after point */
|
|
3199
|
+
|
|
3200
|
+
/** Flag to remove leading and trailing zeros in the end of editing */
|
|
3201
|
+
|
|
3202
|
+
/** Flag to pad trailing zeros after point in the end of editing */
|
|
3203
|
+
|
|
3204
|
+
/** Enable characters overwriting */
|
|
3205
|
+
|
|
3206
|
+
/** */
|
|
3207
|
+
|
|
3208
|
+
/** */
|
|
3209
|
+
|
|
3210
|
+
/** */
|
|
3211
|
+
|
|
3212
|
+
/** Format typed value to string */
|
|
3213
|
+
|
|
3214
|
+
/** Parse string to get typed value */
|
|
3215
|
+
|
|
3216
|
+
constructor(opts) {
|
|
3217
|
+
super({
|
|
3218
|
+
...MaskedNumber.DEFAULTS,
|
|
3219
|
+
...opts
|
|
3220
|
+
});
|
|
3221
|
+
}
|
|
3222
|
+
updateOptions(opts) {
|
|
3223
|
+
super.updateOptions(opts);
|
|
3224
|
+
}
|
|
3225
|
+
_update(opts) {
|
|
3226
|
+
super._update(opts);
|
|
3227
|
+
this._updateRegExps();
|
|
3228
|
+
}
|
|
3229
|
+
_updateRegExps() {
|
|
3230
|
+
const start = '^' + (this.allowNegative ? '[+|\\-]?' : '');
|
|
3231
|
+
const mid = '\\d*';
|
|
3232
|
+
const end = (this.scale ? "(" + escapeRegExp(this.radix) + "\\d{0," + this.scale + "})?" : '') + '$';
|
|
3233
|
+
this._numberRegExp = new RegExp(start + mid + end);
|
|
3234
|
+
this._mapToRadixRegExp = new RegExp("[" + this.mapToRadix.map(escapeRegExp).join('') + "]", 'g');
|
|
3235
|
+
this._thousandsSeparatorRegExp = new RegExp(escapeRegExp(this.thousandsSeparator), 'g');
|
|
3236
|
+
}
|
|
3237
|
+
_removeThousandsSeparators(value) {
|
|
3238
|
+
return value.replace(this._thousandsSeparatorRegExp, '');
|
|
3239
|
+
}
|
|
3240
|
+
_insertThousandsSeparators(value) {
|
|
3241
|
+
// https://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript
|
|
3242
|
+
const parts = value.split(this.radix);
|
|
3243
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandsSeparator);
|
|
3244
|
+
return parts.join(this.radix);
|
|
3245
|
+
}
|
|
3246
|
+
doPrepareChar(ch, flags) {
|
|
3247
|
+
if (flags === void 0) {
|
|
3248
|
+
flags = {};
|
|
3249
|
+
}
|
|
3250
|
+
const [prepCh, details] = super.doPrepareChar(this._removeThousandsSeparators(this.scale && this.mapToRadix.length && (
|
|
3251
|
+
/*
|
|
3252
|
+
radix should be mapped when
|
|
3253
|
+
1) input is done from keyboard = flags.input && flags.raw
|
|
3254
|
+
2) unmasked value is set = !flags.input && !flags.raw
|
|
3255
|
+
and should not be mapped when
|
|
3256
|
+
1) value is set = flags.input && !flags.raw
|
|
3257
|
+
2) raw value is set = !flags.input && flags.raw
|
|
3258
|
+
*/
|
|
3259
|
+
flags.input && flags.raw || !flags.input && !flags.raw) ? ch.replace(this._mapToRadixRegExp, this.radix) : ch), flags);
|
|
3260
|
+
if (ch && !prepCh) details.skip = true;
|
|
3261
|
+
if (prepCh && !this.allowPositive && !this.value && prepCh !== '-') details.aggregate(this._appendChar('-'));
|
|
3262
|
+
return [prepCh, details];
|
|
3263
|
+
}
|
|
3264
|
+
_separatorsCount(to, extendOnSeparators) {
|
|
3265
|
+
if (extendOnSeparators === void 0) {
|
|
3266
|
+
extendOnSeparators = false;
|
|
3267
|
+
}
|
|
3268
|
+
let count = 0;
|
|
3269
|
+
for (let pos = 0; pos < to; ++pos) {
|
|
3270
|
+
if (this._value.indexOf(this.thousandsSeparator, pos) === pos) {
|
|
3271
|
+
++count;
|
|
3272
|
+
if (extendOnSeparators) to += this.thousandsSeparator.length;
|
|
3273
|
+
}
|
|
3274
|
+
}
|
|
3275
|
+
return count;
|
|
3276
|
+
}
|
|
3277
|
+
_separatorsCountFromSlice(slice) {
|
|
3278
|
+
if (slice === void 0) {
|
|
3279
|
+
slice = this._value;
|
|
3280
|
+
}
|
|
3281
|
+
return this._separatorsCount(this._removeThousandsSeparators(slice).length, true);
|
|
3282
|
+
}
|
|
3283
|
+
extractInput(fromPos, toPos, flags) {
|
|
3284
|
+
if (fromPos === void 0) {
|
|
3285
|
+
fromPos = 0;
|
|
3286
|
+
}
|
|
3287
|
+
if (toPos === void 0) {
|
|
3288
|
+
toPos = this.displayValue.length;
|
|
3289
|
+
}
|
|
3290
|
+
[fromPos, toPos] = this._adjustRangeWithSeparators(fromPos, toPos);
|
|
3291
|
+
return this._removeThousandsSeparators(super.extractInput(fromPos, toPos, flags));
|
|
3292
|
+
}
|
|
3293
|
+
_appendCharRaw(ch, flags) {
|
|
3294
|
+
if (flags === void 0) {
|
|
3295
|
+
flags = {};
|
|
3296
|
+
}
|
|
3297
|
+
const prevBeforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
|
|
3298
|
+
const prevBeforeTailSeparatorsCount = this._separatorsCountFromSlice(prevBeforeTailValue);
|
|
3299
|
+
this._value = this._removeThousandsSeparators(this.value);
|
|
3300
|
+
const oldValue = this._value;
|
|
3301
|
+
this._value += ch;
|
|
3302
|
+
const num = this.number;
|
|
3303
|
+
let accepted = !isNaN(num);
|
|
3304
|
+
let skip = false;
|
|
3305
|
+
if (accepted) {
|
|
3306
|
+
let fixedNum;
|
|
3307
|
+
if (this.min != null && this.min < 0 && this.number < this.min) fixedNum = this.min;
|
|
3308
|
+
if (this.max != null && this.max > 0 && this.number > this.max) fixedNum = this.max;
|
|
3309
|
+
if (fixedNum != null) {
|
|
3310
|
+
if (this.autofix) {
|
|
3311
|
+
this._value = this.format(fixedNum, this).replace(MaskedNumber.UNMASKED_RADIX, this.radix);
|
|
3312
|
+
skip || (skip = oldValue === this._value && !flags.tail); // if not changed on tail it's still ok to proceed
|
|
3313
|
+
} else {
|
|
3314
|
+
accepted = false;
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
3317
|
+
accepted && (accepted = Boolean(this._value.match(this._numberRegExp)));
|
|
3318
|
+
}
|
|
3319
|
+
let appendDetails;
|
|
3320
|
+
if (!accepted) {
|
|
3321
|
+
this._value = oldValue;
|
|
3322
|
+
appendDetails = new ChangeDetails();
|
|
3323
|
+
} else {
|
|
3324
|
+
appendDetails = new ChangeDetails({
|
|
3325
|
+
inserted: this._value.slice(oldValue.length),
|
|
3326
|
+
rawInserted: skip ? '' : ch,
|
|
3327
|
+
skip
|
|
3328
|
+
});
|
|
3329
|
+
}
|
|
3330
|
+
this._value = this._insertThousandsSeparators(this._value);
|
|
3331
|
+
const beforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
|
|
3332
|
+
const beforeTailSeparatorsCount = this._separatorsCountFromSlice(beforeTailValue);
|
|
3333
|
+
appendDetails.tailShift += (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length;
|
|
3334
|
+
return appendDetails;
|
|
3335
|
+
}
|
|
3336
|
+
_findSeparatorAround(pos) {
|
|
3337
|
+
if (this.thousandsSeparator) {
|
|
3338
|
+
const searchFrom = pos - this.thousandsSeparator.length + 1;
|
|
3339
|
+
const separatorPos = this.value.indexOf(this.thousandsSeparator, searchFrom);
|
|
3340
|
+
if (separatorPos <= pos) return separatorPos;
|
|
3341
|
+
}
|
|
3342
|
+
return -1;
|
|
3343
|
+
}
|
|
3344
|
+
_adjustRangeWithSeparators(from, to) {
|
|
3345
|
+
const separatorAroundFromPos = this._findSeparatorAround(from);
|
|
3346
|
+
if (separatorAroundFromPos >= 0) from = separatorAroundFromPos;
|
|
3347
|
+
const separatorAroundToPos = this._findSeparatorAround(to);
|
|
3348
|
+
if (separatorAroundToPos >= 0) to = separatorAroundToPos + this.thousandsSeparator.length;
|
|
3349
|
+
return [from, to];
|
|
3350
|
+
}
|
|
3351
|
+
remove(fromPos, toPos) {
|
|
3352
|
+
if (fromPos === void 0) {
|
|
3353
|
+
fromPos = 0;
|
|
3354
|
+
}
|
|
3355
|
+
if (toPos === void 0) {
|
|
3356
|
+
toPos = this.displayValue.length;
|
|
3357
|
+
}
|
|
3358
|
+
[fromPos, toPos] = this._adjustRangeWithSeparators(fromPos, toPos);
|
|
3359
|
+
const valueBeforePos = this.value.slice(0, fromPos);
|
|
3360
|
+
const valueAfterPos = this.value.slice(toPos);
|
|
3361
|
+
const prevBeforeTailSeparatorsCount = this._separatorsCount(valueBeforePos.length);
|
|
3362
|
+
this._value = this._insertThousandsSeparators(this._removeThousandsSeparators(valueBeforePos + valueAfterPos));
|
|
3363
|
+
const beforeTailSeparatorsCount = this._separatorsCountFromSlice(valueBeforePos);
|
|
3364
|
+
return new ChangeDetails({
|
|
3365
|
+
tailShift: (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length
|
|
3366
|
+
});
|
|
3367
|
+
}
|
|
3368
|
+
nearestInputPos(cursorPos, direction) {
|
|
3369
|
+
if (!this.thousandsSeparator) return cursorPos;
|
|
3370
|
+
switch (direction) {
|
|
3371
|
+
case DIRECTION.NONE:
|
|
3372
|
+
case DIRECTION.LEFT:
|
|
3373
|
+
case DIRECTION.FORCE_LEFT:
|
|
3374
|
+
{
|
|
3375
|
+
const separatorAtLeftPos = this._findSeparatorAround(cursorPos - 1);
|
|
3376
|
+
if (separatorAtLeftPos >= 0) {
|
|
3377
|
+
const separatorAtLeftEndPos = separatorAtLeftPos + this.thousandsSeparator.length;
|
|
3378
|
+
if (cursorPos < separatorAtLeftEndPos || this.value.length <= separatorAtLeftEndPos || direction === DIRECTION.FORCE_LEFT) {
|
|
3379
|
+
return separatorAtLeftPos;
|
|
3380
|
+
}
|
|
3381
|
+
}
|
|
3382
|
+
break;
|
|
3383
|
+
}
|
|
3384
|
+
case DIRECTION.RIGHT:
|
|
3385
|
+
case DIRECTION.FORCE_RIGHT:
|
|
3386
|
+
{
|
|
3387
|
+
const separatorAtRightPos = this._findSeparatorAround(cursorPos);
|
|
3388
|
+
if (separatorAtRightPos >= 0) {
|
|
3389
|
+
return separatorAtRightPos + this.thousandsSeparator.length;
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
return cursorPos;
|
|
3394
|
+
}
|
|
3395
|
+
doCommit() {
|
|
3396
|
+
if (this.value) {
|
|
3397
|
+
const number = this.number;
|
|
3398
|
+
let validnum = number;
|
|
3399
|
+
|
|
3400
|
+
// check bounds
|
|
3401
|
+
if (this.min != null) validnum = Math.max(validnum, this.min);
|
|
3402
|
+
if (this.max != null) validnum = Math.min(validnum, this.max);
|
|
3403
|
+
if (validnum !== number) this.unmaskedValue = this.format(validnum, this);
|
|
3404
|
+
let formatted = this.value;
|
|
3405
|
+
if (this.normalizeZeros) formatted = this._normalizeZeros(formatted);
|
|
3406
|
+
if (this.padFractionalZeros && this.scale > 0) formatted = this._padFractionalZeros(formatted);
|
|
3407
|
+
this._value = formatted;
|
|
3408
|
+
}
|
|
3409
|
+
super.doCommit();
|
|
3410
|
+
}
|
|
3411
|
+
_normalizeZeros(value) {
|
|
3412
|
+
const parts = this._removeThousandsSeparators(value).split(this.radix);
|
|
3413
|
+
|
|
3414
|
+
// remove leading zeros
|
|
3415
|
+
parts[0] = parts[0].replace(/^(\D*)(0*)(\d*)/, (match, sign, zeros, num) => sign + num);
|
|
3416
|
+
// add leading zero
|
|
3417
|
+
if (value.length && !/\d$/.test(parts[0])) parts[0] = parts[0] + '0';
|
|
3418
|
+
if (parts.length > 1) {
|
|
3419
|
+
parts[1] = parts[1].replace(/0*$/, ''); // remove trailing zeros
|
|
3420
|
+
if (!parts[1].length) parts.length = 1; // remove fractional
|
|
3421
|
+
}
|
|
3422
|
+
return this._insertThousandsSeparators(parts.join(this.radix));
|
|
3423
|
+
}
|
|
3424
|
+
_padFractionalZeros(value) {
|
|
3425
|
+
if (!value) return value;
|
|
3426
|
+
const parts = value.split(this.radix);
|
|
3427
|
+
if (parts.length < 2) parts.push('');
|
|
3428
|
+
parts[1] = parts[1].padEnd(this.scale, '0');
|
|
3429
|
+
return parts.join(this.radix);
|
|
3430
|
+
}
|
|
3431
|
+
doSkipInvalid(ch, flags, checkTail) {
|
|
3432
|
+
if (flags === void 0) {
|
|
3433
|
+
flags = {};
|
|
3434
|
+
}
|
|
3435
|
+
const dropFractional = this.scale === 0 && ch !== this.thousandsSeparator && (ch === this.radix || ch === MaskedNumber.UNMASKED_RADIX || this.mapToRadix.includes(ch));
|
|
3436
|
+
return super.doSkipInvalid(ch, flags, checkTail) && !dropFractional;
|
|
3437
|
+
}
|
|
3438
|
+
get unmaskedValue() {
|
|
3439
|
+
return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix, MaskedNumber.UNMASKED_RADIX);
|
|
3440
|
+
}
|
|
3441
|
+
set unmaskedValue(unmaskedValue) {
|
|
3442
|
+
super.unmaskedValue = unmaskedValue;
|
|
3443
|
+
}
|
|
3444
|
+
get typedValue() {
|
|
3445
|
+
return this.parse(this.unmaskedValue, this);
|
|
3446
|
+
}
|
|
3447
|
+
set typedValue(n) {
|
|
3448
|
+
this.rawInputValue = this.format(n, this).replace(MaskedNumber.UNMASKED_RADIX, this.radix);
|
|
3449
|
+
}
|
|
3450
|
+
|
|
3451
|
+
/** Parsed Number */
|
|
3452
|
+
get number() {
|
|
3453
|
+
return this.typedValue;
|
|
3454
|
+
}
|
|
3455
|
+
set number(number) {
|
|
3456
|
+
this.typedValue = number;
|
|
3457
|
+
}
|
|
3458
|
+
get allowNegative() {
|
|
3459
|
+
return this.min != null && this.min < 0 || this.max != null && this.max < 0;
|
|
3460
|
+
}
|
|
3461
|
+
get allowPositive() {
|
|
3462
|
+
return this.min != null && this.min > 0 || this.max != null && this.max > 0;
|
|
3463
|
+
}
|
|
3464
|
+
typedValueEquals(value) {
|
|
3465
|
+
// handle 0 -> '' case (typed = 0 even if value = '')
|
|
3466
|
+
// for details see https://github.com/uNmAnNeR/imaskjs/issues/134
|
|
3467
|
+
return (super.typedValueEquals(value) || MaskedNumber.EMPTY_VALUES.includes(value) && MaskedNumber.EMPTY_VALUES.includes(this.typedValue)) && !(value === 0 && this.value === '');
|
|
3468
|
+
}
|
|
3469
|
+
}
|
|
3470
|
+
_MaskedNumber = MaskedNumber;
|
|
3471
|
+
MaskedNumber.UNMASKED_RADIX = '.';
|
|
3472
|
+
MaskedNumber.EMPTY_VALUES = [...Masked.EMPTY_VALUES, 0];
|
|
3473
|
+
MaskedNumber.DEFAULTS = {
|
|
3474
|
+
...Masked.DEFAULTS,
|
|
3475
|
+
mask: Number,
|
|
3476
|
+
radix: ',',
|
|
3477
|
+
thousandsSeparator: '',
|
|
3478
|
+
mapToRadix: [_MaskedNumber.UNMASKED_RADIX],
|
|
3479
|
+
min: Number.MIN_SAFE_INTEGER,
|
|
3480
|
+
max: Number.MAX_SAFE_INTEGER,
|
|
3481
|
+
scale: 2,
|
|
3482
|
+
normalizeZeros: true,
|
|
3483
|
+
padFractionalZeros: false,
|
|
3484
|
+
parse: Number,
|
|
3485
|
+
format: n => n.toLocaleString('en-US', {
|
|
3486
|
+
useGrouping: false,
|
|
3487
|
+
maximumFractionDigits: 20
|
|
3488
|
+
})
|
|
3489
|
+
};
|
|
3490
|
+
IMask.MaskedNumber = MaskedNumber;
|
|
3491
|
+
|
|
3492
|
+
/** Mask pipe source and destination types */
|
|
3493
|
+
const PIPE_TYPE = {
|
|
3494
|
+
MASKED: 'value',
|
|
3495
|
+
UNMASKED: 'unmaskedValue',
|
|
3496
|
+
TYPED: 'typedValue'
|
|
3497
|
+
};
|
|
3498
|
+
/** Creates new pipe function depending on mask type, source and destination options */
|
|
3499
|
+
function createPipe(arg, from, to) {
|
|
3500
|
+
if (from === void 0) {
|
|
3501
|
+
from = PIPE_TYPE.MASKED;
|
|
3502
|
+
}
|
|
3503
|
+
if (to === void 0) {
|
|
3504
|
+
to = PIPE_TYPE.MASKED;
|
|
3505
|
+
}
|
|
3506
|
+
const masked = createMask(arg);
|
|
3507
|
+
return value => masked.runIsolated(m => {
|
|
3508
|
+
m[from] = value;
|
|
3509
|
+
return m[to];
|
|
3510
|
+
});
|
|
3511
|
+
}
|
|
3512
|
+
|
|
3513
|
+
/** Pipes value through mask depending on mask type, source and destination options */
|
|
3514
|
+
function pipe(value, mask, from, to) {
|
|
3515
|
+
return createPipe(mask, from, to)(value);
|
|
3516
|
+
}
|
|
3517
|
+
IMask.PIPE_TYPE = PIPE_TYPE;
|
|
3518
|
+
IMask.createPipe = createPipe;
|
|
3519
|
+
IMask.pipe = pipe;
|
|
3520
|
+
|
|
3521
|
+
/** Pattern mask */
|
|
3522
|
+
class RepeatBlock extends MaskedPattern {
|
|
3523
|
+
get repeatFrom() {
|
|
3524
|
+
var _ref;
|
|
3525
|
+
return (_ref = Array.isArray(this.repeat) ? this.repeat[0] : this.repeat === Infinity ? 0 : this.repeat) != null ? _ref : 0;
|
|
3526
|
+
}
|
|
3527
|
+
get repeatTo() {
|
|
3528
|
+
var _ref2;
|
|
3529
|
+
return (_ref2 = Array.isArray(this.repeat) ? this.repeat[1] : this.repeat) != null ? _ref2 : Infinity;
|
|
3530
|
+
}
|
|
3531
|
+
constructor(opts) {
|
|
3532
|
+
super(opts);
|
|
3533
|
+
}
|
|
3534
|
+
updateOptions(opts) {
|
|
3535
|
+
super.updateOptions(opts);
|
|
3536
|
+
}
|
|
3537
|
+
_update(opts) {
|
|
3538
|
+
var _ref3, _ref4, _this$_blocks;
|
|
3539
|
+
const {
|
|
3540
|
+
repeat,
|
|
3541
|
+
...blockOpts
|
|
3542
|
+
} = normalizeOpts(opts); // TODO type
|
|
3543
|
+
this._blockOpts = Object.assign({}, this._blockOpts, blockOpts);
|
|
3544
|
+
const block = createMask(this._blockOpts);
|
|
3545
|
+
this.repeat = (_ref3 = (_ref4 = repeat != null ? repeat : block.repeat) != null ? _ref4 : this.repeat) != null ? _ref3 : Infinity; // TODO type
|
|
3546
|
+
|
|
3547
|
+
super._update({
|
|
3548
|
+
mask: 'm'.repeat(Math.max(this.repeatTo === Infinity && ((_this$_blocks = this._blocks) == null ? void 0 : _this$_blocks.length) || 0, this.repeatFrom)),
|
|
3549
|
+
blocks: {
|
|
3550
|
+
m: block
|
|
3551
|
+
},
|
|
3552
|
+
eager: block.eager,
|
|
3553
|
+
overwrite: block.overwrite,
|
|
3554
|
+
skipInvalid: block.skipInvalid,
|
|
3555
|
+
lazy: block.lazy,
|
|
3556
|
+
placeholderChar: block.placeholderChar,
|
|
3557
|
+
displayChar: block.displayChar
|
|
3558
|
+
});
|
|
3559
|
+
}
|
|
3560
|
+
_allocateBlock(bi) {
|
|
3561
|
+
if (bi < this._blocks.length) return this._blocks[bi];
|
|
3562
|
+
if (this.repeatTo === Infinity || this._blocks.length < this.repeatTo) {
|
|
3563
|
+
this._blocks.push(createMask(this._blockOpts));
|
|
3564
|
+
this.mask += 'm';
|
|
3565
|
+
return this._blocks[this._blocks.length - 1];
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
_appendCharRaw(ch, flags) {
|
|
3569
|
+
if (flags === void 0) {
|
|
3570
|
+
flags = {};
|
|
3571
|
+
}
|
|
3572
|
+
const details = new ChangeDetails();
|
|
3573
|
+
for (let bi = (_this$_mapPosToBlock$ = (_this$_mapPosToBlock = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : _this$_mapPosToBlock.index) != null ? _this$_mapPosToBlock$ : Math.max(this._blocks.length - 1, 0), block, allocated;
|
|
3574
|
+
// try to get a block or
|
|
3575
|
+
// try to allocate a new block if not allocated already
|
|
3576
|
+
block = (_this$_blocks$bi = this._blocks[bi]) != null ? _this$_blocks$bi : allocated = !allocated && this._allocateBlock(bi); ++bi) {
|
|
3577
|
+
var _this$_mapPosToBlock$, _this$_mapPosToBlock, _this$_blocks$bi, _flags$_beforeTailSta;
|
|
3578
|
+
const blockDetails = block._appendChar(ch, {
|
|
3579
|
+
...flags,
|
|
3580
|
+
_beforeTailState: (_flags$_beforeTailSta = flags._beforeTailState) == null || (_flags$_beforeTailSta = _flags$_beforeTailSta._blocks) == null ? void 0 : _flags$_beforeTailSta[bi]
|
|
3581
|
+
});
|
|
3582
|
+
if (blockDetails.skip && allocated) {
|
|
3583
|
+
// remove the last allocated block and break
|
|
3584
|
+
this._blocks.pop();
|
|
3585
|
+
this.mask = this.mask.slice(1);
|
|
3586
|
+
break;
|
|
3587
|
+
}
|
|
3588
|
+
details.aggregate(blockDetails);
|
|
3589
|
+
if (blockDetails.consumed) break; // go next char
|
|
3590
|
+
}
|
|
3591
|
+
return details;
|
|
3592
|
+
}
|
|
3593
|
+
_trimEmptyTail(fromPos, toPos) {
|
|
3594
|
+
var _this$_mapPosToBlock2, _this$_mapPosToBlock3;
|
|
3595
|
+
if (fromPos === void 0) {
|
|
3596
|
+
fromPos = 0;
|
|
3597
|
+
}
|
|
3598
|
+
const firstBlockIndex = Math.max(((_this$_mapPosToBlock2 = this._mapPosToBlock(fromPos)) == null ? void 0 : _this$_mapPosToBlock2.index) || 0, this.repeatFrom, 0);
|
|
3599
|
+
let lastBlockIndex;
|
|
3600
|
+
if (toPos != null) lastBlockIndex = (_this$_mapPosToBlock3 = this._mapPosToBlock(toPos)) == null ? void 0 : _this$_mapPosToBlock3.index;
|
|
3601
|
+
if (lastBlockIndex == null) lastBlockIndex = this._blocks.length - 1;
|
|
3602
|
+
let removeCount = 0;
|
|
3603
|
+
for (let blockIndex = lastBlockIndex; firstBlockIndex <= blockIndex; --blockIndex, ++removeCount) {
|
|
3604
|
+
if (this._blocks[blockIndex].unmaskedValue) break;
|
|
3605
|
+
}
|
|
3606
|
+
if (removeCount) {
|
|
3607
|
+
this._blocks.splice(lastBlockIndex - removeCount + 1, removeCount);
|
|
3608
|
+
this.mask = this.mask.slice(removeCount);
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3611
|
+
reset() {
|
|
3612
|
+
super.reset();
|
|
3613
|
+
this._trimEmptyTail();
|
|
3614
|
+
}
|
|
3615
|
+
remove(fromPos, toPos) {
|
|
3616
|
+
if (fromPos === void 0) {
|
|
3617
|
+
fromPos = 0;
|
|
3618
|
+
}
|
|
3619
|
+
if (toPos === void 0) {
|
|
3620
|
+
toPos = this.displayValue.length;
|
|
3621
|
+
}
|
|
3622
|
+
const removeDetails = super.remove(fromPos, toPos);
|
|
3623
|
+
this._trimEmptyTail(fromPos, toPos);
|
|
3624
|
+
return removeDetails;
|
|
3625
|
+
}
|
|
3626
|
+
totalInputPositions(fromPos, toPos) {
|
|
3627
|
+
if (fromPos === void 0) {
|
|
3628
|
+
fromPos = 0;
|
|
3629
|
+
}
|
|
3630
|
+
if (toPos == null && this.repeatTo === Infinity) return Infinity;
|
|
3631
|
+
return super.totalInputPositions(fromPos, toPos);
|
|
3632
|
+
}
|
|
3633
|
+
get state() {
|
|
3634
|
+
return super.state;
|
|
3635
|
+
}
|
|
3636
|
+
set state(state) {
|
|
3637
|
+
this._blocks.length = state._blocks.length;
|
|
3638
|
+
this.mask = this.mask.slice(0, this._blocks.length);
|
|
3639
|
+
super.state = state;
|
|
3640
|
+
}
|
|
3641
|
+
}
|
|
3642
|
+
IMask.RepeatBlock = RepeatBlock;
|
|
3643
|
+
|
|
3644
|
+
try {
|
|
3645
|
+
globalThis.IMask = IMask;
|
|
3646
|
+
} catch {}
|
|
3647
|
+
|
|
3648
|
+
var en = {};
|
|
3649
|
+
|
|
3650
|
+
var hasRequiredEn;
|
|
3651
|
+
|
|
3652
|
+
function requireEn () {
|
|
3653
|
+
if (hasRequiredEn) return en;
|
|
3654
|
+
hasRequiredEn = 1;
|
|
3655
|
+
|
|
3656
|
+
Object.defineProperty(en, "__esModule", {
|
|
3657
|
+
value: true
|
|
3658
|
+
});
|
|
3659
|
+
en.default = void 0;
|
|
3660
|
+
var _default = {
|
|
3661
|
+
days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
|
3662
|
+
daysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
|
3663
|
+
daysMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
|
|
3664
|
+
months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
|
3665
|
+
monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
|
3666
|
+
today: 'Today',
|
|
3667
|
+
clear: 'Clear',
|
|
3668
|
+
dateFormat: 'MM/dd/yyyy',
|
|
3669
|
+
timeFormat: 'hh:mm aa',
|
|
3670
|
+
firstDay: 0
|
|
3671
|
+
};
|
|
3672
|
+
en.default = _default;
|
|
3673
|
+
return en;
|
|
3674
|
+
}
|
|
3675
|
+
|
|
3676
|
+
var enExports = requireEn();
|
|
3677
|
+
var localeEn = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(enExports);
|
|
3678
|
+
|
|
3679
|
+
var de = {};
|
|
3680
|
+
|
|
3681
|
+
var hasRequiredDe;
|
|
3682
|
+
|
|
3683
|
+
function requireDe () {
|
|
3684
|
+
if (hasRequiredDe) return de;
|
|
3685
|
+
hasRequiredDe = 1;
|
|
3686
|
+
|
|
3687
|
+
Object.defineProperty(de, "__esModule", {
|
|
3688
|
+
value: true
|
|
3689
|
+
});
|
|
3690
|
+
de.default = void 0;
|
|
3691
|
+
var _default = {
|
|
3692
|
+
days: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'],
|
|
3693
|
+
daysShort: ['Son', 'Mon', 'Die', 'Mit', 'Don', 'Fre', 'Sam'],
|
|
3694
|
+
daysMin: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
|
|
3695
|
+
months: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
|
|
3696
|
+
monthsShort: ['Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'],
|
|
3697
|
+
today: 'Heute',
|
|
3698
|
+
clear: 'Löschen',
|
|
3699
|
+
dateFormat: 'dd.MM.yyyy',
|
|
3700
|
+
timeFormat: 'HH:mm',
|
|
3701
|
+
firstDay: 1
|
|
3702
|
+
};
|
|
3703
|
+
de.default = _default;
|
|
3704
|
+
return de;
|
|
3705
|
+
}
|
|
3706
|
+
|
|
3707
|
+
var deExports = requireDe();
|
|
3708
|
+
var localeDe = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(deExports);
|
|
3709
|
+
|
|
3710
|
+
var it = {};
|
|
3711
|
+
|
|
3712
|
+
var hasRequiredIt;
|
|
3713
|
+
|
|
3714
|
+
function requireIt () {
|
|
3715
|
+
if (hasRequiredIt) return it;
|
|
3716
|
+
hasRequiredIt = 1;
|
|
3717
|
+
|
|
3718
|
+
Object.defineProperty(it, "__esModule", {
|
|
3719
|
+
value: true
|
|
3720
|
+
});
|
|
3721
|
+
it.default = void 0;
|
|
3722
|
+
var _default = {
|
|
3723
|
+
days: ['Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato'],
|
|
3724
|
+
daysShort: ['Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab'],
|
|
3725
|
+
daysMin: ['Do', 'Lu', 'Ma', 'Me', 'Gi', 'Ve', 'Sa'],
|
|
3726
|
+
months: ['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre'],
|
|
3727
|
+
monthsShort: ['Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'],
|
|
3728
|
+
today: 'Oggi',
|
|
3729
|
+
clear: 'Cancella',
|
|
3730
|
+
dateFormat: 'dd/MM/yyyy',
|
|
3731
|
+
timeFormat: 'HH:mm',
|
|
3732
|
+
firstDay: 1
|
|
3733
|
+
};
|
|
3734
|
+
it.default = _default;
|
|
3735
|
+
return it;
|
|
3736
|
+
}
|
|
3737
|
+
|
|
3738
|
+
var itExports = requireIt();
|
|
3739
|
+
var localeIt = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(itExports);
|
|
3740
|
+
|
|
3741
|
+
var fr = {};
|
|
3742
|
+
|
|
3743
|
+
var hasRequiredFr;
|
|
3744
|
+
|
|
3745
|
+
function requireFr () {
|
|
3746
|
+
if (hasRequiredFr) return fr;
|
|
3747
|
+
hasRequiredFr = 1;
|
|
3748
|
+
|
|
3749
|
+
Object.defineProperty(fr, "__esModule", {
|
|
3750
|
+
value: true
|
|
3751
|
+
});
|
|
3752
|
+
fr.default = void 0;
|
|
3753
|
+
var _default = {
|
|
3754
|
+
days: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'],
|
|
3755
|
+
daysShort: ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'],
|
|
3756
|
+
daysMin: ['Di', 'Lu', 'Ma', 'Me', 'Je', 'Ve', 'Sa'],
|
|
3757
|
+
months: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],
|
|
3758
|
+
monthsShort: ['Jan', 'Fév', 'Mars', 'Avr', 'Mai', 'Juin', 'Juil', 'Août', 'Sep', 'Oct', 'Nov', 'Dec'],
|
|
3759
|
+
today: "Aujourd'hui",
|
|
3760
|
+
clear: 'Effacer',
|
|
3761
|
+
dateFormat: 'dd/MM/yyyy',
|
|
3762
|
+
timeFormat: 'HH:mm',
|
|
3763
|
+
firstDay: 1
|
|
3764
|
+
};
|
|
3765
|
+
fr.default = _default;
|
|
3766
|
+
return fr;
|
|
3767
|
+
}
|
|
3768
|
+
|
|
3769
|
+
var frExports = requireFr();
|
|
3770
|
+
var localeFr = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(frExports);
|
|
3771
|
+
|
|
3772
|
+
const localesMap = {
|
|
3773
|
+
en: localeEn,
|
|
3774
|
+
fr: localeFr,
|
|
3775
|
+
de: localeDe,
|
|
3776
|
+
it: localeIt,
|
|
3777
|
+
};
|
|
3778
|
+
|
|
3779
|
+
const postDatePickerCss = () => `.air-datepicker-cell.-year-.-other-decade-,.air-datepicker-cell.-day-.-other-month-{color:var(--adp-color-other-month)}.air-datepicker-cell.-year-.-other-decade-:hover,.air-datepicker-cell.-day-.-other-month-:hover{color:var(--adp-color-other-month-hover)}.-disabled-.-focus-.air-datepicker-cell.-year-.-other-decade-,.-disabled-.-focus-.air-datepicker-cell.-day-.-other-month-{color:var(--adp-color-other-month)}.-selected-.air-datepicker-cell.-year-.-other-decade-,.-selected-.air-datepicker-cell.-day-.-other-month-{color:#fff;background:var(--adp-background-color-selected-other-month)}.-selected-.-focus-.air-datepicker-cell.-year-.-other-decade-,.-selected-.-focus-.air-datepicker-cell.-day-.-other-month-{background:var(--adp-background-color-selected-other-month-focused)}.-in-range-.air-datepicker-cell.-year-.-other-decade-,.-in-range-.air-datepicker-cell.-day-.-other-month-{background-color:var(--adp-background-color-in-range);color:var(--adp-color)}.-in-range-.-focus-.air-datepicker-cell.-year-.-other-decade-,.-in-range-.-focus-.air-datepicker-cell.-day-.-other-month-{background-color:var(--adp-background-color-in-range-focused)}.air-datepicker-cell.-year-.-other-decade-:empty,.air-datepicker-cell.-day-.-other-month-:empty{background:none;border:none}.air-datepicker-cell{border-radius:var(--adp-cell-border-radius);box-sizing:border-box;cursor:pointer;display:flex;position:relative;align-items:center;justify-content:center;z-index:1}.air-datepicker-cell.-focus-{background:var(--adp-cell-background-color-hover)}.air-datepicker-cell.-current-{color:var(--adp-color-current-date)}.air-datepicker-cell.-current-.-focus-{color:var(--adp-color)}.air-datepicker-cell.-current-.-in-range-{color:var(--adp-color-current-date)}.air-datepicker-cell.-disabled-{cursor:default;color:var(--adp-color-disabled)}.air-datepicker-cell.-disabled-.-focus-{color:var(--adp-color-disabled)}.air-datepicker-cell.-disabled-.-in-range-{color:var(--adp-color-disabled-in-range)}.air-datepicker-cell.-disabled-.-current-.-focus-{color:var(--adp-color-disabled)}.air-datepicker-cell.-in-range-{background:var(--adp-cell-background-color-in-range);border-radius:0}.air-datepicker-cell.-in-range-:hover,.air-datepicker-cell.-in-range-.-focus-{background:var(--adp-cell-background-color-in-range-hover)}.air-datepicker-cell.-range-from-{border:1px solid var(--adp-cell-border-color-in-range);background-color:var(--adp-cell-background-color-in-range);border-radius:var(--adp-cell-border-radius) 0 0 var(--adp-cell-border-radius)}.air-datepicker-cell.-range-to-{border:1px solid var(--adp-cell-border-color-in-range);background-color:var(--adp-cell-background-color-in-range);border-radius:0 var(--adp-cell-border-radius) var(--adp-cell-border-radius) 0}.air-datepicker-cell.-range-to-.-range-from-{border-radius:var(--adp-cell-border-radius)}.air-datepicker-cell.-selected-{color:#fff;border:none;background:var(--adp-cell-background-color-selected)}.air-datepicker-cell.-selected-.-current-{color:#fff;background:var(--adp-cell-background-color-selected)}.air-datepicker-cell.-selected-.-focus-{background:var(--adp-cell-background-color-selected-hover)}.air-datepicker-body{transition:all var(--adp-transition-duration) var(--adp-transition-ease)}.air-datepicker-body.-hidden-{display:none}.air-datepicker-body--day-names{display:grid;grid-template-columns:repeat(7, var(--adp-day-cell-width));margin:8px 0 3px}.air-datepicker-body--day-name{color:var(--adp-day-name-color);display:flex;align-items:center;justify-content:center;flex:1;text-align:center;text-transform:uppercase;font-size:.8em}.air-datepicker-body--day-name.-clickable-{cursor:pointer}.air-datepicker-body--day-name.-clickable-:hover{color:var(--adp-day-name-color-hover)}.air-datepicker-body--cells{display:grid}.air-datepicker-body--cells.-days-{grid-template-columns:repeat(7, var(--adp-day-cell-width));grid-auto-rows:var(--adp-day-cell-height)}.air-datepicker-body--cells.-months-{grid-template-columns:repeat(3, 1fr);grid-auto-rows:var(--adp-month-cell-height)}.air-datepicker-body--cells.-years-{grid-template-columns:repeat(4, 1fr);grid-auto-rows:var(--adp-year-cell-height)}.air-datepicker-nav{display:flex;justify-content:space-between;border-bottom:1px solid var(--adp-border-color-inner);min-height:var(--adp-nav-height);padding:var(--adp-padding);box-sizing:content-box}.-only-timepicker- .air-datepicker-nav{display:none}.air-datepicker-nav--title,.air-datepicker-nav--action{display:flex;cursor:pointer;align-items:center;justify-content:center}.air-datepicker-nav--action{width:var(--adp-nav-action-size);border-radius:var(--adp-border-radius);-webkit-user-select:none;-moz-user-select:none;user-select:none}.air-datepicker-nav--action:hover{background:var(--adp-background-color-hover)}.air-datepicker-nav--action:active{background:var(--adp-background-color-active)}.air-datepicker-nav--action.-disabled-{visibility:hidden}.air-datepicker-nav--action svg{width:32px;height:32px}.air-datepicker-nav--action path{fill:none;stroke:var(--adp-nav-arrow-color);stroke-width:2px}.air-datepicker-nav--title{border-radius:var(--adp-border-radius);padding:0 8px}.air-datepicker-nav--title i{font-style:normal;color:var(--adp-nav-color-secondary);margin-left:.3em}.air-datepicker-nav--title:hover{background:var(--adp-background-color-hover)}.air-datepicker-nav--title:active{background:var(--adp-background-color-active)}.air-datepicker-nav--title.-disabled-{cursor:default;background:none}.air-datepicker-buttons{display:grid;grid-auto-columns:1fr;grid-auto-flow:column}.air-datepicker-button{display:inline-flex;color:var(--adp-btn-color);border-radius:var(--adp-btn-border-radius);cursor:pointer;height:var(--adp-btn-height);border:none;background:rgba(255, 255, 255, 0)}.air-datepicker-button:hover{color:var(--adp-btn-color-hover);background:var(--adp-btn-background-color-hover)}.air-datepicker-button:focus{color:var(--adp-btn-color-hover);background:var(--adp-btn-background-color-hover);outline:none}.air-datepicker-button:active{background:var(--adp-btn-background-color-active)}.air-datepicker-button span{outline:none;display:flex;align-items:center;justify-content:center;width:100%;height:100%}.air-datepicker-time{display:grid;grid-template-columns:max-content 1fr;grid-column-gap:12px;align-items:center;position:relative;padding:0 var(--adp-time-padding-inner)}.-only-timepicker- .air-datepicker-time{border-top:none}.air-datepicker-time--current{display:flex;align-items:center;flex:1;font-size:14px;text-align:center}.air-datepicker-time--current-colon{margin:0 2px 3px;line-height:1}.air-datepicker-time--current-hours,.air-datepicker-time--current-minutes{line-height:1;font-size:19px;font-family:"Century Gothic",CenturyGothic,AppleGothic,sans-serif;position:relative;z-index:1}.air-datepicker-time--current-hours:after,.air-datepicker-time--current-minutes:after{content:"";background:var(--adp-background-color-hover);border-radius:var(--adp-border-radius);position:absolute;left:-2px;top:-3px;right:-2px;bottom:-2px;z-index:-1;opacity:0}.air-datepicker-time--current-hours.-focus-:after,.air-datepicker-time--current-minutes.-focus-:after{opacity:1}.air-datepicker-time--current-ampm{text-transform:uppercase;align-self:flex-end;color:var(--adp-time-day-period-color);margin-left:6px;font-size:11px;margin-bottom:1px}.air-datepicker-time--row{display:flex;align-items:center;font-size:11px;height:17px;background:linear-gradient(to right, var(--adp-time-track-color), var(--adp-time-track-color)) left 50%/100% var(--adp-time-track-height) no-repeat}.air-datepicker-time--row:first-child{margin-bottom:4px}.air-datepicker-time--row input[type=range]{background:none;cursor:pointer;flex:1;height:100%;width:100%;padding:0;margin:0;-webkit-appearance:none}.air-datepicker-time--row input[type=range]::-webkit-slider-thumb{-webkit-appearance:none}.air-datepicker-time--row input[type=range]::-ms-tooltip{display:none}.air-datepicker-time--row input[type=range]:hover::-webkit-slider-thumb{border-color:var(--adp-time-track-color-hover)}.air-datepicker-time--row input[type=range]:hover::-moz-range-thumb{border-color:var(--adp-time-track-color-hover)}.air-datepicker-time--row input[type=range]:hover::-ms-thumb{border-color:var(--adp-time-track-color-hover)}.air-datepicker-time--row input[type=range]:focus{outline:none}.air-datepicker-time--row input[type=range]:focus::-webkit-slider-thumb{background:var(--adp-cell-background-color-selected);border-color:var(--adp-cell-background-color-selected)}.air-datepicker-time--row input[type=range]:focus::-moz-range-thumb{background:var(--adp-cell-background-color-selected);border-color:var(--adp-cell-background-color-selected)}.air-datepicker-time--row input[type=range]:focus::-ms-thumb{background:var(--adp-cell-background-color-selected);border-color:var(--adp-cell-background-color-selected)}.air-datepicker-time--row input[type=range]::-webkit-slider-thumb{box-sizing:border-box;height:12px;width:12px;border-radius:3px;border:1px solid var(--adp-time-track-color);background:#fff;cursor:pointer;-webkit-transition:background var(--adp-transition-duration);transition:background var(--adp-transition-duration)}.air-datepicker-time--row input[type=range]::-moz-range-thumb{box-sizing:border-box;height:12px;width:12px;border-radius:3px;border:1px solid var(--adp-time-track-color);background:#fff;cursor:pointer;-moz-transition:background var(--adp-transition-duration);transition:background var(--adp-transition-duration)}.air-datepicker-time--row input[type=range]::-ms-thumb{box-sizing:border-box;height:12px;width:12px;border-radius:3px;border:1px solid var(--adp-time-track-color);background:#fff;cursor:pointer;-ms-transition:background var(--adp-transition-duration);transition:background var(--adp-transition-duration)}.air-datepicker-time--row input[type=range]::-webkit-slider-thumb{margin-top:calc(var(--adp-time-thumb-size)/2*-1)}.air-datepicker-time--row input[type=range]::-webkit-slider-runnable-track{border:none;height:var(--adp-time-track-height);cursor:pointer;color:rgba(0, 0, 0, 0);background:rgba(0, 0, 0, 0)}.air-datepicker-time--row input[type=range]::-moz-range-track{border:none;height:var(--adp-time-track-height);cursor:pointer;color:rgba(0, 0, 0, 0);background:rgba(0, 0, 0, 0)}.air-datepicker-time--row input[type=range]::-ms-track{border:none;height:var(--adp-time-track-height);cursor:pointer;color:rgba(0, 0, 0, 0);background:rgba(0, 0, 0, 0)}.air-datepicker-time--row input[type=range]::-ms-fill-lower{background:rgba(0, 0, 0, 0)}.air-datepicker-time--row input[type=range]::-ms-fill-upper{background:rgba(0, 0, 0, 0)}.air-datepicker{--adp-font-family:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";--adp-font-size:14px;--adp-width:246px;--adp-z-index:100;--adp-padding:4px;--adp-grid-areas:"nav" "body" "timepicker" "buttons";--adp-transition-duration:.3s;--adp-transition-ease:ease-out;--adp-transition-offset:8px;--adp-background-color:#fff;--adp-background-color-hover:#f0f0f0;--adp-background-color-active:#eaeaea;--adp-background-color-in-range:rgba(92, 196, 239, .1);--adp-background-color-in-range-focused:rgba(92, 196, 239, .2);--adp-background-color-selected-other-month-focused:#8ad5f4;--adp-background-color-selected-other-month:#a2ddf6;--adp-color:#4a4a4a;--adp-color-secondary:#9c9c9c;--adp-accent-color:#4eb5e6;--adp-color-current-date:var(--adp-accent-color);--adp-color-other-month:#dedede;--adp-color-disabled:#aeaeae;--adp-color-disabled-in-range:#939393;--adp-color-other-month-hover:#c5c5c5;--adp-border-color:#dbdbdb;--adp-border-color-inner:#efefef;--adp-border-radius:4px;--adp-border-color-inline:#d7d7d7;--adp-nav-height:32px;--adp-nav-arrow-color:var(--adp-color-secondary);--adp-nav-action-size:32px;--adp-nav-color-secondary:var(--adp-color-secondary);--adp-day-name-color:#ff9a19;--adp-day-name-color-hover:#8ad5f4;--adp-day-cell-width:1fr;--adp-day-cell-height:32px;--adp-month-cell-height:42px;--adp-year-cell-height:56px;--adp-pointer-size:10px;--adp-poiner-border-radius:2px;--adp-pointer-offset:14px;--adp-cell-border-radius:4px;--adp-cell-background-color-hover:var(--adp-background-color-hover);--adp-cell-background-color-selected:#5cc4ef;--adp-cell-background-color-selected-hover:#45bced;--adp-cell-background-color-in-range:rgba(92, 196, 239, 0.1);--adp-cell-background-color-in-range-hover:rgba(92, 196, 239, 0.2);--adp-cell-border-color-in-range:var(--adp-cell-background-color-selected);--adp-btn-height:32px;--adp-btn-color:var(--adp-accent-color);--adp-btn-color-hover:var(--adp-color);--adp-btn-border-radius:var(--adp-border-radius);--adp-btn-background-color-hover:var(--adp-background-color-hover);--adp-btn-background-color-active:var(--adp-background-color-active);--adp-time-track-height:1px;--adp-time-track-color:#dedede;--adp-time-track-color-hover:#b1b1b1;--adp-time-thumb-size:12px;--adp-time-padding-inner:10px;--adp-time-day-period-color:var(--adp-color-secondary);--adp-mobile-font-size:16px;--adp-mobile-nav-height:40px;--adp-mobile-width:320px;--adp-mobile-day-cell-height:38px;--adp-mobile-month-cell-height:48px;--adp-mobile-year-cell-height:64px}.air-datepicker-overlay{--adp-overlay-background-color:rgba(0, 0, 0, .3);--adp-overlay-transition-duration:.3s;--adp-overlay-transition-ease:ease-out;--adp-overlay-z-index:99}.air-datepicker{background:var(--adp-background-color);border:1px solid var(--adp-border-color);box-shadow:0 4px 12px rgba(0, 0, 0, 0.15);border-radius:var(--adp-border-radius);box-sizing:content-box;display:grid;grid-template-columns:1fr;grid-template-rows:repeat(4, max-content);grid-template-areas:var(--adp-grid-areas);font-family:var(--adp-font-family),sans-serif;font-size:var(--adp-font-size);color:var(--adp-color);width:var(--adp-width);position:absolute;transition:opacity var(--adp-transition-duration) var(--adp-transition-ease),transform var(--adp-transition-duration) var(--adp-transition-ease);z-index:var(--adp-z-index)}.air-datepicker:not(.-custom-position-){opacity:0}.air-datepicker.-from-top-{transform:translateY(calc(var(--adp-transition-offset) * -1))}.air-datepicker.-from-right-{transform:translateX(var(--adp-transition-offset))}.air-datepicker.-from-bottom-{transform:translateY(var(--adp-transition-offset))}.air-datepicker.-from-left-{transform:translateX(calc(var(--adp-transition-offset) * -1))}.air-datepicker.-active-:not(.-custom-position-){transform:translate(0, 0);opacity:1}.air-datepicker.-active-.-custom-position-{transition:none}.air-datepicker.-inline-{border-color:var(--adp-border-color-inline);box-shadow:none;position:static;left:auto;right:auto;opacity:1;transform:none}.air-datepicker.-inline- .air-datepicker--pointer{display:none}.air-datepicker.-is-mobile-{--adp-font-size:var(--adp-mobile-font-size);--adp-day-cell-height:var(--adp-mobile-day-cell-height);--adp-month-cell-height:var(--adp-mobile-month-cell-height);--adp-year-cell-height:var(--adp-mobile-year-cell-height);--adp-nav-height:var(--adp-mobile-nav-height);--adp-nav-action-size:var(--adp-mobile-nav-height);position:fixed;width:var(--adp-mobile-width);border:none}.air-datepicker.-is-mobile- *{-webkit-tap-highlight-color:rgba(0, 0, 0, 0)}.air-datepicker.-is-mobile- .air-datepicker--pointer{display:none}.air-datepicker.-is-mobile-:not(.-custom-position-){transform:translate(-50%, calc(-50% + var(--adp-transition-offset)))}.air-datepicker.-is-mobile-.-active-:not(.-custom-position-){transform:translate(-50%, -50%)}.air-datepicker.-custom-position-{transition:none}.air-datepicker-global-container{position:absolute;left:0;top:0}.air-datepicker--pointer{--pointer-half-size:calc(var(--adp-pointer-size) / 2);position:absolute;width:var(--adp-pointer-size);height:var(--adp-pointer-size);z-index:-1}.air-datepicker--pointer:after{content:"";position:absolute;background:#fff;border-top:1px solid var(--adp-border-color-inline);border-right:1px solid var(--adp-border-color-inline);border-top-right-radius:var(--adp-poiner-border-radius);width:var(--adp-pointer-size);height:var(--adp-pointer-size);box-sizing:border-box}.-top-left- .air-datepicker--pointer,.-top-center- .air-datepicker--pointer,.-top-right- .air-datepicker--pointer,[data-popper-placement^=top] .air-datepicker--pointer{top:calc(100% - var(--pointer-half-size) + 1px)}.-top-left- .air-datepicker--pointer:after,.-top-center- .air-datepicker--pointer:after,.-top-right- .air-datepicker--pointer:after,[data-popper-placement^=top] .air-datepicker--pointer:after{transform:rotate(135deg)}.-right-top- .air-datepicker--pointer,.-right-center- .air-datepicker--pointer,.-right-bottom- .air-datepicker--pointer,[data-popper-placement^=right] .air-datepicker--pointer{right:calc(100% - var(--pointer-half-size) + 1px)}.-right-top- .air-datepicker--pointer:after,.-right-center- .air-datepicker--pointer:after,.-right-bottom- .air-datepicker--pointer:after,[data-popper-placement^=right] .air-datepicker--pointer:after{transform:rotate(225deg)}.-bottom-left- .air-datepicker--pointer,.-bottom-center- .air-datepicker--pointer,.-bottom-right- .air-datepicker--pointer,[data-popper-placement^=bottom] .air-datepicker--pointer{bottom:calc(100% - var(--pointer-half-size) + 1px)}.-bottom-left- .air-datepicker--pointer:after,.-bottom-center- .air-datepicker--pointer:after,.-bottom-right- .air-datepicker--pointer:after,[data-popper-placement^=bottom] .air-datepicker--pointer:after{transform:rotate(315deg)}.-left-top- .air-datepicker--pointer,.-left-center- .air-datepicker--pointer,.-left-bottom- .air-datepicker--pointer,[data-popper-placement^=left] .air-datepicker--pointer{left:calc(100% - var(--pointer-half-size) + 1px)}.-left-top- .air-datepicker--pointer:after,.-left-center- .air-datepicker--pointer:after,.-left-bottom- .air-datepicker--pointer:after,[data-popper-placement^=left] .air-datepicker--pointer:after{transform:rotate(45deg)}.-top-left- .air-datepicker--pointer,.-bottom-left- .air-datepicker--pointer{left:var(--adp-pointer-offset)}.-top-right- .air-datepicker--pointer,.-bottom-right- .air-datepicker--pointer{right:var(--adp-pointer-offset)}.-top-center- .air-datepicker--pointer,.-bottom-center- .air-datepicker--pointer{left:calc(50% - var(--adp-pointer-size)/2)}.-left-top- .air-datepicker--pointer,.-right-top- .air-datepicker--pointer{top:var(--adp-pointer-offset)}.-left-bottom- .air-datepicker--pointer,.-right-bottom- .air-datepicker--pointer{bottom:var(--adp-pointer-offset)}.-left-center- .air-datepicker--pointer,.-right-center- .air-datepicker--pointer{top:calc(50% - var(--adp-pointer-size)/2)}.air-datepicker--navigation{grid-area:nav}.air-datepicker--content{box-sizing:content-box;padding:var(--adp-padding);grid-area:body}.-only-timepicker- .air-datepicker--content{display:none}.air-datepicker--time{grid-area:timepicker}.air-datepicker--buttons{grid-area:buttons}.air-datepicker--buttons,.air-datepicker--time{padding:var(--adp-padding);border-top:1px solid var(--adp-border-color-inner)}.air-datepicker-overlay{position:fixed;background:var(--adp-overlay-background-color);left:0;top:0;width:0;height:0;opacity:0;transition:opacity var(--adp-overlay-transition-duration) var(--adp-overlay-transition-ease),left 0s,height 0s,width 0s;transition-delay:0s,var(--adp-overlay-transition-duration),var(--adp-overlay-transition-duration),var(--adp-overlay-transition-duration);z-index:var(--adp-overlay-z-index)}.air-datepicker-overlay.-active-{opacity:1;width:100%;height:100%;transition:opacity var(--adp-overlay-transition-duration) var(--adp-overlay-transition-ease),height 0s,width 0s}.air-datepicker{--adp-cell-background-color-in-range:unset;--adp-hover-color:unset;font-family:inherit;font-size:var(--post-device-font-size-8);width:var(--post-core-dimension-296);border-radius:var(--post-device-border-radius-1);box-shadow:var(--post-device-elevation-300);font-weight:700;border:none}.air-datepicker.-inline-{box-shadow:var(--post-device-elevation-300)}.air-datepicker *{font-family:inherit}.air-datepicker .air-datepicker--navigation{border-start-start-radius:inherit;border-start-end-radius:inherit}.air-datepicker .air-datepicker--navigation .air-datepicker-nav{border-start-start-radius:inherit;border-start-end-radius:inherit;border-block-end:none;background:var(--post-core-color-sandgrey-012);padding:var(--post-device-spacing-padding-15)}.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--title{margin-right:auto;margin-inline-start:0;justify-content:flex-start;display:flex;align-items:center;padding:0 0 0 var(--post-device-spacing-padding-15);color:var(--post-scheme-color-interactive-button-tertiary-enabled-fg)}.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--title.-disabled-:hover{color:var(--post-scheme-color-interactive-button-tertiary-enabled-fg) !important}.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--title:hover{background:unset}.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--title button{padding:0;overflow:visible;border:0;background:none;color:var(--post-scheme-color-interactive-button-secondary-enabled-fg);font:inherit;-webkit-user-select:none;user-select:none;appearance:button;border-radius:var(--post-device-border-radius-1);display:flex;align-items:center;gap:var(--post-device-spacing-gap-3);color:var(--post-scheme-color-interactive-button-tertiary-enabled-fg)}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--title button{background-color:ButtonFace !important}.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--title button:hover{background-color:Highlight !important}}.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--title button:not(.-disabled-){outline-offset:var(--post-device-spacing-padding-2) !important;outline:var(--post-scheme-color-interactive-focus-stroke) none var(--post-device-border-width-focus) !important}.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--title button:not(.-disabled-):is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--title button:not(.-disabled-):is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-color:Highlight !important}}@supports not selector(:has(:focus-visible)){.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--title button:not(.-disabled-):is(:focus-visible,:focus-within,.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--title button:not(.-disabled-):is(:focus-visible,:focus-within,.pretend-focus){outline-color:Highlight !important}}}.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--title button:hover{color:var(--post-scheme-color-interactive-button-tertiary-hover-fg)}.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--title button[disabled]{color:var(--post-scheme-color-interactive-button-tertiary-disabled-fg)}.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--title .placeholder{flex-grow:2;pointer-events:none}.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--action{height:var(--post-device-sizing-interactive-button-height-4);width:var(--post-device-sizing-interactive-button-height-4)}.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--action[data-action=next]{margin-inline-start:var(--post-device-spacing-gap-inline-4)}.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--action:hover{background:unset}.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--action button{padding:0;overflow:visible;border:0;background:none;color:var(--post-scheme-color-interactive-button-secondary-enabled-fg);font:inherit;-webkit-user-select:none;user-select:none;appearance:button;height:var(--post-device-sizing-interactive-button-height-4);width:var(--post-device-sizing-interactive-button-height-4);border-radius:var(--post-device-border-radius-round)}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--action button{background-color:ButtonFace !important}.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--action button:hover{background-color:Highlight !important}}.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--action button:hover{color:var(--post-scheme-color-interactive-button-tertiary-hover-fg)}.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--action button:not(.-disabled-){outline-offset:var(--post-device-spacing-padding-2) !important;outline:var(--post-scheme-color-interactive-focus-stroke) none var(--post-device-border-width-focus) !important}.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--action button:not(.-disabled-):is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--action button:not(.-disabled-):is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-color:Highlight !important}}@supports not selector(:has(:focus-visible)){.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--action button:not(.-disabled-):is(:focus-visible,:focus-within,.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--navigation .air-datepicker-nav .air-datepicker-nav--action button:not(.-disabled-):is(:focus-visible,:focus-within,.pretend-focus){outline-color:Highlight !important}}}.air-datepicker .air-datepicker--content{padding:0 !important}.air-datepicker .air-datepicker--content .air-datepicker-body--day-names{background:var(--post-core-color-sandgrey-012);margin:0;padding-block-start:var(--post-device-spacing-padding-13);padding-block-end:var(--post-device-spacing-padding-5);padding-inline:var(--post-device-spacing-padding-15)}.air-datepicker .air-datepicker--content .air-datepicker-body--day-names .air-datepicker-body--day-name{text-transform:capitalize;font-size:inherit;color:var(--post-scheme-color-surface-brand-fg)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells{min-height:var(--post-core-dimension-182);padding:var(--post-device-spacing-padding-15);background:var(--post-scheme-color-surface-accent1-bg);row-gap:var(--post-device-spacing-gap-2);border-radius:var(--post-device-border-radius-1)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days-{grid-template-columns:repeat(7, var(--post-core-dimension-40));grid-auto-rows:var(--post-core-dimension-40)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell>*{box-sizing:border-box}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell::before,.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell::after{box-sizing:border-box}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell.-day-{width:var(--post-core-dimension-40);height:var(--post-core-dimension-40);border-radius:var(--post-device-border-radius-round)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell.-day-:not(.-disabled-){outline-offset:var(--post-device-spacing-padding-2) !important;outline:var(--post-scheme-color-interactive-focus-stroke) none var(--post-device-border-width-focus) !important}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell.-day-:not(.-disabled-):is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-style:var(--post-core-border-style-solid) !important;z-index:3}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell.-day-:not(.-disabled-):is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-color:Highlight !important}}@supports not selector(:has(:focus-visible)){.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell.-day-:not(.-disabled-):is(:focus-visible,:focus-within,.pretend-focus){outline-style:var(--post-core-border-style-solid) !important;z-index:3}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell.-day-:not(.-disabled-):is(:focus-visible,:focus-within,.pretend-focus){outline-color:Highlight !important}}}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell.-day-.-other-month-{pointer-events:none}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell.-day-:hover:not(.-disabled-,.-other-month-,.-in-range-){color:var(--post-scheme-color-interactive-primary-hover-fg3)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell.-day-:hover:not(.-disabled-,.-other-month-,.-in-range-):not(.-current-){background:var(--post-scheme-color-interactive-primary-hover-bg2)}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell.-day-:hover:not(.-disabled-,.-other-month-,.-in-range-):not(.-current-){background-color:ButtonFace;color:ButtonText}}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell.-day-:hover:not(.-disabled-,.-other-month-,.-in-range-).-current-{color:var(--post-scheme-color-interactive-primary-hover-fg1);border-color:var(--post-scheme-color-interactive-primary-hover-stroke)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell.-day-.-selected-:not(.-other-month-){z-index:2;color:var(--post-scheme-color-interactive-primary-selected-fg3);background:var(--post-scheme-color-interactive-primary-selected-bg4)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell.-day-.-selected-:not(.-other-month-):not(.-range-from-):not(.-range-to-,.-other-month-){border-color:var(--post-scheme-color-interactive-primary-selected-stroke1)}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell.-day-.-selected-:not(.-other-month-){background-color:Highlight;color:HighlightText}}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell.-day-.-disabled-:not(.-other-month-){user-select:none;pointer-events:none;color:var(--post-scheme-color-interactive-primary-disabled-fg1);border:2px dashed var(--post-scheme-color-interactive-primary-disabled-stroke);width:var(--post-core-dimension-38);height:var(--post-core-dimension-38);outline:none;display:flex;align-self:center;justify-self:center}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell.-day-.-current-:not(.-disabled-,.-other-month-){border:2px solid var(--post-scheme-color-interactive-primary-enabled-stroke);z-index:2}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell.-day-.-current-:not(.-disabled-,.-other-month-).-selected-{background:var(--post-scheme-color-interactive-primary-selected-bg4);color:var(--post-scheme-color-interactive-primary-selected-fg3);border-color:var(--post-scheme-color-interactive-primary-selected-stroke1)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-days- .air-datepicker-cell.-day-.-current-:not(.-disabled-,.-other-month-).-selected-:hover{border-color:var(--post-scheme-color-interactive-primary-hover-stroke);background:var(--post-scheme-color-interactive-primary-hover-bg2);color:var(--post-scheme-color-interactive-primary-hover-fg3)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-years-{grid-template-columns:repeat(4, var(--post-core-dimension-64));grid-auto-rows:var(--post-core-dimension-40);column-gap:var(--post-device-spacing-gap-inline-8)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-years- .air-datepicker-cell.-year-{width:var(--post-core-dimension-64);height:var(--post-core-dimension-40);border-radius:var(--post-device-border-radius-round);color:var(--post-scheme-color-interactive-primary-enabled-fg1)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-years- .air-datepicker-cell.-year-.-in-range-{background-color:rgba(0,0,0,0)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-years- .air-datepicker-cell.-year-.-other-decade-{color:var(--post-scheme-color-interactive-primary-enabled-fg1)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-years- .air-datepicker-cell.-year-:not(.-disabled-){z-index:3}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-years- .air-datepicker-cell.-year-:not(.-disabled-){outline-offset:var(--post-device-spacing-padding-2) !important;outline:var(--post-scheme-color-interactive-focus-stroke) none var(--post-device-border-width-focus) !important}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-years- .air-datepicker-cell.-year-:not(.-disabled-):is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-years- .air-datepicker-cell.-year-:not(.-disabled-):is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-color:Highlight !important}}@supports not selector(:has(:focus-visible)){.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-years- .air-datepicker-cell.-year-:not(.-disabled-):is(:focus-visible,:focus-within,.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-years- .air-datepicker-cell.-year-:not(.-disabled-):is(:focus-visible,:focus-within,.pretend-focus){outline-color:Highlight !important}}}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-years- .air-datepicker-cell.-year-:hover:not(.-disabled-){color:var(--post-scheme-color-interactive-primary-hover-fg3);background:var(--post-scheme-color-interactive-primary-hover-bg2);border-color:var(--post-scheme-color-interactive-primary-hover-bg2)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-years- .air-datepicker-cell.-year-.-selected-:not(.-selected-~.-selected-){color:var(--post-scheme-color-interactive-primary-selected-fg3);background-color:var(--post-scheme-color-interactive-primary-selected-bg4);border:2px solid var(--post-scheme-color-interactive-primary-selected-stroke1)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-years- .air-datepicker-cell.-year-.-disabled-:not(.-day-.-other-decade-){user-select:none;pointer-events:none;color:var(--post-scheme-color-interactive-primary-disabled-fg1);border:2px dashed var(--post-scheme-color-interactive-primary-disabled-stroke)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-years- .air-datepicker-cell.-year-.-current-{border:2px solid var(--post-scheme-color-interactive-primary-enabled-stroke)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-years- .air-datepicker-cell.-year-.-current-:hover{border-color:var(--post-scheme-color-interactive-primary-hover-stroke);background:var(--post-scheme-color-interactive-primary-hover-bg2)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-months-{grid-template-columns:repeat(4, var(--post-core-dimension-64));padding:var(--post-device-spacing-padding-15);column-gap:var(--post-device-spacing-gap-inline-8);min-height:var(--post-core-dimension-182);text-transform:uppercase}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-months- .air-datepicker-cell.-month-{width:var(--post-core-dimension-64);height:var(--post-core-dimension-40);border-radius:var(--post-device-border-radius-round);color:var(--post-scheme-color-interactive-primary-enabled-fg1)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-months- .air-datepicker-cell.-month-.-in-range-{background-color:rgba(0,0,0,0)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-months- .air-datepicker-cell.-month-.-other-decade-{color:var(--post-scheme-color-interactive-primary-enabled-fg1)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-months- .air-datepicker-cell.-month-:not(.-disabled-){outline-offset:var(--post-device-spacing-padding-2) !important;outline:var(--post-scheme-color-interactive-focus-stroke) none var(--post-device-border-width-focus) !important}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-months- .air-datepicker-cell.-month-:not(.-disabled-):is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-months- .air-datepicker-cell.-month-:not(.-disabled-):is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-color:Highlight !important}}@supports not selector(:has(:focus-visible)){.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-months- .air-datepicker-cell.-month-:not(.-disabled-):is(:focus-visible,:focus-within,.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-months- .air-datepicker-cell.-month-:not(.-disabled-):is(:focus-visible,:focus-within,.pretend-focus){outline-color:Highlight !important}}}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-months- .air-datepicker-cell.-month-:hover:not(.-disabled-){color:var(--post-scheme-color-interactive-primary-hover-fg3);border-color:var(--post-scheme-color-interactive-primary-hover-bg2)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-months- .air-datepicker-cell.-month-:hover:not(.-disabled-):not(.-current-){background:var(--post-scheme-color-interactive-primary-hover-bg2)}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-months- .air-datepicker-cell.-month-:hover:not(.-disabled-):not(.-current-){background-color:ButtonFace;color:ButtonText}}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-months- .air-datepicker-cell.-month-.-selected-:not(.-selected-~.-selected-){color:var(--post-scheme-color-interactive-primary-selected-fg3);background-color:var(--post-scheme-color-interactive-primary-selected-bg4);border:2px solid var(--post-scheme-color-interactive-primary-selected-stroke1)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-months- .air-datepicker-cell.-month-.-disabled-{user-select:none;pointer-events:none;color:var(--post-scheme-color-interactive-primary-disabled-fg1);border:2px dashed var(--post-scheme-color-interactive-primary-disabled-stroke)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-months- .air-datepicker-cell.-month-.-current-{border:2px solid var(--post-scheme-color-interactive-primary-enabled-stroke)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells.-months- .air-datepicker-cell.-month-.-current-:hover{border-color:var(--post-scheme-color-interactive-primary-hover-stroke);color:var(--post-scheme-color-interactive-primary-hover-fg1)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell{z-index:1;position:relative;display:flex;justify-content:center;align-items:center;flex-shrink:0;flex-direction:column;color:var(--post-scheme-color-interactive-primary-enabled-fg1)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell.-focus-:hover{background:none}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-{position:relative}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-::before,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-::after,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-::before,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-::after,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-::before,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-::after{content:"";position:absolute;display:block;width:var(--post-core-dimension-40);height:var(--post-core-dimension-40)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-::before,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-::before,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-::before{z-index:-2}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-:hover:not(.-current-,.-disabled-),.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-:hover:not(.-current-,.-disabled-),.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-:hover:not(.-current-,.-disabled-){color:var(--post-scheme-color-interactive-primary-hover-fg3)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-:hover:not(.-current-,.-disabled-)::after,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-:hover:not(.-current-,.-disabled-)::after,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-:hover:not(.-current-,.-disabled-)::after{z-index:-1;background:var(--post-scheme-color-interactive-primary-hover-bg2);border-radius:var(--post-device-border-radius-round);border-color:var(--post-scheme-color-interactive-primary-hover-bg2)}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-:hover:not(.-current-,.-disabled-)::after,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-:hover:not(.-current-,.-disabled-)::after,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-:hover:not(.-current-,.-disabled-)::after{border:none}}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-.-current-:not(.-disabled-,.-other-month-):hover,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-.-current-:not(.-disabled-,.-other-month-):hover,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-.-current-:not(.-disabled-,.-other-month-):hover{color:var(--post-scheme-color-interactive-primary-hover-fg3)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-.-current-:not(.-disabled-,.-other-month-)::after,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-.-current-:not(.-disabled-,.-other-month-)::after,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-.-current-:not(.-disabled-,.-other-month-)::after{z-index:-1;border:var(--post-device-border-width-default) solid var(--post-scheme-color-interactive-primary-selected-stroke1);border-radius:var(--post-device-border-radius-round);color:var(--post-scheme-color-interactive-primary-selected-fg3)}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-.-current-:not(.-disabled-,.-other-month-)::after,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-.-current-:not(.-disabled-,.-other-month-)::after,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-.-current-:not(.-disabled-,.-other-month-)::after{forced-color-adjust:none;border-color:Highlight}}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-.-current-:hover::after,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-.-current-:hover::after,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-.-current-:hover::after{border-color:var(--post-scheme-color-interactive-primary-hover-stroke);color:var(--post-scheme-color-interactive-primary-hover-fg3);background:var(--post-scheme-color-interactive-primary-hover-bg2)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-{background-color:rgba(0,0,0,0)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-:not(.-disabled-){outline-offset:var(--post-device-spacing-padding-2) !important;outline:var(--post-scheme-color-interactive-focus-stroke) none var(--post-device-border-width-focus) !important}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-:not(.-disabled-):is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-style:var(--post-core-border-style-solid) !important;z-index:3}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-:not(.-disabled-):is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-color:Highlight !important}}@supports not selector(:has(:focus-visible)){.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-:not(.-disabled-):is(:focus-visible,:focus-within,.pretend-focus){outline-style:var(--post-core-border-style-solid) !important;z-index:3}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-:not(.-disabled-):is(:focus-visible,:focus-within,.pretend-focus){outline-color:Highlight !important}}}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-:not(.-disabled-):hover::after{background-color:ButtonFace;color:ButtonText}}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-:not(.-other-month-)::before{z-index:-2;background:var(--post-scheme-color-interactive-primary-selected-bg3);border-block:var(--post-device-border-width-default) solid var(--post-scheme-color-interactive-primary-selected-stroke1)}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-:not(.-other-month-)::before{forced-color-adjust:none}}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-.-disabled-:not(.-other-month-){color:var(--post-scheme-color-interactive-primary-disabled-fg1) !important}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-.-disabled-:not(.-other-month-)::after{z-index:-1;background:var(--post-scheme-color-surface-accent1-bg);border-radius:var(--post-device-border-radius-round);border:2px dashed var(--post-scheme-color-interactive-primary-disabled-stroke);color:var(--post-scheme-color-interactive-primary-disabled-fg1) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-in-range-.-disabled-:not(.-other-month-)::after{forced-color-adjust:none}}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-:not(.-other-month-).-selected-:not(.-disabled-):hover,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-:not(.-other-month-).-selected-:not(.-disabled-):hover{border:none}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-:not(.-other-month-):not(.-disabled-)::before,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-:not(.-other-month-):not(.-disabled-)::before{background:var(--post-scheme-color-interactive-primary-selected-bg3);border-block:var(--post-device-border-width-default) solid var(--post-scheme-color-interactive-primary-selected-stroke1)}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-:not(.-other-month-):not(.-disabled-)::before,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-:not(.-other-month-):not(.-disabled-)::before{forced-color-adjust:none}}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-:not(.-other-month-):not(.-disabled-).-selected-::after,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-:not(.-other-month-):not(.-disabled-).-selected-::after{z-index:-1;border-radius:var(--post-device-border-radius-round);background:var(--post-scheme-color-interactive-primary-selected-bg4)}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-:not(.-other-month-):not(.-disabled-).-selected-::after,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-:not(.-other-month-):not(.-disabled-).-selected-::after{background-color:Highlight;color:HighlightText}}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-:not(.-other-month-):not(.-disabled-):hover,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-:not(.-other-month-):not(.-disabled-):hover{color:var(--post-scheme-color-interactive-primary-hover-fg3)}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-:not(.-other-month-):not(.-disabled-):hover::before,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-:not(.-other-month-):not(.-disabled-):hover::before{forced-color-adjust:none}}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-:not(.-other-month-):not(.-disabled-):hover::after,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-:not(.-other-month-):not(.-disabled-):hover::after{z-index:-1;background:var(--post-scheme-color-interactive-primary-hover-bg2);border-color:var(--post-scheme-color-interactive-primary-hover-bg2)}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-:not(.-other-month-):not(.-disabled-):hover::after,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-:not(.-other-month-):not(.-disabled-):hover::after{background-color:Highlight;color:HighlightText}}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-:not(.-other-month-,.-disabled-):hover::before,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-:not(.-other-month-,.-disabled-).-selected-::before{right:-1px;width:50%;background:linear-gradient(to right, transparent 50%, var(--post-scheme-color-interactive-primary-selected-bg3) 50%);border-image:var(--post-device-border-width-default) solid var(--post-scheme-color-interactive-primary-selected-stroke1)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-:not(.-other-month-,.-disabled-):hover::before,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-from-:not(.-other-month-,.-disabled-).-selected-.-current-::before{right:-2px}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-:not(.-other-month-,.-disabled-):hover::before,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-:not(.-other-month-,.-disabled-).-selected-::before{left:-1px;width:50%;background:linear-gradient(to right, var(--post-scheme-color-interactive-primary-selected-bg3) 50%, transparent 50%);border-image:var(--post-device-border-width-default) solid var(--post-scheme-color-interactive-primary-selected-stroke1)}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-:not(.-other-month-,.-disabled-):hover::before,.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-:not(.-other-month-,.-disabled-).-selected-.-current-::before{left:-2px}.air-datepicker .air-datepicker--content .air-datepicker-body--cells .air-datepicker-cell:not(.-year-,.-month-).-range-to-.-range-from-:hover::before{background:none;border:none}.calendar-input,.calendar-input-range{position:relative}.calendar-input button,.calendar-input-range button{z-index:1;padding:0;position:absolute;transform:translateY(-50%);background:none;border:0;display:flex;align-items:center;justify-content:center;border-radius:var(--post-device-border-radius-focus);transition:opacity .2s ease,visibility .2s ease,fill .2s ease;right:var(--post-core-dimension-14);top:calc(var(--post-device-sizing-interactive-button-height-6) / 2);-webkit-appearance:none;appearance:none;color:var(--post-scheme-color-interactive-primary-enabled-fg1);outline-offset:4px;right:var(--post-core-dimension-14)}.calendar-input button post-icon,.calendar-input-range button post-icon{width:var(--post-device-sizing-notification-1);height:var(--post-device-sizing-notification-1)}.calendar-input button:not([disabled]),.calendar-input-range button:not([disabled]){cursor:pointer}.calendar-input button:not([disabled]) :where(:hover>*) post-icon,.calendar-input-range button:not([disabled]) :where(:hover>*) post-icon{color:var(--post-scheme-color-interactive-input-hover-fg)}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.calendar-input button:not([disabled]) :where(:hover>*) post-icon,.calendar-input-range button:not([disabled]) :where(:hover>*) post-icon{color:Highlight}}.calendar-input button[disabled],.calendar-input-range button[disabled]{color:var(--post-scheme-color-interactive-primary-disabled-fg1)}:host ::slotted(input.form-control:is(.is-invalid,.is-valid):not(:disabled)){background-position:top 50% right calc( var(--post-core-dimension-14) + var(--post-device-spacing-gap-inline-8) + var(--post-device-sizing-notification-1) ) !important}`;
|
|
3780
|
+
|
|
3781
|
+
const PostDatePicker = class {
|
|
3782
|
+
constructor(hostRef) {
|
|
3783
|
+
index.registerInstance(this, hostRef);
|
|
3784
|
+
this.postUpdateDates = index.createEvent(this, "postUpdateDates");
|
|
3785
|
+
this.today = new Date();
|
|
3786
|
+
this.inputDisabled = false;
|
|
3787
|
+
/**
|
|
3788
|
+
* Whether the date picker expects a range selection or a single date selection.
|
|
3789
|
+
*
|
|
3790
|
+
*/
|
|
3791
|
+
this.range = false;
|
|
3792
|
+
/**
|
|
3793
|
+
* Whether the calendar is inline in the page (not showing in a popover when input clicked).
|
|
3794
|
+
*/
|
|
3795
|
+
this.inline = false;
|
|
3796
|
+
this.startDate = new Date();
|
|
3797
|
+
this.locale = document.documentElement.lang ;
|
|
3798
|
+
this.currentViewType = 'days';
|
|
3799
|
+
this.euFormat = true;
|
|
3800
|
+
this.skipOnSelectCount = 0;
|
|
3801
|
+
this.skipFocusOnNextRender = false;
|
|
3802
|
+
this.handleInputBlur = () => {
|
|
3803
|
+
if (this.range) {
|
|
3804
|
+
const dates = this.splitRangeDates(this.inputMask.value);
|
|
3805
|
+
const start = this.dateStrToDate(dates[0]);
|
|
3806
|
+
const end = this.dateStrToDate(dates[1]);
|
|
3807
|
+
const startValid = this.isValidDate(start);
|
|
3808
|
+
const endValid = this.isValidDate(end);
|
|
3809
|
+
if (startValid && endValid) {
|
|
3810
|
+
// Check if user entered dates in wrong order
|
|
3811
|
+
const reversed = start > end;
|
|
3812
|
+
this.skipOnSelectCount = reversed ? 0 : 2; // don't skip if reversed
|
|
3813
|
+
this.dpInstance.selectDate([start, end]);
|
|
3814
|
+
this.dpInstance.setViewDate(start);
|
|
3815
|
+
}
|
|
3816
|
+
else if (startValid && !endValid) {
|
|
3817
|
+
this.dpInstance.clear();
|
|
3818
|
+
this.dpInstance.selectDate(start);
|
|
3819
|
+
this.dpInstance.setViewDate(start);
|
|
3820
|
+
}
|
|
3821
|
+
else {
|
|
3822
|
+
this.resetSelection();
|
|
3823
|
+
}
|
|
3824
|
+
}
|
|
3825
|
+
else {
|
|
3826
|
+
const date = this.dateStrToDate(this.inputMask.value);
|
|
3827
|
+
if (this.isValidDate(date)) {
|
|
3828
|
+
this.skipOnSelectCount = 1;
|
|
3829
|
+
this.dpInstance.selectDate(date);
|
|
3830
|
+
this.dpInstance.setViewDate(date);
|
|
3831
|
+
}
|
|
3832
|
+
else {
|
|
3833
|
+
this.resetSelection();
|
|
3834
|
+
}
|
|
3835
|
+
}
|
|
3836
|
+
};
|
|
3837
|
+
this.handlePrevNextClick = () => {
|
|
3838
|
+
this.skipFocusOnNextRender = true;
|
|
3839
|
+
};
|
|
3840
|
+
/**
|
|
3841
|
+
* Loop through the date picker when not in inline mode
|
|
3842
|
+
*/
|
|
3843
|
+
this.handleTab = (e) => {
|
|
3844
|
+
if (this.inline || (e.key !== 'Tab' && e.key !== 'Escape'))
|
|
3845
|
+
return;
|
|
3846
|
+
// Focus on the input when escaping the calendar
|
|
3847
|
+
if (e.key === 'Escape') {
|
|
3848
|
+
this.dpInput.focus();
|
|
3849
|
+
}
|
|
3850
|
+
const active = this.host.shadowRoot.activeElement;
|
|
3851
|
+
if (active === this.titleBtn && e.shiftKey) {
|
|
3852
|
+
e.preventDefault();
|
|
3853
|
+
const activeCell = this.getCells().find(c => c.tabIndex === 0);
|
|
3854
|
+
if (activeCell) {
|
|
3855
|
+
activeCell.focus();
|
|
3856
|
+
}
|
|
3857
|
+
}
|
|
3858
|
+
if (active?.getAttribute('role') === 'gridcell' && !e.shiftKey) {
|
|
3859
|
+
e.preventDefault();
|
|
3860
|
+
if (this.currentViewType === 'years') {
|
|
3861
|
+
this.prevBtn.focus();
|
|
3862
|
+
}
|
|
3863
|
+
else {
|
|
3864
|
+
this.titleBtn.focus();
|
|
3865
|
+
}
|
|
3866
|
+
}
|
|
3867
|
+
};
|
|
3868
|
+
/**
|
|
3869
|
+
* Handle keyboard/arrow navigation within the grid
|
|
3870
|
+
*/
|
|
3871
|
+
this.handleGridKeydown = (e) => {
|
|
3872
|
+
const key = e.key;
|
|
3873
|
+
const current = this.startDate;
|
|
3874
|
+
if (!current)
|
|
3875
|
+
return;
|
|
3876
|
+
// If user clicks ENTER or Space, trigger click on the cell
|
|
3877
|
+
if (key === 'Enter' || key === ' ') {
|
|
3878
|
+
e.preventDefault();
|
|
3879
|
+
const activeCell = this.getCells().find(c => c.tabIndex === 0);
|
|
3880
|
+
if (activeCell) {
|
|
3881
|
+
activeCell.click();
|
|
3882
|
+
}
|
|
3883
|
+
return;
|
|
3884
|
+
}
|
|
3885
|
+
const newDate = new Date(current);
|
|
3886
|
+
const move = {
|
|
3887
|
+
ArrowLeft: {
|
|
3888
|
+
days: () => newDate.setDate(current.getDate() - 1),
|
|
3889
|
+
months: () => newDate.setMonth(current.getMonth() - 1),
|
|
3890
|
+
years: () => newDate.setFullYear(current.getFullYear() - 1),
|
|
3891
|
+
},
|
|
3892
|
+
ArrowRight: {
|
|
3893
|
+
days: () => newDate.setDate(current.getDate() + 1),
|
|
3894
|
+
months: () => newDate.setMonth(current.getMonth() + 1),
|
|
3895
|
+
years: () => newDate.setFullYear(current.getFullYear() + 1),
|
|
3896
|
+
},
|
|
3897
|
+
// Move up on line
|
|
3898
|
+
ArrowUp: {
|
|
3899
|
+
days: () => newDate.setDate(current.getDate() - 7),
|
|
3900
|
+
months: () => newDate.setMonth(current.getMonth() - 4),
|
|
3901
|
+
years: () => newDate.setFullYear(current.getFullYear() - 4),
|
|
3902
|
+
},
|
|
3903
|
+
// Move down one line
|
|
3904
|
+
ArrowDown: {
|
|
3905
|
+
days: () => newDate.setDate(current.getDate() + 7),
|
|
3906
|
+
months: () => newDate.setMonth(current.getMonth() + 4),
|
|
3907
|
+
years: () => newDate.setFullYear(current.getFullYear() + 4),
|
|
3908
|
+
},
|
|
3909
|
+
// Go to the first element
|
|
3910
|
+
Home: {
|
|
3911
|
+
days: () => newDate.setDate(1),
|
|
3912
|
+
months: () => newDate.setMonth(0),
|
|
3913
|
+
years: () => newDate.setFullYear(current.getFullYear() - (current.getFullYear() % 10)),
|
|
3914
|
+
},
|
|
3915
|
+
// Go to the last element
|
|
3916
|
+
End: {
|
|
3917
|
+
days: () => newDate.setMonth(current.getMonth() + 1, 0),
|
|
3918
|
+
months: () => newDate.setMonth(11),
|
|
3919
|
+
years: () => newDate.setFullYear(current.getFullYear() - (current.getFullYear() % 10) + 9),
|
|
3920
|
+
},
|
|
3921
|
+
// Go to the previous month/year/decade
|
|
3922
|
+
PageUp: {
|
|
3923
|
+
days: () => newDate.setMonth(current.getMonth() - 1),
|
|
3924
|
+
months: () => newDate.setFullYear(current.getFullYear() - 1),
|
|
3925
|
+
years: () => newDate.setFullYear(current.getFullYear() - 10),
|
|
3926
|
+
},
|
|
3927
|
+
// Go to the next month/year/decade
|
|
3928
|
+
PageDown: {
|
|
3929
|
+
days: () => newDate.setMonth(current.getMonth() + 1),
|
|
3930
|
+
months: () => newDate.setFullYear(current.getFullYear() + 1),
|
|
3931
|
+
years: () => newDate.setFullYear(current.getFullYear() + 10),
|
|
3932
|
+
},
|
|
3933
|
+
};
|
|
3934
|
+
if (!move[key] || !move[key][this.currentViewType])
|
|
3935
|
+
return;
|
|
3936
|
+
e.preventDefault();
|
|
3937
|
+
move[key][this.currentViewType]();
|
|
3938
|
+
// If month has changed, update view date
|
|
3939
|
+
const monthChanged = current.getMonth() !== newDate.getMonth() || current.getFullYear() !== newDate.getFullYear();
|
|
3940
|
+
if (monthChanged) {
|
|
3941
|
+
this.skipFocusOnNextRender = false;
|
|
3942
|
+
this.dpInstance.setViewDate(newDate);
|
|
3943
|
+
requestAnimationFrame(() => {
|
|
3944
|
+
this.setActiveCell(newDate, true);
|
|
3945
|
+
});
|
|
3946
|
+
}
|
|
3947
|
+
else {
|
|
3948
|
+
this.setActiveCell(newDate, true);
|
|
3949
|
+
}
|
|
3950
|
+
};
|
|
3951
|
+
// Skip the month view and go directly to year selection
|
|
3952
|
+
this.forceTitleClickToYear = () => {
|
|
3953
|
+
if (this.dpInstance) {
|
|
3954
|
+
this.dpInstance.setCurrentView('years');
|
|
3955
|
+
}
|
|
3956
|
+
};
|
|
3957
|
+
}
|
|
3958
|
+
validateSelectedStartDate() {
|
|
3959
|
+
index$1.checkEmptyOrDate(this, 'selectedStartDate');
|
|
3960
|
+
checkIsoDate(this, 'selectedStartDate');
|
|
3961
|
+
}
|
|
3962
|
+
validateSelectedEndDate() {
|
|
3963
|
+
index$1.checkEmptyOrDate(this, 'selectedEndDate');
|
|
3964
|
+
checkIsoDate(this, 'selectedEndDate');
|
|
3965
|
+
}
|
|
3966
|
+
validateMin() {
|
|
3967
|
+
index$1.checkEmptyOrDate(this, 'min');
|
|
3968
|
+
checkIsoDate(this, 'min');
|
|
3969
|
+
}
|
|
3970
|
+
validateMax() {
|
|
3971
|
+
index$1.checkEmptyOrDate(this, 'max');
|
|
3972
|
+
checkIsoDate(this, 'max');
|
|
3973
|
+
}
|
|
3974
|
+
validateInline() {
|
|
3975
|
+
if (!this.inline && !this.dpInput) {
|
|
3976
|
+
console.error('A non-inline date picker should contain one input');
|
|
3977
|
+
}
|
|
3978
|
+
}
|
|
3979
|
+
validateTextNextMonth() {
|
|
3980
|
+
index$1.checkRequiredAndType(this, 'textNextMonth', 'string');
|
|
3981
|
+
}
|
|
3982
|
+
validateTextNextYear() {
|
|
3983
|
+
index$1.checkRequiredAndType(this, 'textNextYear', 'string');
|
|
3984
|
+
}
|
|
3985
|
+
validateTextNextDecade() {
|
|
3986
|
+
index$1.checkRequiredAndType(this, 'textNextDecade', 'string');
|
|
3987
|
+
}
|
|
3988
|
+
validateTextPreviousMonth() {
|
|
3989
|
+
index$1.checkRequiredAndType(this, 'textPreviousMonth', 'string');
|
|
3990
|
+
}
|
|
3991
|
+
validateTextPreviousYear() {
|
|
3992
|
+
index$1.checkRequiredAndType(this, 'textPreviousYear', 'string');
|
|
3993
|
+
}
|
|
3994
|
+
validateTextPreviousDecade() {
|
|
3995
|
+
index$1.checkRequiredAndType(this, 'textPreviousDecade', 'string');
|
|
3996
|
+
}
|
|
3997
|
+
validateTextSwitchYear() {
|
|
3998
|
+
index$1.checkRequiredAndType(this, 'textSwitchYear', 'string');
|
|
3999
|
+
}
|
|
4000
|
+
validateTextToggleCalendar() {
|
|
4001
|
+
if (!this.inline) {
|
|
4002
|
+
index$1.checkRequiredAndType(this, 'textToggleCalendar', 'string');
|
|
4003
|
+
}
|
|
4004
|
+
}
|
|
4005
|
+
/**
|
|
4006
|
+
* Displays the popover calendar, focusing the first calendar item.
|
|
4007
|
+
*/
|
|
4008
|
+
async show() {
|
|
4009
|
+
if (this.popoverRef) {
|
|
4010
|
+
await this.popoverRef.show(this.dpInput);
|
|
4011
|
+
this.enhanceAccessibility();
|
|
4012
|
+
this.host.shadowRoot.removeEventListener('keydown', this.handleTab, true); // remove before adding
|
|
4013
|
+
this.host.shadowRoot.addEventListener('keydown', this.handleTab, true);
|
|
4014
|
+
}
|
|
4015
|
+
else {
|
|
4016
|
+
console.error('show: popoverRef is null or undefined');
|
|
4017
|
+
}
|
|
4018
|
+
}
|
|
4019
|
+
/**
|
|
4020
|
+
* Hides the popover calendar.
|
|
4021
|
+
*/
|
|
4022
|
+
async hide() {
|
|
4023
|
+
if (this.popoverRef) {
|
|
4024
|
+
await this.popoverRef.hide();
|
|
4025
|
+
}
|
|
4026
|
+
else {
|
|
4027
|
+
console.error('hide: popoverRef is null or undefined');
|
|
4028
|
+
}
|
|
4029
|
+
}
|
|
4030
|
+
setupInputObserver() {
|
|
4031
|
+
if (typeof MutationObserver === 'undefined')
|
|
4032
|
+
return;
|
|
4033
|
+
if (!this.dpInput)
|
|
4034
|
+
return;
|
|
4035
|
+
if (this.inputObserver) {
|
|
4036
|
+
this.inputObserver.disconnect();
|
|
4037
|
+
}
|
|
4038
|
+
this.inputObserver = new MutationObserver(() => {
|
|
4039
|
+
this.syncDatePickerState();
|
|
4040
|
+
});
|
|
4041
|
+
this.inputObserver.observe(this.dpInput, {
|
|
4042
|
+
attributes: true,
|
|
4043
|
+
attributeFilter: ['disabled'],
|
|
4044
|
+
});
|
|
4045
|
+
}
|
|
4046
|
+
/**
|
|
4047
|
+
* Get all the active cells of the calendar
|
|
4048
|
+
*/
|
|
4049
|
+
getCells() {
|
|
4050
|
+
if (!this.dpContainer)
|
|
4051
|
+
return [];
|
|
4052
|
+
let selector = '';
|
|
4053
|
+
switch (this.currentViewType) {
|
|
4054
|
+
case 'days':
|
|
4055
|
+
selector = '.air-datepicker-cell.-day-';
|
|
4056
|
+
break;
|
|
4057
|
+
case 'months':
|
|
4058
|
+
selector = '.air-datepicker-cell.-month-';
|
|
4059
|
+
break;
|
|
4060
|
+
case 'years':
|
|
4061
|
+
selector = '.air-datepicker-cell.-year-';
|
|
4062
|
+
break;
|
|
4063
|
+
}
|
|
4064
|
+
return Array.from(this.dpContainer.querySelectorAll(selector));
|
|
4065
|
+
}
|
|
4066
|
+
setActiveCell(date, focusOnDate = true) {
|
|
4067
|
+
const cells = this.getCells();
|
|
4068
|
+
if (cells.length === 0)
|
|
4069
|
+
return;
|
|
4070
|
+
let target;
|
|
4071
|
+
// If selected date is visible
|
|
4072
|
+
if (this.currentViewType === 'days') {
|
|
4073
|
+
target = cells.find(cell => Number(cell.dataset.date) === date.getDate() &&
|
|
4074
|
+
Number(cell.dataset.month) === date.getMonth() &&
|
|
4075
|
+
Number(cell.dataset.year) === date.getFullYear());
|
|
4076
|
+
if (!target) {
|
|
4077
|
+
const firstOfMonth = new Date(this.currentViewYear, this.currentViewMonth, 1);
|
|
4078
|
+
target = cells.find(cell => Number(cell.dataset.date) === 1 &&
|
|
4079
|
+
Number(cell.dataset.month) === firstOfMonth.getMonth() &&
|
|
4080
|
+
Number(cell.dataset.year) === firstOfMonth.getFullYear() &&
|
|
4081
|
+
!cell.classList.contains('-other-month-'));
|
|
4082
|
+
}
|
|
4083
|
+
}
|
|
4084
|
+
else if (this.currentViewType === 'months') {
|
|
4085
|
+
target = cells.find(cell => Number(cell.dataset.month) === date.getMonth() &&
|
|
4086
|
+
Number(cell.dataset.year) === date.getFullYear());
|
|
4087
|
+
if (!target) {
|
|
4088
|
+
target = cells.find(cell => !cell.classList.contains('-other-year-'));
|
|
4089
|
+
}
|
|
4090
|
+
}
|
|
4091
|
+
else {
|
|
4092
|
+
target = cells.find(cell => Number(cell.dataset.year) === date.getFullYear());
|
|
4093
|
+
if (!target) {
|
|
4094
|
+
target = cells.find(cell => !cell.classList.contains('-other-decade-'));
|
|
4095
|
+
}
|
|
4096
|
+
}
|
|
4097
|
+
// fallback
|
|
4098
|
+
if (!target) {
|
|
4099
|
+
target = cells.at(-1);
|
|
4100
|
+
}
|
|
4101
|
+
// Make only the target focusable
|
|
4102
|
+
cells.forEach(c => (c.tabIndex = -1));
|
|
4103
|
+
target.tabIndex = 0;
|
|
4104
|
+
if (focusOnDate) {
|
|
4105
|
+
target.focus();
|
|
4106
|
+
}
|
|
4107
|
+
// Update start date to match the active cell
|
|
4108
|
+
this.startDate = new Date(Number(target.dataset.year), Number(target.dataset.month), Number(target.dataset.date));
|
|
4109
|
+
}
|
|
4110
|
+
/**
|
|
4111
|
+
* Move title before the previous button in the DOM
|
|
4112
|
+
*/
|
|
4113
|
+
reorderNavigation() {
|
|
4114
|
+
const nav = this.dpContainer?.querySelector('.air-datepicker-nav');
|
|
4115
|
+
if (!nav)
|
|
4116
|
+
return;
|
|
4117
|
+
const prev = this.host.shadowRoot.querySelector('[data-action="prev"]');
|
|
4118
|
+
const title = this.host.shadowRoot.querySelector('.air-datepicker-nav--title');
|
|
4119
|
+
if (prev && title) {
|
|
4120
|
+
nav.insertBefore(title, prev);
|
|
4121
|
+
}
|
|
4122
|
+
}
|
|
4123
|
+
get prevBtn() {
|
|
4124
|
+
return this.host.shadowRoot.querySelector('[data-action="prev"] button');
|
|
4125
|
+
}
|
|
4126
|
+
get nextBtn() {
|
|
4127
|
+
return this.host.shadowRoot.querySelector('[data-action="next"] button');
|
|
4128
|
+
}
|
|
4129
|
+
get titleBtn() {
|
|
4130
|
+
return this.host.shadowRoot.querySelector('.air-datepicker-nav--title button');
|
|
4131
|
+
}
|
|
4132
|
+
/**
|
|
4133
|
+
* Update previous and next button labels based on the current calendar view
|
|
4134
|
+
*/
|
|
4135
|
+
updateNavigationButtonLabels() {
|
|
4136
|
+
if (this.currentViewType === 'months') {
|
|
4137
|
+
this.prevBtn?.setAttribute('aria-label', this.textPreviousYear);
|
|
4138
|
+
this.nextBtn?.setAttribute('aria-label', this.textNextYear);
|
|
4139
|
+
}
|
|
4140
|
+
else if (this.currentViewType === 'years') {
|
|
4141
|
+
this.prevBtn?.setAttribute('aria-label', this.textPreviousDecade);
|
|
4142
|
+
this.nextBtn?.setAttribute('aria-label', this.textNextDecade);
|
|
4143
|
+
}
|
|
4144
|
+
else {
|
|
4145
|
+
this.prevBtn?.setAttribute('aria-label', this.textPreviousMonth);
|
|
4146
|
+
this.nextBtn?.setAttribute('aria-label', this.textNextMonth);
|
|
4147
|
+
}
|
|
4148
|
+
}
|
|
4149
|
+
enhanceAccessibility(focusOnDate = true) {
|
|
4150
|
+
let body = this.dpContainer.querySelector('.air-datepicker-body--cells');
|
|
4151
|
+
if (this.currentViewType === 'months') {
|
|
4152
|
+
body = this.dpContainer.querySelector('.air-datepicker-body--cells.-months-');
|
|
4153
|
+
}
|
|
4154
|
+
else if (this.currentViewType === 'years') {
|
|
4155
|
+
body = this.dpContainer.querySelector('.air-datepicker-body--cells.-years-');
|
|
4156
|
+
}
|
|
4157
|
+
if (!body)
|
|
4158
|
+
return;
|
|
4159
|
+
body.setAttribute('role', 'grid');
|
|
4160
|
+
this.getCells().forEach(c => {
|
|
4161
|
+
c.setAttribute('aria-selected', c.classList.contains('-selected-') ? 'true' : 'false');
|
|
4162
|
+
if (c.classList.contains('-current-')) {
|
|
4163
|
+
c.setAttribute('aria-current', 'date');
|
|
4164
|
+
}
|
|
4165
|
+
});
|
|
4166
|
+
body.removeEventListener('keydown', this.handleGridKeydown);
|
|
4167
|
+
body.addEventListener('keydown', this.handleGridKeydown);
|
|
4168
|
+
this.setActiveCell(this.isoToDate(this.selectedStartDate) || this.today, focusOnDate);
|
|
4169
|
+
}
|
|
4170
|
+
/**
|
|
4171
|
+
* Set up the masks on the inputs to reflect the date pickers
|
|
4172
|
+
*/
|
|
4173
|
+
setUpMask() {
|
|
4174
|
+
const usBlockOpts = {
|
|
4175
|
+
pattern: 'm{/}`d{/}`Y',
|
|
4176
|
+
format: (date) => {
|
|
4177
|
+
if (!date)
|
|
4178
|
+
return '';
|
|
4179
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
4180
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
4181
|
+
const year = date.getFullYear();
|
|
4182
|
+
return [month, day, year].join('/');
|
|
4183
|
+
},
|
|
4184
|
+
parse: (str) => {
|
|
4185
|
+
const [month, day, year] = str.split('/').map(Number);
|
|
4186
|
+
return new Date(year, month - 1, day);
|
|
4187
|
+
},
|
|
4188
|
+
};
|
|
4189
|
+
const baseDateOpts = {
|
|
4190
|
+
mask: Date,
|
|
4191
|
+
min: this.min ? new Date(this.min) : null,
|
|
4192
|
+
max: this.max ? new Date(this.max) : null,
|
|
4193
|
+
};
|
|
4194
|
+
if (this.range) {
|
|
4195
|
+
const baseRangeOpts = {
|
|
4196
|
+
mask: 'from - to',
|
|
4197
|
+
lazy: false,
|
|
4198
|
+
overwrite: true,
|
|
4199
|
+
};
|
|
4200
|
+
if (this.euFormat) {
|
|
4201
|
+
const options = {
|
|
4202
|
+
...baseRangeOpts,
|
|
4203
|
+
blocks: { from: baseDateOpts, to: baseDateOpts },
|
|
4204
|
+
};
|
|
4205
|
+
this.inputMask = IMask(this.dpInput, options);
|
|
4206
|
+
}
|
|
4207
|
+
else {
|
|
4208
|
+
const options = {
|
|
4209
|
+
...baseRangeOpts,
|
|
4210
|
+
blocks: {
|
|
4211
|
+
from: { ...baseDateOpts, ...usBlockOpts },
|
|
4212
|
+
to: { ...baseDateOpts, ...usBlockOpts },
|
|
4213
|
+
},
|
|
4214
|
+
};
|
|
4215
|
+
this.inputMask = IMask(this.dpInput, options);
|
|
4216
|
+
}
|
|
4217
|
+
}
|
|
4218
|
+
else {
|
|
4219
|
+
const baseSingleOpts = {
|
|
4220
|
+
...baseDateOpts,
|
|
4221
|
+
lazy: false,
|
|
4222
|
+
overwrite: true,
|
|
4223
|
+
};
|
|
4224
|
+
if (this.euFormat) {
|
|
4225
|
+
const options = baseSingleOpts;
|
|
4226
|
+
this.inputMask = IMask(this.dpInput, options);
|
|
4227
|
+
}
|
|
4228
|
+
else {
|
|
4229
|
+
const options = { ...baseSingleOpts, ...usBlockOpts };
|
|
4230
|
+
this.inputMask = IMask(this.dpInput, options);
|
|
4231
|
+
}
|
|
4232
|
+
}
|
|
4233
|
+
}
|
|
4234
|
+
configDatePicker() {
|
|
4235
|
+
const slot = this.host.shadowRoot.querySelector('slot');
|
|
4236
|
+
const assignedNodes = slot && slot.assignedElements();
|
|
4237
|
+
const locale = localesMap[this.locale] || localesMap.en;
|
|
4238
|
+
if (!this.inline) {
|
|
4239
|
+
this.dpInput = assignedNodes?.find(el => el.tagName === 'INPUT');
|
|
4240
|
+
this.setUpMask();
|
|
4241
|
+
}
|
|
4242
|
+
this.dpContainer = this.host.shadowRoot.querySelector('.datepicker-container');
|
|
4243
|
+
if (this.dpContainer) {
|
|
4244
|
+
const options = {
|
|
4245
|
+
navTitles: {
|
|
4246
|
+
days: `<button aria-label="${this.textSwitchYear}"><strong>MMMM yyyy</strong><post-icon name="chevrondown"></post-icon></button>`,
|
|
4247
|
+
months: `<button aria-label="${this.textSwitchYear}"><strong>yyyy</strong><post-icon name="chevrondown"></post-icon></button>`,
|
|
4248
|
+
},
|
|
4249
|
+
prevHtml: '<button><post-icon name="chevronleft" ></post-icon></button>',
|
|
4250
|
+
nextHtml: '<button><post-icon name="chevronright" ></post-icon></button>',
|
|
4251
|
+
range: this.range,
|
|
4252
|
+
inline: true,
|
|
4253
|
+
autoClose: true,
|
|
4254
|
+
showOtherYears: true,
|
|
4255
|
+
selectOtherYears: true,
|
|
4256
|
+
showOtherMonths: false,
|
|
4257
|
+
moveToOtherMonthsOnSelect: true,
|
|
4258
|
+
firstDay: 1,
|
|
4259
|
+
startDate: this.startDate,
|
|
4260
|
+
minDate: this.min,
|
|
4261
|
+
maxDate: this.max,
|
|
4262
|
+
locale: locale,
|
|
4263
|
+
dateFormat: (localesMap[this.locale] || localesMap.en).dateFormat,
|
|
4264
|
+
view: 'days',
|
|
4265
|
+
onChangeView: view => {
|
|
4266
|
+
this.currentViewType = view;
|
|
4267
|
+
requestAnimationFrame(() => {
|
|
4268
|
+
this.enhanceAccessibility();
|
|
4269
|
+
});
|
|
4270
|
+
},
|
|
4271
|
+
onChangeViewDate: ({ month, year }) => {
|
|
4272
|
+
this.currentViewYear = year;
|
|
4273
|
+
this.currentViewMonth = month;
|
|
4274
|
+
this.updateNavigationButtonLabels();
|
|
4275
|
+
},
|
|
4276
|
+
onSelect: ({ date }) => {
|
|
4277
|
+
if (!date || (Array.isArray(date) && date.length === 0))
|
|
4278
|
+
return;
|
|
4279
|
+
this.getCells().forEach(c => {
|
|
4280
|
+
c.setAttribute('aria-selected', c.classList.contains('-selected-') ? 'true' : 'false');
|
|
4281
|
+
});
|
|
4282
|
+
// If selected date is added dynamically after user has typed it in the input
|
|
4283
|
+
if (this.skipOnSelectCount > 0) {
|
|
4284
|
+
this.skipOnSelectCount--;
|
|
4285
|
+
return;
|
|
4286
|
+
}
|
|
4287
|
+
// update props
|
|
4288
|
+
if (Array.isArray(date) && date.length === 2) {
|
|
4289
|
+
this.selectedStartDate = this.dateToIso(date[0]);
|
|
4290
|
+
this.selectedEndDate = this.dateToIso(date[1]);
|
|
4291
|
+
}
|
|
4292
|
+
else if (!Array.isArray(date)) {
|
|
4293
|
+
this.selectedStartDate = this.dateToIso(date);
|
|
4294
|
+
this.selectedEndDate = undefined;
|
|
4295
|
+
}
|
|
4296
|
+
this.postUpdateDates.emit(Array.isArray(date) ? date.map(d => this.dateToIso(d)) : this.dateToIso(date));
|
|
4297
|
+
// Assign value to the input, close the popover and focus on the input
|
|
4298
|
+
if (this.dpInput) {
|
|
4299
|
+
if (Array.isArray(date)) {
|
|
4300
|
+
const dates = date.map(d => this.dateToDateStr(d));
|
|
4301
|
+
this.inputMask.value = dates.join(' - ');
|
|
4302
|
+
this.updateInputValue();
|
|
4303
|
+
}
|
|
4304
|
+
else if (date) {
|
|
4305
|
+
// If there is a date, set it to the input. No date = same date as before
|
|
4306
|
+
this.inputMask.value = this.dateToDateStr(date);
|
|
4307
|
+
this.updateInputValue();
|
|
4308
|
+
}
|
|
4309
|
+
// If range & only one date has been selected, user should stay in the DP
|
|
4310
|
+
if (this.range && Array.isArray(date) && date.length === 1) {
|
|
4311
|
+
return;
|
|
4312
|
+
}
|
|
4313
|
+
this.popoverRef?.hide();
|
|
4314
|
+
requestAnimationFrame(() => this.dpInput.focus());
|
|
4315
|
+
}
|
|
4316
|
+
},
|
|
4317
|
+
onShow: () => {
|
|
4318
|
+
this.enhanceAccessibility();
|
|
4319
|
+
},
|
|
4320
|
+
onRenderCell: data => {
|
|
4321
|
+
const internal = this.internalOnRenderCell(data);
|
|
4322
|
+
const custom = this.renderCellCallback?.(data);
|
|
4323
|
+
return this.mergeRenderCellResults(internal, custom);
|
|
4324
|
+
},
|
|
4325
|
+
};
|
|
4326
|
+
this.dpInstance = new AirDatepicker(this.dpContainer, options);
|
|
4327
|
+
this.reorderNavigation();
|
|
4328
|
+
this.prevBtn?.addEventListener('click', this.handlePrevNextClick);
|
|
4329
|
+
this.nextBtn?.addEventListener('click', this.handlePrevNextClick);
|
|
4330
|
+
this.handleSelectedDates();
|
|
4331
|
+
}
|
|
4332
|
+
}
|
|
4333
|
+
updateInputValue() {
|
|
4334
|
+
this.inputMask.updateValue();
|
|
4335
|
+
// Emit the native input and change events
|
|
4336
|
+
this.dpInput.dispatchEvent(new InputEvent('input', { bubbles: true }));
|
|
4337
|
+
this.dpInput.dispatchEvent(new InputEvent('change', { bubbles: true }));
|
|
4338
|
+
}
|
|
4339
|
+
handleSelectedDates() {
|
|
4340
|
+
if (this.range) {
|
|
4341
|
+
if ((this.selectedStartDate && !this.selectedEndDate) ||
|
|
4342
|
+
(!this.selectedStartDate && this.selectedEndDate)) {
|
|
4343
|
+
console.error('The range date picker expects either no selected dates or both of them defined.');
|
|
4344
|
+
}
|
|
4345
|
+
else if (this.selectedStartDate && this.selectedEndDate) {
|
|
4346
|
+
this.dpInstance.selectDate([
|
|
4347
|
+
this.isoToDate(this.selectedStartDate),
|
|
4348
|
+
this.isoToDate(this.selectedEndDate),
|
|
4349
|
+
]);
|
|
4350
|
+
}
|
|
4351
|
+
}
|
|
4352
|
+
else {
|
|
4353
|
+
if (this.selectedStartDate && this.isoToDate(this.selectedStartDate)) {
|
|
4354
|
+
this.dpInstance.selectDate(this.isoToDate(this.selectedStartDate));
|
|
4355
|
+
}
|
|
4356
|
+
}
|
|
4357
|
+
}
|
|
4358
|
+
attachTitleBtnListener() {
|
|
4359
|
+
requestAnimationFrame(() => {
|
|
4360
|
+
if (!this.titleBtn)
|
|
4361
|
+
return;
|
|
4362
|
+
this.titleBtn.onclick = null; // remove inline handler AirDatepicker sets
|
|
4363
|
+
this.titleBtn.removeEventListener('click', this.forceTitleClickToYear);
|
|
4364
|
+
this.titleBtn.addEventListener('click', this.forceTitleClickToYear, { capture: true });
|
|
4365
|
+
});
|
|
4366
|
+
}
|
|
4367
|
+
splitRangeDates(rangeStr) {
|
|
4368
|
+
return rangeStr.split(' - ');
|
|
4369
|
+
}
|
|
4370
|
+
isoToDate(iso) {
|
|
4371
|
+
if (!isIsoDate(iso))
|
|
4372
|
+
return null;
|
|
4373
|
+
const [y, m, d] = iso.split('-').map(Number);
|
|
4374
|
+
return new Date(y, m - 1, d);
|
|
4375
|
+
}
|
|
4376
|
+
dateToIso(date) {
|
|
4377
|
+
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
|
|
4378
|
+
}
|
|
4379
|
+
dateStrToDate(dateStr) {
|
|
4380
|
+
return this.euFormat ? this.euDateStrToDate(dateStr) : this.usDateStrToDate(dateStr);
|
|
4381
|
+
}
|
|
4382
|
+
euDateStrToDate(dateStr) {
|
|
4383
|
+
const [d, m, y] = dateStr.split('.');
|
|
4384
|
+
return new Date(+y, +m - 1, +d);
|
|
4385
|
+
}
|
|
4386
|
+
usDateStrToDate(dateStr) {
|
|
4387
|
+
const [m, d, y] = dateStr.split('/');
|
|
4388
|
+
return new Date(+y, +m - 1, +d);
|
|
4389
|
+
}
|
|
4390
|
+
dateToDateStr(date) {
|
|
4391
|
+
return this.euFormat ? this.dateToEuDateStr(date) : this.dateToUSDateStr(date);
|
|
4392
|
+
}
|
|
4393
|
+
dateToEuDateStr(date) {
|
|
4394
|
+
return `${String(date.getDate()).padStart(2, '0')}.${String(date.getMonth() + 1).padStart(2, '0')}.${date.getFullYear()}`;
|
|
4395
|
+
}
|
|
4396
|
+
dateToUSDateStr(date) {
|
|
4397
|
+
return `${String(date.getMonth() + 1).padStart(2, '0')}/${String(date.getDate()).padStart(2, '0')}/${date.getFullYear()}`;
|
|
4398
|
+
}
|
|
4399
|
+
/**
|
|
4400
|
+
* Add role and aria-label to each grid cell
|
|
4401
|
+
*/
|
|
4402
|
+
internalOnRenderCell({ date, cellType }) {
|
|
4403
|
+
const safeLocale = this.locale || 'en';
|
|
4404
|
+
if (cellType === 'day') {
|
|
4405
|
+
return {
|
|
4406
|
+
attrs: {
|
|
4407
|
+
'role': 'gridcell',
|
|
4408
|
+
'aria-label': date.toLocaleDateString(safeLocale, {
|
|
4409
|
+
weekday: 'long',
|
|
4410
|
+
year: 'numeric',
|
|
4411
|
+
month: 'long',
|
|
4412
|
+
day: 'numeric',
|
|
4413
|
+
}),
|
|
4414
|
+
},
|
|
4415
|
+
};
|
|
4416
|
+
}
|
|
4417
|
+
else if (cellType === 'month') {
|
|
4418
|
+
return {
|
|
4419
|
+
attrs: {
|
|
4420
|
+
'role': 'gridcell',
|
|
4421
|
+
'aria-label': date.toLocaleDateString(safeLocale, {
|
|
4422
|
+
year: 'numeric',
|
|
4423
|
+
month: 'long',
|
|
4424
|
+
}),
|
|
4425
|
+
},
|
|
4426
|
+
};
|
|
4427
|
+
}
|
|
4428
|
+
else if (cellType === 'year') {
|
|
4429
|
+
return {
|
|
4430
|
+
attrs: {
|
|
4431
|
+
'role': 'gridcell',
|
|
4432
|
+
'aria-label': date.toLocaleDateString(safeLocale, {
|
|
4433
|
+
year: 'numeric',
|
|
4434
|
+
}),
|
|
4435
|
+
},
|
|
4436
|
+
};
|
|
4437
|
+
}
|
|
4438
|
+
}
|
|
4439
|
+
/**
|
|
4440
|
+
* Merge the internal render cell (adding of role + aria-label attributes) and the user's render cell (disabling dates, etc.)
|
|
4441
|
+
* @param base Internal render cell
|
|
4442
|
+
* @param custom User render cell
|
|
4443
|
+
* @returns Merged render cell
|
|
4444
|
+
*/
|
|
4445
|
+
mergeRenderCellResults(base, custom) {
|
|
4446
|
+
if (!base)
|
|
4447
|
+
return custom;
|
|
4448
|
+
if (!custom)
|
|
4449
|
+
return base;
|
|
4450
|
+
return {
|
|
4451
|
+
...base,
|
|
4452
|
+
...custom,
|
|
4453
|
+
attrs: {
|
|
4454
|
+
...(base.attrs ?? {}),
|
|
4455
|
+
...(custom.attrs ?? {}),
|
|
4456
|
+
},
|
|
4457
|
+
classes: [base.classes, custom.classes].filter(Boolean).join(' '),
|
|
4458
|
+
disabled: base.disabled || custom.disabled,
|
|
4459
|
+
};
|
|
4460
|
+
}
|
|
4461
|
+
setupNavObserver() {
|
|
4462
|
+
if (typeof MutationObserver === 'undefined')
|
|
4463
|
+
return;
|
|
4464
|
+
const nav = this.dpContainer.querySelector('.air-datepicker-nav');
|
|
4465
|
+
if (!nav)
|
|
4466
|
+
return;
|
|
4467
|
+
if (this.navObserver) {
|
|
4468
|
+
this.navObserver.disconnect();
|
|
4469
|
+
}
|
|
4470
|
+
this.updateNavigationButtonLabels();
|
|
4471
|
+
this.attachTitleBtnListener();
|
|
4472
|
+
this.navObserver = new MutationObserver(() => {
|
|
4473
|
+
this.updateNavigationButtonLabels();
|
|
4474
|
+
this.attachTitleBtnListener();
|
|
4475
|
+
});
|
|
4476
|
+
this.navObserver.observe(nav, {
|
|
4477
|
+
childList: true,
|
|
4478
|
+
subtree: true,
|
|
4479
|
+
});
|
|
4480
|
+
}
|
|
4481
|
+
setupGridObserver() {
|
|
4482
|
+
if (typeof MutationObserver === 'undefined')
|
|
4483
|
+
return;
|
|
4484
|
+
const grid = this.dpContainer.querySelector('.air-datepicker-body--cells');
|
|
4485
|
+
if (!grid)
|
|
4486
|
+
return;
|
|
4487
|
+
if (this.gridObserver) {
|
|
4488
|
+
this.gridObserver.disconnect();
|
|
4489
|
+
}
|
|
4490
|
+
this.gridObserver = new MutationObserver(mutations => {
|
|
4491
|
+
const changed = mutations.some(m => m.type === 'childList');
|
|
4492
|
+
if (!changed)
|
|
4493
|
+
return;
|
|
4494
|
+
// Wait for AirDatepicker to finish rendering frame
|
|
4495
|
+
requestAnimationFrame(() => {
|
|
4496
|
+
this.enhanceAccessibility(!this.skipFocusOnNextRender);
|
|
4497
|
+
this.skipFocusOnNextRender = false;
|
|
4498
|
+
});
|
|
4499
|
+
});
|
|
4500
|
+
this.gridObserver.observe(grid, {
|
|
4501
|
+
childList: true,
|
|
4502
|
+
subtree: false,
|
|
4503
|
+
});
|
|
4504
|
+
}
|
|
4505
|
+
addInputListener() {
|
|
4506
|
+
this.dpInput.addEventListener('blur', this.handleInputBlur);
|
|
4507
|
+
}
|
|
4508
|
+
resetSelection() {
|
|
4509
|
+
this.skipOnSelectCount = 0;
|
|
4510
|
+
this.dpInstance.clear();
|
|
4511
|
+
this.dpInstance.setViewDate(this.today);
|
|
4512
|
+
this.selectedStartDate = undefined;
|
|
4513
|
+
this.selectedEndDate = undefined;
|
|
4514
|
+
}
|
|
4515
|
+
isValidDate(date) {
|
|
4516
|
+
return date instanceof Date && !Number.isNaN(date.getTime());
|
|
4517
|
+
}
|
|
4518
|
+
syncDatePickerState() {
|
|
4519
|
+
this.inputDisabled = this.dpInput.disabled;
|
|
4520
|
+
}
|
|
4521
|
+
async componentDidLoad() {
|
|
4522
|
+
this.euFormat = document.documentElement.lang !== 'en-US';
|
|
4523
|
+
this.configDatePicker();
|
|
4524
|
+
this.setupGridObserver();
|
|
4525
|
+
this.setupNavObserver();
|
|
4526
|
+
this.setupInputObserver();
|
|
4527
|
+
this.validateSelectedStartDate();
|
|
4528
|
+
this.validateSelectedEndDate();
|
|
4529
|
+
this.validateMin();
|
|
4530
|
+
this.validateMax();
|
|
4531
|
+
this.validateTextToggleCalendar();
|
|
4532
|
+
this.validateTextNextDecade();
|
|
4533
|
+
this.validateTextNextMonth();
|
|
4534
|
+
this.validateTextNextYear();
|
|
4535
|
+
this.validateTextPreviousDecade();
|
|
4536
|
+
this.validateTextPreviousMonth();
|
|
4537
|
+
this.validateTextPreviousYear();
|
|
4538
|
+
this.validateTextSwitchYear();
|
|
4539
|
+
this.validateInline();
|
|
4540
|
+
if (this.inline) {
|
|
4541
|
+
requestAnimationFrame(() => this.enhanceAccessibility(false));
|
|
4542
|
+
}
|
|
4543
|
+
else {
|
|
4544
|
+
this.addInputListener();
|
|
4545
|
+
requestAnimationFrame(() => {
|
|
4546
|
+
this.syncDatePickerState();
|
|
4547
|
+
});
|
|
4548
|
+
}
|
|
4549
|
+
}
|
|
4550
|
+
disconnectedCallback() {
|
|
4551
|
+
this.host.shadowRoot?.removeEventListener('keydown', this.handleTab, true);
|
|
4552
|
+
this.titleBtn?.removeEventListener('click', this.forceTitleClickToYear);
|
|
4553
|
+
const body = this.dpContainer?.querySelector('.air-datepicker-body--cells');
|
|
4554
|
+
body?.removeEventListener('keydown', this.handleGridKeydown);
|
|
4555
|
+
this.prevBtn?.removeEventListener('click', this.handlePrevNextClick);
|
|
4556
|
+
this.nextBtn?.removeEventListener('click', this.handlePrevNextClick);
|
|
4557
|
+
this.dpInput?.removeEventListener('blur', this.handleInputBlur);
|
|
4558
|
+
this.gridObserver?.disconnect();
|
|
4559
|
+
this.navObserver?.disconnect();
|
|
4560
|
+
this.inputObserver?.disconnect();
|
|
4561
|
+
if (this.dpInstance) {
|
|
4562
|
+
this.dpInstance.destroy();
|
|
4563
|
+
this.dpInstance = null;
|
|
4564
|
+
}
|
|
4565
|
+
}
|
|
4566
|
+
render() {
|
|
4567
|
+
return (index.h(index.Host, { key: 'b721b731d9ad4ff3c6d80c995a3c471786b6425a' }, this.inline && index.h("div", { key: '9dc37bf0ab23a5ce611139d0efd7f3fca4f6e6e2', class: "datepicker-container" }), !this.inline && (index.h("div", { key: 'f2e0376510e5e26a98e29703fbf11c0be90266bb' }, index.h("div", { key: '52e05c2f28a725c5336fca16842e97ce21a36b42', class: {
|
|
4568
|
+
'calendar-input': !this.range,
|
|
4569
|
+
'calendar-input-range': this.range,
|
|
4570
|
+
'disabled': this.inputDisabled,
|
|
4571
|
+
} }, index.h("slot", { key: '11147329e23c51b3bf7c5fa2925cbf97d26c9da2' }), index.h("button", { key: 'c57f2450bd8ce1976876a8bc11f7d238300ca687', onClick: () => this.show(), "aria-haspopup": "true", "aria-label": this.textToggleCalendar, disabled: this.inputDisabled }, index.h("post-icon", { key: 'd6a37bfc1471a8eabbf3e0450c3010da8e7ef28e', name: "calendar" }))), index.h("post-popovercontainer", { key: 'fd4259c066d92c5bbf1066940da72f74a58bdfe8', placement: "bottom-end", offset: PostDatePicker.FLYOUT_OFFSET, ref: e => (this.popoverRef = e) }, index.h("div", { key: '0ba6ef3f33a003317ab70728e1c67fc8c1d726a9', class: "datepicker-container" }))))));
|
|
4572
|
+
}
|
|
4573
|
+
get host() { return index.getElement(this); }
|
|
4574
|
+
static get watchers() { return {
|
|
4575
|
+
"selectedStartDate": [{
|
|
4576
|
+
"validateSelectedStartDate": 0
|
|
4577
|
+
}],
|
|
4578
|
+
"selectedEndDate": [{
|
|
4579
|
+
"validateSelectedEndDate": 0
|
|
4580
|
+
}],
|
|
4581
|
+
"min": [{
|
|
4582
|
+
"validateMin": 0
|
|
4583
|
+
}],
|
|
4584
|
+
"max": [{
|
|
4585
|
+
"validateMax": 0
|
|
4586
|
+
}],
|
|
4587
|
+
"inline": [{
|
|
4588
|
+
"validateInline": 0
|
|
4589
|
+
}],
|
|
4590
|
+
"textNextMonth": [{
|
|
4591
|
+
"validateTextNextMonth": 0
|
|
4592
|
+
}],
|
|
4593
|
+
"textNextYear": [{
|
|
4594
|
+
"validateTextNextYear": 0
|
|
4595
|
+
}],
|
|
4596
|
+
"textNextDecade": [{
|
|
4597
|
+
"validateTextNextDecade": 0
|
|
4598
|
+
}],
|
|
4599
|
+
"textPreviousMonth": [{
|
|
4600
|
+
"validateTextPreviousMonth": 0
|
|
4601
|
+
}],
|
|
4602
|
+
"textPreviousYear": [{
|
|
4603
|
+
"validateTextPreviousYear": 0
|
|
4604
|
+
}],
|
|
4605
|
+
"textPreviousDecade": [{
|
|
4606
|
+
"validateTextPreviousDecade": 0
|
|
4607
|
+
}],
|
|
4608
|
+
"textSwitchYear": [{
|
|
4609
|
+
"validateTextSwitchYear": 0
|
|
4610
|
+
}],
|
|
4611
|
+
"textToggleCalendar": [{
|
|
4612
|
+
"validateTextToggleCalendar": 0
|
|
4613
|
+
}]
|
|
4614
|
+
}; }
|
|
4615
|
+
};
|
|
4616
|
+
PostDatePicker.FLYOUT_OFFSET = 4;
|
|
4617
|
+
PostDatePicker.style = postDatePickerCss();
|
|
4618
|
+
|
|
4619
|
+
exports.post_date_picker = PostDatePicker;
|