@ukic/canary-web-components 3.0.0-canary.30 → 3.0.0-canary.31
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/core.cjs.js +1 -1
- package/dist/cjs/date-helpers-d7ee7b45.js.map +1 -1
- package/dist/cjs/{helpers-da852478.js → helpers-6f4b406b.js} +20 -20
- package/dist/cjs/helpers-6f4b406b.js.map +1 -0
- package/dist/cjs/ic-button_3.cjs.entry.js +5 -5
- package/dist/cjs/ic-button_3.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-calendar_2.cjs.entry.js +2354 -0
- package/dist/cjs/ic-calendar_2.cjs.entry.js.map +1 -0
- package/dist/cjs/ic-card-horizontal.cjs.entry.js +6 -6
- package/dist/cjs/ic-card-horizontal.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-checkbox-group.cjs.entry.js +2 -2
- package/dist/cjs/ic-checkbox-group.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-checkbox_3.cjs.entry.js +39 -16
- package/dist/cjs/ic-checkbox_3.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-data-list.cjs.entry.js +2 -2
- package/dist/cjs/ic-data-list.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-data-row.cjs.entry.js +2 -2
- package/dist/cjs/ic-data-row.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-data-table-title-bar.cjs.entry.js +4 -4
- package/dist/cjs/ic-data-table.cjs.entry.js +8 -8
- package/dist/cjs/ic-date-picker.cjs.entry.js +98 -854
- package/dist/cjs/ic-date-picker.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-dialog.cjs.entry.js +1 -1
- package/dist/cjs/ic-dialog.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-footer-link.cjs.entry.js +2 -2
- package/dist/cjs/ic-footer-link.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-hero.cjs.entry.js +11 -6
- package/dist/cjs/ic-hero.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-horizontal-scroll.cjs.entry.js +5 -5
- package/dist/cjs/ic-horizontal-scroll.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-input-component-container_4.cjs.entry.js +10 -10
- package/dist/cjs/ic-input-component-container_4.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-layout-grid-item.cjs.entry.js +2 -2
- package/dist/cjs/ic-layout-grid-item.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-layout-grid.cjs.entry.js +2 -2
- package/dist/cjs/ic-layout-grid.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-link.cjs.entry.js +1 -1
- package/dist/cjs/ic-link.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-menu-group.cjs.entry.js +1 -1
- package/dist/cjs/ic-menu-group.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-menu.cjs.entry.js +3 -3
- package/dist/cjs/ic-menu.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-navigation-group.cjs.entry.js +1 -1
- package/dist/cjs/ic-navigation-group.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-navigation-menu.cjs.entry.js +4 -4
- package/dist/cjs/ic-navigation-menu.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-page-header.cjs.entry.js +6 -6
- package/dist/cjs/ic-page-header.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-pagination_4.cjs.entry.js +18 -18
- package/dist/cjs/ic-pagination_4.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-popover-menu.cjs.entry.js +4 -4
- package/dist/cjs/ic-popover-menu.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-radio-group.cjs.entry.js +4 -4
- package/dist/cjs/ic-radio-group.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-radio-option.cjs.entry.js +4 -4
- package/dist/cjs/ic-radio-option.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-search-bar.cjs.entry.js +9 -9
- package/dist/cjs/ic-search-bar.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-section-container.cjs.entry.js +2 -2
- package/dist/cjs/ic-section-container.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-side-navigation.cjs.entry.js +4 -4
- package/dist/cjs/ic-side-navigation.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-skeleton.cjs.entry.js +2 -2
- package/dist/cjs/ic-skeleton.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-skip-link.cjs.entry.js +2 -2
- package/dist/cjs/ic-skip-link.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-status-tag.cjs.entry.js +2 -2
- package/dist/cjs/ic-status-tag.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-step.cjs.entry.js +13 -13
- package/dist/cjs/ic-step.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-stepper.cjs.entry.js +2 -2
- package/dist/cjs/ic-stepper.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-switch.cjs.entry.js +4 -4
- package/dist/cjs/ic-switch.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-tab-context.cjs.entry.js +1 -1
- package/dist/cjs/ic-tab-context.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-tab-group.cjs.entry.js +2 -2
- package/dist/cjs/ic-tab-group.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-tab-panel.cjs.entry.js +2 -2
- package/dist/cjs/ic-tab-panel.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-table-of-contents.cjs.entry.js +4 -4
- package/dist/cjs/ic-theme.cjs.entry.js +1 -1
- package/dist/cjs/ic-theme.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-time-input.cjs.entry.js +5 -5
- package/dist/cjs/ic-time-input.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-toast-region.cjs.entry.js +1 -1
- package/dist/cjs/ic-toast-region.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-toast.cjs.entry.js +4 -4
- package/dist/cjs/ic-toast.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-toggle-button-group.cjs.entry.js +2 -2
- package/dist/cjs/ic-toggle-button-group.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-toggle-button.cjs.entry.js +2 -2
- package/dist/cjs/ic-toggle-button.cjs.entry.js.map +1 -1
- package/dist/cjs/ic-tree-item.cjs.entry.js +3 -3
- package/dist/cjs/ic-tree-view.cjs.entry.js +4 -4
- package/dist/cjs/index-d337cd8a.js +4 -4
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/ic-calendar/ic-calendar.css +910 -0
- package/dist/collection/components/ic-calendar/ic-calendar.js +1542 -0
- package/dist/collection/components/ic-calendar/ic-calendar.js.map +1 -0
- package/dist/collection/components/ic-calendar/ic-calendar.stories.js +295 -0
- package/dist/collection/components/ic-calendar/ic-calendar.stories.js.map +1 -0
- package/dist/collection/components/ic-calendar/ic-day-button.js.map +1 -0
- package/dist/collection/components/ic-calendar/ic-month-picker.js +35 -0
- package/dist/collection/components/ic-calendar/ic-month-picker.js.map +1 -0
- package/dist/collection/components/ic-calendar/ic-year-picker.js +57 -0
- package/dist/collection/components/ic-calendar/ic-year-picker.js.map +1 -0
- package/dist/collection/components/ic-calendar/test/a11y/ic-calendar.test.a11y.js +13 -0
- package/dist/collection/components/ic-calendar/test/a11y/ic-calendar.test.a11y.js.map +1 -0
- package/dist/collection/components/ic-card-horizontal/ic-card-horizontal.js +6 -6
- package/dist/collection/components/ic-card-horizontal/ic-card-horizontal.js.map +1 -1
- package/dist/collection/components/ic-data-table/ic-data-table.js +7 -7
- package/dist/collection/components/ic-data-table-title-bar/ic-data-table-title-bar.js +3 -3
- package/dist/collection/components/ic-date-input/ic-date-input.js +8 -7
- package/dist/collection/components/ic-date-input/ic-date-input.js.map +1 -1
- package/dist/collection/components/ic-date-picker/ic-date-picker.css +7 -405
- package/dist/collection/components/ic-date-picker/ic-date-picker.js +145 -802
- package/dist/collection/components/ic-date-picker/ic-date-picker.js.map +1 -1
- package/dist/collection/components/ic-date-picker/ic-date-picker.stories.js +110 -0
- package/dist/collection/components/ic-date-picker/ic-date-picker.stories.js.map +1 -1
- package/dist/collection/components/ic-date-picker/story-data.js +5 -1
- package/dist/collection/components/ic-date-picker/story-data.js.map +1 -1
- package/dist/collection/components/ic-pagination-bar/ic-pagination-bar.js +7 -7
- package/dist/collection/components/ic-pagination-bar/ic-pagination-bar.js.map +1 -1
- package/dist/collection/components/ic-table-of-contents/ic-table-of-contents.js +3 -3
- package/dist/collection/components/ic-time-input/ic-time-input.js +9 -8
- package/dist/collection/components/ic-time-input/ic-time-input.js.map +1 -1
- package/dist/collection/components/ic-tree-item/ic-tree-item.js +2 -2
- package/dist/collection/components/ic-tree-view/ic-tree-view.js +3 -3
- package/dist/collection/utils/date-helpers.js +3 -0
- package/dist/collection/utils/date-helpers.js.map +1 -1
- package/dist/collection/utils/types.js.map +1 -1
- package/dist/{esm/date-helpers-2b531c8c.js → components/date-helpers.js} +2 -2
- package/dist/components/date-helpers.js.map +1 -0
- package/dist/components/helpers2.js +20 -20
- package/dist/components/helpers2.js.map +1 -1
- package/dist/components/ic-calendar.d.ts +11 -0
- package/dist/components/ic-calendar.js +8 -0
- package/dist/components/ic-calendar.js.map +1 -0
- package/dist/components/ic-calendar2.js +1235 -0
- package/dist/components/ic-calendar2.js.map +1 -0
- package/dist/components/ic-card-horizontal.js +6 -6
- package/dist/components/ic-card-horizontal.js.map +1 -1
- package/dist/components/ic-checkbox-group.js +2 -2
- package/dist/components/ic-checkbox-group.js.map +1 -1
- package/dist/components/ic-checkbox2.js +31 -8
- package/dist/components/ic-checkbox2.js.map +1 -1
- package/dist/components/ic-data-list.js +2 -2
- package/dist/components/ic-data-list.js.map +1 -1
- package/dist/components/ic-data-row.js +2 -2
- package/dist/components/ic-data-row.js.map +1 -1
- package/dist/components/ic-data-table-title-bar.js +3 -3
- package/dist/components/ic-data-table.js +8 -8
- package/dist/components/ic-date-input2.js +6 -88
- package/dist/components/ic-date-input2.js.map +1 -1
- package/dist/components/ic-date-picker.js +113 -880
- package/dist/components/ic-date-picker.js.map +1 -1
- package/dist/components/ic-dialog.js +1 -1
- package/dist/components/ic-dialog.js.map +1 -1
- package/dist/components/ic-empty-state2.js +2 -2
- package/dist/components/ic-empty-state2.js.map +1 -1
- package/dist/components/ic-footer-link.js +2 -2
- package/dist/components/ic-footer-link.js.map +1 -1
- package/dist/components/ic-hero.js +12 -6
- package/dist/components/ic-hero.js.map +1 -1
- package/dist/components/ic-horizontal-scroll2.js +5 -5
- package/dist/components/ic-horizontal-scroll2.js.map +1 -1
- package/dist/components/ic-input-component-container2.js +3 -3
- package/dist/components/ic-input-component-container2.js.map +1 -1
- package/dist/components/ic-input-container2.js +2 -2
- package/dist/components/ic-input-container2.js.map +1 -1
- package/dist/components/ic-input-label2.js +2 -2
- package/dist/components/ic-input-label2.js.map +1 -1
- package/dist/components/ic-input-validation2.js +3 -3
- package/dist/components/ic-input-validation2.js.map +1 -1
- package/dist/components/ic-layout-grid-item.js +2 -2
- package/dist/components/ic-layout-grid-item.js.map +1 -1
- package/dist/components/ic-layout-grid.js +2 -2
- package/dist/components/ic-layout-grid.js.map +1 -1
- package/dist/components/ic-link2.js +1 -1
- package/dist/components/ic-link2.js.map +1 -1
- package/dist/components/ic-loading-indicator2.js +5 -5
- package/dist/components/ic-loading-indicator2.js.map +1 -1
- package/dist/components/ic-menu-group.js +1 -1
- package/dist/components/ic-menu-group.js.map +1 -1
- package/dist/components/ic-menu2.js +3 -3
- package/dist/components/ic-menu2.js.map +1 -1
- package/dist/components/ic-navigation-group.js +1 -1
- package/dist/components/ic-navigation-group.js.map +1 -1
- package/dist/components/ic-navigation-menu2.js +4 -4
- package/dist/components/ic-navigation-menu2.js.map +1 -1
- package/dist/components/ic-page-header.js +6 -6
- package/dist/components/ic-page-header.js.map +1 -1
- package/dist/components/ic-pagination-bar2.js +6 -6
- package/dist/components/ic-pagination-bar2.js.map +1 -1
- package/dist/components/ic-pagination-item2.js +1 -1
- package/dist/components/ic-pagination-item2.js.map +1 -1
- package/dist/components/ic-pagination2.js +4 -4
- package/dist/components/ic-pagination2.js.map +1 -1
- package/dist/components/ic-popover-menu.js +4 -4
- package/dist/components/ic-popover-menu.js.map +1 -1
- package/dist/components/ic-radio-group.js +4 -4
- package/dist/components/ic-radio-group.js.map +1 -1
- package/dist/components/ic-radio-option.js +4 -4
- package/dist/components/ic-radio-option.js.map +1 -1
- package/dist/components/ic-search-bar.js +9 -9
- package/dist/components/ic-search-bar.js.map +1 -1
- package/dist/components/ic-section-container2.js +2 -2
- package/dist/components/ic-section-container2.js.map +1 -1
- package/dist/components/ic-select2.js +7 -7
- package/dist/components/ic-select2.js.map +1 -1
- package/dist/components/ic-side-navigation.js +4 -4
- package/dist/components/ic-side-navigation.js.map +1 -1
- package/dist/components/ic-skeleton.js +2 -2
- package/dist/components/ic-skeleton.js.map +1 -1
- package/dist/components/ic-skip-link.js +2 -2
- package/dist/components/ic-skip-link.js.map +1 -1
- package/dist/components/ic-status-tag.js +2 -2
- package/dist/components/ic-status-tag.js.map +1 -1
- package/dist/components/ic-step.js +13 -13
- package/dist/components/ic-step.js.map +1 -1
- package/dist/components/ic-stepper.js +2 -2
- package/dist/components/ic-stepper.js.map +1 -1
- package/dist/components/ic-switch.js +4 -4
- package/dist/components/ic-switch.js.map +1 -1
- package/dist/components/ic-tab-context.js +1 -1
- package/dist/components/ic-tab-context.js.map +1 -1
- package/dist/components/ic-tab-group.js +2 -2
- package/dist/components/ic-tab-group.js.map +1 -1
- package/dist/components/ic-tab-panel.js +2 -2
- package/dist/components/ic-tab-panel.js.map +1 -1
- package/dist/components/ic-table-of-contents.js +3 -3
- package/dist/components/ic-text-field2.js +6 -6
- package/dist/components/ic-text-field2.js.map +1 -1
- package/dist/components/ic-theme.js +1 -1
- package/dist/components/ic-theme.js.map +1 -1
- package/dist/components/ic-time-input.js +5 -5
- package/dist/components/ic-time-input.js.map +1 -1
- package/dist/components/ic-toast-region.js +1 -1
- package/dist/components/ic-toast-region.js.map +1 -1
- package/dist/components/ic-toast.js +4 -4
- package/dist/components/ic-toast.js.map +1 -1
- package/dist/components/ic-toggle-button-group.js +2 -2
- package/dist/components/ic-toggle-button-group.js.map +1 -1
- package/dist/components/ic-toggle-button.js +2 -2
- package/dist/components/ic-toggle-button.js.map +1 -1
- package/dist/components/ic-tree-item.js +3 -3
- package/dist/components/ic-tree-view.js +4 -4
- package/dist/core/core.css +21 -9
- package/dist/core/core.esm.js +1 -1
- package/dist/core/core.esm.js.map +1 -1
- package/dist/core/{p-9fade6ad.entry.js → p-0043b019.entry.js} +2 -2
- package/dist/core/{p-9fade6ad.entry.js.map → p-0043b019.entry.js.map} +1 -1
- package/dist/core/{p-889bb8db.entry.js → p-04cb17d7.entry.js} +2 -2
- package/dist/core/{p-889bb8db.entry.js.map → p-04cb17d7.entry.js.map} +1 -1
- package/dist/core/{p-5ef453b6.entry.js → p-15c05eb8.entry.js} +2 -2
- package/dist/core/{p-5ef453b6.entry.js.map → p-15c05eb8.entry.js.map} +1 -1
- package/dist/core/p-1a976789.entry.js +2 -0
- package/dist/core/p-1a976789.entry.js.map +1 -0
- package/dist/core/{p-1be092cc.entry.js → p-2188b483.entry.js} +2 -2
- package/dist/core/{p-1be092cc.entry.js.map → p-2188b483.entry.js.map} +1 -1
- package/dist/core/{p-8c94541e.entry.js → p-24bac55f.entry.js} +2 -2
- package/dist/core/{p-8c94541e.entry.js.map → p-24bac55f.entry.js.map} +1 -1
- package/dist/core/{p-7f304d85.entry.js → p-2646a629.entry.js} +2 -2
- package/dist/core/{p-7f304d85.entry.js.map → p-2646a629.entry.js.map} +1 -1
- package/dist/core/{p-5cf704e3.entry.js → p-319e3d5b.entry.js} +2 -2
- package/dist/core/{p-5cf704e3.entry.js.map → p-319e3d5b.entry.js.map} +1 -1
- package/dist/core/{p-9e200827.entry.js → p-31f3fb15.entry.js} +2 -2
- package/dist/core/{p-9e200827.entry.js.map → p-31f3fb15.entry.js.map} +1 -1
- package/dist/core/{p-fd64c0e5.entry.js → p-3891ce53.entry.js} +2 -2
- package/dist/core/{p-fd64c0e5.entry.js.map → p-3891ce53.entry.js.map} +1 -1
- package/dist/core/{p-fad44bc8.entry.js → p-3ba2b455.entry.js} +2 -2
- package/dist/core/{p-fad44bc8.entry.js.map → p-3ba2b455.entry.js.map} +1 -1
- package/dist/core/{p-df220b91.entry.js → p-3ef2e98d.entry.js} +2 -2
- package/dist/core/{p-03ae0bc3.entry.js → p-41def410.entry.js} +2 -2
- package/dist/core/{p-03ae0bc3.entry.js.map → p-41def410.entry.js.map} +1 -1
- package/dist/core/p-4b188516.entry.js +2 -0
- package/dist/core/p-4b188516.entry.js.map +1 -0
- package/dist/core/{p-93e1ba0a.entry.js → p-5254a078.entry.js} +2 -2
- package/dist/core/{p-93e1ba0a.entry.js.map → p-5254a078.entry.js.map} +1 -1
- package/dist/core/{p-9c2e9189.entry.js → p-53740194.entry.js} +2 -2
- package/dist/core/{p-9c2e9189.entry.js.map → p-53740194.entry.js.map} +1 -1
- package/dist/core/{p-e380a54e.entry.js → p-5a4344cb.entry.js} +2 -2
- package/dist/core/{p-e380a54e.entry.js.map → p-5a4344cb.entry.js.map} +1 -1
- package/dist/core/p-5b32aaf3.entry.js +2 -0
- package/dist/core/p-5b32aaf3.entry.js.map +1 -0
- package/dist/core/{p-d8200098.entry.js → p-67c3985d.entry.js} +2 -2
- package/dist/core/{p-d8200098.entry.js.map → p-67c3985d.entry.js.map} +1 -1
- package/dist/core/{p-982a173d.entry.js → p-7332320d.entry.js} +2 -2
- package/dist/core/{p-982a173d.entry.js.map → p-7332320d.entry.js.map} +1 -1
- package/dist/core/{p-bc441e4c.js → p-75c3b882.js} +2 -2
- package/dist/core/{p-bc441e4c.js.map → p-75c3b882.js.map} +1 -1
- package/dist/core/{p-b88db5e3.entry.js → p-7a0f62c2.entry.js} +2 -2
- package/dist/core/{p-b88db5e3.entry.js.map → p-7a0f62c2.entry.js.map} +1 -1
- package/dist/core/p-81f12581.entry.js +2 -0
- package/dist/core/p-81f12581.entry.js.map +1 -0
- package/dist/core/{p-193afb53.entry.js → p-847cbb16.entry.js} +2 -2
- package/dist/core/{p-193afb53.entry.js.map → p-847cbb16.entry.js.map} +1 -1
- package/dist/core/{p-f3ccaa0b.entry.js → p-8e592393.entry.js} +2 -2
- package/dist/core/{p-f3ccaa0b.entry.js.map → p-8e592393.entry.js.map} +1 -1
- package/dist/core/p-9044539c.entry.js +2 -0
- package/dist/core/p-9044539c.entry.js.map +1 -0
- package/dist/core/{p-f4e7cae6.entry.js → p-90611726.entry.js} +2 -2
- package/dist/core/{p-f4e7cae6.entry.js.map → p-90611726.entry.js.map} +1 -1
- package/dist/core/{p-b00efb15.entry.js → p-9674b63f.entry.js} +2 -2
- package/dist/core/{p-b00efb15.entry.js.map → p-9674b63f.entry.js.map} +1 -1
- package/dist/core/{p-a27e1cee.entry.js → p-9a95f428.entry.js} +2 -2
- package/dist/core/{p-a27e1cee.entry.js.map → p-9a95f428.entry.js.map} +1 -1
- package/dist/core/{p-fb43abd6.entry.js → p-9ca147f3.entry.js} +2 -2
- package/dist/core/{p-fb43abd6.entry.js.map → p-9ca147f3.entry.js.map} +1 -1
- package/dist/core/{p-a8cc28a6.entry.js → p-9f76eed6.entry.js} +2 -2
- package/dist/core/{p-035dbee0.entry.js → p-a1448064.entry.js} +2 -2
- package/dist/core/{p-035dbee0.entry.js.map → p-a1448064.entry.js.map} +1 -1
- package/dist/core/{p-9ce9d39a.entry.js → p-a237af88.entry.js} +2 -2
- package/dist/core/{p-9ce9d39a.entry.js.map → p-a237af88.entry.js.map} +1 -1
- package/dist/core/{p-09c31ac6.entry.js → p-adde6c66.entry.js} +2 -2
- package/dist/core/{p-09c31ac6.entry.js.map → p-adde6c66.entry.js.map} +1 -1
- package/dist/core/{p-72b7051a.entry.js → p-af821831.entry.js} +2 -2
- package/dist/core/{p-72b7051a.entry.js.map → p-af821831.entry.js.map} +1 -1
- package/dist/core/{p-12e8dcdd.entry.js → p-afedcfdb.entry.js} +2 -2
- package/dist/core/{p-12e8dcdd.entry.js.map → p-afedcfdb.entry.js.map} +1 -1
- package/dist/core/{p-f098e531.entry.js → p-b4a2f6fa.entry.js} +2 -2
- package/dist/core/{p-f098e531.entry.js.map → p-b4a2f6fa.entry.js.map} +1 -1
- package/dist/core/p-b4bfaf8f.entry.js +2 -0
- package/dist/core/p-b4bfaf8f.entry.js.map +1 -0
- package/dist/core/{p-ea1de762.entry.js → p-b80b08ae.entry.js} +2 -2
- package/dist/core/p-b80b08ae.entry.js.map +1 -0
- package/dist/core/{p-7bf9bbde.entry.js → p-ba21f477.entry.js} +2 -2
- package/dist/core/{p-7bf9bbde.entry.js.map → p-ba21f477.entry.js.map} +1 -1
- package/dist/core/{p-63203e59.entry.js → p-ba75ed34.entry.js} +2 -2
- package/dist/core/{p-63203e59.entry.js.map → p-ba75ed34.entry.js.map} +1 -1
- package/dist/core/{p-15a81f32.entry.js → p-bd9a76d8.entry.js} +2 -2
- package/dist/core/{p-15a81f32.entry.js.map → p-bd9a76d8.entry.js.map} +1 -1
- package/dist/core/{p-10950727.entry.js → p-c3eddb99.entry.js} +2 -2
- package/dist/core/{p-10950727.entry.js.map → p-c3eddb99.entry.js.map} +1 -1
- package/dist/core/{p-a99ad459.entry.js → p-c5d65718.entry.js} +2 -2
- package/dist/core/{p-a99ad459.entry.js.map → p-c5d65718.entry.js.map} +1 -1
- package/dist/core/{p-eb958cc8.entry.js → p-c6c87e58.entry.js} +2 -2
- package/dist/core/{p-eb958cc8.entry.js.map → p-c6c87e58.entry.js.map} +1 -1
- package/dist/core/{p-c8ce7d60.entry.js → p-e00e67ff.entry.js} +2 -2
- package/dist/core/{p-c8ce7d60.entry.js.map → p-e00e67ff.entry.js.map} +1 -1
- package/dist/core/{p-069e758b.entry.js → p-e1920777.entry.js} +2 -2
- package/dist/core/{p-92936b49.entry.js → p-ef5b6622.entry.js} +2 -2
- package/dist/core/{p-0f22f41e.js → p-f48ce5f6.js} +2 -2
- package/dist/core/p-f48ce5f6.js.map +1 -0
- package/dist/core/{p-1ca62941.entry.js → p-f5cea10d.entry.js} +2 -2
- package/dist/esm/core.js +1 -1
- package/dist/esm/date-helpers-5723de08.js +86 -0
- package/dist/esm/{date-helpers-2b531c8c.js.map → date-helpers-5723de08.js.map} +1 -1
- package/dist/esm/{helpers-89cb996d.js → helpers-9f228880.js} +21 -21
- package/dist/esm/helpers-9f228880.js.map +1 -0
- package/dist/esm/ic-button_3.entry.js +5 -5
- package/dist/esm/ic-button_3.entry.js.map +1 -1
- package/dist/esm/ic-calendar_2.entry.js +2349 -0
- package/dist/esm/ic-calendar_2.entry.js.map +1 -0
- package/dist/esm/ic-card-horizontal.entry.js +6 -6
- package/dist/esm/ic-card-horizontal.entry.js.map +1 -1
- package/dist/esm/ic-checkbox-group.entry.js +2 -2
- package/dist/esm/ic-checkbox-group.entry.js.map +1 -1
- package/dist/esm/ic-checkbox_3.entry.js +39 -16
- package/dist/esm/ic-checkbox_3.entry.js.map +1 -1
- package/dist/esm/ic-data-list.entry.js +2 -2
- package/dist/esm/ic-data-list.entry.js.map +1 -1
- package/dist/esm/ic-data-row.entry.js +2 -2
- package/dist/esm/ic-data-row.entry.js.map +1 -1
- package/dist/esm/ic-data-table-title-bar.entry.js +4 -4
- package/dist/esm/ic-data-table.entry.js +8 -8
- package/dist/esm/ic-date-picker.entry.js +100 -856
- package/dist/esm/ic-date-picker.entry.js.map +1 -1
- package/dist/esm/ic-dialog.entry.js +1 -1
- package/dist/esm/ic-dialog.entry.js.map +1 -1
- package/dist/esm/ic-footer-link.entry.js +2 -2
- package/dist/esm/ic-footer-link.entry.js.map +1 -1
- package/dist/esm/ic-hero.entry.js +11 -6
- package/dist/esm/ic-hero.entry.js.map +1 -1
- package/dist/esm/ic-horizontal-scroll.entry.js +5 -5
- package/dist/esm/ic-horizontal-scroll.entry.js.map +1 -1
- package/dist/esm/ic-input-component-container_4.entry.js +10 -10
- package/dist/esm/ic-input-component-container_4.entry.js.map +1 -1
- package/dist/esm/ic-layout-grid-item.entry.js +2 -2
- package/dist/esm/ic-layout-grid-item.entry.js.map +1 -1
- package/dist/esm/ic-layout-grid.entry.js +2 -2
- package/dist/esm/ic-layout-grid.entry.js.map +1 -1
- package/dist/esm/ic-link.entry.js +1 -1
- package/dist/esm/ic-link.entry.js.map +1 -1
- package/dist/esm/ic-menu-group.entry.js +1 -1
- package/dist/esm/ic-menu-group.entry.js.map +1 -1
- package/dist/esm/ic-menu.entry.js +3 -3
- package/dist/esm/ic-menu.entry.js.map +1 -1
- package/dist/esm/ic-navigation-group.entry.js +1 -1
- package/dist/esm/ic-navigation-group.entry.js.map +1 -1
- package/dist/esm/ic-navigation-menu.entry.js +4 -4
- package/dist/esm/ic-navigation-menu.entry.js.map +1 -1
- package/dist/esm/ic-page-header.entry.js +6 -6
- package/dist/esm/ic-page-header.entry.js.map +1 -1
- package/dist/esm/ic-pagination_4.entry.js +18 -18
- package/dist/esm/ic-pagination_4.entry.js.map +1 -1
- package/dist/esm/ic-popover-menu.entry.js +4 -4
- package/dist/esm/ic-popover-menu.entry.js.map +1 -1
- package/dist/esm/ic-radio-group.entry.js +4 -4
- package/dist/esm/ic-radio-group.entry.js.map +1 -1
- package/dist/esm/ic-radio-option.entry.js +4 -4
- package/dist/esm/ic-radio-option.entry.js.map +1 -1
- package/dist/esm/ic-search-bar.entry.js +9 -9
- package/dist/esm/ic-search-bar.entry.js.map +1 -1
- package/dist/esm/ic-section-container.entry.js +2 -2
- package/dist/esm/ic-section-container.entry.js.map +1 -1
- package/dist/esm/ic-side-navigation.entry.js +4 -4
- package/dist/esm/ic-side-navigation.entry.js.map +1 -1
- package/dist/esm/ic-skeleton.entry.js +2 -2
- package/dist/esm/ic-skeleton.entry.js.map +1 -1
- package/dist/esm/ic-skip-link.entry.js +2 -2
- package/dist/esm/ic-skip-link.entry.js.map +1 -1
- package/dist/esm/ic-status-tag.entry.js +2 -2
- package/dist/esm/ic-status-tag.entry.js.map +1 -1
- package/dist/esm/ic-step.entry.js +13 -13
- package/dist/esm/ic-step.entry.js.map +1 -1
- package/dist/esm/ic-stepper.entry.js +2 -2
- package/dist/esm/ic-stepper.entry.js.map +1 -1
- package/dist/esm/ic-switch.entry.js +4 -4
- package/dist/esm/ic-switch.entry.js.map +1 -1
- package/dist/esm/ic-tab-context.entry.js +1 -1
- package/dist/esm/ic-tab-context.entry.js.map +1 -1
- package/dist/esm/ic-tab-group.entry.js +2 -2
- package/dist/esm/ic-tab-group.entry.js.map +1 -1
- package/dist/esm/ic-tab-panel.entry.js +2 -2
- package/dist/esm/ic-tab-panel.entry.js.map +1 -1
- package/dist/esm/ic-table-of-contents.entry.js +4 -4
- package/dist/esm/ic-theme.entry.js +1 -1
- package/dist/esm/ic-theme.entry.js.map +1 -1
- package/dist/esm/ic-time-input.entry.js +5 -5
- package/dist/esm/ic-time-input.entry.js.map +1 -1
- package/dist/esm/ic-toast-region.entry.js +1 -1
- package/dist/esm/ic-toast-region.entry.js.map +1 -1
- package/dist/esm/ic-toast.entry.js +4 -4
- package/dist/esm/ic-toast.entry.js.map +1 -1
- package/dist/esm/ic-toggle-button-group.entry.js +2 -2
- package/dist/esm/ic-toggle-button-group.entry.js.map +1 -1
- package/dist/esm/ic-toggle-button.entry.js +2 -2
- package/dist/esm/ic-toggle-button.entry.js.map +1 -1
- package/dist/esm/ic-tree-item.entry.js +3 -3
- package/dist/esm/ic-tree-view.entry.js +4 -4
- package/dist/esm/index-a7a720e7.js +4 -4
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/ic-calendar/ic-calendar.d.ts +216 -0
- package/dist/types/components/ic-calendar/ic-calendar.stories.d.ts +151 -0
- package/dist/types/components/ic-calendar/test/a11y/ic-calendar.test.a11y.d.ts +1 -0
- package/dist/types/components/ic-card-horizontal/ic-card-horizontal.d.ts +1 -2
- package/dist/types/components/ic-date-input/ic-date-input.d.ts +2 -2
- package/dist/types/components/ic-date-picker/ic-date-picker.d.ts +22 -105
- package/dist/types/components/ic-date-picker/ic-date-picker.stories.d.ts +81 -0
- package/dist/types/components/ic-pagination-bar/ic-pagination-bar.d.ts +1 -1
- package/dist/types/components/ic-time-input/ic-time-input.d.ts +2 -2
- package/dist/types/components.d.ts +213 -14
- package/dist/types/utils/date-helpers.d.ts +1 -0
- package/dist/types/utils/types.d.ts +1 -0
- package/hydrate/index.js +2085 -1639
- package/hydrate/index.mjs +2085 -1639
- package/package.json +3 -3
- package/dist/cjs/helpers-da852478.js.map +0 -1
- package/dist/cjs/ic-date-input.cjs.entry.js +0 -1214
- package/dist/cjs/ic-date-input.cjs.entry.js.map +0 -1
- package/dist/collection/components/ic-date-picker/ic-day-button.js.map +0 -1
- package/dist/collection/components/ic-date-picker/ic-month-picker.js +0 -29
- package/dist/collection/components/ic-date-picker/ic-month-picker.js.map +0 -1
- package/dist/collection/components/ic-date-picker/ic-year-picker.js +0 -39
- package/dist/collection/components/ic-date-picker/ic-year-picker.js.map +0 -1
- package/dist/core/p-0f22f41e.js.map +0 -1
- package/dist/core/p-13c8859b.entry.js +0 -2
- package/dist/core/p-13c8859b.entry.js.map +0 -1
- package/dist/core/p-2528ecec.entry.js +0 -2
- package/dist/core/p-2528ecec.entry.js.map +0 -1
- package/dist/core/p-402870f7.entry.js +0 -2
- package/dist/core/p-402870f7.entry.js.map +0 -1
- package/dist/core/p-bd8c2e24.entry.js +0 -2
- package/dist/core/p-bd8c2e24.entry.js.map +0 -1
- package/dist/core/p-c0d4db72.entry.js +0 -2
- package/dist/core/p-c0d4db72.entry.js.map +0 -1
- package/dist/core/p-ea1de762.entry.js.map +0 -1
- package/dist/core/p-f16c4210.entry.js +0 -2
- package/dist/core/p-f16c4210.entry.js.map +0 -1
- package/dist/esm/helpers-89cb996d.js.map +0 -1
- package/dist/esm/ic-date-input.entry.js +0 -1210
- package/dist/esm/ic-date-input.entry.js.map +0 -1
- /package/dist/collection/components/{ic-date-picker → ic-calendar}/ic-day-button.js +0 -0
- /package/dist/core/{p-df220b91.entry.js.map → p-3ef2e98d.entry.js.map} +0 -0
- /package/dist/core/{p-a8cc28a6.entry.js.map → p-9f76eed6.entry.js.map} +0 -0
- /package/dist/core/{p-069e758b.entry.js.map → p-e1920777.entry.js.map} +0 -0
- /package/dist/core/{p-92936b49.entry.js.map → p-ef5b6622.entry.js.map} +0 -0
- /package/dist/core/{p-1ca62941.entry.js.map → p-f5cea10d.entry.js.map} +0 -0
- /package/dist/types/components/{ic-date-picker → ic-calendar}/ic-day-button.d.ts +0 -0
- /package/dist/types/components/{ic-date-picker → ic-calendar}/ic-month-picker.d.ts +0 -0
- /package/dist/types/components/{ic-date-picker → ic-calendar}/ic-year-picker.d.ts +0 -0
|
@@ -0,0 +1,2349 @@
|
|
|
1
|
+
import { h, r as registerInstance, c as createEvent, H as Host, g as getElement } from './index-a7a720e7.js';
|
|
2
|
+
import { w as stringEnumToArray, x as IcDayNames, y as IcDateInputMonths, k as IcWeekDays, r as removeDisabledFalse, z as IcShortDayNames, b as isEmptyString, l as getInputDescribedByText, q as removeFormResetListener, s as addFormResetListener, o as onComponentRequiredPropUndefined, m as isNumeric, n as IcInformationStatus, t as renderHiddenInput } from './helpers-9f228880.js';
|
|
3
|
+
import { a as dateInRange, g as getMonthEnd, b as getMonthStart, y as yearInRange, c as createDate, e as clampDate, d as dateMatches, f as convertToDoubleDigits, h as getWeekStart, i as addSixWeeks, j as isDateOrEpoch, s as splitStringDate, k as extractDateFromZuluDateTime } from './date-helpers-5723de08.js';
|
|
4
|
+
import { C as Clear } from './clear-icon-1c79bda2.js';
|
|
5
|
+
|
|
6
|
+
const chevron = `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7
|
+
<path d="M9.70687 6L8.29688 7.41L12.8769 12L8.29688 16.59L9.70687 18L15.7069 12L9.70687 6Z" fill="currentColor"/>
|
|
8
|
+
</svg>
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
const DayButton = ({ focussed, today, day, monthInView, onFocusDay, onBlurDay, onSelectDay, selected, focussedDayRef, inRange, showDaysOutsideMonth, disableDay, }) => {
|
|
12
|
+
const handleDayClick = () => {
|
|
13
|
+
onSelectDay(day);
|
|
14
|
+
};
|
|
15
|
+
const handleDayFocus = () => {
|
|
16
|
+
onFocusDay();
|
|
17
|
+
};
|
|
18
|
+
const handleDayBlur = () => {
|
|
19
|
+
onBlurDay();
|
|
20
|
+
};
|
|
21
|
+
const dayNames = stringEnumToArray(IcDayNames);
|
|
22
|
+
const months = stringEnumToArray(IcDateInputMonths);
|
|
23
|
+
const outsideRange = !inRange || disableDay;
|
|
24
|
+
const outsideMonth = monthInView !== day.getMonth();
|
|
25
|
+
const disabled = outsideRange || (outsideMonth && !showDaysOutsideMonth);
|
|
26
|
+
return (h("div", { class: "day-button-container" },
|
|
27
|
+
h("button", { class: {
|
|
28
|
+
"day-button": true,
|
|
29
|
+
"outside-month": outsideMonth,
|
|
30
|
+
"outside-range": !!outsideRange,
|
|
31
|
+
hidden: outsideMonth && !showDaysOutsideMonth,
|
|
32
|
+
disabled: disabled,
|
|
33
|
+
today: today,
|
|
34
|
+
selected: selected,
|
|
35
|
+
focussed: focussed,
|
|
36
|
+
}, tabIndex: focussed ? 0 : -1, "aria-hidden": outsideMonth ? "true" : "false", "aria-disabled": disabled ? "true" : "false", "aria-current": today ? "date" : undefined, "aria-label": disabled || outsideMonth || outsideRange
|
|
37
|
+
? undefined
|
|
38
|
+
: `Choose ${dayNames[day.getDay()]}, ${day.getDate()} ${months[day.getMonth()]} ${day.getFullYear()}`, disabled: disabled, onClick: handleDayClick, onBlur: handleDayBlur, onFocus: handleDayFocus, ref: (el) => {
|
|
39
|
+
if (focussed && el && focussedDayRef) {
|
|
40
|
+
focussedDayRef(el);
|
|
41
|
+
}
|
|
42
|
+
} }, (!outsideMonth || (outsideMonth && showDaysOutsideMonth)) && (h("ic-typography", { variant: "subtitle-small", italic: outsideMonth }, day.getDate())))));
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const MonthPicker = ({ size, focussedMonth, monthInView, onSelectMonth, onKeyDown, focussedMonthRef, minDate, maxDate, yearInView, }) => {
|
|
46
|
+
const handleMonthClick = (ev) => {
|
|
47
|
+
const button = ev.target;
|
|
48
|
+
onSelectMonth(Number(button.getAttribute("data-month")));
|
|
49
|
+
};
|
|
50
|
+
const monthNames = stringEnumToArray(IcDateInputMonths);
|
|
51
|
+
const cols = size === "small" ? 2 : 3;
|
|
52
|
+
const months = [];
|
|
53
|
+
for (let i = 0; i < monthNames.length; i += cols) {
|
|
54
|
+
months.push(monthNames.slice(i, i + cols));
|
|
55
|
+
}
|
|
56
|
+
return (h("div", { class: {
|
|
57
|
+
"month-picker": true,
|
|
58
|
+
}, role: "grid" }, months.map((month, monthIdx) => (h("div", { class: "month-picker-row", key: monthIdx, role: "row" }, month.map((mon, index) => {
|
|
59
|
+
const correctedIndex = monthIdx * cols + index;
|
|
60
|
+
const current = monthInView === correctedIndex;
|
|
61
|
+
const focussed = focussedMonth === correctedIndex;
|
|
62
|
+
const outsideRange = !dateInRange(new Date(yearInView, correctedIndex, 1), minDate ? getMonthStart(minDate) : null, maxDate ? getMonthEnd(maxDate) : null);
|
|
63
|
+
return (h("ic-button", { role: "gridcell", class: {
|
|
64
|
+
"month-button": true,
|
|
65
|
+
selected: current,
|
|
66
|
+
focussed: focussed,
|
|
67
|
+
disabled: outsideRange,
|
|
68
|
+
}, "full-width": true, disabled: outsideRange, variant: current ? "primary" : "tertiary", "data-month": correctedIndex, size: size, tabIndex: focussed ? 0 : -1, "aria-current": current ? "true" : "false", "aria-label": current ? "" : `select ${mon}`, onClick: handleMonthClick, onKeyDown: onKeyDown, ref: (el) => {
|
|
69
|
+
if (focussed && el) {
|
|
70
|
+
focussedMonthRef(el);
|
|
71
|
+
}
|
|
72
|
+
} }, mon));
|
|
73
|
+
}))))));
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const YearPicker = ({ decadeView, size, focussedYear, yearInView, onSelectYear, onFocusYear, onBlurYear, onKeyDown, minDate, maxDate, focussedYearRef, }) => {
|
|
77
|
+
const handleYearClick = (ev) => {
|
|
78
|
+
const button = ev.target;
|
|
79
|
+
onSelectYear(Number(button.getAttribute("data-year")));
|
|
80
|
+
};
|
|
81
|
+
const handleYearFocus = () => {
|
|
82
|
+
onFocusYear();
|
|
83
|
+
};
|
|
84
|
+
const handleYearBlur = () => {
|
|
85
|
+
onBlurYear();
|
|
86
|
+
};
|
|
87
|
+
const navButtonMouseDownHandler = (ev) => {
|
|
88
|
+
ev.preventDefault();
|
|
89
|
+
};
|
|
90
|
+
const cols = size === "small" ? 2 : 3;
|
|
91
|
+
const rows = size === "small" ? 6 : 4;
|
|
92
|
+
const thisDecade = [];
|
|
93
|
+
for (let i = 0; i < decadeView.length; i += cols) {
|
|
94
|
+
thisDecade.push(decadeView.slice(i, i + cols));
|
|
95
|
+
}
|
|
96
|
+
const renderYearButton = (yr, yearIdx, idx) => {
|
|
97
|
+
const isPrevDecade = yearIdx === 0 && idx === 0;
|
|
98
|
+
const isNextDecade = yearIdx === rows - 1 && idx === cols - 1;
|
|
99
|
+
const isCurrent = yearInView === yr;
|
|
100
|
+
const isFocussed = focussedYear === yr;
|
|
101
|
+
return (h("ic-button", { key: yr, role: "gridcell", id: isPrevDecade
|
|
102
|
+
? "prev-decade-button"
|
|
103
|
+
: isNextDecade
|
|
104
|
+
? "next-decade-button"
|
|
105
|
+
: undefined, class: {
|
|
106
|
+
"prev-decade": isPrevDecade,
|
|
107
|
+
"next-decade": isNextDecade,
|
|
108
|
+
"year-button": true,
|
|
109
|
+
selected: !isPrevDecade && !isNextDecade ? isCurrent : false,
|
|
110
|
+
focussed: !isPrevDecade && !isNextDecade ? isFocussed : false,
|
|
111
|
+
flip: isNextDecade,
|
|
112
|
+
}, "full-width": true, disabled: !yearInRange(yr, minDate, maxDate), "data-year": yr, tabIndex: isPrevDecade || isNextDecade ? -1 : isFocussed ? 0 : -1, variant: isPrevDecade || isNextDecade
|
|
113
|
+
? "tertiary"
|
|
114
|
+
: isCurrent
|
|
115
|
+
? "primary"
|
|
116
|
+
: "tertiary", onClick: handleYearClick, onMouseDown: isPrevDecade || isNextDecade ? navButtonMouseDownHandler : undefined, size: size, "aria-label": !isPrevDecade && !isNextDecade
|
|
117
|
+
? isCurrent
|
|
118
|
+
? ""
|
|
119
|
+
: `select ${yr}`
|
|
120
|
+
: undefined, "aria-current": !isPrevDecade && !isNextDecade
|
|
121
|
+
? isCurrent
|
|
122
|
+
? "true"
|
|
123
|
+
: "false"
|
|
124
|
+
: undefined, onKeyDown: !isPrevDecade && !isNextDecade ? onKeyDown : undefined, onFocus: !isPrevDecade && !isNextDecade ? handleYearFocus : undefined, onBlur: !isPrevDecade && !isNextDecade ? handleYearBlur : undefined, ref: !isPrevDecade && !isNextDecade && isFocussed
|
|
125
|
+
? (el) => el && focussedYearRef(el)
|
|
126
|
+
: undefined },
|
|
127
|
+
isPrevDecade ? `${yr - 9}s` : isNextDecade ? `${yr}s` : yr,
|
|
128
|
+
(isPrevDecade || isNextDecade) && (h("svg", { slot: isPrevDecade ? "left-icon" : "right-icon", width: "12", height: "12", fill: "none", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24" },
|
|
129
|
+
h("path", { d: "M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z", fill: "currentColor" })))));
|
|
130
|
+
};
|
|
131
|
+
return (h("div", { class: "year-picker", role: "grid" }, thisDecade.map((years, yearIdx) => (h("div", { class: "year-picker-row", role: "row", key: yearIdx }, years.map((yr, idx) => renderYearButton(yr, yearIdx, idx)))))));
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const icCalendarCss = "/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%;}body{margin:0}main{display:block}h1{font-size:2em;margin:0.67em 0}hr{box-sizing:content-box;height:0;overflow:visible;}pre{font-family:monospace, monospace;font-size:1em;}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace, monospace;font-size:1em;}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0;}button,input{overflow:visible}button,select{text-transform:none}button,[type=\"button\"],[type=\"reset\"],[type=\"submit\"]{-webkit-appearance:button}button::-moz-focus-inner,[type=\"button\"]::-moz-focus-inner,[type=\"reset\"]::-moz-focus-inner,[type=\"submit\"]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type=\"button\"]:-moz-focusring,[type=\"reset\"]:-moz-focusring,[type=\"submit\"]:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:0.35em 0.75em 0.625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal;}progress{vertical-align:baseline}textarea{overflow:auto}[type=\"checkbox\"],[type=\"radio\"]{box-sizing:border-box;padding:0;}[type=\"number\"]::-webkit-inner-spin-button,[type=\"number\"]::-webkit-outer-spin-button{height:auto}[type=\"search\"]{-webkit-appearance:textfield;outline-offset:-2px;}[type=\"search\"]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit;}details{display:block}summary{display:list-item}template{display:none}[hidden]{display:none}html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font-style:inherit;vertical-align:baseline}:host(.ic-date-picker-above) .calendar-container{bottom:calc(var(--ic-space-xxl) - var(--ic-space-xxs))}:host(.ic-date-picker-calendar) .calendar-container{box-shadow:var(--ic-calendar-elevation)}:host .calendar-container{min-width:19rem;max-width:23.5rem;width:var(--input-width);display:flex;flex-direction:column;gap:var(--ic-space-xs);position:absolute;border:var(--ic-border-default);border-color:var(--ic-calendar-border);border-radius:var(--ic-border-radius);align-items:center;background-color:var(--ic-calendar-bg);z-index:var(--ic-z-index-calendar);box-sizing:border-box;margin-top:var(--ic-space-xxxs);padding:var(--ic-space-xs);animation:fade-in-calendar var(--ic-transition-duration-slow)}:host(.ic-calendar-small) .calendar-container{min-width:17rem;max-width:21.5rem}:host(.ic-calendar-large) .calendar-container{min-width:21rem;max-width:25.5rem}:host(.ic-calendar-large){--month-button-width:6.3125rem}:host(.ic-calendar-small){--month-button-width:6.25rem}:host .month-year-nav-container{display:flex;justify-content:space-between;align-items:center;align-self:stretch}:host .month-year-nav-container.hidden{display:none}:host .month-year-nav{display:flex;justify-content:space-between;align-items:center;flex:1 0 0}:host .month-picker,:host .year-picker{display:flex;flex-direction:column;align-items:center;width:17.5rem;-moz-column-gap:var(--ic-space-xs);column-gap:var(--ic-space-xs);row-gap:var(--ic-space-xxs)}:host(.ic-calendar-small) .month-picker,:host(.ic-calendar-small) .year-picker{width:13.125rem}:host(.ic-calendar-large) .month-picker,:host(.ic-calendar-large) .year-picker{width:20rem}:host .month-picker .month-picker-row,:host .year-picker .year-picker-row{display:inline-grid;grid-template-columns:repeat(3, minmax(0px, 1fr));width:100%;gap:var(--ic-space-xs)}:host(.ic-calendar-small) .month-picker .month-picker-row,:host(.ic-calendar-small) .year-picker .year-picker-row{grid-template-columns:repeat(2, minmax(0, 1fr))}:host .month-picker-button,:host .year-picker-button{width:5rem;--min-width:5rem}:host .month-button,:host .year-button{width:var(--month-button-width)}:host .month-button.focussed,:host .year-button.focussed{z-index:1}:host .month-button::part(button),:host .year-button::part(button){min-width:var(--month-button-width);padding:var(--ic-space-xs) auto}:host .prev-decade.year-button svg{margin-right:calc(-1 * var(--ic-space-xs));--icon-width:var(--ic-space-md);--icon-height:var(--ic-space-md)}:host(.ic-calendar-small) .prev-decade.year-button svg{margin-right:calc(-1 * calc(var(--ic-space-md) + var(--ic-space-1px)))}:host(.ic-calendar-large) .prev-decade.year-button svg{margin-right:calc(-1 * calc(var(--ic-space-md) + var(--ic-space-xxs)))}:host .prev-decade.year-button::part(button){padding-left:0;padding-right:var(--ic-space-lg);gap:var(--ic-space-xxxs);display:inline-grid;grid-template-columns:1.5rem 1fr}:host(.ic-calendar-small) .prev-decade.year-button::part(button){padding-left:0;padding-right:calc(var(--ic-space-lg) + var(--ic-space-xxs))}:host .next-decade.year-button svg{margin-left:calc(-1 * var(--ic-space-lg));--icon-width:var(--ic-space-md);--icon-height:var(--ic-space-md)}:host(.ic-calendar-small) .next-decade.year-button svg,:host(.ic-calendar-large) .next-decade.year-button svg{margin-left:calc(\n -1 * (var(--ic-space-lg) + var(--ic-space-xs) + var(--ic-space-1px))\n )}:host .next-decade.year-button::part(button){padding-right:0;padding-left:var(--ic-space-lg);gap:var(--ic-space-xxxs);display:inline-grid;grid-template-columns:1fr 1.5rem}:host(.ic-calendar-small) .next-decade.year-button::part(button),:host(.ic-calendar-large) .next-decade.year-button::part(button){padding-left:calc(var(--ic-space-xl) - var(--ic-space-xxs))}:host .bottom-buttons{display:flex;justify-content:space-between;align-items:center;align-self:stretch;animation:fade-in-buttons var(--ic-transition-duration-slow)}:host .bottom-buttons.no-today{align-items:flex-end;flex-direction:column}:host .bottom-buttons.hidden{display:none}:host .calendar{display:flex;flex-direction:column;align-items:flex-start;width:15.75rem;animation:fade-in-buttons var(--ic-transition-duration-slow)}:host(.ic-calendar-large) .calendar{width:19.25rem}:host(.ic-calendar-small) .calendar{padding-bottom:var(--ic-space-xxs);width:14rem}:host .hidden{display:none}:host .weekdays-container{display:flex;align-self:stretch}:host .weekdays{display:flex;flex-grow:1;justify-content:space-between;align-items:flex-start;padding-bottom:var(--ic-space-xs)}:host .calendar-days-container{display:flex;flex-wrap:wrap;justify-content:space-between;row-gap:var(--ic-space-xs);padding:var(--ic-space-xxs) 0;min-height:16rem;align-content:flex-start}:host(.ic-calendar-small) .calendar-days-container{padding:var(--ic-space-xxxs) 0;min-height:14.5rem}:host(.ic-calendar-large) .calendar-days-container{padding:var(--ic-space-xs) 0;min-height:17.5rem}:host .calendar-days-container tr{display:flex;flex-grow:1;justify-content:space-between;border-spacing:0}:host .calendar-day-header{display:flex;width:2rem;padding:var(--ic-space-xxs) 0;justify-content:center;align-items:center;color:var(--ic-typography-color, var(--ic-color-text-primary));--ic-typography-color:var(--ic-calendar-label);text-align:center;font:var(--ic-font-caption);letter-spacing:var(--ic-font-letter-spacing-0pt0025)}:host(.ic-calendar-large) .calendar-day-header{padding:var(--ic-space-xxs)}:host .day-button-container{display:flex;justify-content:center;align-items:center;width:2.25rem;height:2.25rem}:host(.ic-calendar-small) .day-button-container{width:2rem;height:2rem}:host(.ic-calendar-large) .day-button-container{width:2.5rem;height:2.5rem}:host .day-button{display:flex;position:relative;justify-content:center;align-items:center;border:0;border-radius:2rem;background-color:var(--ic-calendar-bg);width:2rem;height:2rem;cursor:pointer;transition:var(--ic-easing-transition-fast);z-index:0}:host .day-button.disabled{cursor:default}:host(.ic-calendar-large) .day-button{width:2.25rem;height:2.25rem}:host(.ic-calendar-small) .day-button{width:1.75rem;height:1.75rem}:host .day-button ic-typography{width:1.75rem;--ic-typography-color:var(--ic-calendar-date-label-default)}:host .day-button.outside-range ic-typography{--ic-typography-color:var(--ic-calendar-date-label-disabled)}:host .day-button.outside-month ic-typography{font-weight:var(--ic-font-weight-regular) !important}:host .day-button.outside-month:not(.outside-range):not(.selected) ic-typography{--ic-typography-color:var(--ic-calendar-date-label-default)}:host .day-button:hover:not(.disabled){background-color:var(--ic-calendar-date-default-bg-hover)}:host .day-button:active:not(.disabled){background-color:var(--ic-calendar-date-default-bg-pressed)}@media (prefers-reduced-motion: no-preference){:host .day-button:hover:not(.disabled):not(.focussed),:host .day-button:active:not(.disabled):not(.focussed){transition:background-color var(--ic-transition-duration-slow) ease-in-out}}:host .day-button.selected:not(.hidden){background-color:var(--ic-calendar-date-active-bg-default)}:host .day-button.selected ic-typography{--ic-typography-color:var(--ic-calendar-date-label-selected)}:host .day-button.selected:not(.hidden):hover{background-color:var(--ic-calendar-date-active-bg-hover)}:host .day-button.selected:not(.hidden):active{background-color:var(--ic-calendar-date-active-bg-pressed)}:host .day-button.focussed{z-index:1}:host .day-button:focus{outline:none}:host .day-button.focussed:focus{box-shadow:var(--ic-border-focus)}:host .day-button.today:not(.hidden)::after{content:\"\";position:absolute;width:0.875rem;height:0.125rem;bottom:0.4rem;border-radius:var(--ic-border-radius);background-color:var(--ic-calendar-default-underline)}:host(.ic-calendar-small) .day-button.today::after{bottom:0.35rem}:host(.ic-calendar-large) .day-button.today::after{width:1rem}:host .day-button.today.selected::after{background-color:var(--ic-calendar-selected-underline)}:host #select-month-hint,:host #select-year-hint{display:none}.sr-only{position:absolute;left:-9999px}@media (prefers-reduced-motion: reduce){:host .calendar-container,:host .calendar,:host .bottom-buttons{animation:none}}@keyframes fade-in-buttons{0%{opacity:0}50%{opacity:0}100%{opacity:1}}@keyframes fade-in-calendar{0%{display:flex;max-height:0}100%{display:flex;max-height:600px}}@media (forced-colors: active){:host .day-button.today:not(.hidden)::after{background-color:highlight}:host .day-button.selected:not(.hidden){background-color:highlight}:host .day-button.focussed:focus{border:var(--ic-border-hc)}:host .month-button.selected::part(button),:host .year-button.selected::part(button){background-color:highlight}}";
|
|
135
|
+
const IcCalendarStyle0 = icCalendarCss;
|
|
136
|
+
|
|
137
|
+
const FOCUS_TIMER = 100;
|
|
138
|
+
const Calendar$1 = class {
|
|
139
|
+
constructor(hostRef) {
|
|
140
|
+
registerInstance(this, hostRef);
|
|
141
|
+
this.icChange = createEvent(this, "icChange", 7);
|
|
142
|
+
this.icCalendarClearButtonClick = createEvent(this, "icCalendarClearButtonClick", 7);
|
|
143
|
+
this.icCalendarDaySelect = createEvent(this, "icCalendarDaySelect", 7);
|
|
144
|
+
this.icCalendarMonthSelect = createEvent(this, "icCalendarMonthSelect", 7);
|
|
145
|
+
this.icCalendarYearSelect = createEvent(this, "icCalendarYearSelect", 7);
|
|
146
|
+
this.daysOfWeek = [];
|
|
147
|
+
this.dayButtonFocussed = false;
|
|
148
|
+
this.dayPickerKeyboardNav = false;
|
|
149
|
+
this.dialogDescription = "";
|
|
150
|
+
this.focusDay = true;
|
|
151
|
+
this.liveRegionEl = undefined;
|
|
152
|
+
this.monthNames = [];
|
|
153
|
+
this.monthInViewUpdateHandled = false;
|
|
154
|
+
this.parentIsDatePicker = false;
|
|
155
|
+
this.today = new Date();
|
|
156
|
+
this.yearButtonFocussed = false;
|
|
157
|
+
this.clearButtonClicked = false;
|
|
158
|
+
this.currMonthView = [];
|
|
159
|
+
this.currYearPickerView = [];
|
|
160
|
+
this.decadeView = [];
|
|
161
|
+
this.focussedDate = null;
|
|
162
|
+
this.maxDate = null;
|
|
163
|
+
this.minDate = null;
|
|
164
|
+
this.monthPickerVisible = false;
|
|
165
|
+
this.orderedDaysOfWeek = [];
|
|
166
|
+
this.selectedDate = null;
|
|
167
|
+
this.yearPickerVisible = false;
|
|
168
|
+
/**
|
|
169
|
+
* The format in which the date will be displayed.
|
|
170
|
+
*/
|
|
171
|
+
this.dateFormat = "DD/MM/YYYY";
|
|
172
|
+
/**
|
|
173
|
+
* If `true`, the disabled state will be set.
|
|
174
|
+
*/
|
|
175
|
+
this.disabled = false;
|
|
176
|
+
/**
|
|
177
|
+
* The days of the week to disable.
|
|
178
|
+
*/
|
|
179
|
+
this.disableDays = [];
|
|
180
|
+
/**
|
|
181
|
+
* If `true`, dates in the future are not allowed.
|
|
182
|
+
*/
|
|
183
|
+
this.disableFuture = false;
|
|
184
|
+
/**
|
|
185
|
+
* If `true`, dates in the past are not allowed.
|
|
186
|
+
*/
|
|
187
|
+
this.disablePast = false;
|
|
188
|
+
/**
|
|
189
|
+
* The latest date that will be allowed. The value can be in any format supported as `dateFormat`, in ISO 8601 date string format (`yyyy-mm-dd`) or as a JavaScript `Date` object.
|
|
190
|
+
* The value of this prop is ignored if `disableFuture` is set to `true`.
|
|
191
|
+
*/
|
|
192
|
+
this.max = "";
|
|
193
|
+
/**
|
|
194
|
+
* The earliest date that will be allowed. The value can be in any format supported as `dateFormat`, in ISO 8601 date string format (`yyyy-mm-dd`) or as a JavaScript `Date` object.
|
|
195
|
+
* The value of this prop is ignored if `disablePast` is set to `true`.
|
|
196
|
+
*/
|
|
197
|
+
this.min = "";
|
|
198
|
+
/**
|
|
199
|
+
* The date visible when the calendar opens. Used if no date is currently selected.
|
|
200
|
+
* The value can be in any format supported as `dateFormat`, in ISO 8601 date string format (`yyyy-mm-dd`) or as a JavaScript `Date` object.
|
|
201
|
+
*/
|
|
202
|
+
this.openAtDate = "";
|
|
203
|
+
/**
|
|
204
|
+
* If `true`, the `Clear` button on the calendar will be visible.
|
|
205
|
+
*/
|
|
206
|
+
this.showClearButton = true;
|
|
207
|
+
/**
|
|
208
|
+
* If `true`, days outside the current month will be visible in the calendar.
|
|
209
|
+
*/
|
|
210
|
+
this.showDaysOutsideMonth = true;
|
|
211
|
+
/**
|
|
212
|
+
* If `true`, the `Go to today` button on the calendar will be visible.
|
|
213
|
+
*/
|
|
214
|
+
this.showTodayButton = true;
|
|
215
|
+
/**
|
|
216
|
+
* The size of the calendar to be displayed.
|
|
217
|
+
*/
|
|
218
|
+
this.size = "medium";
|
|
219
|
+
/**
|
|
220
|
+
* The first day of the week. `0` for Sunday, `1` for Monday, etc.
|
|
221
|
+
* Default is Monday.
|
|
222
|
+
*/
|
|
223
|
+
this.startOfWeek = IcWeekDays.Monday;
|
|
224
|
+
/**
|
|
225
|
+
* Sets the calendar to the dark or light theme colors. "inherit" will set the color based on the system settings or ic-theme component.
|
|
226
|
+
*/
|
|
227
|
+
this.theme = "inherit";
|
|
228
|
+
/**
|
|
229
|
+
* The value of the calendar and the date visible when the calendar opens.
|
|
230
|
+
* The value can be in any format supported as `dateFormat`, in ISO 8601 date string format (`yyyy-mm-dd`) or as a JavaScript `Date` object.
|
|
231
|
+
*/
|
|
232
|
+
this.value = "";
|
|
233
|
+
this.isValidDateValue = (value) => {
|
|
234
|
+
if (value == null)
|
|
235
|
+
return true;
|
|
236
|
+
if (value instanceof Date) {
|
|
237
|
+
return !isNaN(value.getTime());
|
|
238
|
+
}
|
|
239
|
+
if (typeof value !== "string")
|
|
240
|
+
return false;
|
|
241
|
+
const iso8601Regex = /^\d{4}-\d{2}-\d{2}(?:[T\s]\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?)?$/;
|
|
242
|
+
if (iso8601Regex.test(value)) {
|
|
243
|
+
return !isNaN(Date.parse(value));
|
|
244
|
+
}
|
|
245
|
+
const [a, b, c] = value.split("/").map(Number);
|
|
246
|
+
if ([a, b, c].some(isNaN))
|
|
247
|
+
return false;
|
|
248
|
+
let day, month, year;
|
|
249
|
+
switch (this.dateFormat) {
|
|
250
|
+
case "DD/MM/YYYY":
|
|
251
|
+
[day, month, year] = [a, b, c];
|
|
252
|
+
break;
|
|
253
|
+
case "MM/DD/YYYY":
|
|
254
|
+
[month, day, year] = [a, b, c];
|
|
255
|
+
break;
|
|
256
|
+
case "YYYY/MM/DD":
|
|
257
|
+
[year, month, day] = [a, b, c];
|
|
258
|
+
break;
|
|
259
|
+
default:
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
if (month < 1 || month > 12 || day < 1 || day > 31)
|
|
263
|
+
return false;
|
|
264
|
+
const date = new Date(year, month - 1, day);
|
|
265
|
+
return (date.getFullYear() === year &&
|
|
266
|
+
date.getMonth() === month - 1 &&
|
|
267
|
+
date.getDate() === day);
|
|
268
|
+
};
|
|
269
|
+
this.isPresent = (prop) => prop !== "" && prop !== undefined && prop !== null;
|
|
270
|
+
this.setOpenAtDate = () => {
|
|
271
|
+
var _a;
|
|
272
|
+
let openAt = null;
|
|
273
|
+
if (this.disabled) {
|
|
274
|
+
openAt = new Date();
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
if (this.clearButtonClicked) {
|
|
278
|
+
openAt = this.focussedDate ? this.focussedDate : new Date();
|
|
279
|
+
this.clearButtonClicked = false;
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
if (!this.disabled &&
|
|
283
|
+
this.value != null &&
|
|
284
|
+
this.isValidDateValue(this.value)) {
|
|
285
|
+
openAt = createDate(this.value, this.dateFormat);
|
|
286
|
+
}
|
|
287
|
+
if (!!openAt && dateInRange(openAt, this.minDate, this.maxDate)) {
|
|
288
|
+
const selectedDay = openAt.getDay();
|
|
289
|
+
if (!!this.disableDays &&
|
|
290
|
+
this.disableDays.length > 0 &&
|
|
291
|
+
typeof selectedDay == "number" &&
|
|
292
|
+
this.disableDays.includes(selectedDay)) {
|
|
293
|
+
openAt = createDate((_a = this.value) !== null && _a !== void 0 ? _a : new Date(), this.dateFormat);
|
|
294
|
+
this.setSelectedDate(null);
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
this.setSelectedDate(openAt);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
else if (this.isPresent(this.openAtDate)) {
|
|
301
|
+
openAt = createDate(this.openAtDate, this.dateFormat);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
openAt = new Date();
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
this.setFocussedDate(openAt);
|
|
309
|
+
this.updateMonthInView();
|
|
310
|
+
let dialogDesc = this.getMonthInViewText();
|
|
311
|
+
if (this.selectedDate === null) {
|
|
312
|
+
dialogDesc += " No date selected.";
|
|
313
|
+
}
|
|
314
|
+
dialogDesc += ` Use arrow keys to change day. Press enter or space to select a date${this.parentIsDatePicker ? " or press escape to close the picker" : ""}.`;
|
|
315
|
+
this.dialogDescription = dialogDesc;
|
|
316
|
+
setTimeout(() => this.focusFocussedDay(), FOCUS_TIMER);
|
|
317
|
+
};
|
|
318
|
+
/* Refs & setters */
|
|
319
|
+
this.setFocussedDayEl = (element) => {
|
|
320
|
+
this.focussedDayEl = element;
|
|
321
|
+
};
|
|
322
|
+
this.setFocussedMonthEl = (element) => {
|
|
323
|
+
this.focussedMonthEl = element;
|
|
324
|
+
};
|
|
325
|
+
this.setFocussedYearEl = (element) => {
|
|
326
|
+
this.focussedYearEl = element;
|
|
327
|
+
};
|
|
328
|
+
this.setFocussedYear = (newYear, focus = true) => {
|
|
329
|
+
const prevYear = this.focussedYear;
|
|
330
|
+
this.focussedYear = newYear;
|
|
331
|
+
if (this.yearPickerVisible) {
|
|
332
|
+
const newDecade = Math.floor(newYear / 10) * 10;
|
|
333
|
+
const oldDecade = Math.floor(prevYear / 10) * 10;
|
|
334
|
+
if (newDecade !== oldDecade) {
|
|
335
|
+
this.setDecadeView(newDecade);
|
|
336
|
+
this.setAriaLiveRegionText(this.getDecadeInViewText());
|
|
337
|
+
}
|
|
338
|
+
if (focus) {
|
|
339
|
+
setTimeout(() => {
|
|
340
|
+
if (this.focussedYearEl !== null)
|
|
341
|
+
this.focussedYearEl.setFocus();
|
|
342
|
+
}, FOCUS_TIMER);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
this.setDecadeView(Math.floor(newYear / 10) * 10);
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
this.setFocussedDate = (d) => {
|
|
350
|
+
this.focussedDate = clampDate(d, this.minDate, this.maxDate);
|
|
351
|
+
};
|
|
352
|
+
this.setSelectedDate = (d, emit = true) => {
|
|
353
|
+
if (d === null || !dateMatches(d, this.selectedDate)) {
|
|
354
|
+
this.selectedDate = d;
|
|
355
|
+
this.value = d;
|
|
356
|
+
if (emit) {
|
|
357
|
+
this.icChange.emit(this.setDateChangeEventDetail(d));
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
this.setDateChangeEventDetail = (d) => {
|
|
362
|
+
let UTCDate = null;
|
|
363
|
+
let day = null;
|
|
364
|
+
let month = null;
|
|
365
|
+
let year = null;
|
|
366
|
+
if (d !== null) {
|
|
367
|
+
UTCDate = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
|
|
368
|
+
day = convertToDoubleDigits(d.getDate());
|
|
369
|
+
month = convertToDoubleDigits(d.getMonth() + 1);
|
|
370
|
+
year = d.getFullYear().toString();
|
|
371
|
+
}
|
|
372
|
+
return {
|
|
373
|
+
value: d,
|
|
374
|
+
dateObject: {
|
|
375
|
+
day: day === "" ? null : day,
|
|
376
|
+
month: month === "" ? null : month,
|
|
377
|
+
year: year === "" ? null : year,
|
|
378
|
+
},
|
|
379
|
+
utcValue: UTCDate,
|
|
380
|
+
};
|
|
381
|
+
};
|
|
382
|
+
this.setAriaLiveRegionText = (text) => {
|
|
383
|
+
this.liveRegionEl && (this.liveRegionEl.innerText = text);
|
|
384
|
+
};
|
|
385
|
+
/* Navigation helpers */
|
|
386
|
+
this.goToPreviousMonth = (focusDay = false) => {
|
|
387
|
+
this.focusDay = focusDay;
|
|
388
|
+
this.moveMonths(-1);
|
|
389
|
+
};
|
|
390
|
+
this.goToNextMonth = (focusDay = false) => {
|
|
391
|
+
this.focusDay = focusDay;
|
|
392
|
+
this.moveMonths(1);
|
|
393
|
+
};
|
|
394
|
+
this.goToPreviousYear = (focusDay = false) => {
|
|
395
|
+
if (this.isPrevYearAllowed()) {
|
|
396
|
+
this.focusDay = focusDay;
|
|
397
|
+
this.moveYears(-1);
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
this.goToNextYear = (focusDay = false) => {
|
|
401
|
+
if (this.isNextYearAllowed()) {
|
|
402
|
+
this.focusDay = focusDay;
|
|
403
|
+
this.moveYears(1);
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
this.moveDays = (numDays) => {
|
|
407
|
+
if (this.focussedDate) {
|
|
408
|
+
const d = new Date(this.focussedDate);
|
|
409
|
+
d.setDate(d.getDate() + numDays);
|
|
410
|
+
this.setFocussedDate(d);
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
this.moveMonths = (numMonths) => {
|
|
414
|
+
if (this.focussedDate) {
|
|
415
|
+
const newMonth = this.focussedDate.getMonth() + numMonths;
|
|
416
|
+
const min = new Date(new Date(getMonthStart(this.focussedDate)).setMonth(newMonth));
|
|
417
|
+
const max = getMonthEnd(min);
|
|
418
|
+
const newDate = new Date(new Date(this.focussedDate).setMonth(newMonth));
|
|
419
|
+
this.setFocussedDate(clampDate(newDate, min, max));
|
|
420
|
+
if (this.monthPickerVisible === false &&
|
|
421
|
+
this.yearPickerVisible === false &&
|
|
422
|
+
this.monthInViewUpdateHandled === false) {
|
|
423
|
+
this.setAriaLiveRegionText(this.getMonthInViewText());
|
|
424
|
+
}
|
|
425
|
+
this.monthInViewUpdateHandled = false;
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
this.moveYears = (numYears) => {
|
|
429
|
+
if (this.focussedDate) {
|
|
430
|
+
const newYear = this.focussedDate.getFullYear() + numYears;
|
|
431
|
+
const min = new Date(new Date(getMonthStart(this.focussedDate)).setFullYear(newYear));
|
|
432
|
+
const max = getMonthEnd(min);
|
|
433
|
+
const newDate = new Date(new Date(this.focussedDate).setFullYear(newYear));
|
|
434
|
+
this.setFocussedDate(clampDate(newDate, min, max));
|
|
435
|
+
if (this.monthPickerVisible === false &&
|
|
436
|
+
this.yearPickerVisible === false &&
|
|
437
|
+
this.monthInViewUpdateHandled === false) {
|
|
438
|
+
this.setAriaLiveRegionText(this.getMonthInViewText());
|
|
439
|
+
}
|
|
440
|
+
this.monthInViewUpdateHandled = false;
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
this.updateFocussedMonth = (adjust) => {
|
|
444
|
+
const d = new Date(this.focussedYear, this.focussedMonth, 1);
|
|
445
|
+
d.setMonth(this.focussedMonth + adjust);
|
|
446
|
+
const newDate = clampDate(d, this.minDate, this.maxDate);
|
|
447
|
+
this.focussedMonth = newDate.getMonth();
|
|
448
|
+
setTimeout(() => this.focussedMonthEl.setFocus(), FOCUS_TIMER);
|
|
449
|
+
};
|
|
450
|
+
this.updateFocussedYear = (adjust, focusYear = true) => {
|
|
451
|
+
const d = new Date(new Date().setFullYear(this.focussedYear + adjust));
|
|
452
|
+
const newDate = clampDate(d, this.minDate, this.maxDate);
|
|
453
|
+
this.setFocussedYear(newDate.getFullYear(), focusYear);
|
|
454
|
+
};
|
|
455
|
+
this.getNextDayToFocus = (currDay, forward, level = 1) => {
|
|
456
|
+
var _a;
|
|
457
|
+
const move = forward ? 1 : -1;
|
|
458
|
+
const nextDay = new Date(currDay);
|
|
459
|
+
nextDay.setDate(nextDay.getDate() + move);
|
|
460
|
+
return ((_a = this.disableDays) === null || _a === void 0 ? void 0 : _a.includes(Number(nextDay.getDay())))
|
|
461
|
+
? this.getNextDayToFocus(nextDay, forward, level + 1)
|
|
462
|
+
: level;
|
|
463
|
+
};
|
|
464
|
+
/* Focus helpers */
|
|
465
|
+
this.focusFirstElement = () => {
|
|
466
|
+
var _a;
|
|
467
|
+
(_a = this.monthButtonEl) === null || _a === void 0 ? void 0 : _a.setFocus();
|
|
468
|
+
};
|
|
469
|
+
this.focusLastElement = () => {
|
|
470
|
+
if (this.showClearButton &&
|
|
471
|
+
this.clearButtonEl &&
|
|
472
|
+
!this.clearButtonEl.disabled) {
|
|
473
|
+
this.clearButtonEl.setFocus();
|
|
474
|
+
}
|
|
475
|
+
else if (this.showTodayButton &&
|
|
476
|
+
this.todayButtonEl &&
|
|
477
|
+
!this.todayButtonEl.disabled) {
|
|
478
|
+
this.todayButtonEl.setFocus();
|
|
479
|
+
}
|
|
480
|
+
else if (this.monthPickerVisible) {
|
|
481
|
+
this.focussedMonthEl.setFocus();
|
|
482
|
+
}
|
|
483
|
+
else if (this.yearPickerVisible) {
|
|
484
|
+
this.focussedYearEl.setFocus();
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
this.focussedDayEl.focus();
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
this.focusFocussedDay = () => {
|
|
491
|
+
this.focussedDayEl.focus();
|
|
492
|
+
};
|
|
493
|
+
/* Click handlers */
|
|
494
|
+
this.monthButtonClickHandler = () => {
|
|
495
|
+
this.yearPickerVisible = false;
|
|
496
|
+
this.focusDay = false;
|
|
497
|
+
this.monthPickerVisible = !this.monthPickerVisible;
|
|
498
|
+
if (this.monthPickerVisible) {
|
|
499
|
+
this.setAriaLiveRegionText("Month picker view open");
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
this.setMonthSelectedLiveRegionText();
|
|
503
|
+
this.icCalendarMonthSelect.emit();
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
this.yearButtonClickHandler = () => {
|
|
507
|
+
this.monthPickerVisible = false;
|
|
508
|
+
this.focusDay = false;
|
|
509
|
+
this.yearPickerVisible = !this.yearPickerVisible;
|
|
510
|
+
if (this.yearPickerVisible) {
|
|
511
|
+
this.setAriaLiveRegionText(`Year picker view open. ${this.getDecadeInViewText()}`);
|
|
512
|
+
}
|
|
513
|
+
else {
|
|
514
|
+
this.setYearSelectedLiveRegionText();
|
|
515
|
+
this.icCalendarYearSelect.emit();
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
this.todayButtonClickHandler = () => {
|
|
519
|
+
this.yearPickerVisible = false;
|
|
520
|
+
this.monthPickerVisible = false;
|
|
521
|
+
this.setFocussedDate(new Date());
|
|
522
|
+
this.setAriaLiveRegionText(this.getMonthInViewText());
|
|
523
|
+
setTimeout(() => this.focusFocussedDay(), FOCUS_TIMER);
|
|
524
|
+
};
|
|
525
|
+
this.clearButtonClickHandler = () => {
|
|
526
|
+
this.clearButtonClicked = true;
|
|
527
|
+
this.selectedDate && this.setFocussedDate(this.selectedDate);
|
|
528
|
+
this.setSelectedDate(null);
|
|
529
|
+
this.icChange.emit(this.setDateChangeEventDetail(this.selectedDate));
|
|
530
|
+
let text = "Selected date cleared.";
|
|
531
|
+
if (!this.monthPickerVisible && !this.yearPickerVisible) {
|
|
532
|
+
text += ` ${this.getMonthInViewText()}`;
|
|
533
|
+
}
|
|
534
|
+
if (this.monthPickerVisible) {
|
|
535
|
+
this.focussedMonthEl.setFocus();
|
|
536
|
+
}
|
|
537
|
+
else if (this.yearPickerVisible) {
|
|
538
|
+
this.focussedYearEl.setFocus();
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
this.focusFocussedDay();
|
|
542
|
+
}
|
|
543
|
+
this.setAriaLiveRegionText(text);
|
|
544
|
+
};
|
|
545
|
+
this.monthYearNavClickHandler = (ev) => {
|
|
546
|
+
const target = ev.target;
|
|
547
|
+
switch (target.id) {
|
|
548
|
+
case "previous-month-button":
|
|
549
|
+
this.goToPreviousMonth(this.dayButtonFocussed);
|
|
550
|
+
break;
|
|
551
|
+
case "next-month-button":
|
|
552
|
+
this.goToNextMonth(this.dayButtonFocussed);
|
|
553
|
+
break;
|
|
554
|
+
case "previous-year-button":
|
|
555
|
+
this.goToPreviousYear(this.dayButtonFocussed);
|
|
556
|
+
break;
|
|
557
|
+
case "next-year-button":
|
|
558
|
+
this.goToNextYear(this.dayButtonFocussed);
|
|
559
|
+
break;
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
this.handleCalendarClick = (event) => {
|
|
563
|
+
this.clearDialogDescription();
|
|
564
|
+
event.stopImmediatePropagation();
|
|
565
|
+
};
|
|
566
|
+
/* Keyboard handlers */
|
|
567
|
+
this.handleCalendarKeyDown = (ev) => {
|
|
568
|
+
let handled = true;
|
|
569
|
+
switch (ev.key) {
|
|
570
|
+
case "ArrowDown":
|
|
571
|
+
this.dayPickerKeyboardNav = true;
|
|
572
|
+
this.moveDays(7);
|
|
573
|
+
break;
|
|
574
|
+
case "ArrowUp":
|
|
575
|
+
this.dayPickerKeyboardNav = true;
|
|
576
|
+
this.moveDays(-7);
|
|
577
|
+
break;
|
|
578
|
+
case "ArrowLeft":
|
|
579
|
+
this.dayPickerKeyboardNav = true;
|
|
580
|
+
if (this.focussedDate)
|
|
581
|
+
this.moveDays(-1 * this.getNextDayToFocus(this.focussedDate, false));
|
|
582
|
+
break;
|
|
583
|
+
case "ArrowRight":
|
|
584
|
+
this.dayPickerKeyboardNav = true;
|
|
585
|
+
if (this.focussedDate)
|
|
586
|
+
this.moveDays(this.getNextDayToFocus(this.focussedDate, true));
|
|
587
|
+
break;
|
|
588
|
+
case "PageUp":
|
|
589
|
+
this.dayPickerKeyboardNav = true;
|
|
590
|
+
ev.shiftKey ? this.moveYears(-1) : this.moveMonths(-1);
|
|
591
|
+
break;
|
|
592
|
+
case "PageDown":
|
|
593
|
+
this.dayPickerKeyboardNav = true;
|
|
594
|
+
ev.shiftKey ? this.moveYears(1) : this.moveMonths(1);
|
|
595
|
+
break;
|
|
596
|
+
case "Home":
|
|
597
|
+
this.dayPickerKeyboardNav = true;
|
|
598
|
+
this.setFocussedDate(new Date(this.focussedYear, this.focussedMonth, 1));
|
|
599
|
+
break;
|
|
600
|
+
case "End":
|
|
601
|
+
this.dayPickerKeyboardNav = true;
|
|
602
|
+
this.setFocussedDate(new Date(this.focussedYear, this.focussedMonth + 1, 0));
|
|
603
|
+
break;
|
|
604
|
+
case "Tab":
|
|
605
|
+
handled = this.calendarTabHandler(ev);
|
|
606
|
+
break;
|
|
607
|
+
default:
|
|
608
|
+
handled = false;
|
|
609
|
+
break;
|
|
610
|
+
}
|
|
611
|
+
if (handled) {
|
|
612
|
+
ev.preventDefault();
|
|
613
|
+
}
|
|
614
|
+
};
|
|
615
|
+
this.monthPickerKeyDownHandler = (ev) => {
|
|
616
|
+
let handled = true;
|
|
617
|
+
switch (ev.key) {
|
|
618
|
+
case "ArrowUp":
|
|
619
|
+
case "ArrowLeft":
|
|
620
|
+
this.updateFocussedMonth(-1);
|
|
621
|
+
break;
|
|
622
|
+
case "ArrowDown":
|
|
623
|
+
case "ArrowRight":
|
|
624
|
+
this.updateFocussedMonth(1);
|
|
625
|
+
break;
|
|
626
|
+
case "Home":
|
|
627
|
+
this.updateFocussedMonth(-this.focussedMonth);
|
|
628
|
+
break;
|
|
629
|
+
case "End":
|
|
630
|
+
this.updateFocussedMonth(11 - this.focussedMonth);
|
|
631
|
+
break;
|
|
632
|
+
case "Tab":
|
|
633
|
+
handled = this.calendarTabHandler(ev);
|
|
634
|
+
break;
|
|
635
|
+
case "Escape":
|
|
636
|
+
ev.stopImmediatePropagation();
|
|
637
|
+
this.monthPickerVisible = false;
|
|
638
|
+
setTimeout(() => this.focusFocussedDay(), FOCUS_TIMER);
|
|
639
|
+
break;
|
|
640
|
+
default:
|
|
641
|
+
handled = false;
|
|
642
|
+
}
|
|
643
|
+
if (handled) {
|
|
644
|
+
ev.preventDefault();
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
this.yearPickerKeyDownHandler = (ev) => {
|
|
648
|
+
let handled = true;
|
|
649
|
+
switch (ev.key) {
|
|
650
|
+
case "ArrowUp":
|
|
651
|
+
case "ArrowLeft":
|
|
652
|
+
this.updateFocussedYear(-1);
|
|
653
|
+
break;
|
|
654
|
+
case "ArrowDown":
|
|
655
|
+
case "ArrowRight":
|
|
656
|
+
this.updateFocussedYear(1);
|
|
657
|
+
break;
|
|
658
|
+
case "Home":
|
|
659
|
+
if (this.focussedYear > this.decadeStart) {
|
|
660
|
+
this.updateFocussedYear(this.decadeStart - this.focussedYear);
|
|
661
|
+
}
|
|
662
|
+
break;
|
|
663
|
+
case "End":
|
|
664
|
+
if (this.focussedYear < this.decadeEnd) {
|
|
665
|
+
this.updateFocussedYear(this.decadeEnd - this.focussedYear);
|
|
666
|
+
}
|
|
667
|
+
break;
|
|
668
|
+
case "PageUp":
|
|
669
|
+
this.updateFocussedYear(-10);
|
|
670
|
+
break;
|
|
671
|
+
case "PageDown":
|
|
672
|
+
this.updateFocussedYear(10);
|
|
673
|
+
break;
|
|
674
|
+
case "Tab":
|
|
675
|
+
handled = this.calendarTabHandler(ev);
|
|
676
|
+
break;
|
|
677
|
+
case "Escape":
|
|
678
|
+
ev.stopImmediatePropagation();
|
|
679
|
+
this.yearPickerVisible = false;
|
|
680
|
+
setTimeout(() => this.focusFocussedDay(), FOCUS_TIMER);
|
|
681
|
+
break;
|
|
682
|
+
default:
|
|
683
|
+
handled = false;
|
|
684
|
+
}
|
|
685
|
+
if (handled) {
|
|
686
|
+
ev.preventDefault();
|
|
687
|
+
}
|
|
688
|
+
};
|
|
689
|
+
this.monthButtonKeyDownHandler = (ev) => {
|
|
690
|
+
let handled = false;
|
|
691
|
+
switch (ev.key) {
|
|
692
|
+
case "ArrowLeft":
|
|
693
|
+
case "ArrowUp":
|
|
694
|
+
handled = true;
|
|
695
|
+
this.goToPreviousMonth();
|
|
696
|
+
break;
|
|
697
|
+
case "ArrowRight":
|
|
698
|
+
case "ArrowDown":
|
|
699
|
+
handled = true;
|
|
700
|
+
this.goToNextMonth();
|
|
701
|
+
break;
|
|
702
|
+
case "Home":
|
|
703
|
+
handled = true;
|
|
704
|
+
this.focusDay = false;
|
|
705
|
+
this.moveMonths(-this.monthInView);
|
|
706
|
+
break;
|
|
707
|
+
case "End":
|
|
708
|
+
handled = true;
|
|
709
|
+
this.focusDay = false;
|
|
710
|
+
this.moveMonths(11 - this.monthInView);
|
|
711
|
+
break;
|
|
712
|
+
case "Tab":
|
|
713
|
+
if (ev.shiftKey) {
|
|
714
|
+
handled = true;
|
|
715
|
+
this.focusLastElement();
|
|
716
|
+
}
|
|
717
|
+
break;
|
|
718
|
+
case "Escape":
|
|
719
|
+
if (this.monthPickerVisible) {
|
|
720
|
+
this.monthPickerVisible = false;
|
|
721
|
+
ev.stopImmediatePropagation();
|
|
722
|
+
}
|
|
723
|
+
break;
|
|
724
|
+
}
|
|
725
|
+
if (handled) {
|
|
726
|
+
ev.preventDefault();
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
this.yearButtonKeyDownHandler = (ev) => {
|
|
730
|
+
let handled = false;
|
|
731
|
+
switch (ev.key) {
|
|
732
|
+
case "ArrowLeft":
|
|
733
|
+
case "ArrowUp":
|
|
734
|
+
handled = true;
|
|
735
|
+
this.goToPreviousYear();
|
|
736
|
+
break;
|
|
737
|
+
case "ArrowRight":
|
|
738
|
+
case "ArrowDown":
|
|
739
|
+
handled = true;
|
|
740
|
+
this.goToNextYear();
|
|
741
|
+
break;
|
|
742
|
+
case "Home":
|
|
743
|
+
if (this.yearPickerVisible && this.yearInView > this.decadeStart) {
|
|
744
|
+
handled = true;
|
|
745
|
+
this.moveYears(this.decadeStart - this.yearInView);
|
|
746
|
+
}
|
|
747
|
+
break;
|
|
748
|
+
case "End":
|
|
749
|
+
if (this.yearPickerVisible && this.yearInView < this.decadeEnd) {
|
|
750
|
+
handled = true;
|
|
751
|
+
this.moveYears(this.decadeEnd - this.focussedYear);
|
|
752
|
+
}
|
|
753
|
+
break;
|
|
754
|
+
case "PageUp":
|
|
755
|
+
handled = true;
|
|
756
|
+
this.focusDay = false;
|
|
757
|
+
this.moveYears(-10);
|
|
758
|
+
break;
|
|
759
|
+
case "PageDown":
|
|
760
|
+
handled = true;
|
|
761
|
+
this.focusDay = false;
|
|
762
|
+
this.moveYears(10);
|
|
763
|
+
break;
|
|
764
|
+
case "Escape":
|
|
765
|
+
if (this.yearPickerVisible) {
|
|
766
|
+
this.yearPickerVisible = false;
|
|
767
|
+
ev.stopImmediatePropagation();
|
|
768
|
+
}
|
|
769
|
+
break;
|
|
770
|
+
}
|
|
771
|
+
if (handled) {
|
|
772
|
+
ev.preventDefault();
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
this.todayButtonKeyDownHandler = (ev) => {
|
|
776
|
+
var _a;
|
|
777
|
+
if (ev.key === "Tab" &&
|
|
778
|
+
!ev.shiftKey &&
|
|
779
|
+
((_a = this.clearButtonEl) === null || _a === void 0 ? void 0 : _a.disabled) &&
|
|
780
|
+
this.parentIsDatePicker) {
|
|
781
|
+
this.focusFirstElement();
|
|
782
|
+
ev.preventDefault();
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
this.clearButtonKeyDownHandler = (ev) => {
|
|
786
|
+
if (ev.key === "Tab" && !ev.shiftKey && this.parentIsDatePicker) {
|
|
787
|
+
this.focusFirstElement();
|
|
788
|
+
ev.preventDefault();
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
this.calendarTabHandler = (ev) => {
|
|
792
|
+
var _a, _b;
|
|
793
|
+
let handled = false;
|
|
794
|
+
if (!ev.shiftKey &&
|
|
795
|
+
(!this.showTodayButton || this.isCurrentMonth()) &&
|
|
796
|
+
(!this.showClearButton || ((_a = this.clearButtonEl) === null || _a === void 0 ? void 0 : _a.disabled)) &&
|
|
797
|
+
this.parentIsDatePicker) {
|
|
798
|
+
this.focusFirstElement();
|
|
799
|
+
handled = true;
|
|
800
|
+
}
|
|
801
|
+
else if (ev.shiftKey) {
|
|
802
|
+
(_b = this.yearButtonEl) === null || _b === void 0 ? void 0 : _b.setFocus();
|
|
803
|
+
handled = true;
|
|
804
|
+
}
|
|
805
|
+
return handled;
|
|
806
|
+
};
|
|
807
|
+
/* Utility functions */
|
|
808
|
+
this.setMonthSelectedLiveRegionText = () => {
|
|
809
|
+
this.setAriaLiveRegionText(`${this.monthNames[this.monthInView]} selected. ${this.getMonthInViewText()}`);
|
|
810
|
+
};
|
|
811
|
+
this.setYearSelectedLiveRegionText = () => {
|
|
812
|
+
this.setAriaLiveRegionText(`${this.yearInView} selected. ${this.getMonthInViewText()}`);
|
|
813
|
+
};
|
|
814
|
+
this.setDecadeView = (start) => {
|
|
815
|
+
let currYear = start - 1;
|
|
816
|
+
const decadeArr = [];
|
|
817
|
+
while (currYear <= start + 10) {
|
|
818
|
+
decadeArr.push(currYear);
|
|
819
|
+
currYear++;
|
|
820
|
+
}
|
|
821
|
+
this.decadeView = decadeArr;
|
|
822
|
+
this.decadeStart = decadeArr[1];
|
|
823
|
+
this.decadeEnd = decadeArr[10];
|
|
824
|
+
};
|
|
825
|
+
this.getMonthInViewText = () => {
|
|
826
|
+
return `${this.monthNames[this.monthInView]} ${this.yearInView} currently in view.`;
|
|
827
|
+
};
|
|
828
|
+
this.getDecadeInViewText = () => {
|
|
829
|
+
return `${this.decadeStart} to ${this.decadeEnd} currently in view.`;
|
|
830
|
+
};
|
|
831
|
+
this.isPrevYearAllowed = () => {
|
|
832
|
+
return this.isYearAllowed(this.yearInView - 1);
|
|
833
|
+
};
|
|
834
|
+
this.isNextYearAllowed = () => {
|
|
835
|
+
return this.isYearAllowed(this.yearInView + 1);
|
|
836
|
+
};
|
|
837
|
+
this.isYearAllowed = (yr) => yearInRange(yr, this.minDate, this.maxDate);
|
|
838
|
+
this.getMonthView = (date) => {
|
|
839
|
+
const start = getWeekStart(getMonthStart(date), this.startOfWeek);
|
|
840
|
+
const end = addSixWeeks(start);
|
|
841
|
+
const days = [];
|
|
842
|
+
let current = start;
|
|
843
|
+
while (!dateMatches(current, end)) {
|
|
844
|
+
days.push(current);
|
|
845
|
+
current = new Date(current);
|
|
846
|
+
current.setDate(current.getDate() + 1);
|
|
847
|
+
}
|
|
848
|
+
days.push(current);
|
|
849
|
+
return days;
|
|
850
|
+
};
|
|
851
|
+
this.isCurrentMonth = () => {
|
|
852
|
+
const d = new Date();
|
|
853
|
+
return (d.getFullYear() === this.yearInView && d.getMonth() === this.monthInView);
|
|
854
|
+
};
|
|
855
|
+
this.updateMonthInView = () => {
|
|
856
|
+
if (this.focussedDate) {
|
|
857
|
+
this.currMonthView = this.getMonthView(this.focussedDate);
|
|
858
|
+
this.focussedDay = this.focussedDate.getDate();
|
|
859
|
+
this.monthInView = this.focussedDate.getMonth();
|
|
860
|
+
this.yearInView = this.focussedDate.getFullYear();
|
|
861
|
+
if (this.dayPickerKeyboardNav) {
|
|
862
|
+
this.monthInViewUpdateHandled = true;
|
|
863
|
+
this.setAriaLiveRegionText(this.getMonthInViewText());
|
|
864
|
+
this.dayPickerKeyboardNav = false;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
/* Mouse handlers */
|
|
869
|
+
this.navButtonMouseDownHandler = (ev) => {
|
|
870
|
+
ev.preventDefault();
|
|
871
|
+
};
|
|
872
|
+
this.handleCalendarMouseDown = (event) => {
|
|
873
|
+
const target = event.target;
|
|
874
|
+
if (target.tagName !== "IC-BUTTON") {
|
|
875
|
+
event.preventDefault();
|
|
876
|
+
}
|
|
877
|
+
};
|
|
878
|
+
this.handleSelectDay = (day) => {
|
|
879
|
+
this.setSelectedDate(day);
|
|
880
|
+
this.setFocussedDate(day);
|
|
881
|
+
this.icCalendarDaySelect.emit();
|
|
882
|
+
};
|
|
883
|
+
this.handleSelectMonth = (month) => {
|
|
884
|
+
this.moveMonths(month - this.monthInView);
|
|
885
|
+
setTimeout(() => {
|
|
886
|
+
var _a;
|
|
887
|
+
(_a = this.monthButtonEl) === null || _a === void 0 ? void 0 : _a.setFocus();
|
|
888
|
+
this.monthPickerVisible = false;
|
|
889
|
+
this.setMonthSelectedLiveRegionText();
|
|
890
|
+
this.icCalendarMonthSelect.emit();
|
|
891
|
+
}, FOCUS_TIMER);
|
|
892
|
+
};
|
|
893
|
+
this.handleSelectYear = (year) => {
|
|
894
|
+
const yrPos = this.decadeView.indexOf(year);
|
|
895
|
+
if (yrPos > 0 && yrPos < this.decadeView.length - 1) {
|
|
896
|
+
this.moveYears(year - this.yearInView);
|
|
897
|
+
this.focusDay = false;
|
|
898
|
+
const monthName = this.monthNames[this.monthInView];
|
|
899
|
+
this.setAriaLiveRegionText(`${year} selected. ${monthName} ${year} currently in view.`);
|
|
900
|
+
setTimeout(() => {
|
|
901
|
+
var _a;
|
|
902
|
+
(_a = this.yearButtonEl) === null || _a === void 0 ? void 0 : _a.setFocus();
|
|
903
|
+
this.yearPickerVisible = false;
|
|
904
|
+
this.icCalendarYearSelect.emit();
|
|
905
|
+
}, FOCUS_TIMER);
|
|
906
|
+
}
|
|
907
|
+
else {
|
|
908
|
+
const moveYears = year - this.focussedYear > 0 ? 10 : -10;
|
|
909
|
+
this.updateFocussedYear(moveYears, this.yearButtonFocussed);
|
|
910
|
+
this.setAriaLiveRegionText(this.getDecadeInViewText());
|
|
911
|
+
}
|
|
912
|
+
};
|
|
913
|
+
this.onDayButtonFocusHandler = () => {
|
|
914
|
+
this.dayButtonFocussed = true;
|
|
915
|
+
};
|
|
916
|
+
this.onDayButtonBlurHandler = () => {
|
|
917
|
+
this.dayButtonFocussed = false;
|
|
918
|
+
};
|
|
919
|
+
this.onYearButtonFocusHandler = () => {
|
|
920
|
+
this.yearButtonFocussed = true;
|
|
921
|
+
};
|
|
922
|
+
this.onYearButtonBlurHandler = () => {
|
|
923
|
+
this.yearButtonFocussed = false;
|
|
924
|
+
};
|
|
925
|
+
/* Render helpers */
|
|
926
|
+
this.renderMonthYearNavButton = (id, flip, disabled) => {
|
|
927
|
+
const buttonSize = this.size;
|
|
928
|
+
return (h("ic-button", { id: id, disableTooltip: true, disabled: disabled, onClick: this.monthYearNavClickHandler, class: { flip: flip }, variant: "icon-tertiary", innerHTML: chevron, size: buttonSize, tabIndex: -1, "aria-label": `Go to ${id.slice(0, -7).replace("-", " ")}`, onMouseDown: this.navButtonMouseDownHandler }));
|
|
929
|
+
};
|
|
930
|
+
this.previousMonthButton = () => {
|
|
931
|
+
let disabled = false;
|
|
932
|
+
if (this.disabled) {
|
|
933
|
+
disabled = true;
|
|
934
|
+
}
|
|
935
|
+
else {
|
|
936
|
+
if (this.focussedDate !== null && this.minDate !== null) {
|
|
937
|
+
const yearMatch = this.focussedDate.getFullYear() === this.minDate.getFullYear();
|
|
938
|
+
if (yearMatch) {
|
|
939
|
+
disabled = this.monthInView - 1 < this.minDate.getMonth();
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
return this.renderMonthYearNavButton("previous-month-button", true, disabled);
|
|
944
|
+
};
|
|
945
|
+
this.nextMonthButton = () => {
|
|
946
|
+
let disabled = false;
|
|
947
|
+
if (this.disabled) {
|
|
948
|
+
disabled = true;
|
|
949
|
+
}
|
|
950
|
+
else {
|
|
951
|
+
if (this.focussedDate !== null && this.maxDate !== null) {
|
|
952
|
+
const yearMatch = this.focussedDate.getFullYear() === this.maxDate.getFullYear();
|
|
953
|
+
if (yearMatch) {
|
|
954
|
+
disabled = this.monthInView + 1 > this.maxDate.getMonth();
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
return this.renderMonthYearNavButton("next-month-button", false, disabled);
|
|
959
|
+
};
|
|
960
|
+
this.previousYearButton = () => {
|
|
961
|
+
return this.renderMonthYearNavButton("previous-year-button", true, this.disabled || !this.isPrevYearAllowed());
|
|
962
|
+
};
|
|
963
|
+
this.nextYearButton = () => {
|
|
964
|
+
return this.renderMonthYearNavButton("next-year-button", false, this.disabled || !this.isNextYearAllowed());
|
|
965
|
+
};
|
|
966
|
+
}
|
|
967
|
+
watchDisabledHandler() {
|
|
968
|
+
removeDisabledFalse(this.disabled, this.el);
|
|
969
|
+
if (this.disabled) {
|
|
970
|
+
this.setSelectedDate(null);
|
|
971
|
+
}
|
|
972
|
+
else {
|
|
973
|
+
this.setOpenAtDate();
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
watchDisableFutureHandler() {
|
|
977
|
+
this.watchMaxHandler();
|
|
978
|
+
}
|
|
979
|
+
watchDisablePastHandler() {
|
|
980
|
+
this.watchMinHandler();
|
|
981
|
+
}
|
|
982
|
+
watchMaxHandler() {
|
|
983
|
+
if (this.disableFuture) {
|
|
984
|
+
this.maxDate = new Date();
|
|
985
|
+
}
|
|
986
|
+
else {
|
|
987
|
+
this.maxDate = createDate(this.max, this.dateFormat);
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
watchMinHandler() {
|
|
991
|
+
if (this.disablePast) {
|
|
992
|
+
this.minDate = new Date();
|
|
993
|
+
}
|
|
994
|
+
else {
|
|
995
|
+
this.minDate = createDate(this.min, this.dateFormat);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
watchStartOfWeekHandler() {
|
|
999
|
+
this.orderedDaysOfWeek = this.daysOfWeek
|
|
1000
|
+
.slice(this.startOfWeek)
|
|
1001
|
+
.concat(this.daysOfWeek.slice(0, this.startOfWeek));
|
|
1002
|
+
this.updateMonthInView();
|
|
1003
|
+
}
|
|
1004
|
+
valueChanged(newValue, oldValue, propName) {
|
|
1005
|
+
if (newValue !== oldValue && this.isValidDateValue(newValue)) {
|
|
1006
|
+
if (propName === "value") {
|
|
1007
|
+
this.value = newValue;
|
|
1008
|
+
}
|
|
1009
|
+
this.setOpenAtDate();
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
watchFocussedDateHandler(current, previous) {
|
|
1013
|
+
if (previous === null ||
|
|
1014
|
+
!(previous.getFullYear() === current.getFullYear() &&
|
|
1015
|
+
previous.getMonth() === current.getMonth())) {
|
|
1016
|
+
this.updateMonthInView();
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
watchMonthInViewHandler() {
|
|
1020
|
+
this.focussedMonth = this.monthInView;
|
|
1021
|
+
}
|
|
1022
|
+
watchYearInViewHandler() {
|
|
1023
|
+
this.setFocussedYear(this.yearInView, false);
|
|
1024
|
+
}
|
|
1025
|
+
watchYearPickerVisibleHandler() {
|
|
1026
|
+
if (!this.yearPickerVisible) {
|
|
1027
|
+
this.setFocussedYear(this.yearInView);
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
watchMonthPickerVisibleHandler() {
|
|
1031
|
+
if (!this.monthPickerVisible) {
|
|
1032
|
+
this.focussedMonth = this.monthInView;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
watchFocussedDayEl() {
|
|
1036
|
+
if (this.focusDay) {
|
|
1037
|
+
setTimeout(() => this.focusFocussedDay(), FOCUS_TIMER);
|
|
1038
|
+
}
|
|
1039
|
+
this.focusDay = true;
|
|
1040
|
+
}
|
|
1041
|
+
componentWillLoad() {
|
|
1042
|
+
var _a;
|
|
1043
|
+
const root = this.el.getRootNode();
|
|
1044
|
+
this.parentIsDatePicker =
|
|
1045
|
+
root instanceof ShadowRoot && ((_a = root.host) === null || _a === void 0 ? void 0 : _a.tagName) === "IC-DATE-PICKER";
|
|
1046
|
+
this.monthNames = stringEnumToArray(IcDateInputMonths);
|
|
1047
|
+
this.daysOfWeek = stringEnumToArray(IcShortDayNames);
|
|
1048
|
+
this.watchStartOfWeekHandler();
|
|
1049
|
+
this.watchMaxHandler();
|
|
1050
|
+
this.watchMinHandler();
|
|
1051
|
+
this.setOpenAtDate();
|
|
1052
|
+
removeDisabledFalse(this.disabled, this.el);
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* @internal Clears the dialog description used to provide more context for screen readers.
|
|
1056
|
+
*/
|
|
1057
|
+
async clearDialogDescription() {
|
|
1058
|
+
this.dialogDescription = "";
|
|
1059
|
+
}
|
|
1060
|
+
render() {
|
|
1061
|
+
const { dialogDescription, monthNames, focussedMonth, focussedYear, monthInView, yearInView, monthPickerVisible, yearPickerVisible, decadeView, minDate, maxDate, orderedDaysOfWeek, parentIsDatePicker, showClearButton, showTodayButton, size, theme, } = this;
|
|
1062
|
+
let monthButtonText = "";
|
|
1063
|
+
if (monthPickerVisible) {
|
|
1064
|
+
monthButtonText = `Use the arrow keys to change the selected month. To return to day picker view, press Enter or Space to select a month, or press Escape.`;
|
|
1065
|
+
}
|
|
1066
|
+
else {
|
|
1067
|
+
monthButtonText = `Press Enter or Space to open month picker view or use the arrow keys to change month.`;
|
|
1068
|
+
}
|
|
1069
|
+
let yearButtonText = "";
|
|
1070
|
+
if (yearPickerVisible) {
|
|
1071
|
+
yearButtonText = `Use the arrow keys to change the selected year. To return to day picker view, press Enter or Space to select a year, or press Escape.`;
|
|
1072
|
+
}
|
|
1073
|
+
else {
|
|
1074
|
+
yearButtonText = `Press Enter or Space to open year picker view or use the arrow keys to change the selected year.`;
|
|
1075
|
+
}
|
|
1076
|
+
const dialogLabel = "choose date";
|
|
1077
|
+
const monthLabel = monthNames && monthNames[monthInView]
|
|
1078
|
+
? monthNames[monthInView]
|
|
1079
|
+
: "Open month picker";
|
|
1080
|
+
const yearLabel = this.yearInView ? this.yearInView : "Open year picker";
|
|
1081
|
+
let minDay = minDate;
|
|
1082
|
+
if (minDate && this.disablePast) {
|
|
1083
|
+
const yesterday = new Date(minDate);
|
|
1084
|
+
yesterday.setDate(minDate.getDate() - 1);
|
|
1085
|
+
minDay = yesterday;
|
|
1086
|
+
}
|
|
1087
|
+
const weeks = [];
|
|
1088
|
+
for (let i = 0; i < this.currMonthView.length; i += 7) {
|
|
1089
|
+
weeks.push(this.currMonthView.slice(i, i + 7));
|
|
1090
|
+
}
|
|
1091
|
+
return (h(Host, { key: '5811c7e3bf515643f11c4ecd66e166ab672a15ab', class: {
|
|
1092
|
+
[`ic-calendar-${size}`]: true,
|
|
1093
|
+
[`ic-theme-${theme}`]: theme !== "inherit",
|
|
1094
|
+
} }, h("div", { key: '56f6fbfa98519f60e040d524f19d52bb2449e96d' }, h("span", { key: 'a52cc22ba545f12ccde1541b84bddbedc1a88734', id: "dialog-description", class: "sr-only" }, dialogDescription), h("div", Object.assign({ key: 'a4f6a18f109f7c55c5ba9a369dbc47352d215517' }, (parentIsDatePicker && {
|
|
1095
|
+
role: "dialog",
|
|
1096
|
+
"aria-modal": "true",
|
|
1097
|
+
}), { "aria-label": dialogLabel, "aria-describedBy": "dialog-description", class: {
|
|
1098
|
+
"calendar-container": true,
|
|
1099
|
+
}, onMouseDown: this.handleCalendarMouseDown, onClick: this.handleCalendarClick }), h("span", { key: '63a3c2c916c905efce47669886edff51422fd755', ref: (el) => (this.liveRegionEl = el), id: "live-region", "aria-live": "assertive", class: "sr-only" }), h("div", { key: 'd553857fb83f497d666355b283391530a94c09a9', class: {
|
|
1100
|
+
"month-year-nav-container": true,
|
|
1101
|
+
} }, h("div", { key: 'aff93454cc4f27db3e8464ac4289471c353f0086', class: "month-year-nav" }, this.previousMonthButton(), h("span", { key: 'a4771ae4d86e75fbf80134a4a53190a9d9402297', id: "select-month-hint", "aria-hidden": "true" }, monthButtonText), h("ic-button", { key: '325ed5a8bb306b318c2fa471de7ac82ac0e98e2e', ref: (el) => (this.monthButtonEl = el), size: size, class: "month-picker-button", disabled: this.disabled, "aria-haspopup": "menu", "aria-expanded": monthPickerVisible ? "true" : "false", "full-width": "true", variant: "tertiary", "aria-label": monthLabel, "aria-describedby": "select-month-hint", onKeyDown: this.monthButtonKeyDownHandler, onClick: this.monthButtonClickHandler }, monthNames[monthInView]), this.nextMonthButton()), h("div", { key: '91adac1ecbcccbab1b1c76c741ea64b2d7efe818', class: "month-year-nav" }, this.previousYearButton(), h("span", { key: '2ccac8cb808bfd951f36e5f371c128ff9e1bf84e', id: "select-year-hint", "aria-hidden": "true" }, yearButtonText), h("ic-button", { key: '289835494a1015ec0ea67e8885c627ad1436b404', ref: (el) => (this.yearButtonEl = el), size: size, class: "year-picker-button", disabled: this.disabled, "aria-haspopup": "menu", "aria-expanded": yearPickerVisible ? "true" : "false", "full-width": "true", variant: "tertiary", "aria-label": yearLabel, "aria-describedby": "select-year-hint", onKeyDown: this.yearButtonKeyDownHandler, onClick: this.yearButtonClickHandler }, this.yearInView), this.nextYearButton())), !(monthPickerVisible || yearPickerVisible) && (h("table", { key: 'd1bff2567dee5787f0ccd9ba2c0c40aa2c5e671a', role: "grid", class: {
|
|
1102
|
+
calendar: true,
|
|
1103
|
+
hidden: monthPickerVisible || yearPickerVisible,
|
|
1104
|
+
}, onKeyDown: this.handleCalendarKeyDown }, h("thead", { key: '9dccafd91918a15ec52fd641991e0803ccb65468', class: "weekdays-container" }, h("tr", { key: '2ecccfb88a4220bec5ed80b4819651f57a819909', class: "weekdays" }, orderedDaysOfWeek.map((dayName) => {
|
|
1105
|
+
const header = size === "small" ? dayName.charAt(0) : dayName;
|
|
1106
|
+
return (h("th", { scope: "col", class: "calendar-day-header" }, header));
|
|
1107
|
+
}))), h("tbody", { key: '9c676dff19754d06310e626c8aba69e05ca8a71e', class: "calendar-days-container" }, weeks.map((week, weekIdx) => (h("tr", { key: weekIdx }, week.map((day) => {
|
|
1108
|
+
var _a;
|
|
1109
|
+
return (h("td", { key: day.toISOString() }, h(DayButton, { day: day, disableDay: this.disabled ||
|
|
1110
|
+
((_a = this.disableDays) === null || _a === void 0 ? void 0 : _a.includes(Number(day.getDay()))), today: dateMatches(day, this.today), selected: dateMatches(day, this.selectedDate), focussed: dateMatches(day, this.focussedDate), inRange: dateInRange(day, minDay, maxDate), monthInView: monthInView, onSelectDay: this.handleSelectDay, focussedDayRef: this.setFocussedDayEl, onFocusDay: this.onDayButtonFocusHandler, onBlurDay: this.onDayButtonBlurHandler, showDaysOutsideMonth: this.showDaysOutsideMonth })));
|
|
1111
|
+
}))))))), h("div", { key: '5137281599f0ad0c3d1658448b740d1192073ad2', class: {
|
|
1112
|
+
"month-picker-container": true,
|
|
1113
|
+
hidden: !monthPickerVisible,
|
|
1114
|
+
} }, monthPickerVisible && (h(MonthPicker, { key: '460809cfbfb7db2aacd28470220863769c884651', size: size, onSelectMonth: this.handleSelectMonth, monthInView: monthInView, focussedMonth: focussedMonth, onKeyDown: this.monthPickerKeyDownHandler, focussedMonthRef: this.setFocussedMonthEl, minDate: minDate, maxDate: maxDate, yearInView: yearInView }))), h("div", { key: 'af3eb48f6bbeaf1a1ccdbb7a5f941241d10e6c4f', class: {
|
|
1115
|
+
"year-picker-container": true,
|
|
1116
|
+
hidden: !yearPickerVisible,
|
|
1117
|
+
} }, yearPickerVisible && (h(YearPicker, { key: '4de6dd0c0563a6519b39f0fdf58a329a7bba450c', decadeView: decadeView, size: size, focussedYear: focussedYear, onSelectYear: this.handleSelectYear, onKeyDown: this.yearPickerKeyDownHandler, onFocusYear: this.onYearButtonFocusHandler, onBlurYear: this.onYearButtonBlurHandler, yearInView: yearInView, minDate: minDate, maxDate: maxDate, focussedYearRef: this.setFocussedYearEl }))), h("div", { key: '18495cc7c4150208bb64a0a222a7e233ea3a93d7', class: {
|
|
1118
|
+
"bottom-buttons": true,
|
|
1119
|
+
"no-today": !showTodayButton,
|
|
1120
|
+
} }, showTodayButton && (h("ic-button", { key: 'd8623ea2ecc501dc77ad3fd47cd9f41b8e104c86', id: "today-button", variant: "tertiary", ref: (el) => (this.todayButtonEl = el), size: size, "aria-label": "Navigate to current date", onClick: this.todayButtonClickHandler, onKeyDown: this.todayButtonKeyDownHandler, disabled: this.isCurrentMonth() }, "Go to today")), showClearButton && (h("ic-button", { key: '40df11d2d3b36a505bab8c60acbbfb1eed03eddb', id: "clear-button", "aria-label": "clear selected date", ref: (el) => (this.clearButtonEl = el), variant: "tertiary", size: size, onClick: this.clearButtonClickHandler, onKeyDown: this.clearButtonKeyDownHandler, disabled: this.value === "" ||
|
|
1121
|
+
this.value === null ||
|
|
1122
|
+
this.value === undefined }, "Clear")))))));
|
|
1123
|
+
}
|
|
1124
|
+
static get delegatesFocus() { return true; }
|
|
1125
|
+
get el() { return getElement(this); }
|
|
1126
|
+
static get watchers() { return {
|
|
1127
|
+
"disabled": ["watchDisabledHandler"],
|
|
1128
|
+
"disableFuture": ["watchDisableFutureHandler"],
|
|
1129
|
+
"disablePast": ["watchDisablePastHandler"],
|
|
1130
|
+
"max": ["watchMaxHandler"],
|
|
1131
|
+
"min": ["watchMinHandler"],
|
|
1132
|
+
"startOfWeek": ["watchStartOfWeekHandler"],
|
|
1133
|
+
"value": ["valueChanged"],
|
|
1134
|
+
"openAtDate": ["valueChanged"],
|
|
1135
|
+
"focussedDate": ["watchFocussedDateHandler"],
|
|
1136
|
+
"monthInView": ["watchMonthInViewHandler"],
|
|
1137
|
+
"yearInView": ["watchYearInViewHandler"],
|
|
1138
|
+
"yearPickerVisible": ["watchYearPickerVisibleHandler"],
|
|
1139
|
+
"monthPickerVisible": ["watchMonthPickerVisibleHandler"],
|
|
1140
|
+
"focussedDayEl": ["watchFocussedDayEl"]
|
|
1141
|
+
}; }
|
|
1142
|
+
};
|
|
1143
|
+
Calendar$1.style = IcCalendarStyle0;
|
|
1144
|
+
|
|
1145
|
+
const Calendar = `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20" fill="none">
|
|
1146
|
+
<path d="M16.6667 2.50004H15.8334V0.833374H14.1667V2.50004H5.83342V0.833374H4.16675V2.50004H3.33341C2.41675 2.50004 1.66675 3.25004 1.66675 4.16671V17.5C1.66675 18.4167 2.41675 19.1667 3.33341 19.1667H16.6667C17.5834 19.1667 18.3334 18.4167 18.3334 17.5V4.16671C18.3334 3.25004 17.5834 2.50004 16.6667 2.50004ZM16.6667 17.5H3.33341V6.66671H16.6667V17.5Z" fill="currentColor"/>
|
|
1147
|
+
</svg>`;
|
|
1148
|
+
|
|
1149
|
+
const icDateInputCss = "/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%;}body{margin:0}main{display:block}h1{font-size:2em;margin:0.67em 0}hr{box-sizing:content-box;height:0;overflow:visible;}pre{font-family:monospace, monospace;font-size:1em;}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace, monospace;font-size:1em;}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0;}button,input{overflow:visible}button,select{text-transform:none}button,[type=\"button\"],[type=\"reset\"],[type=\"submit\"]{-webkit-appearance:button}button::-moz-focus-inner,[type=\"button\"]::-moz-focus-inner,[type=\"reset\"]::-moz-focus-inner,[type=\"submit\"]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type=\"button\"]:-moz-focusring,[type=\"reset\"]:-moz-focusring,[type=\"submit\"]:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:0.35em 0.75em 0.625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal;}progress{vertical-align:baseline}textarea{overflow:auto}[type=\"checkbox\"],[type=\"radio\"]{box-sizing:border-box;padding:0;}[type=\"number\"]::-webkit-inner-spin-button,[type=\"number\"]::-webkit-outer-spin-button{height:auto}[type=\"search\"]{-webkit-appearance:textfield;outline-offset:-2px;}[type=\"search\"]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit;}details{display:block}summary{display:list-item}template{display:none}[hidden]{display:none}html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font-style:inherit;vertical-align:baseline}:host{--ic-input-label-helpertext-padding:var(--ic-space-xs);--input-bg-color:var(--ic-date-input-bg);--ic-input-label-text-color:var(--ic-date-input-label);--ic-input-label-helper-text-color:var(--ic-date-input-subtitle);--border-color:var(--ic-date-input-border);--border-color-disabled:var(--ic-date-input-border-disabled);--border-color-hover:var(--ic-date-input-border-default-hover);--border-color-pressed:var(--ic-date-input-border-default-pressed);--border-error-color:var(--ic-date-input-border-error);--border-error-color-hover:var(--ic-date-input-border-error-hover);--border-error-color-pressed:var(--ic-date-input-border-error-pressed);--border-success-color:var(--ic-date-input-border-success);--border-success-color-hover:var(--ic-date-input-border-success-hover);--border-success-color-pressed:var(--ic-date-input-border-success-pressed);--border-warning-color:var(--ic-date-input-border-warning);--border-warning-color-hover:var(--ic-date-input-border-warning-hover);--border-warning-color-pressed:var(--ic-date-input-border-warning-pressed)}:host(.ic-date-input-disabled){--ic-input-label-text-color:var(--ic-date-input-label-disabled);--ic-input-label-helper-text-color:var(--ic-date-input-subtitle-disabled)}input{border:0;height:100%;padding:0;outline:none;background:none;-moz-appearance:textfield;-webkit-appearance:textfield;appearance:textfield;color:var(--ic-date-input-text-filled);caret-color:var(--ic-date-input-typing-cursor)}input::-webkit-outer-spin-button,input::-webkit-inner-spin-button{-webkit-appearance:none}input:-webkit-autofill{box-shadow:0 0 0 var(--ic-space-sm) var(--ic-color-background-primary) inset;-webkit-text-fill-color:var(--ic-date-input-text-filled) !important}input::-moz-placeholder{color:var(--ic-date-input-text-placeholder)}input::placeholder{color:var(--ic-date-input-text-placeholder)}ic-input-component-container{cursor:text}ic-input-component-container .focus-indicator{padding:var(--ic-space-xxxs) var(--ic-space-xs);align-items:center}.date-inputs{color:var(--ic-date-input-text-placeholder)}.day-input{width:1.438rem}.month-input{width:1.813rem}.year-input,.year-input.fit-to-value{width:2.313rem}.fit-to-value{width:1.25rem}.sr-only{position:absolute;left:-9999px}.input-container{width:100%;display:flex;justify-content:space-between;align-items:center;position:relative}.action-buttons{display:flex;align-items:center}.show-calendar-button-wrapper{display:flex;justify-content:center;align-items:center}.clear-button,.calendar-button{border-radius:var(--ic-border-radius);transition:box-shadow var(--ic-easing-transition),\n border-radius var(--ic-easing-transition);margin:0}.clear-button.hidden{display:none}.clear-button:focus,.calendar-button:focus,.clear-button:active,.calendar-button:active{background-color:var(--ic-color-focus-inner) !important;box-shadow:inset 0 0 0 0.125rem var(--ic-color-focus-outer) !important;border-radius:0.25rem}.calendar-button:focus,.calendar-button:active{--ic-button-tertiary-text-active:var(--ic-atoms-input-clear-button-focus);--ic-button-tertiary-text-hover-active:var(\n --ic-atoms-input-clear-button-focus\n );--ic-button-tertiary-text-pressed-active:var(\n --ic-atoms-input-clear-button-focus\n )}.clear-button:focus,.calendar-button:focus,.clear-button:active *,.calendar-button:active *{fill:var(--ic-atoms-input-clear-button-focus)}.clear-button svg{color:var(--ic-date-input-clear-icon)}.clear-button:focus svg{color:var(--ic-atoms-input-clear-button-focus)}.divider{margin:0 var(--ic-space-xxs);width:var(--ic-space-1px);background-color:var(--ic-atoms-input-divider);border-radius:var(--ic-space-1px)}.divider.small{height:var(--ic-space-md)}.divider.medium{height:calc(var(--ic-space-sm) + var(--ic-space-xs))}.divider.large{height:var(--ic-space-lg)}ic-input-validation{--ic-input-validation-status-text-color:var(--ic-date-input-status-text);--ic-input-validation-error:var(--ic-date-input-icon-error);--ic-input-validation-warning-icon-color:var(--ic-date-input-icon-warning);--ic-input-validation-success-icon-color:var(--ic-date-input-icon-success)}@media (forced-colors: active){.clear-button svg{color:currentcolor}}";
|
|
1150
|
+
const IcDateInputStyle0 = icDateInputCss;
|
|
1151
|
+
|
|
1152
|
+
let inputIds = 0;
|
|
1153
|
+
const DateInput = class {
|
|
1154
|
+
constructor(hostRef) {
|
|
1155
|
+
registerInstance(this, hostRef);
|
|
1156
|
+
this.calendarButtonClicked = createEvent(this, "calendarButtonClicked", 7);
|
|
1157
|
+
this.icBlur = createEvent(this, "icBlur", 7);
|
|
1158
|
+
this.icChange = createEvent(this, "icChange", 7);
|
|
1159
|
+
this.icFocus = createEvent(this, "icFocus", 7);
|
|
1160
|
+
this.DEFAULT_DATE_FORMAT = "DD/MM/YYYY";
|
|
1161
|
+
this.ARIA_INVALID = "aria-invalid";
|
|
1162
|
+
this.ARIA_LABEL = "aria-label";
|
|
1163
|
+
this.ARIA_LABELLED_BY = "aria-labelledby";
|
|
1164
|
+
this.EVENT_OBJECT_STRING = "[object Event]";
|
|
1165
|
+
this.FIT_TO_VALUE = "fit-to-value";
|
|
1166
|
+
this.initialValue = this.value;
|
|
1167
|
+
this.INPUT_EVENT_OBJECT_STRING = "[object InputEvent]";
|
|
1168
|
+
this.inputsInOrder = [];
|
|
1169
|
+
this.isAfterMax = false;
|
|
1170
|
+
this.isBeforeMin = false;
|
|
1171
|
+
this.preventInputsUpdating = false;
|
|
1172
|
+
this.isDisabledDate = false;
|
|
1173
|
+
this.isValidDay = true;
|
|
1174
|
+
this.isValidMonth = true;
|
|
1175
|
+
this.isValidDate = true;
|
|
1176
|
+
this.isZuluTime = false;
|
|
1177
|
+
this.KEYBOARD_EVENT_OBJECT_STRING = "[object KeyboardEvent]";
|
|
1178
|
+
this.MAX_DAY = 31;
|
|
1179
|
+
this.MAX_MONTH = 12;
|
|
1180
|
+
this.previousSelectedDate = null;
|
|
1181
|
+
this.selectedDate = null;
|
|
1182
|
+
this.externalSetDate = false;
|
|
1183
|
+
this.clearInput = false;
|
|
1184
|
+
this.calendarIsOpen = false;
|
|
1185
|
+
this.calendarFocused = false;
|
|
1186
|
+
this.clearButtonFocused = false;
|
|
1187
|
+
this.removeLabelledBy = false;
|
|
1188
|
+
this.day = "";
|
|
1189
|
+
this.month = "";
|
|
1190
|
+
this.year = "";
|
|
1191
|
+
/**
|
|
1192
|
+
* The format in which the date will be displayed.
|
|
1193
|
+
*/
|
|
1194
|
+
this.dateFormat = this.DEFAULT_DATE_FORMAT;
|
|
1195
|
+
/**
|
|
1196
|
+
* If `true`, every individual input field completed will emit an icChange event.
|
|
1197
|
+
*/
|
|
1198
|
+
this.emitDatePartChange = false;
|
|
1199
|
+
/**
|
|
1200
|
+
* If `true`, the disabled state will be set.
|
|
1201
|
+
*/
|
|
1202
|
+
this.disabled = false;
|
|
1203
|
+
/**
|
|
1204
|
+
* The days of the week to disable.
|
|
1205
|
+
*/
|
|
1206
|
+
this.disableDays = [];
|
|
1207
|
+
/**
|
|
1208
|
+
* The text to display as the validation message when `disableDays` is set and a disabled date is entered.
|
|
1209
|
+
*/
|
|
1210
|
+
this.disableDaysMessage = "The date you have selected is on a day of the week that is not allowed. Please select another date.";
|
|
1211
|
+
/**
|
|
1212
|
+
* If `true`, dates in the future are not allowed. A validation message will appear if a date in the future is entered.
|
|
1213
|
+
*/
|
|
1214
|
+
this.disableFuture = false;
|
|
1215
|
+
/**
|
|
1216
|
+
* The text to display as the validation message when `disableFuture` is true and a date in the future is entered.
|
|
1217
|
+
*/
|
|
1218
|
+
this.disableFutureMessage = "Dates in the future are not allowed. Please select a date in the past.";
|
|
1219
|
+
/**
|
|
1220
|
+
* If `true`, dates in the past are not allowed. A validation message will appear if a date in the past is entered.
|
|
1221
|
+
*/
|
|
1222
|
+
this.disablePast = false;
|
|
1223
|
+
/**
|
|
1224
|
+
* The text to display as the validation message when `disablePast` is true and a date in the past is entered.
|
|
1225
|
+
*/
|
|
1226
|
+
this.disablePastMessage = "Dates in the past are not allowed. Please select a date in the future.";
|
|
1227
|
+
/**
|
|
1228
|
+
* If `true`, the helper text will be visually hidden, but still read out by screenreaders.
|
|
1229
|
+
*/
|
|
1230
|
+
this.hideHelperText = false;
|
|
1231
|
+
/**
|
|
1232
|
+
* If `true`, the label will be visually hidden, but will still be read out by screen readers.
|
|
1233
|
+
*/
|
|
1234
|
+
this.hideLabel = false;
|
|
1235
|
+
/**
|
|
1236
|
+
* The ID for the input.
|
|
1237
|
+
*/
|
|
1238
|
+
this.inputId = `ic-date-input-${inputIds++}`;
|
|
1239
|
+
/**
|
|
1240
|
+
* The text to display as the validation message when an invalid date is entered.
|
|
1241
|
+
*/
|
|
1242
|
+
this.invalidDateMessage = "Please enter a valid date.";
|
|
1243
|
+
/**
|
|
1244
|
+
* The latest date that will be allowed. The value can be in any format supported as `dateFormat`, in ISO 8601 date string format (`yyyy-mm-dd`) or as a JavaScript `Date` object.
|
|
1245
|
+
* The value of this prop is ignored if `disableFuture` is set to `true`.
|
|
1246
|
+
*/
|
|
1247
|
+
this.max = "";
|
|
1248
|
+
/**
|
|
1249
|
+
* The earliest date that will be allowed. The value can be in any format supported as `dateFormat`, in ISO 8601 date string format (`yyyy-mm-dd`) or as a JavaScript `Date` object.
|
|
1250
|
+
* The value of this prop is ignored if `disablePast` is set to `true`.
|
|
1251
|
+
*/
|
|
1252
|
+
this.min = "";
|
|
1253
|
+
/**
|
|
1254
|
+
* The name of the control, which is submitted with the form data.
|
|
1255
|
+
*/
|
|
1256
|
+
this.name = this.inputId;
|
|
1257
|
+
/**
|
|
1258
|
+
* If `true`, the input will require a value.
|
|
1259
|
+
*/
|
|
1260
|
+
this.required = false;
|
|
1261
|
+
/**
|
|
1262
|
+
* @internal If `true`, a button which displays the calendar view when clicked will be displayed.
|
|
1263
|
+
*/
|
|
1264
|
+
this.showCalendarButton = false;
|
|
1265
|
+
/**
|
|
1266
|
+
* If `true`, a button which clears the date input when clicked will be displayed.
|
|
1267
|
+
*/
|
|
1268
|
+
this.showClearButton = true;
|
|
1269
|
+
/**
|
|
1270
|
+
* The size of the date input to be displayed.
|
|
1271
|
+
*/
|
|
1272
|
+
this.size = "medium";
|
|
1273
|
+
/**
|
|
1274
|
+
* Sets the date picker to the dark or light theme colors. "inherit" will set the color based on the system settings or ic-theme component.
|
|
1275
|
+
*/
|
|
1276
|
+
this.theme = "inherit";
|
|
1277
|
+
/**
|
|
1278
|
+
* The value of the date input. The value can be in any format supported as `dateFormat`, in ISO 8601 date string format (`yyyy-mm-dd`) or as a JavaScript `Date` object.
|
|
1279
|
+
*/
|
|
1280
|
+
this.value = "";
|
|
1281
|
+
/**
|
|
1282
|
+
* The value of the `aria-live` attribute on the validation message.
|
|
1283
|
+
*/
|
|
1284
|
+
this.validationAriaLive = "polite";
|
|
1285
|
+
/**
|
|
1286
|
+
* The validation status - e.g. 'error' | 'warning' | 'success'. This will override the built-in date validation.
|
|
1287
|
+
*/
|
|
1288
|
+
this.validationStatus = "";
|
|
1289
|
+
/**
|
|
1290
|
+
* The text to display as the validation message. This will override the built-in date validation.
|
|
1291
|
+
*/
|
|
1292
|
+
this.validationText = "";
|
|
1293
|
+
this.setInputPasteValue = (input, pastedValue) => {
|
|
1294
|
+
if (input) {
|
|
1295
|
+
const inputEl = input;
|
|
1296
|
+
inputEl.value = pastedValue;
|
|
1297
|
+
inputEl.classList.add(this.FIT_TO_VALUE);
|
|
1298
|
+
}
|
|
1299
|
+
};
|
|
1300
|
+
this.checkSingleCopiedValueIsValid = (input, pastedValue) => {
|
|
1301
|
+
let isValid = false;
|
|
1302
|
+
const value = Number(pastedValue);
|
|
1303
|
+
switch (input) {
|
|
1304
|
+
case this.dayInputEl:
|
|
1305
|
+
isValid = value >= 1 && value <= this.MAX_DAY;
|
|
1306
|
+
break;
|
|
1307
|
+
case this.monthInputEl:
|
|
1308
|
+
isValid = value >= 1 && value <= this.MAX_MONTH;
|
|
1309
|
+
break;
|
|
1310
|
+
case this.yearInputEl:
|
|
1311
|
+
isValid = true;
|
|
1312
|
+
break;
|
|
1313
|
+
}
|
|
1314
|
+
return isValid;
|
|
1315
|
+
};
|
|
1316
|
+
/**
|
|
1317
|
+
* Using Object.prototype.string to determine type if event from user
|
|
1318
|
+
* @param event - event object used to differentiate keyboard, generic or input event
|
|
1319
|
+
* @returns boolean
|
|
1320
|
+
*/
|
|
1321
|
+
this.isKeyboardOrEvent = (event) => {
|
|
1322
|
+
return (Object.prototype.toString.call(event) === this.EVENT_OBJECT_STRING ||
|
|
1323
|
+
Object.prototype.toString.call(event) ===
|
|
1324
|
+
this.KEYBOARD_EVENT_OBJECT_STRING);
|
|
1325
|
+
};
|
|
1326
|
+
this.setDateValidity = () => {
|
|
1327
|
+
if (!isEmptyString(this.day)) {
|
|
1328
|
+
this.isValidDay = +this.day > this.MAX_DAY ? false : true;
|
|
1329
|
+
}
|
|
1330
|
+
else {
|
|
1331
|
+
this.isValidDay = true;
|
|
1332
|
+
}
|
|
1333
|
+
if (!isEmptyString(this.month)) {
|
|
1334
|
+
this.isValidMonth = +this.month > this.MAX_MONTH ? false : true;
|
|
1335
|
+
}
|
|
1336
|
+
else {
|
|
1337
|
+
this.isValidMonth = true;
|
|
1338
|
+
}
|
|
1339
|
+
};
|
|
1340
|
+
this.handleInput = (event) => {
|
|
1341
|
+
const inputEvent = event;
|
|
1342
|
+
const input = event.target;
|
|
1343
|
+
if (input !== this.yearInputEl) {
|
|
1344
|
+
// Only auto-format if input event is not a character being deleted
|
|
1345
|
+
// and not as user is changing value using up / down keys
|
|
1346
|
+
if (inputEvent.inputType !== "deleteContentBackward" &&
|
|
1347
|
+
!this.preventAutoFormatting) {
|
|
1348
|
+
if (input.value.length === 1 &&
|
|
1349
|
+
((input === this.dayInputEl && +input.value >= 4) ||
|
|
1350
|
+
(input === this.monthInputEl && +input.value >= 2)) &&
|
|
1351
|
+
+input.value <= 9) {
|
|
1352
|
+
this.setInputValue(input);
|
|
1353
|
+
this.notifyScreenReader(input, event);
|
|
1354
|
+
this.moveToNextInput(input);
|
|
1355
|
+
}
|
|
1356
|
+
if (input.value.length === 2) {
|
|
1357
|
+
if (+input.value === 0) {
|
|
1358
|
+
input.value = "01";
|
|
1359
|
+
}
|
|
1360
|
+
this.setInputValue(input);
|
|
1361
|
+
this.setPreventInput(input, true);
|
|
1362
|
+
this.notifyScreenReader(input, event);
|
|
1363
|
+
this.moveToNextInput(input);
|
|
1364
|
+
}
|
|
1365
|
+
else {
|
|
1366
|
+
this.setPreventInput(input, false);
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
else if (this.preventAutoFormatting) {
|
|
1370
|
+
/**
|
|
1371
|
+
* Using arrow keys prevents auto formatting so need to deal with
|
|
1372
|
+
* switching from arrow keys to inputting numbers
|
|
1373
|
+
**/
|
|
1374
|
+
if (input.value.length === 2 && !this.isKeyboardOrEvent(event)) {
|
|
1375
|
+
this.setInputValue(input);
|
|
1376
|
+
this.setPreventInput(input, true);
|
|
1377
|
+
this.moveToNextInput(input);
|
|
1378
|
+
}
|
|
1379
|
+
else {
|
|
1380
|
+
this.setInputValue(input);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
if (input.value.length !== 2) {
|
|
1384
|
+
this.setPreventInput(input, false);
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
else {
|
|
1388
|
+
if (input.value.length === 4) {
|
|
1389
|
+
this.setInputValue(input);
|
|
1390
|
+
if (Object.prototype.toString.call(event) !== this.EVENT_OBJECT_STRING) {
|
|
1391
|
+
this.moveToNextInput(input);
|
|
1392
|
+
}
|
|
1393
|
+
this.setPreventInput(input, true);
|
|
1394
|
+
}
|
|
1395
|
+
else {
|
|
1396
|
+
this.setPreventInput(input, false);
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
// Add / remove class to make input width match size of value i.e. 2 digits' width for day / month, 4 for year
|
|
1400
|
+
this.setFitToValueStyling(input);
|
|
1401
|
+
if (input.value.length === 0) {
|
|
1402
|
+
this.setInputValue(input, true);
|
|
1403
|
+
this.setValidationMessage();
|
|
1404
|
+
}
|
|
1405
|
+
this.notifyScreenReader(input, event);
|
|
1406
|
+
};
|
|
1407
|
+
this.handleKeyDown = (event, isInputPrevented) => {
|
|
1408
|
+
var _a;
|
|
1409
|
+
const input = event.target;
|
|
1410
|
+
const eventKey = (_a = event.key) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
1411
|
+
// Regex required due to FF allowing all characters as values for number text field.
|
|
1412
|
+
const regex = /-?\d*\.?\d+(e[-+]?\d+)?|[/-]|arrowup|arrowdown|arrowleft|arrowright|shift|tab|backspace|delete/;
|
|
1413
|
+
if (!regex.test(eventKey) &&
|
|
1414
|
+
!((event.ctrlKey || event.metaKey) &&
|
|
1415
|
+
(eventKey === "v" || eventKey === "c"))) {
|
|
1416
|
+
event.preventDefault();
|
|
1417
|
+
}
|
|
1418
|
+
switch (eventKey) {
|
|
1419
|
+
case "/":
|
|
1420
|
+
case "-":
|
|
1421
|
+
case ".":
|
|
1422
|
+
event.preventDefault();
|
|
1423
|
+
this.setPasteInvalidText();
|
|
1424
|
+
this.moveToNextInput(input);
|
|
1425
|
+
break;
|
|
1426
|
+
case "arrowright":
|
|
1427
|
+
case "arrowleft":
|
|
1428
|
+
event.preventDefault();
|
|
1429
|
+
this.handleLeftRightArrowKeyPress(input, eventKey);
|
|
1430
|
+
break;
|
|
1431
|
+
case "arrowup":
|
|
1432
|
+
case "arrowdown":
|
|
1433
|
+
this.preventAutoFormatting = true;
|
|
1434
|
+
this.handleUpDownArrowKeyPress(input, event);
|
|
1435
|
+
break;
|
|
1436
|
+
case "backspace":
|
|
1437
|
+
if (input.value.length === 0) {
|
|
1438
|
+
event.preventDefault();
|
|
1439
|
+
this.moveToPreviousInput(input);
|
|
1440
|
+
}
|
|
1441
|
+
break;
|
|
1442
|
+
}
|
|
1443
|
+
this.preventInput(event, isInputPrevented);
|
|
1444
|
+
this.preventInputsUpdating = true;
|
|
1445
|
+
};
|
|
1446
|
+
this.handleFocus = (event) => {
|
|
1447
|
+
// Highlight / select all characters in input for easy replacement
|
|
1448
|
+
const input = event.target;
|
|
1449
|
+
input.select();
|
|
1450
|
+
};
|
|
1451
|
+
this.handleBlur = (event) => {
|
|
1452
|
+
const input = event.target;
|
|
1453
|
+
if (input) {
|
|
1454
|
+
this.setPasteInvalidText();
|
|
1455
|
+
this.autocompleteInput(input);
|
|
1456
|
+
}
|
|
1457
|
+
};
|
|
1458
|
+
this.handleLeftRightArrowKeyPress = (input, key) => {
|
|
1459
|
+
if (key === "arrowright") {
|
|
1460
|
+
this.moveToNextInput(input);
|
|
1461
|
+
}
|
|
1462
|
+
else {
|
|
1463
|
+
this.moveToPreviousInput(input);
|
|
1464
|
+
}
|
|
1465
|
+
this.setPasteInvalidText();
|
|
1466
|
+
};
|
|
1467
|
+
this.notifyScreenReaderSelectedDate = () => {
|
|
1468
|
+
if (this.selectedDate && this.selectedDateInfoEl) {
|
|
1469
|
+
const dayNames = stringEnumToArray(IcDayNames);
|
|
1470
|
+
const months = stringEnumToArray(IcDateInputMonths);
|
|
1471
|
+
this.selectedDateInfoEl.textContent = `Selected date: ${dayNames[this.selectedDate.getDay()]}, ${this.selectedDate.getDate()} ${months[this.selectedDate.getMonth()]} ${this.selectedDate.getFullYear()}`;
|
|
1472
|
+
}
|
|
1473
|
+
};
|
|
1474
|
+
this.handleUpDownArrowKeyPress = (input, event) => {
|
|
1475
|
+
const minValue = input === this.yearInputEl ? 0 : 1;
|
|
1476
|
+
let maxValue = 9999;
|
|
1477
|
+
switch (input) {
|
|
1478
|
+
case this.dayInputEl:
|
|
1479
|
+
maxValue = this.MAX_DAY;
|
|
1480
|
+
break;
|
|
1481
|
+
case this.monthInputEl:
|
|
1482
|
+
maxValue = this.MAX_MONTH;
|
|
1483
|
+
break;
|
|
1484
|
+
case this.yearInputEl:
|
|
1485
|
+
maxValue = 9999;
|
|
1486
|
+
}
|
|
1487
|
+
// Make value loop round when min / max reached
|
|
1488
|
+
if (input === null || input === void 0 ? void 0 : input.value) {
|
|
1489
|
+
if (event.key === "ArrowUp") {
|
|
1490
|
+
if (+input.value === maxValue) {
|
|
1491
|
+
event.preventDefault();
|
|
1492
|
+
input.value = `0${minValue}`;
|
|
1493
|
+
}
|
|
1494
|
+
else {
|
|
1495
|
+
input.value =
|
|
1496
|
+
+input.value + 1 < 10
|
|
1497
|
+
? `0${+input.value + 1}`
|
|
1498
|
+
: (+input.value + 1).toString();
|
|
1499
|
+
}
|
|
1500
|
+
this.notifyScreenReader(input, event);
|
|
1501
|
+
}
|
|
1502
|
+
if (event.key === "ArrowDown") {
|
|
1503
|
+
if (+input.value === minValue) {
|
|
1504
|
+
event.preventDefault();
|
|
1505
|
+
input.value = maxValue.toString();
|
|
1506
|
+
}
|
|
1507
|
+
else {
|
|
1508
|
+
input.value =
|
|
1509
|
+
+input.value - 1 < 10
|
|
1510
|
+
? `0${+input.value - 1}`
|
|
1511
|
+
: (+input.value - 1).toString();
|
|
1512
|
+
}
|
|
1513
|
+
this.notifyScreenReader(input, event);
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
else {
|
|
1517
|
+
if (event.key === "ArrowDown") {
|
|
1518
|
+
event.preventDefault();
|
|
1519
|
+
input.value =
|
|
1520
|
+
input === this.yearInputEl
|
|
1521
|
+
? new Date().getFullYear().toString()
|
|
1522
|
+
: maxValue.toString();
|
|
1523
|
+
this.notifyScreenReader(input, event);
|
|
1524
|
+
}
|
|
1525
|
+
else if (event.key === "ArrowUp") {
|
|
1526
|
+
event.preventDefault();
|
|
1527
|
+
input.value =
|
|
1528
|
+
input === this.yearInputEl
|
|
1529
|
+
? new Date().getFullYear().toString()
|
|
1530
|
+
: `0${minValue}`;
|
|
1531
|
+
this.notifyScreenReader(input, event);
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
this.setInputValue(input);
|
|
1535
|
+
this.setFitToValueStyling(input);
|
|
1536
|
+
};
|
|
1537
|
+
this.handleDateChange = (force) => {
|
|
1538
|
+
// Prevent icChange being emitted when each individual input is changed
|
|
1539
|
+
// This method is used within componentWillUpdate instead of using @Watch('value');
|
|
1540
|
+
if (force || !dateMatches(this.selectedDate, this.previousSelectedDate)) {
|
|
1541
|
+
if (this.value) {
|
|
1542
|
+
this.inputsInOrder.forEach((input) => {
|
|
1543
|
+
input.classList.add(this.FIT_TO_VALUE);
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
if (this.day && this.month && this.year && this.invalidDateText === "") {
|
|
1547
|
+
this.setValueAndEmitChange(this.selectedDate);
|
|
1548
|
+
this.notifyScreenReaderSelectedDate();
|
|
1549
|
+
}
|
|
1550
|
+
else if (!(this.selectedDate === null && this.previousSelectedDate === null) &&
|
|
1551
|
+
this.selectedDateInfoEl) {
|
|
1552
|
+
this.setValueAndEmitChange(null);
|
|
1553
|
+
this.selectedDateInfoEl.textContent = "";
|
|
1554
|
+
}
|
|
1555
|
+
this.previousSelectedDate = this.selectedDate;
|
|
1556
|
+
if (!this.preventInputsUpdating) {
|
|
1557
|
+
this.updateInputValues(this.day, this.month, this.year);
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
};
|
|
1561
|
+
this.slicePastedDate = (valueLength, datePart) => {
|
|
1562
|
+
return datePart.length > valueLength
|
|
1563
|
+
? datePart.slice(0, valueLength)
|
|
1564
|
+
: datePart;
|
|
1565
|
+
};
|
|
1566
|
+
this.isPastedStringDateValid = (value) => {
|
|
1567
|
+
if (/\d+-\d+-\d+$/.test(value) ||
|
|
1568
|
+
/\d+\/\d+\/\d+/.test(value) ||
|
|
1569
|
+
/\d+\.\d+\.\d+/.test(value)) {
|
|
1570
|
+
return true;
|
|
1571
|
+
}
|
|
1572
|
+
if (/[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}(?::[0-9]{2}(?:\.\d+)?)?Z/.test(value)) {
|
|
1573
|
+
this.isZuluTime = true;
|
|
1574
|
+
return true;
|
|
1575
|
+
}
|
|
1576
|
+
return false;
|
|
1577
|
+
};
|
|
1578
|
+
// Set value of each input to value of pasted date part
|
|
1579
|
+
// Allows formats separated by '-' or '/'
|
|
1580
|
+
this.handlePaste = (event) => {
|
|
1581
|
+
var _a;
|
|
1582
|
+
event.preventDefault();
|
|
1583
|
+
const pastedValue = ((_a = event.clipboardData) === null || _a === void 0 ? void 0 : _a.getData("Text")) || "";
|
|
1584
|
+
const isValidDate = this.isPastedStringDateValid(pastedValue);
|
|
1585
|
+
this.setPastedValueAndValidation(isValidDate, pastedValue, event);
|
|
1586
|
+
};
|
|
1587
|
+
this.setDate = (date) => {
|
|
1588
|
+
if (date === null || date === "" || date === undefined) {
|
|
1589
|
+
if (this.day)
|
|
1590
|
+
this.day = "";
|
|
1591
|
+
if (this.month)
|
|
1592
|
+
this.month = "";
|
|
1593
|
+
if (this.year)
|
|
1594
|
+
this.year = "";
|
|
1595
|
+
this.inputsInOrder.forEach((input) => {
|
|
1596
|
+
input.classList.remove(this.FIT_TO_VALUE);
|
|
1597
|
+
this.setPreventInput(input, false);
|
|
1598
|
+
});
|
|
1599
|
+
this.handleDateChange(true);
|
|
1600
|
+
}
|
|
1601
|
+
else {
|
|
1602
|
+
if (isDateOrEpoch(date)) {
|
|
1603
|
+
let newDate;
|
|
1604
|
+
if (typeof date === "string") {
|
|
1605
|
+
// Checking if epoch date time
|
|
1606
|
+
newDate = new Date(+date);
|
|
1607
|
+
}
|
|
1608
|
+
else {
|
|
1609
|
+
newDate = date;
|
|
1610
|
+
}
|
|
1611
|
+
this.day = convertToDoubleDigits(newDate.getDate());
|
|
1612
|
+
this.month = convertToDoubleDigits(newDate.getMonth() + 1);
|
|
1613
|
+
this.year = newDate.getFullYear().toString();
|
|
1614
|
+
}
|
|
1615
|
+
else if (typeof date === "string") {
|
|
1616
|
+
const defaultDateArray = splitStringDate(date, this.dateFormat);
|
|
1617
|
+
this.selectedDate = new Date(Number(defaultDateArray[0]), Number(defaultDateArray[1]) - 1, Number(defaultDateArray[2]));
|
|
1618
|
+
this.year = defaultDateArray[0];
|
|
1619
|
+
this.month = defaultDateArray[1];
|
|
1620
|
+
this.day = defaultDateArray[2];
|
|
1621
|
+
this.setValueAndEmitChange(this.selectedDate);
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
this.setValidationMessage();
|
|
1625
|
+
};
|
|
1626
|
+
this.formatMinMax = (date) => {
|
|
1627
|
+
let formattedDate;
|
|
1628
|
+
const day = convertToDoubleDigits(date.getDate());
|
|
1629
|
+
const month = convertToDoubleDigits(date.getMonth() + 1);
|
|
1630
|
+
const year = date.getFullYear();
|
|
1631
|
+
switch (this.dateFormat) {
|
|
1632
|
+
case this.DEFAULT_DATE_FORMAT:
|
|
1633
|
+
formattedDate = `${day}/${month}/${year}`;
|
|
1634
|
+
break;
|
|
1635
|
+
case "MM/DD/YYYY":
|
|
1636
|
+
formattedDate = `${month}/${day}/${year}`;
|
|
1637
|
+
break;
|
|
1638
|
+
case "YYYY/MM/DD":
|
|
1639
|
+
formattedDate = `${year}/${month}/${day}`;
|
|
1640
|
+
break;
|
|
1641
|
+
}
|
|
1642
|
+
return formattedDate;
|
|
1643
|
+
};
|
|
1644
|
+
this.updateInputValues = (day, month, year) => {
|
|
1645
|
+
if (this.dayInputEl && this.monthInputEl && this.yearInputEl) {
|
|
1646
|
+
this.dayInputEl.value = day;
|
|
1647
|
+
this.monthInputEl.value = month;
|
|
1648
|
+
this.yearInputEl.value = year;
|
|
1649
|
+
}
|
|
1650
|
+
};
|
|
1651
|
+
// Set value in state based on input
|
|
1652
|
+
this.setInputValue = (input, clear = false) => {
|
|
1653
|
+
const newValue = clear ? "" : input.value;
|
|
1654
|
+
switch (input) {
|
|
1655
|
+
case this.dayInputEl:
|
|
1656
|
+
this.day = newValue;
|
|
1657
|
+
break;
|
|
1658
|
+
case this.monthInputEl:
|
|
1659
|
+
this.month = newValue;
|
|
1660
|
+
break;
|
|
1661
|
+
case this.yearInputEl:
|
|
1662
|
+
if (this.year !== newValue) {
|
|
1663
|
+
this.year = newValue;
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
this.setValidationMessage();
|
|
1667
|
+
};
|
|
1668
|
+
this.setValidationMessage = () => {
|
|
1669
|
+
this.setDateValidity();
|
|
1670
|
+
if (!isEmptyString(this.day) &&
|
|
1671
|
+
!isEmptyString(this.month) &&
|
|
1672
|
+
!isEmptyString(this.year)) {
|
|
1673
|
+
// Check whether date actually exists
|
|
1674
|
+
// (used https://www.hectane.com/blog/javascript-date-validation-with-leap-year)
|
|
1675
|
+
this.selectedDate = this.convertToDate(this.year, this.month, this.day);
|
|
1676
|
+
this.isValidDate =
|
|
1677
|
+
!!this.selectedDate && this.selectedDate.getDate() == +this.day;
|
|
1678
|
+
this.isDisabledDate = this.isSelectedDateDisabled();
|
|
1679
|
+
if (!this.isValidDate || this.isDisabledDate) {
|
|
1680
|
+
this.inputsInOrder.forEach((input) => input.setAttribute(this.ARIA_INVALID, "true"));
|
|
1681
|
+
}
|
|
1682
|
+
else {
|
|
1683
|
+
this.inputsInOrder.forEach((input) => input.removeAttribute(this.ARIA_INVALID));
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
else {
|
|
1687
|
+
this.selectedDate = null;
|
|
1688
|
+
}
|
|
1689
|
+
if (!(this.isValidDay && this.isValidMonth && this.isValidDate)) {
|
|
1690
|
+
this.invalidDateText = this.invalidDateMessage;
|
|
1691
|
+
}
|
|
1692
|
+
else if (this.isDisabledDate && this.selectedDate !== null) {
|
|
1693
|
+
if (this.isBeforeMin) {
|
|
1694
|
+
if (this.disablePast) {
|
|
1695
|
+
this.invalidDateText = this.disablePastMessage;
|
|
1696
|
+
}
|
|
1697
|
+
else {
|
|
1698
|
+
this.invalidDateText = `Please enter a date after ${this.formatMinMax(this.minDate)}.`;
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
else if (this.isAfterMax) {
|
|
1702
|
+
if (this.disableFuture) {
|
|
1703
|
+
this.invalidDateText = this.disableFutureMessage;
|
|
1704
|
+
}
|
|
1705
|
+
else {
|
|
1706
|
+
this.invalidDateText = `Please enter a date before ${this.formatMinMax(this.maxDate)}.`;
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
else if (this.disableDays.length !== 0) {
|
|
1710
|
+
this.invalidDateText = this.disableDaysMessage;
|
|
1711
|
+
}
|
|
1712
|
+
else {
|
|
1713
|
+
if (this.disablePast) {
|
|
1714
|
+
this.invalidDateText = this.disablePastMessage;
|
|
1715
|
+
}
|
|
1716
|
+
if (this.disableFuture) {
|
|
1717
|
+
this.invalidDateText = this.disableFutureMessage;
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
else {
|
|
1722
|
+
this.invalidDateText = "";
|
|
1723
|
+
}
|
|
1724
|
+
};
|
|
1725
|
+
// Set refs to the input elements in the order they are displayed (based on the dateFormat)
|
|
1726
|
+
this.setInputsInOrder = () => {
|
|
1727
|
+
var _a;
|
|
1728
|
+
(_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll("input").forEach((input) => this.inputsInOrder.push(input));
|
|
1729
|
+
};
|
|
1730
|
+
// Includes text usually added using aria-describedby
|
|
1731
|
+
// (which doesn't work on input component container)
|
|
1732
|
+
this.setAriaLabelledBy = () => {
|
|
1733
|
+
var _a, _b, _c;
|
|
1734
|
+
if (this.disabled &&
|
|
1735
|
+
!isEmptyString((_a = this.inputCompContainerEl) === null || _a === void 0 ? void 0 : _a.getAttribute(this.ARIA_LABELLED_BY))) {
|
|
1736
|
+
this.removeAriaLabelledBy();
|
|
1737
|
+
return;
|
|
1738
|
+
}
|
|
1739
|
+
if (this.disabled) {
|
|
1740
|
+
return;
|
|
1741
|
+
}
|
|
1742
|
+
const labelEl = (_b = this.el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector("label");
|
|
1743
|
+
const labelId = `${this.inputId}-label`;
|
|
1744
|
+
if (labelEl !== null && labelEl !== undefined) {
|
|
1745
|
+
labelEl.id = labelId;
|
|
1746
|
+
}
|
|
1747
|
+
const hasValidation = !isEmptyString(this.validationStatus) ||
|
|
1748
|
+
!isEmptyString(this.invalidDateText);
|
|
1749
|
+
const labelledBy = `${(_c = labelEl === null || labelEl === void 0 ? void 0 : labelEl.id) !== null && _c !== void 0 ? _c : ""} ${this.screenReaderInfoId} ${getInputDescribedByText(this.el, this.inputId, this.helperText !== "" && this.helperText !== this.defaultHelperText, hasValidation)} ${this.selectedDate ? this.selectedDateInfoId : ""} ${this.assistiveHintId}`;
|
|
1750
|
+
this.inputCompContainerEl.setAttribute(this.ARIA_LABELLED_BY, labelledBy);
|
|
1751
|
+
};
|
|
1752
|
+
// Sets boolean for each input, used to limit the number of characters within each field (2 for day / month, 4 for year)
|
|
1753
|
+
this.setPreventInput = (input, isPrevented) => {
|
|
1754
|
+
switch (input) {
|
|
1755
|
+
case this.dayInputEl:
|
|
1756
|
+
this.preventDayInput = isPrevented;
|
|
1757
|
+
break;
|
|
1758
|
+
case this.monthInputEl:
|
|
1759
|
+
this.preventMonthInput = isPrevented;
|
|
1760
|
+
break;
|
|
1761
|
+
case this.yearInputEl:
|
|
1762
|
+
this.preventYearInput = isPrevented;
|
|
1763
|
+
}
|
|
1764
|
+
};
|
|
1765
|
+
// Get input based on letter representing each date part ("D", "M" or "Y")
|
|
1766
|
+
// (retrieved from dateFormat)
|
|
1767
|
+
this.getInputFromDatePart = (datePart) => {
|
|
1768
|
+
const dayInput = (h("input", { class: "day-input", id: "day-input", ref: (el) => (this.dayInputEl = el), "aria-label": "day", placeholder: "DD", disabled: this.disabled, "aria-required": `${this.required}`, onPaste: this.handlePaste, inputmode: "number", pattern: "[0-9]*", onKeyDown: (event) => this.handleKeyDown(event, this.preventDayInput) }));
|
|
1769
|
+
const monthInput = (h("input", { id: "month-input", class: "month-input", ref: (el) => (this.monthInputEl = el), "aria-label": "month", placeholder: "MM", disabled: this.disabled, "aria-required": `${this.required}`, onPaste: this.handlePaste, inputmode: "number", pattern: "[0-9]*", onKeyDown: (event) => this.handleKeyDown(event, this.preventMonthInput) }));
|
|
1770
|
+
const yearInput = (h("input", { id: "year-input", class: "year-input", ref: (el) => (this.yearInputEl = el), "aria-label": "year", placeholder: "YYYY", maxLength: 4, disabled: this.disabled, "aria-required": `${this.required}`, onPaste: this.handlePaste, inputmode: "number", pattern: "[0-9]*", onKeyDown: (event) => this.handleKeyDown(event, this.preventYearInput) }));
|
|
1771
|
+
let input;
|
|
1772
|
+
switch (datePart) {
|
|
1773
|
+
case "D":
|
|
1774
|
+
input = dayInput;
|
|
1775
|
+
break;
|
|
1776
|
+
case "M":
|
|
1777
|
+
input = monthInput;
|
|
1778
|
+
break;
|
|
1779
|
+
case "Y":
|
|
1780
|
+
input = yearInput;
|
|
1781
|
+
}
|
|
1782
|
+
return input;
|
|
1783
|
+
};
|
|
1784
|
+
// Get input elements in order of chosen date format
|
|
1785
|
+
this.getInputsInOrder = () => {
|
|
1786
|
+
const dateParts = this.dateFormat.split("/");
|
|
1787
|
+
const inputsInOrder = [];
|
|
1788
|
+
dateParts.forEach((part) => {
|
|
1789
|
+
inputsInOrder.push(this.getInputFromDatePart(part.substring(0, 1)));
|
|
1790
|
+
});
|
|
1791
|
+
return inputsInOrder;
|
|
1792
|
+
};
|
|
1793
|
+
// To add to the end of assistive hint to make it clearer that each date part has its own input
|
|
1794
|
+
// that can be changed individually
|
|
1795
|
+
this.getDescOfInputsOrder = () => {
|
|
1796
|
+
let description;
|
|
1797
|
+
switch (this.dateFormat) {
|
|
1798
|
+
case this.DEFAULT_DATE_FORMAT:
|
|
1799
|
+
description = "day, month, and year";
|
|
1800
|
+
break;
|
|
1801
|
+
case "MM/DD/YYYY":
|
|
1802
|
+
description = "month, day, and year";
|
|
1803
|
+
break;
|
|
1804
|
+
case "YYYY/MM/DD":
|
|
1805
|
+
description = "year, month, and day";
|
|
1806
|
+
}
|
|
1807
|
+
return description;
|
|
1808
|
+
};
|
|
1809
|
+
// Add 'required' or 'invalid data' to span used in aria-labelledby
|
|
1810
|
+
// Many ARIA attributes aren't read out by screen reader when on the input component container
|
|
1811
|
+
this.getScreenReaderInfo = (validationStatus) => {
|
|
1812
|
+
let inputDescriptors = "";
|
|
1813
|
+
if (this.required) {
|
|
1814
|
+
inputDescriptors += "required";
|
|
1815
|
+
}
|
|
1816
|
+
if (validationStatus === IcInformationStatus.Error) {
|
|
1817
|
+
inputDescriptors += " invalid data";
|
|
1818
|
+
}
|
|
1819
|
+
return inputDescriptors === "" ? "" : inputDescriptors + ", ";
|
|
1820
|
+
};
|
|
1821
|
+
// Prevent non-number characters being entered
|
|
1822
|
+
// ('e' or '.' - which are usually allowed in <input type="number">)
|
|
1823
|
+
// And limit the number of characters within each field (2 for day / month, 4 for year)
|
|
1824
|
+
// (because 'maxlength' doesn't work on <input type="number">)
|
|
1825
|
+
this.preventInput = (event, isInputPrevented) => {
|
|
1826
|
+
const key = event.key;
|
|
1827
|
+
const input = event.target;
|
|
1828
|
+
let selectedString;
|
|
1829
|
+
if (input) {
|
|
1830
|
+
selectedString = input.value.substring(input.selectionStart || 0, input.selectionEnd || undefined);
|
|
1831
|
+
}
|
|
1832
|
+
if (key === "e" ||
|
|
1833
|
+
key === "." ||
|
|
1834
|
+
key === "-" ||
|
|
1835
|
+
(event.key >= "0" &&
|
|
1836
|
+
event.key <= "9" &&
|
|
1837
|
+
isInputPrevented &&
|
|
1838
|
+
!selectedString)) {
|
|
1839
|
+
event.preventDefault();
|
|
1840
|
+
}
|
|
1841
|
+
};
|
|
1842
|
+
/**
|
|
1843
|
+
* Get whether date has been disabled using disableFuture or disablePast prop, but always allow current day
|
|
1844
|
+
* Consider using dateClamp and inDateRange
|
|
1845
|
+
* @returns `boolean`
|
|
1846
|
+
*/
|
|
1847
|
+
this.isSelectedDateDisabled = () => {
|
|
1848
|
+
if (!this.selectedDate)
|
|
1849
|
+
return false;
|
|
1850
|
+
const currentDate = new Date();
|
|
1851
|
+
const isNotToday = this.selectedDate.toDateString() !== currentDate.toDateString();
|
|
1852
|
+
this.isAfterMax =
|
|
1853
|
+
this.maxDate && this.selectedDate > this.maxDate && isNotToday;
|
|
1854
|
+
this.isBeforeMin =
|
|
1855
|
+
this.minDate && this.selectedDate < this.minDate && isNotToday;
|
|
1856
|
+
return (this.isAfterMax ||
|
|
1857
|
+
this.isBeforeMin ||
|
|
1858
|
+
this.disableDays.includes(this.selectedDate.getDay()) ||
|
|
1859
|
+
(((!!this.disablePast && this.selectedDate < currentDate) ||
|
|
1860
|
+
(!!this.disableFuture && this.selectedDate > currentDate)) &&
|
|
1861
|
+
isNotToday));
|
|
1862
|
+
};
|
|
1863
|
+
this.moveToNextInput = (currentInput) => {
|
|
1864
|
+
var _a;
|
|
1865
|
+
this.preventAutoFormatting = false;
|
|
1866
|
+
(_a = this.inputsInOrder[this.inputsInOrder.findIndex((input) => input === currentInput) + 1]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
1867
|
+
};
|
|
1868
|
+
this.moveToPreviousInput = (currentInput) => {
|
|
1869
|
+
var _a;
|
|
1870
|
+
this.preventAutoFormatting = false;
|
|
1871
|
+
(_a = this.inputsInOrder[this.inputsInOrder.findIndex((input) => input === currentInput) - 1]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
1872
|
+
};
|
|
1873
|
+
this.autocompleteInput = (input) => {
|
|
1874
|
+
const inputValue = input.value;
|
|
1875
|
+
if (this.yearInputEl && input === this.yearInputEl) {
|
|
1876
|
+
// Autocomplete year as current millennium when fewer than 4 characters entered
|
|
1877
|
+
const yearNumbers = ["2", "0", "0"];
|
|
1878
|
+
let autocompletedInput = "";
|
|
1879
|
+
if (inputValue) {
|
|
1880
|
+
yearNumbers.forEach((number, index) => {
|
|
1881
|
+
if (inputValue.length + index <= 3) {
|
|
1882
|
+
autocompletedInput += number;
|
|
1883
|
+
}
|
|
1884
|
+
});
|
|
1885
|
+
this.yearInputEl.value = `${autocompletedInput}${inputValue}`;
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
else if (inputValue.length === 1) {
|
|
1889
|
+
// Autocomplete input as 2 characters (leading zero) when only 1 character entered (for day and month)
|
|
1890
|
+
input.value = +inputValue === 0 ? "01" : `0${inputValue}`;
|
|
1891
|
+
}
|
|
1892
|
+
if (input.value) {
|
|
1893
|
+
this.setInputValue(input);
|
|
1894
|
+
}
|
|
1895
|
+
};
|
|
1896
|
+
this.convertToDate = (year, month, day) => {
|
|
1897
|
+
if (!isEmptyString(year) && !isEmptyString(month) && !isEmptyString(day)) {
|
|
1898
|
+
return new Date(+year, +month - 1, +day);
|
|
1899
|
+
}
|
|
1900
|
+
else {
|
|
1901
|
+
return null;
|
|
1902
|
+
}
|
|
1903
|
+
};
|
|
1904
|
+
this.handleHostBlur = () => {
|
|
1905
|
+
this.removeLabelledBy = false;
|
|
1906
|
+
this.icBlur.emit({ value: this.selectedDate });
|
|
1907
|
+
};
|
|
1908
|
+
this.handleHostFocus = () => {
|
|
1909
|
+
var _a, _b;
|
|
1910
|
+
if ((_b = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.activeElement) === null || _b === void 0 ? void 0 : _b.id.match(/(day|month|year)-input$/)) {
|
|
1911
|
+
this.removeLabelledBy = false;
|
|
1912
|
+
}
|
|
1913
|
+
else {
|
|
1914
|
+
this.removeLabelledBy = true;
|
|
1915
|
+
}
|
|
1916
|
+
this.icFocus.emit({ value: this.selectedDate });
|
|
1917
|
+
};
|
|
1918
|
+
this.handleFormReset = () => {
|
|
1919
|
+
// Get the initial value and populate day, month and year again.
|
|
1920
|
+
this.setDate(this.initialValue);
|
|
1921
|
+
this.setValidationMessage();
|
|
1922
|
+
this.handleDateChange(false);
|
|
1923
|
+
};
|
|
1924
|
+
this.getAriaLabel = (input) => input.getAttribute(this.ARIA_LABEL);
|
|
1925
|
+
this.notifyScreenReaderArrowKeys = (input) => {
|
|
1926
|
+
var _a;
|
|
1927
|
+
const liveRegion = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("#live-region");
|
|
1928
|
+
const ariaLabel = this.getAriaLabel(input);
|
|
1929
|
+
if (liveRegion && input.value && ariaLabel) {
|
|
1930
|
+
let announcement = "";
|
|
1931
|
+
if (input === this.monthInputEl &&
|
|
1932
|
+
!!IcDateInputMonths[+input.value - 1]) {
|
|
1933
|
+
announcement = `${input.value} - ${IcDateInputMonths[+input.value - 1]}, ${ariaLabel}`;
|
|
1934
|
+
}
|
|
1935
|
+
if (input === this.dayInputEl || input === this.yearInputEl) {
|
|
1936
|
+
announcement = `${input.value}, ${ariaLabel}`;
|
|
1937
|
+
}
|
|
1938
|
+
liveRegion.textContent = announcement;
|
|
1939
|
+
}
|
|
1940
|
+
};
|
|
1941
|
+
this.notifyScreenReaderInput = (input, liveRegion) => {
|
|
1942
|
+
const ariaLabel = this.getAriaLabel(input);
|
|
1943
|
+
const value = input.value;
|
|
1944
|
+
if (ariaLabel && value) {
|
|
1945
|
+
let announcement = "";
|
|
1946
|
+
const monthValue = IcDateInputMonths[+value - 1];
|
|
1947
|
+
if (input === this.monthInputEl &&
|
|
1948
|
+
!!monthValue &&
|
|
1949
|
+
this.isValidMonth &&
|
|
1950
|
+
value.length === 2) {
|
|
1951
|
+
announcement = `${value} - ${monthValue}`;
|
|
1952
|
+
}
|
|
1953
|
+
else if ((input === this.dayInputEl && this.isValidDay && value.length === 2) ||
|
|
1954
|
+
(input === this.yearInputEl && value.length === 4)) {
|
|
1955
|
+
announcement = value;
|
|
1956
|
+
}
|
|
1957
|
+
liveRegion.textContent = `${announcement}, ${ariaLabel}`;
|
|
1958
|
+
}
|
|
1959
|
+
};
|
|
1960
|
+
this.setFitToValueStyling = (input) => {
|
|
1961
|
+
if (input.value) {
|
|
1962
|
+
input.classList.add(this.FIT_TO_VALUE);
|
|
1963
|
+
}
|
|
1964
|
+
else {
|
|
1965
|
+
input.classList.remove(this.FIT_TO_VALUE);
|
|
1966
|
+
}
|
|
1967
|
+
};
|
|
1968
|
+
this.setAriaInvalid = (validDay, validMonth, validDate, disabledDate) => {
|
|
1969
|
+
var _a, _b;
|
|
1970
|
+
if (this.inputsInOrder.length) {
|
|
1971
|
+
this.inputsInOrder.forEach((input) => {
|
|
1972
|
+
input.removeAttribute(this.ARIA_INVALID);
|
|
1973
|
+
});
|
|
1974
|
+
if (!validDay) {
|
|
1975
|
+
(_a = this.dayInputEl) === null || _a === void 0 ? void 0 : _a.setAttribute(this.ARIA_INVALID, "true");
|
|
1976
|
+
}
|
|
1977
|
+
if (!validMonth) {
|
|
1978
|
+
(_b = this.monthInputEl) === null || _b === void 0 ? void 0 : _b.setAttribute(this.ARIA_INVALID, "true");
|
|
1979
|
+
}
|
|
1980
|
+
if (!validDate || disabledDate) {
|
|
1981
|
+
this.inputsInOrder.forEach((input) => {
|
|
1982
|
+
input.setAttribute(this.ARIA_INVALID, "true");
|
|
1983
|
+
});
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
};
|
|
1987
|
+
this.handleClear = () => {
|
|
1988
|
+
this.clearInput = true;
|
|
1989
|
+
this.inputsInOrder.forEach((input) => {
|
|
1990
|
+
input.classList.remove(this.FIT_TO_VALUE);
|
|
1991
|
+
this.setInputValue(input, true);
|
|
1992
|
+
this.setPreventInput(input, false);
|
|
1993
|
+
});
|
|
1994
|
+
this.clearInput = false;
|
|
1995
|
+
this.preventInputsUpdating = false;
|
|
1996
|
+
this.setValidationMessage();
|
|
1997
|
+
this.handleDateChange(true);
|
|
1998
|
+
this.inputsInOrder[0].focus();
|
|
1999
|
+
};
|
|
2000
|
+
this.handleCalendarOpen = (ev) => {
|
|
2001
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2002
|
+
ev.stopImmediatePropagation();
|
|
2003
|
+
(_c = (_b = (_a = this.calendarButtonEl) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector("ic-tooltip")) === null || _c === void 0 ? void 0 : _c.displayTooltip(false);
|
|
2004
|
+
this.calendarButtonClicked.emit({ value: this.selectedDate });
|
|
2005
|
+
(_f = (_e = (_d = this.calendarButtonEl) === null || _d === void 0 ? void 0 : _d.shadowRoot) === null || _e === void 0 ? void 0 : _e.querySelector("ic-tooltip")) === null || _f === void 0 ? void 0 : _f.displayTooltip(false);
|
|
2006
|
+
this.preventInputsUpdating = false;
|
|
2007
|
+
this.calendarIsOpen = true;
|
|
2008
|
+
};
|
|
2009
|
+
this.setValueAndEmitChange = (value) => {
|
|
2010
|
+
if (!dateMatches(this.value ? new Date(this.value) : null, value)) {
|
|
2011
|
+
this.emitIcChange(value);
|
|
2012
|
+
this.value = value;
|
|
2013
|
+
}
|
|
2014
|
+
};
|
|
2015
|
+
this.handleCalendarFocus = () => {
|
|
2016
|
+
this.calendarFocused = true;
|
|
2017
|
+
if (this.calendarIsOpen) {
|
|
2018
|
+
// focus event triggered by closing calendar dialog so inputs should update
|
|
2019
|
+
this.preventInputsUpdating = false;
|
|
2020
|
+
this.calendarIsOpen = false;
|
|
2021
|
+
}
|
|
2022
|
+
else {
|
|
2023
|
+
this.preventInputsUpdating = true;
|
|
2024
|
+
}
|
|
2025
|
+
};
|
|
2026
|
+
this.handleCalendarBlur = () => {
|
|
2027
|
+
this.calendarFocused = false;
|
|
2028
|
+
this.preventInputsUpdating = true;
|
|
2029
|
+
};
|
|
2030
|
+
this.handleClearFocus = () => {
|
|
2031
|
+
this.removeLabelledBy = true;
|
|
2032
|
+
this.preventInputsUpdating = true;
|
|
2033
|
+
this.clearButtonFocused = true;
|
|
2034
|
+
};
|
|
2035
|
+
this.handleClearBlur = (ev) => {
|
|
2036
|
+
var _a;
|
|
2037
|
+
this.clearButtonFocused = false;
|
|
2038
|
+
this.preventInputsUpdating = true;
|
|
2039
|
+
if ((_a = ev.relatedTarget) === null || _a === void 0 ? void 0 : _a.id.match(/(day|year)-input$/)) {
|
|
2040
|
+
this.removeLabelledBy = false;
|
|
2041
|
+
return;
|
|
2042
|
+
}
|
|
2043
|
+
this.removeLabelledBy = true;
|
|
2044
|
+
};
|
|
2045
|
+
this.emitIcChange = (d) => {
|
|
2046
|
+
this.selectedDate = d;
|
|
2047
|
+
if (!dateMatches(this.selectedDate, d) ||
|
|
2048
|
+
this.day !== null ||
|
|
2049
|
+
this.month !== null ||
|
|
2050
|
+
this.year !== null) {
|
|
2051
|
+
let UTCDate = null;
|
|
2052
|
+
if (d !== null) {
|
|
2053
|
+
UTCDate = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
|
|
2054
|
+
}
|
|
2055
|
+
this.icChange.emit({
|
|
2056
|
+
value: d,
|
|
2057
|
+
dateObject: {
|
|
2058
|
+
day: this.day === "" ? null : this.day,
|
|
2059
|
+
month: this.month === "" ? null : this.month,
|
|
2060
|
+
year: this.year === "" ? null : this.year,
|
|
2061
|
+
},
|
|
2062
|
+
utcValue: UTCDate,
|
|
2063
|
+
});
|
|
2064
|
+
}
|
|
2065
|
+
};
|
|
2066
|
+
}
|
|
2067
|
+
watchInputHandler() {
|
|
2068
|
+
if (this.emitDatePartChange &&
|
|
2069
|
+
!this.externalSetDate &&
|
|
2070
|
+
!this.clearInput &&
|
|
2071
|
+
!(this.day && this.month && this.year) &&
|
|
2072
|
+
this.selectedDate === null) {
|
|
2073
|
+
this.emitIcChange(this.selectedDate);
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
watchDisabledHandler() {
|
|
2077
|
+
removeDisabledFalse(this.disabled, this.el);
|
|
2078
|
+
}
|
|
2079
|
+
watchDisableFutureHandler() {
|
|
2080
|
+
this.watchMaxHandler();
|
|
2081
|
+
}
|
|
2082
|
+
watchDisablePastHandler() {
|
|
2083
|
+
this.watchMinHandler();
|
|
2084
|
+
}
|
|
2085
|
+
watchMaxHandler() {
|
|
2086
|
+
if (this.disableFuture) {
|
|
2087
|
+
this.maxDate = new Date();
|
|
2088
|
+
}
|
|
2089
|
+
else {
|
|
2090
|
+
this.maxDate = createDate(this.max, this.dateFormat);
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
watchMinHandler() {
|
|
2094
|
+
if (this.disablePast) {
|
|
2095
|
+
this.minDate = new Date();
|
|
2096
|
+
}
|
|
2097
|
+
else {
|
|
2098
|
+
this.minDate = createDate(this.min, this.dateFormat);
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
watchRequiredHandler() {
|
|
2102
|
+
var _a, _b;
|
|
2103
|
+
// Prevent asterisk being read out after the label by screen reader (by applying aria-hidden)
|
|
2104
|
+
// Needed because label is included in 'aria-labelledby' instead of using 'aria-label'
|
|
2105
|
+
const labelEl = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("label");
|
|
2106
|
+
if (this.required) {
|
|
2107
|
+
const asteriskSpan = document.createElement("span");
|
|
2108
|
+
asteriskSpan.setAttribute("id", "asterisk-span");
|
|
2109
|
+
asteriskSpan.setAttribute("aria-hidden", "true");
|
|
2110
|
+
asteriskSpan.textContent = " *";
|
|
2111
|
+
labelEl === null || labelEl === void 0 ? void 0 : labelEl.appendChild(asteriskSpan);
|
|
2112
|
+
}
|
|
2113
|
+
else {
|
|
2114
|
+
const asteriskSpan = (_b = this.el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector("#asterisk-span");
|
|
2115
|
+
if (asteriskSpan) {
|
|
2116
|
+
asteriskSpan.remove();
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
disconnectedCallback() {
|
|
2121
|
+
removeFormResetListener(this.el, this.handleFormReset);
|
|
2122
|
+
}
|
|
2123
|
+
componentWillLoad() {
|
|
2124
|
+
this.defaultHelperText = `Use format ${this.dateFormat}`;
|
|
2125
|
+
if (isEmptyString(this.helperText))
|
|
2126
|
+
this.helperText = this.defaultHelperText;
|
|
2127
|
+
this.watchMinHandler();
|
|
2128
|
+
this.watchMaxHandler();
|
|
2129
|
+
if (this.value) {
|
|
2130
|
+
this.externalSetDate = true;
|
|
2131
|
+
this.setDate(this.value);
|
|
2132
|
+
}
|
|
2133
|
+
this.screenReaderInfoId = `${this.inputId}-screen-reader-info`;
|
|
2134
|
+
this.assistiveHintId = `${this.inputId}-assistive-hint`;
|
|
2135
|
+
this.selectedDateInfoId = `${this.inputId}-selected-date-info`;
|
|
2136
|
+
addFormResetListener(this.el, this.handleFormReset);
|
|
2137
|
+
removeDisabledFalse(this.disabled, this.el);
|
|
2138
|
+
}
|
|
2139
|
+
componentDidLoad() {
|
|
2140
|
+
this.setInputsInOrder();
|
|
2141
|
+
onComponentRequiredPropUndefined([{ prop: this.label, propName: "label" }], "Date Input");
|
|
2142
|
+
if (this.value) {
|
|
2143
|
+
this.updateInputValues(this.day, this.month, this.year);
|
|
2144
|
+
this.inputsInOrder.forEach((input) => {
|
|
2145
|
+
input.classList.add(this.FIT_TO_VALUE);
|
|
2146
|
+
});
|
|
2147
|
+
}
|
|
2148
|
+
this.setAriaInvalid(this.isValidDay, this.isValidMonth, this.isValidDate, this.isDisabledDate);
|
|
2149
|
+
if (this.value) {
|
|
2150
|
+
this.notifyScreenReaderSelectedDate();
|
|
2151
|
+
}
|
|
2152
|
+
this.inputsInOrder.forEach((input) => {
|
|
2153
|
+
input.addEventListener("input", this.handleInput);
|
|
2154
|
+
input.addEventListener("focus", this.handleFocus);
|
|
2155
|
+
input.addEventListener("blur", this.handleBlur);
|
|
2156
|
+
});
|
|
2157
|
+
this.watchRequiredHandler();
|
|
2158
|
+
}
|
|
2159
|
+
componentWillUpdate() {
|
|
2160
|
+
if (isEmptyString(this.helperText))
|
|
2161
|
+
this.helperText = this.defaultHelperText;
|
|
2162
|
+
if (!this.preventInputsUpdating)
|
|
2163
|
+
this.setDate(this.value);
|
|
2164
|
+
this.setAriaInvalid(this.isValidDay, this.isValidMonth, this.isValidDate, this.isDisabledDate);
|
|
2165
|
+
this.handleDateChange(false);
|
|
2166
|
+
this.preventInputsUpdating = false;
|
|
2167
|
+
}
|
|
2168
|
+
componentDidRender() {
|
|
2169
|
+
if (this.removeLabelledBy) {
|
|
2170
|
+
this.removeAriaLabelledBy();
|
|
2171
|
+
return;
|
|
2172
|
+
}
|
|
2173
|
+
this.setAriaLabelledBy();
|
|
2174
|
+
}
|
|
2175
|
+
/**
|
|
2176
|
+
* Returns the value as a Date object
|
|
2177
|
+
* @returns Date
|
|
2178
|
+
*/
|
|
2179
|
+
async getDate() {
|
|
2180
|
+
return this.selectedDate;
|
|
2181
|
+
}
|
|
2182
|
+
/**
|
|
2183
|
+
* @internal Sets focus on the calendar button.
|
|
2184
|
+
*/
|
|
2185
|
+
async setCalendarFocus() {
|
|
2186
|
+
if (this.calendarButtonEl) {
|
|
2187
|
+
this.calendarButtonEl.focus();
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
/**
|
|
2191
|
+
* @internal Used to pass disabledDays from parent component.
|
|
2192
|
+
*/
|
|
2193
|
+
async setDisableDays(days) {
|
|
2194
|
+
this.disableDays = days;
|
|
2195
|
+
}
|
|
2196
|
+
/**
|
|
2197
|
+
* @internal Used to enable other components to invoke an IcChange event from the input.
|
|
2198
|
+
*/
|
|
2199
|
+
async triggerIcChange(d) {
|
|
2200
|
+
this.externalSetDate = true;
|
|
2201
|
+
this.setDate(d);
|
|
2202
|
+
this.emitIcChange(d);
|
|
2203
|
+
this.externalSetDate = false;
|
|
2204
|
+
}
|
|
2205
|
+
removeAriaLabelledBy() {
|
|
2206
|
+
this.inputCompContainerEl.removeAttribute(this.ARIA_LABELLED_BY);
|
|
2207
|
+
}
|
|
2208
|
+
setPastedValueAndValidation(isValidDate, pastedValue, event) {
|
|
2209
|
+
switch (true) {
|
|
2210
|
+
case isValidDate: {
|
|
2211
|
+
const nextParsedValue = this.isZuluTime
|
|
2212
|
+
? extractDateFromZuluDateTime(pastedValue)
|
|
2213
|
+
: pastedValue;
|
|
2214
|
+
const dateParts = nextParsedValue.split(/-|\/|\./);
|
|
2215
|
+
this.inputsInOrder.forEach((input, index) => {
|
|
2216
|
+
input.classList.add(this.FIT_TO_VALUE);
|
|
2217
|
+
if (this.isZuluTime) {
|
|
2218
|
+
this.pasteZuluDateTime(dateParts, index);
|
|
2219
|
+
}
|
|
2220
|
+
else {
|
|
2221
|
+
let dateValue;
|
|
2222
|
+
if (input === this.dayInputEl || input === this.monthInputEl) {
|
|
2223
|
+
dateValue = this.slicePastedDate(2, dateParts[index]);
|
|
2224
|
+
}
|
|
2225
|
+
else {
|
|
2226
|
+
dateValue = this.slicePastedDate(4, dateParts[index]);
|
|
2227
|
+
}
|
|
2228
|
+
input.value = dateValue;
|
|
2229
|
+
this.setInputValue(input);
|
|
2230
|
+
this.autocompleteInput(input);
|
|
2231
|
+
}
|
|
2232
|
+
});
|
|
2233
|
+
this.isZuluTime = false;
|
|
2234
|
+
break;
|
|
2235
|
+
}
|
|
2236
|
+
case (pastedValue.length === 1 ||
|
|
2237
|
+
pastedValue.length === 2 ||
|
|
2238
|
+
pastedValue.length === 4) &&
|
|
2239
|
+
isNumeric(pastedValue):
|
|
2240
|
+
if (this.checkSingleCopiedValueIsValid(event.target, pastedValue)) {
|
|
2241
|
+
// Check if copied value can be pasted into input
|
|
2242
|
+
this.setInputPasteValue(event.target, pastedValue);
|
|
2243
|
+
this.setInputValue(event.target);
|
|
2244
|
+
}
|
|
2245
|
+
else {
|
|
2246
|
+
this.displayPastedValidation(event);
|
|
2247
|
+
}
|
|
2248
|
+
break;
|
|
2249
|
+
case pastedValue.length === 3 && isNumeric(pastedValue):
|
|
2250
|
+
if (event.target !== this.yearInputEl) {
|
|
2251
|
+
this.displayPastedValidation(event);
|
|
2252
|
+
}
|
|
2253
|
+
else {
|
|
2254
|
+
this.setInputPasteValue(event.target, pastedValue);
|
|
2255
|
+
this.setInputValue(event.target);
|
|
2256
|
+
}
|
|
2257
|
+
break;
|
|
2258
|
+
case pastedValue.length >= 5 && isNumeric(pastedValue):
|
|
2259
|
+
this.displayPastedValidation(event);
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
pasteZuluDateTime(dateParts, index) {
|
|
2263
|
+
// ['YYYY', 'MM', 'DD']
|
|
2264
|
+
if (index === 0 && this.yearInputEl) {
|
|
2265
|
+
const dateValue = this.slicePastedDate(4, dateParts[index]);
|
|
2266
|
+
this.yearInputEl.value = dateValue;
|
|
2267
|
+
this.setInputValue(this.yearInputEl);
|
|
2268
|
+
}
|
|
2269
|
+
else if (index === 1 && this.monthInputEl) {
|
|
2270
|
+
// The month value is the second item in the array
|
|
2271
|
+
const dateValue = this.slicePastedDate(2, dateParts[index]);
|
|
2272
|
+
this.monthInputEl.value = dateValue;
|
|
2273
|
+
this.setInputValue(this.monthInputEl);
|
|
2274
|
+
}
|
|
2275
|
+
else if (this.dayInputEl) {
|
|
2276
|
+
const dateValue = this.slicePastedDate(2, dateParts[index]);
|
|
2277
|
+
this.dayInputEl.value = dateValue;
|
|
2278
|
+
this.setInputValue(this.dayInputEl);
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
displayPastedValidation(event) {
|
|
2282
|
+
var _a;
|
|
2283
|
+
if (((_a = this.invalidDateText) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
2284
|
+
this.previousInvalidDateTest = this.invalidDateText;
|
|
2285
|
+
}
|
|
2286
|
+
this.invalidDateText = `Please paste a valid ${this.getAriaLabel(event.target)}`;
|
|
2287
|
+
this.validationStatus = IcInformationStatus.Error;
|
|
2288
|
+
this.isPasteValidationDisplayed = true;
|
|
2289
|
+
}
|
|
2290
|
+
setPasteInvalidText() {
|
|
2291
|
+
var _a;
|
|
2292
|
+
if (this.isPasteValidationDisplayed) {
|
|
2293
|
+
this.invalidDateText = (_a = this.previousInvalidDateTest) !== null && _a !== void 0 ? _a : "";
|
|
2294
|
+
this.isPasteValidationDisplayed = false;
|
|
2295
|
+
// This is to prevent setDate from triggering within componentWillUpdate
|
|
2296
|
+
this.preventInputsUpdating = true;
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
notifyScreenReader(input, event) {
|
|
2300
|
+
var _a;
|
|
2301
|
+
const liveRegion = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("#live-region");
|
|
2302
|
+
if (liveRegion) {
|
|
2303
|
+
if (this.isKeyboardOrEvent(event)) {
|
|
2304
|
+
this.notifyScreenReaderArrowKeys(input);
|
|
2305
|
+
}
|
|
2306
|
+
else if (Object.prototype.toString.call(event) === this.INPUT_EVENT_OBJECT_STRING) {
|
|
2307
|
+
this.notifyScreenReaderInput(input, liveRegion);
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
render() {
|
|
2312
|
+
const { inputId, label, disabled, helperText, hideHelperText, hideLabel, showClearButton, showCalendarButton, size, theme, validationAriaLive, } = this;
|
|
2313
|
+
const hasCustomValidation = !isEmptyString(this.validationStatus);
|
|
2314
|
+
const validationStatus = hasCustomValidation
|
|
2315
|
+
? this.validationStatus
|
|
2316
|
+
: !isEmptyString(this.invalidDateText)
|
|
2317
|
+
? IcInformationStatus.Error
|
|
2318
|
+
: "";
|
|
2319
|
+
const assistiveHint = `Type or use the up and down arrow keys to change the values for the ${this.getDescOfInputsOrder()}.`;
|
|
2320
|
+
renderHiddenInput(true, this.el, this.name, this.convertToDate(this.year, this.month, this.day), this.disabled);
|
|
2321
|
+
return (h(Host, { key: '0b677de27ad0835484eb7a68e6bc52cddb13b975', class: {
|
|
2322
|
+
[`ic-theme-${theme}`]: theme !== "inherit",
|
|
2323
|
+
[`ic-date-input-disabled`]: disabled,
|
|
2324
|
+
}, onBlur: this.handleHostBlur, onFocus: this.handleHostFocus }, h("ic-input-container", { key: '8b440f9db75cf42c81163a8fc3fc927bddf061e7', disabled: disabled }, !(hideLabel && hideHelperText) && (h("ic-input-label", { key: '459c0ccececeddf034ee64775c41bea6e2c57b29', for: inputId, label: label, hideLabel: hideLabel, helperText: !hideHelperText ? helperText : "", disabled: disabled }, h("slot", { key: 'd051f25b9e91432752719c4c3e7511242697f93b', name: "helper-text", slot: "helper-text" }))), h("span", { key: 'bf2072a9a7482fa73ad3d4f178eadf3a39ea38d4', id: this.screenReaderInfoId, class: "sr-only", "aria-hidden": "true" }, this.getScreenReaderInfo(validationStatus), hideLabel && `${label}\n`, hideHelperText && `${helperText}\n`, `${this.defaultHelperText}.`), h("span", { key: 'ddae7fb05d3ff797eb08207dd12b3d98f0f3aa05', id: this.assistiveHintId, class: "sr-only", "aria-hidden": "true" }, assistiveHint), h("span", { key: 'bbd17aaf26b098379f436a6fc59fdcee52c52b64', id: "live-region", "aria-live": "assertive", class: "sr-only" }), h("ic-input-component-container", { key: 'c602e815b61b7c7bbd31390f47116f58b21852d4', id: inputId, ref: (el) => (this.inputCompContainerEl = el), disabled: disabled, validationStatus: validationStatus, size: size, role: "group", class: { [`ic-theme-${theme}`]: theme !== "inherit" } }, h("div", { key: '131868d25ab4297d80efec74f893552817f17186', class: "input-container" }, h("div", { key: 'c7184bd4b046ffd309fb20ee8fc90033d33e05fc', class: "date-inputs" }, this.getInputsInOrder()[0], "/", this.getInputsInOrder()[1], "/", this.getInputsInOrder()[2]), h("div", { key: '09009c954f7f4d0771553fdc13bfe2cc25cbf74a', class: "action-buttons" }, showClearButton && (h("ic-button", { key: '7a1878087c6b6091a7ef27c4cac6ac145ca09ae9', id: "clear-button", "aria-label": "Clear input", class: {
|
|
2325
|
+
["clear-button"]: true,
|
|
2326
|
+
["hidden"]: isEmptyString(this.day) &&
|
|
2327
|
+
isEmptyString(this.month) &&
|
|
2328
|
+
isEmptyString(this.year),
|
|
2329
|
+
}, disabled: this.disabled, innerHTML: Clear, onClick: this.handleClear, onFocus: this.handleClearFocus, onBlur: this.handleClearBlur, variant: "icon-tertiary", theme: this.clearButtonFocused ? "light" : "dark", size: size })), showCalendarButton && (h("div", { key: 'ec2f995db607ae5d575ddd7994e85f4b883ce2bb', class: "show-calendar-button-wrapper" }, h("div", { key: '74e895071ab608fcccc0a3e2b2ec368511efe4d3', class: { divider: true, [size]: true } }), h("ic-button", { key: '51e8939da851ae18809840d22492f3b5be958b26', id: "calendar-button", ref: (el) => (this.calendarButtonEl = el), "aria-label": "Display calendar", "aria-haspopup": "dialog", class: "calendar-button", disabled: this.disabled, innerHTML: Calendar, onClick: this.handleCalendarOpen, variant: "icon-tertiary", size: size, onFocus: this.handleCalendarFocus, onBlur: this.handleCalendarBlur, theme: this.calendarFocused ? "light" : "dark" })))))), h("span", { key: '77d360d10492577650304e7914021ad40bb8b281', id: this.selectedDateInfoId, class: "sr-only", "aria-live": "polite" }, h("span", { key: '1c285045fb1b18bca93c9e32956e93b8d400b0a1', ref: (el) => (this.selectedDateInfoEl = el), role: "status" })), h("ic-input-validation", { key: '7f02c2d9ec754c92dec3156339e6ea6b504b8d74', status: validationStatus, message: hasCustomValidation ? this.validationText : this.invalidDateText, for: inputId, ariaLiveMode: validationAriaLive }))));
|
|
2330
|
+
}
|
|
2331
|
+
static get delegatesFocus() { return true; }
|
|
2332
|
+
get el() { return getElement(this); }
|
|
2333
|
+
static get watchers() { return {
|
|
2334
|
+
"day": ["watchInputHandler"],
|
|
2335
|
+
"month": ["watchInputHandler"],
|
|
2336
|
+
"year": ["watchInputHandler"],
|
|
2337
|
+
"disabled": ["watchDisabledHandler"],
|
|
2338
|
+
"disableFuture": ["watchDisableFutureHandler"],
|
|
2339
|
+
"disablePast": ["watchDisablePastHandler"],
|
|
2340
|
+
"max": ["watchMaxHandler"],
|
|
2341
|
+
"min": ["watchMinHandler"],
|
|
2342
|
+
"required": ["watchRequiredHandler"]
|
|
2343
|
+
}; }
|
|
2344
|
+
};
|
|
2345
|
+
DateInput.style = IcDateInputStyle0;
|
|
2346
|
+
|
|
2347
|
+
export { Calendar$1 as ic_calendar, DateInput as ic_date_input };
|
|
2348
|
+
|
|
2349
|
+
//# sourceMappingURL=ic-calendar_2.entry.js.map
|