@refinitiv-ui/elements 5.3.4 → 5.8.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 +89 -0
- package/lib/accordion/custom-elements.md +18 -0
- package/lib/accordion/index.d.ts +5 -5
- package/lib/accordion/index.js +8 -11
- package/lib/appstate-bar/custom-elements.md +22 -0
- package/lib/appstate-bar/index.d.ts +5 -5
- package/lib/appstate-bar/index.js +8 -11
- package/lib/autosuggest/custom-elements.json +24 -4
- package/lib/autosuggest/custom-elements.md +54 -0
- package/lib/autosuggest/helpers/types.d.ts +1 -1
- package/lib/autosuggest/helpers/utils.d.ts +2 -2
- package/lib/autosuggest/helpers/utils.js +1 -2
- package/lib/autosuggest/index.d.ts +13 -8
- package/lib/autosuggest/index.js +38 -31
- package/lib/button/custom-elements.json +2 -2
- package/lib/button/custom-elements.md +23 -0
- package/lib/button/index.d.ts +13 -13
- package/lib/button/index.js +41 -31
- package/lib/button-bar/custom-elements.md +9 -0
- package/lib/button-bar/index.d.ts +3 -3
- package/lib/button-bar/index.js +8 -10
- package/lib/calendar/constants.d.ts +22 -0
- package/lib/calendar/constants.js +23 -0
- package/lib/calendar/custom-elements.json +8 -6
- package/lib/calendar/custom-elements.md +35 -0
- package/lib/calendar/index.d.ts +9 -7
- package/lib/calendar/index.js +20 -38
- package/lib/calendar/locales.d.ts +1 -31
- package/lib/calendar/locales.js +0 -104
- package/lib/calendar/types.d.ts +1 -5
- package/lib/calendar/types.js +1 -6
- package/lib/calendar/utils.d.ts +31 -1
- package/lib/calendar/utils.js +104 -2
- package/lib/canvas/custom-elements.json +7 -5
- package/lib/canvas/custom-elements.md +27 -0
- package/lib/canvas/index.d.ts +4 -3
- package/lib/canvas/index.js +8 -10
- package/lib/card/custom-elements.json +3 -1
- package/lib/card/custom-elements.md +24 -0
- package/lib/card/helpers/types.d.ts +1 -1
- package/lib/card/index.d.ts +10 -8
- package/lib/card/index.js +14 -13
- package/lib/chart/custom-elements.json +1 -1
- package/lib/chart/custom-elements.md +16 -0
- package/lib/chart/helpers/index.d.ts +2 -2
- package/lib/chart/helpers/index.js +2 -2
- package/lib/chart/index.d.ts +6 -6
- package/lib/chart/index.js +12 -14
- package/lib/checkbox/custom-elements.json +4 -4
- package/lib/checkbox/custom-elements.md +18 -0
- package/lib/checkbox/index.d.ts +21 -13
- package/lib/checkbox/index.js +56 -31
- package/lib/clock/custom-elements.json +21 -4
- package/lib/clock/custom-elements.md +28 -0
- package/lib/clock/index.d.ts +17 -5
- package/lib/clock/index.js +37 -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 -2
- package/lib/collapse/custom-elements.md +27 -0
- package/lib/collapse/index.d.ts +7 -7
- package/lib/collapse/index.js +11 -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 +5 -5
- package/lib/color-dialog/elements/color-palettes.js +9 -13
- package/lib/color-dialog/elements/grayscale-palettes.d.ts +5 -5
- package/lib/color-dialog/elements/grayscale-palettes.js +10 -13
- package/lib/color-dialog/elements/palettes.d.ts +10 -3
- package/lib/color-dialog/elements/palettes.js +58 -45
- package/lib/color-dialog/helpers/color-helpers.d.ts +7 -53
- package/lib/color-dialog/helpers/color-helpers.js +12 -109
- package/lib/color-dialog/helpers/value-model.d.ts +1 -1
- package/lib/color-dialog/helpers/value-model.js +18 -16
- package/lib/color-dialog/index.d.ts +19 -19
- package/lib/color-dialog/index.js +47 -45
- package/lib/combo-box/custom-elements.json +28 -16
- package/lib/combo-box/custom-elements.md +35 -0
- package/lib/combo-box/helpers/filter.d.ts +4 -4
- package/lib/combo-box/helpers/types.d.ts +2 -2
- package/lib/combo-box/index.d.ts +26 -18
- package/lib/combo-box/index.js +36 -27
- package/lib/combo-box/themes/halo/dark/index.js +1 -1
- package/lib/combo-box/themes/halo/light/index.js +1 -1
- package/lib/combo-box/themes/solar/charcoal/index.js +1 -1
- package/lib/combo-box/themes/solar/pearl/index.js +1 -1
- package/lib/counter/custom-elements.json +8 -4
- package/lib/counter/custom-elements.md +11 -0
- package/lib/counter/index.d.ts +5 -3
- package/lib/counter/index.js +11 -12
- package/lib/datetime-picker/custom-elements.json +52 -23
- package/lib/datetime-picker/custom-elements.md +57 -0
- package/lib/datetime-picker/index.d.ts +25 -14
- package/lib/datetime-picker/index.js +46 -35
- package/lib/datetime-picker/locales.d.ts +1 -1
- package/lib/datetime-picker/locales.js +12 -1
- 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/utils.js +1 -1
- package/lib/dialog/custom-elements.json +34 -12
- package/lib/dialog/custom-elements.md +47 -0
- package/lib/dialog/index.d.ts +17 -20
- package/lib/dialog/index.js +28 -31
- 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 +44 -116
- package/lib/email-field/index.js +48 -249
- 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 +2 -2
- package/lib/events.js +1 -2
- package/lib/flag/custom-elements.md +10 -0
- package/lib/flag/index.d.ts +6 -4
- package/lib/flag/index.js +12 -12
- package/lib/flag/utils/FlagLoader.d.ts +1 -1
- package/lib/flag/utils/FlagLoader.js +1 -1
- package/lib/header/custom-elements.md +18 -0
- package/lib/header/index.d.ts +2 -2
- package/lib/header/index.js +5 -8
- package/lib/heatmap/custom-elements.md +26 -0
- package/lib/heatmap/helpers/color.d.ts +1 -1
- package/lib/heatmap/helpers/color.js +1 -1
- package/lib/heatmap/helpers/text.d.ts +1 -1
- package/lib/heatmap/index.d.ts +7 -7
- package/lib/heatmap/index.js +15 -16
- package/lib/icon/custom-elements.json +6 -4
- package/lib/icon/custom-elements.md +8 -0
- package/lib/icon/index.d.ts +9 -6
- package/lib/icon/index.js +28 -18
- package/lib/icon/utils/IconLoader.d.ts +6 -1
- package/lib/icon/utils/IconLoader.js +24 -17
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/interactive-chart/custom-elements.json +6 -10
- package/lib/interactive-chart/custom-elements.md +31 -0
- package/lib/interactive-chart/helpers/types.d.ts +2 -2
- package/lib/interactive-chart/index.d.ts +11 -8
- package/lib/interactive-chart/index.js +17 -17
- 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/index.d.ts +18 -8
- package/lib/item/index.js +36 -16
- package/lib/label/custom-elements.md +11 -0
- package/lib/label/index.d.ts +3 -3
- package/lib/label/index.js +12 -20
- package/lib/layout/custom-elements.md +26 -0
- package/lib/layout/index.d.ts +3 -3
- package/lib/layout/index.js +6 -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 +5 -4
- package/lib/led-gauge/index.js +9 -11
- package/lib/list/custom-elements.json +18 -5
- package/lib/list/custom-elements.md +32 -0
- package/lib/list/helpers/list-renderer.d.ts +2 -2
- package/lib/list/helpers/list-renderer.js +4 -2
- package/lib/list/helpers/types.d.ts +2 -2
- package/lib/list/index.d.ts +27 -10
- package/lib/list/index.js +54 -25
- package/lib/list/renderer.d.ts +2 -2
- package/lib/list/renderer.js +1 -1
- package/lib/loader/custom-elements.md +5 -0
- package/lib/loader/index.js +4 -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/index.d.ts +11 -7
- package/lib/multi-input/index.js +20 -17
- 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 +2 -2
- package/lib/notification/elements/notification-tray.js +6 -9
- package/lib/notification/elements/notification.d.ts +5 -5
- package/lib/notification/elements/notification.js +8 -11
- package/lib/notification/helpers/status.d.ts +1 -1
- package/lib/notification/helpers/status.js +1 -1
- package/lib/notification/helpers/types.d.ts +1 -1
- package/lib/notification/index.d.ts +2 -2
- package/lib/notification/index.js +2 -2
- 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 +96 -51
- package/lib/number-field/index.js +121 -89
- 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 +4 -4
- package/lib/overlay/elements/overlay-backdrop.js +6 -9
- package/lib/overlay/elements/overlay-viewport.d.ts +3 -3
- package/lib/overlay/elements/overlay-viewport.js +5 -9
- package/lib/overlay/elements/overlay.d.ts +10 -5
- package/lib/overlay/elements/overlay.js +27 -28
- package/lib/overlay/index.d.ts +2 -2
- package/lib/overlay/index.js +1 -1
- package/lib/overlay/managers/backdrop-manager.d.ts +1 -1
- package/lib/overlay/managers/backdrop-manager.js +2 -2
- package/lib/overlay/managers/close-manager.js +1 -1
- package/lib/overlay/managers/focus-manager.js +2 -2
- package/lib/overlay/managers/interaction-lock-manager.js +2 -2
- package/lib/overlay/managers/viewport-manager.d.ts +2 -2
- package/lib/overlay/managers/viewport-manager.js +6 -2
- package/lib/overlay/managers/zindex-manager.js +1 -1
- package/lib/overlay-menu/custom-elements.json +70 -20
- package/lib/overlay-menu/custom-elements.md +44 -0
- package/lib/overlay-menu/helpers/types.d.ts +3 -3
- package/lib/overlay-menu/index.d.ts +26 -19
- package/lib/overlay-menu/index.js +47 -33
- package/lib/overlay-menu/managers/menu-manager.d.ts +2 -2
- package/lib/overlay-menu/managers/menu-manager.js +3 -3
- package/lib/pagination/custom-elements.md +27 -0
- package/lib/pagination/index.d.ts +8 -8
- package/lib/pagination/index.js +13 -15
- package/lib/panel/custom-elements.md +11 -0
- package/lib/panel/index.d.ts +3 -3
- package/lib/panel/index.js +6 -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 +43 -94
- package/lib/password-field/index.js +52 -198
- 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 +8 -6
- package/lib/pill/custom-elements.md +22 -0
- package/lib/pill/index.d.ts +5 -5
- package/lib/pill/index.js +9 -11
- package/lib/progress-bar/custom-elements.md +18 -0
- package/lib/progress-bar/index.d.ts +3 -3
- package/lib/progress-bar/index.js +7 -9
- 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 +25 -8
- package/lib/radio-button/index.js +84 -21
- package/lib/radio-button/radio-button-registry.d.ts +3 -2
- package/lib/radio-button/radio-button-registry.js +57 -4
- package/lib/rating/custom-elements.md +17 -0
- package/lib/rating/index.d.ts +3 -3
- package/lib/rating/index.js +9 -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 +44 -101
- package/lib/search-field/index.js +50 -220
- 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/index.d.ts +18 -10
- package/lib/select/index.js +84 -45
- 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 +7 -6
- package/lib/sidebar-layout/index.js +9 -10
- package/lib/slider/custom-elements.json +4 -4
- package/lib/slider/custom-elements.md +28 -0
- package/lib/slider/index.d.ts +4 -4
- package/lib/slider/index.js +9 -10
- package/lib/sparkline/custom-elements.json +4 -4
- package/lib/sparkline/custom-elements.md +16 -0
- package/lib/sparkline/index.d.ts +6 -4
- package/lib/sparkline/index.js +10 -10
- package/lib/swing-gauge/custom-elements.json +5 -3
- package/lib/swing-gauge/custom-elements.md +17 -0
- package/lib/swing-gauge/helpers.d.ts +1 -1
- package/lib/swing-gauge/helpers.js +1 -1
- package/lib/swing-gauge/index.d.ts +9 -7
- package/lib/swing-gauge/index.js +17 -15
- package/lib/tab/custom-elements.json +2 -2
- package/lib/tab/custom-elements.md +22 -0
- package/lib/tab/index.d.ts +5 -5
- package/lib/tab/index.js +9 -12
- 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.md +11 -0
- package/lib/tab-bar/index.d.ts +4 -4
- package/lib/tab-bar/index.js +9 -11
- 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 +59 -79
- package/lib/text-field/index.js +99 -158
- 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 +4 -4
- package/lib/time-picker/custom-elements.md +28 -0
- package/lib/time-picker/index.d.ts +7 -4
- package/lib/time-picker/index.js +15 -14
- 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 +14 -4
- package/lib/toggle/index.js +31 -12
- package/lib/tooltip/custom-elements.md +14 -0
- package/lib/tooltip/elements/title-tooltip.js +2 -2
- package/lib/tooltip/elements/tooltip-element.d.ts +1 -1
- package/lib/tooltip/helpers/overflow-tooltip.d.ts +1 -1
- package/lib/tooltip/helpers/overflow-tooltip.js +1 -1
- package/lib/tooltip/helpers/renderer.d.ts +1 -1
- package/lib/tooltip/helpers/types.d.ts +1 -1
- package/lib/tooltip/index.d.ts +9 -9
- package/lib/tooltip/index.js +18 -20
- package/lib/tooltip/managers/tooltip-manager.d.ts +2 -2
- package/lib/tooltip/managers/tooltip-manager.js +3 -7
- package/lib/tornado-chart/custom-elements.md +18 -0
- package/lib/tornado-chart/elements/tornado-chart.d.ts +4 -4
- package/lib/tornado-chart/elements/tornado-chart.js +8 -11
- package/lib/tornado-chart/elements/tornado-item.d.ts +5 -5
- package/lib/tornado-chart/elements/tornado-item.js +10 -12
- package/lib/tornado-chart/index.d.ts +2 -2
- package/lib/tornado-chart/index.js +2 -2
- package/lib/tree/custom-elements.json +17 -3
- package/lib/tree/custom-elements.md +32 -0
- package/lib/tree/elements/tree-item.d.ts +4 -4
- package/lib/tree/elements/tree-item.js +10 -13
- package/lib/tree/elements/tree.d.ts +51 -5
- package/lib/tree/elements/tree.js +138 -11
- 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 +3 -3
- package/lib/tree/helpers/types.d.ts +9 -1
- package/lib/tree/index.d.ts +4 -4
- package/lib/tree/index.js +3 -3
- package/lib/tree/managers/tree-manager.d.ts +22 -10
- package/lib/tree/managers/tree-manager.js +56 -40
- 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 +10 -6
- package/lib/tree-select/custom-elements.md +26 -0
- package/lib/tree-select/helpers/types.d.ts +2 -2
- package/lib/tree-select/index.d.ts +32 -28
- package/lib/tree-select/index.js +54 -44
- package/lib/tree-select/themes/halo/dark/index.js +1 -1
- package/lib/tree-select/themes/halo/light/index.js +1 -1
- package/lib/tree-select/themes/solar/charcoal/index.js +1 -1
- package/lib/tree-select/themes/solar/pearl/index.js +1 -1
- package/lib/version.d.ts +1 -0
- package/lib/version.js +1 -0
- package/package.json +298 -15
- package/lib/autosuggest/helpers/const.d.ts +0 -2
- package/lib/autosuggest/helpers/const.js +0 -3
- package/lib/overlay-menu/helpers/uuid.d.ts +0 -7
- package/lib/overlay-menu/helpers/uuid.js +0 -13
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# ef-color-dialog
|
|
2
|
+
|
|
3
|
+
Displays a colour picker dialog,
|
|
4
|
+
for selecting a predefined range of colours.
|
|
5
|
+
|
|
6
|
+
## Attributes
|
|
7
|
+
|
|
8
|
+
| Attribute | Type | Default | Description |
|
|
9
|
+
|------------------------|-----------------------|---------|--------------------------------------------------|
|
|
10
|
+
| `no-cancel-on-esc-key` | `boolean` | false | Prevents dialog to close when user presses ESC key |
|
|
11
|
+
| `position-target` | `string \| undefined` | | Set position of dialog i.e. `top`, `right`, `left`, `bottom`, `center` or combination of theme e.g. `top right`. |
|
|
12
|
+
|
|
13
|
+
## Properties
|
|
14
|
+
|
|
15
|
+
| Property | Attribute | Type | Default | Description |
|
|
16
|
+
|--------------------------|------------------------|-----------------------|---------|--------------------------------------------------|
|
|
17
|
+
| `allowNocolor` | `allow-nocolor` | `boolean` | false | Set the palettes to activate no-color option |
|
|
18
|
+
| `blue` | `blue` | `string` | "" | Blue value from 0 to 255 |
|
|
19
|
+
| `draggable` | | `boolean` | true | False to make the dialog not draggable. |
|
|
20
|
+
| `green` | `green` | `string` | "" | Green value from 0 to 255 |
|
|
21
|
+
| `header` | `header` | `string \| null` | null | Set Header/Title of the color dialog |
|
|
22
|
+
| `hex` | `hex` | `string` | "" | Value of hex without # sign, supports both 3-digits shorthand hex and regular 6-digits hex |
|
|
23
|
+
| `noCancelOnEscKey` | `no-cancel-on-esc-key` | `boolean` | false | Prevents dialog to close when user presses ESC key |
|
|
24
|
+
| `noCancelOnOutsideClick` | | `boolean` | true | Prevents dialog to close when user clicks outside the dialog. |
|
|
25
|
+
| `opened` | `opened` | `boolean` | false | Set dialog to open |
|
|
26
|
+
| `positionTarget` | `position-target` | `string \| undefined` | | Set position of dialog i.e. `top`, `right`, `left`, `bottom`, `center` or combination of theme e.g. `top right`. |
|
|
27
|
+
| `red` | `red` | `string` | "" | Red value from 0 to 255 |
|
|
28
|
+
| `value` | `value` | `string` | "" | Value of selected color from color dialog will be written here as hex value<br />e.g. "#00f" or "#0000ff" |
|
|
29
|
+
| `withBackdrop` | | `boolean` | true | False to hide backdrop. |
|
|
30
|
+
| `withShadow` | | `boolean` | true | False to remove shadow for dialog component. |
|
|
31
|
+
| `x` | `x` | `string \| undefined` | | Set a specific x coordinate of dialog |
|
|
32
|
+
| `y` | `y` | `string \| undefined` | | Set a specific y coordinate of dialog |
|
|
33
|
+
|
|
34
|
+
## Events
|
|
35
|
+
|
|
36
|
+
| Event | Description |
|
|
37
|
+
|------------------|-------------------------------------------|
|
|
38
|
+
| `opened-changed` | Fired when the `opened` property changes. |
|
|
39
|
+
| `value-changed` | Fired when the `value` property changes. |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JSXInterface } from '../../jsx';
|
|
2
|
-
import { TemplateResult,
|
|
3
|
-
import { Palettes } from './palettes';
|
|
2
|
+
import { TemplateResult, CSSResultGroup, PropertyValues } from '@refinitiv-ui/core';
|
|
3
|
+
import { Palettes } from './palettes.js';
|
|
4
4
|
/**
|
|
5
5
|
* Component that allows user to select
|
|
6
6
|
* any colours by tapping or dragging
|
|
@@ -12,12 +12,12 @@ export declare class ColorPalettes extends Palettes {
|
|
|
12
12
|
*/
|
|
13
13
|
static get version(): string;
|
|
14
14
|
/**
|
|
15
|
-
* A `
|
|
15
|
+
* A `CSSResultGroup` that will be used
|
|
16
16
|
* to style the host, slotted children
|
|
17
17
|
* and the internal template of the element.
|
|
18
|
-
* @return
|
|
18
|
+
* @return CSS template
|
|
19
19
|
*/
|
|
20
|
-
static get styles():
|
|
20
|
+
static get styles(): CSSResultGroup;
|
|
21
21
|
/**
|
|
22
22
|
* create color items template from COLOR_ITEMS array
|
|
23
23
|
* @return color items template
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
import { html, css, customElement, svg } from '@refinitiv-ui/core';
|
|
8
|
-
import { Palettes } from './palettes';
|
|
9
|
-
import { COLOR_ITEMS, ColorHelpers } from '../helpers/color-helpers';
|
|
10
|
-
import { VERSION } from '../../';
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, css, svg } from '@refinitiv-ui/core';
|
|
3
|
+
import { customElement } from '@refinitiv-ui/core/lib/decorators/custom-element.js';
|
|
4
|
+
import { VERSION } from '../../version.js';
|
|
5
|
+
import { Palettes } from './palettes.js';
|
|
6
|
+
import { COLOR_ITEMS } from '../helpers/color-helpers.js';
|
|
11
7
|
/**
|
|
12
8
|
* Component that allows user to select
|
|
13
9
|
* any colours by tapping or dragging
|
|
@@ -21,10 +17,10 @@ let ColorPalettes = class ColorPalettes extends Palettes {
|
|
|
21
17
|
return VERSION;
|
|
22
18
|
}
|
|
23
19
|
/**
|
|
24
|
-
* A `
|
|
20
|
+
* A `CSSResultGroup` that will be used
|
|
25
21
|
* to style the host, slotted children
|
|
26
22
|
* and the internal template of the element.
|
|
27
|
-
* @return
|
|
23
|
+
* @return CSS template
|
|
28
24
|
*/
|
|
29
25
|
static get styles() {
|
|
30
26
|
return css `
|
|
@@ -75,7 +71,7 @@ let ColorPalettes = class ColorPalettes extends Palettes {
|
|
|
75
71
|
*/
|
|
76
72
|
updated(changedProperties) {
|
|
77
73
|
if (changedProperties.has('value')) {
|
|
78
|
-
const value =
|
|
74
|
+
const value = this.expandHex(this.value);
|
|
79
75
|
const item = COLOR_ITEMS.find((item) => item[1] === value);
|
|
80
76
|
if (item) {
|
|
81
77
|
this.showSelector(item[0]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JSXInterface } from '../../jsx';
|
|
2
|
-
import { TemplateResult,
|
|
3
|
-
import { Palettes } from './palettes';
|
|
2
|
+
import { TemplateResult, CSSResultGroup, PropertyValues } from '@refinitiv-ui/core';
|
|
3
|
+
import { Palettes } from './palettes.js';
|
|
4
4
|
/**
|
|
5
5
|
* Component that allows user to select any
|
|
6
6
|
* grayscale color by tapping or dragging
|
|
@@ -12,12 +12,12 @@ export declare class GrayscalePalettes extends Palettes {
|
|
|
12
12
|
*/
|
|
13
13
|
static get version(): string;
|
|
14
14
|
/**
|
|
15
|
-
* A `
|
|
15
|
+
* A `CSSResultGroup` that will be used
|
|
16
16
|
* to style the host, slotted children
|
|
17
17
|
* and the internal template of the element.
|
|
18
|
-
* @return
|
|
18
|
+
* @return CSS template
|
|
19
19
|
*/
|
|
20
|
-
static get styles():
|
|
20
|
+
static get styles(): CSSResultGroup;
|
|
21
21
|
/**
|
|
22
22
|
* Set the palettes to activate no-color option
|
|
23
23
|
*/
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
import {
|
|
8
|
-
import { Palettes } from './palettes';
|
|
9
|
-
import { GRAYSCALE_ITEMS, NOCOLOR_POINTS, ColorHelpers } from '../helpers/color-helpers';
|
|
10
|
-
import { VERSION } from '../../';
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, css, svg } 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 { VERSION } from '../../version.js';
|
|
6
|
+
import { Palettes } from './palettes.js';
|
|
7
|
+
import { GRAYSCALE_ITEMS, NOCOLOR_POINTS } from '../helpers/color-helpers.js';
|
|
11
8
|
/**
|
|
12
9
|
* Component that allows user to select any
|
|
13
10
|
* grayscale color by tapping or dragging
|
|
@@ -28,10 +25,10 @@ let GrayscalePalettes = class GrayscalePalettes extends Palettes {
|
|
|
28
25
|
return VERSION;
|
|
29
26
|
}
|
|
30
27
|
/**
|
|
31
|
-
* A `
|
|
28
|
+
* A `CSSResultGroup` that will be used
|
|
32
29
|
* to style the host, slotted children
|
|
33
30
|
* and the internal template of the element.
|
|
34
|
-
* @return
|
|
31
|
+
* @return CSS template
|
|
35
32
|
*/
|
|
36
33
|
static get styles() {
|
|
37
34
|
return css `
|
|
@@ -107,7 +104,7 @@ let GrayscalePalettes = class GrayscalePalettes extends Palettes {
|
|
|
107
104
|
*/
|
|
108
105
|
updated(changedProperties) {
|
|
109
106
|
if (changedProperties.has('value')) {
|
|
110
|
-
const value =
|
|
107
|
+
const value = this.expandHex(this.value);
|
|
111
108
|
const item = GRAYSCALE_ITEMS.find((item) => item[1] === value);
|
|
112
109
|
if (this.allowNocolor && this.value === '') {
|
|
113
110
|
this.showSelector(NOCOLOR_POINTS);
|
|
@@ -36,23 +36,30 @@ export declare class Palettes extends BasicElement {
|
|
|
36
36
|
* @param event mouse event
|
|
37
37
|
* @return {void}
|
|
38
38
|
*/
|
|
39
|
-
protected onTapItem
|
|
39
|
+
protected onTapItem(event: MouseEvent): void;
|
|
40
40
|
/**
|
|
41
41
|
* Update color value when drag on color item
|
|
42
42
|
* @param event mouse event
|
|
43
43
|
* @return {void}
|
|
44
44
|
*/
|
|
45
|
-
protected onMousemove
|
|
45
|
+
protected onMousemove(event: MouseEvent): void;
|
|
46
46
|
/**
|
|
47
47
|
* Update color value when drag on color item in mobile device
|
|
48
48
|
* @param event touch event
|
|
49
49
|
* @return {void}
|
|
50
50
|
*/
|
|
51
|
-
protected onTouchmove
|
|
51
|
+
protected onTouchmove(event: TouchEvent): void;
|
|
52
52
|
/**
|
|
53
53
|
* Update color value and fired value-changed event
|
|
54
54
|
* @param element target element to get value
|
|
55
55
|
* @return {void}
|
|
56
56
|
*/
|
|
57
57
|
protected updateValue(element: SVGAElement): void;
|
|
58
|
+
/**
|
|
59
|
+
* Expand short format hex into long format
|
|
60
|
+
* For instance, "#fff" becomes "#ffffff"
|
|
61
|
+
* @param hex hex to expand
|
|
62
|
+
* @returns expanded hex value
|
|
63
|
+
*/
|
|
64
|
+
protected expandHex(hex: string): string;
|
|
58
65
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
import {
|
|
8
|
-
import { VERSION } from '../../';
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { BasicElement, svg } from '@refinitiv-ui/core';
|
|
3
|
+
import { property } from '@refinitiv-ui/core/lib/decorators/property.js';
|
|
4
|
+
import { query } from '@refinitiv-ui/core/lib/decorators/query.js';
|
|
5
|
+
import { VERSION } from '../../version.js';
|
|
6
|
+
import { rgb } from '@refinitiv-ui/utils/lib/color.js';
|
|
7
|
+
import { isHex } from '../helpers/color-helpers.js';
|
|
9
8
|
/**
|
|
10
9
|
* Element base class usually used
|
|
11
10
|
* for creating palettes elements.
|
|
@@ -17,43 +16,6 @@ export class Palettes extends BasicElement {
|
|
|
17
16
|
* Color value in hex
|
|
18
17
|
*/
|
|
19
18
|
this.value = '';
|
|
20
|
-
/**
|
|
21
|
-
* Update color value when tab on color item
|
|
22
|
-
* @param event mouse event
|
|
23
|
-
* @return {void}
|
|
24
|
-
*/
|
|
25
|
-
this.onTapItem = (event) => {
|
|
26
|
-
const polygonElement = event.target;
|
|
27
|
-
this.updateValue(polygonElement);
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Update color value when drag on color item
|
|
31
|
-
* @param event mouse event
|
|
32
|
-
* @return {void}
|
|
33
|
-
*/
|
|
34
|
-
this.onMousemove = (event) => {
|
|
35
|
-
const polygonElement = event.target;
|
|
36
|
-
let mouseButton = event.buttons;
|
|
37
|
-
if (mouseButton === undefined) { // buttons property is not supported in safari
|
|
38
|
-
mouseButton = event.which;
|
|
39
|
-
}
|
|
40
|
-
if (mouseButton !== 1) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
// only update when user click and drag on color item
|
|
44
|
-
this.updateValue(polygonElement);
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Update color value when drag on color item in mobile device
|
|
48
|
-
* @param event touch event
|
|
49
|
-
* @return {void}
|
|
50
|
-
*/
|
|
51
|
-
this.onTouchmove = (event) => {
|
|
52
|
-
var _a;
|
|
53
|
-
const touchOffsets = event.changedTouches[0];
|
|
54
|
-
const realTarget = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.elementFromPoint(touchOffsets.clientX, touchOffsets.clientY);
|
|
55
|
-
this.updateValue(realTarget);
|
|
56
|
-
};
|
|
57
19
|
}
|
|
58
20
|
/**
|
|
59
21
|
* Element version number
|
|
@@ -95,6 +57,48 @@ export class Palettes extends BasicElement {
|
|
|
95
57
|
this.colorSelector.setAttribute('points', points);
|
|
96
58
|
}
|
|
97
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Update color value when tab on color item
|
|
62
|
+
* @param event mouse event
|
|
63
|
+
* @return {void}
|
|
64
|
+
*/
|
|
65
|
+
onTapItem(event) {
|
|
66
|
+
const polygonElement = event.target;
|
|
67
|
+
this.updateValue(polygonElement);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Update color value when drag on color item
|
|
71
|
+
* @param event mouse event
|
|
72
|
+
* @return {void}
|
|
73
|
+
*/
|
|
74
|
+
onMousemove(event) {
|
|
75
|
+
const polygonElement = event.target;
|
|
76
|
+
let mouseButton = event.buttons;
|
|
77
|
+
if (mouseButton === undefined) { // buttons property is not supported in safari
|
|
78
|
+
mouseButton = event.which;
|
|
79
|
+
}
|
|
80
|
+
if (mouseButton !== 1) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// only update when user click and drag on color item
|
|
84
|
+
this.updateValue(polygonElement);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Update color value when drag on color item in mobile device
|
|
88
|
+
* @param event touch event
|
|
89
|
+
* @return {void}
|
|
90
|
+
*/
|
|
91
|
+
onTouchmove(event) {
|
|
92
|
+
var _a;
|
|
93
|
+
const touchOffsets = event.changedTouches[0];
|
|
94
|
+
// TODO: it is a bug of TypeScript@4.4 remove ts-ignore once it is fixed
|
|
95
|
+
// https://github.com/microsoft/TypeScript/issues/45047
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
97
|
+
// @ts-ignore
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
99
|
+
const realTarget = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.elementFromPoint(touchOffsets.clientX, touchOffsets.clientY);
|
|
100
|
+
this.updateValue(realTarget);
|
|
101
|
+
}
|
|
98
102
|
/**
|
|
99
103
|
* Update color value and fired value-changed event
|
|
100
104
|
* @param element target element to get value
|
|
@@ -107,6 +111,15 @@ export class Palettes extends BasicElement {
|
|
|
107
111
|
this.notifyPropertyChange('value', color);
|
|
108
112
|
}
|
|
109
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Expand short format hex into long format
|
|
116
|
+
* For instance, "#fff" becomes "#ffffff"
|
|
117
|
+
* @param hex hex to expand
|
|
118
|
+
* @returns expanded hex value
|
|
119
|
+
*/
|
|
120
|
+
expandHex(hex) {
|
|
121
|
+
return isHex(hex) ? rgb(this.value).formatHex() : '';
|
|
122
|
+
}
|
|
110
123
|
}
|
|
111
124
|
__decorate([
|
|
112
125
|
query('.color-selector')
|
|
@@ -7,56 +7,10 @@ export declare const COLOR_ITEMS: string[][];
|
|
|
7
7
|
*/
|
|
8
8
|
export declare const GRAYSCALE_ITEMS: string[][];
|
|
9
9
|
export declare const NOCOLOR_POINTS = "6, 2, 15, 6, 15, 17, 6, 21, -3, 17, -3, 6";
|
|
10
|
-
declare
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* Remove hash (#) sign from hex value
|
|
18
|
-
* @param hex Hex to check
|
|
19
|
-
* @returns hex value without # sign
|
|
20
|
-
*/
|
|
21
|
-
static removeHashSign(hex: string): string;
|
|
22
|
-
/**
|
|
23
|
-
* Expand short format hex into long format
|
|
24
|
-
* For instance, "#fff" becomes "#ffffff"
|
|
25
|
-
* @param value hex to expand
|
|
26
|
-
* @returns expanded hex value
|
|
27
|
-
*/
|
|
28
|
-
static expandHex(value: string): string;
|
|
29
|
-
/**
|
|
30
|
-
* Transform RGB value into hex (with #)
|
|
31
|
-
* @param red Red value, 0 - 255
|
|
32
|
-
* @param green Green value, 0 - 255
|
|
33
|
-
* @param blue Blue value, 0 - 255
|
|
34
|
-
* @returns hex value
|
|
35
|
-
*/
|
|
36
|
-
static rgbToHex(red: string, green: string, blue: string): string;
|
|
37
|
-
/**
|
|
38
|
-
* Transform 10 base number to HEX number
|
|
39
|
-
* @param num Number to transform
|
|
40
|
-
* @returns hex representation
|
|
41
|
-
*/
|
|
42
|
-
private static numberToHex;
|
|
43
|
-
/**
|
|
44
|
-
* Transform Hex to RGB
|
|
45
|
-
* @param hex Hex to transform
|
|
46
|
-
* @returns rgb values
|
|
47
|
-
*/
|
|
48
|
-
static hexToRGB(hex: string): rgbValue;
|
|
49
|
-
/**
|
|
50
|
-
* Check if value is a valid hex (including #)
|
|
51
|
-
* @param value Value to check
|
|
52
|
-
* @returns true if valid hex
|
|
53
|
-
*/
|
|
54
|
-
static isHex(value: string): boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Check if value is a valid RGB string number between 0 - 255
|
|
57
|
-
* @param value Value to check
|
|
58
|
-
* @returns true if a valid number
|
|
59
|
-
*/
|
|
60
|
-
static isValidDecimalForRGB(value: string): boolean;
|
|
61
|
-
}
|
|
62
|
-
export {};
|
|
10
|
+
export declare const isHex: (value: string) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Remove hash (#) sign from hex value
|
|
13
|
+
* @param hex Hex to check
|
|
14
|
+
* @returns hex value without # sign
|
|
15
|
+
*/
|
|
16
|
+
export declare const removeHashSign: (hex: string) => string;
|
|
@@ -145,114 +145,17 @@ export const GRAYSCALE_ITEMS = [
|
|
|
145
145
|
];
|
|
146
146
|
export const NOCOLOR_POINTS = '6, 2, 15, 6, 15, 17, 6, 21, -3, 17, -3, 6';
|
|
147
147
|
const HEX_REGEXP = /^#([0-9A-F]{3}){1,2}$/i; // used to validate HEX
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
if (hex) {
|
|
157
|
-
|
|
158
|
-
hex = hex.slice(1);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return hex;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Expand short format hex into long format
|
|
165
|
-
* For instance, "#fff" becomes "#ffffff"
|
|
166
|
-
* @param value hex to expand
|
|
167
|
-
* @returns expanded hex value
|
|
168
|
-
*/
|
|
169
|
-
static expandHex(value) {
|
|
170
|
-
const hex = this.removeHashSign(value);
|
|
171
|
-
if (hex && hex.length <= 3) {
|
|
172
|
-
return '#' + hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
173
|
-
}
|
|
174
|
-
return value;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Transform RGB value into hex (with #)
|
|
178
|
-
* @param red Red value, 0 - 255
|
|
179
|
-
* @param green Green value, 0 - 255
|
|
180
|
-
* @param blue Blue value, 0 - 255
|
|
181
|
-
* @returns hex value
|
|
182
|
-
*/
|
|
183
|
-
static rgbToHex(red, green, blue) {
|
|
184
|
-
const rHex = this.numberToHex(parseInt(red, 10));
|
|
185
|
-
const gHex = this.numberToHex(parseInt(green, 10));
|
|
186
|
-
const bHex = this.numberToHex(parseInt(blue, 10));
|
|
187
|
-
return `#${rHex}${gHex}${bHex}`;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Transform 10 base number to HEX number
|
|
191
|
-
* @param num Number to transform
|
|
192
|
-
* @returns hex representation
|
|
193
|
-
*/
|
|
194
|
-
static numberToHex(num) {
|
|
195
|
-
if (num && num > 0) {
|
|
196
|
-
if (num < 10) {
|
|
197
|
-
return `0${num}`;
|
|
198
|
-
}
|
|
199
|
-
else if (num <= 15) {
|
|
200
|
-
return `0${num.toString(16)}`;
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
return num.toString(16);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
return '00';
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Transform Hex to RGB
|
|
212
|
-
* @param hex Hex to transform
|
|
213
|
-
* @returns rgb values
|
|
214
|
-
*/
|
|
215
|
-
static hexToRGB(hex) {
|
|
216
|
-
hex = this.removeHashSign(hex);
|
|
217
|
-
if (!hex) {
|
|
218
|
-
return {
|
|
219
|
-
red: '',
|
|
220
|
-
green: '',
|
|
221
|
-
blue: ''
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
if (hex.length === 3) {
|
|
225
|
-
let hex6 = '';
|
|
226
|
-
for (let i = 0; i < 3; i++) {
|
|
227
|
-
const c = hex[i];
|
|
228
|
-
hex6 += '' + c + c;
|
|
229
|
-
}
|
|
230
|
-
hex = hex6;
|
|
148
|
+
export const isHex = (value) => HEX_REGEXP.test(value);
|
|
149
|
+
/**
|
|
150
|
+
* Remove hash (#) sign from hex value
|
|
151
|
+
* @param hex Hex to check
|
|
152
|
+
* @returns hex value without # sign
|
|
153
|
+
*/
|
|
154
|
+
export const removeHashSign = (hex) => {
|
|
155
|
+
if (hex) {
|
|
156
|
+
if (hex.startsWith('#')) {
|
|
157
|
+
hex = hex.slice(1);
|
|
231
158
|
}
|
|
232
|
-
const bigint = parseInt(hex, 16);
|
|
233
|
-
const r = (bigint >> 16) & 255;
|
|
234
|
-
const g = (bigint >> 8) & 255;
|
|
235
|
-
const b = bigint & 255;
|
|
236
|
-
return {
|
|
237
|
-
red: String(r),
|
|
238
|
-
green: String(g),
|
|
239
|
-
blue: String(b)
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Check if value is a valid hex (including #)
|
|
244
|
-
* @param value Value to check
|
|
245
|
-
* @returns true if valid hex
|
|
246
|
-
*/
|
|
247
|
-
static isHex(value) {
|
|
248
|
-
return HEX_REGEXP.test(value);
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Check if value is a valid RGB string number between 0 - 255
|
|
252
|
-
* @param value Value to check
|
|
253
|
-
* @returns true if a valid number
|
|
254
|
-
*/
|
|
255
|
-
static isValidDecimalForRGB(value) {
|
|
256
|
-
return RGB_REGEXP.test(value);
|
|
257
159
|
}
|
|
258
|
-
|
|
160
|
+
return hex;
|
|
161
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { rgb } from '@refinitiv-ui/utils/lib/color.js';
|
|
2
|
+
import { isHex } from './color-helpers.js';
|
|
3
|
+
const rgbNumberToString = (value) => isNaN(value) ? '' : `${value}`; // replace NaN with empty string
|
|
2
4
|
/**
|
|
3
5
|
* A helper model in order to keep and update values between RGB and HEX
|
|
4
6
|
*/
|
|
@@ -9,11 +11,11 @@ class ValueModel {
|
|
|
9
11
|
*/
|
|
10
12
|
constructor(value = '') {
|
|
11
13
|
this.initialValue = value;
|
|
12
|
-
const {
|
|
13
|
-
this._red =
|
|
14
|
-
this._green =
|
|
15
|
-
this._blue =
|
|
16
|
-
this._hex =
|
|
14
|
+
const { r, g, b } = rgb(value);
|
|
15
|
+
this._red = rgbNumberToString(r);
|
|
16
|
+
this._green = rgbNumberToString(g);
|
|
17
|
+
this._blue = rgbNumberToString(b);
|
|
18
|
+
this._hex = value.slice(1);
|
|
17
19
|
}
|
|
18
20
|
getHexValue() {
|
|
19
21
|
if (this.red === '' && this.green === '' && this.blue === '') {
|
|
@@ -22,14 +24,14 @@ class ValueModel {
|
|
|
22
24
|
else if (!this.isValidRGB()) {
|
|
23
25
|
return '';
|
|
24
26
|
}
|
|
25
|
-
const hex =
|
|
26
|
-
return hex ?
|
|
27
|
+
const hex = rgb(Number(this.red), Number(this.green), Number(this.blue)).formatHex();
|
|
28
|
+
return hex ? hex.slice(1) : '';
|
|
27
29
|
}
|
|
28
30
|
isValidRGBValue(value) {
|
|
29
|
-
return value === '' ||
|
|
31
|
+
return value === '' || Number(value) >= 0 && Number(value) <= 255;
|
|
30
32
|
}
|
|
31
33
|
isValidHexValue(value) {
|
|
32
|
-
return value === '' ||
|
|
34
|
+
return value === '' || isHex(`#${value}`);
|
|
33
35
|
}
|
|
34
36
|
isValidRGB() {
|
|
35
37
|
return this.isValidRGBValue(this.red)
|
|
@@ -42,10 +44,10 @@ class ValueModel {
|
|
|
42
44
|
/**
|
|
43
45
|
* Check if new value is different to initial
|
|
44
46
|
* ignoring hex length
|
|
45
|
-
* @returns
|
|
47
|
+
* @returns true if different
|
|
46
48
|
*/
|
|
47
49
|
hasChanged() {
|
|
48
|
-
return
|
|
50
|
+
return rgb(this.initialValue).formatHex() !== rgb(this.value).formatHex();
|
|
49
51
|
}
|
|
50
52
|
/**
|
|
51
53
|
* Check if RGB and Hex values are valid
|
|
@@ -116,10 +118,10 @@ class ValueModel {
|
|
|
116
118
|
this._blue = '';
|
|
117
119
|
}
|
|
118
120
|
else {
|
|
119
|
-
const
|
|
120
|
-
this._red =
|
|
121
|
-
this._green =
|
|
122
|
-
this._blue =
|
|
121
|
+
const { r, g, b } = rgb(`#${hex}`);
|
|
122
|
+
this._red = rgbNumberToString(r);
|
|
123
|
+
this._green = rgbNumberToString(g);
|
|
124
|
+
this._blue = rgbNumberToString(b);
|
|
123
125
|
}
|
|
124
126
|
this._hex = hex;
|
|
125
127
|
}
|