@vonage/vivid 4.10.0 → 4.11.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/custom-elements.json +9103 -6572
- package/lib/badge/badge.d.ts +1 -1
- package/lib/breadcrumb-item/breadcrumb-item.d.ts +1 -1
- package/lib/button/button.d.ts +1 -1
- package/lib/checkbox/checkbox.d.ts +5 -3
- package/lib/checkbox/checkbox.form-associated.d.ts +10 -0
- package/lib/enums.d.ts +1 -0
- package/lib/fab/fab.d.ts +1 -1
- package/lib/file-picker/file-picker.d.ts +3 -0
- package/lib/slider/slider.d.ts +30 -6
- package/lib/slider/slider.form-associated.d.ts +10 -0
- package/lib/split-button/split-button.d.ts +1 -1
- package/lib/tabs/tabs.d.ts +1 -0
- package/package.json +1 -1
- package/shared/aria-global2.cjs +93 -0
- package/shared/aria-global2.js +91 -0
- package/shared/breadcrumb-item.cjs +2 -89
- package/shared/breadcrumb-item.js +1 -88
- package/shared/definition11.cjs +200 -4
- package/shared/definition11.js +198 -3
- package/shared/definition15.cjs +34 -91
- package/shared/definition15.js +35 -92
- package/shared/definition16.cjs +9 -7
- package/shared/definition16.js +9 -7
- package/shared/definition20.cjs +1 -1
- package/shared/definition20.js +1 -1
- package/shared/definition21.cjs +1 -1
- package/shared/definition21.js +1 -1
- package/shared/definition24.cjs +156 -2
- package/shared/definition24.js +157 -3
- package/shared/definition25.cjs +106 -56
- package/shared/definition25.js +106 -56
- package/shared/definition35.cjs +2 -2
- package/shared/definition35.js +2 -2
- package/shared/definition37.cjs +1 -1
- package/shared/definition37.js +1 -1
- package/shared/definition4.cjs +5 -6
- package/shared/definition4.js +1 -2
- package/shared/definition40.cjs +11 -4
- package/shared/definition40.js +8 -1
- package/shared/definition42.cjs +3 -22
- package/shared/definition42.js +2 -21
- package/shared/definition43.cjs +1 -2
- package/shared/definition43.js +1 -2
- package/shared/definition44.js +1 -1
- package/shared/definition47.cjs +369 -502
- package/shared/definition47.js +370 -503
- package/shared/definition5.cjs +4 -4
- package/shared/definition5.js +1 -1
- package/shared/definition51.cjs +1 -1
- package/shared/definition51.js +1 -1
- package/shared/definition52.cjs +63 -26
- package/shared/definition52.js +63 -26
- package/shared/definition56.cjs +41 -43
- package/shared/definition56.js +41 -43
- package/shared/definition57.cjs +1 -1
- package/shared/definition57.js +1 -1
- package/shared/definition64.cjs +242 -79
- package/shared/definition64.js +242 -79
- package/shared/definition7.cjs +1 -1
- package/shared/definition7.js +1 -1
- package/shared/definition8.cjs +1 -1
- package/shared/definition8.js +1 -1
- package/shared/enums.cjs +1 -0
- package/shared/enums.js +1 -0
- package/shared/form-associated.js +1 -1
- package/shared/{patterns → foundation/anchor}/anchor.d.ts +1 -1
- package/shared/foundation/button/button.d.ts +27 -0
- package/shared/foundation/button/button.template.d.ts +4 -0
- package/shared/foundation/button/index.d.ts +2 -0
- package/shared/foundation/patterns/index.d.ts +1 -0
- package/shared/index.cjs +22 -2
- package/shared/index.js +22 -2
- package/shared/key-codes2.js +1 -1
- package/shared/presentationDate.cjs +4328 -4042
- package/shared/presentationDate.js +4327 -4041
- package/shared/slider.template.cjs +23 -1
- package/shared/slider.template.js +21 -2
- package/styles/core/all.css +1 -1
- package/styles/core/theme.css +1 -1
- package/styles/core/typography.css +1 -1
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/styles/tokens/vivid-2-compat.css +1 -1
- package/vivid.api.json +52 -4
- package/shared/aria2.cjs +0 -11
- package/shared/aria2.js +0 -9
- package/shared/button.cjs +0 -202
- package/shared/button.js +0 -200
- /package/shared/{patterns → foundation/patterns}/aria-global.d.ts +0 -0
package/shared/definition47.js
CHANGED
|
@@ -1,506 +1,205 @@
|
|
|
1
|
-
import { F as FoundationElement,
|
|
1
|
+
import { F as FoundationElement, a as attr, o as observable, n as nullableNumberConverter, v as volatile, r as registerFactory } from './index.js';
|
|
2
2
|
import { p as popupRegistries } from './definition64.js';
|
|
3
|
-
import {
|
|
4
|
-
import { l as limit } from './
|
|
3
|
+
import { c as keyHome, d as keyEnd, e as keyArrowDown, k as keyArrowLeft, f as keyArrowUp, a as keyArrowRight } from './key-codes2.js';
|
|
4
|
+
import { i as inverseLerp, l as lerp, a as limit, r as roundToStepValue, S as SliderTemplate } from './slider.template.js';
|
|
5
5
|
import { F as FormAssociated } from './form-associated.js';
|
|
6
|
-
import { O as Orientation } from './
|
|
7
|
-
import { g as
|
|
8
|
-
import { l as limit$1, S as SliderTemplate } from './slider.template.js';
|
|
6
|
+
import { O as Orientation } from './aria.js';
|
|
7
|
+
import { g as getDirection } from './direction.js';
|
|
9
8
|
import { a as applyMixins } from './apply-mixins.js';
|
|
10
9
|
import { L as Localized } from './localized.js';
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
|
-
*
|
|
12
|
+
* Expose ltr and rtl strings
|
|
14
13
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
14
|
+
var Direction;
|
|
15
|
+
(function (Direction) {
|
|
16
|
+
Direction["ltr"] = "ltr";
|
|
17
|
+
Direction["rtl"] = "rtl";
|
|
18
|
+
})(Direction || (Direction = {}));
|
|
19
|
+
|
|
20
|
+
const styles = ":host{display:inline-block}:host(:not([orientation=vertical])){inline-size:100%}:host([orientation=vertical]){block-size:100%;min-block-size:calc(var(--_thumb-interaction-indicator-size) * 5)}:host([disabled]){cursor:not-allowed}.control.connotation-cta{--_connotation-color-primary: var(--vvd-slider-cta-primary, var(--vvd-color-cta-500))}.control:not(.connotation-cta){--_connotation-color-primary: var(--vvd-slider-accent-primary, var(--vvd-color-canvas-text))}.control{--_appearance-color-text: var(--_connotation-color-primary-text);--_appearance-color-fill: var(--_connotation-color-primary);--_appearance-color-outline: transparent}.control{--_thumb-size: 12px;--_thumb-interaction-indicator-size: 36px;--_track-start-inset-inline-start: 0;--_track-start-inset-block-start: 0;cursor:pointer;outline:none;user-select:none}.control .positioning-region{position:relative}.control .track{position:absolute;border-radius:4px;background:var(--_track-background-color)}.control .track-start{position:absolute;border-radius:inherit;background:var(--_track-start-background-color);block-size:100%;inset-inline-start:var(--_track-start-inset-inline-start)}.control.horizontal{block-size:var(--_thumb-interaction-indicator-size);inline-size:calc(100% - var(--_thumb-size));margin-inline-start:calc(var(--_thumb-size) / 2);min-inline-size:var(--_thumb-size)}.control.horizontal .track{top:calc((var(--_thumb-interaction-indicator-size) - 2px) / 2);right:0;left:0;block-size:2px}:host([markers]) .control.horizontal .track-start{--_track-start-inset-inline-start: 1px;border-bottom-left-radius:0;border-top-left-radius:0}.control.horizontal .track .mark{position:absolute;block-size:6px;inline-size:100%;inset-block-start:-2px;inset-inline-start:0}.control.vertical{margin-top:calc(var(--_thumb-interaction-indicator-size) / 2);block-size:calc(100% - var(--_thumb-interaction-indicator-size));inline-size:var(--_thumb-interaction-indicator-size);min-block-size:var(--_thumb-interaction-indicator-size)}.control.vertical .positioning-region{block-size:100%}.control.vertical .track{left:calc((var(--_thumb-interaction-indicator-size) - 2px) / 2);block-size:100%;inline-size:2px}.control.vertical .track .mark{position:absolute;block-size:100%;inline-size:6px;inset-block-start:0;inset-inline-start:-2px}.control.vertical .track-start{block-size:auto;inline-size:100%;inset-block-start:var(--_track-start-inset-block-start)}:host([markers]) .control.vertical .track-start{--_track-start-inset-block-start: 1px;border-radius:0}.control.disabled{--_track-background-color: var(--vvd-color-neutral-100);--_track-start-background-color: var(--vvd-color-neutral-300);pointer-events:none}.control:not(.disabled){--_track-background-color: var(--vvd-color-neutral-300);--_track-start-background-color: var(--_appearance-color-fill)}.control:not(.disabled) .mark{color:var(--vvd-color-neutral-950)}.control.disabled .mark{color:var(--_track-start-background-color)}.thumb-container{position:absolute;border-radius:50%;block-size:var(--_thumb-interaction-indicator-size);cursor:inherit;inline-size:var(--_thumb-interaction-indicator-size);outline:none;touch-action:none}.thumb-container.focus-visible{box-shadow:inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));outline-offset:calc(-2px - var(--focus-inset, 0px));--focus-stroke-gap-color: transparent;--_thumb-interaction-indicator-alpha: .05;border-radius:50%}.control.horizontal .thumb-container{transform:translate(calc(var(--_thumb-interaction-indicator-size) / 2))}.control.vertical .thumb-container{transform:translateY(calc(var(--_thumb-interaction-indicator-size) / 2))}.control:not(.disabled) .thumb-container:hover{--_thumb-interaction-indicator-alpha: .12}.control:not(.disabled) .thumb-container:active{--_thumb-interaction-indicator-alpha: .25}.thumb-container:before{position:absolute;display:block;border-radius:inherit;background-color:var(--_track-start-background-color);block-size:var(--_thumb-interaction-indicator-size);content:\"\";inline-size:var(--_thumb-interaction-indicator-size);opacity:var(--_thumb-interaction-indicator-alpha, 0);transition:opacity .2s ease-out 0s}.thumb-container:after{position:absolute;display:block;border-radius:inherit;background-color:var(--_track-start-background-color);block-size:var(--_thumb-size);content:\"\";inline-size:var(--_thumb-size);inset:calc((var(--_thumb-interaction-indicator-size) - var(--_thumb-size)) / 2)}.popup{pointer-events:none}.tooltip{width:auto;padding:8px 12px;color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base-bold)}";
|
|
22
21
|
|
|
23
22
|
class _Slider extends FoundationElement {
|
|
24
23
|
}
|
|
25
|
-
/**
|
|
26
|
-
* A form-associated base class for the {@link @microsoft/fast-foundation#(Slider:class)} component.
|
|
27
|
-
*
|
|
28
|
-
* @internal
|
|
29
|
-
*/
|
|
30
24
|
class FormAssociatedSlider extends FormAssociated(_Slider) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
constructor() {
|
|
26
|
+
super(...arguments);
|
|
27
|
+
this.proxy = document.createElement("input");
|
|
28
|
+
}
|
|
35
29
|
}
|
|
36
30
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
var __defProp = Object.defineProperty;
|
|
32
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
33
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
34
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
35
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
36
|
+
if (decorator = decorators[i])
|
|
37
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
38
|
+
if (kind && result) __defProp(target, key, result);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
41
|
const SliderMode = {
|
|
42
|
-
|
|
42
|
+
singleValue: "single-value"
|
|
43
43
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
this.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* @internal
|
|
89
|
-
*/
|
|
90
|
-
this.trackMinHeight = 0;
|
|
91
|
-
/**
|
|
92
|
-
* Custom function that generates a string for the component's "aria-valuetext" attribute based on the current value.
|
|
93
|
-
*
|
|
94
|
-
* @public
|
|
95
|
-
*/
|
|
96
|
-
this.valueTextFormatter = () => null;
|
|
97
|
-
/**
|
|
98
|
-
* The minimum allowed value.
|
|
99
|
-
*
|
|
100
|
-
* @defaultValue - 0
|
|
101
|
-
* @public
|
|
102
|
-
* @remarks
|
|
103
|
-
* HTML Attribute: min
|
|
104
|
-
*/
|
|
105
|
-
this.min = 0; // Map to proxy element.
|
|
106
|
-
/**
|
|
107
|
-
* The maximum allowed value.
|
|
108
|
-
*
|
|
109
|
-
* @defaultValue - 10
|
|
110
|
-
* @public
|
|
111
|
-
* @remarks
|
|
112
|
-
* HTML Attribute: max
|
|
113
|
-
*/
|
|
114
|
-
this.max = 10; // Map to proxy element.
|
|
115
|
-
/**
|
|
116
|
-
* Value to increment or decrement via arrow keys, mouse click or drag.
|
|
117
|
-
*
|
|
118
|
-
* @public
|
|
119
|
-
* @remarks
|
|
120
|
-
* HTML Attribute: step
|
|
121
|
-
*/
|
|
122
|
-
this.step = 1; // Map to proxy element.
|
|
123
|
-
/**
|
|
124
|
-
* The orientation of the slider.
|
|
125
|
-
*
|
|
126
|
-
* @public
|
|
127
|
-
* @remarks
|
|
128
|
-
* HTML Attribute: orientation
|
|
129
|
-
*/
|
|
130
|
-
this.orientation = Orientation.horizontal;
|
|
131
|
-
/**
|
|
132
|
-
* The selection mode.
|
|
133
|
-
*
|
|
134
|
-
* @public
|
|
135
|
-
* @remarks
|
|
136
|
-
* HTML Attribute: mode
|
|
137
|
-
*/
|
|
138
|
-
this.mode = SliderMode.singleValue;
|
|
139
|
-
this.keypressHandler = (e) => {
|
|
140
|
-
if (this.readOnly) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
if (e.key === keyHome) {
|
|
144
|
-
e.preventDefault();
|
|
145
|
-
this.value = `${this.min}`;
|
|
146
|
-
}
|
|
147
|
-
else if (e.key === keyEnd) {
|
|
148
|
-
e.preventDefault();
|
|
149
|
-
this.value = `${this.max}`;
|
|
150
|
-
}
|
|
151
|
-
else if (!e.shiftKey) {
|
|
152
|
-
switch (e.key) {
|
|
153
|
-
case keyArrowRight:
|
|
154
|
-
case keyArrowUp:
|
|
155
|
-
e.preventDefault();
|
|
156
|
-
this.increment();
|
|
157
|
-
break;
|
|
158
|
-
case keyArrowLeft:
|
|
159
|
-
case keyArrowDown:
|
|
160
|
-
e.preventDefault();
|
|
161
|
-
this.decrement();
|
|
162
|
-
break;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
this.setupTrackConstraints = () => {
|
|
167
|
-
const clientRect = this.track.getBoundingClientRect();
|
|
168
|
-
this.trackWidth = this.track.clientWidth;
|
|
169
|
-
this.trackMinWidth = this.track.clientLeft;
|
|
170
|
-
this.trackHeight = clientRect.bottom;
|
|
171
|
-
this.trackMinHeight = clientRect.top;
|
|
172
|
-
this.trackLeft = this.getBoundingClientRect().left;
|
|
173
|
-
if (this.trackWidth === 0) {
|
|
174
|
-
this.trackWidth = 1;
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
this.setupListeners = (remove = false) => {
|
|
178
|
-
const eventAction = `${remove ? "remove" : "add"}EventListener`;
|
|
179
|
-
this[eventAction]("keydown", this.keypressHandler);
|
|
180
|
-
this[eventAction]("mousedown", this.handleMouseDown);
|
|
181
|
-
this.thumb[eventAction]("mousedown", this.handleThumbMouseDown, {
|
|
182
|
-
passive: true,
|
|
183
|
-
});
|
|
184
|
-
this.thumb[eventAction]("touchstart", this.handleThumbMouseDown, {
|
|
185
|
-
passive: true,
|
|
186
|
-
});
|
|
187
|
-
// removes handlers attached by mousedown handlers
|
|
188
|
-
if (remove) {
|
|
189
|
-
this.handleMouseDown(null);
|
|
190
|
-
this.handleThumbMouseDown(null);
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
/**
|
|
194
|
-
* @internal
|
|
195
|
-
*/
|
|
196
|
-
this.initialValue = "";
|
|
197
|
-
/**
|
|
198
|
-
* Handle mouse moves during a thumb drag operation
|
|
199
|
-
* If the event handler is null it removes the events
|
|
200
|
-
*/
|
|
201
|
-
this.handleThumbMouseDown = (event) => {
|
|
202
|
-
if (event) {
|
|
203
|
-
if (this.readOnly || this.disabled || event.defaultPrevented) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
event.target.focus();
|
|
207
|
-
}
|
|
208
|
-
const eventAction = `${event !== null ? "add" : "remove"}EventListener`;
|
|
209
|
-
window[eventAction]("mouseup", this.handleWindowMouseUp);
|
|
210
|
-
window[eventAction]("mousemove", this.handleMouseMove, { passive: true });
|
|
211
|
-
window[eventAction]("touchmove", this.handleMouseMove, { passive: true });
|
|
212
|
-
window[eventAction]("touchend", this.handleWindowMouseUp);
|
|
213
|
-
this.isDragging = event !== null;
|
|
214
|
-
};
|
|
215
|
-
/**
|
|
216
|
-
* Handle mouse moves during a thumb drag operation
|
|
217
|
-
*/
|
|
218
|
-
this.handleMouseMove = (e) => {
|
|
219
|
-
if (this.readOnly || this.disabled || e.defaultPrevented) {
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
// update the value based on current position
|
|
223
|
-
const sourceEvent = window.TouchEvent && e instanceof TouchEvent
|
|
224
|
-
? e.touches[0]
|
|
225
|
-
: e;
|
|
226
|
-
const eventValue = this.orientation === Orientation.horizontal
|
|
227
|
-
? sourceEvent.pageX - document.documentElement.scrollLeft - this.trackLeft
|
|
228
|
-
: sourceEvent.pageY - document.documentElement.scrollTop;
|
|
229
|
-
this.value = `${this.calculateNewValue(eventValue)}`;
|
|
230
|
-
};
|
|
231
|
-
this.calculateNewValue = (rawValue) => {
|
|
232
|
-
// update the value based on current position
|
|
233
|
-
const newPosition = convertPixelToPercent(rawValue, this.orientation === Orientation.horizontal
|
|
234
|
-
? this.trackMinWidth
|
|
235
|
-
: this.trackMinHeight, this.orientation === Orientation.horizontal
|
|
236
|
-
? this.trackWidth
|
|
237
|
-
: this.trackHeight, this.direction);
|
|
238
|
-
const newValue = (this.max - this.min) * newPosition + this.min;
|
|
239
|
-
return this.convertToConstrainedValue(newValue);
|
|
240
|
-
};
|
|
241
|
-
/**
|
|
242
|
-
* Handle a window mouse up during a drag operation
|
|
243
|
-
*/
|
|
244
|
-
this.handleWindowMouseUp = (event) => {
|
|
245
|
-
this.stopDragging();
|
|
246
|
-
};
|
|
247
|
-
this.stopDragging = () => {
|
|
248
|
-
this.isDragging = false;
|
|
249
|
-
this.handleMouseDown(null);
|
|
250
|
-
this.handleThumbMouseDown(null);
|
|
251
|
-
};
|
|
252
|
-
/**
|
|
253
|
-
*
|
|
254
|
-
* @param e - MouseEvent or null. If there is no event handler it will remove the events
|
|
255
|
-
*/
|
|
256
|
-
this.handleMouseDown = (e) => {
|
|
257
|
-
const eventAction = `${e !== null ? "add" : "remove"}EventListener`;
|
|
258
|
-
if (e === null || (!this.disabled && !this.readOnly)) {
|
|
259
|
-
window[eventAction]("mouseup", this.handleWindowMouseUp);
|
|
260
|
-
window.document[eventAction]("mouseleave", this.handleWindowMouseUp);
|
|
261
|
-
window[eventAction]("mousemove", this.handleMouseMove);
|
|
262
|
-
if (e) {
|
|
263
|
-
e.preventDefault();
|
|
264
|
-
this.setupTrackConstraints();
|
|
265
|
-
e.target.focus();
|
|
266
|
-
const controlValue = this.orientation === Orientation.horizontal
|
|
267
|
-
? e.pageX - document.documentElement.scrollLeft - this.trackLeft
|
|
268
|
-
: e.pageY - document.documentElement.scrollTop;
|
|
269
|
-
this.value = `${this.calculateNewValue(controlValue)}`;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
this.convertToConstrainedValue = (value) => {
|
|
274
|
-
if (isNaN(value)) {
|
|
275
|
-
value = this.min;
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* The following logic intends to overcome the issue with math in JavaScript with regards to floating point numbers.
|
|
279
|
-
* This is needed as the `step` may be an integer but could also be a float. To accomplish this the step is assumed to be a float
|
|
280
|
-
* and is converted to an integer by determining the number of decimal places it represent, multiplying it until it is an
|
|
281
|
-
* integer and then dividing it to get back to the correct number.
|
|
282
|
-
*/
|
|
283
|
-
let constrainedValue = value - this.min;
|
|
284
|
-
const roundedConstrainedValue = Math.round(constrainedValue / this.step);
|
|
285
|
-
const remainderValue = constrainedValue -
|
|
286
|
-
(roundedConstrainedValue * (this.stepMultiplier * this.step)) /
|
|
287
|
-
this.stepMultiplier;
|
|
288
|
-
constrainedValue =
|
|
289
|
-
remainderValue >= Number(this.step) / 2
|
|
290
|
-
? constrainedValue - remainderValue + Number(this.step)
|
|
291
|
-
: constrainedValue - remainderValue;
|
|
292
|
-
return constrainedValue + this.min;
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
readOnlyChanged() {
|
|
296
|
-
if (this.proxy instanceof HTMLInputElement) {
|
|
297
|
-
this.proxy.readOnly = this.readOnly;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* The value property, typed as a number.
|
|
302
|
-
*
|
|
303
|
-
* @public
|
|
304
|
-
*/
|
|
305
|
-
get valueAsNumber() {
|
|
306
|
-
return parseFloat(super.value);
|
|
307
|
-
}
|
|
308
|
-
set valueAsNumber(next) {
|
|
309
|
-
this.value = next.toString();
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* @internal
|
|
313
|
-
*/
|
|
314
|
-
valueChanged(previous, next) {
|
|
315
|
-
super.valueChanged(previous, next);
|
|
316
|
-
if (this.$fastController.isConnected) {
|
|
317
|
-
this.setThumbPositionForOrientation(this.direction);
|
|
318
|
-
}
|
|
319
|
-
this.$emit("change");
|
|
320
|
-
}
|
|
321
|
-
minChanged() {
|
|
322
|
-
if (this.proxy instanceof HTMLInputElement) {
|
|
323
|
-
this.proxy.min = `${this.min}`;
|
|
324
|
-
}
|
|
325
|
-
this.validate();
|
|
326
|
-
}
|
|
327
|
-
maxChanged() {
|
|
328
|
-
if (this.proxy instanceof HTMLInputElement) {
|
|
329
|
-
this.proxy.max = `${this.max}`;
|
|
44
|
+
class Slider extends FormAssociatedSlider {
|
|
45
|
+
constructor() {
|
|
46
|
+
super(...arguments);
|
|
47
|
+
this.direction = Direction.ltr;
|
|
48
|
+
this.isDragging = false;
|
|
49
|
+
this.trackWidth = 0;
|
|
50
|
+
this.trackMinWidth = 0;
|
|
51
|
+
this.trackHeight = 0;
|
|
52
|
+
this.trackLeft = 0;
|
|
53
|
+
this.trackMinHeight = 0;
|
|
54
|
+
this.valueTextFormatter = (value) => parseFloat(value).toLocaleString(this.locale.lang);
|
|
55
|
+
// eslint-disable-next-line @nrwl/nx/workspace/no-attribute-default-value
|
|
56
|
+
this.min = 0;
|
|
57
|
+
// eslint-disable-next-line @nrwl/nx/workspace/no-attribute-default-value
|
|
58
|
+
this.max = 10;
|
|
59
|
+
// eslint-disable-next-line @nrwl/nx/workspace/no-attribute-default-value
|
|
60
|
+
this.step = 1;
|
|
61
|
+
// eslint-disable-next-line @nrwl/nx/workspace/no-attribute-default-value
|
|
62
|
+
this.orientation = Orientation.horizontal;
|
|
63
|
+
this.mode = SliderMode.singleValue;
|
|
64
|
+
this.keypressHandler = (e) => {
|
|
65
|
+
this._focusVisible = true;
|
|
66
|
+
if (this.readOnly) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (e.key === keyHome) {
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
this.value = `${this.min}`;
|
|
72
|
+
} else if (e.key === keyEnd) {
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
this.value = `${this.max}`;
|
|
75
|
+
} else if (!e.shiftKey) {
|
|
76
|
+
switch (e.key) {
|
|
77
|
+
case keyArrowRight:
|
|
78
|
+
case keyArrowUp:
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
this.increment();
|
|
81
|
+
break;
|
|
82
|
+
case keyArrowLeft:
|
|
83
|
+
case keyArrowDown:
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
this.decrement();
|
|
86
|
+
break;
|
|
330
87
|
}
|
|
331
|
-
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
this.setupTrackConstraints = () => {
|
|
91
|
+
const clientRect = this.track.getBoundingClientRect();
|
|
92
|
+
this.trackWidth = this.track.clientWidth;
|
|
93
|
+
this.trackMinWidth = this.track.clientLeft;
|
|
94
|
+
this.trackHeight = clientRect.bottom;
|
|
95
|
+
this.trackMinHeight = clientRect.top;
|
|
96
|
+
this.trackLeft = this.getBoundingClientRect().left;
|
|
97
|
+
if (this.trackWidth === 0) {
|
|
98
|
+
this.trackWidth = 1;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
this.setupListeners = (remove = false) => {
|
|
102
|
+
const eventAction = remove ? "removeEventListener" : "addEventListener";
|
|
103
|
+
this[eventAction]("keydown", this.keypressHandler);
|
|
104
|
+
this[eventAction]("mousedown", this.handleMouseDown);
|
|
105
|
+
this.thumb[eventAction](
|
|
106
|
+
"mousedown",
|
|
107
|
+
this.handleThumbMouseDown,
|
|
108
|
+
{
|
|
109
|
+
passive: true
|
|
336
110
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
111
|
+
);
|
|
112
|
+
this.thumb[eventAction](
|
|
113
|
+
"touchstart",
|
|
114
|
+
this.handleThumbMouseDown,
|
|
115
|
+
{
|
|
116
|
+
passive: true
|
|
343
117
|
}
|
|
344
|
-
|
|
118
|
+
);
|
|
119
|
+
if (remove) {
|
|
120
|
+
this.handleMouseDown(null);
|
|
121
|
+
this.handleThumbMouseDown(null);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
345
124
|
/**
|
|
346
125
|
* @internal
|
|
347
126
|
*/
|
|
348
|
-
|
|
349
|
-
super.connectedCallback();
|
|
350
|
-
this.proxy.setAttribute("type", "range");
|
|
351
|
-
this.direction = getDirection(this);
|
|
352
|
-
this.updateStepMultiplier();
|
|
353
|
-
this.setupTrackConstraints();
|
|
354
|
-
this.setupListeners();
|
|
355
|
-
this.setupDefaultValue();
|
|
356
|
-
this.setThumbPositionForOrientation(this.direction);
|
|
357
|
-
}
|
|
127
|
+
this.initialValue = "";
|
|
358
128
|
/**
|
|
359
|
-
*
|
|
129
|
+
* Handle mouse moves during a thumb drag operation
|
|
130
|
+
* If the event handler is null it removes the events
|
|
360
131
|
*/
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
132
|
+
this.handleThumbMouseDown = (event) => {
|
|
133
|
+
if (event) {
|
|
134
|
+
if (this.readOnly || this.disabled || event.defaultPrevented) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
this.#isNonVisibleFocus = true;
|
|
138
|
+
event.target.focus();
|
|
139
|
+
this.#isNonVisibleFocus = false;
|
|
140
|
+
}
|
|
141
|
+
const eventAction = event !== null ? "addEventListener" : "removeEventListener";
|
|
142
|
+
window[eventAction]("mouseup", this.handleWindowMouseUp);
|
|
143
|
+
window[eventAction]("mousemove", this.handleMouseMove, {
|
|
144
|
+
passive: true
|
|
145
|
+
});
|
|
146
|
+
window[eventAction]("touchmove", this.handleMouseMove, {
|
|
147
|
+
passive: true
|
|
148
|
+
});
|
|
149
|
+
window[eventAction]("touchend", this.handleWindowMouseUp);
|
|
150
|
+
this.isDragging = event !== null;
|
|
151
|
+
};
|
|
364
152
|
/**
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
* @public
|
|
153
|
+
* Handle mouse moves during a thumb drag operation
|
|
368
154
|
*/
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
}
|
|
155
|
+
this.handleMouseMove = (e) => {
|
|
156
|
+
if (this.readOnly || this.disabled || e.defaultPrevented) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const sourceEvent = "TouchEvent" in window && e instanceof TouchEvent ? e.touches[0] : e;
|
|
160
|
+
const value = this.#calculateValueFromMouseEvent(sourceEvent);
|
|
161
|
+
this.value = `${this.#roundToNearestStep(value)}`;
|
|
162
|
+
};
|
|
377
163
|
/**
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
* @public
|
|
164
|
+
* Handle a window mouse up during a drag operation
|
|
381
165
|
*/
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}
|
|
166
|
+
this.handleWindowMouseUp = (_) => {
|
|
167
|
+
this.stopDragging();
|
|
168
|
+
};
|
|
169
|
+
this.stopDragging = () => {
|
|
170
|
+
this.isDragging = false;
|
|
171
|
+
this.handleMouseDown(null);
|
|
172
|
+
this.handleThumbMouseDown(null);
|
|
173
|
+
};
|
|
390
174
|
/**
|
|
391
|
-
* Places the thumb based on the current value
|
|
392
175
|
*
|
|
393
|
-
* @
|
|
394
|
-
* @param direction - writing mode
|
|
176
|
+
* @param e - MouseEvent or null. If there is no event handler it will remove the events
|
|
395
177
|
*/
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
updateStepMultiplier() {
|
|
415
|
-
const stepString = this.step + "";
|
|
416
|
-
const decimalPlacesOfStep = !!(this.step % 1)
|
|
417
|
-
? stepString.length - stepString.indexOf(".") - 1
|
|
418
|
-
: 0;
|
|
419
|
-
this.stepMultiplier = Math.pow(10, decimalPlacesOfStep);
|
|
420
|
-
}
|
|
421
|
-
get midpoint() {
|
|
422
|
-
return `${this.convertToConstrainedValue((this.max + this.min) / 2)}`;
|
|
423
|
-
}
|
|
424
|
-
setupDefaultValue() {
|
|
425
|
-
if (typeof this.value === "string") {
|
|
426
|
-
if (this.value.length === 0) {
|
|
427
|
-
this.initialValue = this.midpoint;
|
|
428
|
-
}
|
|
429
|
-
else {
|
|
430
|
-
const value = parseFloat(this.value);
|
|
431
|
-
if (!Number.isNaN(value) && (value < this.min || value > this.max)) {
|
|
432
|
-
this.value = this.midpoint;
|
|
433
|
-
}
|
|
434
|
-
}
|
|
178
|
+
this.handleMouseDown = (e) => {
|
|
179
|
+
const eventAction = e !== null ? "addEventListener" : "removeEventListener";
|
|
180
|
+
if (e === null || !this.disabled && !this.readOnly) {
|
|
181
|
+
window[eventAction]("mouseup", this.handleWindowMouseUp);
|
|
182
|
+
window.document[eventAction](
|
|
183
|
+
"mouseleave",
|
|
184
|
+
this.handleWindowMouseUp
|
|
185
|
+
);
|
|
186
|
+
window[eventAction]("mousemove", this.handleMouseMove);
|
|
187
|
+
if (e) {
|
|
188
|
+
e.preventDefault();
|
|
189
|
+
this.setupTrackConstraints();
|
|
190
|
+
this.#isNonVisibleFocus = true;
|
|
191
|
+
e.target.focus();
|
|
192
|
+
this.#isNonVisibleFocus = false;
|
|
193
|
+
const value = this.#calculateValueFromMouseEvent(e);
|
|
194
|
+
this.value = `${this.#roundToNearestStep(value)}`;
|
|
195
|
+
this.isDragging = true;
|
|
435
196
|
}
|
|
436
|
-
|
|
437
|
-
};
|
|
438
|
-
__decorate([
|
|
439
|
-
attr({ attribute: "readonly", mode: "boolean" })
|
|
440
|
-
], Slider$1.prototype, "readOnly", void 0);
|
|
441
|
-
__decorate([
|
|
442
|
-
observable
|
|
443
|
-
], Slider$1.prototype, "direction", void 0);
|
|
444
|
-
__decorate([
|
|
445
|
-
observable
|
|
446
|
-
], Slider$1.prototype, "isDragging", void 0);
|
|
447
|
-
__decorate([
|
|
448
|
-
observable
|
|
449
|
-
], Slider$1.prototype, "position", void 0);
|
|
450
|
-
__decorate([
|
|
451
|
-
observable
|
|
452
|
-
], Slider$1.prototype, "trackWidth", void 0);
|
|
453
|
-
__decorate([
|
|
454
|
-
observable
|
|
455
|
-
], Slider$1.prototype, "trackMinWidth", void 0);
|
|
456
|
-
__decorate([
|
|
457
|
-
observable
|
|
458
|
-
], Slider$1.prototype, "trackHeight", void 0);
|
|
459
|
-
__decorate([
|
|
460
|
-
observable
|
|
461
|
-
], Slider$1.prototype, "trackLeft", void 0);
|
|
462
|
-
__decorate([
|
|
463
|
-
observable
|
|
464
|
-
], Slider$1.prototype, "trackMinHeight", void 0);
|
|
465
|
-
__decorate([
|
|
466
|
-
observable
|
|
467
|
-
], Slider$1.prototype, "valueTextFormatter", void 0);
|
|
468
|
-
__decorate([
|
|
469
|
-
attr({ converter: nullableNumberConverter })
|
|
470
|
-
], Slider$1.prototype, "min", void 0);
|
|
471
|
-
__decorate([
|
|
472
|
-
attr({ converter: nullableNumberConverter })
|
|
473
|
-
], Slider$1.prototype, "max", void 0);
|
|
474
|
-
__decorate([
|
|
475
|
-
attr({ converter: nullableNumberConverter })
|
|
476
|
-
], Slider$1.prototype, "step", void 0);
|
|
477
|
-
__decorate([
|
|
478
|
-
attr
|
|
479
|
-
], Slider$1.prototype, "orientation", void 0);
|
|
480
|
-
__decorate([
|
|
481
|
-
attr
|
|
482
|
-
], Slider$1.prototype, "mode", void 0);
|
|
483
|
-
|
|
484
|
-
const styles = ":host{display:inline-block}:host(:not([orientation=vertical])){inline-size:100%}:host([orientation=vertical]){block-size:100%;min-block-size:calc(var(--_thumb-interaction-indicator-size) * 5)}:host([disabled]){cursor:not-allowed}.control.connotation-cta{--_connotation-color-primary: var(--vvd-slider-cta-primary, var(--vvd-color-cta-500))}.control:not(.connotation-cta){--_connotation-color-primary: var(--vvd-slider-accent-primary, var(--vvd-color-canvas-text))}.control{--_appearance-color-text: var(--_connotation-color-primary-text);--_appearance-color-fill: var(--_connotation-color-primary);--_appearance-color-outline: transparent}.control{--_thumb-size: 12px;--_thumb-interaction-indicator-size: 36px;--_track-start-inset-inline-start: 0;--_track-start-inset-block-start: 0;cursor:pointer;outline:none;user-select:none}.control .positioning-region{position:relative}.control .track{position:absolute;border-radius:4px;background:var(--_track-background-color)}.control .track-start{position:absolute;border-radius:inherit;background:var(--_track-start-background-color);block-size:100%;inset-inline-start:var(--_track-start-inset-inline-start)}.control.horizontal{block-size:var(--_thumb-interaction-indicator-size);inline-size:calc(100% - var(--_thumb-size));margin-inline-start:calc(var(--_thumb-size) / 2);min-inline-size:var(--_thumb-size)}.control.horizontal .track{top:calc((var(--_thumb-interaction-indicator-size) - 2px) / 2);right:0;left:0;block-size:2px}:host([markers]) .control.horizontal .track-start{--_track-start-inset-inline-start: 1px;border-bottom-left-radius:0;border-top-left-radius:0}.control.horizontal .track .mark{position:absolute;block-size:6px;inline-size:100%;inset-block-start:-2px;inset-inline-start:0}.control.vertical{margin-top:calc(var(--_thumb-interaction-indicator-size) / 2);block-size:calc(100% - var(--_thumb-interaction-indicator-size));inline-size:var(--_thumb-interaction-indicator-size);min-block-size:var(--_thumb-interaction-indicator-size)}.control.vertical .positioning-region{block-size:100%}.control.vertical .track{left:calc((var(--_thumb-interaction-indicator-size) - 2px) / 2);block-size:100%;inline-size:2px}.control.vertical .track .mark{position:absolute;block-size:100%;inline-size:6px;inset-block-start:0;inset-inline-start:-2px}.control.vertical .track-start{block-size:auto;inline-size:100%;inset-block-start:var(--_track-start-inset-block-start)}:host([markers]) .control.vertical .track-start{--_track-start-inset-block-start: 1px;border-radius:0}.control.disabled{--_track-background-color: var(--vvd-color-neutral-100);--_track-start-background-color: var(--vvd-color-neutral-300);pointer-events:none}.control:not(.disabled){--_track-background-color: var(--vvd-color-neutral-300);--_track-start-background-color: var(--_appearance-color-fill)}.control:not(.disabled) .mark{color:var(--vvd-color-neutral-950)}.control.disabled .mark{color:var(--_track-start-background-color)}.thumb-container{position:absolute;border-radius:50%;block-size:var(--_thumb-interaction-indicator-size);cursor:inherit;inline-size:var(--_thumb-interaction-indicator-size);outline:none;touch-action:none}.thumb-container.focus-visible{box-shadow:inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));outline-offset:calc(-2px - var(--focus-inset, 0px));--focus-stroke-gap-color: transparent;--_thumb-interaction-indicator-alpha: .05;border-radius:50%}.control.horizontal .thumb-container{transform:translate(calc(var(--_thumb-interaction-indicator-size) / 2))}.control.vertical .thumb-container{transform:translateY(calc(var(--_thumb-interaction-indicator-size) / 2))}.control:not(.disabled) .thumb-container:hover{--_thumb-interaction-indicator-alpha: .12}.control:not(.disabled) .thumb-container:active{--_thumb-interaction-indicator-alpha: .25}.thumb-container:before{position:absolute;display:block;border-radius:inherit;background-color:var(--_track-start-background-color);block-size:var(--_thumb-interaction-indicator-size);content:\"\";inline-size:var(--_thumb-interaction-indicator-size);opacity:var(--_thumb-interaction-indicator-alpha, 0);transition:opacity .2s ease-out 0s}.thumb-container:after{position:absolute;display:block;border-radius:inherit;background-color:var(--_track-start-background-color);block-size:var(--_thumb-size);content:\"\";inline-size:var(--_thumb-size);inset:calc((var(--_thumb-interaction-indicator-size) - var(--_thumb-size)) / 2)}.popup{pointer-events:none}.tooltip{width:auto;padding:8px 12px;color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base-bold)}";
|
|
485
|
-
|
|
486
|
-
var __defProp = Object.defineProperty;
|
|
487
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
488
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
489
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
490
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
491
|
-
if (decorator = decorators[i])
|
|
492
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
493
|
-
if (kind && result) __defProp(target, key, result);
|
|
494
|
-
return result;
|
|
495
|
-
};
|
|
496
|
-
class Slider extends Slider$1 {
|
|
497
|
-
constructor() {
|
|
498
|
-
super();
|
|
197
|
+
}
|
|
198
|
+
};
|
|
499
199
|
this.ariaLabel = null;
|
|
500
200
|
this.ariaValuetext = null;
|
|
501
201
|
this.markers = false;
|
|
502
202
|
this.pin = false;
|
|
503
|
-
this.valueTextFormatter = (value) => parseFloat(value).toLocaleString(this.locale.lang);
|
|
504
203
|
this._focusVisible = false;
|
|
505
204
|
this._hoveringOnThumb = false;
|
|
506
205
|
this.#isNonVisibleFocus = false;
|
|
@@ -524,60 +223,186 @@ class Slider extends Slider$1 {
|
|
|
524
223
|
this.#onMouseOut = () => {
|
|
525
224
|
this._hoveringOnThumb = false;
|
|
526
225
|
};
|
|
527
|
-
const fastSliderInternals = this;
|
|
528
|
-
const originalHandleMouseDown = fastSliderInternals.handleMouseDown;
|
|
529
|
-
fastSliderInternals.handleMouseDown = (e) => {
|
|
530
|
-
this.#isNonVisibleFocus = true;
|
|
531
|
-
originalHandleMouseDown(e);
|
|
532
|
-
this.#isNonVisibleFocus = false;
|
|
533
|
-
if (e && !this.disabled && !this.readOnly) {
|
|
534
|
-
this.isDragging = true;
|
|
535
|
-
}
|
|
536
|
-
};
|
|
537
|
-
const originalHandleThumbMouseDown = fastSliderInternals.handleThumbMouseDown;
|
|
538
|
-
fastSliderInternals.handleThumbMouseDown = (e) => {
|
|
539
|
-
this.#isNonVisibleFocus = true;
|
|
540
|
-
originalHandleThumbMouseDown(e);
|
|
541
|
-
this.#isNonVisibleFocus = false;
|
|
542
|
-
};
|
|
543
|
-
const originalKeypressHandler = fastSliderInternals.keypressHandler;
|
|
544
|
-
fastSliderInternals.keypressHandler = (e) => {
|
|
545
|
-
this._focusVisible = true;
|
|
546
|
-
originalKeypressHandler(e);
|
|
547
|
-
};
|
|
548
226
|
}
|
|
227
|
+
// Map to proxy element
|
|
549
228
|
/**
|
|
550
|
-
*
|
|
229
|
+
* @internal
|
|
230
|
+
*/
|
|
231
|
+
readOnlyChanged() {
|
|
232
|
+
if (this.proxy instanceof HTMLInputElement) {
|
|
233
|
+
this.proxy.readOnly = this.readOnly;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* The value property, typed as a number.
|
|
551
238
|
*
|
|
239
|
+
* @public
|
|
240
|
+
*/
|
|
241
|
+
get valueAsNumber() {
|
|
242
|
+
return parseFloat(super.value);
|
|
243
|
+
}
|
|
244
|
+
set valueAsNumber(next) {
|
|
245
|
+
this.value = next.toString();
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
552
248
|
* @internal
|
|
553
249
|
*/
|
|
554
250
|
valueChanged(previous, next) {
|
|
251
|
+
super.valueChanged(previous, next);
|
|
555
252
|
if (this.$fastController.isConnected) {
|
|
556
253
|
const nextAsNumber = parseFloat(next);
|
|
557
|
-
const value =
|
|
558
|
-
this.min,
|
|
559
|
-
this.max,
|
|
560
|
-
this["convertToConstrainedValue"](nextAsNumber)
|
|
561
|
-
).toString();
|
|
254
|
+
const value = this.#roundToNearestStep(nextAsNumber).toString();
|
|
562
255
|
if (value !== next) {
|
|
563
256
|
this.value = value;
|
|
564
257
|
return;
|
|
565
258
|
}
|
|
566
|
-
|
|
259
|
+
this.setThumbPositionForOrientation(this.direction);
|
|
260
|
+
this.$emit("change");
|
|
567
261
|
}
|
|
568
262
|
}
|
|
569
|
-
|
|
570
|
-
|
|
263
|
+
// Map to proxy element.
|
|
264
|
+
/**
|
|
265
|
+
* @internal
|
|
266
|
+
*/
|
|
267
|
+
minChanged() {
|
|
268
|
+
if (this.proxy instanceof HTMLInputElement) {
|
|
269
|
+
this.proxy.min = `${this.min}`;
|
|
270
|
+
}
|
|
271
|
+
this.validate();
|
|
571
272
|
}
|
|
572
|
-
|
|
273
|
+
// Map to proxy element.
|
|
274
|
+
/**
|
|
275
|
+
* @internal
|
|
276
|
+
*/
|
|
277
|
+
maxChanged() {
|
|
278
|
+
if (this.proxy instanceof HTMLInputElement) {
|
|
279
|
+
this.proxy.max = `${this.max}`;
|
|
280
|
+
}
|
|
281
|
+
this.validate();
|
|
282
|
+
}
|
|
283
|
+
// Map to proxy element.
|
|
284
|
+
/**
|
|
285
|
+
* @internal
|
|
286
|
+
*/
|
|
287
|
+
stepChanged() {
|
|
288
|
+
if (this.proxy instanceof HTMLInputElement) {
|
|
289
|
+
this.proxy.step = `${this.step}`;
|
|
290
|
+
}
|
|
291
|
+
this.updateStepMultiplier();
|
|
292
|
+
this.validate();
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* @internal
|
|
296
|
+
*/
|
|
297
|
+
orientationChanged() {
|
|
298
|
+
if (this.$fastController.isConnected) {
|
|
299
|
+
this.setThumbPositionForOrientation(this.direction);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* @internal
|
|
304
|
+
*/
|
|
573
305
|
connectedCallback() {
|
|
574
306
|
super.connectedCallback();
|
|
307
|
+
this.proxy.setAttribute("type", "range");
|
|
308
|
+
this.direction = getDirection(this);
|
|
309
|
+
this.updateStepMultiplier();
|
|
310
|
+
this.setupTrackConstraints();
|
|
311
|
+
this.setupListeners();
|
|
312
|
+
this.setupDefaultValue();
|
|
313
|
+
this.setThumbPositionForOrientation(this.direction);
|
|
575
314
|
this.#registerThumbListeners();
|
|
576
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* @internal
|
|
318
|
+
*/
|
|
577
319
|
disconnectedCallback() {
|
|
578
|
-
|
|
320
|
+
this.setupListeners(true);
|
|
579
321
|
this.#unregisterThumbListeners();
|
|
580
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Increment the value by the step
|
|
325
|
+
*
|
|
326
|
+
* @public
|
|
327
|
+
*/
|
|
328
|
+
increment() {
|
|
329
|
+
const newVal = this.direction !== Direction.rtl && this.orientation !== Orientation.vertical ? Number(this.value) + Number(this.step) : Number(this.value) - Number(this.step);
|
|
330
|
+
this.value = this.#roundToNearestStep(newVal).toString();
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Decrement the value by the step
|
|
334
|
+
*
|
|
335
|
+
* @public
|
|
336
|
+
*/
|
|
337
|
+
decrement() {
|
|
338
|
+
const newVal = this.direction !== Direction.rtl && this.orientation !== Orientation.vertical ? Number(this.value) - Number(this.step) : Number(this.value) + Number(this.step);
|
|
339
|
+
this.value = this.#roundToNearestStep(newVal).toString();
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Places the thumb based on the current value
|
|
343
|
+
*
|
|
344
|
+
* @public
|
|
345
|
+
* @param direction - writing mode
|
|
346
|
+
*/
|
|
347
|
+
setThumbPositionForOrientation(_) {
|
|
348
|
+
const percentage = this.#thumbTrackEndOffset(this.valueAsNumber);
|
|
349
|
+
if (this.orientation === Orientation.horizontal) {
|
|
350
|
+
this.position = this.isDragging ? `right: ${percentage}%; transition: none;` : `right: ${percentage}%; transition: all 0.2s ease;`;
|
|
351
|
+
} else {
|
|
352
|
+
this.position = this.isDragging ? `bottom: ${percentage}%; transition: none;` : `bottom: ${percentage}%; transition: all 0.2s ease;`;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
#thumbTrackEndOffset(value) {
|
|
356
|
+
return (1 - inverseLerp(this.min, this.max, value)) * 100;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Update the step multiplier used to ensure rounding errors from steps that
|
|
360
|
+
* are not whole numbers
|
|
361
|
+
*/
|
|
362
|
+
updateStepMultiplier() {
|
|
363
|
+
const stepString = this.step + "";
|
|
364
|
+
const decimalPlacesOfStep = this.step % 1 ? stepString.length - stepString.indexOf(".") - 1 : 0;
|
|
365
|
+
this.stepMultiplier = Math.pow(10, decimalPlacesOfStep);
|
|
366
|
+
}
|
|
367
|
+
get midpoint() {
|
|
368
|
+
return `${this.#roundToNearestStep((this.max + this.min) / 2)}`;
|
|
369
|
+
}
|
|
370
|
+
setupDefaultValue() {
|
|
371
|
+
if (typeof this.value === "string") {
|
|
372
|
+
if (this.value.length === 0) {
|
|
373
|
+
this.initialValue = this.midpoint;
|
|
374
|
+
} else {
|
|
375
|
+
const value = parseFloat(this.value);
|
|
376
|
+
if (!Number.isNaN(value) && (value < this.min || value > this.max)) {
|
|
377
|
+
this.value = this.midpoint;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
#calculateValueFromMouseEvent(e) {
|
|
383
|
+
const trackClientRect = this.track.getBoundingClientRect();
|
|
384
|
+
const [minPos, maxPos, valuePos] = this.orientation === Orientation.horizontal ? [
|
|
385
|
+
this.track.clientLeft,
|
|
386
|
+
this.track.clientWidth,
|
|
387
|
+
e.pageX - document.documentElement.scrollLeft - this.getBoundingClientRect().left
|
|
388
|
+
] : [
|
|
389
|
+
trackClientRect.top,
|
|
390
|
+
trackClientRect.bottom,
|
|
391
|
+
e.pageY - document.documentElement.scrollTop
|
|
392
|
+
];
|
|
393
|
+
return lerp(this.min, this.max, inverseLerp(minPos, maxPos, valuePos));
|
|
394
|
+
}
|
|
395
|
+
#roundToNearestStep(value) {
|
|
396
|
+
return limit(
|
|
397
|
+
this.min,
|
|
398
|
+
this.max,
|
|
399
|
+
roundToStepValue(value - this.min, this.step) + this.min
|
|
400
|
+
);
|
|
401
|
+
}
|
|
402
|
+
get _isThumbPopupOpen() {
|
|
403
|
+
return this._focusVisible || this._hoveringOnThumb || this.isDragging;
|
|
404
|
+
}
|
|
405
|
+
#isNonVisibleFocus;
|
|
581
406
|
#registerThumbListeners() {
|
|
582
407
|
this.thumb.addEventListener("mouseover", this.#onMouseOver, {
|
|
583
408
|
passive: true
|
|
@@ -593,6 +418,51 @@ class Slider extends Slider$1 {
|
|
|
593
418
|
#onMouseOver;
|
|
594
419
|
#onMouseOut;
|
|
595
420
|
}
|
|
421
|
+
__decorateClass([
|
|
422
|
+
attr({ attribute: "readonly", mode: "boolean" })
|
|
423
|
+
], Slider.prototype, "readOnly", 2);
|
|
424
|
+
__decorateClass([
|
|
425
|
+
observable
|
|
426
|
+
], Slider.prototype, "direction", 2);
|
|
427
|
+
__decorateClass([
|
|
428
|
+
observable
|
|
429
|
+
], Slider.prototype, "isDragging", 2);
|
|
430
|
+
__decorateClass([
|
|
431
|
+
observable
|
|
432
|
+
], Slider.prototype, "position", 2);
|
|
433
|
+
__decorateClass([
|
|
434
|
+
observable
|
|
435
|
+
], Slider.prototype, "trackWidth", 2);
|
|
436
|
+
__decorateClass([
|
|
437
|
+
observable
|
|
438
|
+
], Slider.prototype, "trackMinWidth", 2);
|
|
439
|
+
__decorateClass([
|
|
440
|
+
observable
|
|
441
|
+
], Slider.prototype, "trackHeight", 2);
|
|
442
|
+
__decorateClass([
|
|
443
|
+
observable
|
|
444
|
+
], Slider.prototype, "trackLeft", 2);
|
|
445
|
+
__decorateClass([
|
|
446
|
+
observable
|
|
447
|
+
], Slider.prototype, "trackMinHeight", 2);
|
|
448
|
+
__decorateClass([
|
|
449
|
+
observable
|
|
450
|
+
], Slider.prototype, "valueTextFormatter", 2);
|
|
451
|
+
__decorateClass([
|
|
452
|
+
attr({ converter: nullableNumberConverter })
|
|
453
|
+
], Slider.prototype, "min", 2);
|
|
454
|
+
__decorateClass([
|
|
455
|
+
attr({ converter: nullableNumberConverter })
|
|
456
|
+
], Slider.prototype, "max", 2);
|
|
457
|
+
__decorateClass([
|
|
458
|
+
attr({ converter: nullableNumberConverter })
|
|
459
|
+
], Slider.prototype, "step", 2);
|
|
460
|
+
__decorateClass([
|
|
461
|
+
attr
|
|
462
|
+
], Slider.prototype, "orientation", 2);
|
|
463
|
+
__decorateClass([
|
|
464
|
+
attr
|
|
465
|
+
], Slider.prototype, "mode", 2);
|
|
596
466
|
__decorateClass([
|
|
597
467
|
attr({ attribute: "aria-label" })
|
|
598
468
|
], Slider.prototype, "ariaLabel", 2);
|
|
@@ -610,9 +480,6 @@ __decorateClass([
|
|
|
610
480
|
__decorateClass([
|
|
611
481
|
attr
|
|
612
482
|
], Slider.prototype, "connotation", 2);
|
|
613
|
-
__decorateClass([
|
|
614
|
-
observable
|
|
615
|
-
], Slider.prototype, "valueTextFormatter", 2);
|
|
616
483
|
__decorateClass([
|
|
617
484
|
observable
|
|
618
485
|
], Slider.prototype, "_focusVisible", 2);
|