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