@vonage/vivid 3.0.0-next.93 → 3.0.0-next.95

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 (65) hide show
  1. package/accordion/index.js +1 -1
  2. package/accordion-item/index.js +2 -1
  3. package/action-group/index.js +1 -1
  4. package/avatar/index.js +2 -1
  5. package/badge/index.js +2 -1
  6. package/banner/index.js +2 -1
  7. package/breadcrumb-item/index.js +2 -1
  8. package/button/index.js +1 -0
  9. package/calendar/index.js +1 -1
  10. package/calendar-event/index.js +1 -1
  11. package/card/index.js +2 -1
  12. package/checkbox/index.js +2 -1
  13. package/dialog/index.js +2 -1
  14. package/fab/index.js +2 -1
  15. package/focus/index.js +1 -1
  16. package/header/index.js +1 -1
  17. package/icon/index.js +1 -0
  18. package/index.js +5 -0
  19. package/lib/components.d.ts +2 -0
  20. package/lib/slider/index.d.ts +3 -0
  21. package/lib/slider/slider.d.ts +4 -0
  22. package/lib/slider/slider.template.d.ts +4 -0
  23. package/lib/switch/index.d.ts +4 -0
  24. package/lib/switch/switch.d.ts +7 -0
  25. package/lib/switch/switch.template.d.ts +4 -0
  26. package/listbox/index.js +3 -18
  27. package/listbox-option/index.js +1 -0
  28. package/menu/index.js +1 -0
  29. package/menu-item/index.js +1 -0
  30. package/nav-disclosure/index.js +2 -1
  31. package/nav-item/index.js +2 -1
  32. package/note/index.js +2 -1
  33. package/number-field/index.js +5 -60
  34. package/package.json +6 -4
  35. package/popup/index.js +1 -0
  36. package/progress/index.js +1 -1
  37. package/progress-ring/index.js +1 -1
  38. package/radio/index.js +1 -1
  39. package/radio-group/index.js +1 -1
  40. package/shared/es.object.assign.js +1 -1
  41. package/shared/es.regexp.to-string.js +59 -0
  42. package/shared/export.js +1 -1
  43. package/shared/form-elements.js +1 -1
  44. package/shared/icon.js +10 -45
  45. package/shared/index2.js +1 -1
  46. package/shared/index4.js +1 -1
  47. package/shared/index5.js +1 -1
  48. package/shared/index7.js +1 -1
  49. package/shared/numbers.js +25 -0
  50. package/shared/object-keys.js +1 -1
  51. package/shared/patterns/form-elements/form-elements.d.ts +1 -1
  52. package/shared/string-trim.js +40 -0
  53. package/shared/web.dom-collections.iterator.js +1 -1
  54. package/side-drawer/index.js +1 -1
  55. package/slider/index.js +596 -0
  56. package/styles/core/all.css +1 -1
  57. package/styles/core/theme.css +1 -1
  58. package/styles/core/typography.css +1 -1
  59. package/styles/tokens/theme-dark.css +4 -4
  60. package/styles/tokens/theme-light.css +4 -4
  61. package/switch/index.js +153 -0
  62. package/text-anchor/index.js +1 -0
  63. package/text-area/index.js +2 -1
  64. package/text-field/index.js +2 -1
  65. package/tooltip/index.js +2 -1
