@refinitiv-ui/elements 6.0.0-next.3 → 6.0.2
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 +51 -0
- package/README.md +3 -15
- package/lib/accordion/index.js +2 -2
- package/lib/autosuggest/custom-elements.json +5 -15
- package/lib/autosuggest/custom-elements.md +14 -14
- package/lib/autosuggest/helpers/renderer.d.ts +8 -0
- package/lib/autosuggest/helpers/renderer.js +35 -0
- package/lib/autosuggest/helpers/types.d.ts +101 -1
- package/lib/autosuggest/helpers/utils.d.ts +1 -8
- package/lib/autosuggest/helpers/utils.js +0 -27
- package/lib/autosuggest/index.d.ts +34 -32
- package/lib/autosuggest/index.js +246 -202
- package/lib/autosuggest/themes/halo/dark/index.js +1 -1
- package/lib/autosuggest/themes/halo/light/index.js +1 -1
- package/lib/autosuggest/themes/solar/charcoal/index.js +1 -1
- package/lib/autosuggest/themes/solar/pearl/index.js +1 -1
- package/lib/button/index.js +2 -1
- 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/calendar/index.d.ts +1 -1
- 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/chart/plugins/doughnut-center-label.js +1 -1
- package/lib/chart/themes/halo/dark/index.js +1 -1
- package/lib/chart/themes/halo/light/index.js +1 -1
- package/lib/checkbox/index.d.ts +8 -15
- package/lib/checkbox/index.js +19 -41
- package/lib/checkbox/themes/halo/dark/index.js +1 -1
- package/lib/checkbox/themes/halo/light/index.js +1 -1
- package/lib/checkbox/themes/solar/charcoal/index.js +1 -1
- package/lib/checkbox/themes/solar/pearl/index.js +1 -1
- package/lib/clock/custom-elements.json +10 -10
- package/lib/clock/custom-elements.md +1 -1
- package/lib/clock/index.d.ts +44 -16
- package/lib/clock/index.js +178 -61
- 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/combo-box/index.d.ts +4 -3
- package/lib/combo-box/index.js +7 -3
- 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/datetime-field/index.d.ts +1 -1
- package/lib/datetime-field/utils.d.ts +1 -1
- package/lib/datetime-picker/themes/halo/dark/index.js +1 -1
- package/lib/datetime-picker/themes/halo/light/index.js +1 -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/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/flag/utils/FlagLoader.d.ts +2 -32
- package/lib/flag/utils/FlagLoader.js +2 -69
- package/lib/heatmap/index.d.ts +2 -2
- package/lib/heatmap/themes/halo/dark/index.js +1 -1
- package/lib/heatmap/themes/halo/light/index.js +1 -1
- package/lib/icon/utils/IconLoader.d.ts +2 -37
- package/lib/icon/utils/IconLoader.js +2 -76
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/interactive-chart/themes/halo/dark/index.js +1 -1
- package/lib/interactive-chart/themes/halo/light/index.js +1 -1
- package/lib/item/helpers/types.d.ts +6 -6
- package/lib/item/index.d.ts +2 -2
- package/lib/item/index.js +0 -1
- package/lib/item/themes/halo/dark/index.js +1 -1
- package/lib/item/themes/halo/light/index.js +1 -1
- package/lib/list/elements/list-item.d.ts +30 -0
- package/lib/list/elements/list-item.js +19 -0
- package/lib/list/elements/list.d.ts +307 -0
- package/lib/list/elements/list.js +632 -0
- package/lib/list/helpers/renderer.d.ts +0 -1
- package/lib/list/helpers/renderer.js +1 -3
- package/lib/list/index.d.ts +3 -317
- package/lib/list/index.js +3 -641
- package/lib/list/themes/halo/dark/index.js +4 -1
- package/lib/list/themes/halo/light/index.js +5 -2
- package/lib/list/themes/solar/charcoal/index.js +4 -1
- package/lib/list/themes/solar/pearl/index.js +4 -1
- package/lib/multi-input/index.d.ts +1 -5
- package/lib/multi-input/index.js +17 -18
- package/lib/notification/themes/halo/dark/index.js +1 -1
- package/lib/notification/themes/halo/light/index.js +1 -1
- package/lib/notification/themes/solar/charcoal/index.js +1 -1
- package/lib/notification/themes/solar/pearl/index.js +1 -1
- 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/index.d.ts +2 -1
- package/lib/overlay-menu/helpers/constants.d.ts +6 -0
- package/lib/overlay-menu/helpers/constants.js +7 -0
- package/lib/overlay-menu/helpers/types.d.ts +0 -6
- package/lib/overlay-menu/helpers/types.js +1 -7
- package/lib/overlay-menu/index.d.ts +1 -1
- package/lib/overlay-menu/index.js +1 -1
- 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/index.d.ts +11 -3
- package/lib/pill/index.js +25 -11
- package/lib/radio-button/index.d.ts +7 -11
- package/lib/radio-button/index.js +14 -25
- package/lib/radio-button/themes/halo/dark/index.js +1 -1
- package/lib/radio-button/themes/halo/light/index.js +1 -1
- package/lib/radio-button/themes/solar/charcoal/index.js +1 -1
- package/lib/radio-button/themes/solar/pearl/index.js +1 -1
- package/lib/rating/custom-elements.json +4 -4
- package/lib/rating/custom-elements.md +2 -2
- package/lib/rating/index.d.ts +84 -32
- package/lib/rating/index.js +209 -80
- package/lib/rating/themes/halo/dark/index.js +1 -1
- package/lib/rating/themes/halo/light/index.js +1 -1
- package/lib/rating/themes/solar/charcoal/index.js +1 -1
- package/lib/rating/themes/solar/pearl/index.js +1 -1
- package/lib/rating/utils.d.ts +9 -0
- package/lib/rating/utils.js +11 -0
- 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/index.d.ts +13 -1
- package/lib/select/index.js +25 -7
- package/lib/select/themes/halo/dark/index.js +1 -1
- package/lib/select/themes/halo/light/index.js +1 -1
- package/lib/select/themes/solar/charcoal/index.js +1 -1
- package/lib/select/themes/solar/pearl/index.js +1 -1
- package/lib/slider/constants.d.ts +5 -1
- package/lib/slider/constants.js +6 -1
- package/lib/slider/index.d.ts +112 -49
- package/lib/slider/index.js +331 -182
- package/lib/slider/themes/halo/dark/index.js +1 -1
- package/lib/slider/themes/halo/light/index.js +1 -1
- package/lib/slider/themes/solar/charcoal/index.js +1 -1
- package/lib/slider/themes/solar/pearl/index.js +1 -1
- package/lib/slider/utils.d.ts +1 -9
- package/lib/slider/utils.js +1 -18
- package/lib/sparkline/themes/halo/dark/index.js +1 -1
- package/lib/sparkline/themes/halo/light/index.js +1 -1
- 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/index.d.ts +6 -7
- package/lib/tab-bar/index.js +12 -10
- package/lib/tab-bar/themes/halo/dark/index.js +1 -0
- package/lib/tab-bar/themes/halo/light/index.js +1 -0
- package/lib/tab-bar/themes/solar/charcoal/index.js +1 -0
- package/lib/tab-bar/themes/solar/pearl/index.js +1 -0
- package/lib/text-field/index.js +2 -3
- 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/toggle/index.d.ts +7 -10
- package/lib/toggle/index.js +14 -24
- 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/helpers/overflow-tooltip.d.ts +11 -4
- package/lib/tooltip/helpers/overflow-tooltip.js +34 -6
- package/lib/tooltip/index.d.ts +2 -2
- package/lib/tooltip/index.js +2 -2
- package/lib/tree/elements/tree-item.d.ts +4 -0
- package/lib/tree/elements/tree-item.js +5 -2
- package/lib/tree/elements/tree.d.ts +7 -0
- package/lib/tree/elements/tree.js +12 -1
- package/lib/tree/helpers/renderer.d.ts +0 -1
- package/lib/tree/helpers/renderer.js +0 -2
- package/lib/tree/index.d.ts +2 -1
- package/lib/tree/themes/halo/dark/index.js +2 -2
- package/lib/tree/themes/halo/light/index.js +3 -3
- package/lib/tree/themes/solar/charcoal/index.js +2 -2
- package/lib/tree/themes/solar/pearl/index.js +2 -2
- package/lib/tree-select/index.js +15 -5
- 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.js +1 -1
- package/package.json +20 -19
- package/lib/clock/utils/timestamps.d.ts +0 -6
- package/lib/clock/utils/timestamps.js +0 -6
package/lib/rating/index.js
CHANGED
|
@@ -2,9 +2,8 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import { BasicElement, html, css } from '@refinitiv-ui/core';
|
|
3
3
|
import { customElement } from '@refinitiv-ui/core/decorators/custom-element.js';
|
|
4
4
|
import { property } from '@refinitiv-ui/core/decorators/property.js';
|
|
5
|
-
import { queryAll } from '@refinitiv-ui/core/decorators/query-all.js';
|
|
6
|
-
import { repeat } from '@refinitiv-ui/core/directives/repeat.js';
|
|
7
5
|
import { VERSION } from '../version.js';
|
|
6
|
+
import { clamp } from './utils.js';
|
|
8
7
|
/**
|
|
9
8
|
* Star visualisation component that is generally used for ranking
|
|
10
9
|
* @fires value-changed - Fired when the `value` changes.
|
|
@@ -12,21 +11,22 @@ import { VERSION } from '../version.js';
|
|
|
12
11
|
let Rating = class Rating extends BasicElement {
|
|
13
12
|
constructor() {
|
|
14
13
|
super(...arguments);
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
14
|
+
this.MAX_VALUE = '5'; // default max value
|
|
15
|
+
this.MIN_VALUE = 1; // min value of interactive mode
|
|
17
16
|
/**
|
|
18
17
|
* Make it possible to interact with rating control and change the value
|
|
19
18
|
*/
|
|
20
19
|
this.interactive = false;
|
|
21
20
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
* Internal max value of rating.
|
|
22
|
+
* Controlled by public setter and getter
|
|
23
|
+
*/
|
|
24
|
+
this._max = this.MAX_VALUE;
|
|
25
25
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.
|
|
26
|
+
* Internal value of rating.
|
|
27
|
+
* Controlled by public setter and getter
|
|
28
|
+
*/
|
|
29
|
+
this._value = '0';
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Element version number
|
|
@@ -36,95 +36,226 @@ let Rating = class Rating extends BasicElement {
|
|
|
36
36
|
return VERSION;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
39
|
+
* A `CSSResultGroup` that will be used
|
|
40
|
+
* to style the host, slotted children
|
|
41
|
+
* and the internal template of the element.
|
|
42
|
+
* @returns CSS template
|
|
41
43
|
*/
|
|
42
|
-
get
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
static get styles() {
|
|
45
|
+
return css `
|
|
46
|
+
:host {
|
|
47
|
+
display: inline-block;
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Set number of total stars
|
|
53
|
+
* @param max max value
|
|
54
|
+
* @default '5'
|
|
55
|
+
*/
|
|
56
|
+
set max(max) {
|
|
57
|
+
const newMax = max && this.isValidValue(max) ? Math.round(Number(max)).toString() : this.MAX_VALUE;
|
|
58
|
+
const oldMax = this._max;
|
|
59
|
+
if (oldMax !== newMax) {
|
|
60
|
+
this._max = newMax;
|
|
61
|
+
if (this.interactive) {
|
|
62
|
+
this.setAttribute('aria-valuemax', newMax);
|
|
63
|
+
}
|
|
64
|
+
this.requestUpdate('max', oldMax);
|
|
46
65
|
}
|
|
47
|
-
|
|
66
|
+
}
|
|
67
|
+
get max() {
|
|
68
|
+
return this._max;
|
|
48
69
|
}
|
|
49
70
|
/**
|
|
50
71
|
* Converts max value from string to number for calculations
|
|
51
72
|
* @returns maximum value of rating as a number
|
|
52
73
|
*/
|
|
53
74
|
get maxNumber() {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
75
|
+
return Number(this.max);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Set number of selected stars. Value can be any number between 0 and `max`.
|
|
79
|
+
* Decimal values are calculated to empty star (0 - .25); half-star (.25 - .75) and full star (.75 - 1)
|
|
80
|
+
* @param value Element value
|
|
81
|
+
* @default '0'
|
|
82
|
+
*/
|
|
83
|
+
set value(value) {
|
|
84
|
+
const newValue = this.isValidValue(value) ? Number(value).toString() : '0';
|
|
85
|
+
const oldValue = this._value;
|
|
86
|
+
if (oldValue !== newValue) {
|
|
87
|
+
this._value = newValue;
|
|
88
|
+
if (this.interactive) {
|
|
89
|
+
this.setAttribute('aria-valuenow', newValue);
|
|
90
|
+
}
|
|
91
|
+
this.requestUpdate('value', oldValue);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
get value() {
|
|
95
|
+
return this._value;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Converts value from string to number for calculations
|
|
99
|
+
* @returns value of rating as a number
|
|
100
|
+
*/
|
|
101
|
+
get valueNumber() {
|
|
102
|
+
return Number(this.value);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Called before update() to compute values needed during the update.
|
|
106
|
+
* @param changedProperties Properties that has changed
|
|
107
|
+
* @returns {void}
|
|
108
|
+
*/
|
|
109
|
+
willUpdate(changedProperties) {
|
|
110
|
+
super.willUpdate(changedProperties);
|
|
111
|
+
if (changedProperties.has('interactive')) {
|
|
112
|
+
this.interactiveChanged();
|
|
57
113
|
}
|
|
58
|
-
// Prevent decimal max value
|
|
59
|
-
max = max % 1 === 0 ? max : Math.round(max);
|
|
60
|
-
return max;
|
|
61
114
|
}
|
|
62
115
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
116
|
+
* Invoked when the element is first updated
|
|
117
|
+
* @param changedProperties changed properties
|
|
118
|
+
* @returns {void}
|
|
119
|
+
*/
|
|
120
|
+
firstUpdated(changedProperties) {
|
|
121
|
+
super.firstUpdated(changedProperties);
|
|
122
|
+
this.addEventListener('keydown', this.onKeyDown.bind(this));
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Handles interactive and aria attribute changes
|
|
69
126
|
* @returns {void}
|
|
70
127
|
*/
|
|
71
|
-
|
|
72
|
-
this.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
this.
|
|
128
|
+
interactiveChanged() {
|
|
129
|
+
if (this.interactive) {
|
|
130
|
+
this.setAttribute('role', 'slider');
|
|
131
|
+
this.setAttribute('aria-valuemin', this.MIN_VALUE.toString());
|
|
132
|
+
this.setAttribute('aria-valuenow', this.value);
|
|
133
|
+
this.setAttribute('aria-valuemax', this.max);
|
|
134
|
+
this.setAttribute('tabindex', this.getAttribute('tabindex') || '0');
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
if (this.getAttribute('role') === 'slider') {
|
|
138
|
+
this.removeAttribute('role');
|
|
139
|
+
}
|
|
140
|
+
this.removeAttribute('aria-valuemin');
|
|
141
|
+
this.removeAttribute('aria-valuenow');
|
|
142
|
+
this.removeAttribute('aria-valuemax');
|
|
78
143
|
}
|
|
79
|
-
this.valuePrevious = value;
|
|
80
|
-
this.requestUpdate();
|
|
81
144
|
}
|
|
82
145
|
/**
|
|
83
|
-
*
|
|
84
|
-
* @param
|
|
146
|
+
* Handles key input
|
|
147
|
+
* @param event Key down event object
|
|
85
148
|
* @returns {void}
|
|
86
149
|
*/
|
|
87
|
-
|
|
88
|
-
if (!this.interactive) {
|
|
150
|
+
onKeyDown(event) {
|
|
151
|
+
if (event.defaultPrevented || !this.interactive) {
|
|
89
152
|
return;
|
|
90
153
|
}
|
|
91
|
-
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
-
|
|
154
|
+
// Ignore special keys
|
|
155
|
+
if (event.shiftKey || event.ctrlKey || event.altKey || event.metaKey) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
switch (event.key) {
|
|
159
|
+
case 'Right':
|
|
160
|
+
case 'Up':
|
|
161
|
+
case 'ArrowRight':
|
|
162
|
+
case 'ArrowUp':
|
|
163
|
+
this.stepUp();
|
|
164
|
+
break;
|
|
165
|
+
case 'Left':
|
|
166
|
+
case 'Down':
|
|
167
|
+
case 'ArrowLeft':
|
|
168
|
+
case 'ArrowDown':
|
|
169
|
+
this.stepDown();
|
|
170
|
+
break;
|
|
171
|
+
case 'Home':
|
|
172
|
+
this.stepDown(this.MIN_VALUE);
|
|
173
|
+
break;
|
|
174
|
+
case 'End':
|
|
175
|
+
this.stepUp(this.maxNumber);
|
|
176
|
+
break;
|
|
177
|
+
default:
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
event.preventDefault();
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Update value and fired value-changed event
|
|
184
|
+
* @param value value to updated
|
|
185
|
+
* @returns {void}
|
|
186
|
+
*/
|
|
187
|
+
notifyValueChange(value) {
|
|
188
|
+
if (this.value !== value) {
|
|
189
|
+
this.value = value;
|
|
95
190
|
this.notifyPropertyChange('value', this.value);
|
|
96
191
|
}
|
|
97
192
|
}
|
|
98
193
|
/**
|
|
99
|
-
*
|
|
100
|
-
* @
|
|
194
|
+
* Check if passed value is a valid value
|
|
195
|
+
* @override
|
|
196
|
+
* @param value Value to check
|
|
197
|
+
* @returns {boolean} false if value is invalid
|
|
198
|
+
*/
|
|
199
|
+
isValidValue(value) {
|
|
200
|
+
const number = Number(value);
|
|
201
|
+
return !isNaN(number) && isFinite(number);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Increases the value of rating by half or 1 if not specific amount but not exceed max value
|
|
205
|
+
* @param value step up value to specific number (optional)
|
|
101
206
|
* @returns {void}
|
|
102
207
|
*/
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
else if (propName === 'max') {
|
|
111
|
-
this.max = this.maxNumber.toString();
|
|
112
|
-
this.computeRating(this.maxNumber, this.valueNumber);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
208
|
+
stepUp(value) {
|
|
209
|
+
if (this.valueNumber > this.maxNumber) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const newValue = value || clamp(Math.floor(this.valueNumber + 1), this.MIN_VALUE, this.maxNumber);
|
|
213
|
+
this.notifyValueChange(newValue.toString());
|
|
115
214
|
}
|
|
116
215
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
* @returns CSS template
|
|
216
|
+
* Decrease the value of rating by half or 1 if not specific amount but not exceed min value
|
|
217
|
+
* @param value step down value to specific number (optional)
|
|
218
|
+
* @returns {void}
|
|
121
219
|
*/
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
220
|
+
stepDown(value) {
|
|
221
|
+
if (this.valueNumber < this.MIN_VALUE) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const newValue = value || clamp(Math.round(this.valueNumber - 1), this.MIN_VALUE, this.maxNumber - 1);
|
|
225
|
+
this.notifyValueChange(newValue.toString());
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Process click event to set the new value
|
|
229
|
+
* @param {number} index index of star
|
|
230
|
+
* @returns {void}
|
|
231
|
+
*/
|
|
232
|
+
handleTap(index) {
|
|
233
|
+
if (!this.interactive) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
const newValue = this.maxNumber - index;
|
|
237
|
+
if (this.valueNumber !== newValue) {
|
|
238
|
+
this.value = newValue.toString();
|
|
239
|
+
this.notifyPropertyChange('value', this.value);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Render rating based on max number of stars and value.
|
|
244
|
+
* Note: to speed up the component, hover state is implemented using CSS only.
|
|
245
|
+
* CSS3 specification does not allow to select items preceding the hover, but allows to select the following items.
|
|
246
|
+
* Therefore `flex: reverse` style is applied and the items are constructed in the reverse mode to mimic the correct behaviour.
|
|
247
|
+
* @returns stars template
|
|
248
|
+
*/
|
|
249
|
+
get starsTemplate() {
|
|
250
|
+
const stars = [];
|
|
251
|
+
for (let index = 0; index < this.maxNumber; index += 1) {
|
|
252
|
+
const reverseIndex = this.valueNumber - (this.maxNumber - index) + 1;
|
|
253
|
+
const starValue = reverseIndex > 0 ? Math.min(1, reverseIndex) : 0;
|
|
254
|
+
const selected = starValue >= 0.75 ? 'full' : starValue >= 0.25 ? 'half' : false;
|
|
255
|
+
const className = selected ? `icon icon-${selected}` : 'icon';
|
|
256
|
+
stars.push(html `<div part="${className}" @tap="${() => this.handleTap(index)}"></div>`);
|
|
257
|
+
}
|
|
258
|
+
return stars;
|
|
128
259
|
}
|
|
129
260
|
/**
|
|
130
261
|
* A `TemplateResult` that will be used
|
|
@@ -132,9 +263,10 @@ let Rating = class Rating extends BasicElement {
|
|
|
132
263
|
* @return Render template
|
|
133
264
|
*/
|
|
134
265
|
render() {
|
|
135
|
-
return html
|
|
136
|
-
|
|
137
|
-
|
|
266
|
+
return html `
|
|
267
|
+
<div part="container">
|
|
268
|
+
${this.starsTemplate}
|
|
269
|
+
</div>`;
|
|
138
270
|
}
|
|
139
271
|
};
|
|
140
272
|
__decorate([
|
|
@@ -142,13 +274,10 @@ __decorate([
|
|
|
142
274
|
], Rating.prototype, "interactive", void 0);
|
|
143
275
|
__decorate([
|
|
144
276
|
property({ type: String })
|
|
145
|
-
], Rating.prototype, "max",
|
|
146
|
-
__decorate([
|
|
147
|
-
property({ type: String, reflect: true })
|
|
148
|
-
], Rating.prototype, "value", void 0);
|
|
277
|
+
], Rating.prototype, "max", null);
|
|
149
278
|
__decorate([
|
|
150
|
-
|
|
151
|
-
], Rating.prototype, "
|
|
279
|
+
property({ type: String })
|
|
280
|
+
], Rating.prototype, "value", null);
|
|
152
281
|
Rating = __decorate([
|
|
153
282
|
customElement('ef-rating', {
|
|
154
283
|
alias: 'sapphire-rating'
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
elf.customStyles.define('ef-rating', ':host{font-size:16px}:host [part=container]{touch-action:manipulation;display:flex;flex-direction:row-reverse;flex-wrap:nowrap}:host [part^=icon]{margin:0 1px;background:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IG0tNTEyIDM1Ny0yMjQgMTE4IDQzLTI0OS0xODEtMTc2IDI1MC0zNiAxMTItMjI2IDExMiAyMjYgMjUwIDM2LTE4MSAxNzYgNDMgMjQ5eiIgZmlsbD0iIzQwNDA0MCIvPgo8L3N2Zz4K) 0 0/100% no-repeat;width:1em;height:1em}:host [part^=icon]:first-child,:host [part^=icon]:last-child{margin:0}:host(:not([interactive])) [part~=icon-full],:host([interactive]) [part=container]:not(:hover) [part~=icon-full]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IiBmaWxsPSIjMzM0QkZGIi8+Cjwvc3ZnPgo=)}:host(:not([interactive])) [part~=icon-half],:host([interactive]) [part=container]:not(:hover) [part~=icon-half]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggaWQ9InJpZ2h0IiBkPSJtMTAyNCAzOTctMzU0LTUxLTE1OS0zMjF2ODA4bDMxNyAxNjYtNjAtMzUyem0tNTEzIDM1N3YtNTcwbDExMyAyMjYgMjUwIDM2LTE4MSAxNzYgNDMgMjQ5eiIgZmlsbD0iIzQwNDA0MCIvPgogICAgPHBhdGggaWQ9ImxlZnQiIGQ9Im01MTIgMjUtMTU4IDMyMS0zNTQgNTEgMjU2IDI1MC02MCAzNTIgMzE2LTE2NnoiIGZpbGw9IiMzMzRCRkYiLz4KPC9zdmc+Cg==)}:host([interactive]) [part^=icon]{cursor:pointer}:host([interactive]) [part^=icon]:hover,:host([interactive]) [part^=icon]:hover~[part^=icon]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IiBmaWxsPSIjMzM0QkZGIi8+Cjwvc3ZnPgo=)}');
|
|
2
|
+
elf.customStyles.define('ef-rating', ':host{font-size:16px}:host [part=container]{touch-action:manipulation;display:flex;flex-direction:row-reverse;flex-wrap:nowrap}:host [part^=icon]{margin:0 1px;background:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IG0tNTEyIDM1Ny0yMjQgMTE4IDQzLTI0OS0xODEtMTc2IDI1MC0zNiAxMTItMjI2IDExMiAyMjYgMjUwIDM2LTE4MSAxNzYgNDMgMjQ5eiIgZmlsbD0iIzQwNDA0MCIvPgo8L3N2Zz4K) 0 0/100% no-repeat;width:1em;height:1em}:host [part^=icon]:first-child,:host [part^=icon]:last-child{margin:0}:host(:not([interactive])) [part~=icon-full],:host([interactive]) [part=container]:not(:hover) [part~=icon-full]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IiBmaWxsPSIjMzM0QkZGIi8+Cjwvc3ZnPgo=)}:host(:not([interactive])) [part~=icon-half],:host([interactive]) [part=container]:not(:hover) [part~=icon-half]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggaWQ9InJpZ2h0IiBkPSJtMTAyNCAzOTctMzU0LTUxLTE1OS0zMjF2ODA4bDMxNyAxNjYtNjAtMzUyem0tNTEzIDM1N3YtNTcwbDExMyAyMjYgMjUwIDM2LTE4MSAxNzYgNDMgMjQ5eiIgZmlsbD0iIzQwNDA0MCIvPgogICAgPHBhdGggaWQ9ImxlZnQiIGQ9Im01MTIgMjUtMTU4IDMyMS0zNTQgNTEgMjU2IDI1MC02MCAzNTIgMzE2LTE2NnoiIGZpbGw9IiMzMzRCRkYiLz4KPC9zdmc+Cg==)}:host([interactive]) [part^=icon]{cursor:pointer}:host([interactive]) [part^=icon]:hover,:host([interactive]) [part^=icon]:hover~[part^=icon]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IiBmaWxsPSIjMzM0QkZGIi8+Cjwvc3ZnPgo=)}:host([focused=visible]){outline:#334bff solid 1px;outline-offset:2px}');
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
elf.customStyles.define('ef-rating', ':host{font-size:16px}:host [part=container]{touch-action:manipulation;display:flex;flex-direction:row-reverse;flex-wrap:nowrap}:host [part^=icon]{margin:0 1px;background:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IG0tNTEyIDM1Ny0yMjQgMTE4IDQzLTI0OS0xODEtMTc2IDI1MC0zNiAxMTItMjI2IDExMiAyMjYgMjUwIDM2LTE4MSAxNzYgNDMgMjQ5eiIgZmlsbD0iIzU5NTk1OSIvPgo8L3N2Zz4K) 0 0/100% no-repeat;width:1em;height:1em}:host [part^=icon]:first-child,:host [part^=icon]:last-child{margin:0}:host(:not([interactive])) [part~=icon-full],:host([interactive]) [part=container]:not(:hover) [part~=icon-full]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IiBmaWxsPSIjMzM0QkZGIi8+Cjwvc3ZnPgo=)}:host(:not([interactive])) [part~=icon-half],:host([interactive]) [part=container]:not(:hover) [part~=icon-half]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggaWQ9InJpZ2h0IiBkPSJtMTAyNCAzOTctMzU0LTUxLTE1OS0zMjF2ODA4bDMxNyAxNjYtNjAtMzUyem0tNTEzIDM1N3YtNTcwbDExMyAyMjYgMjUwIDM2LTE4MSAxNzYgNDMgMjQ5eiIgZmlsbD0iIzU5NTk1OSIvPgogICAgPHBhdGggaWQ9ImxlZnQiIGQ9Im01MTIgMjUtMTU4IDMyMS0zNTQgNTEgMjU2IDI1MC02MCAzNTIgMzE2LTE2NnoiIGZpbGw9IiMzMzRCRkYiLz4KPC9zdmc+Cg==)}:host([interactive]) [part^=icon]{cursor:pointer}:host([interactive]) [part^=icon]:hover,:host([interactive]) [part^=icon]:hover~[part^=icon]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IiBmaWxsPSIjMzM0QkZGIi8+Cjwvc3ZnPgo=)}');
|
|
2
|
+
elf.customStyles.define('ef-rating', ':host{font-size:16px}:host [part=container]{touch-action:manipulation;display:flex;flex-direction:row-reverse;flex-wrap:nowrap}:host [part^=icon]{margin:0 1px;background:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IG0tNTEyIDM1Ny0yMjQgMTE4IDQzLTI0OS0xODEtMTc2IDI1MC0zNiAxMTItMjI2IDExMiAyMjYgMjUwIDM2LTE4MSAxNzYgNDMgMjQ5eiIgZmlsbD0iIzU5NTk1OSIvPgo8L3N2Zz4K) 0 0/100% no-repeat;width:1em;height:1em}:host [part^=icon]:first-child,:host [part^=icon]:last-child{margin:0}:host(:not([interactive])) [part~=icon-full],:host([interactive]) [part=container]:not(:hover) [part~=icon-full]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IiBmaWxsPSIjMzM0QkZGIi8+Cjwvc3ZnPgo=)}:host(:not([interactive])) [part~=icon-half],:host([interactive]) [part=container]:not(:hover) [part~=icon-half]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggaWQ9InJpZ2h0IiBkPSJtMTAyNCAzOTctMzU0LTUxLTE1OS0zMjF2ODA4bDMxNyAxNjYtNjAtMzUyem0tNTEzIDM1N3YtNTcwbDExMyAyMjYgMjUwIDM2LTE4MSAxNzYgNDMgMjQ5eiIgZmlsbD0iIzU5NTk1OSIvPgogICAgPHBhdGggaWQ9ImxlZnQiIGQ9Im01MTIgMjUtMTU4IDMyMS0zNTQgNTEgMjU2IDI1MC02MCAzNTIgMzE2LTE2NnoiIGZpbGw9IiMzMzRCRkYiLz4KPC9zdmc+Cg==)}:host([interactive]) [part^=icon]{cursor:pointer}:host([interactive]) [part^=icon]:hover,:host([interactive]) [part^=icon]:hover~[part^=icon]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IiBmaWxsPSIjMzM0QkZGIi8+Cjwvc3ZnPgo=)}:host([focused=visible]){outline:#334bff solid 1px;outline-offset:2px}');
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
elf.customStyles.define('ef-rating', ':host [part=container]{touch-action:manipulation;display:flex;flex-direction:row-reverse;flex-wrap:nowrap}:host [part^=icon]{margin:0 1px;background:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IiBmaWxsPSIjNjY2NTcwIi8+Cjwvc3ZnPgo=) 0 0/100% no-repeat;width:1em;height:1em}:host [part^=icon]:first-child,:host [part^=icon]:last-child{margin:0}:host([interactive]) [part^=icon]{cursor:pointer}:host{font-size:10px}:host([size=large]){font-size:15px}:host(:not([interactive])) [part~=icon-full],:host([interactive]) [part=container]:not(:hover) [part~=icon-full]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IiBmaWxsPSIjRkY5OTMzIi8+Cjwvc3ZnPgo=)}:host(:not([interactive])) [part~=icon-half],:host([interactive]) [part=container]:not(:hover) [part~=icon-half]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggaWQ9ImxlZnQiIGQ9Im01MTIgMjUtMTU4IDMyMS0zNTQgNTEgMjU2IDI1MC02MCAzNTIgMzE2LTE2NnoiIGZpbGw9IiNGRjk5MzMiLz4KICAgIDxwYXRoIGlkPSJyaWdodCIgZD0ibTEwMjQgMzk3LTM1NC01MS0xNTktMzIxdjgwOGwzMTcgMTY2LTYwLTM1MnoiIGZpbGw9IiM2NjY1NzAiLz4KPC9zdmc+Cg==)}:host([interactive]) [part^=icon]:hover,:host([interactive]) [part^=icon]:hover~[part^=icon]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IiBmaWxsPSIjRkY5OTMzIi8+Cjwvc3ZnPgo=)}');
|
|
2
|
+
elf.customStyles.define('ef-rating', ':host [part=container]{touch-action:manipulation;display:flex;flex-direction:row-reverse;flex-wrap:nowrap}:host [part^=icon]{margin:0 1px;background:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IiBmaWxsPSIjNjY2NTcwIi8+Cjwvc3ZnPgo=) 0 0/100% no-repeat;width:1em;height:1em}:host [part^=icon]:first-child,:host [part^=icon]:last-child{margin:0}:host([interactive]) [part^=icon]{cursor:pointer}:host([focused=visible]){outline:#f93 solid 1px;outline-offset:2px}:host{font-size:10px}:host([size=large]){font-size:15px}:host(:not([interactive])) [part~=icon-full],:host([interactive]) [part=container]:not(:hover) [part~=icon-full]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IiBmaWxsPSIjRkY5OTMzIi8+Cjwvc3ZnPgo=)}:host(:not([interactive])) [part~=icon-half],:host([interactive]) [part=container]:not(:hover) [part~=icon-half]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggaWQ9ImxlZnQiIGQ9Im01MTIgMjUtMTU4IDMyMS0zNTQgNTEgMjU2IDI1MC02MCAzNTIgMzE2LTE2NnoiIGZpbGw9IiNGRjk5MzMiLz4KICAgIDxwYXRoIGlkPSJyaWdodCIgZD0ibTEwMjQgMzk3LTM1NC01MS0xNTktMzIxdjgwOGwzMTcgMTY2LTYwLTM1MnoiIGZpbGw9IiM2NjY1NzAiLz4KPC9zdmc+Cg==)}:host([interactive]) [part^=icon]:hover,:host([interactive]) [part^=icon]:hover~[part^=icon]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IiBmaWxsPSIjRkY5OTMzIi8+Cjwvc3ZnPgo=)}');
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
elf.customStyles.define('ef-rating', ':host [part=container]{touch-action:manipulation;display:flex;flex-direction:row-reverse;flex-wrap:nowrap}:host [part^=icon]{margin:0 1px;background:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IiBmaWxsPSIjQUNBRkI1Ii8+Cjwvc3ZnPgo=) 0 0/100% no-repeat;width:1em;height:1em}:host [part^=icon]:first-child,:host [part^=icon]:last-child{margin:0}:host([interactive]) [part^=icon]{cursor:pointer}:host{font-size:10px}:host([size=large]){font-size:15px}:host(:not([interactive])) [part~=icon-full],:host([interactive]) [part=container]:not(:hover) [part~=icon-full]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IiBmaWxsPSIjRUU3NjAwIi8+Cjwvc3ZnPgo=)}:host(:not([interactive])) [part~=icon-half],:host([interactive]) [part=container]:not(:hover) [part~=icon-half]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggaWQ9ImxlZnQiIGQ9Im01MTIgMjUtMTU4IDMyMS0zNTQgNTEgMjU2IDI1MC02MCAzNTIgMzE2LTE2NnoiIGZpbGw9IiNFRTc2MDAiLz4KICAgIDxwYXRoIGlkPSJyaWdodCIgZD0ibTEwMjQgMzk3LTM1NC01MS0xNTktMzIxdjgwOGwzMTcgMTY2LTYwLTM1MnoiIGZpbGw9IiNBQ0FGQjUiLz4KPC9zdmc+Cg==)}:host([interactive]) [part^=icon]:hover,:host([interactive]) [part^=icon]:hover~[part^=icon]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IiBmaWxsPSIjRUU3NjAwIi8+Cjwvc3ZnPgo=)}');
|
|
2
|
+
elf.customStyles.define('ef-rating', ':host [part=container]{touch-action:manipulation;display:flex;flex-direction:row-reverse;flex-wrap:nowrap}:host [part^=icon]{margin:0 1px;background:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IiBmaWxsPSIjQUNBRkI1Ii8+Cjwvc3ZnPgo=) 0 0/100% no-repeat;width:1em;height:1em}:host [part^=icon]:first-child,:host [part^=icon]:last-child{margin:0}:host([interactive]) [part^=icon]{cursor:pointer}:host([focused=visible]){outline:#ffb266 solid 1px;outline-offset:2px}:host{font-size:10px}:host([size=large]){font-size:15px}:host(:not([interactive])) [part~=icon-full],:host([interactive]) [part=container]:not(:hover) [part~=icon-full]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IiBmaWxsPSIjRUU3NjAwIi8+Cjwvc3ZnPgo=)}:host(:not([interactive])) [part~=icon-half],:host([interactive]) [part=container]:not(:hover) [part~=icon-half]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggaWQ9ImxlZnQiIGQ9Im01MTIgMjUtMTU4IDMyMS0zNTQgNTEgMjU2IDI1MC02MCAzNTIgMzE2LTE2NnoiIGZpbGw9IiNFRTc2MDAiLz4KICAgIDxwYXRoIGlkPSJyaWdodCIgZD0ibTEwMjQgMzk3LTM1NC01MS0xNTktMzIxdjgwOGwzMTcgMTY2LTYwLTM1MnoiIGZpbGw9IiNBQ0FGQjUiLz4KPC9zdmc+Cg==)}:host([interactive]) [part^=icon]:hover,:host([interactive]) [part^=icon]:hover~[part^=icon]{background-image:url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAyNCAxMDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgogICAgPHBhdGggZD0ibTEwMjQgMzk3LTM1NC01MS0xNTgtMzIxLTE1OCAzMjEtMzU0IDUxIDI1NiAyNTAtNjAgMzUyIDMxNi0xNjYgMzE2IDE2Ni02MC0zNTJ6IiBmaWxsPSIjRUU3NjAwIi8+Cjwvc3ZnPgo=)}');
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return value that never exceed the maximum boundary
|
|
3
|
+
* @param value value for check clamp
|
|
4
|
+
* @param min max value
|
|
5
|
+
* @param max min value
|
|
6
|
+
* @returns number between two numbers
|
|
7
|
+
*/
|
|
8
|
+
declare const clamp: (value: number, min: number, max: number) => number;
|
|
9
|
+
export { clamp };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return value that never exceed the maximum boundary
|
|
3
|
+
* @param value value for check clamp
|
|
4
|
+
* @param min max value
|
|
5
|
+
* @param max min value
|
|
6
|
+
* @returns number between two numbers
|
|
7
|
+
*/
|
|
8
|
+
const clamp = function (value, min, max) {
|
|
9
|
+
return Math.max(min, Math.min(value, max));
|
|
10
|
+
};
|
|
11
|
+
export { clamp };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import '@refinitiv-ui/elements/icon/themes/halo/dark';
|
|
2
2
|
|
|
3
|
-
elf.customStyles.define('ef-search-field', ':host{display:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;text-align:left;font-family:inherit;font-size:12rem;font-weight:400;height:24px;width:152px;max-width:100%;padding:0 8px;margin:1px 0;outline:0;box-sizing:border-box;display:inline-flex;align-items:center;position:relative;vertical-align:middle;border-radius:0;background-color:#0d0d0d;text-overflow:ellipsis;border:1px solid #404040;color:#ccc}:host([disabled]){border:1px solid rgba(64,64,64,.5);color:rgba(204,204,204,.5);background-color:rgba(13,13,13,.5)}:host([type=number]){padding-right:0}:host([warning]){border:1px solid #ffc800}:host([warning][disabled]){color:rgba(204,204,204,.5);border:1px solid rgba(127,100,0,.5)}:host([error]),:host([error][warning]){border:1px solid #f5475b}:host([error][disabled]),:host([error][warning][disabled]){color:rgba(204,204,204,.5);border:1px solid rgba(160,28,43,.5)}:host ::-ms-clear{display:none}:host([focused]){background-size:100% 2px,100% 1px!important;background-position:center bottom!important;border-color:#334bff}:host [part=input]{color:inherit;padding:0;margin:0;flex:1 1 auto;min-width:0;width:100%;height:100%;-webkit-appearance:none;-moz-appearance:none;appearance:none;text-overflow:ellipsis;touch-action:manipulation}:host [part=input]::-webkit-clear-button,:host [part=input]::-webkit-inner-spin-button,:host [part=input]::-webkit-search-cancel-button,:host [part=input]::-webkit-search-decoration{-webkit-appearance:none}:host [part=input]:invalid{box-shadow:none}:host [part=icon]{color:#ccc;min-width:1em;padding-left:2px}:host([disabled]) [part=input]{-webkit-user-select:none;-moz-user-select:none
|
|
3
|
+
elf.customStyles.define('ef-search-field', ':host{display:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;text-align:left;font-family:inherit;font-size:12rem;font-weight:400;height:24px;width:152px;max-width:100%;padding:0 8px;margin:1px 0;outline:0;box-sizing:border-box;display:inline-flex;align-items:center;position:relative;vertical-align:middle;border-radius:0;background-color:#0d0d0d;text-overflow:ellipsis;border:1px solid #404040;color:#ccc}:host([disabled]){border:1px solid rgba(64,64,64,.5);color:rgba(204,204,204,.5);background-color:rgba(13,13,13,.5)}:host([type=number]){padding-right:0}:host([warning]){border:1px solid #ffc800}:host([warning][disabled]){color:rgba(204,204,204,.5);border:1px solid rgba(127,100,0,.5)}:host([error]),:host([error][warning]){border:1px solid #f5475b}:host([error][disabled]),:host([error][warning][disabled]){color:rgba(204,204,204,.5);border:1px solid rgba(160,28,43,.5)}:host ::-ms-clear{display:none}:host([focused]){background-size:100% 2px,100% 1px!important;background-position:center bottom!important;border-color:#334bff}:host [part=input]{color:inherit;padding:0;margin:0;flex:1 1 auto;min-width:0;width:100%;height:100%;-webkit-appearance:none;-moz-appearance:none;appearance:none;text-overflow:ellipsis;touch-action:manipulation}:host [part=input]::-webkit-clear-button,:host [part=input]::-webkit-inner-spin-button,:host [part=input]::-webkit-search-cancel-button,:host [part=input]::-webkit-search-decoration{-webkit-appearance:none}:host [part=input]:invalid{box-shadow:none}:host [part=icon]{color:#ccc;min-width:1em;padding-left:2px}:host([disabled]) [part=input]{-webkit-user-select:none;-moz-user-select:none;user-select:none}:host ::-moz-selection{color:#fff;background-color:#334bff}:host ::selection{color:#fff;background-color:#334bff}:host(:not([readonly]):not([error]):not([warning]):not([focused]):hover){border-color:grey;color:#fff}:host(:not([readonly]):not([error]):not([warning]):not([focused]):hover) [part=icon]{color:#6678ff}:host([warning]:hover:not([readonly]):not([focused])){color:#fff;border-color:#ffe999}:host([warning][disabled]),:host([warning][readonly]:not([focused])){border-color:rgba(255,233,153,.5)}:host([error]:hover:not([readonly]):not([focused])){color:#fff;border-color:#faa8b1}:host([error][disabled]),:host([error][readonly]:not([focused])),:host([error][warning][disabled]){border-color:rgba(250,168,177,.5)}:host([readonly]:not([focused])){border-color:rgba(64,64,64,.5);background-color:rgba(13,13,13,.5)}:host([readonly]:not([focused])) [part=icon]{color:rgba(204,204,204,.5)}:host([focused]),:host([focused][error][warning]){border-color:#334bff;color:#fff}:host([focused]) [part=icon],:host([focused][error][warning]) [part=icon]{color:#6678ff}');
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import '@refinitiv-ui/elements/icon/themes/halo/light';
|
|
2
2
|
|
|
3
|
-
elf.customStyles.define('ef-search-field', ':host{display:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;text-align:left;font-family:inherit;font-size:12rem;font-weight:400;height:24px;width:152px;max-width:100%;padding:0 8px;margin:1px 0;outline:0;box-sizing:border-box;display:inline-flex;align-items:center;position:relative;vertical-align:middle;border-radius:0;background-color:#fff;text-overflow:ellipsis;border:1px solid #595959;color:#404040}:host([disabled]){border:1px solid rgba(89,89,89,.5);color:rgba(64,64,64,.5);background-color:rgba(255,255,255,.5)}:host([type=number]){padding-right:0}:host([warning]){border:1px solid #cca000}:host([warning][disabled]){color:rgba(64,64,64,.5);border:1px solid rgba(204,160,0,.5)}:host([error]),:host([error][warning]){border:1px solid #d94255}:host([error][disabled]),:host([error][warning][disabled]){color:rgba(64,64,64,.5);border:1px solid rgba(182,50,67,.5)}:host ::-ms-clear{display:none}:host([focused]){background-size:100% 2px,100% 1px!important;background-position:center bottom!important;border-color:#334bff}:host [part=input]{color:inherit;padding:0;margin:0;flex:1 1 auto;min-width:0;width:100%;height:100%;-webkit-appearance:none;-moz-appearance:none;appearance:none;text-overflow:ellipsis;touch-action:manipulation}:host [part=input]::-webkit-clear-button,:host [part=input]::-webkit-inner-spin-button,:host [part=input]::-webkit-search-cancel-button,:host [part=input]::-webkit-search-decoration{-webkit-appearance:none}:host [part=input]:invalid{box-shadow:none}:host [part=icon]{color:#404040;min-width:1em;padding-left:2px}:host([disabled]) [part=input]{-webkit-user-select:none;-moz-user-select:none
|
|
3
|
+
elf.customStyles.define('ef-search-field', ':host{display:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;text-align:left;font-family:inherit;font-size:12rem;font-weight:400;height:24px;width:152px;max-width:100%;padding:0 8px;margin:1px 0;outline:0;box-sizing:border-box;display:inline-flex;align-items:center;position:relative;vertical-align:middle;border-radius:0;background-color:#fff;text-overflow:ellipsis;border:1px solid #595959;color:#404040}:host([disabled]){border:1px solid rgba(89,89,89,.5);color:rgba(64,64,64,.5);background-color:rgba(255,255,255,.5)}:host([type=number]){padding-right:0}:host([warning]){border:1px solid #cca000}:host([warning][disabled]){color:rgba(64,64,64,.5);border:1px solid rgba(204,160,0,.5)}:host([error]),:host([error][warning]){border:1px solid #d94255}:host([error][disabled]),:host([error][warning][disabled]){color:rgba(64,64,64,.5);border:1px solid rgba(182,50,67,.5)}:host ::-ms-clear{display:none}:host([focused]){background-size:100% 2px,100% 1px!important;background-position:center bottom!important;border-color:#334bff}:host [part=input]{color:inherit;padding:0;margin:0;flex:1 1 auto;min-width:0;width:100%;height:100%;-webkit-appearance:none;-moz-appearance:none;appearance:none;text-overflow:ellipsis;touch-action:manipulation}:host [part=input]::-webkit-clear-button,:host [part=input]::-webkit-inner-spin-button,:host [part=input]::-webkit-search-cancel-button,:host [part=input]::-webkit-search-decoration{-webkit-appearance:none}:host [part=input]:invalid{box-shadow:none}:host [part=icon]{color:#404040;min-width:1em;padding-left:2px}:host([disabled]) [part=input]{-webkit-user-select:none;-moz-user-select:none;user-select:none}:host ::-moz-selection{color:#fff;background-color:#334bff}:host ::selection{color:#fff;background-color:#334bff}:host(:not([readonly]):not([error]):not([warning]):not([focused]):hover){border-color:#0d0d0d;color:#0d0d0d}:host(:not([readonly]):not([error]):not([warning]):not([focused]):hover) [part=icon]{color:#334bff}:host([warning]:hover:not([readonly]):not([focused])){color:#0d0d0d;border-color:#ffe999}:host([warning][disabled]),:host([warning][readonly]:not([focused])){border-color:rgba(255,233,153,.5)}:host([error]:hover:not([readonly]):not([focused])){color:#0d0d0d;border-color:#eeacb4}:host([error][disabled]),:host([error][readonly]:not([focused])),:host([error][warning][disabled]){border-color:rgba(238,172,180,.5)}:host([readonly]:not([focused])){border-color:rgba(89,89,89,.5);background-color:rgba(255,255,255,.5)}:host([readonly]:not([focused])) [part=icon]{color:rgba(64,64,64,.5)}:host([focused]),:host([focused][error][warning]){border-color:#334bff;color:#0d0d0d}:host([focused]) [part=icon],:host([focused][error][warning]) [part=icon]{color:#334bff}');
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import '@refinitiv-ui/elements/icon/themes/solar/charcoal';
|
|
2
2
|
|
|
3
|
-
elf.customStyles.define('ef-search-field', ':host{display:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;text-align:left;font-family:inherit;font-size:13rem;font-weight:400;height:23px;width:140px;max-width:100%;padding:0 5px;margin:1px 0;outline:0;box-sizing:border-box;display:inline-flex;align-items:center;position:relative;vertical-align:middle;color:#c2c2c2;border-radius:0;text-overflow:ellipsis;background-color:#000;border:1px solid #4a4a52}:host([type=number]){padding-right:0}:host([error]),:host([error][warning]){border:1px solid #f5475b}:host([error][disabled]),:host([error][warning][disabled]){color:rgba(194,194,194,.6);border:1px solid rgba(245,71,91,.6)}:host ::-ms-clear{display:none}:host [part=input]{color:inherit;padding:0;margin:0;flex:1 1 auto;min-width:0;width:100%;height:100%;-webkit-appearance:none;-moz-appearance:none;appearance:none;text-overflow:ellipsis;touch-action:manipulation}:host [part=input]::-webkit-clear-button,:host [part=input]::-webkit-inner-spin-button,:host [part=input]::-webkit-search-cancel-button,:host [part=input]::-webkit-search-decoration{-webkit-appearance:none}:host [part=input]:invalid{box-shadow:none}:host [part=icon]{color:#e2e2e2;min-width:1em}:host([disabled]) [part=input]{-webkit-user-select:none;-moz-user-select:none
|
|
3
|
+
elf.customStyles.define('ef-search-field', ':host{display:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;text-align:left;font-family:inherit;font-size:13rem;font-weight:400;height:23px;width:140px;max-width:100%;padding:0 5px;margin:1px 0;outline:0;box-sizing:border-box;display:inline-flex;align-items:center;position:relative;vertical-align:middle;color:#c2c2c2;border-radius:0;text-overflow:ellipsis;background-color:#000;border:1px solid #4a4a52}:host([type=number]){padding-right:0}:host([error]),:host([error][warning]){border:1px solid #f5475b}:host([error][disabled]),:host([error][warning][disabled]){color:rgba(194,194,194,.6);border:1px solid rgba(245,71,91,.6)}:host ::-ms-clear{display:none}:host [part=input]{color:inherit;padding:0;margin:0;flex:1 1 auto;min-width:0;width:100%;height:100%;-webkit-appearance:none;-moz-appearance:none;appearance:none;text-overflow:ellipsis;touch-action:manipulation}:host [part=input]::-webkit-clear-button,:host [part=input]::-webkit-inner-spin-button,:host [part=input]::-webkit-search-cancel-button,:host [part=input]::-webkit-search-decoration{-webkit-appearance:none}:host [part=input]:invalid{box-shadow:none}:host [part=icon]{color:#e2e2e2;min-width:1em}:host([disabled]) [part=input]{-webkit-user-select:none;-moz-user-select:none;user-select:none}:host([disabled]){border:1px solid rgba(74,74,82,.6);color:rgba(194,194,194,.6)}:host([readonly]){border:1px solid rgba(74,74,82,.6)}:host(:not([focused]):not(:focus):not([disabled]):not([readonly]):hover){border:1px solid #77777d}:host([warning]){background-color:#000;border:1px solid #f93}:host([warning][disabled]){border:1px solid rgba(255,153,51,.6);color:rgba(194,194,194,.6)}:host([warning][readonly]){border:1px solid rgba(255,153,51,.6)}:host([warning]:not([focused]):not(:focus):not([disabled]):not([readonly]):hover){border:1px solid #ffb366}:host([error]),:host([error][warning]:not([focused])){background-color:#000;border:1px solid #f5475b}:host([error][disabled]),:host([error][warning]:not([focused])[disabled]){border:1px solid rgba(245,71,91,.6);color:rgba(194,194,194,.6)}:host([error][readonly]),:host([error][warning]:not([focused])[readonly]){border:1px solid rgba(245,71,91,.6)}:host([error]:not([focused]):not(:focus):not([disabled]):not([readonly]):hover),:host([error][warning]:not([focused]):not([focused]):not(:focus):not([disabled]):not([readonly]):hover){border:1px solid #f87584}:host([highlight]){background-color:#1b252f;border:1px solid #4a4a52}:host([highlight][disabled]){border:1px solid rgba(74,74,82,.6);color:rgba(194,194,194,.6);background-color:rgba(27,37,47,.6)}:host([highlight][readonly]){border:1px solid rgba(74,74,82,.6)}:host([highlight]:not([focused]):not(:focus):not([disabled]):not([readonly]):hover){border:1px solid #77777d}:host([indirect]){color:#0fd;background-color:#000;border:1px solid #898623}:host([indirect][disabled]){border:1px solid rgba(137,134,35,.6);color:rgba(0,255,221,.6)}:host([indirect][readonly]){border:1px solid rgba(137,134,35,.6)}:host([indirect]:not([focused]):not(:focus):not([disabled]):not([readonly]):hover){border:1px solid #a7a45a}:host([focused]){background-size:100% 2px,100% 1px!important;background-position:center bottom!important;border-color:#f93;border-style:dotted}:host([disabled]) [part=input]::-webkit-input-placeholder{color:rgba(102,101,112,.6)}:host([disabled]) [part=input]::-moz-placeholder{color:rgba(102,101,112,.6)}:host([disabled]) [part=input]:-ms-input-placeholder{color:rgba(102,101,112,.6)}');
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import '@refinitiv-ui/elements/icon/themes/solar/pearl';
|
|
2
2
|
|
|
3
|
-
elf.customStyles.define('ef-search-field', ':host{display:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;text-align:left;font-family:inherit;font-size:13rem;font-weight:400;height:23px;width:140px;max-width:100%;padding:0 5px;margin:1px 0;outline:0;box-sizing:border-box;display:inline-flex;align-items:center;position:relative;vertical-align:middle;color:#484848;border-radius:0;text-overflow:ellipsis;background-color:#fff;border:1px solid #a9afba}:host([type=number]){padding-right:0}:host([error]),:host([error][warning]){border:1px solid #d94255}:host([error][disabled]),:host([error][warning][disabled]){color:rgba(72,72,72,.6);border:1px solid rgba(217,66,85,.6)}:host ::-ms-clear{display:none}:host [part=input]{color:inherit;padding:0;margin:0;flex:1 1 auto;min-width:0;width:100%;height:100%;-webkit-appearance:none;-moz-appearance:none;appearance:none;text-overflow:ellipsis;touch-action:manipulation}:host [part=input]::-webkit-clear-button,:host [part=input]::-webkit-inner-spin-button,:host [part=input]::-webkit-search-cancel-button,:host [part=input]::-webkit-search-decoration{-webkit-appearance:none}:host [part=input]:invalid{box-shadow:none}:host [part=icon]{color:#acafb5;min-width:1em}:host([disabled]) [part=input]{-webkit-user-select:none;-moz-user-select:none
|
|
3
|
+
elf.customStyles.define('ef-search-field', ':host{display:none;-webkit-appearance:none;-moz-appearance:none;appearance:none;text-align:left;font-family:inherit;font-size:13rem;font-weight:400;height:23px;width:140px;max-width:100%;padding:0 5px;margin:1px 0;outline:0;box-sizing:border-box;display:inline-flex;align-items:center;position:relative;vertical-align:middle;color:#484848;border-radius:0;text-overflow:ellipsis;background-color:#fff;border:1px solid #a9afba}:host([type=number]){padding-right:0}:host([error]),:host([error][warning]){border:1px solid #d94255}:host([error][disabled]),:host([error][warning][disabled]){color:rgba(72,72,72,.6);border:1px solid rgba(217,66,85,.6)}:host ::-ms-clear{display:none}:host [part=input]{color:inherit;padding:0;margin:0;flex:1 1 auto;min-width:0;width:100%;height:100%;-webkit-appearance:none;-moz-appearance:none;appearance:none;text-overflow:ellipsis;touch-action:manipulation}:host [part=input]::-webkit-clear-button,:host [part=input]::-webkit-inner-spin-button,:host [part=input]::-webkit-search-cancel-button,:host [part=input]::-webkit-search-decoration{-webkit-appearance:none}:host [part=input]:invalid{box-shadow:none}:host [part=icon]{color:#acafb5;min-width:1em}:host([disabled]) [part=input]{-webkit-user-select:none;-moz-user-select:none;user-select:none}:host([disabled]){border:1px solid rgba(169,175,186,.6);color:rgba(72,72,72,.6)}:host([readonly]){border:1px solid rgba(169,175,186,.6)}:host(:not([focused]):not(:focus):not([disabled]):not([readonly]):hover){border:1px solid #bfc3cb}:host([warning]){background-color:#fff;border:1px solid #f93}:host([warning][disabled]){border:1px solid rgba(255,153,51,.6);color:rgba(72,72,72,.6)}:host([warning][readonly]){border:1px solid rgba(255,153,51,.6)}:host([warning]:not([focused]):not(:focus):not([disabled]):not([readonly]):hover){border:1px solid #ffb366}:host([error]),:host([error][warning]:not([focused])){background-color:#fff;border:1px solid #d94255}:host([error][disabled]),:host([error][warning]:not([focused])[disabled]){border:1px solid rgba(217,66,85,.6);color:rgba(72,72,72,.6)}:host([error][readonly]),:host([error][warning]:not([focused])[readonly]){border:1px solid rgba(217,66,85,.6)}:host([error]:not([focused]):not(:focus):not([disabled]):not([readonly]):hover),:host([error][warning]:not([focused]):not([focused]):not(:focus):not([disabled]):not([readonly]):hover){border:1px solid #e37180}:host([highlight]){background-color:#b0ffff;border:1px solid #a9afba}:host([highlight][disabled]){border:1px solid rgba(169,175,186,.6);color:rgba(72,72,72,.6);background-color:rgba(176,255,255,.6)}:host([highlight][readonly]){border:1px solid rgba(169,175,186,.6)}:host([highlight]:not([focused]):not(:focus):not([disabled]):not([readonly]):hover){border:1px solid #bfc3cb}:host([indirect]){color:#009494;background-color:#effefe;border:1px solid #898623}:host([indirect][disabled]){border:1px solid rgba(137,134,35,.6);color:rgba(0,148,148,.6)}:host([indirect][readonly]){border:1px solid rgba(137,134,35,.6)}:host([indirect]:not([focused]):not(:focus):not([disabled]):not([readonly]):hover){border:1px solid #a7a45a}:host([focused]){background-size:100% 2px,100% 1px!important;background-position:center bottom!important;border-color:#ffb266;border-style:dotted}:host([disabled]) [part=input]::-webkit-input-placeholder{color:rgba(102,101,112,.6)}:host([disabled]) [part=input]::-moz-placeholder{color:rgba(102,101,112,.6)}:host([disabled]) [part=input]:-ms-input-placeholder{color:rgba(102,101,112,.6)}');
|
package/lib/select/index.d.ts
CHANGED
|
@@ -103,7 +103,14 @@ export declare class Select extends ControlElement implements MultiValue {
|
|
|
103
103
|
* @readonly
|
|
104
104
|
*/
|
|
105
105
|
get values(): string[];
|
|
106
|
-
|
|
106
|
+
/**
|
|
107
|
+
* Reference to the menu element
|
|
108
|
+
*/
|
|
109
|
+
private menuRef;
|
|
110
|
+
/**
|
|
111
|
+
* Reference to the label element
|
|
112
|
+
*/
|
|
113
|
+
private labelRef;
|
|
107
114
|
/**
|
|
108
115
|
* Called when connected to DOM
|
|
109
116
|
* @returns {void}
|
|
@@ -338,6 +345,11 @@ export declare class Select extends ControlElement implements MultiValue {
|
|
|
338
345
|
* @returns Selected data item
|
|
339
346
|
*/
|
|
340
347
|
private get selectedSlotItems();
|
|
348
|
+
/**
|
|
349
|
+
* Get text for labels
|
|
350
|
+
* @returns Label
|
|
351
|
+
*/
|
|
352
|
+
private get labelText();
|
|
341
353
|
/**
|
|
342
354
|
* Calculating whether the placeholder should be hidden
|
|
343
355
|
* @returns result
|
package/lib/select/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import { ControlElement, html, css, FocusedPropertyKey } from '@refinitiv-ui/core';
|
|
3
3
|
import { customElement } from '@refinitiv-ui/core/decorators/custom-element.js';
|
|
4
4
|
import { property } from '@refinitiv-ui/core/decorators/property.js';
|
|
5
|
-
import { query } from '@refinitiv-ui/core/decorators/query.js';
|
|
6
5
|
import { styleMap } from '@refinitiv-ui/core/directives/style-map.js';
|
|
6
|
+
import { createRef, ref } from '@refinitiv-ui/core/directives/ref.js';
|
|
7
7
|
import { VERSION } from '../version.js';
|
|
8
8
|
import '../overlay/index.js';
|
|
9
9
|
import '../item/index.js';
|
|
@@ -11,6 +11,8 @@ import '../icon/index.js';
|
|
|
11
11
|
import { Item } from '../item/index.js';
|
|
12
12
|
import { CollectionComposer } from '@refinitiv-ui/utils/collection.js';
|
|
13
13
|
import { TimeoutTaskRunner, AnimationTaskRunner } from '@refinitiv-ui/utils/async.js';
|
|
14
|
+
import { isElementOverflown } from '@refinitiv-ui/utils/element.js';
|
|
15
|
+
import { registerOverflowTooltip } from '../tooltip/index.js';
|
|
14
16
|
// Observer config for items
|
|
15
17
|
const observerOptions = {
|
|
16
18
|
subtree: true,
|
|
@@ -80,6 +82,14 @@ let Select = class Select extends ControlElement {
|
|
|
80
82
|
* Therefore as soon as value has been set externally, selected state in data setter is ignored
|
|
81
83
|
*/
|
|
82
84
|
this.cachedValue = '';
|
|
85
|
+
/**
|
|
86
|
+
* Reference to the menu element
|
|
87
|
+
*/
|
|
88
|
+
this.menuRef = createRef();
|
|
89
|
+
/**
|
|
90
|
+
* Reference to the label element
|
|
91
|
+
*/
|
|
92
|
+
this.labelRef = createRef();
|
|
83
93
|
/**
|
|
84
94
|
* Handles all mutations and filters out
|
|
85
95
|
* any Shadow DOM changes in polyfilled browsers
|
|
@@ -316,6 +326,7 @@ let Select = class Select extends ControlElement {
|
|
|
316
326
|
firstUpdated(changedProperties) {
|
|
317
327
|
super.firstUpdated(changedProperties);
|
|
318
328
|
this.addEventListener('keydown', this.onKeyDown); /* keydown when select is closed */
|
|
329
|
+
registerOverflowTooltip(this, () => this.labelText, () => this.labelRef.value ? isElementOverflown(this.labelRef.value) : false);
|
|
319
330
|
}
|
|
320
331
|
/**
|
|
321
332
|
* Called when element finished updating
|
|
@@ -513,7 +524,9 @@ let Select = class Select extends ControlElement {
|
|
|
513
524
|
* @returns {void}
|
|
514
525
|
*/
|
|
515
526
|
onPopupMouseMove(event) {
|
|
516
|
-
this.
|
|
527
|
+
if (this.menuRef.value) {
|
|
528
|
+
this.menuRef.value.focus();
|
|
529
|
+
}
|
|
517
530
|
const item = this.findSelectableElement(event);
|
|
518
531
|
if (item) {
|
|
519
532
|
this.setItemHighlight(item);
|
|
@@ -686,7 +699,7 @@ let Select = class Select extends ControlElement {
|
|
|
686
699
|
* @returns A list of selectable HTML elements
|
|
687
700
|
*/
|
|
688
701
|
getSelectableElements() {
|
|
689
|
-
const root = this.hasDataItems() ? this.
|
|
702
|
+
const root = this.hasDataItems() ? this.menuRef.value : this;
|
|
690
703
|
/* istanbul ignore next */
|
|
691
704
|
if (!root) {
|
|
692
705
|
return [];
|
|
@@ -823,6 +836,13 @@ let Select = class Select extends ControlElement {
|
|
|
823
836
|
get selectedSlotItems() {
|
|
824
837
|
return this.getSelectedElements();
|
|
825
838
|
}
|
|
839
|
+
/**
|
|
840
|
+
* Get text for labels
|
|
841
|
+
* @returns Label
|
|
842
|
+
*/
|
|
843
|
+
get labelText() {
|
|
844
|
+
return this.multiple ? this.labels.join(LABEL_SEPARATOR) : this.label;
|
|
845
|
+
}
|
|
826
846
|
/**
|
|
827
847
|
* Calculating whether the placeholder should be hidden
|
|
828
848
|
* @returns result
|
|
@@ -866,7 +886,7 @@ let Select = class Select extends ControlElement {
|
|
|
866
886
|
* Template for label
|
|
867
887
|
*/
|
|
868
888
|
get labelTemplate() {
|
|
869
|
-
return html `<div part="label"
|
|
889
|
+
return html `<div part="label" ${ref(this.labelRef)}>${this.labelText}</div>`;
|
|
870
890
|
}
|
|
871
891
|
/**
|
|
872
892
|
* Edit template when select is not readonly or disabled
|
|
@@ -897,6 +917,7 @@ let Select = class Select extends ControlElement {
|
|
|
897
917
|
get popupTemplate() {
|
|
898
918
|
if (this.lazyRendered) {
|
|
899
919
|
return html `<ef-overlay
|
|
920
|
+
${ref(this.menuRef)}
|
|
900
921
|
tabindex="-1"
|
|
901
922
|
id="menu"
|
|
902
923
|
part="list"
|
|
@@ -967,9 +988,6 @@ __decorate([
|
|
|
967
988
|
__decorate([
|
|
968
989
|
property({ attribute: false })
|
|
969
990
|
], Select.prototype, "values", null);
|
|
970
|
-
__decorate([
|
|
971
|
-
query('#menu')
|
|
972
|
-
], Select.prototype, "menuEl", void 0);
|
|
973
991
|
Select = __decorate([
|
|
974
992
|
customElement('ef-select', {
|
|
975
993
|
alias: 'coral-select'
|