@vonage/vivid 3.51.0 → 3.52.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.
Files changed (261) hide show
  1. package/alert/index.cjs +1 -1
  2. package/alert/index.js +1 -1
  3. package/appearance-ui/index.cjs +19 -11
  4. package/appearance-ui/index.js +19 -11
  5. package/audio-player/index.cjs +2 -1
  6. package/audio-player/index.js +2 -1
  7. package/card/index.cjs +1 -1
  8. package/card/index.js +1 -1
  9. package/combobox/index.cjs +2 -5
  10. package/combobox/index.js +2 -5
  11. package/custom-elements.json +1357 -529
  12. package/date-picker/index.cjs +3 -6
  13. package/date-picker/index.js +3 -6
  14. package/date-range-picker/index.cjs +2 -5
  15. package/date-range-picker/index.js +2 -5
  16. package/dialog/index.cjs +1 -1
  17. package/dialog/index.js +1 -1
  18. package/elevation/index.cjs +1 -1
  19. package/elevation/index.js +1 -1
  20. package/file-picker/index.cjs +0 -2
  21. package/file-picker/index.js +0 -2
  22. package/header/index.cjs +1 -1
  23. package/header/index.js +1 -1
  24. package/index.cjs +60 -58
  25. package/index.js +22 -23
  26. package/lib/avatar/definition.d.ts +1 -1
  27. package/lib/button/button.d.ts +1 -0
  28. package/lib/button/definition.d.ts +1 -1
  29. package/lib/calendar-event/definition.d.ts +1 -1
  30. package/lib/components.d.ts +1 -0
  31. package/lib/layout/definition.d.ts +1 -1
  32. package/lib/menu-item/menu-item.d.ts +3 -0
  33. package/lib/range-slider/definition.d.ts +3 -0
  34. package/lib/range-slider/locale.d.ts +4 -0
  35. package/lib/range-slider/range-slider.d.ts +32 -0
  36. package/lib/range-slider/range-slider.form-associated.d.ts +10 -0
  37. package/lib/range-slider/range-slider.template.d.ts +4 -0
  38. package/lib/range-slider/utils/lerp.d.ts +2 -0
  39. package/lib/range-slider/utils/roundToStepValue.d.ts +1 -0
  40. package/lib/slider/slider.template.d.ts +1 -0
  41. package/lib/split-button/definition.d.ts +1 -1
  42. package/listbox/index.cjs +23 -22
  43. package/listbox/index.js +23 -22
  44. package/locales/en-GB.cjs +4 -0
  45. package/locales/en-GB.js +4 -0
  46. package/locales/en-US.cjs +4 -0
  47. package/locales/en-US.js +4 -0
  48. package/locales/ja-JP.cjs +5 -1
  49. package/locales/ja-JP.js +5 -1
  50. package/locales/zh-CN.cjs +4 -0
  51. package/locales/zh-CN.js +4 -0
  52. package/menu/index.cjs +3 -3
  53. package/menu/index.js +3 -3
  54. package/menu-item/index.cjs +2 -2
  55. package/menu-item/index.js +2 -2
  56. package/number-field/index.cjs +0 -2
  57. package/number-field/index.js +0 -2
  58. package/package.json +34 -34
  59. package/popup/index.cjs +2 -2
  60. package/popup/index.js +2 -2
  61. package/range-slider/index.cjs +22 -0
  62. package/range-slider/index.js +20 -0
  63. package/select/index.cjs +3 -3
  64. package/select/index.js +3 -3
  65. package/selectable-box/index.cjs +1 -1
  66. package/selectable-box/index.js +1 -1
  67. package/shared/Reflector.cjs +5 -1
  68. package/shared/Reflector.js +5 -1
  69. package/shared/affix.cjs +11 -4
  70. package/shared/affix.js +12 -4
  71. package/shared/anchored.cjs +8 -2
  72. package/shared/anchored.js +8 -2
  73. package/shared/definition.cjs +8 -3
  74. package/shared/definition.js +8 -3
  75. package/shared/definition10.cjs +5 -5
  76. package/shared/definition10.js +5 -5
  77. package/shared/definition11.cjs +75 -47
  78. package/shared/definition11.js +76 -48
  79. package/shared/definition12.cjs +12 -14
  80. package/shared/definition12.js +12 -14
  81. package/shared/definition13.cjs +118 -75
  82. package/shared/definition13.js +118 -75
  83. package/shared/definition14.cjs +33 -32
  84. package/shared/definition14.js +33 -32
  85. package/shared/definition15.cjs +20 -7
  86. package/shared/definition15.js +20 -7
  87. package/shared/definition16.cjs +37 -42
  88. package/shared/definition16.js +36 -41
  89. package/shared/definition17.cjs +125 -65
  90. package/shared/definition17.js +126 -66
  91. package/shared/definition18.cjs +30 -14
  92. package/shared/definition18.js +30 -14
  93. package/shared/definition19.cjs +116 -80
  94. package/shared/definition19.js +116 -80
  95. package/shared/definition2.cjs +10 -5
  96. package/shared/definition2.js +10 -5
  97. package/shared/definition20.cjs +16 -15
  98. package/shared/definition20.js +16 -15
  99. package/shared/definition21.cjs +6 -10
  100. package/shared/definition21.js +6 -10
  101. package/shared/definition22.cjs +14 -18
  102. package/shared/definition22.js +14 -18
  103. package/shared/definition23.cjs +34 -35
  104. package/shared/definition23.js +34 -35
  105. package/shared/definition24.cjs +116 -69
  106. package/shared/definition24.js +116 -69
  107. package/shared/definition25.cjs +2 -4
  108. package/shared/definition25.js +2 -4
  109. package/shared/definition26.cjs +9 -8
  110. package/shared/definition26.js +9 -8
  111. package/shared/definition27.cjs +7 -5
  112. package/shared/definition27.js +7 -5
  113. package/shared/definition28.cjs +209 -143
  114. package/shared/definition28.js +209 -143
  115. package/shared/definition29.cjs +10 -4
  116. package/shared/definition29.js +10 -4
  117. package/shared/definition3.cjs +7 -10
  118. package/shared/definition3.js +7 -10
  119. package/shared/definition30.cjs +7 -5
  120. package/shared/definition30.js +7 -5
  121. package/shared/definition31.cjs +2 -4
  122. package/shared/definition31.js +2 -4
  123. package/shared/definition32.cjs +1 -3
  124. package/shared/definition32.js +1 -3
  125. package/shared/definition33.cjs +7 -10
  126. package/shared/definition33.js +7 -10
  127. package/shared/definition34.cjs +76 -59
  128. package/shared/definition34.js +76 -59
  129. package/shared/definition35.cjs +19 -20
  130. package/shared/definition35.js +19 -20
  131. package/shared/definition36.cjs +30 -14
  132. package/shared/definition36.js +30 -14
  133. package/shared/definition37.cjs +33 -46
  134. package/shared/definition37.js +33 -46
  135. package/shared/definition38.cjs +31 -33
  136. package/shared/definition38.js +31 -33
  137. package/shared/definition39.cjs +13 -4
  138. package/shared/definition39.js +13 -4
  139. package/shared/definition4.cjs +23 -11
  140. package/shared/definition4.js +23 -11
  141. package/shared/definition40.cjs +19 -14
  142. package/shared/definition40.js +19 -14
  143. package/shared/definition41.cjs +534 -635
  144. package/shared/definition41.js +534 -635
  145. package/shared/definition42.cjs +674 -106
  146. package/shared/definition42.js +673 -105
  147. package/shared/definition43.cjs +122 -79
  148. package/shared/definition43.js +120 -77
  149. package/shared/definition44.cjs +72 -567
  150. package/shared/definition44.js +71 -565
  151. package/shared/definition45.cjs +520 -118
  152. package/shared/definition45.js +518 -117
  153. package/shared/definition46.cjs +117 -130
  154. package/shared/definition46.js +116 -129
  155. package/shared/definition47.cjs +152 -18
  156. package/shared/definition47.js +151 -17
  157. package/shared/definition48.cjs +20 -77
  158. package/shared/definition48.js +19 -76
  159. package/shared/definition49.cjs +52 -495
  160. package/shared/definition49.js +51 -494
  161. package/shared/definition5.cjs +20 -17
  162. package/shared/definition5.js +20 -17
  163. package/shared/definition50.cjs +525 -24
  164. package/shared/definition50.js +524 -23
  165. package/shared/definition51.cjs +28 -119
  166. package/shared/definition51.js +26 -118
  167. package/shared/definition52.cjs +113 -266
  168. package/shared/definition52.js +113 -265
  169. package/shared/definition53.cjs +285 -245
  170. package/shared/definition53.js +285 -245
  171. package/shared/definition54.cjs +285 -751
  172. package/shared/definition54.js +284 -750
  173. package/shared/definition55.cjs +828 -99
  174. package/shared/definition55.js +827 -98
  175. package/shared/definition56.cjs +126 -77
  176. package/shared/definition56.js +125 -76
  177. package/shared/definition57.cjs +125 -71
  178. package/shared/definition57.js +124 -70
  179. package/shared/definition58.cjs +73 -287
  180. package/shared/definition58.js +74 -288
  181. package/shared/definition59.cjs +298 -40
  182. package/shared/definition59.js +297 -39
  183. package/shared/definition6.cjs +3 -4
  184. package/shared/definition6.js +3 -4
  185. package/shared/definition60.cjs +24 -1784
  186. package/shared/definition60.js +23 -1783
  187. package/shared/definition61.cjs +1819 -11
  188. package/shared/definition61.js +1818 -11
  189. package/shared/definition7.cjs +6 -4
  190. package/shared/definition7.js +6 -4
  191. package/shared/definition8.cjs +25 -18
  192. package/shared/definition8.js +25 -18
  193. package/shared/definition9.cjs +6 -9
  194. package/shared/definition9.js +6 -9
  195. package/shared/icon.cjs +7 -2
  196. package/shared/icon.js +7 -2
  197. package/shared/index2.cjs +1 -1
  198. package/shared/index2.js +1 -1
  199. package/shared/key-codes2.cjs +8 -0
  200. package/shared/key-codes2.js +5 -1
  201. package/shared/localization/Locale.d.ts +2 -0
  202. package/shared/patterns/index.d.ts +0 -1
  203. package/shared/presentationDate.cjs +126 -78
  204. package/shared/presentationDate.js +126 -78
  205. package/shared/slider.template.cjs +71 -0
  206. package/shared/slider.template.js +67 -0
  207. package/shared/text-anchor.template.cjs +30 -35
  208. package/shared/text-anchor.template.js +30 -35
  209. package/shared/text-field.cjs +1 -1
  210. package/shared/text-field.js +1 -1
  211. package/side-drawer/index.cjs +1 -1
  212. package/side-drawer/index.js +1 -1
  213. package/slider/index.cjs +2 -1
  214. package/slider/index.js +2 -1
  215. package/split-button/index.cjs +1 -1
  216. package/split-button/index.js +1 -1
  217. package/styles/core/all.css +1 -1
  218. package/styles/core/theme.css +1 -1
  219. package/styles/core/typography.css +1 -1
  220. package/styles/fonts/spezia-variable.css +39 -13
  221. package/styles/tokens/theme-dark.css +4 -4
  222. package/styles/tokens/theme-light.css +4 -4
  223. package/styles/tokens/vivid-2-compat.css +4 -2
  224. package/switch/index.cjs +1 -1
  225. package/switch/index.js +1 -1
  226. package/tab/index.cjs +1 -1
  227. package/tab/index.js +1 -1
  228. package/tab-panel/index.cjs +1 -1
  229. package/tab-panel/index.js +1 -1
  230. package/tabs/index.cjs +3 -3
  231. package/tabs/index.js +3 -3
  232. package/tag/index.cjs +1 -1
  233. package/tag/index.js +1 -1
  234. package/tag-group/index.cjs +1 -1
  235. package/tag-group/index.js +1 -1
  236. package/text-area/index.cjs +1 -1
  237. package/text-area/index.js +1 -1
  238. package/text-field/index.cjs +1 -4
  239. package/text-field/index.js +1 -4
  240. package/time-picker/index.cjs +4 -7
  241. package/time-picker/index.js +4 -7
  242. package/toggletip/index.cjs +3 -3
  243. package/toggletip/index.js +3 -3
  244. package/tooltip/index.cjs +3 -3
  245. package/tooltip/index.js +3 -3
  246. package/tree-item/index.cjs +1 -1
  247. package/tree-item/index.js +1 -1
  248. package/tree-view/index.cjs +1 -1
  249. package/tree-view/index.js +1 -1
  250. package/vivid.api.json +117 -1
  251. package/focus/index.cjs +0 -7
  252. package/focus/index.js +0 -5
  253. package/lib/focus/definition.d.ts +0 -3
  254. package/lib/focus/focus.d.ts +0 -3
  255. package/lib/focus/focus.template.d.ts +0 -4
  256. package/lib/popup/popup.d.ts +0 -21
  257. package/shared/focus.cjs +0 -8
  258. package/shared/focus.js +0 -6
  259. package/shared/focus2.cjs +0 -11
  260. package/shared/focus2.js +0 -9
  261. package/shared/patterns/focus.d.ts +0 -3