@@ -0,0 +1,40 @@
1
+ import { f as functionUncurryThis, L as requireObjectCoercible$1 } from './export.js';
2
+ import { t as toString$1 } from './to-string.js';
3
+
4
+ // a string of all valid unicode whitespaces
5
+ var whitespaces$1 = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' +
6
+ '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
7
+
8
+ var uncurryThis = functionUncurryThis;
9
+ var requireObjectCoercible = requireObjectCoercible$1;
10
+ var toString = toString$1;
11
+ var whitespaces = whitespaces$1;
12
+
13
+ var replace = uncurryThis(''.replace);
14
+ var whitespace = '[' + whitespaces + ']';
15
+ var ltrim = RegExp('^' + whitespace + whitespace + '*');
16
+ var rtrim = RegExp(whitespace + whitespace + '*$');
17
+
18
+ // `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation
19
+ var createMethod = function (TYPE) {
20
+ return function ($this) {
21
+ var string = toString(requireObjectCoercible($this));
22
+ if (TYPE & 1) string = replace(string, ltrim, '');
23
+ if (TYPE & 2) string = replace(string, rtrim, '');
24
+ return string;
25
+ };
26
+ };
27
+
28
+ var stringTrim = {
29
+ // `String.prototype.{ trimLeft, trimStart }` methods
30
+ // https://tc39.es/ecma262/#sec-string.prototype.trimstart
31
+ start: createMethod(1),
32
+ // `String.prototype.{ trimRight, trimEnd }` methods
33
+ // https://tc39.es/ecma262/#sec-string.prototype.trimend
34
+ end: createMethod(2),
35
+ // `String.prototype.trim` method
36
+ // https://tc39.es/ecma262/#sec-string.prototype.trim
37
+ trim: createMethod(3)
38
+ };
39
+
40
+ export { stringTrim as s, whitespaces$1 as w };
@@ -1,4 +1,4 @@
1
- import { d as descriptors, E as v8PrototypeDefineBug, o as objectDefineProperty, j as anObject$2, F as toIndexedObject$2, G as sharedKey$2, H as enumBugKeys$1, I as hiddenKeys$1, p as documentCreateElement$2, w as wellKnownSymbol$4, e as fails$2, q as hasOwnProperty_1, i as isCallable$3, J as toObject$1, z as isObject$1, v as defineBuiltIn$2, K as createPropertyDescriptor$1, _ as _export, L as createNonEnumerableProperty$2, x as functionCall, D as functionName, y as internalState, g as global$1 } from './export.js';
1
+ import { d as descriptors, D as v8PrototypeDefineBug, o as objectDefineProperty, j as anObject$2, E as toIndexedObject$2, F as sharedKey$2, G as enumBugKeys$1, H as hiddenKeys$1, p as documentCreateElement$2, w as wellKnownSymbol$4, e as fails$2, q as hasOwnProperty_1, i as isCallable$3, I as toObject$1, z as isObject$1, v as defineBuiltIn$2, J as createPropertyDescriptor$1, _ as _export, K as createNonEnumerableProperty$2, x as functionCall, C as functionName, y as internalState, g as global$1 } from './export.js';
2
2
  import { o as objectKeys$1 } from './object-keys.js';
3
3
  import { h as html$1, s as setToStringTag$2, i as iterators, o as objectSetPrototypeOf } from './iterators.js';
4
4
 
@@ -44,7 +44,7 @@ __decorate([attr({
44
44
  mode: 'boolean'
45
45
  }), __metadata("design:type", Object)], SideDrawer.prototype, "trailing", void 0);
46
46
 
47
- var css_248z = "/**\n * Do not edit directly\n * Generated on Mon, 07 Nov 2022 11:12:43 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);\n opacity: 0.5;\n position: fixed;\n inset: 0;\n}\n.scrim:not(.open) {\n display: none;\n}";
47
+ var css_248z = "/**\n * Do not edit directly\n * Generated on Tue, 08 Nov 2022 19:42:32 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);\n opacity: 0.5;\n position: fixed;\n inset: 0;\n}\n.scrim:not(.open) {\n display: none;\n}";
48
48
 
49
49
  let _ = t => t,
50
50
  _t,
