@vonage/vivid 3.0.0-next.129 → 3.0.0-next.130

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