@vonage/vivid 3.31.0 → 3.34.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/accordion/index.js +5 -5
- package/accordion-item/index.js +4 -4
- package/action-group/index.js +1 -1
- package/alert/index.js +8 -7
- package/avatar/index.js +2 -2
- package/badge/index.js +2 -2
- package/banner/index.js +5 -5
- package/breadcrumb/index.js +1 -1
- package/breadcrumb-item/index.js +3 -3
- package/button/index.js +4 -4
- package/calendar/index.js +1 -1
- package/calendar-event/index.js +1 -1
- package/card/index.js +3 -3
- package/checkbox/index.js +7 -4
- package/combobox/index.js +10 -9
- package/custom-elements.json +996 -29
- package/data-grid/index.js +2 -2
- package/date-picker/index.js +35 -0
- package/dialog/index.js +6 -6
- package/divider/index.js +1 -1
- package/elevation/index.js +1 -1
- package/empty-state/index.js +2 -2
- package/fab/index.js +4 -4
- package/file-picker/index.js +7 -6
- package/focus/index.js +1 -1
- package/header/index.js +2 -2
- package/icon/index.js +1 -1
- package/index.d.ts +1 -0
- package/index.js +68 -66
- package/layout/index.js +1 -1
- package/lib/button/button.d.ts +2 -0
- package/lib/calendar/calendar.d.ts +1 -1
- package/lib/components.d.ts +20 -19
- package/lib/date-picker/calendar/calendarGrid.d.ts +17 -0
- package/lib/date-picker/calendar/dateStr.d.ts +7 -0
- package/lib/date-picker/calendar/month.d.ts +12 -0
- package/lib/date-picker/calendar/monthPickerGrid.d.ts +10 -0
- package/lib/date-picker/calendar/presentationDate.d.ts +4 -0
- package/lib/date-picker/calendar/year.d.ts +2 -0
- package/lib/date-picker/date-picker.d.ts +18 -0
- package/lib/date-picker/date-picker.template.d.ts +4 -0
- package/lib/date-picker/definition.d.ts +3 -0
- package/lib/date-picker/locale.d.ts +21 -0
- package/lib/icon/icon.d.ts +0 -1
- package/lib/listbox/listbox.d.ts +9 -1
- package/lib/select/select.d.ts +4 -2
- package/lib/text-field/text-field.d.ts +1 -0
- package/listbox/index.js +22 -17
- package/locales/en-GB.d.ts +3 -0
- package/locales/en-GB.js +59 -0
- package/locales/en-US.d.ts +3 -0
- package/locales/en-US.js +59 -0
- package/locales/ja-JP.d.ts +3 -0
- package/locales/ja-JP.js +59 -0
- package/locales/zh-CN.d.ts +3 -0
- package/locales/zh-CN.js +59 -0
- package/menu/index.js +8 -8
- package/menu-item/index.js +4 -4
- package/nav/index.js +1 -1
- package/nav-disclosure/index.js +3 -3
- package/nav-item/index.js +3 -3
- package/note/index.js +4 -4
- package/number-field/index.js +8 -7
- package/option/index.js +5 -4
- package/package.json +2 -15
- package/pagination/index.js +5 -5
- package/popup/index.js +6 -6
- package/progress/index.js +1 -1
- package/progress-ring/index.js +1 -1
- package/radio/index.js +2 -2
- package/radio-group/index.js +1 -1
- package/select/index.js +10 -9
- package/shared/affix.js +25 -9
- package/shared/apply-mixins.js +1 -1
- package/shared/breadcrumb-item.js +5 -5
- package/shared/button.js +13 -13
- package/shared/calendar-event.js +36 -16
- package/shared/definition.js +133 -194
- package/shared/definition10.js +225 -40
- package/shared/definition11.js +36 -32
- package/shared/definition12.js +763 -98
- package/shared/definition13.js +125 -89
- package/shared/definition14.js +207 -27
- package/shared/definition15.js +710 -731
- package/shared/definition16.js +1289 -47
- package/shared/definition17.js +6113 -93
- package/shared/definition18.js +242 -164
- package/shared/definition19.js +47 -692
- package/shared/definition2.js +199 -117
- package/shared/definition20.js +59 -1671
- package/shared/definition21.js +95 -255
- package/shared/definition22.js +2218 -1167
- package/shared/definition23.js +57 -219
- package/shared/definition24.js +27 -68
- package/shared/definition25.js +54 -38
- package/shared/definition26.js +395 -70
- package/shared/definition27.js +381 -2223
- package/shared/definition28.js +85 -44
- package/shared/definition29.js +27 -40
- package/shared/definition3.js +61 -24
- package/shared/definition30.js +13 -427
- package/shared/definition31.js +49 -360
- package/shared/definition32.js +466 -13
- package/shared/definition33.js +273 -63
- package/shared/definition34.js +195 -25
- package/shared/definition35.js +86 -35
- package/shared/definition36.js +66 -427
- package/shared/definition37.js +430 -190
- package/shared/definition38.js +34 -52
- package/shared/definition39.js +683 -31
- package/shared/definition4.js +157 -12
- package/shared/definition40.js +97 -422
- package/shared/definition41.js +473 -543
- package/shared/definition42.js +122 -73
- package/shared/definition43.js +103 -502
- package/shared/definition44.js +23 -101
- package/shared/definition45.js +76 -126
- package/shared/definition46.js +494 -48
- package/shared/definition47.js +23 -23
- package/shared/definition48.js +126 -476
- package/shared/definition49.js +275 -98
- package/shared/definition5.js +71 -36
- package/shared/definition50.js +157 -16
- package/shared/definition51.js +133 -263
- package/shared/definition52.js +131 -115
- package/shared/definition53.js +85 -120
- package/shared/definition54.js +295 -111
- package/shared/definition55.js +12 -71
- package/shared/definition56.js +39 -295
- package/shared/definition57.js +181 -0
- package/shared/definition6.js +56 -111
- package/shared/definition7.js +119 -187
- package/shared/definition8.js +58 -23
- package/shared/definition9.js +92 -66
- package/shared/focus.js +2 -1
- package/shared/focus2.js +1 -1
- package/shared/form-associated.js +2 -2
- package/shared/icon.js +48 -27
- package/shared/index.js +7 -27
- package/shared/index2.js +202 -0
- package/shared/key-codes.js +1 -1
- package/shared/listbox.js +88 -11
- package/shared/localization/Locale.d.ts +4 -0
- package/shared/localization/index.d.ts +7 -0
- package/shared/patterns/form-elements/form-elements.d.ts +4 -4
- package/shared/patterns/index.d.ts +1 -0
- package/shared/patterns/localized.d.ts +4 -0
- package/shared/radio.js +23 -7
- package/shared/repeat.js +1 -1
- package/shared/text-anchor.js +21 -4
- package/shared/text-anchor.template.js +37 -40
- package/shared/text-field.js +2 -2
- package/shared/text-field2.js +15 -15
- package/shared/tree-item.js +12 -12
- package/side-drawer/index.js +1 -1
- package/slider/index.js +2 -2
- package/split-button/index.js +3 -3
- package/style.css +6097 -0
- package/styles/core/all.css +25 -3
- package/styles/core/theme.css +1 -1
- package/styles/core/typography.css +25 -3
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/styles/tokens/vivid-2-compat.css +2 -2
- package/switch/index.js +5 -4
- package/tab/index.js +3 -3
- package/tab-panel/index.js +1 -1
- package/tabs/index.js +5 -5
- package/tag/index.js +3 -3
- package/tag-group/index.js +1 -1
- package/text-anchor/index.js +1 -1
- package/text-area/index.js +5 -4
- package/text-field/index.js +5 -4
- package/toggletip/index.js +7 -7
- package/tooltip/index.js +7 -7
- package/tree-item/index.js +3 -3
- package/tree-view/index.js +1 -1
- package/vivid.api.json +137 -0
- package/lib/accordion/index.d.ts +0 -1
- package/lib/accordion-item/index.d.ts +0 -1
- package/lib/action-group/index.d.ts +0 -1
- package/lib/alert/index.d.ts +0 -1
- package/lib/avatar/index.d.ts +0 -1
- package/lib/badge/index.d.ts +0 -1
- package/lib/banner/index.d.ts +0 -1
- package/lib/breadcrumb/index.d.ts +0 -1
- package/lib/breadcrumb-item/index.d.ts +0 -1
- package/lib/button/index.d.ts +0 -1
- package/lib/calendar/index.d.ts +0 -1
- package/lib/calendar-event/index.d.ts +0 -1
- package/lib/card/index.d.ts +0 -1
- package/lib/checkbox/index.d.ts +0 -1
- package/lib/combobox/index.d.ts +0 -1
- package/lib/data-grid/index.d.ts +0 -1
- package/lib/dialog/index.d.ts +0 -1
- package/lib/divider/index.d.ts +0 -1
- package/lib/elevation/index.d.ts +0 -1
- package/lib/empty-state/index.d.ts +0 -1
- package/lib/fab/index.d.ts +0 -1
- package/lib/file-picker/index.d.ts +0 -1
- package/lib/focus/index.d.ts +0 -1
- package/lib/header/index.d.ts +0 -1
- package/lib/icon/index.d.ts +0 -1
- package/lib/layout/index.d.ts +0 -1
- package/lib/listbox/index.d.ts +0 -1
- package/lib/menu/index.d.ts +0 -1
- package/lib/menu-item/index.d.ts +0 -1
- package/lib/nav/index.d.ts +0 -1
- package/lib/nav-disclosure/index.d.ts +0 -1
- package/lib/nav-item/index.d.ts +0 -1
- package/lib/note/index.d.ts +0 -1
- package/lib/number-field/index.d.ts +0 -1
- package/lib/option/index.d.ts +0 -1
- package/lib/pagination/index.d.ts +0 -1
- package/lib/popup/index.d.ts +0 -1
- package/lib/progress/index.d.ts +0 -1
- package/lib/progress-ring/index.d.ts +0 -1
- package/lib/radio/index.d.ts +0 -1
- package/lib/radio-group/index.d.ts +0 -1
- package/lib/select/index.d.ts +0 -1
- package/lib/side-drawer/index.d.ts +0 -1
- package/lib/slider/index.d.ts +0 -1
- package/lib/split-button/index.d.ts +0 -1
- package/lib/switch/index.d.ts +0 -1
- package/lib/tab/index.d.ts +0 -1
- package/lib/tab-panel/index.d.ts +0 -1
- package/lib/tabs/index.d.ts +0 -1
- package/lib/tag/index.d.ts +0 -1
- package/lib/tag-group/index.d.ts +0 -1
- package/lib/text-anchor/index.d.ts +0 -1
- package/lib/text-area/index.d.ts +0 -1
- package/lib/text-field/index.d.ts +0 -1
- package/lib/toggletip/index.d.ts +0 -1
- package/lib/tooltip/index.d.ts +0 -1
- package/lib/tree-item/index.d.ts +0 -1
- package/lib/tree-view/index.d.ts +0 -1
- package/shared/form-elements.js +0 -162
package/shared/definition41.js
CHANGED
|
@@ -1,659 +1,589 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as focusRegistries } from './
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { l as listboxOptionRegistries } from './definition21.js';
|
|
6
|
-
import { A as AffixIconWithTrailing, a as affixIconTemplateFactory } from './affix.js';
|
|
7
|
-
import './focus.js';
|
|
8
|
-
import { e as errorText, f as formElements, F as FormElementSuccessText, a as FormElementHelperText, g as getFeedbackTemplate } from './form-elements.js';
|
|
9
|
-
import { b as ListboxElement, L as Listbox, D as DelegatesARIAListbox, a as Listbox$1 } from './listbox.js';
|
|
10
|
-
import { S as StartEnd } from './start-end.js';
|
|
11
|
-
import { a as applyMixins } from './apply-mixins.js';
|
|
1
|
+
import { F as FoundationElement, _ as __decorate, a as attr, o as observable, n as nullableNumberConverter, h as html, r as registerFactory } from './index.js';
|
|
2
|
+
import { f as focusRegistries } from './definition55.js';
|
|
3
|
+
import { D as Direction, g as getDirection } from './direction.js';
|
|
4
|
+
import { l as limit$1 } from './numbers.js';
|
|
12
5
|
import { F as FormAssociated } from './form-associated.js';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { g as keyTab, f as keyEscape, d as keyEnter, k as keyEnd, a as keyHome, e as keySpace, b as keyArrowDown, c as keyArrowUp } from './key-codes.js';
|
|
6
|
+
import { O as Orientation } from './aria.js';
|
|
7
|
+
import { c as keyHome, b as keyEnd, d as keyArrowDown, i as keyArrowLeft, e as keyArrowUp, h as keyArrowRight } from './key-codes.js';
|
|
16
8
|
import { f as focusTemplateFactory } from './focus2.js';
|
|
17
|
-
import { w as when } from './when.js';
|
|
18
9
|
import { r as ref } from './ref.js';
|
|
19
|
-
import {
|
|
10
|
+
import { O as Orientation$1 } from './aria2.js';
|
|
20
11
|
import { c as classNames } from './class-names.js';
|
|
21
12
|
|
|
22
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Converts a pixel coordinate on the track to a percent of the track's range
|
|
15
|
+
*/
|
|
16
|
+
function convertPixelToPercent(pixelPos, minPosition, maxPosition, direction) {
|
|
17
|
+
let pct = limit$1(0, 1, (pixelPos - minPosition) / (maxPosition - minPosition));
|
|
18
|
+
if (direction === Direction.rtl) {
|
|
19
|
+
pct = 1 - pct;
|
|
20
|
+
}
|
|
21
|
+
return pct;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
class _Slider extends FoundationElement {
|
|
23
25
|
}
|
|
24
26
|
/**
|
|
25
|
-
* A form-associated base class for the {@link @microsoft/fast-foundation#(
|
|
27
|
+
* A form-associated base class for the {@link @microsoft/fast-foundation#(Slider:class)} component.
|
|
26
28
|
*
|
|
27
29
|
* @internal
|
|
28
30
|
*/
|
|
29
|
-
class
|
|
31
|
+
class FormAssociatedSlider extends FormAssociated(_Slider) {
|
|
30
32
|
constructor() {
|
|
31
33
|
super(...arguments);
|
|
32
|
-
this.proxy = document.createElement("
|
|
34
|
+
this.proxy = document.createElement("input");
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
+
* The selection modes of a {@link @microsoft/fast-foundation#(Slider:class)}.
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
const SliderMode = {
|
|
43
|
+
singleValue: "single-value",
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* A Slider Custom HTML Element.
|
|
47
|
+
* Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#slider | ARIA slider }.
|
|
39
48
|
*
|
|
40
|
-
* @slot
|
|
41
|
-
* @slot
|
|
42
|
-
* @slot
|
|
43
|
-
* @slot
|
|
44
|
-
* @
|
|
45
|
-
* @
|
|
46
|
-
* @csspart
|
|
47
|
-
* @csspart
|
|
48
|
-
* @
|
|
49
|
-
* @csspart listbox - The listbox element
|
|
50
|
-
* @fires input - Fires a custom 'input' event when the value updates
|
|
51
|
-
* @fires change - Fires a custom 'change' event when the value updates
|
|
49
|
+
* @slot track - The track of the slider
|
|
50
|
+
* @slot track-start - The track-start visual indicator
|
|
51
|
+
* @slot thumb - The slider thumb
|
|
52
|
+
* @slot - The default slot for labels
|
|
53
|
+
* @csspart positioning-region - The region used to position the elements of the slider
|
|
54
|
+
* @csspart track-container - The region containing the track elements
|
|
55
|
+
* @csspart track-start - The element wrapping the track start slot
|
|
56
|
+
* @csspart thumb-container - The thumb container element which is programatically positioned
|
|
57
|
+
* @fires change - Fires a custom 'change' event when the slider value changes
|
|
52
58
|
*
|
|
53
59
|
* @public
|
|
54
60
|
*/
|
|
55
|
-
|
|
61
|
+
let Slider$1 = class Slider extends FormAssociatedSlider {
|
|
56
62
|
constructor() {
|
|
57
63
|
super(...arguments);
|
|
58
64
|
/**
|
|
59
|
-
*
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
this.direction = Direction.ltr;
|
|
68
|
+
/**
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
this.isDragging = false;
|
|
72
|
+
/**
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
this.trackWidth = 0;
|
|
76
|
+
/**
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
this.trackMinWidth = 0;
|
|
80
|
+
/**
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
this.trackHeight = 0;
|
|
84
|
+
/**
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
this.trackLeft = 0;
|
|
88
|
+
/**
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
91
|
+
this.trackMinHeight = 0;
|
|
92
|
+
/**
|
|
93
|
+
* Custom function that generates a string for the component's "aria-valuetext" attribute based on the current value.
|
|
60
94
|
*
|
|
61
95
|
* @public
|
|
96
|
+
*/
|
|
97
|
+
this.valueTextFormatter = () => null;
|
|
98
|
+
/**
|
|
99
|
+
* The minimum allowed value.
|
|
100
|
+
*
|
|
101
|
+
* @defaultValue - 0
|
|
102
|
+
* @public
|
|
62
103
|
* @remarks
|
|
63
|
-
* HTML Attribute:
|
|
104
|
+
* HTML Attribute: min
|
|
64
105
|
*/
|
|
65
|
-
this.
|
|
106
|
+
this.min = 0; // Map to proxy element.
|
|
66
107
|
/**
|
|
67
|
-
*
|
|
108
|
+
* The maximum allowed value.
|
|
68
109
|
*
|
|
69
|
-
* @
|
|
110
|
+
* @defaultValue - 10
|
|
111
|
+
* @public
|
|
112
|
+
* @remarks
|
|
113
|
+
* HTML Attribute: max
|
|
70
114
|
*/
|
|
71
|
-
this.
|
|
115
|
+
this.max = 10; // Map to proxy element.
|
|
72
116
|
/**
|
|
73
|
-
*
|
|
117
|
+
* Value to increment or decrement via arrow keys, mouse click or drag.
|
|
74
118
|
*
|
|
75
|
-
* @
|
|
119
|
+
* @public
|
|
120
|
+
* @remarks
|
|
121
|
+
* HTML Attribute: step
|
|
122
|
+
*/
|
|
123
|
+
this.step = 1; // Map to proxy element.
|
|
124
|
+
/**
|
|
125
|
+
* The orientation of the slider.
|
|
126
|
+
*
|
|
127
|
+
* @public
|
|
128
|
+
* @remarks
|
|
129
|
+
* HTML Attribute: orientation
|
|
76
130
|
*/
|
|
77
|
-
this.
|
|
131
|
+
this.orientation = Orientation.horizontal;
|
|
78
132
|
/**
|
|
79
|
-
* The
|
|
133
|
+
* The selection mode.
|
|
80
134
|
*
|
|
135
|
+
* @public
|
|
136
|
+
* @remarks
|
|
137
|
+
* HTML Attribute: mode
|
|
138
|
+
*/
|
|
139
|
+
this.mode = SliderMode.singleValue;
|
|
140
|
+
this.keypressHandler = (e) => {
|
|
141
|
+
if (this.readOnly) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (e.key === keyHome) {
|
|
145
|
+
e.preventDefault();
|
|
146
|
+
this.value = `${this.min}`;
|
|
147
|
+
}
|
|
148
|
+
else if (e.key === keyEnd) {
|
|
149
|
+
e.preventDefault();
|
|
150
|
+
this.value = `${this.max}`;
|
|
151
|
+
}
|
|
152
|
+
else if (!e.shiftKey) {
|
|
153
|
+
switch (e.key) {
|
|
154
|
+
case keyArrowRight:
|
|
155
|
+
case keyArrowUp:
|
|
156
|
+
e.preventDefault();
|
|
157
|
+
this.increment();
|
|
158
|
+
break;
|
|
159
|
+
case keyArrowLeft:
|
|
160
|
+
case keyArrowDown:
|
|
161
|
+
e.preventDefault();
|
|
162
|
+
this.decrement();
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
this.setupTrackConstraints = () => {
|
|
168
|
+
const clientRect = this.track.getBoundingClientRect();
|
|
169
|
+
this.trackWidth = this.track.clientWidth;
|
|
170
|
+
this.trackMinWidth = this.track.clientLeft;
|
|
171
|
+
this.trackHeight = clientRect.bottom;
|
|
172
|
+
this.trackMinHeight = clientRect.top;
|
|
173
|
+
this.trackLeft = this.getBoundingClientRect().left;
|
|
174
|
+
if (this.trackWidth === 0) {
|
|
175
|
+
this.trackWidth = 1;
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
this.setupListeners = (remove = false) => {
|
|
179
|
+
const eventAction = `${remove ? "remove" : "add"}EventListener`;
|
|
180
|
+
this[eventAction]("keydown", this.keypressHandler);
|
|
181
|
+
this[eventAction]("mousedown", this.handleMouseDown);
|
|
182
|
+
this.thumb[eventAction]("mousedown", this.handleThumbMouseDown, {
|
|
183
|
+
passive: true,
|
|
184
|
+
});
|
|
185
|
+
this.thumb[eventAction]("touchstart", this.handleThumbMouseDown, {
|
|
186
|
+
passive: true,
|
|
187
|
+
});
|
|
188
|
+
// removes handlers attached by mousedown handlers
|
|
189
|
+
if (remove) {
|
|
190
|
+
this.handleMouseDown(null);
|
|
191
|
+
this.handleThumbMouseDown(null);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
81
195
|
* @internal
|
|
82
196
|
*/
|
|
83
|
-
this.
|
|
197
|
+
this.initialValue = "";
|
|
198
|
+
/**
|
|
199
|
+
* Handle mouse moves during a thumb drag operation
|
|
200
|
+
* If the event handler is null it removes the events
|
|
201
|
+
*/
|
|
202
|
+
this.handleThumbMouseDown = (event) => {
|
|
203
|
+
if (event) {
|
|
204
|
+
if (this.readOnly || this.disabled || event.defaultPrevented) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
event.target.focus();
|
|
208
|
+
}
|
|
209
|
+
const eventAction = `${event !== null ? "add" : "remove"}EventListener`;
|
|
210
|
+
window[eventAction]("mouseup", this.handleWindowMouseUp);
|
|
211
|
+
window[eventAction]("mousemove", this.handleMouseMove, { passive: true });
|
|
212
|
+
window[eventAction]("touchmove", this.handleMouseMove, { passive: true });
|
|
213
|
+
window[eventAction]("touchend", this.handleWindowMouseUp);
|
|
214
|
+
this.isDragging = event !== null;
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* Handle mouse moves during a thumb drag operation
|
|
218
|
+
*/
|
|
219
|
+
this.handleMouseMove = (e) => {
|
|
220
|
+
if (this.readOnly || this.disabled || e.defaultPrevented) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
// update the value based on current position
|
|
224
|
+
const sourceEvent = window.TouchEvent && e instanceof TouchEvent
|
|
225
|
+
? e.touches[0]
|
|
226
|
+
: e;
|
|
227
|
+
const eventValue = this.orientation === Orientation.horizontal
|
|
228
|
+
? sourceEvent.pageX - document.documentElement.scrollLeft - this.trackLeft
|
|
229
|
+
: sourceEvent.pageY - document.documentElement.scrollTop;
|
|
230
|
+
this.value = `${this.calculateNewValue(eventValue)}`;
|
|
231
|
+
};
|
|
232
|
+
this.calculateNewValue = (rawValue) => {
|
|
233
|
+
// update the value based on current position
|
|
234
|
+
const newPosition = convertPixelToPercent(rawValue, this.orientation === Orientation.horizontal
|
|
235
|
+
? this.trackMinWidth
|
|
236
|
+
: this.trackMinHeight, this.orientation === Orientation.horizontal
|
|
237
|
+
? this.trackWidth
|
|
238
|
+
: this.trackHeight, this.direction);
|
|
239
|
+
const newValue = (this.max - this.min) * newPosition + this.min;
|
|
240
|
+
return this.convertToConstrainedValue(newValue);
|
|
241
|
+
};
|
|
242
|
+
/**
|
|
243
|
+
* Handle a window mouse up during a drag operation
|
|
244
|
+
*/
|
|
245
|
+
this.handleWindowMouseUp = (event) => {
|
|
246
|
+
this.stopDragging();
|
|
247
|
+
};
|
|
248
|
+
this.stopDragging = () => {
|
|
249
|
+
this.isDragging = false;
|
|
250
|
+
this.handleMouseDown(null);
|
|
251
|
+
this.handleThumbMouseDown(null);
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
*
|
|
255
|
+
* @param e - MouseEvent or null. If there is no event handler it will remove the events
|
|
256
|
+
*/
|
|
257
|
+
this.handleMouseDown = (e) => {
|
|
258
|
+
const eventAction = `${e !== null ? "add" : "remove"}EventListener`;
|
|
259
|
+
if (e === null || (!this.disabled && !this.readOnly)) {
|
|
260
|
+
window[eventAction]("mouseup", this.handleWindowMouseUp);
|
|
261
|
+
window.document[eventAction]("mouseleave", this.handleWindowMouseUp);
|
|
262
|
+
window[eventAction]("mousemove", this.handleMouseMove);
|
|
263
|
+
if (e) {
|
|
264
|
+
e.preventDefault();
|
|
265
|
+
this.setupTrackConstraints();
|
|
266
|
+
e.target.focus();
|
|
267
|
+
const controlValue = this.orientation === Orientation.horizontal
|
|
268
|
+
? e.pageX - document.documentElement.scrollLeft - this.trackLeft
|
|
269
|
+
: e.pageY - document.documentElement.scrollTop;
|
|
270
|
+
this.value = `${this.calculateNewValue(controlValue)}`;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
this.convertToConstrainedValue = (value) => {
|
|
275
|
+
if (isNaN(value)) {
|
|
276
|
+
value = this.min;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* The following logic intends to overcome the issue with math in JavaScript with regards to floating point numbers.
|
|
280
|
+
* 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
|
|
281
|
+
* and is converted to an integer by determining the number of decimal places it represent, multiplying it until it is an
|
|
282
|
+
* integer and then dividing it to get back to the correct number.
|
|
283
|
+
*/
|
|
284
|
+
let constrainedValue = value - this.min;
|
|
285
|
+
const roundedConstrainedValue = Math.round(constrainedValue / this.step);
|
|
286
|
+
const remainderValue = constrainedValue -
|
|
287
|
+
(roundedConstrainedValue * (this.stepMultiplier * this.step)) /
|
|
288
|
+
this.stepMultiplier;
|
|
289
|
+
constrainedValue =
|
|
290
|
+
remainderValue >= Number(this.step) / 2
|
|
291
|
+
? constrainedValue - remainderValue + Number(this.step)
|
|
292
|
+
: constrainedValue - remainderValue;
|
|
293
|
+
return constrainedValue + this.min;
|
|
294
|
+
};
|
|
84
295
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
* @param prev - the previous open value
|
|
89
|
-
* @param next - the current open value
|
|
90
|
-
*
|
|
91
|
-
* @internal
|
|
92
|
-
*/
|
|
93
|
-
openChanged(prev, next) {
|
|
94
|
-
if (!this.collapsible) {
|
|
95
|
-
return;
|
|
296
|
+
readOnlyChanged() {
|
|
297
|
+
if (this.proxy instanceof HTMLInputElement) {
|
|
298
|
+
this.proxy.readOnly = this.readOnly;
|
|
96
299
|
}
|
|
97
|
-
if (this.open) {
|
|
98
|
-
this.ariaControls = this.listboxId;
|
|
99
|
-
this.ariaExpanded = "true";
|
|
100
|
-
this.setPositioning();
|
|
101
|
-
this.focusAndScrollOptionIntoView();
|
|
102
|
-
this.indexWhenOpened = this.selectedIndex;
|
|
103
|
-
// focus is directed to the element when `open` is changed programmatically
|
|
104
|
-
DOM.queueUpdate(() => this.focus());
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
this.ariaControls = "";
|
|
108
|
-
this.ariaExpanded = "false";
|
|
109
300
|
}
|
|
110
301
|
/**
|
|
111
|
-
* The
|
|
112
|
-
*
|
|
113
|
-
* @internal
|
|
114
|
-
*/
|
|
115
|
-
get collapsible() {
|
|
116
|
-
return !(this.multiple || typeof this.size === "number");
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* The value property.
|
|
302
|
+
* The value property, typed as a number.
|
|
120
303
|
*
|
|
121
304
|
* @public
|
|
122
305
|
*/
|
|
123
|
-
get
|
|
124
|
-
|
|
125
|
-
return this._value;
|
|
306
|
+
get valueAsNumber() {
|
|
307
|
+
return parseFloat(super.value);
|
|
126
308
|
}
|
|
127
|
-
set
|
|
128
|
-
|
|
129
|
-
const prev = `${this._value}`;
|
|
130
|
-
if ((_a = this._options) === null || _a === void 0 ? void 0 : _a.length) {
|
|
131
|
-
const selectedIndex = this._options.findIndex(el => el.value === next);
|
|
132
|
-
const prevSelectedValue = (_c = (_b = this._options[this.selectedIndex]) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : null;
|
|
133
|
-
const nextSelectedValue = (_e = (_d = this._options[selectedIndex]) === null || _d === void 0 ? void 0 : _d.value) !== null && _e !== void 0 ? _e : null;
|
|
134
|
-
if (selectedIndex === -1 || prevSelectedValue !== nextSelectedValue) {
|
|
135
|
-
next = "";
|
|
136
|
-
this.selectedIndex = selectedIndex;
|
|
137
|
-
}
|
|
138
|
-
next = (_g = (_f = this.firstSelectedOption) === null || _f === void 0 ? void 0 : _f.value) !== null && _g !== void 0 ? _g : next;
|
|
139
|
-
}
|
|
140
|
-
if (prev !== next) {
|
|
141
|
-
this._value = next;
|
|
142
|
-
super.valueChanged(prev, next);
|
|
143
|
-
Observable.notify(this, "value");
|
|
144
|
-
this.updateDisplayValue();
|
|
145
|
-
}
|
|
309
|
+
set valueAsNumber(next) {
|
|
310
|
+
this.value = next.toString();
|
|
146
311
|
}
|
|
147
312
|
/**
|
|
148
|
-
* Sets the value and display value to match the first selected option.
|
|
149
|
-
*
|
|
150
|
-
* @param shouldEmit - if true, the input and change events will be emitted
|
|
151
|
-
*
|
|
152
313
|
* @internal
|
|
153
314
|
*/
|
|
154
|
-
|
|
155
|
-
|
|
315
|
+
valueChanged(previous, next) {
|
|
316
|
+
super.valueChanged(previous, next);
|
|
156
317
|
if (this.$fastController.isConnected) {
|
|
157
|
-
this.
|
|
318
|
+
this.setThumbPositionForOrientation(this.direction);
|
|
158
319
|
}
|
|
159
|
-
|
|
160
|
-
this.$emit("input");
|
|
161
|
-
this.$emit("change", this, {
|
|
162
|
-
bubbles: true,
|
|
163
|
-
composed: undefined,
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Updates the proxy value when the selected index changes.
|
|
169
|
-
*
|
|
170
|
-
* @param prev - the previous selected index
|
|
171
|
-
* @param next - the next selected index
|
|
172
|
-
*
|
|
173
|
-
* @internal
|
|
174
|
-
*/
|
|
175
|
-
selectedIndexChanged(prev, next) {
|
|
176
|
-
super.selectedIndexChanged(prev, next);
|
|
177
|
-
this.updateValue();
|
|
178
|
-
}
|
|
179
|
-
positionChanged(prev, next) {
|
|
180
|
-
this.positionAttribute = next;
|
|
181
|
-
this.setPositioning();
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Calculate and apply listbox positioning based on available viewport space.
|
|
185
|
-
*
|
|
186
|
-
* @public
|
|
187
|
-
*/
|
|
188
|
-
setPositioning() {
|
|
189
|
-
const currentBox = this.getBoundingClientRect();
|
|
190
|
-
const viewportHeight = window.innerHeight;
|
|
191
|
-
const availableBottom = viewportHeight - currentBox.bottom;
|
|
192
|
-
this.position = this.forcedPosition
|
|
193
|
-
? this.positionAttribute
|
|
194
|
-
: currentBox.top > availableBottom
|
|
195
|
-
? SelectPosition.above
|
|
196
|
-
: SelectPosition.below;
|
|
197
|
-
this.positionAttribute = this.forcedPosition
|
|
198
|
-
? this.positionAttribute
|
|
199
|
-
: this.position;
|
|
200
|
-
this.maxHeight =
|
|
201
|
-
this.position === SelectPosition.above ? ~~currentBox.top : ~~availableBottom;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* The value displayed on the button.
|
|
205
|
-
*
|
|
206
|
-
* @public
|
|
207
|
-
*/
|
|
208
|
-
get displayValue() {
|
|
209
|
-
var _a, _b;
|
|
210
|
-
Observable.track(this, "displayValue");
|
|
211
|
-
return (_b = (_a = this.firstSelectedOption) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : "";
|
|
320
|
+
this.$emit("change");
|
|
212
321
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
* @param prev - The previous disabled value
|
|
217
|
-
* @param next - The next disabled value
|
|
218
|
-
*
|
|
219
|
-
* @internal
|
|
220
|
-
*/
|
|
221
|
-
disabledChanged(prev, next) {
|
|
222
|
-
if (super.disabledChanged) {
|
|
223
|
-
super.disabledChanged(prev, next);
|
|
322
|
+
minChanged() {
|
|
323
|
+
if (this.proxy instanceof HTMLInputElement) {
|
|
324
|
+
this.proxy.min = `${this.min}`;
|
|
224
325
|
}
|
|
225
|
-
this.
|
|
326
|
+
this.validate();
|
|
226
327
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
* @internal
|
|
231
|
-
*/
|
|
232
|
-
formResetCallback() {
|
|
233
|
-
this.setProxyOptions();
|
|
234
|
-
// Call the base class's implementation setDefaultSelectedOption instead of the select's
|
|
235
|
-
// override, in order to reset the selectedIndex without using the value property.
|
|
236
|
-
super.setDefaultSelectedOption();
|
|
237
|
-
if (this.selectedIndex === -1) {
|
|
238
|
-
this.selectedIndex = 0;
|
|
328
|
+
maxChanged() {
|
|
329
|
+
if (this.proxy instanceof HTMLInputElement) {
|
|
330
|
+
this.proxy.max = `${this.max}`;
|
|
239
331
|
}
|
|
332
|
+
this.validate();
|
|
240
333
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
* @param e - the mouse event
|
|
245
|
-
* @internal
|
|
246
|
-
*/
|
|
247
|
-
clickHandler(e) {
|
|
248
|
-
// do nothing if the select is disabled
|
|
249
|
-
if (this.disabled) {
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
if (this.open) {
|
|
253
|
-
const captured = e.target.closest(`option,[role=option]`);
|
|
254
|
-
if (captured && captured.disabled) {
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
super.clickHandler(e);
|
|
259
|
-
this.open = this.collapsible && !this.open;
|
|
260
|
-
if (!this.open && this.indexWhenOpened !== this.selectedIndex) {
|
|
261
|
-
this.updateValue(true);
|
|
262
|
-
}
|
|
263
|
-
return true;
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Handles focus state when the element or its children lose focus.
|
|
267
|
-
*
|
|
268
|
-
* @param e - The focus event
|
|
269
|
-
* @internal
|
|
270
|
-
*/
|
|
271
|
-
focusoutHandler(e) {
|
|
272
|
-
var _a;
|
|
273
|
-
super.focusoutHandler(e);
|
|
274
|
-
if (!this.open) {
|
|
275
|
-
return true;
|
|
276
|
-
}
|
|
277
|
-
const focusTarget = e.relatedTarget;
|
|
278
|
-
if (this.isSameNode(focusTarget)) {
|
|
279
|
-
this.focus();
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
if (!((_a = this.options) === null || _a === void 0 ? void 0 : _a.includes(focusTarget))) {
|
|
283
|
-
this.open = false;
|
|
284
|
-
if (this.indexWhenOpened !== this.selectedIndex) {
|
|
285
|
-
this.updateValue(true);
|
|
286
|
-
}
|
|
334
|
+
stepChanged() {
|
|
335
|
+
if (this.proxy instanceof HTMLInputElement) {
|
|
336
|
+
this.proxy.step = `${this.step}`;
|
|
287
337
|
}
|
|
338
|
+
this.updateStepMultiplier();
|
|
339
|
+
this.validate();
|
|
288
340
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
* @param source - the source object
|
|
293
|
-
* @param propertyName - the property to evaluate
|
|
294
|
-
*
|
|
295
|
-
* @internal
|
|
296
|
-
* @override
|
|
297
|
-
*/
|
|
298
|
-
handleChange(source, propertyName) {
|
|
299
|
-
super.handleChange(source, propertyName);
|
|
300
|
-
if (propertyName === "value") {
|
|
301
|
-
this.updateValue();
|
|
341
|
+
orientationChanged() {
|
|
342
|
+
if (this.$fastController.isConnected) {
|
|
343
|
+
this.setThumbPositionForOrientation(this.direction);
|
|
302
344
|
}
|
|
303
345
|
}
|
|
304
346
|
/**
|
|
305
|
-
* Synchronize the form-associated proxy and updates the value property of the element.
|
|
306
|
-
*
|
|
307
|
-
* @param prev - the previous collection of slotted option elements
|
|
308
|
-
* @param next - the next collection of slotted option elements
|
|
309
|
-
*
|
|
310
347
|
* @internal
|
|
311
348
|
*/
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
this.
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
});
|
|
322
|
-
this.setProxyOptions();
|
|
323
|
-
this.updateValue();
|
|
349
|
+
connectedCallback() {
|
|
350
|
+
super.connectedCallback();
|
|
351
|
+
this.proxy.setAttribute("type", "range");
|
|
352
|
+
this.direction = getDirection(this);
|
|
353
|
+
this.updateStepMultiplier();
|
|
354
|
+
this.setupTrackConstraints();
|
|
355
|
+
this.setupListeners();
|
|
356
|
+
this.setupDefaultValue();
|
|
357
|
+
this.setThumbPositionForOrientation(this.direction);
|
|
324
358
|
}
|
|
325
359
|
/**
|
|
326
|
-
* Prevents focus when size is set and a scrollbar is clicked.
|
|
327
|
-
*
|
|
328
|
-
* @param e - the mouse event object
|
|
329
|
-
*
|
|
330
|
-
* @override
|
|
331
360
|
* @internal
|
|
332
361
|
*/
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
if (e.offsetX >= 0 && e.offsetX <= ((_a = this.listbox) === null || _a === void 0 ? void 0 : _a.scrollWidth)) {
|
|
336
|
-
return super.mousedownHandler(e);
|
|
337
|
-
}
|
|
338
|
-
return this.collapsible;
|
|
362
|
+
disconnectedCallback() {
|
|
363
|
+
this.setupListeners(true);
|
|
339
364
|
}
|
|
340
365
|
/**
|
|
341
|
-
*
|
|
366
|
+
* Increment the value by the step
|
|
342
367
|
*
|
|
343
|
-
* @
|
|
344
|
-
* @param next - the current multiple value
|
|
368
|
+
* @public
|
|
345
369
|
*/
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
this.
|
|
350
|
-
|
|
370
|
+
increment() {
|
|
371
|
+
const newVal = this.direction !== Direction.rtl && this.orientation !== Orientation.vertical
|
|
372
|
+
? Number(this.value) + Number(this.step)
|
|
373
|
+
: Number(this.value) - Number(this.step);
|
|
374
|
+
const incrementedVal = this.convertToConstrainedValue(newVal);
|
|
375
|
+
const incrementedValString = incrementedVal < Number(this.max) ? `${incrementedVal}` : `${this.max}`;
|
|
376
|
+
this.value = incrementedValString;
|
|
351
377
|
}
|
|
352
378
|
/**
|
|
353
|
-
*
|
|
354
|
-
*
|
|
355
|
-
* @param prev - the previous list of selected options
|
|
356
|
-
* @param next - the current list of selected options
|
|
379
|
+
* Decrement the value by the step
|
|
357
380
|
*
|
|
358
|
-
* @
|
|
359
|
-
* @internal
|
|
381
|
+
* @public
|
|
360
382
|
*/
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
proxyOption.selected = o.selected;
|
|
369
|
-
}
|
|
370
|
-
});
|
|
383
|
+
decrement() {
|
|
384
|
+
const newVal = this.direction !== Direction.rtl && this.orientation !== Orientation.vertical
|
|
385
|
+
? Number(this.value) - Number(this.step)
|
|
386
|
+
: Number(this.value) + Number(this.step);
|
|
387
|
+
const decrementedVal = this.convertToConstrainedValue(newVal);
|
|
388
|
+
const decrementedValString = decrementedVal > Number(this.min) ? `${decrementedVal}` : `${this.min}`;
|
|
389
|
+
this.value = decrementedValString;
|
|
371
390
|
}
|
|
372
391
|
/**
|
|
373
|
-
*
|
|
374
|
-
* the first selectable option.
|
|
392
|
+
* Places the thumb based on the current value
|
|
375
393
|
*
|
|
376
|
-
* @
|
|
377
|
-
* @
|
|
394
|
+
* @public
|
|
395
|
+
* @param direction - writing mode
|
|
378
396
|
*/
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
397
|
+
setThumbPositionForOrientation(direction) {
|
|
398
|
+
const newPct = convertPixelToPercent(Number(this.value), Number(this.min), Number(this.max), direction);
|
|
399
|
+
const percentage = (1 - newPct) * 100;
|
|
400
|
+
if (this.orientation === Orientation.horizontal) {
|
|
401
|
+
this.position = this.isDragging
|
|
402
|
+
? `right: ${percentage}%; transition: none;`
|
|
403
|
+
: `right: ${percentage}%; transition: all 0.2s ease;`;
|
|
386
404
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
*
|
|
392
|
-
* @internal
|
|
393
|
-
*/
|
|
394
|
-
setProxyOptions() {
|
|
395
|
-
if (this.proxy instanceof HTMLSelectElement && this.options) {
|
|
396
|
-
this.proxy.options.length = 0;
|
|
397
|
-
this.options.forEach(option => {
|
|
398
|
-
const proxyOption = option.proxy ||
|
|
399
|
-
(option instanceof HTMLOptionElement ? option.cloneNode() : null);
|
|
400
|
-
if (proxyOption) {
|
|
401
|
-
this.proxy.options.add(proxyOption);
|
|
402
|
-
}
|
|
403
|
-
});
|
|
405
|
+
else {
|
|
406
|
+
this.position = this.isDragging
|
|
407
|
+
? `bottom: ${percentage}%; transition: none;`
|
|
408
|
+
: `bottom: ${percentage}%; transition: all 0.2s ease;`;
|
|
404
409
|
}
|
|
405
410
|
}
|
|
406
411
|
/**
|
|
407
|
-
*
|
|
408
|
-
*
|
|
409
|
-
* @param e - the keyboard event
|
|
410
|
-
* @internal
|
|
412
|
+
* Update the step multiplier used to ensure rounding errors from steps that
|
|
413
|
+
* are not whole numbers
|
|
411
414
|
*/
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
const
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
break;
|
|
427
|
-
}
|
|
428
|
-
case keyEnter: {
|
|
429
|
-
e.preventDefault();
|
|
430
|
-
this.open = !this.open;
|
|
431
|
-
break;
|
|
432
|
-
}
|
|
433
|
-
case keyEscape: {
|
|
434
|
-
if (this.collapsible && this.open) {
|
|
435
|
-
e.preventDefault();
|
|
436
|
-
this.open = false;
|
|
437
|
-
}
|
|
438
|
-
break;
|
|
415
|
+
updateStepMultiplier() {
|
|
416
|
+
const stepString = this.step + "";
|
|
417
|
+
const decimalPlacesOfStep = !!(this.step % 1)
|
|
418
|
+
? stepString.length - stepString.indexOf(".") - 1
|
|
419
|
+
: 0;
|
|
420
|
+
this.stepMultiplier = Math.pow(10, decimalPlacesOfStep);
|
|
421
|
+
}
|
|
422
|
+
get midpoint() {
|
|
423
|
+
return `${this.convertToConstrainedValue((this.max + this.min) / 2)}`;
|
|
424
|
+
}
|
|
425
|
+
setupDefaultValue() {
|
|
426
|
+
if (typeof this.value === "string") {
|
|
427
|
+
if (this.value.length === 0) {
|
|
428
|
+
this.initialValue = this.midpoint;
|
|
439
429
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
this.
|
|
430
|
+
else {
|
|
431
|
+
const value = parseFloat(this.value);
|
|
432
|
+
if (!Number.isNaN(value) && (value < this.min || value > this.max)) {
|
|
433
|
+
this.value = this.midpoint;
|
|
444
434
|
}
|
|
445
|
-
return true;
|
|
446
435
|
}
|
|
447
436
|
}
|
|
448
|
-
if (!this.open && this.indexWhenOpened !== this.selectedIndex) {
|
|
449
|
-
this.updateValue(true);
|
|
450
|
-
this.indexWhenOpened = this.selectedIndex;
|
|
451
|
-
}
|
|
452
|
-
return !(key === keyArrowDown || key === keyArrowUp);
|
|
453
|
-
}
|
|
454
|
-
connectedCallback() {
|
|
455
|
-
super.connectedCallback();
|
|
456
|
-
this.forcedPosition = !!this.positionAttribute;
|
|
457
|
-
this.addEventListener("contentchange", this.updateDisplayValue);
|
|
458
|
-
}
|
|
459
|
-
disconnectedCallback() {
|
|
460
|
-
this.removeEventListener("contentchange", this.updateDisplayValue);
|
|
461
|
-
super.disconnectedCallback();
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* Updates the proxy's size property when the size attribute changes.
|
|
465
|
-
*
|
|
466
|
-
* @param prev - the previous size
|
|
467
|
-
* @param next - the current size
|
|
468
|
-
*
|
|
469
|
-
* @override
|
|
470
|
-
* @internal
|
|
471
|
-
*/
|
|
472
|
-
sizeChanged(prev, next) {
|
|
473
|
-
super.sizeChanged(prev, next);
|
|
474
|
-
if (this.proxy) {
|
|
475
|
-
this.proxy.size = next;
|
|
476
|
-
}
|
|
477
437
|
}
|
|
478
|
-
|
|
479
|
-
*
|
|
480
|
-
* @internal
|
|
481
|
-
*/
|
|
482
|
-
updateDisplayValue() {
|
|
483
|
-
if (this.collapsible) {
|
|
484
|
-
Observable.notify(this, "displayValue");
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
}
|
|
438
|
+
};
|
|
488
439
|
__decorate([
|
|
489
|
-
attr({ attribute: "
|
|
490
|
-
],
|
|
440
|
+
attr({ attribute: "readonly", mode: "boolean" })
|
|
441
|
+
], Slider$1.prototype, "readOnly", void 0);
|
|
491
442
|
__decorate([
|
|
492
|
-
|
|
493
|
-
],
|
|
443
|
+
observable
|
|
444
|
+
], Slider$1.prototype, "direction", void 0);
|
|
445
|
+
__decorate([
|
|
446
|
+
observable
|
|
447
|
+
], Slider$1.prototype, "isDragging", void 0);
|
|
494
448
|
__decorate([
|
|
495
449
|
observable
|
|
496
|
-
],
|
|
450
|
+
], Slider$1.prototype, "position", void 0);
|
|
497
451
|
__decorate([
|
|
498
|
-
|
|
499
|
-
],
|
|
452
|
+
observable
|
|
453
|
+
], Slider$1.prototype, "trackWidth", void 0);
|
|
500
454
|
__decorate([
|
|
501
455
|
observable
|
|
502
|
-
],
|
|
456
|
+
], Slider$1.prototype, "trackMinWidth", void 0);
|
|
503
457
|
__decorate([
|
|
504
458
|
observable
|
|
505
|
-
],
|
|
459
|
+
], Slider$1.prototype, "trackHeight", void 0);
|
|
460
|
+
__decorate([
|
|
461
|
+
observable
|
|
462
|
+
], Slider$1.prototype, "trackLeft", void 0);
|
|
463
|
+
__decorate([
|
|
464
|
+
observable
|
|
465
|
+
], Slider$1.prototype, "trackMinHeight", void 0);
|
|
466
|
+
__decorate([
|
|
467
|
+
observable
|
|
468
|
+
], Slider$1.prototype, "valueTextFormatter", void 0);
|
|
469
|
+
__decorate([
|
|
470
|
+
attr({ converter: nullableNumberConverter })
|
|
471
|
+
], Slider$1.prototype, "min", void 0);
|
|
472
|
+
__decorate([
|
|
473
|
+
attr({ converter: nullableNumberConverter })
|
|
474
|
+
], Slider$1.prototype, "max", void 0);
|
|
475
|
+
__decorate([
|
|
476
|
+
attr({ converter: nullableNumberConverter })
|
|
477
|
+
], Slider$1.prototype, "step", void 0);
|
|
478
|
+
__decorate([
|
|
479
|
+
attr
|
|
480
|
+
], Slider$1.prototype, "orientation", void 0);
|
|
481
|
+
__decorate([
|
|
482
|
+
attr
|
|
483
|
+
], Slider$1.prototype, "mode", void 0);
|
|
484
|
+
|
|
506
485
|
/**
|
|
507
|
-
*
|
|
508
|
-
*
|
|
509
|
-
*
|
|
486
|
+
* This method keeps a given value within the bounds of a min and max value. If the value
|
|
487
|
+
* is larger than the max, the minimum value will be returned. If the value is smaller than the minimum,
|
|
488
|
+
* the maximum will be returned. Otherwise, the value is returned un-changed.
|
|
510
489
|
*/
|
|
511
|
-
|
|
490
|
+
/**
|
|
491
|
+
* Ensures that a value is between a min and max value. If value is lower than min, min will be returned.
|
|
492
|
+
* If value is greater than max, max will be returned.
|
|
493
|
+
*/
|
|
494
|
+
function limit(min, max, value) {
|
|
495
|
+
return Math.min(Math.max(value, min), max);
|
|
512
496
|
}
|
|
513
|
-
__decorate([
|
|
514
|
-
observable
|
|
515
|
-
], DelegatesARIASelect.prototype, "ariaControls", void 0);
|
|
516
|
-
applyMixins(DelegatesARIASelect, DelegatesARIAListbox);
|
|
517
|
-
applyMixins(Select$1, StartEnd, DelegatesARIASelect);
|
|
518
497
|
|
|
519
|
-
|
|
498
|
+
const styles = ":host {\n display: inline-block;\n width: 100%;\n}\n\n:host([orientation=vertical]) {\n height: 100%;\n min-height: calc(var(--_thumb-interaction-indicator-size) * 5);\n}\n\n.control {\n --_thumb-size: 12px;\n --_thumb-interaction-indicator-size: 36px;\n height: var(--_thumb-interaction-indicator-size);\n cursor: pointer;\n outline: none;\n user-select: none;\n}\n@supports selector(:focus-visible) {\n .control:focus-visible {\n outline: none;\n }\n}\n.control .positioning-region {\n position: relative;\n}\n.control .track {\n position: absolute;\n background: var(--_track-background-color);\n border-radius: 4px;\n}\n.control .track .track-start {\n position: absolute;\n left: 0;\n height: 100%;\n background: var(--_track-start-background-color);\n border-radius: 4px;\n}\n.control .thumb-container {\n position: absolute;\n width: var(--_thumb-interaction-indicator-size);\n height: var(--_thumb-interaction-indicator-size);\n cursor: inherit;\n touch-action: none;\n}\n.control .thumb-container::before {\n position: absolute;\n display: block;\n width: var(--_thumb-interaction-indicator-size);\n height: var(--_thumb-interaction-indicator-size);\n background-color: var(--_track-start-background-color);\n border-radius: 50%;\n content: \"\";\n opacity: var(--_thumb-interaction-indicator-alpha, 0);\n transition: opacity 0.2s ease-out 0s;\n}\n.control .thumb-container::after {\n position: absolute;\n display: block;\n width: var(--_thumb-size);\n height: var(--_thumb-size);\n background-color: var(--_track-start-background-color);\n border-radius: 50%;\n content: \"\";\n inset: calc((var(--_thumb-interaction-indicator-size) - var(--_thumb-size)) / 2);\n}\n.control[aria-orientation=horizontal] {\n width: calc(100% - var(--_thumb-size));\n min-width: var(--_thumb-size);\n margin-left: calc(var(--_thumb-size) / 2);\n}\n.control[aria-orientation=horizontal] .track {\n top: calc((var(--_thumb-interaction-indicator-size) - 2px) / 2);\n right: 0;\n left: 0;\n height: 2px;\n}\n.control[aria-orientation=horizontal] .track .mark {\n width: 100%;\n height: 4px;\n}\n.control[aria-orientation=horizontal] .thumb-container {\n transform: translateX(calc(var(--_thumb-interaction-indicator-size) / 2));\n}\n.control[aria-orientation=vertical] {\n height: calc(100% - var(--_thumb-interaction-indicator-size));\n min-height: var(--_thumb-interaction-indicator-size);\n margin-top: calc(var(--_thumb-interaction-indicator-size) / 2);\n}\n.control[aria-orientation=vertical] .positioning-region {\n height: 100%;\n}\n.control[aria-orientation=vertical] .track {\n left: calc((var(--_thumb-interaction-indicator-size) - 2px) / 2);\n width: 2px;\n height: 100%;\n}\n.control[aria-orientation=vertical] .track .mark {\n width: 4px;\n height: 100%;\n}\n.control[aria-orientation=vertical] .track-start {\n top: 0;\n width: 100%;\n height: auto;\n}\n.control[aria-orientation=vertical] .thumb-container {\n transform: translateY(calc(var(--_thumb-interaction-indicator-size) / 2));\n}\n.control.disabled {\n --_track-background-color: var(--vvd-color-neutral-100);\n --_track-start-background-color: var(--vvd-color-neutral-500);\n cursor: not-allowed;\n pointer-events: none;\n}\n.control:not(.disabled) {\n --_track-background-color: var(--vvd-color-neutral-300);\n --_track-start-background-color: var(--vvd-color-canvas-text);\n}\n.control:not(.disabled) .thumb-container:hover {\n --_thumb-interaction-indicator-alpha: 0.12;\n}\n.control:not(.disabled) .thumb-container:active {\n --_thumb-interaction-indicator-alpha: 0.25;\n}\n\n.focus-indicator {\n --focus-inset: -3px;\n --focus-stroke-gap-color: transparent;\n border-radius: 50%;\n}\n.control:not(:focus-visible) .focus-indicator {\n display: none;\n}";
|
|
520
499
|
|
|
521
|
-
|
|
500
|
+
var __defProp = Object.defineProperty;
|
|
501
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
502
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
503
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
504
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
505
|
+
if (decorator = decorators[i])
|
|
506
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
507
|
+
if (kind && result)
|
|
508
|
+
__defProp(target, key, result);
|
|
509
|
+
return result;
|
|
510
|
+
};
|
|
511
|
+
class Slider extends Slider$1 {
|
|
522
512
|
constructor() {
|
|
523
513
|
super(...arguments);
|
|
524
|
-
this.
|
|
525
|
-
}
|
|
526
|
-
connectedCallback() {
|
|
527
|
-
super.connectedCallback();
|
|
528
|
-
this._popup.anchor = this._anchor;
|
|
514
|
+
this.markers = false;
|
|
529
515
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
516
|
+
/**
|
|
517
|
+
* TO BE REMOVED WHEN UPGRADING TO FAST-FOUNDATION 3
|
|
518
|
+
*
|
|
519
|
+
* @internal
|
|
520
|
+
*/
|
|
521
|
+
valueChanged(previous, next) {
|
|
522
|
+
if (this.$fastController.isConnected) {
|
|
523
|
+
const nextAsNumber = parseFloat(next);
|
|
524
|
+
const value = limit(
|
|
525
|
+
this.min,
|
|
526
|
+
this.max,
|
|
527
|
+
this["convertToConstrainedValue"](nextAsNumber)
|
|
528
|
+
).toString();
|
|
529
|
+
if (value !== next) {
|
|
530
|
+
this.value = value;
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
super.valueChanged(previous, value);
|
|
534
|
+
}
|
|
534
535
|
}
|
|
535
|
-
};
|
|
536
|
-
__decorate([attr, __metadata("design:type", String)], Select.prototype, "appearance", void 0);
|
|
537
|
-
__decorate([attr, __metadata("design:type", String)], Select.prototype, "shape", void 0);
|
|
538
|
-
__decorate([observable, __metadata("design:type", Array)], Select.prototype, "metaSlottedContent", void 0);
|
|
539
|
-
__decorate([attr({
|
|
540
|
-
mode: 'boolean',
|
|
541
|
-
attribute: 'fixed-dropdown'
|
|
542
|
-
}), __metadata("design:type", Object)], Select.prototype, "fixedDropdown", void 0);
|
|
543
|
-
Select = __decorate([errorText, formElements], Select);
|
|
544
|
-
applyMixins(Select, AffixIconWithTrailing, FormElementHelperText, FormElementSuccessText);
|
|
545
|
-
|
|
546
|
-
const getStateClasses = ({
|
|
547
|
-
shape,
|
|
548
|
-
disabled,
|
|
549
|
-
appearance,
|
|
550
|
-
metaSlottedContent,
|
|
551
|
-
errorValidationMessage,
|
|
552
|
-
successText
|
|
553
|
-
}) => classNames(['disabled', disabled], [`appearance-${appearance}`, Boolean(appearance)], [`shape-${shape}`, Boolean(shape)], ['has-meta', Boolean(metaSlottedContent === null || metaSlottedContent === void 0 ? void 0 : metaSlottedContent.length)], ['error connotation-alert', Boolean(errorValidationMessage)], ['success connotation-success', !!successText], ['has-meta', Boolean(metaSlottedContent === null || metaSlottedContent === void 0 ? void 0 : metaSlottedContent.length)]);
|
|
554
|
-
function renderLabel() {
|
|
555
|
-
return html`
|
|
556
|
-
<label for="control" class="label">
|
|
557
|
-
${x => x.label}
|
|
558
|
-
</label>`;
|
|
559
536
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
537
|
+
__decorateClass([
|
|
538
|
+
attr({
|
|
539
|
+
mode: "boolean"
|
|
540
|
+
})
|
|
541
|
+
], Slider.prototype, "markers", 2);
|
|
542
|
+
|
|
543
|
+
const getClasses = ({ disabled }) => classNames(
|
|
544
|
+
"control",
|
|
545
|
+
["disabled", Boolean(disabled)]
|
|
546
|
+
);
|
|
547
|
+
const getMarkersTemplate = (isHorizontal, numMarkers) => {
|
|
548
|
+
const placeholder = isHorizontal ? ["right", "center", "", "100% repeat-x"] : ["bottom", "top", "100%", "repeat-y"];
|
|
563
549
|
return html`
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
<div class="selected-value">
|
|
571
|
-
<slot name="icon">
|
|
572
|
-
${when(x => x.icon, html`${x => affixIconTemplate(x.icon)}`)}
|
|
573
|
-
</slot>
|
|
574
|
-
<span class="text">${x => x.displayValue}</span>
|
|
575
|
-
<slot name="meta" ${slotted('metaSlottedContent')}></slot>
|
|
576
|
-
</div>
|
|
577
|
-
${() => affixIconTemplate('chevron-down-line')}
|
|
578
|
-
${() => focusTemplate}
|
|
579
|
-
</div>
|
|
580
|
-
`;
|
|
581
|
-
}
|
|
582
|
-
function setFixedDropdownVarWidth(x) {
|
|
583
|
-
return x.open && x.fixedDropdown ? `--_select-fixed-width: ${Math.round(x.getBoundingClientRect().width)}px` : null;
|
|
584
|
-
}
|
|
585
|
-
function renderControl(context) {
|
|
550
|
+
<div class="mark" style="
|
|
551
|
+
background: linear-gradient(to ${placeholder[0]}, currentcolor 3px, transparent 0px)
|
|
552
|
+
0px ${placeholder[1]} / ${placeholder[2]} calc((100% - 3px) / ${numMarkers}) ${placeholder[3]}
|
|
553
|
+
"></div>`;
|
|
554
|
+
};
|
|
555
|
+
const SliderTemplate = (context) => {
|
|
586
556
|
const focusTemplate = focusTemplateFactory(context);
|
|
587
|
-
const popupTag = context.tagFor(Popup);
|
|
588
557
|
return html`
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
?disabled="${x => x.disabled}"
|
|
605
|
-
${ref('listbox')}
|
|
606
|
-
class="list-box"
|
|
607
|
-
>
|
|
608
|
-
${when(x => x.multiple, focusTemplate)}
|
|
609
|
-
<slot
|
|
610
|
-
${slotted({
|
|
611
|
-
filter: Listbox$1.slottedOptionFilter,
|
|
612
|
-
flatten: true,
|
|
613
|
-
property: 'slottedOptions'
|
|
614
|
-
})}
|
|
615
|
-
></slot>
|
|
616
|
-
</div>
|
|
617
|
-
</${popupTag}>
|
|
558
|
+
<div
|
|
559
|
+
role="slider"
|
|
560
|
+
tabindex="${(x) => x.disabled ? null : 0}"
|
|
561
|
+
aria-valuetext="${(x) => x.valueTextFormatter(x.value)}"
|
|
562
|
+
aria-valuenow="${(x) => x.value}"
|
|
563
|
+
aria-valuemin="${(x) => x.min}"
|
|
564
|
+
aria-valuemax="${(x) => x.max}"
|
|
565
|
+
aria-disabled="${(x) => x.disabled ? true : void 0}"
|
|
566
|
+
aria-orientation="${(x) => x.orientation}"
|
|
567
|
+
class="${getClasses} ${(x) => x.orientation}"
|
|
568
|
+
>
|
|
569
|
+
<div class="positioning-region">
|
|
570
|
+
<div ${ref("track")} class="track">
|
|
571
|
+
<div class="track-start" style="${(x) => x.position}"></div>
|
|
572
|
+
${(x) => x.markers ? getMarkersTemplate(x.orientation === Orientation$1.horizontal, Math.floor((x.max - x.min) / x.step)) : void 0}
|
|
618
573
|
</div>
|
|
619
|
-
${
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
${when(x => x.successText, getFeedbackTemplate('success', context))}
|
|
625
|
-
`;
|
|
626
|
-
}
|
|
627
|
-
const SelectTemplate = context => {
|
|
628
|
-
return html`
|
|
629
|
-
<template class="base"
|
|
630
|
-
aria-label="${x => x.ariaLabel ? x.ariaLabel : x.label}"
|
|
631
|
-
aria-activedescendant="${x => x.ariaActiveDescendant}"
|
|
632
|
-
aria-controls="${x => x.ariaControls}"
|
|
633
|
-
aria-disabled="${x => x.ariaDisabled}"
|
|
634
|
-
aria-expanded="${x => x.ariaExpanded}"
|
|
635
|
-
aria-haspopup="${x => x.collapsible ? 'listbox' : null}"
|
|
636
|
-
aria-multiselectable="${x => x.ariaMultiSelectable}"
|
|
637
|
-
?open="${x => x.open}"
|
|
638
|
-
role="combobox"
|
|
639
|
-
tabindex="${x => !x.disabled ? '0' : null}"
|
|
640
|
-
@click="${(x, c) => x.clickHandler(c.event)}"
|
|
641
|
-
@focusin="${(x, c) => x.focusinHandler(c.event)}"
|
|
642
|
-
@focusout="${(x, c) => x.focusoutHandler(c.event)}"
|
|
643
|
-
@keydown="${(x, c) => x.keydownHandler(c.event)}"
|
|
644
|
-
@mousedown="${(x, c) => x.mousedownHandler(c.event)}"
|
|
645
|
-
>
|
|
646
|
-
${renderControl(context)}
|
|
647
|
-
</template>
|
|
648
|
-
`;
|
|
574
|
+
<div ${ref("thumb")} class="thumb-container" style="${(x) => x.position}">
|
|
575
|
+
${() => focusTemplate}
|
|
576
|
+
</div>
|
|
577
|
+
</div>
|
|
578
|
+
</div>`;
|
|
649
579
|
};
|
|
650
580
|
|
|
651
|
-
const
|
|
652
|
-
baseName:
|
|
653
|
-
template:
|
|
654
|
-
styles
|
|
581
|
+
const sliderDefinition = Slider.compose({
|
|
582
|
+
baseName: "slider",
|
|
583
|
+
template: SliderTemplate,
|
|
584
|
+
styles
|
|
655
585
|
});
|
|
656
|
-
const
|
|
657
|
-
const
|
|
586
|
+
const sliderRegistries = [sliderDefinition(), ...focusRegistries];
|
|
587
|
+
const registerSlider = registerFactory(sliderRegistries);
|
|
658
588
|
|
|
659
|
-
export {
|
|
589
|
+
export { sliderRegistries as a, registerSlider as r, sliderDefinition as s };
|