@vonage/vivid 3.31.0 → 3.34.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 (237) hide show
  1. package/accordion/index.js +5 -5
  2. package/accordion-item/index.js +4 -4
  3. package/action-group/index.js +1 -1
  4. package/alert/index.js +8 -7
  5. package/avatar/index.js +2 -2
  6. package/badge/index.js +2 -2
  7. package/banner/index.js +5 -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 +3 -3
  14. package/checkbox/index.js +7 -4
  15. package/combobox/index.js +10 -9
  16. package/custom-elements.json +996 -29
  17. package/data-grid/index.js +2 -2
  18. package/date-picker/index.js +35 -0
  19. package/dialog/index.js +6 -6
  20. package/divider/index.js +1 -1
  21. package/elevation/index.js +1 -1
  22. package/empty-state/index.js +2 -2
  23. package/fab/index.js +4 -4
  24. package/file-picker/index.js +7 -6
  25. package/focus/index.js +1 -1
  26. package/header/index.js +2 -2
  27. package/icon/index.js +1 -1
  28. package/index.d.ts +1 -0
  29. package/index.js +68 -66
  30. package/layout/index.js +1 -1
  31. package/lib/button/button.d.ts +2 -0
  32. package/lib/calendar/calendar.d.ts +1 -1
  33. package/lib/components.d.ts +20 -19
  34. package/lib/date-picker/calendar/calendarGrid.d.ts +17 -0
  35. package/lib/date-picker/calendar/dateStr.d.ts +7 -0
  36. package/lib/date-picker/calendar/month.d.ts +12 -0
  37. package/lib/date-picker/calendar/monthPickerGrid.d.ts +10 -0
  38. package/lib/date-picker/calendar/presentationDate.d.ts +4 -0
  39. package/lib/date-picker/calendar/year.d.ts +2 -0
  40. package/lib/date-picker/date-picker.d.ts +18 -0
  41. package/lib/date-picker/date-picker.template.d.ts +4 -0
  42. package/lib/date-picker/definition.d.ts +3 -0
  43. package/lib/date-picker/locale.d.ts +21 -0
  44. package/lib/icon/icon.d.ts +0 -1
  45. package/lib/listbox/listbox.d.ts +9 -1
  46. package/lib/select/select.d.ts +4 -2
  47. package/lib/text-field/text-field.d.ts +1 -0
  48. package/listbox/index.js +22 -17
  49. package/locales/en-GB.d.ts +3 -0
  50. package/locales/en-GB.js +59 -0
  51. package/locales/en-US.d.ts +3 -0
  52. package/locales/en-US.js +59 -0
  53. package/locales/ja-JP.d.ts +3 -0
  54. package/locales/ja-JP.js +59 -0
  55. package/locales/zh-CN.d.ts +3 -0
  56. package/locales/zh-CN.js +59 -0
  57. package/menu/index.js +8 -8
  58. package/menu-item/index.js +4 -4
  59. package/nav/index.js +1 -1
  60. package/nav-disclosure/index.js +3 -3
  61. package/nav-item/index.js +3 -3
  62. package/note/index.js +4 -4
  63. package/number-field/index.js +8 -7
  64. package/option/index.js +5 -4
  65. package/package.json +2 -15
  66. package/pagination/index.js +5 -5
  67. package/popup/index.js +6 -6
  68. package/progress/index.js +1 -1
  69. package/progress-ring/index.js +1 -1
  70. package/radio/index.js +2 -2
  71. package/radio-group/index.js +1 -1
  72. package/select/index.js +10 -9
  73. package/shared/affix.js +25 -9
  74. package/shared/apply-mixins.js +1 -1
  75. package/shared/breadcrumb-item.js +5 -5
  76. package/shared/button.js +13 -13
  77. package/shared/calendar-event.js +36 -16
  78. package/shared/definition.js +133 -194
  79. package/shared/definition10.js +225 -40
  80. package/shared/definition11.js +36 -32
  81. package/shared/definition12.js +763 -98
  82. package/shared/definition13.js +125 -89
  83. package/shared/definition14.js +207 -27
  84. package/shared/definition15.js +710 -731
  85. package/shared/definition16.js +1289 -47
  86. package/shared/definition17.js +6113 -93
  87. package/shared/definition18.js +242 -164
  88. package/shared/definition19.js +47 -692
  89. package/shared/definition2.js +199 -117
  90. package/shared/definition20.js +59 -1671
  91. package/shared/definition21.js +95 -255
  92. package/shared/definition22.js +2218 -1167
  93. package/shared/definition23.js +57 -219
  94. package/shared/definition24.js +27 -68
  95. package/shared/definition25.js +54 -38
  96. package/shared/definition26.js +395 -70
  97. package/shared/definition27.js +381 -2223
  98. package/shared/definition28.js +85 -44
  99. package/shared/definition29.js +27 -40
  100. package/shared/definition3.js +61 -24
  101. package/shared/definition30.js +13 -427
  102. package/shared/definition31.js +49 -360
  103. package/shared/definition32.js +466 -13
  104. package/shared/definition33.js +273 -63
  105. package/shared/definition34.js +195 -25
  106. package/shared/definition35.js +86 -35
  107. package/shared/definition36.js +66 -427
  108. package/shared/definition37.js +430 -190
  109. package/shared/definition38.js +34 -52
  110. package/shared/definition39.js +683 -31
  111. package/shared/definition4.js +157 -12
  112. package/shared/definition40.js +97 -422
  113. package/shared/definition41.js +473 -543
  114. package/shared/definition42.js +122 -73
  115. package/shared/definition43.js +103 -502
  116. package/shared/definition44.js +23 -101
  117. package/shared/definition45.js +76 -126
  118. package/shared/definition46.js +494 -48
  119. package/shared/definition47.js +23 -23
  120. package/shared/definition48.js +126 -476
  121. package/shared/definition49.js +275 -98
  122. package/shared/definition5.js +71 -36
  123. package/shared/definition50.js +157 -16
  124. package/shared/definition51.js +133 -263
  125. package/shared/definition52.js +131 -115
  126. package/shared/definition53.js +85 -120
  127. package/shared/definition54.js +295 -111
  128. package/shared/definition55.js +12 -71
  129. package/shared/definition56.js +39 -295
  130. package/shared/definition57.js +181 -0
  131. package/shared/definition6.js +56 -111
  132. package/shared/definition7.js +119 -187
  133. package/shared/definition8.js +58 -23
  134. package/shared/definition9.js +92 -66
  135. package/shared/focus.js +2 -1
  136. package/shared/focus2.js +1 -1
  137. package/shared/form-associated.js +2 -2
  138. package/shared/icon.js +48 -27
  139. package/shared/index.js +7 -27
  140. package/shared/index2.js +202 -0
  141. package/shared/key-codes.js +1 -1
  142. package/shared/listbox.js +88 -11
  143. package/shared/localization/Locale.d.ts +4 -0
  144. package/shared/localization/index.d.ts +7 -0
  145. package/shared/patterns/form-elements/form-elements.d.ts +4 -4
  146. package/shared/patterns/index.d.ts +1 -0
  147. package/shared/patterns/localized.d.ts +4 -0
  148. package/shared/radio.js +23 -7
  149. package/shared/repeat.js +1 -1
  150. package/shared/text-anchor.js +21 -4
  151. package/shared/text-anchor.template.js +37 -40
  152. package/shared/text-field.js +2 -2
  153. package/shared/text-field2.js +15 -15
  154. package/shared/tree-item.js +12 -12
  155. package/side-drawer/index.js +1 -1
  156. package/slider/index.js +2 -2
  157. package/split-button/index.js +3 -3
  158. package/style.css +6097 -0
  159. package/styles/core/all.css +25 -3
  160. package/styles/core/theme.css +1 -1
  161. package/styles/core/typography.css +25 -3
  162. package/styles/tokens/theme-dark.css +4 -4
  163. package/styles/tokens/theme-light.css +4 -4
  164. package/styles/tokens/vivid-2-compat.css +2 -2
  165. package/switch/index.js +5 -4
  166. package/tab/index.js +3 -3
  167. package/tab-panel/index.js +1 -1
  168. package/tabs/index.js +5 -5
  169. package/tag/index.js +3 -3
  170. package/tag-group/index.js +1 -1
  171. package/text-anchor/index.js +1 -1
  172. package/text-area/index.js +5 -4
  173. package/text-field/index.js +5 -4
  174. package/toggletip/index.js +7 -7
  175. package/tooltip/index.js +7 -7
  176. package/tree-item/index.js +3 -3
  177. package/tree-view/index.js +1 -1
  178. package/vivid.api.json +137 -0
  179. package/lib/accordion/index.d.ts +0 -1
  180. package/lib/accordion-item/index.d.ts +0 -1
  181. package/lib/action-group/index.d.ts +0 -1
  182. package/lib/alert/index.d.ts +0 -1
  183. package/lib/avatar/index.d.ts +0 -1
  184. package/lib/badge/index.d.ts +0 -1
  185. package/lib/banner/index.d.ts +0 -1
  186. package/lib/breadcrumb/index.d.ts +0 -1
  187. package/lib/breadcrumb-item/index.d.ts +0 -1
  188. package/lib/button/index.d.ts +0 -1
  189. package/lib/calendar/index.d.ts +0 -1
  190. package/lib/calendar-event/index.d.ts +0 -1
  191. package/lib/card/index.d.ts +0 -1
  192. package/lib/checkbox/index.d.ts +0 -1
  193. package/lib/combobox/index.d.ts +0 -1
  194. package/lib/data-grid/index.d.ts +0 -1
  195. package/lib/dialog/index.d.ts +0 -1
  196. package/lib/divider/index.d.ts +0 -1
  197. package/lib/elevation/index.d.ts +0 -1
  198. package/lib/empty-state/index.d.ts +0 -1
  199. package/lib/fab/index.d.ts +0 -1
  200. package/lib/file-picker/index.d.ts +0 -1
  201. package/lib/focus/index.d.ts +0 -1
  202. package/lib/header/index.d.ts +0 -1
  203. package/lib/icon/index.d.ts +0 -1
  204. package/lib/layout/index.d.ts +0 -1
  205. package/lib/listbox/index.d.ts +0 -1
  206. package/lib/menu/index.d.ts +0 -1
  207. package/lib/menu-item/index.d.ts +0 -1
  208. package/lib/nav/index.d.ts +0 -1
  209. package/lib/nav-disclosure/index.d.ts +0 -1
  210. package/lib/nav-item/index.d.ts +0 -1
  211. package/lib/note/index.d.ts +0 -1
  212. package/lib/number-field/index.d.ts +0 -1
  213. package/lib/option/index.d.ts +0 -1
  214. package/lib/pagination/index.d.ts +0 -1
  215. package/lib/popup/index.d.ts +0 -1
  216. package/lib/progress/index.d.ts +0 -1
  217. package/lib/progress-ring/index.d.ts +0 -1
  218. package/lib/radio/index.d.ts +0 -1
  219. package/lib/radio-group/index.d.ts +0 -1
  220. package/lib/select/index.d.ts +0 -1
  221. package/lib/side-drawer/index.d.ts +0 -1
  222. package/lib/slider/index.d.ts +0 -1
  223. package/lib/split-button/index.d.ts +0 -1
  224. package/lib/switch/index.d.ts +0 -1
  225. package/lib/tab/index.d.ts +0 -1
  226. package/lib/tab-panel/index.d.ts +0 -1
  227. package/lib/tabs/index.d.ts +0 -1
  228. package/lib/tag/index.d.ts +0 -1
  229. package/lib/tag-group/index.d.ts +0 -1
  230. package/lib/text-anchor/index.d.ts +0 -1
  231. package/lib/text-area/index.d.ts +0 -1
  232. package/lib/text-field/index.d.ts +0 -1
  233. package/lib/toggletip/index.d.ts +0 -1
  234. package/lib/tooltip/index.d.ts +0 -1
  235. package/lib/tree-item/index.d.ts +0 -1
  236. package/lib/tree-view/index.d.ts +0 -1
  237. package/shared/form-elements.js +0 -162
