@vonage/vivid 3.37.0 → 3.38.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 (156) hide show
  1. package/accordion/index.js +2 -2
  2. package/accordion-item/index.js +2 -2
  3. package/alert/index.js +4 -4
  4. package/avatar/index.js +1 -1
  5. package/badge/index.js +1 -1
  6. package/banner/index.js +3 -3
  7. package/breadcrumb-item/index.js +2 -2
  8. package/button/index.js +3 -3
  9. package/card/index.js +2 -2
  10. package/checkbox/index.js +2 -2
  11. package/combobox/index.js +6 -6
  12. package/custom-elements.json +304 -767
  13. package/data-grid/index.js +1 -1
  14. package/date-picker/index.js +9 -7
  15. package/date-range-picker/index.js +36 -0
  16. package/dialog/index.js +5 -5
  17. package/divider/index.js +1 -1
  18. package/elevation/index.js +1 -1
  19. package/empty-state/index.js +2 -2
  20. package/fab/index.js +3 -3
  21. package/file-picker/index.js +5 -4
  22. package/focus/index.js +1 -1
  23. package/header/index.js +2 -2
  24. package/icon/index.js +1 -1
  25. package/index.js +43 -40
  26. package/layout/index.js +1 -1
  27. package/lib/components.d.ts +1 -0
  28. package/lib/date-picker/date-picker.d.ts +4 -14
  29. package/lib/date-range-picker/date-range-picker.d.ts +16 -0
  30. package/lib/date-range-picker/definition.d.ts +3 -0
  31. package/lib/file-picker/file-picker.d.ts +8 -5
  32. package/lib/file-picker/file-picker.form-associated.d.ts +10 -0
  33. package/lib/file-picker/locale.d.ts +6 -0
  34. package/lib/tag-group/tag-group.d.ts +1 -0
  35. package/listbox/index.js +4 -4
  36. package/locales/en-GB.js +27 -3
  37. package/locales/en-US.js +27 -3
  38. package/locales/ja-JP.js +25 -1
  39. package/locales/zh-CN.js +25 -1
  40. package/menu/index.js +7 -7
  41. package/menu-item/index.js +3 -3
  42. package/nav/index.js +1 -1
  43. package/nav-disclosure/index.js +3 -3
  44. package/nav-item/index.js +3 -3
  45. package/note/index.js +2 -2
  46. package/number-field/index.js +5 -5
  47. package/option/index.js +3 -3
  48. package/package.json +1 -1
  49. package/pagination/index.js +4 -4
  50. package/popup/index.js +5 -5
  51. package/progress/index.js +1 -1
  52. package/progress-ring/index.js +1 -1
  53. package/radio/index.js +2 -2
  54. package/radio-group/index.js +1 -1
  55. package/select/index.js +7 -7
  56. package/shared/date-picker/calendar/dateRange.d.ts +5 -0
  57. package/shared/date-picker/calendar/presentationDateRange.d.ts +5 -0
  58. package/shared/date-picker/date-picker-base.d.ts +20 -0
  59. package/shared/date-picker/date-picker-base.form-associated.d.ts +10 -0
  60. package/shared/date-picker/date-picker-base.template.d.ts +4 -0
  61. package/{lib → shared}/date-picker/locale.d.ts +6 -0
  62. package/shared/definition.js +4 -4
  63. package/shared/definition10.js +9 -14
  64. package/shared/definition11.js +1 -1
  65. package/shared/definition12.js +1 -1
  66. package/shared/definition13.js +3 -3
  67. package/shared/definition14.js +3 -3
  68. package/shared/definition15.js +5 -5
  69. package/shared/definition16.js +3 -3
  70. package/shared/definition17.js +44 -6055
  71. package/shared/definition18.js +350 -213
  72. package/shared/definition19.js +251 -67
  73. package/shared/definition2.js +1 -1
  74. package/shared/definition20.js +66 -58
  75. package/shared/definition21.js +43 -84
  76. package/shared/definition22.js +75 -2298
  77. package/shared/definition23.js +2361 -45
  78. package/shared/definition24.js +63 -27
  79. package/shared/definition25.js +24 -51
  80. package/shared/definition26.js +36 -805
  81. package/shared/definition27.js +820 -49
  82. package/shared/definition28.js +52 -89
  83. package/shared/definition29.js +88 -24
  84. package/shared/definition3.js +1 -1
  85. package/shared/definition30.js +25 -12
  86. package/shared/definition31.js +12 -53
  87. package/shared/definition32.js +28 -487
  88. package/shared/definition33.js +427 -197
  89. package/shared/definition34.js +260 -174
  90. package/shared/definition35.js +187 -69
  91. package/shared/definition36.js +68 -55
  92. package/shared/definition37.js +61 -421
  93. package/shared/definition38.js +435 -35
  94. package/shared/definition39.js +30 -679
  95. package/shared/definition4.js +3 -3
  96. package/shared/definition40.js +661 -77
  97. package/shared/definition41.js +77 -557
  98. package/shared/definition42.js +559 -106
  99. package/shared/definition43.js +105 -136
  100. package/shared/definition44.js +153 -17
  101. package/shared/definition45.js +16 -79
  102. package/shared/definition46.js +53 -475
  103. package/shared/definition47.js +506 -20
  104. package/shared/definition48.js +22 -121
  105. package/shared/definition49.js +115 -262
  106. package/shared/definition5.js +2 -2
  107. package/shared/definition50.js +248 -120
  108. package/shared/definition51.js +139 -123
  109. package/shared/definition52.js +84 -74
  110. package/shared/definition53.js +114 -69
  111. package/shared/definition54.js +81 -292
  112. package/shared/definition55.js +302 -13
  113. package/shared/definition56.js +11 -41
  114. package/shared/definition57.js +20 -154
  115. package/shared/definition58.js +181 -0
  116. package/shared/definition6.js +2 -2
  117. package/shared/definition7.js +2 -2
  118. package/shared/definition8.js +3 -3
  119. package/shared/index2.js +1 -1
  120. package/shared/listbox.js +1 -1
  121. package/shared/localization/Locale.d.ts +3 -1
  122. package/shared/localized.js +9 -0
  123. package/shared/presentationDate.js +6133 -0
  124. package/shared/text-anchor.template.js +4 -4
  125. package/shared/text-field.js +1 -1
  126. package/side-drawer/index.js +1 -1
  127. package/slider/index.js +2 -2
  128. package/split-button/index.js +3 -3
  129. package/style.css +246 -183
  130. package/styles/core/all.css +1 -1
  131. package/styles/core/theme.css +1 -1
  132. package/styles/core/typography.css +1 -1
  133. package/styles/tokens/theme-dark.css +4 -4
  134. package/styles/tokens/theme-light.css +4 -4
  135. package/styles/tokens/vivid-2-compat.css +1 -1
  136. package/switch/index.js +3 -3
  137. package/tab/index.js +3 -3
  138. package/tab-panel/index.js +1 -1
  139. package/tabs/index.js +5 -5
  140. package/tag/index.js +3 -3
  141. package/tag-group/index.js +1 -1
  142. package/text-area/index.js +3 -3
  143. package/text-field/index.js +3 -3
  144. package/toggletip/index.js +6 -6
  145. package/tooltip/index.js +6 -6
  146. package/tree-item/index.js +3 -3
  147. package/tree-view/index.js +1 -1
  148. package/vivid.api.json +105 -0
  149. package/lib/date-picker/date-picker.form-associated.d.ts +0 -11
  150. package/lib/date-picker/date-picker.template.d.ts +0 -4
  151. /package/{lib → shared}/date-picker/calendar/calendarGrid.d.ts +0 -0
  152. /package/{lib → shared}/date-picker/calendar/dateStr.d.ts +0 -0
  153. /package/{lib → shared}/date-picker/calendar/month.d.ts +0 -0
  154. /package/{lib → shared}/date-picker/calendar/monthPickerGrid.d.ts +0 -0
  155. /package/{lib → shared}/date-picker/calendar/presentationDate.d.ts +0 -0
  156. /package/{lib → shared}/date-picker/calendar/year.d.ts +0 -0
