@vonage/vivid 4.24.0 → 4.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (402) hide show
  1. package/custom-elements.json +23176 -14463
  2. package/elevation/index.cjs +1 -1
  3. package/elevation/index.js +1 -1
  4. package/index.cjs +112 -150
  5. package/index.js +37 -35
  6. package/lib/accordion-item/accordion-item.d.ts +7 -1
  7. package/lib/action-group/action-group.d.ts +7 -1
  8. package/lib/alert/alert.d.ts +22 -2
  9. package/lib/audio-player/audio-player.d.ts +7 -1
  10. package/lib/badge/badge.d.ts +10 -2
  11. package/lib/banner/banner.d.ts +28 -3
  12. package/lib/breadcrumb/breadcrumb.d.ts +7 -1
  13. package/lib/breadcrumb-item/breadcrumb-item.d.ts +64 -8
  14. package/lib/button/button.d.ts +733 -8
  15. package/lib/button/locale.d.ts +3 -0
  16. package/lib/calendar/calendar.d.ts +2 -0
  17. package/lib/calendar-event/calendar-event.d.ts +7 -1
  18. package/lib/card/card.d.ts +394 -2
  19. package/lib/card/card.template.d.ts +2 -1
  20. package/lib/checkbox/checkbox.d.ts +1830 -13
  21. package/lib/combobox/combobox.d.ts +1827 -20
  22. package/lib/data-grid/data-grid-cell.d.ts +342 -2
  23. package/lib/data-grid/data-grid-row.d.ts +1 -0
  24. package/lib/data-grid/data-grid.d.ts +1 -1
  25. package/lib/data-grid/locale.d.ts +5 -0
  26. package/lib/date-picker/date-picker.d.ts +1676 -207
  27. package/lib/date-range-picker/date-range-picker.d.ts +840 -107
  28. package/lib/date-time-picker/date-time-picker.d.ts +1678 -209
  29. package/lib/dial-pad/dial-pad.d.ts +9 -1
  30. package/lib/dialog/dialog.d.ts +15 -2
  31. package/lib/divider/divider.d.ts +7 -1
  32. package/lib/fab/fab.d.ts +7 -1
  33. package/lib/file-picker/file-picker.d.ts +1509 -31
  34. package/lib/header/header.d.ts +7 -1
  35. package/lib/icon/icon.d.ts +1 -0
  36. package/lib/icon/icon.template.d.ts +2 -1
  37. package/lib/menu/menu.d.ts +17 -8
  38. package/lib/menu/name.d.ts +1 -0
  39. package/lib/menu-item/menu-item.d.ts +16 -4
  40. package/lib/nav/nav.d.ts +7 -1
  41. package/lib/nav-disclosure/nav-disclosure.d.ts +15 -2
  42. package/lib/nav-item/nav-item.d.ts +406 -4
  43. package/lib/note/note.d.ts +7 -1
  44. package/lib/number-field/locale.d.ts +3 -2
  45. package/lib/number-field/number-field.d.ts +1859 -38
  46. package/lib/option/option.d.ts +14 -2
  47. package/lib/pagination/locale.d.ts +5 -0
  48. package/lib/pagination/pagination.d.ts +341 -2
  49. package/lib/popup/popup.d.ts +1 -0
  50. package/lib/progress/progress.d.ts +7 -1
  51. package/lib/progress-ring/progress-ring.d.ts +7 -1
  52. package/lib/radio/radio.d.ts +1137 -4
  53. package/lib/radio-group/radio-group.d.ts +21 -3
  54. package/lib/range-slider/range-slider.d.ts +765 -18
  55. package/lib/rich-text-editor/definition.d.ts +2 -2
  56. package/lib/rich-text-editor/facades/vivid-prose-mirror.facade.d.ts +3 -1
  57. package/lib/rich-text-editor/locale.d.ts +1 -0
  58. package/lib/rich-text-editor/menubar/menubar.d.ts +7 -1
  59. package/lib/rich-text-editor/rich-text-editor.d.ts +352 -2
  60. package/lib/searchable-select/option-tag.d.ts +7 -1
  61. package/lib/searchable-select/searchable-select.d.ts +1859 -38
  62. package/lib/select/select.d.ts +1844 -29
  63. package/lib/selectable-box/selectable-box.d.ts +7 -1
  64. package/lib/slider/slider.d.ts +386 -4
  65. package/lib/split-button/split-button.d.ts +21 -3
  66. package/lib/switch/switch.d.ts +387 -4
  67. package/lib/tab/tab.d.ts +21 -4
  68. package/lib/tab-panel/tab-panel.d.ts +7 -1
  69. package/lib/tag/tag.d.ts +14 -2
  70. package/lib/tag-group/tag-group.d.ts +7 -1
  71. package/lib/text-area/text-area.d.ts +2174 -19
  72. package/lib/text-field/text-field.d.ts +2197 -33
  73. package/lib/time-picker/time-picker.d.ts +839 -106
  74. package/lib/toggletip/toggletip.d.ts +10 -4
  75. package/lib/tooltip/tooltip.d.ts +10 -4
  76. package/lib/tree-item/tree-item.d.ts +14 -2
  77. package/lib/tree-view/tree-view.d.ts +7 -1
  78. package/lib/video-player/video-player.d.ts +7 -1
  79. package/lib/visually-hidden/definition.d.ts +4 -0
  80. package/lib/visually-hidden/visually-hidden.d.ts +3 -0
  81. package/lib/visually-hidden/visually-hidden.template.d.ts +3 -0
  82. package/locales/de-DE.cjs +54 -4
  83. package/locales/de-DE.js +54 -4
  84. package/locales/en-GB.cjs +54 -4
  85. package/locales/en-GB.js +54 -4
  86. package/locales/en-US.cjs +54 -4
  87. package/locales/en-US.js +54 -4
  88. package/locales/ja-JP.cjs +54 -4
  89. package/locales/ja-JP.js +54 -4
  90. package/locales/zh-CN.cjs +54 -4
  91. package/locales/zh-CN.js +54 -4
  92. package/menu/index.cjs +1 -1
  93. package/menu/index.js +1 -1
  94. package/nav/index.cjs +1 -1
  95. package/nav/index.js +1 -1
  96. package/nav-disclosure/index.cjs +1 -1
  97. package/nav-disclosure/index.js +1 -1
  98. package/nav-item/index.cjs +1 -1
  99. package/nav-item/index.js +1 -1
  100. package/note/index.cjs +1 -1
  101. package/note/index.js +1 -1
  102. package/number-field/index.cjs +1 -1
  103. package/number-field/index.js +1 -1
  104. package/option/index.cjs +1 -1
  105. package/option/index.js +1 -1
  106. package/package.json +1 -1
  107. package/pagination/index.cjs +1 -1
  108. package/pagination/index.js +1 -1
  109. package/popup/index.cjs +1 -1
  110. package/popup/index.js +1 -1
  111. package/progress/index.cjs +1 -1
  112. package/progress/index.js +1 -1
  113. package/progress-ring/index.cjs +1 -1
  114. package/progress-ring/index.js +1 -1
  115. package/radio/index.cjs +1 -1
  116. package/radio/index.js +1 -1
  117. package/radio-group/index.cjs +1 -1
  118. package/radio-group/index.js +1 -1
  119. package/range-slider/index.cjs +1 -1
  120. package/range-slider/index.js +1 -1
  121. package/rich-text-editor/index.cjs +1 -1
  122. package/rich-text-editor/index.js +1 -1
  123. package/searchable-select/index.cjs +1 -1
  124. package/searchable-select/index.js +1 -1
  125. package/select/index.cjs +1 -1
  126. package/select/index.js +1 -1
  127. package/selectable-box/index.cjs +1 -1
  128. package/selectable-box/index.js +1 -1
  129. package/shared/affix.cjs +13 -7
  130. package/shared/affix.js +13 -8
  131. package/shared/aria/delegates-aria.d.ts +7 -1
  132. package/shared/aria/host-semantics.d.ts +7 -1
  133. package/shared/breadcrumb-item.cjs +2 -5
  134. package/shared/breadcrumb-item.js +2 -5
  135. package/shared/button.cjs +13 -11
  136. package/shared/button.js +13 -11
  137. package/shared/calendar-picker.template.cjs +3 -3
  138. package/shared/calendar-picker.template.js +1 -1
  139. package/shared/char-count.cjs +92 -0
  140. package/shared/char-count.js +90 -0
  141. package/shared/definition.cjs +19 -3
  142. package/shared/definition.js +20 -4
  143. package/shared/definition10.js +1 -1
  144. package/shared/definition11.cjs +27 -44
  145. package/shared/definition11.js +28 -45
  146. package/shared/definition12.js +1 -1
  147. package/shared/definition13.cjs +25 -0
  148. package/shared/definition13.js +26 -1
  149. package/shared/definition14.cjs +53 -22
  150. package/shared/definition14.js +54 -23
  151. package/shared/definition15.cjs +32 -37
  152. package/shared/definition15.js +31 -37
  153. package/shared/definition16.cjs +44 -64
  154. package/shared/definition16.js +43 -64
  155. package/shared/definition17.cjs +608 -524
  156. package/shared/definition17.js +604 -520
  157. package/shared/definition18.cjs +10 -14
  158. package/shared/definition18.js +9 -14
  159. package/shared/definition19.cjs +85 -100
  160. package/shared/definition19.js +75 -91
  161. package/shared/definition2.js +1 -1
  162. package/shared/definition20.cjs +15 -20
  163. package/shared/definition20.js +14 -20
  164. package/shared/definition21.cjs +24 -5
  165. package/shared/definition21.js +25 -6
  166. package/shared/definition22.cjs +12 -6
  167. package/shared/definition22.js +13 -7
  168. package/shared/definition23.cjs +5 -38
  169. package/shared/definition23.js +5 -37
  170. package/shared/definition24.cjs +2 -7
  171. package/shared/definition24.js +3 -8
  172. package/shared/definition25.js +1 -1
  173. package/shared/definition26.cjs +157 -171
  174. package/shared/definition26.js +156 -171
  175. package/shared/definition27.cjs +1 -1
  176. package/shared/definition27.js +2 -2
  177. package/shared/definition28.cjs +33 -18
  178. package/shared/definition28.js +34 -19
  179. package/shared/definition29.js +1 -1
  180. package/shared/definition3.cjs +1 -1
  181. package/shared/definition3.js +2 -2
  182. package/shared/definition30.cjs +96 -482
  183. package/shared/definition30.js +99 -482
  184. package/shared/definition31.cjs +334 -57
  185. package/shared/definition31.js +333 -56
  186. package/shared/definition32.cjs +104 -19
  187. package/shared/definition32.js +105 -20
  188. package/shared/definition33.cjs +67 -15
  189. package/shared/definition33.js +66 -14
  190. package/shared/definition34.cjs +15 -50
  191. package/shared/definition34.js +14 -49
  192. package/shared/definition35.cjs +28 -397
  193. package/shared/definition35.js +27 -397
  194. package/shared/definition36.cjs +415 -54
  195. package/shared/definition36.js +415 -55
  196. package/shared/definition37.cjs +57 -234
  197. package/shared/definition37.js +57 -233
  198. package/shared/definition38.cjs +228 -66
  199. package/shared/definition38.js +227 -65
  200. package/shared/definition39.cjs +52 -44
  201. package/shared/definition39.js +51 -43
  202. package/shared/definition4.cjs +31 -24
  203. package/shared/definition4.js +33 -26
  204. package/shared/definition40.cjs +56 -266
  205. package/shared/definition40.js +55 -265
  206. package/shared/definition41.cjs +285 -142
  207. package/shared/definition41.js +285 -142
  208. package/shared/definition42.cjs +156 -564
  209. package/shared/definition42.js +156 -565
  210. package/shared/definition43.cjs +554 -14378
  211. package/shared/definition43.js +553 -14377
  212. package/shared/definition44.cjs +14418 -1155
  213. package/shared/definition44.js +14417 -1156
  214. package/shared/definition45.cjs +1049 -677
  215. package/shared/definition45.js +1050 -678
  216. package/shared/definition46.cjs +848 -113
  217. package/shared/definition46.js +847 -112
  218. package/shared/definition47.cjs +125 -90
  219. package/shared/definition47.js +124 -89
  220. package/shared/definition48.cjs +88 -455
  221. package/shared/definition48.js +87 -454
  222. package/shared/definition49.cjs +466 -109
  223. package/shared/definition49.js +466 -109
  224. package/shared/definition5.cjs +8 -7
  225. package/shared/definition5.js +6 -5
  226. package/shared/definition50.cjs +106 -106
  227. package/shared/definition50.js +105 -105
  228. package/shared/definition51.cjs +136 -15
  229. package/shared/definition51.js +135 -14
  230. package/shared/definition52.cjs +16 -115
  231. package/shared/definition52.js +15 -114
  232. package/shared/definition53.cjs +78 -412
  233. package/shared/definition53.js +77 -410
  234. package/shared/definition54.cjs +445 -23
  235. package/shared/definition54.js +443 -22
  236. package/shared/definition55.cjs +22 -136
  237. package/shared/definition55.js +21 -135
  238. package/shared/definition56.cjs +95 -291
  239. package/shared/definition56.js +95 -292
  240. package/shared/definition57.cjs +192 -480
  241. package/shared/definition57.js +190 -479
  242. package/shared/definition58.cjs +411 -24
  243. package/shared/definition58.js +410 -24
  244. package/shared/definition59.cjs +27 -144
  245. package/shared/definition59.js +27 -143
  246. package/shared/definition6.js +1 -1
  247. package/shared/definition60.cjs +83 -54
  248. package/shared/definition60.js +82 -53
  249. package/shared/definition61.cjs +78 -166
  250. package/shared/definition61.js +77 -164
  251. package/shared/definition62.cjs +143 -232
  252. package/shared/definition62.js +141 -231
  253. package/shared/definition63.cjs +234 -69417
  254. package/shared/definition63.js +233 -69416
  255. package/shared/definition64.cjs +69454 -28
  256. package/shared/definition64.js +69453 -27
  257. package/shared/definition65.cjs +28 -2168
  258. package/shared/definition65.js +27 -2166
  259. package/shared/definition66.cjs +27 -0
  260. package/shared/definition66.js +23 -0
  261. package/shared/definition67.cjs +2203 -0
  262. package/shared/definition67.js +2198 -0
  263. package/shared/definition7.cjs +11 -2
  264. package/shared/definition7.js +12 -3
  265. package/shared/definition8.cjs +24 -11
  266. package/shared/definition8.js +26 -13
  267. package/shared/definition9.cjs +1 -2
  268. package/shared/definition9.js +2 -3
  269. package/shared/delegates-aria.js +1 -1
  270. package/shared/deprecation/replaced-props.d.ts +20 -0
  271. package/shared/divider.cjs +41 -0
  272. package/shared/divider.js +38 -0
  273. package/shared/feedback/feedback-message.d.ts +345 -0
  274. package/shared/feedback/locale.d.ts +4 -0
  275. package/{lib/text-anchor/text-anchor.d.ts → shared/feedback/mixins.d.ts} +64 -41
  276. package/shared/form-associated.cjs +124 -100
  277. package/shared/form-associated.js +125 -101
  278. package/shared/form-element.cjs +84 -0
  279. package/shared/form-element.js +82 -0
  280. package/shared/foundation/button/button.d.ts +379 -3
  281. package/shared/foundation/form-associated/form-associated.d.ts +753 -49
  282. package/shared/foundation/listbox/listbox.d.ts +1 -1
  283. package/shared/foundation/vivid-element/vivid-element.d.ts +16 -0
  284. package/shared/host-semantics.js +1 -1
  285. package/shared/key-codes.js +1 -1
  286. package/shared/linkable.cjs +70 -0
  287. package/shared/linkable.js +68 -0
  288. package/shared/localization/Locale.d.ts +16 -0
  289. package/shared/mixins.cjs +309 -0
  290. package/shared/mixins.js +303 -0
  291. package/shared/patterns/affix.d.ts +18 -3
  292. package/shared/patterns/anchored.d.ts +20 -8
  293. package/shared/patterns/char-count/char-count.d.ts +351 -0
  294. package/shared/patterns/char-count/index.d.ts +1 -0
  295. package/shared/patterns/char-count/locale.d.ts +4 -0
  296. package/shared/patterns/form-elements/form-element.d.ts +744 -0
  297. package/shared/patterns/form-elements/index.d.ts +3 -1
  298. package/shared/patterns/form-elements/with-error-text.d.ts +1122 -0
  299. package/shared/patterns/form-elements/with-success-text.d.ts +341 -0
  300. package/shared/patterns/index.d.ts +2 -0
  301. package/shared/patterns/linkable.d.ts +394 -0
  302. package/shared/patterns/localized.d.ts +7 -1
  303. package/shared/patterns/trapped-focus.d.ts +7 -1
  304. package/shared/picker-field/mixins/calendar-picker.d.ts +420 -52
  305. package/shared/picker-field/mixins/calendar-picker.template.d.ts +420 -52
  306. package/shared/picker-field/mixins/inline-time-picker/inline-time-picker.d.ts +7 -1
  307. package/shared/picker-field/mixins/min-max-calendar-picker.d.ts +843 -107
  308. package/shared/picker-field/mixins/single-date-picker.d.ts +1259 -155
  309. package/shared/picker-field/mixins/single-value-picker.d.ts +417 -49
  310. package/shared/picker-field/mixins/time-selection-picker.d.ts +842 -106
  311. package/shared/picker-field/mixins/time-selection-picker.template.d.ts +839 -103
  312. package/shared/picker-field/picker-field.d.ts +1492 -16
  313. package/shared/picker-field.template.cjs +26 -35
  314. package/shared/picker-field.template.js +27 -36
  315. package/shared/repeat.js +1 -1
  316. package/shared/slider.template.cjs +1 -1
  317. package/shared/slider.template.js +1 -1
  318. package/shared/time-selection-picker.template.cjs +10 -15
  319. package/shared/time-selection-picker.template.js +10 -16
  320. package/shared/vivid-element.cjs +63 -4
  321. package/shared/vivid-element.js +63 -3
  322. package/shared/with-error-text.cjs +56 -0
  323. package/shared/with-error-text.js +54 -0
  324. package/shared/with-success-text.cjs +23 -0
  325. package/shared/with-success-text.js +21 -0
  326. package/side-drawer/index.cjs +1 -1
  327. package/side-drawer/index.js +1 -1
  328. package/slider/index.cjs +1 -1
  329. package/slider/index.js +1 -1
  330. package/split-button/index.cjs +1 -1
  331. package/split-button/index.js +1 -1
  332. package/styles/core/all.css +1 -1
  333. package/styles/core/theme.css +1 -1
  334. package/styles/core/typography.css +1 -1
  335. package/styles/tokens/theme-dark.css +4 -4
  336. package/styles/tokens/theme-light.css +4 -4
  337. package/styles/tokens/vivid-2-compat.css +1 -1
  338. package/switch/index.cjs +1 -1
  339. package/switch/index.js +1 -1
  340. package/tab/index.cjs +1 -1
  341. package/tab/index.js +1 -1
  342. package/tab-panel/index.cjs +1 -1
  343. package/tab-panel/index.js +1 -1
  344. package/tabs/index.cjs +1 -1
  345. package/tabs/index.js +1 -1
  346. package/tag/index.cjs +1 -1
  347. package/tag/index.js +1 -1
  348. package/tag-group/index.cjs +1 -1
  349. package/tag-group/index.js +1 -1
  350. package/text-area/index.cjs +1 -1
  351. package/text-area/index.js +1 -1
  352. package/text-field/index.cjs +1 -1
  353. package/text-field/index.js +1 -1
  354. package/time-picker/index.cjs +1 -1
  355. package/time-picker/index.js +1 -1
  356. package/toggletip/index.cjs +1 -1
  357. package/toggletip/index.js +1 -1
  358. package/tooltip/index.cjs +1 -1
  359. package/tooltip/index.js +1 -1
  360. package/tree-item/index.cjs +1 -1
  361. package/tree-item/index.js +1 -1
  362. package/tree-view/index.cjs +1 -1
  363. package/tree-view/index.js +1 -1
  364. package/video-player/index.cjs +1 -1
  365. package/video-player/index.js +1 -1
  366. package/visually-hidden/index.cjs +5 -0
  367. package/visually-hidden/index.js +3 -0
  368. package/vivid.api.json +845 -1503
  369. package/lib/checkbox/checkbox.form-associated.d.ts +0 -11
  370. package/lib/file-picker/file-picker.form-associated.d.ts +0 -11
  371. package/lib/number-field/number-field.form-associated.d.ts +0 -11
  372. package/lib/radio/radio.form-associated.d.ts +0 -13
  373. package/lib/range-slider/range-slider.form-associated.d.ts +0 -11
  374. package/lib/searchable-select/searchable-select.form-associated.d.ts +0 -11
  375. package/lib/select/select.form-associated.d.ts +0 -11
  376. package/lib/slider/slider.form-associated.d.ts +0 -11
  377. package/lib/switch/switch.form-associated.d.ts +0 -11
  378. package/lib/text-anchor/definition.d.ts +0 -2
  379. package/lib/text-anchor/text-anchor.template.d.ts +0 -3
  380. package/lib/text-area/text-area.form-associated.d.ts +0 -11
  381. package/lib/text-field/text-field.form-associated.d.ts +0 -11
  382. package/shared/anchor.cjs +0 -49
  383. package/shared/anchor.js +0 -47
  384. package/shared/apply-mixins.cjs +0 -23
  385. package/shared/apply-mixins.js +0 -21
  386. package/shared/applyMixinsWithObservables.cjs +0 -15
  387. package/shared/applyMixinsWithObservables.js +0 -13
  388. package/shared/direction.cjs +0 -17
  389. package/shared/direction.js +0 -15
  390. package/shared/form-elements.cjs +0 -209
  391. package/shared/form-elements.js +0 -202
  392. package/shared/foundation/anchor/anchor.d.ts +0 -11
  393. package/shared/foundation/utilities/apply-mixins.d.ts +0 -1
  394. package/shared/patterns/form-elements/form-elements.d.ts +0 -58
  395. package/shared/picker-field/picker-field.form-associated.d.ts +0 -11
  396. package/shared/text-anchor.cjs +0 -38
  397. package/shared/text-anchor.js +0 -36
  398. package/shared/text-anchor.template.cjs +0 -35
  399. package/shared/text-anchor.template.js +0 -33
  400. package/shared/utils/applyMixinsWithObservables.d.ts +0 -1
  401. package/text-anchor/index.cjs +0 -17
  402. package/text-anchor/index.js +0 -15
