@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,906 @@
|
|
|
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 { ifDefined } from '@refinitiv-ui/core/lib/directives/if-defined.js';
|
|
6
|
+
import { VERSION } from '../version.js';
|
|
7
|
+
import { isIE } from '@refinitiv-ui/utils/lib/browser.js';
|
|
8
|
+
import { DateFormat, format, utcFormat, utcParse, isValidDate, isWeekend, isAfter, isBefore, addMonths, subMonths, isToday, isThisMonth, isThisYear, isSameDay, isSameMonth, isSameYear, toDateSegment } from '@refinitiv-ui/utils/lib/date.js';
|
|
9
|
+
import { monthInfo, weekdaysNames, monthsNames, formatLocaleDate, ViewFormatTranslateParams } from './utils.js';
|
|
10
|
+
import { translate, getLocale, TranslatePropertyKey } from '@refinitiv-ui/translate';
|
|
11
|
+
import { RenderView, FIRST_DAY_OF_WEEK, YEARS_PER_YEAR_VIEW, DAY_VIEW, YEAR_VIEW, MONTH_VIEW } from './constants.js';
|
|
12
|
+
import './locales.js';
|
|
13
|
+
import '../button/index.js';
|
|
14
|
+
/**
|
|
15
|
+
* Standard calendar element
|
|
16
|
+
*
|
|
17
|
+
* @fires value-changed - Fired when the `value` changes.
|
|
18
|
+
* @fires view-changed - Fired when the `view` changes.
|
|
19
|
+
*
|
|
20
|
+
* @attr {boolean} readonly - Set readonly state
|
|
21
|
+
* @prop {boolean} [readonly=false] - Set readonly state
|
|
22
|
+
*
|
|
23
|
+
* @attr {boolean} disabled - Set disabled state
|
|
24
|
+
* @prop {boolean} [disabled=false] - Set disabled state
|
|
25
|
+
*
|
|
26
|
+
* @slot footer - Adds slotted content into the footer of the calendar control
|
|
27
|
+
*/
|
|
28
|
+
let Calendar = class Calendar extends ControlElement {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
this._min = '';
|
|
32
|
+
this._max = '';
|
|
33
|
+
/**
|
|
34
|
+
* Only enable weekdays
|
|
35
|
+
*/
|
|
36
|
+
this.weekdaysOnly = false;
|
|
37
|
+
/**
|
|
38
|
+
* Only enable weekends
|
|
39
|
+
*/
|
|
40
|
+
this.weekendsOnly = false;
|
|
41
|
+
/**
|
|
42
|
+
* Custom filter, used for enabling/disabling certain dates
|
|
43
|
+
* @type {CalendarFilter | null}
|
|
44
|
+
*/
|
|
45
|
+
this.filter = null;
|
|
46
|
+
this._view = '';
|
|
47
|
+
this.localFirstDayOfWeek = FIRST_DAY_OF_WEEK; // used from locales. 0 stands for Sunday
|
|
48
|
+
this._firstDayOfWeek = null; // used from setter
|
|
49
|
+
/**
|
|
50
|
+
* Set to switch to range select mode
|
|
51
|
+
*/
|
|
52
|
+
this.range = false;
|
|
53
|
+
/**
|
|
54
|
+
* Set to switch to multiple select mode
|
|
55
|
+
*/
|
|
56
|
+
this.multiple = false;
|
|
57
|
+
this._values = [];
|
|
58
|
+
/**
|
|
59
|
+
* Fill head and tail cell dates
|
|
60
|
+
*/
|
|
61
|
+
this.fillCells = false;
|
|
62
|
+
/**
|
|
63
|
+
* Used for internal navigation between render views
|
|
64
|
+
*/
|
|
65
|
+
this.renderView = RenderView.DAY;
|
|
66
|
+
this.isDateAvailable = null; /* a constructed filter based on multiple local filters */
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Element version number
|
|
70
|
+
* @returns version number
|
|
71
|
+
*/
|
|
72
|
+
static get version() {
|
|
73
|
+
return VERSION;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* A `CSSResultGroup` that will be used
|
|
77
|
+
* to style the host, slotted children
|
|
78
|
+
* and the internal template of the element.
|
|
79
|
+
* @return CSS template
|
|
80
|
+
*/
|
|
81
|
+
static get styles() {
|
|
82
|
+
return css `
|
|
83
|
+
:host {
|
|
84
|
+
display: inline-block;
|
|
85
|
+
}
|
|
86
|
+
[part=navigation], [part=navigation] section {
|
|
87
|
+
display: flex;
|
|
88
|
+
flex-flow: row nowrap;
|
|
89
|
+
}
|
|
90
|
+
[part=navigation] {
|
|
91
|
+
justify-content: space-between;
|
|
92
|
+
}
|
|
93
|
+
[part=navigation] > div {
|
|
94
|
+
display: flex;
|
|
95
|
+
flex: 1;
|
|
96
|
+
justify-content: center;
|
|
97
|
+
}
|
|
98
|
+
[part~=cell-content] {
|
|
99
|
+
position: absolute;
|
|
100
|
+
top: 0;
|
|
101
|
+
bottom: 0;
|
|
102
|
+
left: 0;
|
|
103
|
+
right: 0;
|
|
104
|
+
pointer-events: none;
|
|
105
|
+
display: flex;
|
|
106
|
+
align-items: center;
|
|
107
|
+
justify-content: center;
|
|
108
|
+
}
|
|
109
|
+
[part=navigation] [part] {
|
|
110
|
+
flex: none;
|
|
111
|
+
}
|
|
112
|
+
[part=table] {
|
|
113
|
+
width: 100%;
|
|
114
|
+
}
|
|
115
|
+
[part~=row] {
|
|
116
|
+
display: flex;
|
|
117
|
+
width: 100%;
|
|
118
|
+
}
|
|
119
|
+
[part~=cell] {
|
|
120
|
+
position: relative;
|
|
121
|
+
}
|
|
122
|
+
[part~=cell][part~=year] {
|
|
123
|
+
width: calc(100% / ${YEAR_VIEW.columnCount});
|
|
124
|
+
padding-top: calc(100% / ${YEAR_VIEW.columnCount});
|
|
125
|
+
}
|
|
126
|
+
[part~=cell][part~=month] {
|
|
127
|
+
width: calc(100% / ${MONTH_VIEW.columnCount});
|
|
128
|
+
padding-top: calc(100% / ${MONTH_VIEW.columnCount});
|
|
129
|
+
}
|
|
130
|
+
[part~=cell][part~=day], [part~=cell][part~=day-name] {
|
|
131
|
+
width: calc(100% / ${DAY_VIEW.columnCount});
|
|
132
|
+
padding-top: calc(100% / ${DAY_VIEW.columnCount});
|
|
133
|
+
}
|
|
134
|
+
[part~=cell][tabindex] {
|
|
135
|
+
cursor: pointer;
|
|
136
|
+
}
|
|
137
|
+
`;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Set minimum date
|
|
141
|
+
* @param min min date
|
|
142
|
+
* @default -
|
|
143
|
+
*/
|
|
144
|
+
set min(min) {
|
|
145
|
+
const oldMin = this._min;
|
|
146
|
+
if (!this.isValidValue(min)) {
|
|
147
|
+
this.warnInvalidValue(min);
|
|
148
|
+
min = '';
|
|
149
|
+
}
|
|
150
|
+
if (oldMin !== min) {
|
|
151
|
+
this._min = min;
|
|
152
|
+
this.requestUpdate('min', oldMin);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
get min() {
|
|
156
|
+
return this._min;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Set maximum date
|
|
160
|
+
* @param max max date
|
|
161
|
+
* @default -
|
|
162
|
+
*/
|
|
163
|
+
set max(max) {
|
|
164
|
+
const oldMax = this._max;
|
|
165
|
+
if (!this.isValidValue(max)) {
|
|
166
|
+
this.warnInvalidValue(max);
|
|
167
|
+
max = '';
|
|
168
|
+
}
|
|
169
|
+
if (oldMax !== max) {
|
|
170
|
+
this._max = max;
|
|
171
|
+
this.requestUpdate('max', oldMax);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
get max() {
|
|
175
|
+
return this._max;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Current calendar view date
|
|
179
|
+
* @param view view date
|
|
180
|
+
* @default -
|
|
181
|
+
*/
|
|
182
|
+
set view(view) {
|
|
183
|
+
if (view && !isValidDate(view, DateFormat.yyyyMM)) {
|
|
184
|
+
this.warnInvalidView(view);
|
|
185
|
+
view = '';
|
|
186
|
+
}
|
|
187
|
+
const oldView = this._view;
|
|
188
|
+
if (oldView !== view) {
|
|
189
|
+
this._view = view;
|
|
190
|
+
this.requestUpdate('view', oldView);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
get view() {
|
|
194
|
+
/* as soon as user interaction has happened, always rely on view */
|
|
195
|
+
return this._view || (this.value ? utcFormat(toDateSegment(this.value), DateFormat.yyyyMM) : format(new Date(), DateFormat.yyyyMM));
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Set the first day of the week.
|
|
199
|
+
* 0 - for Sunday, 6 - for Saturday
|
|
200
|
+
* @param firstDayOfWeek The first day of the week
|
|
201
|
+
* @type {number | null}
|
|
202
|
+
*/
|
|
203
|
+
set firstDayOfWeek(firstDayOfWeek) {
|
|
204
|
+
firstDayOfWeek %= 7;
|
|
205
|
+
const oldFirstDayOfWeek = this._firstDayOfWeek;
|
|
206
|
+
if (oldFirstDayOfWeek !== firstDayOfWeek) {
|
|
207
|
+
this._firstDayOfWeek = firstDayOfWeek;
|
|
208
|
+
this.requestUpdate('firstDayOfWeek', oldFirstDayOfWeek);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
get firstDayOfWeek() {
|
|
212
|
+
return this._firstDayOfWeek === null ? this.localFirstDayOfWeek : this._firstDayOfWeek;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Current date time value
|
|
216
|
+
* @param value Calendar value
|
|
217
|
+
* @default -
|
|
218
|
+
*/
|
|
219
|
+
set value(value) {
|
|
220
|
+
this.values = [value];
|
|
221
|
+
}
|
|
222
|
+
get value() {
|
|
223
|
+
return this.values[0] || '';
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Set multiple selected values
|
|
227
|
+
* @param values Values to set
|
|
228
|
+
* @type {string[]}
|
|
229
|
+
*/
|
|
230
|
+
set values(values) {
|
|
231
|
+
const oldValues = this._values;
|
|
232
|
+
const newValues = this.filterAndWarnInvalidValues(values);
|
|
233
|
+
if (oldValues.toString() !== newValues.toString()) {
|
|
234
|
+
this._values = newValues;
|
|
235
|
+
this.requestUpdate('values', oldValues);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
get values() {
|
|
239
|
+
return this._values.concat();
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Get weekday numbers.
|
|
243
|
+
* Sort the list based on first day of the week
|
|
244
|
+
*/
|
|
245
|
+
get weekdaysNames() {
|
|
246
|
+
const firstDayOfWeek = this.firstDayOfWeek;
|
|
247
|
+
const localWeekdaysNames = this.localWeekdaysNames;
|
|
248
|
+
return localWeekdaysNames.slice(firstDayOfWeek).concat(localWeekdaysNames.slice(0, firstDayOfWeek));
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Get localised month names from January to December
|
|
252
|
+
*/
|
|
253
|
+
get monthsNames() {
|
|
254
|
+
return this.localMonthsNames;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Perform asynchronous update
|
|
258
|
+
* @returns promise
|
|
259
|
+
*/
|
|
260
|
+
async performUpdate() {
|
|
261
|
+
const localFirstDayOfWeek = Number(await this.tPromise('FIRST_DAY_OF_WEEK'));
|
|
262
|
+
this.localFirstDayOfWeek = isNaN(localFirstDayOfWeek) ? FIRST_DAY_OF_WEEK : (localFirstDayOfWeek % 7);
|
|
263
|
+
void super.performUpdate();
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Updates the element
|
|
267
|
+
* @param changedProperties Properties that has changed
|
|
268
|
+
* @returns {void}
|
|
269
|
+
*/
|
|
270
|
+
update(changedProperties) {
|
|
271
|
+
if (!this.localMonthsNames || changedProperties.has(TranslatePropertyKey)) {
|
|
272
|
+
this.localMonthsNames = monthsNames(getLocale(this));
|
|
273
|
+
}
|
|
274
|
+
if (!this.localWeekdaysNames || changedProperties.has(TranslatePropertyKey)) {
|
|
275
|
+
this.localWeekdaysNames = weekdaysNames(getLocale(this));
|
|
276
|
+
}
|
|
277
|
+
this.shouldConstructFilters(changedProperties) && this.constructFilters();
|
|
278
|
+
super.update(changedProperties);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Run when an element has been first updated
|
|
282
|
+
* @param changedProperties properties that was changed on first update
|
|
283
|
+
* @returns {void}
|
|
284
|
+
*/
|
|
285
|
+
firstUpdated(changedProperties) {
|
|
286
|
+
super.firstUpdated(changedProperties);
|
|
287
|
+
this.renderRoot.addEventListener('keydown', event => this.onTableKeyDown(event));
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Show invalid view message
|
|
291
|
+
* @param value Invalid value
|
|
292
|
+
* @returns {void}
|
|
293
|
+
*/
|
|
294
|
+
warnInvalidView(value) {
|
|
295
|
+
new WarningNotice(`The specified value "${value}" does not conform to the required format. The format is "yyyy-MM".`).once();
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Show invalid value message
|
|
299
|
+
* @param value Invalid value
|
|
300
|
+
* @returns {void}
|
|
301
|
+
*/
|
|
302
|
+
warnInvalidValue(value) {
|
|
303
|
+
new WarningNotice(`The specified value "${value}" does not conform to the required format. The format is "yyyy-MM-dd".`).once();
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Validate that the value confirms the control type
|
|
307
|
+
* @param value Value to check
|
|
308
|
+
* @returns false if value is invalid
|
|
309
|
+
*/
|
|
310
|
+
isValidValue(value) {
|
|
311
|
+
return value === '' || isValidDate(value);
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* A helper method to make sure that only valid values are passed
|
|
315
|
+
* Warn if passed value is invalid
|
|
316
|
+
* @param values Values to check
|
|
317
|
+
* @returns Filtered collection of values
|
|
318
|
+
*/
|
|
319
|
+
filterAndWarnInvalidValues(values) {
|
|
320
|
+
const filtered = [];
|
|
321
|
+
values.forEach(value => {
|
|
322
|
+
if (this.isValidValue(value)) {
|
|
323
|
+
value && filtered.push(value);
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
this.warnInvalidValue(value);
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
return filtered;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Check if there is a need to reconstruct filters
|
|
333
|
+
* @param changedProperties properties that was changed on first update
|
|
334
|
+
* @returns true if filter needs to be constructed
|
|
335
|
+
*/
|
|
336
|
+
shouldConstructFilters(changedProperties) {
|
|
337
|
+
return changedProperties.has('min')
|
|
338
|
+
|| changedProperties.has('max')
|
|
339
|
+
|| changedProperties.has('weekdaysOnly')
|
|
340
|
+
|| changedProperties.has('weekendsOnly')
|
|
341
|
+
|| changedProperties.has('filter');
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Construct and store a collection of filters
|
|
345
|
+
* First always comes default filters and last custom filters
|
|
346
|
+
* @returns {void}
|
|
347
|
+
*/
|
|
348
|
+
constructFilters() {
|
|
349
|
+
const filters = [];
|
|
350
|
+
this.min && filters.push(date => isSameDay(date, this.min) || isAfter(date, this.min));
|
|
351
|
+
this.max && filters.push(date => isSameDay(date, this.max) || isBefore(date, this.max));
|
|
352
|
+
if (this.weekdaysOnly) {
|
|
353
|
+
filters.push(date => !isWeekend(date));
|
|
354
|
+
}
|
|
355
|
+
if (this.weekendsOnly) {
|
|
356
|
+
filters.push(date => isWeekend(date));
|
|
357
|
+
}
|
|
358
|
+
if (this.filter) {
|
|
359
|
+
filters.push(this.filter);
|
|
360
|
+
}
|
|
361
|
+
const filtersLength = filters.length;
|
|
362
|
+
if (filtersLength) {
|
|
363
|
+
this.isDateAvailable = (value) => {
|
|
364
|
+
for (let i = 0; i < filtersLength; i += 1) {
|
|
365
|
+
if (!filters[i](value)) {
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
return true;
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
this.isDateAvailable = null;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Check if date cell is selected
|
|
378
|
+
* @param value A value to compare
|
|
379
|
+
* @param comparator A comparator to check for selection. Can be day, month or year
|
|
380
|
+
* @returns true if cell is selected
|
|
381
|
+
*/
|
|
382
|
+
isDateCellSelected(value, comparator) {
|
|
383
|
+
const values = this._values;
|
|
384
|
+
const valuesLength = values.length;
|
|
385
|
+
for (let i = 0; i < valuesLength; i += 1) {
|
|
386
|
+
if (comparator(value, values[i])) {
|
|
387
|
+
return true;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Get cell selection model, which is used to bind values and ranges
|
|
394
|
+
* to cell styles
|
|
395
|
+
* @param value A value to compare
|
|
396
|
+
* @param comparator A comparator to check for selection. Can be day, month or year
|
|
397
|
+
* @returns cell selection model
|
|
398
|
+
*/
|
|
399
|
+
getCellSelection(value, comparator) {
|
|
400
|
+
const values = this._values;
|
|
401
|
+
const selected = this.isDateCellSelected(value, comparator);
|
|
402
|
+
const from = values[0];
|
|
403
|
+
const to = values[1];
|
|
404
|
+
if (!this.range || !from || !to) {
|
|
405
|
+
return {
|
|
406
|
+
selected
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
const rangeFrom = comparator(value, from);
|
|
410
|
+
const rangeTo = comparator(value, to);
|
|
411
|
+
const range = !rangeFrom && !rangeTo && isAfter(value, from) && isBefore(value, to);
|
|
412
|
+
return {
|
|
413
|
+
selected,
|
|
414
|
+
range,
|
|
415
|
+
rangeFrom,
|
|
416
|
+
rangeTo
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* Run when next button is tapped.
|
|
421
|
+
* Change current view to next view
|
|
422
|
+
* @returns {void}
|
|
423
|
+
*/
|
|
424
|
+
onNextTap() {
|
|
425
|
+
let viewSegment = toDateSegment(this.view);
|
|
426
|
+
switch (this.renderView) {
|
|
427
|
+
case RenderView.DAY:
|
|
428
|
+
viewSegment = toDateSegment(addMonths(this.view, 1));
|
|
429
|
+
break;
|
|
430
|
+
case RenderView.MONTH:
|
|
431
|
+
viewSegment.year += 1;
|
|
432
|
+
break;
|
|
433
|
+
case RenderView.YEAR:
|
|
434
|
+
viewSegment.year += YEARS_PER_YEAR_VIEW;
|
|
435
|
+
break;
|
|
436
|
+
// no default
|
|
437
|
+
}
|
|
438
|
+
this.notifyViewChange(viewSegment);
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Run when previous button is tapped.
|
|
442
|
+
* Change current view to previous view
|
|
443
|
+
* @returns {void}
|
|
444
|
+
*/
|
|
445
|
+
onPreviousTap() {
|
|
446
|
+
let viewSegment = toDateSegment(this.view);
|
|
447
|
+
switch (this.renderView) {
|
|
448
|
+
case RenderView.DAY:
|
|
449
|
+
viewSegment = toDateSegment(subMonths(this.view, 1));
|
|
450
|
+
break;
|
|
451
|
+
case RenderView.MONTH:
|
|
452
|
+
viewSegment.year -= 1;
|
|
453
|
+
break;
|
|
454
|
+
case RenderView.YEAR:
|
|
455
|
+
viewSegment.year -= YEARS_PER_YEAR_VIEW;
|
|
456
|
+
break;
|
|
457
|
+
// no default
|
|
458
|
+
}
|
|
459
|
+
this.notifyViewChange(viewSegment);
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Run when change view button is tapped.
|
|
463
|
+
* Switch between views
|
|
464
|
+
* @returns {void}
|
|
465
|
+
*/
|
|
466
|
+
onRenderViewTap() {
|
|
467
|
+
this.renderView = this.renderView === RenderView.DAY ? RenderView.YEAR : RenderView.DAY;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Run when key down event happens on calendar
|
|
471
|
+
* @param event Keyboard event
|
|
472
|
+
* @returns {void}
|
|
473
|
+
*/
|
|
474
|
+
onTableKeyDown(event) {
|
|
475
|
+
switch (event.key) {
|
|
476
|
+
case ' ':
|
|
477
|
+
case 'Enter':
|
|
478
|
+
case 'Spacebar':
|
|
479
|
+
event.preventDefault();
|
|
480
|
+
this.onTableTap(event);
|
|
481
|
+
break;
|
|
482
|
+
case 'Esc':
|
|
483
|
+
case 'Escape':
|
|
484
|
+
if (this.renderView === RenderView.YEAR || this.renderView === RenderView.MONTH) {
|
|
485
|
+
event.preventDefault();
|
|
486
|
+
this.renderView = RenderView.DAY;
|
|
487
|
+
}
|
|
488
|
+
break;
|
|
489
|
+
// no default
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Run when tap event happens ot table.
|
|
494
|
+
* Select the values or switch the view
|
|
495
|
+
* @param event Tap event
|
|
496
|
+
* @returns {void}
|
|
497
|
+
*/
|
|
498
|
+
onTableTap(event) {
|
|
499
|
+
const cell = event.target; /* here we just emulate interface */
|
|
500
|
+
if (!cell || !cell.value) {
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
const cellSegment = toDateSegment(cell.value);
|
|
504
|
+
const viewSegment = toDateSegment(this.view);
|
|
505
|
+
if (this.renderView === RenderView.YEAR) { /* YEAR -> MONTH */
|
|
506
|
+
viewSegment.year = cellSegment.year;
|
|
507
|
+
if (this.notifyViewChange(viewSegment)) {
|
|
508
|
+
this.renderView = RenderView.MONTH;
|
|
509
|
+
}
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
if (this.renderView === RenderView.MONTH) { /* MONTH -> DAY */
|
|
513
|
+
viewSegment.year = cellSegment.year;
|
|
514
|
+
viewSegment.month = cellSegment.month;
|
|
515
|
+
if (this.notifyViewChange(viewSegment)) {
|
|
516
|
+
this.renderView = RenderView.DAY;
|
|
517
|
+
}
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
this.onTapSelectValue(cell.value);
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Run when tap event happened on DAY view and the cell has the values
|
|
524
|
+
* Try to select/deselect cell value
|
|
525
|
+
* @param value Date string
|
|
526
|
+
* @returns {void}
|
|
527
|
+
*/
|
|
528
|
+
onTapSelectValue(value) {
|
|
529
|
+
if (this.readonly || this.disabled) {
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
let values;
|
|
533
|
+
if (this.multiple) {
|
|
534
|
+
values = this.values.filter(oldValue => {
|
|
535
|
+
return oldValue !== value;
|
|
536
|
+
});
|
|
537
|
+
if (this.values.length === values.length) {
|
|
538
|
+
values.push(value);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
else if (this.range) {
|
|
542
|
+
if (!this.values.length) {
|
|
543
|
+
values = [value];
|
|
544
|
+
}
|
|
545
|
+
else if (this.values.length === 1) { /* from is populated */
|
|
546
|
+
const from = this.values[0];
|
|
547
|
+
const to = value;
|
|
548
|
+
if (isAfter(to, from) || isSameDay(to, from)) {
|
|
549
|
+
values = [this.values[0], value];
|
|
550
|
+
}
|
|
551
|
+
else {
|
|
552
|
+
values = [value];
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
values = [value];
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
else {
|
|
560
|
+
values = [value];
|
|
561
|
+
}
|
|
562
|
+
this.notifyValuesChange(values);
|
|
563
|
+
}
|
|
564
|
+
/**
|
|
565
|
+
* Notify that values array has been changed
|
|
566
|
+
* @param values A collection of string dates
|
|
567
|
+
* @returns {void}
|
|
568
|
+
*/
|
|
569
|
+
notifyValuesChange(values) {
|
|
570
|
+
if (this.values.toString() !== values.toString()) {
|
|
571
|
+
this.values = values;
|
|
572
|
+
this.notifyPropertyChange('value', this.value);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
/**
|
|
576
|
+
* Notify that view has been changed
|
|
577
|
+
* @param view Date
|
|
578
|
+
* @returns {void}
|
|
579
|
+
*/
|
|
580
|
+
notifyViewChange(view) {
|
|
581
|
+
const viewString = utcFormat(view, DateFormat.yyyyMM);
|
|
582
|
+
const res = this.notifyPropertyChange('view', viewString, true);
|
|
583
|
+
if (res) {
|
|
584
|
+
this.view = viewString;
|
|
585
|
+
}
|
|
586
|
+
return res;
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Localised format for render view
|
|
590
|
+
* @param segment Segment object
|
|
591
|
+
* @param includeMonth True to include a month
|
|
592
|
+
* @returns template result
|
|
593
|
+
*/
|
|
594
|
+
viewFormattedDate(segment, includeMonth = false) {
|
|
595
|
+
const year = segment.year;
|
|
596
|
+
const isBC = year <= 0;
|
|
597
|
+
const includeEra = isBC;
|
|
598
|
+
const date = utcParse(segment);
|
|
599
|
+
// Unfortunately IE11 does not support date formatting for year <= 0
|
|
600
|
+
// Do manual conversion instead
|
|
601
|
+
if (isIE && isBC) {
|
|
602
|
+
return html `${formatLocaleDate(date, getLocale(this), includeMonth, includeEra)}`;
|
|
603
|
+
}
|
|
604
|
+
return html `${this.t('VIEW_FORMAT', {
|
|
605
|
+
date,
|
|
606
|
+
includeMonth,
|
|
607
|
+
includeEra
|
|
608
|
+
}, ViewFormatTranslateParams)}`;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Get a string representation of current view
|
|
612
|
+
* @returns template result
|
|
613
|
+
*/
|
|
614
|
+
get formattedViewRender() {
|
|
615
|
+
const segment = toDateSegment(this.view);
|
|
616
|
+
switch (this.renderView) {
|
|
617
|
+
case RenderView.MONTH:
|
|
618
|
+
return this.viewFormattedDate(segment);
|
|
619
|
+
case RenderView.YEAR:
|
|
620
|
+
const month = segment.month;
|
|
621
|
+
const day = segment.day;
|
|
622
|
+
const fromYear = Math.floor(segment.year / YEARS_PER_YEAR_VIEW) * YEARS_PER_YEAR_VIEW;
|
|
623
|
+
const toYear = fromYear + YEARS_PER_YEAR_VIEW - 1;
|
|
624
|
+
return html `${this.viewFormattedDate({ year: fromYear, month, day })} - ${this.viewFormattedDate({ year: toYear, month, day })}`;
|
|
625
|
+
case RenderView.DAY:
|
|
626
|
+
default:
|
|
627
|
+
return this.viewFormattedDate(segment, true);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Render cell content template.
|
|
632
|
+
* If the cell is selectable (aka has value) add selection part
|
|
633
|
+
* @param text Text to render
|
|
634
|
+
* @param selectable True if cell may be selected
|
|
635
|
+
* @returns template result
|
|
636
|
+
*/
|
|
637
|
+
renderContentBox(text = '', selectable = false) {
|
|
638
|
+
return html `<div part="cell-content${selectable ? ' selection' : ''}">${text}</div>`;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Get year view template
|
|
642
|
+
*/
|
|
643
|
+
get yearView() {
|
|
644
|
+
const view = RenderView.YEAR;
|
|
645
|
+
const currentYear = toDateSegment(this.view).year;
|
|
646
|
+
const startIdx = Math.floor(currentYear / YEARS_PER_YEAR_VIEW) * YEARS_PER_YEAR_VIEW;
|
|
647
|
+
const years = [];
|
|
648
|
+
const rows = [];
|
|
649
|
+
let cells = [];
|
|
650
|
+
let cell;
|
|
651
|
+
for (let i = 0; i < YEAR_VIEW.totalCount; i += 1) {
|
|
652
|
+
if (i % YEAR_VIEW.columnCount === 0) {
|
|
653
|
+
cells = [];
|
|
654
|
+
rows.push({
|
|
655
|
+
cells
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
const year = startIdx + i;
|
|
659
|
+
const value = utcFormat({ year, month: 0, day: 1 }, DateFormat.yyyyMMdd);
|
|
660
|
+
cell = Object.assign({ view, text: year > 0 ? `${year}` : year === 0 ? '1' : `${Math.abs(year - 1)}`, value: `${year}`, now: isThisYear(value) }, this.getCellSelection(value, isSameYear));
|
|
661
|
+
cells.push(cell);
|
|
662
|
+
years.push(cell);
|
|
663
|
+
}
|
|
664
|
+
years[0].firstDate = true;
|
|
665
|
+
years[years.length - 1].lastDate = true;
|
|
666
|
+
return html `${this.renderRows(rows)}`;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Get month view template
|
|
670
|
+
*/
|
|
671
|
+
get monthView() {
|
|
672
|
+
const view = RenderView.MONTH;
|
|
673
|
+
const currentYear = toDateSegment(this.view).year;
|
|
674
|
+
const columnCount = MONTH_VIEW.columnCount;
|
|
675
|
+
const monthCount = 12;
|
|
676
|
+
const totalCount = MONTH_VIEW.totalCount;
|
|
677
|
+
const monthsNames = this.monthsNames;
|
|
678
|
+
const before = (totalCount - monthCount) / 2;
|
|
679
|
+
const startIdx = monthCount - before % monthCount;
|
|
680
|
+
const after = before + monthCount;
|
|
681
|
+
const months = [];
|
|
682
|
+
const rows = [];
|
|
683
|
+
let cell;
|
|
684
|
+
let cells = [];
|
|
685
|
+
for (let i = 0; i < totalCount; i += 1) {
|
|
686
|
+
if (i % columnCount === 0) {
|
|
687
|
+
cells = [];
|
|
688
|
+
rows.push({
|
|
689
|
+
cells
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
const month = (startIdx + i) % monthCount; /* 0 for Jan, 11 for Dev */
|
|
693
|
+
const year = currentYear + Math.floor((i - before) / monthCount);
|
|
694
|
+
const segment = { year, month, day: 1 };
|
|
695
|
+
const value = utcFormat(segment, DateFormat.yyyyMMdd);
|
|
696
|
+
const idle = i < before || i >= after;
|
|
697
|
+
cell = Object.assign({ view, text: monthsNames[month], value: utcFormat(segment, DateFormat.yyyyMM), idle, now: isThisMonth(value) }, this.getCellSelection(value, isSameMonth));
|
|
698
|
+
cells.push(cell);
|
|
699
|
+
months.push(cell);
|
|
700
|
+
}
|
|
701
|
+
months[0].firstDate = true;
|
|
702
|
+
months[months.length - 1].lastDate = true;
|
|
703
|
+
return html `${this.renderRows(rows)}`;
|
|
704
|
+
}
|
|
705
|
+
/**
|
|
706
|
+
* Get day view template
|
|
707
|
+
*/
|
|
708
|
+
get dayView() {
|
|
709
|
+
const view = RenderView.DAY;
|
|
710
|
+
const firstDayOfWeek = this.firstDayOfWeek;
|
|
711
|
+
const padding = (7 + utcParse(this.view).getUTCDay() - firstDayOfWeek) % 7;
|
|
712
|
+
const viewMonth = monthInfo(this.view);
|
|
713
|
+
const prevMonth = monthInfo(subMonths(this.view, 1));
|
|
714
|
+
const nextMonth = monthInfo(addMonths(this.view, 1));
|
|
715
|
+
const days = [];
|
|
716
|
+
const rows = [];
|
|
717
|
+
let cells = [];
|
|
718
|
+
let day;
|
|
719
|
+
let month;
|
|
720
|
+
let year;
|
|
721
|
+
// Generate new cells.
|
|
722
|
+
for (let i = 0; i < DAY_VIEW.totalCount; i += 1) {
|
|
723
|
+
if (i % DAY_VIEW.columnCount === 0) {
|
|
724
|
+
cells = [];
|
|
725
|
+
rows.push({
|
|
726
|
+
cells
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
const datePadding = i - padding + 1;
|
|
730
|
+
if (datePadding <= 0) {
|
|
731
|
+
if (!this.fillCells) {
|
|
732
|
+
cells.push({
|
|
733
|
+
view
|
|
734
|
+
});
|
|
735
|
+
continue;
|
|
736
|
+
}
|
|
737
|
+
day = prevMonth.days + datePadding;
|
|
738
|
+
month = prevMonth.month;
|
|
739
|
+
year = prevMonth.year;
|
|
740
|
+
}
|
|
741
|
+
else if (datePadding > viewMonth.days) {
|
|
742
|
+
if (!this.fillCells) {
|
|
743
|
+
cells.push({
|
|
744
|
+
view
|
|
745
|
+
});
|
|
746
|
+
continue;
|
|
747
|
+
}
|
|
748
|
+
day = datePadding - viewMonth.days;
|
|
749
|
+
month = nextMonth.month;
|
|
750
|
+
year = nextMonth.year;
|
|
751
|
+
}
|
|
752
|
+
else {
|
|
753
|
+
day = datePadding;
|
|
754
|
+
month = viewMonth.month;
|
|
755
|
+
year = viewMonth.year;
|
|
756
|
+
}
|
|
757
|
+
const value = utcFormat({ year, month, day }, DateFormat.yyyyMMdd);
|
|
758
|
+
const disabled = this.isDateAvailable ? !this.isDateAvailable(value) : false;
|
|
759
|
+
const dayCell = Object.assign({ view, text: day.toString(), value,
|
|
760
|
+
disabled, idle: month !== viewMonth.month || year !== viewMonth.year, now: isToday(value) }, this.getCellSelection(value, isSameDay));
|
|
761
|
+
cells.push(dayCell);
|
|
762
|
+
days.push(dayCell);
|
|
763
|
+
}
|
|
764
|
+
days[0].firstDate = true;
|
|
765
|
+
days[days.length - 1].lastDate = true;
|
|
766
|
+
return html `
|
|
767
|
+
${this.renderWeekdayNames}
|
|
768
|
+
${this.renderRows(rows)}
|
|
769
|
+
`;
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* Get weekday names template
|
|
773
|
+
*/
|
|
774
|
+
get renderWeekdayNames() {
|
|
775
|
+
return html `
|
|
776
|
+
<div part="row day-name-row">${this.weekdaysNames.map(day => html `<div part="cell day-name">${this.renderContentBox(day)}</div>`)}</div>
|
|
777
|
+
`;
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Render a view based on the current render view
|
|
781
|
+
*/
|
|
782
|
+
get viewRender() {
|
|
783
|
+
switch (this.renderView) {
|
|
784
|
+
case RenderView.MONTH:
|
|
785
|
+
return this.monthView;
|
|
786
|
+
case RenderView.YEAR:
|
|
787
|
+
return this.yearView;
|
|
788
|
+
case RenderView.DAY:
|
|
789
|
+
default:
|
|
790
|
+
return this.dayView;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* Render cell template. Cell can be a day, month or year
|
|
795
|
+
* @param cell Cell object
|
|
796
|
+
* @returns template result
|
|
797
|
+
*/
|
|
798
|
+
renderCell(cell) {
|
|
799
|
+
return html `<div
|
|
800
|
+
part="cell ${cell.view}"
|
|
801
|
+
?disabled=${cell.disabled}
|
|
802
|
+
.value=${cell.value}
|
|
803
|
+
?idle=${cell.idle}
|
|
804
|
+
?today=${cell.now}
|
|
805
|
+
?first-date=${cell.firstDate}
|
|
806
|
+
?last-date=${cell.lastDate}
|
|
807
|
+
?selected=${cell.selected}
|
|
808
|
+
?range=${cell.range}
|
|
809
|
+
?range-from=${cell.rangeFrom}
|
|
810
|
+
?range-to=${cell.rangeTo}
|
|
811
|
+
tabindex=${ifDefined(cell.value !== undefined && !cell.disabled ? 0 : undefined)}
|
|
812
|
+
>${this.renderContentBox(cell.text, cell.value !== undefined)}</div>`;
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* Render view rows
|
|
816
|
+
* @param rows A collection of rows with cells
|
|
817
|
+
* @returns template result
|
|
818
|
+
*/
|
|
819
|
+
renderRows(rows) {
|
|
820
|
+
return rows.map(row => html `<div part="row">${row.cells.map(cell => this.renderCell(cell))}</div>`);
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* A `TemplateResult` that will be used
|
|
824
|
+
* to render the updated internal template.
|
|
825
|
+
* @return Render template
|
|
826
|
+
*/
|
|
827
|
+
render() {
|
|
828
|
+
return html `
|
|
829
|
+
<div part="navigation">
|
|
830
|
+
<ef-button
|
|
831
|
+
part="btn-prev"
|
|
832
|
+
icon="left"
|
|
833
|
+
@tap=${this.onPreviousTap}></ef-button>
|
|
834
|
+
<ef-button
|
|
835
|
+
part="btn-view"
|
|
836
|
+
textpos="before"
|
|
837
|
+
.icon="${this.renderView === RenderView.DAY ? 'down' : 'up'}"
|
|
838
|
+
@tap="${this.onRenderViewTap}">${this.formattedViewRender}</ef-button>
|
|
839
|
+
<ef-button
|
|
840
|
+
part="btn-next"
|
|
841
|
+
icon="right"
|
|
842
|
+
@tap=${this.onNextTap}></ef-button>
|
|
843
|
+
</div>
|
|
844
|
+
<div part="table"
|
|
845
|
+
@tap=${this.onTableTap}>${this.viewRender}</div>
|
|
846
|
+
<div part="footer"><slot name="footer"></slot></div>
|
|
847
|
+
`;
|
|
848
|
+
}
|
|
849
|
+
};
|
|
850
|
+
__decorate([
|
|
851
|
+
property({ type: String })
|
|
852
|
+
], Calendar.prototype, "min", null);
|
|
853
|
+
__decorate([
|
|
854
|
+
property({ type: String })
|
|
855
|
+
], Calendar.prototype, "max", null);
|
|
856
|
+
__decorate([
|
|
857
|
+
property({ type: Boolean, attribute: 'weekdays-only' })
|
|
858
|
+
], Calendar.prototype, "weekdaysOnly", void 0);
|
|
859
|
+
__decorate([
|
|
860
|
+
property({ type: Boolean, attribute: 'weekends-only' })
|
|
861
|
+
], Calendar.prototype, "weekendsOnly", void 0);
|
|
862
|
+
__decorate([
|
|
863
|
+
property({ attribute: false })
|
|
864
|
+
], Calendar.prototype, "filter", void 0);
|
|
865
|
+
__decorate([
|
|
866
|
+
property({ type: String })
|
|
867
|
+
], Calendar.prototype, "view", null);
|
|
868
|
+
__decorate([
|
|
869
|
+
property({ type: Number, attribute: 'first-day-of-week' })
|
|
870
|
+
], Calendar.prototype, "firstDayOfWeek", null);
|
|
871
|
+
__decorate([
|
|
872
|
+
property({ type: Boolean, reflect: true })
|
|
873
|
+
], Calendar.prototype, "range", void 0);
|
|
874
|
+
__decorate([
|
|
875
|
+
property({ type: Boolean, reflect: true })
|
|
876
|
+
], Calendar.prototype, "multiple", void 0);
|
|
877
|
+
__decorate([
|
|
878
|
+
property({ type: String })
|
|
879
|
+
], Calendar.prototype, "value", null);
|
|
880
|
+
__decorate([
|
|
881
|
+
property({
|
|
882
|
+
converter: {
|
|
883
|
+
fromAttribute: function (value) {
|
|
884
|
+
return value.split(',');
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
})
|
|
888
|
+
], Calendar.prototype, "values", null);
|
|
889
|
+
__decorate([
|
|
890
|
+
property({ type: Boolean, attribute: 'fill-cells' })
|
|
891
|
+
], Calendar.prototype, "fillCells", void 0);
|
|
892
|
+
__decorate([
|
|
893
|
+
translate({ mode: 'directive', scope: 'ef-calendar' })
|
|
894
|
+
], Calendar.prototype, "t", void 0);
|
|
895
|
+
__decorate([
|
|
896
|
+
translate({ mode: 'promise', scope: 'ef-calendar' })
|
|
897
|
+
], Calendar.prototype, "tPromise", void 0);
|
|
898
|
+
__decorate([
|
|
899
|
+
property({ type: String })
|
|
900
|
+
], Calendar.prototype, "renderView", void 0);
|
|
901
|
+
Calendar = __decorate([
|
|
902
|
+
customElement('ef-calendar', {
|
|
903
|
+
alias: 'coral-calendar'
|
|
904
|
+
})
|
|
905
|
+
], Calendar);
|
|
906
|
+
export { Calendar };
|