@refinitiv-ui/elements 5.0.0-beta.3 → 5.0.0-dev.204
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +325 -73
- package/README.md +13 -2
- package/lib/accordion/custom-elements.json +0 -13
- package/lib/accordion/custom-elements.md +18 -0
- package/lib/accordion/index.d.ts +13 -10
- package/lib/accordion/index.js +15 -18
- package/lib/appstate-bar/custom-elements.json +1 -1
- package/lib/appstate-bar/custom-elements.md +22 -0
- package/lib/appstate-bar/index.d.ts +15 -6
- package/lib/appstate-bar/index.js +17 -11
- package/lib/autosuggest/custom-elements.json +24 -4
- package/lib/autosuggest/custom-elements.md +54 -0
- package/lib/autosuggest/helpers/types.d.ts +22 -1
- package/lib/autosuggest/helpers/types.js +0 -1
- package/lib/autosuggest/helpers/utils.d.ts +2 -2
- package/lib/autosuggest/helpers/utils.js +1 -3
- package/lib/autosuggest/index.d.ts +21 -9
- package/lib/autosuggest/index.js +45 -31
- package/lib/button/custom-elements.json +3 -3
- package/lib/button/custom-elements.md +23 -0
- package/lib/button/index.d.ts +27 -20
- package/lib/button/index.js +92 -74
- package/lib/button/themes/halo/dark/index.js +1 -1
- package/lib/button/themes/halo/light/index.js +1 -1
- package/lib/button/themes/solar/charcoal/index.js +1 -1
- package/lib/button/themes/solar/pearl/index.js +1 -1
- package/lib/button-bar/custom-elements.md +9 -0
- package/lib/button-bar/index.d.ts +60 -4
- package/lib/button-bar/index.js +164 -19
- package/lib/calendar/constants.d.ts +26 -0
- package/lib/calendar/constants.js +28 -0
- package/lib/calendar/custom-elements.json +8 -6
- package/lib/calendar/custom-elements.md +35 -0
- package/lib/calendar/index.d.ts +119 -21
- package/lib/calendar/index.js +512 -157
- package/lib/calendar/locales.d.ts +1 -31
- package/lib/calendar/locales.js +3 -107
- package/lib/calendar/themes/halo/dark/index.js +1 -1
- package/lib/calendar/themes/halo/light/index.js +1 -1
- package/lib/calendar/themes/solar/charcoal/index.js +1 -1
- package/lib/calendar/themes/solar/pearl/index.js +1 -1
- package/lib/calendar/types.d.ts +12 -13
- package/lib/calendar/types.js +1 -7
- package/lib/calendar/utils.d.ts +31 -1
- package/lib/calendar/utils.js +105 -3
- package/lib/canvas/custom-elements.json +9 -7
- package/lib/canvas/custom-elements.md +27 -0
- package/lib/canvas/index.d.ts +14 -6
- package/lib/canvas/index.js +17 -12
- package/lib/card/custom-elements.json +21 -9
- package/lib/card/custom-elements.md +24 -0
- package/lib/card/helpers/types.d.ts +1 -1
- package/lib/card/helpers/types.js +0 -1
- package/lib/card/index.d.ts +67 -20
- package/lib/card/index.js +132 -35
- package/lib/card/themes/halo/dark/index.js +1 -1
- package/lib/card/themes/halo/light/index.js +1 -1
- package/lib/card/themes/solar/charcoal/index.js +1 -1
- package/lib/card/themes/solar/pearl/index.js +1 -1
- package/lib/chart/custom-elements.json +3 -3
- package/lib/chart/custom-elements.md +16 -0
- package/lib/chart/helpers/index.d.ts +2 -0
- package/lib/chart/helpers/index.js +2 -0
- package/lib/chart/helpers/legend.d.ts +2 -2
- package/lib/chart/helpers/legend.js +2 -3
- package/lib/chart/helpers/merge.d.ts +15 -0
- package/lib/chart/helpers/merge.js +28 -0
- package/lib/chart/helpers/types.d.ts +40 -12
- package/lib/chart/helpers/types.js +0 -1
- package/lib/chart/index.d.ts +34 -26
- package/lib/chart/index.js +58 -55
- package/lib/chart/plugins/doughnut-center-label.js +4 -5
- package/lib/checkbox/custom-elements.json +4 -4
- package/lib/checkbox/custom-elements.md +18 -0
- package/lib/checkbox/index.d.ts +29 -14
- package/lib/checkbox/index.js +65 -34
- package/lib/checkbox/themes/halo/dark/index.js +1 -1
- package/lib/checkbox/themes/halo/light/index.js +1 -1
- package/lib/clock/custom-elements.json +21 -4
- package/lib/clock/custom-elements.md +28 -0
- package/lib/clock/index.d.ts +25 -6
- package/lib/clock/index.js +44 -18
- package/lib/clock/themes/halo/dark/index.js +1 -1
- package/lib/clock/themes/halo/light/index.js +1 -1
- package/lib/clock/themes/solar/charcoal/index.js +1 -1
- package/lib/clock/themes/solar/pearl/index.js +1 -1
- package/lib/clock/utils/TickManager.js +2 -3
- package/lib/clock/utils/timestamps.js +0 -1
- package/lib/collapse/custom-elements.md +27 -0
- package/lib/collapse/index.d.ts +15 -8
- package/lib/collapse/index.js +18 -13
- package/lib/color-dialog/custom-elements.json +29 -16
- package/lib/color-dialog/custom-elements.md +39 -0
- package/lib/color-dialog/elements/color-palettes.d.ts +13 -6
- package/lib/color-dialog/elements/color-palettes.js +16 -13
- package/lib/color-dialog/elements/grayscale-palettes.d.ts +13 -6
- package/lib/color-dialog/elements/grayscale-palettes.js +17 -13
- package/lib/color-dialog/elements/palettes.d.ts +15 -3
- package/lib/color-dialog/elements/palettes.js +65 -45
- package/lib/color-dialog/helpers/color-helpers.d.ts +7 -53
- package/lib/color-dialog/helpers/color-helpers.js +12 -110
- package/lib/color-dialog/helpers/value-model.d.ts +1 -1
- package/lib/color-dialog/helpers/value-model.js +18 -17
- package/lib/color-dialog/index.d.ts +27 -20
- package/lib/color-dialog/index.js +54 -45
- package/lib/combo-box/custom-elements.json +51 -17
- package/lib/combo-box/custom-elements.md +42 -0
- package/lib/combo-box/helpers/filter.d.ts +4 -4
- package/lib/combo-box/helpers/filter.js +0 -1
- package/lib/combo-box/helpers/keyboard-event.js +0 -1
- package/lib/combo-box/helpers/renderer.d.ts +8 -0
- package/lib/combo-box/helpers/renderer.js +24 -0
- package/lib/combo-box/helpers/types.d.ts +2 -2
- package/lib/combo-box/helpers/types.js +0 -1
- package/lib/combo-box/index.d.ts +63 -32
- package/lib/combo-box/index.js +102 -60
- package/lib/combo-box/themes/halo/dark/index.js +2 -3
- package/lib/combo-box/themes/halo/light/index.js +2 -3
- package/lib/combo-box/themes/solar/charcoal/index.js +2 -3
- package/lib/combo-box/themes/solar/pearl/index.js +2 -3
- package/lib/counter/custom-elements.json +39 -0
- package/lib/counter/custom-elements.md +11 -0
- package/lib/counter/index.d.ts +91 -0
- package/lib/counter/index.js +154 -0
- package/lib/counter/themes/halo/dark/index.js +3 -0
- package/lib/counter/themes/halo/light/index.js +3 -0
- package/lib/counter/themes/solar/charcoal/index.js +3 -0
- package/lib/counter/themes/solar/pearl/index.js +3 -0
- package/lib/counter/utils.d.ts +13 -0
- package/lib/counter/utils.js +52 -0
- package/lib/datetime-picker/custom-elements.json +53 -24
- package/lib/datetime-picker/custom-elements.md +57 -0
- package/lib/datetime-picker/index.d.ts +34 -16
- package/lib/datetime-picker/index.js +56 -38
- package/lib/datetime-picker/locales.d.ts +1 -1
- package/lib/datetime-picker/locales.js +12 -2
- package/lib/datetime-picker/themes/solar/charcoal/index.js +1 -1
- package/lib/datetime-picker/themes/solar/pearl/index.js +1 -1
- package/lib/datetime-picker/types.d.ts +1 -1
- package/lib/datetime-picker/types.js +0 -1
- package/lib/datetime-picker/utils.js +1 -2
- package/lib/dialog/custom-elements.json +34 -12
- package/lib/dialog/custom-elements.md +47 -0
- package/lib/dialog/draggable-element.js +25 -16
- package/lib/dialog/index.d.ts +25 -21
- package/lib/dialog/index.js +36 -32
- package/lib/email-field/custom-elements.json +81 -94
- package/lib/email-field/custom-elements.md +37 -0
- package/lib/email-field/index.d.ts +47 -112
- package/lib/email-field/index.js +48 -241
- package/lib/email-field/themes/halo/dark/index.js +1 -1
- package/lib/email-field/themes/halo/light/index.js +1 -1
- package/lib/email-field/themes/solar/charcoal/index.js +1 -1
- package/lib/email-field/themes/solar/pearl/index.js +1 -1
- package/lib/events.d.ts +121 -0
- package/lib/events.js +1 -0
- package/lib/flag/custom-elements.md +10 -0
- package/lib/flag/index.d.ts +14 -5
- package/lib/flag/index.js +19 -12
- package/lib/flag/utils/FlagLoader.d.ts +1 -1
- package/lib/flag/utils/FlagLoader.js +1 -2
- package/lib/header/custom-elements.md +18 -0
- package/lib/header/index.d.ts +10 -3
- package/lib/header/index.js +12 -8
- package/lib/heatmap/custom-elements.json +13 -0
- package/lib/heatmap/custom-elements.md +26 -0
- package/lib/heatmap/helpers/color.d.ts +1 -1
- package/lib/heatmap/helpers/color.js +1 -2
- package/lib/heatmap/helpers/text.d.ts +1 -1
- package/lib/heatmap/helpers/text.js +0 -1
- package/lib/heatmap/helpers/track.js +2 -3
- package/lib/heatmap/helpers/types.js +0 -1
- package/lib/heatmap/index.d.ts +32 -13
- package/lib/heatmap/index.js +61 -35
- package/lib/icon/custom-elements.json +6 -4
- package/lib/icon/custom-elements.md +8 -0
- package/lib/icon/index.d.ts +17 -7
- package/lib/icon/index.js +36 -18
- package/lib/icon/utils/IconLoader.d.ts +6 -1
- package/lib/icon/utils/IconLoader.js +24 -18
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -1
- package/lib/interactive-chart/custom-elements.json +5 -11
- package/lib/interactive-chart/custom-elements.md +31 -0
- package/lib/interactive-chart/helpers/merge.d.ts +15 -0
- package/lib/interactive-chart/helpers/merge.js +28 -0
- package/lib/interactive-chart/helpers/types.d.ts +10 -9
- package/lib/interactive-chart/helpers/types.js +6 -2
- package/lib/interactive-chart/index.d.ts +37 -18
- package/lib/interactive-chart/index.js +61 -51
- package/lib/item/custom-elements.json +4 -4
- package/lib/item/custom-elements.md +29 -0
- package/lib/item/helpers/types.d.ts +1 -1
- package/lib/item/helpers/types.js +0 -1
- package/lib/item/index.d.ts +26 -9
- package/lib/item/index.js +43 -16
- package/lib/label/custom-elements.json +7 -16
- package/lib/label/custom-elements.md +11 -0
- package/lib/label/index.d.ts +41 -73
- package/lib/label/index.js +150 -187
- package/lib/layout/custom-elements.md +26 -0
- package/lib/layout/index.d.ts +11 -4
- package/lib/layout/index.js +13 -9
- package/lib/led-gauge/custom-elements.json +4 -4
- package/lib/led-gauge/custom-elements.md +17 -0
- package/lib/led-gauge/index.d.ts +13 -5
- package/lib/led-gauge/index.js +16 -11
- package/lib/list/custom-elements.json +37 -5
- package/lib/list/custom-elements.md +33 -0
- package/lib/list/extensible-function.js +2 -1
- package/lib/list/helpers/list-renderer.d.ts +2 -2
- package/lib/list/helpers/list-renderer.js +4 -3
- package/lib/list/helpers/types.d.ts +2 -2
- package/lib/list/helpers/types.js +0 -1
- package/lib/list/index.d.ts +47 -12
- package/lib/list/index.js +100 -39
- package/lib/list/renderer.d.ts +2 -2
- package/lib/list/renderer.js +1 -2
- package/lib/loader/custom-elements.md +5 -0
- package/lib/loader/index.d.ts +8 -1
- package/lib/loader/index.js +11 -8
- package/lib/multi-input/custom-elements.json +7 -6
- package/lib/multi-input/custom-elements.md +43 -0
- package/lib/multi-input/helpers/types.d.ts +1 -1
- package/lib/multi-input/helpers/types.js +0 -1
- package/lib/multi-input/index.d.ts +19 -8
- package/lib/multi-input/index.js +28 -18
- package/lib/multi-input/themes/solar/charcoal/index.js +1 -1
- package/lib/multi-input/themes/solar/pearl/index.js +1 -1
- package/lib/notification/custom-elements.md +26 -0
- package/lib/notification/elements/notification-tray.d.ts +10 -4
- package/lib/notification/elements/notification-tray.js +15 -11
- package/lib/notification/elements/notification.d.ts +19 -7
- package/lib/notification/elements/notification.js +25 -13
- package/lib/notification/helpers/status.d.ts +1 -1
- package/lib/notification/helpers/status.js +1 -2
- package/lib/notification/helpers/types.d.ts +1 -1
- package/lib/notification/helpers/types.js +0 -1
- package/lib/notification/index.d.ts +2 -2
- package/lib/notification/index.js +2 -3
- package/lib/number-field/custom-elements.json +99 -54
- package/lib/number-field/custom-elements.md +42 -0
- package/lib/number-field/index.d.ts +104 -52
- package/lib/number-field/index.js +129 -88
- package/lib/number-field/themes/halo/dark/index.js +1 -1
- package/lib/number-field/themes/halo/light/index.js +1 -1
- package/lib/number-field/themes/solar/charcoal/index.js +1 -1
- package/lib/number-field/themes/solar/pearl/index.js +1 -1
- package/lib/overlay/custom-elements.json +26 -13
- package/lib/overlay/custom-elements.md +54 -0
- package/lib/overlay/elements/overlay-backdrop.d.ts +12 -5
- package/lib/overlay/elements/overlay-backdrop.js +13 -9
- package/lib/overlay/elements/overlay-viewport.d.ts +11 -4
- package/lib/overlay/elements/overlay-viewport.js +12 -9
- package/lib/overlay/elements/overlay.d.ts +18 -6
- package/lib/overlay/elements/overlay.js +35 -28
- package/lib/overlay/helpers/functions.js +0 -1
- package/lib/overlay/helpers/types.js +0 -1
- package/lib/overlay/index.d.ts +2 -2
- package/lib/overlay/index.js +1 -2
- package/lib/overlay/managers/backdrop-manager.d.ts +2 -2
- package/lib/overlay/managers/backdrop-manager.js +2 -3
- package/lib/overlay/managers/close-manager.d.ts +1 -1
- package/lib/overlay/managers/close-manager.js +1 -2
- package/lib/overlay/managers/focus-manager.d.ts +1 -1
- package/lib/overlay/managers/focus-manager.js +3 -5
- package/lib/overlay/managers/interaction-lock-manager.js +2 -3
- package/lib/overlay/managers/viewport-manager.d.ts +3 -3
- package/lib/overlay/managers/viewport-manager.js +6 -3
- package/lib/overlay/managers/zindex-manager.d.ts +1 -1
- package/lib/overlay/managers/zindex-manager.js +1 -4
- package/lib/overlay-menu/custom-elements.json +126 -12
- package/lib/overlay-menu/custom-elements.md +44 -0
- package/lib/overlay-menu/helpers/types.d.ts +3 -3
- package/lib/overlay-menu/helpers/types.js +0 -1
- package/lib/overlay-menu/index.d.ts +44 -12
- package/lib/overlay-menu/index.js +66 -35
- package/lib/overlay-menu/managers/menu-manager.d.ts +2 -2
- package/lib/overlay-menu/managers/menu-manager.js +8 -8
- package/lib/pagination/custom-elements.json +16 -33
- package/lib/pagination/custom-elements.md +26 -0
- package/lib/pagination/index.d.ts +156 -81
- package/lib/pagination/index.js +373 -214
- package/lib/pagination/themes/halo/dark/index.js +1 -1
- package/lib/pagination/themes/halo/light/index.js +1 -1
- package/lib/pagination/themes/solar/charcoal/index.js +1 -1
- package/lib/pagination/themes/solar/pearl/index.js +1 -1
- package/lib/panel/custom-elements.md +11 -0
- package/lib/panel/index.d.ts +11 -4
- package/lib/panel/index.js +13 -9
- package/lib/password-field/custom-elements.json +62 -67
- package/lib/password-field/custom-elements.md +39 -0
- package/lib/password-field/index.d.ts +46 -90
- package/lib/password-field/index.js +52 -190
- package/lib/password-field/themes/halo/dark/index.js +1 -1
- package/lib/password-field/themes/halo/light/index.js +1 -1
- package/lib/password-field/themes/solar/charcoal/index.js +1 -1
- package/lib/password-field/themes/solar/pearl/index.js +1 -1
- package/lib/pill/custom-elements.json +9 -7
- package/lib/pill/custom-elements.md +22 -0
- package/lib/pill/index.d.ts +15 -7
- package/lib/pill/index.js +21 -27
- package/lib/pill/themes/halo/dark/index.js +1 -1
- package/lib/pill/themes/halo/light/index.js +1 -1
- package/lib/progress-bar/custom-elements.md +18 -0
- package/lib/progress-bar/index.d.ts +11 -15
- package/lib/progress-bar/index.js +14 -25
- package/lib/radio-button/custom-elements.json +4 -4
- package/lib/radio-button/custom-elements.md +19 -0
- package/lib/radio-button/index.d.ts +33 -9
- package/lib/radio-button/index.js +97 -24
- package/lib/radio-button/radio-button-registry.d.ts +3 -2
- package/lib/radio-button/radio-button-registry.js +57 -5
- package/lib/radio-button/themes/halo/dark/index.js +1 -1
- package/lib/radio-button/themes/halo/light/index.js +1 -1
- package/lib/rating/custom-elements.md +17 -0
- package/lib/rating/index.d.ts +11 -4
- package/lib/rating/index.js +16 -10
- package/lib/search-field/custom-elements.json +70 -74
- package/lib/search-field/custom-elements.md +41 -0
- package/lib/search-field/index.d.ts +47 -97
- package/lib/search-field/index.js +50 -212
- package/lib/search-field/themes/halo/dark/index.js +1 -1
- package/lib/search-field/themes/halo/light/index.js +1 -1
- package/lib/search-field/themes/solar/charcoal/index.js +1 -1
- package/lib/search-field/themes/solar/pearl/index.js +1 -1
- package/lib/select/custom-elements.json +5 -4
- package/lib/select/custom-elements.md +24 -0
- package/lib/select/helpers/types.d.ts +1 -1
- package/lib/select/helpers/types.js +0 -1
- package/lib/select/index.d.ts +26 -11
- package/lib/select/index.js +93 -52
- package/lib/select/themes/halo/dark/index.js +1 -1
- package/lib/select/themes/halo/light/index.js +1 -1
- package/lib/sidebar-layout/custom-elements.json +2 -6
- package/lib/sidebar-layout/custom-elements.md +21 -0
- package/lib/sidebar-layout/index.d.ts +15 -7
- package/lib/sidebar-layout/index.js +16 -10
- package/lib/slider/custom-elements.json +4 -4
- package/lib/slider/custom-elements.md +28 -0
- package/lib/slider/index.d.ts +18 -5
- package/lib/slider/index.js +69 -16
- package/lib/sparkline/custom-elements.json +4 -4
- package/lib/sparkline/custom-elements.md +16 -0
- package/lib/sparkline/index.d.ts +14 -5
- package/lib/sparkline/index.js +17 -10
- package/lib/swing-gauge/const.d.ts +22 -0
- package/lib/swing-gauge/const.js +26 -0
- package/lib/swing-gauge/custom-elements.json +51 -22
- package/lib/swing-gauge/custom-elements.md +17 -0
- package/lib/swing-gauge/helpers.d.ts +8 -0
- package/lib/swing-gauge/helpers.js +105 -0
- package/lib/swing-gauge/index.d.ts +220 -72
- package/lib/swing-gauge/index.js +648 -168
- package/lib/swing-gauge/themes/halo/dark/index.js +1 -1
- package/lib/swing-gauge/themes/halo/light/index.js +1 -1
- package/lib/swing-gauge/themes/solar/charcoal/index.js +1 -1
- package/lib/swing-gauge/themes/solar/pearl/index.js +1 -1
- package/lib/swing-gauge/types.d.ts +34 -0
- package/lib/swing-gauge/types.js +1 -0
- package/lib/tab/custom-elements.json +10 -21
- package/lib/tab/custom-elements.md +22 -0
- package/lib/tab/index.d.ts +19 -14
- package/lib/tab/index.js +31 -40
- package/lib/tab/themes/halo/dark/index.js +1 -1
- package/lib/tab/themes/halo/light/index.js +1 -1
- package/lib/tab/themes/solar/charcoal/index.js +1 -1
- package/lib/tab/themes/solar/pearl/index.js +1 -1
- package/lib/tab-bar/custom-elements.json +0 -6
- package/lib/tab-bar/custom-elements.md +11 -0
- package/lib/tab-bar/helpers/animate.d.ts +1 -1
- package/lib/tab-bar/helpers/animate.js +5 -2
- package/lib/tab-bar/index.d.ts +12 -5
- package/lib/tab-bar/index.js +18 -21
- package/lib/tab-bar/themes/solar/charcoal/index.js +1 -1
- package/lib/tab-bar/themes/solar/pearl/index.js +1 -1
- package/lib/text-field/custom-elements.json +78 -89
- package/lib/text-field/custom-elements.md +35 -0
- package/lib/text-field/index.d.ts +67 -80
- package/lib/text-field/index.js +106 -157
- package/lib/text-field/themes/halo/dark/index.js +1 -1
- package/lib/text-field/themes/halo/light/index.js +1 -1
- package/lib/text-field/themes/solar/charcoal/index.js +1 -1
- package/lib/text-field/themes/solar/pearl/index.js +1 -1
- package/lib/time-picker/custom-elements.json +6 -8
- package/lib/time-picker/custom-elements.md +28 -0
- package/lib/time-picker/index.d.ts +105 -65
- package/lib/time-picker/index.js +297 -169
- package/lib/time-picker/themes/solar/charcoal/index.js +1 -1
- package/lib/time-picker/themes/solar/pearl/index.js +1 -1
- package/lib/toggle/custom-elements.json +4 -4
- package/lib/toggle/custom-elements.md +19 -0
- package/lib/toggle/index.d.ts +22 -5
- package/lib/toggle/index.js +58 -13
- package/lib/toggle/themes/halo/dark/index.js +1 -1
- package/lib/toggle/themes/halo/light/index.js +1 -1
- package/lib/toggle/themes/solar/charcoal/index.js +1 -1
- package/lib/toggle/themes/solar/pearl/index.js +1 -1
- package/lib/tooltip/custom-elements.md +14 -0
- package/lib/tooltip/elements/title-tooltip.js +2 -3
- package/lib/tooltip/elements/tooltip-element.d.ts +2 -3
- package/lib/tooltip/elements/tooltip-element.js +0 -2
- package/lib/tooltip/helpers/overflow-tooltip.d.ts +1 -1
- package/lib/tooltip/helpers/overflow-tooltip.js +1 -2
- package/lib/tooltip/helpers/renderer.d.ts +1 -1
- package/lib/tooltip/helpers/renderer.js +0 -1
- package/lib/tooltip/helpers/types.d.ts +1 -1
- package/lib/tooltip/helpers/types.js +0 -1
- package/lib/tooltip/index.d.ts +18 -11
- package/lib/tooltip/index.js +27 -23
- package/lib/tooltip/managers/tooltip-manager.d.ts +2 -2
- package/lib/tooltip/managers/tooltip-manager.js +17 -11
- package/lib/tornado-chart/custom-elements.md +18 -0
- package/lib/tornado-chart/elements/tornado-chart.d.ts +12 -5
- package/lib/tornado-chart/elements/tornado-chart.js +15 -11
- package/lib/tornado-chart/elements/tornado-item.d.ts +13 -6
- package/lib/tornado-chart/elements/tornado-item.js +17 -12
- package/lib/tornado-chart/index.d.ts +2 -2
- package/lib/tornado-chart/index.js +2 -3
- package/lib/tree/custom-elements.json +30 -2
- package/lib/tree/custom-elements.md +32 -0
- package/lib/tree/elements/tree-item.d.ts +53 -5
- package/lib/tree/elements/tree-item.js +114 -34
- package/lib/tree/elements/tree.d.ts +65 -20
- package/lib/tree/elements/tree.js +151 -34
- package/lib/tree/helpers/filter.d.ts +8 -0
- package/lib/tree/helpers/filter.js +33 -0
- package/lib/tree/helpers/renderer.d.ts +2 -2
- package/lib/tree/helpers/renderer.js +4 -4
- package/lib/tree/helpers/types.d.ts +13 -1
- package/lib/tree/helpers/types.js +0 -1
- package/lib/tree/index.d.ts +4 -4
- package/lib/tree/index.js +3 -4
- package/lib/tree/managers/tree-manager.d.ts +22 -10
- package/lib/tree/managers/tree-manager.js +56 -41
- package/lib/tree/themes/halo/dark/index.js +1 -1
- package/lib/tree/themes/halo/light/index.js +1 -1
- package/lib/tree/themes/solar/charcoal/index.js +1 -1
- package/lib/tree/themes/solar/pearl/index.js +1 -1
- package/lib/tree-select/custom-elements.json +14 -5
- package/lib/tree-select/custom-elements.md +26 -0
- package/lib/tree-select/helpers/types.d.ts +2 -2
- package/lib/tree-select/helpers/types.js +0 -1
- package/lib/tree-select/index.d.ts +55 -27
- package/lib/tree-select/index.js +107 -45
- package/lib/tree-select/themes/halo/dark/index.js +3 -2
- package/lib/tree-select/themes/halo/light/index.js +3 -2
- package/lib/tree-select/themes/solar/charcoal/index.js +3 -2
- package/lib/tree-select/themes/solar/pearl/index.js +3 -2
- package/lib/version.d.ts +1 -0
- package/lib/version.js +1 -0
- package/package.json +601 -25
- package/lib/accordion/index.js.map +0 -1
- package/lib/appstate-bar/index.js.map +0 -1
- package/lib/autosuggest/helpers/const.d.ts +0 -2
- package/lib/autosuggest/helpers/const.js +0 -4
- package/lib/autosuggest/helpers/const.js.map +0 -1
- package/lib/autosuggest/helpers/types.js.map +0 -1
- package/lib/autosuggest/helpers/utils.js.map +0 -1
- package/lib/autosuggest/index.js.map +0 -1
- package/lib/button/index.js.map +0 -1
- package/lib/button-bar/index.js.map +0 -1
- package/lib/calendar/index.js.map +0 -1
- package/lib/calendar/locales.js.map +0 -1
- package/lib/calendar/types.js.map +0 -1
- package/lib/calendar/utils.js.map +0 -1
- package/lib/canvas/index.js.map +0 -1
- package/lib/card/helpers/types.js.map +0 -1
- package/lib/card/index.js.map +0 -1
- package/lib/chart/helpers/legend.js.map +0 -1
- package/lib/chart/helpers/types.js.map +0 -1
- package/lib/chart/index.js.map +0 -1
- package/lib/chart/plugins/doughnut-center-label.js.map +0 -1
- package/lib/checkbox/index.js.map +0 -1
- package/lib/clock/index.js.map +0 -1
- package/lib/clock/utils/TickManager.js.map +0 -1
- package/lib/clock/utils/timestamps.js.map +0 -1
- package/lib/collapse/index.js.map +0 -1
- package/lib/color-dialog/elements/color-palettes.js.map +0 -1
- package/lib/color-dialog/elements/grayscale-palettes.js.map +0 -1
- package/lib/color-dialog/elements/palettes.js.map +0 -1
- package/lib/color-dialog/helpers/color-helpers.js.map +0 -1
- package/lib/color-dialog/helpers/value-model.js.map +0 -1
- package/lib/color-dialog/index.js.map +0 -1
- package/lib/combo-box/helpers/filter.js.map +0 -1
- package/lib/combo-box/helpers/keyboard-event.js.map +0 -1
- package/lib/combo-box/helpers/types.js.map +0 -1
- package/lib/combo-box/index.js.map +0 -1
- package/lib/datetime-picker/index.js.map +0 -1
- package/lib/datetime-picker/locales.js.map +0 -1
- package/lib/datetime-picker/types.js.map +0 -1
- package/lib/datetime-picker/utils.js.map +0 -1
- package/lib/dialog/draggable-element.js.map +0 -1
- package/lib/dialog/index.js.map +0 -1
- package/lib/email-field/index.js.map +0 -1
- package/lib/flag/index.js.map +0 -1
- package/lib/flag/utils/FlagLoader.js.map +0 -1
- package/lib/header/index.js.map +0 -1
- package/lib/heatmap/helpers/color.js.map +0 -1
- package/lib/heatmap/helpers/text.js.map +0 -1
- package/lib/heatmap/helpers/track.js.map +0 -1
- package/lib/heatmap/helpers/types.js.map +0 -1
- package/lib/heatmap/index.js.map +0 -1
- package/lib/icon/index.js.map +0 -1
- package/lib/icon/utils/IconLoader.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/interactive-chart/helpers/types.js.map +0 -1
- package/lib/interactive-chart/index.js.map +0 -1
- package/lib/item/helpers/types.js.map +0 -1
- package/lib/item/index.js.map +0 -1
- package/lib/label/helpers/text.d.ts +0 -35
- package/lib/label/helpers/text.js +0 -57
- package/lib/label/helpers/text.js.map +0 -1
- package/lib/label/index.js.map +0 -1
- package/lib/layout/index.js.map +0 -1
- package/lib/led-gauge/index.js.map +0 -1
- package/lib/list/extensible-function.js.map +0 -1
- package/lib/list/helpers/list-renderer.js.map +0 -1
- package/lib/list/helpers/types.js.map +0 -1
- package/lib/list/index.js.map +0 -1
- package/lib/list/renderer.js.map +0 -1
- package/lib/loader/index.js.map +0 -1
- package/lib/multi-input/helpers/types.js.map +0 -1
- package/lib/multi-input/index.js.map +0 -1
- package/lib/notification/elements/notification-tray.js.map +0 -1
- package/lib/notification/elements/notification.js.map +0 -1
- package/lib/notification/helpers/status.js.map +0 -1
- package/lib/notification/helpers/types.js.map +0 -1
- package/lib/notification/index.js.map +0 -1
- package/lib/number-field/index.js.map +0 -1
- package/lib/overlay/elements/overlay-backdrop.js.map +0 -1
- package/lib/overlay/elements/overlay-viewport.js.map +0 -1
- package/lib/overlay/elements/overlay.js.map +0 -1
- package/lib/overlay/helpers/functions.js.map +0 -1
- package/lib/overlay/helpers/types.js.map +0 -1
- package/lib/overlay/index.js.map +0 -1
- package/lib/overlay/managers/backdrop-manager.js.map +0 -1
- package/lib/overlay/managers/close-manager.js.map +0 -1
- package/lib/overlay/managers/focus-manager.js.map +0 -1
- package/lib/overlay/managers/interaction-lock-manager.js.map +0 -1
- package/lib/overlay/managers/viewport-manager.js.map +0 -1
- package/lib/overlay/managers/zindex-manager.js.map +0 -1
- package/lib/overlay-menu/helpers/types.js.map +0 -1
- package/lib/overlay-menu/helpers/uuid.d.ts +0 -7
- package/lib/overlay-menu/helpers/uuid.js +0 -14
- package/lib/overlay-menu/helpers/uuid.js.map +0 -1
- package/lib/overlay-menu/index.js.map +0 -1
- package/lib/overlay-menu/managers/menu-manager.js.map +0 -1
- package/lib/pagination/helpers/types.d.ts +0 -9
- package/lib/pagination/helpers/types.js +0 -2
- package/lib/pagination/helpers/types.js.map +0 -1
- package/lib/pagination/index.js.map +0 -1
- package/lib/panel/index.js.map +0 -1
- package/lib/password-field/index.js.map +0 -1
- package/lib/pill/index.js.map +0 -1
- package/lib/progress-bar/index.js.map +0 -1
- package/lib/radio-button/index.js.map +0 -1
- package/lib/radio-button/radio-button-registry.js.map +0 -1
- package/lib/rating/index.js.map +0 -1
- package/lib/search-field/index.js.map +0 -1
- package/lib/select/helpers/types.js.map +0 -1
- package/lib/select/index.js.map +0 -1
- package/lib/sidebar-layout/index.js.map +0 -1
- package/lib/slider/index.js.map +0 -1
- package/lib/sparkline/index.js.map +0 -1
- package/lib/swing-gauge/helpers/canvas.d.ts +0 -8
- package/lib/swing-gauge/helpers/canvas.js +0 -115
- package/lib/swing-gauge/helpers/canvas.js.map +0 -1
- package/lib/swing-gauge/helpers/types.d.ts +0 -33
- package/lib/swing-gauge/helpers/types.js +0 -2
- package/lib/swing-gauge/helpers/types.js.map +0 -1
- package/lib/swing-gauge/index.js.map +0 -1
- package/lib/tab/index.js.map +0 -1
- package/lib/tab-bar/helpers/animate.js.map +0 -1
- package/lib/tab-bar/index.js.map +0 -1
- package/lib/text-field/index.js.map +0 -1
- package/lib/time-picker/index.js.map +0 -1
- package/lib/toggle/index.js.map +0 -1
- package/lib/tooltip/elements/title-tooltip.js.map +0 -1
- package/lib/tooltip/elements/tooltip-element.js.map +0 -1
- package/lib/tooltip/helpers/overflow-tooltip.js.map +0 -1
- package/lib/tooltip/helpers/renderer.js.map +0 -1
- package/lib/tooltip/helpers/types.js.map +0 -1
- package/lib/tooltip/index.js.map +0 -1
- package/lib/tooltip/managers/tooltip-manager.js.map +0 -1
- package/lib/tornado-chart/elements/tornado-chart.js.map +0 -1
- package/lib/tornado-chart/elements/tornado-item.js.map +0 -1
- package/lib/tornado-chart/index.js.map +0 -1
- package/lib/tree/elements/tree-item.js.map +0 -1
- package/lib/tree/elements/tree.js.map +0 -1
- package/lib/tree/helpers/renderer.js.map +0 -1
- package/lib/tree/helpers/types.js.map +0 -1
- package/lib/tree/index.js.map +0 -1
- package/lib/tree/managers/tree-manager.js.map +0 -1
- package/lib/tree-select/helpers/types.js.map +0 -1
- package/lib/tree-select/index.js.map +0 -1
package/lib/swing-gauge/index.js
CHANGED
|
@@ -1,60 +1,134 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { ResponsiveElement, css, html, WarningNotice } from '@refinitiv-ui/core';
|
|
3
|
+
import { customElement } from '@refinitiv-ui/core/lib/decorators/custom-element.js';
|
|
4
|
+
import { property } from '@refinitiv-ui/core/lib/decorators/property.js';
|
|
5
|
+
import { query } from '@refinitiv-ui/core/lib/decorators/query.js';
|
|
6
|
+
import { state } from '@refinitiv-ui/core/lib/decorators/state.js';
|
|
7
|
+
import { styleMap } from '@refinitiv-ui/core/lib/directives/style-map.js';
|
|
8
|
+
import { VERSION } from '../version.js';
|
|
9
|
+
import '../canvas/index.js';
|
|
10
|
+
import '../label/index.js';
|
|
11
|
+
import { helpers as canvasHelper } from './helpers.js';
|
|
12
|
+
import { DefaultStyle, Segment, TextType } from './const.js';
|
|
13
|
+
/**
|
|
14
|
+
* Constants from swing-gauge default specs
|
|
15
|
+
*/
|
|
16
|
+
const GAUGE_WIDTH_SCALE = 0.4;
|
|
17
|
+
const GAUGE_HEIGHT_SCALE = 0.8;
|
|
18
|
+
const GAUGE_UPPER_BOUND = GAUGE_HEIGHT_SCALE + GAUGE_WIDTH_SCALE / 2;
|
|
19
|
+
const GAUGE_LOWER_BOUND = GAUGE_HEIGHT_SCALE - GAUGE_WIDTH_SCALE / 2;
|
|
20
|
+
const PRIMARY_RADIAN = 1.25;
|
|
21
|
+
const SECONDARY_RADIAN = 1.75;
|
|
22
|
+
const LINE_POINTER_OFFSET = 0.3;
|
|
23
|
+
const POINT_POINTER_OFFSET = 0.1;
|
|
24
|
+
const DEFAULT_OFFSET = 0.05;
|
|
25
|
+
const OVERFLOW_OFFSET = 0.08;
|
|
26
|
+
// When either value is below this threshold, the label position changes
|
|
27
|
+
const GAUGE_PERCENTAGE_THRESHOLD = 30;
|
|
28
|
+
const GAUGE_LABEL_FONT_SCALE = 0.14;
|
|
29
|
+
const GAUGE_VALUE_FONT_SCALE = 0.18;
|
|
30
|
+
const MIN_LABEL_FONT_SIZE = 12;
|
|
31
|
+
const MIN_VALUE_FONT_SIZE = 15;
|
|
32
|
+
const MAX_LABEL_LINE = 3;
|
|
33
|
+
const MAX_VALUE_LINE = 1;
|
|
34
|
+
const MAX_LEGEND_LINE = 2;
|
|
10
35
|
/**
|
|
11
36
|
* Data visualisation showing the percentage between two values
|
|
12
37
|
*/
|
|
13
|
-
let SwingGauge = class SwingGauge extends
|
|
38
|
+
let SwingGauge = class SwingGauge extends ResponsiveElement {
|
|
14
39
|
constructor() {
|
|
15
|
-
super();
|
|
40
|
+
super(...arguments);
|
|
41
|
+
this._primaryValue = 0;
|
|
16
42
|
/**
|
|
17
|
-
*
|
|
18
|
-
* @default 50
|
|
43
|
+
* Primary label
|
|
19
44
|
*/
|
|
20
|
-
this.
|
|
45
|
+
this.primaryLabel = '';
|
|
46
|
+
this._secondaryValue = 0;
|
|
21
47
|
/**
|
|
22
|
-
*
|
|
48
|
+
* Secondary label
|
|
23
49
|
*/
|
|
24
|
-
this.
|
|
50
|
+
this.secondaryLabel = '';
|
|
25
51
|
/**
|
|
26
|
-
*
|
|
27
|
-
* @default 50
|
|
52
|
+
* Animation duration in milliseconds
|
|
28
53
|
*/
|
|
29
|
-
this.
|
|
54
|
+
this.duration = 1000;
|
|
55
|
+
/**
|
|
56
|
+
* Primary value legend
|
|
57
|
+
*/
|
|
58
|
+
this.primaryLegend = '';
|
|
59
|
+
/**
|
|
60
|
+
* Secondary value legend
|
|
61
|
+
*/
|
|
62
|
+
this.secondaryLegend = '';
|
|
30
63
|
/**
|
|
31
|
-
*
|
|
64
|
+
* Custom value formatter
|
|
65
|
+
* @type {SwingGaugeValueFormatter}
|
|
32
66
|
*/
|
|
33
|
-
this.
|
|
67
|
+
this.valueFormatter = this.defaultValueFormatter;
|
|
34
68
|
/**
|
|
35
|
-
*
|
|
36
|
-
* @default 1000
|
|
69
|
+
* Controls swing gauge animations
|
|
37
70
|
*/
|
|
38
|
-
this.duration = 1000;
|
|
39
|
-
this.w = null;
|
|
40
|
-
this.h = null;
|
|
41
|
-
this.min = null;
|
|
42
|
-
this.max = null;
|
|
43
|
-
this.size = null;
|
|
44
|
-
this.maxFontSize = null;
|
|
45
|
-
this.centerlineOptions = ['solid', 'dotted', 'dashed'];
|
|
46
71
|
this.onFrame = requestAnimationFrame.bind(window);
|
|
47
72
|
this.cancelFrame = cancelAnimationFrame.bind(window);
|
|
48
|
-
this.
|
|
49
|
-
this.
|
|
50
|
-
this.
|
|
73
|
+
this.requestedAnimationID = 0;
|
|
74
|
+
this.gaugeWidthScale = GAUGE_WIDTH_SCALE;
|
|
75
|
+
this.gaugeHeightScale = GAUGE_HEIGHT_SCALE;
|
|
76
|
+
this.gaugeUpperBound = GAUGE_UPPER_BOUND;
|
|
77
|
+
this.gaugeLowerBound = GAUGE_LOWER_BOUND;
|
|
78
|
+
this.linePointerOffset = LINE_POINTER_OFFSET;
|
|
79
|
+
this.pointPointerOffset = POINT_POINTER_OFFSET;
|
|
80
|
+
this.primaryLineRadian = PRIMARY_RADIAN;
|
|
81
|
+
this.secondaryLineRadian = SECONDARY_RADIAN;
|
|
82
|
+
/**
|
|
83
|
+
* Data requires to draw swing gauge
|
|
84
|
+
*/
|
|
85
|
+
this.data = null;
|
|
86
|
+
/**
|
|
87
|
+
* Internal sizes and scales
|
|
88
|
+
*/
|
|
89
|
+
this.width = 0;
|
|
90
|
+
this.height = 0;
|
|
91
|
+
this.size = 0;
|
|
92
|
+
this.lineLength = 60;
|
|
93
|
+
this.scale = 1;
|
|
94
|
+
/**
|
|
95
|
+
* Current fill percentage
|
|
96
|
+
*/
|
|
97
|
+
this.fillPercentage = 0;
|
|
98
|
+
/**
|
|
99
|
+
* Keeps previous percentage calculation to avoid re-rendering the same value
|
|
100
|
+
*/
|
|
101
|
+
this.previousFillPercentage = 0;
|
|
102
|
+
/**
|
|
103
|
+
* This for keep line number of label for calculate new radius
|
|
104
|
+
*/
|
|
105
|
+
this.labelLineNumber = 1;
|
|
106
|
+
/**
|
|
107
|
+
* Style for primary container
|
|
108
|
+
*/
|
|
109
|
+
this.primaryContainerStyle = {};
|
|
110
|
+
/**
|
|
111
|
+
* Style for secondary container
|
|
112
|
+
*/
|
|
113
|
+
this.secondaryContainerStyle = {};
|
|
114
|
+
/**
|
|
115
|
+
* Style for label
|
|
116
|
+
*/
|
|
117
|
+
this.labelStyle = {};
|
|
51
118
|
/**
|
|
52
|
-
*
|
|
119
|
+
* Style for both values
|
|
53
120
|
*/
|
|
54
|
-
this.
|
|
121
|
+
this.valueStyle = {};
|
|
55
122
|
}
|
|
56
123
|
/**
|
|
57
|
-
*
|
|
124
|
+
* Element version number
|
|
125
|
+
* @returns version number
|
|
126
|
+
*/
|
|
127
|
+
static get version() {
|
|
128
|
+
return VERSION;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* A `CSSResultGroup` that will be used
|
|
58
132
|
* to style the host, slotted children
|
|
59
133
|
* and the internal template of the element.
|
|
60
134
|
* @return CSS template
|
|
@@ -63,222 +137,628 @@ let SwingGauge = class SwingGauge extends Canvas {
|
|
|
63
137
|
return css `
|
|
64
138
|
:host {
|
|
65
139
|
display: block;
|
|
66
|
-
|
|
140
|
+
height: 200px;
|
|
141
|
+
}
|
|
142
|
+
:host [part=container] {
|
|
143
|
+
display: flex;
|
|
144
|
+
flex-direction: column;
|
|
145
|
+
height: 100%;
|
|
146
|
+
}
|
|
147
|
+
:host [part=canvas-container] {
|
|
67
148
|
position: relative;
|
|
149
|
+
flex: 1;
|
|
68
150
|
}
|
|
69
|
-
:host
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
151
|
+
:host [part=canvas] {
|
|
152
|
+
height: 100%;
|
|
153
|
+
}
|
|
154
|
+
:host [part=primary-legend], [part=secondary-legend] {
|
|
155
|
+
text-align: left;
|
|
156
|
+
display: flex;
|
|
157
|
+
}
|
|
158
|
+
:host [part=primary-label], [part=primary-value] {
|
|
159
|
+
text-align: left;
|
|
160
|
+
}
|
|
161
|
+
:host [part=secondary-label], [part=secondary-value] {
|
|
162
|
+
text-align: right;
|
|
163
|
+
}
|
|
164
|
+
:host [part=legend-container-outer] {
|
|
165
|
+
width: 60%;
|
|
166
|
+
margin: 0 auto;
|
|
167
|
+
text-align: center;
|
|
168
|
+
}
|
|
169
|
+
:host [part=legend-container-inner] {
|
|
170
|
+
max-width: 100%;
|
|
171
|
+
display: inline-block;
|
|
74
172
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
173
|
+
:host [part=primary-legend-symbol], [part=secondary-legend-symbol] {
|
|
174
|
+
display: inline-block;
|
|
175
|
+
flex-shrink: 0;
|
|
176
|
+
}
|
|
177
|
+
:host [part=primary-container] {
|
|
178
|
+
position: absolute;
|
|
179
|
+
text-align: left;
|
|
180
|
+
}
|
|
181
|
+
:host [part=secondary-container] {
|
|
80
182
|
position: absolute;
|
|
183
|
+
text-align: right;
|
|
81
184
|
}
|
|
82
185
|
`;
|
|
83
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* Primary value
|
|
189
|
+
* @param value primary value
|
|
190
|
+
*/
|
|
191
|
+
set primaryValue(value) {
|
|
192
|
+
value = this.validateNumber(value, 'primary-value');
|
|
193
|
+
const oldValue = this._primaryValue;
|
|
194
|
+
if (oldValue !== value) {
|
|
195
|
+
this._primaryValue = value;
|
|
196
|
+
this.requestUpdate('primaryValue', oldValue);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
get primaryValue() {
|
|
200
|
+
return this._primaryValue;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Secondary value
|
|
204
|
+
* @param value secondary value
|
|
205
|
+
*/
|
|
206
|
+
set secondaryValue(value) {
|
|
207
|
+
value = this.validateNumber(value, 'secondary-value');
|
|
208
|
+
const oldValue = this._secondaryValue;
|
|
209
|
+
if (oldValue !== value) {
|
|
210
|
+
this._secondaryValue = value;
|
|
211
|
+
this.requestUpdate('secondaryValue', oldValue);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
get secondaryValue() {
|
|
215
|
+
return this._secondaryValue;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Get primary percentage
|
|
219
|
+
*/
|
|
220
|
+
get primaryPercentage() {
|
|
221
|
+
return this.getPercentage(this.primaryValue);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Get secondary percentage
|
|
225
|
+
*/
|
|
226
|
+
get secondaryPercentage() {
|
|
227
|
+
return this.getPercentage(this.secondaryValue);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Check width and height are valid
|
|
231
|
+
* @returns if size is valid
|
|
232
|
+
*/
|
|
233
|
+
get hasValidSize() {
|
|
234
|
+
return this.offsetWidth > 0 && this.offsetHeight > 0 && this.canvas.width > 0 && this.canvas.height > 0;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Get default value format
|
|
238
|
+
* @param value A value on each side of swing gauge
|
|
239
|
+
* @returns default value format
|
|
240
|
+
*/
|
|
241
|
+
defaultValueFormatter(value) {
|
|
242
|
+
return `${value.toFixed(2)}%`;
|
|
243
|
+
}
|
|
84
244
|
/**
|
|
85
245
|
* Getter size of component
|
|
86
|
-
* @
|
|
246
|
+
* @type {SwingGaugeCanvasSize}
|
|
247
|
+
* @returns return size of canvas
|
|
87
248
|
*/
|
|
88
249
|
get canvasSize() {
|
|
89
250
|
return {
|
|
90
|
-
width: this.
|
|
91
|
-
height: this.
|
|
251
|
+
width: this.offsetWidth,
|
|
252
|
+
height: this.offsetHeight
|
|
92
253
|
};
|
|
93
254
|
}
|
|
94
255
|
/**
|
|
95
|
-
*
|
|
96
|
-
* @
|
|
97
|
-
* @param
|
|
256
|
+
* Validate number
|
|
257
|
+
* @protected
|
|
258
|
+
* @param value number that want to validate
|
|
259
|
+
* @param propName name of property
|
|
260
|
+
* @returns {number} valid number
|
|
261
|
+
*/
|
|
262
|
+
validateNumber(value, propName) {
|
|
263
|
+
if (typeof value === 'number' && !isNaN(value) && isFinite(value) && value >= 0) {
|
|
264
|
+
return value;
|
|
265
|
+
}
|
|
266
|
+
new WarningNotice(`${this.localName} : The specified value "${value}" of ${propName} property is not valid. Default value will be used instead.`).show();
|
|
267
|
+
return 0;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* On update lifecycle
|
|
271
|
+
* @param changedProperties changed properties
|
|
98
272
|
* @returns {void}
|
|
99
273
|
*/
|
|
100
|
-
|
|
101
|
-
super.
|
|
102
|
-
|
|
274
|
+
update(changedProperties) {
|
|
275
|
+
super.update(changedProperties);
|
|
276
|
+
if (changedProperties.has('primaryValue') || changedProperties.has('secondaryValue')
|
|
277
|
+
|| (this.primaryValue === 0 && this.secondaryValue === 0)) {
|
|
278
|
+
this.canvas.autoloop = true;
|
|
279
|
+
this.renderCanvas('frame');
|
|
280
|
+
this.animateCanvas();
|
|
281
|
+
}
|
|
282
|
+
if (changedProperties.has('primaryLabel') || changedProperties.has('secondaryLabel')) {
|
|
283
|
+
this.calculateLabelFontSize();
|
|
284
|
+
}
|
|
285
|
+
if (changedProperties.has('valueFormatter')) {
|
|
286
|
+
this.calculateValueFontSize();
|
|
287
|
+
}
|
|
288
|
+
if (changedProperties.has('primaryValue') || changedProperties.has('secondaryValue')
|
|
289
|
+
|| changedProperties.has('primaryLabel') || changedProperties.has('secondaryLabel')
|
|
290
|
+
|| changedProperties.has('valueFormatter')) {
|
|
291
|
+
this.updateGaugePositions();
|
|
292
|
+
}
|
|
103
293
|
}
|
|
104
294
|
/**
|
|
105
|
-
* Handles when
|
|
106
|
-
* @protected
|
|
107
|
-
* @param time timestamp
|
|
295
|
+
* Handles when component disconnected
|
|
108
296
|
* @returns {void}
|
|
109
297
|
*/
|
|
110
|
-
|
|
111
|
-
super.
|
|
112
|
-
this.
|
|
298
|
+
disconnectedCallback() {
|
|
299
|
+
super.disconnectedCallback();
|
|
300
|
+
if (this.requestedAnimationID) {
|
|
301
|
+
this.cancelFrame(this.requestedAnimationID);
|
|
302
|
+
}
|
|
113
303
|
}
|
|
114
304
|
/**
|
|
115
|
-
*
|
|
116
|
-
* @
|
|
117
|
-
* @param
|
|
305
|
+
* Calls easing based on both left and right values
|
|
306
|
+
* @param primaryValue primary value
|
|
307
|
+
* @param secondaryValue secondary value
|
|
118
308
|
* @returns {void}
|
|
119
309
|
*/
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
this.
|
|
310
|
+
ease(primaryValue, secondaryValue) {
|
|
311
|
+
let to = 0.5;
|
|
312
|
+
let from = this.fillPercentage;
|
|
313
|
+
if (primaryValue > 0 || secondaryValue > 0) {
|
|
314
|
+
to = primaryValue / (primaryValue + secondaryValue);
|
|
315
|
+
}
|
|
316
|
+
// this for prevent gauge not render when 'to' and 'from' are 0
|
|
317
|
+
if (primaryValue === 0 && from === 0) {
|
|
318
|
+
from = 0.1;
|
|
319
|
+
}
|
|
320
|
+
this.easeTo(to, from, performance.now() + this.duration);
|
|
123
321
|
}
|
|
124
322
|
/**
|
|
125
|
-
*
|
|
126
|
-
* @
|
|
127
|
-
* @param
|
|
323
|
+
* Eases the fill percentage
|
|
324
|
+
* @param to ease to value
|
|
325
|
+
* @param from ease from value
|
|
326
|
+
* @param time ease time
|
|
128
327
|
* @returns {void}
|
|
129
328
|
*/
|
|
130
|
-
|
|
131
|
-
|
|
329
|
+
easeTo(to, from, time) {
|
|
330
|
+
const diff = (this.duration - (time - performance.now())) / this.duration;
|
|
331
|
+
this.fillPercentage = from + (to - from) * canvasHelper.elasticOut(diff > 1 ? 1 : diff < 0 ? 0 : diff) || 0;
|
|
332
|
+
if (this.fillPercentage !== to) {
|
|
333
|
+
this.cancelFrame(this.requestedAnimationID);
|
|
334
|
+
this.requestedAnimationID = this.onFrame(() => this.easeTo(to, from, time));
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
this.canvas.autoloop = false;
|
|
338
|
+
}
|
|
339
|
+
this.renderCanvas('frame', true);
|
|
132
340
|
}
|
|
133
341
|
/**
|
|
134
|
-
*
|
|
135
|
-
* @ignore
|
|
136
|
-
* @param changedProperties changed properties
|
|
342
|
+
* Restart the animation, re-render the canvas
|
|
137
343
|
* @returns {void}
|
|
138
344
|
*/
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
this.reDrawCanvas();
|
|
345
|
+
animateCanvas() {
|
|
346
|
+
this.ease(this.primaryValue, this.secondaryValue);
|
|
142
347
|
}
|
|
143
348
|
/**
|
|
144
|
-
*
|
|
145
|
-
* @
|
|
349
|
+
* Render chart
|
|
350
|
+
* @param onDraw drawing type
|
|
351
|
+
* @param isFrameUpdated Optional called by on frame event
|
|
146
352
|
* @returns {void}
|
|
147
353
|
*/
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
354
|
+
renderCanvas(onDraw, isFrameUpdated) {
|
|
355
|
+
const percentageChanged = this.previousFillPercentage !== this.fillPercentage;
|
|
356
|
+
const canRender = this.hasValidSize && percentageChanged;
|
|
357
|
+
if ((isFrameUpdated && !canRender) || !this.hasValidSize) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
this.width = this.canvas.width;
|
|
361
|
+
this.height = this.canvas.height;
|
|
362
|
+
const min = this.width > this.height ? this.height : this.width;
|
|
363
|
+
const max = this.width > this.height ? this.width : this.height;
|
|
364
|
+
this.size = Math.floor(max / this.scale < min ? max / this.scale : min);
|
|
365
|
+
const canvasSize = { width: this.width, height: this.height };
|
|
366
|
+
// Prevent draw frame unnecessary recalculate position and draw data
|
|
367
|
+
if (!isFrameUpdated) {
|
|
368
|
+
this.data = this.getData();
|
|
369
|
+
}
|
|
370
|
+
else if (this.data !== null) {
|
|
371
|
+
this.data.fillPercentage = this.fillPercentage;
|
|
153
372
|
}
|
|
373
|
+
const clear = () => {
|
|
374
|
+
if (!this.canvas.ctx) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
canvasHelper.clear(canvasSize, this.canvas.ctx);
|
|
378
|
+
};
|
|
379
|
+
this.canvas.addEventListener(onDraw, clear, { once: true });
|
|
380
|
+
const draw = () => {
|
|
381
|
+
if (!this.canvas.ctx) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
canvasHelper.draw(this.data === null ? this.getData() : this.data, this.canvas.ctx, {
|
|
385
|
+
strokeWidth: Math.ceil(this.scale * this.size * 0.005),
|
|
386
|
+
primaryColor: this.getComputedVariable('--primary-color', DefaultStyle.PRIMARY_GAUGE_COLOR),
|
|
387
|
+
secondaryColor: this.getComputedVariable('--secondary-color', DefaultStyle.SECONDARY_GAUGE_COLOR),
|
|
388
|
+
borderColor: this.getComputedVariable('--border-color', DefaultStyle.BOREDER_COLOR),
|
|
389
|
+
centerline: `${this.getComputedVariable('--center-line', DefaultStyle.CENTER_LINE_STYLE)}`.trim(),
|
|
390
|
+
centerlineOpacity: this.getComputedVariable('--center-line-opacity', DefaultStyle.CENTER_LINE_OPACITY),
|
|
391
|
+
centerlineColor: this.getComputedVariable('--center-line-color', DefaultStyle.CENTER_LINE_COLOR)
|
|
392
|
+
});
|
|
393
|
+
};
|
|
394
|
+
this.canvas.addEventListener(onDraw, draw, { once: true });
|
|
395
|
+
// Set this for comparison when deciding if we should paint
|
|
396
|
+
this.previousFillPercentage = this.fillPercentage;
|
|
154
397
|
}
|
|
155
398
|
/**
|
|
156
|
-
*
|
|
157
|
-
* @
|
|
158
|
-
|
|
159
|
-
|
|
399
|
+
* Get computed swing-gauge data for drawing
|
|
400
|
+
* @returns swing-gauge data
|
|
401
|
+
*/
|
|
402
|
+
getData() {
|
|
403
|
+
// Recalculate radius to prevent container overflow
|
|
404
|
+
const gaugeHeight = this.size * this.gaugeHeightScale;
|
|
405
|
+
const containerHeight = this.labelLineNumber * MIN_LABEL_FONT_SIZE + MIN_VALUE_FONT_SIZE;
|
|
406
|
+
if (containerHeight > gaugeHeight) {
|
|
407
|
+
// The value of 'reverseScale' increases as the value of 'scale' decreases.
|
|
408
|
+
const reverseScale = 1 - this.scale;
|
|
409
|
+
// increase the offset by 25%, this for buffer to make label have some space from bottom
|
|
410
|
+
this.linePointerOffset = (containerHeight / gaugeHeight) * reverseScale * 1.25;
|
|
411
|
+
this.primaryLineRadian = PRIMARY_RADIAN + DEFAULT_OFFSET + (OVERFLOW_OFFSET * reverseScale);
|
|
412
|
+
this.secondaryLineRadian = 3 - this.primaryLineRadian;
|
|
413
|
+
}
|
|
414
|
+
const primaryPosLine = this.getPositionStyle(Segment.PRIMARY, this.primaryLineRadian, this.linePointerOffset, 0);
|
|
415
|
+
const primaryPosPoint = this.getPositionStyle(Segment.PRIMARY, PRIMARY_RADIAN, this.pointPointerOffset, 0);
|
|
416
|
+
const secondaryPosLine = this.getPositionStyle(Segment.SECONDARY, this.secondaryLineRadian, this.linePointerOffset, 0);
|
|
417
|
+
const secondaryPosPoint = this.getPositionStyle(Segment.SECONDARY, SECONDARY_RADIAN, this.pointPointerOffset, 0);
|
|
418
|
+
return {
|
|
419
|
+
width: this.width,
|
|
420
|
+
height: this.height,
|
|
421
|
+
size: this.size,
|
|
422
|
+
fillPercentage: this.fillPercentage,
|
|
423
|
+
gaugeWidthScale: this.gaugeWidthScale,
|
|
424
|
+
gaugeHeightScale: this.gaugeHeightScale,
|
|
425
|
+
gaugeUpperBound: this.gaugeUpperBound,
|
|
426
|
+
gaugeLowerBound: this.gaugeLowerBound,
|
|
427
|
+
lineLength: this.lineLength,
|
|
428
|
+
offsetLeftPrimaryLine: this.getValueFromStyle(primaryPosLine.left),
|
|
429
|
+
offsetTopPrimaryLine: this.getValueFromStyle(primaryPosLine.top),
|
|
430
|
+
offsetLeftPrimaryPoint: this.getValueFromStyle(primaryPosPoint.left),
|
|
431
|
+
offsetTopPrimaryPoint: this.getValueFromStyle(primaryPosPoint.top),
|
|
432
|
+
offsetLeftSecondaryLine: this.getValueFromStyle(secondaryPosLine.left),
|
|
433
|
+
offsetTopSecondaryLine: this.getValueFromStyle(secondaryPosLine.top),
|
|
434
|
+
offsetLeftSecondaryPoint: this.getValueFromStyle(secondaryPosPoint.left),
|
|
435
|
+
offsetTopSecondaryPoint: this.getValueFromStyle(secondaryPosPoint.top)
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Get number from CSS declaration value
|
|
440
|
+
* @param styleValue value of CSS declaration
|
|
441
|
+
* @returns number without CSS unit
|
|
442
|
+
*/
|
|
443
|
+
getValueFromStyle(styleValue) {
|
|
444
|
+
return Number(styleValue === null || styleValue === void 0 ? void 0 : styleValue.replace('px', ''));
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Compute and update style of containers and labels
|
|
160
448
|
* @returns {void}
|
|
161
449
|
*/
|
|
162
|
-
|
|
163
|
-
if (
|
|
164
|
-
|
|
450
|
+
updateGaugePositions() {
|
|
451
|
+
if (!this.hasValidSize) {
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
const primaryPosition = this.getPositionStyle(Segment.PRIMARY, this.primaryLineRadian, this.linePointerOffset, -this.lineLength);
|
|
455
|
+
const secondaryPosition = this.getPositionStyle(Segment.SECONDARY, this.secondaryLineRadian, this.linePointerOffset, 0);
|
|
456
|
+
this.primaryContainerStyle = Object.assign({ width: `${this.lineLength}px` }, primaryPosition);
|
|
457
|
+
this.secondaryContainerStyle = Object.assign({ width: `${this.lineLength}px` }, secondaryPosition);
|
|
458
|
+
// position container over line pointer
|
|
459
|
+
if (this.primaryPercentage < GAUGE_PERCENTAGE_THRESHOLD) {
|
|
460
|
+
delete this.primaryContainerStyle.top;
|
|
461
|
+
this.primaryContainerStyle.bottom = '5px';
|
|
165
462
|
}
|
|
166
|
-
|
|
167
|
-
|
|
463
|
+
if (this.secondaryPercentage < GAUGE_PERCENTAGE_THRESHOLD || this.secondaryValue === 0) {
|
|
464
|
+
delete this.secondaryContainerStyle.top;
|
|
465
|
+
this.secondaryContainerStyle.bottom = '5px';
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Compute position style
|
|
470
|
+
* @param segment primary or secondary
|
|
471
|
+
* @param maxRadian max radian
|
|
472
|
+
* @param radiusOffset radius offset from gauge upper bound
|
|
473
|
+
* @param offset line length offset
|
|
474
|
+
* @returns position style
|
|
475
|
+
*/
|
|
476
|
+
getPositionStyle(segment, maxRadian, radiusOffset, offset) {
|
|
477
|
+
let radius = this.size * (1 + radiusOffset) * this.scale;
|
|
478
|
+
let radianValue;
|
|
479
|
+
if (segment === Segment.PRIMARY) {
|
|
480
|
+
radianValue = this.primaryPercentage >= GAUGE_PERCENTAGE_THRESHOLD ? maxRadian : 1;
|
|
168
481
|
}
|
|
169
482
|
else {
|
|
170
|
-
this.
|
|
483
|
+
radianValue = this.secondaryPercentage >= GAUGE_PERCENTAGE_THRESHOLD ? maxRadian : 0;
|
|
484
|
+
}
|
|
485
|
+
// reduce line length when line is on the bottom of canvas
|
|
486
|
+
if ((radianValue === 1 || radianValue === 0) && radiusOffset > 0.1) {
|
|
487
|
+
radius = this.size * (1 + this.pointPointerOffset) * this.scale;
|
|
171
488
|
}
|
|
489
|
+
const radian = radianValue * Math.PI;
|
|
490
|
+
const left = `${Math.round(this.width / 2 + Math.cos(radian) * radius) + offset}px`;
|
|
491
|
+
const top = `${Math.round(this.height + Math.sin(radian) * radius)}px`;
|
|
492
|
+
return { left: left, top: top };
|
|
172
493
|
}
|
|
173
494
|
/**
|
|
174
|
-
*
|
|
175
|
-
* @private
|
|
176
|
-
* @param {number} to ease to value
|
|
177
|
-
* @param {number} from ease from value
|
|
178
|
-
* @param {number} time ease time
|
|
495
|
+
* Scales canvas variables making it responsive before painting
|
|
179
496
|
* @returns {void}
|
|
180
497
|
*/
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
498
|
+
calculateCanvasSize() {
|
|
499
|
+
const lineLength = this.canvas.height * 0.75;
|
|
500
|
+
const bestWidth = 2 * (GAUGE_UPPER_BOUND + LINE_POINTER_OFFSET) * this.canvas.height + 2 * lineLength;
|
|
501
|
+
const ratio = bestWidth / this.canvas.height;
|
|
502
|
+
this.scale = 1;
|
|
503
|
+
if (this.canvas.width < bestWidth) {
|
|
504
|
+
const width = this.canvas.width;
|
|
505
|
+
const bestHeight = width / ratio;
|
|
506
|
+
this.scale = bestHeight / this.canvas.height;
|
|
507
|
+
}
|
|
508
|
+
this.scale = this.scale < 0.1 ? 0.1 : this.scale;
|
|
509
|
+
this.lineLength = this.scale * lineLength;
|
|
510
|
+
this.gaugeWidthScale = this.scale * GAUGE_WIDTH_SCALE;
|
|
511
|
+
this.gaugeHeightScale = this.scale * GAUGE_HEIGHT_SCALE;
|
|
512
|
+
this.gaugeUpperBound = this.scale * GAUGE_UPPER_BOUND;
|
|
513
|
+
this.gaugeLowerBound = this.scale * GAUGE_LOWER_BOUND;
|
|
514
|
+
this.primaryLineRadian = PRIMARY_RADIAN;
|
|
515
|
+
this.secondaryLineRadian = SECONDARY_RADIAN;
|
|
516
|
+
this.linePointerOffset = LINE_POINTER_OFFSET;
|
|
517
|
+
this.pointPointerOffset = POINT_POINTER_OFFSET;
|
|
518
|
+
if (this.scale < 1) {
|
|
519
|
+
// The value of 'reverseScale' increases as the value of 'scale' decreases.
|
|
520
|
+
// This mean when scale down the offset will grow up
|
|
521
|
+
const reverseScale = 1 - this.scale;
|
|
522
|
+
const offset = DEFAULT_OFFSET * reverseScale;
|
|
523
|
+
this.primaryLineRadian = PRIMARY_RADIAN + offset;
|
|
524
|
+
this.secondaryLineRadian = SECONDARY_RADIAN - offset;
|
|
525
|
+
this.linePointerOffset = LINE_POINTER_OFFSET + (0.4 * (1 - this.scale));
|
|
188
526
|
}
|
|
527
|
+
this.primaryLineRadian = this.primaryLineRadian > 1.3 ? 1.3 : this.primaryLineRadian;
|
|
528
|
+
this.secondaryLineRadian = this.primaryLineRadian > 1.7 ? 1.7 : this.secondaryLineRadian;
|
|
189
529
|
}
|
|
190
530
|
/**
|
|
191
|
-
*
|
|
192
|
-
* @returns {
|
|
531
|
+
* Calculate and update font sizes on canvas
|
|
532
|
+
* @returns {void}
|
|
193
533
|
*/
|
|
194
|
-
|
|
195
|
-
|
|
534
|
+
updateFontSize() {
|
|
535
|
+
this.calculateLabelFontSize();
|
|
536
|
+
this.calculateValueFontSize();
|
|
196
537
|
}
|
|
197
538
|
/**
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
* @
|
|
539
|
+
* Calculate label or value font size
|
|
540
|
+
* @param ctx canvas context
|
|
541
|
+
* @param textType text type
|
|
542
|
+
* @returns {number} font size
|
|
201
543
|
*/
|
|
202
|
-
|
|
203
|
-
|
|
544
|
+
calculateFontSize(ctx, textType) {
|
|
545
|
+
let maxLine;
|
|
546
|
+
let minFontSize;
|
|
547
|
+
let widthScale;
|
|
548
|
+
let fontSize;
|
|
549
|
+
let longerLabel;
|
|
550
|
+
if (textType === TextType.LABEL) {
|
|
551
|
+
maxLine = MAX_LABEL_LINE;
|
|
552
|
+
minFontSize = MIN_LABEL_FONT_SIZE;
|
|
553
|
+
// buffer for word wrap
|
|
554
|
+
widthScale = 1.1;
|
|
555
|
+
longerLabel = this.primaryLabel.length > this.secondaryLabel.length ? this.primaryLabel : this.secondaryLabel;
|
|
556
|
+
fontSize = Math.ceil(this.scale * this.canvas.height * GAUGE_LABEL_FONT_SCALE);
|
|
557
|
+
}
|
|
558
|
+
else {
|
|
559
|
+
maxLine = MAX_VALUE_LINE;
|
|
560
|
+
minFontSize = MIN_VALUE_FONT_SIZE;
|
|
561
|
+
widthScale = 1;
|
|
562
|
+
const primaryValue = String(this.valueFormatter(this.primaryPercentage, this.primaryValue));
|
|
563
|
+
const secondaryValue = String(this.valueFormatter(this.secondaryPercentage, this.secondaryValue));
|
|
564
|
+
longerLabel = primaryValue.length > secondaryValue.length ? primaryValue : secondaryValue;
|
|
565
|
+
fontSize = Math.ceil(this.scale * this.canvas.height * GAUGE_VALUE_FONT_SCALE);
|
|
566
|
+
}
|
|
567
|
+
let textWidth = canvasHelper.textWidth(ctx, longerLabel, fontSize, getComputedStyle(this).fontFamily);
|
|
568
|
+
let numberOfLines = Math.ceil(textWidth / this.lineLength);
|
|
569
|
+
if (numberOfLines > maxLine) {
|
|
570
|
+
numberOfLines = maxLine;
|
|
571
|
+
}
|
|
572
|
+
if (textType === TextType.LABEL) {
|
|
573
|
+
this.labelLineNumber = numberOfLines;
|
|
574
|
+
}
|
|
575
|
+
do {
|
|
576
|
+
fontSize -= 1;
|
|
577
|
+
if (fontSize < minFontSize) {
|
|
578
|
+
fontSize = minFontSize;
|
|
579
|
+
break;
|
|
580
|
+
}
|
|
581
|
+
textWidth = canvasHelper.textWidth(ctx, longerLabel, fontSize, getComputedStyle(this).fontFamily);
|
|
582
|
+
} while (textWidth * widthScale > this.lineLength * numberOfLines);
|
|
583
|
+
return fontSize;
|
|
204
584
|
}
|
|
205
585
|
/**
|
|
206
|
-
*
|
|
586
|
+
* Update label font size
|
|
207
587
|
* @returns {void}
|
|
208
588
|
*/
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
589
|
+
calculateLabelFontSize() {
|
|
590
|
+
if (!this.canvas.ctx) {
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
this.labelStyle = { maxWidth: `${this.lineLength}px`, fontSize: `${this.calculateFontSize(this.canvas.ctx, TextType.LABEL)}px` };
|
|
212
594
|
}
|
|
213
595
|
/**
|
|
214
|
-
*
|
|
215
|
-
* @param isFrameUpdated Optional called by on frame event
|
|
596
|
+
* Update value font size
|
|
216
597
|
* @returns {void}
|
|
217
598
|
*/
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
if ((isFrameUpdated && !this.canRender()) || !this.dataValid()) {
|
|
599
|
+
calculateValueFontSize() {
|
|
600
|
+
if (!this.canvas.ctx) {
|
|
221
601
|
return;
|
|
222
602
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
603
|
+
this.valueStyle = { maxWidth: `${this.lineLength}px`, fontSize: `${this.calculateFontSize(this.canvas.ctx, TextType.VALUE)}px` };
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* Compute percentage of value
|
|
607
|
+
* @param value value of primary or secondary
|
|
608
|
+
* @returns percentage of value
|
|
609
|
+
*/
|
|
610
|
+
getPercentage(value) {
|
|
611
|
+
if (value === 0) {
|
|
612
|
+
return 0;
|
|
613
|
+
}
|
|
614
|
+
return 100 * value / (this.primaryValue + this.secondaryValue);
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Handles canvas resize
|
|
618
|
+
* @returns {void}
|
|
619
|
+
*/
|
|
620
|
+
onCanvasResize() {
|
|
621
|
+
this.calculateCanvasSize();
|
|
622
|
+
this.updateFontSize();
|
|
623
|
+
this.renderCanvas('resize');
|
|
624
|
+
this.updateGaugePositions();
|
|
625
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* Renders legend container
|
|
628
|
+
* @returns {TemplateResult} Legend template or null
|
|
629
|
+
*/
|
|
630
|
+
get legendTemplate() {
|
|
631
|
+
return this.primaryLegend.length > 0 || this.secondaryLegend.length > 0
|
|
632
|
+
? html `<div part="legend-container-outer">
|
|
633
|
+
<div part="legend-container-inner">
|
|
634
|
+
${this.primaryLegendTemplate}
|
|
635
|
+
${this.secondaryLegendTemplate}
|
|
636
|
+
</div>
|
|
637
|
+
</div>`
|
|
638
|
+
: null;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Renders primary legend if property present
|
|
642
|
+
* @returns {TemplateResult} Primary legend template or null
|
|
643
|
+
*/
|
|
644
|
+
get primaryLegendTemplate() {
|
|
645
|
+
return this.primaryLegend
|
|
646
|
+
? html `<div part="primary-legend">
|
|
647
|
+
<span part="primary-legend-symbol"></span>
|
|
648
|
+
<ef-label max-line="${MAX_LEGEND_LINE}" line-clamp="${MAX_LEGEND_LINE}">${this.primaryLegend}</ef-label>
|
|
649
|
+
</div>`
|
|
650
|
+
: null;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Renders secondary legend if property present
|
|
654
|
+
* @returns {TemplateResult} Secondary legend template or null
|
|
655
|
+
*/
|
|
656
|
+
get secondaryLegendTemplate() {
|
|
657
|
+
return this.secondaryLegend
|
|
658
|
+
? html `<div part="secondary-legend">
|
|
659
|
+
<span part="secondary-legend-symbol"></span>
|
|
660
|
+
<ef-label max-line="${MAX_LEGEND_LINE}" line-clamp="${MAX_LEGEND_LINE}">${this.secondaryLegend}</ef-label>
|
|
661
|
+
</div>`
|
|
662
|
+
: null;
|
|
663
|
+
}
|
|
664
|
+
render() {
|
|
665
|
+
return html `
|
|
666
|
+
<div part="container">
|
|
667
|
+
${this.legendTemplate}
|
|
668
|
+
<div part="canvas-container">
|
|
669
|
+
<ef-canvas part="canvas" @resize=${this.onCanvasResize}></ef-canvas>
|
|
670
|
+
<div part="primary-container" style=${styleMap(this.primaryContainerStyle)}>
|
|
671
|
+
${this.primaryLabel ? html `
|
|
672
|
+
<ef-label
|
|
673
|
+
part="primary-label"
|
|
674
|
+
max-line="${MAX_LABEL_LINE}"
|
|
675
|
+
line-clamp="${MAX_LABEL_LINE}"
|
|
676
|
+
style=${styleMap(this.labelStyle)}
|
|
677
|
+
>${this.primaryLabel}
|
|
678
|
+
</ef-label><br>`
|
|
679
|
+
: null}
|
|
680
|
+
<ef-label
|
|
681
|
+
part="primary-value"
|
|
682
|
+
truncate=""
|
|
683
|
+
line-clamp="1"
|
|
684
|
+
style=${styleMap(this.valueStyle)}
|
|
685
|
+
>${this.valueFormatter(this.primaryPercentage, this.primaryValue)}</ef-label
|
|
686
|
+
>
|
|
687
|
+
</div>
|
|
688
|
+
<div part="secondary-container" style=${styleMap(this.secondaryContainerStyle)}>
|
|
689
|
+
${this.secondaryLabel ? html `
|
|
690
|
+
<ef-label
|
|
691
|
+
part="secondary-label"
|
|
692
|
+
max-line="${MAX_LABEL_LINE}"
|
|
693
|
+
line-clamp="${MAX_LABEL_LINE}"
|
|
694
|
+
style=${styleMap(this.labelStyle)}
|
|
695
|
+
>${this.secondaryLabel}
|
|
696
|
+
</ef-label><br>`
|
|
697
|
+
: null}
|
|
698
|
+
<ef-label
|
|
699
|
+
part="secondary-value"
|
|
700
|
+
truncate=""
|
|
701
|
+
line-clamp="1"
|
|
702
|
+
style=${styleMap(this.valueStyle)}
|
|
703
|
+
>${this.valueFormatter(this.secondaryPercentage, this.secondaryValue)}</ef-label
|
|
704
|
+
>
|
|
705
|
+
</div>
|
|
706
|
+
</div>
|
|
707
|
+
</div>
|
|
708
|
+
`;
|
|
261
709
|
}
|
|
262
710
|
};
|
|
263
711
|
__decorate([
|
|
264
712
|
property({ attribute: 'primary-value', type: Number })
|
|
265
|
-
], SwingGauge.prototype, "primaryValue",
|
|
713
|
+
], SwingGauge.prototype, "primaryValue", null);
|
|
266
714
|
__decorate([
|
|
267
715
|
property({ attribute: 'primary-label', type: String })
|
|
268
716
|
], SwingGauge.prototype, "primaryLabel", void 0);
|
|
269
717
|
__decorate([
|
|
270
718
|
property({ attribute: 'secondary-value', type: Number })
|
|
271
|
-
], SwingGauge.prototype, "secondaryValue",
|
|
719
|
+
], SwingGauge.prototype, "secondaryValue", null);
|
|
272
720
|
__decorate([
|
|
273
721
|
property({ attribute: 'secondary-label', type: String })
|
|
274
722
|
], SwingGauge.prototype, "secondaryLabel", void 0);
|
|
275
723
|
__decorate([
|
|
276
724
|
property({ type: Number })
|
|
277
725
|
], SwingGauge.prototype, "duration", void 0);
|
|
726
|
+
__decorate([
|
|
727
|
+
property({ type: String, reflect: true, attribute: 'primary-legend' })
|
|
728
|
+
], SwingGauge.prototype, "primaryLegend", void 0);
|
|
729
|
+
__decorate([
|
|
730
|
+
property({ type: String, reflect: true, attribute: 'secondary-legend' })
|
|
731
|
+
], SwingGauge.prototype, "secondaryLegend", void 0);
|
|
732
|
+
__decorate([
|
|
733
|
+
property({ type: Function, attribute: false })
|
|
734
|
+
], SwingGauge.prototype, "valueFormatter", void 0);
|
|
735
|
+
__decorate([
|
|
736
|
+
state()
|
|
737
|
+
], SwingGauge.prototype, "primaryContainerStyle", void 0);
|
|
738
|
+
__decorate([
|
|
739
|
+
state()
|
|
740
|
+
], SwingGauge.prototype, "secondaryContainerStyle", void 0);
|
|
741
|
+
__decorate([
|
|
742
|
+
state()
|
|
743
|
+
], SwingGauge.prototype, "labelStyle", void 0);
|
|
744
|
+
__decorate([
|
|
745
|
+
state()
|
|
746
|
+
], SwingGauge.prototype, "valueStyle", void 0);
|
|
747
|
+
__decorate([
|
|
748
|
+
query('[part=primary-container]', true)
|
|
749
|
+
], SwingGauge.prototype, "primaryContainer", void 0);
|
|
750
|
+
__decorate([
|
|
751
|
+
query('[part=secondary-container]', true)
|
|
752
|
+
], SwingGauge.prototype, "secondaryContainer", void 0);
|
|
753
|
+
__decorate([
|
|
754
|
+
query('[part=legend-container-outer]')
|
|
755
|
+
], SwingGauge.prototype, "legendContainer", void 0);
|
|
756
|
+
__decorate([
|
|
757
|
+
query('[part=canvas]', true)
|
|
758
|
+
], SwingGauge.prototype, "canvas", void 0);
|
|
278
759
|
SwingGauge = __decorate([
|
|
279
760
|
customElement('ef-swing-gauge', {
|
|
280
761
|
alias: 'sapphire-swing-gauge'
|
|
281
762
|
})
|
|
282
763
|
], SwingGauge);
|
|
283
764
|
export { SwingGauge };
|
|
284
|
-
//# sourceMappingURL=index.js.map
|