@@ -1,502 +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 { f as focusRegistries } from './definition55.js';
3
- import { D as Direction, g as getDirection } from './direction.js';
4
- import { l as limit$1 } from './numbers.js';
5
- import { F as FormAssociated } from './form-associated.js';
6
- import { O as Orientation } from './aria.js';
7
- import { c as keyHome, b as keyEnd, d as keyArrowDown, i as keyArrowLeft, e as keyArrowUp, h as keyArrowRight } from './key-codes.js';
8
- import { f as focusTemplateFactory } from './focus2.js';
9
- import { r as ref } from './ref.js';
10
- import { O as Orientation$1 } from './aria2.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';
11
3
  import { c as classNames } from './class-names.js';
12
4
 
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 {
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(_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.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 = 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 === keyHome) {
145
- e.preventDefault();
146
- this.value = `${this.min}`;
147
- }
148
- else if (e.key === keyEnd) {
149
- e.preventDefault();
150
- this.value = `${this.max}`;
151
- }
152
- else if (!e.shiftKey) {
153
- switch (e.key) {
154
- case keyArrowRight:
155
- case keyArrowUp:
156
- e.preventDefault();
157
- this.increment();
158
- break;
159
- case keyArrowLeft:
160
- case keyArrowDown:
161
- e.preventDefault();
162
- this.decrement();
163
- break;
164
- }
165
- }
166
- };
167
- this.setupTrackConstraints = () => {
168
- const clientRect = this.track.getBoundingClientRect();
169
- this.trackWidth = this.track.clientWidth;
170
- this.trackMinWidth = this.track.clientLeft;
171
- this.trackHeight = clientRect.bottom;
172
- this.trackMinHeight = clientRect.top;
173
- this.trackLeft = this.getBoundingClientRect().left;
174
- if (this.trackWidth === 0) {
175
- this.trackWidth = 1;
176
- }
177
- };
178
- this.setupListeners = (remove = false) => {
179
- const eventAction = `${remove ? "remove" : "add"}EventListener`;
180
- this[eventAction]("keydown", this.keypressHandler);
181
- this[eventAction]("mousedown", this.handleMouseDown);
182
- this.thumb[eventAction]("mousedown", this.handleThumbMouseDown, {
183
- passive: true,
184
- });
185
- this.thumb[eventAction]("touchstart", this.handleThumbMouseDown, {
186
- passive: true,
187
- });
188
- // removes handlers attached by mousedown handlers
189
- if (remove) {
190
- this.handleMouseDown(null);
191
- this.handleThumbMouseDown(null);
192
- }
193
- };
194
- /**
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 === Orientation.horizontal
228
- ? sourceEvent.pageX - document.documentElement.scrollLeft - this.trackLeft
229
- : sourceEvent.pageY - document.documentElement.scrollTop;
230
- this.value = `${this.calculateNewValue(eventValue)}`;
231
- };
232
- this.calculateNewValue = (rawValue) => {
233
- // update the value based on current position
234
- const newPosition = convertPixelToPercent(rawValue, this.orientation === Orientation.horizontal
235
- ? this.trackMinWidth
236
- : this.trackMinHeight, this.orientation === Orientation.horizontal
237
- ? this.trackWidth
238
- : this.trackHeight, this.direction);
239
- const newValue = (this.max - this.min) * newPosition + this.min;
240
- return this.convertToConstrainedValue(newValue);
241
- };
242
- /**
243
- * Handle a window mouse up during a drag operation
244
- */
245
- this.handleWindowMouseUp = (event) => {
246
- this.stopDragging();
247
- };
248
- this.stopDragging = () => {
249
- this.isDragging = false;
250
- this.handleMouseDown(null);
251
- this.handleThumbMouseDown(null);
252
- };
253
- /**
254
- *
255
- * @param e - MouseEvent or null. If there is no event handler it will remove the events
256
- */
257
- this.handleMouseDown = (e) => {
258
- const eventAction = `${e !== null ? "add" : "remove"}EventListener`;
259
- if (e === null || (!this.disabled && !this.readOnly)) {
260
- window[eventAction]("mouseup", this.handleWindowMouseUp);
261
- window.document[eventAction]("mouseleave", this.handleWindowMouseUp);
262
- window[eventAction]("mousemove", this.handleMouseMove);
263
- if (e) {
264
- e.preventDefault();
265
- this.setupTrackConstraints();
266
- e.target.focus();
267
- const controlValue = this.orientation === Orientation.horizontal
268
- ? e.pageX - document.documentElement.scrollLeft - this.trackLeft
269
- : e.pageY - document.documentElement.scrollTop;
270
- this.value = `${this.calculateNewValue(controlValue)}`;
271
- }
272
- }
273
- };
274
- this.convertToConstrainedValue = (value) => {
275
- if (isNaN(value)) {
276
- value = this.min;
277
- }
278
- /**
279
- * The following logic intends to overcome the issue with math in JavaScript with regards to floating point numbers.
280
- * This is needed as the `step` may be an integer but could also be a float. To accomplish this the step is assumed to be a float
281
- * and is converted to an integer by determining the number of decimal places it represent, multiplying it until it is an
282
- * integer and then dividing it to get back to the correct number.
283
- */
284
- let constrainedValue = value - this.min;
285
- const roundedConstrainedValue = Math.round(constrainedValue / this.step);
286
- const remainderValue = constrainedValue -
287
- (roundedConstrainedValue * (this.stepMultiplier * this.step)) /
288
- this.stepMultiplier;
289
- constrainedValue =
290
- remainderValue >= Number(this.step) / 2
291
- ? constrainedValue - remainderValue + Number(this.step)
292
- : constrainedValue - remainderValue;
293
- return constrainedValue + this.min;
294
- };
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 = 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
- }
437
- }
438
- };
439
- __decorate([
440
- attr({ attribute: "readonly", mode: "boolean" })
441
- ], Slider$1.prototype, "readOnly", void 0);
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);
454
- __decorate([
455
- observable
456
- ], Slider$1.prototype, "trackMinWidth", void 0);
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
- }
497
-
498
- const styles = ":host {\n display: inline-block;\n width: 100%;\n}\n\n:host([orientation=vertical]) {\n height: 100%;\n min-height: calc(var(--_thumb-interaction-indicator-size) * 5);\n}\n\n.control {\n --_thumb-size: 12px;\n --_thumb-interaction-indicator-size: 36px;\n height: var(--_thumb-interaction-indicator-size);\n cursor: pointer;\n outline: none;\n user-select: none;\n}\n@supports selector(:focus-visible) {\n .control:focus-visible {\n outline: none;\n }\n}\n.control .positioning-region {\n position: relative;\n}\n.control .track {\n position: absolute;\n background: var(--_track-background-color);\n border-radius: 4px;\n}\n.control .track .track-start {\n position: absolute;\n left: 0;\n height: 100%;\n background: var(--_track-start-background-color);\n border-radius: 4px;\n}\n.control .thumb-container {\n position: absolute;\n width: var(--_thumb-interaction-indicator-size);\n height: var(--_thumb-interaction-indicator-size);\n cursor: inherit;\n touch-action: none;\n}\n.control .thumb-container::before {\n position: absolute;\n display: block;\n width: var(--_thumb-interaction-indicator-size);\n height: var(--_thumb-interaction-indicator-size);\n background-color: var(--_track-start-background-color);\n border-radius: 50%;\n content: \"\";\n opacity: var(--_thumb-interaction-indicator-alpha, 0);\n transition: opacity 0.2s ease-out 0s;\n}\n.control .thumb-container::after {\n position: absolute;\n display: block;\n width: var(--_thumb-size);\n height: var(--_thumb-size);\n background-color: var(--_track-start-background-color);\n border-radius: 50%;\n content: \"\";\n inset: calc((var(--_thumb-interaction-indicator-size) - var(--_thumb-size)) / 2);\n}\n.control[aria-orientation=horizontal] {\n width: calc(100% - var(--_thumb-size));\n min-width: var(--_thumb-size);\n margin-left: calc(var(--_thumb-size) / 2);\n}\n.control[aria-orientation=horizontal] .track {\n top: calc((var(--_thumb-interaction-indicator-size) - 2px) / 2);\n right: 0;\n left: 0;\n height: 2px;\n}\n.control[aria-orientation=horizontal] .track .mark {\n width: 100%;\n height: 4px;\n}\n.control[aria-orientation=horizontal] .thumb-container {\n transform: translateX(calc(var(--_thumb-interaction-indicator-size) / 2));\n}\n.control[aria-orientation=vertical] {\n height: calc(100% - var(--_thumb-interaction-indicator-size));\n min-height: var(--_thumb-interaction-indicator-size);\n margin-top: calc(var(--_thumb-interaction-indicator-size) / 2);\n}\n.control[aria-orientation=vertical] .positioning-region {\n height: 100%;\n}\n.control[aria-orientation=vertical] .track {\n left: calc((var(--_thumb-interaction-indicator-size) - 2px) / 2);\n width: 2px;\n height: 100%;\n}\n.control[aria-orientation=vertical] .track .mark {\n width: 4px;\n height: 100%;\n}\n.control[aria-orientation=vertical] .track-start {\n top: 0;\n width: 100%;\n height: auto;\n}\n.control[aria-orientation=vertical] .thumb-container {\n transform: translateY(calc(var(--_thumb-interaction-indicator-size) / 2));\n}\n.control.disabled {\n --_track-background-color: var(--vvd-color-neutral-100);\n --_track-start-background-color: var(--vvd-color-neutral-500);\n cursor: not-allowed;\n pointer-events: none;\n}\n.control:not(.disabled) {\n --_track-background-color: var(--vvd-color-neutral-300);\n --_track-start-background-color: var(--vvd-color-canvas-text);\n}\n.control:not(.disabled) .thumb-container:hover {\n --_thumb-interaction-indicator-alpha: 0.12;\n}\n.control:not(.disabled) .thumb-container:active {\n --_thumb-interaction-indicator-alpha: 0.25;\n}\n\n.focus-indicator {\n --focus-inset: -3px;\n --focus-stroke-gap-color: transparent;\n border-radius: 50%;\n}\n.control:not(:focus-visible) .focus-indicator {\n display: none;\n}";
499
-
500
5
  var __defProp = Object.defineProperty;
