@vonage/vivid 3.48.0 → 3.49.0-preview.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 (182) hide show
  1. package/accordion/index.cjs +21 -0
  2. package/accordion-item/index.cjs +18 -0
  3. package/action-group/index.cjs +7 -0
  4. package/alert/index.cjs +30 -0
  5. package/appearance-ui/index.cjs +96 -0
  6. package/audio-player/index.cjs +34 -0
  7. package/avatar/index.cjs +11 -0
  8. package/badge/index.cjs +14 -0
  9. package/banner/index.cjs +29 -0
  10. package/breadcrumb/index.cjs +13 -0
  11. package/breadcrumb-item/index.cjs +22 -0
  12. package/button/index.cjs +25 -0
  13. package/calendar/index.cjs +9 -0
  14. package/calendar-event/index.cjs +9 -0
  15. package/card/index.cjs +14 -0
  16. package/checkbox/index.cjs +21 -0
  17. package/combobox/index.cjs +39 -0
  18. package/data-grid/index.cjs +18 -0
  19. package/date-picker/index.cjs +40 -0
  20. package/date-range-picker/index.cjs +40 -0
  21. package/dialog/index.cjs +31 -0
  22. package/divider/index.cjs +8 -0
  23. package/elevation/index.cjs +7 -0
  24. package/empty-state/index.cjs +12 -0
  25. package/fab/index.cjs +22 -0
  26. package/file-picker/index.cjs +30 -0
  27. package/focus/index.cjs +7 -0
  28. package/header/index.cjs +8 -0
  29. package/icon/index.cjs +10 -0
  30. package/index.cjs +296 -0
  31. package/layout/index.cjs +7 -0
  32. package/listbox/index.cjs +77 -0
  33. package/locales/en-GB.cjs +106 -0
  34. package/locales/en-US.cjs +106 -0
  35. package/locales/ja-JP.cjs +106 -0
  36. package/locales/zh-CN.cjs +106 -0
  37. package/menu/index.cjs +32 -0
  38. package/menu-item/index.cjs +22 -0
  39. package/nav/index.cjs +6 -0
  40. package/nav-disclosure/index.cjs +17 -0
  41. package/nav-item/index.cjs +22 -0
  42. package/note/index.cjs +16 -0
  43. package/number-field/index.cjs +33 -0
  44. package/option/index.cjs +23 -0
  45. package/package.json +20 -2
  46. package/pagination/index.cjs +28 -0
  47. package/popup/index.cjs +27 -0
  48. package/progress/index.cjs +9 -0
  49. package/progress-ring/index.cjs +9 -0
  50. package/radio/index.cjs +14 -0
  51. package/radio-group/index.cjs +14 -0
  52. package/select/index.cjs +38 -0
  53. package/selectable-box/index.cjs +25 -0
  54. package/shared/Reflector.cjs +67 -0
  55. package/shared/_has.cjs +62 -0
  56. package/shared/affix.cjs +64 -0
  57. package/shared/affix.js +8 -4
  58. package/shared/anchor.cjs +90 -0
  59. package/shared/anchored.cjs +78 -0
  60. package/shared/apply-mixins.cjs +25 -0
  61. package/shared/aria-global.cjs +74 -0
  62. package/shared/aria.cjs +11 -0
  63. package/shared/aria2.cjs +11 -0
  64. package/shared/base-progress.cjs +72 -0
  65. package/shared/breadcrumb-item.cjs +27 -0
  66. package/shared/button.cjs +202 -0
  67. package/shared/calendar-event.cjs +41 -0
  68. package/shared/children.cjs +61 -0
  69. package/shared/class-names.cjs +17 -0
  70. package/shared/definition.cjs +165 -0
  71. package/shared/definition10.cjs +102 -0
  72. package/shared/definition11.cjs +164 -0
  73. package/shared/definition11.js +38 -36
  74. package/shared/definition12.cjs +50 -0
  75. package/shared/definition13.cjs +779 -0
  76. package/shared/definition14.cjs +157 -0
  77. package/shared/definition15.cjs +249 -0
  78. package/shared/definition16.cjs +746 -0
  79. package/shared/definition17.cjs +1372 -0
  80. package/shared/definition18.cjs +175 -0
  81. package/shared/definition19.cjs +416 -0
  82. package/shared/definition2.cjs +232 -0
  83. package/shared/definition20.cjs +278 -0
  84. package/shared/definition21.cjs +83 -0
  85. package/shared/definition22.cjs +74 -0
  86. package/shared/definition23.cjs +106 -0
  87. package/shared/definition24.cjs +2392 -0
  88. package/shared/definition25.cjs +75 -0
  89. package/shared/definition26.cjs +39 -0
  90. package/shared/definition27.cjs +66 -0
  91. package/shared/definition28.cjs +849 -0
  92. package/shared/definition29.cjs +72 -0
  93. package/shared/definition3.cjs +72 -0
  94. package/shared/definition30.cjs +98 -0
  95. package/shared/definition31.cjs +37 -0
  96. package/shared/definition32.cjs +24 -0
  97. package/shared/definition33.cjs +64 -0
  98. package/shared/definition34.cjs +533 -0
  99. package/shared/definition35.cjs +295 -0
  100. package/shared/definition36.cjs +219 -0
  101. package/shared/definition37.cjs +109 -0
  102. package/shared/definition38.cjs +92 -0
  103. package/shared/definition39.cjs +448 -0
  104. package/shared/definition4.cjs +198 -0
  105. package/shared/definition40.cjs +49 -0
  106. package/shared/definition41.cjs +694 -0
  107. package/shared/definition42.cjs +152 -0
  108. package/shared/definition43.cjs +113 -0
  109. package/shared/definition44.cjs +607 -0
  110. package/shared/definition45.cjs +152 -0
  111. package/shared/definition46.cjs +166 -0
  112. package/shared/definition47.cjs +35 -0
  113. package/shared/definition48.cjs +98 -0
  114. package/shared/definition49.cjs +543 -0
  115. package/shared/definition5.cjs +199 -0
  116. package/shared/definition50.cjs +52 -0
  117. package/shared/definition51.cjs +150 -0
  118. package/shared/definition52.cjs +304 -0
  119. package/shared/definition53.cjs +309 -0
  120. package/shared/definition54.cjs +146 -0
  121. package/shared/definition55.cjs +128 -0
  122. package/shared/definition56.cjs +99 -0
  123. package/shared/definition57.cjs +310 -0
  124. package/shared/definition58.cjs +20 -0
  125. package/shared/definition59.cjs +51 -0
  126. package/shared/definition6.cjs +83 -0
  127. package/shared/definition60.cjs +1810 -0
  128. package/shared/definition7.cjs +72 -0
  129. package/shared/definition8.cjs +152 -0
  130. package/shared/definition9.cjs +69 -0
  131. package/shared/dialog-polyfill.esm.cjs +862 -0
  132. package/shared/direction.cjs +22 -0
  133. package/shared/dom.cjs +23 -0
  134. package/shared/enums.cjs +87 -0
  135. package/shared/focus.cjs +8 -0
  136. package/shared/focus2.cjs +11 -0
  137. package/shared/form-associated.cjs +470 -0
  138. package/shared/icon.cjs +237 -0
  139. package/shared/index.cjs +5061 -0
  140. package/shared/index2.cjs +231 -0
  141. package/shared/key-codes.cjs +115 -0
  142. package/shared/key-codes2.cjs +14 -0
  143. package/shared/listbox.cjs +1072 -0
  144. package/shared/localized.cjs +11 -0
  145. package/shared/numbers.cjs +38 -0
  146. package/shared/patterns/affix.d.ts +5 -1
  147. package/shared/presentationDate.cjs +6192 -0
  148. package/shared/radio.cjs +153 -0
  149. package/shared/ref.cjs +43 -0
  150. package/shared/repeat.cjs +767 -0
  151. package/shared/select.options.cjs +12 -0
  152. package/shared/slotted.cjs +123 -0
  153. package/shared/start-end.cjs +52 -0
  154. package/shared/strings.cjs +11 -0
  155. package/shared/text-anchor.cjs +33 -0
  156. package/shared/text-anchor.template.cjs +48 -0
  157. package/shared/text-field.cjs +5 -0
  158. package/shared/text-field2.cjs +228 -0
  159. package/shared/tree-item.cjs +154 -0
  160. package/shared/when.cjs +31 -0
  161. package/side-drawer/index.cjs +8 -0
  162. package/slider/index.cjs +16 -0
  163. package/split-button/index.cjs +20 -0
  164. package/styles/core/all.css +1 -1
  165. package/styles/core/theme.css +1 -1
  166. package/styles/core/typography.css +1 -1
  167. package/styles/tokens/theme-dark.css +4 -4
  168. package/styles/tokens/theme-light.css +4 -4
  169. package/styles/tokens/vivid-2-compat.css +1 -1
  170. package/switch/index.cjs +15 -0
  171. package/tab/index.cjs +17 -0
  172. package/tab-panel/index.cjs +6 -0
  173. package/tabs/index.cjs +24 -0
  174. package/tag/index.cjs +17 -0
  175. package/tag-group/index.cjs +7 -0
  176. package/text-anchor/index.cjs +24 -0
  177. package/text-area/index.cjs +25 -0
  178. package/text-field/index.cjs +27 -0
  179. package/toggletip/index.cjs +29 -0
  180. package/tooltip/index.cjs +29 -0
  181. package/tree-item/index.cjs +22 -0
  182. package/tree-view/index.cjs +14 -0