@@ -0,0 +1,596 @@
1
+ import '../focus/index.js';
2
+ import { F as FoundationElement, _ as __decorate, a as attr, o as observable, n as nullableNumberConverter, b as __metadata, h as html, d as designSystem } from '../shared/index.js';
3
+ import '../shared/web.dom-collections.iterator.js';
4
+ import { g as global$1, e as fails$1, f as functionUncurryThis, _ as _export } from '../shared/export.js';
5
+ import { t as toString$1 } from '../shared/to-string.js';
6
+ import { w as whitespaces$1, s as stringTrim } from '../shared/string-trim.js';
7
+ import '../shared/es.regexp.to-string.js';
8
+ import { D as Direction, g as getDirection } from '../shared/direction.js';
9
+ import { l as limit } from '../shared/numbers.js';
10
+ import { F as FormAssociated } from '../shared/form-associated.js';
11
+ import { O as Orientation } from '../shared/aria.js';
12
+ import { g as keyHome, d as keyEnd, f as keyArrowDown, h as keyArrowLeft, e as keyArrowUp, i as keyArrowRight } from '../shared/key-codes.js';
13
+ import { f as focusTemplateFactory } from '../shared/focus2.js';
14
+ import { r as ref } from '../shared/ref.js';
15
+ import { c as classNames } from '../shared/class-names.js';
16
+ import '../shared/focus.js';
17
+ import '../shared/object-keys.js';
18
+ import '../shared/iterators.js';
19
+
20
+ /**
21
+ * Converts a pixel coordinate on the track to a percent of the track's range
22
+ */
23
+ function convertPixelToPercent(pixelPos, minPosition, maxPosition, direction) {
24
+ let pct = limit(0, 1, (pixelPos - minPosition) / (maxPosition - minPosition));
25
+ if (direction === Direction.rtl) {
26
+ pct = 1 - pct;
27
+ }
28
+ return pct;
29
+ }
30
+
31
+ class _Slider extends FoundationElement {
32
+ }
33
+ /**
34
+ * A form-associated base class for the {@link @microsoft/fast-foundation#(Slider:class)} component.
35
+ *
36
+ * @internal
37
+ */
38
+ class FormAssociatedSlider extends FormAssociated(_Slider) {
39
+ constructor() {
40
+ super(...arguments);
41
+ this.proxy = document.createElement("input");
42
+ }
43
+ }
44
+
45
+ /**
46
+ * The selection modes of a {@link @microsoft/fast-foundation#(Slider:class)}.
47
+ * @public
48
+ */
49
+ const SliderMode = {
50
+ singleValue: "single-value",
51
+ };
52
+ /**
53
+ * A Slider Custom HTML Element.
54
+ * Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#slider | ARIA slider }.
55
+ *
56
+ * @slot track - The track of the slider
57
+ * @slot track-start - The track-start visual indicator
58
+ * @slot thumb - The slider thumb
59
+ * @slot - The default slot for labels
60
+ * @csspart positioning-region - The region used to position the elements of the slider
61
+ * @csspart track-container - The region containing the track elements
62
+ * @csspart track-start - The element wrapping the track start slot
63
+ * @csspart thumb-container - The thumb container element which is programatically positioned
64
+ * @fires change - Fires a custom 'change' event when the slider value changes
65
+ *
66
+ * @public
67
+ */
68
+ class Slider$1 extends FormAssociatedSlider {
69
+ constructor() {
70
+ super(...arguments);
71
+ /**
72
+ * @internal
73
+ */
74
+ this.direction = Direction.ltr;
75
+ /**
76
+ * @internal
77
+ */
78
+ this.isDragging = false;
79
+ /**
80
+ * @internal
81
+ */
82
+ this.trackWidth = 0;
83
+ /**
84
+ * @internal
85
+ */
86
+ this.trackMinWidth = 0;
87
+ /**
88
+ * @internal
89
+ */
90
+ this.trackHeight = 0;
91
+ /**
92
+ * @internal
93
+ */
94
+ this.trackLeft = 0;
95
+ /**
96
+ * @internal
97
+ */
98
+ this.trackMinHeight = 0;
99
+ /**
100
+ * Custom function that generates a string for the component's "aria-valuetext" attribute based on the current value.
101
+ *
102
+ * @public
103
+ */
104
+ this.valueTextFormatter = () => null;
105
+ /**
106
+ * The minimum allowed value.
107
+ *
108
+ * @defaultValue - 0
109
+ * @public
110
+ * @remarks
111
+ * HTML Attribute: min
112
+ */
113
+ this.min = 0; // Map to proxy element.
114
+ /**
115
+ * The maximum allowed value.
116
+ *
117
+ * @defaultValue - 10
118
+ * @public
119
+ * @remarks
120
+ * HTML Attribute: max
121
+ */
122
+ this.max = 10; // Map to proxy element.
123
+ /**
124
+ * Value to increment or decrement via arrow keys, mouse click or drag.
125
+ *
126
+ * @public
127
+ * @remarks
128
+ * HTML Attribute: step
129
+ */
130
+ this.step = 1; // Map to proxy element.
131
+ /**
132
+ * The orientation of the slider.
133
+ *
134
+ * @public
135
+ * @remarks
136
+ * HTML Attribute: orientation
137
+ */
138
+ this.orientation = Orientation.horizontal;
139
+ /**
140
+ * The selection mode.
141
+ *
142
+ * @public
143
+ * @remarks
144
+ * HTML Attribute: mode
145
+ */
146
+ this.mode = SliderMode.singleValue;
147
+ this.keypressHandler = (e) => {
148
+ if (this.readOnly) {
149
+ return;
150
+ }
151
+ if (e.key === keyHome) {
152
+ e.preventDefault();
153
+ this.value = `${this.min}`;
154
+ }
155
+ else if (e.key === keyEnd) {
156
+ e.preventDefault();
157
+ this.value = `${this.max}`;
158
+ }
159
+ else if (!e.shiftKey) {
160
+ switch (e.key) {
161
+ case keyArrowRight:
162
+ case keyArrowUp:
163
+ e.preventDefault();
164
+ this.increment();
165
+ break;
166
+ case keyArrowLeft:
167
+ case keyArrowDown:
168
+ e.preventDefault();
169
+ this.decrement();
170
+ break;
171
+ }
172
+ }
173
+ };
174
+ this.setupTrackConstraints = () => {
175
+ const clientRect = this.track.getBoundingClientRect();
176
+ this.trackWidth = this.track.clientWidth;
177
+ this.trackMinWidth = this.track.clientLeft;
178
+ this.trackHeight = clientRect.bottom;
179
+ this.trackMinHeight = clientRect.top;
180
+ this.trackLeft = this.getBoundingClientRect().left;
181
+ if (this.trackWidth === 0) {
182
+ this.trackWidth = 1;
183
+ }
184
+ };
185
+ this.setupListeners = (remove = false) => {
186
+ const eventAction = `${remove ? "remove" : "add"}EventListener`;
187
+ this[eventAction]("keydown", this.keypressHandler);
188
+ this[eventAction]("mousedown", this.handleMouseDown);
189
+ this.thumb[eventAction]("mousedown", this.handleThumbMouseDown, {
190
+ passive: true,
191
+ });
192
+ this.thumb[eventAction]("touchstart", this.handleThumbMouseDown, {
193
+ passive: true,
194
+ });
195
+ // removes handlers attached by mousedown handlers
196
+ if (remove) {
197
+ this.handleMouseDown(null);
198
+ this.handleThumbMouseDown(null);
199
+ }
200
+ };
201
+ /**
202
+ * @internal
203
+ */
204
+ this.initialValue = "";
205
+ /**
206
+ * Handle mouse moves during a thumb drag operation
207
+ * If the event handler is null it removes the events
208
+ */
209
+ this.handleThumbMouseDown = (event) => {
210
+ if (event) {
211
+ if (this.readOnly || this.disabled || event.defaultPrevented) {
212
+ return;
213
+ }
214
+ event.target.focus();
215
+ }
216
+ const eventAction = `${event !== null ? "add" : "remove"}EventListener`;
217
+ window[eventAction]("mouseup", this.handleWindowMouseUp);
218
+ window[eventAction]("mousemove", this.handleMouseMove, { passive: true });
219
+ window[eventAction]("touchmove", this.handleMouseMove, { passive: true });
220
+ window[eventAction]("touchend", this.handleWindowMouseUp);
221
+ this.isDragging = event !== null;
222
+ };
223
+ /**
224
+ * Handle mouse moves during a thumb drag operation
225
+ */
226
+ this.handleMouseMove = (e) => {
227
+ if (this.readOnly || this.disabled || e.defaultPrevented) {
228
+ return;
229
+ }
230
+ // update the value based on current position
231
+ const sourceEvent = window.TouchEvent && e instanceof TouchEvent
232
+ ? e.touches[0]
233
+ : e;
234
+ const eventValue = this.orientation === Orientation.horizontal
235
+ ? sourceEvent.pageX - document.documentElement.scrollLeft - this.trackLeft
236
+ : sourceEvent.pageY - document.documentElement.scrollTop;
237
+ this.value = `${this.calculateNewValue(eventValue)}`;
238
+ };
239
+ this.calculateNewValue = (rawValue) => {
240
+ // update the value based on current position
241
+ const newPosition = convertPixelToPercent(rawValue, this.orientation === Orientation.horizontal
242
+ ? this.trackMinWidth
243
+ : this.trackMinHeight, this.orientation === Orientation.horizontal
244
+ ? this.trackWidth
245
+ : this.trackHeight, this.direction);
246
+ const newValue = (this.max - this.min) * newPosition + this.min;
247
+ return this.convertToConstrainedValue(newValue);
248
+ };
249
+ /**
250
+ * Handle a window mouse up during a drag operation
251
+ */
252
+ this.handleWindowMouseUp = (event) => {
253
+ this.stopDragging();
254
+ };
255
+ this.stopDragging = () => {
256
+ this.isDragging = false;
257
+ this.handleMouseDown(null);
258
+ this.handleThumbMouseDown(null);
259
+ };
260
+ /**
261
+ *
262
+ * @param e - MouseEvent or null. If there is no event handler it will remove the events
263
+ */
264
+ this.handleMouseDown = (e) => {
265
+ const eventAction = `${e !== null ? "add" : "remove"}EventListener`;
266
+ if (e === null || (!this.disabled && !this.readOnly)) {
267
+ window[eventAction]("mouseup", this.handleWindowMouseUp);
268
+ window.document[eventAction]("mouseleave", this.handleWindowMouseUp);
269
+ window[eventAction]("mousemove", this.handleMouseMove);
270
+ if (e) {
271
+ e.preventDefault();
272
+ this.setupTrackConstraints();
273
+ e.target.focus();
274
+ const controlValue = this.orientation === Orientation.horizontal
275
+ ? e.pageX - document.documentElement.scrollLeft - this.trackLeft
276
+ : e.pageY - document.documentElement.scrollTop;
277
+ this.value = `${this.calculateNewValue(controlValue)}`;
278
+ }
279
+ }
280
+ };
281
+ this.convertToConstrainedValue = (value) => {
282
+ if (isNaN(value)) {
283
+ value = this.min;
284
+ }
285
+ /**
286
+ * The following logic intends to overcome the issue with math in JavaScript with regards to floating point numbers.
287
+ * 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
288
+ * and is converted to an integer by determining the number of decimal places it represent, multiplying it until it is an
289
+ * integer and then dividing it to get back to the correct number.
290
+ */
291
+ let constrainedValue = value - this.min;
292
+ const roundedConstrainedValue = Math.round(constrainedValue / this.step);
293
+ const remainderValue = constrainedValue -
294
+ (roundedConstrainedValue * (this.stepMultiplier * this.step)) /
295
+ this.stepMultiplier;
296
+ constrainedValue =
297
+ remainderValue >= Number(this.step) / 2
298
+ ? constrainedValue - remainderValue + Number(this.step)
299
+ : constrainedValue - remainderValue;
300
+ return constrainedValue + this.min;
301
+ };
302
+ }
303
+ readOnlyChanged() {
304
+ if (this.proxy instanceof HTMLInputElement) {
305
+ this.proxy.readOnly = this.readOnly;
306
+ }
307
+ }
308
+ /**
309
+ * The value property, typed as a number.
310
+ *
311
+ * @public
312
+ */
313
+ get valueAsNumber() {
314
+ return parseFloat(super.value);
315
+ }
316
+ set valueAsNumber(next) {
317
+ this.value = next.toString();
318
+ }
319
+ /**
320
+ * @internal
321
+ */
322
+ valueChanged(previous, next) {
323
+ super.valueChanged(previous, next);
324
+ if (this.$fastController.isConnected) {
325
+ this.setThumbPositionForOrientation(this.direction);
326
+ }
327
+ this.$emit("change");
328
+ }
329
+ minChanged() {
330
+ if (this.proxy instanceof HTMLInputElement) {
331
+ this.proxy.min = `${this.min}`;
332
+ }
333
+ this.validate();
334
+ }
335
+ maxChanged() {
336
+ if (this.proxy instanceof HTMLInputElement) {
337
+ this.proxy.max = `${this.max}`;
338
+ }
339
+ this.validate();
340
+ }
341
+ stepChanged() {
342
+ if (this.proxy instanceof HTMLInputElement) {
343
+ this.proxy.step = `${this.step}`;
344
+ }
345
+ this.updateStepMultiplier();
346
+ this.validate();
347
+ }
348
+ orientationChanged() {
349
+ if (this.$fastController.isConnected) {
350
+ this.setThumbPositionForOrientation(this.direction);
351
+ }
352
+ }
353
+ /**
354
+ * @internal
355
+ */
356
+ connectedCallback() {
357
+ super.connectedCallback();
358
+ this.proxy.setAttribute("type", "range");
359
+ this.direction = getDirection(this);
360
+ this.updateStepMultiplier();
361
+ this.setupTrackConstraints();
362
+ this.setupListeners();
363
+ this.setupDefaultValue();
364
+ this.setThumbPositionForOrientation(this.direction);
365
+ }
366
+ /**
367
+ * @internal
368
+ */
369
+ disconnectedCallback() {
370
+ this.setupListeners(true);
371
+ }
372
+ /**
373
+ * Increment the value by the step
374
+ *
375
+ * @public
376
+ */
377
+ increment() {
378
+ const newVal = this.direction !== Direction.rtl && this.orientation !== Orientation.vertical
379
+ ? Number(this.value) + Number(this.step)
380
+ : Number(this.value) - Number(this.step);
381
+ const incrementedVal = this.convertToConstrainedValue(newVal);
382
+ const incrementedValString = incrementedVal < Number(this.max) ? `${incrementedVal}` : `${this.max}`;
383
+ this.value = incrementedValString;
384
+ }
385
+ /**
386
+ * Decrement the value by the step
387
+ *
388
+ * @public
389
+ */
390
+ decrement() {
391
+ const newVal = this.direction !== Direction.rtl && this.orientation !== Orientation.vertical
392
+ ? Number(this.value) - Number(this.step)
393
+ : Number(this.value) + Number(this.step);
394
+ const decrementedVal = this.convertToConstrainedValue(newVal);
395
+ const decrementedValString = decrementedVal > Number(this.min) ? `${decrementedVal}` : `${this.min}`;
396
+ this.value = decrementedValString;
397
+ }
398
+ /**
399
+ * Places the thumb based on the current value
400
+ *
401
+ * @public
402
+ * @param direction - writing mode
403
+ */
404
+ setThumbPositionForOrientation(direction) {
405
+ const newPct = convertPixelToPercent(Number(this.value), Number(this.min), Number(this.max), direction);
406
+ const percentage = (1 - newPct) * 100;
407
+ if (this.orientation === Orientation.horizontal) {
408
+ this.position = this.isDragging
409
+ ? `right: ${percentage}%; transition: none;`
410
+ : `right: ${percentage}%; transition: all 0.2s ease;`;
411
+ }
412
+ else {
413
+ this.position = this.isDragging
414
+ ? `bottom: ${percentage}%; transition: none;`
415
+ : `bottom: ${percentage}%; transition: all 0.2s ease;`;
416
+ }
417
+ }
418
+ /**
419
+ * Update the step multiplier used to ensure rounding errors from steps that
420
+ * are not whole numbers
421
+ */
422
+ updateStepMultiplier() {
423
+ const stepString = this.step + "";
424
+ const decimalPlacesOfStep = !!(this.step % 1)
425
+ ? stepString.length - stepString.indexOf(".") - 1
426
+ : 0;
427
+ this.stepMultiplier = Math.pow(10, decimalPlacesOfStep);
428
+ }
429
+ get midpoint() {
430
+ return `${this.convertToConstrainedValue((this.max + this.min) / 2)}`;
431
+ }
432
+ setupDefaultValue() {
433
+ if (typeof this.value === "string") {
434
+ if (this.value.length === 0) {
435
+ this.initialValue = this.midpoint;
436
+ }
437
+ else {
438
+ const value = parseFloat(this.value);
439
+ if (!Number.isNaN(value) && (value < this.min || value > this.max)) {
440
+ this.value = this.midpoint;
441
+ }
442
+ }
443
+ }
444
+ }
445
+ }
446
+ __decorate([
447
+ attr({ attribute: "readonly", mode: "boolean" })
448
+ ], Slider$1.prototype, "readOnly", void 0);
449
+ __decorate([
450
+ observable
451
+ ], Slider$1.prototype, "direction", void 0);
452
+ __decorate([
453
+ observable
454
+ ], Slider$1.prototype, "isDragging", void 0);
455
+ __decorate([
456
+ observable
457
+ ], Slider$1.prototype, "position", void 0);
458
+ __decorate([
459
+ observable
460
+ ], Slider$1.prototype, "trackWidth", void 0);
461
+ __decorate([
462
+ observable
463
+ ], Slider$1.prototype, "trackMinWidth", void 0);
464
+ __decorate([
465
+ observable
466
+ ], Slider$1.prototype, "trackHeight", void 0);
467
+ __decorate([
468
+ observable
469
+ ], Slider$1.prototype, "trackLeft", void 0);
470
+ __decorate([
471
+ observable
472
+ ], Slider$1.prototype, "trackMinHeight", void 0);
473
+ __decorate([
474
+ observable
475
+ ], Slider$1.prototype, "valueTextFormatter", void 0);
476
+ __decorate([
477
+ attr({ converter: nullableNumberConverter })
478
+ ], Slider$1.prototype, "min", void 0);
479
+ __decorate([
480
+ attr({ converter: nullableNumberConverter })
481
+ ], Slider$1.prototype, "max", void 0);
482
+ __decorate([
483
+ attr({ converter: nullableNumberConverter })
484
+ ], Slider$1.prototype, "step", void 0);
485
+ __decorate([
486
+ attr
487
+ ], Slider$1.prototype, "orientation", void 0);
488
+ __decorate([
489
+ attr
490
+ ], Slider$1.prototype, "mode", void 0);
491
+
492
+ var css_248z = ":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 {\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}\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}";
493
+
494
+ var global = global$1;
495
+ var fails = fails$1;
496
+ var uncurryThis = functionUncurryThis;
497
+ var toString = toString$1;
498
+ var trim = stringTrim.trim;
499
+ var whitespaces = whitespaces$1;
500
+
501
+ var charAt = uncurryThis(''.charAt);
502
+ var $parseFloat$1 = global.parseFloat;
503
+ var Symbol = global.Symbol;
504
+ var ITERATOR = Symbol && Symbol.iterator;
505
+ var FORCED = 1 / $parseFloat$1(whitespaces + '-0') !== -Infinity
506
+ // MS Edge 18- broken with boxed symbols
507
+ || (ITERATOR && !fails(function () { $parseFloat$1(Object(ITERATOR)); }));
508
+
509
+ // `parseFloat` method
510
+ // https://tc39.es/ecma262/#sec-parsefloat-string
511
+ var numberParseFloat = FORCED ? function parseFloat(string) {
512
+ var trimmedString = trim(toString(string));
513
+ var result = $parseFloat$1(trimmedString);
514
+ return result === 0 && charAt(trimmedString, 0) == '-' ? -0 : result;
515
+ } : $parseFloat$1;
516
+
517
+ var $ = _export;
518
+ var $parseFloat = numberParseFloat;
519
+
520
+ // `parseFloat` method
521
+ // https://tc39.es/ecma262/#sec-parsefloat-string
522
+ $({ global: true, forced: parseFloat != $parseFloat }, {
523
+ parseFloat: $parseFloat
524
+ });
525
+
526
+ class Slider extends Slider$1 {
527
+ constructor() {
528
+ super(...arguments);
529
+ this.markers = false;
530
+ }
531
+ valueChanged(previous, next) {
532
+ if (this.$fastController.isConnected) {
533
+ const nextAsNumber = parseFloat(next);
534
+ const value = Math.min(Math.max(this['convertToConstrainedValue'](nextAsNumber), this.min), this.max).toString();
535
+ if (value !== next) {
536
+ this.value = value;
537
+ return;
538
+ }
539
+ super.valueChanged(previous, next);
540
+ this['setThumbPositionForOrientation'](this.direction);
541
+ this.$emit('change');
542
+ }
543
+ }
544
+ }
545
+ __decorate([attr({
546
+ mode: 'boolean'
547
+ }), __metadata("design:type", Object)], Slider.prototype, "markers", void 0);
548
+
549
+ let _ = t => t,
550
+ _t,
551
+ _t2;
552
+ const getClasses = ({
553
+ disabled
554
+ }) => classNames('control', ['disabled', Boolean(disabled)]);
555
+ const getMarkersTemplate = (isHorizontal, numMarkers) => {
556
+ const placeholder = isHorizontal ? ['right', 'center', '', '100% repeat-x'] : ['bottom', 'top', '100%', 'repeat-y'];
557
+ return html(_t || (_t = _`
558
+ <div class="mark" style="
559
+ background: linear-gradient(to ${0}, currentcolor 3px, transparent 0px)
560
+ 0px ${0} / ${0} calc((100% - 3px) / ${0}) ${0}
561
+ "></div>`), placeholder[0], placeholder[1], placeholder[2], numMarkers, placeholder[3]);
562
+ };
563
+ const SliderTemplate = context => {
564
+ const focusTemplate = focusTemplateFactory(context);
565
+ return html(_t2 || (_t2 = _`
566
+ <div
567
+ role="slider"
568
+ tabindex="${0}"
569
+ aria-valuetext="${0}"
570
+ aria-valuenow="${0}"
571
+ aria-valuemin="${0}"
572
+ aria-valuemax="${0}"
573
+ aria-disabled="${0}"
574
+ aria-orientation="${0}"
575
+ class="${0} ${0}"
576
+ >
577
+ <div class="positioning-region">
578
+ <div ${0} class="track">
579
+ <div class="track-start" style="${0}"></div>
580
+ ${0}
581
+ </div>
582
+ <div ${0} class="thumb-container" style="${0}">
583
+ ${0}
584
+ </div>
585
+ </div>
586
+ </div>`), x => x.disabled ? null : 0, x => x.valueTextFormatter(x.value), x => x.value, x => x.min, x => x.max, x => x.disabled ? true : void 0, x => x.orientation, getClasses, x => x.orientation, ref('track'), x => x.position, x => x.markers ? getMarkersTemplate(x.orientation === Orientation.horizontal, Math.floor((x.max - x.min) / x.step)) : void 0, ref('thumb'), x => x.position, () => focusTemplate);
587
+ };
588
+
589
+ const vividSlider = Slider.compose({
590
+ baseName: 'slider',
591
+ template: SliderTemplate,
592
+ styles: css_248z
593
+ });
594
+ designSystem.register(vividSlider());
595
+
596
+ export { vividSlider };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Mon, 07 Nov 2022 11:12:43 GMT
3
+ * Generated on Tue, 08 Nov 2022 19:42:32 GMT
4
4
  */
5
5
  .vvd-root {
6
6
  color-scheme: var(--vvd-color-scheme);
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Mon, 07 Nov 2022 11:12:43 GMT
3
+ * Generated on Tue, 08 Nov 2022 19:42:32 GMT
4
4
  */
5
5
  .vvd-root {
6
6
  color-scheme: var(--vvd-color-scheme);
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Mon, 07 Nov 2022 11:12:43 GMT
3
+ * Generated on Tue, 08 Nov 2022 19:42:32 GMT
4
4
  */
5
5
  .vvd-root {
6
6
  font-feature-settings: "kern"; /* turns on kerning */