@@ -1,156 +1,891 @@
1
- import { C as Checkbox, c as checkboxDefinition } from './definition15.js';
2
- import { R as Radio, r as radioDefinition } from './definition41.js';
3
- import { V as VividElement, a as attr, h as html, g as createRegisterFunction, i as defineVividComponent } from './vivid-element.js';
4
- import { D as DelegatesAria, d as delegateAria } from './delegates-aria.js';
5
- import { C as Connotation } from './enums.js';
6
- import { c as classNames } from './class-names.js';
1
+ import { P as Popup, p as popupDefinition } from './definition67.js';
2
+ import { i as iconDefinition } from './definition28.js';
3
+ import { l as listboxOptionDefinition } from './definition37.js';
4
+ import { D as DOM, O as Observable, o as observable, a as attr, v as volatile, h as html, d as createRegisterFunction, f as defineVividComponent } from './vivid-element.js';
5
+ import { W as WithLightDOMFeedback, f as feedbackMessageDefinition } from './mixins.js';
6
+ import { L as Listbox } from './listbox.js';
7
+ import { H as HostSemantics, a as applyHostSemantics } from './host-semantics.js';
8
+ import { F as FormAssociated } from './form-associated.js';
9
+ import { i as inRange } from './numbers.js';
10
+ import { W as WithErrorText } from './with-error-text.js';
11
+ import { W as WithSuccessText } from './with-success-text.js';
12
+ import { F as FormElement } from './form-element.js';
13
+ import { A as AffixIconWithTrailing, a as affixIconTemplateFactory, I as IconWrapper } from './affix.js';
14
+ import { u as uniqueId } from './strings.js';
15
+ import { a as keySpace, b as keyEscape, c as keyTab, d as keyEnd, e as keyArrowUp, f as keyArrowDown, g as keyHome, k as keyEnter } from './key-codes.js';
16
+ import { L as ListboxOption } from './option.js';
17
+ import { c as chevronTemplateFactory } from './definition11.js';
18
+ import { h as handleEscapeKeyAndStopPropogation } from './index.js';
19
+ import { r as ref } from './ref.js';
7
20
  import { w as when } from './when.js';