@@ -1,723 +1,78 @@
1
- import { D 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';
2
- import { i as iconRegistries } from './definition3.js';
3
- import { P as Popup, p as popupRegistries } from './definition20.js';
4
- import { f as focusRegistries } from './definition4.js';
5
- import { l as listboxOptionRegistries } from './definition21.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';
17
- import { f as focusTemplateFactory } from './focus2.js';
18
- import { r as ref } from './ref.js';
19
- import { s as slotted } from './slotted.js';
20
- import { w as when } from './when.js';
1
+ import { F as FoundationElement, _ as __decorate, a as attr, h as html, r as registerFactory } from './index.js';
2
+ import { O as Orientation } from './aria.js';
21
3
  import { c as classNames } from './class-names.js';
22
4
 
23
- class _Combobox extends Listbox {
24
- }
25
- /**
26
- * A form-associated base class for the {@link (Combobox:class)} component.
27
- *
28
- * @internal
29
- */
30
- class FormAssociatedCombobox extends FormAssociated(_Combobox) {
31
- constructor() {
32
- super(...arguments);
33
- this.proxy = document.createElement("input");
34
- }
35
- }
36
-
37
5
  /**
38
- * Autocomplete values for combobox.
6
+ * Divider roles
39
7
  * @public
40
8
  */
41
- const ComboboxAutocomplete = {
42
- inline: "inline",
43
- list: "list",
44
- both: "both",
45
- none: "none",
9
+ const DividerRole = {
10
+ /**
11
+ * The divider semantically separates content
12
+ */
13
+ separator: "separator",
14
+ /**
15
+ * The divider has no semantic value and is for visual presentation only.
16
+ */
17
+ presentation: "presentation",
46
18
  };
47
19
 
48
20
  /**
49
- * A Combobox Custom HTML Element.
50
- * Implements the {@link https://w3c.github.io/aria-practices/#combobox | ARIA combobox }.
51
- *
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
21
+ * A Divider Custom HTML Element.
22
+ * Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#separator | ARIA separator } or {@link https://www.w3.org/TR/wai-aria-1.1/#presentation | ARIA presentation}.
62
23
  *
63
24
  * @public
64
25
  */
65
- class Combobox$1 extends FormAssociatedCombobox {
26
+ let Divider$1 = class Divider extends FoundationElement {
66
27
  constructor() {
67
28
  super(...arguments);
68
29
  /**
69
- * The internal value property.
70
- *
71
- * @internal
72
- */
73
- this._value = "";
74
- /**
75
- * The collection of currently filtered options.
30
+ * The role of the element.
76
31
  *
77
32
  * @public
33
+ * @remarks
34
+ * HTML Attribute: role
78
35
  */
79
- this.filteredOptions = [];
80
- /**
81
- * The current filter value.
82
- *
83
- * @internal
84
- */
85
- this.filter = "";
86
- /**
87
- * The initial state of the position attribute.
88
- *
89
- * @internal
90
- */
91
- this.forcedPosition = false;
92
- /**
93
- * The unique id for the internal listbox element.
94
- *
95
- * @internal
96
- */
97
- this.listboxId = uniqueId("listbox-");
98
- /**
99
- * The max height for the listbox when opened.
100
- *
101
- * @internal
102
- */
103
- this.maxHeight = 0;
36
+ this.role = DividerRole.separator;
104
37
  /**
105
- * The open attribute.
38
+ * The orientation of the divider.
106
39
  *
107
40
  * @public
108
41
  * @remarks
109
- * HTML Attribute: open
42
+ * HTML Attribute: orientation
110
43
  */
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) {
226
- return;
227
- }
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
- }
44
+ this.orientation = Orientation.horizontal;
297
45
  }
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;
377
- 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
- }
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();
406
- }
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;
480
- }
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();
565
- }
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");
581
- }
582
- }
583
- /**
584
- * @internal
585
- */
586
- clearSelectionRange() {
587
- const controlValueLength = this.control.value.length;
588
- this.control.setSelectionRange(controlValueLength, controlValueLength);
589
- }
590
- }
591
- __decorate([
592
- attr({ attribute: "autocomplete", mode: "fromView" })
593
- ], Combobox$1.prototype, "autocomplete", void 0);
594
- __decorate([
595
- observable
596
- ], Combobox$1.prototype, "maxHeight", void 0);
597
- __decorate([
598
- attr({ attribute: "open", mode: "boolean" })
599
- ], Combobox$1.prototype, "open", void 0);
46
+ };
600
47
  __decorate([
601
48
  attr
602
- ], Combobox$1.prototype, "placeholder", void 0);
603
- __decorate([
604
- attr({ attribute: "position" })
605
- ], Combobox$1.prototype, "positionAttribute", void 0);
606
- __decorate([
607
- 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);
49
+ ], Divider$1.prototype, "role", void 0);
619
50
  __decorate([
620
- observable
621
- ], DelegatesARIACombobox.prototype, "ariaControls", void 0);
622
- applyMixins(DelegatesARIACombobox, DelegatesARIAListbox);
623
- applyMixins(Combobox$1, StartEnd, DelegatesARIACombobox);
624
-
625
- var css_248z = "/**\n * Do not edit directly\n * Generated on Thu, 17 Aug 2023 11:13:18 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 /* @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}";
51
+ attr
52
+ ], Divider$1.prototype, "orientation", void 0);
626
53
 
