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