@@ -1,500 +1,7 @@
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 { D as Direction, g as getDirection } from './direction.js';
3
- import { l as limit$1 } from './numbers.js';
4
- import { F as FormAssociated } from './form-associated.js';
5
- import { O as Orientation } from './aria.js';
6
- import { g as keyHome, d as keyEnd, f as keyArrowDown, i as keyArrowLeft, e as keyArrowUp, h as keyArrowRight } from './key-codes.js';
7
- import { O as Orientation$1 } from './aria2.js';
8
- import { r as ref } from './ref.js';
1
+ import { a as attr, F as FoundationElement, h as html, r as registerFactory } from './index.js';
2
+ import { w as when } from './when.js';
9
3
  import { c as classNames } from './class-names.js';
10
4
 
11
- /**
12
- * Converts a pixel coordinate on the track to a percent of the track's range
13
- */
14
- function convertPixelToPercent(pixelPos, minPosition, maxPosition, direction) {
15
- let pct = limit$1(0, 1, (pixelPos - minPosition) / (maxPosition - minPosition));
16
- if (direction === Direction.rtl) {
17
- pct = 1 - pct;
18
- }
19
- return pct;
20
- }
21
-
22
- class _Slider extends FoundationElement {
23
- }
24
- /**
25
- * A form-associated base class for the {@link @microsoft/fast-foundation#(Slider:class)} component.
26
- *
27
- * @internal
28
- */
29
- class FormAssociatedSlider extends FormAssociated(_Slider) {
30
- constructor() {
31
- super(...arguments);
32
- this.proxy = document.createElement("input");
33
- }
34
- }
35
-
36
- /**
37
- * The selection modes of a {@link @microsoft/fast-foundation#(Slider:class)}.
38
- * @public
39
- */
40
- const SliderMode = {
41
- singleValue: "single-value",
42
- };
43
- /**
44
- * A Slider Custom HTML Element.
45
- * Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#slider | ARIA slider }.
46
- *
47
- * @slot track - The track of the slider
48
- * @slot track-start - The track-start visual indicator
49
- * @slot thumb - The slider thumb
50
- * @slot - The default slot for labels
51
- * @csspart positioning-region - The region used to position the elements of the slider
52
- * @csspart track-container - The region containing the track elements
53
- * @csspart track-start - The element wrapping the track start slot
54
- * @csspart thumb-container - The thumb container element which is programatically positioned
55
- * @fires change - Fires a custom 'change' event when the slider value changes
56
- *
57
- * @public
58
- */
59
- let Slider$1 = class Slider extends FormAssociatedSlider {
60
- constructor() {
61
- super(...arguments);
62
- /**
63
- * @internal
64
- */
65
- this.direction = Direction.ltr;
66
- /**
67
- * @internal
68
- */
69
- this.isDragging = false;
70
- /**
71
- * @internal
72
- */
73
- this.trackWidth = 0;
74
- /**
75
- * @internal
76
- */
77
- this.trackMinWidth = 0;
78
- /**
79
- * @internal
80
- */
81
- this.trackHeight = 0;
82
- /**
83
- * @internal
84
- */
85
- this.trackLeft = 0;
86
- /**
87
- * @internal
88
- */
89
- this.trackMinHeight = 0;
90
- /**
91
- * Custom function that generates a string for the component's "aria-valuetext" attribute based on the current value.
92
- *
93
- * @public
94
- */
95
- this.valueTextFormatter = () => null;
96
- /**
97
- * The minimum allowed value.
98
- *
99
- * @defaultValue - 0
100
- * @public
101
- * @remarks
102
- * HTML Attribute: min
103
- */
104
- this.min = 0; // Map to proxy element.
105
- /**
106
- * The maximum allowed value.
107
- *
108
- * @defaultValue - 10
109
- * @public
110
- * @remarks
111
- * HTML Attribute: max
112
- */
113
- this.max = 10; // Map to proxy element.
114
- /**
115
- * Value to increment or decrement via arrow keys, mouse click or drag.
116
- *
117
- * @public
118
- * @remarks
119
- * HTML Attribute: step
120
- */
121
- this.step = 1; // Map to proxy element.
122
- /**
123
- * The orientation of the slider.
124
- *
125
- * @public
126
- * @remarks
127
- * HTML Attribute: orientation
128
- */
129
- this.orientation = Orientation.horizontal;
130
- /**
131
- * The selection mode.
132
- *
133
- * @public
134
- * @remarks
135
- * HTML Attribute: mode
136
- */
137
- this.mode = SliderMode.singleValue;
138
- this.keypressHandler = (e) => {
139
- if (this.readOnly) {
140
- return;
141
- }
142
- if (e.key === keyHome) {
143
- e.preventDefault();
144
- this.value = `${this.min}`;
145
- }
146
- else if (e.key === keyEnd) {
147
- e.preventDefault();
148
- this.value = `${this.max}`;
149
- }
150
- else if (!e.shiftKey) {
151
- switch (e.key) {
152
- case keyArrowRight:
153
- case keyArrowUp:
154
- e.preventDefault();
155
- this.increment();
156
- break;
157
- case keyArrowLeft:
158
- case keyArrowDown:
159
- e.preventDefault();
160
- this.decrement();
161
- break;
162
- }
163
- }
164
- };
165
- this.setupTrackConstraints = () => {
166
- const clientRect = this.track.getBoundingClientRect();
167
- this.trackWidth = this.track.clientWidth;
168
- this.trackMinWidth = this.track.clientLeft;
169
- this.trackHeight = clientRect.bottom;
170
- this.trackMinHeight = clientRect.top;
171
- this.trackLeft = this.getBoundingClientRect().left;
172
- if (this.trackWidth === 0) {
173
- this.trackWidth = 1;
174
- }
175
- };
176
- this.setupListeners = (remove = false) => {
177
- const eventAction = `${remove ? "remove" : "add"}EventListener`;
178
- this[eventAction]("keydown", this.keypressHandler);
179
- this[eventAction]("mousedown", this.handleMouseDown);
180
- this.thumb[eventAction]("mousedown", this.handleThumbMouseDown, {
181
- passive: true,
182
- });
183
- this.thumb[eventAction]("touchstart", this.handleThumbMouseDown, {
184
- passive: true,
185
- });
186
- // removes handlers attached by mousedown handlers
187
- if (remove) {
188
- this.handleMouseDown(null);
189
- this.handleThumbMouseDown(null);
190
- }
191
- };
192
- /**
193
- * @internal
194
- */
195
- this.initialValue = "";
196
- /**
197
- * Handle mouse moves during a thumb drag operation
198
- * If the event handler is null it removes the events
199
- */
200
- this.handleThumbMouseDown = (event) => {
201
- if (event) {
202
- if (this.readOnly || this.disabled || event.defaultPrevented) {
203
- return;
204
- }
205
- event.target.focus();
206
- }
207
- const eventAction = `${event !== null ? "add" : "remove"}EventListener`;
208
- window[eventAction]("mouseup", this.handleWindowMouseUp);
209
- window[eventAction]("mousemove", this.handleMouseMove, { passive: true });
210
- window[eventAction]("touchmove", this.handleMouseMove, { passive: true });
211
- window[eventAction]("touchend", this.handleWindowMouseUp);
212
- this.isDragging = event !== null;
213
- };
214
- /**
215
- * Handle mouse moves during a thumb drag operation
216
- */
217
- this.handleMouseMove = (e) => {
218
- if (this.readOnly || this.disabled || e.defaultPrevented) {
219
- return;
220
- }
221
- // update the value based on current position
222
- const sourceEvent = window.TouchEvent && e instanceof TouchEvent
223
- ? e.touches[0]
224
- : e;
225
- const eventValue = this.orientation === Orientation.horizontal
226
- ? sourceEvent.pageX - document.documentElement.scrollLeft - this.trackLeft
227
- : sourceEvent.pageY - document.documentElement.scrollTop;
228
- this.value = `${this.calculateNewValue(eventValue)}`;
229
- };
230
- this.calculateNewValue = (rawValue) => {
231
- // update the value based on current position
232
- const newPosition = convertPixelToPercent(rawValue, this.orientation === Orientation.horizontal
233
- ? this.trackMinWidth
234
- : this.trackMinHeight, this.orientation === Orientation.horizontal
235
- ? this.trackWidth
236
- : this.trackHeight, this.direction);
237
- const newValue = (this.max - this.min) * newPosition + this.min;
238
- return this.convertToConstrainedValue(newValue);
239
- };
240
- /**
241
- * Handle a window mouse up during a drag operation
242
- */
243
- this.handleWindowMouseUp = (event) => {
244
- this.stopDragging();
245
- };
246
- this.stopDragging = () => {
247
- this.isDragging = false;
248
- this.handleMouseDown(null);
249
- this.handleThumbMouseDown(null);
250
- };
251
- /**
252
- *
253
- * @param e - MouseEvent or null. If there is no event handler it will remove the events
254
- */
255
- this.handleMouseDown = (e) => {
256
- const eventAction = `${e !== null ? "add" : "remove"}EventListener`;
257
- if (e === null || (!this.disabled && !this.readOnly)) {
258
- window[eventAction]("mouseup", this.handleWindowMouseUp);
259
- window.document[eventAction]("mouseleave", this.handleWindowMouseUp);
260
- window[eventAction]("mousemove", this.handleMouseMove);
261
- if (e) {
262
- e.preventDefault();
263
- this.setupTrackConstraints();
264
- e.target.focus();
265
- const controlValue = this.orientation === Orientation.horizontal
266
- ? e.pageX - document.documentElement.scrollLeft - this.trackLeft
267
- : e.pageY - document.documentElement.scrollTop;
268
- this.value = `${this.calculateNewValue(controlValue)}`;
269
- }
270
- }
271
- };
272
- this.convertToConstrainedValue = (value) => {
273
- if (isNaN(value)) {
274
- value = this.min;
275
- }
276
- /**
277
- * The following logic intends to overcome the issue with math in JavaScript with regards to floating point numbers.
278
- * 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
279
- * and is converted to an integer by determining the number of decimal places it represent, multiplying it until it is an
280
- * integer and then dividing it to get back to the correct number.
281
- */
282
- let constrainedValue = value - this.min;
283
- const roundedConstrainedValue = Math.round(constrainedValue / this.step);
284
- const remainderValue = constrainedValue -
285
- (roundedConstrainedValue * (this.stepMultiplier * this.step)) /
286
- this.stepMultiplier;
287
- constrainedValue =
288
- remainderValue >= Number(this.step) / 2
289
- ? constrainedValue - remainderValue + Number(this.step)
290
- : constrainedValue - remainderValue;
291
- return constrainedValue + this.min;
292
- };
293
- }
294
- readOnlyChanged() {
295
- if (this.proxy instanceof HTMLInputElement) {
296
- this.proxy.readOnly = this.readOnly;
297
- }
298
- }
299
- /**
300
- * The value property, typed as a number.
301
- *
302
- * @public
303
- */
304
- get valueAsNumber() {
305
- return parseFloat(super.value);
306
- }
307
- set valueAsNumber(next) {
308
- this.value = next.toString();
309
- }
310
- /**
311
- * @internal
312
- */
313
- valueChanged(previous, next) {
314
- super.valueChanged(previous, next);
315
- if (this.$fastController.isConnected) {
316
- this.setThumbPositionForOrientation(this.direction);
317
- }
318
- this.$emit("change");
319
- }
320
- minChanged() {
321
- if (this.proxy instanceof HTMLInputElement) {
322
- this.proxy.min = `${this.min}`;
323
- }
324
- this.validate();
325
- }
326
- maxChanged() {
327
- if (this.proxy instanceof HTMLInputElement) {
328
- this.proxy.max = `${this.max}`;
329
- }
330
- this.validate();
331
- }
332
- stepChanged() {
333
- if (this.proxy instanceof HTMLInputElement) {
334
- this.proxy.step = `${this.step}`;
335
- }
336
- this.updateStepMultiplier();
337
- this.validate();
338
- }
339
- orientationChanged() {
340
- if (this.$fastController.isConnected) {
341
- this.setThumbPositionForOrientation(this.direction);
342
- }
343
- }
344
- /**
345
- * @internal
346
- */
347
- connectedCallback() {
348
- super.connectedCallback();
349
- this.proxy.setAttribute("type", "range");
350
- this.direction = getDirection(this);
351
- this.updateStepMultiplier();
352
- this.setupTrackConstraints();
353
- this.setupListeners();
354
- this.setupDefaultValue();
355
- this.setThumbPositionForOrientation(this.direction);
356
- }
357
- /**
358
- * @internal
359
- */
360
- disconnectedCallback() {
361
- this.setupListeners(true);
362
- }
363
- /**
364
- * Increment the value by the step
365
- *
366
- * @public
367
- */
368
- increment() {
369
- const newVal = this.direction !== Direction.rtl && this.orientation !== Orientation.vertical
370
- ? Number(this.value) + Number(this.step)
371
- : Number(this.value) - Number(this.step);
372
- const incrementedVal = this.convertToConstrainedValue(newVal);
373
- const incrementedValString = incrementedVal < Number(this.max) ? `${incrementedVal}` : `${this.max}`;
374
- this.value = incrementedValString;
375
- }
376
- /**
377
- * Decrement the value by the step
378
- *
379
- * @public
380
- */
381
- decrement() {
382
- const newVal = this.direction !== Direction.rtl && this.orientation !== Orientation.vertical
383
- ? Number(this.value) - Number(this.step)
384
- : Number(this.value) + Number(this.step);
385
- const decrementedVal = this.convertToConstrainedValue(newVal);
386
- const decrementedValString = decrementedVal > Number(this.min) ? `${decrementedVal}` : `${this.min}`;
387
- this.value = decrementedValString;
388
- }
389
- /**
390
- * Places the thumb based on the current value
391
- *
392
- * @public
393
- * @param direction - writing mode
394
- */
395
- setThumbPositionForOrientation(direction) {
396
- const newPct = convertPixelToPercent(Number(this.value), Number(this.min), Number(this.max), direction);
397
- const percentage = (1 - newPct) * 100;
398
- if (this.orientation === Orientation.horizontal) {
399
- this.position = this.isDragging
400
- ? `right: ${percentage}%; transition: none;`
401
- : `right: ${percentage}%; transition: all 0.2s ease;`;
402
- }
403
- else {
404
- this.position = this.isDragging
405
- ? `bottom: ${percentage}%; transition: none;`
406
- : `bottom: ${percentage}%; transition: all 0.2s ease;`;
407
- }
408
- }
409
- /**
410
- * Update the step multiplier used to ensure rounding errors from steps that
411
- * are not whole numbers
412
- */
413
- updateStepMultiplier() {
414
- const stepString = this.step + "";
415
- const decimalPlacesOfStep = !!(this.step % 1)
416
- ? stepString.length - stepString.indexOf(".") - 1
417
- : 0;
418
- this.stepMultiplier = Math.pow(10, decimalPlacesOfStep);
419
- }
420
- get midpoint() {
421
- return `${this.convertToConstrainedValue((this.max + this.min) / 2)}`;
422
- }
423
- setupDefaultValue() {
424
- if (typeof this.value === "string") {
425
- if (this.value.length === 0) {
426
- this.initialValue = this.midpoint;
427
- }
428
- else {
429
- const value = parseFloat(this.value);
430
- if (!Number.isNaN(value) && (value < this.min || value > this.max)) {
431
- this.value = this.midpoint;
432
- }
433
- }
434
- }
435
- }
436
- };
437
- __decorate([
438
- attr({ attribute: "readonly", mode: "boolean" })
439
- ], Slider$1.prototype, "readOnly", void 0);
440
- __decorate([
441
- observable
442
- ], Slider$1.prototype, "direction", void 0);
443
- __decorate([
444
- observable
445
- ], Slider$1.prototype, "isDragging", void 0);
446
- __decorate([
447
- observable
448
- ], Slider$1.prototype, "position", void 0);
449
- __decorate([
450
- observable
451
- ], Slider$1.prototype, "trackWidth", void 0);
452
- __decorate([
453
- observable
454
- ], Slider$1.prototype, "trackMinWidth", void 0);
455
- __decorate([
456
- observable
457
- ], Slider$1.prototype, "trackHeight", void 0);
458
- __decorate([
459
- observable
460
- ], Slider$1.prototype, "trackLeft", void 0);
461
- __decorate([
462
- observable
463
- ], Slider$1.prototype, "trackMinHeight", void 0);
464
- __decorate([
465
- observable
466
- ], Slider$1.prototype, "valueTextFormatter", void 0);
467
- __decorate([
468
- attr({ converter: nullableNumberConverter })
469
- ], Slider$1.prototype, "min", void 0);
470
- __decorate([
471
- attr({ converter: nullableNumberConverter })
472
- ], Slider$1.prototype, "max", void 0);
473
- __decorate([
474
- attr({ converter: nullableNumberConverter })
475
- ], Slider$1.prototype, "step", void 0);
476
- __decorate([
477
- attr
478
- ], Slider$1.prototype, "orientation", void 0);
479
- __decorate([
480
- attr
481
- ], Slider$1.prototype, "mode", void 0);
482
-
483
- /**
484
- * This method keeps a given value within the bounds of a min and max value. If the value
485
- * is larger than the max, the minimum value will be returned. If the value is smaller than the minimum,
486
- * the maximum will be returned. Otherwise, the value is returned un-changed.
487
- */
488
- /**
489
- * Ensures that a value is between a min and max value. If value is lower than min, min will be returned.
490
- * If value is greater than max, max will be returned.
491
- */
492
- function limit(min, max, value) {
493
- return Math.min(Math.max(value, min), max);
494
- }
495
-
496
- 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";
497
-
498
5
  var __defProp = Object.defineProperty;
