@vonage/vivid 4.13.0 → 4.14.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 (512) hide show
  1. package/custom-elements.json +3088 -1610
  2. package/elevation/index.cjs +1 -1
  3. package/elevation/index.js +1 -1
  4. package/index.cjs +70 -136
  5. package/index.d.ts +0 -1
  6. package/index.js +60 -62
  7. package/lib/accordion/accordion.d.ts +2 -2
  8. package/lib/accordion/accordion.template.d.ts +1 -2
  9. package/lib/accordion/definition.d.ts +1 -1
  10. package/lib/accordion-item/accordion-item.d.ts +2 -2
  11. package/lib/accordion-item/accordion-item.template.d.ts +2 -3
  12. package/lib/accordion-item/definition.d.ts +1 -1
  13. package/lib/action-group/action-group.d.ts +2 -2
  14. package/lib/action-group/action-group.template.d.ts +1 -3
  15. package/lib/action-group/definition.d.ts +1 -1
  16. package/lib/alert/alert.d.ts +2 -2
  17. package/lib/alert/alert.template.d.ts +2 -3
  18. package/lib/alert/definition.d.ts +1 -1
  19. package/lib/audio-player/audio-player.d.ts +2 -2
  20. package/lib/audio-player/audio-player.template.d.ts +2 -3
  21. package/lib/audio-player/definition.d.ts +1 -3
  22. package/lib/avatar/avatar.d.ts +2 -2
  23. package/lib/avatar/avatar.template.d.ts +2 -3
  24. package/lib/avatar/definition.d.ts +1 -1
  25. package/lib/badge/badge.d.ts +2 -2
  26. package/lib/badge/badge.template.d.ts +2 -3
  27. package/lib/badge/definition.d.ts +1 -3
  28. package/lib/banner/banner.d.ts +2 -2
  29. package/lib/banner/banner.template.d.ts +2 -3
  30. package/lib/banner/definition.d.ts +1 -1
  31. package/lib/breadcrumb/breadcrumb.d.ts +2 -2
  32. package/lib/breadcrumb/breadcrumb.template.d.ts +3 -4
  33. package/lib/breadcrumb/definition.d.ts +1 -1
  34. package/lib/breadcrumb-item/breadcrumb-item.d.ts +2 -2
  35. package/lib/breadcrumb-item/breadcrumb-item.template.d.ts +2 -3
  36. package/lib/breadcrumb-item/definition.d.ts +1 -1
  37. package/lib/button/button.d.ts +2 -2
  38. package/lib/button/button.template.d.ts +2 -4
  39. package/lib/button/definition.d.ts +1 -1
  40. package/lib/calendar/calendar.d.ts +2 -2
  41. package/lib/calendar/calendar.template.d.ts +1 -3
  42. package/lib/calendar/definition.d.ts +1 -1
  43. package/lib/calendar-event/calendar-event.d.ts +2 -2
  44. package/lib/calendar-event/calendar-event.template.d.ts +1 -3
  45. package/lib/calendar-event/definition.d.ts +1 -1
  46. package/lib/card/card.d.ts +2 -2
  47. package/lib/card/card.template.d.ts +2 -3
  48. package/lib/card/definition.d.ts +1 -1
  49. package/lib/checkbox/checkbox.form-associated.d.ts +3 -2
  50. package/lib/checkbox/checkbox.template.d.ts +2 -3
  51. package/lib/checkbox/definition.d.ts +1 -1
  52. package/lib/combobox/combobox.d.ts +17 -2
  53. package/lib/combobox/combobox.options.d.ts +7 -0
  54. package/lib/combobox/combobox.template.d.ts +2 -3
  55. package/lib/combobox/definition.d.ts +1 -2
  56. package/lib/data-grid/data-grid-cell.d.ts +16 -13
  57. package/lib/data-grid/data-grid-cell.template.d.ts +2 -3
  58. package/lib/data-grid/data-grid-row.d.ts +19 -2
  59. package/lib/data-grid/data-grid-row.template.d.ts +2 -2
  60. package/lib/data-grid/data-grid.d.ts +45 -4
  61. package/lib/data-grid/data-grid.template.d.ts +2 -2
  62. package/lib/data-grid/definition.d.ts +1 -6
  63. package/lib/date-picker/definition.d.ts +1 -3
  64. package/lib/date-range-picker/definition.d.ts +1 -3
  65. package/lib/dial-pad/definition.d.ts +1 -3
  66. package/lib/dial-pad/dial-pad.d.ts +2 -2
  67. package/lib/dial-pad/dial-pad.template.d.ts +2 -3
  68. package/lib/dialog/definition.d.ts +1 -1
  69. package/lib/dialog/dialog.d.ts +2 -2
  70. package/lib/dialog/dialog.template.d.ts +2 -3
  71. package/lib/divider/definition.d.ts +1 -1
  72. package/lib/divider/divider.d.ts +2 -2
  73. package/lib/divider/divider.template.d.ts +1 -3
  74. package/lib/elevation/definition.d.ts +1 -1
  75. package/lib/elevation/elevation.d.ts +3 -2
  76. package/lib/elevation/elevation.template.d.ts +1 -3
  77. package/lib/empty-state/definition.d.ts +1 -3
  78. package/lib/empty-state/empty-state.d.ts +2 -2
  79. package/lib/empty-state/empty-state.template.d.ts +2 -3
  80. package/lib/fab/definition.d.ts +1 -3
  81. package/lib/fab/fab.template.d.ts +2 -3
  82. package/lib/file-picker/definition.d.ts +1 -3
  83. package/lib/file-picker/file-picker.form-associated.d.ts +3 -2
  84. package/lib/file-picker/file-picker.template.d.ts +2 -3
  85. package/lib/header/definition.d.ts +1 -3
  86. package/lib/header/header.d.ts +2 -2
  87. package/lib/header/header.template.d.ts +2 -3
  88. package/lib/icon/definition.d.ts +1 -3
  89. package/lib/icon/icon.d.ts +2 -2
  90. package/lib/icon/icon.template.d.ts +1 -3
  91. package/lib/layout/definition.d.ts +1 -3
  92. package/lib/layout/layout.d.ts +2 -2
  93. package/lib/layout/layout.template.d.ts +1 -3
  94. package/lib/listbox/definition.d.ts +1 -3
  95. package/lib/listbox/listbox.template.d.ts +1 -3
  96. package/lib/menu/definition.d.ts +1 -11
  97. package/lib/menu/menu.d.ts +2 -2
  98. package/lib/menu/menu.template.d.ts +3 -3
  99. package/lib/menu-item/definition.d.ts +1 -3
  100. package/lib/menu-item/menu-item.d.ts +2 -2
  101. package/lib/menu-item/menu-item.template.d.ts +2 -3
  102. package/lib/nav/definition.d.ts +1 -3
  103. package/lib/nav/nav.d.ts +2 -2
  104. package/lib/nav/nav.template.d.ts +1 -3
  105. package/lib/nav-disclosure/definition.d.ts +1 -3
  106. package/lib/nav-disclosure/nav-disclosure.d.ts +2 -2
  107. package/lib/nav-disclosure/nav-disclosure.template.d.ts +2 -3
  108. package/lib/nav-item/definition.d.ts +1 -3
  109. package/lib/nav-item/nav-item.template.d.ts +2 -3
  110. package/lib/note/definition.d.ts +1 -3
  111. package/lib/note/note.d.ts +2 -2
  112. package/lib/note/note.template.d.ts +2 -3
  113. package/lib/number-field/definition.d.ts +1 -4
  114. package/lib/number-field/number-field.form-associated.d.ts +3 -2
  115. package/lib/number-field/number-field.template.d.ts +2 -3
  116. package/lib/option/definition.d.ts +1 -3
  117. package/lib/option/option.d.ts +3 -2
  118. package/lib/option/option.template.d.ts +2 -3
  119. package/lib/pagination/definition.d.ts +1 -3
  120. package/lib/pagination/pagination.d.ts +2 -2
  121. package/lib/pagination/pagination.template.d.ts +2 -3
  122. package/lib/popup/definition.d.ts +1 -3
  123. package/lib/popup/popup.template.d.ts +2 -3
  124. package/lib/progress/definition.d.ts +1 -3
  125. package/lib/progress/progress.d.ts +1 -1
  126. package/lib/progress/progress.template.d.ts +1 -4
  127. package/lib/progress-ring/definition.d.ts +1 -3
  128. package/lib/progress-ring/progress-ring.d.ts +1 -1
  129. package/lib/progress-ring/progress-ring.template.d.ts +1 -3
  130. package/lib/radio/definition.d.ts +1 -3
  131. package/lib/radio/radio.form-associated.d.ts +5 -2
  132. package/lib/radio/radio.template.d.ts +1 -3
  133. package/lib/radio-group/definition.d.ts +1 -11
  134. package/lib/radio-group/radio-group.d.ts +2 -2
  135. package/lib/radio-group/radio-group.template.d.ts +2 -3
  136. package/lib/range-slider/definition.d.ts +1 -3
  137. package/lib/range-slider/range-slider.form-associated.d.ts +3 -2
  138. package/lib/range-slider/range-slider.template.d.ts +2 -3
  139. package/lib/searchable-select/definition.d.ts +1 -4
  140. package/lib/searchable-select/option-tag.template.d.ts +2 -3
  141. package/lib/searchable-select/searchable-select.form-associated.d.ts +3 -2
  142. package/lib/searchable-select/searchable-select.template.d.ts +2 -3
  143. package/lib/select/definition.d.ts +1 -3
  144. package/lib/select/select.d.ts +14 -4
  145. package/lib/select/select.form-associated.d.ts +11 -0
  146. package/lib/select/select.template.d.ts +2 -3
  147. package/lib/selectable-box/definition.d.ts +1 -3
  148. package/lib/selectable-box/selectable-box.d.ts +2 -2
  149. package/lib/selectable-box/selectable-box.template.d.ts +2 -3
  150. package/lib/side-drawer/definition.d.ts +1 -3
  151. package/lib/side-drawer/side-drawer.d.ts +2 -2
  152. package/lib/side-drawer/side-drawer.template.d.ts +1 -3
  153. package/lib/slider/definition.d.ts +1 -3
  154. package/lib/slider/slider.form-associated.d.ts +3 -2
  155. package/lib/slider/slider.template.d.ts +3 -4
  156. package/lib/split-button/definition.d.ts +1 -1
  157. package/lib/split-button/split-button.d.ts +2 -2
  158. package/lib/split-button/split-button.template.d.ts +2 -3
  159. package/lib/switch/definition.d.ts +1 -3
  160. package/lib/switch/switch.form-associated.d.ts +3 -2
  161. package/lib/switch/switch.template.d.ts +1 -3
  162. package/lib/tab/definition.d.ts +1 -3
  163. package/lib/tab/tab.d.ts +2 -2
  164. package/lib/tab/tab.template.d.ts +2 -2
  165. package/lib/tab-panel/definition.d.ts +1 -3
  166. package/lib/tab-panel/tab-panel.d.ts +2 -2
  167. package/lib/tab-panel/tab-panel.template.d.ts +1 -1
  168. package/lib/tabs/definition.d.ts +1 -3
  169. package/lib/tabs/tabs.d.ts +3 -7
  170. package/lib/tabs/tabs.template.d.ts +1 -1
  171. package/lib/tag/definition.d.ts +1 -4
  172. package/lib/tag/tag.d.ts +2 -2
  173. package/lib/tag/tag.template.d.ts +2 -3
  174. package/lib/tag-group/definition.d.ts +1 -3
  175. package/lib/tag-group/tag-group.d.ts +2 -2
  176. package/lib/tag-group/tag-group.template.d.ts +1 -3
  177. package/lib/text-anchor/definition.d.ts +1 -3
  178. package/lib/text-anchor/text-anchor.d.ts +4 -3
  179. package/lib/text-anchor/text-anchor.template.d.ts +2 -3
  180. package/lib/text-area/definition.d.ts +1 -3
  181. package/lib/text-area/text-area.d.ts +1 -1
  182. package/lib/text-area/{text-field.form-associated.d.ts → text-area.form-associated.d.ts} +3 -2
  183. package/lib/text-area/text-area.template.d.ts +2 -3
  184. package/lib/text-field/definition.d.ts +1 -3
  185. package/lib/text-field/text-field.form-associated.d.ts +3 -2
  186. package/lib/text-field/text-field.template.d.ts +2 -3
  187. package/lib/time-picker/definition.d.ts +1 -3
  188. package/lib/time-picker/time-picker.form-associated.d.ts +3 -2
  189. package/lib/time-picker/time-picker.template.d.ts +2 -2
  190. package/lib/toggletip/definition.d.ts +1 -3
  191. package/lib/toggletip/toggletip.d.ts +2 -2
  192. package/lib/toggletip/toggletip.template.d.ts +2 -3
  193. package/lib/tooltip/definition.d.ts +1 -3
  194. package/lib/tooltip/tooltip.d.ts +2 -2
  195. package/lib/tooltip/tooltip.template.d.ts +2 -3
  196. package/lib/tree-item/definition.d.ts +1 -3
  197. package/lib/tree-item/tree-item.d.ts +11 -2
  198. package/lib/tree-item/tree-item.template.d.ts +3 -3
  199. package/lib/tree-view/definition.d.ts +1 -3
  200. package/lib/tree-view/tree-view.d.ts +16 -2
  201. package/lib/tree-view/tree-view.template.d.ts +1 -1
  202. package/lib/video-player/definition.d.ts +1 -3
  203. package/lib/video-player/video-player.d.ts +2 -2
  204. package/lib/video-player/video-player.template.d.ts +1 -3
  205. package/listbox/index.cjs +37 -39
  206. package/listbox/index.js +37 -39
  207. package/menu/index.cjs +1 -1
  208. package/menu/index.js +1 -1
  209. package/nav/index.cjs +1 -1
  210. package/nav/index.js +1 -1
  211. package/nav-disclosure/index.cjs +1 -1
  212. package/nav-disclosure/index.js +1 -1
  213. package/nav-item/index.cjs +1 -1
  214. package/nav-item/index.js +1 -1
  215. package/note/index.cjs +1 -1
  216. package/note/index.js +1 -1
  217. package/number-field/index.cjs +1 -1
  218. package/number-field/index.js +1 -1
  219. package/option/index.cjs +1 -1
  220. package/option/index.js +1 -1
  221. package/package.json +1 -1
  222. package/pagination/index.cjs +1 -1
  223. package/pagination/index.js +1 -1
  224. package/popup/index.cjs +1 -1
  225. package/popup/index.js +1 -1
  226. package/progress/index.cjs +1 -1
  227. package/progress/index.js +1 -1
  228. package/progress-ring/index.cjs +1 -1
  229. package/progress-ring/index.js +1 -1
  230. package/radio/index.cjs +1 -1
  231. package/radio/index.js +1 -1
  232. package/radio-group/index.cjs +1 -1
  233. package/radio-group/index.js +1 -1
  234. package/range-slider/index.cjs +1 -1
  235. package/range-slider/index.js +1 -1
  236. package/searchable-select/index.cjs +1 -1
  237. package/searchable-select/index.js +1 -1
  238. package/select/index.cjs +1 -1
  239. package/select/index.js +1 -1
  240. package/selectable-box/index.cjs +1 -1
  241. package/selectable-box/index.js +1 -1
  242. package/shared/affix.cjs +10 -10
  243. package/shared/affix.js +2 -2
  244. package/shared/anchor.cjs +59 -0
  245. package/shared/anchor.js +57 -0
  246. package/shared/anchored.cjs +6 -6
  247. package/shared/anchored.js +2 -2
  248. package/shared/apply-mixins.cjs +15 -17
  249. package/shared/apply-mixins.js +15 -17
  250. package/shared/apply-mixins2.cjs +25 -0
  251. package/shared/apply-mixins2.js +23 -0
  252. package/shared/applyMixinsWithObservables.cjs +4 -4
  253. package/shared/applyMixinsWithObservables.js +2 -2
  254. package/shared/aria-global.cjs +86 -67
  255. package/shared/aria-global.js +86 -67
  256. package/shared/aria-global2.cjs +68 -86
  257. package/shared/aria-global2.js +68 -86
  258. package/shared/base-progress.cjs +69 -63
  259. package/shared/base-progress.js +69 -63
  260. package/shared/breadcrumb-item.cjs +6 -58
  261. package/shared/breadcrumb-item.js +3 -55
  262. package/shared/button.cjs +177 -0
  263. package/shared/button.js +175 -0
  264. package/shared/calendar-event.cjs +9 -9
  265. package/shared/calendar-event.js +2 -2
  266. package/shared/children.cjs +2 -2
  267. package/shared/children.js +1 -1
  268. package/shared/date-picker/date-picker-base.form-associated.d.ts +3 -2
  269. package/shared/date-picker/date-picker-base.template.d.ts +2 -3
  270. package/shared/definition.cjs +25 -24
  271. package/shared/definition.js +16 -14
  272. package/shared/definition10.cjs +14 -12
  273. package/shared/definition10.js +14 -11
  274. package/shared/definition11.cjs +52 -248
  275. package/shared/definition11.js +24 -218
  276. package/shared/definition12.cjs +18 -14
  277. package/shared/definition12.js +17 -12
  278. package/shared/definition13.cjs +19 -19
  279. package/shared/definition13.js +10 -9
  280. package/shared/definition14.cjs +35 -38
  281. package/shared/definition14.js +15 -17
  282. package/shared/definition15.cjs +27 -26
  283. package/shared/definition15.js +16 -14
  284. package/shared/definition16.cjs +480 -612
  285. package/shared/definition16.js +473 -604
  286. package/shared/definition17.cjs +933 -1113
  287. package/shared/definition17.js +911 -1090
  288. package/shared/definition18.cjs +16 -20
  289. package/shared/definition18.js +19 -22
  290. package/shared/definition19.cjs +26 -30
  291. package/shared/definition19.js +21 -24
  292. package/shared/definition2.cjs +19 -22
  293. package/shared/definition2.js +20 -22
  294. package/shared/definition20.cjs +50 -52
  295. package/shared/definition20.js +34 -35
  296. package/shared/definition21.cjs +43 -47
  297. package/shared/definition21.js +19 -22
  298. package/shared/definition22.cjs +15 -13
  299. package/shared/definition22.js +14 -11
  300. package/shared/definition23.cjs +21 -20
  301. package/shared/definition23.js +14 -12
  302. package/shared/definition24.cjs +21 -173
  303. package/shared/definition24.js +18 -169
  304. package/shared/definition25.cjs +26 -28
  305. package/shared/definition25.js +18 -19
  306. package/shared/definition26.cjs +16 -14
  307. package/shared/definition26.js +14 -11
  308. package/shared/definition27.cjs +264 -12
  309. package/shared/definition27.js +261 -10
  310. package/shared/definition28.cjs +19 -17
  311. package/shared/definition28.js +15 -12
  312. package/shared/definition29.cjs +142 -68
  313. package/shared/definition29.js +101 -29
  314. package/shared/definition3.cjs +20 -16
  315. package/shared/definition3.js +16 -11
  316. package/shared/definition30.cjs +98 -76
  317. package/shared/definition30.js +97 -74
  318. package/shared/definition31.cjs +24 -97
  319. package/shared/definition31.js +25 -97
  320. package/shared/definition32.cjs +9 -25
  321. package/shared/definition32.js +8 -23
  322. package/shared/definition33.cjs +52 -14
  323. package/shared/definition33.js +51 -12
  324. package/shared/definition34.cjs +639 -34
  325. package/shared/definition34.js +636 -30
  326. package/shared/definition35.cjs +203 -596
  327. package/shared/definition35.js +197 -591
  328. package/shared/definition36.cjs +197 -233
  329. package/shared/definition36.js +192 -226
  330. package/shared/definition37.cjs +79 -206
  331. package/shared/definition37.js +75 -202
  332. package/shared/definition38.cjs +50 -56
  333. package/shared/definition38.js +48 -52
  334. package/shared/definition39.cjs +259 -56
  335. package/shared/definition39.js +258 -54
  336. package/shared/definition4.cjs +32 -35
  337. package/shared/definition4.js +19 -21
  338. package/shared/definition40.cjs +156 -225
  339. package/shared/definition40.js +152 -221
  340. package/shared/definition41.cjs +626 -36
  341. package/shared/definition41.js +625 -34
  342. package/shared/definition42.cjs +974 -487
  343. package/shared/definition42.js +971 -482
  344. package/shared/definition43.cjs +725 -932
  345. package/shared/definition43.js +713 -918
  346. package/shared/definition44.cjs +115 -734
  347. package/shared/definition44.js +113 -731
  348. package/shared/definition45.cjs +92 -116
  349. package/shared/definition45.js +92 -115
  350. package/shared/definition46.cjs +468 -89
  351. package/shared/definition46.js +465 -86
  352. package/shared/definition47.cjs +118 -470
  353. package/shared/definition47.js +115 -465
  354. package/shared/definition48.cjs +113 -120
  355. package/shared/definition48.js +111 -117
  356. package/shared/definition49.cjs +16 -134
  357. package/shared/definition49.js +15 -132
  358. package/shared/definition5.cjs +47 -49
  359. package/shared/definition5.js +18 -19
  360. package/shared/definition50.cjs +111 -15
  361. package/shared/definition50.js +109 -12
  362. package/shared/definition51.cjs +862 -84
  363. package/shared/definition51.js +858 -79
  364. package/shared/definition52.cjs +30 -873
  365. package/shared/definition52.js +28 -870
  366. package/shared/definition53.cjs +125 -28
  367. package/shared/definition53.js +123 -25
  368. package/shared/definition54.cjs +267 -107
  369. package/shared/definition54.js +261 -100
  370. package/shared/definition55.cjs +63 -278
  371. package/shared/definition55.js +61 -275
  372. package/shared/definition56.cjs +867 -76
  373. package/shared/definition56.js +866 -74
  374. package/shared/definition57.cjs +107 -826
  375. package/shared/definition57.js +105 -823
  376. package/shared/definition58.cjs +73 -100
  377. package/shared/definition58.js +69 -95
  378. package/shared/definition59.cjs +180 -106
  379. package/shared/definition59.js +174 -101
  380. package/shared/definition6.cjs +22 -21
  381. package/shared/definition6.js +14 -12
  382. package/shared/definition60.cjs +272 -70
  383. package/shared/definition60.js +272 -69
  384. package/shared/definition61.cjs +66154 -271
  385. package/shared/definition61.js +66153 -269
  386. package/shared/definition62.cjs +38 -66173
  387. package/shared/definition62.js +35 -66170
  388. package/shared/definition63.cjs +2153 -27
  389. package/shared/definition63.js +2150 -25
  390. package/shared/definition7.cjs +18 -15
  391. package/shared/definition7.js +13 -10
  392. package/shared/definition8.cjs +25 -27
  393. package/shared/definition8.js +16 -17
  394. package/shared/definition9.cjs +21 -21
  395. package/shared/definition9.js +18 -17
  396. package/shared/design-system/createRegisterFunction.d.ts +2 -0
  397. package/shared/design-system/defineVividComponent.d.ts +15 -0
  398. package/shared/{localization.js → direction.js} +11 -11
  399. package/shared/dom.cjs +0 -13
  400. package/shared/dom.js +1 -13
  401. package/shared/form-associated.cjs +422 -457
  402. package/shared/form-associated.js +422 -457
  403. package/shared/form-associated2.cjs +383 -0
  404. package/shared/form-associated2.js +381 -0
  405. package/shared/form-elements.cjs +15 -42
  406. package/shared/form-elements.js +2 -29
  407. package/shared/foundation/anchor/anchor.d.ts +1 -0
  408. package/shared/foundation/button/button.d.ts +3 -2
  409. package/shared/foundation/button/button.template.d.ts +2 -4
  410. package/shared/foundation/form-associated/form-associated.d.ts +51 -0
  411. package/shared/foundation/listbox/listbox.d.ts +22 -0
  412. package/shared/foundation/progress/base-progress.d.ts +9 -0
  413. package/shared/foundation/utilities/apply-mixins.d.ts +1 -0
  414. package/shared/foundation/vivid-element/vivid-element.d.ts +3 -0
  415. package/shared/index.cjs +7 -5097
  416. package/shared/index.js +7 -5079
  417. package/shared/key-codes.cjs +10 -0
  418. package/shared/key-codes.js +6 -1
  419. package/shared/key-codes2.cjs +1463 -6
  420. package/shared/key-codes2.js +1461 -4
  421. package/shared/listbox.cjs +427 -1195
  422. package/shared/listbox.js +411 -1176
  423. package/shared/listbox2.cjs +1267 -0
  424. package/shared/listbox2.js +1264 -0
  425. package/shared/localized.cjs +2 -2
  426. package/shared/localized.js +1 -1
  427. package/shared/numbers.cjs +12 -0
  428. package/shared/numbers.js +12 -1
  429. package/shared/patterns/affix.d.ts +2 -2
  430. package/shared/patterns/chevron.d.ts +2 -2
  431. package/shared/patterns/form-elements/form-elements.d.ts +2 -2
  432. package/shared/presentationDate.cjs +49 -49
  433. package/shared/presentationDate.js +6 -6
  434. package/shared/ref.cjs +2 -2
  435. package/shared/ref.js +1 -1
  436. package/shared/repeat.cjs +22 -22
  437. package/shared/repeat.js +1 -1
  438. package/shared/slider.template.cjs +5 -5
  439. package/shared/slider.template.js +2 -2
  440. package/shared/slotted.cjs +4 -4
  441. package/shared/slotted.js +1 -1
  442. package/shared/strings.cjs +0 -26
  443. package/shared/strings.js +1 -25
  444. package/shared/strings2.cjs +37 -0
  445. package/shared/strings2.js +33 -0
  446. package/shared/text-anchor.cjs +7 -89
  447. package/shared/text-anchor.js +4 -86
  448. package/shared/text-anchor.template.cjs +2 -2
  449. package/shared/text-anchor.template.js +1 -1
  450. package/shared/text-field2.cjs +28 -28
  451. package/shared/text-field2.js +5 -5
  452. package/shared/vivid-element.cjs +2616 -0
  453. package/shared/vivid-element.js +2595 -0
  454. package/side-drawer/index.cjs +1 -1
  455. package/side-drawer/index.js +1 -1
  456. package/slider/index.cjs +1 -1
  457. package/slider/index.js +1 -1
  458. package/split-button/index.cjs +1 -1
  459. package/split-button/index.js +1 -1
  460. package/styles/core/all.css +40 -1
  461. package/styles/core/theme.css +40 -1
  462. package/styles/core/typography.css +1 -1
  463. package/styles/tokens/theme-dark.css +25 -4
  464. package/styles/tokens/theme-light.css +25 -4
  465. package/styles/tokens/vivid-2-compat.css +1 -1
  466. package/switch/index.cjs +1 -1
  467. package/switch/index.js +1 -1
  468. package/tab/index.cjs +1 -1
  469. package/tab/index.js +1 -1
  470. package/tab-panel/index.cjs +1 -1
  471. package/tab-panel/index.js +1 -1
  472. package/tabs/index.cjs +1 -1
  473. package/tabs/index.js +1 -1
  474. package/tag/index.cjs +1 -1
  475. package/tag/index.js +1 -1
  476. package/tag-group/index.cjs +1 -1
  477. package/tag-group/index.js +1 -1
  478. package/text-anchor/index.cjs +10 -7
  479. package/text-anchor/index.js +10 -7
  480. package/text-area/index.cjs +1 -1
  481. package/text-area/index.js +1 -1
  482. package/text-field/index.cjs +1 -1
  483. package/text-field/index.js +1 -1
  484. package/time-picker/index.cjs +1 -1
  485. package/time-picker/index.js +1 -1
  486. package/toggletip/index.cjs +1 -1
  487. package/toggletip/index.js +1 -1
  488. package/tooltip/index.cjs +1 -1
  489. package/tooltip/index.js +1 -1
  490. package/tree-item/index.cjs +1 -1
  491. package/tree-item/index.js +1 -1
  492. package/tree-view/index.cjs +1 -1
  493. package/tree-view/index.js +1 -1
  494. package/video-player/index.cjs +1 -1
  495. package/video-player/index.js +1 -1
  496. package/vivid.api.json +2846 -7860
  497. package/shared/definition64.cjs +0 -2175
  498. package/shared/definition64.js +0 -2170
  499. package/shared/design-system/index.d.ts +0 -3
  500. package/shared/icon.cjs +0 -261
  501. package/shared/icon.js +0 -258
  502. package/shared/index2.cjs +0 -11
  503. package/shared/index2.js +0 -9
  504. package/shared/radio.cjs +0 -126
  505. package/shared/radio.js +0 -124
  506. package/shared/select.options.cjs +0 -12
  507. package/shared/select.options.js +0 -10
  508. package/shared/start-end.cjs +0 -52
  509. package/shared/start-end.js +0 -50
  510. package/shared/tree-item.cjs +0 -154
  511. package/shared/tree-item.js +0 -151
  512. package/shared/{localization.cjs → direction.cjs} +9 -9
