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