@vonage/vivid 4.12.0 → 4.13.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 (124) hide show
  1. package/custom-elements.json +2339 -288
  2. package/lib/accordion/accordion.d.ts +21 -2
  3. package/lib/accordion-item/accordion-item.d.ts +6 -2
  4. package/lib/calendar/calendar.d.ts +1 -1
  5. package/lib/date-picker/date-picker.d.ts +1 -0
  6. package/lib/file-picker/file-picker.d.ts +6 -0
  7. package/lib/menu/menu.d.ts +16 -3
  8. package/lib/menu-item/menu-item.d.ts +10 -2
  9. package/lib/option/option.d.ts +27 -7
  10. package/lib/radio/radio.d.ts +12 -2
  11. package/lib/radio/radio.form-associated.d.ts +10 -0
  12. package/lib/radio-group/radio-group.d.ts +20 -2
  13. package/lib/switch/switch.d.ts +5 -2
  14. package/lib/switch/switch.form-associated.d.ts +10 -0
  15. package/lib/tab/tab.d.ts +3 -2
  16. package/lib/tab-panel/tab-panel.d.ts +2 -2
  17. package/lib/tabs/tabs.d.ts +33 -11
  18. package/lib/text-area/text-area.d.ts +25 -3
  19. package/lib/text-area/text-field.form-associated.d.ts +10 -0
  20. package/lib/text-field/text-field.d.ts +28 -3
  21. package/lib/text-field/text-field.form-associated.d.ts +10 -0
  22. package/package.json +1 -1
  23. package/shared/date-picker/date-picker-base.d.ts +1 -0
  24. package/shared/definition.cjs +29 -72
  25. package/shared/definition.js +30 -73
  26. package/shared/definition11.cjs +1 -1
  27. package/shared/definition11.js +1 -1
  28. package/shared/definition16.cjs +1 -2
  29. package/shared/definition16.js +1 -2
  30. package/shared/definition17.cjs +3 -3
  31. package/shared/definition17.js +3 -3
  32. package/shared/definition18.cjs +6 -1
  33. package/shared/definition18.js +6 -1
  34. package/shared/definition19.cjs +17 -8
  35. package/shared/definition19.js +17 -8
  36. package/shared/definition2.cjs +154 -187
  37. package/shared/definition2.js +157 -190
  38. package/shared/definition20.cjs +3 -2
  39. package/shared/definition20.js +3 -2
  40. package/shared/definition21.cjs +1 -1
  41. package/shared/definition21.js +1 -1
  42. package/shared/definition24.cjs +1 -1
  43. package/shared/definition24.js +1 -1
  44. package/shared/definition25.cjs +24 -3
  45. package/shared/definition25.js +24 -3
  46. package/shared/definition29.cjs +358 -559
  47. package/shared/definition29.js +359 -560
  48. package/shared/definition30.cjs +2 -0
  49. package/shared/definition30.js +2 -0
  50. package/shared/definition35.cjs +223 -3
  51. package/shared/definition35.js +223 -3
  52. package/shared/definition36.cjs +149 -14
  53. package/shared/definition36.js +150 -15
  54. package/shared/definition40.cjs +226 -399
  55. package/shared/definition40.js +229 -402
  56. package/shared/definition42.cjs +3 -2
  57. package/shared/definition42.js +3 -2
  58. package/shared/definition43.cjs +1 -0
  59. package/shared/definition43.js +1 -0
  60. package/shared/definition44.cjs +1 -1
  61. package/shared/definition44.js +1 -1
  62. package/shared/definition46.cjs +1 -1
  63. package/shared/definition46.js +1 -1
  64. package/shared/definition47.cjs +8 -16
  65. package/shared/definition47.js +4 -12
  66. package/shared/definition49.cjs +64 -89
  67. package/shared/definition49.js +66 -91
  68. package/shared/definition5.cjs +1 -1
  69. package/shared/definition5.js +1 -1
  70. package/shared/definition50.cjs +1 -11
  71. package/shared/definition50.js +1 -11
  72. package/shared/definition51.cjs +5 -15
  73. package/shared/definition51.js +6 -16
  74. package/shared/definition52.cjs +284 -20
  75. package/shared/definition52.js +288 -24
  76. package/shared/definition55.cjs +160 -180
  77. package/shared/definition55.js +160 -180
  78. package/shared/definition56.cjs +3 -307
  79. package/shared/definition56.js +5 -309
  80. package/shared/definition57.cjs +34 -11
  81. package/shared/definition57.js +30 -7
  82. package/shared/definition61.cjs +1 -1
  83. package/shared/definition61.js +1 -1
  84. package/shared/definition62.cjs +17 -8
  85. package/shared/definition62.js +17 -8
  86. package/shared/definition64.cjs +18 -7
  87. package/shared/definition64.js +19 -8
  88. package/shared/form-associated.cjs +1 -1
  89. package/shared/form-associated.js +1 -1
  90. package/shared/icon.cjs +1 -1
  91. package/shared/icon.js +1 -1
  92. package/shared/index.cjs +1 -0
  93. package/shared/index.js +1 -1
  94. package/shared/key-codes.cjs +1 -94
  95. package/shared/key-codes.js +2 -89
  96. package/shared/key-codes2.cjs +87 -1
  97. package/shared/key-codes2.js +83 -2
  98. package/shared/listbox.cjs +204 -10
  99. package/shared/listbox.js +200 -6
  100. package/shared/{direction.cjs → localization.cjs} +12 -3
  101. package/shared/{direction.js → localization.js} +12 -3
  102. package/shared/numbers.cjs +0 -12
  103. package/shared/numbers.js +1 -12
  104. package/shared/presentationDate.cjs +22 -8
  105. package/shared/presentationDate.js +16 -2
  106. package/shared/radio.cjs +92 -117
  107. package/shared/radio.js +93 -118
  108. package/shared/slider.template.cjs +2 -15
  109. package/shared/slider.template.js +2 -14
  110. package/shared/strings.cjs +26 -0
  111. package/shared/strings.js +25 -1
  112. package/shared/text-field2.cjs +538 -194
  113. package/shared/text-field2.js +539 -195
  114. package/styles/core/all.css +21 -1
  115. package/styles/core/theme.css +21 -1
  116. package/styles/core/typography.css +1 -1
  117. package/styles/tokens/theme-dark.css +4 -4
  118. package/styles/tokens/theme-light.css +4 -4
  119. package/styles/tokens/vivid-2-compat.css +1 -1
  120. package/vivid.api.json +44 -0
  121. package/shared/Reflector.cjs +0 -71
  122. package/shared/Reflector.js +0 -69
  123. package/shared/listbox-option.cjs +0 -204
  124. package/shared/listbox-option.js +0 -201
