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