@refinitiv-ui/elements 6.0.0-next.2 → 6.0.1
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 +37 -0
- package/README.md +3 -15
- 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 +33 -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/themes/halo/dark/index.js +1 -1
- package/lib/button/themes/halo/light/index.js +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/card/themes/halo/dark/index.js +1 -1
- package/lib/card/themes/halo/light/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/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/collapse/themes/halo/dark/index.js +1 -1
- package/lib/collapse/themes/halo/light/index.js +1 -1
- package/lib/combo-box/custom-elements.json +0 -22
- package/lib/combo-box/custom-elements.md +0 -7
- package/lib/combo-box/themes/halo/dark/index.js +1 -1
- package/lib/combo-box/themes/halo/light/index.js +1 -1
- package/lib/counter/themes/halo/dark/index.js +1 -1
- package/lib/counter/themes/halo/light/index.js +1 -1
- package/lib/datetime-field/custom-elements.json +0 -75
- package/lib/datetime-field/custom-elements.md +27 -36
- package/lib/datetime-picker/themes/halo/dark/index.js +1 -1
- package/lib/datetime-picker/themes/halo/light/index.js +1 -1
- package/lib/dialog/themes/halo/dark/index.js +1 -1
- package/lib/dialog/themes/halo/light/index.js +1 -1
- package/lib/flag/utils/FlagLoader.d.ts +2 -32
- package/lib/flag/utils/FlagLoader.js +2 -69
- 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/interactive-chart/themes/halo/dark/index.js +1 -1
- package/lib/interactive-chart/themes/halo/light/index.js +1 -1
- package/lib/item/themes/halo/dark/index.js +1 -1
- package/lib/item/themes/halo/light/index.js +1 -1
- package/lib/list/themes/halo/dark/index.js +1 -1
- package/lib/list/themes/halo/light/index.js +1 -1
- package/lib/multi-input/themes/halo/dark/index.js +1 -1
- package/lib/multi-input/themes/halo/light/index.js +1 -1
- package/lib/number-field/custom-elements.json +0 -48
- package/lib/number-field/custom-elements.md +20 -26
- package/lib/number-field/themes/halo/dark/index.js +1 -1
- package/lib/number-field/themes/halo/light/index.js +1 -1
- package/lib/overlay/themes/halo/dark/index.js +1 -1
- package/lib/overlay/themes/halo/light/index.js +1 -1
- package/lib/overlay-menu/themes/halo/dark/index.js +1 -1
- package/lib/overlay-menu/themes/halo/light/index.js +1 -1
- package/lib/password-field/custom-elements.json +0 -7
- package/lib/password-field/custom-elements.md +0 -6
- package/lib/pill/themes/halo/dark/index.js +1 -1
- package/lib/pill/themes/halo/light/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/custom-elements.json +0 -7
- package/lib/search-field/custom-elements.md +0 -6
- package/lib/select/themes/halo/dark/index.js +1 -1
- package/lib/select/themes/halo/light/index.js +1 -1
- package/lib/sidebar-layout/themes/halo/dark/index.js +1 -1
- package/lib/sidebar-layout/themes/halo/light/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-bar/themes/halo/dark/index.js +1 -1
- package/lib/tab-bar/themes/halo/light/index.js +1 -1
- package/lib/text-field/custom-elements.json +0 -22
- package/lib/text-field/custom-elements.md +0 -7
- package/lib/toggle/themes/halo/dark/index.js +1 -1
- package/lib/toggle/themes/halo/light/index.js +1 -1
- package/lib/tree/elements/tree-item.js +1 -2
- package/lib/tree/elements/tree.d.ts +6 -0
- package/lib/tree/elements/tree.js +11 -1
- package/lib/tree/themes/halo/dark/index.js +2 -2
- package/lib/tree/themes/halo/light/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/version.js +1 -1
- package/package.json +19 -18
- package/lib/clock/utils/timestamps.d.ts +0 -6
- package/lib/clock/utils/timestamps.js +0 -6
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import '@refinitiv-ui/elements/icon/themes/halo/light';
|
|
2
2
|
|
|
3
|
-
elf.customStyles.define('ef-pill', ':host{touch-action:manipulation;background:#fafafa;transition:120ms;color:#0d0d0d;margin:2px;font-family:inherit;font-size:12rem;font-weight:400;padding:0 5px;min-width:21px;max-width:180px;outline:0;display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;vertical-align:middle;position:relative;overflow:hidden}:host [part=close]{touch-action:manipulation;border-radius:100%;position:relative;display:flex;margin-left:4px;flex:none;width:12px;height:12px;box-sizing:border-box;cursor:pointer;background-clip:content-box;color:#595959;min-width:12px;opacity:.4;background-color:initial}:host [part=close]:active{border:1px solid transparent}:host([focused=visible]){border:1px solid #334bff}:host{border-radius:10px;height:20px;line-height:20px;background-color:#fafafa;border:1px solid #ccc}:host(:hover),:host([active]:hover){background-color:#
|
|
3
|
+
elf.customStyles.define('ef-pill', ':host{touch-action:manipulation;background:#fafafa;transition:120ms;color:#0d0d0d;margin:2px;font-family:inherit;font-size:12rem;font-weight:400;padding:0 5px;min-width:21px;max-width:180px;outline:0;display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;vertical-align:middle;position:relative;overflow:hidden}:host [part=close]{touch-action:manipulation;border-radius:100%;position:relative;display:flex;margin-left:4px;flex:none;width:12px;height:12px;box-sizing:border-box;cursor:pointer;background-clip:content-box;color:#595959;min-width:12px;opacity:.4;background-color:initial}:host [part=close]:active{border:1px solid transparent}:host([focused=visible]){border:1px solid #334bff}:host{border-radius:10px;height:20px;line-height:20px;background-color:#fafafa;border:1px solid #ccc}:host(:hover),:host([active]:hover){background-color:#1429bd;border-color:#1429bd}:host([active]){border-color:#ccc;background-color:#334bff}:host([toggles][active][pressed]),:host([toggles][pressed]){border-color:#ccc}:host([toggles][pressed]),:host([toggles][pressed]:hover){background-color:#0f1e8a}:host(:hover),:host([active]),:host([pressed]){color:#fff}:host(:hover) [part=close],:host([active]) [part=close],:host([pressed]) [part=close]{color:#fff;opacity:1}:host([disabled]){border-color:#ccc;color:#0d0d0d;background-color:#fafafa}@media (pointer:coarse){:host(:not([active])),:host([toggles]:not([active])){color:#0d0d0d;background-color:#fafafa;border-color:#ccc}:host(:not([active])) [part=close],:host([toggles]:not([active])) [part=close]{color:#0d0d0d;opacity:.4}}');
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
"name": "max",
|
|
16
16
|
"description": "Set number of total stars",
|
|
17
17
|
"type": "string",
|
|
18
|
-
"default": "\"5\""
|
|
18
|
+
"default": "\"'5'\""
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"name": "value",
|
|
22
22
|
"description": "Set number of selected stars. Value can be any number between 0 and `max`.\nDecimal values are calculated to empty star (0 - .25); half-star (.25 - .75) and full star (.75 - 1)",
|
|
23
23
|
"type": "string",
|
|
24
|
-
"default": "\"0\""
|
|
24
|
+
"default": "\"'0'\""
|
|
25
25
|
}
|
|
26
26
|
],
|
|
27
27
|
"properties": [
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
"attribute": "max",
|
|
38
38
|
"description": "Set number of total stars",
|
|
39
39
|
"type": "string",
|
|
40
|
-
"default": "\"5\""
|
|
40
|
+
"default": "\"'5'\""
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
"name": "value",
|
|
44
44
|
"attribute": "value",
|
|
45
45
|
"description": "Set number of selected stars. Value can be any number between 0 and `max`.\nDecimal values are calculated to empty star (0 - .25); half-star (.25 - .75) and full star (.75 - 1)",
|
|
46
46
|
"type": "string",
|
|
47
|
-
"default": "\"0\""
|
|
47
|
+
"default": "\"'0'\""
|
|
48
48
|
}
|
|
49
49
|
],
|
|
50
50
|
"events": [
|
|
@@ -7,8 +7,8 @@ Star visualisation component that is generally used for ranking
|
|
|
7
7
|
| Property | Attribute | Type | Default | Description |
|
|
8
8
|
|---------------|---------------|-----------|---------|--------------------------------------------------|
|
|
9
9
|
| `interactive` | `interactive` | `boolean` | false | Make it possible to interact with rating control and change the value |
|
|
10
|
-
| `max` | `max` | `string` | "5"
|
|
11
|
-
| `value` | `value` | `string` | "0"
|
|
10
|
+
| `max` | `max` | `string` | "'5'" | Set number of total stars |
|
|
11
|
+
| `value` | `value` | `string` | "'0'" | Set number of selected stars. Value can be any number between 0 and `max`.<br />Decimal values are calculated to empty star (0 - .25); half-star (.25 - .75) and full star (.75 - 1) |
|
|
12
12
|
|
|
13
13
|
## Events
|
|
14
14
|
|
package/lib/rating/index.d.ts
CHANGED
|
@@ -10,64 +10,116 @@ export declare class Rating extends BasicElement {
|
|
|
10
10
|
* @returns version number
|
|
11
11
|
*/
|
|
12
12
|
static get version(): string;
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* A `CSSResultGroup` that will be used
|
|
15
|
+
* to style the host, slotted children
|
|
16
|
+
* and the internal template of the element.
|
|
17
|
+
* @returns CSS template
|
|
18
|
+
*/
|
|
19
|
+
static get styles(): CSSResultGroup;
|
|
20
|
+
private MAX_VALUE;
|
|
21
|
+
private MIN_VALUE;
|
|
15
22
|
/**
|
|
16
23
|
* Make it possible to interact with rating control and change the value
|
|
17
24
|
*/
|
|
18
25
|
interactive: boolean;
|
|
19
26
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
* Internal max value of rating.
|
|
28
|
+
* Controlled by public setter and getter
|
|
29
|
+
*/
|
|
30
|
+
private _max;
|
|
31
|
+
/**
|
|
32
|
+
* Set number of total stars
|
|
33
|
+
* @param max max value
|
|
34
|
+
* @default '5'
|
|
35
|
+
*/
|
|
36
|
+
set max(max: string);
|
|
37
|
+
get max(): string;
|
|
23
38
|
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
39
|
+
* Converts max value from string to number for calculations
|
|
40
|
+
* @returns maximum value of rating as a number
|
|
41
|
+
*/
|
|
42
|
+
private get maxNumber();
|
|
28
43
|
/**
|
|
29
|
-
*
|
|
44
|
+
* Internal value of rating.
|
|
45
|
+
* Controlled by public setter and getter
|
|
30
46
|
*/
|
|
31
|
-
private
|
|
47
|
+
private _value;
|
|
48
|
+
/**
|
|
49
|
+
* Set number of selected stars. Value can be any number between 0 and `max`.
|
|
50
|
+
* Decimal values are calculated to empty star (0 - .25); half-star (.25 - .75) and full star (.75 - 1)
|
|
51
|
+
* @param value Element value
|
|
52
|
+
* @default '0'
|
|
53
|
+
*/
|
|
54
|
+
set value(value: string);
|
|
55
|
+
get value(): string;
|
|
32
56
|
/**
|
|
33
57
|
* Converts value from string to number for calculations
|
|
34
58
|
* @returns value of rating as a number
|
|
35
59
|
*/
|
|
36
60
|
private get valueNumber();
|
|
37
61
|
/**
|
|
38
|
-
*
|
|
39
|
-
* @
|
|
62
|
+
* Called before update() to compute values needed during the update.
|
|
63
|
+
* @param changedProperties Properties that has changed
|
|
64
|
+
* @returns {void}
|
|
40
65
|
*/
|
|
41
|
-
|
|
66
|
+
protected willUpdate(changedProperties: PropertyValues): void;
|
|
42
67
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* CSS3 specification does not allow to select items preceding the hover, but allows to select the following items.
|
|
46
|
-
* Therefore `flex: reverse` style is applied and the items are constructed in the reverse mode to mimic the correct behaviour.
|
|
47
|
-
* @param {Number} max Number of stars
|
|
48
|
-
* @param {Number} value Value
|
|
68
|
+
* Invoked when the element is first updated
|
|
69
|
+
* @param changedProperties changed properties
|
|
49
70
|
* @returns {void}
|
|
50
71
|
*/
|
|
51
|
-
|
|
72
|
+
protected firstUpdated(changedProperties: PropertyValues): void;
|
|
52
73
|
/**
|
|
53
|
-
*
|
|
54
|
-
* @param {number} index index of star
|
|
74
|
+
* Handles interactive and aria attribute changes
|
|
55
75
|
* @returns {void}
|
|
56
76
|
*/
|
|
57
|
-
private
|
|
77
|
+
private interactiveChanged;
|
|
58
78
|
/**
|
|
59
|
-
*
|
|
60
|
-
* @param
|
|
79
|
+
* Handles key input
|
|
80
|
+
* @param event Key down event object
|
|
61
81
|
* @returns {void}
|
|
62
82
|
*/
|
|
63
|
-
protected
|
|
83
|
+
protected onKeyDown(event: KeyboardEvent): void;
|
|
64
84
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* @returns CSS template
|
|
85
|
+
* Update value and fired value-changed event
|
|
86
|
+
* @param value value to updated
|
|
87
|
+
* @returns {void}
|
|
69
88
|
*/
|
|
70
|
-
|
|
89
|
+
private notifyValueChange;
|
|
90
|
+
/**
|
|
91
|
+
* Check if passed value is a valid value
|
|
92
|
+
* @override
|
|
93
|
+
* @param value Value to check
|
|
94
|
+
* @returns {boolean} false if value is invalid
|
|
95
|
+
*/
|
|
96
|
+
protected isValidValue(value: string): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Increases the value of rating by half or 1 if not specific amount but not exceed max value
|
|
99
|
+
* @param value step up value to specific number (optional)
|
|
100
|
+
* @returns {void}
|
|
101
|
+
*/
|
|
102
|
+
private stepUp;
|
|
103
|
+
/**
|
|
104
|
+
* Decrease the value of rating by half or 1 if not specific amount but not exceed min value
|
|
105
|
+
* @param value step down value to specific number (optional)
|
|
106
|
+
* @returns {void}
|
|
107
|
+
*/
|
|
108
|
+
private stepDown;
|
|
109
|
+
/**
|
|
110
|
+
* Process click event to set the new value
|
|
111
|
+
* @param {number} index index of star
|
|
112
|
+
* @returns {void}
|
|
113
|
+
*/
|
|
114
|
+
private handleTap;
|
|
115
|
+
/**
|
|
116
|
+
* Render rating based on max number of stars and value.
|
|
117
|
+
* Note: to speed up the component, hover state is implemented using CSS only.
|
|
118
|
+
* CSS3 specification does not allow to select items preceding the hover, but allows to select the following items.
|
|
119
|
+
* Therefore `flex: reverse` style is applied and the items are constructed in the reverse mode to mimic the correct behaviour.
|
|
120
|
+
* @returns stars template
|
|
121
|
+
*/
|
|
122
|
+
private get starsTemplate();
|
|
71
123
|
/**
|
|
72
124
|
* A `TemplateResult` that will be used
|
|
73
125
|
* to render the updated internal template.
|
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 };
|