package/shared/listbox.js CHANGED
@@ -1,11 +1,9 @@
1
- import { e as keyArrowLeft, f as keyArrowRight } from './key-codes.js';
2
- import { _ as __decorate, o as observable, a as attr, F as FoundationElement, O as Observable, D as DOM, n as nullableNumberConverter } from './index.js';
1
+ import { i as isListboxOption } from './definition35.js';
2
+ import { V as VividElement, O as Observable, a as attr, o as observable } from './vivid-element.js';
3
+ import { a as keySpace, b as keyEscape, k as keyEnter, c as keyTab, d as keyEnd, e as keyArrowUp, f as keyArrowDown, g as keyHome } from './key-codes.js';
4
+ import { u as uniqueId } from './strings.js';
5
+ import { a as applyMixins } from './apply-mixins2.js';
3
6
  import { A as ARIAGlobalStatesAndProperties } from './aria-global.js';
4
- import { S as StartEnd } from './start-end.js';
5
- import { a as applyMixins } from './apply-mixins.js';
6
- import { i as isHTMLElement } from './dom.js';
7
- import { a as keySpace, b as keyEscape, k as keyEnter, c as keyTab, d as keyEnd, e as keyArrowUp, f as keyArrowDown, g as keyHome } from './key-codes2.js';
8
- import { u as uniqueId, i as inRange } from './strings.js';
9
7
 