package/shared/radio.cjs CHANGED
@@ -1,128 +1,18 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./index.cjs');
4
3
  const formAssociated = require('./form-associated.cjs');
4
+ const index = require('./index.cjs');
5
5
  const keyCodes = require('./key-codes.cjs');
6
6
 
7
7
  class _Radio extends index.FoundationElement {
8
8
  }
9
- /**
10
- * A form-associated base class for the {@link @microsoft/fast-foundation#(Radio:class)} component.
11
- *
12
- * @internal
13
- */
14
9
  class FormAssociatedRadio extends formAssociated.CheckableFormAssociated(_Radio) {
15
- constructor() {
16
- super(...arguments);
17
- this.proxy = document.createElement("input");
18
- }
10
+ constructor() {
11
+ super(...arguments);
12
+ this.proxy = document.createElement("input");
13
+ }
19
14
  }
20
15
 
21
- /**
22
- * A Radio Custom HTML Element.
23
- * Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#radio | ARIA radio }.
24
- *
25
- * @slot checked-indicator - The checked indicator
26
- * @slot - The default slot for the label
27
- * @csspart control - The element representing the visual radio control
28
- * @csspart label - The label
29
- * @fires change - Emits a custom change event when the checked state changes
30
- *
31
- * @public
32
- */
33
- let Radio$1 = class Radio extends FormAssociatedRadio {
34
- constructor() {
35
- super();
36
- /**
37
- * The element's value to be included in form submission when checked.
38
- * Default to "on" to reach parity with input[type="radio"]
39
- *
40
- * @internal
41
- */
42
- this.initialValue = "on";
43
- /**
44
- * @internal
45
- */
46
- this.keypressHandler = (e) => {
47
- switch (e.key) {
48
- case keyCodes.keySpace:
49
- if (!this.checked && !this.readOnly) {
50
- this.checked = true;
51
- }
52
- return;
53
- }
54
- return true;
55
- };
56
- this.proxy.setAttribute("type", "radio");
57
- }
58
- readOnlyChanged() {
59
- if (this.proxy instanceof HTMLInputElement) {
60
- this.proxy.readOnly = this.readOnly;
61
- }
62
- }
63
- /**
64
- * @internal
65
- */
66
- defaultCheckedChanged() {
67
- var _a;
68
- if (this.$fastController.isConnected && !this.dirtyChecked) {
69
- // Setting this.checked will cause us to enter a dirty state,
70
- // but if we are clean when defaultChecked is changed, we want to stay
71
- // in a clean state, so reset this.dirtyChecked
72
- if (!this.isInsideRadioGroup()) {
73
- this.checked = (_a = this.defaultChecked) !== null && _a !== void 0 ? _a : false;
74
- this.dirtyChecked = false;
75
- }
76
- }
77
- }
78
- /**
79
- * @internal
80
- */
81
- connectedCallback() {
82
- var _a, _b;
83
- super.connectedCallback();
84
- this.validate();
85
- if (((_a = this.parentElement) === null || _a === void 0 ? void 0 : _a.getAttribute("role")) !== "radiogroup" &&
86
- this.getAttribute("tabindex") === null) {
87
- if (!this.disabled) {
88
- this.setAttribute("tabindex", "0");
89
- }
90
- }
91
- if (this.checkedAttribute) {
92
- if (!this.dirtyChecked) {
93
- // Setting this.checked will cause us to enter a dirty state,
94
- // but if we are clean when defaultChecked is changed, we want to stay
95
- // in a clean state, so reset this.dirtyChecked
96
- if (!this.isInsideRadioGroup()) {
97
- this.checked = (_b = this.defaultChecked) !== null && _b !== void 0 ? _b : false;
98
- this.dirtyChecked = false;
99
- }
100
- }
101
- }
102
- }
103
- isInsideRadioGroup() {
104
- const parent = this.closest("[role=radiogroup]");
105
- return parent !== null;
106
- }
107
- /**
108
- * @internal
109
- */
110
- clickHandler(e) {
111
- if (!this.disabled && !this.readOnly && !this.checked) {
112
- this.checked = true;
113
- }
114
- }
115
- };
116
- index.__decorate([
117
- index.attr({ attribute: "readonly", mode: "boolean" })
118
- ], Radio$1.prototype, "readOnly", void 0);
119
- index.__decorate([
120
- index.observable
121
- ], Radio$1.prototype, "name", void 0);
122
- index.__decorate([
123
- index.observable
124
- ], Radio$1.prototype, "defaultSlottedNodes", void 0);
125
-
126
16
  var __defProp = Object.defineProperty;