499
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
500
7
  var __decorateClass = (decorators, target, key, kind) => {
@@ -506,96 +13,95 @@ var __decorateClass = (decorators, target, key, kind) => {
506
13
  __defProp(target, key, result);
507
14
  return result;
508
15
  };
509
- class Slider extends Slider$1 {
16
+ class SideDrawer extends FoundationElement {
510
17
  constructor() {
511
18
  super(...arguments);
512
- this.ariaLabel = null;
513
- this.ariaValuetext = null;
514
- this.markers = false;
19
+ this.alternate = false;
20
+ this.modal = false;
21
+ this.open = false;
22
+ this.trailing = false;
515
23
  }
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;
24
+ attributeChangedCallback(name, oldValue, newValue) {
25
+ super.attributeChangedCallback(name, oldValue, newValue);
26
+ switch (name) {
27
+ case "open": {
28
+ this.open ? this.#open() : this.#close();
532
29
  }
533
- super.valueChanged(previous, value);
534
30
  }
535
31
  }
32
+ #close() {
33
+ this.$emit("close", void 0, { bubbles: false });
34
+ }
35
+ #open() {
36
+ this.$emit("open", void 0, { bubbles: false });
37
+ }
536
38
  }
537
39
  __decorateClass([
538
- attr({ attribute: "aria-label" })
539
- ], Slider.prototype, "ariaLabel", 2);
40
+ attr({
41
+ mode: "boolean"
42
+ })
43
+ ], SideDrawer.prototype, "alternate", 2);
540
44
  __decorateClass([
541
- attr({ attribute: "aria-valuetext" })
542
- ], Slider.prototype, "ariaValuetext", 2);
45
+ attr({
46
+ mode: "boolean"
47
+ })
48
+ ], SideDrawer.prototype, "modal", 2);
543
49
  __decorateClass([
544
50
  attr({
545
51
  mode: "boolean"
546
52
  })
547
- ], Slider.prototype, "markers", 2);
53
+ ], SideDrawer.prototype, "open", 2);
548
54
  __decorateClass([
549
- attr
550
- ], Slider.prototype, "connotation", 2);
55
+ attr({
56
+ mode: "boolean"
57
+ })
58
+ ], SideDrawer.prototype, "trailing", 2);
59
+
60
+ const styles = ":host{display:block}.side-drawer-app-content{block-size:100%}.control{position:fixed;z-index:1;background-color:var(--vvd-color-canvas);color:var(--vvd-color-canvas-text);inline-size:280px;inset-block:0;overflow-y:auto}.control[part~=vvd-theme-alternate]{background-color:var(--vvd-color-canvas);color:var(--vvd-color-canvas-text);color-scheme:var(--vvd-color-scheme)}.control.trailing{inset-inline-end:0}.control:not(.open).trailing{transform:translate(100%)}.control:not(.open):not(.trailing){transform:translate(-100%)}.control.open:not(.modal).trailing+.side-drawer-app-content{margin-inline-end:var(--side-drawer-app-content-offset, 280px)}.control.open:not(.modal):not(.trailing)+.side-drawer-app-content{margin-inline-start:var(--side-drawer-app-content-offset, 280px)}@media (prefers-reduced-motion: no-preference){.control{transition:transform .2s cubic-bezier(.4,0,.2,1)}}.scrim{background-color:var(--vvd-color-canvas-text, currentColor);opacity:.5;position:fixed;inset:0}.scrim:not(.open){display:none}\n";
551
61
 