21
+ import { s as slotted } from './slotted.js';
22
+ import { c as classNames } from './class-names.js';
8
23
 
9
- const styles = ":host{display:flex}.base.connotation-cta{--_connotation-color-firm-all: var(--vvd-selectable-box-cta-firm-all, var(--vvd-color-cta-600));--_connotation-color-pale: var(--vvd-selectable-box-cta-pale, var(--vvd-color-cta-300));--_connotation-color-fierce: var(--vvd-selectable-box-cta-fierce, var(--vvd-color-cta-700));--_connotation-color-faint: var(--vvd-selectable-box-cta-faint, var(--vvd-color-cta-50));--_connotation-color-soft: var(--vvd-selectable-box-cta-soft, var(--vvd-color-cta-100))}.base:not(.connotation-cta){--_connotation-color-firm-all: var(--vvd-selectable-box-accent-firm-all, var(--vvd-color-neutral-600));--_connotation-color-pale: var(--vvd-selectable-box-accent-pale, var(--vvd-color-neutral-300));--_connotation-color-fierce: var(--vvd-selectable-box-accent-fierce, var(--vvd-color-neutral-700));--_connotation-color-faint: var(--vvd-selectable-box-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-selectable-box-accent-soft, var(--vvd-color-neutral-100))}.base{--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: transparent;--_appearance-color-outline: var(--_connotation-color-pale)}.base:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: transparent;--_appearance-color-outline: var(--_connotation-color-firm-all)}.base:where(.selected):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: var(--_connotation-color-pale)}.base:where(.selected):where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-firm-all);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: var(--_connotation-color-firm-all)}.base{position:relative;padding:var(--selectable-box-spacing, 16px);border:1px solid var(--_appearance-color-outline);border-radius:8px;background-color:var(--_appearance-color-fill);inline-size:100%;padding-block-start:calc(var(--selectable-box-spacing, 16px) + 36px);text-align:start}.base:focus-visible{--focus-stroke-gap-color: transparent;box-shadow:0 0 0 4px color-mix(in srgb,var(--vvd-color-cta-500),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px))}.base.tight{overflow:hidden;min-height:calc(var(--selectable-box-spacing, 16px) * 2 + 22px);padding:0}.base.clickable{cursor:pointer}.control{position:absolute;inset-block-start:var(--selectable-box-spacing, 16px);inset-inline-end:var(--selectable-box-spacing, 16px)}";
24
+ const styles = ".chevron{display:flex;flex-shrink:0;font:var(--vvd-typography-base-extended);transform:rotate(0);transition:transform .2s}:host([data-expanded=true]) .chevron,:host([open]) .chevron{transform:rotate(180deg)}:host(:focus-visible){outline:none}:host{display:inline-flex;flex-direction:column;gap:4px;--_low-ink-color: var(--vvd-color-neutral-600);--focus-stroke-gap-color: transparent}:host([disabled]){--_low-ink-color: var(--vvd-color-neutral-400);cursor:not-allowed}.label{color:var(--vvd-color-canvas-text);contain:inline-size;font:var(--vvd-typography-base)}.control{--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--vvd-color-canvas);--_appearance-color-outline: var(--vvd-color-neutral-500)}.control.appearance-ghost{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--vvd-color-canvas);--_appearance-color-outline: var(--vvd-color-neutral-700)}.control:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)).appearance-ghost{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}.control:where(.disabled,:disabled){--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: var(--vvd-color-neutral-100);--_appearance-color-outline: var(--vvd-color-neutral-300)}.control:where(.disabled,:disabled).appearance-ghost{--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control:where(.readonly):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--vvd-color-neutral-200);--_appearance-color-outline: var(--vvd-color-neutral-400)}.control:where(.readonly):where(:not(.disabled,:disabled)).appearance-ghost{--_appearance-color-text: var(--vvd-color-neutral-600);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control:where(.error):where(:not(.disabled,:disabled)){--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-alert-50);--_appearance-color-outline: var(--vvd-color-alert-500)}.control:where(.error):where(:not(.disabled,:disabled)).appearance-ghost{--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-alert-50);--_appearance-color-outline: transparent}.control:where(.success):where(:not(.disabled,:disabled)){--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-success-50);--_appearance-color-outline: var(--vvd-color-success-500)}.control:where(.success):where(:not(.disabled,:disabled)).appearance-ghost{--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-success-50);--_appearance-color-outline: transparent}.control{--_connotation-color-primary: var(--vvd-select-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-primary-text: var(--vvd-select-accent-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-select-accent-primary-increment, var(--vvd-color-neutral-800));--_connotation-color-intermediate: var(--vvd-select-accent-intermediate, var(--vvd-color-neutral-500));--_connotation-color-faint: var(--vvd-select-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-select-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-firm: var(--vvd-select-accent-firm, var(--vvd-color-canvas-text));--_connotation-color-fierce: var(--vvd-select-accent-fierce, var(--vvd-color-neutral-700))}.control{border-radius:var(--_select-control-border-radius);block-size:var(--_select-block-size);padding-inline:var(--_select-padding-inline)}.control{--_select-icon-size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))/2) ;--_select-block-size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) ;--_select-padding-inline: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))*.4) ;display:flex;align-items:center;justify-content:space-between;background-color:var(--_appearance-color-fill);box-shadow:inset 0 0 0 1px var(--_appearance-color-outline);color:var(--_appearance-color-text);font:var(--vvd-typography-base);gap:8px;transition:box-shadow .2s,background-color .2s}.control.size-condensed{--_select-icon-size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))*.4) ;--_select-block-size: calc(1px*(32 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) ;--_select-padding-inline: calc(1px*(24 + 4*clamp(-1, var(--vvd-size-density, 0), 2))/2) }.control.size-condensed:not(.shape-pill){--_select-control-border-radius: 4px}.control-wrapper{position:relative}.control:not(.disabled){cursor:pointer}.control.disabled{pointer-events:none}.control:not(.shape-pill){--_select-control-border-radius: 8px}.control.shape-pill{--_select-control-border-radius: 24px}:host(:focus-visible) .control{box-shadow:0 0 0 4px color-mix(in srgb,var(--vvd-color-cta-500),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px))}.listbox{display:flex;max-height:var(--select-height, 408px);flex-direction:column;padding:4px;gap:2px;overflow-y:auto}:host([multiple]:focus-visible) .listbox{box-shadow:0 0 0 4px color-mix(in srgb,var(--vvd-color-cta-500),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px));border-radius:8px}.selected-value{display:flex;overflow:hidden;flex-grow:1;align-items:center;column-gap:12px;white-space:nowrap}.selected-value .text{overflow:hidden;max-inline-size:100%;text-overflow:ellipsis}.control.shows-placeholder .selected-value .text{color:var(--vvd-color-neutral-600)}.selected-value slot[name=icon]{flex:0 0 var(--_select-icon-size);font-size:var(--_select-icon-size);line-height:1}.control.has-meta .selected-value{padding-inline-end:8px}.feedback-wrapper{display:contents}::part(popup-base){inline-size:max-content;min-inline-size:var(--_select-fixed-width, 100%)}:host([multiple]) ::part(popup-base){position:static}";
10
25
 
