@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,1146 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { ControlElement, css, html, WarningNotice, FocusedPropertyKey } 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 { eventOptions } from '@refinitiv-ui/core/lib/decorators/event-options.js';
|
|
7
|
+
import { styleMap } from '@refinitiv-ui/core/lib/directives/style-map.js';
|
|
8
|
+
import { ifDefined } from '@refinitiv-ui/core/lib/directives/if-defined.js';
|
|
9
|
+
import { VERSION } from '../version.js';
|
|
10
|
+
import { CollectionComposer } from '@refinitiv-ui/utils/lib/collection.js';
|
|
11
|
+
import { AnimationTaskRunner, TimeoutTaskRunner } from '@refinitiv-ui/utils/lib/async.js';
|
|
12
|
+
import { ListRenderer as ComboBoxRenderer } from '../list/index.js';
|
|
13
|
+
import { defaultFilter } from './helpers/filter.js';
|
|
14
|
+
import { CustomKeyboardEvent } from './helpers/keyboard-event.js';
|
|
15
|
+
import '../icon/index.js';
|
|
16
|
+
import '../overlay/index.js';
|
|
17
|
+
import '../list/index.js';
|
|
18
|
+
import '../pill/index.js';
|
|
19
|
+
import '../text-field/index.js';
|
|
20
|
+
import { translate } from '@refinitiv-ui/translate';
|
|
21
|
+
import '@refinitiv-ui/phrasebook/lib/locale/en/combo-box.js';
|
|
22
|
+
const QUERY_DEBOUNCE_RATE = 0;
|
|
23
|
+
// Maximum number of characters to display in multiple mode
|
|
24
|
+
const MULTIPLE_LABEL_MAX_SIZE = 250;
|
|
25
|
+
// Separator for labels in multiple mode
|
|
26
|
+
// Double space is expected
|
|
27
|
+
const MULTIPLE_LABEL_SEPARATOR = '; ';
|
|
28
|
+
const POPUP_POSITION = ['bottom-start', 'top-start'];
|
|
29
|
+
const valueFormatWarning = new WarningNotice('The specified \'values\' format does not conform to the required format.');
|
|
30
|
+
const freeTextMultipleWarning = new WarningNotice('"free-text" mode is not compatible with "multiple" mode');
|
|
31
|
+
/**
|
|
32
|
+
* Combines a popup with a filterable selection list
|
|
33
|
+
*
|
|
34
|
+
* @attr {boolean} readonly - Set readonly state
|
|
35
|
+
* @prop {boolean} [readonly=false] - Set readonly state
|
|
36
|
+
*
|
|
37
|
+
* @attr {boolean} disabled - Set disabled state
|
|
38
|
+
* @prop {boolean} [disabled=false] - Set disabled state
|
|
39
|
+
*
|
|
40
|
+
* @attr {string} name - Set name of the element
|
|
41
|
+
* @prop {string} [name=''] - Set name of the element
|
|
42
|
+
*
|
|
43
|
+
* @fires value-changed - Dispatched when value changes
|
|
44
|
+
* @fires query-changed - Dispatched when query changes
|
|
45
|
+
* @fires opened-changed - Dispatched when opened state changes
|
|
46
|
+
*/
|
|
47
|
+
let ComboBox = class ComboBox extends ControlElement {
|
|
48
|
+
constructor() {
|
|
49
|
+
super(...arguments);
|
|
50
|
+
/**
|
|
51
|
+
* Custom filter for static data
|
|
52
|
+
* Set this to null when data is filtered externally, eg XHR
|
|
53
|
+
* @type {ComboBoxFilter<T> | null}
|
|
54
|
+
*/
|
|
55
|
+
this.filter = defaultFilter(this);
|
|
56
|
+
/**
|
|
57
|
+
* Renderer used to render list item elements
|
|
58
|
+
* @type {ComboBoxRenderer}
|
|
59
|
+
*/
|
|
60
|
+
this.renderer = new ComboBoxRenderer(this);
|
|
61
|
+
this._multiple = false;
|
|
62
|
+
/**
|
|
63
|
+
* Track opened state of popup
|
|
64
|
+
*/
|
|
65
|
+
this.opened = false;
|
|
66
|
+
/**
|
|
67
|
+
* Placeholder for input field
|
|
68
|
+
*/
|
|
69
|
+
this.placeholder = '';
|
|
70
|
+
/**
|
|
71
|
+
* Show clears button
|
|
72
|
+
*/
|
|
73
|
+
this.clears = false;
|
|
74
|
+
this._freeText = false;
|
|
75
|
+
/**
|
|
76
|
+
* Set state to error
|
|
77
|
+
*/
|
|
78
|
+
this.error = false;
|
|
79
|
+
/**
|
|
80
|
+
* Set state to warning
|
|
81
|
+
*/
|
|
82
|
+
this.warning = false;
|
|
83
|
+
// Internal reference to debounce rate
|
|
84
|
+
this._queryDebounceRate = QUERY_DEBOUNCE_RATE;
|
|
85
|
+
// Debounces the query using queryDebounceRate
|
|
86
|
+
this.queryDebouncer = new TimeoutTaskRunner(this._queryDebounceRate);
|
|
87
|
+
this._data = []; // Local data object set through data setter
|
|
88
|
+
/**
|
|
89
|
+
* `value` always initialised before `data`, so it cannot query and select items when using attribute.
|
|
90
|
+
* This variable is to store value for selecting a data item after data has been initialised.
|
|
91
|
+
*/
|
|
92
|
+
this.cachedValue = '';
|
|
93
|
+
this._query = null; // Internally set and store query value
|
|
94
|
+
/**
|
|
95
|
+
* Composer used to query and modify item state.
|
|
96
|
+
*/
|
|
97
|
+
this.composer = new CollectionComposer([]);
|
|
98
|
+
/**
|
|
99
|
+
* Initiate one time popup rendering
|
|
100
|
+
*/
|
|
101
|
+
this.lazyRendered = false;
|
|
102
|
+
/**
|
|
103
|
+
* Throttle popup resizing
|
|
104
|
+
*/
|
|
105
|
+
this.resizeThrottler = new AnimationTaskRunner();
|
|
106
|
+
/**
|
|
107
|
+
* Input text to display in text field while typing
|
|
108
|
+
* Use because of query debouncer to avoid input to be not in sync with query
|
|
109
|
+
*/
|
|
110
|
+
this.inputText = '';
|
|
111
|
+
/**
|
|
112
|
+
* Used to store free text value
|
|
113
|
+
* If freeText mode is defined
|
|
114
|
+
*/
|
|
115
|
+
this.freeTextValue = '';
|
|
116
|
+
/**
|
|
117
|
+
* Hold popup styling applied on open
|
|
118
|
+
*/
|
|
119
|
+
this.popupDynamicStyles = {};
|
|
120
|
+
/**
|
|
121
|
+
* Use to call request update when CC changes its value
|
|
122
|
+
* @returns {void}
|
|
123
|
+
*/
|
|
124
|
+
this.modificationHandler = () => this.modificationUpdate();
|
|
125
|
+
this._resolvedData = [];
|
|
126
|
+
this.dataPromiseCounter = 0; // A counter to detect that the promise resolved is the last promise set
|
|
127
|
+
/**
|
|
128
|
+
* Mark combobox with loading flag
|
|
129
|
+
* Used in conjunction with data promise
|
|
130
|
+
*/
|
|
131
|
+
this.loading = false;
|
|
132
|
+
this.shouldOpenOnFocus = false;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Element version number
|
|
136
|
+
* @returns version number
|
|
137
|
+
*/
|
|
138
|
+
static get version() {
|
|
139
|
+
return VERSION;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* A `CSSResultGroup` that will be used
|
|
143
|
+
* to style the host, slotted children
|
|
144
|
+
* and the internal template of the element.
|
|
145
|
+
* @return CSS template
|
|
146
|
+
*/
|
|
147
|
+
static get styles() {
|
|
148
|
+
return css `
|
|
149
|
+
:host {
|
|
150
|
+
display: inline-flex;
|
|
151
|
+
flex-flow: row nowrap;
|
|
152
|
+
user-select: none;
|
|
153
|
+
outline: none;
|
|
154
|
+
}
|
|
155
|
+
[part=input-wrapper] {
|
|
156
|
+
cursor: pointer;
|
|
157
|
+
}
|
|
158
|
+
[part=input] {
|
|
159
|
+
cursor: text;
|
|
160
|
+
}
|
|
161
|
+
[part=input]::-ms-clear {
|
|
162
|
+
display: none;
|
|
163
|
+
}
|
|
164
|
+
[hidden] {
|
|
165
|
+
display: none !important;
|
|
166
|
+
}
|
|
167
|
+
`;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Multiple selection mode
|
|
171
|
+
* @param multiple true to set multiple mode
|
|
172
|
+
*/
|
|
173
|
+
set multiple(multiple) {
|
|
174
|
+
if (multiple && this.freeText) {
|
|
175
|
+
freeTextMultipleWarning.show();
|
|
176
|
+
multiple = false;
|
|
177
|
+
}
|
|
178
|
+
const oldMultiple = this._multiple;
|
|
179
|
+
this._multiple = multiple;
|
|
180
|
+
this.requestUpdate('multiple', oldMultiple);
|
|
181
|
+
}
|
|
182
|
+
get multiple() {
|
|
183
|
+
return this._multiple;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Allow to enter any value
|
|
187
|
+
* @param freeText true to set freeText mode
|
|
188
|
+
*/
|
|
189
|
+
set freeText(freeText) {
|
|
190
|
+
if (this.multiple && freeText) {
|
|
191
|
+
freeTextMultipleWarning.show();
|
|
192
|
+
freeText = false;
|
|
193
|
+
}
|
|
194
|
+
if (!freeText) {
|
|
195
|
+
this.freeTextValue = '';
|
|
196
|
+
}
|
|
197
|
+
const oldFreeText = this._freeText;
|
|
198
|
+
this._freeText = freeText;
|
|
199
|
+
this.requestUpdate('freeText', oldFreeText);
|
|
200
|
+
}
|
|
201
|
+
get freeText() {
|
|
202
|
+
return this._freeText;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Control query rate, defaults to 0
|
|
206
|
+
*/
|
|
207
|
+
get queryDebounceRate() {
|
|
208
|
+
return this._queryDebounceRate;
|
|
209
|
+
}
|
|
210
|
+
set queryDebounceRate(value) {
|
|
211
|
+
const oldValue = this._queryDebounceRate;
|
|
212
|
+
if (value !== oldValue) {
|
|
213
|
+
this._queryDebounceRate = value;
|
|
214
|
+
this.queryDebouncer = new TimeoutTaskRunner(this._queryDebounceRate);
|
|
215
|
+
// no need to update as this is called for input changes
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Data array to be displayed
|
|
220
|
+
* @type {ComboBoxData<T>}
|
|
221
|
+
*/
|
|
222
|
+
get data() {
|
|
223
|
+
return this._data;
|
|
224
|
+
}
|
|
225
|
+
set data(value) {
|
|
226
|
+
this._data = value;
|
|
227
|
+
void this.resolveDataPromise(value);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Returns the first selected item value.
|
|
231
|
+
* Use `values` when multiple selection mode is enabled.
|
|
232
|
+
*/
|
|
233
|
+
get value() {
|
|
234
|
+
return this.values[0] || '';
|
|
235
|
+
}
|
|
236
|
+
set value(value) {
|
|
237
|
+
/**
|
|
238
|
+
* Set the value if the data is ready,
|
|
239
|
+
* otherwise cache it for later.
|
|
240
|
+
*/
|
|
241
|
+
if (this.composer.size) {
|
|
242
|
+
this.values = [value];
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
this.cachedValue = value;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Returns a values collection of the currently
|
|
250
|
+
* selected item values
|
|
251
|
+
* @type {string[]}
|
|
252
|
+
*/
|
|
253
|
+
get values() {
|
|
254
|
+
// In free text mode, compare selected to values
|
|
255
|
+
return this.freeTextValue ? [this.freeTextValue] : this.composerValues;
|
|
256
|
+
}
|
|
257
|
+
set values(values) {
|
|
258
|
+
if (!Array.isArray(values)) {
|
|
259
|
+
valueFormatWarning.show();
|
|
260
|
+
this.values = [];
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
// Clone value arrays
|
|
264
|
+
const newValues = values.slice(0, this.multiple ? values.length : 1);
|
|
265
|
+
const oldValues = this.composerValues.slice();
|
|
266
|
+
// Create comparison strings to check for differences
|
|
267
|
+
const newComparison = newValues.sort().toString();
|
|
268
|
+
const oldComparison = oldValues.sort().toString();
|
|
269
|
+
// Should we update the selection state?
|
|
270
|
+
if (newComparison !== oldComparison) {
|
|
271
|
+
this.updateComposerValues(newValues);
|
|
272
|
+
this.requestUpdate('values', oldValues);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Update composer values.
|
|
278
|
+
* @param newValues new values
|
|
279
|
+
* @returns {void}
|
|
280
|
+
*/
|
|
281
|
+
updateComposerValues(newValues) {
|
|
282
|
+
this.queryItems((item, composer) => {
|
|
283
|
+
if (newValues.includes(composer.getItemPropertyValue(item, 'value'))) {
|
|
284
|
+
composer.setItemPropertyValue(item, 'selected', true);
|
|
285
|
+
return true;
|
|
286
|
+
}
|
|
287
|
+
composer.setItemPropertyValue(item, 'selected', false);
|
|
288
|
+
return false;
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Query string applied to combo-box
|
|
293
|
+
* Set via internal text-field input
|
|
294
|
+
* @readonly
|
|
295
|
+
*/
|
|
296
|
+
get query() {
|
|
297
|
+
return this._query;
|
|
298
|
+
}
|
|
299
|
+
set query(query) {
|
|
300
|
+
const oldVal = this._query;
|
|
301
|
+
this._query = query;
|
|
302
|
+
this.queryDebouncer.cancel();
|
|
303
|
+
if (oldVal !== this._query) {
|
|
304
|
+
this.clearHighlighted();
|
|
305
|
+
this.filterItems();
|
|
306
|
+
this.requestUpdate('query', oldVal);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Label of selected value
|
|
311
|
+
* @returns Label to use, defaults to empty string
|
|
312
|
+
* @readonly
|
|
313
|
+
*/
|
|
314
|
+
get label() {
|
|
315
|
+
const labels = this.selectedLabels;
|
|
316
|
+
if (labels.length <= 1) {
|
|
317
|
+
return labels[0] || '';
|
|
318
|
+
}
|
|
319
|
+
// multiple mode, do according to UX specs
|
|
320
|
+
const output = labels.join(MULTIPLE_LABEL_SEPARATOR);
|
|
321
|
+
return output.length > MULTIPLE_LABEL_MAX_SIZE ? `${output.slice(0, MULTIPLE_LABEL_MAX_SIZE - 3)}...` : output;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Get resolved data (if possible)
|
|
325
|
+
*/
|
|
326
|
+
get resolvedData() {
|
|
327
|
+
return this._resolvedData;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Set resolved data
|
|
331
|
+
* @param value resolved data
|
|
332
|
+
*/
|
|
333
|
+
set resolvedData(value) {
|
|
334
|
+
const oldValue = this._resolvedData;
|
|
335
|
+
if (value !== oldValue) {
|
|
336
|
+
if (Array.isArray(value)) {
|
|
337
|
+
this.composer = new CollectionComposer(value);
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
this.composer = new CollectionComposer([]);
|
|
341
|
+
}
|
|
342
|
+
this.listenToComposer();
|
|
343
|
+
this._resolvedData = value;
|
|
344
|
+
/**
|
|
345
|
+
* Select using initialised the value once from attribute/property,
|
|
346
|
+
* only when there is no existing selections.
|
|
347
|
+
*/
|
|
348
|
+
if (this.cachedValue && this.selection.length === 0) {
|
|
349
|
+
this.value = this.cachedValue;
|
|
350
|
+
this.cachedValue = ''; // Reset as it's only needed for initialisation
|
|
351
|
+
}
|
|
352
|
+
this.requestUpdate('data', oldValue);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Used to resolve data when set as a promise
|
|
357
|
+
* @param data Data promise
|
|
358
|
+
* @returns Promise<void>
|
|
359
|
+
*/
|
|
360
|
+
async resolveDataPromise(data) {
|
|
361
|
+
const dataPromiseCounter = this.dataPromiseCounter += 1;
|
|
362
|
+
let resolvedData;
|
|
363
|
+
if (data instanceof Promise) {
|
|
364
|
+
this.loading = true;
|
|
365
|
+
try {
|
|
366
|
+
resolvedData = await data;
|
|
367
|
+
}
|
|
368
|
+
catch (error) {
|
|
369
|
+
resolvedData = [];
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
resolvedData = data;
|
|
374
|
+
}
|
|
375
|
+
if (dataPromiseCounter === this.dataPromiseCounter) {
|
|
376
|
+
this.resolvedData = resolvedData;
|
|
377
|
+
this.loading = false;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* The the values from composer ignoring freeTextValue
|
|
382
|
+
*/
|
|
383
|
+
get composerValues() {
|
|
384
|
+
return this.queryItemsByPropertyValue('selected', true)
|
|
385
|
+
.map(item => this.getItemPropertyValue(item, 'value'));
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Return currently selected items
|
|
389
|
+
* This is distinct from values as for controls with persistence features
|
|
390
|
+
* it can be used to show current selection count and get the selection labels
|
|
391
|
+
* @returns List of selected items
|
|
392
|
+
*/
|
|
393
|
+
get selection() {
|
|
394
|
+
return this.queryItemsByPropertyValue('selected', true).slice();
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Count of selected items
|
|
398
|
+
* @returns Has selection
|
|
399
|
+
*/
|
|
400
|
+
get selectionCount() {
|
|
401
|
+
return this.selection.length;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Determine if list has visible items
|
|
405
|
+
* @returns List has visible items or not
|
|
406
|
+
*/
|
|
407
|
+
get listHasVisibleItems() {
|
|
408
|
+
return this.resolvedData.some(item => !this.getItemPropertyValue(item, 'hidden'));
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Selected item
|
|
412
|
+
* @returns Has selection
|
|
413
|
+
*/
|
|
414
|
+
get selectedItem() {
|
|
415
|
+
return this.queryItemsByPropertyValue('selected', true)[0];
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Get a list of selected item labels
|
|
419
|
+
* @returns Has selection
|
|
420
|
+
*/
|
|
421
|
+
get selectedLabels() {
|
|
422
|
+
return this.selection.map(selected => this.getItemPropertyValue(selected, 'label') || '');
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Utility method - ensures correct composer is being listened to
|
|
426
|
+
* @returns {void}
|
|
427
|
+
*/
|
|
428
|
+
listenToComposer() {
|
|
429
|
+
this.composer.on('modification', // Listen for modifications
|
|
430
|
+
this.modificationHandler // Update the template
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Updates the element
|
|
435
|
+
* @param changedProperties Properties that has changed
|
|
436
|
+
* @returns {void}
|
|
437
|
+
*/
|
|
438
|
+
update(changedProperties) {
|
|
439
|
+
const focusedChanged = changedProperties.has(FocusedPropertyKey);
|
|
440
|
+
// the opened logic is bound to focus state
|
|
441
|
+
if (focusedChanged) {
|
|
442
|
+
// When focus changes the popup can open only on tapstart
|
|
443
|
+
if (this.focused && this.shouldOpenOnFocus) {
|
|
444
|
+
this.setOpened(true);
|
|
445
|
+
}
|
|
446
|
+
else if (!this.focused) {
|
|
447
|
+
this.setOpened(false);
|
|
448
|
+
}
|
|
449
|
+
this.shouldOpenOnFocus = false;
|
|
450
|
+
}
|
|
451
|
+
/*
|
|
452
|
+
* data can be visible and opened changed = open
|
|
453
|
+
* or, opened is true and data; and contains visible data = open
|
|
454
|
+
* queries local properties first to short circuit querying map iteration
|
|
455
|
+
*/
|
|
456
|
+
if (changedProperties.has('opened')) {
|
|
457
|
+
if (this.opened) {
|
|
458
|
+
// fulfil any queries if opened is changed
|
|
459
|
+
// this is the case if keyboard navigation is used
|
|
460
|
+
this.queryDebouncer.fulfil();
|
|
461
|
+
this.opening();
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
this.clearHighlighted();
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
// combo-box may be opened programmatically (via opened attribute)
|
|
468
|
+
// make sure that the element correctly reacts on this change
|
|
469
|
+
if ((changedProperties.has('data') && this.opened && !this.focused) || focusedChanged) {
|
|
470
|
+
this.resetInput();
|
|
471
|
+
}
|
|
472
|
+
// If label is defined it means that there is an actual value
|
|
473
|
+
// Select input text to simplify clearing the value
|
|
474
|
+
if (focusedChanged && this.focused && this.label) {
|
|
475
|
+
this.inputEl.focus();
|
|
476
|
+
this.inputEl.select();
|
|
477
|
+
}
|
|
478
|
+
// Make sure that the first item is always highlighted
|
|
479
|
+
if (this.opened && (changedProperties.has('opened') || changedProperties.has('data') || changedProperties.has('query'))) {
|
|
480
|
+
this.highlightFirstItem();
|
|
481
|
+
}
|
|
482
|
+
// If data is set asynchronously while popup is opened
|
|
483
|
+
// list might not trigger popup update
|
|
484
|
+
if (changedProperties.has('data') && this.opened) {
|
|
485
|
+
this.forcePopupLayout();
|
|
486
|
+
}
|
|
487
|
+
super.update(changedProperties);
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Called once after the component is first rendered
|
|
491
|
+
* @param changedProperties map of changed properties with old values
|
|
492
|
+
* @returns {void}
|
|
493
|
+
*/
|
|
494
|
+
firstUpdated(changedProperties) {
|
|
495
|
+
super.firstUpdated(changedProperties);
|
|
496
|
+
this.addEventListener('keydown', this.onKeyDown);
|
|
497
|
+
this.addEventListener('tapstart', this.onTapStart);
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Sets opened state and fires event
|
|
501
|
+
* Use this to set opened state when user interacts to the component
|
|
502
|
+
* @param opened True if opened
|
|
503
|
+
* @returns {void}
|
|
504
|
+
*/
|
|
505
|
+
setOpened(opened) {
|
|
506
|
+
if (this.opened !== opened && this.notifyPropertyChange('opened', opened, true)) {
|
|
507
|
+
this.opened = opened;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Requests an update after a composer modification.
|
|
512
|
+
* @returns {void}
|
|
513
|
+
*/
|
|
514
|
+
modificationUpdate() {
|
|
515
|
+
this.requestUpdate();
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Queries the composer for data items
|
|
519
|
+
* @param engine Composer query engine
|
|
520
|
+
* @returns Collection of matched items
|
|
521
|
+
*/
|
|
522
|
+
queryItems(engine) {
|
|
523
|
+
return this.composer.queryItems(engine);
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Queries the composer for data items,
|
|
527
|
+
* matching by property value.
|
|
528
|
+
* @param property Property name to query
|
|
529
|
+
* @param value Property value to match against
|
|
530
|
+
* @returns Collection of matched items
|
|
531
|
+
*/
|
|
532
|
+
queryItemsByPropertyValue(property, value) {
|
|
533
|
+
return this.composer.queryItemsByPropertyValue(property, value, 0);
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Gets the property value of an item
|
|
537
|
+
* @param item Original data item
|
|
538
|
+
* @param property Property name to get the value of
|
|
539
|
+
* @returns Value of the property
|
|
540
|
+
*/
|
|
541
|
+
getItemPropertyValue(item, property) {
|
|
542
|
+
return this.composer.getItemPropertyValue(item, property);
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* Sets the property value of an item
|
|
546
|
+
* @param item Original data item
|
|
547
|
+
* @param property Property name to set the value of
|
|
548
|
+
* @param value New value of the property
|
|
549
|
+
* @returns {void}
|
|
550
|
+
*/
|
|
551
|
+
setItemPropertyValue(item, property, value) {
|
|
552
|
+
this.composer.setItemPropertyValue(item, property, value);
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Set width on popup using parent and --list-max-width if set
|
|
556
|
+
* @returns {void}
|
|
557
|
+
*/
|
|
558
|
+
opening() {
|
|
559
|
+
this.lazyRendered = true;
|
|
560
|
+
this.restrictPopupWidth();
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Scrolls to the currently selected item
|
|
564
|
+
* @returns {void}
|
|
565
|
+
*/
|
|
566
|
+
scrollToSelected() {
|
|
567
|
+
var _a;
|
|
568
|
+
const item = this.selectedItem;
|
|
569
|
+
if (item) {
|
|
570
|
+
(_a = this.listEl) === null || _a === void 0 ? void 0 : _a.scrollToItem(item);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* Highlights the item
|
|
575
|
+
* @param item data item to highlight
|
|
576
|
+
* @returns {void}
|
|
577
|
+
*/
|
|
578
|
+
highlightItem(item) {
|
|
579
|
+
this.clearHighlighted();
|
|
580
|
+
this.setItemPropertyValue(item, 'highlighted', true);
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Clears any highlighted items
|
|
584
|
+
* @returns {void}
|
|
585
|
+
*/
|
|
586
|
+
clearHighlighted() {
|
|
587
|
+
this.queryItemsByPropertyValue('highlighted', true)
|
|
588
|
+
.forEach(item => this.setItemPropertyValue(item, 'highlighted', false));
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* Popup has to use max width if --list-max-width specified
|
|
592
|
+
* otherwise, popup should have same width as control or wider
|
|
593
|
+
* @returns {void}
|
|
594
|
+
*/
|
|
595
|
+
restrictPopupWidth() {
|
|
596
|
+
/* istanbul ignore next */
|
|
597
|
+
if (this.offsetWidth === 0) {
|
|
598
|
+
// this code might happen only when opened has been set during initialisation
|
|
599
|
+
// or when display is set to none
|
|
600
|
+
this.resizeThrottler.schedule(() => {
|
|
601
|
+
if (this.offsetWidth) { /* must be here to avoid infinitive loop */
|
|
602
|
+
this.restrictPopupWidth();
|
|
603
|
+
this.requestUpdate();
|
|
604
|
+
}
|
|
605
|
+
});
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
const maxWidth = parseFloat(this.getComputedVariable('--list-max-width', 'none'));
|
|
609
|
+
let minWidth = this.offsetWidth;
|
|
610
|
+
// reset min-width if max-width less than min-width, otherwise browser won't apply max-width
|
|
611
|
+
if (maxWidth < minWidth) {
|
|
612
|
+
minWidth = 0;
|
|
613
|
+
}
|
|
614
|
+
this.popupDynamicStyles.minWidth = `${minWidth}px`;
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Set the query string and run `query-change` event
|
|
618
|
+
* @param query query
|
|
619
|
+
* @returns void
|
|
620
|
+
*/
|
|
621
|
+
setQuery(query) {
|
|
622
|
+
const oldQuery = this.query;
|
|
623
|
+
this.query = query; // reset debouncer here
|
|
624
|
+
if (oldQuery !== query) {
|
|
625
|
+
this.notifyPropertyChange('query', this.query);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Reset the input text to match label
|
|
630
|
+
* @returns {void}
|
|
631
|
+
*/
|
|
632
|
+
resetInput() {
|
|
633
|
+
this.setQuery('');
|
|
634
|
+
this.inputText = this.multiple ? '' : (this.freeTextValue || this.label);
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Filter the internal items by query
|
|
638
|
+
* Changes items' hidden state
|
|
639
|
+
* @returns {void}
|
|
640
|
+
*/
|
|
641
|
+
filterItems() {
|
|
642
|
+
// if filter is null, it is off and external app is responsible
|
|
643
|
+
if (this.filter) {
|
|
644
|
+
// we do not produce a new list as it will loose all association with this composer
|
|
645
|
+
// unless we spent time re-applying this composer to a new list/composer
|
|
646
|
+
// instead we change the hidden state
|
|
647
|
+
// by list applying a queryItems itself and does not render hidden items
|
|
648
|
+
// filter declared here to avoid the possibility of being null if used directly in the callback
|
|
649
|
+
const filter = this.filter;
|
|
650
|
+
let groupHeaderItem = null;
|
|
651
|
+
this.queryItems((item, composer) => {
|
|
652
|
+
// do not filter hidden items
|
|
653
|
+
if (item.hidden) {
|
|
654
|
+
return false;
|
|
655
|
+
}
|
|
656
|
+
let result = false;
|
|
657
|
+
// support groups
|
|
658
|
+
if (composer.getItemPropertyValue(item, 'type') === 'header') {
|
|
659
|
+
groupHeaderItem = item;
|
|
660
|
+
}
|
|
661
|
+
else {
|
|
662
|
+
result = filter(item);
|
|
663
|
+
}
|
|
664
|
+
composer.setItemPropertyValue(item, 'hidden', !result);
|
|
665
|
+
composer.updateItemTimestamp(item);
|
|
666
|
+
if (result && groupHeaderItem && composer.getItemParent(groupHeaderItem) === composer.getItemParent(item)) {
|
|
667
|
+
composer.setItemPropertyValue(groupHeaderItem, 'hidden', false);
|
|
668
|
+
composer.updateItemTimestamp(groupHeaderItem);
|
|
669
|
+
groupHeaderItem = null;
|
|
670
|
+
}
|
|
671
|
+
return result;
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
this.forcePopupLayout();
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Highlight the selected item or the first available item
|
|
678
|
+
* @returns {void}
|
|
679
|
+
*/
|
|
680
|
+
highlightFirstItem() {
|
|
681
|
+
let selectedItem = null;
|
|
682
|
+
const highlightItem = this.queryItems((item, composer) => {
|
|
683
|
+
if (selectedItem || !this.canHighlightItem(item, composer)) {
|
|
684
|
+
return false;
|
|
685
|
+
}
|
|
686
|
+
if (composer.getItemPropertyValue(item, 'selected') === true) {
|
|
687
|
+
selectedItem = item;
|
|
688
|
+
}
|
|
689
|
+
return true;
|
|
690
|
+
})[0];
|
|
691
|
+
(selectedItem || highlightItem) && this.highlightItem(selectedItem || highlightItem);
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Check if an item can be highlighted
|
|
695
|
+
* @param item Collection composer item
|
|
696
|
+
* @param composer Collection composer
|
|
697
|
+
* @returns can highlight
|
|
698
|
+
*/
|
|
699
|
+
canHighlightItem(item, composer) {
|
|
700
|
+
let canHighlight = !(composer.getItemPropertyValue(item, 'hidden') === true
|
|
701
|
+
|| (composer.getItemPropertyValue(item, 'type') || 'text') !== 'text'
|
|
702
|
+
|| composer.getItemPropertyValue(item, 'disabled') === true
|
|
703
|
+
|| composer.isItemLocked(item) === true);
|
|
704
|
+
// check ancestors
|
|
705
|
+
if (canHighlight) {
|
|
706
|
+
const parent = composer.getItemParent(item);
|
|
707
|
+
canHighlight = !parent || this.canHighlightItem(parent, composer);
|
|
708
|
+
}
|
|
709
|
+
return canHighlight;
|
|
710
|
+
}
|
|
711
|
+
/**
|
|
712
|
+
* https://github.com/juggle/resize-observer/issues/42
|
|
713
|
+
*
|
|
714
|
+
* This event ensures that ResizeObserver picks up resize events
|
|
715
|
+
* when popup is deeply nested inside shadow root.
|
|
716
|
+
* TODO: remove this workaround once ResizeObserver handles shadow root scenario
|
|
717
|
+
* @returns {void}
|
|
718
|
+
*/
|
|
719
|
+
forcePopupLayout() {
|
|
720
|
+
window.dispatchEvent(new Event('animationiteration'));
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
* Shift focus back to input.
|
|
724
|
+
* This method is required to prevent popup from focusing
|
|
725
|
+
* @returns {void}
|
|
726
|
+
*/
|
|
727
|
+
shiftFocus() {
|
|
728
|
+
this.focus({
|
|
729
|
+
preventScroll: true
|
|
730
|
+
});
|
|
731
|
+
}
|
|
732
|
+
/**
|
|
733
|
+
* Handle text value change from text-field
|
|
734
|
+
* @param event Custom Event fired from text-field
|
|
735
|
+
* @returns {void}
|
|
736
|
+
*/
|
|
737
|
+
onInputValueChanged(event) {
|
|
738
|
+
const inputText = event.detail.value;
|
|
739
|
+
/**
|
|
740
|
+
* Query is used to track if there is a query
|
|
741
|
+
* We always use it so the absence of it can be used to reapply the
|
|
742
|
+
* selected item's label, if applicable
|
|
743
|
+
*/
|
|
744
|
+
this.queryDebouncer.schedule(() => {
|
|
745
|
+
this.setQuery(inputText);
|
|
746
|
+
});
|
|
747
|
+
// Reset text when clearing the value
|
|
748
|
+
if (!this.multiple && !inputText) {
|
|
749
|
+
this.setValueAndNotify('');
|
|
750
|
+
}
|
|
751
|
+
// always ensure that internal val matches input val
|
|
752
|
+
this.inputText = inputText;
|
|
753
|
+
// Used for free input. Never set it unless in free text mode
|
|
754
|
+
if (this.freeText) {
|
|
755
|
+
this.value = ''; // make sure that composer does not have selected
|
|
756
|
+
this.freeTextValue = inputText;
|
|
757
|
+
this.notifyPropertyChange('value', inputText);
|
|
758
|
+
}
|
|
759
|
+
this.setOpened(true);
|
|
760
|
+
}
|
|
761
|
+
/**
|
|
762
|
+
* Handle list value changed
|
|
763
|
+
* @returns {void}
|
|
764
|
+
*/
|
|
765
|
+
onListValueChanged() {
|
|
766
|
+
// cascade value changed event
|
|
767
|
+
this.notifyPropertyChange('value', this.value);
|
|
768
|
+
this.onListInteraction();
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* Handle popup opened event
|
|
772
|
+
*
|
|
773
|
+
* Scrolls the current selection into view
|
|
774
|
+
* @returns {void}
|
|
775
|
+
*/
|
|
776
|
+
onPopupOpened() {
|
|
777
|
+
this.scrollToSelected();
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Handle popup closed event
|
|
781
|
+
*
|
|
782
|
+
* Ensures that popup state equals combo box opened prop
|
|
783
|
+
* @returns {void}
|
|
784
|
+
*/
|
|
785
|
+
onPopupClosed() {
|
|
786
|
+
this.setOpened(false);
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* Run when input-wrapper is tapped
|
|
790
|
+
* @param event Tap event
|
|
791
|
+
* @returns {void}
|
|
792
|
+
*/
|
|
793
|
+
onTapStart(event) {
|
|
794
|
+
// do nothing if disabled or readonly
|
|
795
|
+
if (this.readonly || this.disabled) {
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
const path = event.composedPath();
|
|
799
|
+
if (this.clearsButtonEl && path.includes(this.clearsButtonEl)) {
|
|
800
|
+
this.onClearsButtonTap();
|
|
801
|
+
return;
|
|
802
|
+
}
|
|
803
|
+
if (path.includes(this.toggleButtonEl)) {
|
|
804
|
+
this.onToggleButtonTap();
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
this.onInputWrapperTap();
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Run when tap event happens on toggle button
|
|
811
|
+
* @returns {void}
|
|
812
|
+
*/
|
|
813
|
+
onToggleButtonTap() {
|
|
814
|
+
if (this.opened) {
|
|
815
|
+
this.setOpened(false);
|
|
816
|
+
}
|
|
817
|
+
else {
|
|
818
|
+
this.openOnFocus();
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Run when tap event happens on clears button
|
|
823
|
+
* @returns {void}
|
|
824
|
+
*/
|
|
825
|
+
onClearsButtonTap() {
|
|
826
|
+
this.freeTextValue = '';
|
|
827
|
+
this.inputText = '';
|
|
828
|
+
this.setQuery('');
|
|
829
|
+
this.setValueAndNotify('');
|
|
830
|
+
this.openOnFocus();
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Run when tap event happens on input wrapper
|
|
834
|
+
* excluding clears and toggles buttons
|
|
835
|
+
* @returns {void}
|
|
836
|
+
*/
|
|
837
|
+
onInputWrapperTap() {
|
|
838
|
+
this.openOnFocus();
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* This flag is required to remove the frame gap
|
|
842
|
+
* between tap start and opening the popup
|
|
843
|
+
* @returns {void}
|
|
844
|
+
*/
|
|
845
|
+
openOnFocus() {
|
|
846
|
+
if (this.opened) {
|
|
847
|
+
return;
|
|
848
|
+
}
|
|
849
|
+
if (this.focused) {
|
|
850
|
+
this.setOpened(true);
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
this.shouldOpenOnFocus = true;
|
|
854
|
+
}
|
|
855
|
+
/**
|
|
856
|
+
* Handles key input
|
|
857
|
+
* @param event Key down event object
|
|
858
|
+
* @returns {void}
|
|
859
|
+
*/
|
|
860
|
+
onKeyDown(event) {
|
|
861
|
+
// Check if the event is already handle by list
|
|
862
|
+
if (event.defaultPrevented) {
|
|
863
|
+
return;
|
|
864
|
+
}
|
|
865
|
+
switch (event.key) {
|
|
866
|
+
case 'Enter':
|
|
867
|
+
this.enter(event);
|
|
868
|
+
break;
|
|
869
|
+
case 'Up':
|
|
870
|
+
case 'ArrowUp':
|
|
871
|
+
this.up(event);
|
|
872
|
+
break;
|
|
873
|
+
case 'Down':
|
|
874
|
+
case 'ArrowDown':
|
|
875
|
+
this.down(event);
|
|
876
|
+
break;
|
|
877
|
+
default:
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
880
|
+
event.preventDefault();
|
|
881
|
+
}
|
|
882
|
+
/**
|
|
883
|
+
* Run when tap event or enter
|
|
884
|
+
* happened on the list
|
|
885
|
+
* @returns {void}
|
|
886
|
+
*/
|
|
887
|
+
onListInteraction() {
|
|
888
|
+
this.freeTextValue = ''; // when the item has been selected, reset the freeText
|
|
889
|
+
if (!this.multiple) {
|
|
890
|
+
this.resetInput();
|
|
891
|
+
const label = this.label;
|
|
892
|
+
this.setOpened(false);
|
|
893
|
+
// make sure that focus is kept withing an element
|
|
894
|
+
// and the cursor is positioned at the end of input
|
|
895
|
+
// Wait before the update cycle completes
|
|
896
|
+
void this.updateComplete.then(() => {
|
|
897
|
+
this.inputEl.focus();
|
|
898
|
+
this.inputEl.setSelectionRange(label.length, label.length);
|
|
899
|
+
});
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Handles action keys, either opening the list,
|
|
904
|
+
* or, selecting a highlighted item.
|
|
905
|
+
* @param event keyboard event
|
|
906
|
+
* @returns {void}
|
|
907
|
+
*/
|
|
908
|
+
enter(event) {
|
|
909
|
+
if (this.opened && this.listEl) {
|
|
910
|
+
this.reTargetEvent(event, this.listEl);
|
|
911
|
+
this.onListInteraction();
|
|
912
|
+
}
|
|
913
|
+
else {
|
|
914
|
+
this.setOpened(true);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
/**
|
|
918
|
+
* Navigates up the list.
|
|
919
|
+
* Opens the list if closed.
|
|
920
|
+
* @param event keyboard event
|
|
921
|
+
* @returns {void}
|
|
922
|
+
*/
|
|
923
|
+
up(event) {
|
|
924
|
+
if (this.opened && this.listEl) {
|
|
925
|
+
this.reTargetEvent(event, this.listEl);
|
|
926
|
+
}
|
|
927
|
+
else {
|
|
928
|
+
this.setOpened(true);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* Navigates down the list.
|
|
933
|
+
* Opens the list if closed.
|
|
934
|
+
* @param event keyboard event
|
|
935
|
+
* @returns {void}
|
|
936
|
+
*/
|
|
937
|
+
down(event) {
|
|
938
|
+
if (this.opened && this.listEl) {
|
|
939
|
+
this.reTargetEvent(event, this.listEl);
|
|
940
|
+
}
|
|
941
|
+
else {
|
|
942
|
+
this.setOpened(true);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
/**
|
|
946
|
+
* Retarget event to target element
|
|
947
|
+
* @param event keyboard event
|
|
948
|
+
* @param target new target element
|
|
949
|
+
* @returns re-targeted event or the passed event if target is invalid
|
|
950
|
+
*/
|
|
951
|
+
reTargetEvent(event, target) {
|
|
952
|
+
const path = event.composedPath();
|
|
953
|
+
/* istanbul ignore next */
|
|
954
|
+
if (path[0] === target) {
|
|
955
|
+
// this must not happen, but keep it here to avoid infinitive loop
|
|
956
|
+
return event;
|
|
957
|
+
}
|
|
958
|
+
const keyboardEvent = new CustomKeyboardEvent(event.type, event);
|
|
959
|
+
target.dispatchEvent(keyboardEvent);
|
|
960
|
+
if (keyboardEvent.defaultPrevented) {
|
|
961
|
+
event.preventDefault();
|
|
962
|
+
}
|
|
963
|
+
return keyboardEvent;
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* Template for clear button
|
|
967
|
+
* Rendered when `clears` attribute is set
|
|
968
|
+
* @returns Popup template or undefined
|
|
969
|
+
*/
|
|
970
|
+
get clearButtonTemplate() {
|
|
971
|
+
if (this.clears) {
|
|
972
|
+
return html `
|
|
973
|
+
<div
|
|
974
|
+
id="clears-button"
|
|
975
|
+
part="button button-clear"
|
|
976
|
+
?hidden=${!this.label && !this.query && !this.freeTextValue && !this.inputText}><ef-icon part="icon icon-clear" icon="cross"></ef-icon>
|
|
977
|
+
</div>
|
|
978
|
+
`;
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
/**
|
|
982
|
+
* Template for selection badge in multiple mode
|
|
983
|
+
* @returns Selection badge template or undefined
|
|
984
|
+
*/
|
|
985
|
+
get selectionBadgeTemplate() {
|
|
986
|
+
if (this.multiple) {
|
|
987
|
+
const selectionLength = this.selectionCount;
|
|
988
|
+
// TODO Make this a short format number using i18n which has specific support for this +
|
|
989
|
+
// benefit of being localised too
|
|
990
|
+
if (this.focused || selectionLength > 1) {
|
|
991
|
+
return html `
|
|
992
|
+
<ef-counter part="selection-badge" tabindex="-1" .value=${selectionLength} title=${ifDefined(selectionLength > 999 ? selectionLength.toLocaleString() : undefined)} max="999"></ef-counter>
|
|
993
|
+
`;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
/**
|
|
998
|
+
* Returns a list template
|
|
999
|
+
*/
|
|
1000
|
+
get listTemplate() {
|
|
1001
|
+
return html `
|
|
1002
|
+
<ef-list
|
|
1003
|
+
id="internal-list"
|
|
1004
|
+
@value-changed="${this.onListValueChanged}"
|
|
1005
|
+
.data="${this.composer}"
|
|
1006
|
+
.multiple="${this.multiple}"
|
|
1007
|
+
.renderer="${this.renderer}"
|
|
1008
|
+
></ef-list>
|
|
1009
|
+
`;
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Returns a template showing no options text
|
|
1013
|
+
* Called when freeText mode is off and all items are filtered out
|
|
1014
|
+
*/
|
|
1015
|
+
get noItemsTemplate() {
|
|
1016
|
+
if (!this.freeText) {
|
|
1017
|
+
return html `<ef-item disabled>${this.t('NO_OPTIONS')}</ef-item>`;
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
/**
|
|
1021
|
+
* Returns template for popup
|
|
1022
|
+
* Lazy loads the popup
|
|
1023
|
+
* @returns Popup template or undefined
|
|
1024
|
+
*/
|
|
1025
|
+
get popupTemplate() {
|
|
1026
|
+
if (this.lazyRendered) {
|
|
1027
|
+
const hasVisibleItems = this.listHasVisibleItems;
|
|
1028
|
+
return html `<ef-overlay
|
|
1029
|
+
part="list"
|
|
1030
|
+
style="${styleMap(this.popupDynamicStyles)}"
|
|
1031
|
+
@opened="${this.onPopupOpened}"
|
|
1032
|
+
@closed="${this.onPopupClosed}"
|
|
1033
|
+
.focusBoundary="${this}"
|
|
1034
|
+
.opened="${this.opened && (hasVisibleItems || !this.freeText)}"
|
|
1035
|
+
.positionTarget="${this}"
|
|
1036
|
+
.position="${POPUP_POSITION}"
|
|
1037
|
+
with-shadow
|
|
1038
|
+
no-overlap
|
|
1039
|
+
no-focus-management
|
|
1040
|
+
no-autofocus
|
|
1041
|
+
@focusin="${this.shiftFocus}"
|
|
1042
|
+
>${hasVisibleItems ? this.listTemplate : this.noItemsTemplate}</ef-overlay>`;
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
/**
|
|
1046
|
+
* Returns a template for input field
|
|
1047
|
+
* @returns Input template
|
|
1048
|
+
*/
|
|
1049
|
+
get inputTemplate() {
|
|
1050
|
+
const inputValue = this.focused ? this.inputText : this.freeTextValue || this.label;
|
|
1051
|
+
return html `<div part="input-wrapper">
|
|
1052
|
+
<ef-text-field
|
|
1053
|
+
part="input"
|
|
1054
|
+
transparent
|
|
1055
|
+
.placeholder="${this.placeholder}"
|
|
1056
|
+
.readonly="${this.readonly}"
|
|
1057
|
+
.value="${inputValue}"
|
|
1058
|
+
@value-changed="${this.onInputValueChanged}"></ef-text-field>
|
|
1059
|
+
${this.selectionBadgeTemplate}
|
|
1060
|
+
${this.clearButtonTemplate}
|
|
1061
|
+
<div id="toggle-button" part="button button-toggle">
|
|
1062
|
+
<ef-icon part="icon icon-toggle" icon="down"></ef-icon>
|
|
1063
|
+
</div>
|
|
1064
|
+
</div>`;
|
|
1065
|
+
}
|
|
1066
|
+
/**
|
|
1067
|
+
* A `TemplateResult` that will be used
|
|
1068
|
+
* to render the updated internal template.
|
|
1069
|
+
* @returns Render template
|
|
1070
|
+
*/
|
|
1071
|
+
render() {
|
|
1072
|
+
return html `
|
|
1073
|
+
${this.inputTemplate}
|
|
1074
|
+
${this.popupTemplate}
|
|
1075
|
+
`;
|
|
1076
|
+
}
|
|
1077
|
+
};
|
|
1078
|
+
__decorate([
|
|
1079
|
+
property({ type: Function, attribute: false })
|
|
1080
|
+
], ComboBox.prototype, "filter", void 0);
|
|
1081
|
+
__decorate([
|
|
1082
|
+
property({ type: Function, attribute: false })
|
|
1083
|
+
], ComboBox.prototype, "renderer", void 0);
|
|
1084
|
+
__decorate([
|
|
1085
|
+
property({ type: Boolean })
|
|
1086
|
+
], ComboBox.prototype, "multiple", null);
|
|
1087
|
+
__decorate([
|
|
1088
|
+
property({ type: Boolean, reflect: true })
|
|
1089
|
+
], ComboBox.prototype, "opened", void 0);
|
|
1090
|
+
__decorate([
|
|
1091
|
+
property({ type: String })
|
|
1092
|
+
], ComboBox.prototype, "placeholder", void 0);
|
|
1093
|
+
__decorate([
|
|
1094
|
+
property({ type: Boolean })
|
|
1095
|
+
], ComboBox.prototype, "clears", void 0);
|
|
1096
|
+
__decorate([
|
|
1097
|
+
property({ type: Boolean, attribute: 'free-text' })
|
|
1098
|
+
], ComboBox.prototype, "freeText", null);
|
|
1099
|
+
__decorate([
|
|
1100
|
+
property({ type: Boolean, reflect: true })
|
|
1101
|
+
], ComboBox.prototype, "error", void 0);
|
|
1102
|
+
__decorate([
|
|
1103
|
+
property({ type: Boolean, reflect: true })
|
|
1104
|
+
], ComboBox.prototype, "warning", void 0);
|
|
1105
|
+
__decorate([
|
|
1106
|
+
property({ type: Number, attribute: 'query-debounce-rate' })
|
|
1107
|
+
], ComboBox.prototype, "queryDebounceRate", null);
|
|
1108
|
+
__decorate([
|
|
1109
|
+
property({ attribute: false })
|
|
1110
|
+
], ComboBox.prototype, "data", null);
|
|
1111
|
+
__decorate([
|
|
1112
|
+
property({ type: String })
|
|
1113
|
+
], ComboBox.prototype, "value", null);
|
|
1114
|
+
__decorate([
|
|
1115
|
+
property({ type: Array, attribute: false })
|
|
1116
|
+
], ComboBox.prototype, "values", null);
|
|
1117
|
+
__decorate([
|
|
1118
|
+
property({ type: String, attribute: false })
|
|
1119
|
+
], ComboBox.prototype, "query", null);
|
|
1120
|
+
__decorate([
|
|
1121
|
+
query('[part=input]')
|
|
1122
|
+
], ComboBox.prototype, "inputEl", void 0);
|
|
1123
|
+
__decorate([
|
|
1124
|
+
query('#internal-list')
|
|
1125
|
+
], ComboBox.prototype, "listEl", void 0);
|
|
1126
|
+
__decorate([
|
|
1127
|
+
query('#toggle-button')
|
|
1128
|
+
], ComboBox.prototype, "toggleButtonEl", void 0);
|
|
1129
|
+
__decorate([
|
|
1130
|
+
query('#clears-button')
|
|
1131
|
+
], ComboBox.prototype, "clearsButtonEl", void 0);
|
|
1132
|
+
__decorate([
|
|
1133
|
+
property({ type: String, reflect: true })
|
|
1134
|
+
], ComboBox.prototype, "loading", void 0);
|
|
1135
|
+
__decorate([
|
|
1136
|
+
translate({ scope: 'ef-combo-box' })
|
|
1137
|
+
], ComboBox.prototype, "t", void 0);
|
|
1138
|
+
__decorate([
|
|
1139
|
+
eventOptions({ capture: true })
|
|
1140
|
+
], ComboBox.prototype, "shiftFocus", null);
|
|
1141
|
+
ComboBox = __decorate([
|
|
1142
|
+
customElement('ef-combo-box', {
|
|
1143
|
+
alias: 'coral-combo-box'
|
|
1144
|
+
})
|
|
1145
|
+
], ComboBox);
|
|
1146
|
+
export { ComboBox };
|