@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/definition43.js
CHANGED
|
@@ -1,34 +1,22 @@
|
|
|
1
|
-
import { F as FoundationElement, _ as __decorate, a as attr, o as observable,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import { a as keyHome, k as keyEnd, b as keyArrowDown, i as keyArrowLeft, c as keyArrowUp, h as keyArrowRight } from './key-codes.js';
|
|
1
|
+
import { F as FoundationElement, _ as __decorate, a as attr, o as observable, h as html, r as registerFactory } from './index.js';
|
|
2
|
+
import { a as iconRegistries } from './definition24.js';
|
|
3
|
+
import { f as focusRegistries } from './definition55.js';
|
|
4
|
+
import { C as CheckableFormAssociated } from './form-associated.js';
|
|
5
|
+
import { a as keySpace, k as keyEnter } from './key-codes.js';
|
|
6
|
+
import './affix.js';
|
|
8
7
|
import { f as focusTemplateFactory } from './focus2.js';
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
8
|
+
import './index2.js';
|
|
9
|
+
import { w as when } from './when.js';
|
|
11
10
|
import { c as classNames } from './class-names.js';
|
|
12
11
|
|
|
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 {
|
|
12
|
+
class _Switch extends FoundationElement {
|
|
25
13
|
}
|
|
26
14
|
/**
|
|
27
|
-
* A form-associated base class for the {@link @microsoft/fast-foundation#(
|
|
15
|
+
* A form-associated base class for the {@link @microsoft/fast-foundation#(Switch:class)} component.
|
|
28
16
|
*
|
|
29
17
|
* @internal
|
|
30
18
|
*/
|
|
31
|
-
class
|
|
19
|
+
class FormAssociatedSwitch extends CheckableFormAssociated(_Switch) {
|
|
32
20
|
constructor() {
|
|
33
21
|
super(...arguments);
|
|
34
22
|
this.proxy = document.createElement("input");
|
|
@@ -36,531 +24,144 @@ class FormAssociatedSlider extends FormAssociated(_Slider) {
|
|
|
36
24
|
}
|
|
37
25
|
|
|
38
26
|
/**
|
|
39
|
-
*
|
|
40
|
-
* @
|
|
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 }.
|
|
27
|
+
* A Switch Custom HTML Element.
|
|
28
|
+
* Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#switch | ARIA switch }.
|
|
48
29
|
*
|
|
49
|
-
* @slot
|
|
50
|
-
* @slot
|
|
51
|
-
* @slot
|
|
52
|
-
* @
|
|
53
|
-
* @csspart
|
|
54
|
-
* @csspart
|
|
55
|
-
* @csspart
|
|
56
|
-
* @csspart
|
|
57
|
-
* @fires change -
|
|
30
|
+
* @slot - The deafult slot for the label
|
|
31
|
+
* @slot checked-message - The message when in a checked state
|
|
32
|
+
* @slot unchecked-message - The message when in an unchecked state
|
|
33
|
+
* @csspart label - The label
|
|
34
|
+
* @csspart switch - The element representing the switch, which wraps the indicator
|
|
35
|
+
* @csspart status-message - The wrapper for the status messages
|
|
36
|
+
* @csspart checked-message - The checked message
|
|
37
|
+
* @csspart unchecked-message - The unchecked message
|
|
38
|
+
* @fires change - Emits a custom change event when the checked state changes
|
|
58
39
|
*
|
|
59
40
|
* @public
|
|
60
41
|
*/
|
|
61
|
-
|
|
42
|
+
let Switch$1 = class Switch extends FormAssociatedSwitch {
|
|
62
43
|
constructor() {
|
|
63
|
-
super(
|
|
64
|
-
/**
|
|
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;
|
|
44
|
+
super();
|
|
84
45
|
/**
|
|
46
|
+
* The element's value to be included in form submission when checked.
|
|
47
|
+
* Default to "on" to reach parity with input[type="checkbox"]
|
|
48
|
+
*
|
|
85
49
|
* @internal
|
|
86
50
|
*/
|
|
87
|
-
this.
|
|
51
|
+
this.initialValue = "on";
|
|
88
52
|
/**
|
|
89
53
|
* @internal
|
|
90
54
|
*/
|
|
91
|
-
this.trackMinHeight = 0;
|
|
92
|
-
/**
|
|
93
|
-
* Custom function that generates a string for the component's "aria-valuetext" attribute based on the current value.
|
|
94
|
-
*
|
|
95
|
-
* @public
|
|
96
|
-
*/
|
|
97
|
-
this.valueTextFormatter = () => null;
|
|
98
|
-
/**
|
|
99
|
-
* The minimum allowed value.
|
|
100
|
-
*
|
|
101
|
-
* @defaultValue - 0
|
|
102
|
-
* @public
|
|
103
|
-
* @remarks
|
|
104
|
-
* HTML Attribute: min
|
|
105
|
-
*/
|
|
106
|
-
this.min = 0; // Map to proxy element.
|
|
107
|
-
/**
|
|
108
|
-
* The maximum allowed value.
|
|
109
|
-
*
|
|
110
|
-
* @defaultValue - 10
|
|
111
|
-
* @public
|
|
112
|
-
* @remarks
|
|
113
|
-
* HTML Attribute: max
|
|
114
|
-
*/
|
|
115
|
-
this.max = 10; // Map to proxy element.
|
|
116
|
-
/**
|
|
117
|
-
* Value to increment or decrement via arrow keys, mouse click or drag.
|
|
118
|
-
*
|
|
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
|
|
130
|
-
*/
|
|
131
|
-
this.orientation = Orientation.horizontal;
|
|
132
|
-
/**
|
|
133
|
-
* The selection mode.
|
|
134
|
-
*
|
|
135
|
-
* @public
|
|
136
|
-
* @remarks
|
|
137
|
-
* HTML Attribute: mode
|
|
138
|
-
*/
|
|
139
|
-
this.mode = SliderMode.singleValue;
|
|
140
55
|
this.keypressHandler = (e) => {
|
|
141
56
|
if (this.readOnly) {
|
|
142
57
|
return;
|
|
143
58
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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);
|
|
59
|
+
switch (e.key) {
|
|
60
|
+
case keyEnter:
|
|
61
|
+
case keySpace:
|
|
62
|
+
this.checked = !this.checked;
|
|
63
|
+
break;
|
|
192
64
|
}
|
|
193
65
|
};
|
|
194
66
|
/**
|
|
195
67
|
* @internal
|
|
196
68
|
*/
|
|
197
|
-
this.
|
|
198
|
-
|
|
199
|
-
|
|
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
|
-
}
|
|
69
|
+
this.clickHandler = (e) => {
|
|
70
|
+
if (!this.disabled && !this.readOnly) {
|
|
71
|
+
this.checked = !this.checked;
|
|
272
72
|
}
|
|
273
73
|
};
|
|
274
|
-
this.
|
|
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
|
-
};
|
|
74
|
+
this.proxy.setAttribute("type", "checkbox");
|
|
295
75
|
}
|
|
296
76
|
readOnlyChanged() {
|
|
297
77
|
if (this.proxy instanceof HTMLInputElement) {
|
|
298
78
|
this.proxy.readOnly = this.readOnly;
|
|
299
79
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
*
|
|
304
|
-
* @public
|
|
305
|
-
*/
|
|
306
|
-
get valueAsNumber() {
|
|
307
|
-
return parseFloat(super.value);
|
|
308
|
-
}
|
|
309
|
-
set valueAsNumber(next) {
|
|
310
|
-
this.value = next.toString();
|
|
80
|
+
this.readOnly
|
|
81
|
+
? this.classList.add("readonly")
|
|
82
|
+
: this.classList.remove("readonly");
|
|
311
83
|
}
|
|
312
84
|
/**
|
|
313
85
|
* @internal
|
|
314
86
|
*/
|
|
315
|
-
|
|
316
|
-
super.
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
this
|
|
321
|
-
}
|
|
322
|
-
minChanged() {
|
|
323
|
-
if (this.proxy instanceof HTMLInputElement) {
|
|
324
|
-
this.proxy.min = `${this.min}`;
|
|
325
|
-
}
|
|
326
|
-
this.validate();
|
|
327
|
-
}
|
|
328
|
-
maxChanged() {
|
|
329
|
-
if (this.proxy instanceof HTMLInputElement) {
|
|
330
|
-
this.proxy.max = `${this.max}`;
|
|
331
|
-
}
|
|
332
|
-
this.validate();
|
|
333
|
-
}
|
|
334
|
-
stepChanged() {
|
|
335
|
-
if (this.proxy instanceof HTMLInputElement) {
|
|
336
|
-
this.proxy.step = `${this.step}`;
|
|
337
|
-
}
|
|
338
|
-
this.updateStepMultiplier();
|
|
339
|
-
this.validate();
|
|
340
|
-
}
|
|
341
|
-
orientationChanged() {
|
|
342
|
-
if (this.$fastController.isConnected) {
|
|
343
|
-
this.setThumbPositionForOrientation(this.direction);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* @internal
|
|
348
|
-
*/
|
|
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);
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* @internal
|
|
361
|
-
*/
|
|
362
|
-
disconnectedCallback() {
|
|
363
|
-
this.setupListeners(true);
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Increment the value by the step
|
|
367
|
-
*
|
|
368
|
-
* @public
|
|
369
|
-
*/
|
|
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;
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* Decrement the value by the step
|
|
380
|
-
*
|
|
381
|
-
* @public
|
|
382
|
-
*/
|
|
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;
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* Places the thumb based on the current value
|
|
393
|
-
*
|
|
394
|
-
* @public
|
|
395
|
-
* @param direction - writing mode
|
|
396
|
-
*/
|
|
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;`;
|
|
404
|
-
}
|
|
405
|
-
else {
|
|
406
|
-
this.position = this.isDragging
|
|
407
|
-
? `bottom: ${percentage}%; transition: none;`
|
|
408
|
-
: `bottom: ${percentage}%; transition: all 0.2s ease;`;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* Update the step multiplier used to ensure rounding errors from steps that
|
|
413
|
-
* are not whole numbers
|
|
414
|
-
*/
|
|
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;
|
|
429
|
-
}
|
|
430
|
-
else {
|
|
431
|
-
const value = parseFloat(this.value);
|
|
432
|
-
if (!Number.isNaN(value) && (value < this.min || value > this.max)) {
|
|
433
|
-
this.value = this.midpoint;
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
}
|
|
87
|
+
checkedChanged(prev, next) {
|
|
88
|
+
super.checkedChanged(prev, next);
|
|
89
|
+
/**
|
|
90
|
+
* @deprecated - this behavior already exists in the template and should not exist in the class.
|
|
91
|
+
*/
|
|
92
|
+
this.checked ? this.classList.add("checked") : this.classList.remove("checked");
|
|
437
93
|
}
|
|
438
|
-
}
|
|
94
|
+
};
|
|
439
95
|
__decorate([
|
|
440
96
|
attr({ attribute: "readonly", mode: "boolean" })
|
|
441
|
-
],
|
|
442
|
-
__decorate([
|
|
443
|
-
observable
|
|
444
|
-
], Slider$1.prototype, "direction", void 0);
|
|
445
|
-
__decorate([
|
|
446
|
-
observable
|
|
447
|
-
], Slider$1.prototype, "isDragging", void 0);
|
|
448
|
-
__decorate([
|
|
449
|
-
observable
|
|
450
|
-
], Slider$1.prototype, "position", void 0);
|
|
451
|
-
__decorate([
|
|
452
|
-
observable
|
|
453
|
-
], Slider$1.prototype, "trackWidth", void 0);
|
|
97
|
+
], Switch$1.prototype, "readOnly", void 0);
|
|
454
98
|
__decorate([
|
|
455
99
|
observable
|
|
456
|
-
],
|
|
457
|
-
__decorate([
|
|
458
|
-
observable
|
|
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
|
-
|
|
485
|
-
/**
|
|
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.
|
|
489
|
-
*/
|
|
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);
|
|
496
|
-
}
|
|
100
|
+
], Switch$1.prototype, "defaultSlottedNodes", void 0);
|
|
497
101
|
|
|
498
|
-
|
|
102
|
+
const styles = "/**\n * Do not edit directly\n * Generated on Mon, 04 Sep 2023 12:44:18 GMT\n */\n.control {\n display: inline-flex;\n gap: 8px;\n}\n.control.connotation-cta {\n /* @cssprop [--vvd-switch-cta-primary-text=var(--vvd-color-canvas)] */\n --_connotation-color-primary-text: var(--vvd-switch-cta-primary-text, var(--vvd-color-canvas));\n /* @cssprop [--vvd-switch-cta-primary=var(--vvd-color-cta-500)] */\n --_connotation-color-primary: var(--vvd-switch-cta-primary, var(--vvd-color-cta-500));\n /* @cssprop [--vvd-switch-cta-primary-increment=var(--vvd-color-cta-600)] */\n --_connotation-color-primary-increment: var(--vvd-switch-cta-primary-increment, var(--vvd-color-cta-600));\n /* @cssprop [--vvd-switch-cta-backdrop=var(--vvd-color-cta-50)] */\n --_connotation-color-backdrop: var(--vvd-switch-cta-backdrop, var(--vvd-color-cta-50));\n /* @cssprop [--vvd-switch-cta-firm=var(--vvd-color-cta-600)] */\n --_connotation-color-firm: var(--vvd-switch-cta-firm, var(--vvd-color-cta-600));\n /* @cssprop [--vvd-switch-cta-intermediate=var(--vvd-color-cta-500)] */\n --_connotation-color-intermediate: var(--vvd-switch-cta-intermediate, var(--vvd-color-cta-500));\n}\n.control.connotation-alert {\n /* @cssprop [--vvd-switch-alert-primary-text=var(--vvd-color-canvas)] */\n --_connotation-color-primary-text: var(--vvd-switch-alert-primary-text, var(--vvd-color-canvas));\n /* @cssprop [--vvd-switch-alert-primary=var(--vvd-color-alert-500)] */\n --_connotation-color-primary: var(--vvd-switch-alert-primary, var(--vvd-color-alert-500));\n /* @cssprop [--vvd-switch-alert-primary-increment=var(--vvd-color-alert-600)] */\n --_connotation-color-primary-increment: var(--vvd-switch-alert-primary-increment, var(--vvd-color-alert-600));\n /* @cssprop [--vvd-switch-alert-backdrop=var(--vvd-color-alert-50)] */\n --_connotation-color-backdrop: var(--vvd-switch-alert-backdrop, var(--vvd-color-alert-50));\n /* @cssprop [--vvd-switch-alert-firm=var(--vvd-color-alert-600)] */\n --_connotation-color-firm: var(--vvd-switch-alert-firm, var(--vvd-color-alert-600));\n /* @cssprop [--vvd-switch-alert-intermediate=var(--vvd-color-alert-500)] */\n --_connotation-color-intermediate: var(--vvd-switch-alert-intermediate, var(--vvd-color-alert-500));\n}\n.control.connotation-success {\n /* @cssprop [--vvd-switch-success-primary-text=var(--vvd-color-canvas)] */\n --_connotation-color-primary-text: var(--vvd-switch-success-primary-text, var(--vvd-color-canvas));\n /* @cssprop [--vvd-switch-success-primary=var(--vvd-color-success-500)] */\n --_connotation-color-primary: var(--vvd-switch-success-primary, var(--vvd-color-success-500));\n /* @cssprop [--vvd-switch-success-primary-increment=var(--vvd-color-success-600)] */\n --_connotation-color-primary-increment: var(--vvd-switch-success-primary-increment, var(--vvd-color-success-600));\n /* @cssprop [--vvd-switch-success-backdrop=var(--vvd-color-success-50)] */\n --_connotation-color-backdrop: var(--vvd-switch-success-backdrop, var(--vvd-color-success-50));\n /* @cssprop [--vvd-switch-success-firm=var(--vvd-color-success-600)] */\n --_connotation-color-firm: var(--vvd-switch-success-firm, var(--vvd-color-success-600));\n /* @cssprop [--vvd-switch-success-intermediate=var(--vvd-color-success-500)] */\n --_connotation-color-intermediate: var(--vvd-switch-success-intermediate, var(--vvd-color-success-500));\n}\n.control:not(.connotation-cta, .connotation-alert, .connotation-success) {\n /* @cssprop [--vvd-switch-accent-primary-text=var(--vvd-color-canvas)] */\n --_connotation-color-primary-text: var(--vvd-switch-accent-primary-text, var(--vvd-color-canvas));\n /* @cssprop [--vvd-switch-accent-primary=var(--vvd-color-canvas-text)] */\n --_connotation-color-primary: var(--vvd-switch-accent-primary, var(--vvd-color-canvas-text));\n /* @cssprop [--vvd-switch-accent-primary-increment=var(--vvd-color-neutral-800)] */\n --_connotation-color-primary-increment: var(--vvd-switch-accent-primary-increment, var(--vvd-color-neutral-800));\n /* @cssprop [--vvd-switch-accent-backdrop=var(--vvd-color-canvas)] */\n --_connotation-color-backdrop: var(--vvd-switch-accent-backdrop, var(--vvd-color-canvas));\n /* @cssprop [--vvd-switch-accent-firm=var(--vvd-color-canvas-text)] */\n --_connotation-color-firm: var(--vvd-switch-accent-firm, var(--vvd-color-canvas-text));\n /* @cssprop [--vvd-switch-accent-intermediate=var(--vvd-color-neutral-500)] */\n --_connotation-color-intermediate: var(--vvd-switch-accent-intermediate, var(--vvd-color-neutral-500));\n}\n.control {\n --_appearance-color-text: var(--vvd-color-canvas-text);\n --_appearance-color-fill: var(--_connotation-color-backdrop);\n --_appearance-color-outline: var(--_connotation-color-intermediate);\n}\n.control.appearance-filled {\n --_appearance-color-text: var(--_connotation-color-primary-text);\n --_appearance-color-fill: var(--_connotation-color-primary);\n --_appearance-color-outline: transparent;\n}\n.control:where(:hover, .hover):where(:not(:disabled, .disabled, .readonly)) {\n --_appearance-color-text: var(--vvd-color-canvas-text);\n --_appearance-color-fill: var(--_connotation-color-backdrop);\n --_appearance-color-outline: var(--_connotation-color-firm);\n}\n.control:where(:hover, .hover):where(:not(:disabled, .disabled, .readonly)).appearance-filled {\n --_appearance-color-text: var(--_connotation-color-primary-text);\n --_appearance-color-fill: var(--_connotation-color-primary-increment);\n --_appearance-color-outline: transparent;\n}\n.control:where(:disabled, .disabled) {\n --_appearance-color-text: var(--vvd-color-neutral-300);\n --_appearance-color-fill: var(--vvd-color-neutral-100);\n --_appearance-color-outline: var(--vvd-color-neutral-300);\n}\n.control:where(:disabled, .disabled).appearance-filled {\n --_appearance-color-text: var(--vvd-color-neutral-300);\n --_appearance-color-fill: var(--vvd-color-neutral-100);\n --_appearance-color-outline: transparent;\n}\n.control:where(.readonly):where(:not(:disabled, .disabled)) {\n --_appearance-color-text: var(--vvd-color-canvas-text);\n --_appearance-color-fill: var(--vvd-color-neutral-200);\n --_appearance-color-outline: var(--vvd-color-neutral-400);\n}\n.control:where(.readonly):where(:not(:disabled, .disabled)).appearance-filled {\n --_appearance-color-text: var(--vvd-color-neutral-800);\n --_appearance-color-fill: var(--vvd-color-neutral-200);\n --_appearance-color-outline: transparent;\n}\n@supports selector(:focus-visible) {\n .control:focus-visible {\n outline: none;\n }\n}\n@supports (user-select: none) {\n .control {\n user-select: none;\n }\n}\n.control:not(.disabled) {\n cursor: pointer;\n}\n.control.disabled {\n cursor: not-allowed;\n pointer-events: none;\n}\n\n.switch {\n --_switch-inline-size: calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 20)) * 1.8);\n position: relative;\n display: flex;\n box-sizing: border-box;\n align-items: center;\n background-color: var(--_appearance-color-fill);\n block-size: calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 20));\n border-radius: calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 20)) / .5);\n box-shadow: inset 0 0 0 1px var(--_appearance-color-outline);\n inline-size: var(--_switch-inline-size);\n transition: all 0.2s ease-in-out 0s;\n}\n\n.checked-indicator {\n --_switch-checked-indicator-size: calc(calc(1px * (40 + 4 * clamp(-1, var(--vvd-size-density, 0), 2) - 20)) / 1.6667);\n --_switch-gutter: calc(var(--_switch-checked-indicator-size) / 3);\n block-size: var(--_switch-checked-indicator-size);\n border-radius: inherit;\n inline-size: var(--_switch-checked-indicator-size);\n margin-inline-start: auto;\n transition: all 0.2s ease-in-out 0s;\n}\n.control.appearance-filled .checked-indicator {\n background-color: var(--vvd-color-neutral-100);\n}\n.control:not(.appearance-filled) .checked-indicator {\n background-color: var(--_appearance-color-outline);\n}\n.control:not(.checked) .checked-indicator {\n transform: translateX(calc(-1 * var(--_switch-inline-size) + var(--_switch-checked-indicator-size) + var(--_switch-gutter)));\n}\n.control.checked .checked-indicator {\n transform: translateX(calc(-1 * var(--_switch-gutter)));\n}\n\n.label {\n color: var(--vvd-color-canvas-text);\n cursor: pointer;\n font: var(--vvd-typography-base);\n}\n\n.focus-indicator {\n --focus-inset: -4px;\n --focus-stroke-gap-color: transparent;\n border-radius: 14px;\n}\n.control:not(:focus-visible) .focus-indicator {\n display: none;\n}";
|
|
499
103
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
}
|
|
513
|
-
super.valueChanged(previous, value);
|
|
514
|
-
}
|
|
515
|
-
}
|
|
104
|
+
var __defProp = Object.defineProperty;
|
|
105
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
106
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
107
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
108
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
109
|
+
if (decorator = decorators[i])
|
|
110
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
111
|
+
if (kind && result)
|
|
112
|
+
__defProp(target, key, result);
|
|
113
|
+
return result;
|
|
114
|
+
};
|
|
115
|
+
class Switch extends Switch$1 {
|
|
516
116
|
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
117
|
+
__decorateClass([
|
|
118
|
+
attr
|
|
119
|
+
], Switch.prototype, "label", 2);
|
|
120
|
+
__decorateClass([
|
|
121
|
+
attr
|
|
122
|
+
], Switch.prototype, "connotation", 2);
|
|
520
123
|
|
|
521
|
-
const getClasses = (
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
"></div>`;
|
|
531
|
-
};
|
|
532
|
-
const SliderTemplate = context => {
|
|
124
|
+
const getClasses = (_) => classNames(
|
|
125
|
+
"control",
|
|
126
|
+
["appearance-filled", _.checked && !_.disabled && !_.readOnly],
|
|
127
|
+
["checked", _.checked],
|
|
128
|
+
["disabled", _.disabled],
|
|
129
|
+
["readonly", _.readOnly],
|
|
130
|
+
[`connotation-${_.connotation}`, Boolean(_.checked) && Boolean(_.connotation)]
|
|
131
|
+
);
|
|
132
|
+
const SwitchTemplate = (context) => {
|
|
533
133
|
const focusTemplate = focusTemplateFactory(context);
|
|
534
134
|
return html`
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
<div ${ref('track')} class="track">
|
|
548
|
-
<div class="track-start" style="${x => x.position}"></div>
|
|
549
|
-
${x => x.markers ? getMarkersTemplate(x.orientation === Orientation$1.horizontal, Math.floor((x.max - x.min) / x.step)) : void 0}
|
|
550
|
-
</div>
|
|
551
|
-
<div ${ref('thumb')} class="thumb-container" style="${x => x.position}">
|
|
135
|
+
<div
|
|
136
|
+
class="${getClasses}"
|
|
137
|
+
role="switch"
|
|
138
|
+
aria-checked="${(x) => x.checked}"
|
|
139
|
+
aria-disabled="${(x) => x.disabled}"
|
|
140
|
+
aria-readonly="${(x) => x.readOnly}"
|
|
141
|
+
tabindex="${(x) => x.disabled ? null : 0}"
|
|
142
|
+
@keypress="${(x, c) => x.keypressHandler(c.event)}"
|
|
143
|
+
@click="${(x, c) => x.clickHandler(c.event)}"
|
|
144
|
+
>
|
|
145
|
+
<div class="switch">
|
|
146
|
+
<span class="checked-indicator"></span>
|
|
552
147
|
${() => focusTemplate}
|
|
553
148
|
</div>
|
|
149
|
+
${when((x) => x.label, html`<div class="label">
|
|
150
|
+
${(x) => x.label}
|
|
151
|
+
</div>`)}
|
|
554
152
|
</div>
|
|
555
|
-
|
|
153
|
+
`;
|
|
556
154
|
};
|
|
557
155
|
|
|
558
|
-
const
|
|
559
|
-
baseName:
|
|
560
|
-
template:
|
|
561
|
-
styles
|
|
156
|
+
const switchDefinition = Switch.compose({
|
|
157
|
+
baseName: "switch",
|
|
158
|
+
template: SwitchTemplate,
|
|
159
|
+
styles,
|
|
160
|
+
shadowOptions: {
|
|
161
|
+
delegatesFocus: true
|
|
162
|
+
}
|
|
562
163
|
});
|
|
563
|
-
const
|
|
564
|
-
const
|
|
164
|
+
const switchRegistries = [switchDefinition(), ...iconRegistries, ...focusRegistries];
|
|
165
|
+
const registerSwitch = registerFactory(switchRegistries);
|
|
565
166
|
|
|
566
|
-
export {
|
|
167
|
+
export { switchRegistries as a, registerSwitch as r, switchDefinition as s };
|