627
- let Combobox = class Combobox extends Combobox$1 {
628
- connectedCallback() {
629
- super.connectedCallback();
630
- this._popup.anchor = this._anchor;
631
- }
632
- };
633
- __decorate([attr, __metadata("design:type", String)], Combobox.prototype, "placement", void 0);
634
- Combobox = __decorate([formElements], Combobox);
635
- applyMixins(Combobox, AffixIcon);
54
+ const styles = "/**\n * Do not edit directly\n * Generated on Mon, 04 Sep 2023 12:44:18 GMT\n */\n:host {\n display: block;\n}\n\n.base {\n display: block;\n background-color: var(--vvd-color-neutral-200);\n}\n.base:not(.vertical) {\n block-size: 1px;\n inline-size: 100%;\n}\n.base.vertical {\n block-size: 100%;\n inline-size: 1px;\n}";
636
55
 
637
- function renderLabel() {
638
- return html`
639
- <label for="control" class="label">
640
- ${x => x.label}
641
- </label>`;
642
- }
643
- const getStateClasses = ({
644
- disabled,
645
- placeholder,
646
- label
647
- }) => classNames('base', ['disabled', disabled], ['placeholder', Boolean(placeholder)], ['no-label', !label]);
648
- function renderInput(context) {
649
- const affixIconTemplate = affixIconTemplateFactory(context);
650
- const focusTemplate = focusTemplateFactory(context);
651
- return html`
652
- <div class="${getStateClasses}" ${ref('_anchor')}>
653
- ${when(x => x.label, renderLabel())}
654
- <div class="fieldset">
655
- <input
656
- id="control"
657
- class="control"
658
- aria-activedescendant="${x => x.open ? x.ariaActiveDescendant : null}"
659
- aria-autocomplete="${x => x.ariaAutoComplete}"
660
- aria-controls="${x => x.ariaControls}"
661
- aria-disabled="${x => x.ariaDisabled}"
662
- aria-expanded="${x => x.ariaExpanded}"
663
- aria-haspopup="listbox"
664
- placeholder="${x => x.placeholder}"
665
- role="combobox"
666
- type="text"
667
- ?disabled="${x => x.disabled}"
668
- :value="${x => x.value}"
669
- @input="${(x, c) => x.inputHandler(c.event)}"
670
- @keyup="${(x, c) => x.keyupHandler(c.event)}"
671
- ${ref('control')}
672
- />
673
- ${() => affixIconTemplate('chevron-down-line')}
674
- ${() => focusTemplate}
675
- </div>
676
- </div>`;
56
+ class Divider extends Divider$1 {
677
57
  }
678
- const comboboxTemplate = context => {
679
- const popupTag = context.tagFor(Popup);
680
- return html`
681
- <template
682
- aria-disabled="${x => x.ariaDisabled}"
683
- autocomplete="${x => x.autocomplete}"
684
- tabindex="${x => !x.disabled ? '0' : null}"
685
- @click="${(x, c) => x.clickHandler(c.event)}"
686
- @focusout="${(x, c) => x.focusoutHandler(c.event)}"
687
- @keydown="${(x, c) => x.keydownHandler(c.event)}"
688
- >
689
- ${() => renderInput(context)}
690
- <${popupTag} class="popup"
691
- ?open="${x => x.open}"
692
- placement="${x => x.placement}"
693
- strategy="absolute"
694
- ${ref('_popup')}>
695
- <div id="${x => x.listboxId}"
696
- class="listbox"
697
- role="listbox"
698
- ?disabled="${x => x.disabled}"
699
- ${ref('listbox')}>
700
- <slot ${slotted({
701
- filter: Listbox$1.slottedOptionFilter,
702
- flatten: true,
703
- property: 'slottedOptions'
704
- })}>
705
- </slot>
706
- </div>
707
- </${popupTag}>
708
- </template>
709
- `;
710
- };
711
58
 
712
- const combobox = Combobox.compose({
713
- baseName: 'combobox',
714
- template: comboboxTemplate,
715
- styles: [css_248z$1, css_248z],
716
- shadowOptions: {
717
- delegatesFocus: true
718
- }
719
- })();
720
- const comboboxRegistries = [combobox, ...iconRegistries, ...popupRegistries, ...focusRegistries, ...listboxOptionRegistries];
721
- const registerCombobox = registerFactory(comboboxRegistries);
59
+ const getClasses = ({ orientation }) => classNames(
60
+ "base",
61
+ [`${orientation}`, Boolean(orientation)]
62
+ );
63
+ const DividerTemplate = () => html`
64
+ <span
65
+ class="${getClasses}"
66
+ orientation="${(x) => x.orientation}"
67
+ role="${(x) => x.role}"
68
+ ></span>`;
69
+
70
+ const dividerDefinition = Divider.compose({
71
+ baseName: "divider",
72
+ template: DividerTemplate,
73
+ styles
74
+ });
75
+ const dividerRegistries = [dividerDefinition()];
76
+ const registerDivider = registerFactory(dividerRegistries);
722
77
 
723
- export { comboboxRegistries as a, combobox as c, registerCombobox as r };
78
+ export { Divider as D, dividerRegistries as a, dividerDefinition as d, registerDivider as r };