552
- const getClasses = ({ disabled, connotation }) => classNames(
62
+ const getClasses = ({ modal, open, trailing }) => classNames(
553
63
  "control",
554
- ["disabled", Boolean(disabled)],
555
- [`connotation-${connotation}`, Boolean(connotation)]
64
+ ["modal", modal],
65
+ ["open", open],
66
+ ["trailing", trailing]
556
67
  );
557
- const getMarkersTemplate = (isHorizontal, numMarkers) => {
558
- const placeholder = isHorizontal ? ["right", "center", "", "100% repeat-x"] : ["bottom", "top", "100%", "repeat-y"];
559
- return html`
560
- <div class="mark" style="
561
- background: linear-gradient(to ${placeholder[0]}, currentcolor 3px, transparent 0px)
562
- 0px ${placeholder[1]} / ${placeholder[2]} calc((100% - 3px) / ${numMarkers}) ${placeholder[3]}
563
- "></div>`;
564
- };
565
- const SliderTemplate = () => {
566
- return html`<template role="${(x) => x.ariaLabel ? "presentation" : null}">
68
+ const getScrimClasses = ({ open }) => classNames("scrim", ["open", open]);
69
+ const sideDrawerTemplate = () => html`
567
70
  <div
568
- role="slider"
569
- tabindex="${(x) => x.disabled ? null : 0}"
570
- aria-label="${(x) => x.ariaLabel}"
571
- aria-valuetext="${(x) => x.ariaValuetext || x.valueTextFormatter(x.value)}"
572
- aria-valuenow="${(x) => x.value}"
573
- aria-valuemin="${(x) => x.min}"
574
- aria-valuemax="${(x) => x.max}"
575
- aria-disabled="${(x) => x.disabled ? true : void 0}"
576
- aria-orientation="${(x) => x.orientation}"
577
- class="${getClasses} ${(x) => x.orientation}"
71
+ class="${getClasses}"
72
+ ?inert="${(x) => !x.open}"
73
+ part="base ${(x) => x.alternate ? "vvd-theme-alternate" : ""}"
74
+ @keydown="${(x, c) => handleKeydown(x, c.event)}"
578
75
  >
579
- <div class="positioning-region">
580
- <div ${ref("track")} class="track">
581
- <div class="track-start" style="${(x) => x.position}"></div>
582
- ${(x) => x.markers ? getMarkersTemplate(x.orientation === Orientation$1.horizontal, Math.floor((x.max - x.min) / x.step)) : void 0}
583
- </div>
584
- <div ${ref("thumb")} class="thumb-container" style="${(x) => x.position}">
585
- </div>
586
- </div>
587
- </div>`;
588
- };
76
+ <slot></slot>
77
+ </div>
78
+
79
+ <div class="side-drawer-app-content" ?inert="${(x) => x.open && x.modal}">
80
+ <slot name="app-content"></slot>
81
+ </div>
589
82
 
590
- const sliderDefinition = Slider.compose({
591
- baseName: "slider",
592
- template: SliderTemplate,
593
- styles,
594
- shadowOptions: {
595
- delegatesFocus: true
83
+ ${when(
84
+ (x) => x.modal,
85
+ html`<div
86
+ class="${getScrimClasses}"
87
+ @click="${(x) => x.open = false}"
88
+ ></div>`
89
+ )}
90
+ `;
91
+ const handleKeydown = (x, { key }) => {
92
+ if (key === "Escape") {
93
+ x.open = false;
94
+ } else {
95
+ return true;
596
96
  }
97
+ };
98
+
99
+ const sideDrawerDefinition = SideDrawer.compose({
100
+ baseName: "side-drawer",
101
+ template: sideDrawerTemplate,
102
+ styles
597
103
  });
598
- const sliderRegistries = [sliderDefinition()];
599
- const registerSlider = registerFactory(sliderRegistries);
104
+ const sideDrawerRegistries = [sideDrawerDefinition()];
105
+ const registerSideDrawer = registerFactory(sideDrawerRegistries);
600
106
 
601
- export { Slider as S, sliderRegistries as a, registerSlider as r, sliderDefinition as s };
107
+ export { sideDrawerRegistries as a, registerSideDrawer as r, sideDrawerDefinition as s };