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