@vonage/vivid 4.15.0 → 4.16.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.
@@ -22061,6 +22061,14 @@
22061
22061
  }
22062
22062
  ],
22063
22063
  "description": "Rounds a value to the nearest step value. Handles decimal rounding."
22064
+ },
22065
+ {
22066
+ "kind": "variable",
22067
+ "name": "defaultToOneConverter",
22068
+ "type": {
22069
+ "text": "object"
22070
+ },
22071
+ "default": "{\n\tfromView(value: string | number): number {\n\t\tconst num = Number(value);\n\t\treturn handleStepValue(num);\n\t},\n\ttoView(value: number): string {\n\t\treturn value.toString();\n\t},\n}"
22064
22072
  }
22065
22073
  ],
22066
22074
  "exports": [
@@ -22071,6 +22079,14 @@
22071
22079
  "name": "roundToStepValue",
22072
22080
  "module": "libs/components/src/lib/range-slider/utils/roundToStepValue.ts"
22073
22081
  }
22082
+ },
22083
+ {
22084
+ "kind": "js",
22085
+ "name": "defaultToOneConverter",
22086
+ "declaration": {
22087
+ "name": "defaultToOneConverter",
22088
+ "module": "libs/components/src/lib/range-slider/utils/roundToStepValue.ts"
22089
+ }
22074
22090
  }
22075
22091
  ]
22076
22092
  },
@@ -1 +1,5 @@
1
1
  export declare const roundToStepValue: (value: number, step: number) => number;