127
17
  var __decorateClass = (decorators, target, key, kind) => {
128
18
  var result = void 0 ;
@@ -132,10 +22,86 @@ var __decorateClass = (decorators, target, key, kind) => {
132
22
  if (result) __defProp(target, key, result);
133
23
  return result;
134
24
  };
135
- class Radio extends Radio$1 {
25
+ class Radio extends FormAssociatedRadio {
136
26
  constructor() {
137
- super(...arguments);
27
+ super();
138
28
  this.ariaLabel = null;
29
+ /**
30
+ * The element's value to be included in form submission when checked.
31
+ * Default to "on" to reach parity with input[type="radio"]
32
+ *
33
+ * @internal
34
+ */
35
+ this.initialValue = "on";
36
+ this.defaultSlottedNodes = [];
37
+ /**
38
+ * @internal
39
+ */
40
+ this.keypressHandler = (e) => {
41
+ switch (e.key) {
42
+ case keyCodes.keySpace:
43
+ if (!this.checked && !this.readOnly) {
44
+ this.checked = true;
45
+ }
46
+ return;
47
+ }
48
+ return true;
49
+ };
50
+ this.proxy.setAttribute("type", "radio");
51
+ }
52
+ // Map to proxy element
53
+ /**
54
+ * @internal
55
+ */
56
+ readOnlyChanged() {
57
+ if (this.proxy instanceof HTMLInputElement) {
58
+ this.proxy.readOnly = this.readOnly;
59
+ }
60
+ }
61
+ /**
62
+ * @internal
63
+ */
64
+ defaultCheckedChanged() {
65
+ if (this.$fastController.isConnected && !this.dirtyChecked) {
66
+ if (!this.isInsideRadioGroup()) {
67
+ this.checked = this.defaultChecked;
68
+ this.dirtyChecked = false;
69
+ }
70
+ }
71
+ }
72
+ /**
73
+ * @internal
74
+ */
75
+ connectedCallback() {
76
+ super.connectedCallback();
77
+ this.validate();
78
+ if (this.parentElement.getAttribute("role") !== "radiogroup" && this.getAttribute("tabindex") === null) {
79
+ if (!this.disabled) {
80
+ this.setAttribute("tabindex", "0");
81
+ }
82
+ }
83
+ if (this.checkedAttribute) {
84
+ if (!this.dirtyChecked) {
85
+ if (!this.isInsideRadioGroup()) {
86
+ this.checked = this.defaultChecked;
87
+ this.dirtyChecked = false;
88
+ }
89
+ }
90
+ }
91
+ }
92
+ isInsideRadioGroup() {
93
+ const parent = this.closest(
94
+ "[role=radiogroup]"
95
+ );
96
+ return parent !== null;
97
+ }
98
+ /**
99
+ * @internal
100
+ */
101
+ clickHandler(_) {
102
+ if (!this.disabled && !this.readOnly && !this.checked) {
103
+ this.checked = true;
104
+ }
139
105
  }
140
106
  }
141
107
  __decorateClass([
@@ -147,5 +113,14 @@ __decorateClass([
147
113
  __decorateClass([
148
114
  index.attr
149
115
  ], Radio.prototype, "connotation");
116
+ __decorateClass([
117
+ index.attr({ attribute: "readonly", mode: "boolean" })
118
+ ], Radio.prototype, "readOnly");
119
+ __decorateClass([
120
+ index.observable
121
+ ], Radio.prototype, "name");
122
+ __decorateClass([
123
+ index.observable
124
+ ], Radio.prototype, "defaultSlottedNodes");
150
125
 
151
126
  exports.Radio = Radio;
package/shared/radio.js CHANGED
@@ -1,126 +1,16 @@
1
- import { F as FoundationElement, _ as __decorate, a as attr, o as observable } from './index.js';
2
1
  import { C as CheckableFormAssociated } from './form-associated.js';
3
- import { a as keySpace } from './key-codes.js';
2
+ import { F as FoundationElement, a as attr, o as observable } from './index.js';
3
+ import { k as keySpace } from './key-codes.js';
4
4
 
5
5
  class _Radio extends FoundationElement {
6
6
  }
7
- /**
8
- * A form-associated base class for the {@link @microsoft/fast-foundation#(Radio:class)} component.
9
- *
10
- * @internal
11
- */
12
7
  class FormAssociatedRadio extends CheckableFormAssociated(_Radio) {
13
- constructor() {
14
- super(...arguments);
15
- this.proxy = document.createElement("input");
16
- }
8
+ constructor() {
9
+ super(...arguments);
10
+ this.proxy = document.createElement("input");
11
+ }
17
12
  }
18
13
 
19
- /**
20
- * A Radio Custom HTML Element.
21
- * Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#radio | ARIA radio }.
22
- *
23
- * @slot checked-indicator - The checked indicator
24
- * @slot - The default slot for the label
25
- * @csspart control - The element representing the visual radio control
26
- * @csspart label - The label
27
- * @fires change - Emits a custom change event when the checked state changes
28
- *
29
- * @public
30
- */
31
- let Radio$1 = class Radio extends FormAssociatedRadio {
32
- constructor() {
33
- super();
34
- /**
35
- * The element's value to be included in form submission when checked.
36
- * Default to "on" to reach parity with input[type="radio"]
37
- *
38
- * @internal
39
- */
40
- this.initialValue = "on";
41
- /**
42
- * @internal
43
- */
44
- this.keypressHandler = (e) => {
45
- switch (e.key) {
46
- case keySpace:
47
- if (!this.checked && !this.readOnly) {
48
- this.checked = true;
49
- }
50
- return;
51
- }
52
- return true;
53
- };
54
- this.proxy.setAttribute("type", "radio");
55
- }
56
- readOnlyChanged() {
57
- if (this.proxy instanceof HTMLInputElement) {
58
- this.proxy.readOnly = this.readOnly;
59
- }
60
- }
61
- /**
62
- * @internal
63
- */
64
- defaultCheckedChanged() {
65
- var _a;
66
- if (this.$fastController.isConnected && !this.dirtyChecked) {
67
- // Setting this.checked will cause us to enter a dirty state,
68
- // but if we are clean when defaultChecked is changed, we want to stay
69
- // in a clean state, so reset this.dirtyChecked
70
- if (!this.isInsideRadioGroup()) {
71
- this.checked = (_a = this.defaultChecked) !== null && _a !== void 0 ? _a : false;
72
- this.dirtyChecked = false;
73
- }
74
- }
75
- }
76
- /**
77
- * @internal
78
- */
79
- connectedCallback() {
80
- var _a, _b;
81
- super.connectedCallback();
82
- this.validate();
83
- if (((_a = this.parentElement) === null || _a === void 0 ? void 0 : _a.getAttribute("role")) !== "radiogroup" &&
84
- this.getAttribute("tabindex") === null) {
85
- if (!this.disabled) {
86
- this.setAttribute("tabindex", "0");
87
- }
88
- }
89
- if (this.checkedAttribute) {
90
- if (!this.dirtyChecked) {
91
- // Setting this.checked will cause us to enter a dirty state,
92
- // but if we are clean when defaultChecked is changed, we want to stay
93
- // in a clean state, so reset this.dirtyChecked
94
- if (!this.isInsideRadioGroup()) {
95
- this.checked = (_b = this.defaultChecked) !== null && _b !== void 0 ? _b : false;
96
- this.dirtyChecked = false;
97
- }
98
- }
99
- }
100
- }
101
- isInsideRadioGroup() {
102
- const parent = this.closest("[role=radiogroup]");
103
- return parent !== null;
104
- }
105
- /**
106
- * @internal
107
- */
108
- clickHandler(e) {
109
- if (!this.disabled && !this.readOnly && !this.checked) {
110
- this.checked = true;
111
- }
112
- }
113
- };
114
- __decorate([
115
- attr({ attribute: "readonly", mode: "boolean" })
116
- ], Radio$1.prototype, "readOnly", void 0);
117
- __decorate([
118
- observable
119
- ], Radio$1.prototype, "name", void 0);
120
- __decorate([
121
- observable
122
- ], Radio$1.prototype, "defaultSlottedNodes", void 0);
123
-
124
14
  var __defProp = Object.defineProperty;
125
15
  var __decorateClass = (decorators, target, key, kind) => {
126
16
  var result = void 0 ;
@@ -130,10 +20,86 @@ var __decorateClass = (decorators, target, key, kind) => {
130
20
  if (result) __defProp(target, key, result);
131
21
  return result;
132
22
  };
133
- class Radio extends Radio$1 {
23
+ class Radio extends FormAssociatedRadio {
134
24
  constructor() {
135
- super(...arguments);
25
+ super();
136
26
  this.ariaLabel = null;
27
+ /**
28
+ * The element's value to be included in form submission when checked.
29
+ * Default to "on" to reach parity with input[type="radio"]
30
+ *
31
+ * @internal
32
+ */
33
+ this.initialValue = "on";
34
+ this.defaultSlottedNodes = [];
35
+ /**
36
+ * @internal
37
+ */
38
+ this.keypressHandler = (e) => {
39
+ switch (e.key) {
40
+ case keySpace:
41
+ if (!this.checked && !this.readOnly) {
42
+ this.checked = true;
43
+ }
44
+ return;
45
+ }
46
+ return true;
47
+ };
48
+ this.proxy.setAttribute("type", "radio");
49
+ }
50
+ // Map to proxy element
51
+ /**
52
+ * @internal
53
+ */
54
+ readOnlyChanged() {
55
+ if (this.proxy instanceof HTMLInputElement) {
56
+ this.proxy.readOnly = this.readOnly;
57
+ }
58
+ }
59
+ /**
60
+ * @internal
61
+ */
62
+ defaultCheckedChanged() {
63
+ if (this.$fastController.isConnected && !this.dirtyChecked) {
64
+ if (!this.isInsideRadioGroup()) {
65
+ this.checked = this.defaultChecked;
66
+ this.dirtyChecked = false;
67
+ }
68
+ }
69
+ }
70
+ /**
71
+ * @internal
72
+ */
73
+ connectedCallback() {
74
+ super.connectedCallback();
75
+ this.validate();
76
+ if (this.parentElement.getAttribute("role") !== "radiogroup" && this.getAttribute("tabindex") === null) {
77
+ if (!this.disabled) {
78
+ this.setAttribute("tabindex", "0");
79
+ }
80
+ }
81
+ if (this.checkedAttribute) {
82
+ if (!this.dirtyChecked) {
83
+ if (!this.isInsideRadioGroup()) {
84
+ this.checked = this.defaultChecked;
85
+ this.dirtyChecked = false;
86
+ }
87
+ }
88
+ }
89
+ }
90
+ isInsideRadioGroup() {
91
+ const parent = this.closest(
92
+ "[role=radiogroup]"
93
+ );
94
+ return parent !== null;
95
+ }
96
+ /**
97
+ * @internal
98
+ */
99
+ clickHandler(_) {
100
+ if (!this.disabled && !this.readOnly && !this.checked) {
101
+ this.checked = true;
102
+ }
137
103
  }
138
104
  }
139
105
  __decorateClass([
@@ -145,5 +111,14 @@ __decorateClass([
145
111
  __decorateClass([
146
112
  attr
147
113
  ], Radio.prototype, "connotation");
114
+ __decorateClass([
115
+ attr({ attribute: "readonly", mode: "boolean" })
116
+ ], Radio.prototype, "readOnly");
117
+ __decorateClass([
118
+ observable
119
+ ], Radio.prototype, "name");
120
+ __decorateClass([
121
+ observable
122
+ ], Radio.prototype, "defaultSlottedNodes");
148
123
 
149
124
  export { Radio as R };
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const numbers = require('./numbers.cjs');
3
4
  const definition = require('./definition64.cjs');
4
5
  const index = require('./index.cjs');
5
6
  const ref = require('./ref.cjs');
@@ -7,19 +8,6 @@ const aria = require('./aria.cjs');
7
8
  const when = require('./when.cjs');
8
9
  const classNames = require('./class-names.cjs');
9
10
 
10
- /**
11
- * This method keeps a given value within the bounds of a min and max value. If the value
12
- * is larger than the max, the minimum value will be returned. If the value is smaller than the minimum,
13
- * the maximum will be returned. Otherwise, the value is returned un-changed.
14
- */
15
- /**
16
- * Ensures that a value is between a min and max value. If value is lower than min, min will be returned.
17
- * If value is greater than max, max will be returned.
18
- */
19
- function limit(min, max, value) {
20
- return Math.min(Math.max(value, min), max);
21
- }
22
-
23
11
  const getDecimalPlaces = (num) => {
24
12
  const match = num.toString().match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
25
13
  return Math.max(
@@ -37,7 +25,7 @@ const roundToStepValue = (value, step) => {
37
25
  };
38
26
 
39
27
  const lerp = (a, b, value) => a + (b - a) * value;
40
- const inverseLerp = (a, b, value) => limit(0, 1, (value - a) / (b - a));
28
+ const inverseLerp = (a, b, value) => numbers.limit(0, 1, (value - a) / (b - a));
41
29
 
42
30
  const getClasses = ({ disabled, connotation }) => classNames.classNames(
43
31
  "control",
@@ -112,5 +100,4 @@ exports.SliderTemplate = SliderTemplate;
112
100
  exports.getMarkersTemplate = getMarkersTemplate;
113
101
  exports.inverseLerp = inverseLerp;
114
102
  exports.lerp = lerp;
115
- exports.limit = limit;
116
103
  exports.roundToStepValue = roundToStepValue;
@@ -1,3 +1,4 @@
1
+ import { l as limit } from './numbers.js';
1
2
  import { P as Popup, a as PlacementStrategy } from './definition64.js';
2
3
  import { h as html } from './index.js';
3
4
  import { r as ref } from './ref.js';
@@ -5,19 +6,6 @@ import { O as Orientation } from './aria.js';
5
6
  import { w as when } from './when.js';
6
7
  import { c as classNames } from './class-names.js';
7
8
 
8
- /**
9
- * This method keeps a given value within the bounds of a min and max value. If the value
10
- * is larger than the max, the minimum value will be returned. If the value is smaller than the minimum,
11
- * the maximum will be returned. Otherwise, the value is returned un-changed.
12
- */
13
- /**
14
- * Ensures that a value is between a min and max value. If value is lower than min, min will be returned.
15
- * If value is greater than max, max will be returned.
16
- */
17
- function limit(min, max, value) {
18
- return Math.min(Math.max(value, min), max);
19
- }
20
-
21
9
  const getDecimalPlaces = (num) => {
22
10
  const match = num.toString().match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
23
11
  return Math.max(
@@ -106,4 +94,4 @@ const SliderTemplate = (context) => {
106
94
  >`;
107
95
  };
108
96
 
109
- export { SliderTemplate as S, limit as a, getMarkersTemplate as g, inverseLerp as i, lerp as l, roundToStepValue as r };
97
+ export { SliderTemplate as S, getMarkersTemplate as g, inverseLerp as i, lerp as l, roundToStepValue as r };
@@ -1,5 +1,29 @@
1
1
  'use strict';
2
2
 
3
+ /**
4
+ * This method keeps a given value within the bounds of a min and max value. If the value
5
+ * is larger than the max, the minimum value will be returned. If the value is smaller than the minimum,
6
+ * the maximum will be returned. Otherwise, the value is returned un-changed.
7
+ */
8
+ /**
9
+ * Ensures that a value is between a min and max value. If value is lower than min, min will be returned.
10
+ * If value is greater than max, max will be returned.
11
+ */
12
+ function limit(min, max, value) {
13
+ return Math.min(Math.max(value, min), max);
14
+ }
15
+ /**
16
+ * Determines if a number value is within a specified range.
17
+ *
18
+ * @param value - the value to check
19
+ * @param min - the range start
20
+ * @param max - the range end
21
+ */
22
+ function inRange(value, min, max = 0) {
23
+ [min, max] = [min, max].sort((a, b) => a - b);
24
+ return min <= value && value < max;
25
+ }
26
+
3
27
  let uniqueIdCounter = 0;
4
28
  /**
5
29
  * Generates a unique ID based on incrementing a counter.
@@ -8,4 +32,6 @@ function uniqueId(prefix = "") {
8
32
  return `${prefix}${uniqueIdCounter++}`;
9
33
  }
10
34
 
35
+ exports.inRange = inRange;
36
+ exports.limit = limit;
11
37
  exports.uniqueId = uniqueId;
package/shared/strings.js CHANGED
@@ -1,3 +1,27 @@
1
+ /**
2
+ * This method keeps a given value within the bounds of a min and max value. If the value
3
+ * is larger than the max, the minimum value will be returned. If the value is smaller than the minimum,
4
+ * the maximum will be returned. Otherwise, the value is returned un-changed.
5
+ */
6
+ /**
7
+ * Ensures that a value is between a min and max value. If value is lower than min, min will be returned.
8
+ * If value is greater than max, max will be returned.
9
+ */
10
+ function limit(min, max, value) {
11
+ return Math.min(Math.max(value, min), max);
12
+ }
13
+ /**
14
+ * Determines if a number value is within a specified range.
15
+ *
16
+ * @param value - the value to check
17
+ * @param min - the range start
18
+ * @param max - the range end
19
+ */
20
+ function inRange(value, min, max = 0) {
21
+ [min, max] = [min, max].sort((a, b) => a - b);
22
+ return min <= value && value < max;
23
+ }
24
+
1
25
  let uniqueIdCounter = 0;
2
26
  /**
3
27
  * Generates a unique ID based on incrementing a counter.
@@ -6,4 +30,4 @@ function uniqueId(prefix = "") {
6
30
  return `${prefix}${uniqueIdCounter++}`;
7
31
  }
8
32
 
9
- export { uniqueId as u };
33
+ export { inRange as i, limit as l, uniqueId as u };