@@ -0,0 +1,746 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index.cjs');
4
+ const definition$1 = require('./definition26.cjs');
5
+ const definition = require('./definition60.cjs');
6
+ const definition$2 = require('./definition58.cjs');
7
+ const definition$3 = require('./definition35.cjs');
8
+ const textField = require('./text-field.cjs');
9
+ const affix = require('./affix.cjs');
10
+ const index$1 = require('./index2.cjs');
11
+ const listbox = require('./listbox.cjs');
12
+ const startEnd = require('./start-end.cjs');
13
+ const select_options = require('./select.options.cjs');
14
+ const applyMixins = require('./apply-mixins.cjs');
15
+ const formAssociated = require('./form-associated.cjs');
16
+ const numbers = require('./numbers.cjs');
17
+ const strings = require('./strings.cjs');
18
+ const focus = require('./focus2.cjs');
19
+ const ref = require('./ref.cjs');
20
+ const slotted = require('./slotted.cjs');
21
+ const when = require('./when.cjs');
22
+ const classNames = require('./class-names.cjs');
23
+
24
+ class _Combobox extends listbox.Listbox$1 {
25
+ }
26
+ /**
27
+ * A form-associated base class for the {@link (Combobox:class)} component.
28
+ *
29
+ * @internal
30
+ */
31
+ class FormAssociatedCombobox extends formAssociated.FormAssociated(_Combobox) {
32
+ constructor() {
33
+ super(...arguments);
34
+ this.proxy = document.createElement("input");
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Autocomplete values for combobox.
40
+ * @public
41
+ */
42
+ const ComboboxAutocomplete = {
43
+ inline: "inline",
44
+ list: "list",
45
+ both: "both",
46
+ none: "none",
47
+ };
48
+
49
+ /**
50
+ * A Combobox Custom HTML Element.
51
+ * Implements the {@link https://w3c.github.io/aria-practices/#combobox | ARIA combobox }.
52
+ *
53
+ * @slot start - Content which can be provided before the input
54
+ * @slot end - Content which can be provided after the input
55
+ * @slot control - Used to replace the input element representing the combobox
56
+ * @slot indicator - The visual indicator representing the expanded state
57
+ * @slot - The default slot for the options
58
+ * @csspart control - The wrapper element containing the input area, including start and end
59
+ * @csspart selected-value - The input element representing the selected value
60
+ * @csspart indicator - The element wrapping the indicator slot
61
+ * @csspart listbox - The wrapper for the listbox slotted options
62
+ * @fires change - Fires a custom 'change' event when the value updates
63
+ *
64
+ * @public
65
+ */
66
+ let Combobox$1 = class Combobox extends FormAssociatedCombobox {
67
+ constructor() {
68
+ super(...arguments);
69
+ /**
70
+ * The internal value property.
71
+ *
72
+ * @internal
73
+ */
74
+ this._value = "";
75
+ /**
76
+ * The collection of currently filtered options.
77
+ *
78
+ * @public
79
+ */
80
+ this.filteredOptions = [];
81
+ /**
82
+ * The current filter value.
83
+ *
84
+ * @internal
85
+ */
86
+ this.filter = "";
87
+ /**
88
+ * The initial state of the position attribute.
89
+ *
90
+ * @internal
91
+ */
92
+ this.forcedPosition = false;
93
+ /**
94
+ * The unique id for the internal listbox element.
95
+ *
96
+ * @internal
97
+ */
98
+ this.listboxId = strings.uniqueId("listbox-");
99
+ /**
100
+ * The max height for the listbox when opened.
101
+ *
102
+ * @internal
103
+ */
104
+ this.maxHeight = 0;
105
+ /**
106
+ * The open attribute.
107
+ *
108
+ * @public
109
+ * @remarks
110
+ * HTML Attribute: open
111
+ */
112
+ this.open = false;
113
+ }
114
+ /**
115
+ * Reset the element to its first selectable option when its parent form is reset.
116
+ *
117
+ * @internal
118
+ */
119
+ formResetCallback() {
120
+ super.formResetCallback();
121
+ this.setDefaultSelectedOption();
122
+ this.updateValue();
123
+ }
124
+ /** {@inheritDoc (FormAssociated:interface).validate} */
125
+ validate() {
126
+ super.validate(this.control);
127
+ }
128
+ get isAutocompleteInline() {
129
+ return (this.autocomplete === ComboboxAutocomplete.inline || this.isAutocompleteBoth);
130
+ }
131
+ get isAutocompleteList() {
132
+ return this.autocomplete === ComboboxAutocomplete.list || this.isAutocompleteBoth;
133
+ }
134
+ get isAutocompleteBoth() {
135
+ return this.autocomplete === ComboboxAutocomplete.both;
136
+ }
137
+ /**
138
+ * Sets focus and synchronize ARIA attributes when the open property changes.
139
+ *
140
+ * @param prev - the previous open value
141
+ * @param next - the current open value
142
+ *
143
+ * @internal
144
+ */
145
+ openChanged() {
146
+ if (this.open) {
147
+ this.ariaControls = this.listboxId;
148
+ this.ariaExpanded = "true";
149
+ this.setPositioning();
150
+ this.focusAndScrollOptionIntoView();
151
+ // focus is directed to the element when `open` is changed programmatically
152
+ index.DOM.queueUpdate(() => this.focus());
153
+ return;
154
+ }
155
+ this.ariaControls = "";
156
+ this.ariaExpanded = "false";
157
+ }
158
+ /**
159
+ * The list of options.
160
+ *
161
+ * @public
162
+ * @remarks
163
+ * Overrides `Listbox.options`.
164
+ */
165
+ get options() {
166
+ index.Observable.track(this, "options");
167
+ return this.filteredOptions.length ? this.filteredOptions : this._options;
168
+ }
169
+ set options(value) {
170
+ this._options = value;
171
+ index.Observable.notify(this, "options");
172
+ }
173
+ /**
174
+ * Updates the placeholder on the proxy element.
175
+ * @internal
176
+ */
177
+ placeholderChanged() {
178
+ if (this.proxy instanceof HTMLInputElement) {
179
+ this.proxy.placeholder = this.placeholder;
180
+ }
181
+ }
182
+ positionChanged(prev, next) {
183
+ this.positionAttribute = next;
184
+ this.setPositioning();
185
+ }
186
+ /**
187
+ * The value property.
188
+ *
189
+ * @public
190
+ */
191
+ get value() {
192
+ index.Observable.track(this, "value");
193
+ return this._value;
194
+ }
195
+ set value(next) {
196
+ var _a, _b, _c;
197
+ const prev = `${this._value}`;
198
+ if (this.$fastController.isConnected && this.options) {
199
+ const selectedIndex = this.options.findIndex(el => el.text.toLowerCase() === next.toLowerCase());
200
+ const prevSelectedValue = (_a = this.options[this.selectedIndex]) === null || _a === void 0 ? void 0 : _a.text;
201
+ const nextSelectedValue = (_b = this.options[selectedIndex]) === null || _b === void 0 ? void 0 : _b.text;
202
+ this.selectedIndex =
203
+ prevSelectedValue !== nextSelectedValue
204
+ ? selectedIndex
205
+ : this.selectedIndex;
206
+ next = ((_c = this.firstSelectedOption) === null || _c === void 0 ? void 0 : _c.text) || next;
207
+ }
208
+ if (prev !== next) {
209
+ this._value = next;
210
+ super.valueChanged(prev, next);
211
+ index.Observable.notify(this, "value");
212
+ }
213
+ }
214
+ /**
215
+ * Handle opening and closing the listbox when the combobox is clicked.
216
+ *
217
+ * @param e - the mouse event
218
+ * @internal
219
+ */
220
+ clickHandler(e) {
221
+ if (this.disabled) {
222
+ return;
223
+ }
224
+ if (this.open) {
225
+ const captured = e.target.closest(`option,[role=option]`);
226
+ if (!captured || captured.disabled) {
227
+ return;
228
+ }
229
+ this.selectedOptions = [captured];
230
+ this.control.value = captured.text;
231
+ this.clearSelectionRange();
232
+ this.updateValue(true);
233
+ }
234
+ this.open = !this.open;
235
+ if (this.open) {
236
+ this.control.focus();
237
+ }
238
+ return true;
239
+ }
240
+ connectedCallback() {
241
+ super.connectedCallback();
242
+ this.forcedPosition = !!this.positionAttribute;
243
+ if (this.value) {
244
+ this.initialValue = this.value;
245
+ }
246
+ }
247
+ /**
248
+ * Synchronize the `aria-disabled` property when the `disabled` property changes.
249
+ *
250
+ * @param prev - The previous disabled value
251
+ * @param next - The next disabled value
252
+ *
253
+ * @internal
254
+ */
255
+ disabledChanged(prev, next) {
256
+ if (super.disabledChanged) {
257
+ super.disabledChanged(prev, next);
258
+ }
259
+ this.ariaDisabled = this.disabled ? "true" : "false";
260
+ }
261
+ /**
262
+ * Filter available options by text value.
263
+ *
264
+ * @public
265
+ */
266
+ filterOptions() {
267
+ if (!this.autocomplete || this.autocomplete === ComboboxAutocomplete.none) {
268
+ this.filter = "";
269
+ }
270
+ const filter = this.filter.toLowerCase();
271
+ this.filteredOptions = this._options.filter(o => o.text.toLowerCase().startsWith(this.filter.toLowerCase()));
272
+ if (this.isAutocompleteList) {
273
+ if (!this.filteredOptions.length && !filter) {
274
+ this.filteredOptions = this._options;
275
+ }
276
+ this._options.forEach(o => {
277
+ o.hidden = !this.filteredOptions.includes(o);
278
+ });
279
+ }
280
+ }
281
+ /**
282
+ * Focus the control and scroll the first selected option into view.
283
+ *
284
+ * @internal
285
+ * @remarks
286
+ * Overrides: `Listbox.focusAndScrollOptionIntoView`
287
+ */
288
+ focusAndScrollOptionIntoView() {
289
+ if (this.contains(document.activeElement)) {
290
+ this.control.focus();
291
+ if (this.firstSelectedOption) {
292
+ requestAnimationFrame(() => {
293
+ var _a;
294
+ (_a = this.firstSelectedOption) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ block: "nearest" });
295
+ });
296
+ }
297
+ }
298
+ }
299
+ /**
300
+ * Handle focus state when the element or its children lose focus.
301
+ *
302
+ * @param e - The focus event
303
+ * @internal
304
+ */
305
+ focusoutHandler(e) {
306
+ this.syncValue();
307
+ if (!this.open) {
308
+ return true;
309
+ }
310
+ const focusTarget = e.relatedTarget;
311
+ if (this.isSameNode(focusTarget)) {
312
+ this.focus();
313
+ return;
314
+ }
315
+ if (!this.options || !this.options.includes(focusTarget)) {
316
+ this.open = false;
317
+ }
318
+ }
319
+ /**
320
+ * Handle content changes on the control input.
321
+ *
322
+ * @param e - the input event
323
+ * @internal
324
+ */
325
+ inputHandler(e) {
326
+ this.filter = this.control.value;
327
+ this.filterOptions();
328
+ if (!this.isAutocompleteInline) {
329
+ this.selectedIndex = this.options
330
+ .map(option => option.text)
331
+ .indexOf(this.control.value);
332
+ }
333
+ if (e.inputType.includes("deleteContent") || !this.filter.length) {
334
+ return true;
335
+ }
336
+ if (this.isAutocompleteList && !this.open) {
337
+ this.open = true;
338
+ }
339
+ if (this.isAutocompleteInline) {
340
+ if (this.filteredOptions.length) {
341
+ this.selectedOptions = [this.filteredOptions[0]];
342
+ this.selectedIndex = this.options.indexOf(this.firstSelectedOption);
343
+ this.setInlineSelection();
344
+ }
345
+ else {
346
+ this.selectedIndex = -1;
347
+ }
348
+ }
349
+ return;
350
+ }
351
+ /**
352
+ * Handle keydown actions for listbox navigation.
353
+ *
354
+ * @param e - the keyboard event
355
+ * @internal
356
+ */
357
+ keydownHandler(e) {
358
+ const key = e.key;
359
+ if (e.ctrlKey || e.shiftKey) {
360
+ return true;
361
+ }
362
+ switch (key) {
363
+ case "Enter": {
364
+ this.syncValue();
365
+ if (this.isAutocompleteInline) {
366
+ this.filter = this.value;
367
+ }
368
+ this.open = false;
369
+ this.clearSelectionRange();
370
+ break;
371
+ }
372
+ case "Escape": {
373
+ if (!this.isAutocompleteInline) {
374
+ this.selectedIndex = -1;
375
+ }
376
+ if (this.open) {
377
+ this.open = false;
378
+ break;
379
+ }
380
+ this.value = "";
381
+ this.control.value = "";
382
+ this.filter = "";
383
+ this.filterOptions();
384
+ break;
385
+ }
386
+ case "Tab": {
387
+ this.setInputToSelection();
388
+ if (!this.open) {
389
+ return true;
390
+ }
391
+ e.preventDefault();
392
+ this.open = false;
393
+ break;
394
+ }
395
+ case "ArrowUp":
396
+ case "ArrowDown": {
397
+ this.filterOptions();
398
+ if (!this.open) {
399
+ this.open = true;
400
+ break;
401
+ }
402
+ if (this.filteredOptions.length > 0) {
403
+ super.keydownHandler(e);
404
+ }
405
+ if (this.isAutocompleteInline) {
406
+ this.setInlineSelection();
407
+ }
408
+ break;
409
+ }
410
+ default: {
411
+ return true;
412
+ }
413
+ }
414
+ }
415
+ /**
416
+ * Handle keyup actions for value input and text field manipulations.
417
+ *
418
+ * @param e - the keyboard event
419
+ * @internal
420
+ */
421
+ keyupHandler(e) {
422
+ const key = e.key;
423
+ switch (key) {
424
+ case "ArrowLeft":
425
+ case "ArrowRight":
426
+ case "Backspace":
427
+ case "Delete":
428
+ case "Home":
429
+ case "End": {
430
+ this.filter = this.control.value;
431
+ this.selectedIndex = -1;
432
+ this.filterOptions();
433
+ break;
434
+ }
435
+ }
436
+ }
437
+ /**
438
+ * Ensure that the selectedIndex is within the current allowable filtered range.
439
+ *
440
+ * @param prev - the previous selected index value
441
+ * @param next - the current selected index value
442
+ *
443
+ * @internal
444
+ */
445
+ selectedIndexChanged(prev, next) {
446
+ if (this.$fastController.isConnected) {
447
+ next = numbers.limit(-1, this.options.length - 1, next);
448
+ // we only want to call the super method when the selectedIndex is in range
449
+ if (next !== this.selectedIndex) {
450
+ this.selectedIndex = next;
451
+ return;
452
+ }
453
+ super.selectedIndexChanged(prev, next);
454
+ }
455
+ }
456
+ /**
457
+ * Move focus to the previous selectable option.
458
+ *
459
+ * @internal
460
+ * @remarks
461
+ * Overrides `Listbox.selectPreviousOption`
462
+ */
463
+ selectPreviousOption() {
464
+ if (!this.disabled && this.selectedIndex >= 0) {
465
+ this.selectedIndex = this.selectedIndex - 1;
466
+ }
467
+ }
468
+ /**
469
+ * Set the default selected options at initialization or reset.
470
+ *
471
+ * @internal
472
+ * @remarks
473
+ * Overrides `Listbox.setDefaultSelectedOption`
474
+ */
475
+ setDefaultSelectedOption() {
476
+ if (this.$fastController.isConnected && this.options) {
477
+ const selectedIndex = this.options.findIndex(el => el.getAttribute("selected") !== null || el.selected);
478
+ this.selectedIndex = selectedIndex;
479
+ if (!this.dirtyValue && this.firstSelectedOption) {
480
+ this.value = this.firstSelectedOption.text;
481
+ }
482
+ this.setSelectedOptions();
483
+ }
484
+ }
485
+ /**
486
+ * Focus and set the content of the control based on the first selected option.
487
+ *
488
+ * @internal
489
+ */
490
+ setInputToSelection() {
491
+ if (this.firstSelectedOption) {
492
+ this.control.value = this.firstSelectedOption.text;
493
+ this.control.focus();
494
+ }
495
+ }
496
+ /**
497
+ * Focus, set and select the content of the control based on the first selected option.
498
+ *
499
+ * @internal
500
+ */
501
+ setInlineSelection() {
502
+ if (this.firstSelectedOption) {
503
+ this.setInputToSelection();
504
+ this.control.setSelectionRange(this.filter.length, this.control.value.length, "backward");
505
+ }
506
+ }
507
+ /**
508
+ * Determines if a value update should involve emitting a change event, then updates the value.
509
+ *
510
+ * @internal
511
+ */
512
+ syncValue() {
513
+ var _a;
514
+ const newValue = this.selectedIndex > -1 ? (_a = this.firstSelectedOption) === null || _a === void 0 ? void 0 : _a.text : this.control.value;
515
+ this.updateValue(this.value !== newValue);
516
+ }
517
+ /**
518
+ * Calculate and apply listbox positioning based on available viewport space.
519
+ *
520
+ * @param force - direction to force the listbox to display
521
+ * @public
522
+ */
523
+ setPositioning() {
524
+ const currentBox = this.getBoundingClientRect();
525
+ const viewportHeight = window.innerHeight;
526
+ const availableBottom = viewportHeight - currentBox.bottom;
527
+ this.position = this.forcedPosition
528
+ ? this.positionAttribute
529
+ : currentBox.top > availableBottom
530
+ ? select_options.SelectPosition.above
531
+ : select_options.SelectPosition.below;
532
+ this.positionAttribute = this.forcedPosition
533
+ ? this.positionAttribute
534
+ : this.position;
535
+ this.maxHeight =
536
+ this.position === select_options.SelectPosition.above ? ~~currentBox.top : ~~availableBottom;
537
+ }
538
+ /**
539
+ * Ensure that the entire list of options is used when setting the selected property.
540
+ *
541
+ * @param prev - the previous list of selected options
542
+ * @param next - the current list of selected options
543
+ *
544
+ * @internal
545
+ * @remarks
546
+ * Overrides: `Listbox.selectedOptionsChanged`
547
+ */
548
+ selectedOptionsChanged(prev, next) {
549
+ if (this.$fastController.isConnected) {
550
+ this._options.forEach(o => {
551
+ o.selected = next.includes(o);
552
+ });
553
+ }
554
+ }
555
+ /**
556
+ * Synchronize the form-associated proxy and update the value property of the element.
557
+ *
558
+ * @param prev - the previous collection of slotted option elements
559
+ * @param next - the next collection of slotted option elements
560
+ *
561
+ * @internal
562
+ */
563
+ slottedOptionsChanged(prev, next) {
564
+ super.slottedOptionsChanged(prev, next);
565
+ this.updateValue();
566
+ }
567
+ /**
568
+ * Sets the value and to match the first selected option.
569
+ *
570
+ * @param shouldEmit - if true, the change event will be emitted
571
+ *
572
+ * @internal
573
+ */
574
+ updateValue(shouldEmit) {
575
+ var _a;
576
+ if (this.$fastController.isConnected) {
577
+ this.value = ((_a = this.firstSelectedOption) === null || _a === void 0 ? void 0 : _a.text) || this.control.value;
578
+ this.control.value = this.value;
579
+ }
580
+ if (shouldEmit) {
581
+ this.$emit("change");
582
+ }
583
+ }
584
+ /**
585
+ * @internal
586
+ */
587
+ clearSelectionRange() {
588
+ const controlValueLength = this.control.value.length;
589
+ this.control.setSelectionRange(controlValueLength, controlValueLength);
590
+ }
591
+ };
592
+ index.__decorate([
593
+ index.attr({ attribute: "autocomplete", mode: "fromView" })
594
+ ], Combobox$1.prototype, "autocomplete", void 0);
595
+ index.__decorate([
596
+ index.observable
597
+ ], Combobox$1.prototype, "maxHeight", void 0);
598
+ index.__decorate([
599
+ index.attr({ attribute: "open", mode: "boolean" })
600
+ ], Combobox$1.prototype, "open", void 0);
601
+ index.__decorate([
602
+ index.attr
603
+ ], Combobox$1.prototype, "placeholder", void 0);
604
+ index.__decorate([
605
+ index.attr({ attribute: "position" })
606
+ ], Combobox$1.prototype, "positionAttribute", void 0);
607
+ index.__decorate([
608
+ index.observable
609
+ ], Combobox$1.prototype, "position", void 0);
610
+ /**
611
+ * Includes ARIA states and properties relating to the ARIA combobox role.
612
+ *
613
+ * @public
614
+ */
615
+ class DelegatesARIACombobox {
616
+ }
617
+ index.__decorate([
618
+ index.observable
619
+ ], DelegatesARIACombobox.prototype, "ariaAutoComplete", void 0);
620
+ index.__decorate([
621
+ index.observable
622
+ ], DelegatesARIACombobox.prototype, "ariaControls", void 0);
623
+ applyMixins.applyMixins(DelegatesARIACombobox, listbox.DelegatesARIAListbox);
624
+ applyMixins.applyMixins(Combobox$1, startEnd.StartEnd, DelegatesARIACombobox);
625
+
626
+ const styles = ":host{position:relative}.base{--_text-field-gutter-end: 44px}.icon{inset-inline-end:16px;inset-inline-start:unset}:not(.disabled) .icon{cursor:pointer}.disabled .icon{cursor:not-allowed}.listbox{padding:4px;background-color:var(--_appearance-color-fill);border-radius:8px;box-shadow:inset 0 0 0 1px var(--_appearance-color-outline);contain:paint}.listbox{--_connotation-color-backdrop: var(--vvd-combobox-accent-backdrop, var(--vvd-color-canvas));--_connotation-color-intermediate: var(--vvd-combobox-accent-intermediate, var(--vvd-color-neutral-500));--_connotation-color-primary: var(--vvd-combobox-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-soft: var(--vvd-combobox-accent-soft, var(--vvd-color-neutral-100))}.listbox{--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--_connotation-color-backdrop);--_appearance-color-outline: var(--_connotation-color-intermediate)}.listbox.appearance-ghost{--_appearance-color-text: var(--_connotation-color-primary);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.listbox:where(:disabled,.disabled){--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: var(--vvd-color-neutral-100);--_appearance-color-outline: var(--vvd-color-neutral-300)}.listbox:where(:disabled,.disabled).appearance-ghost{--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}::part(popup-base){inline-size:100%}\n";
627
+
628
+ var __defProp = Object.defineProperty;
629
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
630
+ var __decorateClass = (decorators, target, key, kind) => {
631
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
632
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
633
+ if (decorator = decorators[i])
634
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
635
+ if (kind && result)
636
+ __defProp(target, key, result);
637
+ return result;
638
+ };
639
+ let Combobox = class extends Combobox$1 {
640
+ connectedCallback() {
641
+ super.connectedCallback();
642
+ this._popup.anchor = this._anchor;
643
+ }
644
+ };
645
+ __decorateClass([
646
+ index.attr
647
+ ], Combobox.prototype, "placement", 2);
648
+ Combobox = __decorateClass([
649
+ index$1.formElements
650
+ ], Combobox);
651
+ applyMixins.applyMixins(Combobox, affix.AffixIcon);
652
+
653
+ function renderLabel() {
654
+ return index.html`
655
+ <label for="control" class="label">
656
+ ${(x) => x.label}
657
+ </label>`;
658
+ }
659
+ const getStateClasses = ({
660
+ disabled,
661
+ placeholder,
662
+ label
663
+ }) => classNames.classNames(
664
+ "base",
665
+ ["disabled", disabled],
666
+ ["placeholder", Boolean(placeholder)],
667
+ ["no-label", !label]
668
+ );
669
+ function renderInput(context) {
670
+ const affixIconTemplate = affix.affixIconTemplateFactory(context);
671
+ const focusTemplate = focus.focusTemplateFactory(context);
672
+ return index.html`
673
+ <div class="${getStateClasses}" ${ref.ref("_anchor")}>
674
+ ${when.when((x) => x.label, renderLabel())}
675
+ <div class="fieldset">
676
+ <input
677
+ id="control"
678
+ class="control"
679
+ aria-activedescendant="${(x) => x.open ? x.ariaActiveDescendant : null}"
680
+ aria-autocomplete="${(x) => x.ariaAutoComplete}"
681
+ aria-controls="${(x) => x.ariaControls}"
682
+ aria-disabled="${(x) => x.ariaDisabled}"
683
+ aria-expanded="${(x) => x.ariaExpanded}"
684
+ aria-haspopup="listbox"
685
+ placeholder="${(x) => x.placeholder}"
686
+ role="combobox"
687
+ type="text"
688
+ ?disabled="${(x) => x.disabled}"
689
+ :value="${(x) => x.value}"
690
+ @input="${(x, c) => x.inputHandler(c.event)}"
691
+ @keyup="${(x, c) => x.keyupHandler(c.event)}"
692
+ ${ref.ref("control")}
693
+ />
694
+ ${() => affixIconTemplate("chevron-down-line")}
695
+ ${() => focusTemplate}
696
+ </div>
697
+ </div>`;
698
+ }
699
+ const comboboxTemplate = (context) => {
700
+ const popupTag = context.tagFor(definition.Popup);
701
+ return index.html`
702
+ <template
703
+ aria-disabled="${(x) => x.ariaDisabled}"
704
+ autocomplete="${(x) => x.autocomplete}"
705
+ tabindex="${(x) => !x.disabled ? "0" : null}"
706
+ @click="${(x, c) => x.clickHandler(c.event)}"
707
+ @focusout="${(x, c) => x.focusoutHandler(c.event)}"
708
+ @keydown="${(x, c) => x.keydownHandler(c.event)}"
709
+ >
710
+ ${() => renderInput(context)}
711
+ <${popupTag} class="popup"
712
+ ?open="${(x) => x.open}"
713
+ placement="${(x) => x.placement}"
714
+ strategy="absolute"
715
+ ${ref.ref("_popup")}>
716
+ <div id="${(x) => x.listboxId}"
717
+ class="listbox"
718
+ role="listbox"
719
+ ?disabled="${(x) => x.disabled}"
720
+ ${ref.ref("listbox")}>
721
+ <slot ${slotted.slotted({
722
+ filter: listbox.Listbox.slottedOptionFilter,
723
+ flatten: true,
724
+ property: "slottedOptions"
725
+ })}>
726
+ </slot>
727
+ </div>
728
+ </${popupTag}>
729
+ </template>
730
+ `;
731
+ };
732
+
733
+ const combobox = Combobox.compose({
734
+ baseName: "combobox",
735
+ template: comboboxTemplate,
736
+ styles: [textField.styles, styles],
737
+ shadowOptions: {
738
+ delegatesFocus: true
739
+ }
740
+ })();
741
+ const comboboxRegistries = [combobox, ...definition$1.iconRegistries, ...definition.popupRegistries, ...definition$2.focusRegistries, ...definition$3.listboxOptionRegistries];
742
+ const registerCombobox = index.registerFactory(comboboxRegistries);
743
+
744
+ exports.combobox = combobox;
745
+ exports.comboboxRegistries = comboboxRegistries;
746
+ exports.registerCombobox = registerCombobox;