@refinitiv-ui/elements 5.0.0-beta.3 → 5.0.0-dev.204
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/CHANGELOG.md +325 -73
- package/README.md +13 -2
- package/lib/accordion/custom-elements.json +0 -13
- package/lib/accordion/custom-elements.md +18 -0
- package/lib/accordion/index.d.ts +13 -10
- package/lib/accordion/index.js +15 -18
- package/lib/appstate-bar/custom-elements.json +1 -1
- package/lib/appstate-bar/custom-elements.md +22 -0
- package/lib/appstate-bar/index.d.ts +15 -6
- package/lib/appstate-bar/index.js +17 -11
- package/lib/autosuggest/custom-elements.json +24 -4
- package/lib/autosuggest/custom-elements.md +54 -0
- package/lib/autosuggest/helpers/types.d.ts +22 -1
- package/lib/autosuggest/helpers/types.js +0 -1
- package/lib/autosuggest/helpers/utils.d.ts +2 -2
- package/lib/autosuggest/helpers/utils.js +1 -3
- package/lib/autosuggest/index.d.ts +21 -9
- package/lib/autosuggest/index.js +45 -31
- package/lib/button/custom-elements.json +3 -3
- package/lib/button/custom-elements.md +23 -0
- package/lib/button/index.d.ts +27 -20
- package/lib/button/index.js +92 -74
- package/lib/button/themes/halo/dark/index.js +1 -1
- package/lib/button/themes/halo/light/index.js +1 -1
- package/lib/button/themes/solar/charcoal/index.js +1 -1
- package/lib/button/themes/solar/pearl/index.js +1 -1
- package/lib/button-bar/custom-elements.md +9 -0
- package/lib/button-bar/index.d.ts +60 -4
- package/lib/button-bar/index.js +164 -19
- package/lib/calendar/constants.d.ts +26 -0
- package/lib/calendar/constants.js +28 -0
- package/lib/calendar/custom-elements.json +8 -6
- package/lib/calendar/custom-elements.md +35 -0
- package/lib/calendar/index.d.ts +119 -21
- package/lib/calendar/index.js +512 -157
- package/lib/calendar/locales.d.ts +1 -31
- package/lib/calendar/locales.js +3 -107
- package/lib/calendar/themes/halo/dark/index.js +1 -1
- package/lib/calendar/themes/halo/light/index.js +1 -1
- package/lib/calendar/themes/solar/charcoal/index.js +1 -1
- package/lib/calendar/themes/solar/pearl/index.js +1 -1
- package/lib/calendar/types.d.ts +12 -13
- package/lib/calendar/types.js +1 -7
- package/lib/calendar/utils.d.ts +31 -1
- package/lib/calendar/utils.js +105 -3
- package/lib/canvas/custom-elements.json +9 -7
- package/lib/canvas/custom-elements.md +27 -0
- package/lib/canvas/index.d.ts +14 -6
- package/lib/canvas/index.js +17 -12
- package/lib/card/custom-elements.json +21 -9
- package/lib/card/custom-elements.md +24 -0
- package/lib/card/helpers/types.d.ts +1 -1
- package/lib/card/helpers/types.js +0 -1
- package/lib/card/index.d.ts +67 -20
- package/lib/card/index.js +132 -35
- package/lib/card/themes/halo/dark/index.js +1 -1
- package/lib/card/themes/halo/light/index.js +1 -1
- package/lib/card/themes/solar/charcoal/index.js +1 -1
- package/lib/card/themes/solar/pearl/index.js +1 -1
- package/lib/chart/custom-elements.json +3 -3
- package/lib/chart/custom-elements.md +16 -0
- package/lib/chart/helpers/index.d.ts +2 -0
- package/lib/chart/helpers/index.js +2 -0
- package/lib/chart/helpers/legend.d.ts +2 -2
- package/lib/chart/helpers/legend.js +2 -3
- package/lib/chart/helpers/merge.d.ts +15 -0
- package/lib/chart/helpers/merge.js +28 -0
- package/lib/chart/helpers/types.d.ts +40 -12
- package/lib/chart/helpers/types.js +0 -1
- package/lib/chart/index.d.ts +34 -26
- package/lib/chart/index.js +58 -55
- package/lib/chart/plugins/doughnut-center-label.js +4 -5
- package/lib/checkbox/custom-elements.json +4 -4
- package/lib/checkbox/custom-elements.md +18 -0
- package/lib/checkbox/index.d.ts +29 -14
- package/lib/checkbox/index.js +65 -34
- package/lib/checkbox/themes/halo/dark/index.js +1 -1
- package/lib/checkbox/themes/halo/light/index.js +1 -1
- package/lib/clock/custom-elements.json +21 -4
- package/lib/clock/custom-elements.md +28 -0
- package/lib/clock/index.d.ts +25 -6
- package/lib/clock/index.js +44 -18
- package/lib/clock/themes/halo/dark/index.js +1 -1
- package/lib/clock/themes/halo/light/index.js +1 -1
- package/lib/clock/themes/solar/charcoal/index.js +1 -1
- package/lib/clock/themes/solar/pearl/index.js +1 -1
- package/lib/clock/utils/TickManager.js +2 -3
- package/lib/clock/utils/timestamps.js +0 -1
- package/lib/collapse/custom-elements.md +27 -0
- package/lib/collapse/index.d.ts +15 -8
- package/lib/collapse/index.js +18 -13
- package/lib/color-dialog/custom-elements.json +29 -16
- package/lib/color-dialog/custom-elements.md +39 -0
- package/lib/color-dialog/elements/color-palettes.d.ts +13 -6
- package/lib/color-dialog/elements/color-palettes.js +16 -13
- package/lib/color-dialog/elements/grayscale-palettes.d.ts +13 -6
- package/lib/color-dialog/elements/grayscale-palettes.js +17 -13
- package/lib/color-dialog/elements/palettes.d.ts +15 -3
- package/lib/color-dialog/elements/palettes.js +65 -45
- package/lib/color-dialog/helpers/color-helpers.d.ts +7 -53
- package/lib/color-dialog/helpers/color-helpers.js +12 -110
- package/lib/color-dialog/helpers/value-model.d.ts +1 -1
- package/lib/color-dialog/helpers/value-model.js +18 -17
- package/lib/color-dialog/index.d.ts +27 -20
- package/lib/color-dialog/index.js +54 -45
- package/lib/combo-box/custom-elements.json +51 -17
- package/lib/combo-box/custom-elements.md +42 -0
- package/lib/combo-box/helpers/filter.d.ts +4 -4
- package/lib/combo-box/helpers/filter.js +0 -1
- package/lib/combo-box/helpers/keyboard-event.js +0 -1
- package/lib/combo-box/helpers/renderer.d.ts +8 -0
- package/lib/combo-box/helpers/renderer.js +24 -0
- package/lib/combo-box/helpers/types.d.ts +2 -2
- package/lib/combo-box/helpers/types.js +0 -1
- package/lib/combo-box/index.d.ts +63 -32
- package/lib/combo-box/index.js +102 -60
- package/lib/combo-box/themes/halo/dark/index.js +2 -3
- package/lib/combo-box/themes/halo/light/index.js +2 -3
- package/lib/combo-box/themes/solar/charcoal/index.js +2 -3
- package/lib/combo-box/themes/solar/pearl/index.js +2 -3
- package/lib/counter/custom-elements.json +39 -0
- package/lib/counter/custom-elements.md +11 -0
- package/lib/counter/index.d.ts +91 -0
- package/lib/counter/index.js +154 -0
- package/lib/counter/themes/halo/dark/index.js +3 -0
- package/lib/counter/themes/halo/light/index.js +3 -0
- package/lib/counter/themes/solar/charcoal/index.js +3 -0
- package/lib/counter/themes/solar/pearl/index.js +3 -0
- package/lib/counter/utils.d.ts +13 -0
- package/lib/counter/utils.js +52 -0
- package/lib/datetime-picker/custom-elements.json +53 -24
- package/lib/datetime-picker/custom-elements.md +57 -0
- package/lib/datetime-picker/index.d.ts +34 -16
- package/lib/datetime-picker/index.js +56 -38
- package/lib/datetime-picker/locales.d.ts +1 -1
- package/lib/datetime-picker/locales.js +12 -2
- package/lib/datetime-picker/themes/solar/charcoal/index.js +1 -1
- package/lib/datetime-picker/themes/solar/pearl/index.js +1 -1
- package/lib/datetime-picker/types.d.ts +1 -1
- package/lib/datetime-picker/types.js +0 -1
- package/lib/datetime-picker/utils.js +1 -2
- package/lib/dialog/custom-elements.json +34 -12
- package/lib/dialog/custom-elements.md +47 -0
- package/lib/dialog/draggable-element.js +25 -16
- package/lib/dialog/index.d.ts +25 -21
- package/lib/dialog/index.js +36 -32
- package/lib/email-field/custom-elements.json +81 -94
- package/lib/email-field/custom-elements.md +37 -0
- package/lib/email-field/index.d.ts +47 -112
- package/lib/email-field/index.js +48 -241
- package/lib/email-field/themes/halo/dark/index.js +1 -1
- package/lib/email-field/themes/halo/light/index.js +1 -1
- package/lib/email-field/themes/solar/charcoal/index.js +1 -1
- package/lib/email-field/themes/solar/pearl/index.js +1 -1
- package/lib/events.d.ts +121 -0
- package/lib/events.js +1 -0
- package/lib/flag/custom-elements.md +10 -0
- package/lib/flag/index.d.ts +14 -5
- package/lib/flag/index.js +19 -12
- package/lib/flag/utils/FlagLoader.d.ts +1 -1
- package/lib/flag/utils/FlagLoader.js +1 -2
- package/lib/header/custom-elements.md +18 -0
- package/lib/header/index.d.ts +10 -3
- package/lib/header/index.js +12 -8
- package/lib/heatmap/custom-elements.json +13 -0
- package/lib/heatmap/custom-elements.md +26 -0
- package/lib/heatmap/helpers/color.d.ts +1 -1
- package/lib/heatmap/helpers/color.js +1 -2
- package/lib/heatmap/helpers/text.d.ts +1 -1
- package/lib/heatmap/helpers/text.js +0 -1
- package/lib/heatmap/helpers/track.js +2 -3
- package/lib/heatmap/helpers/types.js +0 -1
- package/lib/heatmap/index.d.ts +32 -13
- package/lib/heatmap/index.js +61 -35
- package/lib/icon/custom-elements.json +6 -4
- package/lib/icon/custom-elements.md +8 -0
- package/lib/icon/index.d.ts +17 -7
- package/lib/icon/index.js +36 -18
- package/lib/icon/utils/IconLoader.d.ts +6 -1
- package/lib/icon/utils/IconLoader.js +24 -18
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -1
- package/lib/interactive-chart/custom-elements.json +5 -11
- package/lib/interactive-chart/custom-elements.md +31 -0
- package/lib/interactive-chart/helpers/merge.d.ts +15 -0
- package/lib/interactive-chart/helpers/merge.js +28 -0
- package/lib/interactive-chart/helpers/types.d.ts +10 -9
- package/lib/interactive-chart/helpers/types.js +6 -2
- package/lib/interactive-chart/index.d.ts +37 -18
- package/lib/interactive-chart/index.js +61 -51
- package/lib/item/custom-elements.json +4 -4
- package/lib/item/custom-elements.md +29 -0
- package/lib/item/helpers/types.d.ts +1 -1
- package/lib/item/helpers/types.js +0 -1
- package/lib/item/index.d.ts +26 -9
- package/lib/item/index.js +43 -16
- package/lib/label/custom-elements.json +7 -16
- package/lib/label/custom-elements.md +11 -0
- package/lib/label/index.d.ts +41 -73
- package/lib/label/index.js +150 -187
- package/lib/layout/custom-elements.md +26 -0
- package/lib/layout/index.d.ts +11 -4
- package/lib/layout/index.js +13 -9
- package/lib/led-gauge/custom-elements.json +4 -4
- package/lib/led-gauge/custom-elements.md +17 -0
- package/lib/led-gauge/index.d.ts +13 -5
- package/lib/led-gauge/index.js +16 -11
- package/lib/list/custom-elements.json +37 -5
- package/lib/list/custom-elements.md +33 -0
- package/lib/list/extensible-function.js +2 -1
- package/lib/list/helpers/list-renderer.d.ts +2 -2
- package/lib/list/helpers/list-renderer.js +4 -3
- package/lib/list/helpers/types.d.ts +2 -2
- package/lib/list/helpers/types.js +0 -1
- package/lib/list/index.d.ts +47 -12
- package/lib/list/index.js +100 -39
- package/lib/list/renderer.d.ts +2 -2
- package/lib/list/renderer.js +1 -2
- package/lib/loader/custom-elements.md +5 -0
- package/lib/loader/index.d.ts +8 -1
- package/lib/loader/index.js +11 -8
- package/lib/multi-input/custom-elements.json +7 -6
- package/lib/multi-input/custom-elements.md +43 -0
- package/lib/multi-input/helpers/types.d.ts +1 -1
- package/lib/multi-input/helpers/types.js +0 -1
- package/lib/multi-input/index.d.ts +19 -8
- package/lib/multi-input/index.js +28 -18
- package/lib/multi-input/themes/solar/charcoal/index.js +1 -1
- package/lib/multi-input/themes/solar/pearl/index.js +1 -1
- package/lib/notification/custom-elements.md +26 -0
- package/lib/notification/elements/notification-tray.d.ts +10 -4
- package/lib/notification/elements/notification-tray.js +15 -11
- package/lib/notification/elements/notification.d.ts +19 -7
- package/lib/notification/elements/notification.js +25 -13
- package/lib/notification/helpers/status.d.ts +1 -1
- package/lib/notification/helpers/status.js +1 -2
- package/lib/notification/helpers/types.d.ts +1 -1
- package/lib/notification/helpers/types.js +0 -1
- package/lib/notification/index.d.ts +2 -2
- package/lib/notification/index.js +2 -3
- package/lib/number-field/custom-elements.json +99 -54
- package/lib/number-field/custom-elements.md +42 -0
- package/lib/number-field/index.d.ts +104 -52
- package/lib/number-field/index.js +129 -88
- package/lib/number-field/themes/halo/dark/index.js +1 -1
- package/lib/number-field/themes/halo/light/index.js +1 -1
- package/lib/number-field/themes/solar/charcoal/index.js +1 -1
- package/lib/number-field/themes/solar/pearl/index.js +1 -1
- package/lib/overlay/custom-elements.json +26 -13
- package/lib/overlay/custom-elements.md +54 -0
- package/lib/overlay/elements/overlay-backdrop.d.ts +12 -5
- package/lib/overlay/elements/overlay-backdrop.js +13 -9
- package/lib/overlay/elements/overlay-viewport.d.ts +11 -4
- package/lib/overlay/elements/overlay-viewport.js +12 -9
- package/lib/overlay/elements/overlay.d.ts +18 -6
- package/lib/overlay/elements/overlay.js +35 -28
- package/lib/overlay/helpers/functions.js +0 -1
- package/lib/overlay/helpers/types.js +0 -1
- package/lib/overlay/index.d.ts +2 -2
- package/lib/overlay/index.js +1 -2
- package/lib/overlay/managers/backdrop-manager.d.ts +2 -2
- package/lib/overlay/managers/backdrop-manager.js +2 -3
- package/lib/overlay/managers/close-manager.d.ts +1 -1
- package/lib/overlay/managers/close-manager.js +1 -2
- package/lib/overlay/managers/focus-manager.d.ts +1 -1
- package/lib/overlay/managers/focus-manager.js +3 -5
- package/lib/overlay/managers/interaction-lock-manager.js +2 -3
- package/lib/overlay/managers/viewport-manager.d.ts +3 -3
- package/lib/overlay/managers/viewport-manager.js +6 -3
- package/lib/overlay/managers/zindex-manager.d.ts +1 -1
- package/lib/overlay/managers/zindex-manager.js +1 -4
- package/lib/overlay-menu/custom-elements.json +126 -12
- package/lib/overlay-menu/custom-elements.md +44 -0
- package/lib/overlay-menu/helpers/types.d.ts +3 -3
- package/lib/overlay-menu/helpers/types.js +0 -1
- package/lib/overlay-menu/index.d.ts +44 -12
- package/lib/overlay-menu/index.js +66 -35
- package/lib/overlay-menu/managers/menu-manager.d.ts +2 -2
- package/lib/overlay-menu/managers/menu-manager.js +8 -8
- package/lib/pagination/custom-elements.json +16 -33
- package/lib/pagination/custom-elements.md +26 -0
- package/lib/pagination/index.d.ts +156 -81
- package/lib/pagination/index.js +373 -214
- package/lib/pagination/themes/halo/dark/index.js +1 -1
- package/lib/pagination/themes/halo/light/index.js +1 -1
- package/lib/pagination/themes/solar/charcoal/index.js +1 -1
- package/lib/pagination/themes/solar/pearl/index.js +1 -1
- package/lib/panel/custom-elements.md +11 -0
- package/lib/panel/index.d.ts +11 -4
- package/lib/panel/index.js +13 -9
- package/lib/password-field/custom-elements.json +62 -67
- package/lib/password-field/custom-elements.md +39 -0
- package/lib/password-field/index.d.ts +46 -90
- package/lib/password-field/index.js +52 -190
- package/lib/password-field/themes/halo/dark/index.js +1 -1
- package/lib/password-field/themes/halo/light/index.js +1 -1
- package/lib/password-field/themes/solar/charcoal/index.js +1 -1
- package/lib/password-field/themes/solar/pearl/index.js +1 -1
- package/lib/pill/custom-elements.json +9 -7
- package/lib/pill/custom-elements.md +22 -0
- package/lib/pill/index.d.ts +15 -7
- package/lib/pill/index.js +21 -27
- package/lib/pill/themes/halo/dark/index.js +1 -1
- package/lib/pill/themes/halo/light/index.js +1 -1
- package/lib/progress-bar/custom-elements.md +18 -0
- package/lib/progress-bar/index.d.ts +11 -15
- package/lib/progress-bar/index.js +14 -25
- package/lib/radio-button/custom-elements.json +4 -4
- package/lib/radio-button/custom-elements.md +19 -0
- package/lib/radio-button/index.d.ts +33 -9
- package/lib/radio-button/index.js +97 -24
- package/lib/radio-button/radio-button-registry.d.ts +3 -2
- package/lib/radio-button/radio-button-registry.js +57 -5
- package/lib/radio-button/themes/halo/dark/index.js +1 -1
- package/lib/radio-button/themes/halo/light/index.js +1 -1
- package/lib/rating/custom-elements.md +17 -0
- package/lib/rating/index.d.ts +11 -4
- package/lib/rating/index.js +16 -10
- package/lib/search-field/custom-elements.json +70 -74
- package/lib/search-field/custom-elements.md +41 -0
- package/lib/search-field/index.d.ts +47 -97
- package/lib/search-field/index.js +50 -212
- package/lib/search-field/themes/halo/dark/index.js +1 -1
- package/lib/search-field/themes/halo/light/index.js +1 -1
- package/lib/search-field/themes/solar/charcoal/index.js +1 -1
- package/lib/search-field/themes/solar/pearl/index.js +1 -1
- package/lib/select/custom-elements.json +5 -4
- package/lib/select/custom-elements.md +24 -0
- package/lib/select/helpers/types.d.ts +1 -1
- package/lib/select/helpers/types.js +0 -1
- package/lib/select/index.d.ts +26 -11
- package/lib/select/index.js +93 -52
- package/lib/select/themes/halo/dark/index.js +1 -1
- package/lib/select/themes/halo/light/index.js +1 -1
- package/lib/sidebar-layout/custom-elements.json +2 -6
- package/lib/sidebar-layout/custom-elements.md +21 -0
- package/lib/sidebar-layout/index.d.ts +15 -7
- package/lib/sidebar-layout/index.js +16 -10
- package/lib/slider/custom-elements.json +4 -4
- package/lib/slider/custom-elements.md +28 -0
- package/lib/slider/index.d.ts +18 -5
- package/lib/slider/index.js +69 -16
- package/lib/sparkline/custom-elements.json +4 -4
- package/lib/sparkline/custom-elements.md +16 -0
- package/lib/sparkline/index.d.ts +14 -5
- package/lib/sparkline/index.js +17 -10
- package/lib/swing-gauge/const.d.ts +22 -0
- package/lib/swing-gauge/const.js +26 -0
- package/lib/swing-gauge/custom-elements.json +51 -22
- package/lib/swing-gauge/custom-elements.md +17 -0
- package/lib/swing-gauge/helpers.d.ts +8 -0
- package/lib/swing-gauge/helpers.js +105 -0
- package/lib/swing-gauge/index.d.ts +220 -72
- package/lib/swing-gauge/index.js +648 -168
- package/lib/swing-gauge/themes/halo/dark/index.js +1 -1
- package/lib/swing-gauge/themes/halo/light/index.js +1 -1
- package/lib/swing-gauge/themes/solar/charcoal/index.js +1 -1
- package/lib/swing-gauge/themes/solar/pearl/index.js +1 -1
- package/lib/swing-gauge/types.d.ts +34 -0
- package/lib/swing-gauge/types.js +1 -0
- package/lib/tab/custom-elements.json +10 -21
- package/lib/tab/custom-elements.md +22 -0
- package/lib/tab/index.d.ts +19 -14
- package/lib/tab/index.js +31 -40
- package/lib/tab/themes/halo/dark/index.js +1 -1
- package/lib/tab/themes/halo/light/index.js +1 -1
- package/lib/tab/themes/solar/charcoal/index.js +1 -1
- package/lib/tab/themes/solar/pearl/index.js +1 -1
- package/lib/tab-bar/custom-elements.json +0 -6
- package/lib/tab-bar/custom-elements.md +11 -0
- package/lib/tab-bar/helpers/animate.d.ts +1 -1
- package/lib/tab-bar/helpers/animate.js +5 -2
- package/lib/tab-bar/index.d.ts +12 -5
- package/lib/tab-bar/index.js +18 -21
- package/lib/tab-bar/themes/solar/charcoal/index.js +1 -1
- package/lib/tab-bar/themes/solar/pearl/index.js +1 -1
- package/lib/text-field/custom-elements.json +78 -89
- package/lib/text-field/custom-elements.md +35 -0
- package/lib/text-field/index.d.ts +67 -80
- package/lib/text-field/index.js +106 -157
- package/lib/text-field/themes/halo/dark/index.js +1 -1
- package/lib/text-field/themes/halo/light/index.js +1 -1
- package/lib/text-field/themes/solar/charcoal/index.js +1 -1
- package/lib/text-field/themes/solar/pearl/index.js +1 -1
- package/lib/time-picker/custom-elements.json +6 -8
- package/lib/time-picker/custom-elements.md +28 -0
- package/lib/time-picker/index.d.ts +105 -65
- package/lib/time-picker/index.js +297 -169
- package/lib/time-picker/themes/solar/charcoal/index.js +1 -1
- package/lib/time-picker/themes/solar/pearl/index.js +1 -1
- package/lib/toggle/custom-elements.json +4 -4
- package/lib/toggle/custom-elements.md +19 -0
- package/lib/toggle/index.d.ts +22 -5
- package/lib/toggle/index.js +58 -13
- package/lib/toggle/themes/halo/dark/index.js +1 -1
- package/lib/toggle/themes/halo/light/index.js +1 -1
- package/lib/toggle/themes/solar/charcoal/index.js +1 -1
- package/lib/toggle/themes/solar/pearl/index.js +1 -1
- package/lib/tooltip/custom-elements.md +14 -0
- package/lib/tooltip/elements/title-tooltip.js +2 -3
- package/lib/tooltip/elements/tooltip-element.d.ts +2 -3
- package/lib/tooltip/elements/tooltip-element.js +0 -2
- package/lib/tooltip/helpers/overflow-tooltip.d.ts +1 -1
- package/lib/tooltip/helpers/overflow-tooltip.js +1 -2
- package/lib/tooltip/helpers/renderer.d.ts +1 -1
- package/lib/tooltip/helpers/renderer.js +0 -1
- package/lib/tooltip/helpers/types.d.ts +1 -1
- package/lib/tooltip/helpers/types.js +0 -1
- package/lib/tooltip/index.d.ts +18 -11
- package/lib/tooltip/index.js +27 -23
- package/lib/tooltip/managers/tooltip-manager.d.ts +2 -2
- package/lib/tooltip/managers/tooltip-manager.js +17 -11
- package/lib/tornado-chart/custom-elements.md +18 -0
- package/lib/tornado-chart/elements/tornado-chart.d.ts +12 -5
- package/lib/tornado-chart/elements/tornado-chart.js +15 -11
- package/lib/tornado-chart/elements/tornado-item.d.ts +13 -6
- package/lib/tornado-chart/elements/tornado-item.js +17 -12
- package/lib/tornado-chart/index.d.ts +2 -2
- package/lib/tornado-chart/index.js +2 -3
- package/lib/tree/custom-elements.json +30 -2
- package/lib/tree/custom-elements.md +32 -0
- package/lib/tree/elements/tree-item.d.ts +53 -5
- package/lib/tree/elements/tree-item.js +114 -34
- package/lib/tree/elements/tree.d.ts +65 -20
- package/lib/tree/elements/tree.js +151 -34
- package/lib/tree/helpers/filter.d.ts +8 -0
- package/lib/tree/helpers/filter.js +33 -0
- package/lib/tree/helpers/renderer.d.ts +2 -2
- package/lib/tree/helpers/renderer.js +4 -4
- package/lib/tree/helpers/types.d.ts +13 -1
- package/lib/tree/helpers/types.js +0 -1
- package/lib/tree/index.d.ts +4 -4
- package/lib/tree/index.js +3 -4
- package/lib/tree/managers/tree-manager.d.ts +22 -10
- package/lib/tree/managers/tree-manager.js +56 -41
- package/lib/tree/themes/halo/dark/index.js +1 -1
- package/lib/tree/themes/halo/light/index.js +1 -1
- package/lib/tree/themes/solar/charcoal/index.js +1 -1
- package/lib/tree/themes/solar/pearl/index.js +1 -1
- package/lib/tree-select/custom-elements.json +14 -5
- package/lib/tree-select/custom-elements.md +26 -0
- package/lib/tree-select/helpers/types.d.ts +2 -2
- package/lib/tree-select/helpers/types.js +0 -1
- package/lib/tree-select/index.d.ts +55 -27
- package/lib/tree-select/index.js +107 -45
- package/lib/tree-select/themes/halo/dark/index.js +3 -2
- package/lib/tree-select/themes/halo/light/index.js +3 -2
- package/lib/tree-select/themes/solar/charcoal/index.js +3 -2
- package/lib/tree-select/themes/solar/pearl/index.js +3 -2
- package/lib/version.d.ts +1 -0
- package/lib/version.js +1 -0
- package/package.json +601 -25
- package/lib/accordion/index.js.map +0 -1
- package/lib/appstate-bar/index.js.map +0 -1
- package/lib/autosuggest/helpers/const.d.ts +0 -2
- package/lib/autosuggest/helpers/const.js +0 -4
- package/lib/autosuggest/helpers/const.js.map +0 -1
- package/lib/autosuggest/helpers/types.js.map +0 -1
- package/lib/autosuggest/helpers/utils.js.map +0 -1
- package/lib/autosuggest/index.js.map +0 -1
- package/lib/button/index.js.map +0 -1
- package/lib/button-bar/index.js.map +0 -1
- package/lib/calendar/index.js.map +0 -1
- package/lib/calendar/locales.js.map +0 -1
- package/lib/calendar/types.js.map +0 -1
- package/lib/calendar/utils.js.map +0 -1
- package/lib/canvas/index.js.map +0 -1
- package/lib/card/helpers/types.js.map +0 -1
- package/lib/card/index.js.map +0 -1
- package/lib/chart/helpers/legend.js.map +0 -1
- package/lib/chart/helpers/types.js.map +0 -1
- package/lib/chart/index.js.map +0 -1
- package/lib/chart/plugins/doughnut-center-label.js.map +0 -1
- package/lib/checkbox/index.js.map +0 -1
- package/lib/clock/index.js.map +0 -1
- package/lib/clock/utils/TickManager.js.map +0 -1
- package/lib/clock/utils/timestamps.js.map +0 -1
- package/lib/collapse/index.js.map +0 -1
- package/lib/color-dialog/elements/color-palettes.js.map +0 -1
- package/lib/color-dialog/elements/grayscale-palettes.js.map +0 -1
- package/lib/color-dialog/elements/palettes.js.map +0 -1
- package/lib/color-dialog/helpers/color-helpers.js.map +0 -1
- package/lib/color-dialog/helpers/value-model.js.map +0 -1
- package/lib/color-dialog/index.js.map +0 -1
- package/lib/combo-box/helpers/filter.js.map +0 -1
- package/lib/combo-box/helpers/keyboard-event.js.map +0 -1
- package/lib/combo-box/helpers/types.js.map +0 -1
- package/lib/combo-box/index.js.map +0 -1
- package/lib/datetime-picker/index.js.map +0 -1
- package/lib/datetime-picker/locales.js.map +0 -1
- package/lib/datetime-picker/types.js.map +0 -1
- package/lib/datetime-picker/utils.js.map +0 -1
- package/lib/dialog/draggable-element.js.map +0 -1
- package/lib/dialog/index.js.map +0 -1
- package/lib/email-field/index.js.map +0 -1
- package/lib/flag/index.js.map +0 -1
- package/lib/flag/utils/FlagLoader.js.map +0 -1
- package/lib/header/index.js.map +0 -1
- package/lib/heatmap/helpers/color.js.map +0 -1
- package/lib/heatmap/helpers/text.js.map +0 -1
- package/lib/heatmap/helpers/track.js.map +0 -1
- package/lib/heatmap/helpers/types.js.map +0 -1
- package/lib/heatmap/index.js.map +0 -1
- package/lib/icon/index.js.map +0 -1
- package/lib/icon/utils/IconLoader.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/interactive-chart/helpers/types.js.map +0 -1
- package/lib/interactive-chart/index.js.map +0 -1
- package/lib/item/helpers/types.js.map +0 -1
- package/lib/item/index.js.map +0 -1
- package/lib/label/helpers/text.d.ts +0 -35
- package/lib/label/helpers/text.js +0 -57
- package/lib/label/helpers/text.js.map +0 -1
- package/lib/label/index.js.map +0 -1
- package/lib/layout/index.js.map +0 -1
- package/lib/led-gauge/index.js.map +0 -1
- package/lib/list/extensible-function.js.map +0 -1
- package/lib/list/helpers/list-renderer.js.map +0 -1
- package/lib/list/helpers/types.js.map +0 -1
- package/lib/list/index.js.map +0 -1
- package/lib/list/renderer.js.map +0 -1
- package/lib/loader/index.js.map +0 -1
- package/lib/multi-input/helpers/types.js.map +0 -1
- package/lib/multi-input/index.js.map +0 -1
- package/lib/notification/elements/notification-tray.js.map +0 -1
- package/lib/notification/elements/notification.js.map +0 -1
- package/lib/notification/helpers/status.js.map +0 -1
- package/lib/notification/helpers/types.js.map +0 -1
- package/lib/notification/index.js.map +0 -1
- package/lib/number-field/index.js.map +0 -1
- package/lib/overlay/elements/overlay-backdrop.js.map +0 -1
- package/lib/overlay/elements/overlay-viewport.js.map +0 -1
- package/lib/overlay/elements/overlay.js.map +0 -1
- package/lib/overlay/helpers/functions.js.map +0 -1
- package/lib/overlay/helpers/types.js.map +0 -1
- package/lib/overlay/index.js.map +0 -1
- package/lib/overlay/managers/backdrop-manager.js.map +0 -1
- package/lib/overlay/managers/close-manager.js.map +0 -1
- package/lib/overlay/managers/focus-manager.js.map +0 -1
- package/lib/overlay/managers/interaction-lock-manager.js.map +0 -1
- package/lib/overlay/managers/viewport-manager.js.map +0 -1
- package/lib/overlay/managers/zindex-manager.js.map +0 -1
- package/lib/overlay-menu/helpers/types.js.map +0 -1
- package/lib/overlay-menu/helpers/uuid.d.ts +0 -7
- package/lib/overlay-menu/helpers/uuid.js +0 -14
- package/lib/overlay-menu/helpers/uuid.js.map +0 -1
- package/lib/overlay-menu/index.js.map +0 -1
- package/lib/overlay-menu/managers/menu-manager.js.map +0 -1
- package/lib/pagination/helpers/types.d.ts +0 -9
- package/lib/pagination/helpers/types.js +0 -2
- package/lib/pagination/helpers/types.js.map +0 -1
- package/lib/pagination/index.js.map +0 -1
- package/lib/panel/index.js.map +0 -1
- package/lib/password-field/index.js.map +0 -1
- package/lib/pill/index.js.map +0 -1
- package/lib/progress-bar/index.js.map +0 -1
- package/lib/radio-button/index.js.map +0 -1
- package/lib/radio-button/radio-button-registry.js.map +0 -1
- package/lib/rating/index.js.map +0 -1
- package/lib/search-field/index.js.map +0 -1
- package/lib/select/helpers/types.js.map +0 -1
- package/lib/select/index.js.map +0 -1
- package/lib/sidebar-layout/index.js.map +0 -1
- package/lib/slider/index.js.map +0 -1
- package/lib/sparkline/index.js.map +0 -1
- package/lib/swing-gauge/helpers/canvas.d.ts +0 -8
- package/lib/swing-gauge/helpers/canvas.js +0 -115
- package/lib/swing-gauge/helpers/canvas.js.map +0 -1
- package/lib/swing-gauge/helpers/types.d.ts +0 -33
- package/lib/swing-gauge/helpers/types.js +0 -2
- package/lib/swing-gauge/helpers/types.js.map +0 -1
- package/lib/swing-gauge/index.js.map +0 -1
- package/lib/tab/index.js.map +0 -1
- package/lib/tab-bar/helpers/animate.js.map +0 -1
- package/lib/tab-bar/index.js.map +0 -1
- package/lib/text-field/index.js.map +0 -1
- package/lib/time-picker/index.js.map +0 -1
- package/lib/toggle/index.js.map +0 -1
- package/lib/tooltip/elements/title-tooltip.js.map +0 -1
- package/lib/tooltip/elements/tooltip-element.js.map +0 -1
- package/lib/tooltip/helpers/overflow-tooltip.js.map +0 -1
- package/lib/tooltip/helpers/renderer.js.map +0 -1
- package/lib/tooltip/helpers/types.js.map +0 -1
- package/lib/tooltip/index.js.map +0 -1
- package/lib/tooltip/managers/tooltip-manager.js.map +0 -1
- package/lib/tornado-chart/elements/tornado-chart.js.map +0 -1
- package/lib/tornado-chart/elements/tornado-item.js.map +0 -1
- package/lib/tornado-chart/index.js.map +0 -1
- package/lib/tree/elements/tree-item.js.map +0 -1
- package/lib/tree/elements/tree.js.map +0 -1
- package/lib/tree/helpers/renderer.js.map +0 -1
- package/lib/tree/helpers/types.js.map +0 -1
- package/lib/tree/index.js.map +0 -1
- package/lib/tree/managers/tree-manager.js.map +0 -1
- package/lib/tree-select/helpers/types.js.map +0 -1
- package/lib/tree-select/index.js.map +0 -1
package/lib/calendar/index.js
CHANGED
|
@@ -1,35 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
import {
|
|
8
|
-
import '
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import '
|
|
12
|
-
import {
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { ControlElement, html, css, WarningNotice } from '@refinitiv-ui/core';
|
|
3
|
+
import { customElement } from '@refinitiv-ui/core/lib/decorators/custom-element.js';
|
|
4
|
+
import { property } from '@refinitiv-ui/core/lib/decorators/property.js';
|
|
5
|
+
import { state } from '@refinitiv-ui/core/lib/decorators/state.js';
|
|
6
|
+
import { ifDefined } from '@refinitiv-ui/core/lib/directives/if-defined.js';
|
|
7
|
+
import { cache } from '@refinitiv-ui/core/lib/directives/cache.js';
|
|
8
|
+
import { guard } from '@refinitiv-ui/core/lib/directives/guard.js';
|
|
9
|
+
import { ref, createRef } from '@refinitiv-ui/core/lib/directives/ref.js';
|
|
10
|
+
import { VERSION } from '../version.js';
|
|
11
|
+
import { isIE } from '@refinitiv-ui/utils/lib/browser.js';
|
|
12
|
+
import { DateFormat, format, utcFormat, utcParse, isValidDate, isWeekend, isAfter, isBefore, addMonths, subMonths, isToday, isThisMonth, isThisYear, isSameDay, isSameMonth, isSameYear, toDateSegment, parse } from '@refinitiv-ui/utils/lib/date.js';
|
|
13
|
+
import { left, right, up, down, first, last } from '@refinitiv-ui/utils/lib/navigation.js';
|
|
14
|
+
import { monthInfo, weekdaysNames, monthsNames, formatLocaleDate, ViewFormatTranslateParams } from './utils.js';
|
|
13
15
|
import { translate, getLocale, TranslatePropertyKey } from '@refinitiv-ui/translate';
|
|
14
|
-
import { RenderView } from './
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const DAY_VIEW = {
|
|
19
|
-
rowCount: 6,
|
|
20
|
-
columnCount: 7,
|
|
21
|
-
totalCount: 6 * 7
|
|
22
|
-
};
|
|
23
|
-
const YEAR_VIEW = {
|
|
24
|
-
rowCount: 4,
|
|
25
|
-
columnCount: 4,
|
|
26
|
-
totalCount: 4 * 4
|
|
27
|
-
};
|
|
28
|
-
const MONTH_VIEW = {
|
|
29
|
-
rowCount: 4,
|
|
30
|
-
columnCount: 4,
|
|
31
|
-
totalCount: 4 * 4
|
|
32
|
-
};
|
|
16
|
+
import { RenderView, CalendarLocaleScope, FIRST_DAY_OF_WEEK, YEARS_PER_YEAR_VIEW, DAY_VIEW, YEAR_VIEW, MONTH_VIEW } from './constants.js';
|
|
17
|
+
import './locales.js';
|
|
18
|
+
import '../button/index.js';
|
|
19
|
+
import '@refinitiv-ui/phrasebook/lib/locale/en/calendar.js';
|
|
33
20
|
/**
|
|
34
21
|
* Standard calendar element
|
|
35
22
|
*
|
|
@@ -47,6 +34,11 @@ const MONTH_VIEW = {
|
|
|
47
34
|
let Calendar = class Calendar extends ControlElement {
|
|
48
35
|
constructor() {
|
|
49
36
|
super(...arguments);
|
|
37
|
+
this.defaultRole = 'group';
|
|
38
|
+
/**
|
|
39
|
+
* Reference to the view button
|
|
40
|
+
*/
|
|
41
|
+
this.viewBtnRef = createRef();
|
|
50
42
|
this._min = '';
|
|
51
43
|
this._max = '';
|
|
52
44
|
/**
|
|
@@ -81,11 +73,30 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
81
73
|
/**
|
|
82
74
|
* Used for internal navigation between render views
|
|
83
75
|
*/
|
|
84
|
-
this.
|
|
85
|
-
|
|
76
|
+
this._renderView = RenderView.DAY;
|
|
77
|
+
/**
|
|
78
|
+
* Used for keyboard navigation when trying
|
|
79
|
+
* to restore focus on re-render and control navigation
|
|
80
|
+
*/
|
|
81
|
+
this._activeCellIndex = null;
|
|
82
|
+
// Used to store current navigation map
|
|
83
|
+
this.navigationGrid = [];
|
|
84
|
+
/**
|
|
85
|
+
* Connected to role. If false, the values are not announced in the screen reader
|
|
86
|
+
*/
|
|
87
|
+
this.announceValues = true;
|
|
88
|
+
// Cashed filter, which is constructed based on multiple local filters
|
|
89
|
+
this.isDateAvailable = null;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Element version number
|
|
93
|
+
* @returns version number
|
|
94
|
+
*/
|
|
95
|
+
static get version() {
|
|
96
|
+
return VERSION;
|
|
86
97
|
}
|
|
87
98
|
/**
|
|
88
|
-
* A `
|
|
99
|
+
* A `CSSResultGroup` that will be used
|
|
89
100
|
* to style the host, slotted children
|
|
90
101
|
* and the internal template of the element.
|
|
91
102
|
* @return CSS template
|
|
@@ -95,14 +106,14 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
95
106
|
:host {
|
|
96
107
|
display: inline-block;
|
|
97
108
|
}
|
|
98
|
-
[part
|
|
109
|
+
[part~=navigation], [part~=navigation] section {
|
|
99
110
|
display: flex;
|
|
100
111
|
flex-flow: row nowrap;
|
|
101
112
|
}
|
|
102
|
-
[part
|
|
113
|
+
[part~=navigation] {
|
|
103
114
|
justify-content: space-between;
|
|
104
115
|
}
|
|
105
|
-
[part
|
|
116
|
+
[part~=navigation] > div {
|
|
106
117
|
display: flex;
|
|
107
118
|
flex: 1;
|
|
108
119
|
justify-content: center;
|
|
@@ -113,7 +124,6 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
113
124
|
bottom: 0;
|
|
114
125
|
left: 0;
|
|
115
126
|
right: 0;
|
|
116
|
-
pointer-events: none;
|
|
117
127
|
display: flex;
|
|
118
128
|
align-items: center;
|
|
119
129
|
justify-content: center;
|
|
@@ -143,7 +153,10 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
143
153
|
width: calc(100% / ${DAY_VIEW.columnCount});
|
|
144
154
|
padding-top: calc(100% / ${DAY_VIEW.columnCount});
|
|
145
155
|
}
|
|
146
|
-
[part~=cell][tabindex] {
|
|
156
|
+
[part~=cell-content]:not([tabindex]) {
|
|
157
|
+
pointer-events: none;
|
|
158
|
+
}
|
|
159
|
+
[part~=selection] {
|
|
147
160
|
cursor: pointer;
|
|
148
161
|
}
|
|
149
162
|
`;
|
|
@@ -161,7 +174,7 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
161
174
|
}
|
|
162
175
|
if (oldMin !== min) {
|
|
163
176
|
this._min = min;
|
|
164
|
-
|
|
177
|
+
this.requestUpdate('min', oldMin);
|
|
165
178
|
}
|
|
166
179
|
}
|
|
167
180
|
get min() {
|
|
@@ -180,7 +193,7 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
180
193
|
}
|
|
181
194
|
if (oldMax !== max) {
|
|
182
195
|
this._max = max;
|
|
183
|
-
|
|
196
|
+
this.requestUpdate('max', oldMax);
|
|
184
197
|
}
|
|
185
198
|
}
|
|
186
199
|
get max() {
|
|
@@ -199,7 +212,8 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
199
212
|
const oldView = this._view;
|
|
200
213
|
if (oldView !== view) {
|
|
201
214
|
this._view = view;
|
|
202
|
-
|
|
215
|
+
this.resetActiveCellIndex();
|
|
216
|
+
this.requestUpdate('view', oldView);
|
|
203
217
|
}
|
|
204
218
|
}
|
|
205
219
|
get view() {
|
|
@@ -211,13 +225,14 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
211
225
|
* 0 - for Sunday, 6 - for Saturday
|
|
212
226
|
* @param firstDayOfWeek The first day of the week
|
|
213
227
|
* @type {number | null}
|
|
228
|
+
* @default null
|
|
214
229
|
*/
|
|
215
230
|
set firstDayOfWeek(firstDayOfWeek) {
|
|
216
231
|
firstDayOfWeek %= 7;
|
|
217
|
-
const oldFirstDayOfWeek = this.
|
|
232
|
+
const oldFirstDayOfWeek = this._firstDayOfWeek;
|
|
218
233
|
if (oldFirstDayOfWeek !== firstDayOfWeek) {
|
|
219
234
|
this._firstDayOfWeek = firstDayOfWeek;
|
|
220
|
-
|
|
235
|
+
this.requestUpdate('firstDayOfWeek', oldFirstDayOfWeek);
|
|
221
236
|
}
|
|
222
237
|
}
|
|
223
238
|
get firstDayOfWeek() {
|
|
@@ -238,39 +253,95 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
238
253
|
* Set multiple selected values
|
|
239
254
|
* @param values Values to set
|
|
240
255
|
* @type {string[]}
|
|
256
|
+
* @default []
|
|
241
257
|
*/
|
|
242
258
|
set values(values) {
|
|
243
259
|
const oldValues = this._values;
|
|
244
260
|
const newValues = this.filterAndWarnInvalidValues(values);
|
|
245
261
|
if (oldValues.toString() !== newValues.toString()) {
|
|
246
262
|
this._values = newValues;
|
|
247
|
-
|
|
263
|
+
this.requestUpdate('values', oldValues);
|
|
248
264
|
}
|
|
249
265
|
}
|
|
250
266
|
get values() {
|
|
251
267
|
return this._values.concat();
|
|
252
268
|
}
|
|
269
|
+
get renderView() {
|
|
270
|
+
return this._renderView;
|
|
271
|
+
}
|
|
272
|
+
set renderView(renderView) {
|
|
273
|
+
const oldRenderView = this._renderView;
|
|
274
|
+
if (oldRenderView !== renderView) {
|
|
275
|
+
this._renderView = renderView;
|
|
276
|
+
// always reset active cell to not focus on potentially invalid cell
|
|
277
|
+
this.resetActiveCellIndex();
|
|
278
|
+
this.requestUpdate('renderView', oldRenderView);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
get activeCellIndex() {
|
|
282
|
+
return this._activeCellIndex;
|
|
283
|
+
}
|
|
284
|
+
set activeCellIndex(activeCellIndex) {
|
|
285
|
+
const oldCellIndex = this._activeCellIndex;
|
|
286
|
+
if (String(activeCellIndex) !== String(oldCellIndex)) {
|
|
287
|
+
this._activeCellIndex = activeCellIndex;
|
|
288
|
+
this.requestUpdate('activeCellIndex', oldCellIndex);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
253
291
|
/**
|
|
254
|
-
*
|
|
255
|
-
*
|
|
292
|
+
* Silently reset cell index without calling request update
|
|
293
|
+
* @returns {void}
|
|
256
294
|
*/
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
295
|
+
resetActiveCellIndex() {
|
|
296
|
+
this._activeCellIndex = null;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Get an active element
|
|
300
|
+
*/
|
|
301
|
+
get activeElement() {
|
|
302
|
+
return this.shadowRoot.activeElement;
|
|
261
303
|
}
|
|
262
304
|
/**
|
|
263
|
-
* Get
|
|
305
|
+
* Get selectable date button element by index
|
|
306
|
+
* @param index Cell index
|
|
307
|
+
* @returns button HTML date button element or null
|
|
264
308
|
*/
|
|
265
|
-
|
|
266
|
-
|
|
309
|
+
getDateButtonByIndex(index) {
|
|
310
|
+
const elements = Array.from(this.renderRoot.querySelectorAll('[part~=cell] > [part~=selection]'));
|
|
311
|
+
return elements.find((element) => this.isDateButton(element) && String(element.index) === String(index));
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Get active date button element
|
|
315
|
+
* @returns button HTML date button element or null
|
|
316
|
+
*/
|
|
317
|
+
get activeDateButton() {
|
|
318
|
+
return this.renderRoot.querySelector('[part~=cell][active] > [part~=selection]');
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Return true if passed target is HTML
|
|
322
|
+
* date button element that can be selected
|
|
323
|
+
* @param target Target to check
|
|
324
|
+
* @returns isDateButtonElement
|
|
325
|
+
*/
|
|
326
|
+
isDateButton(target) {
|
|
327
|
+
return target.index !== undefined;
|
|
328
|
+
}
|
|
329
|
+
static get observedAttributes() {
|
|
330
|
+
const observed = super.observedAttributes;
|
|
331
|
+
return ['role'].concat(observed);
|
|
332
|
+
}
|
|
333
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
334
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
335
|
+
if (name === 'role') {
|
|
336
|
+
this.announceValues = !(!newValue || newValue === 'none' || newValue === 'presentation');
|
|
337
|
+
}
|
|
267
338
|
}
|
|
268
339
|
/**
|
|
269
340
|
* Perform asynchronous update
|
|
270
341
|
* @returns promise
|
|
271
342
|
*/
|
|
272
343
|
async performUpdate() {
|
|
273
|
-
const localFirstDayOfWeek = Number(await this.
|
|
344
|
+
const localFirstDayOfWeek = Number(await this.dateTPromise('FIRST_DAY_OF_WEEK'));
|
|
274
345
|
this.localFirstDayOfWeek = isNaN(localFirstDayOfWeek) ? FIRST_DAY_OF_WEEK : (localFirstDayOfWeek % 7);
|
|
275
346
|
void super.performUpdate();
|
|
276
347
|
}
|
|
@@ -281,14 +352,39 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
281
352
|
*/
|
|
282
353
|
update(changedProperties) {
|
|
283
354
|
if (!this.localMonthsNames || changedProperties.has(TranslatePropertyKey)) {
|
|
284
|
-
|
|
355
|
+
const locale = getLocale(this);
|
|
356
|
+
this.localMonthsNames = monthsNames(locale);
|
|
285
357
|
}
|
|
286
358
|
if (!this.localWeekdaysNames || changedProperties.has(TranslatePropertyKey)) {
|
|
287
|
-
|
|
359
|
+
const locale = getLocale(this);
|
|
360
|
+
const longWeekdaysNames = weekdaysNames(locale, 'long');
|
|
361
|
+
this.localWeekdaysNames = weekdaysNames(locale).map((narrow, index) => {
|
|
362
|
+
return { narrow, long: longWeekdaysNames[index] };
|
|
363
|
+
});
|
|
288
364
|
}
|
|
289
365
|
this.shouldConstructFilters(changedProperties) && this.constructFilters();
|
|
290
366
|
super.update(changedProperties);
|
|
291
367
|
}
|
|
368
|
+
/**
|
|
369
|
+
* Called after render life-cycle finished
|
|
370
|
+
* @param changedProperties Properties which have changed
|
|
371
|
+
* @return {void}
|
|
372
|
+
*/
|
|
373
|
+
updated(changedProperties) {
|
|
374
|
+
super.updated(changedProperties);
|
|
375
|
+
// This code is here to ensure that focus is not lost
|
|
376
|
+
// while navigating through the render views using keyboard
|
|
377
|
+
if (this.focused && changedProperties.has('renderView') && this.viewBtnRef.value && this.activeElement !== this.viewBtnRef.value) {
|
|
378
|
+
this.viewBtnRef.value.focus();
|
|
379
|
+
}
|
|
380
|
+
const cellIndex = this.activeCellIndex;
|
|
381
|
+
if (cellIndex && changedProperties.has('activeCellIndex')) {
|
|
382
|
+
const dateButtonEl = this.getDateButtonByIndex(cellIndex);
|
|
383
|
+
if (dateButtonEl && this.activeElement !== dateButtonEl) {
|
|
384
|
+
dateButtonEl.focus();
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
292
388
|
/**
|
|
293
389
|
* Run when an element has been first updated
|
|
294
390
|
* @param changedProperties properties that was changed on first update
|
|
@@ -296,7 +392,7 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
296
392
|
*/
|
|
297
393
|
firstUpdated(changedProperties) {
|
|
298
394
|
super.firstUpdated(changedProperties);
|
|
299
|
-
this.renderRoot.addEventListener('keydown', event => this.
|
|
395
|
+
this.renderRoot.addEventListener('keydown', event => this.onKeyDown(event));
|
|
300
396
|
}
|
|
301
397
|
/**
|
|
302
398
|
* Show invalid view message
|
|
@@ -428,78 +524,88 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
428
524
|
rangeTo
|
|
429
525
|
};
|
|
430
526
|
}
|
|
527
|
+
/**
|
|
528
|
+
* Set navigation map based on rows
|
|
529
|
+
* @param rows A collection of rows with cells
|
|
530
|
+
* @returns {void}
|
|
531
|
+
*/
|
|
532
|
+
setNavigationMap(rows) {
|
|
533
|
+
this.navigationGrid = rows.map(row => row.map(cell => cell.value && !cell.disabled ? 1 : 0));
|
|
534
|
+
}
|
|
431
535
|
/**
|
|
432
536
|
* Run when next button is tapped.
|
|
433
537
|
* Change current view to next view
|
|
538
|
+
* @param event Next view tap event
|
|
434
539
|
* @returns {void}
|
|
435
540
|
*/
|
|
436
|
-
onNextTap() {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
case RenderView.DAY:
|
|
440
|
-
viewSegment = toDateSegment(addMonths(this.view, 1));
|
|
441
|
-
break;
|
|
442
|
-
case RenderView.MONTH:
|
|
443
|
-
viewSegment.year += 1;
|
|
444
|
-
break;
|
|
445
|
-
case RenderView.YEAR:
|
|
446
|
-
viewSegment.year += YEARS_PER_YEAR_VIEW;
|
|
447
|
-
break;
|
|
448
|
-
// no default
|
|
541
|
+
onNextTap(event) {
|
|
542
|
+
if (!event.defaultPrevented) {
|
|
543
|
+
this.toNextView();
|
|
449
544
|
}
|
|
450
|
-
this.notifyViewChange(viewSegment);
|
|
451
545
|
}
|
|
452
546
|
/**
|
|
453
547
|
* Run when previous button is tapped.
|
|
454
548
|
* Change current view to previous view
|
|
549
|
+
* @param event Previous view tap event
|
|
455
550
|
* @returns {void}
|
|
456
551
|
*/
|
|
457
|
-
onPreviousTap() {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
case RenderView.DAY:
|
|
461
|
-
viewSegment = toDateSegment(subMonths(this.view, 1));
|
|
462
|
-
break;
|
|
463
|
-
case RenderView.MONTH:
|
|
464
|
-
viewSegment.year -= 1;
|
|
465
|
-
break;
|
|
466
|
-
case RenderView.YEAR:
|
|
467
|
-
viewSegment.year -= YEARS_PER_YEAR_VIEW;
|
|
468
|
-
break;
|
|
469
|
-
// no default
|
|
552
|
+
onPreviousTap(event) {
|
|
553
|
+
if (!event.defaultPrevented) {
|
|
554
|
+
this.toPreviousView();
|
|
470
555
|
}
|
|
471
|
-
this.notifyViewChange(viewSegment);
|
|
472
556
|
}
|
|
473
557
|
/**
|
|
474
558
|
* Run when change view button is tapped.
|
|
475
559
|
* Switch between views
|
|
560
|
+
* @param event Render view tap event
|
|
476
561
|
* @returns {void}
|
|
477
562
|
*/
|
|
478
|
-
onRenderViewTap() {
|
|
479
|
-
|
|
563
|
+
onRenderViewTap(event) {
|
|
564
|
+
if (!event.defaultPrevented) {
|
|
565
|
+
this.renderView = this.renderView === RenderView.DAY ? RenderView.YEAR : RenderView.DAY;
|
|
566
|
+
}
|
|
480
567
|
}
|
|
481
568
|
/**
|
|
482
569
|
* Run when key down event happens on calendar
|
|
483
570
|
* @param event Keyboard event
|
|
484
571
|
* @returns {void}
|
|
485
572
|
*/
|
|
486
|
-
|
|
573
|
+
onKeyDown(event) {
|
|
574
|
+
if (event.defaultPrevented) {
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
487
577
|
switch (event.key) {
|
|
488
|
-
case ' ':
|
|
489
|
-
case 'Enter':
|
|
490
|
-
case 'Spacebar':
|
|
491
|
-
event.preventDefault();
|
|
492
|
-
this.onTableTap(event);
|
|
493
|
-
break;
|
|
494
578
|
case 'Esc':
|
|
495
579
|
case 'Escape':
|
|
496
580
|
if (this.renderView === RenderView.YEAR || this.renderView === RenderView.MONTH) {
|
|
497
|
-
event.preventDefault();
|
|
498
581
|
this.renderView = RenderView.DAY;
|
|
582
|
+
break;
|
|
499
583
|
}
|
|
584
|
+
return;
|
|
585
|
+
case 'Up': // IE11
|
|
586
|
+
case 'ArrowUp':
|
|
587
|
+
void this.onNavigation('ArrowUp');
|
|
500
588
|
break;
|
|
501
|
-
|
|
589
|
+
case 'Down':
|
|
590
|
+
case 'ArrowDown':
|
|
591
|
+
void this.onNavigation('ArrowDown');
|
|
592
|
+
break;
|
|
593
|
+
case 'Left':
|
|
594
|
+
case 'ArrowLeft':
|
|
595
|
+
void this.onNavigation('ArrowLeft');
|
|
596
|
+
break;
|
|
597
|
+
case 'Right':
|
|
598
|
+
case 'ArrowRight':
|
|
599
|
+
void this.onNavigation('ArrowRight');
|
|
600
|
+
break;
|
|
601
|
+
case 'Home':
|
|
602
|
+
case 'End':
|
|
603
|
+
void this.onNavigation(event.key);
|
|
604
|
+
break;
|
|
605
|
+
default:
|
|
606
|
+
return;
|
|
502
607
|
}
|
|
608
|
+
event.preventDefault();
|
|
503
609
|
}
|
|
504
610
|
/**
|
|
505
611
|
* Run when tap event happens ot table.
|
|
@@ -508,10 +614,14 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
508
614
|
* @returns {void}
|
|
509
615
|
*/
|
|
510
616
|
onTableTap(event) {
|
|
511
|
-
|
|
512
|
-
|
|
617
|
+
if (event.defaultPrevented) {
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
const cell = event.target;
|
|
621
|
+
if (!cell || !this.isDateButton(cell) || !cell.value) {
|
|
513
622
|
return;
|
|
514
623
|
}
|
|
624
|
+
this.activeCellIndex = cell.index;
|
|
515
625
|
const cellSegment = toDateSegment(cell.value);
|
|
516
626
|
const viewSegment = toDateSegment(this.view);
|
|
517
627
|
if (this.renderView === RenderView.YEAR) { /* YEAR -> MONTH */
|
|
@@ -531,6 +641,117 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
531
641
|
}
|
|
532
642
|
this.onTapSelectValue(cell.value);
|
|
533
643
|
}
|
|
644
|
+
/**
|
|
645
|
+
* Navigate over the grid
|
|
646
|
+
* @param key Navigation direction
|
|
647
|
+
* @returns navigation promise
|
|
648
|
+
*/
|
|
649
|
+
async onNavigation(key) {
|
|
650
|
+
const grid = this.navigationGrid;
|
|
651
|
+
switch (key) {
|
|
652
|
+
case 'Home':
|
|
653
|
+
this.activeCellIndex = first(grid);
|
|
654
|
+
return;
|
|
655
|
+
case 'End':
|
|
656
|
+
this.activeCellIndex = last(grid);
|
|
657
|
+
return;
|
|
658
|
+
// no default
|
|
659
|
+
}
|
|
660
|
+
// no previously selected cell, but there is cell which is a candidate for navigation
|
|
661
|
+
const activeDateEl = this.activeDateButton;
|
|
662
|
+
if (!this.activeCellIndex && activeDateEl) {
|
|
663
|
+
this.activeCellIndex = activeDateEl.index;
|
|
664
|
+
// current cell is already in focus (e.g. via Tab key, continue navigation from that point)
|
|
665
|
+
if (!(this.activeElement === activeDateEl)) {
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
const activeCellIndex = this.activeCellIndex;
|
|
670
|
+
// All cells are disabled
|
|
671
|
+
if (!activeCellIndex) {
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
// active cell is selected
|
|
675
|
+
if (activeCellIndex) {
|
|
676
|
+
let newActiveCell;
|
|
677
|
+
switch (key) {
|
|
678
|
+
case 'ArrowUp':
|
|
679
|
+
newActiveCell = up(grid, activeCellIndex);
|
|
680
|
+
break;
|
|
681
|
+
case 'ArrowDown':
|
|
682
|
+
newActiveCell = down(grid, activeCellIndex);
|
|
683
|
+
break;
|
|
684
|
+
case 'ArrowLeft':
|
|
685
|
+
newActiveCell = left(grid, activeCellIndex);
|
|
686
|
+
break;
|
|
687
|
+
case 'ArrowRight':
|
|
688
|
+
newActiveCell = right(grid, activeCellIndex);
|
|
689
|
+
break;
|
|
690
|
+
// no default
|
|
691
|
+
}
|
|
692
|
+
// Standard navigation withing the same view
|
|
693
|
+
if (newActiveCell) {
|
|
694
|
+
this.activeCellIndex = newActiveCell;
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
// Jump to the next view
|
|
699
|
+
switch (key) {
|
|
700
|
+
// case 'ArrowUp': // it feels better not having Up/Down in these case
|
|
701
|
+
case 'ArrowLeft':
|
|
702
|
+
this.toPreviousView();
|
|
703
|
+
await this.updateComplete; // must wait until the render cycle has finished
|
|
704
|
+
await this.onNavigation('End');
|
|
705
|
+
break;
|
|
706
|
+
// case 'ArrowDown':
|
|
707
|
+
case 'ArrowRight':
|
|
708
|
+
this.toNextView();
|
|
709
|
+
await this.updateComplete;
|
|
710
|
+
await this.onNavigation('Home');
|
|
711
|
+
break;
|
|
712
|
+
// no default
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Navigate to the next view
|
|
717
|
+
* @returns {void}
|
|
718
|
+
*/
|
|
719
|
+
toNextView() {
|
|
720
|
+
let viewSegment = toDateSegment(this.view);
|
|
721
|
+
switch (this.renderView) {
|
|
722
|
+
case RenderView.DAY:
|
|
723
|
+
viewSegment = toDateSegment(addMonths(this.view, 1));
|
|
724
|
+
break;
|
|
725
|
+
case RenderView.MONTH:
|
|
726
|
+
viewSegment.year += 1;
|
|
727
|
+
break;
|
|
728
|
+
case RenderView.YEAR:
|
|
729
|
+
viewSegment.year += YEARS_PER_YEAR_VIEW;
|
|
730
|
+
break;
|
|
731
|
+
// no default
|
|
732
|
+
}
|
|
733
|
+
this.notifyViewChange(viewSegment);
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Navigate to the previous view
|
|
737
|
+
* @returns {void}
|
|
738
|
+
*/
|
|
739
|
+
toPreviousView() {
|
|
740
|
+
let viewSegment = toDateSegment(this.view);
|
|
741
|
+
switch (this.renderView) {
|
|
742
|
+
case RenderView.DAY:
|
|
743
|
+
viewSegment = toDateSegment(subMonths(this.view, 1));
|
|
744
|
+
break;
|
|
745
|
+
case RenderView.MONTH:
|
|
746
|
+
viewSegment.year -= 1;
|
|
747
|
+
break;
|
|
748
|
+
case RenderView.YEAR:
|
|
749
|
+
viewSegment.year -= YEARS_PER_YEAR_VIEW;
|
|
750
|
+
break;
|
|
751
|
+
// no default
|
|
752
|
+
}
|
|
753
|
+
this.notifyViewChange(viewSegment);
|
|
754
|
+
}
|
|
534
755
|
/**
|
|
535
756
|
* Run when tap event happened on DAY view and the cell has the values
|
|
536
757
|
* Try to select/deselect cell value
|
|
@@ -543,12 +764,14 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
543
764
|
}
|
|
544
765
|
let values;
|
|
545
766
|
if (this.multiple) {
|
|
546
|
-
values = this.values.
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
if (this.values.length === values.length) {
|
|
767
|
+
values = this.values.concat([]);
|
|
768
|
+
const valueIdx = this.values.indexOf(value);
|
|
769
|
+
if (valueIdx === -1) {
|
|
550
770
|
values.push(value);
|
|
551
771
|
}
|
|
772
|
+
else {
|
|
773
|
+
values.splice(valueIdx, 1);
|
|
774
|
+
}
|
|
552
775
|
}
|
|
553
776
|
else if (this.range) {
|
|
554
777
|
if (!this.values.length) {
|
|
@@ -564,12 +787,16 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
564
787
|
values = [value];
|
|
565
788
|
}
|
|
566
789
|
}
|
|
567
|
-
else {
|
|
790
|
+
else if (this.values.indexOf(value) === -1) {
|
|
568
791
|
values = [value];
|
|
569
792
|
}
|
|
793
|
+
else {
|
|
794
|
+
// remove range if start/end index match
|
|
795
|
+
values = [];
|
|
796
|
+
}
|
|
570
797
|
}
|
|
571
798
|
else {
|
|
572
|
-
values = [value];
|
|
799
|
+
values = this.value === value ? [] : [value];
|
|
573
800
|
}
|
|
574
801
|
this.notifyValuesChange(values);
|
|
575
802
|
}
|
|
@@ -613,11 +840,7 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
613
840
|
if (isIE && isBC) {
|
|
614
841
|
return html `${formatLocaleDate(date, getLocale(this), includeMonth, includeEra)}`;
|
|
615
842
|
}
|
|
616
|
-
return html `${this.
|
|
617
|
-
date,
|
|
618
|
-
includeMonth,
|
|
619
|
-
includeEra
|
|
620
|
-
}, ViewFormatTranslateParams)}`;
|
|
843
|
+
return html `${this.dateT('VIEW_FORMAT', { date, includeMonth, includeEra }, ViewFormatTranslateParams)}`;
|
|
621
844
|
}
|
|
622
845
|
/**
|
|
623
846
|
* Get a string representation of current view
|
|
@@ -640,14 +863,49 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
640
863
|
}
|
|
641
864
|
}
|
|
642
865
|
/**
|
|
643
|
-
*
|
|
644
|
-
*
|
|
645
|
-
* @
|
|
646
|
-
* @param selectable True if cell may be selected
|
|
647
|
-
* @returns template result
|
|
866
|
+
* Set an active state of the cell based
|
|
867
|
+
* @param rows A collection of rows with cells
|
|
868
|
+
* @returns {void}
|
|
648
869
|
*/
|
|
649
|
-
|
|
650
|
-
|
|
870
|
+
setActiveCell(rows) {
|
|
871
|
+
const setActive = (cell) => {
|
|
872
|
+
if (cell) {
|
|
873
|
+
cell.active = true;
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
const columnIdx = this.activeCellIndex ? this.activeCellIndex[0] : NaN;
|
|
877
|
+
const rowIdx = this.activeCellIndex ? this.activeCellIndex[1] : NaN;
|
|
878
|
+
// Selected cell is active or today cell or first available cell
|
|
879
|
+
let activeCell;
|
|
880
|
+
let nowCell;
|
|
881
|
+
let firstCell;
|
|
882
|
+
let selectedCell;
|
|
883
|
+
for (let i = 0; i < rows.length; i += 1) {
|
|
884
|
+
const row = rows[i];
|
|
885
|
+
for (let e = 0; e < row.length; e += 1) {
|
|
886
|
+
const cell = row[e];
|
|
887
|
+
if (cell.disabled || !cell.value) {
|
|
888
|
+
continue;
|
|
889
|
+
}
|
|
890
|
+
if (i === rowIdx && e === columnIdx) {
|
|
891
|
+
activeCell = cell;
|
|
892
|
+
}
|
|
893
|
+
if (!selectedCell && cell.selected) {
|
|
894
|
+
selectedCell = cell;
|
|
895
|
+
}
|
|
896
|
+
if (cell.now) {
|
|
897
|
+
nowCell = cell;
|
|
898
|
+
}
|
|
899
|
+
if (!firstCell) {
|
|
900
|
+
firstCell = cell;
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
// If a cell that was active before last render is not available now, remove index
|
|
905
|
+
if (!activeCell && this.activeCellIndex) {
|
|
906
|
+
this.resetActiveCellIndex(); // set on private to not cause another re-render
|
|
907
|
+
}
|
|
908
|
+
setActive(activeCell || selectedCell || nowCell || firstCell);
|
|
651
909
|
}
|
|
652
910
|
/**
|
|
653
911
|
* Get year view template
|
|
@@ -663,18 +921,18 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
663
921
|
for (let i = 0; i < YEAR_VIEW.totalCount; i += 1) {
|
|
664
922
|
if (i % YEAR_VIEW.columnCount === 0) {
|
|
665
923
|
cells = [];
|
|
666
|
-
rows.push(
|
|
667
|
-
cells
|
|
668
|
-
});
|
|
924
|
+
rows.push(cells);
|
|
669
925
|
}
|
|
670
926
|
const year = startIdx + i;
|
|
671
927
|
const value = utcFormat({ year, month: 0, day: 1 }, DateFormat.yyyyMMdd);
|
|
672
|
-
cell = Object.assign({ view, text: year > 0 ? `${year}` : year === 0 ? '1' : `${Math.abs(year - 1)}`, value: `${year}`, now: isThisYear(value) }, this.getCellSelection(value, isSameYear));
|
|
928
|
+
cell = Object.assign({ view, text: year > 0 ? `${year}` : year === 0 ? '1' : `${Math.abs(year - 1)}`, value: `${year}`, now: isThisYear(value), index: [cells.length, rows.length - 1] }, this.getCellSelection(value, isSameYear));
|
|
673
929
|
cells.push(cell);
|
|
674
930
|
years.push(cell);
|
|
675
931
|
}
|
|
676
932
|
years[0].firstDate = true;
|
|
677
933
|
years[years.length - 1].lastDate = true;
|
|
934
|
+
this.setActiveCell(rows);
|
|
935
|
+
this.setNavigationMap(rows);
|
|
678
936
|
return html `${this.renderRows(rows)}`;
|
|
679
937
|
}
|
|
680
938
|
/**
|
|
@@ -686,7 +944,7 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
686
944
|
const columnCount = MONTH_VIEW.columnCount;
|
|
687
945
|
const monthCount = 12;
|
|
688
946
|
const totalCount = MONTH_VIEW.totalCount;
|
|
689
|
-
const monthsNames = this.
|
|
947
|
+
const monthsNames = this.localMonthsNames;
|
|
690
948
|
const before = (totalCount - monthCount) / 2;
|
|
691
949
|
const startIdx = monthCount - before % monthCount;
|
|
692
950
|
const after = before + monthCount;
|
|
@@ -697,21 +955,21 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
697
955
|
for (let i = 0; i < totalCount; i += 1) {
|
|
698
956
|
if (i % columnCount === 0) {
|
|
699
957
|
cells = [];
|
|
700
|
-
rows.push(
|
|
701
|
-
cells
|
|
702
|
-
});
|
|
958
|
+
rows.push(cells);
|
|
703
959
|
}
|
|
704
960
|
const month = (startIdx + i) % monthCount; /* 0 for Jan, 11 for Dev */
|
|
705
961
|
const year = currentYear + Math.floor((i - before) / monthCount);
|
|
706
962
|
const segment = { year, month, day: 1 };
|
|
707
963
|
const value = utcFormat(segment, DateFormat.yyyyMMdd);
|
|
708
964
|
const idle = i < before || i >= after;
|
|
709
|
-
cell = Object.assign({ view, text: monthsNames[month], value: utcFormat(segment, DateFormat.yyyyMM), idle, now: isThisMonth(value) }, this.getCellSelection(value, isSameMonth));
|
|
965
|
+
cell = Object.assign({ view, text: monthsNames[month], value: utcFormat(segment, DateFormat.yyyyMM), idle, now: isThisMonth(value), index: [cells.length, rows.length - 1] }, this.getCellSelection(value, isSameMonth));
|
|
710
966
|
cells.push(cell);
|
|
711
967
|
months.push(cell);
|
|
712
968
|
}
|
|
713
969
|
months[0].firstDate = true;
|
|
714
970
|
months[months.length - 1].lastDate = true;
|
|
971
|
+
this.setActiveCell(rows);
|
|
972
|
+
this.setNavigationMap(rows);
|
|
715
973
|
return html `${this.renderRows(rows)}`;
|
|
716
974
|
}
|
|
717
975
|
/**
|
|
@@ -734,15 +992,14 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
734
992
|
for (let i = 0; i < DAY_VIEW.totalCount; i += 1) {
|
|
735
993
|
if (i % DAY_VIEW.columnCount === 0) {
|
|
736
994
|
cells = [];
|
|
737
|
-
rows.push(
|
|
738
|
-
cells
|
|
739
|
-
});
|
|
995
|
+
rows.push(cells);
|
|
740
996
|
}
|
|
741
997
|
const datePadding = i - padding + 1;
|
|
742
998
|
if (datePadding <= 0) {
|
|
743
999
|
if (!this.fillCells) {
|
|
744
1000
|
cells.push({
|
|
745
|
-
view
|
|
1001
|
+
view,
|
|
1002
|
+
index: [cells.length, rows.length - 1]
|
|
746
1003
|
});
|
|
747
1004
|
continue;
|
|
748
1005
|
}
|
|
@@ -753,7 +1010,8 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
753
1010
|
else if (datePadding > viewMonth.days) {
|
|
754
1011
|
if (!this.fillCells) {
|
|
755
1012
|
cells.push({
|
|
756
|
-
view
|
|
1013
|
+
view,
|
|
1014
|
+
index: [cells.length, rows.length - 1]
|
|
757
1015
|
});
|
|
758
1016
|
continue;
|
|
759
1017
|
}
|
|
@@ -769,14 +1027,16 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
769
1027
|
const value = utcFormat({ year, month, day }, DateFormat.yyyyMMdd);
|
|
770
1028
|
const disabled = this.isDateAvailable ? !this.isDateAvailable(value) : false;
|
|
771
1029
|
const dayCell = Object.assign({ view, text: day.toString(), value,
|
|
772
|
-
disabled, idle: month !== viewMonth.month || year !== viewMonth.year, now: isToday(value) }, this.getCellSelection(value, isSameDay));
|
|
1030
|
+
disabled, idle: month !== viewMonth.month || year !== viewMonth.year, now: isToday(value), index: [cells.length, rows.length - 1] }, this.getCellSelection(value, isSameDay));
|
|
773
1031
|
cells.push(dayCell);
|
|
774
1032
|
days.push(dayCell);
|
|
775
1033
|
}
|
|
776
1034
|
days[0].firstDate = true;
|
|
777
1035
|
days[days.length - 1].lastDate = true;
|
|
1036
|
+
this.setActiveCell(rows);
|
|
1037
|
+
this.setNavigationMap(rows);
|
|
778
1038
|
return html `
|
|
779
|
-
${this.renderWeekdayNames}
|
|
1039
|
+
${guard([this.firstDayOfWeek, this.lang], () => this.renderWeekdayNames)}
|
|
780
1040
|
${this.renderRows(rows)}
|
|
781
1041
|
`;
|
|
782
1042
|
}
|
|
@@ -784,23 +1044,50 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
784
1044
|
* Get weekday names template
|
|
785
1045
|
*/
|
|
786
1046
|
get renderWeekdayNames() {
|
|
1047
|
+
const firstDayOfWeek = this.firstDayOfWeek;
|
|
1048
|
+
const weekdaysNames = this.localWeekdaysNames.slice(firstDayOfWeek).concat(this.localWeekdaysNames.slice(0, firstDayOfWeek));
|
|
787
1049
|
return html `
|
|
788
|
-
<div
|
|
789
|
-
|
|
1050
|
+
<div role="row"
|
|
1051
|
+
part="row day-name-row">${weekdaysNames.map(day => html `
|
|
1052
|
+
<div scope="col" role="columnheader" part="cell day-name" abbr="${day.long}">
|
|
1053
|
+
<div part="cell-content">${day.narrow}</div>
|
|
1054
|
+
</div>
|
|
1055
|
+
`)}</div>`;
|
|
790
1056
|
}
|
|
791
1057
|
/**
|
|
792
1058
|
* Render a view based on the current render view
|
|
793
1059
|
*/
|
|
794
1060
|
get viewRender() {
|
|
1061
|
+
let renderView;
|
|
795
1062
|
switch (this.renderView) {
|
|
796
1063
|
case RenderView.MONTH:
|
|
797
|
-
|
|
1064
|
+
renderView = this.monthView;
|
|
1065
|
+
break;
|
|
798
1066
|
case RenderView.YEAR:
|
|
799
|
-
|
|
1067
|
+
renderView = this.yearView;
|
|
1068
|
+
break;
|
|
800
1069
|
case RenderView.DAY:
|
|
801
1070
|
default:
|
|
802
|
-
|
|
1071
|
+
renderView = this.dayView;
|
|
803
1072
|
}
|
|
1073
|
+
return html `${cache(renderView)}`;
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* Get cell translate label key based on selected state
|
|
1077
|
+
* @param cell Cell
|
|
1078
|
+
* @returns key Translate label key
|
|
1079
|
+
*/
|
|
1080
|
+
getCellLabelKey(cell) {
|
|
1081
|
+
if (cell.selected && cell.now) {
|
|
1082
|
+
return 'SELECTED_NOW';
|
|
1083
|
+
}
|
|
1084
|
+
if (cell.selected) {
|
|
1085
|
+
return 'SELECTED';
|
|
1086
|
+
}
|
|
1087
|
+
if (cell.now) {
|
|
1088
|
+
return 'NOW';
|
|
1089
|
+
}
|
|
1090
|
+
return 'CELL_LABEL';
|
|
804
1091
|
}
|
|
805
1092
|
/**
|
|
806
1093
|
* Render cell template. Cell can be a day, month or year
|
|
@@ -808,10 +1095,13 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
808
1095
|
* @returns template result
|
|
809
1096
|
*/
|
|
810
1097
|
renderCell(cell) {
|
|
1098
|
+
const isSelectable = cell.value !== undefined && !cell.disabled;
|
|
811
1099
|
return html `<div
|
|
1100
|
+
role="gridcell"
|
|
812
1101
|
part="cell ${cell.view}"
|
|
1102
|
+
aria-selected="${ifDefined(isSelectable ? (cell.selected ? 'true' : 'false') : undefined)}"
|
|
1103
|
+
?active=${cell.active}
|
|
813
1104
|
?disabled=${cell.disabled}
|
|
814
|
-
.value=${cell.value}
|
|
815
1105
|
?idle=${cell.idle}
|
|
816
1106
|
?today=${cell.now}
|
|
817
1107
|
?first-date=${cell.firstDate}
|
|
@@ -819,9 +1109,18 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
819
1109
|
?selected=${cell.selected}
|
|
820
1110
|
?range=${cell.range}
|
|
821
1111
|
?range-from=${cell.rangeFrom}
|
|
822
|
-
?range-to=${cell.rangeTo}
|
|
823
|
-
|
|
824
|
-
|
|
1112
|
+
?range-to=${cell.rangeTo}>
|
|
1113
|
+
<div role="${ifDefined(cell.value ? 'button' : undefined)}"
|
|
1114
|
+
tabindex=${ifDefined(isSelectable ? (cell.active ? 0 : -1) : undefined)}
|
|
1115
|
+
aria-label="${ifDefined(isSelectable && !isIE ? this.t(this.getCellLabelKey(cell), {
|
|
1116
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1117
|
+
value: parse(cell.value),
|
|
1118
|
+
view: this.renderView
|
|
1119
|
+
}) : undefined)}"
|
|
1120
|
+
part="cell-content${isSelectable ? ' selection' : ''}"
|
|
1121
|
+
.value=${cell.value}
|
|
1122
|
+
.index=${cell.index}>${cell.text}</div>
|
|
1123
|
+
</div>`;
|
|
825
1124
|
}
|
|
826
1125
|
/**
|
|
827
1126
|
* Render view rows
|
|
@@ -829,32 +1128,80 @@ let Calendar = class Calendar extends ControlElement {
|
|
|
829
1128
|
* @returns template result
|
|
830
1129
|
*/
|
|
831
1130
|
renderRows(rows) {
|
|
832
|
-
return rows.map(row => html `<div part="row">${row.
|
|
1131
|
+
return rows.map(row => html `<div role="row" part="row">${row.map(cell => this.renderCell(cell))}</div>`);
|
|
833
1132
|
}
|
|
834
1133
|
/**
|
|
835
|
-
*
|
|
836
|
-
*
|
|
837
|
-
* @return Render template
|
|
1134
|
+
* Render button navigation template
|
|
1135
|
+
* @returns template result
|
|
838
1136
|
*/
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
1137
|
+
get buttonNavigationTemplate() {
|
|
1138
|
+
let prevBtnAriaLabel = this.t('PREVIOUS_MONTH');
|
|
1139
|
+
let nextBtnAriaLabel = this.t('NEXT_MONTH');
|
|
1140
|
+
let viewBtnAriaLabel = this.t('YEAR_SELECTOR');
|
|
1141
|
+
switch (this.renderView) {
|
|
1142
|
+
case RenderView.YEAR:
|
|
1143
|
+
prevBtnAriaLabel = this.t('PREVIOUS_DECADE');
|
|
1144
|
+
nextBtnAriaLabel = this.t('NEXT_DECADE');
|
|
1145
|
+
viewBtnAriaLabel = this.t('DATE_SELECTOR');
|
|
1146
|
+
break;
|
|
1147
|
+
case RenderView.MONTH:
|
|
1148
|
+
prevBtnAriaLabel = this.t('PREVIOUS_YEAR');
|
|
1149
|
+
nextBtnAriaLabel = this.t('NEXT_YEAR');
|
|
1150
|
+
viewBtnAriaLabel = this.t('DATE_SELECTOR');
|
|
1151
|
+
break;
|
|
1152
|
+
// RenderView.DAY
|
|
1153
|
+
// no default
|
|
1154
|
+
}
|
|
1155
|
+
return html `<div part="navigation">
|
|
842
1156
|
<ef-button
|
|
843
1157
|
part="btn-prev"
|
|
1158
|
+
aria-label="${prevBtnAriaLabel}"
|
|
844
1159
|
icon="left"
|
|
845
1160
|
@tap=${this.onPreviousTap}></ef-button>
|
|
846
1161
|
<ef-button
|
|
1162
|
+
${ref(this.viewBtnRef)}
|
|
1163
|
+
aria-description="${viewBtnAriaLabel}"
|
|
847
1164
|
part="btn-view"
|
|
848
1165
|
textpos="before"
|
|
849
1166
|
.icon="${this.renderView === RenderView.DAY ? 'down' : 'up'}"
|
|
850
1167
|
@tap="${this.onRenderViewTap}">${this.formattedViewRender}</ef-button>
|
|
851
1168
|
<ef-button
|
|
852
1169
|
part="btn-next"
|
|
1170
|
+
aria-label="${nextBtnAriaLabel}"
|
|
853
1171
|
icon="right"
|
|
854
1172
|
@tap=${this.onNextTap}></ef-button>
|
|
855
|
-
</div
|
|
856
|
-
|
|
857
|
-
|
|
1173
|
+
</div>`;
|
|
1174
|
+
}
|
|
1175
|
+
/**
|
|
1176
|
+
* A template used to notify currently selected value for screen readers
|
|
1177
|
+
* @returns template result
|
|
1178
|
+
*/
|
|
1179
|
+
get selectionTemplate() {
|
|
1180
|
+
if (isIE || !this.announceValues) { /* IE11 has significant performance complications */
|
|
1181
|
+
return;
|
|
1182
|
+
}
|
|
1183
|
+
return html `<div
|
|
1184
|
+
part="aria-selection"
|
|
1185
|
+
aria-live="polite"
|
|
1186
|
+
aria-label="${this.value
|
|
1187
|
+
? this.range
|
|
1188
|
+
? this.t('SELECTED_RANGE', { from: parse(this.values[0]), to: this.values[1] ? parse(this.values[1]) : null })
|
|
1189
|
+
: this.t('SELECTED_DATE', { value: parse(this.value), count: this.values.length })
|
|
1190
|
+
: this.t('SELECTED_NONE', { multiple: this.multiple, range: this.range })}"></div>`;
|
|
1191
|
+
}
|
|
1192
|
+
/**
|
|
1193
|
+
* A `TemplateResult` that will be used
|
|
1194
|
+
* to render the updated internal template.
|
|
1195
|
+
* @return Render template
|
|
1196
|
+
*/
|
|
1197
|
+
render() {
|
|
1198
|
+
return html `
|
|
1199
|
+
${guard([this.values, this.lang, this.range, this.multiple, this.announceValues], () => this.selectionTemplate)}
|
|
1200
|
+
${guard([this.view, this.renderView, this.lang], () => this.buttonNavigationTemplate)}
|
|
1201
|
+
<div role="grid"
|
|
1202
|
+
aria-multiselectable="${this.range || this.multiple}"
|
|
1203
|
+
part="table"
|
|
1204
|
+
@tap=${this.onTableTap}>${this.viewRender}</div>
|
|
858
1205
|
<div part="footer"><slot name="footer"></slot></div>
|
|
859
1206
|
`;
|
|
860
1207
|
}
|
|
@@ -901,19 +1248,27 @@ __decorate([
|
|
|
901
1248
|
__decorate([
|
|
902
1249
|
property({ type: Boolean, attribute: 'fill-cells' })
|
|
903
1250
|
], Calendar.prototype, "fillCells", void 0);
|
|
1251
|
+
__decorate([
|
|
1252
|
+
translate({ mode: 'directive', scope: CalendarLocaleScope })
|
|
1253
|
+
], Calendar.prototype, "dateT", void 0);
|
|
1254
|
+
__decorate([
|
|
1255
|
+
translate({ mode: 'promise', scope: CalendarLocaleScope })
|
|
1256
|
+
], Calendar.prototype, "dateTPromise", void 0);
|
|
904
1257
|
__decorate([
|
|
905
1258
|
translate({ mode: 'directive', scope: 'ef-calendar' })
|
|
906
1259
|
], Calendar.prototype, "t", void 0);
|
|
907
1260
|
__decorate([
|
|
908
|
-
|
|
909
|
-
], Calendar.prototype, "
|
|
1261
|
+
state()
|
|
1262
|
+
], Calendar.prototype, "renderView", null);
|
|
910
1263
|
__decorate([
|
|
911
|
-
|
|
912
|
-
], Calendar.prototype, "
|
|
1264
|
+
state()
|
|
1265
|
+
], Calendar.prototype, "activeCellIndex", null);
|
|
1266
|
+
__decorate([
|
|
1267
|
+
state()
|
|
1268
|
+
], Calendar.prototype, "announceValues", void 0);
|
|
913
1269
|
Calendar = __decorate([
|
|
914
1270
|
customElement('ef-calendar', {
|
|
915
1271
|
alias: 'coral-calendar'
|
|
916
1272
|
})
|
|
917
1273
|
], Calendar);
|
|
918
1274
|
export { Calendar };
|
|
919
|
-
//# sourceMappingURL=index.js.map
|