2
+ export declare const defaultToOneConverter: {
3
+ fromView(value: string | number): number;
4
+ toView(value: number): string;
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vonage/vivid",
3
- "version": "4.15.0",
3
+ "version": "4.16.0",
4
4
  "type": "module",
5
5
  "module": "./index.js",
6
6
  "main": "./index.cjs",
@@ -483,7 +483,7 @@ __decorateClass([
483
483
  vividElement.attr({ converter: vividElement.nullableNumberConverter })
484
484
  ], RangeSlider.prototype, "max", 2);
485
485
  __decorateClass([
486
- vividElement.attr({ converter: vividElement.nullableNumberConverter })
486
+ vividElement.attr({ converter: slider_template.defaultToOneConverter })
487
487
  ], RangeSlider.prototype, "step", 2);
488
488
  __decorateClass([
489
489
  vividElement.attr
@@ -3,7 +3,7 @@ import { V as VividElement, o as observable, a as attr, n as nullableNumberConve
3
3
  import { g as keyHome, d as keyEnd, e as keyArrowUp, h as keyArrowLeft, f as keyArrowDown, i as keyArrowRight } from './key-codes.js';
4
4
  import { a as applyMixins } from './apply-mixins.js';
5
5
  import { F as FormAssociated } from './form-associated.js';
6
- import { i as inverseLerp, l as lerp, r as roundToStepValue, g as getMarkersTemplate } from './slider.template.js';
6
+ import { i as inverseLerp, l as lerp, r as roundToStepValue, d as defaultToOneConverter, g as getMarkersTemplate } from './slider.template.js';
7
7
  import { O as Orientation } from './aria.js';
8
8
  import { l as limit } from './numbers.js';
9
9
  import { f as formElements } from './form-elements.js';
@@ -481,7 +481,7 @@ __decorateClass([
481
481
  attr({ converter: nullableNumberConverter })
482
482
  ], RangeSlider.prototype, "max", 2);
483
483
  __decorateClass([
484
- attr({ converter: nullableNumberConverter })
484
+ attr({ converter: defaultToOneConverter })
485
485
  ], RangeSlider.prototype, "step", 2);
486
486
  __decorateClass([
487
487
  attr
@@ -150,12 +150,12 @@ let Select = class extends FormAssociatedSelect {
150
150
  this.rangeStartIndex = this.activeIndex;
151
151
  }
152
152
  this.options.forEach((o, i) => {
153
- o.checked = numbers.inRange(i, this.rangeStartIndex, this.options.length);
153
+ o.checked = numbers.inRange(i, this.rangeStartIndex, this.length);
154
154
  });
155
155
  } else {
156
156
  this.uncheckAllOptions();
157
157
  }
158
- this.activeIndex = this.options.length - 1;
158
+ this.activeIndex = this.length - 1;
159
159
  this.checkActiveIndex();
160
160
  }
161
161
  /**
@@ -179,7 +179,7 @@ let Select = class extends FormAssociatedSelect {
179
179
  } else {
180
180
  this.uncheckAllOptions();
181
181
  }
182
- this.activeIndex += this.activeIndex < this.options.length - 1 ? 1 : 0;
182
+ this.activeIndex += this.activeIndex < this.length - 1 ? 1 : 0;
183
183
  this.checkActiveIndex();
184
184
  }
185
185
  /**
@@ -346,7 +346,7 @@ let Select = class extends FormAssociatedSelect {
346
346
  }
347
347
  set value(next) {
348
348
  const prev = `${this._value}`;
349
- if (this._options.length) {
349
+ if (this.length) {
350
350
  const selectedIndex = this._options.findIndex((el) => el.value === next);
351
351
  const prevSelectedValue = this._options[this.selectedIndex]?.value ?? null;
352
352
  const nextSelectedValue = this._options[selectedIndex]?.value ?? null;
@@ -523,7 +523,7 @@ let Select = class extends FormAssociatedSelect {
523
523
  */
524
524
  setProxyOptions() {
525
525
  if (this.proxy instanceof HTMLSelectElement && this.options) {
526
- this.proxy.options.length = 0;
526
+ this.proxy.length = 0;
527
527
  this.options.forEach((option) => {
528
528
  const proxyOption = option.proxy || (option instanceof HTMLOptionElement ? option.cloneNode() : null);
529
529
  if (proxyOption) {
@@ -148,12 +148,12 @@ let Select = class extends FormAssociatedSelect {
148
148
  this.rangeStartIndex = this.activeIndex;
149
149
  }
150
150
  this.options.forEach((o, i) => {
151
- o.checked = inRange(i, this.rangeStartIndex, this.options.length);
151
+ o.checked = inRange(i, this.rangeStartIndex, this.length);
152
152
  });
153
153
  } else {
154
154
  this.uncheckAllOptions();
155
155
  }
156
- this.activeIndex = this.options.length - 1;
156
+ this.activeIndex = this.length - 1;
157
157
  this.checkActiveIndex();
158
158
  }
159
159
  /**
@@ -177,7 +177,7 @@ let Select = class extends FormAssociatedSelect {
177
177
  } else {
178
178
  this.uncheckAllOptions();
179
179
  }
180
- this.activeIndex += this.activeIndex < this.options.length - 1 ? 1 : 0;
180
+ this.activeIndex += this.activeIndex < this.length - 1 ? 1 : 0;
181
181
  this.checkActiveIndex();
182
182
  }
183
183
  /**
@@ -344,7 +344,7 @@ let Select = class extends FormAssociatedSelect {
344
344
  }
345
345
  set value(next) {
346
346
  const prev = `${this._value}`;
347
- if (this._options.length) {
347
+ if (this.length) {
348
348
  const selectedIndex = this._options.findIndex((el) => el.value === next);
349
349
  const prevSelectedValue = this._options[this.selectedIndex]?.value ?? null;
350
350
  const nextSelectedValue = this._options[selectedIndex]?.value ?? null;
@@ -521,7 +521,7 @@ let Select = class extends FormAssociatedSelect {
521
521
  */
522
522
  setProxyOptions() {
523
523
  if (this.proxy instanceof HTMLSelectElement && this.options) {
524
- this.proxy.options.length = 0;
524
+ this.proxy.length = 0;
525
525
  this.options.forEach((option) => {
526
526
  const proxyOption = option.proxy || (option instanceof HTMLOptionElement ? option.cloneNode() : null);
527
527
  if (proxyOption) {
@@ -449,7 +449,7 @@ __decorateClass([
449
449
  vividElement.attr({ converter: vividElement.nullableNumberConverter })
450
450
  ], Slider.prototype, "max", 2);
451
451
  __decorateClass([
452
- vividElement.attr({ converter: vividElement.nullableNumberConverter })
452
+ vividElement.attr({ converter: slider_template.defaultToOneConverter })
453
453
  ], Slider.prototype, "step", 2);
454
454
  __decorateClass([
455
455
  vividElement.attr
@@ -3,7 +3,7 @@ import { V as VividElement, a as attr, o as observable, v as volatile, n as null
3
3
  import { g as keyHome, d as keyEnd, f as keyArrowDown, h as keyArrowLeft, e as keyArrowUp, i as keyArrowRight } from './key-codes.js';
4
4
  import { D as Direction, g as getDirection } from './direction.js';
5
5
  import { a as applyMixins } from './apply-mixins.js';
6
- import { i as inverseLerp, l as lerp, r as roundToStepValue, S as SliderTemplate } from './slider.template.js';
6
+ import { i as inverseLerp, l as lerp, r as roundToStepValue, d as defaultToOneConverter, S as SliderTemplate } from './slider.template.js';
7
7
  import { F as FormAssociated } from './form-associated.js';
8
8
  import { O as Orientation } from './aria.js';
9
9
  import { l as limit } from './numbers.js';
@@ -447,7 +447,7 @@ __decorateClass([
447
447
  attr({ converter: nullableNumberConverter })
448
448
  ], Slider.prototype, "max", 2);
449
449
  __decorateClass([
450
- attr({ converter: nullableNumberConverter })
450
+ attr({ converter: defaultToOneConverter })
451
451
  ], Slider.prototype, "step", 2);
452
452
  __decorateClass([
453
453
  attr
@@ -23,6 +23,16 @@ const roundToStepValue = (value, step) => {
23
23
  const roundedValue = Math.round(value / step) * step;
24
24
  return Math.round(roundedValue * factor) / factor;
25
25
  };
26
+ const handleStepValue = (step) => step > 0 ? step : 1;
27
+ const defaultToOneConverter = {
28
+ fromView(value) {
29
+ const num = Number(value);
30
+ return handleStepValue(num);
31
+ },
32
+ toView(value) {
33
+ return value.toString();
34
+ }
35
+ };
26
36
 
27
37
  const lerp = (a, b, value) => a + (b - a) * value;
28
38
  const inverseLerp = (a, b, value) => numbers.limit(0, 1, (value - a) / (b - a));
@@ -97,6 +107,7 @@ const SliderTemplate = (context) => {
97
107
  };
98
108
 
99
109
  exports.SliderTemplate = SliderTemplate;
110
+ exports.defaultToOneConverter = defaultToOneConverter;
100
111
  exports.getMarkersTemplate = getMarkersTemplate;
101
112
  exports.inverseLerp = inverseLerp;
102
113
  exports.lerp = lerp;
@@ -21,6 +21,16 @@ const roundToStepValue = (value, step) => {
21
21
  const roundedValue = Math.round(value / step) * step;
22
22
  return Math.round(roundedValue * factor) / factor;
23
23
  };
24
+ const handleStepValue = (step) => step > 0 ? step : 1;
25
+ const defaultToOneConverter = {
26
+ fromView(value) {
27
+ const num = Number(value);
28
+ return handleStepValue(num);
29
+ },
30
+ toView(value) {
31
+ return value.toString();
32
+ }
33
+ };
24
34
 
25
35
  const lerp = (a, b, value) => a + (b - a) * value;
26
36
  const inverseLerp = (a, b, value) => limit(0, 1, (value - a) / (b - a));
@@ -94,4 +104,4 @@ const SliderTemplate = (context) => {
94
104
  >`;
95
105
  };
96
106
 
97
- export { SliderTemplate as S, getMarkersTemplate as g, inverseLerp as i, lerp as l, roundToStepValue as r };
107
+ export { SliderTemplate as S, defaultToOneConverter as d, getMarkersTemplate as g, inverseLerp as i, lerp as l, roundToStepValue as r };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Thu, 13 Feb 2025 13:39:16 GMT
3
+ * Generated on Fri, 14 Feb 2025 16:50:35 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 Thu, 13 Feb 2025 13:39:16 GMT
3
+ * Generated on Fri, 14 Feb 2025 16:50:35 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 Thu, 13 Feb 2025 13:39:16 GMT
3
+ * Generated on Fri, 14 Feb 2025 16:50:35 GMT
4
4
  */
5
5
  .vvd-root:root {
6
6
  --vvd-size-font-scale-base: 1rem;
@@ -1,18 +1,18 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Thu, 13 Feb 2025 13:39:17 GMT
3
+ * Generated on Fri, 14 Feb 2025 16:50:36 GMT
4
4
  */
5
5
  /**
6
6
  * Do not edit directly
7
- * Generated on Thu, 13 Feb 2025 13:39:16 GMT
7
+ * Generated on Fri, 14 Feb 2025 16:50:35 GMT
8
8
  */
9
9
  /**
10
10
  * Do not edit directly
11
- * Generated on Thu, 13 Feb 2025 13:39:17 GMT
11
+ * Generated on Fri, 14 Feb 2025 16:50:36 GMT
12
12
  */
13
13
  /**
14
14
  * Do not edit directly
15
- * Generated on Thu, 13 Feb 2025 13:39:17 GMT
15
+ * Generated on Fri, 14 Feb 2025 16:50:36 GMT
16
16
  */
17
17
  @property --vvd-size-density {
18
18
  syntax: "<integer>";
@@ -1,18 +1,18 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Thu, 13 Feb 2025 13:39:16 GMT
3
+ * Generated on Fri, 14 Feb 2025 16:50:35 GMT
4
4
  */
5
5
  /**
6
6
  * Do not edit directly
7
- * Generated on Thu, 13 Feb 2025 13:39:17 GMT
7
+ * Generated on Fri, 14 Feb 2025 16:50:36 GMT
8
8
  */
9
9
  /**
10
10
  * Do not edit directly
11
- * Generated on Thu, 13 Feb 2025 13:39:17 GMT
11
+ * Generated on Fri, 14 Feb 2025 16:50:36 GMT
12
12
  */
13
13
  /**
14
14
  * Do not edit directly
15
- * Generated on Thu, 13 Feb 2025 13:39:17 GMT
15
+ * Generated on Fri, 14 Feb 2025 16:50:36 GMT
16
16
  */
17
17
  @property --vvd-size-density {
18
18
  syntax: "<integer>";
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Do not edit directly
3
- * Generated on Thu, 13 Feb 2025 13:39:16 GMT
3
+ * Generated on Fri, 14 Feb 2025 16:50:35 GMT
4
4
  */
5
5
  .vvd-root, ::part(vvd-root),
6
6
  .vvd-theme-alternate, ::part(vvd-theme-alternate) {