501
6
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
502
7
  var __decorateClass = (decorators, target, key, kind) => {
@@ -508,82 +13,97 @@ var __decorateClass = (decorators, target, key, kind) => {
508
13
  __defProp(target, key, result);
509
14
  return result;
510
15
  };
511
- class Slider extends Slider$1 {
16
+ class SideDrawer extends FoundationElement {
512
17
  constructor() {
513
18
  super(...arguments);
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
40
  attr({
539
41
  mode: "boolean"
540
42
  })
541
- ], Slider.prototype, "markers", 2);
43
+ ], SideDrawer.prototype, "alternate", 2);
44
+ __decorateClass([
45
+ attr({
46
+ mode: "boolean"
47
+ })
48
+ ], SideDrawer.prototype, "modal", 2);
49
+ __decorateClass([
50
+ attr({
51
+ mode: "boolean"
52
+ })
53
+ ], SideDrawer.prototype, "open", 2);
54
+ __decorateClass([
55
+ attr({
56
+ mode: "boolean"
57
+ })
58
+ ], SideDrawer.prototype, "trailing", 2);
542
59
 
543
- const getClasses = ({ disabled }) => classNames(
60
+ const styles = "/**\n * Do not edit directly\n * Generated on Fri, 13 Oct 2023 14:45:50 GMT\n */\n.control {\n position: fixed;\n z-index: 1;\n background-color: var(--vvd-color-canvas);\n color: var(--vvd-color-canvas-text);\n inline-size: 280px;\n inset-block: 0;\n overflow-y: auto;\n}\n.control[part~=vvd-theme-alternate] {\n background-color: var(--vvd-color-canvas);\n color: var(--vvd-color-canvas-text);\n color-scheme: var(--vvd-color-scheme);\n}\n.control.trailing {\n inset-inline-end: 0;\n}\n.control:not(.open).trailing {\n transform: translateX(100%);\n}\n.control:not(.open):not(.trailing) {\n transform: translateX(-100%);\n}\n.control.open:not(.modal).trailing + .side-drawer-app-content {\n margin-inline-end: var(--side-drawer-app-content-offset, 280px);\n}\n.control.open:not(.modal):not(.trailing) + .side-drawer-app-content {\n margin-inline-start: var(--side-drawer-app-content-offset, 280px);\n}\n@media (prefers-reduced-motion: no-preference) {\n .control {\n transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);\n }\n}\n\n.scrim {\n background-color: var(--vvd-color-canvas-text, currentColor);\n opacity: 0.5;\n position: fixed;\n inset: 0;\n}\n.scrim:not(.open) {\n display: none;\n}";
61
+
62
+ const getClasses = ({
63
+ modal,
64
+ open,
65
+ trailing
66
+ }) => classNames(
544
67
  "control",
545
- ["disabled", Boolean(disabled)]
68
+ ["modal", modal],
69
+ ["open", open],
70
+ ["trailing", trailing]
546
71
  );
547
- const getMarkersTemplate = (isHorizontal, numMarkers) => {
548
- const placeholder = isHorizontal ? ["right", "center", "", "100% repeat-x"] : ["bottom", "top", "100%", "repeat-y"];
549
- return html`
550
- <div class="mark" style="
551
- background: linear-gradient(to ${placeholder[0]}, currentcolor 3px, transparent 0px)
552
- 0px ${placeholder[1]} / ${placeholder[2]} calc((100% - 3px) / ${numMarkers}) ${placeholder[3]}
553
- "></div>`;
554
- };
555
- const SliderTemplate = (context) => {
556
- const focusTemplate = focusTemplateFactory(context);
557
- return html`
558
- <div
559
- role="slider"
560
- tabindex="${(x) => x.disabled ? null : 0}"
561
- aria-valuetext="${(x) => x.valueTextFormatter(x.value)}"
562
- aria-valuenow="${(x) => x.value}"
563
- aria-valuemin="${(x) => x.min}"
564
- aria-valuemax="${(x) => x.max}"
565
- aria-disabled="${(x) => x.disabled ? true : void 0}"
566
- aria-orientation="${(x) => x.orientation}"
567
- class="${getClasses} ${(x) => x.orientation}"
568
- >
569
- <div class="positioning-region">
570
- <div ${ref("track")} class="track">
571
- <div class="track-start" style="${(x) => x.position}"></div>
572
- ${(x) => x.markers ? getMarkersTemplate(x.orientation === Orientation$1.horizontal, Math.floor((x.max - x.min) / x.step)) : void 0}
573
- </div>
574
- <div ${ref("thumb")} class="thumb-container" style="${(x) => x.position}">
575
- ${() => focusTemplate}
576
- </div>
577
- </div>
578
- </div>`;
72
+ const getScrimClasses = ({
73
+ open
74
+ }) => classNames(
75
+ "scrim",
76
+ ["open", open]
77
+ );
78
+ const sideDrawerTemplate = () => html`
79
+ <aside class="${getClasses}" part="base ${(x) => x.alternate ? "vvd-theme-alternate" : ""}"
80
+ @keydown="${(x, c) => handleKeydown(x, c.event)}">
81
+ <slot></slot>
82
+ </aside>
83
+
84
+ <div class="side-drawer-app-content" ?inert="${(x) => x.open && x.modal}">
85
+ <slot name="app-content"></slot>
86
+ </div>
87
+
88
+ ${when(
89
+ (x) => x.modal,
90
+ html`<div class="${getScrimClasses}" @click="${(x) => x.open = false}"></div>`
91
+ )}
92
+ `;
93
+ const handleKeydown = (x, { key }) => {
94
+ if (key === "Escape") {
95
+ x.open = false;
96
+ } else {
97
+ return true;
98
+ }
579
99
  };
580
100
 
581
- const sliderDefinition = Slider.compose({
582
- baseName: "slider",
583
- template: SliderTemplate,
101
+ const sideDrawerDefinition = SideDrawer.compose({
102
+ baseName: "side-drawer",
103
+ template: sideDrawerTemplate,
584
104
  styles
585
105
  });
586
- const sliderRegistries = [sliderDefinition(), ...focusRegistries];
587
- const registerSlider = registerFactory(sliderRegistries);
106
+ const sideDrawerRegistries = [sideDrawerDefinition()];
107
+ const registerSideDrawer = registerFactory(sideDrawerRegistries);
588
108
 
589
- export { sliderRegistries as a, registerSlider as r, sliderDefinition as s };
109
+ export { sideDrawerRegistries as a, registerSideDrawer as r, sideDrawerDefinition as s };