@refinitiv-ui/elements 5.3.3 → 5.7.0
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 +70 -0
- package/lib/accordion/custom-elements.json +49 -0
- package/lib/accordion/custom-elements.md +18 -0
- package/lib/accordion/index.d.ts +76 -0
- package/lib/accordion/index.js +136 -0
- package/lib/accordion/themes/halo/dark/index.js +3 -0
- package/lib/accordion/themes/halo/light/index.js +3 -0
- package/lib/accordion/themes/solar/charcoal/index.js +3 -0
- package/lib/accordion/themes/solar/pearl/index.js +3 -0
- package/lib/appstate-bar/custom-elements.json +49 -0
- package/lib/appstate-bar/custom-elements.md +22 -0
- package/lib/appstate-bar/index.d.ts +65 -0
- package/lib/appstate-bar/index.js +100 -0
- package/lib/appstate-bar/themes/halo/dark/index.js +3 -0
- package/lib/appstate-bar/themes/halo/light/index.js +3 -0
- package/lib/appstate-bar/themes/solar/charcoal/index.js +3 -0
- package/lib/appstate-bar/themes/solar/pearl/index.js +3 -0
- package/lib/autosuggest/custom-elements.json +233 -0
- package/lib/autosuggest/custom-elements.md +47 -0
- package/lib/autosuggest/helpers/types.d.ts +54 -0
- package/lib/autosuggest/helpers/types.js +1 -0
- package/lib/autosuggest/helpers/utils.d.ts +39 -0
- package/lib/autosuggest/helpers/utils.js +75 -0
- package/lib/autosuggest/index.d.ts +534 -0
- package/lib/autosuggest/index.js +1251 -0
- package/lib/autosuggest/themes/halo/dark/index.js +5 -0
- package/lib/autosuggest/themes/halo/light/index.js +5 -0
- package/lib/autosuggest/themes/solar/charcoal/index.js +5 -0
- package/lib/autosuggest/themes/solar/pearl/index.js +5 -0
- package/lib/button/custom-elements.json +119 -0
- package/lib/button/custom-elements.md +23 -0
- package/lib/button/index.d.ts +132 -0
- package/lib/button/index.js +223 -0
- package/lib/button/themes/halo/dark/index.js +3 -0
- package/lib/button/themes/halo/light/index.js +3 -0
- package/lib/button/themes/solar/charcoal/index.js +3 -0
- package/lib/button/themes/solar/pearl/index.js +3 -0
- package/lib/button-bar/custom-elements.json +26 -0
- package/lib/button-bar/custom-elements.md +9 -0
- package/lib/button-bar/index.d.ts +76 -0
- package/lib/button-bar/index.js +155 -0
- package/lib/button-bar/themes/halo/dark/index.js +3 -0
- package/lib/button-bar/themes/halo/light/index.js +3 -0
- package/lib/button-bar/themes/solar/charcoal/index.js +3 -0
- package/lib/button-bar/themes/solar/pearl/index.js +3 -0
- package/lib/calendar/constants.d.ts +22 -0
- package/lib/calendar/constants.js +23 -0
- package/lib/calendar/custom-elements.json +199 -0
- package/lib/calendar/custom-elements.md +35 -0
- package/lib/calendar/index.d.ts +321 -0
- package/lib/calendar/index.js +906 -0
- package/lib/calendar/locales.d.ts +1 -0
- package/lib/calendar/locales.js +40 -0
- package/lib/calendar/themes/halo/dark/index.js +3 -0
- package/lib/calendar/themes/halo/light/index.js +3 -0
- package/lib/calendar/themes/solar/charcoal/index.js +3 -0
- package/lib/calendar/themes/solar/pearl/index.js +3 -0
- package/lib/calendar/types.d.ts +29 -0
- package/lib/calendar/types.js +1 -0
- package/lib/calendar/utils.d.ts +42 -0
- package/lib/calendar/utils.js +119 -0
- package/lib/canvas/custom-elements.json +69 -0
- package/lib/canvas/custom-elements.md +27 -0
- package/lib/canvas/index.d.ts +100 -0
- package/lib/canvas/index.js +172 -0
- package/lib/canvas/themes/halo/dark/index.js +2 -0
- package/lib/canvas/themes/halo/light/index.js +2 -0
- package/lib/canvas/themes/solar/charcoal/index.js +2 -0
- package/lib/canvas/themes/solar/pearl/index.js +2 -0
- package/lib/card/custom-elements.json +59 -0
- package/lib/card/custom-elements.md +24 -0
- package/lib/card/helpers/types.d.ts +12 -0
- package/lib/card/helpers/types.js +1 -0
- package/lib/card/index.d.ts +140 -0
- package/lib/card/index.js +246 -0
- package/lib/card/themes/halo/dark/index.js +5 -0
- package/lib/card/themes/halo/light/index.js +5 -0
- package/lib/card/themes/solar/charcoal/index.js +5 -0
- package/lib/card/themes/solar/pearl/index.js +5 -0
- package/lib/chart/custom-elements.json +42 -0
- 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 +5 -0
- package/lib/chart/helpers/legend.js +78 -0
- package/lib/chart/helpers/merge.d.ts +15 -0
- package/lib/chart/helpers/merge.js +28 -0
- package/lib/chart/helpers/types.d.ts +69 -0
- package/lib/chart/helpers/types.js +1 -0
- package/lib/chart/index.d.ts +187 -0
- package/lib/chart/index.js +491 -0
- package/lib/chart/plugins/doughnut-center-label.d.ts +3 -0
- package/lib/chart/plugins/doughnut-center-label.js +196 -0
- package/lib/chart/themes/halo/dark/index.js +4 -0
- package/lib/chart/themes/halo/light/index.js +4 -0
- package/lib/chart/themes/solar/charcoal/index.js +4 -0
- package/lib/chart/themes/solar/pearl/index.js +4 -0
- package/lib/checkbox/custom-elements.json +67 -0
- package/lib/checkbox/custom-elements.md +18 -0
- package/lib/checkbox/index.d.ts +95 -0
- package/lib/checkbox/index.js +193 -0
- package/lib/checkbox/themes/halo/dark/index.js +4 -0
- package/lib/checkbox/themes/halo/light/index.js +4 -0
- package/lib/checkbox/themes/solar/charcoal/index.js +4 -0
- package/lib/checkbox/themes/solar/pearl/index.js +4 -0
- package/lib/clock/custom-elements.json +121 -0
- package/lib/clock/custom-elements.md +28 -0
- package/lib/clock/index.d.ts +319 -0
- package/lib/clock/index.js +581 -0
- package/lib/clock/themes/halo/dark/index.js +2 -0
- package/lib/clock/themes/halo/light/index.js +2 -0
- package/lib/clock/themes/solar/charcoal/index.js +2 -0
- package/lib/clock/themes/solar/pearl/index.js +2 -0
- package/lib/clock/utils/TickManager.d.ts +14 -0
- package/lib/clock/utils/TickManager.js +66 -0
- package/lib/clock/utils/timestamps.d.ts +6 -0
- package/lib/clock/utils/timestamps.js +6 -0
- package/lib/collapse/custom-elements.json +79 -0
- package/lib/collapse/custom-elements.md +27 -0
- package/lib/collapse/index.d.ts +119 -0
- package/lib/collapse/index.js +197 -0
- package/lib/collapse/themes/halo/dark/index.js +5 -0
- package/lib/collapse/themes/halo/light/index.js +5 -0
- package/lib/collapse/themes/solar/charcoal/index.js +5 -0
- package/lib/collapse/themes/solar/pearl/index.js +5 -0
- package/lib/color-dialog/custom-elements.json +193 -0
- package/lib/color-dialog/custom-elements.md +39 -0
- package/lib/color-dialog/elements/color-palettes.d.ts +52 -0
- package/lib/color-dialog/elements/color-palettes.js +101 -0
- package/lib/color-dialog/elements/grayscale-palettes.d.ts +67 -0
- package/lib/color-dialog/elements/grayscale-palettes.js +161 -0
- package/lib/color-dialog/elements/palettes.d.ts +65 -0
- package/lib/color-dialog/elements/palettes.js +132 -0
- package/lib/color-dialog/helpers/color-helpers.d.ts +16 -0
- package/lib/color-dialog/helpers/color-helpers.js +161 -0
- package/lib/color-dialog/helpers/value-model.d.ts +75 -0
- package/lib/color-dialog/helpers/value-model.js +141 -0
- package/lib/color-dialog/index.d.ts +232 -0
- package/lib/color-dialog/index.js +459 -0
- package/lib/color-dialog/themes/halo/dark/index.js +7 -0
- package/lib/color-dialog/themes/halo/light/index.js +7 -0
- package/lib/color-dialog/themes/solar/charcoal/index.js +7 -0
- package/lib/color-dialog/themes/solar/pearl/index.js +7 -0
- package/lib/combo-box/custom-elements.json +210 -0
- package/lib/combo-box/custom-elements.md +35 -0
- package/lib/combo-box/helpers/filter.d.ts +10 -0
- package/lib/combo-box/helpers/filter.js +29 -0
- package/lib/combo-box/helpers/keyboard-event.d.ts +17 -0
- package/lib/combo-box/helpers/keyboard-event.js +19 -0
- package/lib/combo-box/helpers/types.d.ts +11 -0
- package/lib/combo-box/helpers/types.js +1 -0
- package/lib/combo-box/index.d.ts +523 -0
- package/lib/combo-box/index.js +1146 -0
- package/lib/combo-box/themes/halo/dark/index.js +8 -0
- package/lib/combo-box/themes/halo/light/index.js +8 -0
- package/lib/combo-box/themes/solar/charcoal/index.js +8 -0
- package/lib/combo-box/themes/solar/pearl/index.js +8 -0
- package/lib/counter/custom-elements.json +35 -0
- package/lib/counter/custom-elements.md +11 -0
- package/lib/counter/index.d.ts +89 -0
- package/lib/counter/index.js +152 -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 +333 -0
- package/lib/datetime-picker/custom-elements.md +49 -0
- package/lib/datetime-picker/index.d.ts +498 -0
- package/lib/datetime-picker/index.js +1164 -0
- package/lib/datetime-picker/locales.d.ts +8 -0
- package/lib/datetime-picker/locales.js +57 -0
- package/lib/datetime-picker/themes/halo/dark/index.js +7 -0
- package/lib/datetime-picker/themes/halo/light/index.js +7 -0
- package/lib/datetime-picker/themes/solar/charcoal/index.js +7 -0
- package/lib/datetime-picker/themes/solar/pearl/index.js +7 -0
- package/lib/datetime-picker/types.d.ts +3 -0
- package/lib/datetime-picker/types.js +1 -0
- package/lib/datetime-picker/utils.d.ts +55 -0
- package/lib/datetime-picker/utils.js +92 -0
- package/lib/dialog/custom-elements.json +136 -0
- package/lib/dialog/custom-elements.md +47 -0
- package/lib/dialog/draggable-element.d.ts +14 -0
- package/lib/dialog/draggable-element.js +221 -0
- package/lib/dialog/index.d.ts +199 -0
- package/lib/dialog/index.js +331 -0
- package/lib/dialog/themes/halo/dark/index.js +7 -0
- package/lib/dialog/themes/halo/light/index.js +7 -0
- package/lib/dialog/themes/solar/charcoal/index.js +7 -0
- package/lib/dialog/themes/solar/pearl/index.js +7 -0
- package/lib/email-field/custom-elements.json +199 -0
- package/lib/email-field/custom-elements.md +35 -0
- package/lib/email-field/index.d.ts +152 -0
- package/lib/email-field/index.js +286 -0
- package/lib/email-field/themes/halo/dark/index.js +3 -0
- package/lib/email-field/themes/halo/light/index.js +3 -0
- package/lib/email-field/themes/solar/charcoal/index.js +3 -0
- package/lib/email-field/themes/solar/pearl/index.js +3 -0
- package/lib/events.d.ts +121 -0
- package/lib/events.js +1 -0
- package/lib/flag/custom-elements.json +35 -0
- package/lib/flag/custom-elements.md +10 -0
- package/lib/flag/index.d.ts +94 -0
- package/lib/flag/index.js +166 -0
- package/lib/flag/themes/halo/dark/index.js +2 -0
- package/lib/flag/themes/halo/light/index.js +2 -0
- package/lib/flag/themes/solar/charcoal/index.js +2 -0
- package/lib/flag/themes/solar/pearl/index.js +2 -0
- package/lib/flag/utils/FlagLoader.d.ts +47 -0
- package/lib/flag/utils/FlagLoader.js +86 -0
- package/lib/header/custom-elements.json +36 -0
- package/lib/header/custom-elements.md +18 -0
- package/lib/header/index.d.ts +46 -0
- package/lib/header/index.js +73 -0
- package/lib/header/themes/halo/dark/index.js +2 -0
- package/lib/header/themes/halo/light/index.js +2 -0
- package/lib/header/themes/solar/charcoal/index.js +2 -0
- package/lib/header/themes/solar/pearl/index.js +2 -0
- package/lib/heatmap/custom-elements.json +151 -0
- package/lib/heatmap/custom-elements.md +26 -0
- package/lib/heatmap/helpers/color.d.ts +30 -0
- package/lib/heatmap/helpers/color.js +68 -0
- package/lib/heatmap/helpers/text.d.ts +26 -0
- package/lib/heatmap/helpers/text.js +91 -0
- package/lib/heatmap/helpers/track.d.ts +102 -0
- package/lib/heatmap/helpers/track.js +160 -0
- package/lib/heatmap/helpers/types.d.ts +40 -0
- package/lib/heatmap/helpers/types.js +1 -0
- package/lib/heatmap/index.d.ts +453 -0
- package/lib/heatmap/index.js +1103 -0
- package/lib/heatmap/themes/halo/dark/index.js +4 -0
- package/lib/heatmap/themes/halo/light/index.js +4 -0
- package/lib/heatmap/themes/solar/charcoal/index.js +4 -0
- package/lib/heatmap/themes/solar/pearl/index.js +4 -0
- package/lib/icon/custom-elements.json +36 -0
- package/lib/icon/custom-elements.md +8 -0
- package/lib/icon/index.d.ts +88 -0
- package/lib/icon/index.js +169 -0
- package/lib/icon/themes/halo/dark/index.js +2 -0
- package/lib/icon/themes/halo/light/index.js +2 -0
- package/lib/icon/themes/solar/charcoal/index.js +2 -0
- package/lib/icon/themes/solar/pearl/index.js +2 -0
- package/lib/icon/utils/IconLoader.d.ts +52 -0
- package/lib/icon/utils/IconLoader.js +93 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +3 -0
- package/lib/interactive-chart/custom-elements.json +86 -0
- package/lib/interactive-chart/custom-elements.md +32 -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 +45 -0
- package/lib/interactive-chart/helpers/types.js +6 -0
- package/lib/interactive-chart/index.d.ts +380 -0
- package/lib/interactive-chart/index.js +1090 -0
- package/lib/interactive-chart/themes/halo/dark/index.js +3 -0
- package/lib/interactive-chart/themes/halo/light/index.js +3 -0
- package/lib/interactive-chart/themes/solar/charcoal/index.js +3 -0
- package/lib/interactive-chart/themes/solar/pearl/index.js +3 -0
- package/lib/item/custom-elements.json +151 -0
- package/lib/item/custom-elements.md +29 -0
- package/lib/item/helpers/types.d.ts +57 -0
- package/lib/item/helpers/types.js +1 -0
- package/lib/item/index.d.ts +158 -0
- package/lib/item/index.js +271 -0
- package/lib/item/themes/halo/dark/index.js +4 -0
- package/lib/item/themes/halo/light/index.js +4 -0
- package/lib/item/themes/solar/charcoal/index.js +4 -0
- package/lib/item/themes/solar/pearl/index.js +4 -0
- package/lib/jsx.d.ts +223 -0
- package/lib/label/custom-elements.json +52 -0
- package/lib/label/custom-elements.md +11 -0
- package/lib/label/index.d.ts +102 -0
- package/lib/label/index.js +244 -0
- package/lib/label/themes/halo/dark/index.js +3 -0
- package/lib/label/themes/halo/light/index.js +3 -0
- package/lib/label/themes/solar/charcoal/index.js +3 -0
- package/lib/label/themes/solar/pearl/index.js +3 -0
- package/lib/layout/custom-elements.json +163 -0
- package/lib/layout/custom-elements.md +26 -0
- package/lib/layout/index.d.ts +107 -0
- package/lib/layout/index.js +212 -0
- package/lib/layout/themes/halo/dark/index.js +2 -0
- package/lib/layout/themes/halo/light/index.js +2 -0
- package/lib/layout/themes/solar/charcoal/index.js +2 -0
- package/lib/layout/themes/solar/pearl/index.js +2 -0
- package/lib/led-gauge/custom-elements.json +113 -0
- package/lib/led-gauge/custom-elements.md +17 -0
- package/lib/led-gauge/index.d.ts +143 -0
- package/lib/led-gauge/index.js +437 -0
- package/lib/led-gauge/themes/halo/dark/index.js +3 -0
- package/lib/led-gauge/themes/halo/light/index.js +3 -0
- package/lib/led-gauge/themes/solar/charcoal/index.js +3 -0
- package/lib/led-gauge/themes/solar/pearl/index.js +3 -0
- package/lib/list/custom-elements.json +111 -0
- package/lib/list/custom-elements.md +30 -0
- package/lib/list/extensible-function.d.ts +8 -0
- package/lib/list/extensible-function.js +13 -0
- package/lib/list/helpers/list-renderer.d.ts +9 -0
- package/lib/list/helpers/list-renderer.js +35 -0
- package/lib/list/helpers/types.d.ts +3 -0
- package/lib/list/helpers/types.js +1 -0
- package/lib/list/index.d.ts +292 -0
- package/lib/list/index.js +600 -0
- package/lib/list/renderer.d.ts +36 -0
- package/lib/list/renderer.js +9 -0
- package/lib/list/themes/halo/dark/index.js +3 -0
- package/lib/list/themes/halo/light/index.js +3 -0
- package/lib/list/themes/solar/charcoal/index.js +3 -0
- package/lib/list/themes/solar/pearl/index.js +3 -0
- package/lib/loader/custom-elements.json +9 -0
- package/lib/loader/custom-elements.md +5 -0
- package/lib/loader/index.d.ts +41 -0
- package/lib/loader/index.js +61 -0
- package/lib/loader/themes/halo/dark/index.js +2 -0
- package/lib/loader/themes/halo/light/index.js +2 -0
- package/lib/loader/themes/solar/charcoal/index.js +2 -0
- package/lib/loader/themes/solar/pearl/index.js +2 -0
- package/lib/multi-input/custom-elements.json +238 -0
- package/lib/multi-input/custom-elements.md +43 -0
- package/lib/multi-input/helpers/types.d.ts +11 -0
- package/lib/multi-input/helpers/types.js +1 -0
- package/lib/multi-input/index.d.ts +297 -0
- package/lib/multi-input/index.js +590 -0
- package/lib/multi-input/themes/halo/dark/index.js +4 -0
- package/lib/multi-input/themes/halo/light/index.js +4 -0
- package/lib/multi-input/themes/solar/charcoal/index.js +4 -0
- package/lib/multi-input/themes/solar/pearl/index.js +4 -0
- package/lib/notification/custom-elements.json +95 -0
- package/lib/notification/custom-elements.md +26 -0
- package/lib/notification/elements/notification-tray.d.ts +97 -0
- package/lib/notification/elements/notification-tray.js +167 -0
- package/lib/notification/elements/notification.d.ts +90 -0
- package/lib/notification/elements/notification.js +154 -0
- package/lib/notification/helpers/status.d.ts +30 -0
- package/lib/notification/helpers/status.js +130 -0
- package/lib/notification/helpers/types.d.ts +10 -0
- package/lib/notification/helpers/types.js +1 -0
- package/lib/notification/index.d.ts +2 -0
- package/lib/notification/index.js +2 -0
- package/lib/notification/themes/halo/dark/index.js +5 -0
- package/lib/notification/themes/halo/light/index.js +5 -0
- package/lib/notification/themes/solar/charcoal/index.js +5 -0
- package/lib/notification/themes/solar/pearl/index.js +5 -0
- package/lib/number-field/custom-elements.json +200 -0
- package/lib/number-field/custom-elements.md +37 -0
- package/lib/number-field/index.d.ts +294 -0
- package/lib/number-field/index.js +707 -0
- package/lib/number-field/themes/halo/dark/index.js +3 -0
- package/lib/number-field/themes/halo/light/index.js +3 -0
- package/lib/number-field/themes/solar/charcoal/index.js +3 -0
- package/lib/number-field/themes/solar/pearl/index.js +3 -0
- package/lib/overlay/custom-elements.json +345 -0
- package/lib/overlay/custom-elements.md +54 -0
- package/lib/overlay/elements/overlay-backdrop.d.ts +46 -0
- package/lib/overlay/elements/overlay-backdrop.js +64 -0
- package/lib/overlay/elements/overlay-viewport.d.ts +40 -0
- package/lib/overlay/elements/overlay-viewport.js +52 -0
- package/lib/overlay/elements/overlay.d.ts +403 -0
- package/lib/overlay/elements/overlay.js +1426 -0
- package/lib/overlay/helpers/functions.d.ts +13 -0
- package/lib/overlay/helpers/functions.js +16 -0
- package/lib/overlay/helpers/types.d.ts +97 -0
- package/lib/overlay/helpers/types.js +16 -0
- package/lib/overlay/index.d.ts +2 -0
- package/lib/overlay/index.js +1 -0
- package/lib/overlay/managers/backdrop-manager.d.ts +45 -0
- package/lib/overlay/managers/backdrop-manager.js +96 -0
- package/lib/overlay/managers/close-manager.d.ts +54 -0
- package/lib/overlay/managers/close-manager.js +138 -0
- package/lib/overlay/managers/focus-manager.d.ts +71 -0
- package/lib/overlay/managers/focus-manager.js +228 -0
- package/lib/overlay/managers/interaction-lock-manager.d.ts +138 -0
- package/lib/overlay/managers/interaction-lock-manager.js +375 -0
- package/lib/overlay/managers/viewport-manager.d.ts +93 -0
- package/lib/overlay/managers/viewport-manager.js +211 -0
- package/lib/overlay/managers/zindex-manager.d.ts +80 -0
- package/lib/overlay/managers/zindex-manager.js +195 -0
- package/lib/overlay/themes/halo/dark/index.js +4 -0
- package/lib/overlay/themes/halo/light/index.js +4 -0
- package/lib/overlay/themes/solar/charcoal/index.js +4 -0
- package/lib/overlay/themes/solar/pearl/index.js +4 -0
- package/lib/overlay-menu/custom-elements.json +194 -0
- package/lib/overlay-menu/custom-elements.md +44 -0
- package/lib/overlay-menu/helpers/types.d.ts +8 -0
- package/lib/overlay-menu/helpers/types.js +1 -0
- package/lib/overlay-menu/index.d.ts +385 -0
- package/lib/overlay-menu/index.js +933 -0
- package/lib/overlay-menu/managers/menu-manager.d.ts +98 -0
- package/lib/overlay-menu/managers/menu-manager.js +240 -0
- package/lib/overlay-menu/themes/halo/dark/index.js +5 -0
- package/lib/overlay-menu/themes/halo/light/index.js +5 -0
- package/lib/overlay-menu/themes/solar/charcoal/index.js +5 -0
- package/lib/overlay-menu/themes/solar/pearl/index.js +5 -0
- package/lib/pagination/custom-elements.json +93 -0
- package/lib/pagination/custom-elements.md +27 -0
- package/lib/pagination/helpers/types.d.ts +9 -0
- package/lib/pagination/helpers/types.js +1 -0
- package/lib/pagination/index.d.ts +207 -0
- package/lib/pagination/index.js +398 -0
- package/lib/pagination/themes/halo/dark/index.js +6 -0
- package/lib/pagination/themes/halo/light/index.js +6 -0
- package/lib/pagination/themes/solar/charcoal/index.js +6 -0
- package/lib/pagination/themes/solar/pearl/index.js +6 -0
- package/lib/panel/custom-elements.json +39 -0
- package/lib/panel/custom-elements.md +11 -0
- package/lib/panel/index.d.ts +48 -0
- package/lib/panel/index.js +74 -0
- package/lib/panel/themes/halo/dark/index.js +2 -0
- package/lib/panel/themes/halo/light/index.js +2 -0
- package/lib/panel/themes/solar/charcoal/index.js +2 -0
- package/lib/panel/themes/solar/pearl/index.js +2 -0
- package/lib/password-field/custom-elements.json +156 -0
- package/lib/password-field/custom-elements.md +31 -0
- package/lib/password-field/index.d.ts +141 -0
- package/lib/password-field/index.js +258 -0
- package/lib/password-field/themes/halo/dark/index.js +3 -0
- package/lib/password-field/themes/halo/light/index.js +3 -0
- package/lib/password-field/themes/solar/charcoal/index.js +3 -0
- package/lib/password-field/themes/solar/pearl/index.js +3 -0
- package/lib/pill/custom-elements.json +95 -0
- package/lib/pill/custom-elements.md +22 -0
- package/lib/pill/index.d.ts +97 -0
- package/lib/pill/index.js +160 -0
- package/lib/pill/themes/halo/dark/index.js +3 -0
- package/lib/pill/themes/halo/light/index.js +3 -0
- package/lib/pill/themes/solar/charcoal/index.js +3 -0
- package/lib/pill/themes/solar/pearl/index.js +3 -0
- package/lib/progress-bar/custom-elements.json +58 -0
- package/lib/progress-bar/custom-elements.md +18 -0
- package/lib/progress-bar/index.d.ts +82 -0
- package/lib/progress-bar/index.js +157 -0
- package/lib/progress-bar/themes/halo/dark/index.js +2 -0
- package/lib/progress-bar/themes/halo/light/index.js +2 -0
- package/lib/progress-bar/themes/solar/charcoal/index.js +2 -0
- package/lib/progress-bar/themes/solar/pearl/index.js +2 -0
- package/lib/radio-button/custom-elements.json +82 -0
- package/lib/radio-button/custom-elements.md +19 -0
- package/lib/radio-button/index.d.ts +122 -0
- package/lib/radio-button/index.js +257 -0
- package/lib/radio-button/radio-button-registry.d.ts +22 -0
- package/lib/radio-button/radio-button-registry.js +93 -0
- package/lib/radio-button/themes/halo/dark/index.js +3 -0
- package/lib/radio-button/themes/halo/light/index.js +3 -0
- package/lib/radio-button/themes/solar/charcoal/index.js +3 -0
- package/lib/radio-button/themes/solar/pearl/index.js +3 -0
- package/lib/rating/custom-elements.json +58 -0
- package/lib/rating/custom-elements.md +17 -0
- package/lib/rating/index.d.ts +91 -0
- package/lib/rating/index.js +157 -0
- package/lib/rating/themes/halo/dark/index.js +2 -0
- package/lib/rating/themes/halo/light/index.js +2 -0
- package/lib/rating/themes/solar/charcoal/index.js +2 -0
- package/lib/rating/themes/solar/pearl/index.js +2 -0
- package/lib/search-field/custom-elements.json +173 -0
- package/lib/search-field/custom-elements.md +33 -0
- package/lib/search-field/index.d.ts +134 -0
- package/lib/search-field/index.js +253 -0
- package/lib/search-field/themes/halo/dark/index.js +3 -0
- package/lib/search-field/themes/halo/light/index.js +3 -0
- package/lib/search-field/themes/solar/charcoal/index.js +3 -0
- package/lib/search-field/themes/solar/pearl/index.js +3 -0
- package/lib/select/custom-elements.json +103 -0
- package/lib/select/custom-elements.md +24 -0
- package/lib/select/helpers/types.d.ts +3 -0
- package/lib/select/helpers/types.js +1 -0
- package/lib/select/index.d.ts +388 -0
- package/lib/select/index.js +942 -0
- package/lib/select/themes/halo/dark/index.js +5 -0
- package/lib/select/themes/halo/light/index.js +5 -0
- package/lib/select/themes/solar/charcoal/index.js +5 -0
- package/lib/select/themes/solar/pearl/index.js +5 -0
- package/lib/sidebar-layout/custom-elements.json +72 -0
- package/lib/sidebar-layout/custom-elements.md +22 -0
- package/lib/sidebar-layout/index.d.ts +69 -0
- package/lib/sidebar-layout/index.js +134 -0
- package/lib/sidebar-layout/themes/halo/dark/index.js +3 -0
- package/lib/sidebar-layout/themes/halo/light/index.js +3 -0
- package/lib/sidebar-layout/themes/solar/charcoal/index.js +3 -0
- package/lib/sidebar-layout/themes/solar/pearl/index.js +3 -0
- package/lib/slider/custom-elements.json +181 -0
- package/lib/slider/custom-elements.md +28 -0
- package/lib/slider/index.d.ts +409 -0
- package/lib/slider/index.js +1187 -0
- package/lib/slider/themes/halo/dark/index.js +3 -0
- package/lib/slider/themes/halo/light/index.js +3 -0
- package/lib/slider/themes/solar/charcoal/index.js +3 -0
- package/lib/slider/themes/solar/pearl/index.js +3 -0
- package/lib/sparkline/custom-elements.json +59 -0
- package/lib/sparkline/custom-elements.md +16 -0
- package/lib/sparkline/index.d.ts +107 -0
- package/lib/sparkline/index.js +186 -0
- package/lib/sparkline/themes/halo/dark/index.js +2 -0
- package/lib/sparkline/themes/halo/light/index.js +2 -0
- package/lib/sparkline/themes/solar/charcoal/index.js +2 -0
- package/lib/sparkline/themes/solar/pearl/index.js +2 -0
- package/lib/swing-gauge/const.d.ts +22 -0
- package/lib/swing-gauge/const.js +26 -0
- package/lib/swing-gauge/custom-elements.json +109 -0
- 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 +294 -0
- package/lib/swing-gauge/index.js +762 -0
- package/lib/swing-gauge/themes/halo/dark/index.js +3 -0
- package/lib/swing-gauge/themes/halo/light/index.js +3 -0
- package/lib/swing-gauge/themes/solar/charcoal/index.js +3 -0
- package/lib/swing-gauge/themes/solar/pearl/index.js +3 -0
- package/lib/swing-gauge/types.d.ts +34 -0
- package/lib/swing-gauge/types.js +1 -0
- package/lib/tab/custom-elements.json +123 -0
- package/lib/tab/custom-elements.md +22 -0
- package/lib/tab/index.d.ts +118 -0
- package/lib/tab/index.js +208 -0
- package/lib/tab/themes/halo/dark/index.js +4 -0
- package/lib/tab/themes/halo/light/index.js +4 -0
- package/lib/tab/themes/solar/charcoal/index.js +4 -0
- package/lib/tab/themes/solar/pearl/index.js +4 -0
- package/lib/tab-bar/custom-elements.json +52 -0
- package/lib/tab-bar/custom-elements.md +11 -0
- package/lib/tab-bar/helpers/animate.d.ts +16 -0
- package/lib/tab-bar/helpers/animate.js +53 -0
- package/lib/tab-bar/index.d.ts +108 -0
- package/lib/tab-bar/index.js +218 -0
- package/lib/tab-bar/themes/halo/dark/index.js +4 -0
- package/lib/tab-bar/themes/halo/light/index.js +4 -0
- package/lib/tab-bar/themes/solar/charcoal/index.js +4 -0
- package/lib/tab-bar/themes/solar/pearl/index.js +4 -0
- package/lib/text-field/custom-elements.json +210 -0
- package/lib/text-field/custom-elements.md +37 -0
- package/lib/text-field/index.d.ts +193 -0
- package/lib/text-field/index.js +409 -0
- package/lib/text-field/themes/halo/dark/index.js +3 -0
- package/lib/text-field/themes/halo/light/index.js +3 -0
- package/lib/text-field/themes/solar/charcoal/index.js +3 -0
- package/lib/text-field/themes/solar/pearl/index.js +3 -0
- package/lib/time-picker/custom-elements.json +124 -0
- package/lib/time-picker/custom-elements.md +28 -0
- package/lib/time-picker/index.d.ts +379 -0
- package/lib/time-picker/index.js +775 -0
- package/lib/time-picker/themes/halo/dark/index.js +4 -0
- package/lib/time-picker/themes/halo/light/index.js +4 -0
- package/lib/time-picker/themes/solar/charcoal/index.js +4 -0
- package/lib/time-picker/themes/solar/pearl/index.js +4 -0
- package/lib/toggle/custom-elements.json +82 -0
- package/lib/toggle/custom-elements.md +19 -0
- package/lib/toggle/index.d.ts +86 -0
- package/lib/toggle/index.js +152 -0
- package/lib/toggle/themes/halo/dark/index.js +2 -0
- package/lib/toggle/themes/halo/light/index.js +2 -0
- package/lib/toggle/themes/solar/charcoal/index.js +2 -0
- package/lib/toggle/themes/solar/pearl/index.js +2 -0
- package/lib/tooltip/custom-elements.json +62 -0
- package/lib/tooltip/custom-elements.md +14 -0
- package/lib/tooltip/elements/title-tooltip.d.ts +1 -0
- package/lib/tooltip/elements/title-tooltip.js +18 -0
- package/lib/tooltip/elements/tooltip-element.d.ts +21 -0
- package/lib/tooltip/elements/tooltip-element.js +54 -0
- package/lib/tooltip/helpers/overflow-tooltip.d.ts +9 -0
- package/lib/tooltip/helpers/overflow-tooltip.js +19 -0
- package/lib/tooltip/helpers/renderer.d.ts +8 -0
- package/lib/tooltip/helpers/renderer.js +11 -0
- package/lib/tooltip/helpers/types.d.ts +23 -0
- package/lib/tooltip/helpers/types.js +1 -0
- package/lib/tooltip/index.d.ts +232 -0
- package/lib/tooltip/index.js +477 -0
- package/lib/tooltip/managers/tooltip-manager.d.ts +15 -0
- package/lib/tooltip/managers/tooltip-manager.js +140 -0
- package/lib/tooltip/themes/halo/dark/index.js +3 -0
- package/lib/tooltip/themes/halo/light/index.js +3 -0
- package/lib/tooltip/themes/solar/charcoal/index.js +3 -0
- package/lib/tooltip/themes/solar/pearl/index.js +3 -0
- package/lib/tornado-chart/custom-elements.json +45 -0
- package/lib/tornado-chart/custom-elements.md +18 -0
- package/lib/tornado-chart/elements/tornado-chart.d.ts +78 -0
- package/lib/tornado-chart/elements/tornado-chart.js +122 -0
- package/lib/tornado-chart/elements/tornado-item.d.ts +110 -0
- package/lib/tornado-chart/elements/tornado-item.js +207 -0
- package/lib/tornado-chart/index.d.ts +2 -0
- package/lib/tornado-chart/index.js +2 -0
- package/lib/tornado-chart/themes/halo/dark/index.js +6 -0
- package/lib/tornado-chart/themes/halo/light/index.js +6 -0
- package/lib/tornado-chart/themes/solar/charcoal/index.js +6 -0
- package/lib/tornado-chart/themes/solar/pearl/index.js +6 -0
- package/lib/tree/custom-elements.json +113 -0
- package/lib/tree/custom-elements.md +32 -0
- package/lib/tree/elements/tree-item.d.ts +96 -0
- package/lib/tree/elements/tree-item.js +179 -0
- package/lib/tree/elements/tree.d.ts +201 -0
- package/lib/tree/elements/tree.js +412 -0
- package/lib/tree/helpers/filter.d.ts +8 -0
- package/lib/tree/helpers/filter.js +33 -0
- package/lib/tree/helpers/renderer.d.ts +5 -0
- package/lib/tree/helpers/renderer.js +33 -0
- package/lib/tree/helpers/types.d.ts +25 -0
- package/lib/tree/helpers/types.js +1 -0
- package/lib/tree/index.d.ts +4 -0
- package/lib/tree/index.js +3 -0
- package/lib/tree/managers/tree-manager.d.ts +248 -0
- package/lib/tree/managers/tree-manager.js +395 -0
- package/lib/tree/themes/halo/dark/index.js +7 -0
- package/lib/tree/themes/halo/light/index.js +7 -0
- package/lib/tree/themes/solar/charcoal/index.js +7 -0
- package/lib/tree/themes/solar/pearl/index.js +7 -0
- package/lib/tree-select/custom-elements.json +107 -0
- package/lib/tree-select/custom-elements.md +26 -0
- package/lib/tree-select/helpers/types.d.ts +4 -0
- package/lib/tree-select/helpers/types.js +1 -0
- package/lib/tree-select/index.d.ts +402 -0
- package/lib/tree-select/index.js +890 -0
- package/lib/tree-select/themes/halo/dark/index.js +12 -0
- package/lib/tree-select/themes/halo/light/index.js +12 -0
- package/lib/tree-select/themes/solar/charcoal/index.js +12 -0
- package/lib/tree-select/themes/solar/pearl/index.js +12 -0
- package/lib/version.d.ts +1 -0
- package/lib/version.js +1 -0
- package/package.json +298 -15
|
@@ -0,0 +1,1164 @@
|
|
|
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 { query } from '@refinitiv-ui/core/lib/decorators/query.js';
|
|
6
|
+
import { ifDefined } from '@refinitiv-ui/core/lib/directives/if-defined.js';
|
|
7
|
+
import { VERSION } from '../version.js';
|
|
8
|
+
import '../calendar/index.js';
|
|
9
|
+
import '../icon/index.js';
|
|
10
|
+
import '../overlay/index.js';
|
|
11
|
+
import '../text-field/index.js';
|
|
12
|
+
import '../time-picker/index.js';
|
|
13
|
+
import { translate, getLocale, TranslatePropertyKey } from '@refinitiv-ui/translate';
|
|
14
|
+
import { getDateFNSLocale } from './locales.js';
|
|
15
|
+
import inputFormat from 'date-fns/esm/format/index.js';
|
|
16
|
+
import inputParse from 'date-fns/esm/parse/index.js';
|
|
17
|
+
import isValid from 'date-fns/esm/isValid/index.js';
|
|
18
|
+
import { addMonths, subMonths, isAfter, isBefore, isValidDate, isValidDateTime, DateFormat, DateTimeFormat, parse, format } from '@refinitiv-ui/utils/lib/date.js';
|
|
19
|
+
import { DateTimeSegment, formatToView, getCurrentTime } from './utils.js';
|
|
20
|
+
import { preload } from '../icon/index.js';
|
|
21
|
+
preload('calendar', 'down', 'left', 'right'); /* preload calendar icons for faster loading */
|
|
22
|
+
const POPUP_POSITION = ['bottom-start', 'top-start', 'bottom-end', 'top-end', 'bottom-middle', 'top-middle'];
|
|
23
|
+
const INPUT_FORMAT = {
|
|
24
|
+
DATE: 'dd-MMM-yyyy',
|
|
25
|
+
DATETIME: 'dd-MMM-yyyy HH:mm',
|
|
26
|
+
DATETIME_AM_PM: 'dd-MMM-yyyy hh:mm aaa',
|
|
27
|
+
DATETIME_SECONDS: 'dd-MMM-yyyy HH:mm:ss',
|
|
28
|
+
DATETIME_SECONDS_AM_PM: 'dd-MMM-yyyy hh:mm:ss aaa'
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Control to pick date and time
|
|
32
|
+
*
|
|
33
|
+
* @fires opened-changed - Dispatched when when opened attribute changes internally
|
|
34
|
+
* @fires value-changed - Dispatched when value changes
|
|
35
|
+
* @fires error-changed - Dispatched when error state changes
|
|
36
|
+
* @fires view-changed - Dispatched when internal view changes
|
|
37
|
+
*
|
|
38
|
+
* @attr {boolean} readonly - Set readonly state
|
|
39
|
+
* @prop {boolean} [readonly=false] - Set readonly state
|
|
40
|
+
*
|
|
41
|
+
* @attr {boolean} disabled - Set disabled state
|
|
42
|
+
* @prop {boolean} [disabled=false] - Set disabled state
|
|
43
|
+
*
|
|
44
|
+
* @slots header - Header slot
|
|
45
|
+
* @slots right - Right slot
|
|
46
|
+
* @slots footer - Footer slot
|
|
47
|
+
* @slots left - Left slot
|
|
48
|
+
*/
|
|
49
|
+
let DatetimePicker = class DatetimePicker extends ControlElement {
|
|
50
|
+
constructor() {
|
|
51
|
+
super(...arguments);
|
|
52
|
+
this.lazyRendered = false; /* speed up rendering by not populating popup window on first load */
|
|
53
|
+
this.calendarValues = []; /* used to store date information for calendars */
|
|
54
|
+
this.timepickerValues = []; /* used to store time information for timepickers */
|
|
55
|
+
this.inputValues = []; /* used to formatted datetime value for inputs */
|
|
56
|
+
this.inputSyncing = true; /* true when inputs and pickers are in sync. False while user types in input */
|
|
57
|
+
this._min = '';
|
|
58
|
+
this.minDate = '';
|
|
59
|
+
this._max = '';
|
|
60
|
+
this.maxDate = '';
|
|
61
|
+
/**
|
|
62
|
+
* Only enable weekdays
|
|
63
|
+
*/
|
|
64
|
+
this.weekdaysOnly = false;
|
|
65
|
+
/**
|
|
66
|
+
* Only enable weekends
|
|
67
|
+
*/
|
|
68
|
+
this.weekendsOnly = false;
|
|
69
|
+
/**
|
|
70
|
+
* Custom filter, used for enabling/disabling certain dates
|
|
71
|
+
* @type {DatetimePickerFilter | null}
|
|
72
|
+
*/
|
|
73
|
+
this.filter = null;
|
|
74
|
+
/**
|
|
75
|
+
* Set to switch to range select mode
|
|
76
|
+
*/
|
|
77
|
+
this.range = false;
|
|
78
|
+
this._values = []; /* list of values as passed by the user */
|
|
79
|
+
this._segments = []; /* filtered and processed list of values */
|
|
80
|
+
/**
|
|
81
|
+
* Toggles 12hr time display
|
|
82
|
+
*/
|
|
83
|
+
this.amPm = false;
|
|
84
|
+
/**
|
|
85
|
+
* Flag to show seconds time segment in display.
|
|
86
|
+
* Seconds are automatically shown when `hh:mm:ss` time format is provided as a value.
|
|
87
|
+
*/
|
|
88
|
+
this.showSeconds = false;
|
|
89
|
+
this._placeholder = '';
|
|
90
|
+
/**
|
|
91
|
+
* Toggles the opened state of the list
|
|
92
|
+
*/
|
|
93
|
+
this.opened = false;
|
|
94
|
+
/**
|
|
95
|
+
* Set state to error
|
|
96
|
+
*/
|
|
97
|
+
this.error = false;
|
|
98
|
+
/**
|
|
99
|
+
* Set state to warning
|
|
100
|
+
*/
|
|
101
|
+
this.warning = false;
|
|
102
|
+
/**
|
|
103
|
+
* Only open picker panel when calendar icon is clicked.
|
|
104
|
+
* Clicking on the input will no longer open the picker.
|
|
105
|
+
*/
|
|
106
|
+
this.inputTriggerDisabled = false;
|
|
107
|
+
/**
|
|
108
|
+
* Disable input part of the picker
|
|
109
|
+
*/
|
|
110
|
+
this.inputDisabled = false;
|
|
111
|
+
/**
|
|
112
|
+
* Disable the popup
|
|
113
|
+
*/
|
|
114
|
+
this.popupDisabled = false;
|
|
115
|
+
this._format = '';
|
|
116
|
+
/**
|
|
117
|
+
* Toggle to display the time picker
|
|
118
|
+
*/
|
|
119
|
+
this.timepicker = false;
|
|
120
|
+
/**
|
|
121
|
+
* Display two calendar pickers.
|
|
122
|
+
* @type {"" | "consecutive" | "split"}
|
|
123
|
+
*/
|
|
124
|
+
this.duplex = null;
|
|
125
|
+
this._views = [];
|
|
126
|
+
this._interimSegments = [];
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Element version number
|
|
130
|
+
* @returns version number
|
|
131
|
+
*/
|
|
132
|
+
static get version() {
|
|
133
|
+
return VERSION;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* A `CSSResultGroup` that will be used
|
|
137
|
+
* to style the host, slotted children
|
|
138
|
+
* and the internal template of the element.
|
|
139
|
+
* @return CSS template
|
|
140
|
+
*/
|
|
141
|
+
static get styles() {
|
|
142
|
+
return css `
|
|
143
|
+
:host {
|
|
144
|
+
display: inline-block;
|
|
145
|
+
height: 48px;
|
|
146
|
+
outline: none;
|
|
147
|
+
cursor: text;
|
|
148
|
+
}
|
|
149
|
+
[part=input-wrapper] {
|
|
150
|
+
display: flex;
|
|
151
|
+
flex: 1;
|
|
152
|
+
}
|
|
153
|
+
[part=body] {
|
|
154
|
+
display: flex;
|
|
155
|
+
}
|
|
156
|
+
[part=timepicker-wrapper] {
|
|
157
|
+
display: flex;
|
|
158
|
+
justify-content: space-between;
|
|
159
|
+
}
|
|
160
|
+
[part=timepicker-wrapper]:before,
|
|
161
|
+
[part=timepicker-wrapper]:after {
|
|
162
|
+
content: '';
|
|
163
|
+
}
|
|
164
|
+
[part=input] {
|
|
165
|
+
flex: 1;
|
|
166
|
+
width: auto;
|
|
167
|
+
height: auto;
|
|
168
|
+
padding: 0;
|
|
169
|
+
margin: 0;
|
|
170
|
+
}
|
|
171
|
+
[part=calendar-wrapper] {
|
|
172
|
+
display: inline-flex;
|
|
173
|
+
}
|
|
174
|
+
[part=icon] {
|
|
175
|
+
cursor: pointer;
|
|
176
|
+
}
|
|
177
|
+
:host([popup-disabled]) [part=icon], :host([readonly]) [part=icon] {
|
|
178
|
+
pointer-event: none;
|
|
179
|
+
}
|
|
180
|
+
`;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Set minimum date
|
|
184
|
+
* @param min date
|
|
185
|
+
*/
|
|
186
|
+
set min(min) {
|
|
187
|
+
if (!this.isValidValue(min)) {
|
|
188
|
+
this.warnInvalidValue(min);
|
|
189
|
+
min = '';
|
|
190
|
+
}
|
|
191
|
+
const oldMin = this.min;
|
|
192
|
+
if (oldMin !== min) {
|
|
193
|
+
this._min = min;
|
|
194
|
+
this.minDate = min ? format(parse(min), DateFormat.yyyyMMdd) : '';
|
|
195
|
+
this.requestUpdate('min', oldMin);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
get min() {
|
|
199
|
+
return this._min;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Set maximum date
|
|
203
|
+
* @param max date
|
|
204
|
+
*/
|
|
205
|
+
set max(max) {
|
|
206
|
+
if (!this.isValidValue(max)) {
|
|
207
|
+
this.warnInvalidValue(max);
|
|
208
|
+
max = '';
|
|
209
|
+
}
|
|
210
|
+
const oldMax = this.max;
|
|
211
|
+
if (oldMax !== max) {
|
|
212
|
+
this._max = max;
|
|
213
|
+
this.maxDate = max ? format(parse(max), DateFormat.yyyyMMdd) : '';
|
|
214
|
+
this.requestUpdate('max', oldMax);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
get max() {
|
|
218
|
+
return this._max;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Set to switch to multiple select mode
|
|
222
|
+
* @ignore
|
|
223
|
+
* @param multiple Multiple
|
|
224
|
+
*/
|
|
225
|
+
/* istanbul ignore next */
|
|
226
|
+
set multiple(multiple) {
|
|
227
|
+
new WarningNotice('multiple is not currently supported').show();
|
|
228
|
+
}
|
|
229
|
+
get multiple() {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Current date time value
|
|
234
|
+
* @param value Calendar value
|
|
235
|
+
*/
|
|
236
|
+
set value(value) {
|
|
237
|
+
this.values = value ? [value] : [];
|
|
238
|
+
}
|
|
239
|
+
get value() {
|
|
240
|
+
return this.values[0] || '';
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Set multiple selected values
|
|
244
|
+
* @param values Values to set
|
|
245
|
+
* @type {string[]}
|
|
246
|
+
*/
|
|
247
|
+
set values(values) {
|
|
248
|
+
const oldValues = this._values;
|
|
249
|
+
if (String(oldValues) !== String(values)) {
|
|
250
|
+
this._values = values;
|
|
251
|
+
this.valuesToSegments();
|
|
252
|
+
this.requestUpdate('_values', oldValues); /* segments are populated in update */
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
get values() {
|
|
256
|
+
return this._segments.map(segment => segment.value);
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Placeholder to display when no value is set
|
|
260
|
+
* @param placeholder Placeholder
|
|
261
|
+
*/
|
|
262
|
+
set placeholder(placeholder) {
|
|
263
|
+
const oldPlaceholder = this._placeholder;
|
|
264
|
+
if (oldPlaceholder !== placeholder) {
|
|
265
|
+
this._placeholder = placeholder;
|
|
266
|
+
this.requestUpdate('placeholder', oldPlaceholder);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
get placeholder() {
|
|
270
|
+
return this._placeholder || this.format;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Set the datetime format
|
|
274
|
+
* Based on dane-fns datetime formats
|
|
275
|
+
* @param format Date format
|
|
276
|
+
*/
|
|
277
|
+
set format(format) {
|
|
278
|
+
const oldFormat = this._format;
|
|
279
|
+
if (oldFormat !== format) {
|
|
280
|
+
this._format = format;
|
|
281
|
+
this.requestUpdate('format', oldFormat);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
get format() {
|
|
285
|
+
return this._format || (this.timepicker
|
|
286
|
+
? (this.showSeconds
|
|
287
|
+
? (this.amPm ? INPUT_FORMAT.DATETIME_SECONDS_AM_PM : INPUT_FORMAT.DATETIME_SECONDS)
|
|
288
|
+
: (this.amPm ? INPUT_FORMAT.DATETIME_AM_PM : INPUT_FORMAT.DATETIME))
|
|
289
|
+
: INPUT_FORMAT.DATE);
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Set the current calendar view.
|
|
293
|
+
* Accepted format: 'yyyy-MM'
|
|
294
|
+
* @param view view date
|
|
295
|
+
*/
|
|
296
|
+
set view(view) {
|
|
297
|
+
this.views = view ? [view] : [];
|
|
298
|
+
}
|
|
299
|
+
get view() {
|
|
300
|
+
return this.views[0] || '';
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Set the current calendar views for duplex mode
|
|
304
|
+
* Accepted format: 'yyyy-MM'
|
|
305
|
+
* @param views view dates
|
|
306
|
+
* @type {string[]}
|
|
307
|
+
*/
|
|
308
|
+
set views(views) {
|
|
309
|
+
const oldViews = this._views;
|
|
310
|
+
views = this.filterAndWarnInvalidViews(views);
|
|
311
|
+
if (oldViews.toString() !== views.toString()) {
|
|
312
|
+
this._views = views;
|
|
313
|
+
this.requestUpdate('views', oldViews);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
get views() {
|
|
317
|
+
if (this._views.length) {
|
|
318
|
+
return this._views;
|
|
319
|
+
}
|
|
320
|
+
const now = new Date();
|
|
321
|
+
const from = this.values[0];
|
|
322
|
+
if (!this.isDuplex()) {
|
|
323
|
+
return [formatToView(from || now)];
|
|
324
|
+
}
|
|
325
|
+
const to = this.values[1];
|
|
326
|
+
// default duplex mode
|
|
327
|
+
if (this.isDuplexConsecutive() || !from || !to || formatToView(from) === formatToView(to) || isBefore(to, from)) {
|
|
328
|
+
return this.composeViews(formatToView(from || to || now), !from && to ? 1 : 0, []);
|
|
329
|
+
}
|
|
330
|
+
// duplex split if as from and to
|
|
331
|
+
return [formatToView(from), formatToView(to)];
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Validates the input, marking the element as invalid if its value does not meet the validation criteria.
|
|
335
|
+
* @returns {void}
|
|
336
|
+
*/
|
|
337
|
+
validateInput() {
|
|
338
|
+
const hasError = this.hasError();
|
|
339
|
+
if (this.error !== hasError) {
|
|
340
|
+
this.error = hasError;
|
|
341
|
+
this.notifyPropertyChange('error', this.error);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Updates the element
|
|
346
|
+
* @param changedProperties Properties that has changed
|
|
347
|
+
* @returns {void}
|
|
348
|
+
*/
|
|
349
|
+
update(changedProperties) {
|
|
350
|
+
if (changedProperties.has('opened') && this.opened) {
|
|
351
|
+
this.lazyRendered = true;
|
|
352
|
+
}
|
|
353
|
+
// make sure to close popup for disabled
|
|
354
|
+
if (this.opened && !this.canOpenPopup) {
|
|
355
|
+
this.opened = false; /* this cannot be nor stopped nor listened */
|
|
356
|
+
}
|
|
357
|
+
if (changedProperties.has('_values') || changedProperties.has(TranslatePropertyKey)) {
|
|
358
|
+
this.syncInputValues();
|
|
359
|
+
}
|
|
360
|
+
if (this.shouldValidateValue(changedProperties)) {
|
|
361
|
+
this.validateInput();
|
|
362
|
+
}
|
|
363
|
+
super.update(changedProperties);
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Called after the component is first rendered
|
|
367
|
+
* @param changedProperties Properties which have changed
|
|
368
|
+
* @returns {void}
|
|
369
|
+
*/
|
|
370
|
+
firstUpdated(changedProperties) {
|
|
371
|
+
super.firstUpdated(changedProperties);
|
|
372
|
+
this.addEventListener('keydown', this.onKeyDown);
|
|
373
|
+
this.addEventListener('tap', this.onTap);
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Overwrite validation method for value
|
|
377
|
+
*
|
|
378
|
+
* @param value value
|
|
379
|
+
* @returns {boolean} result
|
|
380
|
+
*/
|
|
381
|
+
isValidValue(value) {
|
|
382
|
+
if (value === '') {
|
|
383
|
+
return true;
|
|
384
|
+
}
|
|
385
|
+
// Need to check for the attribute to cover the case when
|
|
386
|
+
// timepicker and value attributes are set
|
|
387
|
+
return (this.timepicker || this.hasAttribute('timepicker'))
|
|
388
|
+
? isValidDateTime(value)
|
|
389
|
+
: isValidDate(value, DateFormat.yyyyMMdd);
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Used to show a warning when the value does not pass the validation
|
|
393
|
+
* @param value that is invalid
|
|
394
|
+
* @returns {void}
|
|
395
|
+
*/
|
|
396
|
+
warnInvalidValue(value) {
|
|
397
|
+
new WarningNotice(`The specified value "${value}" does not conform to the required format. The format is ${this.timepicker ? '"yyyy-MM-ddThh:mm" followed by optional ":ss" or ":ss.SSS"' : '"yyyy-MM-dd"'}.`).show();
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* Show invalid view message
|
|
401
|
+
* @param value Invalid value
|
|
402
|
+
* @returns {void}
|
|
403
|
+
*/
|
|
404
|
+
warnInvalidView(value) {
|
|
405
|
+
new WarningNotice(`The specified value "${value}" does not conform to the required format. The format is "yyyy-MM".`).show();
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Convert value string array to date segments
|
|
409
|
+
* Warn invalid value if passed value does not confirm a segment
|
|
410
|
+
* @returns {void}
|
|
411
|
+
*/
|
|
412
|
+
valuesToSegments() {
|
|
413
|
+
const newSegments = this.filterAndWarnInvalidValues(this._values).map(value => DateTimeSegment.fromString(value));
|
|
414
|
+
this._segments = newSegments;
|
|
415
|
+
this.interimSegments = newSegments;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Check if the value needs re-validation against min/max and format
|
|
419
|
+
* @param changedProperties Properties which have changed
|
|
420
|
+
* @returns needs re-validation
|
|
421
|
+
*/
|
|
422
|
+
shouldValidateValue(changedProperties) {
|
|
423
|
+
// do not validate default value
|
|
424
|
+
if (changedProperties.has('_values') && changedProperties.get('_values') !== undefined
|
|
425
|
+
|| changedProperties.has('min') && changedProperties.get('min') !== undefined
|
|
426
|
+
|| changedProperties.has('max') && changedProperties.get('max') !== undefined
|
|
427
|
+
|| changedProperties.has('showSeconds') && changedProperties.get('showSeconds') !== undefined) {
|
|
428
|
+
return true;
|
|
429
|
+
}
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* A helper method to make sure that only valid values are passed
|
|
434
|
+
* Warn if passed value is invalid
|
|
435
|
+
* @param values Values to check
|
|
436
|
+
* @returns Filtered collection of values
|
|
437
|
+
*/
|
|
438
|
+
filterAndWarnInvalidValues(values) {
|
|
439
|
+
return values.map(value => {
|
|
440
|
+
if (this.isValidValue(value)) {
|
|
441
|
+
return value;
|
|
442
|
+
}
|
|
443
|
+
this.warnInvalidValue(value);
|
|
444
|
+
return '';
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* A helper method to make sure that only valid views are passed
|
|
449
|
+
* Warn if passed view is invalid
|
|
450
|
+
* @param views Views to check
|
|
451
|
+
* @returns Filtered collection of values
|
|
452
|
+
*/
|
|
453
|
+
filterAndWarnInvalidViews(views) {
|
|
454
|
+
for (let i = 0; i < views.length; i += 1) {
|
|
455
|
+
const view = views[i];
|
|
456
|
+
if (!isValidDate(view, DateFormat.yyyyMM)) {
|
|
457
|
+
this.warnInvalidView(view);
|
|
458
|
+
return []; /* if at least one view is invalid, do not care about the rest to avoid empty views */
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
return views;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Return true if calendar is in duplex mode
|
|
465
|
+
* @returns duplex
|
|
466
|
+
*/
|
|
467
|
+
isDuplex() {
|
|
468
|
+
return this.isDuplexSplit() || this.isDuplexConsecutive();
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Return true if calendar is in duplex split mode
|
|
472
|
+
* @returns duplex split
|
|
473
|
+
*/
|
|
474
|
+
isDuplexSplit() {
|
|
475
|
+
return this.duplex === 'split';
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Return true if calendar is in duplex consecutive mode
|
|
479
|
+
* @returns duplex consecutive
|
|
480
|
+
*/
|
|
481
|
+
isDuplexConsecutive() {
|
|
482
|
+
return this.duplex === '' || this.duplex === 'consecutive';
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Stop syncing input values and picker values
|
|
486
|
+
* @returns {void}
|
|
487
|
+
*/
|
|
488
|
+
disableInputSync() {
|
|
489
|
+
this.inputSyncing = false;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* Start syncing input values and picker values
|
|
493
|
+
* @returns {void}
|
|
494
|
+
*/
|
|
495
|
+
enableInputSync() {
|
|
496
|
+
this.inputSyncing = true;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Synchronise input values and values
|
|
500
|
+
* @return {void}
|
|
501
|
+
*/
|
|
502
|
+
syncInputValues() {
|
|
503
|
+
if (!this.inputSyncing) {
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
// input values cannot be populated off interim segments as require a valid date
|
|
507
|
+
// date-fns formats to local if there is time info
|
|
508
|
+
this.inputValues = this._segments.map(segment => this.formatSegment(segment));
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Format date segment according to format and locale
|
|
512
|
+
* @param segment Date segment
|
|
513
|
+
* @returns formatted string
|
|
514
|
+
*/
|
|
515
|
+
formatSegment(segment) {
|
|
516
|
+
return segment.value ? inputFormat(segment.getTime(), this.format, {
|
|
517
|
+
locale: getDateFNSLocale(getLocale(this))
|
|
518
|
+
}) : '';
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Construct view collection
|
|
522
|
+
* @param view The view that has changed
|
|
523
|
+
* @param index View index (0 - single, or from); (1 - to)
|
|
524
|
+
* @param [views=this.views] The original views collection
|
|
525
|
+
* @returns the new view collection
|
|
526
|
+
*/
|
|
527
|
+
composeViews(view, index, views = this.views) {
|
|
528
|
+
view = formatToView(view);
|
|
529
|
+
if (!this.isDuplex()) {
|
|
530
|
+
return [view];
|
|
531
|
+
}
|
|
532
|
+
if (this.isDuplexConsecutive()) {
|
|
533
|
+
if (index === 0) { /* from */
|
|
534
|
+
return [view, formatToView(addMonths(view, 1))];
|
|
535
|
+
}
|
|
536
|
+
else { /* to */
|
|
537
|
+
return [formatToView(subMonths(view, 1)), view];
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
// duplex split
|
|
541
|
+
if (index === 0) { /* from. to must be after or the same */
|
|
542
|
+
let after = views[1] || addMonths(view, 1);
|
|
543
|
+
if (isBefore(after, view)) {
|
|
544
|
+
after = view;
|
|
545
|
+
}
|
|
546
|
+
return [view, formatToView(after)];
|
|
547
|
+
}
|
|
548
|
+
if (index === 1) { /* to. from must be before or the same */
|
|
549
|
+
let before = views[0] || subMonths(view, 1);
|
|
550
|
+
if (isAfter(before, view)) {
|
|
551
|
+
before = view;
|
|
552
|
+
}
|
|
553
|
+
return [formatToView(before), view];
|
|
554
|
+
}
|
|
555
|
+
return [];
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* An interim collection of segments to push values when all parts are populated
|
|
559
|
+
* and validated
|
|
560
|
+
* @param segments Segments
|
|
561
|
+
*/
|
|
562
|
+
set interimSegments(segments) {
|
|
563
|
+
const interimSegments = segments.map(segment => DateTimeSegment.fromDateTimeSegment(segment));
|
|
564
|
+
this._interimSegments = interimSegments;
|
|
565
|
+
// cannot populate calendar if from is after to, it looks broken
|
|
566
|
+
this.calendarValues = this.isFromBeforeTo() ? interimSegments.map(segment => segment.dateSegment) : [];
|
|
567
|
+
this.timepickerValues = interimSegments.map(segment => segment.timeSegment);
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Get interim segments. These are free to modify
|
|
571
|
+
* @returns interim segments
|
|
572
|
+
*/
|
|
573
|
+
get interimSegments() {
|
|
574
|
+
return this._interimSegments;
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Submit interim segments to values.
|
|
578
|
+
* Notify value-changed event.
|
|
579
|
+
* @returns true if values have changed. False otherwise
|
|
580
|
+
*/
|
|
581
|
+
submitInterimSegments() {
|
|
582
|
+
const oldSegments = this._segments;
|
|
583
|
+
const newSegments = this.interimSegments;
|
|
584
|
+
// compare if different
|
|
585
|
+
if (oldSegments.toString() === newSegments.toString()) {
|
|
586
|
+
return false;
|
|
587
|
+
}
|
|
588
|
+
const newValues = newSegments.map(segment => segment.value);
|
|
589
|
+
// validate
|
|
590
|
+
for (let i = 0; i < newValues.length; i += 1) { /* need this step in case timepicker is not populated */
|
|
591
|
+
if (!this.isValidValue(newValues[i])) {
|
|
592
|
+
return false;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
this.notifyValuesChange(newValues);
|
|
596
|
+
return true;
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* Notify that values array has been changed
|
|
600
|
+
* @param values A collection of string dates
|
|
601
|
+
* @returns {void}
|
|
602
|
+
*/
|
|
603
|
+
notifyValuesChange(values) {
|
|
604
|
+
if (this.values.toString() !== values.toString()) {
|
|
605
|
+
this.values = values;
|
|
606
|
+
this.notifyPropertyChange('value', this.value);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Notify that views array has been changed
|
|
611
|
+
* @param views A collection of string dates
|
|
612
|
+
* @returns {void}
|
|
613
|
+
*/
|
|
614
|
+
notifyViewsChange(views) {
|
|
615
|
+
if (this._views.toString() !== views.toString()) {
|
|
616
|
+
this.views = views;
|
|
617
|
+
this.notifyPropertyChange('view', this.view);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Handles key input on datetime picker
|
|
622
|
+
* @param event Key down event object
|
|
623
|
+
* @returns {void}
|
|
624
|
+
*/
|
|
625
|
+
onKeyDown(event) {
|
|
626
|
+
switch (event.key) {
|
|
627
|
+
case 'Down':
|
|
628
|
+
case 'ArrowDown':
|
|
629
|
+
this.setOpened(true);
|
|
630
|
+
break;
|
|
631
|
+
case 'Up':
|
|
632
|
+
case 'ArrowUp':
|
|
633
|
+
!event.defaultPrevented && this.setOpened(false);
|
|
634
|
+
break;
|
|
635
|
+
default:
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
event.preventDefault();
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Handles key input on calendar picker
|
|
642
|
+
* @param event Key down event object
|
|
643
|
+
* @returns {void}
|
|
644
|
+
*/
|
|
645
|
+
onCalendarKeyDown(event) {
|
|
646
|
+
switch (event.key) {
|
|
647
|
+
case 'Esc':
|
|
648
|
+
case 'Escape':
|
|
649
|
+
this.resetViews();
|
|
650
|
+
this.setOpened(false);
|
|
651
|
+
break;
|
|
652
|
+
default:
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
event.preventDefault();
|
|
656
|
+
}
|
|
657
|
+
/**
|
|
658
|
+
* Handles key input on text field
|
|
659
|
+
* @param event Key down event object
|
|
660
|
+
* @returns {void}
|
|
661
|
+
*/
|
|
662
|
+
onInputKeyDown(event) {
|
|
663
|
+
switch (event.key) {
|
|
664
|
+
case 'Esc':
|
|
665
|
+
case 'Escape':
|
|
666
|
+
!this.opened && this.blur();
|
|
667
|
+
this.setOpened(false);
|
|
668
|
+
break;
|
|
669
|
+
case 'Enter':
|
|
670
|
+
this.toggleOpened();
|
|
671
|
+
break;
|
|
672
|
+
default:
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
event.preventDefault();
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* Run on tap event
|
|
679
|
+
* @param event Tap event
|
|
680
|
+
* @returns {void}
|
|
681
|
+
*/
|
|
682
|
+
onTap(event) {
|
|
683
|
+
const path = event.composedPath();
|
|
684
|
+
if (this.popupEl && path.includes(this.popupEl)) {
|
|
685
|
+
return; /* popup is managed separately */
|
|
686
|
+
}
|
|
687
|
+
if (path.includes(this.iconEl)) {
|
|
688
|
+
this.toggleOpened();
|
|
689
|
+
}
|
|
690
|
+
else if (!this.inputTriggerDisabled) {
|
|
691
|
+
this.setOpened(true);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* Run when popup opened flag changes
|
|
696
|
+
* @param event opened-change event
|
|
697
|
+
* @returns {void}
|
|
698
|
+
*/
|
|
699
|
+
onPopupOpenedChanged(event) {
|
|
700
|
+
event.preventDefault(); /* re-target opened changed event */
|
|
701
|
+
this.setOpened(event.detail.value);
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* Run on calendar view-changed event
|
|
705
|
+
* @param event view-changed event
|
|
706
|
+
* @returns {void}
|
|
707
|
+
*/
|
|
708
|
+
onCalendarViewChanged(event) {
|
|
709
|
+
const index = event.target === this.calendarToEl ? 1 : 0; /* 0 - from, single; 1 - to */
|
|
710
|
+
const view = event.detail.value;
|
|
711
|
+
this.notifyViewsChange(this.composeViews(view, index));
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Run on calendar value-changed event
|
|
715
|
+
* @param event value-changed event
|
|
716
|
+
* @returns {void}
|
|
717
|
+
*/
|
|
718
|
+
onCalendarValueChanged(event) {
|
|
719
|
+
var _a, _b;
|
|
720
|
+
const values = event.target.values;
|
|
721
|
+
this.interimSegments = values.map((value, index) => {
|
|
722
|
+
const segment = this.interimSegments[index] || new DateTimeSegment();
|
|
723
|
+
segment.dateSegment = value;
|
|
724
|
+
if (this.timepicker && !segment.timeSegment) {
|
|
725
|
+
segment.timeSegment = getCurrentTime(this.showSeconds); /* populate time, as otherwise time picker looks broken */
|
|
726
|
+
}
|
|
727
|
+
return segment;
|
|
728
|
+
});
|
|
729
|
+
this.submitInterimSegments();
|
|
730
|
+
// in duplex mode, avoid jumping on views
|
|
731
|
+
// Therefore if any of values have changed, save the current view
|
|
732
|
+
if (this.isDuplex() && this.calendarEl && this.calendarToEl) {
|
|
733
|
+
this.notifyViewsChange([(_a = this.calendarEl) === null || _a === void 0 ? void 0 : _a.view, (_b = this.calendarToEl) === null || _b === void 0 ? void 0 : _b.view]);
|
|
734
|
+
}
|
|
735
|
+
// Close popup if there is no time picker
|
|
736
|
+
const newValues = this.values;
|
|
737
|
+
if (!this.timepicker && newValues[0] && (this.range ? newValues[1] : true)) {
|
|
738
|
+
this.setOpened(false);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* Run on time-picker value-changed event
|
|
743
|
+
* @param event value-changed event
|
|
744
|
+
* @returns {void}
|
|
745
|
+
*/
|
|
746
|
+
onTimePickerValueChanged(event) {
|
|
747
|
+
const target = event.target;
|
|
748
|
+
const index = target === this.timepickerToEl ? 1 : 0; /* 0 - from, single; 1 - to */
|
|
749
|
+
const segment = this.interimSegments[index] || new DateTimeSegment();
|
|
750
|
+
segment.timeSegment = target.value;
|
|
751
|
+
this.interimSegments[index] = segment;
|
|
752
|
+
this.submitInterimSegments();
|
|
753
|
+
}
|
|
754
|
+
/**
|
|
755
|
+
* Run on input focus
|
|
756
|
+
* @returns {void}
|
|
757
|
+
*/
|
|
758
|
+
onInputFocus() {
|
|
759
|
+
this.disableInputSync();
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* Run on input blur
|
|
763
|
+
* @param event blur event
|
|
764
|
+
* @returns {void}
|
|
765
|
+
*/
|
|
766
|
+
onInputBlur(event) {
|
|
767
|
+
this.enableInputSync();
|
|
768
|
+
// remove all code once strict formatting is supported in date-fns
|
|
769
|
+
const index = event.target === this.inputToEl ? 1 : 0;
|
|
770
|
+
const segment = this._segments[index];
|
|
771
|
+
if (!segment || !segment.value) {
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
774
|
+
const formattedValue = segment ? this.formatSegment(segment) : '';
|
|
775
|
+
if (formattedValue !== this.inputValues[index]) {
|
|
776
|
+
const inputValues = [...this.inputValues];
|
|
777
|
+
inputValues[index] = formattedValue;
|
|
778
|
+
this.inputValues = inputValues;
|
|
779
|
+
this.requestUpdate();
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
/**
|
|
783
|
+
* Run on input value-changed event
|
|
784
|
+
* @param event value-changed event
|
|
785
|
+
* @returns {void}
|
|
786
|
+
*/
|
|
787
|
+
onInputValueChanged(event) {
|
|
788
|
+
const target = event.target;
|
|
789
|
+
const index = target === this.inputToEl ? 1 : 0; /* 0 - from, single; 1 - to */
|
|
790
|
+
const inputValue = target.value;
|
|
791
|
+
const inputValues = [...this.inputValues];
|
|
792
|
+
inputValues[index] = inputValue;
|
|
793
|
+
this.inputValues = inputValues;
|
|
794
|
+
let dateString = '';
|
|
795
|
+
if (inputValue) {
|
|
796
|
+
const recoveryDate = (this.interimSegments[index] || new DateTimeSegment()).getTime();
|
|
797
|
+
const date = inputParse(inputValue, this.format, recoveryDate, {
|
|
798
|
+
locale: getDateFNSLocale(getLocale(this))
|
|
799
|
+
});
|
|
800
|
+
if (isValid(date)) {
|
|
801
|
+
dateString = inputFormat(date, this.timepicker ? this.showSeconds ? DateTimeFormat.yyyMMddTHHmmss : DateTimeFormat.yyyMMddTHHmm : DateFormat.yyyyMMdd);
|
|
802
|
+
this.resetViews(); /* user input should be treated similar to manually switching the views */
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
else {
|
|
806
|
+
this.resetViews();
|
|
807
|
+
}
|
|
808
|
+
this.interimSegments[index] = DateTimeSegment.fromString(dateString);
|
|
809
|
+
this.submitInterimSegments();
|
|
810
|
+
this.validateInput();
|
|
811
|
+
}
|
|
812
|
+
/**
|
|
813
|
+
* Check if input format conforms to value format
|
|
814
|
+
* @returns true if valid format
|
|
815
|
+
*/
|
|
816
|
+
isValidFormat() {
|
|
817
|
+
const inputValues = this.inputValues;
|
|
818
|
+
const values = this.values;
|
|
819
|
+
// No need to format values to validate.
|
|
820
|
+
// If input is invalid, value is not populated
|
|
821
|
+
for (let i = 0; i < inputValues.length; i += 1) {
|
|
822
|
+
if (inputValues[i] && !values[i]) {
|
|
823
|
+
return false;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
return true;
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Check if `value` is within `min` and `max`
|
|
830
|
+
* @returns true if value is within
|
|
831
|
+
*/
|
|
832
|
+
isValueWithinMinMax() {
|
|
833
|
+
if (this.min || this.max) {
|
|
834
|
+
const minTime = this.min ? parse(this.min).getTime() : -Infinity;
|
|
835
|
+
const maxTime = this.max ? parse(this.max).getTime() : Infinity;
|
|
836
|
+
for (let i = 0; i < this.values.length; i += 1) {
|
|
837
|
+
const valueTime = parse(this.values[i]).getTime();
|
|
838
|
+
if (minTime > valueTime || maxTime < valueTime) {
|
|
839
|
+
return false;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
return true;
|
|
844
|
+
}
|
|
845
|
+
/**
|
|
846
|
+
* Check if `from` is before or the same as `to`
|
|
847
|
+
* @returns true if `from` is before or the same as `to`
|
|
848
|
+
*/
|
|
849
|
+
isFromBeforeTo() {
|
|
850
|
+
if (this.range) {
|
|
851
|
+
const from = this.values[0];
|
|
852
|
+
const to = this.values[1];
|
|
853
|
+
if (from && to) {
|
|
854
|
+
if (parse(from).getTime() > parse(to).getTime()) {
|
|
855
|
+
return false;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
return true;
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Check if datetime picker has an error
|
|
863
|
+
* @returns true if error
|
|
864
|
+
*/
|
|
865
|
+
hasError() {
|
|
866
|
+
return !(this.isValidFormat() && this.isValueWithinMinMax() && this.isFromBeforeTo());
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Toggles the opened state of the list
|
|
870
|
+
* @returns {void}
|
|
871
|
+
*/
|
|
872
|
+
toggleOpened() {
|
|
873
|
+
this.setOpened(!this.opened);
|
|
874
|
+
}
|
|
875
|
+
/**
|
|
876
|
+
* Return true if popup can be opened
|
|
877
|
+
*/
|
|
878
|
+
get canOpenPopup() {
|
|
879
|
+
return !(this.disabled || this.readonly || this.popupDisabled);
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Set opened state with event
|
|
883
|
+
* @param opened True if opened
|
|
884
|
+
* @returns {void}
|
|
885
|
+
*/
|
|
886
|
+
setOpened(opened) {
|
|
887
|
+
if (opened && !this.canOpenPopup) { /* never allow to open popup if cannot do so */
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
if (this.opened !== opened && this.notifyPropertyChange('opened', opened, true)) {
|
|
891
|
+
this.opened = opened;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
/**
|
|
895
|
+
* Reset views to default
|
|
896
|
+
* @returns {void}
|
|
897
|
+
*/
|
|
898
|
+
resetViews() {
|
|
899
|
+
this.notifyViewsChange([]);
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* Get time picker template
|
|
903
|
+
* @param id Timepicker identifier
|
|
904
|
+
* @param value Time picker value
|
|
905
|
+
* @returns template result
|
|
906
|
+
*/
|
|
907
|
+
getTimepickerTemplate(id, value = '') {
|
|
908
|
+
return html `<ef-time-picker
|
|
909
|
+
id="${id}"
|
|
910
|
+
part="time-picker"
|
|
911
|
+
.showSeconds=${this.showSeconds}
|
|
912
|
+
.amPm=${this.amPm}
|
|
913
|
+
.value=${value}
|
|
914
|
+
@value-changed=${this.onTimePickerValueChanged}></ef-time-picker>`;
|
|
915
|
+
}
|
|
916
|
+
/**
|
|
917
|
+
* Get calendar template
|
|
918
|
+
* @param id Calendar identifier
|
|
919
|
+
* @param view Calendar view
|
|
920
|
+
* @returns template result
|
|
921
|
+
*/
|
|
922
|
+
getCalendarTemplate(id, view = '') {
|
|
923
|
+
return html `<ef-calendar
|
|
924
|
+
part="calendar"
|
|
925
|
+
id=${id}
|
|
926
|
+
lang=${ifDefined(this.lang || undefined)}
|
|
927
|
+
.fillCells=${!this.isDuplex()}
|
|
928
|
+
.range=${this.range}
|
|
929
|
+
.multiple=${this.multiple}
|
|
930
|
+
.min=${this.minDate}
|
|
931
|
+
.max=${this.maxDate}
|
|
932
|
+
.weekdaysOnly=${this.weekdaysOnly}
|
|
933
|
+
.weekendsOnly=${this.weekendsOnly}
|
|
934
|
+
.firstDayOfWeek=${ifDefined(this.firstDayOfWeek)}
|
|
935
|
+
.values=${this.calendarValues}
|
|
936
|
+
.filter=${this.filter}
|
|
937
|
+
.view=${view}
|
|
938
|
+
@keydown=${this.onCalendarKeyDown}
|
|
939
|
+
@view-changed=${this.onCalendarViewChanged}
|
|
940
|
+
@value-changed=${this.onCalendarValueChanged}></ef-calendar>`;
|
|
941
|
+
}
|
|
942
|
+
/**
|
|
943
|
+
* Get calendar templates
|
|
944
|
+
*/
|
|
945
|
+
get calendarsTemplate() {
|
|
946
|
+
return html `
|
|
947
|
+
${this.getCalendarTemplate('calendar', this.views[0])}
|
|
948
|
+
${this.isDuplex() ? this.getCalendarTemplate('calendar-to', this.views[1]) : undefined}
|
|
949
|
+
`;
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Get timepicker templates
|
|
953
|
+
*/
|
|
954
|
+
get timepickersTemplate() {
|
|
955
|
+
// TODO: how can we add support timepicker with multiple?
|
|
956
|
+
const values = this.timepickerValues;
|
|
957
|
+
return html `
|
|
958
|
+
${this.getTimepickerTemplate('timepicker', values[0])}
|
|
959
|
+
${this.range ? html `<div part="input-separator"></div>` : undefined}
|
|
960
|
+
${this.range ? this.getTimepickerTemplate('timepicker-to', values[1]) : undefined}
|
|
961
|
+
`;
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* Get input template
|
|
965
|
+
* @param id Input identifier
|
|
966
|
+
* @param value Input value
|
|
967
|
+
* @returns template result
|
|
968
|
+
*/
|
|
969
|
+
getInputTemplate(id, value = '') {
|
|
970
|
+
return html `
|
|
971
|
+
<ef-text-field
|
|
972
|
+
id=${id}
|
|
973
|
+
part="input"
|
|
974
|
+
transparent
|
|
975
|
+
?disabled="${this.disabled}"
|
|
976
|
+
?readonly="${this.readonly || this.inputDisabled}"
|
|
977
|
+
.value=${value}
|
|
978
|
+
.placeholder="${this.placeholder}"
|
|
979
|
+
@focus=${this.onInputFocus}
|
|
980
|
+
@blur=${this.onInputBlur}
|
|
981
|
+
@keydown=${this.onInputKeyDown}
|
|
982
|
+
@value-changed=${this.onInputValueChanged}></ef-text-field>
|
|
983
|
+
`;
|
|
984
|
+
}
|
|
985
|
+
/**
|
|
986
|
+
* Template for rendering an icon
|
|
987
|
+
*/
|
|
988
|
+
get iconTemplate() {
|
|
989
|
+
return html `
|
|
990
|
+
<ef-icon
|
|
991
|
+
part="icon"
|
|
992
|
+
icon="calendar"></ef-icon>
|
|
993
|
+
`;
|
|
994
|
+
}
|
|
995
|
+
/**
|
|
996
|
+
* Template for inputs
|
|
997
|
+
* @returns inputTemplate
|
|
998
|
+
*/
|
|
999
|
+
get inputTemplates() {
|
|
1000
|
+
const values = this.inputValues;
|
|
1001
|
+
return html `
|
|
1002
|
+
<div part="input-wrapper">
|
|
1003
|
+
${this.getInputTemplate('input', values[0])}
|
|
1004
|
+
${this.range ? html `<div part="input-separator"></div>` : undefined}
|
|
1005
|
+
${this.range ? this.getInputTemplate('input-to', values[1]) : undefined}
|
|
1006
|
+
</div>
|
|
1007
|
+
`;
|
|
1008
|
+
}
|
|
1009
|
+
/**
|
|
1010
|
+
* Popup panel template
|
|
1011
|
+
*/
|
|
1012
|
+
get popupTemplate() {
|
|
1013
|
+
if (this.lazyRendered) {
|
|
1014
|
+
return html `<ef-overlay
|
|
1015
|
+
tabindex="0"
|
|
1016
|
+
part="list"
|
|
1017
|
+
with-shadow
|
|
1018
|
+
no-cancel-on-esc-key
|
|
1019
|
+
no-autofocus
|
|
1020
|
+
.delegatesFocus=${true}
|
|
1021
|
+
.focusBoundary=${this}
|
|
1022
|
+
.positionTarget=${this}
|
|
1023
|
+
.position=${POPUP_POSITION}
|
|
1024
|
+
?opened=${this.opened}
|
|
1025
|
+
@opened-changed=${this.onPopupOpenedChanged}>
|
|
1026
|
+
<div><slot name="header"></div>
|
|
1027
|
+
<div part="body">
|
|
1028
|
+
<div><slot name="left"></div>
|
|
1029
|
+
<div part="selectors-wrapper">
|
|
1030
|
+
<div part="calendar-wrapper">
|
|
1031
|
+
${this.calendarsTemplate}
|
|
1032
|
+
</div>
|
|
1033
|
+
${this.timepicker ? html `<div part="timepicker-wrapper">${this.timepickersTemplate}</div>` : undefined}
|
|
1034
|
+
</div>
|
|
1035
|
+
<div><slot name="right"></div>
|
|
1036
|
+
</div>
|
|
1037
|
+
<div><slot name="footer"></div>
|
|
1038
|
+
</ef-overlay>`;
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
/**
|
|
1042
|
+
* A `TemplateResult` that will be used
|
|
1043
|
+
* to render the updated internal template.
|
|
1044
|
+
* @return Render template
|
|
1045
|
+
*/
|
|
1046
|
+
render() {
|
|
1047
|
+
return html `
|
|
1048
|
+
${this.inputTemplates}
|
|
1049
|
+
${this.iconTemplate}
|
|
1050
|
+
${this.popupTemplate}
|
|
1051
|
+
`;
|
|
1052
|
+
}
|
|
1053
|
+
};
|
|
1054
|
+
__decorate([
|
|
1055
|
+
property({ type: String })
|
|
1056
|
+
], DatetimePicker.prototype, "min", null);
|
|
1057
|
+
__decorate([
|
|
1058
|
+
property({ type: String })
|
|
1059
|
+
], DatetimePicker.prototype, "max", null);
|
|
1060
|
+
__decorate([
|
|
1061
|
+
property({ type: Boolean, attribute: 'weekdays-only' })
|
|
1062
|
+
], DatetimePicker.prototype, "weekdaysOnly", void 0);
|
|
1063
|
+
__decorate([
|
|
1064
|
+
property({ type: Boolean, attribute: 'weekends-only' })
|
|
1065
|
+
], DatetimePicker.prototype, "weekendsOnly", void 0);
|
|
1066
|
+
__decorate([
|
|
1067
|
+
property({ attribute: false })
|
|
1068
|
+
], DatetimePicker.prototype, "filter", void 0);
|
|
1069
|
+
__decorate([
|
|
1070
|
+
property({ type: Number, attribute: 'first-day-of-week' })
|
|
1071
|
+
], DatetimePicker.prototype, "firstDayOfWeek", void 0);
|
|
1072
|
+
__decorate([
|
|
1073
|
+
property({ type: Boolean, reflect: true })
|
|
1074
|
+
], DatetimePicker.prototype, "range", void 0);
|
|
1075
|
+
__decorate([
|
|
1076
|
+
property({ type: Boolean })
|
|
1077
|
+
], DatetimePicker.prototype, "multiple", null);
|
|
1078
|
+
__decorate([
|
|
1079
|
+
property({ type: String })
|
|
1080
|
+
], DatetimePicker.prototype, "value", null);
|
|
1081
|
+
__decorate([
|
|
1082
|
+
property({
|
|
1083
|
+
converter: {
|
|
1084
|
+
fromAttribute: function (value) {
|
|
1085
|
+
return value.split(',');
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
})
|
|
1089
|
+
], DatetimePicker.prototype, "values", null);
|
|
1090
|
+
__decorate([
|
|
1091
|
+
property({ type: Boolean, attribute: 'am-pm', reflect: true })
|
|
1092
|
+
], DatetimePicker.prototype, "amPm", void 0);
|
|
1093
|
+
__decorate([
|
|
1094
|
+
property({ type: Boolean, attribute: 'show-seconds', reflect: true })
|
|
1095
|
+
], DatetimePicker.prototype, "showSeconds", void 0);
|
|
1096
|
+
__decorate([
|
|
1097
|
+
property({ type: String })
|
|
1098
|
+
], DatetimePicker.prototype, "placeholder", null);
|
|
1099
|
+
__decorate([
|
|
1100
|
+
property({ type: Boolean, reflect: true })
|
|
1101
|
+
], DatetimePicker.prototype, "opened", void 0);
|
|
1102
|
+
__decorate([
|
|
1103
|
+
property({ type: Boolean, reflect: true })
|
|
1104
|
+
], DatetimePicker.prototype, "error", void 0);
|
|
1105
|
+
__decorate([
|
|
1106
|
+
property({ type: Boolean, reflect: true })
|
|
1107
|
+
], DatetimePicker.prototype, "warning", void 0);
|
|
1108
|
+
__decorate([
|
|
1109
|
+
property({ type: Boolean, attribute: 'input-trigger-disabled' })
|
|
1110
|
+
], DatetimePicker.prototype, "inputTriggerDisabled", void 0);
|
|
1111
|
+
__decorate([
|
|
1112
|
+
property({ type: Boolean, attribute: 'input-disabled', reflect: true })
|
|
1113
|
+
], DatetimePicker.prototype, "inputDisabled", void 0);
|
|
1114
|
+
__decorate([
|
|
1115
|
+
property({ type: Boolean, attribute: 'popup-disabled', reflect: true })
|
|
1116
|
+
], DatetimePicker.prototype, "popupDisabled", void 0);
|
|
1117
|
+
__decorate([
|
|
1118
|
+
property({ type: String })
|
|
1119
|
+
], DatetimePicker.prototype, "format", null);
|
|
1120
|
+
__decorate([
|
|
1121
|
+
property({ type: Boolean, reflect: true })
|
|
1122
|
+
], DatetimePicker.prototype, "timepicker", void 0);
|
|
1123
|
+
__decorate([
|
|
1124
|
+
property({ type: String, reflect: true })
|
|
1125
|
+
], DatetimePicker.prototype, "duplex", void 0);
|
|
1126
|
+
__decorate([
|
|
1127
|
+
property({ type: String })
|
|
1128
|
+
], DatetimePicker.prototype, "view", null);
|
|
1129
|
+
__decorate([
|
|
1130
|
+
property({ attribute: false })
|
|
1131
|
+
], DatetimePicker.prototype, "views", null);
|
|
1132
|
+
__decorate([
|
|
1133
|
+
translate({ mode: 'directive', scope: 'ef-datetime-picker' })
|
|
1134
|
+
], DatetimePicker.prototype, "t", void 0);
|
|
1135
|
+
__decorate([
|
|
1136
|
+
query('[part=icon]', true)
|
|
1137
|
+
], DatetimePicker.prototype, "iconEl", void 0);
|
|
1138
|
+
__decorate([
|
|
1139
|
+
query('[part=list]')
|
|
1140
|
+
], DatetimePicker.prototype, "popupEl", void 0);
|
|
1141
|
+
__decorate([
|
|
1142
|
+
query('#timepicker')
|
|
1143
|
+
], DatetimePicker.prototype, "timepickerEl", void 0);
|
|
1144
|
+
__decorate([
|
|
1145
|
+
query('#timepicker-to')
|
|
1146
|
+
], DatetimePicker.prototype, "timepickerToEl", void 0);
|
|
1147
|
+
__decorate([
|
|
1148
|
+
query('#calendar')
|
|
1149
|
+
], DatetimePicker.prototype, "calendarEl", void 0);
|
|
1150
|
+
__decorate([
|
|
1151
|
+
query('#calendar-to')
|
|
1152
|
+
], DatetimePicker.prototype, "calendarToEl", void 0);
|
|
1153
|
+
__decorate([
|
|
1154
|
+
query('#input')
|
|
1155
|
+
], DatetimePicker.prototype, "inputEl", void 0);
|
|
1156
|
+
__decorate([
|
|
1157
|
+
query('#input-to')
|
|
1158
|
+
], DatetimePicker.prototype, "inputToEl", void 0);
|
|
1159
|
+
DatetimePicker = __decorate([
|
|
1160
|
+
customElement('ef-datetime-picker', {
|
|
1161
|
+
alias: 'emerald-datetime-picker'
|
|
1162
|
+
})
|
|
1163
|
+
], DatetimePicker);
|
|
1164
|
+
export { DatetimePicker };
|