11
26
  var __defProp = Object.defineProperty;
27
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
28
  var __decorateClass = (decorators, target, key, kind) => {
13
- var result = void 0 ;
29
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
14
30
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
15
31
  if (decorator = decorators[i])
16
- result = (decorator(target, key, result) ) || result;
17
- if (result) __defProp(target, key, result);
32
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
33
+ if (kind && result) __defProp(target, key, result);
18
34
  return result;
19
35
  };
20
- class SelectableBox extends DelegatesAria(VividElement) {
36
+ class Select extends WithLightDOMFeedback(
37
+ WithErrorText(
38
+ WithSuccessText(
39
+ FormElement(HostSemantics(AffixIconWithTrailing(FormAssociated(Listbox))))
40
+ )
41
+ )
42
+ ) {
21
43
  constructor() {
22
44
  super(...arguments);
23
- this.checked = false;
24
- this.clickable = false;
25
- this.clickableBox = false;
26
- this.tight = false;
45
+ /**
46
+ * @internal
47
+ */
48
+ this.proxy = document.createElement("select");
49
+ this.activeIndex = -1;
50
+ /**
51
+ * The start index when checking a range of options.
52
+ *
53
+ * @internal
54
+ */
55
+ this.rangeStartIndex = -1;
56
+ this.open = false;
57
+ /**
58
+ * The unique id for the internal listbox element.
59
+ *
60
+ * @internal
61
+ */
62
+ this.listboxId = uniqueId("listbox-");
63
+ this.maxHeight = 0;
64
+ this.fixedDropdown = false;
65
+ this.placeholderOption = null;
66
+ this._feedbackWrapper = null;
67
+ }
68
+ /**
69
+ * Returns the last checked option.
70
+ *
71
+ * @internal
72
+ */
73
+ get activeOption() {
74
+ return this.options[this.activeIndex];
75
+ }
76
+ /**
77
+ * Returns the list of checked options.
78
+ *
79
+ * @internal
80
+ */
81
+ get checkedOptions() {
82
+ return this.options.filter((o) => o.checked);
83
+ }
84
+ /**
85
+ * Returns the index of the first selected option.
86
+ *
87
+ * @internal
88
+ */
89
+ get firstSelectedOptionIndex() {
90
+ return this.options.indexOf(this.firstSelectedOption);
91
+ }
92
+ /**
93
+ * Updates the `ariaActiveDescendant` property when the active index changes.
94
+ *
95
+ * @internal
96
+ */
97
+ activeIndexChanged(_, next) {
98
+ this._activeDescendant = this.options[next]?.id ?? "";
99
+ this.focusAndScrollOptionIntoView();
100
+ }
101
+ /**
102
+ * Toggles the checked state for the currently active option.
103
+ *
104
+ * @remarks
105
+ * Multiple-selection mode only.
106
+ *
107
+ * @internal
108
+ */
109
+ checkActiveIndex() {
110
+ const activeItem = this.activeOption;
111
+ if (activeItem) {
112
+ activeItem.checked = true;
113
+ }
27
114
  }
28
115
  /**
116
+ * Sets the active index to the first option and marks it as checked.
117
+ *
118
+ * @remarks
119
+ * Multi-selection mode only.
120
+ *
121
+ * @param preserveChecked - mark all options unchecked before changing the active index
122
+ *
29
123
  * @internal
30
124
  */
31
- _handleCheckedChange() {
32
- if (this.controlType === "radio" && this.checked) return;
33
- this.checked = !this.checked;
34
- if (this.clickableBox || this.clickable) this.$emit("change");
125
+ checkFirstOption(preserveChecked) {
126
+ if (preserveChecked) {
127
+ if (this.rangeStartIndex === -1) {
128
+ this.rangeStartIndex = this.activeIndex + 1;
129
+ }
130
+ this.options.forEach((o, i) => {
131
+ o.checked = inRange(i, this.rangeStartIndex);
132
+ });
133
+ } else {
134
+ this.uncheckAllOptions();
135
+ }
136
+ this.activeIndex = 0;
137
+ this.checkActiveIndex();
138
+ }
139
+ /**
140
+ * Decrements the active index and sets the matching option as checked.
141
+ *
142
+ * @remarks
143
+ * Multi-selection mode only.
144
+ *
145
+ * @param preserveChecked - mark all options unchecked before changing the active index
146
+ *
147
+ * @internal
148
+ */
149
+ checkLastOption(preserveChecked) {
150
+ if (preserveChecked) {
151
+ if (this.rangeStartIndex === -1) {
152
+ this.rangeStartIndex = this.activeIndex;
153
+ }
154
+ this.options.forEach((o, i) => {
155
+ o.checked = inRange(i, this.rangeStartIndex, this.length);
156
+ });
157
+ } else {
158
+ this.uncheckAllOptions();
159
+ }
160
+ this.activeIndex = this.length - 1;
161
+ this.checkActiveIndex();
35
162
  }
36
163
  /**
164
+ * Increments the active index and marks the matching option as checked.
165
+ *
166
+ * @remarks
167
+ * Multiple-selection mode only.
168
+ *
169
+ * @param preserveChecked - mark all options unchecked before changing the active index
170
+ *
37
171
  * @internal
38
172
  */
39
- _handleKeydown(event) {
40
- if ((event.code === "Space" || event.code === "Enter") && (this.clickableBox || this.clickable))
41
- return this._handleCheckedChange();
173
+ checkNextOption(preserveChecked) {
174
+ if (preserveChecked) {
175
+ if (this.rangeStartIndex === -1) {
176
+ this.rangeStartIndex = this.activeIndex;
177
+ }
178
+ this.options.forEach((o, i) => {
179
+ o.checked = inRange(i, this.rangeStartIndex, this.activeIndex + 1);
180
+ });
181
+ } else {
182
+ this.uncheckAllOptions();
183
+ }
184
+ this.activeIndex += this.activeIndex < this.length - 1 ? 1 : 0;
185
+ this.checkActiveIndex();
186
+ }
187
+ /**
188
+ * Decrements the active index and marks the matching option as checked.
189
+ *
190
+ * @remarks
191
+ * Multiple-selection mode only.
192
+ *
193
+ * @param preserveChecked - mark all options unchecked before changing the active index
194
+ *
195
+ * @internal
196
+ */
197
+ checkPreviousOption(preserveChecked) {
198
+ if (preserveChecked) {
199
+ if (this.rangeStartIndex === -1) {
200
+ this.rangeStartIndex = this.activeIndex;
201
+ }
202
+ if (this.checkedOptions.length === 1) {
203
+ this.rangeStartIndex += 1;
204
+ }
205
+ this.options.forEach((o, i) => {
206
+ o.checked = inRange(i, this.activeIndex, this.rangeStartIndex);
207
+ });
208
+ } else {
209
+ this.uncheckAllOptions();
210
+ }
211
+ this.activeIndex -= this.activeIndex > 0 ? 1 : 0;
212
+ this.checkActiveIndex();
213
+ }
214
+ /**
215
+ * @internal
216
+ */
217
+ focusAndScrollOptionIntoView() {
218
+ super.focusAndScrollOptionIntoView(this.activeOption);
219
+ }
220
+ /**
221
+ * In multiple-selection mode:
222
+ * If any options are selected, the first selected option is checked when
223
+ * the listbox receives focus. If no options are selected, the first
224
+ * selectable option is checked.
225
+ *
226
+ * @internal
227
+ */
228
+ focusinHandler(e) {
229
+ if (!this.multiple) {
230
+ return super.focusinHandler(e);
231
+ }
232
+ if (!this.shouldSkipFocus && e.target === e.currentTarget) {
233
+ this.uncheckAllOptions();
234
+ if (this.activeIndex === -1) {
235
+ this.activeIndex = this.firstSelectedOptionIndex !== -1 ? this.firstSelectedOptionIndex : 0;
236
+ }
237
+ this.checkActiveIndex();
238
+ this.setSelectedOptions();
239
+ this.focusAndScrollOptionIntoView();
240
+ }
241
+ this.shouldSkipFocus = false;
242
+ }
243
+ /**
244
+ * Sets an option as selected and gives it focus.
245
+ *
246
+ * @public
247
+ */
248
+ setSelectedOptions() {
249
+ if (!this.multiple) {
250
+ super.setSelectedOptions();
251
+ return;
252
+ }
253
+ if (this.$fastController.isConnected && this.options) {
254
+ this.selectedOptions = this.options.filter((o) => o.selected);
255
+ this.focusAndScrollOptionIntoView();
256
+ }
257
+ }
258
+ /**
259
+ * Toggles the selected state of the provided options. If any provided items
260
+ * are in an unselected state, all items are set to selected. If every
261
+ * provided item is selected, they are all unselected.
262
+ *
263
+ * @internal
264
+ */
265
+ toggleSelectedForAllCheckedOptions() {
266
+ const enabledCheckedOptions = this.checkedOptions.filter(
267
+ (o) => !o.disabled
268
+ );
269
+ const force = !enabledCheckedOptions.every((o) => o.selected);
270
+ enabledCheckedOptions.forEach((o) => o.selected = force);
271
+ this.selectedIndex = this.options.indexOf(
272
+ enabledCheckedOptions[enabledCheckedOptions.length - 1]
273
+ );
274
+ this.setSelectedOptions();
275
+ this.updateValue(true);
276
+ }
277
+ /**
278
+ * @internal
279
+ */
280
+ typeaheadBufferChanged(prev, next) {
281
+ if (!this.multiple) {
282
+ super.typeaheadBufferChanged(prev, next);
283
+ return;
284
+ }
285
+ if (this.$fastController.isConnected) {
286
+ const typeaheadMatches = this.getTypeaheadMatches();
287
+ const activeIndex = this.options.indexOf(typeaheadMatches[0]);
288
+ if (activeIndex > -1) {
289
+ this.activeIndex = activeIndex;
290
+ this.uncheckAllOptions();
291
+ this.checkActiveIndex();
292
+ }
293
+ this.typeaheadExpired = false;
294
+ }
295
+ }
296
+ /**
297
+ * Unchecks all options.
298
+ *
299
+ * @remarks
300
+ * Multiple-selection mode only.
301
+ *
302
+ * @param preserveChecked - reset the rangeStartIndex
303
+ *
304
+ * @internal
305
+ */
306
+ uncheckAllOptions(preserveChecked = false) {
307
+ this.options.forEach((o) => o.checked = false);
308
+ if (!preserveChecked) {
309
+ this.rangeStartIndex = -1;
310
+ }
311
+ }
312
+ /**
313
+ * Sets focus when the open property changes.
314
+ *
315
+ * @internal
316
+ */
317
+ openChanged(prev, next) {
318
+ if (!this.collapsible) {
319
+ return;
320
+ }
321
+ if (this.open) {
322
+ this.focusAndScrollOptionIntoView();
323
+ this.indexWhenOpened = this.selectedIndex;
324
+ DOM.queueUpdate(() => this.focus());
325
+ return;
326
+ }
327
+ const didClose = prev === true && next === false;
328
+ const selectionChangedWhileOpen = this.indexWhenOpened !== this.selectedIndex;
329
+ if (didClose && selectionChangedWhileOpen) {
330
+ this.updateValue(true);
331
+ }
332
+ }
333
+ get collapsible() {
334
+ return !this.multiple;
335
+ }
336
+ /**
337
+ * @internal
338
+ */
339
+ valueChanged(prev, next) {
340
+ let nextValue = next;
341
+ if (this.length) {
342
+ const selectedIndex = this._options.findIndex((el) => el.value === next);
343
+ const prevSelectedValue = this._options[this.selectedIndex]?.value ?? null;
344
+ const nextSelectedValue = this._options[selectedIndex]?.value ?? null;
345
+ if (selectedIndex === -1 || prevSelectedValue !== nextSelectedValue) {
346
+ nextValue = "";
347
+ this.selectedIndex = selectedIndex;
348
+ }
349
+ nextValue = this.firstSelectedOption?.value ?? nextValue;
350
+ }
351
+ if (next !== nextValue) {
352
+ this.value = nextValue;
353
+ return;
354
+ }
355
+ super.valueChanged(prev, next);
356
+ this.updateDisplayValue();
357
+ }
358
+ /**
359
+ * Sets the value and display value to match the first selected option.
360
+ *
361
+ * @param shouldEmit - if true, the input and change events will be emitted
362
+ *
363
+ * @internal
364
+ */
365
+ updateValue(shouldEmit) {
366
+ if (this.$fastController.isConnected) {
367
+ this.value = this.firstSelectedOption?.value ?? "";
368
+ }
369
+ if (shouldEmit) {
370
+ this.$emit("input");
371
+ this.$emit("change", this, {
372
+ bubbles: true,
373
+ composed: void 0
374
+ });
375
+ }
376
+ }
377
+ /**
378
+ * Updates the proxy value when the selected index changes.
379
+ *
380
+ * @param prev - the previous selected index
381
+ * @param next - the next selected index
382
+ *
383
+ * @internal
384
+ */
385
+ selectedIndexChanged(prev, next) {
386
+ super.selectedIndexChanged(prev, next);
387
+ this.updateValue();
388
+ }
389
+ /**
390
+ * Handle opening and closing the listbox when the select is clicked.
391
+ *
392
+ * @param e - the mouse event
393
+ * @internal
394
+ */
395
+ clickHandler(e) {
396
+ if (this.disabled) {
397
+ return;
398
+ }
399
+ const clickedOption = e.target.closest(
400
+ `option,[role=option],[data-vvd-component=option]`
401
+ );
402
+ if (clickedOption && clickedOption.disabled) {
403
+ return;
404
+ }
405
+ if (this.multiple) {
406
+ this.uncheckAllOptions();
407
+ this.activeIndex = this.options.indexOf(clickedOption);
408
+ this.checkActiveIndex();
409
+ this.toggleSelectedForAllCheckedOptions();
410
+ } else {
411
+ super.clickHandler(e);
412
+ }
413
+ if (this.collapsible) {
414
+ this.open = !this.open;
415
+ }
42
416
  return true;
43
417
  }
418
+ /**
419
+ * Handles focus state when the element or its children lose focus.
420
+ *
421
+ * @param e - The focus event
422
+ * @internal
423
+ */
424
+ focusoutHandler(e) {
425
+ if (this.multiple) {
426
+ this.uncheckAllOptions();
427
+ }
428
+ if (!this.open) {
429
+ return true;
430
+ }
431
+ const focusTarget = e.relatedTarget;
432
+ if (this.isSameNode(focusTarget)) {
433
+ this.focus();
434
+ return;
435
+ }
436
+ if (!this.options.includes(focusTarget)) {
437
+ this.open = false;
438
+ if (this.indexWhenOpened !== this.selectedIndex) {
439
+ this.updateValue(true);
440
+ }
441
+ }
442
+ }
443
+ /**
444
+ * Updates the value when an option's value changes.
445
+ *
446
+ * @param source - the source object
447
+ * @param propertyName - the property to evaluate
448
+ *
449
+ * @internal
450
+ */
451
+ handleChange(source, propertyName) {
452
+ super.handleChange(source, propertyName);
453
+ if (propertyName === "value") {
454
+ this.updateValue();
455
+ }
456
+ }
457
+ /**
458
+ * Prevents focus when a scrollbar is clicked.
459
+ *
460
+ * @param e - the mouse event object
461
+ *
462
+ * @internal
463
+ */
464
+ mousedownHandler(e) {
465
+ if (e.offsetX >= 0 && e.offsetX <= this.listbox.scrollWidth) {
466
+ return super.mousedownHandler(e);
467
+ }
468
+ return this.collapsible;
469
+ }
470
+ /**
471
+ * @internal
472
+ */
473
+ multipleChanged(_, next) {
474
+ this.options.forEach((o) => {
475
+ o.checked = next ? false : void 0;
476
+ });
477
+ this.setSelectedOptions();
478
+ if (this.proxy) {
479
+ this.proxy.multiple = next;
480
+ }
481
+ }
482
+ /**
483
+ * Updates the selectedness of each option when the list of selected options changes.
484
+ *
485
+ * @param prev - the previous list of selected options
486
+ * @param next - the current list of selected options
487
+ *
488
+ * @internal
489
+ */
490
+ selectedOptionsChanged(prev, next) {
491
+ super.selectedOptionsChanged(prev, next);
492
+ this.options.forEach((o, i) => {
493
+ const proxyOption = this.proxy.options.item(i);
494
+ if (proxyOption) {
495
+ proxyOption.selected = o.selected;
496
+ }
497
+ });
498
+ }
499
+ /**
500
+ * Resets and fills the proxy to match the component's options.
501
+ *
502
+ * @internal
503
+ */
504
+ setProxyOptions() {
505
+ if (this.proxy instanceof HTMLSelectElement && this.options) {
506
+ this.proxy.length = 0;
507
+ this.options.forEach((option) => {
508
+ const proxyOption = option.proxy || (option instanceof HTMLOptionElement ? option.cloneNode() : null);
509
+ if (proxyOption) {
510
+ this.proxy.options.add(proxyOption);
511
+ }
512
+ });
513
+ }
514
+ }
515
+ /**
516
+ * Handles keydown actions when the select is in multiple selection mode.
517
+ *
518
+ * @internal
519
+ */
520
+ multipleKeydownHandler(e) {
521
+ if (this.disabled) {
522
+ return;
523
+ }
524
+ const { key, shiftKey } = e;
525
+ this.shouldSkipFocus = false;
526
+ switch (key) {
527
+ case keyHome: {
528
+ this.checkFirstOption(shiftKey);
529
+ return;
530
+ }
531
+ case keyArrowDown: {
532
+ this.checkNextOption(shiftKey);
533
+ return;
534
+ }
535
+ case keyArrowUp: {
536
+ this.checkPreviousOption(shiftKey);
537
+ return;
538
+ }
539
+ case keyEnd: {
540
+ this.checkLastOption(shiftKey);
541
+ return;
542
+ }
543
+ case keyTab: {
544
+ this.focusAndScrollOptionIntoView();
545
+ return;
546
+ }
547
+ case keyEscape: {
548
+ this.uncheckAllOptions();
549
+ this.checkActiveIndex();
550
+ return;
551
+ }
552
+ case keySpace: {
553
+ e.preventDefault();
554
+ if (this.typeaheadExpired) {
555
+ this.toggleSelectedForAllCheckedOptions();
556
+ return;
557
+ }
558
+ }
559
+ default: {
560
+ if (key.length === 1) {
561
+ this.handleTypeAhead(`${key}`);
562
+ }
563
+ return;
564
+ }
565
+ }
566
+ }
567
+ /**
568
+ * Handle keyboard interaction for the select.
569
+ *
570
+ * @param e - the keyboard event
571
+ * @internal
572
+ */
573
+ keydownHandler(e) {
574
+ const selectedIndexBefore = this.selectedIndex;
575
+ if (this.multiple) {
576
+ this.multipleKeydownHandler(e);
577
+ } else {
578
+ super.keydownHandler(e);
579
+ }
580
+ const key = e.key;
581
+ switch (key) {
582
+ case keySpace: {
583
+ e.preventDefault();
584
+ if (this.collapsible && this.typeaheadExpired) {
585
+ this.open = !this.open;
586
+ }
587
+ break;
588
+ }
589
+ case keyHome:
590
+ case keyEnd: {
591
+ e.preventDefault();
592
+ break;
593
+ }
594
+ case keyEnter: {
595
+ e.preventDefault();
596
+ this.open = !this.open;
597
+ break;
598
+ }
599
+ case keyEscape: {
600
+ if (this.collapsible && this.open) {
601
+ e.preventDefault();
602
+ this.open = false;
603
+ }
604
+ break;
605
+ }
606
+ case keyTab: {
607
+ if (this.collapsible && this.open) {
608
+ e.preventDefault();
609
+ this.open = false;
610
+ }
611
+ return true;
612
+ }
613
+ }
614
+ if (this.collapsible && !this.open && this.selectedIndex !== selectedIndexBefore) {
615
+ this.updateValue(true);
616
+ }
617
+ return !(e.key === keyArrowDown || e.key === keyArrowUp);
618
+ }
619
+ connectedCallback() {
620
+ super.connectedCallback();
621
+ this.addEventListener("focusout", this.focusoutHandler);
622
+ this.addEventListener("contentchange", this.updateDisplayValue);
623
+ }
624
+ disconnectedCallback() {
625
+ this.removeEventListener("focusout", this.focusoutHandler);
626
+ this.removeEventListener("contentchange", this.updateDisplayValue);
627
+ super.disconnectedCallback();
628
+ }
629
+ /**
630
+ *
631
+ * @internal
632
+ */
633
+ updateDisplayValue() {
634
+ if (this.collapsible) {
635
+ Observable.notify(this, "displayValue");
636
+ }
637
+ }
638
+ get displayValue() {
639
+ Observable.track(this, "displayValue");
640
+ return this.firstSelectedOption?.getAttribute("label") ?? this.firstSelectedOption?.text ?? this.placeholder ?? "";
641
+ }
642
+ setDefaultSelectedOption() {
643
+ const options = Array.from(this.children).filter(
644
+ Listbox.slottedOptionFilter
645
+ );
646
+ const selectedIndex = options.findIndex(
647
+ (el) => el.hasAttribute("selected") || el.selected || el.value === this.value
648
+ );
649
+ if (selectedIndex === -1 && !this.placeholderOption) {
650
+ this.selectedIndex = 0;
651
+ return;
652
+ }
653
+ if (selectedIndex !== -1 || this.placeholder !== "") {
654
+ this.selectedIndex = selectedIndex;
655
+ return;
656
+ }
657
+ }
658
+ /*
659
+ * @internal
660
+ */
661
+ slottedOptionsChanged(prev, next) {
662
+ this.options.forEach((o) => {
663
+ const notifier = Observable.getNotifier(o);
664
+ notifier.unsubscribe(this, "value");
665
+ });
666
+ super.slottedOptionsChanged(prev, next);
667
+ this.options.forEach((o) => {
668
+ const notifier = Observable.getNotifier(o);
669
+ notifier.subscribe(this, "value");
670
+ });
671
+ this.setProxyOptions();
672
+ this.updateValue();
673
+ const scale = this.getAttribute("scale") || this.scale;
674
+ next.forEach((element) => {
675
+ if (scale) {
676
+ element.setAttribute("scale", scale);
677
+ element.scale = scale;
678
+ }
679
+ });
680
+ this.proxy.value = this.value;
681
+ this.validate();
682
+ }
683
+ formResetCallback() {
684
+ this.setProxyOptions();
685
+ super.setDefaultSelectedOption();
686
+ if (this.selectedIndex === -1) {
687
+ this.selectedIndex = 0;
688
+ }
689
+ if (this.placeholder) {
690
+ this.selectedIndex = -1;
691
+ }
692
+ }
44
693
  }
45
694
  __decorateClass([
46
- attr({ mode: "boolean" })
47
- ], SelectableBox.prototype, "checked");
695
+ observable
696
+ ], Select.prototype, "activeIndex", 2);
697
+ // @ts-expect-error Type is incorrectly non-optional
48
698
  __decorateClass([
49
699
  attr({ mode: "boolean" })
50
- ], SelectableBox.prototype, "clickable");
700
+ ], Select.prototype, "multiple", 2);
701
+ __decorateClass([
702
+ attr({ attribute: "open", mode: "boolean" })
703
+ ], Select.prototype, "open", 2);
704
+ __decorateClass([
705
+ volatile
706
+ ], Select.prototype, "collapsible", 1);
707
+ __decorateClass([
708
+ observable
709
+ ], Select.prototype, "control", 2);
710
+ __decorateClass([
711
+ observable
712
+ ], Select.prototype, "maxHeight", 2);
713
+ __decorateClass([
714
+ observable
715
+ ], Select.prototype, "_anchor", 2);
51
716
  __decorateClass([
52
- attr({ attribute: "clickable-box", mode: "boolean" })
53
- ], SelectableBox.prototype, "clickableBox");
717
+ attr()
718
+ ], Select.prototype, "scale", 2);
54
719
  __decorateClass([
55
720
  attr
56
- ], SelectableBox.prototype, "connotation");
721
+ ], Select.prototype, "appearance", 2);
57
722
  __decorateClass([
58
- attr({ attribute: "control-type" })
59
- ], SelectableBox.prototype, "controlType");
723
+ attr
724
+ ], Select.prototype, "shape", 2);
60
725
  __decorateClass([
61
- attr({ mode: "boolean" })
62
- ], SelectableBox.prototype, "tight");
726
+ attr({ mode: "boolean", attribute: "fixed-dropdown" })
727
+ ], Select.prototype, "fixedDropdown", 2);
728
+ __decorateClass([
729
+ attr
730
+ ], Select.prototype, "placeholder", 2);
731
+ __decorateClass([
732
+ observable
733
+ ], Select.prototype, "placeholderOption", 2);
734
+ __decorateClass([
735
+ observable
736
+ ], Select.prototype, "_feedbackWrapper", 2);
737
+ __decorateClass([
738
+ observable
739
+ ], Select.prototype, "metaSlottedContent", 2);
63
740
 
