@vonage/vivid 3.8.0 → 3.10.0

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