@vonage/vivid 4.14.0 → 4.14.2

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 (218) hide show
  1. package/custom-elements.json +152 -197
  2. package/lib/divider/divider.d.ts +1 -1
  3. package/lib/divider/divider.template.d.ts +1 -1
  4. package/lib/elevation/elevation.d.ts +1 -0
  5. package/lib/radio/radio.form-associated.d.ts +2 -0
  6. package/lib/tabs/tabs.d.ts +0 -5
  7. package/lib/text-anchor/text-anchor.d.ts +2 -2
  8. package/lib/tree-item/tree-item.d.ts +2 -2
  9. package/lib/tree-view/tree-view.d.ts +2 -2
  10. package/package.json +1 -1
  11. package/shared/affix.cjs +8 -8
  12. package/shared/affix.js +2 -2
  13. package/shared/anchor.cjs +10 -10
  14. package/shared/anchor.js +1 -1
  15. package/shared/anchored.cjs +6 -6
  16. package/shared/anchored.js +1 -1
  17. package/shared/apply-mixins.cjs +3 -3
  18. package/shared/apply-mixins.js +1 -1
  19. package/shared/apply-mixins2.cjs +3 -3
  20. package/shared/apply-mixins2.js +1 -1
  21. package/shared/applyMixinsWithObservables.cjs +3 -3
  22. package/shared/applyMixinsWithObservables.js +1 -1
  23. package/shared/aria-global.cjs +20 -20
  24. package/shared/aria-global.js +1 -1
  25. package/shared/base-progress.cjs +7 -8
  26. package/shared/base-progress.js +2 -3
  27. package/shared/breadcrumb-item.cjs +2 -3
  28. package/shared/breadcrumb-item.js +1 -2
  29. package/shared/button.cjs +10 -11
  30. package/shared/button.js +1 -2
  31. package/shared/calendar-event.cjs +7 -8
  32. package/shared/calendar-event.js +1 -2
  33. package/shared/children.cjs +2 -2
  34. package/shared/children.js +1 -1
  35. package/shared/definition.cjs +14 -15
  36. package/shared/definition.js +2 -3
  37. package/shared/definition10.cjs +5 -6
  38. package/shared/definition10.js +1 -2
  39. package/shared/definition11.cjs +29 -29
  40. package/shared/definition11.js +2 -2
  41. package/shared/definition12.cjs +6 -6
  42. package/shared/definition12.js +1 -1
  43. package/shared/definition13.cjs +13 -14
  44. package/shared/definition13.js +1 -2
  45. package/shared/definition14.cjs +23 -24
  46. package/shared/definition14.js +1 -2
  47. package/shared/definition15.cjs +15 -16
  48. package/shared/definition15.js +1 -2
  49. package/shared/definition16.cjs +21 -21
  50. package/shared/definition16.js +5 -5
  51. package/shared/definition17.cjs +62 -61
  52. package/shared/definition17.js +10 -9
  53. package/shared/definition18.cjs +4 -4
  54. package/shared/definition18.js +1 -1
  55. package/shared/definition19.cjs +12 -12
  56. package/shared/definition19.js +1 -1
  57. package/shared/definition2.cjs +6 -7
  58. package/shared/definition2.js +1 -2
  59. package/shared/definition20.cjs +20 -21
  60. package/shared/definition20.js +1 -2
  61. package/shared/definition21.cjs +27 -28
  62. package/shared/definition21.js +3 -4
  63. package/shared/definition22.cjs +7 -7
  64. package/shared/definition22.js +3 -3
  65. package/shared/definition23.cjs +10 -11
  66. package/shared/definition23.js +1 -2
  67. package/shared/definition24.cjs +8 -8
  68. package/shared/definition24.js +3 -3
  69. package/shared/definition25.cjs +13 -14
  70. package/shared/definition25.js +1 -2
  71. package/shared/definition26.cjs +5 -6
  72. package/shared/definition26.js +1 -2
  73. package/shared/definition27.cjs +12 -13
  74. package/shared/definition27.js +2 -3
  75. package/shared/definition28.cjs +9 -10
  76. package/shared/definition28.js +2 -3
  77. package/shared/definition29.cjs +44 -45
  78. package/shared/definition29.js +3 -4
  79. package/shared/definition3.cjs +8 -9
  80. package/shared/definition3.js +1 -2
  81. package/shared/definition30.cjs +9 -10
  82. package/shared/definition30.js +2 -3
  83. package/shared/definition31.cjs +5 -5
  84. package/shared/definition31.js +2 -2
  85. package/shared/definition32.cjs +3 -4
  86. package/shared/definition32.js +1 -2
  87. package/shared/definition33.cjs +6 -7
  88. package/shared/definition33.js +2 -3
  89. package/shared/definition34.cjs +112 -45
  90. package/shared/definition34.js +73 -6
  91. package/shared/definition35.cjs +9 -209
  92. package/shared/definition35.js +4 -202
  93. package/shared/definition36.cjs +15 -16
  94. package/shared/definition36.js +1 -2
  95. package/shared/definition37.cjs +9 -9
  96. package/shared/definition37.js +1 -1
  97. package/shared/definition38.cjs +10 -10
  98. package/shared/definition38.js +1 -1
  99. package/shared/definition39.cjs +12 -13
  100. package/shared/definition39.js +1 -2
  101. package/shared/definition4.cjs +19 -20
  102. package/shared/definition4.js +2 -3
  103. package/shared/definition40.cjs +61 -13
  104. package/shared/definition40.js +52 -4
  105. package/shared/definition41.cjs +29 -30
  106. package/shared/definition41.js +1 -2
  107. package/shared/definition42.cjs +52 -53
  108. package/shared/definition42.js +3 -4
  109. package/shared/definition43.cjs +40 -40
  110. package/shared/definition43.js +6 -6
  111. package/shared/definition44.cjs +14 -15
  112. package/shared/definition44.js +1 -2
  113. package/shared/definition45.cjs +9 -10
  114. package/shared/definition45.js +1 -2
  115. package/shared/definition46.cjs +26 -27
  116. package/shared/definition46.js +1 -2
  117. package/shared/definition47.cjs +17 -18
  118. package/shared/definition47.js +2 -3
  119. package/shared/definition48.cjs +9 -10
  120. package/shared/definition48.js +1 -2
  121. package/shared/definition49.cjs +3 -4
  122. package/shared/definition49.js +1 -2
  123. package/shared/definition5.cjs +30 -31
  124. package/shared/definition5.js +1 -2
  125. package/shared/definition50.cjs +12 -13
  126. package/shared/definition50.js +2 -3
  127. package/shared/definition51.cjs +109 -72
  128. package/shared/definition51.js +78 -41
  129. package/shared/definition52.cjs +4 -5
  130. package/shared/definition52.js +1 -2
  131. package/shared/definition53.cjs +15 -16
  132. package/shared/definition53.js +2 -3
  133. package/shared/definition54.cjs +20 -21
  134. package/shared/definition54.js +1 -2
  135. package/shared/definition55.cjs +5 -5
  136. package/shared/definition55.js +1 -1
  137. package/shared/definition56.cjs +18 -19
  138. package/shared/definition56.js +1 -2
  139. package/shared/definition57.cjs +10 -11
  140. package/shared/definition57.js +1 -2
  141. package/shared/definition58.cjs +7 -8
  142. package/shared/definition58.js +1 -2
  143. package/shared/definition59.cjs +16 -17
  144. package/shared/definition59.js +3 -4
  145. package/shared/definition6.cjs +11 -12
  146. package/shared/definition6.js +1 -2
  147. package/shared/definition60.cjs +9 -10
  148. package/shared/definition60.js +2 -3
  149. package/shared/definition61.cjs +27 -30
  150. package/shared/definition61.js +17 -20
  151. package/shared/definition62.cjs +12 -9
  152. package/shared/definition62.js +8 -5
  153. package/shared/definition63.cjs +13 -14
  154. package/shared/definition63.js +1 -2
  155. package/shared/definition7.cjs +9 -10
  156. package/shared/definition7.js +2 -3
  157. package/shared/definition8.cjs +14 -15
  158. package/shared/definition8.js +2 -3
  159. package/shared/definition9.cjs +7 -7
  160. package/shared/definition9.js +1 -1
  161. package/shared/form-associated.cjs +14 -14
  162. package/shared/form-associated.js +1 -1
  163. package/shared/form-associated2.cjs +10 -10
  164. package/shared/form-associated2.js +1 -1
  165. package/shared/form-elements.cjs +13 -13
  166. package/shared/form-elements.js +1 -1
  167. package/shared/foundation/progress/base-progress.d.ts +2 -2
  168. package/shared/foundation-element.cjs +11 -11
  169. package/shared/foundation-element.js +1 -1
  170. package/shared/key-codes2.cjs +0 -56
  171. package/shared/key-codes2.js +1 -53
  172. package/shared/listbox.cjs +15 -16
  173. package/shared/listbox.js +2 -3
  174. package/shared/localized.cjs +2 -2
  175. package/shared/localized.js +1 -1
  176. package/shared/option.cjs +205 -0
  177. package/shared/option.js +202 -0
  178. package/shared/presentationDate.cjs +42 -43
  179. package/shared/presentationDate.js +1 -2
  180. package/shared/ref.cjs +2 -2
  181. package/shared/ref.js +1 -1
  182. package/shared/repeat.cjs +15 -15
  183. package/shared/repeat.js +1 -1
  184. package/shared/slider.template.cjs +4 -4
  185. package/shared/slider.template.js +1 -1
  186. package/shared/slotted.cjs +4 -4
  187. package/shared/slotted.js +1 -1
  188. package/shared/start-end.cjs +52 -0
  189. package/shared/start-end.js +50 -0
  190. package/shared/text-anchor.cjs +5 -6
  191. package/shared/text-anchor.js +3 -4
  192. package/shared/text-anchor.template.cjs +2 -2
  193. package/shared/text-anchor.template.js +1 -1
  194. package/shared/text-field2.cjs +23 -24
  195. package/shared/text-field2.js +2 -3
  196. package/shared/vivid-element.cjs +2610 -2
  197. package/shared/vivid-element.js +2591 -2
  198. package/styles/core/all.css +40 -1
  199. package/styles/core/theme.css +40 -1
  200. package/styles/core/typography.css +1 -1
  201. package/styles/tokens/theme-dark.css +25 -4
  202. package/styles/tokens/theme-light.css +25 -4
  203. package/styles/tokens/vivid-2-compat.css +1 -1
  204. package/text-anchor/index.cjs +3 -3
  205. package/text-anchor/index.js +1 -1
  206. package/lib/listbox/definition.d.ts +0 -2
  207. package/lib/listbox/listbox.d.ts +0 -14
  208. package/lib/listbox/listbox.template.d.ts +0 -2
  209. package/listbox/index.cjs +0 -54
  210. package/listbox/index.js +0 -52
  211. package/shared/aria-global2.cjs +0 -75
  212. package/shared/aria-global2.js +0 -73
  213. package/shared/defineVividComponent.cjs +0 -2612
  214. package/shared/defineVividComponent.js +0 -2592
  215. package/shared/listbox2.cjs +0 -1268
  216. package/shared/listbox2.js +0 -1265
  217. package/shared/strings2.cjs +0 -37
  218. package/shared/strings2.js +0 -33