64
- const getClasses = ({
65
- connotation,
66
- tight,
67
- checked,
68
- clickableBox,
69
- clickable
741
+ const getStateClasses = ({
742
+ shape,
743
+ disabled,
744
+ appearance,
745
+ metaSlottedContent,
746
+ errorValidationMessage,
747
+ successText,
748
+ placeholder,
749
+ value,
750
+ scale
70
751
  }) => classNames(
71
- "base",
72
- [`connotation-${connotation}`, Boolean(connotation)],
73
- ["tight", tight],
74
- ["selected", checked],
75
- ["clickable", clickableBox || clickable],
76
- ["readonly", !clickableBox && !clickable]
752
+ ["disabled", disabled],
753
+ [`appearance-${appearance}`, Boolean(appearance)],
754
+ [`shape-${shape}`, Boolean(shape)],
755
+ ["has-meta", Boolean(metaSlottedContent?.length)],
756
+ ["error", Boolean(errorValidationMessage)],
757
+ ["success", !!successText],
758
+ ["shows-placeholder", Boolean(placeholder) && !value],
759
+ [`size-${scale}`, Boolean(scale)]
77
760
  );
78
- function handleControlChange(x) {
79
- if (!x.clickableBox) x._handleCheckedChange();
761
+ function renderLabel() {
762
+ return html` <label
763
+ for="${(x) => x.multiple ? null : "control"}"
764
+ class="label"
765
+ id="label"
766
+ >
767
+ ${(x) => x.label}
768
+ </label>`;
769
+ }
770
+ function renderPlaceholder(context) {
771
+ const optionTag = context.tagFor(ListboxOption);
772
+ return html`
773
+ <${optionTag} ${ref("placeholderOption")}
774
+ text="${(x) => x.placeholder}" hidden disabled>
775
+ </${optionTag}>`;
80
776
  }
81
- function checkbox(context) {
82
- const checkboxTag = context.tagFor(Checkbox);
83
- return html`${when(
84
- (x) => x.controlType !== "radio",
85
- html`
86
- <${checkboxTag}
87
- ${delegateAria(
88
- {
89
- ariaLabel: (x) => !x.clickableBox && !x.clickable && x.ariaLabel ? x.ariaLabel : null
90
- },
91
- { onlySpecified: true }
92
- )}
93
- @change="${(x) => handleControlChange(x)}"
94
- class="control checkbox"
95
- connotation="${(x) => x.connotation === "cta" ? Connotation.CTA : Connotation.Accent}"
96
- :checked="${(x) => x.checked}"
97
- inert="${(x) => x.clickableBox || x.clickable ? true : null}"
98
- ></${checkboxTag}>`
99
- )} `;
777
+ function selectValue(context) {
778
+ const affixIconTemplate = affixIconTemplateFactory(context);
779
+ const chevronTemplate = chevronTemplateFactory(context);
780
+ return html` <div
781
+ class="control ${getStateClasses}"
782
+ ${ref("_anchor")}
783
+ id="control"
784
+ ?disabled="${(x) => x.disabled}"
785
+ >
786
+ <div class="selected-value">
787
+ ${(x) => affixIconTemplate(x.icon, IconWrapper.Slot)}
788
+ <span class="text">${(x) => x.displayValue}</span>
789
+ <slot name="meta" ${slotted("metaSlottedContent")}></slot>
790
+ </div>
791
+ ${chevronTemplate}
792
+ </div>`;
793
+ }
794
+ function setFixedDropdownVarWidth(x) {
795
+ return x.open && x.fixedDropdown ? `--_select-fixed-width: ${Math.round(x.getBoundingClientRect().width)}px` : null;
100
796
  }
101
- function radio(context) {
102
- const radioTag = context.tagFor(Radio);
103
- return html`${when(
104
- (x) => x.controlType === "radio",
105
- html`
106
- <${radioTag}
107
- ${delegateAria(
108
- {
109
- ariaLabel: (x) => !x.clickableBox && !x.clickable && x.ariaLabel ? x.ariaLabel : null
110
- },
111
- { onlySpecified: true }
112
- )}
113
- @change="${(x) => handleControlChange(x)}"
114
- class="control radio"
115
- connotation="${(x) => x.connotation === "cta" ? Connotation.CTA : Connotation.Accent}"
116
- :checked="${(x) => x.checked}"
117
- inert="${(x) => x.clickableBox || x.clickable ? true : null}"
118
- ></${radioTag}>`
119
- )} `;
797
+ function renderControl(context) {
798
+ const popupTag = context.tagFor(Popup);
799
+ return html`
800
+ ${when((x) => x.label, renderLabel())}
801
+ <div class="control-wrapper">
802
+ ${when((x) => !x.multiple, selectValue(context))}
803
+ <${popupTag} class="popup"
804
+ style="${setFixedDropdownVarWidth}"
805
+ ?open="${(x) => x.collapsible ? x.open : true}"
806
+ :anchor="${(x) => x._anchor}"
807
+ placement="bottom-start"
808
+ strategy="${(x) => x.fixedDropdown ? null : "absolute"}">
809
+ <div class="listbox"
810
+ id="${(x) => x.listboxId}"
811
+ role="listbox"
812
+ aria-multiselectable="${(x) => x.multiple}"
813
+ aria-label="${(x) => x.multiple && !x.label && x.ariaLabel ? x.ariaLabel : null}"
814
+ aria-labelledby="${(x) => x.multiple && x.label ? "label" : null}"
815
+ ?disabled="${(x) => x.disabled}"
816
+ ?hidden="${(x) => x.collapsible ? !x.open : false}"
817
+ ${ref("listbox")}>
818
+ ${when((x) => x.placeholder, renderPlaceholder(context))}
819
+ <slot
820
+ ${slotted({
821
+ filter: Listbox.slottedOptionFilter,
822
+ flatten: true,
823
+ property: "slottedOptions"
824
+ })}>
825
+ </slot>
826
+ </div>
827
+ </${popupTag}>
828
+ </div>
829
+ `;
120
830
  }
121
- const SelectableBoxTemplate = (context) => {
122
- return html`<template>
123
- <div
124
- class="${getClasses}"
125
- tabindex="${(x) => x.clickableBox || x.clickable ? "0" : null}"
126
- ${delegateAria({
127
- role: (x) => x.clickableBox || x.clickable ? "button" : null,
128
- ariaPressed: (x) => x.clickableBox || x.clickable ? x.checked ? "true" : "false" : null,
129
- ariaLabel: (x) => x.clickableBox || x.clickable ? x.ariaLabel : null
831
+ function ifNotFromFeedback(handler) {
832
+ return (x, c) => {
833
+ if (!c.event.composedPath().includes(x._feedbackWrapper)) {
834
+ return handler(x, c.event);
835
+ }
836
+ return true;
837
+ };
838
+ }
839
+ const SelectTemplate = (context) => {
840
+ return html`
841
+ <template
842
+ class="base"
843
+ ${applyHostSemantics({
844
+ role: "combobox",
845
+ ariaLabel: (x) => x.ariaLabel ?? x.label,
846
+ ariaHasPopup: (x) => x.collapsible ? "listbox" : "false",
847
+ ariaExpanded: (x) => x.open,
848
+ ariaDisabled: (x) => x.disabled
130
849
  })}
131
- @keydown="${(x, c) => x._handleKeydown(c.event)}"
132
- @click="${(x) => x.clickableBox || x.clickable ? x._handleCheckedChange() : null}"
850
+ aria-controls="${(x) => x.listboxId}"
851
+ aria-activedescendant="${(x) => x._activeDescendant}"
852
+ aria-describedby="${(x) => x._feedbackDescribedBy}"
853
+ tabindex="${(x) => !x.disabled ? "0" : null}"
854
+ @click="${ifNotFromFeedback((x, e) => x.clickHandler(e))}"
855
+ @focusin="${ifNotFromFeedback((x, e) => x.focusinHandler(e))}"
856
+ @focusout="${ifNotFromFeedback(
857
+ (x, e) => x.focusoutHandler(e)
858
+ )}"
859
+ @keydown="${ifNotFromFeedback((x, e) => {
860
+ x.open && handleEscapeKeyAndStopPropogation(e);
861
+ return x.keydownHandler(e);
862
+ })}"
863
+ @mousedown="${ifNotFromFeedback(
864
+ (x, e) => x.mousedownHandler(e)
865
+ )}"
133
866
  >
