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