@@ -1,10 +1,9 @@
1
1
  'use strict';
2
2
 
3
- const definition = require('./definition35.cjs');
3
+ const option = require('./option.cjs');
4
4
  const vividElement = require('./vivid-element.cjs');
5
5
  const keyCodes = require('./key-codes.cjs');
6
6
  const strings = require('./strings.cjs');
7
- const defineVividComponent = require('./defineVividComponent.cjs');
8
7
  const applyMixins = require('./apply-mixins2.cjs');
9
8
  const ariaGlobal = require('./aria-global.cjs');
10
9
 
@@ -95,12 +94,12 @@ const _Listbox = class _Listbox extends vividElement.VividElement {
95
94
  * @public
96
95
  */
97
96
  get options() {
98
- defineVividComponent.Observable.track(this, "options");
97
+ vividElement.Observable.track(this, "options");
99
98
  return this._options;
100
99
  }
101
100
  set options(value) {
102
101
  this._options = value;
103
- defineVividComponent.Observable.notify(this, "options");
102
+ vividElement.Observable.notify(this, "options");
104
103
  }
105
104
  static {
106
105
  /**
@@ -109,7 +108,7 @@ const _Listbox = class _Listbox extends vividElement.VividElement {
109
108
  * @param n - element to filter
110
109
  * @public
111
110
  */
112
- this.slottedOptionFilter = (n) => definition.isListboxOption(n) && !n.hidden;
111
+ this.slottedOptionFilter = (n) => option.isListboxOption(n) && !n.hidden;
113
112
  }
114
113
  static {
115
114
  /**
@@ -347,7 +346,7 @@ const _Listbox = class _Listbox extends vividElement.VividElement {
347
346
  selectedOptionsChanged(_, next) {
348
347
  const filteredNext = next.filter(_Listbox.slottedOptionFilter);
349
348
  this.options.forEach((o) => {
350
- const notifier = defineVividComponent.Observable.getNotifier(o);
349
+ const notifier = vividElement.Observable.getNotifier(o);
351
350
  notifier.unsubscribe(this, "selected");
352
351
  o.selected = filteredNext.includes(o);
353
352
  notifier.subscribe(this, "selected");
@@ -420,7 +419,7 @@ const _Listbox = class _Listbox extends vividElement.VividElement {
420
419
  */
421
420
  slottedOptionsChanged(_, next) {
422
421
  this.options = next.reduce((options, item) => {
423
- if (definition.isListboxOption(item)) {
422
+ if (option.isListboxOption(item)) {
424
423
  options.push(item);
425
424
  }
426
425
  return options;
@@ -458,38 +457,38 @@ const _Listbox = class _Listbox extends vividElement.VividElement {
458
457
  };
459
458
  // @ts-expect-error Type is incorrectly non-optional
460
459
  __decorateClass([
461
- defineVividComponent.attr({ mode: "boolean" })
460
+ vividElement.attr({ mode: "boolean" })
462
461
  ], _Listbox.prototype, "disabled");
463
462
  __decorateClass([
464
- defineVividComponent.observable
463
+ vividElement.observable
465
464
  ], _Listbox.prototype, "selectedIndex");
466
465
  __decorateClass([
467
- defineVividComponent.observable
466
+ vividElement.observable
468
467
  ], _Listbox.prototype, "selectedOptions");
469
468
  __decorateClass([
470
- defineVividComponent.observable
469
+ vividElement.observable
471
470
  ], _Listbox.prototype, "slottedOptions");
472
471
  __decorateClass([
473
- defineVividComponent.observable
472
+ vividElement.observable
474
473
  ], _Listbox.prototype, "typeaheadBuffer");
475
474
  let Listbox = _Listbox;
476
475
  class DelegatesARIAListbox {
477
476
  }
478
477
  // @ts-expect-error Type is incorrectly non-optional
479
478
  __decorateClass([
480
- defineVividComponent.observable
479
+ vividElement.observable
481
480
  ], DelegatesARIAListbox.prototype, "ariaActiveDescendant");
482
481
  // @ts-expect-error Type is incorrectly non-optional
483
482
  __decorateClass([
484
- defineVividComponent.observable
483
+ vividElement.observable
485
484
  ], DelegatesARIAListbox.prototype, "ariaDisabled");
486
485
  // @ts-expect-error Type is incorrectly non-optional
487
486
  __decorateClass([
488
- defineVividComponent.observable
487
+ vividElement.observable
489
488
  ], DelegatesARIAListbox.prototype, "ariaExpanded");
490
489
  // @ts-expect-error Type is incorrectly non-optional
491
490
  __decorateClass([
492
- defineVividComponent.observable
491
+ vividElement.observable
493
492
  ], DelegatesARIAListbox.prototype, "ariaMultiSelectable");
494
493
  applyMixins.applyMixins(DelegatesARIAListbox, ariaGlobal.ARIAGlobalStatesAndProperties);
495
494
  applyMixins.applyMixins(Listbox, DelegatesARIAListbox);
package/shared/listbox.js CHANGED
@@ -1,8 +1,7 @@
1
- import { i as isListboxOption } from './definition35.js';
2
- import { V as VividElement } from './vivid-element.js';
1
+ import { i as isListboxOption } from './option.js';
2
+ import { V as VividElement, O as Observable, a as attr, o as observable } from './vivid-element.js';
3
3
  import { a as keySpace, b as keyEscape, k as keyEnter, c as keyTab, d as keyEnd, e as keyArrowUp, f as keyArrowDown, g as keyHome } from './key-codes.js';
4
4
  import { u as uniqueId } from './strings.js';
5
- import { O as Observable, a as attr, o as observable } from './defineVividComponent.js';
6
5
  import { a as applyMixins } from './apply-mixins2.js';
7
6
  import { A as ARIAGlobalStatesAndProperties } from './aria-global.js';
8
7
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const locales_enUS = require('../locales/en-US.cjs');
4
- const defineVividComponent = require('./defineVividComponent.cjs');
4
+ const vividElement = require('./vivid-element.cjs');
5
5
 
6
6
  var __defProp = Object.defineProperty;
7
7
  var __decorateClass = (decorators, target, key, kind) => {
@@ -18,7 +18,7 @@ class CurrentLocale {
18
18
  }
19
19
  }
20
20
  __decorateClass([
21
- defineVividComponent.observable
21
+ vividElement.observable
22
22
  ], CurrentLocale.prototype, "locale");
23
23
  const currentLocale = new CurrentLocale();
24
24
  const setLocale = (locale) => {
@@ -1,5 +1,5 @@
1
1
  import enUS from '../locales/en-US.js';
2
- import { o as observable } from './defineVividComponent.js';
2
+ import { o as observable } from './vivid-element.js';
3
3
 
4
4
  var __defProp = Object.defineProperty;
5
5
  var __decorateClass = (decorators, target, key, kind) => {
@@ -0,0 +1,205 @@
1
+ 'use strict';
2
+
3
+ const applyMixins = require('./apply-mixins.cjs');
4
+ const affix = require('./affix.cjs');
5
+ const ariaGlobal = require('./aria-global.cjs');
6
+ const vividElement = require('./vivid-element.cjs');
7
+ const dom = require('./dom.cjs');
8
+
9
+ var __defProp = Object.defineProperty;
10
+ var __decorateClass = (decorators, target, key, kind) => {
11
+ var result = void 0 ;
12
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
13
+ if (decorator = decorators[i])
14
+ result = (decorator(target, key, result) ) || result;
15
+ if (result) __defProp(target, key, result);
16
+ return result;
17
+ };
18
+ function isListboxOption(el) {
19
+ return dom.isHTMLElement(el) && (el.getAttribute("role") === "option" || el instanceof HTMLOptionElement);
20
+ }
21
+ class ListboxOption extends vividElement.VividElement {
22
+ constructor(text, value, defaultSelected, selected) {
23
+ super();
24
+ this.defaultSelected = false;
25
+ /**
26
+ * Tracks whether the "selected" property has been changed.
27
+ * @internal
28
+ */
29
+ this.dirtySelected = false;
30
+ this.selected = this.defaultSelected;
31
+ /**
32
+ * Track whether the value has been changed from the initial value
33
+ */
34
+ this.dirtyValue = false;
35
+ this._highlighted = false;
36
+ this._displayCheckmark = false;
37
+ this._matchedRange = null;
38
+ if (text) {
39
+ this.text = text;
40
+ }
41
+ if (value) {
42
+ this.initialValue = value;
43
+ }
44
+ if (defaultSelected) {
45
+ this.defaultSelected = defaultSelected;
46
+ }
47
+ if (selected) {
48
+ this.selected = selected;
49
+ }
50
+ this.proxy = new Option(
51
+ this.text,
52
+ // @ts-expect-error Propery is used before it is assigned
53
+ this.initialValue,
54
+ this.defaultSelected,
55
+ this.selected
56
+ );
57
+ this.proxy.disabled = this.disabled;
58
+ }
59
+ /**
60
+ * Updates the ariaChecked property when the checked property changes.
61
+ *
62
+ * @param _ - the previous checked value
63
+ * @param next - the current checked value
64
+ *
65
+ * @public
66
+ */
67
+ checkedChanged(_, next) {
68
+ if (typeof next === "boolean") {
69
+ this.ariaChecked = next ? "true" : "false";
70
+ return;
71
+ }
72
+ this.ariaChecked = null;
73
+ }
74
+ defaultSelectedChanged() {
75
+ if (!this.dirtySelected) {
76
+ this.selected = this.defaultSelected;
77
+ if (this.proxy instanceof HTMLOptionElement) {
78
+ this.proxy.selected = this.defaultSelected;
79
+ }
80
+ }
81
+ }
82
+ disabledChanged() {
83
+ this.ariaDisabled = this.disabled ? "true" : "false";
84
+ if (this.proxy instanceof HTMLOptionElement) {
85
+ this.proxy.disabled = this.disabled;
86
+ }
87
+ }
88
+ selectedAttributeChanged() {
89
+ this.defaultSelected = this.selectedAttribute;
90
+ if (this.proxy instanceof HTMLOptionElement) {
91
+ this.proxy.defaultSelected = this.defaultSelected;
92
+ }
93
+ }
94
+ selectedChanged() {
95
+ this.ariaSelected = this.selected ? "true" : "false";
96
+ if (!this.dirtySelected) {
97
+ this.dirtySelected = true;
98
+ }
99
+ if (this.proxy instanceof HTMLOptionElement) {
100
+ this.proxy.selected = this.selected;
101
+ }
102
+ }
103
+ initialValueChanged() {
104
+ if (!this.dirtyValue) {
105
+ this.value = this.initialValue;
106
+ this.dirtyValue = false;
107
+ }
108
+ }
109
+ get label() {
110
+ return this._label ?? this.text;
111
+ }
112
+ set label(value) {
113
+ this._label = value;
114
+ }
115
+ set text(value) {
116
+ this._text = value;
117
+ }
118
+ get text() {
119
+ return this._text ?? "";
120
+ }
121
+ set value(next) {
122
+ const newValue = `${next ?? ""}`;
123
+ this._value = newValue;
124
+ this.dirtyValue = true;
125
+ if (this.proxy instanceof HTMLOptionElement) {
126
+ this.proxy.value = newValue;
127
+ }
128
+ vividElement.Observable.notify(this, "value");
129
+ }
130
+ get value() {
131
+ vividElement.Observable.track(this, "value");
132
+ return this._value ?? this.text;
133
+ }
134
+ get form() {
135
+ return null;
136
+ }
137
+ /**
138
+ * @internal
139
+ */
140
+ get _matchedRangeSafe() {
141
+ return this._matchedRange ?? { from: 0, to: 0 };
142
+ }
143
+ }
144
+ __decorateClass([
145
+ vividElement.observable
146
+ ], ListboxOption.prototype, "checked");
147
+ __decorateClass([
148
+ vividElement.observable
149
+ ], ListboxOption.prototype, "defaultSelected");
150
+ // @ts-expect-error Type is incorrectly non-optional
151
+ __decorateClass([
152
+ vividElement.attr({ mode: "boolean" })
153
+ ], ListboxOption.prototype, "disabled");
154
+ // @ts-expect-error Type is incorrectly non-optional
155
+ __decorateClass([
156
+ vividElement.attr({ attribute: "selected", mode: "boolean" })
157
+ ], ListboxOption.prototype, "selectedAttribute");
158
+ __decorateClass([
159
+ vividElement.observable
160
+ ], ListboxOption.prototype, "selected");
161
+ __decorateClass([
162
+ vividElement.attr({ attribute: "value", mode: "fromView" })
163
+ ], ListboxOption.prototype, "initialValue");
164
+ __decorateClass([
165
+ vividElement.attr({
166
+ attribute: "label"
167
+ })
168
+ ], ListboxOption.prototype, "_label");
169
+ __decorateClass([
170
+ vividElement.attr({
171
+ attribute: "text"
172
+ })
173
+ ], ListboxOption.prototype, "_text");
174
+ __decorateClass([
175
+ vividElement.observable
176
+ ], ListboxOption.prototype, "_highlighted");
177
+ __decorateClass([
178
+ vividElement.observable
179
+ ], ListboxOption.prototype, "_displayCheckmark");
180
+ __decorateClass([
181
+ vividElement.observable
182
+ ], ListboxOption.prototype, "_matchedRange");
183
+ class DelegatesARIAListboxOption {
184
+ }
185
+ // @ts-expect-error Type is incorrectly non-optional
186
+ __decorateClass([
187
+ vividElement.observable
188
+ ], DelegatesARIAListboxOption.prototype, "ariaChecked");
189
+ // @ts-expect-error Type is incorrectly non-optional
190
+ __decorateClass([
191
+ vividElement.observable
192
+ ], DelegatesARIAListboxOption.prototype, "ariaPosInSet");
193
+ // @ts-expect-error Type is incorrectly non-optional
194
+ __decorateClass([
195
+ vividElement.observable
196
+ ], DelegatesARIAListboxOption.prototype, "ariaSelected");
197
+ // @ts-expect-error Type is incorrectly non-optional
198
+ __decorateClass([
199
+ vividElement.observable
200
+ ], DelegatesARIAListboxOption.prototype, "ariaSetSize");
201
+ applyMixins.applyMixins(DelegatesARIAListboxOption, ariaGlobal.ARIAGlobalStatesAndProperties);
202
+ applyMixins.applyMixins(ListboxOption, affix.AffixIconWithTrailing, DelegatesARIAListboxOption);
203
+
204
+ exports.ListboxOption = ListboxOption;
205
+ exports.isListboxOption = isListboxOption;
@@ -0,0 +1,202 @@
1
+ import { a as applyMixins } from './apply-mixins.js';
2
+ import { A as AffixIconWithTrailing } from './affix.js';
3
+ import { A as ARIAGlobalStatesAndProperties } from './aria-global.js';
4
+ import { V as VividElement, O as Observable, o as observable, a as attr } from './vivid-element.js';
5
+ import { i as isHTMLElement } from './dom.js';
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __decorateClass = (decorators, target, key, kind) => {
9
+ var result = void 0 ;
10
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
11
+ if (decorator = decorators[i])
12
+ result = (decorator(target, key, result) ) || result;
13
+ if (result) __defProp(target, key, result);
14
+ return result;
15
+ };
16
+ function isListboxOption(el) {
17
+ return isHTMLElement(el) && (el.getAttribute("role") === "option" || el instanceof HTMLOptionElement);
18
+ }
19
+ class ListboxOption extends VividElement {
20
+ constructor(text, value, defaultSelected, selected) {
21
+ super();
22
+ this.defaultSelected = false;
23
+ /**
24
+ * Tracks whether the "selected" property has been changed.
25
+ * @internal
26
+ */
27
+ this.dirtySelected = false;
28
+ this.selected = this.defaultSelected;
29
+ /**
30
+ * Track whether the value has been changed from the initial value
31
+ */
32
+ this.dirtyValue = false;
33
+ this._highlighted = false;
34
+ this._displayCheckmark = false;
35
+ this._matchedRange = null;
36
+ if (text) {
37
+ this.text = text;
38
+ }
39
+ if (value) {
40
+ this.initialValue = value;
41
+ }
42
+ if (defaultSelected) {
43
+ this.defaultSelected = defaultSelected;
44
+ }
45
+ if (selected) {
46
+ this.selected = selected;
47
+ }
48
+ this.proxy = new Option(
49
+ this.text,
50
+ // @ts-expect-error Propery is used before it is assigned
51
+ this.initialValue,
52
+ this.defaultSelected,
53
+ this.selected
54
+ );
55
+ this.proxy.disabled = this.disabled;
56
+ }
57
+ /**
58
+ * Updates the ariaChecked property when the checked property changes.
59
+ *
60
+ * @param _ - the previous checked value
61
+ * @param next - the current checked value
62
+ *
63
+ * @public
64
+ */
65
+ checkedChanged(_, next) {
66
+ if (typeof next === "boolean") {
67
+ this.ariaChecked = next ? "true" : "false";
68
+ return;
69
+ }
70
+ this.ariaChecked = null;
71
+ }
72
+ defaultSelectedChanged() {
73
+ if (!this.dirtySelected) {
74
+ this.selected = this.defaultSelected;
75
+ if (this.proxy instanceof HTMLOptionElement) {
76
+ this.proxy.selected = this.defaultSelected;
77
+ }
78
+ }
79
+ }
80
+ disabledChanged() {
81
+ this.ariaDisabled = this.disabled ? "true" : "false";
82
+ if (this.proxy instanceof HTMLOptionElement) {
83
+ this.proxy.disabled = this.disabled;
84
+ }
85
+ }
86
+ selectedAttributeChanged() {
87
+ this.defaultSelected = this.selectedAttribute;
88
+ if (this.proxy instanceof HTMLOptionElement) {
89
+ this.proxy.defaultSelected = this.defaultSelected;
90
+ }
91
+ }
92
+ selectedChanged() {
93
+ this.ariaSelected = this.selected ? "true" : "false";
94
+ if (!this.dirtySelected) {
95
+ this.dirtySelected = true;
96
+ }
97
+ if (this.proxy instanceof HTMLOptionElement) {
98
+ this.proxy.selected = this.selected;
99
+ }
100
+ }
101
+ initialValueChanged() {
102
+ if (!this.dirtyValue) {
103
+ this.value = this.initialValue;
104
+ this.dirtyValue = false;
105
+ }
106
+ }
107
+ get label() {
108
+ return this._label ?? this.text;
109
+ }
110
+ set label(value) {
111
+ this._label = value;
112
+ }
113
+ set text(value) {
114
+ this._text = value;
115
+ }
116
+ get text() {
117
+ return this._text ?? "";
118
+ }
119
+ set value(next) {
120
+ const newValue = `${next ?? ""}`;
121
+ this._value = newValue;
122
+ this.dirtyValue = true;
123
+ if (this.proxy instanceof HTMLOptionElement) {
124
+ this.proxy.value = newValue;
125
+ }
126
+ Observable.notify(this, "value");
127
+ }
128
+ get value() {
129
+ Observable.track(this, "value");
130
+ return this._value ?? this.text;
131
+ }
132
+ get form() {
133
+ return null;
134
+ }
135
+ /**
136
+ * @internal
137
+ */
138
+ get _matchedRangeSafe() {
139
+ return this._matchedRange ?? { from: 0, to: 0 };
140
+ }
141
+ }
142
+ __decorateClass([
143
+ observable
144
+ ], ListboxOption.prototype, "checked");
145
+ __decorateClass([
146
+ observable
147
+ ], ListboxOption.prototype, "defaultSelected");
148
+ // @ts-expect-error Type is incorrectly non-optional
149
+ __decorateClass([
150
+ attr({ mode: "boolean" })
151
+ ], ListboxOption.prototype, "disabled");
152
+ // @ts-expect-error Type is incorrectly non-optional
153
+ __decorateClass([
154
+ attr({ attribute: "selected", mode: "boolean" })
155
+ ], ListboxOption.prototype, "selectedAttribute");
156
+ __decorateClass([
157
+ observable
158
+ ], ListboxOption.prototype, "selected");
159
+ __decorateClass([
160
+ attr({ attribute: "value", mode: "fromView" })
161
+ ], ListboxOption.prototype, "initialValue");
162
+ __decorateClass([
163
+ attr({
164
+ attribute: "label"
165
+ })
166
+ ], ListboxOption.prototype, "_label");
167
+ __decorateClass([
168
+ attr({
169
+ attribute: "text"
170
+ })
171
+ ], ListboxOption.prototype, "_text");
172
+ __decorateClass([
173
+ observable
174
+ ], ListboxOption.prototype, "_highlighted");
175
+ __decorateClass([
176
+ observable
177
+ ], ListboxOption.prototype, "_displayCheckmark");
178
+ __decorateClass([
179
+ observable
180
+ ], ListboxOption.prototype, "_matchedRange");
181
+ class DelegatesARIAListboxOption {
182
+ }
183
+ // @ts-expect-error Type is incorrectly non-optional
184
+ __decorateClass([
185
+ observable
186
+ ], DelegatesARIAListboxOption.prototype, "ariaChecked");
187
+ // @ts-expect-error Type is incorrectly non-optional
188
+ __decorateClass([
189
+ observable
190
+ ], DelegatesARIAListboxOption.prototype, "ariaPosInSet");
191
+ // @ts-expect-error Type is incorrectly non-optional
192
+ __decorateClass([
193
+ observable
194
+ ], DelegatesARIAListboxOption.prototype, "ariaSelected");
195
+ // @ts-expect-error Type is incorrectly non-optional
196
+ __decorateClass([
197
+ observable
198
+ ], DelegatesARIAListboxOption.prototype, "ariaSetSize");
199
+ applyMixins(DelegatesARIAListboxOption, ARIAGlobalStatesAndProperties);
200
+ applyMixins(ListboxOption, AffixIconWithTrailing, DelegatesARIAListboxOption);
201
+
202
+ export { ListboxOption as L, isListboxOption as i };