134
- ${checkbox(context)} ${radio(context)}
135
- <slot></slot>
136
- </div>
137
- </template>`;
867
+ ${renderControl(context)}
868
+ <div class="feedback-wrapper" ${ref("_feedbackWrapper")}>
869
+ ${(x) => x._getFeedbackTemplate(context)}
870
+ </div>
871
+ </template>
872
+ `;
138
873
  };
139
874
 
140
- const selectableBoxDefinition = defineVividComponent(
141
- "selectable-box",
142
- SelectableBox,
143
- SelectableBoxTemplate,
144
- [checkboxDefinition, radioDefinition],
875
+ const selectDefinition = defineVividComponent(
876
+ "select",
877
+ Select,
878
+ SelectTemplate,
879
+ [
880
+ popupDefinition,
881
+ iconDefinition,
882
+ listboxOptionDefinition,
883
+ feedbackMessageDefinition
884
+ ],
145
885
  {
146
- styles,
147
- shadowOptions: {
148
- delegatesFocus: true
149
- }
886
+ styles
150
887
  }
151
888
  );
152
- const registerSelectableBox = createRegisterFunction(
153
- selectableBoxDefinition
154
- );
889
+ const registerSelect = createRegisterFunction(selectDefinition);
155
890
 
156
- export { SelectableBox as S, registerSelectableBox as r, selectableBoxDefinition as s };
891
+ export { Select as S, registerSelect as r, selectDefinition as s };