@vonage/vivid 3.0.0-test.0 → 3.0.1

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 (325) hide show
  1. package/README.md +176 -4
  2. package/accordion/index.js +22 -61
  3. package/accordion-item/index.js +16 -123
  4. package/action-group/index.js +5 -0
  5. package/avatar/index.js +11 -0
  6. package/badge/index.js +9 -60
  7. package/banner/index.js +20 -208
  8. package/breadcrumb/index.js +7 -96
  9. package/breadcrumb-item/index.js +15 -48
  10. package/button/index.js +19 -758
  11. package/calendar/index.js +5 -1519
  12. package/calendar-event/index.js +9 -0
  13. package/card/index.js +13 -0
  14. package/checkbox/index.js +16 -0
  15. package/combobox/index.js +35 -0
  16. package/dialog/index.js +24 -0
  17. package/divider/index.js +6 -0
  18. package/elevation/index.js +4 -30
  19. package/fab/index.js +22 -0
  20. package/focus/index.js +4 -2
  21. package/header/index.js +6 -0
  22. package/icon/index.js +8 -32
  23. package/index.js +76 -25
  24. package/layout/index.js +4 -52
  25. package/lib/accordion/accordion.d.ts +3 -7
  26. package/lib/accordion/accordion.template.d.ts +1 -2
  27. package/lib/accordion/definition.d.ts +1 -0
  28. package/lib/accordion/index.d.ts +1 -2
  29. package/lib/accordion-item/accordion-item.d.ts +4 -8
  30. package/lib/accordion-item/accordion-item.template.d.ts +4 -4
  31. package/lib/accordion-item/definition.d.ts +1 -0
  32. package/lib/accordion-item/index.d.ts +1 -3
  33. package/lib/action-group/action-group.d.ts +10 -0
  34. package/lib/{sidenav-item/sidenav-item.template.d.ts → action-group/action-group.template.d.ts} +2 -2
  35. package/lib/action-group/definition.d.ts +1 -0
  36. package/lib/action-group/index.d.ts +1 -0
  37. package/lib/avatar/avatar.d.ts +15 -0
  38. package/lib/avatar/avatar.template.d.ts +4 -0
  39. package/lib/avatar/definition.d.ts +1 -0
  40. package/lib/avatar/index.d.ts +1 -0
  41. package/lib/badge/badge.d.ts +4 -6
  42. package/lib/badge/definition.d.ts +3 -0
  43. package/lib/badge/index.d.ts +1 -3
  44. package/lib/banner/banner.d.ts +1 -1
  45. package/lib/banner/banner.template.d.ts +0 -2
  46. package/lib/banner/definition.d.ts +1 -0
  47. package/lib/banner/index.d.ts +1 -2
  48. package/lib/breadcrumb/breadcrumb.template.d.ts +4 -0
  49. package/lib/breadcrumb/definition.d.ts +1 -0
  50. package/lib/breadcrumb/index.d.ts +1 -2
  51. package/lib/breadcrumb-item/breadcrumb-item.d.ts +1 -1
  52. package/lib/breadcrumb-item/definition.d.ts +1 -0
  53. package/lib/breadcrumb-item/index.d.ts +1 -3
  54. package/lib/button/button.d.ts +4 -3
  55. package/lib/button/definition.d.ts +1 -0
  56. package/lib/button/index.d.ts +1 -21
  57. package/lib/calendar/calendar.d.ts +3 -1
  58. package/lib/calendar/definition.d.ts +1 -0
  59. package/lib/calendar/index.d.ts +1 -3
  60. package/lib/calendar-event/calendar-event.d.ts +14 -0
  61. package/lib/calendar-event/calendar-event.template.d.ts +4 -0
  62. package/lib/calendar-event/definition.d.ts +1 -0
  63. package/lib/calendar-event/index.d.ts +1 -0
  64. package/lib/card/card.d.ts +10 -0
  65. package/lib/{text/text.template.d.ts → card/card.template.d.ts} +2 -2
  66. package/lib/card/definition.d.ts +1 -0
  67. package/lib/card/index.d.ts +1 -0
  68. package/lib/checkbox/checkbox.d.ts +5 -0
  69. package/lib/checkbox/checkbox.template.d.ts +4 -0
  70. package/lib/checkbox/definition.d.ts +1 -0
  71. package/lib/checkbox/index.d.ts +1 -0
  72. package/lib/combobox/combobox.d.ts +14 -0
  73. package/lib/combobox/combobox.template.d.ts +4 -0
  74. package/lib/combobox/definition.d.ts +3 -0
  75. package/lib/combobox/index.d.ts +1 -0
  76. package/lib/components.d.ts +44 -16
  77. package/lib/dialog/definition.d.ts +1 -0
  78. package/lib/dialog/dialog.d.ts +23 -0
  79. package/lib/dialog/dialog.template.d.ts +4 -0
  80. package/lib/dialog/index.d.ts +1 -0
  81. package/lib/divider/definition.d.ts +1 -0
  82. package/lib/divider/divider.d.ts +3 -0
  83. package/lib/divider/divider.template.d.ts +4 -0
  84. package/lib/divider/index.d.ts +1 -0
  85. package/lib/elevation/definition.d.ts +1 -0
  86. package/lib/elevation/elevation.d.ts +1 -0
  87. package/lib/elevation/index.d.ts +1 -2
  88. package/lib/enums.d.ts +20 -6
  89. package/lib/fab/definition.d.ts +3 -0
  90. package/lib/fab/fab.d.ts +13 -0
  91. package/lib/fab/fab.template.d.ts +4 -0
  92. package/lib/fab/index.d.ts +1 -0
  93. package/lib/focus/definition.d.ts +3 -0
  94. package/lib/focus/index.d.ts +1 -2
  95. package/lib/{sidenav-item/index.d.ts → header/definition.d.ts} +2 -2
  96. package/lib/header/header.d.ts +5 -0
  97. package/lib/header/header.template.d.ts +4 -0
  98. package/lib/header/index.d.ts +1 -0
  99. package/lib/icon/definition.d.ts +3 -0
  100. package/lib/icon/icon.d.ts +5 -6
  101. package/lib/icon/index.d.ts +1 -2
  102. package/lib/layout/definition.d.ts +3 -0
  103. package/lib/layout/index.d.ts +1 -2
  104. package/lib/layout/layout.d.ts +4 -4
  105. package/lib/listbox/definition.d.ts +3 -0
  106. package/lib/listbox/index.d.ts +1 -0
  107. package/lib/listbox/listbox.d.ts +6 -0
  108. package/lib/listbox/listbox.template.d.ts +4 -0
  109. package/lib/menu/definition.d.ts +11 -0
  110. package/lib/menu/index.d.ts +1 -0
  111. package/lib/menu/menu.d.ts +10 -0
  112. package/lib/menu/menu.template.d.ts +3 -0
  113. package/lib/menu-item/definition.d.ts +3 -0
  114. package/lib/menu-item/index.d.ts +1 -0
  115. package/lib/menu-item/menu-item.d.ts +8 -0
  116. package/lib/menu-item/menu-item.template.d.ts +5 -0
  117. package/lib/nav/definition.d.ts +3 -0
  118. package/lib/nav/index.d.ts +1 -0
  119. package/lib/nav/nav.d.ts +3 -0
  120. package/lib/nav/nav.template.d.ts +4 -0
  121. package/lib/nav-disclosure/definition.d.ts +3 -0
  122. package/lib/nav-disclosure/index.d.ts +1 -0
  123. package/lib/nav-disclosure/nav-disclosure.d.ts +10 -0
  124. package/lib/nav-disclosure/nav-disclosure.template.d.ts +4 -0
  125. package/lib/nav-item/definition.d.ts +3 -0
  126. package/lib/nav-item/index.d.ts +1 -0
  127. package/lib/{sidenav-item/sidenav-item.d.ts → nav-item/nav-item.d.ts} +2 -2
  128. package/lib/nav-item/nav-item.template.d.ts +4 -0
  129. package/lib/note/definition.d.ts +3 -0
  130. package/lib/note/index.d.ts +1 -0
  131. package/lib/note/note.d.ts +10 -0
  132. package/lib/note/note.template.d.ts +4 -0
  133. package/lib/number-field/definition.d.ts +4 -0
  134. package/lib/number-field/index.d.ts +1 -0
  135. package/lib/number-field/number-field.d.ts +14 -0
  136. package/lib/number-field/number-field.template.d.ts +4 -0
  137. package/lib/option/definition.d.ts +3 -0
  138. package/lib/option/index.d.ts +1 -0
  139. package/lib/option/option.d.ts +9 -0
  140. package/lib/option/option.template.d.ts +4 -0
  141. package/lib/popup/definition.d.ts +4 -0
  142. package/lib/popup/index.d.ts +1 -4
  143. package/lib/popup/popup.d.ts +8 -4
  144. package/lib/progress/definition.d.ts +3 -0
  145. package/lib/progress/index.d.ts +1 -2
  146. package/lib/progress/progress.d.ts +1 -1
  147. package/lib/progress-ring/definition.d.ts +3 -0
  148. package/lib/progress-ring/index.d.ts +1 -2
  149. package/lib/progress-ring/progress-ring.d.ts +2 -1
  150. package/lib/radio/definition.d.ts +3 -0
  151. package/lib/radio/index.d.ts +1 -0
  152. package/lib/radio/radio.d.ts +4 -0
  153. package/lib/radio/radio.template.d.ts +4 -0
  154. package/lib/radio-group/definition.d.ts +11 -0
  155. package/lib/radio-group/index.d.ts +1 -0
  156. package/lib/radio-group/radio-group.d.ts +4 -0
  157. package/lib/radio-group/radio-group.template.d.ts +4 -0
  158. package/lib/select/definition.d.ts +3 -0
  159. package/lib/select/index.d.ts +1 -0
  160. package/lib/select/select.d.ts +17 -0
  161. package/lib/select/select.template.d.ts +4 -0
  162. package/lib/side-drawer/definition.d.ts +3 -0
  163. package/lib/side-drawer/index.d.ts +1 -2
  164. package/lib/side-drawer/side-drawer.d.ts +3 -2
  165. package/lib/slider/definition.d.ts +3 -0
  166. package/lib/slider/index.d.ts +1 -0
  167. package/lib/slider/slider.d.ts +4 -0
  168. package/lib/slider/slider.template.d.ts +4 -0
  169. package/lib/switch/definition.d.ts +3 -0
  170. package/lib/switch/index.d.ts +1 -0
  171. package/lib/switch/switch.d.ts +7 -0
  172. package/lib/switch/switch.template.d.ts +4 -0
  173. package/lib/tab/definition.d.ts +3 -0
  174. package/lib/tab/index.d.ts +1 -0
  175. package/lib/tab/tab.d.ts +9 -0
  176. package/lib/tab/tab.template.d.ts +3 -0
  177. package/lib/tab-panel/definition.d.ts +3 -0
  178. package/lib/tab-panel/index.d.ts +1 -0
  179. package/lib/tab-panel/tab-panel.d.ts +3 -0
  180. package/lib/tab-panel/tab-panel.template.d.ts +2 -0
  181. package/lib/tabs/definition.d.ts +3 -0
  182. package/lib/tabs/index.d.ts +1 -0
  183. package/lib/tabs/tabs.d.ts +10 -0
  184. package/lib/tabs/tabs.template.d.ts +2 -0
  185. package/lib/text-anchor/definition.d.ts +3 -0
  186. package/lib/text-anchor/index.d.ts +1 -2
  187. package/lib/text-anchor/text-anchor.d.ts +1 -1
  188. package/lib/text-area/definition.d.ts +3 -0
  189. package/lib/text-area/index.d.ts +1 -0
  190. package/lib/text-area/text-area.d.ts +9 -0
  191. package/lib/text-area/text-area.template.d.ts +4 -0
  192. package/lib/text-field/definition.d.ts +3 -0
  193. package/lib/text-field/index.d.ts +1 -0
  194. package/lib/text-field/text-field.d.ts +14 -0
  195. package/lib/text-field/text-field.template.d.ts +4 -0
  196. package/lib/tooltip/definition.d.ts +3 -0
  197. package/lib/tooltip/index.d.ts +1 -3
  198. package/lib/tooltip/tooltip.d.ts +7 -7
  199. package/listbox/index.js +27 -0
  200. package/menu/index.js +30 -0
  201. package/menu-item/index.js +20 -0
  202. package/nav/index.js +4 -0
  203. package/nav-disclosure/index.js +17 -0
  204. package/nav-item/index.js +22 -0
  205. package/note/index.js +15 -0
  206. package/number-field/index.js +459 -0
  207. package/option/index.js +21 -0
  208. package/package.json +29 -19
  209. package/popup/index.js +21 -2061
  210. package/progress/index.js +6 -97
  211. package/progress-ring/index.js +6 -75
  212. package/radio/index.js +12 -0
  213. package/radio-group/index.js +11 -0
  214. package/select/index.js +34 -0
  215. package/shared/affix.js +2 -8
  216. package/shared/anchor.js +10 -2
  217. package/shared/apply-mixins.js +5 -4
  218. package/shared/aria-global.js +2 -86
  219. package/shared/aria.js +9 -0
  220. package/shared/base-progress.js +5 -0
  221. package/shared/breadcrumb-item.js +1 -1
  222. package/shared/button.js +200 -0
  223. package/shared/calendar-event.js +19 -0
  224. package/shared/definition.js +225 -0
  225. package/shared/definition10.js +99 -0
  226. package/shared/definition11.js +48 -0
  227. package/shared/definition12.js +1523 -0
  228. package/shared/definition13.js +111 -0
  229. package/shared/definition14.js +114 -0
  230. package/shared/definition15.js +32 -0
  231. package/shared/definition16.js +172 -0
  232. package/shared/definition17.js +727 -0
  233. package/shared/definition18.js +1842 -0
  234. package/shared/definition19.js +261 -0
  235. package/shared/definition2.js +150 -0
  236. package/shared/definition20.js +221 -0
  237. package/shared/definition21.js +78 -0
  238. package/shared/definition22.js +87 -0
  239. package/shared/definition23.js +58 -0
  240. package/shared/definition24.js +44 -0
  241. package/shared/definition25.js +58 -0
  242. package/shared/definition26.js +348 -0
  243. package/shared/definition27.js +363 -0
  244. package/shared/definition28.js +21 -0
  245. package/shared/definition29.js +75 -0
  246. package/shared/definition3.js +29 -0
  247. package/shared/definition30.js +31 -0
  248. package/shared/definition31.js +49 -0
  249. package/shared/definition32.js +94 -0
  250. package/shared/definition33.js +77 -0
  251. package/shared/definition34.js +45 -0
  252. package/shared/definition35.js +435 -0
  253. package/shared/definition36.js +634 -0
  254. package/shared/definition37.js +86 -0
  255. package/shared/definition38.js +592 -0
  256. package/shared/definition39.js +147 -0
  257. package/shared/definition4.js +19 -0
  258. package/shared/definition40.js +67 -0
  259. package/shared/definition41.js +32 -0
  260. package/shared/definition42.js +440 -0
  261. package/shared/definition43.js +282 -0
  262. package/shared/definition44.js +119 -0
  263. package/shared/definition45.js +77 -0
  264. package/shared/definition5.js +38 -0
  265. package/shared/definition6.js +60 -0
  266. package/shared/definition7.js +45 -0
  267. package/shared/definition8.js +113 -0
  268. package/shared/definition9.js +107 -0
  269. package/shared/design-system/index.d.ts +1 -1
  270. package/shared/dialog-polyfill.esm.js +858 -0
  271. package/shared/direction.js +20 -0
  272. package/shared/dom.js +8 -0
  273. package/shared/enums.js +70 -0
  274. package/shared/es.object.assign.js +2 -2
  275. package/shared/es.regexp.to-string.js +59 -0
  276. package/shared/focus.js +5 -0
  277. package/shared/focus2.js +11 -0
  278. package/shared/form-associated.js +466 -0
  279. package/shared/form-elements.js +127 -0
  280. package/shared/icon.js +538 -572
  281. package/shared/index.js +1664 -83
  282. package/shared/key-codes.js +97 -0
  283. package/shared/listbox.js +995 -0
  284. package/shared/numbers.js +34 -0
  285. package/shared/patterns/affix.d.ts +1 -1
  286. package/shared/patterns/focus.d.ts +3 -0
  287. package/shared/patterns/form-elements/form-elements.d.ts +43 -0
  288. package/shared/patterns/form-elements/index.d.ts +1 -0
  289. package/shared/patterns/index.d.ts +2 -0
  290. package/shared/radio.js +127 -0
  291. package/shared/ref.js +41 -0
  292. package/shared/select.options.js +10 -0
  293. package/shared/start-end.js +50 -0
  294. package/shared/string-trim.js +40 -0
  295. package/shared/strings.js +9 -0
  296. package/shared/text-anchor.js +2 -13
  297. package/shared/text-anchor.template.js +6 -5
  298. package/shared/text-field.js +3 -0
  299. package/shared/text-field2.js +225 -0
  300. package/shared/to-string.js +51 -0
  301. package/side-drawer/index.js +5 -80
  302. package/slider/index.js +17 -0
  303. package/styles/core/all.css +83 -0
  304. package/styles/core/theme.css +11 -0
  305. package/styles/core/typography.css +77 -0
  306. package/styles/tokens/theme-dark.css +228 -0
  307. package/styles/tokens/theme-light.css +228 -0
  308. package/switch/index.js +18 -0
  309. package/tab/index.js +16 -0
  310. package/tab-panel/index.js +4 -0
  311. package/tabs/index.js +24 -0
  312. package/text-anchor/index.js +11 -5
  313. package/text-area/index.js +23 -0
  314. package/text-field/index.js +24 -0
  315. package/tooltip/index.js +18 -57
  316. package/lib/text/index.d.ts +0 -2
  317. package/lib/text/text.d.ts +0 -10
  318. package/shared/index2.js +0 -21
  319. package/shared/style-inject.es.js +0 -28
  320. package/shared/web.dom-collections.iterator.js +0 -1479
  321. package/sidenav-item/index.js +0 -38
  322. package/styles/fonts/spezia.css +0 -23
  323. package/styles/themes/dark.css +0 -205
  324. package/styles/themes/light.css +0 -205
  325. package/text/index.js +0 -45