10
8
  /**
11
9
  * Returns the index of the last element in the array where predicate is true, and -1 otherwise.
@@ -23,1237 +21,474 @@ function findLastIndex(array, predicate) {
23
21
  return -1;
24
22
  }
25
23
 
26
- /**
27
- * Determines if the element is a {@link (ListboxOption:class)}
28
- *
29
- * @param element - the element to test.
30
- * @public
31
- */
32
- function isListboxOption(el) {
33
- return (isHTMLElement(el) &&
34
- (el.getAttribute("role") === "option" ||
35
- el instanceof HTMLOptionElement));
36
- }
37
- /**
38
- * An Option Custom HTML Element.
39
- * Implements {@link https://www.w3.org/TR/wai-aria-1.1/#option | ARIA option }.
40
- *
41
- * @slot start - Content which can be provided before the listbox option content
42
- * @slot end - Content which can be provided after the listbox option content
43
- * @slot - The default slot for listbox option content
44
- * @csspart content - Wraps the listbox option content
45
- *
46
- * @public
47
- */
48
- class ListboxOption extends FoundationElement {
49
- constructor(text, value, defaultSelected, selected) {
50
- super();
51
- /**
52
- * The defaultSelected state of the option.
53
- * @public
54
- */
55
- this.defaultSelected = false;
56
- /**
57
- * Tracks whether the "selected" property has been changed.
58
- * @internal
59
- */
60
- this.dirtySelected = false;
61
- /**
62
- * The checked state of the control.
63
- *
64
- * @public
65
- */
66
- this.selected = this.defaultSelected;
67
- /**
68
- * Track whether the value has been changed from the initial value
69
- */
70
- this.dirtyValue = false;
71
- if (text) {
72
- this.textContent = text;
73
- }
74
- if (value) {
75
- this.initialValue = value;
76
- }
77
- if (defaultSelected) {
78
- this.defaultSelected = defaultSelected;
79
- }
80
- if (selected) {
81
- this.selected = selected;
82
- }
83
- this.proxy = new Option(`${this.textContent}`, this.initialValue, this.defaultSelected, this.selected);
84
- this.proxy.disabled = this.disabled;
85
- }
86
- /**
87
- * Updates the ariaChecked property when the checked property changes.
88
- *
89
- * @param prev - the previous checked value
90
- * @param next - the current checked value
91
- *
92
- * @public
93
- */
94
- checkedChanged(prev, next) {
95
- if (typeof next === "boolean") {
96
- this.ariaChecked = next ? "true" : "false";
97
- return;
98
- }
99
- this.ariaChecked = null;
100
- }
101
- /**
102
- * Updates the proxy's text content when the default slot changes.
103
- * @param prev - the previous content value
104
- * @param next - the current content value
105
- *
106
- * @internal
107
- */
108
- contentChanged(prev, next) {
109
- if (this.proxy instanceof HTMLOptionElement) {
110
- this.proxy.textContent = this.textContent;
111
- }
112
- this.$emit("contentchange", null, { bubbles: true });
113
- }
114
- defaultSelectedChanged() {
115
- if (!this.dirtySelected) {
116
- this.selected = this.defaultSelected;
117
- if (this.proxy instanceof HTMLOptionElement) {
118
- this.proxy.selected = this.defaultSelected;
119
- }
120
- }
121
- }
122
- disabledChanged(prev, next) {
123
- this.ariaDisabled = this.disabled ? "true" : "false";
124
- if (this.proxy instanceof HTMLOptionElement) {
125
- this.proxy.disabled = this.disabled;
126
- }
127
- }
128
- selectedAttributeChanged() {
129
- this.defaultSelected = this.selectedAttribute;
130
- if (this.proxy instanceof HTMLOptionElement) {
131
- this.proxy.defaultSelected = this.defaultSelected;
132
- }
133
- }
134
- selectedChanged() {
135
- this.ariaSelected = this.selected ? "true" : "false";
136
- if (!this.dirtySelected) {
137
- this.dirtySelected = true;
138
- }
139
- if (this.proxy instanceof HTMLOptionElement) {
140
- this.proxy.selected = this.selected;
141
- }
142
- }
143
- initialValueChanged(previous, next) {
144
- // If the value is clean and the component is connected to the DOM
145
- // then set value equal to the attribute value.
146
- if (!this.dirtyValue) {
147
- this.value = this.initialValue;
148
- this.dirtyValue = false;
149
- }
150
- }
151
- get label() {
152
- var _a;
153
- return (_a = this.value) !== null && _a !== void 0 ? _a : this.text;
154
- }
155
- get text() {
156
- var _a, _b;
157
- return (_b = (_a = this.textContent) === null || _a === void 0 ? void 0 : _a.replace(/\s+/g, " ").trim()) !== null && _b !== void 0 ? _b : "";
158
- }
159
- set value(next) {
160
- const newValue = `${next !== null && next !== void 0 ? next : ""}`;
161
- this._value = newValue;
162
- this.dirtyValue = true;
163
- if (this.proxy instanceof HTMLOptionElement) {
164
- this.proxy.value = newValue;
165
- }
166
- Observable.notify(this, "value");
167
- }
168
- get value() {
169
- var _a;
170
- Observable.track(this, "value");
171
- return (_a = this._value) !== null && _a !== void 0 ? _a : this.text;
172
- }
173
- get form() {
174
- return this.proxy ? this.proxy.form : null;
175
- }
176
- }
177
- __decorate([
178
- observable
179
- ], ListboxOption.prototype, "checked", void 0);
180
- __decorate([
181
- observable
182
- ], ListboxOption.prototype, "content", void 0);
183
- __decorate([
184
- observable
185
- ], ListboxOption.prototype, "defaultSelected", void 0);
186
- __decorate([
187
- attr({ mode: "boolean" })
188
- ], ListboxOption.prototype, "disabled", void 0);
189
- __decorate([
190
- attr({ attribute: "selected", mode: "boolean" })
191
- ], ListboxOption.prototype, "selectedAttribute", void 0);
192
- __decorate([
193
- observable
194
- ], ListboxOption.prototype, "selected", void 0);
195
- __decorate([
196
- attr({ attribute: "value", mode: "fromView" })
197
- ], ListboxOption.prototype, "initialValue", void 0);
198
- /**
199
- * States and properties relating to the ARIA `option` role.
200
- *
201
- * @public
202
- */
203
- class DelegatesARIAListboxOption {
204
- }
205
- __decorate([
206
- observable
207
- ], DelegatesARIAListboxOption.prototype, "ariaChecked", void 0);
208
- __decorate([
209
- observable
210
- ], DelegatesARIAListboxOption.prototype, "ariaPosInSet", void 0);
211
- __decorate([
212
- observable
213
- ], DelegatesARIAListboxOption.prototype, "ariaSelected", void 0);
214
- __decorate([
215
- observable
216
- ], DelegatesARIAListboxOption.prototype, "ariaSetSize", void 0);
217
- applyMixins(DelegatesARIAListboxOption, ARIAGlobalStatesAndProperties);
218
- applyMixins(ListboxOption, StartEnd, DelegatesARIAListboxOption);
219
-
220
- /**
221
- * A Listbox Custom HTML Element.
222
- * Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#listbox | ARIA listbox }.
223
- *
224
- * @slot - The default slot for the listbox options
225
- *
226
- * @public
227
- */
228
- let Listbox$1 = class Listbox extends FoundationElement {
229
- constructor() {
230
- super(...arguments);
231
- /**
232
- * The internal unfiltered list of selectable options.
233
- *
234
- * @internal
235
- */
236
- this._options = [];
237
- /**
238
- * The index of the selected option.
239
- *
240
- * @public
241
- */
242
- this.selectedIndex = -1;
243
- /**
244
- * A collection of the selected options.
245
- *
246
- * @public
247
- */
248
- this.selectedOptions = [];
249
- /**
250
- * A standard `click` event creates a `focus` event before firing, so a
251
- * `mousedown` event is used to skip that initial focus.
252
- *
253
- * @internal
254
- */
255
- this.shouldSkipFocus = false;
256
- /**
257
- * The current typeahead buffer string.
258
- *
259
- * @internal
260
- */
261
- this.typeaheadBuffer = "";
262
- /**
263
- * Flag for the typeahead timeout expiration.
264
- *
265
- * @internal
266
- */
267
- this.typeaheadExpired = true;
268
- /**
269
- * The timeout ID for the typeahead handler.
270
- *
271
- * @internal
272
- */
273
- this.typeaheadTimeout = -1;
274
- }
275
- /**
276
- * The first selected option.
277
- *
278
- * @internal
279
- */
280
- get firstSelectedOption() {
281
- var _a;
282
- return (_a = this.selectedOptions[0]) !== null && _a !== void 0 ? _a : null;
283
- }
284
- /**
285
- * Returns true if there is one or more selectable option.
286
- *
287
- * @internal
288
- */
289
- get hasSelectableOptions() {
290
- return this.options.length > 0 && !this.options.every(o => o.disabled);
291
- }
292
- /**
293
- * The number of options.
294
- *
295
- * @public
296
- */
297
- get length() {
298
- var _a, _b;
299
- return (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
300
- }
301
- /**
302
- * The list of options.
303
- *
304
- * @public
305
- */
306
- get options() {
307
- Observable.track(this, "options");
308
- return this._options;
309
- }
310
- set options(value) {
311
- this._options = value;
312
- Observable.notify(this, "options");
313
- }
314
- /**
315
- * Flag for the typeahead timeout expiration.
316
- *
317
- * @deprecated use `Listbox.typeaheadExpired`
318
- * @internal
319
- */
320
- get typeAheadExpired() {
321
- return this.typeaheadExpired;
322
- }
323
- set typeAheadExpired(value) {
324
- this.typeaheadExpired = value;
325
- }
326
- /**
327
- * Handle click events for listbox options.
328
- *
329
- * @internal
330
- */
331
- clickHandler(e) {
332
- const captured = e.target.closest(`option,[role=option]`);
333
- if (captured && !captured.disabled) {
334
- this.selectedIndex = this.options.indexOf(captured);
335
- return true;
336
- }
337
- }
338
- /**
339
- * Ensures that the provided option is focused and scrolled into view.
340
- *
341
- * @param optionToFocus - The option to focus
342
- * @internal
343
- */
344
- focusAndScrollOptionIntoView(optionToFocus = this.firstSelectedOption) {
345
- // To ensure that the browser handles both `focus()` and `scrollIntoView()`, the
346
- // timing here needs to guarantee that they happen on different frames. Since this
347
- // function is typically called from the `openChanged` observer, `DOM.queueUpdate`
348
- // causes the calls to be grouped into the same frame. To prevent this,
349
- // `requestAnimationFrame` is used instead of `DOM.queueUpdate`.
350
- if (this.contains(document.activeElement) && optionToFocus !== null) {
351
- optionToFocus.focus();
352
- requestAnimationFrame(() => {
353
- optionToFocus.scrollIntoView({ block: "nearest" });
354
- });
355
- }
356
- }
357
- /**
358
- * Handles `focusin` actions for the component. When the component receives focus,
359
- * the list of selected options is refreshed and the first selected option is scrolled
360
- * into view.
361
- *
362
- * @internal
363
- */
364
- focusinHandler(e) {
365
- if (!this.shouldSkipFocus && e.target === e.currentTarget) {
366
- this.setSelectedOptions();
367
- this.focusAndScrollOptionIntoView();
368
- }
369
- this.shouldSkipFocus = false;
370
- }
371
- /**
372
- * Returns the options which match the current typeahead buffer.
373
- *
374
- * @internal
375
- */
376
- getTypeaheadMatches() {
377
- const pattern = this.typeaheadBuffer.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&");
378
- const re = new RegExp(`^${pattern}`, "gi");
379
- return this.options.filter((o) => o.text.trim().match(re));
380
- }
381
- /**
382
- * Determines the index of the next option which is selectable, if any.
383
- *
384
- * @param prev - the previous selected index
385
- * @param next - the next index to select
386
- *
387
- * @internal
388
- */
389
- getSelectableIndex(prev = this.selectedIndex, next) {
390
- const direction = prev > next ? -1 : prev < next ? 1 : 0;
391
- const potentialDirection = prev + direction;
392
- let nextSelectableOption = null;
393
- switch (direction) {
394
- case -1: {
395
- nextSelectableOption = this.options.reduceRight((nextSelectableOption, thisOption, index) => !nextSelectableOption &&
396
- !thisOption.disabled &&
397
- index < potentialDirection
398
- ? thisOption
399
- : nextSelectableOption, nextSelectableOption);
400
- break;
401
- }
402
- case 1: {
403
- nextSelectableOption = this.options.reduce((nextSelectableOption, thisOption, index) => !nextSelectableOption &&
404
- !thisOption.disabled &&
405
- index > potentialDirection
406
- ? thisOption
407
- : nextSelectableOption, nextSelectableOption);
408
- break;
409
- }
410
- }
411
- return this.options.indexOf(nextSelectableOption);
412
- }
413
- /**
414
- * Handles external changes to child options.
415
- *
416
- * @param source - the source object
417
- * @param propertyName - the property
418
- *
419
- * @internal
420
- */
421
- handleChange(source, propertyName) {
422
- switch (propertyName) {
423
- case "selected": {
424
- if (Listbox.slottedOptionFilter(source)) {
425
- this.selectedIndex = this.options.indexOf(source);
426
- }
427
- this.setSelectedOptions();
428
- break;
429
- }
430
- }
431
- }
432
- /**
433
- * Moves focus to an option whose label matches characters typed by the user.
434
- * Consecutive keystrokes are batched into a buffer of search text used
435
- * to match against the set of options. If `TYPE_AHEAD_TIMEOUT_MS` passes
436
- * between consecutive keystrokes, the search restarts.
437
- *
438
- * @param key - the key to be evaluated
439
- *
440
- * @internal
441
- */
442
- handleTypeAhead(key) {
443
- if (this.typeaheadTimeout) {
444
- window.clearTimeout(this.typeaheadTimeout);
445
- }
446
- this.typeaheadTimeout = window.setTimeout(() => (this.typeaheadExpired = true), Listbox.TYPE_AHEAD_TIMEOUT_MS);
447
- if (key.length > 1) {
448
- return;
449
- }
450
- this.typeaheadBuffer = `${this.typeaheadExpired ? "" : this.typeaheadBuffer}${key}`;
451
- }
452
- /**
453
- * Handles `keydown` actions for listbox navigation and typeahead.
454
- *
455
- * @internal
456
- */
457
- keydownHandler(e) {
458
- if (this.disabled) {
459
- return true;
460
- }
461
- this.shouldSkipFocus = false;
462
- const key = e.key;
463
- switch (key) {
464
- // Select the first available option
465
- case keyHome: {
466
- if (!e.shiftKey) {
467
- e.preventDefault();
468
- this.selectFirstOption();
469
- }
470
- break;
471
- }
472
- // Select the next selectable option
473
- case keyArrowDown: {
474
- if (!e.shiftKey) {
475
- e.preventDefault();
476
- this.selectNextOption();
477
- }
478
- break;
479
- }
480
- // Select the previous selectable option
481
- case keyArrowUp: {
482
- if (!e.shiftKey) {
483
- e.preventDefault();
484
- this.selectPreviousOption();
485
- }
486
- break;
487
- }
488
- // Select the last available option
489
- case keyEnd: {
490
- e.preventDefault();
491
- this.selectLastOption();
492
- break;
493
- }
494
- case keyTab: {
495
- this.focusAndScrollOptionIntoView();
496
- return true;
497
- }
498
- case keyEnter:
499
- case keyEscape: {
500
- return true;
501
- }
502
- case keySpace: {
503
- if (this.typeaheadExpired) {
504
- return true;
505
- }
506
- }
507
- // Send key to Typeahead handler
508
- default: {
509
- if (key.length === 1) {
510
- this.handleTypeAhead(`${key}`);
511
- }
512
- return true;
513
- }
514
- }
515
- }
516
- /**
517
- * Prevents `focusin` events from firing before `click` events when the
518
- * element is unfocused.
519
- *
520
- * @internal
521
- */
522
- mousedownHandler(e) {
523
- this.shouldSkipFocus = !this.contains(document.activeElement);
524
- return true;
525
- }
526
- /**
527
- * Switches between single-selection and multi-selection mode.
528
- *
529
- * @param prev - the previous value of the `multiple` attribute
530
- * @param next - the next value of the `multiple` attribute
531
- *
532
- * @internal
533
- */
534
- multipleChanged(prev, next) {
535
- this.ariaMultiSelectable = next ? "true" : null;
536
- }
537
- /**
538
- * Updates the list of selected options when the `selectedIndex` changes.
539
- *
540
- * @param prev - the previous selected index value
541
- * @param next - the current selected index value
542
- *
543
- * @internal
544
- */
545
- selectedIndexChanged(prev, next) {
546
- var _a;
547
- if (!this.hasSelectableOptions) {
548
- this.selectedIndex = -1;
549
- return;
550
- }
551
- if (((_a = this.options[this.selectedIndex]) === null || _a === void 0 ? void 0 : _a.disabled) && typeof prev === "number") {
552
- const selectableIndex = this.getSelectableIndex(prev, next);
553
- const newNext = selectableIndex > -1 ? selectableIndex : prev;
554
- this.selectedIndex = newNext;
555
- if (next === newNext) {
556
- this.selectedIndexChanged(next, newNext);
557
- }
558
- return;
559
- }
560
- this.setSelectedOptions();
561
- }
562
- /**
563
- * Updates the selectedness of each option when the list of selected options changes.
564
- *
565
- * @param prev - the previous list of selected options
566
- * @param next - the current list of selected options
567
- *
568
- * @internal
569
- */
570
- selectedOptionsChanged(prev, next) {
571
- var _a;
572
- const filteredNext = next.filter(Listbox.slottedOptionFilter);
573
- (_a = this.options) === null || _a === void 0 ? void 0 : _a.forEach(o => {
574
- const notifier = Observable.getNotifier(o);
575
- notifier.unsubscribe(this, "selected");
576
- o.selected = filteredNext.includes(o);
577
- notifier.subscribe(this, "selected");
578
- });
579
- }
580
- /**
581
- * Moves focus to the first selectable option.
582
- *
583
- * @public
584
- */
585
- selectFirstOption() {
586
- var _a, _b;
587
- if (!this.disabled) {
588
- this.selectedIndex = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.findIndex(o => !o.disabled)) !== null && _b !== void 0 ? _b : -1;
589
- }
590
- }
591
- /**
592
- * Moves focus to the last selectable option.
593
- *
594
- * @internal
595
- */
596
- selectLastOption() {
597
- if (!this.disabled) {
598
- this.selectedIndex = findLastIndex(this.options, o => !o.disabled);
599
- }
600
- }
601
- /**
602
- * Moves focus to the next selectable option.
603
- *
604
- * @internal
605
- */
606
- selectNextOption() {
607
- if (!this.disabled && this.selectedIndex < this.options.length - 1) {
608
- this.selectedIndex += 1;
609
- }
610
- }
611
- /**
612
- * Moves focus to the previous selectable option.
613
- *
614
- * @internal
615
- */
616
- selectPreviousOption() {
617
- if (!this.disabled && this.selectedIndex > 0) {
618
- this.selectedIndex = this.selectedIndex - 1;
619
- }
620
- }
621
- /**
622
- * Updates the selected index to match the first selected option.
623
- *
624
- * @internal
625
- */
626
- setDefaultSelectedOption() {
627
- var _a, _b;
628
- this.selectedIndex = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.findIndex(el => el.defaultSelected)) !== null && _b !== void 0 ? _b : -1;
629
- }
630
- /**
631
- * Sets an option as selected and gives it focus.
632
- *
633
- * @public
634
- */
635
- setSelectedOptions() {
636
- var _a, _b, _c;
637
- if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.length) {
638
- this.selectedOptions = [this.options[this.selectedIndex]];
639
- this.ariaActiveDescendant = (_c = (_b = this.firstSelectedOption) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : "";
640
- this.focusAndScrollOptionIntoView();
641
- }
642
- }
643
- /**
644
- * Updates the list of options and resets the selected option when the slotted option content changes.
645
- *
646
- * @param prev - the previous list of slotted options
647
- * @param next - the current list of slotted options
648
- *
649
- * @internal
650
- */
651
- slottedOptionsChanged(prev, next) {
652
- this.options = next.reduce((options, item) => {
653
- if (isListboxOption(item)) {
654
- options.push(item);
655
- }
656
- return options;
657
- }, []);
658
- const setSize = `${this.options.length}`;
659
- this.options.forEach((option, index) => {
660
- if (!option.id) {
661
- option.id = uniqueId("option-");
662
- }
663
- option.ariaPosInSet = `${index + 1}`;
664
- option.ariaSetSize = setSize;
665
- });
666
- if (this.$fastController.isConnected) {
667
- this.setSelectedOptions();
668
- this.setDefaultSelectedOption();
669
- }
670
- }
671
- /**
672
- * Updates the filtered list of options when the typeahead buffer changes.
673
- *
674
- * @param prev - the previous typeahead buffer value
675
- * @param next - the current typeahead buffer value
676
- *
677
- * @internal
678
- */
679
- typeaheadBufferChanged(prev, next) {
680
- if (this.$fastController.isConnected) {
681
- const typeaheadMatches = this.getTypeaheadMatches();
682
- if (typeaheadMatches.length) {
683
- const selectedIndex = this.options.indexOf(typeaheadMatches[0]);
684
- if (selectedIndex > -1) {
685
- this.selectedIndex = selectedIndex;
686
- }
687
- }
688
- this.typeaheadExpired = false;
689
- }
690
- }
691
- };
692
- /**
693
- * A static filter to include only selectable options.
694
- *
695
- * @param n - element to filter
696
- * @public
697
- */
698
- Listbox$1.slottedOptionFilter = (n) => isListboxOption(n) && !n.hidden;
699
- /**
700
- * Typeahead timeout in milliseconds.
701
- *
702
- * @internal
703
- */
704
- Listbox$1.TYPE_AHEAD_TIMEOUT_MS = 1000;
705
- __decorate([
706
- attr({ mode: "boolean" })
707
- ], Listbox$1.prototype, "disabled", void 0);
708
- __decorate([
709
- observable
710
- ], Listbox$1.prototype, "selectedIndex", void 0);
711
- __decorate([
712
- observable
713
- ], Listbox$1.prototype, "selectedOptions", void 0);
714
- __decorate([
715
- observable
716
- ], Listbox$1.prototype, "slottedOptions", void 0);
717
- __decorate([
718
- observable
719
- ], Listbox$1.prototype, "typeaheadBuffer", void 0);
720
- /**
721
- * Includes ARIA states and properties relating to the ARIA listbox role
722
- *
723
- * @public
724
- */
725
- class DelegatesARIAListbox {
726
- }
727
- __decorate([
728
- observable
729
- ], DelegatesARIAListbox.prototype, "ariaActiveDescendant", void 0);
730
- __decorate([
731
- observable
732
- ], DelegatesARIAListbox.prototype, "ariaDisabled", void 0);
733
- __decorate([
734
- observable
735
- ], DelegatesARIAListbox.prototype, "ariaExpanded", void 0);
736
- __decorate([
737
- observable
738
- ], DelegatesARIAListbox.prototype, "ariaMultiSelectable", void 0);
739
- applyMixins(DelegatesARIAListbox, ARIAGlobalStatesAndProperties);
740
- applyMixins(Listbox$1, DelegatesARIAListbox);
741
-
742
- /**
743
- * A Listbox Custom HTML Element.
744
- * Implements the {@link https://w3c.github.io/aria/#listbox | ARIA listbox }.
745
- *
746
- * @public
747
- */
748
- class ListboxElement extends Listbox$1 {
749
- constructor() {
750
- super(...arguments);
751
- /**
752
- * The index of the most recently checked option.
753
- *
754
- * @internal
755
- * @remarks
756
- * Multiple-selection mode only.
757
- */
758
- this.activeIndex = -1;
759
- /**
760
- * The start index when checking a range of options.
761
- *
762
- * @internal
763
- */
764
- this.rangeStartIndex = -1;
765
- }
766
- /**
767
- * Returns the last checked option.
768
- *
769
- * @internal
770
- */
771
- get activeOption() {
772
- return this.options[this.activeIndex];
773
- }
774
- /**
775
- * Returns the list of checked options.
776
- *
777
- * @internal
778
- */
779
- get checkedOptions() {
780
- var _a;
781
- return (_a = this.options) === null || _a === void 0 ? void 0 : _a.filter(o => o.checked);
782
- }
783
- /**
784
- * Returns the index of the first selected option.
785
- *
786
- * @internal
787
- */
788
- get firstSelectedOptionIndex() {
789
- return this.options.indexOf(this.firstSelectedOption);
790
- }
791
- /**
792
- * Updates the `ariaActiveDescendant` property when the active index changes.
793
- *
794
- * @param prev - the previous active index
795
- * @param next - the next active index
796
- *
797
- * @internal
798
- */
799
- activeIndexChanged(prev, next) {
800
- var _a, _b;
801
- this.ariaActiveDescendant = (_b = (_a = this.options[next]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : "";
802
- this.focusAndScrollOptionIntoView();
803
- }
804
- /**
805
- * Toggles the checked state for the currently active option.
806
- *
807
- * @remarks
808
- * Multiple-selection mode only.
809
- *
810
- * @internal
811
- */
812
- checkActiveIndex() {
813
- if (!this.multiple) {
814
- return;
815
- }
816
- const activeItem = this.activeOption;
817
- if (activeItem) {
818
- activeItem.checked = true;
819
- }
820
- }
821
- /**
822
- * Sets the active index to the first option and marks it as checked.
823
- *
824
- * @remarks
825
- * Multi-selection mode only.
826
- *
827
- * @param preserveChecked - mark all options unchecked before changing the active index
828
- *
829
- * @internal
830
- */
831
- checkFirstOption(preserveChecked = false) {
832
- if (preserveChecked) {
833
- if (this.rangeStartIndex === -1) {
834
- this.rangeStartIndex = this.activeIndex + 1;
835
- }
836
- this.options.forEach((o, i) => {
837
- o.checked = inRange(i, this.rangeStartIndex);
838
- });
839
- }
840
- else {
841
- this.uncheckAllOptions();
842
- }
843
- this.activeIndex = 0;
844
- this.checkActiveIndex();
845
- }
846
- /**
847
- * Decrements the active index and sets the matching option as checked.
848
- *
849
- * @remarks
850
- * Multi-selection mode only.
851
- *
852
- * @param preserveChecked - mark all options unchecked before changing the active index
853
- *
854
- * @internal
855
- */
856
- checkLastOption(preserveChecked = false) {
857
- if (preserveChecked) {
858
- if (this.rangeStartIndex === -1) {
859
- this.rangeStartIndex = this.activeIndex;
860
- }
861
- this.options.forEach((o, i) => {
862
- o.checked = inRange(i, this.rangeStartIndex, this.options.length);
863
- });
864
- }
865
- else {
866
- this.uncheckAllOptions();
867
- }
868
- this.activeIndex = this.options.length - 1;
869
- this.checkActiveIndex();
870
- }
871
- /**
872
- * @override
873
- * @internal
874
- */
875
- connectedCallback() {
876
- super.connectedCallback();
877
- this.addEventListener("focusout", this.focusoutHandler);
878
- }
879
- /**
880
- * @override
881
- * @internal
882
- */
883
- disconnectedCallback() {
884
- this.removeEventListener("focusout", this.focusoutHandler);
885
- super.disconnectedCallback();
886
- }
24
+ var __defProp = Object.defineProperty;
25
+ var __decorateClass = (decorators, target, key, kind) => {
26
+ var result = void 0 ;
27
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
28
+ if (decorator = decorators[i])
29
+ result = (decorator(target, key, result) ) || result;
30
+ if (result) __defProp(target, key, result);
31
+ return result;
32
+ };
33
+ const _Listbox = class _Listbox extends VividElement {
34
+ constructor() {
35
+ super(...arguments);
887
36
  /**
888
- * Increments the active index and marks the matching option as checked.
889
- *
890
- * @remarks
891
- * Multiple-selection mode only.
892
- *
893
- * @param preserveChecked - mark all options unchecked before changing the active index
37
+ * The internal unfiltered list of selectable options.
894
38
  *
895
39
  * @internal
896
40
  */
897
- checkNextOption(preserveChecked = false) {
898
- if (preserveChecked) {
899
- if (this.rangeStartIndex === -1) {
900
- this.rangeStartIndex = this.activeIndex;
901
- }
902
- this.options.forEach((o, i) => {
903
- o.checked = inRange(i, this.rangeStartIndex, this.activeIndex + 1);
904
- });
905
- }
906
- else {
907
- this.uncheckAllOptions();
908
- }
909
- this.activeIndex += this.activeIndex < this.options.length - 1 ? 1 : 0;
910
- this.checkActiveIndex();
911
- }
41
+ this._options = [];
42
+ this.selectedIndex = -1;
43
+ this.selectedOptions = [];
912
44
  /**
913
- * Decrements the active index and marks the matching option as checked.
914
- *
915
- * @remarks
916
- * Multiple-selection mode only.
917
- *
918
- * @param preserveChecked - mark all options unchecked before changing the active index
45
+ * A standard `click` event creates a `focus` event before firing, so a
46
+ * `mousedown` event is used to skip that initial focus.
919
47
  *
920
48
  * @internal
921
49
  */
922
- checkPreviousOption(preserveChecked = false) {
923
- if (preserveChecked) {
924
- if (this.rangeStartIndex === -1) {
925
- this.rangeStartIndex = this.activeIndex;
926
- }
927
- if (this.checkedOptions.length === 1) {
928
- this.rangeStartIndex += 1;
929
- }
930
- this.options.forEach((o, i) => {
931
- o.checked = inRange(i, this.activeIndex, this.rangeStartIndex);
932
- });
933
- }
934
- else {
935
- this.uncheckAllOptions();
936
- }
937
- this.activeIndex -= this.activeIndex > 0 ? 1 : 0;
938
- this.checkActiveIndex();
939
- }
50
+ this.shouldSkipFocus = false;
51
+ this.typeaheadBuffer = "";
940
52
  /**
941
- * Handles click events for listbox options.
942
- *
943
- * @param e - the event object
53
+ * Flag for the typeahead timeout expiration.
944
54
  *
945
- * @override
946
- * @internal
947
- */
948
- clickHandler(e) {
949
- var _a;
950
- if (!this.multiple) {
951
- return super.clickHandler(e);
952
- }
953
- const captured = (_a = e.target) === null || _a === void 0 ? void 0 : _a.closest(`[role=option]`);
954
- if (!captured || captured.disabled) {
955
- return;
956
- }
957
- this.uncheckAllOptions();
958
- this.activeIndex = this.options.indexOf(captured);
959
- this.checkActiveIndex();
960
- this.toggleSelectedForAllCheckedOptions();
961
- return true;
962
- }
963
- /**
964
- * @override
965
55
  * @internal
966
56
  */
967
- focusAndScrollOptionIntoView() {
968
- super.focusAndScrollOptionIntoView(this.activeOption);
969
- }
57
+ this.typeaheadExpired = true;
970
58
  /**
971
- * In multiple-selection mode:
972
- * If any options are selected, the first selected option is checked when
973
- * the listbox receives focus. If no options are selected, the first
974
- * selectable option is checked.
59
+ * The timeout ID for the typeahead handler.
975
60
  *
976
- * @override
977
61
  * @internal
978
62
  */
979
- focusinHandler(e) {
980
- if (!this.multiple) {
981
- return super.focusinHandler(e);
982
- }
983
- if (!this.shouldSkipFocus && e.target === e.currentTarget) {
984
- this.uncheckAllOptions();
985
- if (this.activeIndex === -1) {
986
- this.activeIndex =
987
- this.firstSelectedOptionIndex !== -1
988
- ? this.firstSelectedOptionIndex
989
- : 0;
990
- }
991
- this.checkActiveIndex();
992
- this.setSelectedOptions();
993
- this.focusAndScrollOptionIntoView();
994
- }
995
- this.shouldSkipFocus = false;
996
- }
63
+ this.typeaheadTimeout = -1;
64
+ }
65
+ /**
66
+ * The first selected option.
67
+ *
68
+ * @internal
69
+ */
70
+ get firstSelectedOption() {
71
+ return this.selectedOptions[0] ?? null;
72
+ }
73
+ /**
74
+ * Returns true if there is one or more selectable option.
75
+ *
76
+ * @internal
77
+ */
78
+ get hasSelectableOptions() {
79
+ return this.options.length > 0 && !this.options.every((o) => o.disabled);
80
+ }
81
+ /**
82
+ * The number of options.
83
+ *
84
+ * @public
85
+ */
86
+ get length() {
87
+ return this.options.length;
88
+ }
89
+ /**
90
+ * The list of options.
91
+ *
92
+ * @public
93
+ */
94
+ get options() {
95
+ Observable.track(this, "options");
96
+ return this._options;
97
+ }
98
+ set options(value) {
99
+ this._options = value;
100
+ Observable.notify(this, "options");
101
+ }
102
+ static {
997
103
  /**
998
- * Unchecks all options when the listbox loses focus.
104
+ * A static filter to include only selectable options.
999
105
  *
1000
- * @internal
106
+ * @param n - element to filter
107
+ * @public
1001
108
  */
1002
- focusoutHandler(e) {
1003
- if (this.multiple) {
1004
- this.uncheckAllOptions();
1005
- }
1006
- }
109
+ this.slottedOptionFilter = (n) => isListboxOption(n) && !n.hidden;
110
+ }
111
+ static {
1007
112
  /**
1008
- * Handles keydown actions for listbox navigation and typeahead
113
+ * Typeahead timeout in milliseconds.
1009
114
  *
1010
- * @override
1011
115
  * @internal
1012
116
  */
1013
- keydownHandler(e) {
1014
- if (!this.multiple) {
1015
- return super.keydownHandler(e);
1016
- }
1017
- if (this.disabled) {
1018
- return true;
1019
- }
1020
- const { key, shiftKey } = e;
1021
- this.shouldSkipFocus = false;
1022
- switch (key) {
1023
- // Select the first available option
1024
- case keyHome: {
1025
- this.checkFirstOption(shiftKey);
1026
- return;
1027
- }
1028
- // Select the next selectable option
1029
- case keyArrowDown: {
1030
- this.checkNextOption(shiftKey);
1031
- return;
1032
- }
1033
- // Select the previous selectable option
1034
- case keyArrowUp: {
1035
- this.checkPreviousOption(shiftKey);
1036
- return;
1037
- }
1038
- // Select the last available option
1039
- case keyEnd: {
1040
- this.checkLastOption(shiftKey);
1041
- return;
1042
- }
1043
- case keyTab: {
1044
- this.focusAndScrollOptionIntoView();
1045
- return true;
1046
- }
1047
- case keyEscape: {
1048
- this.uncheckAllOptions();
1049
- this.checkActiveIndex();
1050
- return true;
1051
- }
1052
- case keySpace: {
1053
- e.preventDefault();
1054
- if (this.typeAheadExpired) {
1055
- this.toggleSelectedForAllCheckedOptions();
1056
- return;
1057
- }
1058
- }
1059
- // Send key to Typeahead handler
1060
- default: {
1061
- if (key.length === 1) {
1062
- this.handleTypeAhead(`${key}`);
1063
- }
1064
- return true;
1065
- }
1066
- }
117
+ this.TYPE_AHEAD_TIMEOUT_MS = 1e3;
118
+ }
119
+ /**
120
+ * Handle click events for listbox options.
121
+ *
122
+ * @internal
123
+ */
124
+ clickHandler(e) {
125
+ const captured = e.target.closest(
126
+ `option,[role=option]`
127
+ );
128
+ if (captured && !captured.disabled) {
129
+ this.selectedIndex = this.options.indexOf(captured);
130
+ return true;
1067
131
  }
1068
- /**
1069
- * Prevents `focusin` events from firing before `click` events when the
1070
- * element is unfocused.
1071
- *
1072
- * @override
1073
- * @internal
1074
- */
1075
- mousedownHandler(e) {
1076
- if (e.offsetX >= 0 && e.offsetX <= this.scrollWidth) {
1077
- return super.mousedownHandler(e);
1078
- }
132
+ }
133
+ /**
134
+ * Ensures that the provided option is focused and scrolled into view.
135
+ *
136
+ * @param optionToFocus - The option to focus
137
+ * @internal
138
+ */
139
+ focusAndScrollOptionIntoView(optionToFocus = this.firstSelectedOption) {
140
+ if (this.contains(document.activeElement) && optionToFocus !== null) {
141
+ optionToFocus.focus();
142
+ requestAnimationFrame(() => {
143
+ optionToFocus.scrollIntoView({ block: "nearest" });
144
+ });
1079
145
  }
1080
- /**
1081
- * Switches between single-selection and multi-selection mode.
1082
- *
1083
- * @internal
1084
- */
1085
- multipleChanged(prev, next) {
1086
- var _a;
1087
- this.ariaMultiSelectable = next ? "true" : null;
1088
- (_a = this.options) === null || _a === void 0 ? void 0 : _a.forEach(o => {
1089
- o.checked = next ? false : undefined;
1090
- });
1091
- this.setSelectedOptions();
146
+ }
147
+ /**
148
+ * Handles `focusin` actions for the component. When the component receives focus,
149
+ * the list of selected options is refreshed and the first selected option is scrolled
150
+ * into view.
151
+ *
152
+ * @internal
153
+ */
154
+ focusinHandler(e) {
155
+ if (!this.shouldSkipFocus && e.target === e.currentTarget) {
156
+ this.setSelectedOptions();
157
+ this.focusAndScrollOptionIntoView();
1092
158
  }
1093
- /**
1094
- * Sets an option as selected and gives it focus.
1095
- *
1096
- * @override
1097
- * @public
1098
- */
1099
- setSelectedOptions() {
1100
- if (!this.multiple) {
1101
- super.setSelectedOptions();
1102
- return;
1103
- }
1104
- if (this.$fastController.isConnected && this.options) {
1105
- this.selectedOptions = this.options.filter(o => o.selected);
1106
- this.focusAndScrollOptionIntoView();
1107
- }
159
+ this.shouldSkipFocus = false;
160
+ }
161
+ /**
162
+ * Returns the options which match the current typeahead buffer.
163
+ *
164
+ * @internal
165
+ */
166
+ getTypeaheadMatches() {
167
+ const pattern = this.typeaheadBuffer.replace(
168
+ /[.*+\-?^${}()|[\]\\]/g,
169
+ "\\$&"
170
+ );
171
+ const re = new RegExp(`^${pattern}`, "gi");
172
+ return this.options.filter((o) => o.text.trim().match(re));
173
+ }
174
+ /**
175
+ * Determines the index of the next option which is selectable, if any.
176
+ *
177
+ * @param prev - the previous selected index
178
+ * @param next - the next index to select
179
+ *
180
+ * @internal
181
+ */
182
+ getSelectableIndex(prev, next) {
183
+ const direction = prev > next ? -1 : 1;
184
+ const potentialDirection = prev + direction;
185
+ let nextSelectableOption = null;
186
+ switch (direction) {
187
+ case -1: {
188
+ nextSelectableOption = this.options.reduceRight(
189
+ (nextSelectableOption2, thisOption, index) => !nextSelectableOption2 && !thisOption.disabled && index < potentialDirection ? thisOption : nextSelectableOption2,
190
+ nextSelectableOption
191
+ );
192
+ break;
193
+ }
194
+ case 1: {
195
+ nextSelectableOption = this.options.reduce(
196
+ (nextSelectableOption2, thisOption, index) => !nextSelectableOption2 && !thisOption.disabled && index > potentialDirection ? thisOption : nextSelectableOption2,
197
+ nextSelectableOption
198
+ );
199
+ break;
200
+ }
1108
201
  }
1109
- /**
1110
- * Ensures the size is a positive integer when the property is updated.
1111
- *
1112
- * @param prev - the previous size value
1113
- * @param next - the current size value
1114
- *
1115
- * @internal
1116
- */
1117
- sizeChanged(prev, next) {
1118
- var _a;
1119
- const size = Math.max(0, parseInt((_a = next === null || next === void 0 ? void 0 : next.toFixed()) !== null && _a !== void 0 ? _a : "", 10));
1120
- if (size !== next) {
1121
- DOM.queueUpdate(() => {
1122
- this.size = size;
1123
- });
202
+ return this.options.indexOf(nextSelectableOption);
203
+ }
204
+ /**
205
+ * Handles external changes to child options.
206
+ *
207
+ * @param source - the source object
208
+ * @param propertyName - the property
209
+ *
210
+ * @internal
211
+ */
212
+ handleChange(source, propertyName) {
213
+ switch (propertyName) {
214
+ case "selected": {
215
+ if (_Listbox.slottedOptionFilter(source)) {
216
+ this.selectedIndex = this.options.indexOf(source);
1124
217
  }
1125
- }
1126
- /**
1127
- * Toggles the selected state of the provided options. If any provided items
1128
- * are in an unselected state, all items are set to selected. If every
1129
- * provided item is selected, they are all unselected.
1130
- *
1131
- * @internal
1132
- */
1133
- toggleSelectedForAllCheckedOptions() {
1134
- const enabledCheckedOptions = this.checkedOptions.filter(o => !o.disabled);
1135
- const force = !enabledCheckedOptions.every(o => o.selected);
1136
- enabledCheckedOptions.forEach(o => (o.selected = force));
1137
- this.selectedIndex = this.options.indexOf(enabledCheckedOptions[enabledCheckedOptions.length - 1]);
1138
218
  this.setSelectedOptions();
1139
- }
1140
- /**
1141
- * @override
1142
- * @internal
1143
- */
1144
- typeaheadBufferChanged(prev, next) {
1145
- if (!this.multiple) {
1146
- super.typeaheadBufferChanged(prev, next);
1147
- return;
1148
- }
1149
- if (this.$fastController.isConnected) {
1150
- const typeaheadMatches = this.getTypeaheadMatches();
1151
- const activeIndex = this.options.indexOf(typeaheadMatches[0]);
1152
- if (activeIndex > -1) {
1153
- this.activeIndex = activeIndex;
1154
- this.uncheckAllOptions();
1155
- this.checkActiveIndex();
1156
- }
1157
- this.typeAheadExpired = false;
1158
- }
1159
- }
1160
- /**
1161
- * Unchecks all options.
1162
- *
1163
- * @remarks
1164
- * Multiple-selection mode only.
1165
- *
1166
- * @param preserveChecked - reset the rangeStartIndex
1167
- *
1168
- * @internal
1169
- */
1170
- uncheckAllOptions(preserveChecked = false) {
1171
- this.options.forEach(o => (o.checked = this.multiple ? false : undefined));
1172
- if (!preserveChecked) {
1173
- this.rangeStartIndex = -1;
1174
- }
1175
- }
1176
- }
1177
- __decorate([
1178
- observable
1179
- ], ListboxElement.prototype, "activeIndex", void 0);
1180
- __decorate([
1181
- attr({ mode: "boolean" })
1182
- ], ListboxElement.prototype, "multiple", void 0);
1183
- __decorate([
1184
- attr({ converter: nullableNumberConverter })
1185
- ], ListboxElement.prototype, "size", void 0);
1186
-
1187
- var __defProp = Object.defineProperty;
1188
- var __decorateClass = (decorators, target, key, kind) => {
1189
- var result = void 0 ;
1190
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
1191
- if (decorator = decorators[i])
1192
- result = (decorator(target, key, result) ) || result;
1193
- if (result) __defProp(target, key, result);
1194
- return result;
1195
- };
1196
- class Listbox extends ListboxElement {
1197
- orientationChanged() {
1198
- if (this.orientation === "horizontal") {
1199
- this.addEventListener("keydown", this.#horizontalKeydownHandler);
1200
- } else {
1201
- this.removeEventListener("keydown", this.#horizontalKeydownHandler);
219
+ break;
220
+ }
1202
221
  }
1203
222
  }
1204
223
  /**
1205
- * Handles `keydown` actions for horizontal listbox navigation and typeahead.
224
+ * Moves focus to an option whose label matches characters typed by the user.
225
+ * Consecutive keystrokes are batched into a buffer of search text used
226
+ * to match against the set of options. If `TYPE_AHEAD_TIMEOUT_MS` passes
227
+ * between consecutive keystrokes, the search restarts.
228
+ *
229
+ * @param key - the key to be evaluated
230
+ *
231
+ * @internal
232
+ */
233
+ handleTypeAhead(key) {
234
+ if (this.typeaheadTimeout) {
235
+ window.clearTimeout(this.typeaheadTimeout);
236
+ }
237
+ this.typeaheadTimeout = window.setTimeout(
238
+ () => this.typeaheadExpired = true,
239
+ _Listbox.TYPE_AHEAD_TIMEOUT_MS
240
+ );
241
+ this.typeaheadBuffer = `${this.typeaheadExpired ? "" : this.typeaheadBuffer}${key}`;
242
+ }
243
+ /**
244
+ * Handles `keydown` actions for listbox navigation and typeahead.
1206
245
  *
1207
246
  * @internal
1208
247
  */
1209
- #horizontalKeydownHandler(e) {
248
+ keydownHandler(e) {
1210
249
  if (this.disabled) {
1211
250
  return true;
1212
251
  }
252
+ this.shouldSkipFocus = false;
1213
253
  const key = e.key;
1214
254
  switch (key) {
1215
- case keyArrowRight: {
255
+ case keyHome: {
256
+ if (!e.shiftKey) {
257
+ e.preventDefault();
258
+ this.selectFirstOption();
259
+ }
260
+ break;
261
+ }
262
+ case keyArrowDown: {
1216
263
  if (!e.shiftKey) {
1217
264
  e.preventDefault();
1218
265
  this.selectNextOption();
1219
266
  }
1220
267
  break;
1221
268
  }
1222
- case keyArrowLeft: {
269
+ case keyArrowUp: {
1223
270
  if (!e.shiftKey) {
1224
271
  e.preventDefault();
1225
272
  this.selectPreviousOption();
1226
273
  }
1227
274
  break;
1228
275
  }
276
+ case keyEnd: {
277
+ e.preventDefault();
278
+ this.selectLastOption();
279
+ break;
280
+ }
281
+ case keyTab: {
282
+ this.focusAndScrollOptionIntoView();
283
+ return true;
284
+ }
285
+ case keyEnter:
286
+ case keyEscape:
287
+ return true;
288
+ case keySpace:
289
+ if (this.typeaheadExpired) {
290
+ return true;
291
+ }
292
+ default: {
293
+ if (key.length === 1) {
294
+ this.handleTypeAhead(`${key}`);
295
+ }
296
+ return true;
297
+ }
298
+ }
299
+ }
300
+ /**
301
+ * Prevents `focusin` events from firing before `click` events when the
302
+ * element is unfocused.
303
+ *
304
+ * @internal
305
+ */
306
+ mousedownHandler(_) {
307
+ this.shouldSkipFocus = !this.contains(document.activeElement);
308
+ return true;
309
+ }
310
+ /**
311
+ * Switches between single-selection and multi-selection mode.
312
+ *
313
+ * @internal
314
+ */
315
+ multipleChanged(_, next) {
316
+ this.ariaMultiSelectable = next ? "true" : null;
317
+ }
318
+ /**
319
+ * Updates the list of selected options when the `selectedIndex` changes.
320
+ *
321
+ * @param prev - the previous selected index value
322
+ * @param next - the current selected index value
323
+ *
324
+ * @internal
325
+ */
326
+ selectedIndexChanged(prev, next) {
327
+ if (!this.hasSelectableOptions) {
328
+ this.selectedIndex = -1;
329
+ return;
330
+ }
331
+ if (this.options[this.selectedIndex]?.disabled && typeof prev === "number") {
332
+ const selectableIndex = this.getSelectableIndex(prev, next);
333
+ const newNext = selectableIndex > -1 ? selectableIndex : prev;
334
+ this.selectedIndex = newNext;
335
+ return;
336
+ }
337
+ this.setSelectedOptions();
338
+ }
339
+ /**
340
+ * Updates the selectedness of each option when the list of selected options changes.
341
+ *
342
+ * @internal
343
+ */
344
+ selectedOptionsChanged(_, next) {
345
+ const filteredNext = next.filter(_Listbox.slottedOptionFilter);
346
+ this.options.forEach((o) => {
347
+ const notifier = Observable.getNotifier(o);
348
+ notifier.unsubscribe(this, "selected");
349
+ o.selected = filteredNext.includes(o);
350
+ notifier.subscribe(this, "selected");
351
+ });
352
+ }
353
+ /**
354
+ * Moves focus to the first selectable option.
355
+ *
356
+ * @public
357
+ */
358
+ selectFirstOption() {
359
+ if (!this.disabled) {
360
+ this.selectedIndex = this.options.findIndex((o) => !o.disabled);
361
+ }
362
+ }
363
+ /**
364
+ * Moves focus to the last selectable option.
365
+ *
366
+ * @internal
367
+ */
368
+ selectLastOption() {
369
+ if (!this.disabled) {
370
+ this.selectedIndex = findLastIndex(this.options, (o) => !o.disabled);
371
+ }
372
+ }
373
+ /**
374
+ * Moves focus to the next selectable option.
375
+ *
376
+ * @internal
377
+ */
378
+ selectNextOption() {
379
+ if (!this.disabled && this.selectedIndex < this.options.length - 1) {
380
+ this.selectedIndex += 1;
381
+ }
382
+ }
383
+ /**
384
+ * Moves focus to the previous selectable option.
385
+ *
386
+ * @internal
387
+ */
388
+ selectPreviousOption() {
389
+ if (!this.disabled && this.selectedIndex > 0) {
390
+ this.selectedIndex = this.selectedIndex - 1;
1229
391
  }
1230
392
  }
1231
- slottedOptionsChanged(prev, next) {
1232
- super.slottedOptionsChanged(prev, next);
1233
- this.#disableSlottedChildren();
393
+ /**
394
+ * Updates the selected index to match the first selected option.
395
+ *
396
+ * @internal
397
+ */
398
+ setDefaultSelectedOption() {
399
+ this.selectedIndex = this.options.findIndex((el) => el.defaultSelected);
1234
400
  }
1235
- attributeChangedCallback(name, oldValue, newValue) {
1236
- super.attributeChangedCallback(name, oldValue, newValue);
1237
- if (name === "disabled") {
1238
- this.#disableSlottedChildren();
401
+ /**
402
+ * Sets an option as selected and gives it focus.
403
+ *
404
+ * @public
405
+ */
406
+ setSelectedOptions() {
407
+ if (this.options.length) {
408
+ this.selectedOptions = [this.options[this.selectedIndex]];
409
+ this.ariaActiveDescendant = this.firstSelectedOption?.id ?? "";
410
+ this.focusAndScrollOptionIntoView();
1239
411
  }
1240
412
  }
1241
- #disableSlottedChildren() {
1242
- this.options.forEach((optionElement) => {
1243
- if (!optionElement.disabled) {
1244
- optionElement.disabled = this.disabled;
413
+ /**
414
+ * Updates the list of options and resets the selected option when the slotted option content changes.
415
+ *
416
+ * @internal
417
+ */
418
+ slottedOptionsChanged(_, next) {
419
+ this.options = next.reduce((options, item) => {
420
+ if (isListboxOption(item)) {
421
+ options.push(item);
422
+ }
423
+ return options;
424
+ }, []);
425
+ const setSize = `${this.options.length}`;
426
+ this.options.forEach((option, index) => {
427
+ if (!option.id) {
428
+ option.id = uniqueId("option-");
1245
429
  }
430
+ option.ariaPosInSet = `${index + 1}`;
431
+ option.ariaSetSize = setSize;
1246
432
  });
433
+ if (this.$fastController.isConnected) {
434
+ this.setSelectedOptions();
435
+ this.setDefaultSelectedOption();
436
+ }
437
+ }
438
+ /**
439
+ * Updates the filtered list of options when the typeahead buffer changes.
440
+ *
441
+ * @internal
442
+ */
443
+ typeaheadBufferChanged(_prev, _next) {
444
+ if (this.$fastController.isConnected) {
445
+ const typeaheadMatches = this.getTypeaheadMatches();
446
+ if (typeaheadMatches.length) {
447
+ const selectedIndex = this.options.indexOf(typeaheadMatches[0]);
448
+ if (selectedIndex > -1) {
449
+ this.selectedIndex = selectedIndex;
450
+ }
451
+ }
452
+ this.typeaheadExpired = false;
453
+ }
1247
454
  }
455
+ };
456
+ // @ts-expect-error Type is incorrectly non-optional
457
+ __decorateClass([
458
+ attr({ mode: "boolean" })
459
+ ], _Listbox.prototype, "disabled");
460
+ __decorateClass([
461
+ observable
462
+ ], _Listbox.prototype, "selectedIndex");
463
+ __decorateClass([
464
+ observable
465
+ ], _Listbox.prototype, "selectedOptions");
466
+ __decorateClass([
467
+ observable
468
+ ], _Listbox.prototype, "slottedOptions");
469
+ __decorateClass([
470
+ observable
471
+ ], _Listbox.prototype, "typeaheadBuffer");
472
+ let Listbox = _Listbox;
473
+ class DelegatesARIAListbox {
1248
474
  }
475
+ // @ts-expect-error Type is incorrectly non-optional
1249
476
  __decorateClass([
1250
- attr
1251
- ], Listbox.prototype, "appearance");
477
+ observable
478
+ ], DelegatesARIAListbox.prototype, "ariaActiveDescendant");
479
+ // @ts-expect-error Type is incorrectly non-optional
1252
480
  __decorateClass([
1253
- attr
1254
- ], Listbox.prototype, "orientation");
481
+ observable
482
+ ], DelegatesARIAListbox.prototype, "ariaDisabled");
483
+ // @ts-expect-error Type is incorrectly non-optional
1255
484
  __decorateClass([
1256
- attr
1257
- ], Listbox.prototype, "shape");
485
+ observable
486
+ ], DelegatesARIAListbox.prototype, "ariaExpanded");
487
+ // @ts-expect-error Type is incorrectly non-optional
488
+ __decorateClass([
489
+ observable
490
+ ], DelegatesARIAListbox.prototype, "ariaMultiSelectable");
491
+ applyMixins(DelegatesARIAListbox, ARIAGlobalStatesAndProperties);
492
+ applyMixins(Listbox, DelegatesARIAListbox);
1258
493
 
1259
- export { DelegatesARIAListbox as D, ListboxElement as L, Listbox as a, Listbox$1 as b };
494
+ export { Listbox as L };