@momentum-design/components 0.110.1 → 0.111.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +709 -405
- package/dist/browser/index.js.map +4 -4
- package/dist/components/slider/index.d.ts +1 -0
- package/dist/components/slider/index.js +1 -0
- package/dist/components/slider/slider.component.d.ts +154 -37
- package/dist/components/slider/slider.component.js +489 -90
- package/dist/components/slider/slider.constants.d.ts +14 -1
- package/dist/components/slider/slider.constants.js +14 -1
- package/dist/components/slider/slider.styles.js +195 -1
- package/dist/components/slider/slider.types.d.ts +8 -1
- package/dist/components/slider/slider.types.js +0 -1
- package/dist/custom-elements.json +752 -483
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +2 -2
- package/dist/react/slider/index.d.ts +34 -4
- package/dist/react/slider/index.js +31 -4
- package/dist/utils/styles/index.d.ts +2 -1
- package/dist/utils/styles/index.js +5 -5
- package/package.json +1 -1
@@ -7,183 +7,582 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9
9
|
};
|
10
|
-
import { html } from 'lit';
|
11
|
-
import { property } from 'lit/decorators.js';
|
10
|
+
import { html, nothing } from 'lit';
|
11
|
+
import { property, queryAll, state } from 'lit/decorators.js';
|
12
|
+
import { repeat } from 'lit/directives/repeat.js';
|
12
13
|
import { Component } from '../../models';
|
14
|
+
import { KEYS } from '../../utils/keys';
|
15
|
+
import { DEFAULTS } from './slider.constants';
|
13
16
|
import styles from './slider.styles';
|
14
17
|
/**
|
15
|
-
*
|
18
|
+
* Slider component is used to select a value or range of values from within a defined range.
|
19
|
+
* It provides a visual representation of the current value(s) and allows users to adjust the value(s) by dragging the thumb(s) along the track.
|
20
|
+
* It can be used as a single slider or a range slider. This is set by the boolean attribute `range`
|
21
|
+
* If the step value is more than 1, tick marks are shown to represent the steps between the min and max values. The slider thumb will snap to the nearest tick mark.
|
16
22
|
*
|
17
23
|
* @tagname mdc-slider
|
18
24
|
*
|
19
|
-
* @
|
25
|
+
* @dependency mdc-icon
|
20
26
|
*
|
21
|
-
* @
|
27
|
+
* @csspart slider-tooltip - The tooltip of the slider
|
28
|
+
* @csspart slider-track - The track of the slider
|
29
|
+
* @csspart slider-wrapper - The wrapper around the slider input(s)
|
30
|
+
* @csspart slider-ticks - The container for the tick marks
|
31
|
+
* @csspart slider-tick - The individual tick marks
|
32
|
+
* @csspart slider-input - The input element of the slider
|
33
|
+
* @csspart slider-label - The label of the slider
|
34
|
+
*
|
35
|
+
* @event input - Fired when the slider value changes
|
36
|
+
* @event change - Fired when the slider value is committed
|
37
|
+
*
|
38
|
+
* @cssproperty --mdc-slider-thumb-color - The color of the slider thumb
|
39
|
+
* @cssproperty --mdc-slider-thumb-border-color - The color of the slider thumb border
|
40
|
+
* @cssproperty --mdc-slider-thumb-size - The size of the slider thumb
|
41
|
+
* @cssproperty --mdc-slider-input-size - The height of the slider input
|
42
|
+
* @cssproperty --mdc-slider-tick-size - The size of the slider tick marks
|
43
|
+
* @cssproperty --mdc-slider-track-height - The height of the slider track
|
44
|
+
* @cssproperty --mdc-slider-tick-color - The color of the slider tick marks
|
45
|
+
* @cssproperty --mdc-slider-progress-color - The color of the slider progress
|
46
|
+
* @cssproperty --mdc-slider-track-color - The color of the slider track
|
47
|
+
* @cssproperty --mdc-slider-tooltip-left - The left position of the slider tooltip
|
48
|
+
* @cssproperty --mdc-slider-tick-left - The left position of the slider tick marks
|
22
49
|
*/
|
23
50
|
class Slider extends Component {
|
24
51
|
constructor() {
|
25
|
-
super(
|
26
|
-
/**
|
27
|
-
* Whether or not to show a value range. When false, the slider displays a slide-able handle for the value property; when true, it displays slide-able handles for the valueStart and valueEnd properties.
|
28
|
-
*/
|
29
|
-
this.range = false;
|
30
|
-
/**
|
31
|
-
* The slider minimum value.
|
32
|
-
*/
|
33
|
-
this.min = 0;
|
34
|
-
/**
|
35
|
-
* The slider maximum value.
|
36
|
-
*/
|
37
|
-
this.max = 100;
|
38
|
-
/**
|
39
|
-
* The step between values. This will show tick marks and the stepper will snap to the nearest tick mark.
|
40
|
-
*/
|
41
|
-
this.step = 1;
|
42
|
-
/**
|
43
|
-
* An optional label for the slider's value displayed when range is false; if not set, the label is the value itself.
|
44
|
-
*/
|
45
|
-
this.valueLabel = '';
|
46
|
-
/**
|
47
|
-
* An optional label for the slider's start value displayed when range is true; if not set, the label is the valueStart itself.
|
48
|
-
*/
|
49
|
-
this.valueLabelStart = '';
|
52
|
+
super();
|
50
53
|
/**
|
51
|
-
*
|
54
|
+
* Internal state to track if the slider thumb is focused (single value)
|
55
|
+
* @internal
|
52
56
|
*/
|
53
|
-
this.
|
57
|
+
this.thumbFocused = DEFAULTS.STATE;
|
54
58
|
/**
|
55
|
-
*
|
59
|
+
* @internal
|
56
60
|
*/
|
57
|
-
this.
|
61
|
+
this.thumbHovered = DEFAULTS.STATE;
|
58
62
|
/**
|
59
|
-
*
|
63
|
+
* Indicates whether it is a range slider. When true, the slider displays two handles for selecting a range of values.
|
64
|
+
* When false, the slider displays a single handle for selecting a single value.
|
65
|
+
* @default false
|
60
66
|
*/
|
61
|
-
this.
|
62
|
-
/**
|
63
|
-
* Aria label for the slider's end handle displayed when range is true.
|
64
|
-
*/
|
65
|
-
this.ariaLabelEnd = '';
|
67
|
+
this.range = false;
|
66
68
|
/**
|
67
|
-
*
|
69
|
+
* The slider minimum value.
|
70
|
+
* @default 0
|
68
71
|
*/
|
69
|
-
this.
|
72
|
+
this.min = DEFAULTS.MIN;
|
70
73
|
/**
|
71
|
-
*
|
74
|
+
* The slider maximum value.
|
75
|
+
* @default 100
|
72
76
|
*/
|
73
|
-
this.
|
77
|
+
this.max = DEFAULTS.MAX;
|
74
78
|
/**
|
75
|
-
*
|
79
|
+
* The step between values. If defined and greater than 1, we will show tick marks and the stepper will snap to the nearest tick mark.
|
80
|
+
* @default 1
|
76
81
|
*/
|
77
|
-
this.
|
82
|
+
this.step = DEFAULTS.STEP;
|
83
|
+
this.addEventListener('keydown', this.preventChange.bind(this));
|
84
|
+
this.addEventListener('mousedown', this.preventChange.bind(this));
|
85
|
+
}
|
86
|
+
updated(changedProperties) {
|
87
|
+
super.updated(changedProperties);
|
88
|
+
if (changedProperties.has('value') ||
|
89
|
+
changedProperties.has('step') ||
|
90
|
+
changedProperties.has('min') ||
|
91
|
+
changedProperties.has('max') ||
|
92
|
+
changedProperties.has('disabled') ||
|
93
|
+
changedProperties.has('softDisabled') ||
|
94
|
+
changedProperties.has('range') ||
|
95
|
+
changedProperties.has('valueStart') ||
|
96
|
+
changedProperties.has('valueEnd')) {
|
97
|
+
this.updateTrackStyling();
|
98
|
+
}
|
99
|
+
if (changedProperties.has('softDisabled')) {
|
100
|
+
this.setSoftDisabled();
|
101
|
+
}
|
102
|
+
if (changedProperties.has('range') || changedProperties.has('valueStart') || changedProperties.has('valueEnd')) {
|
103
|
+
this.initializeRangeSlider();
|
104
|
+
}
|
105
|
+
}
|
106
|
+
/**
|
107
|
+
* Prevents default behavior for mouse and keyboard events.
|
108
|
+
* This prevents user interaction with the slider when it is soft-disabled.
|
109
|
+
* @param e - The event to prevent.
|
110
|
+
*/
|
111
|
+
preventChange(e) {
|
112
|
+
if (this.softDisabled && ((e instanceof KeyboardEvent && e.key !== KEYS.TAB) || !(e instanceof KeyboardEvent))) {
|
113
|
+
e.preventDefault();
|
114
|
+
e.stopPropagation();
|
115
|
+
}
|
116
|
+
}
|
117
|
+
/**
|
118
|
+
* Sets the soft-disabled state for the slider.
|
119
|
+
* Applies the appropriate ARIA attributes.
|
120
|
+
*/
|
121
|
+
setSoftDisabled() {
|
122
|
+
this.inputElements.forEach(input => {
|
123
|
+
const inputElement = input;
|
124
|
+
if (this.softDisabled) {
|
125
|
+
inputElement.setAttribute('aria-disabled', 'true');
|
126
|
+
}
|
127
|
+
else {
|
128
|
+
inputElement.removeAttribute('aria-disabled');
|
129
|
+
}
|
130
|
+
});
|
131
|
+
}
|
132
|
+
/**
|
133
|
+
* Initializes the range slider by setting default values for the start and end handles.
|
134
|
+
* Updates the slider's input elements to reflect the current values.
|
135
|
+
*/
|
136
|
+
initializeRangeSlider() {
|
137
|
+
if (this.valueStart === undefined) {
|
138
|
+
this.valueStart = this.min;
|
139
|
+
}
|
140
|
+
if (this.valueEnd === undefined) {
|
141
|
+
this.valueEnd = this.max;
|
142
|
+
}
|
143
|
+
this.handleInput(0);
|
144
|
+
this.handleInput(1);
|
145
|
+
}
|
146
|
+
/**
|
147
|
+
* Handles input changes for either the start or end thumb of the range slider.
|
148
|
+
* Ensures thumbs do not cross over each other.
|
149
|
+
* @param thumbIndex - 0 for start thumb, 1 for end thumb.
|
150
|
+
*/
|
151
|
+
handleInput(thumbIndex) {
|
152
|
+
const input = this.inputElements[thumbIndex];
|
153
|
+
if (!input)
|
154
|
+
return;
|
155
|
+
if (thumbIndex === 0) {
|
156
|
+
if (!this.valueEnd)
|
157
|
+
return; // Ensure valueEnd is available
|
158
|
+
const inputValue = Number(input.value);
|
159
|
+
if (inputValue > this.valueEnd) {
|
160
|
+
input.value = String(this.valueEnd);
|
161
|
+
this.valueStart = this.valueEnd;
|
162
|
+
}
|
163
|
+
else if (inputValue >= this.min && inputValue < this.valueEnd) {
|
164
|
+
this.valueStart = inputValue;
|
165
|
+
}
|
166
|
+
else if (inputValue < this.min) {
|
167
|
+
// Handle case where input goes below min
|
168
|
+
input.value = String(this.min);
|
169
|
+
this.valueStart = this.min;
|
170
|
+
}
|
171
|
+
}
|
172
|
+
else {
|
173
|
+
// Handling the end thumb
|
174
|
+
if (!this.valueStart)
|
175
|
+
return; // Ensure valueStart is available
|
176
|
+
const inputValue = Number(input.value);
|
177
|
+
if (inputValue < this.valueStart) {
|
178
|
+
input.value = String(this.valueStart);
|
179
|
+
this.valueEnd = this.valueStart;
|
180
|
+
}
|
181
|
+
else if (inputValue <= this.max && inputValue > this.valueStart) {
|
182
|
+
this.valueEnd = inputValue;
|
183
|
+
}
|
184
|
+
else if (inputValue > this.max) {
|
185
|
+
// Handle case where input goes above max
|
186
|
+
input.value = String(this.max);
|
187
|
+
this.valueEnd = this.max;
|
188
|
+
}
|
189
|
+
}
|
190
|
+
}
|
191
|
+
/**
|
192
|
+
* Renders an icon element.
|
193
|
+
* @param icon - The name of the icon to render.
|
194
|
+
* @param part - The part attribute for the icon element.
|
195
|
+
* @returns The icon element or null.
|
196
|
+
*/
|
197
|
+
iconTemplate(icon, part) {
|
198
|
+
return typeof icon === 'string' && icon.length > 0
|
199
|
+
? html `<mdc-icon
|
200
|
+
name="${icon}"
|
201
|
+
part="${part}"
|
202
|
+
length-unit="${DEFAULTS.ICON_LENGTH_UNIT}"
|
203
|
+
size="${DEFAULTS.ICON_SIZE}"
|
204
|
+
></mdc-icon>`
|
205
|
+
: null;
|
206
|
+
}
|
207
|
+
/**
|
208
|
+
* Renders a visual representation of tooltip element and places it exactly above the slider thumb.
|
209
|
+
* @param label - The label to display in the tooltip.
|
210
|
+
* @param source - The source of the tooltip (e.g., 'start' or 'end').
|
211
|
+
* @returns The tooltip element.
|
212
|
+
*/
|
213
|
+
tooltipTemplate(label, source) {
|
214
|
+
const [inputStart, inputEnd] = this.inputElements;
|
215
|
+
const input = source === 'end' ? inputEnd : inputStart;
|
216
|
+
const value = Number(input === null || input === void 0 ? void 0 : input.value);
|
217
|
+
if (typeof value !== 'number' || Number.isNaN(value) || this.max === this.min) {
|
218
|
+
return nothing;
|
219
|
+
}
|
220
|
+
const normalizedValue = (value - this.min) / (this.max - this.min);
|
221
|
+
return html `<div part="slider-tooltip" aria-hidden="true" style="--mdc-slider-tooltip-left: ${normalizedValue}">
|
222
|
+
${label || value}
|
223
|
+
</div> `;
|
224
|
+
}
|
225
|
+
/**
|
226
|
+
* Updates the styling of the slider track.
|
227
|
+
* The progress value is calculated and updated using appropriate tokens
|
228
|
+
* In a range slider, both thumbs are considered.
|
229
|
+
* The track is filled between the two thumbs.
|
230
|
+
*/
|
231
|
+
updateTrackStyling() {
|
232
|
+
let progressColor = `var(--mdc-slider-progress-color)`;
|
233
|
+
let trackColor = `var(--mdc-slider-track-color)`;
|
234
|
+
if (this.disabled || this.softDisabled) {
|
235
|
+
progressColor = `var(--mds-color-theme-control-active-disabled)`;
|
236
|
+
trackColor = `var(--mds-color-theme-control-inactive-disabled)`;
|
237
|
+
}
|
238
|
+
if (this.range) {
|
239
|
+
if (!this.inputElements[1])
|
240
|
+
return;
|
241
|
+
const valueStart = Number(this.inputElements[0].value);
|
242
|
+
const valueEnd = Number(this.inputElements[1].value);
|
243
|
+
const max = Number(this.inputElements[0].max) || 1;
|
244
|
+
const progressStart = Math.max(0, Math.min(100, ((valueStart - this.min) / (max - this.min)) * 100));
|
245
|
+
const progressEnd = Math.max(0, Math.min(100, ((valueEnd - this.min) / (max - this.min)) * 100));
|
246
|
+
this.inputElements[1].style.background = `linear-gradient(
|
247
|
+
to right,
|
248
|
+
${trackColor} 0%,
|
249
|
+
${trackColor} ${progressStart}%,
|
250
|
+
${progressColor} ${progressStart}%,
|
251
|
+
${progressColor} ${progressEnd}%,
|
252
|
+
${trackColor} ${progressEnd}%,
|
253
|
+
${trackColor} 100%
|
254
|
+
)`;
|
255
|
+
}
|
256
|
+
else {
|
257
|
+
if (!this.inputElements[0])
|
258
|
+
return;
|
259
|
+
const value = Number(this.inputElements[0].value);
|
260
|
+
const max = Number(this.inputElements[0].max) || 1;
|
261
|
+
const progress = Math.max(0, Math.min(100, ((value - this.min) / (max - this.min)) * 100));
|
262
|
+
this.inputElements[0].style.background = `linear-gradient(to right, ${progressColor} ${progress}%, ${trackColor} ${progress}%)`;
|
263
|
+
}
|
264
|
+
}
|
265
|
+
/**
|
266
|
+
* Handles the input event for the single value slider.
|
267
|
+
* @param e - The input event.
|
268
|
+
*/
|
269
|
+
onInput(e) {
|
270
|
+
const input = e.target;
|
271
|
+
this.value = Number(input.value);
|
272
|
+
}
|
273
|
+
/**
|
274
|
+
* Handles the change event for the single value slider.
|
275
|
+
* @param e - The change event.
|
276
|
+
*/
|
277
|
+
onChange(e) {
|
278
|
+
const input = e.target;
|
279
|
+
this.value = Number(input.value);
|
280
|
+
this.dispatchEvent(new CustomEvent('change', { detail: { value: this.value } }));
|
281
|
+
}
|
282
|
+
/**
|
283
|
+
* Handles the change event for the start thumb of the range slider.
|
284
|
+
* @param e - The change event.
|
285
|
+
*/
|
286
|
+
onChangeStart(e) {
|
287
|
+
const input = e.target;
|
288
|
+
this.valueStart = Number(input.value);
|
289
|
+
this.dispatchEvent(new CustomEvent('change', { detail: { valueStart: this.valueStart, valueEnd: this.valueEnd } }));
|
290
|
+
}
|
291
|
+
/**
|
292
|
+
* Handles the change event for the end thumb of the range slider.
|
293
|
+
* @param e - The change event.
|
294
|
+
*/
|
295
|
+
onChangeEnd(e) {
|
296
|
+
const input = e.target;
|
297
|
+
this.valueEnd = Number(input.value);
|
298
|
+
this.dispatchEvent(new CustomEvent('change', { detail: { valueEnd: this.valueEnd, valueStart: this.valueStart } }));
|
299
|
+
}
|
300
|
+
/**
|
301
|
+
* Get the styles for the tick marks.
|
302
|
+
* Since the ticks are placed above the slider, we need to hide the tick that is placed exactly where the slider thumb is.
|
303
|
+
* Based on this condition, it renders the styles appropriately.
|
304
|
+
* @param tick - The tick value.
|
305
|
+
* @returns The styles for the tick mark.
|
306
|
+
*/
|
307
|
+
getTickStyles(tick) {
|
308
|
+
if (this.max === this.min)
|
309
|
+
return '';
|
310
|
+
const normalizedTick = (tick - this.min) / (this.max - this.min);
|
311
|
+
const normalizedValues = [];
|
312
|
+
if (this.inputElements[0]) {
|
313
|
+
const value = Number(this.inputElements[0].value);
|
314
|
+
const normalizedValue = (value - this.min) / (this.max - this.min);
|
315
|
+
normalizedValues.push(normalizedValue);
|
316
|
+
}
|
317
|
+
if (this.range && this.inputElements[1]) {
|
318
|
+
const valueEnd = Number(this.inputElements[1].value);
|
319
|
+
const normalizedValueEnd = (valueEnd - this.min) / (this.max - this.min);
|
320
|
+
normalizedValues.push(normalizedValueEnd);
|
321
|
+
}
|
322
|
+
// Hide tick if it is at the same pixel as any thumb (allowing for 1px tolerance)
|
323
|
+
if (normalizedValues.includes(normalizedTick)) {
|
324
|
+
return 'display:none;';
|
325
|
+
}
|
326
|
+
return `--mdc-slider-tick-left:${normalizedTick};`;
|
327
|
+
}
|
328
|
+
renderTicks() {
|
329
|
+
// Tick marks
|
330
|
+
const ticks = [];
|
331
|
+
if (this.step && this.step > 1) {
|
332
|
+
for (let i = this.min; i <= this.max; i += this.step) {
|
333
|
+
ticks.push(i);
|
334
|
+
}
|
335
|
+
}
|
336
|
+
if (this.step > 1) {
|
337
|
+
return html ` <div part="slider-ticks">
|
338
|
+
${repeat(ticks, tick => tick, tick => html `<span part="slider-tick" style=${this.getTickStyles(tick)}></span>`)}
|
339
|
+
</div>`;
|
340
|
+
}
|
341
|
+
return nothing;
|
78
342
|
}
|
79
343
|
render() {
|
80
|
-
|
81
|
-
|
344
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
345
|
+
return html `
|
346
|
+
${this.label ? html `<label part="slider-label" for="single-slider">${this.label}</label>` : null}
|
347
|
+
<div part="slider-track">
|
348
|
+
${this.iconTemplate(this.leadingIcon, 'leading-icon')}
|
349
|
+
<div part="slider-wrapper">
|
350
|
+
${this.renderTicks()}
|
351
|
+
${this.range
|
352
|
+
? html `
|
353
|
+
<input
|
354
|
+
id="start-slider"
|
355
|
+
part="start-slider"
|
356
|
+
type="range"
|
357
|
+
min="${this.min}"
|
358
|
+
max="${this.max}"
|
359
|
+
step="${(_a = this.step) !== null && _a !== void 0 ? _a : 1}"
|
360
|
+
.value="${String((_b = this.valueStart) !== null && _b !== void 0 ? _b : this.min)}"
|
361
|
+
?disabled="${this.disabled}"
|
362
|
+
name="${(_c = this.nameStart) !== null && _c !== void 0 ? _c : ''}"
|
363
|
+
aria-valuemin="${this.min}"
|
364
|
+
aria-valuemax="${this.max}"
|
365
|
+
aria-valuenow="${(_d = this.valueStart) !== null && _d !== void 0 ? _d : this.min}"
|
366
|
+
aria-label="${this.startAriaLabel || this.label || ''}"
|
367
|
+
aria-valuetext="${this.startAriaValuetext || this.valueLabelStart || this.valueStart || ''}"
|
368
|
+
tabindex="${this.disabled ? -1 : 0}"
|
369
|
+
@input=${() => this.handleInput(0)}
|
370
|
+
@change=${this.onChangeStart}
|
371
|
+
@focus=${() => {
|
372
|
+
this.thumbFocused = 'start';
|
373
|
+
}}
|
374
|
+
@blur=${() => {
|
375
|
+
this.thumbFocused = undefined;
|
376
|
+
}}
|
377
|
+
@mouseenter=${() => {
|
378
|
+
if (!this.disabled)
|
379
|
+
this.thumbHovered = 'start';
|
380
|
+
}}
|
381
|
+
@mouseleave=${() => {
|
382
|
+
this.thumbHovered = undefined;
|
383
|
+
}}
|
384
|
+
/>
|
385
|
+
${this.thumbFocused === 'start' || this.thumbHovered === 'start'
|
386
|
+
? this.tooltipTemplate(this.valueLabelStart)
|
387
|
+
: nothing}
|
388
|
+
<input
|
389
|
+
id="end-slider"
|
390
|
+
part="end-slider"
|
391
|
+
type="range"
|
392
|
+
min="${this.min}"
|
393
|
+
max="${this.max}"
|
394
|
+
step="${(_e = this.step) !== null && _e !== void 0 ? _e : 1}"
|
395
|
+
.value="${String((_f = this.valueEnd) !== null && _f !== void 0 ? _f : this.max)}"
|
396
|
+
?disabled="${this.disabled}"
|
397
|
+
name="${(_g = this.nameEnd) !== null && _g !== void 0 ? _g : ''}"
|
398
|
+
aria-valuemin="${this.min}"
|
399
|
+
aria-valuemax="${this.max}"
|
400
|
+
aria-valuenow="${(_h = this.valueEnd) !== null && _h !== void 0 ? _h : this.max}"
|
401
|
+
aria-label="${this.endAriaLabel || this.label || ''}"
|
402
|
+
aria-valuetext="${this.endAriaValueText || this.valueLabelEnd || this.valueEnd || ''}"
|
403
|
+
tabindex="${this.disabled ? -1 : 0}"
|
404
|
+
@input=${() => this.handleInput(1)}
|
405
|
+
@change=${this.onChangeEnd}
|
406
|
+
@focus=${() => {
|
407
|
+
this.thumbFocused = 'end';
|
408
|
+
}}
|
409
|
+
@blur=${() => {
|
410
|
+
this.thumbFocused = undefined;
|
411
|
+
}}
|
412
|
+
@mouseenter=${() => {
|
413
|
+
if (!this.disabled)
|
414
|
+
this.thumbHovered = 'end';
|
415
|
+
}}
|
416
|
+
@mouseleave=${() => {
|
417
|
+
this.thumbHovered = undefined;
|
418
|
+
}}
|
419
|
+
/>
|
420
|
+
${this.thumbFocused === 'end' || this.thumbHovered === 'end'
|
421
|
+
? this.tooltipTemplate(this.valueLabelEnd, this.thumbFocused || this.thumbHovered)
|
422
|
+
: nothing}
|
423
|
+
`
|
424
|
+
: html `
|
425
|
+
<input
|
426
|
+
id="single-slider"
|
427
|
+
part="single-slider"
|
428
|
+
type="range"
|
429
|
+
min="${this.min}"
|
430
|
+
max="${this.max}"
|
431
|
+
step="${(_j = this.step) !== null && _j !== void 0 ? _j : 1}"
|
432
|
+
.value="${String((_k = this.value) !== null && _k !== void 0 ? _k : this.min)}"
|
433
|
+
?disabled="${this.disabled}"
|
434
|
+
name="${(_l = this.name) !== null && _l !== void 0 ? _l : ''}"
|
435
|
+
aria-valuemin="${this.min}"
|
436
|
+
aria-valuemax="${this.max}"
|
437
|
+
aria-valuenow="${(_m = this.value) !== null && _m !== void 0 ? _m : this.min}"
|
438
|
+
aria-label="${(_p = (_o = this.dataAriaLabel) !== null && _o !== void 0 ? _o : this.label) !== null && _p !== void 0 ? _p : ''}"
|
439
|
+
aria-valuetext="${(_r = (_q = this.dataAriaValuetext) !== null && _q !== void 0 ? _q : this.valueLabel) !== null && _r !== void 0 ? _r : String((_s = this.value) !== null && _s !== void 0 ? _s : '')}"
|
440
|
+
tabindex="${this.disabled ? -1 : 0}"
|
441
|
+
@input=${this.onInput}
|
442
|
+
@change=${this.onChange}
|
443
|
+
@focus=${() => {
|
444
|
+
this.thumbFocused = 'start';
|
445
|
+
}}
|
446
|
+
@blur=${() => {
|
447
|
+
this.thumbFocused = undefined;
|
448
|
+
}}
|
449
|
+
@mouseenter=${() => {
|
450
|
+
if (!this.disabled)
|
451
|
+
this.thumbHovered = 'start';
|
452
|
+
}}
|
453
|
+
@mouseleave=${() => {
|
454
|
+
this.thumbHovered = undefined;
|
455
|
+
}}
|
456
|
+
/>
|
457
|
+
${this.thumbFocused === 'start' || this.thumbHovered === 'start'
|
458
|
+
? this.tooltipTemplate(this.valueLabel)
|
459
|
+
: nothing}
|
460
|
+
`}
|
461
|
+
</div>
|
462
|
+
${this.iconTemplate(this.trailingIcon, 'trailing-icon')}
|
463
|
+
</div>
|
464
|
+
<div part="slider-labels">
|
465
|
+
${this.labelStart ? html `<span part="slider-label-start">${this.labelStart}</span>` : null}
|
466
|
+
${this.labelEnd ? html `<span part="slider-label-end">${this.labelEnd}</span>` : null}
|
467
|
+
</div>
|
468
|
+
`;
|
82
469
|
}
|
83
470
|
}
|
84
471
|
Slider.styles = [...Component.styles, ...styles];
|
85
472
|
__decorate([
|
86
|
-
|
473
|
+
state(),
|
474
|
+
__metadata("design:type", Object)
|
475
|
+
], Slider.prototype, "thumbFocused", void 0);
|
476
|
+
__decorate([
|
477
|
+
state(),
|
478
|
+
__metadata("design:type", Object)
|
479
|
+
], Slider.prototype, "thumbHovered", void 0);
|
480
|
+
__decorate([
|
481
|
+
property({ reflect: true, type: Boolean }),
|
87
482
|
__metadata("design:type", Object)
|
88
483
|
], Slider.prototype, "range", void 0);
|
89
484
|
__decorate([
|
90
|
-
property({ type:
|
485
|
+
property({ reflect: true, type: Number }),
|
486
|
+
__metadata("design:type", Number)
|
487
|
+
], Slider.prototype, "min", void 0);
|
488
|
+
__decorate([
|
489
|
+
property({ reflect: true, type: Number }),
|
490
|
+
__metadata("design:type", Number)
|
491
|
+
], Slider.prototype, "max", void 0);
|
492
|
+
__decorate([
|
493
|
+
property({ reflect: true, type: Boolean }),
|
91
494
|
__metadata("design:type", Boolean)
|
92
495
|
], Slider.prototype, "disabled", void 0);
|
93
496
|
__decorate([
|
94
|
-
property({ type: Boolean, attribute: 'soft-disabled' }),
|
497
|
+
property({ reflect: true, type: Boolean, attribute: 'soft-disabled' }),
|
95
498
|
__metadata("design:type", Boolean)
|
96
499
|
], Slider.prototype, "softDisabled", void 0);
|
97
500
|
__decorate([
|
98
|
-
property({ type: String, attribute: 'leading-icon' }),
|
501
|
+
property({ reflect: true, type: String, attribute: 'leading-icon' }),
|
99
502
|
__metadata("design:type", String)
|
100
503
|
], Slider.prototype, "leadingIcon", void 0);
|
101
504
|
__decorate([
|
102
|
-
property({ type: String, attribute: 'trailing-icon' }),
|
505
|
+
property({ reflect: true, type: String, attribute: 'trailing-icon' }),
|
103
506
|
__metadata("design:type", String)
|
104
507
|
], Slider.prototype, "trailingIcon", void 0);
|
105
508
|
__decorate([
|
106
|
-
property({ type: Number }),
|
107
|
-
__metadata("design:type", Object)
|
108
|
-
], Slider.prototype, "min", void 0);
|
109
|
-
__decorate([
|
110
|
-
property({ type: Number }),
|
111
|
-
__metadata("design:type", Object)
|
112
|
-
], Slider.prototype, "max", void 0);
|
113
|
-
__decorate([
|
114
|
-
property({ type: Number }),
|
509
|
+
property({ reflect: true, type: Number }),
|
115
510
|
__metadata("design:type", Number)
|
116
511
|
], Slider.prototype, "value", void 0);
|
117
512
|
__decorate([
|
118
|
-
property({ type: Number, attribute: 'value-start' }),
|
513
|
+
property({ reflect: true, type: Number, attribute: 'value-start' }),
|
119
514
|
__metadata("design:type", Number)
|
120
515
|
], Slider.prototype, "valueStart", void 0);
|
121
516
|
__decorate([
|
122
|
-
property({ type: Number, attribute: 'value-end' }),
|
517
|
+
property({ reflect: true, type: Number, attribute: 'value-end' }),
|
123
518
|
__metadata("design:type", Number)
|
124
519
|
], Slider.prototype, "valueEnd", void 0);
|
125
520
|
__decorate([
|
126
|
-
property({ type: Number }),
|
127
|
-
__metadata("design:type",
|
521
|
+
property({ reflect: true, type: Number }),
|
522
|
+
__metadata("design:type", Number)
|
128
523
|
], Slider.prototype, "step", void 0);
|
129
524
|
__decorate([
|
130
|
-
property({ type: String }),
|
525
|
+
property({ reflect: true, type: String }),
|
131
526
|
__metadata("design:type", String)
|
132
527
|
], Slider.prototype, "label", void 0);
|
133
528
|
__decorate([
|
134
|
-
property({ type: String, attribute: 'label-start' }),
|
529
|
+
property({ reflect: true, type: String, attribute: 'label-start' }),
|
135
530
|
__metadata("design:type", String)
|
136
531
|
], Slider.prototype, "labelStart", void 0);
|
137
532
|
__decorate([
|
138
|
-
property({ type: String, attribute: 'label-end' }),
|
533
|
+
property({ reflect: true, type: String, attribute: 'label-end' }),
|
139
534
|
__metadata("design:type", String)
|
140
535
|
], Slider.prototype, "labelEnd", void 0);
|
141
536
|
__decorate([
|
142
|
-
property({ type: String, attribute: 'value-label' }),
|
537
|
+
property({ reflect: true, type: String, attribute: 'value-label' }),
|
143
538
|
__metadata("design:type", String)
|
144
539
|
], Slider.prototype, "valueLabel", void 0);
|
145
540
|
__decorate([
|
146
|
-
property({ type: String, attribute: 'value-label-start' }),
|
541
|
+
property({ reflect: true, type: String, attribute: 'value-label-start' }),
|
147
542
|
__metadata("design:type", String)
|
148
543
|
], Slider.prototype, "valueLabelStart", void 0);
|
149
544
|
__decorate([
|
150
|
-
property({ type: String, attribute: 'value-label-end' }),
|
545
|
+
property({ reflect: true, type: String, attribute: 'value-label-end' }),
|
151
546
|
__metadata("design:type", String)
|
152
547
|
], Slider.prototype, "valueLabelEnd", void 0);
|
153
548
|
__decorate([
|
154
|
-
property({
|
549
|
+
property({ reflect: true, type: String }),
|
155
550
|
__metadata("design:type", String)
|
156
|
-
], Slider.prototype, "
|
551
|
+
], Slider.prototype, "name", void 0);
|
157
552
|
__decorate([
|
158
|
-
property({ type: String, attribute: '
|
553
|
+
property({ reflect: true, type: String, attribute: 'name-start' }),
|
159
554
|
__metadata("design:type", String)
|
160
|
-
], Slider.prototype, "
|
555
|
+
], Slider.prototype, "nameStart", void 0);
|
161
556
|
__decorate([
|
162
|
-
property({ type: String, attribute: '
|
557
|
+
property({ reflect: true, type: String, attribute: 'name-end' }),
|
163
558
|
__metadata("design:type", String)
|
164
|
-
], Slider.prototype, "
|
559
|
+
], Slider.prototype, "nameEnd", void 0);
|
165
560
|
__decorate([
|
166
|
-
property({ type: String, attribute: 'aria-
|
561
|
+
property({ reflect: true, type: String, attribute: 'data-aria-label' }),
|
167
562
|
__metadata("design:type", String)
|
168
|
-
], Slider.prototype, "
|
563
|
+
], Slider.prototype, "dataAriaLabel", void 0);
|
169
564
|
__decorate([
|
170
|
-
property({ type: String }),
|
565
|
+
property({ reflect: true, type: String, attribute: 'start-aria-label' }),
|
171
566
|
__metadata("design:type", String)
|
172
|
-
], Slider.prototype, "
|
567
|
+
], Slider.prototype, "startAriaLabel", void 0);
|
173
568
|
__decorate([
|
174
|
-
property({ type: String, attribute: '
|
569
|
+
property({ reflect: true, type: String, attribute: 'end-aria-label' }),
|
175
570
|
__metadata("design:type", String)
|
176
|
-
], Slider.prototype, "
|
571
|
+
], Slider.prototype, "endAriaLabel", void 0);
|
177
572
|
__decorate([
|
178
|
-
property({ type: String, attribute: '
|
573
|
+
property({ reflect: true, type: String, attribute: 'data-aria-valuetext' }),
|
179
574
|
__metadata("design:type", String)
|
180
|
-
], Slider.prototype, "
|
575
|
+
], Slider.prototype, "dataAriaValuetext", void 0);
|
181
576
|
__decorate([
|
182
|
-
property({ type: String, attribute: '
|
577
|
+
property({ reflect: true, type: String, attribute: 'start-aria-valuetext' }),
|
183
578
|
__metadata("design:type", String)
|
184
|
-
], Slider.prototype, "
|
579
|
+
], Slider.prototype, "startAriaValuetext", void 0);
|
185
580
|
__decorate([
|
186
|
-
property({ type: String, attribute: '
|
581
|
+
property({ reflect: true, type: String, attribute: 'end-aria-valuetext' }),
|
187
582
|
__metadata("design:type", String)
|
188
|
-
], Slider.prototype, "
|
583
|
+
], Slider.prototype, "endAriaValueText", void 0);
|
584
|
+
__decorate([
|
585
|
+
queryAll('input[type="range"]'),
|
586
|
+
__metadata("design:type", Array)
|
587
|
+
], Slider.prototype, "inputElements", void 0);
|
189
588
|
export default Slider;
|