@@ -0,0 +1,995 @@
1
+ import { F as FoundationElement, O as Observable, _ as __decorate, a as attr, o as observable, W as DOM, n as nullableNumberConverter, b as __metadata } from './index.js';
2
+ import { i as isListboxOption } from './definition19.js';
3
+ import { A as ARIAGlobalStatesAndProperties } from './aria-global.js';
4
+ import { a as applyMixins } from './apply-mixins.js';
5
+ import { e as keySpace, f as keyEscape, d as keyEnter, g as keyTab, k as keyEnd, c as keyArrowUp, b as keyArrowDown, a as keyHome } from './key-codes.js';
6
+ import { u as uniqueId } from './strings.js';
7
+ import { i as inRange } from './numbers.js';
8
+
9
+ /**
10
+ * Returns the index of the last element in the array where predicate is true, and -1 otherwise.
11
+ *
12
+ * @param array - the array to test
13
+ * @param predicate - find calls predicate once for each element of the array, in descending order, until it finds one where predicate returns true. If such an element is found, findLastIndex immediately returns that element index. Otherwise, findIndex returns -1.
14
+ */
15
+ function findLastIndex(array, predicate) {
16
+ let k = array.length;
17
+ while (k--) {
18
+ if (predicate(array[k], k, array)) {
19
+ return k;
20
+ }
21
+ }
22
+ return -1;
23
+ }
24
+
25
+ /**
26
+ * A Listbox Custom HTML Element.
27
+ * Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#listbox | ARIA listbox }.
28
+ *
29
+ * @slot - The default slot for the listbox options
30
+ *
31
+ * @public
32
+ */
33
+ class Listbox$1 extends FoundationElement {
34
+ constructor() {
35
+ super(...arguments);
36
+ /**
37
+ * The internal unfiltered list of selectable options.
38
+ *
39
+ * @internal
40
+ */
41
+ this._options = [];
42
+ /**
43
+ * The index of the selected option.
44
+ *
45
+ * @public
46
+ */
47
+ this.selectedIndex = -1;
48
+ /**
49
+ * A collection of the selected options.
50
+ *
51
+ * @public
52
+ */
53
+ this.selectedOptions = [];
54
+ /**
55
+ * A standard `click` event creates a `focus` event before firing, so a
56
+ * `mousedown` event is used to skip that initial focus.
57
+ *
58
+ * @internal
59
+ */
60
+ this.shouldSkipFocus = false;
61
+ /**
62
+ * The current typeahead buffer string.
63
+ *
64
+ * @internal
65
+ */
66
+ this.typeaheadBuffer = "";
67
+ /**
68
+ * Flag for the typeahead timeout expiration.
69
+ *
70
+ * @internal
71
+ */
72
+ this.typeaheadExpired = true;
73
+ /**
74
+ * The timeout ID for the typeahead handler.
75
+ *
76
+ * @internal
77
+ */
78
+ this.typeaheadTimeout = -1;
79
+ }
80
+ /**
81
+ * The first selected option.
82
+ *
83
+ * @internal
84
+ */
85
+ get firstSelectedOption() {
86
+ var _a;
87
+ return (_a = this.selectedOptions[0]) !== null && _a !== void 0 ? _a : null;
88
+ }
89
+ /**
90
+ * Returns true if there is one or more selectable option.
91
+ *
92
+ * @internal
93
+ */
94
+ get hasSelectableOptions() {
95
+ return this.options.length > 0 && !this.options.every(o => o.disabled);
96
+ }
97
+ /**
98
+ * The number of options.
99
+ *
100
+ * @public
101
+ */
102
+ get length() {
103
+ var _a, _b;
104
+ return (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
105
+ }
106
+ /**
107
+ * The list of options.
108
+ *
109
+ * @public
110
+ */
111
+ get options() {
112
+ Observable.track(this, "options");
113
+ return this._options;
114
+ }
115
+ set options(value) {
116
+ this._options = value;
117
+ Observable.notify(this, "options");
118
+ }
119
+ /**
120
+ * Flag for the typeahead timeout expiration.
121
+ *
122
+ * @deprecated use `Listbox.typeaheadExpired`
123
+ * @internal
124
+ */
125
+ get typeAheadExpired() {
126
+ return this.typeaheadExpired;
127
+ }
128
+ set typeAheadExpired(value) {
129
+ this.typeaheadExpired = value;
130
+ }
131
+ /**
132
+ * Handle click events for listbox options.
133
+ *
134
+ * @internal
135
+ */
136
+ clickHandler(e) {
137
+ const captured = e.target.closest(`option,[role=option]`);
138
+ if (captured && !captured.disabled) {
139
+ this.selectedIndex = this.options.indexOf(captured);
140
+ return true;
141
+ }
142
+ }
143
+ /**
144
+ * Ensures that the provided option is focused and scrolled into view.
145
+ *
146
+ * @param optionToFocus - The option to focus
147
+ * @internal
148
+ */
149
+ focusAndScrollOptionIntoView(optionToFocus = this.firstSelectedOption) {
150
+ // To ensure that the browser handles both `focus()` and `scrollIntoView()`, the
151
+ // timing here needs to guarantee that they happen on different frames. Since this
152
+ // function is typically called from the `openChanged` observer, `DOM.queueUpdate`
153
+ // causes the calls to be grouped into the same frame. To prevent this,
154
+ // `requestAnimationFrame` is used instead of `DOM.queueUpdate`.
155
+ if (this.contains(document.activeElement) && optionToFocus !== null) {
156
+ optionToFocus.focus();
157
+ requestAnimationFrame(() => {
158
+ optionToFocus.scrollIntoView({ block: "nearest" });
159
+ });
160
+ }
161
+ }
162
+ /**
163
+ * Handles `focusin` actions for the component. When the component receives focus,
164
+ * the list of selected options is refreshed and the first selected option is scrolled
165
+ * into view.
166
+ *
167
+ * @internal
168
+ */
169
+ focusinHandler(e) {
170
+ if (!this.shouldSkipFocus && e.target === e.currentTarget) {
171
+ this.setSelectedOptions();
172
+ this.focusAndScrollOptionIntoView();
173
+ }
174
+ this.shouldSkipFocus = false;
175
+ }
176
+ /**
177
+ * Returns the options which match the current typeahead buffer.
178
+ *
179
+ * @internal
180
+ */
181
+ getTypeaheadMatches() {
182
+ const pattern = this.typeaheadBuffer.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&");
183
+ const re = new RegExp(`^${pattern}`, "gi");
184
+ return this.options.filter((o) => o.text.trim().match(re));
185
+ }
186
+ /**
187
+ * Determines the index of the next option which is selectable, if any.
188
+ *
189
+ * @param prev - the previous selected index
190
+ * @param next - the next index to select
191
+ *
192
+ * @internal
193
+ */
194
+ getSelectableIndex(prev = this.selectedIndex, next) {
195
+ const direction = prev > next ? -1 : prev < next ? 1 : 0;
196
+ const potentialDirection = prev + direction;
197
+ let nextSelectableOption = null;
198
+ switch (direction) {
199
+ case -1: {
200
+ nextSelectableOption = this.options.reduceRight((nextSelectableOption, thisOption, index) => !nextSelectableOption &&
201
+ !thisOption.disabled &&
202
+ index < potentialDirection
203
+ ? thisOption
204
+ : nextSelectableOption, nextSelectableOption);
205
+ break;
206
+ }
207
+ case 1: {
208
+ nextSelectableOption = this.options.reduce((nextSelectableOption, thisOption, index) => !nextSelectableOption &&
209
+ !thisOption.disabled &&
210
+ index > potentialDirection
211
+ ? thisOption
212
+ : nextSelectableOption, nextSelectableOption);
213
+ break;
214
+ }
215
+ }
216
+ return this.options.indexOf(nextSelectableOption);
217
+ }
218
+ /**
219
+ * Handles external changes to child options.
220
+ *
221
+ * @param source - the source object
222
+ * @param propertyName - the property
223
+ *
224
+ * @internal
225
+ */
226
+ handleChange(source, propertyName) {
227
+ switch (propertyName) {
228
+ case "selected": {
229
+ if (Listbox$1.slottedOptionFilter(source)) {
230
+ this.selectedIndex = this.options.indexOf(source);
231
+ }
232
+ this.setSelectedOptions();
233
+ break;
234
+ }
235
+ }
236
+ }
237
+ /**
238
+ * Moves focus to an option whose label matches characters typed by the user.
239
+ * Consecutive keystrokes are batched into a buffer of search text used
240
+ * to match against the set of options. If `TYPE_AHEAD_TIMEOUT_MS` passes
241
+ * between consecutive keystrokes, the search restarts.
242
+ *
243
+ * @param key - the key to be evaluated
244
+ *
245
+ * @internal
246
+ */
247
+ handleTypeAhead(key) {
248
+ if (this.typeaheadTimeout) {
249
+ window.clearTimeout(this.typeaheadTimeout);
250
+ }
251
+ this.typeaheadTimeout = window.setTimeout(() => (this.typeaheadExpired = true), Listbox$1.TYPE_AHEAD_TIMEOUT_MS);
252
+ if (key.length > 1) {
253
+ return;
254
+ }
255
+ this.typeaheadBuffer = `${this.typeaheadExpired ? "" : this.typeaheadBuffer}${key}`;
256
+ }
257
+ /**
258
+ * Handles `keydown` actions for listbox navigation and typeahead.
259
+ *
260
+ * @internal
261
+ */
262
+ keydownHandler(e) {
263
+ if (this.disabled) {
264
+ return true;
265
+ }
266
+ this.shouldSkipFocus = false;
267
+ const key = e.key;
268
+ switch (key) {
269
+ // Select the first available option
270
+ case keyHome: {
271
+ if (!e.shiftKey) {
272
+ e.preventDefault();
273
+ this.selectFirstOption();
274
+ }
275
+ break;
276
+ }
277
+ // Select the next selectable option
278
+ case keyArrowDown: {
279
+ if (!e.shiftKey) {
280
+ e.preventDefault();
281
+ this.selectNextOption();
282
+ }
283
+ break;
284
+ }
285
+ // Select the previous selectable option
286
+ case keyArrowUp: {
287
+ if (!e.shiftKey) {
288
+ e.preventDefault();
289
+ this.selectPreviousOption();
290
+ }
291
+ break;
292
+ }
293
+ // Select the last available option
294
+ case keyEnd: {
295
+ e.preventDefault();
296
+ this.selectLastOption();
297
+ break;
298
+ }
299
+ case keyTab: {
300
+ this.focusAndScrollOptionIntoView();
301
+ return true;
302
+ }
303
+ case keyEnter:
304
+ case keyEscape: {
305
+ return true;
306
+ }
307
+ case keySpace: {
308
+ if (this.typeaheadExpired) {
309
+ return true;
310
+ }
311
+ }
312
+ // Send key to Typeahead handler
313
+ default: {
314
+ if (key.length === 1) {
315
+ this.handleTypeAhead(`${key}`);
316
+ }
317
+ return true;
318
+ }
319
+ }
320
+ }
321
+ /**
322
+ * Prevents `focusin` events from firing before `click` events when the
323
+ * element is unfocused.
324
+ *
325
+ * @internal
326
+ */
327
+ mousedownHandler(e) {
328
+ this.shouldSkipFocus = !this.contains(document.activeElement);
329
+ return true;
330
+ }
331
+ /**
332
+ * Switches between single-selection and multi-selection mode.
333
+ *
334
+ * @param prev - the previous value of the `multiple` attribute
335
+ * @param next - the next value of the `multiple` attribute
336
+ *
337
+ * @internal
338
+ */
339
+ multipleChanged(prev, next) {
340
+ this.ariaMultiSelectable = next ? "true" : null;
341
+ }
342
+ /**
343
+ * Updates the list of selected options when the `selectedIndex` changes.
344
+ *
345
+ * @param prev - the previous selected index value
346
+ * @param next - the current selected index value
347
+ *
348
+ * @internal
349
+ */
350
+ selectedIndexChanged(prev, next) {
351
+ var _a;
352
+ if (!this.hasSelectableOptions) {
353
+ this.selectedIndex = -1;
354
+ return;
355
+ }
356
+ if (((_a = this.options[this.selectedIndex]) === null || _a === void 0 ? void 0 : _a.disabled) && typeof prev === "number") {
357
+ const selectableIndex = this.getSelectableIndex(prev, next);
358
+ const newNext = selectableIndex > -1 ? selectableIndex : prev;
359
+ this.selectedIndex = newNext;
360
+ if (next === newNext) {
361
+ this.selectedIndexChanged(next, newNext);
362
+ }
363
+ return;
364
+ }
365
+ this.setSelectedOptions();
366
+ }
367
+ /**
368
+ * Updates the selectedness of each option when the list of selected options changes.
369
+ *
370
+ * @param prev - the previous list of selected options
371
+ * @param next - the current list of selected options
372
+ *
373
+ * @internal
374
+ */
375
+ selectedOptionsChanged(prev, next) {
376
+ var _a;
377
+ const filteredNext = next.filter(Listbox$1.slottedOptionFilter);
378
+ (_a = this.options) === null || _a === void 0 ? void 0 : _a.forEach(o => {
379
+ const notifier = Observable.getNotifier(o);
380
+ notifier.unsubscribe(this, "selected");
381
+ o.selected = filteredNext.includes(o);
382
+ notifier.subscribe(this, "selected");
383
+ });
384
+ }
385
+ /**
386
+ * Moves focus to the first selectable option.
387
+ *
388
+ * @public
389
+ */
390
+ selectFirstOption() {
391
+ var _a, _b;
392
+ if (!this.disabled) {
393
+ this.selectedIndex = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.findIndex(o => !o.disabled)) !== null && _b !== void 0 ? _b : -1;
394
+ }
395
+ }
396
+ /**
397
+ * Moves focus to the last selectable option.
398
+ *
399
+ * @internal
400
+ */
401
+ selectLastOption() {
402
+ if (!this.disabled) {
403
+ this.selectedIndex = findLastIndex(this.options, o => !o.disabled);
404
+ }
405
+ }
406
+ /**
407
+ * Moves focus to the next selectable option.
408
+ *
409
+ * @internal
410
+ */
411
+ selectNextOption() {
412
+ if (!this.disabled && this.selectedIndex < this.options.length - 1) {
413
+ this.selectedIndex += 1;
414
+ }
415
+ }
416
+ /**
417
+ * Moves focus to the previous selectable option.
418
+ *
419
+ * @internal
420
+ */
421
+ selectPreviousOption() {
422
+ if (!this.disabled && this.selectedIndex > 0) {
423
+ this.selectedIndex = this.selectedIndex - 1;
424
+ }
425
+ }
426
+ /**
427
+ * Updates the selected index to match the first selected option.
428
+ *
429
+ * @internal
430
+ */
431
+ setDefaultSelectedOption() {
432
+ var _a, _b;
433
+ this.selectedIndex = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.findIndex(el => el.defaultSelected)) !== null && _b !== void 0 ? _b : -1;
434
+ }
435
+ /**
436
+ * Sets an option as selected and gives it focus.
437
+ *
438
+ * @public
439
+ */
440
+ setSelectedOptions() {
441
+ var _a, _b, _c;
442
+ if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.length) {
443
+ this.selectedOptions = [this.options[this.selectedIndex]];
444
+ this.ariaActiveDescendant = (_c = (_b = this.firstSelectedOption) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : "";
445
+ this.focusAndScrollOptionIntoView();
446
+ }
447
+ }
448
+ /**
449
+ * Updates the list of options and resets the selected option when the slotted option content changes.
450
+ *
451
+ * @param prev - the previous list of slotted options
452
+ * @param next - the current list of slotted options
453
+ *
454
+ * @internal
455
+ */
456
+ slottedOptionsChanged(prev, next) {
457
+ this.options = next.reduce((options, item) => {
458
+ if (isListboxOption(item)) {
459
+ options.push(item);
460
+ }
461
+ return options;
462
+ }, []);
463
+ const setSize = `${this.options.length}`;
464
+ this.options.forEach((option, index) => {
465
+ if (!option.id) {
466
+ option.id = uniqueId("option-");
467
+ }
468
+ option.ariaPosInSet = `${index + 1}`;
469
+ option.ariaSetSize = setSize;
470
+ });
471
+ if (this.$fastController.isConnected) {
472
+ this.setSelectedOptions();
473
+ this.setDefaultSelectedOption();
474
+ }
475
+ }
476
+ /**
477
+ * Updates the filtered list of options when the typeahead buffer changes.
478
+ *
479
+ * @param prev - the previous typeahead buffer value
480
+ * @param next - the current typeahead buffer value
481
+ *
482
+ * @internal
483
+ */
484
+ typeaheadBufferChanged(prev, next) {
485
+ if (this.$fastController.isConnected) {
486
+ const typeaheadMatches = this.getTypeaheadMatches();
487
+ if (typeaheadMatches.length) {
488
+ const selectedIndex = this.options.indexOf(typeaheadMatches[0]);
489
+ if (selectedIndex > -1) {
490
+ this.selectedIndex = selectedIndex;
491
+ }
492
+ }
493
+ this.typeaheadExpired = false;
494
+ }
495
+ }
496
+ }
497
+ /**
498
+ * A static filter to include only selectable options.
499
+ *
500
+ * @param n - element to filter
501
+ * @public
502
+ */
503
+ Listbox$1.slottedOptionFilter = (n) => isListboxOption(n) && !n.hidden;
504
+ /**
505
+ * Typeahead timeout in milliseconds.
506
+ *
507
+ * @internal
508
+ */
509
+ Listbox$1.TYPE_AHEAD_TIMEOUT_MS = 1000;
510
+ __decorate([
511
+ attr({ mode: "boolean" })
512
+ ], Listbox$1.prototype, "disabled", void 0);
513
+ __decorate([
514
+ observable
515
+ ], Listbox$1.prototype, "selectedIndex", void 0);
516
+ __decorate([
517
+ observable
518
+ ], Listbox$1.prototype, "selectedOptions", void 0);
519
+ __decorate([
520
+ observable
521
+ ], Listbox$1.prototype, "slottedOptions", void 0);
522
+ __decorate([
523
+ observable
524
+ ], Listbox$1.prototype, "typeaheadBuffer", void 0);
525
+ /**
526
+ * Includes ARIA states and properties relating to the ARIA listbox role
527
+ *
528
+ * @public
529
+ */
530
+ class DelegatesARIAListbox {
531
+ }
532
+ __decorate([
533
+ observable
534
+ ], DelegatesARIAListbox.prototype, "ariaActiveDescendant", void 0);
535
+ __decorate([
536
+ observable
537
+ ], DelegatesARIAListbox.prototype, "ariaDisabled", void 0);
538
+ __decorate([
539
+ observable
540
+ ], DelegatesARIAListbox.prototype, "ariaExpanded", void 0);
541
+ __decorate([
542
+ observable
543
+ ], DelegatesARIAListbox.prototype, "ariaMultiSelectable", void 0);
544
+ applyMixins(DelegatesARIAListbox, ARIAGlobalStatesAndProperties);
545
+ applyMixins(Listbox$1, DelegatesARIAListbox);
546
+
547
+ /**
548
+ * A Listbox Custom HTML Element.
549
+ * Implements the {@link https://w3c.github.io/aria/#listbox | ARIA listbox }.
550
+ *
551
+ * @public
552
+ */
553
+ class ListboxElement extends Listbox$1 {
554
+ constructor() {
555
+ super(...arguments);
556
+ /**
557
+ * The index of the most recently checked option.
558
+ *
559
+ * @internal
560
+ * @remarks
561
+ * Multiple-selection mode only.
562
+ */
563
+ this.activeIndex = -1;
564
+ /**
565
+ * The start index when checking a range of options.
566
+ *
567
+ * @internal
568
+ */
569
+ this.rangeStartIndex = -1;
570
+ }
571
+ /**
572
+ * Returns the last checked option.
573
+ *
574
+ * @internal
575
+ */
576
+ get activeOption() {
577
+ return this.options[this.activeIndex];
578
+ }
579
+ /**
580
+ * Returns the list of checked options.
581
+ *
582
+ * @internal
583
+ */
584
+ get checkedOptions() {
585
+ var _a;
586
+ return (_a = this.options) === null || _a === void 0 ? void 0 : _a.filter(o => o.checked);
587
+ }
588
+ /**
589
+ * Returns the index of the first selected option.
590
+ *
591
+ * @internal
592
+ */
593
+ get firstSelectedOptionIndex() {
594
+ return this.options.indexOf(this.firstSelectedOption);
595
+ }
596
+ /**
597
+ * Updates the `ariaActiveDescendant` property when the active index changes.
598
+ *
599
+ * @param prev - the previous active index
600
+ * @param next - the next active index
601
+ *
602
+ * @internal
603
+ */
604
+ activeIndexChanged(prev, next) {
605
+ var _a, _b;
606
+ this.ariaActiveDescendant = (_b = (_a = this.options[next]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : "";
607
+ this.focusAndScrollOptionIntoView();
608
+ }
609
+ /**
610
+ * Toggles the checked state for the currently active option.
611
+ *
612
+ * @remarks
613
+ * Multiple-selection mode only.
614
+ *
615
+ * @internal
616
+ */
617
+ checkActiveIndex() {
618
+ if (!this.multiple) {
619
+ return;
620
+ }
621
+ const activeItem = this.activeOption;
622
+ if (activeItem) {
623
+ activeItem.checked = true;
624
+ }
625
+ }
626
+ /**
627
+ * Sets the active index to the first option and marks it as checked.
628
+ *
629
+ * @remarks
630
+ * Multi-selection mode only.
631
+ *
632
+ * @param preserveChecked - mark all options unchecked before changing the active index
633
+ *
634
+ * @internal
635
+ */
636
+ checkFirstOption(preserveChecked = false) {
637
+ if (preserveChecked) {
638
+ if (this.rangeStartIndex === -1) {
639
+ this.rangeStartIndex = this.activeIndex + 1;
640
+ }
641
+ this.options.forEach((o, i) => {
642
+ o.checked = inRange(i, this.rangeStartIndex);
643
+ });
644
+ }
645
+ else {
646
+ this.uncheckAllOptions();
647
+ }
648
+ this.activeIndex = 0;
649
+ this.checkActiveIndex();
650
+ }
651
+ /**
652
+ * Decrements the active index and sets the matching option as checked.
653
+ *
654
+ * @remarks
655
+ * Multi-selection mode only.
656
+ *
657
+ * @param preserveChecked - mark all options unchecked before changing the active index
658
+ *
659
+ * @internal
660
+ */
661
+ checkLastOption(preserveChecked = false) {
662
+ if (preserveChecked) {
663
+ if (this.rangeStartIndex === -1) {
664
+ this.rangeStartIndex = this.activeIndex;
665
+ }
666
+ this.options.forEach((o, i) => {
667
+ o.checked = inRange(i, this.rangeStartIndex, this.options.length);
668
+ });
669
+ }
670
+ else {
671
+ this.uncheckAllOptions();
672
+ }
673
+ this.activeIndex = this.options.length - 1;
674
+ this.checkActiveIndex();
675
+ }
676
+ /**
677
+ * @override
678
+ * @internal
679
+ */
680
+ connectedCallback() {
681
+ super.connectedCallback();
682
+ this.addEventListener("focusout", this.focusoutHandler);
683
+ }
684
+ /**
685
+ * @override
686
+ * @internal
687
+ */
688
+ disconnectedCallback() {
689
+ this.removeEventListener("focusout", this.focusoutHandler);
690
+ super.disconnectedCallback();
691
+ }
692
+ /**
693
+ * Increments the active index and marks the matching option as checked.
694
+ *
695
+ * @remarks
696
+ * Multiple-selection mode only.
697
+ *
698
+ * @param preserveChecked - mark all options unchecked before changing the active index
699
+ *
700
+ * @internal
701
+ */
702
+ checkNextOption(preserveChecked = false) {
703
+ if (preserveChecked) {
704
+ if (this.rangeStartIndex === -1) {
705
+ this.rangeStartIndex = this.activeIndex;
706
+ }
707
+ this.options.forEach((o, i) => {
708
+ o.checked = inRange(i, this.rangeStartIndex, this.activeIndex + 1);
709
+ });
710
+ }
711
+ else {
712
+ this.uncheckAllOptions();
713
+ }
714
+ this.activeIndex += this.activeIndex < this.options.length - 1 ? 1 : 0;
715
+ this.checkActiveIndex();
716
+ }
717
+ /**
718
+ * Decrements the active index and marks the matching option as checked.
719
+ *
720
+ * @remarks
721
+ * Multiple-selection mode only.
722
+ *
723
+ * @param preserveChecked - mark all options unchecked before changing the active index
724
+ *
725
+ * @internal
726
+ */
727
+ checkPreviousOption(preserveChecked = false) {
728
+ if (preserveChecked) {
729
+ if (this.rangeStartIndex === -1) {
730
+ this.rangeStartIndex = this.activeIndex;
731
+ }
732
+ if (this.checkedOptions.length === 1) {
733
+ this.rangeStartIndex += 1;
734
+ }
735
+ this.options.forEach((o, i) => {
736
+ o.checked = inRange(i, this.activeIndex, this.rangeStartIndex);
737
+ });
738
+ }
739
+ else {
740
+ this.uncheckAllOptions();
741
+ }
742
+ this.activeIndex -= this.activeIndex > 0 ? 1 : 0;
743
+ this.checkActiveIndex();
744
+ }
745
+ /**
746
+ * Handles click events for listbox options.
747
+ *
748
+ * @param e - the event object
749
+ *
750
+ * @override
751
+ * @internal
752
+ */
753
+ clickHandler(e) {
754
+ var _a;
755
+ if (!this.multiple) {
756
+ return super.clickHandler(e);
757
+ }
758
+ const captured = (_a = e.target) === null || _a === void 0 ? void 0 : _a.closest(`[role=option]`);
759
+ if (!captured || captured.disabled) {
760
+ return;
761
+ }
762
+ this.uncheckAllOptions();
763
+ this.activeIndex = this.options.indexOf(captured);
764
+ this.checkActiveIndex();
765
+ this.toggleSelectedForAllCheckedOptions();
766
+ return true;
767
+ }
768
+ /**
769
+ * @override
770
+ * @internal
771
+ */
772
+ focusAndScrollOptionIntoView() {
773
+ super.focusAndScrollOptionIntoView(this.activeOption);
774
+ }
775
+ /**
776
+ * In multiple-selection mode:
777
+ * If any options are selected, the first selected option is checked when
778
+ * the listbox receives focus. If no options are selected, the first
779
+ * selectable option is checked.
780
+ *
781
+ * @override
782
+ * @internal
783
+ */
784
+ focusinHandler(e) {
785
+ if (!this.multiple) {
786
+ return super.focusinHandler(e);
787
+ }
788
+ if (!this.shouldSkipFocus && e.target === e.currentTarget) {
789
+ this.uncheckAllOptions();
790
+ if (this.activeIndex === -1) {
791
+ this.activeIndex =
792
+ this.firstSelectedOptionIndex !== -1
793
+ ? this.firstSelectedOptionIndex
794
+ : 0;
795
+ }
796
+ this.checkActiveIndex();
797
+ this.setSelectedOptions();
798
+ this.focusAndScrollOptionIntoView();
799
+ }
800
+ this.shouldSkipFocus = false;
801
+ }
802
+ /**
803
+ * Unchecks all options when the listbox loses focus.
804
+ *
805
+ * @internal
806
+ */
807
+ focusoutHandler(e) {
808
+ if (this.multiple) {
809
+ this.uncheckAllOptions();
810
+ }
811
+ }
812
+ /**
813
+ * Handles keydown actions for listbox navigation and typeahead
814
+ *
815
+ * @override
816
+ * @internal
817
+ */
818
+ keydownHandler(e) {
819
+ if (!this.multiple) {
820
+ return super.keydownHandler(e);
821
+ }
822
+ if (this.disabled) {
823
+ return true;
824
+ }
825
+ const { key, shiftKey } = e;
826
+ this.shouldSkipFocus = false;
827
+ switch (key) {
828
+ // Select the first available option
829
+ case keyHome: {
830
+ this.checkFirstOption(shiftKey);
831
+ return;
832
+ }
833
+ // Select the next selectable option
834
+ case keyArrowDown: {
835
+ this.checkNextOption(shiftKey);
836
+ return;
837
+ }
838
+ // Select the previous selectable option
839
+ case keyArrowUp: {
840
+ this.checkPreviousOption(shiftKey);
841
+ return;
842
+ }
843
+ // Select the last available option
844
+ case keyEnd: {
845
+ this.checkLastOption(shiftKey);
846
+ return;
847
+ }
848
+ case keyTab: {
849
+ this.focusAndScrollOptionIntoView();
850
+ return true;
851
+ }
852
+ case keyEscape: {
853
+ this.uncheckAllOptions();
854
+ this.checkActiveIndex();
855
+ return true;
856
+ }
857
+ case keySpace: {
858
+ e.preventDefault();
859
+ if (this.typeAheadExpired) {
860
+ this.toggleSelectedForAllCheckedOptions();
861
+ return;
862
+ }
863
+ }
864
+ // Send key to Typeahead handler
865
+ default: {
866
+ if (key.length === 1) {
867
+ this.handleTypeAhead(`${key}`);
868
+ }
869
+ return true;
870
+ }
871
+ }
872
+ }
873
+ /**
874
+ * Prevents `focusin` events from firing before `click` events when the
875
+ * element is unfocused.
876
+ *
877
+ * @override
878
+ * @internal
879
+ */
880
+ mousedownHandler(e) {
881
+ if (e.offsetX >= 0 && e.offsetX <= this.scrollWidth) {
882
+ return super.mousedownHandler(e);
883
+ }
884
+ }
885
+ /**
886
+ * Switches between single-selection and multi-selection mode.
887
+ *
888
+ * @internal
889
+ */
890
+ multipleChanged(prev, next) {
891
+ var _a;
892
+ this.ariaMultiSelectable = next ? "true" : null;
893
+ (_a = this.options) === null || _a === void 0 ? void 0 : _a.forEach(o => {
894
+ o.checked = next ? false : undefined;
895
+ });
896
+ this.setSelectedOptions();
897
+ }
898
+ /**
899
+ * Sets an option as selected and gives it focus.
900
+ *
901
+ * @override
902
+ * @public
903
+ */
904
+ setSelectedOptions() {
905
+ if (!this.multiple) {
906
+ super.setSelectedOptions();
907
+ return;
908
+ }
909
+ if (this.$fastController.isConnected && this.options) {
910
+ this.selectedOptions = this.options.filter(o => o.selected);
911
+ this.focusAndScrollOptionIntoView();
912
+ }
913
+ }
914
+ /**
915
+ * Ensures the size is a positive integer when the property is updated.
916
+ *
917
+ * @param prev - the previous size value
918
+ * @param next - the current size value
919
+ *
920
+ * @internal
921
+ */
922
+ sizeChanged(prev, next) {
923
+ var _a;
924
+ const size = Math.max(0, parseInt((_a = next === null || next === void 0 ? void 0 : next.toFixed()) !== null && _a !== void 0 ? _a : "", 10));
925
+ if (size !== next) {
926
+ DOM.queueUpdate(() => {
927
+ this.size = size;
928
+ });
929
+ }
930
+ }
931
+ /**
932
+ * Toggles the selected state of the provided options. If any provided items
933
+ * are in an unselected state, all items are set to selected. If every
934
+ * provided item is selected, they are all unselected.
935
+ *
936
+ * @internal
937
+ */
938
+ toggleSelectedForAllCheckedOptions() {
939
+ const enabledCheckedOptions = this.checkedOptions.filter(o => !o.disabled);
940
+ const force = !enabledCheckedOptions.every(o => o.selected);
941
+ enabledCheckedOptions.forEach(o => (o.selected = force));
942
+ this.selectedIndex = this.options.indexOf(enabledCheckedOptions[enabledCheckedOptions.length - 1]);
943
+ this.setSelectedOptions();
944
+ }
945
+ /**
946
+ * @override
947
+ * @internal
948
+ */
949
+ typeaheadBufferChanged(prev, next) {
950
+ if (!this.multiple) {
951
+ super.typeaheadBufferChanged(prev, next);
952
+ return;
953
+ }
954
+ if (this.$fastController.isConnected) {
955
+ const typeaheadMatches = this.getTypeaheadMatches();
956
+ const activeIndex = this.options.indexOf(typeaheadMatches[0]);
957
+ if (activeIndex > -1) {
958
+ this.activeIndex = activeIndex;
959
+ this.uncheckAllOptions();
960
+ this.checkActiveIndex();
961
+ }
962
+ this.typeAheadExpired = false;
963
+ }
964
+ }
965
+ /**
966
+ * Unchecks all options.
967
+ *
968
+ * @remarks
969
+ * Multiple-selection mode only.
970
+ *
971
+ * @param preserveChecked - reset the rangeStartIndex
972
+ *
973
+ * @internal
974
+ */
975
+ uncheckAllOptions(preserveChecked = false) {
976
+ this.options.forEach(o => (o.checked = this.multiple ? false : undefined));
977
+ if (!preserveChecked) {
978
+ this.rangeStartIndex = -1;
979
+ }
980
+ }
981
+ }
982
+ __decorate([
983
+ observable
984
+ ], ListboxElement.prototype, "activeIndex", void 0);
985
+ __decorate([
986
+ attr({ mode: "boolean" })
987
+ ], ListboxElement.prototype, "multiple", void 0);
988
+ __decorate([
989
+ attr({ converter: nullableNumberConverter })
990
+ ], ListboxElement.prototype, "size", void 0);
991
+
992
+ class Listbox extends ListboxElement {}
993
+ __decorate([attr, __metadata("design:type", String)], Listbox.prototype, "appearance", void 0);
994
+
995
+ export { DelegatesARIAListbox as D, Listbox$1 as L, Listbox as a, ListboxElement as b };