@vonage/vivid 3.51.0 → 3.53.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/README.md +1 -1
- package/accordion/index.cjs +1 -1
- package/accordion/index.js +1 -1
- package/accordion-item/index.cjs +1 -1
- package/accordion-item/index.js +1 -1
- package/alert/index.cjs +3 -3
- package/alert/index.js +3 -3
- package/appearance-ui/index.cjs +19 -11
- package/appearance-ui/index.js +19 -11
- package/audio-player/index.cjs +4 -3
- package/audio-player/index.js +4 -3
- package/avatar/index.cjs +1 -1
- package/avatar/index.js +1 -1
- package/badge/index.cjs +1 -1
- package/badge/index.js +1 -1
- package/banner/index.cjs +2 -2
- package/banner/index.js +2 -2
- package/breadcrumb-item/index.cjs +1 -1
- package/breadcrumb-item/index.js +1 -1
- package/button/index.cjs +2 -2
- package/button/index.js +2 -2
- package/card/index.cjs +2 -2
- package/card/index.js +2 -2
- package/checkbox/index.cjs +3 -2
- package/checkbox/index.js +3 -2
- package/combobox/index.cjs +5 -8
- package/combobox/index.js +5 -8
- package/custom-elements.json +2310 -769
- package/data-grid/index.cjs +1 -1
- package/data-grid/index.js +1 -1
- package/date-picker/index.cjs +7 -9
- package/date-picker/index.js +7 -9
- package/date-range-picker/index.cjs +7 -9
- package/date-range-picker/index.js +7 -9
- package/dial-pad/index.cjs +33 -0
- package/dial-pad/index.js +31 -0
- package/dialog/index.cjs +4 -4
- package/dialog/index.js +4 -4
- package/divider/index.cjs +1 -1
- package/divider/index.js +1 -1
- package/elevation/index.cjs +1 -1
- package/elevation/index.js +1 -1
- package/empty-state/index.cjs +2 -2
- package/empty-state/index.js +2 -2
- package/fab/index.cjs +2 -2
- package/fab/index.js +2 -2
- package/file-picker/index.cjs +4 -5
- package/file-picker/index.js +4 -5
- package/header/index.cjs +2 -2
- package/header/index.js +2 -2
- package/icon/index.cjs +1 -1
- package/icon/index.js +1 -1
- package/index.cjs +135 -123
- package/index.js +48 -46
- package/layout/index.cjs +1 -1
- package/layout/index.js +1 -1
- package/lib/avatar/definition.d.ts +1 -1
- package/lib/button/button.d.ts +1 -0
- package/lib/button/definition.d.ts +1 -1
- package/lib/calendar-event/definition.d.ts +1 -1
- package/lib/components.d.ts +3 -0
- package/lib/dial-pad/definition.d.ts +3 -0
- package/lib/dial-pad/dial-pad.d.ts +14 -0
- package/lib/dial-pad/dial-pad.template.d.ts +4 -0
- package/lib/dial-pad/locale.d.ts +18 -0
- package/lib/enums.d.ts +6 -0
- package/lib/layout/definition.d.ts +1 -1
- package/lib/menu-item/menu-item.d.ts +3 -0
- package/lib/range-slider/definition.d.ts +3 -0
- package/lib/range-slider/locale.d.ts +4 -0
- package/lib/range-slider/range-slider.d.ts +32 -0
- package/lib/range-slider/range-slider.form-associated.d.ts +10 -0
- package/lib/range-slider/range-slider.template.d.ts +4 -0
- package/lib/range-slider/utils/lerp.d.ts +2 -0
- package/lib/range-slider/utils/roundToStepValue.d.ts +1 -0
- package/lib/slider/slider.template.d.ts +1 -0
- package/lib/split-button/definition.d.ts +1 -1
- package/lib/text-anchor/definition.d.ts +1 -0
- package/lib/text-anchor/text-anchor.d.ts +5 -0
- package/lib/video-player/definition.d.ts +3 -0
- package/lib/video-player/locale.d.ts +1 -0
- package/lib/video-player/video-player.d.ts +17 -0
- package/lib/video-player/video-player.template.d.ts +4 -0
- package/listbox/index.cjs +25 -24
- package/listbox/index.js +25 -24
- package/locales/en-GB.cjs +34 -0
- package/locales/en-GB.js +34 -0
- package/locales/en-US.cjs +202 -0
- package/locales/en-US.js +202 -0
- package/locales/ja-JP.cjs +202 -1
- package/locales/ja-JP.js +202 -1
- package/locales/zh-CN.cjs +203 -0
- package/locales/zh-CN.js +203 -0
- package/menu/index.cjs +7 -7
- package/menu/index.js +7 -7
- package/menu-item/index.cjs +4 -4
- package/menu-item/index.js +4 -4
- package/nav/index.cjs +1 -1
- package/nav/index.js +1 -1
- package/nav-disclosure/index.cjs +2 -2
- package/nav-disclosure/index.js +2 -2
- package/nav-item/index.cjs +2 -2
- package/nav-item/index.js +2 -2
- package/note/index.cjs +2 -2
- package/note/index.js +2 -2
- package/number-field/index.cjs +5 -6
- package/number-field/index.js +5 -6
- package/option/index.cjs +2 -2
- package/option/index.js +2 -2
- package/package.json +34 -34
- package/pagination/index.cjs +3 -3
- package/pagination/index.js +3 -3
- package/popup/index.cjs +4 -4
- package/popup/index.js +4 -4
- package/progress/index.cjs +1 -1
- package/progress/index.js +1 -1
- package/progress-ring/index.cjs +1 -1
- package/progress-ring/index.js +1 -1
- package/radio/index.cjs +1 -1
- package/radio/index.js +1 -1
- package/radio-group/index.cjs +1 -1
- package/radio-group/index.js +1 -1
- package/range-slider/index.cjs +22 -0
- package/range-slider/index.js +20 -0
- package/select/index.cjs +7 -6
- package/select/index.js +7 -6
- package/selectable-box/index.cjs +5 -4
- package/selectable-box/index.js +5 -4
- package/shared/Reflector.cjs +5 -1
- package/shared/Reflector.js +5 -1
- package/shared/affix.cjs +11 -4
- package/shared/affix.js +12 -4
- package/shared/anchored.cjs +8 -2
- package/shared/anchored.js +8 -2
- package/shared/applyMixinsWithObservables.cjs +15 -0
- package/shared/applyMixinsWithObservables.js +13 -0
- package/shared/definition.cjs +9 -4
- package/shared/definition.js +9 -4
- package/shared/definition10.cjs +5 -5
- package/shared/definition10.js +5 -5
- package/shared/definition11.cjs +77 -49
- package/shared/definition11.js +78 -50
- package/shared/definition12.cjs +12 -14
- package/shared/definition12.js +12 -14
- package/shared/definition13.cjs +118 -75
- package/shared/definition13.js +118 -75
- package/shared/definition14.cjs +34 -33
- package/shared/definition14.js +34 -33
- package/shared/definition15.cjs +24 -12
- package/shared/definition15.js +24 -12
- package/shared/definition16.cjs +38 -43
- package/shared/definition16.js +38 -43
- package/shared/definition17.cjs +126 -66
- package/shared/definition17.js +127 -67
- package/shared/definition18.cjs +31 -15
- package/shared/definition18.js +31 -15
- package/shared/definition19.cjs +117 -81
- package/shared/definition19.js +117 -81
- package/shared/definition2.cjs +10 -5
- package/shared/definition2.js +10 -5
- package/shared/definition20.cjs +187 -227
- package/shared/definition20.js +183 -223
- package/shared/definition21.cjs +262 -69
- package/shared/definition21.js +261 -67
- package/shared/definition22.cjs +66 -61
- package/shared/definition22.js +64 -60
- package/shared/definition23.cjs +42 -77
- package/shared/definition23.js +41 -76
- package/shared/definition24.cjs +65 -2350
- package/shared/definition24.js +64 -2349
- package/shared/definition25.cjs +2402 -48
- package/shared/definition25.js +2401 -47
- package/shared/definition26.cjs +62 -28
- package/shared/definition26.js +61 -27
- package/shared/definition27.cjs +28 -54
- package/shared/definition27.js +27 -53
- package/shared/definition28.cjs +39 -819
- package/shared/definition28.js +38 -817
- package/shared/definition29.cjs +893 -54
- package/shared/definition29.js +893 -55
- package/shared/definition3.cjs +7 -10
- package/shared/definition3.js +7 -10
- package/shared/definition30.cjs +69 -85
- package/shared/definition30.js +68 -84
- package/shared/definition31.cjs +86 -23
- package/shared/definition31.js +86 -23
- package/shared/definition32.cjs +24 -14
- package/shared/definition32.js +23 -13
- package/shared/definition33.cjs +11 -53
- package/shared/definition33.js +10 -52
- package/shared/definition34.cjs +28 -500
- package/shared/definition34.js +28 -500
- package/shared/definition35.cjs +447 -194
- package/shared/definition35.js +447 -192
- package/shared/definition36.cjs +258 -188
- package/shared/definition36.js +255 -187
- package/shared/definition37.cjs +204 -78
- package/shared/definition37.js +203 -76
- package/shared/definition38.cjs +55 -51
- package/shared/definition38.js +52 -49
- package/shared/definition39.cjs +65 -423
- package/shared/definition39.js +64 -422
- package/shared/definition4.cjs +24 -12
- package/shared/definition4.js +24 -12
- package/shared/definition40.cjs +447 -35
- package/shared/definition40.js +444 -32
- package/shared/definition41.cjs +35 -678
- package/shared/definition41.js +34 -677
- package/shared/definition42.cjs +544 -99
- package/shared/definition42.js +543 -98
- package/shared/definition43.cjs +696 -77
- package/shared/definition43.js +695 -76
- package/shared/definition44.cjs +113 -563
- package/shared/definition44.js +112 -561
- package/shared/definition45.cjs +77 -117
- package/shared/definition45.js +75 -115
- package/shared/definition46.cjs +474 -86
- package/shared/definition46.js +474 -87
- package/shared/definition47.cjs +140 -23
- package/shared/definition47.js +139 -22
- package/shared/definition48.cjs +132 -57
- package/shared/definition48.js +131 -56
- package/shared/definition49.cjs +18 -524
- package/shared/definition49.js +17 -523
- package/shared/definition5.cjs +20 -17
- package/shared/definition5.js +20 -17
- package/shared/definition50.cjs +73 -25
- package/shared/definition50.js +72 -24
- package/shared/definition51.cjs +506 -99
- package/shared/definition51.js +505 -99
- package/shared/definition52.cjs +29 -277
- package/shared/definition52.js +28 -276
- package/shared/definition53.cjs +97 -256
- package/shared/definition53.js +97 -255
- package/shared/definition54.cjs +287 -769
- package/shared/definition54.js +287 -769
- package/shared/definition55.cjs +305 -105
- package/shared/definition55.js +304 -104
- package/shared/definition56.cjs +841 -81
- package/shared/definition56.js +840 -80
- package/shared/definition57.cjs +153 -69
- package/shared/definition57.js +152 -68
- package/shared/definition58.cjs +138 -299
- package/shared/definition58.js +137 -298
- package/shared/definition59.cjs +72 -27
- package/shared/definition59.js +71 -26
- package/shared/definition6.cjs +4 -5
- package/shared/definition6.js +4 -5
- package/shared/definition60.cjs +279 -1780
- package/shared/definition60.js +278 -1779
- package/shared/definition61.cjs +65870 -11
- package/shared/definition61.js +65869 -11
- package/shared/definition62.cjs +50 -0
- package/shared/definition62.js +46 -0
- package/shared/definition63.cjs +1828 -0
- package/shared/definition63.js +1824 -0
- package/shared/definition7.cjs +8 -6
- package/shared/definition7.js +8 -6
- package/shared/definition8.cjs +27 -20
- package/shared/definition8.js +27 -20
- package/shared/definition9.cjs +7 -10
- package/shared/definition9.js +7 -10
- package/shared/enums.cjs +8 -0
- package/shared/enums.js +8 -1
- package/shared/icon.cjs +7 -2
- package/shared/icon.js +7 -2
- package/shared/index2.cjs +67 -38
- package/shared/index2.js +67 -38
- package/shared/key-codes2.cjs +8 -0
- package/shared/key-codes2.js +5 -1
- package/shared/listbox.cjs +1 -1
- package/shared/listbox.js +1 -1
- package/shared/localization/Locale.d.ts +6 -0
- package/shared/patterns/form-elements/form-elements.d.ts +2 -3
- package/shared/patterns/index.d.ts +0 -1
- package/shared/presentationDate.cjs +140 -81
- package/shared/presentationDate.js +140 -81
- package/shared/slider.template.cjs +71 -0
- package/shared/slider.template.js +67 -0
- package/shared/text-anchor.cjs +6 -0
- package/shared/text-anchor.js +6 -0
- package/shared/text-anchor.template.cjs +33 -33
- package/shared/text-anchor.template.js +33 -33
- package/shared/text-field.cjs +1 -1
- package/shared/text-field.js +1 -1
- package/shared/utils/applyMixinsWithObservables.d.ts +1 -0
- package/side-drawer/index.cjs +1 -1
- package/side-drawer/index.js +1 -1
- package/slider/index.cjs +2 -1
- package/slider/index.js +2 -1
- package/split-button/index.cjs +2 -2
- package/split-button/index.js +2 -2
- package/style.css +1 -0
- package/styles/core/all.css +1 -1
- package/styles/core/theme.css +1 -1
- package/styles/core/typography.css +1 -1
- package/styles/fonts/spezia-variable.css +39 -13
- package/styles/tokens/theme-dark.css +4 -4
- package/styles/tokens/theme-light.css +4 -4
- package/styles/tokens/vivid-2-compat.css +4 -2
- package/switch/index.cjs +2 -2
- package/switch/index.js +2 -2
- package/tab/index.cjs +2 -2
- package/tab/index.js +2 -2
- package/tab-panel/index.cjs +1 -1
- package/tab-panel/index.js +1 -1
- package/tabs/index.cjs +4 -4
- package/tabs/index.js +4 -4
- package/tag/index.cjs +2 -2
- package/tag/index.js +2 -2
- package/tag-group/index.cjs +1 -1
- package/tag-group/index.js +1 -1
- package/text-area/index.cjs +4 -3
- package/text-area/index.js +4 -3
- package/text-field/index.cjs +4 -6
- package/text-field/index.js +4 -6
- package/time-picker/index.cjs +8 -10
- package/time-picker/index.js +8 -10
- package/toggletip/index.cjs +5 -5
- package/toggletip/index.js +5 -5
- package/tooltip/index.cjs +5 -5
- package/tooltip/index.js +5 -5
- package/tree-item/index.cjs +2 -2
- package/tree-item/index.js +2 -2
- package/tree-view/index.cjs +1 -1
- package/tree-view/index.js +1 -1
- package/video-player/index.cjs +17 -0
- package/video-player/index.js +15 -0
- package/vivid.api.json +428 -1
- package/focus/index.cjs +0 -7
- package/focus/index.js +0 -5
- package/lib/focus/definition.d.ts +0 -3
- package/lib/focus/focus.d.ts +0 -3
- package/lib/focus/focus.template.d.ts +0 -4
- package/lib/popup/popup.d.ts +0 -21
- package/shared/focus.cjs +0 -8
- package/shared/focus.js +0 -6
- package/shared/focus2.cjs +0 -11
- package/shared/focus2.js +0 -9
- package/shared/patterns/focus.d.ts +0 -3
package/shared/definition44.cjs
CHANGED
|
@@ -1,501 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const index = require('./index.cjs');
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const keyCodes = require('./key-codes.cjs');
|
|
9
|
-
const aria$1 = require('./aria2.cjs');
|
|
10
|
-
const ref = require('./ref.cjs');
|
|
4
|
+
const definition = require('./definition15.cjs');
|
|
5
|
+
const definition$1 = require('./definition41.cjs');
|
|
6
|
+
const enums = require('./enums.cjs');
|
|
7
|
+
const radio$1 = require('./radio.cjs');
|
|
11
8
|
const classNames = require('./class-names.cjs');
|
|
9
|
+
const when = require('./when.cjs');
|
|
12
10
|
|
|
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$1) {
|
|
17
|
-
let pct = numbers.limit(0, 1, (pixelPos - minPosition) / (maxPosition - minPosition));
|
|
18
|
-
if (direction$1 === direction.Direction.rtl) {
|
|
19
|
-
pct = 1 - pct;
|
|
20
|
-
}
|
|
21
|
-
return pct;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
class _Slider extends index.FoundationElement {
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* A form-associated base class for the {@link @microsoft/fast-foundation#(Slider:class)} component.
|
|
28
|
-
*
|
|
29
|
-
* @internal
|
|
30
|
-
*/
|
|
31
|
-
class FormAssociatedSlider extends formAssociated.FormAssociated(_Slider) {
|
|
32
|
-
constructor() {
|
|
33
|
-
super(...arguments);
|
|
34
|
-
this.proxy = document.createElement("input");
|
|
35
|
-
}
|
|
36
|
-
}
|
|
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 }.
|
|
48
|
-
*
|
|
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
|
|
58
|
-
*
|
|
59
|
-
* @public
|
|
60
|
-
*/
|
|
61
|
-
let Slider$1 = class Slider extends FormAssociatedSlider {
|
|
62
|
-
constructor() {
|
|
63
|
-
super(...arguments);
|
|
64
|
-
/**
|
|
65
|
-
* @internal
|
|
66
|
-
*/
|
|
67
|
-
this.direction = 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.
|
|
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 = aria.Orientation.horizontal;
|
|
132
|
-
/**
|
|
133
|
-
* The selection mode.
|
|
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 === keyCodes.keyHome) {
|
|
145
|
-
e.preventDefault();
|
|
146
|
-
this.value = `${this.min}`;
|
|
147
|
-
}
|
|
148
|
-
else if (e.key === keyCodes.keyEnd) {
|
|
149
|
-
e.preventDefault();
|
|
150
|
-
this.value = `${this.max}`;
|
|
151
|
-
}
|
|
152
|
-
else if (!e.shiftKey) {
|
|
153
|
-
switch (e.key) {
|
|
154
|
-
case keyCodes.keyArrowRight:
|
|
155
|
-
case keyCodes.keyArrowUp:
|
|
156
|
-
e.preventDefault();
|
|
157
|
-
this.increment();
|
|
158
|
-
break;
|
|
159
|
-
case keyCodes.keyArrowLeft:
|
|
160
|
-
case keyCodes.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
|
-
/**
|
|
195
|
-
* @internal
|
|
196
|
-
*/
|
|
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 === aria.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 === aria.Orientation.horizontal
|
|
235
|
-
? this.trackMinWidth
|
|
236
|
-
: this.trackMinHeight, this.orientation === aria.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 === aria.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
|
-
};
|
|
295
|
-
}
|
|
296
|
-
readOnlyChanged() {
|
|
297
|
-
if (this.proxy instanceof HTMLInputElement) {
|
|
298
|
-
this.proxy.readOnly = this.readOnly;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* The value property, typed as a number.
|
|
303
|
-
*
|
|
304
|
-
* @public
|
|
305
|
-
*/
|
|
306
|
-
get valueAsNumber() {
|
|
307
|
-
return parseFloat(super.value);
|
|
308
|
-
}
|
|
309
|
-
set valueAsNumber(next) {
|
|
310
|
-
this.value = next.toString();
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* @internal
|
|
314
|
-
*/
|
|
315
|
-
valueChanged(previous, next) {
|
|
316
|
-
super.valueChanged(previous, next);
|
|
317
|
-
if (this.$fastController.isConnected) {
|
|
318
|
-
this.setThumbPositionForOrientation(this.direction);
|
|
319
|
-
}
|
|
320
|
-
this.$emit("change");
|
|
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 = 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.Direction.rtl && this.orientation !== aria.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.Direction.rtl && this.orientation !== aria.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 === aria.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
|
-
}
|
|
437
|
-
}
|
|
438
|
-
};
|
|
439
|
-
index.__decorate([
|
|
440
|
-
index.attr({ attribute: "readonly", mode: "boolean" })
|
|
441
|
-
], Slider$1.prototype, "readOnly", void 0);
|
|
442
|
-
index.__decorate([
|
|
443
|
-
index.observable
|
|
444
|
-
], Slider$1.prototype, "direction", void 0);
|
|
445
|
-
index.__decorate([
|
|
446
|
-
index.observable
|
|
447
|
-
], Slider$1.prototype, "isDragging", void 0);
|
|
448
|
-
index.__decorate([
|
|
449
|
-
index.observable
|
|
450
|
-
], Slider$1.prototype, "position", void 0);
|
|
451
|
-
index.__decorate([
|
|
452
|
-
index.observable
|
|
453
|
-
], Slider$1.prototype, "trackWidth", void 0);
|
|
454
|
-
index.__decorate([
|
|
455
|
-
index.observable
|
|
456
|
-
], Slider$1.prototype, "trackMinWidth", void 0);
|
|
457
|
-
index.__decorate([
|
|
458
|
-
index.observable
|
|
459
|
-
], Slider$1.prototype, "trackHeight", void 0);
|
|
460
|
-
index.__decorate([
|
|
461
|
-
index.observable
|
|
462
|
-
], Slider$1.prototype, "trackLeft", void 0);
|
|
463
|
-
index.__decorate([
|
|
464
|
-
index.observable
|
|
465
|
-
], Slider$1.prototype, "trackMinHeight", void 0);
|
|
466
|
-
index.__decorate([
|
|
467
|
-
index.observable
|
|
468
|
-
], Slider$1.prototype, "valueTextFormatter", void 0);
|
|
469
|
-
index.__decorate([
|
|
470
|
-
index.attr({ converter: index.nullableNumberConverter })
|
|
471
|
-
], Slider$1.prototype, "min", void 0);
|
|
472
|
-
index.__decorate([
|
|
473
|
-
index.attr({ converter: index.nullableNumberConverter })
|
|
474
|
-
], Slider$1.prototype, "max", void 0);
|
|
475
|
-
index.__decorate([
|
|
476
|
-
index.attr({ converter: index.nullableNumberConverter })
|
|
477
|
-
], Slider$1.prototype, "step", void 0);
|
|
478
|
-
index.__decorate([
|
|
479
|
-
index.attr
|
|
480
|
-
], Slider$1.prototype, "orientation", void 0);
|
|
481
|
-
index.__decorate([
|
|
482
|
-
index.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
|
-
}
|
|
497
|
-
|
|
498
|
-
const styles = ":host{display:inline-block}:host(:not([orientation=vertical])){inline-size:100%}:host([orientation=vertical]){block-size:100%;min-block-size:calc(var(--_thumb-interaction-indicator-size) * 5)}:host([disabled]){cursor:not-allowed}.control{--_thumb-size: 12px;--_thumb-interaction-indicator-size: 36px;cursor:pointer;outline:none;user-select:none}.control.connotation-cta{--_connotation-color-primary: var(--vvd-slider-cta-primary, var(--vvd-color-cta-500))}.control:not(.connotation-cta){--_connotation-color-primary: var(--vvd-slider-accent-primary, var(--vvd-color-canvas-text))}.control{--_appearance-color-text: var(--_connotation-color-primary-text);--_appearance-color-fill: var(--_connotation-color-primary);--_appearance-color-outline: transparent}.control .positioning-region{position:relative}.control .track{position:absolute;background:var(--_track-background-color);border-radius:4px}.control .track-start{position:absolute;left:0;background:var(--_track-start-background-color);block-size:100%;border-radius:inherit}.control[aria-orientation=horizontal]{block-size:var(--_thumb-interaction-indicator-size);inline-size:calc(100% - var(--_thumb-size));margin-inline-start:calc(var(--_thumb-size) / 2);min-inline-size:var(--_thumb-size)}.control[aria-orientation=horizontal] .track{top:calc((var(--_thumb-interaction-indicator-size) - 2px) / 2);right:0;left:0;block-size:2px}.control[aria-orientation=horizontal] .track .mark{block-size:4px;inline-size:100%}.control[aria-orientation=vertical]{margin-top:calc(var(--_thumb-interaction-indicator-size) / 2);block-size:calc(100% - var(--_thumb-interaction-indicator-size));inline-size:var(--_thumb-interaction-indicator-size);min-block-size:var(--_thumb-interaction-indicator-size)}.control[aria-orientation=vertical] .positioning-region{block-size:100%}.control[aria-orientation=vertical] .track{left:calc((var(--_thumb-interaction-indicator-size) - 2px) / 2);block-size:100%;inline-size:2px}.control[aria-orientation=vertical] .track .mark{block-size:100%;inline-size:4px}.control[aria-orientation=vertical] .track-start{top:0;block-size:auto;inline-size:100%}.control.disabled{--_track-background-color: var(--vvd-color-neutral-100);--_track-start-background-color: var(--vvd-color-neutral-300);pointer-events:none}.control:not(.disabled){--_track-background-color: var(--vvd-color-neutral-300);--_track-start-background-color: var(--_appearance-color-fill)}.thumb-container{position:absolute;block-size:var(--_thumb-interaction-indicator-size);border-radius:50%;cursor:inherit;inline-size:var(--_thumb-interaction-indicator-size);outline-color:transparent;touch-action:none}:focus-visible .thumb-container{box-shadow:inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));outline-offset:calc(-2px - var(--focus-inset, 0px));--focus-stroke-gap-color: transparent;--_thumb-interaction-indicator-alpha: .05;border-radius:50%}.control[aria-orientation=horizontal] .thumb-container{transform:translate(calc(var(--_thumb-interaction-indicator-size) / 2))}.control[aria-orientation=vertical] .thumb-container{transform:translateY(calc(var(--_thumb-interaction-indicator-size) / 2))}.control:not(.disabled) .thumb-container:hover{--_thumb-interaction-indicator-alpha: .12}.control:not(.disabled) .thumb-container:active{--_thumb-interaction-indicator-alpha: .25}.thumb-container:before{position:absolute;display:block;background-color:var(--_track-start-background-color);block-size:var(--_thumb-interaction-indicator-size);border-radius:inherit;content:\"\";inline-size:var(--_thumb-interaction-indicator-size);opacity:var(--_thumb-interaction-indicator-alpha, 0);transition:opacity .2s ease-out 0s}.thumb-container:after{position:absolute;display:block;background-color:var(--_track-start-background-color);block-size:var(--_thumb-size);border-radius:inherit;content:\"\";inline-size:var(--_thumb-size);inset:calc((var(--_thumb-interaction-indicator-size) - var(--_thumb-size)) / 2)}\n";
|
|
11
|
+
const styles = ":host{display:flex}.base{position:relative;padding:var(--selectable-box-spacing, 16px);border:1px solid var(--_appearance-color-outline);border-radius:8px;background-color:var(--_appearance-color-fill);inline-size:100%;padding-block-start:calc(var(--selectable-box-spacing, 16px) + 36px);text-align:start}.base.connotation-cta{--_connotation-color-firm-all: var(--vvd-selectable-box-cta-firm-all, var(--vvd-color-cta-600));--_connotation-color-pale: var(--vvd-selectable-box-cta-pale, var(--vvd-color-cta-300));--_connotation-color-fierce: var(--vvd-selectable-box-cta-fierce, var(--vvd-color-cta-700));--_connotation-color-faint: var(--vvd-selectable-box-cta-faint, var(--vvd-color-cta-50));--_connotation-color-soft: var(--vvd-selectable-box-cta-soft, var(--vvd-color-cta-100))}.base:not(.connotation-cta){--_connotation-color-firm-all: var(--vvd-selectable-box-accent-firm-all, var(--vvd-color-neutral-600));--_connotation-color-pale: var(--vvd-selectable-box-accent-pale, var(--vvd-color-neutral-300));--_connotation-color-fierce: var(--vvd-selectable-box-accent-fierce, var(--vvd-color-neutral-700));--_connotation-color-faint: var(--vvd-selectable-box-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-selectable-box-accent-soft, var(--vvd-color-neutral-100))}.base{--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: transparent;--_appearance-color-outline: var(--_connotation-color-pale)}.base:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: transparent;--_appearance-color-outline: var(--_connotation-color-firm-all)}.base:where(.selected):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: var(--_connotation-color-pale)}.base:where(.selected):where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: var(--_connotation-color-firm-all)}.base:focus-visible{--focus-stroke-gap-color: transparent;box-shadow:inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));outline-offset:calc(-2px - var(--focus-inset, 0px))}.base.tight{overflow:hidden;min-height:calc(var(--selectable-box-spacing, 16px) * 2 + 22px);padding:0}.base.clickable{cursor:pointer}.control{position:absolute;inset-block-start:var(--selectable-box-spacing, 16px);inset-inline-end:var(--selectable-box-spacing, 16px)}\n";
|
|
499
12
|
|
|
500
13
|
var __defProp = Object.defineProperty;
|
|
501
14
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -508,99 +21,136 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
508
21
|
__defProp(target, key, result);
|
|
509
22
|
return result;
|
|
510
23
|
};
|
|
511
|
-
class
|
|
24
|
+
class SelectableBox extends index.FoundationElement {
|
|
512
25
|
constructor() {
|
|
513
26
|
super(...arguments);
|
|
514
27
|
this.ariaLabel = null;
|
|
515
|
-
this.
|
|
516
|
-
this.
|
|
28
|
+
this.checked = false;
|
|
29
|
+
this.clickable = false;
|
|
30
|
+
this.clickableBox = false;
|
|
31
|
+
this.tight = false;
|
|
517
32
|
}
|
|
518
33
|
/**
|
|
519
|
-
* TO BE REMOVED WHEN UPGRADING TO FAST-FOUNDATION 3
|
|
520
|
-
*
|
|
521
34
|
* @internal
|
|
522
35
|
*/
|
|
523
|
-
|
|
524
|
-
if (this
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
36
|
+
_handleCheckedChange() {
|
|
37
|
+
if (this.controlType === "radio" && this.checked)
|
|
38
|
+
return;
|
|
39
|
+
this.checked = !this.checked;
|
|
40
|
+
if (this.clickableBox || this.clickable)
|
|
41
|
+
this.$emit("change");
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* @internal
|
|
45
|
+
*/
|
|
46
|
+
_handleKeydown(event) {
|
|
47
|
+
if ((event.code === "Space" || event.code === "Enter") && (this.clickableBox || this.clickable))
|
|
48
|
+
return this._handleCheckedChange();
|
|
49
|
+
return true;
|
|
537
50
|
}
|
|
538
51
|
}
|
|
539
52
|
__decorateClass([
|
|
540
53
|
index.attr({ attribute: "aria-label" })
|
|
541
|
-
],
|
|
54
|
+
], SelectableBox.prototype, "ariaLabel", 2);
|
|
542
55
|
__decorateClass([
|
|
543
|
-
index.attr({
|
|
544
|
-
],
|
|
56
|
+
index.attr({ mode: "boolean" })
|
|
57
|
+
], SelectableBox.prototype, "checked", 2);
|
|
545
58
|
__decorateClass([
|
|
546
|
-
index.attr({
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
59
|
+
index.attr({ mode: "boolean" })
|
|
60
|
+
], SelectableBox.prototype, "clickable", 2);
|
|
61
|
+
__decorateClass([
|
|
62
|
+
index.attr({ attribute: "clickable-box", mode: "boolean" })
|
|
63
|
+
], SelectableBox.prototype, "clickableBox", 2);
|
|
550
64
|
__decorateClass([
|
|
551
65
|
index.attr
|
|
552
|
-
],
|
|
66
|
+
], SelectableBox.prototype, "connotation", 2);
|
|
67
|
+
__decorateClass([
|
|
68
|
+
index.attr({ attribute: "control-type" })
|
|
69
|
+
], SelectableBox.prototype, "controlType", 2);
|
|
70
|
+
__decorateClass([
|
|
71
|
+
index.attr({ mode: "boolean" })
|
|
72
|
+
], SelectableBox.prototype, "tight", 2);
|
|
553
73
|
|
|
554
|
-
const getClasses = ({
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
74
|
+
const getClasses = ({
|
|
75
|
+
connotation,
|
|
76
|
+
tight,
|
|
77
|
+
checked,
|
|
78
|
+
clickableBox,
|
|
79
|
+
clickable
|
|
80
|
+
}) => classNames.classNames(
|
|
81
|
+
"base",
|
|
82
|
+
[`connotation-${connotation}`, Boolean(connotation)],
|
|
83
|
+
["tight", tight],
|
|
84
|
+
["selected", checked],
|
|
85
|
+
["clickable", clickableBox || clickable],
|
|
86
|
+
["readonly", !clickableBox && !clickable]
|
|
558
87
|
);
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
88
|
+
function handleControlChange(x) {
|
|
89
|
+
if (!x.clickableBox)
|
|
90
|
+
x._handleCheckedChange();
|
|
91
|
+
}
|
|
92
|
+
function checkbox(context) {
|
|
93
|
+
const checkboxTag = context.tagFor(definition.Checkbox);
|
|
94
|
+
return index.html`${when.when(
|
|
95
|
+
(x) => x.controlType !== "radio",
|
|
96
|
+
index.html`
|
|
97
|
+
<${checkboxTag}
|
|
98
|
+
aria-label="${(x) => !x.clickableBox && !x.clickable && x.ariaLabel ? x.ariaLabel : null}"
|
|
99
|
+
@change="${(x) => handleControlChange(x)}"
|
|
100
|
+
class="control checkbox"
|
|
101
|
+
connotation="${(x) => x.connotation === "cta" ? enums.Connotation.CTA : enums.Connotation.Accent}"
|
|
102
|
+
:checked="${(x) => x.checked}"
|
|
103
|
+
inert="${(x) => x.clickableBox || x.clickable ? true : null}"
|
|
104
|
+
></${checkboxTag}>`
|
|
105
|
+
)} `;
|
|
106
|
+
}
|
|
107
|
+
function radio(context) {
|
|
108
|
+
const radioTag = context.tagFor(radio$1.Radio);
|
|
109
|
+
return index.html`${when.when(
|
|
110
|
+
(x) => x.controlType === "radio",
|
|
111
|
+
index.html`
|
|
112
|
+
<${radioTag}
|
|
113
|
+
aria-label="${(x) => !x.clickableBox && !x.clickable && x.ariaLabel ? x.ariaLabel : null}"
|
|
114
|
+
@change="${(x) => handleControlChange(x)}"
|
|
115
|
+
class="control radio"
|
|
116
|
+
connotation="${(x) => x.connotation === "cta" ? enums.Connotation.CTA : enums.Connotation.Accent}"
|
|
117
|
+
:checked="${(x) => x.checked}"
|
|
118
|
+
inert="${(x) => x.clickableBox || x.clickable ? true : null}"
|
|
119
|
+
></${radioTag}>`
|
|
120
|
+
)} `;
|
|
121
|
+
}
|
|
122
|
+
const SelectableBoxTemplate = (context) => {
|
|
123
|
+
return index.html`<template role="presentation">
|
|
124
|
+
<div
|
|
125
|
+
class="${getClasses}"
|
|
126
|
+
tabindex="${(x) => x.clickableBox || x.clickable ? "0" : null}"
|
|
127
|
+
role="${(x) => x.clickableBox || x.clickable ? "button" : null}"
|
|
128
|
+
aria-pressed="${(x) => (x.clickableBox || x.clickable) && x.checked ? x.checked : null}"
|
|
129
|
+
aria-label="${(x) => x.clickableBox || x.clickable ? x.ariaLabel : null}"
|
|
130
|
+
@keydown="${(x, c) => x._handleKeydown(c.event)}"
|
|
131
|
+
@click="${(x) => x.clickableBox || x.clickable ? x._handleCheckedChange() : null}"
|
|
132
|
+
>
|
|
133
|
+
${checkbox(context)} ${radio(context)}
|
|
134
|
+
<slot></slot>
|
|
588
135
|
</div>
|
|
589
|
-
</
|
|
136
|
+
</template>`;
|
|
590
137
|
};
|
|
591
138
|
|
|
592
|
-
const
|
|
593
|
-
baseName: "
|
|
594
|
-
template:
|
|
139
|
+
const selectableBoxDefinition = SelectableBox.compose({
|
|
140
|
+
baseName: "selectable-box",
|
|
141
|
+
template: SelectableBoxTemplate,
|
|
595
142
|
styles,
|
|
596
143
|
shadowOptions: {
|
|
597
144
|
delegatesFocus: true
|
|
598
145
|
}
|
|
599
146
|
});
|
|
600
|
-
const
|
|
601
|
-
|
|
147
|
+
const selectableBoxRegistries = [
|
|
148
|
+
selectableBoxDefinition(),
|
|
149
|
+
...definition.checkboxRegistries,
|
|
150
|
+
...definition$1.radioRegistries
|
|
151
|
+
];
|
|
152
|
+
const registerSelectableBox = index.registerFactory(selectableBoxRegistries);
|
|
602
153
|
|
|
603
|
-
exports.
|
|
604
|
-
exports.
|
|
605
|
-
exports.
|
|
606
|
-
exports.sliderRegistries = sliderRegistries;
|
|
154
|
+
exports.registerSelectableBox = registerSelectableBox;
|
|
155
|
+
exports.selectableBoxDefinition = selectableBoxDefinition;
|
|
156
|
+
exports.selectableBoxRegistries = selectableBoxRegistries;
|