@vonage/vivid 3.52.0 → 3.54.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 (299) hide show
  1. package/README.md +1 -1
  2. package/accordion/index.cjs +1 -1
  3. package/accordion/index.js +1 -1
  4. package/accordion-item/index.cjs +1 -1
  5. package/accordion-item/index.js +1 -1
  6. package/alert/index.cjs +3 -3
  7. package/alert/index.js +3 -3
  8. package/appearance-ui/index.cjs +1 -1
  9. package/appearance-ui/index.js +1 -1
  10. package/audio-player/index.cjs +3 -3
  11. package/audio-player/index.js +3 -3
  12. package/avatar/index.cjs +1 -1
  13. package/avatar/index.js +1 -1
  14. package/badge/index.cjs +1 -1
  15. package/badge/index.js +1 -1
  16. package/banner/index.cjs +2 -2
  17. package/banner/index.js +2 -2
  18. package/breadcrumb-item/index.cjs +1 -1
  19. package/breadcrumb-item/index.js +1 -1
  20. package/button/index.cjs +2 -2
  21. package/button/index.js +2 -2
  22. package/card/index.cjs +2 -2
  23. package/card/index.js +2 -2
  24. package/checkbox/index.cjs +3 -2
  25. package/checkbox/index.js +3 -2
  26. package/combobox/index.cjs +5 -5
  27. package/combobox/index.js +5 -5
  28. package/custom-elements.json +1162 -99
  29. package/data-grid/index.cjs +1 -1
  30. package/data-grid/index.js +1 -1
  31. package/date-picker/index.cjs +7 -6
  32. package/date-picker/index.js +7 -6
  33. package/date-range-picker/index.cjs +7 -6
  34. package/date-range-picker/index.js +7 -6
  35. package/dial-pad/index.cjs +33 -0
  36. package/dial-pad/index.js +31 -0
  37. package/dialog/index.cjs +4 -4
  38. package/dialog/index.js +4 -4
  39. package/divider/index.cjs +1 -1
  40. package/divider/index.js +1 -1
  41. package/elevation/index.cjs +1 -1
  42. package/elevation/index.js +1 -1
  43. package/empty-state/index.cjs +2 -2
  44. package/empty-state/index.js +2 -2
  45. package/fab/index.cjs +2 -2
  46. package/fab/index.js +2 -2
  47. package/file-picker/index.cjs +4 -3
  48. package/file-picker/index.js +4 -3
  49. package/header/index.cjs +2 -2
  50. package/header/index.js +2 -2
  51. package/icon/index.cjs +1 -1
  52. package/icon/index.js +1 -1
  53. package/index.cjs +132 -122
  54. package/index.js +46 -43
  55. package/layout/index.cjs +1 -1
  56. package/layout/index.js +1 -1
  57. package/lib/appearance-ui/appearance-ui.d.ts +1 -1
  58. package/lib/audio-player/audio-player.d.ts +4 -0
  59. package/lib/audio-player/locale.d.ts +2 -0
  60. package/lib/components.d.ts +2 -0
  61. package/lib/dial-pad/definition.d.ts +3 -0
  62. package/lib/dial-pad/dial-pad.d.ts +17 -0
  63. package/lib/dial-pad/dial-pad.template.d.ts +4 -0
  64. package/lib/dial-pad/locale.d.ts +18 -0
  65. package/lib/enums.d.ts +7 -0
  66. package/lib/menu/menu.d.ts +1 -0
  67. package/lib/nav-disclosure/nav-disclosure.d.ts +5 -0
  68. package/lib/text-anchor/definition.d.ts +1 -0
  69. package/lib/text-anchor/text-anchor.d.ts +5 -0
  70. package/lib/video-player/definition.d.ts +3 -0
  71. package/lib/video-player/locale.d.ts +1 -0
  72. package/lib/video-player/video-player.d.ts +17 -0
  73. package/lib/video-player/video-player.template.d.ts +4 -0
  74. package/lib/video-player/vivid-video-svg.d.ts +1 -0
  75. package/listbox/index.cjs +2 -2
  76. package/listbox/index.js +2 -2
  77. package/locales/en-GB.cjs +33 -1
  78. package/locales/en-GB.js +33 -1
  79. package/locales/en-US.cjs +201 -1
  80. package/locales/en-US.js +201 -1
  81. package/locales/ja-JP.cjs +200 -1
  82. package/locales/ja-JP.js +200 -1
  83. package/locales/zh-CN.cjs +202 -1
  84. package/locales/zh-CN.js +202 -1
  85. package/menu/index.cjs +6 -6
  86. package/menu/index.js +6 -6
  87. package/menu-item/index.cjs +2 -2
  88. package/menu-item/index.js +2 -2
  89. package/nav/index.cjs +1 -1
  90. package/nav/index.js +1 -1
  91. package/nav-disclosure/index.cjs +2 -2
  92. package/nav-disclosure/index.js +2 -2
  93. package/nav-item/index.cjs +2 -2
  94. package/nav-item/index.js +2 -2
  95. package/note/index.cjs +2 -2
  96. package/note/index.js +2 -2
  97. package/number-field/index.cjs +5 -4
  98. package/number-field/index.js +5 -4
  99. package/option/index.cjs +2 -2
  100. package/option/index.js +2 -2
  101. package/package.json +1 -1
  102. package/pagination/index.cjs +3 -3
  103. package/pagination/index.js +3 -3
  104. package/popup/index.cjs +4 -4
  105. package/popup/index.js +4 -4
  106. package/progress/index.cjs +1 -1
  107. package/progress/index.js +1 -1
  108. package/progress-ring/index.cjs +1 -1
  109. package/progress-ring/index.js +1 -1
  110. package/radio/index.cjs +1 -1
  111. package/radio/index.js +1 -1
  112. package/radio-group/index.cjs +1 -1
  113. package/radio-group/index.js +1 -1
  114. package/range-slider/index.cjs +2 -2
  115. package/range-slider/index.js +2 -2
  116. package/select/index.cjs +7 -6
  117. package/select/index.js +7 -6
  118. package/selectable-box/index.cjs +5 -4
  119. package/selectable-box/index.js +5 -4
  120. package/shared/applyMixinsWithObservables.cjs +15 -0
  121. package/shared/applyMixinsWithObservables.js +13 -0
  122. package/shared/definition.cjs +1 -1
  123. package/shared/definition.js +1 -1
  124. package/shared/definition11.cjs +3 -3
  125. package/shared/definition11.js +3 -3
  126. package/shared/definition14.cjs +2 -2
  127. package/shared/definition14.js +2 -2
  128. package/shared/definition15.cjs +8 -9
  129. package/shared/definition15.js +8 -9
  130. package/shared/definition16.cjs +3 -3
  131. package/shared/definition16.js +3 -3
  132. package/shared/definition17.cjs +2 -2
  133. package/shared/definition17.js +3 -3
  134. package/shared/definition18.cjs +3 -3
  135. package/shared/definition18.js +3 -3
  136. package/shared/definition19.cjs +3 -3
  137. package/shared/definition19.js +3 -3
  138. package/shared/definition20.cjs +196 -224
  139. package/shared/definition20.js +191 -219
  140. package/shared/definition21.cjs +264 -67
  141. package/shared/definition21.js +263 -65
  142. package/shared/definition22.cjs +66 -57
  143. package/shared/definition22.js +64 -56
  144. package/shared/definition23.cjs +42 -76
  145. package/shared/definition23.js +41 -75
  146. package/shared/definition24.cjs +70 -2402
  147. package/shared/definition24.js +69 -2401
  148. package/shared/definition25.cjs +2402 -46
  149. package/shared/definition25.js +2401 -45
  150. package/shared/definition26.cjs +63 -30
  151. package/shared/definition26.js +62 -29
  152. package/shared/definition27.cjs +28 -56
  153. package/shared/definition27.js +27 -55
  154. package/shared/definition28.cjs +35 -881
  155. package/shared/definition28.js +34 -879
  156. package/shared/definition29.cjs +922 -60
  157. package/shared/definition29.js +922 -61
  158. package/shared/definition30.cjs +68 -86
  159. package/shared/definition30.js +67 -85
  160. package/shared/definition31.cjs +98 -21
  161. package/shared/definition31.js +98 -21
  162. package/shared/definition32.cjs +24 -12
  163. package/shared/definition32.js +23 -11
  164. package/shared/definition33.cjs +11 -50
  165. package/shared/definition33.js +10 -49
  166. package/shared/definition34.cjs +26 -515
  167. package/shared/definition34.js +26 -515
  168. package/shared/definition35.cjs +448 -194
  169. package/shared/definition35.js +448 -192
  170. package/shared/definition36.cjs +256 -202
  171. package/shared/definition36.js +253 -201
  172. package/shared/definition37.cjs +204 -65
  173. package/shared/definition37.js +203 -63
  174. package/shared/definition38.cjs +63 -57
  175. package/shared/definition38.js +60 -55
  176. package/shared/definition39.cjs +65 -432
  177. package/shared/definition39.js +64 -431
  178. package/shared/definition4.cjs +2 -2
  179. package/shared/definition4.js +2 -2
  180. package/shared/definition40.cjs +441 -34
  181. package/shared/definition40.js +438 -31
  182. package/shared/definition41.cjs +34 -576
  183. package/shared/definition41.js +33 -575
  184. package/shared/definition42.cjs +531 -654
  185. package/shared/definition42.js +531 -654
  186. package/shared/definition43.cjs +690 -114
  187. package/shared/definition43.js +689 -113
  188. package/shared/definition44.cjs +124 -79
  189. package/shared/definition44.js +122 -77
  190. package/shared/definition45.cjs +78 -520
  191. package/shared/definition45.js +77 -518
  192. package/shared/definition46.cjs +520 -119
  193. package/shared/definition46.js +518 -118
  194. package/shared/definition47.cjs +118 -135
  195. package/shared/definition47.js +117 -134
  196. package/shared/definition48.cjs +151 -19
  197. package/shared/definition48.js +150 -18
  198. package/shared/definition49.cjs +21 -84
  199. package/shared/definition49.js +20 -83
  200. package/shared/definition5.cjs +100 -19
  201. package/shared/definition5.js +100 -19
  202. package/shared/definition50.cjs +52 -505
  203. package/shared/definition50.js +51 -504
  204. package/shared/definition51.cjs +526 -28
  205. package/shared/definition51.js +525 -27
  206. package/shared/definition52.cjs +28 -123
  207. package/shared/definition52.js +26 -122
  208. package/shared/definition53.cjs +110 -309
  209. package/shared/definition53.js +110 -308
  210. package/shared/definition54.cjs +255 -271
  211. package/shared/definition54.js +255 -271
  212. package/shared/definition55.cjs +315 -776
  213. package/shared/definition55.js +314 -775
  214. package/shared/definition56.cjs +818 -107
  215. package/shared/definition56.js +817 -106
  216. package/shared/definition57.cjs +85 -55
  217. package/shared/definition57.js +84 -54
  218. package/shared/definition58.cjs +125 -72
  219. package/shared/definition58.js +124 -71
  220. package/shared/definition59.cjs +72 -285
  221. package/shared/definition59.js +73 -286
  222. package/shared/definition6.cjs +1 -1
  223. package/shared/definition6.js +1 -1
  224. package/shared/definition60.cjs +298 -39
  225. package/shared/definition60.js +297 -38
  226. package/shared/definition61.cjs +66044 -1687
  227. package/shared/definition61.js +66043 -1686
  228. package/shared/definition62.cjs +50 -0
  229. package/shared/definition62.js +46 -0
  230. package/shared/definition63.cjs +1828 -0
  231. package/shared/definition63.js +1824 -0
  232. package/shared/definition7.cjs +2 -2
  233. package/shared/definition7.js +2 -2
  234. package/shared/definition8.cjs +2 -2
  235. package/shared/definition8.js +2 -2
  236. package/shared/definition9.cjs +1 -1
  237. package/shared/definition9.js +1 -1
  238. package/shared/enums.cjs +9 -0
  239. package/shared/enums.js +9 -1
  240. package/shared/icon.cjs +20 -2
  241. package/shared/icon.js +21 -3
  242. package/shared/index2.cjs +73 -37
  243. package/shared/index2.js +73 -37
  244. package/shared/key-codes2.js +1 -1
  245. package/shared/listbox.cjs +1 -1
  246. package/shared/listbox.js +1 -1
  247. package/shared/localization/Locale.d.ts +4 -0
  248. package/shared/patterns/form-elements/form-elements.d.ts +2 -3
  249. package/shared/presentationDate.cjs +16 -5
  250. package/shared/presentationDate.js +16 -5
  251. package/shared/text-anchor.cjs +6 -0
  252. package/shared/text-anchor.js +6 -0
  253. package/shared/text-anchor.template.cjs +6 -1
  254. package/shared/text-anchor.template.js +6 -1
  255. package/shared/text-field.cjs +1 -1
  256. package/shared/text-field.js +1 -1
  257. package/shared/utils/applyMixinsWithObservables.d.ts +1 -0
  258. package/shared/utils/numberConverter.d.ts +2 -0
  259. package/side-drawer/index.cjs +1 -1
  260. package/side-drawer/index.js +1 -1
  261. package/slider/index.cjs +1 -1
  262. package/slider/index.js +1 -1
  263. package/split-button/index.cjs +2 -2
  264. package/split-button/index.js +2 -2
  265. package/styles/core/all.css +1 -1
  266. package/styles/core/theme.css +1 -1
  267. package/styles/core/typography.css +1 -1
  268. package/styles/tokens/theme-dark.css +4 -4
  269. package/styles/tokens/theme-light.css +4 -4
  270. package/styles/tokens/vivid-2-compat.css +1 -1
  271. package/switch/index.cjs +2 -2
  272. package/switch/index.js +2 -2
  273. package/tab/index.cjs +2 -2
  274. package/tab/index.js +2 -2
  275. package/tab-panel/index.cjs +1 -1
  276. package/tab-panel/index.js +1 -1
  277. package/tabs/index.cjs +4 -4
  278. package/tabs/index.js +4 -4
  279. package/tag/index.cjs +2 -2
  280. package/tag/index.js +2 -2
  281. package/tag-group/index.cjs +1 -1
  282. package/tag-group/index.js +1 -1
  283. package/text-area/index.cjs +4 -3
  284. package/text-area/index.js +4 -3
  285. package/text-field/index.cjs +4 -3
  286. package/text-field/index.js +4 -3
  287. package/time-picker/index.cjs +8 -7
  288. package/time-picker/index.js +8 -7
  289. package/toggletip/index.cjs +5 -5
  290. package/toggletip/index.js +5 -5
  291. package/tooltip/index.cjs +5 -5
  292. package/tooltip/index.js +5 -5
  293. package/tree-item/index.cjs +2 -2
  294. package/tree-item/index.js +2 -2
  295. package/tree-view/index.cjs +1 -1
  296. package/tree-view/index.js +1 -1
  297. package/video-player/index.cjs +17 -0
  298. package/video-player/index.js +15 -0
  299. package/vivid.api.json +332 -0
@@ -1,12 +1,520 @@
1
- import { a as attr, F as FoundationElement, h as html, r as registerFactory } from './index.js';
2
- import { C as Checkbox, a as checkboxRegistries } from './definition15.js';
3
- import { a as radioRegistries } from './definition40.js';
4
- import { C as Connotation } from './enums.js';
5
- import { R as Radio } from './radio.js';
6
- import { c as classNames } from './class-names.js';
1
+ import { D as DOM, O as Observable, _ as __decorate, a as attr, v as volatile, o as observable, h as html, r as registerFactory } from './index.js';
2
+ import { P as Popup, p as popupRegistries } from './definition63.js';
3
+ import { a as iconRegistries } from './definition27.js';
4
+ import { L as ListboxOption, a as listboxOptionRegistries } from './definition36.js';
5
+ import { b as AffixIconWithTrailing, a as affixIconTemplateFactory, I as IconWrapper } from './affix.js';
6
+ import { e as errorText, f as formElements, F as FormElementSuccessText, a as FormElementHelperText, g as getFeedbackTemplate } from './index2.js';
7
+ import { L as ListboxElement, b as Listbox, D as DelegatesARIAListbox, a as Listbox$1 } from './listbox.js';
8
+ import { a as applyMixinsWithObservables } from './applyMixinsWithObservables.js';
9
+ import { S as StartEnd } from './start-end.js';
10
+ import { a as applyMixins } from './apply-mixins.js';
11
+ import { F as FormAssociated } from './form-associated.js';
12
+ import { S as SelectPosition } from './select.options.js';
13
+ import { u as uniqueId } from './strings.js';
14
+ import { c as keyTab, b as keyEscape, k as keyEnter, d as keyEnd, g as keyHome, a as keySpace, f as keyArrowDown, e as keyArrowUp } from './key-codes.js';
15
+ import { r as ref } from './ref.js';
7
16
  import { w as when } from './when.js';
17
+ import { s as slotted } from './slotted.js';
18
+ import { c as classNames } from './class-names.js';
8
19
 
9
- const styles = ":host{display:flex}.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.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: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)}\n";
20
+ class _Select extends ListboxElement {
21
+ }
22
+ /**
23
+ * A form-associated base class for the {@link @microsoft/fast-foundation#(Select:class)} component.
24
+ *
25
+ * @internal
26
+ */
27
+ class FormAssociatedSelect extends FormAssociated(_Select) {
28
+ constructor() {
29
+ super(...arguments);
30
+ this.proxy = document.createElement("select");
31
+ }
32
+ }
33
+
34
+ /**
35
+ * A Select Custom HTML Element.
36
+ * Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#select | ARIA select }.
37
+ *
38
+ * @slot start - Content which can be provided before the button content
39
+ * @slot end - Content which can be provided after the button content
40
+ * @slot button-container - The element representing the select button
41
+ * @slot selected-value - The selected value
42
+ * @slot indicator - The visual indicator for the expand/collapse state of the button
43
+ * @slot - The default slot for slotted options
44
+ * @csspart control - The element representing the select invoking element
45
+ * @csspart selected-value - The element wrapping the selected value
46
+ * @csspart indicator - The element wrapping the visual indicator
47
+ * @csspart listbox - The listbox element
48
+ * @fires input - Fires a custom 'input' event when the value updates
49
+ * @fires change - Fires a custom 'change' event when the value updates
50
+ *
51
+ * @public
52
+ */
53
+ let Select$1 = class Select extends FormAssociatedSelect {
54
+ constructor() {
55
+ super(...arguments);
56
+ /**
57
+ * The open attribute.
58
+ *
59
+ * @public
60
+ * @remarks
61
+ * HTML Attribute: open
62
+ */
63
+ this.open = false;
64
+ /**
65
+ * Indicates the initial state of the position attribute.
66
+ *
67
+ * @internal
68
+ */
69
+ this.forcedPosition = false;
70
+ /**
71
+ * The unique id for the internal listbox element.
72
+ *
73
+ * @internal
74
+ */
75
+ this.listboxId = uniqueId("listbox-");
76
+ /**
77
+ * The max height for the listbox when opened.
78
+ *
79
+ * @internal
80
+ */
81
+ this.maxHeight = 0;
82
+ }
83
+ /**
84
+ * Sets focus and synchronizes ARIA attributes when the open property changes.
85
+ *
86
+ * @param prev - the previous open value
87
+ * @param next - the current open value
88
+ *
89
+ * @internal
90
+ */
91
+ openChanged(prev, next) {
92
+ if (!this.collapsible) {
93
+ return;
94
+ }
95
+ if (this.open) {
96
+ this.ariaControls = this.listboxId;
97
+ this.ariaExpanded = "true";
98
+ this.setPositioning();
99
+ this.focusAndScrollOptionIntoView();
100
+ this.indexWhenOpened = this.selectedIndex;
101
+ // focus is directed to the element when `open` is changed programmatically
102
+ DOM.queueUpdate(() => this.focus());
103
+ return;
104
+ }
105
+ this.ariaControls = "";
106
+ this.ariaExpanded = "false";
107
+ }
108
+ /**
109
+ * The component is collapsible when in single-selection mode with no size attribute.
110
+ *
111
+ * @internal
112
+ */
113
+ get collapsible() {
114
+ return !(this.multiple || typeof this.size === "number");
115
+ }
116
+ /**
117
+ * The value property.
118
+ *
119
+ * @public
120
+ */
121
+ get value() {
122
+ Observable.track(this, "value");
123
+ return this._value;
124
+ }
125
+ set value(next) {
126
+ var _a, _b, _c, _d, _e, _f, _g;
127
+ const prev = `${this._value}`;
128
+ if ((_a = this._options) === null || _a === void 0 ? void 0 : _a.length) {
129
+ const selectedIndex = this._options.findIndex(el => el.value === next);
130
+ const prevSelectedValue = (_c = (_b = this._options[this.selectedIndex]) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : null;
131
+ const nextSelectedValue = (_e = (_d = this._options[selectedIndex]) === null || _d === void 0 ? void 0 : _d.value) !== null && _e !== void 0 ? _e : null;
132
+ if (selectedIndex === -1 || prevSelectedValue !== nextSelectedValue) {
133
+ next = "";
134
+ this.selectedIndex = selectedIndex;
135
+ }
136
+ next = (_g = (_f = this.firstSelectedOption) === null || _f === void 0 ? void 0 : _f.value) !== null && _g !== void 0 ? _g : next;
137
+ }
138
+ if (prev !== next) {
139
+ this._value = next;
140
+ super.valueChanged(prev, next);
141
+ Observable.notify(this, "value");
142
+ this.updateDisplayValue();
143
+ }
144
+ }
145
+ /**
146
+ * Sets the value and display value to match the first selected option.
147
+ *
148
+ * @param shouldEmit - if true, the input and change events will be emitted
149
+ *
150
+ * @internal
151
+ */
152
+ updateValue(shouldEmit) {
153
+ var _a, _b;
154
+ if (this.$fastController.isConnected) {
155
+ this.value = (_b = (_a = this.firstSelectedOption) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : "";
156
+ }
157
+ if (shouldEmit) {
158
+ this.$emit("input");
159
+ this.$emit("change", this, {
160
+ bubbles: true,
161
+ composed: undefined,
162
+ });
163
+ }
164
+ }
165
+ /**
166
+ * Updates the proxy value when the selected index changes.
167
+ *
168
+ * @param prev - the previous selected index
169
+ * @param next - the next selected index
170
+ *
171
+ * @internal
172
+ */
173
+ selectedIndexChanged(prev, next) {
174
+ super.selectedIndexChanged(prev, next);
175
+ this.updateValue();
176
+ }
177
+ positionChanged(prev, next) {
178
+ this.positionAttribute = next;
179
+ this.setPositioning();
180
+ }
181
+ /**
182
+ * Calculate and apply listbox positioning based on available viewport space.
183
+ *
184
+ * @public
185
+ */
186
+ setPositioning() {
187
+ const currentBox = this.getBoundingClientRect();
188
+ const viewportHeight = window.innerHeight;
189
+ const availableBottom = viewportHeight - currentBox.bottom;
190
+ this.position = this.forcedPosition
191
+ ? this.positionAttribute
192
+ : currentBox.top > availableBottom
193
+ ? SelectPosition.above
194
+ : SelectPosition.below;
195
+ this.positionAttribute = this.forcedPosition
196
+ ? this.positionAttribute
197
+ : this.position;
198
+ this.maxHeight =
199
+ this.position === SelectPosition.above ? ~~currentBox.top : ~~availableBottom;
200
+ }
201
+ /**
202
+ * The value displayed on the button.
203
+ *
204
+ * @public
205
+ */
206
+ get displayValue() {
207
+ var _a, _b;
208
+ Observable.track(this, "displayValue");
209
+ return (_b = (_a = this.firstSelectedOption) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : "";
210
+ }
211
+ /**
212
+ * Synchronize the `aria-disabled` property when the `disabled` property changes.
213
+ *
214
+ * @param prev - The previous disabled value
215
+ * @param next - The next disabled value
216
+ *
217
+ * @internal
218
+ */
219
+ disabledChanged(prev, next) {
220
+ if (super.disabledChanged) {
221
+ super.disabledChanged(prev, next);
222
+ }
223
+ this.ariaDisabled = this.disabled ? "true" : "false";
224
+ }
225
+ /**
226
+ * Reset the element to its first selectable option when its parent form is reset.
227
+ *
228
+ * @internal
229
+ */
230
+ formResetCallback() {
231
+ this.setProxyOptions();
232
+ // Call the base class's implementation setDefaultSelectedOption instead of the select's
233
+ // override, in order to reset the selectedIndex without using the value property.
234
+ super.setDefaultSelectedOption();
235
+ if (this.selectedIndex === -1) {
236
+ this.selectedIndex = 0;
237
+ }
238
+ }
239
+ /**
240
+ * Handle opening and closing the listbox when the select is clicked.
241
+ *
242
+ * @param e - the mouse event
243
+ * @internal
244
+ */
245
+ clickHandler(e) {
246
+ // do nothing if the select is disabled
247
+ if (this.disabled) {
248
+ return;
249
+ }
250
+ if (this.open) {
251
+ const captured = e.target.closest(`option,[role=option]`);
252
+ if (captured && captured.disabled) {
253
+ return;
254
+ }
255
+ }
256
+ super.clickHandler(e);
257
+ this.open = this.collapsible && !this.open;
258
+ if (!this.open && this.indexWhenOpened !== this.selectedIndex) {
259
+ this.updateValue(true);
260
+ }
261
+ return true;
262
+ }
263
+ /**
264
+ * Handles focus state when the element or its children lose focus.
265
+ *
266
+ * @param e - The focus event
267
+ * @internal
268
+ */
269
+ focusoutHandler(e) {
270
+ var _a;
271
+ super.focusoutHandler(e);
272
+ if (!this.open) {
273
+ return true;
274
+ }
275
+ const focusTarget = e.relatedTarget;
276
+ if (this.isSameNode(focusTarget)) {
277
+ this.focus();
278
+ return;
279
+ }
280
+ if (!((_a = this.options) === null || _a === void 0 ? void 0 : _a.includes(focusTarget))) {
281
+ this.open = false;
282
+ if (this.indexWhenOpened !== this.selectedIndex) {
283
+ this.updateValue(true);
284
+ }
285
+ }
286
+ }
287
+ /**
288
+ * Updates the value when an option's value changes.
289
+ *
290
+ * @param source - the source object
291
+ * @param propertyName - the property to evaluate
292
+ *
293
+ * @internal
294
+ * @override
295
+ */
296
+ handleChange(source, propertyName) {
297
+ super.handleChange(source, propertyName);
298
+ if (propertyName === "value") {
299
+ this.updateValue();
300
+ }
301
+ }
302
+ /**
303
+ * Synchronize the form-associated proxy and updates the value property of the element.
304
+ *
305
+ * @param prev - the previous collection of slotted option elements
306
+ * @param next - the next collection of slotted option elements
307
+ *
308
+ * @internal
309
+ */
310
+ slottedOptionsChanged(prev, next) {
311
+ this.options.forEach(o => {
312
+ const notifier = Observable.getNotifier(o);
313
+ notifier.unsubscribe(this, "value");
314
+ });
315
+ super.slottedOptionsChanged(prev, next);
316
+ this.options.forEach(o => {
317
+ const notifier = Observable.getNotifier(o);
318
+ notifier.subscribe(this, "value");
319
+ });
320
+ this.setProxyOptions();
321
+ this.updateValue();
322
+ }
323
+ /**
324
+ * Prevents focus when size is set and a scrollbar is clicked.
325
+ *
326
+ * @param e - the mouse event object
327
+ *
328
+ * @override
329
+ * @internal
330
+ */
331
+ mousedownHandler(e) {
332
+ var _a;
333
+ if (e.offsetX >= 0 && e.offsetX <= ((_a = this.listbox) === null || _a === void 0 ? void 0 : _a.scrollWidth)) {
334
+ return super.mousedownHandler(e);
335
+ }
336
+ return this.collapsible;
337
+ }
338
+ /**
339
+ * Sets the multiple property on the proxy element.
340
+ *
341
+ * @param prev - the previous multiple value
342
+ * @param next - the current multiple value
343
+ */
344
+ multipleChanged(prev, next) {
345
+ super.multipleChanged(prev, next);
346
+ if (this.proxy) {
347
+ this.proxy.multiple = next;
348
+ }
349
+ }
350
+ /**
351
+ * Updates the selectedness of each option when the list of selected options changes.
352
+ *
353
+ * @param prev - the previous list of selected options
354
+ * @param next - the current list of selected options
355
+ *
356
+ * @override
357
+ * @internal
358
+ */
359
+ selectedOptionsChanged(prev, next) {
360
+ var _a;
361
+ super.selectedOptionsChanged(prev, next);
362
+ (_a = this.options) === null || _a === void 0 ? void 0 : _a.forEach((o, i) => {
363
+ var _a;
364
+ const proxyOption = (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.options.item(i);
365
+ if (proxyOption) {
366
+ proxyOption.selected = o.selected;
367
+ }
368
+ });
369
+ }
370
+ /**
371
+ * Sets the selected index to match the first option with the selected attribute, or
372
+ * the first selectable option.
373
+ *
374
+ * @override
375
+ * @internal
376
+ */
377
+ setDefaultSelectedOption() {
378
+ var _a;
379
+ const options = (_a = this.options) !== null && _a !== void 0 ? _a : Array.from(this.children).filter(Listbox.slottedOptionFilter);
380
+ const selectedIndex = options === null || options === void 0 ? void 0 : options.findIndex(el => el.hasAttribute("selected") || el.selected || el.value === this.value);
381
+ if (selectedIndex !== -1) {
382
+ this.selectedIndex = selectedIndex;
383
+ return;
384
+ }
385
+ this.selectedIndex = 0;
386
+ }
387
+ /**
388
+ * Resets and fills the proxy to match the component's options.
389
+ *
390
+ * @internal
391
+ */
392
+ setProxyOptions() {
393
+ if (this.proxy instanceof HTMLSelectElement && this.options) {
394
+ this.proxy.options.length = 0;
395
+ this.options.forEach(option => {
396
+ const proxyOption = option.proxy ||
397
+ (option instanceof HTMLOptionElement ? option.cloneNode() : null);
398
+ if (proxyOption) {
399
+ this.proxy.options.add(proxyOption);
400
+ }
401
+ });
402
+ }
403
+ }
404
+ /**
405
+ * Handle keyboard interaction for the select.
406
+ *
407
+ * @param e - the keyboard event
408
+ * @internal
409
+ */
410
+ keydownHandler(e) {
411
+ super.keydownHandler(e);
412
+ const key = e.key || e.key.charCodeAt(0);
413
+ switch (key) {
414
+ case keySpace: {
415
+ e.preventDefault();
416
+ if (this.collapsible && this.typeAheadExpired) {
417
+ this.open = !this.open;
418
+ }
419
+ break;
420
+ }
421
+ case keyHome:
422
+ case keyEnd: {
423
+ e.preventDefault();
424
+ break;
425
+ }
426
+ case keyEnter: {
427
+ e.preventDefault();
428
+ this.open = !this.open;
429
+ break;
430
+ }
431
+ case keyEscape: {
432
+ if (this.collapsible && this.open) {
433
+ e.preventDefault();
434
+ this.open = false;
435
+ }
436
+ break;
437
+ }
438
+ case keyTab: {
439
+ if (this.collapsible && this.open) {
440
+ e.preventDefault();
441
+ this.open = false;
442
+ }
443
+ return true;
444
+ }
445
+ }
446
+ if (!this.open && this.indexWhenOpened !== this.selectedIndex) {
447
+ this.updateValue(true);
448
+ this.indexWhenOpened = this.selectedIndex;
449
+ }
450
+ return !(key === keyArrowDown || key === keyArrowUp);
451
+ }
452
+ connectedCallback() {
453
+ super.connectedCallback();
454
+ this.forcedPosition = !!this.positionAttribute;
455
+ this.addEventListener("contentchange", this.updateDisplayValue);
456
+ }
457
+ disconnectedCallback() {
458
+ this.removeEventListener("contentchange", this.updateDisplayValue);
459
+ super.disconnectedCallback();
460
+ }
461
+ /**
462
+ * Updates the proxy's size property when the size attribute changes.
463
+ *
464
+ * @param prev - the previous size
465
+ * @param next - the current size
466
+ *
467
+ * @override
468
+ * @internal
469
+ */
470
+ sizeChanged(prev, next) {
471
+ super.sizeChanged(prev, next);
472
+ if (this.proxy) {
473
+ this.proxy.size = next;
474
+ }
475
+ }
476
+ /**
477
+ *
478
+ * @internal
479
+ */
480
+ updateDisplayValue() {
481
+ if (this.collapsible) {
482
+ Observable.notify(this, "displayValue");
483
+ }
484
+ }
485
+ };
486
+ __decorate([
487
+ attr({ attribute: "open", mode: "boolean" })
488
+ ], Select$1.prototype, "open", void 0);
489
+ __decorate([
490
+ volatile
491
+ ], Select$1.prototype, "collapsible", null);
492
+ __decorate([
493
+ observable
494
+ ], Select$1.prototype, "control", void 0);
495
+ __decorate([
496
+ attr({ attribute: "position" })
497
+ ], Select$1.prototype, "positionAttribute", void 0);
498
+ __decorate([
499
+ observable
500
+ ], Select$1.prototype, "position", void 0);
501
+ __decorate([
502
+ observable
503
+ ], Select$1.prototype, "maxHeight", void 0);
504
+ /**
505
+ * Includes ARIA states and properties relating to the ARIA select role.
506
+ *
507
+ * @public
508
+ */
509
+ class DelegatesARIASelect {
510
+ }
511
+ __decorate([
512
+ observable
513
+ ], DelegatesARIASelect.prototype, "ariaControls", void 0);
514
+ applyMixins(DelegatesARIASelect, DelegatesARIAListbox);
515
+ applyMixins(Select$1, StartEnd, DelegatesARIASelect);
516
+
517
+ const styles = ":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{display:flex;align-items:center;justify-content:space-between;border-radius:var(--_select-control-border-radius);background-color:var(--_appearance-color-fill);block-size:calc(1px*(40 + 4*clamp(-1,var(--vvd-size-density, 0),2)));box-shadow:inset 0 0 0 1px var(--_appearance-color-outline);color:var(--_appearance-color-text);font:var(--vvd-typography-base);gap:8px;padding-inline:16px;transition:box-shadow .2s,background-color .2s}.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-primary);--_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-primary);--_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-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}.icon{display:flex;flex-shrink:0}.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}.selected-value slot[name=icon]{flex:0 0 20px;font-size:20px;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}\n";
10
518
 
11
519
  var __defProp = Object.defineProperty;
12
520
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -19,134 +527,202 @@ var __decorateClass = (decorators, target, key, kind) => {
19
527
  __defProp(target, key, result);
20
528
  return result;
21
529
  };
22
- class SelectableBox extends FoundationElement {
530
+ let Select = class extends Select$1 {
23
531
  constructor() {
24
532
  super(...arguments);
25
- this.ariaLabel = null;
26
- this.checked = false;
27
- this.clickable = false;
28
- this.clickableBox = false;
29
- this.tight = false;
533
+ this.fixedDropdown = false;
534
+ this.placeholderOption = null;
535
+ this._feedbackWrapper = null;
30
536
  }
31
- /**
32
- * @internal
33
- */
34
- _handleCheckedChange() {
35
- if (this.controlType === "radio" && this.checked)
36
- return;
37
- this.checked = !this.checked;
38
- if (this.clickableBox || this.clickable)
39
- this.$emit("change");
537
+ connectedCallback() {
538
+ super.connectedCallback();
40
539
  }
41
- /**
42
- * @internal
43
- */
44
- _handleKeydown(event) {
45
- if ((event.code === "Space" || event.code === "Enter") && (this.clickableBox || this.clickable))
46
- return this._handleCheckedChange();
47
- return true;
540
+ get displayValue() {
541
+ Observable.track(this, "displayValue");
542
+ return this.firstSelectedOption?.getAttribute("label") ?? this.firstSelectedOption?.text ?? this.placeholder ?? "";
48
543
  }
49
- }
544
+ setDefaultSelectedOption() {
545
+ const options = Array.from(this.children).filter(
546
+ Listbox$1.slottedOptionFilter
547
+ );
548
+ const selectedIndex = options.findIndex(
549
+ (el) => el.hasAttribute("selected") || el.selected || el.value === this.value
550
+ );
551
+ if (selectedIndex === -1 && !this.placeholderOption) {
552
+ this.selectedIndex = 0;
553
+ return;
554
+ }
555
+ if (selectedIndex !== -1 || this.placeholder !== "") {
556
+ this.selectedIndex = selectedIndex;
557
+ return;
558
+ }
559
+ }
560
+ };
50
561
  __decorateClass([
51
- attr({ attribute: "aria-label" })
52
- ], SelectableBox.prototype, "ariaLabel", 2);
562
+ observable
563
+ ], Select.prototype, "_anchor", 2);
53
564
  __decorateClass([
54
- attr({ mode: "boolean" })
55
- ], SelectableBox.prototype, "checked", 2);
565
+ attr
566
+ ], Select.prototype, "appearance", 2);
56
567
  __decorateClass([
57
- attr({ mode: "boolean" })
58
- ], SelectableBox.prototype, "clickable", 2);
568
+ attr
569
+ ], Select.prototype, "shape", 2);
59
570
  __decorateClass([
60
- attr({ attribute: "clickable-box", mode: "boolean" })
61
- ], SelectableBox.prototype, "clickableBox", 2);
571
+ attr({ mode: "boolean", attribute: "fixed-dropdown" })
572
+ ], Select.prototype, "fixedDropdown", 2);
62
573
  __decorateClass([
63
574
  attr
64
- ], SelectableBox.prototype, "connotation", 2);
575
+ ], Select.prototype, "placeholder", 2);
65
576
  __decorateClass([
66
- attr({ attribute: "control-type" })
67
- ], SelectableBox.prototype, "controlType", 2);
577
+ observable
578
+ ], Select.prototype, "placeholderOption", 2);
68
579
  __decorateClass([
69
- attr({ mode: "boolean" })
70
- ], SelectableBox.prototype, "tight", 2);
580
+ observable
581
+ ], Select.prototype, "_feedbackWrapper", 2);
582
+ __decorateClass([
583
+ observable
584
+ ], Select.prototype, "metaSlottedContent", 2);
585
+ Select = __decorateClass([
586
+ errorText,
587
+ formElements
588
+ ], Select);
589
+ applyMixinsWithObservables(
590
+ Select,
591
+ AffixIconWithTrailing,
592
+ FormElementHelperText,
593
+ FormElementSuccessText
594
+ );
71
595
 
72
- const getClasses = ({
73
- connotation,
74
- tight,
75
- checked,
76
- clickableBox,
77
- clickable
596
+ const getStateClasses = ({
597
+ shape,
598
+ disabled,
599
+ appearance,
600
+ metaSlottedContent,
601
+ errorValidationMessage,
602
+ successText
78
603
  }) => classNames(
79
- "base",
80
- [`connotation-${connotation}`, Boolean(connotation)],
81
- ["tight", tight],
82
- ["selected", checked],
83
- ["clickable", clickableBox || clickable],
84
- ["readonly", !clickableBox && !clickable]
604
+ ["disabled", disabled],
605
+ [`appearance-${appearance}`, Boolean(appearance)],
606
+ [`shape-${shape}`, Boolean(shape)],
607
+ ["has-meta", Boolean(metaSlottedContent?.length)],
608
+ ["error", Boolean(errorValidationMessage)],
609
+ ["success", !!successText],
610
+ ["has-meta", Boolean(metaSlottedContent?.length)]
85
611
  );
86
- function handleControlChange(x) {
87
- if (!x.clickableBox)
88
- x._handleCheckedChange();
612
+ function renderLabel() {
613
+ return html` <label for="control" class="label" id="label">
614
+ ${(x) => x.label}
615
+ </label>`;
89
616
  }
90
- function checkbox(context) {
91
- const checkboxTag = context.tagFor(Checkbox);
92
- return html`${when(
93
- (x) => x.controlType !== "radio",
94
- html`
95
- <${checkboxTag}
96
- aria-label="${(x) => !x.clickableBox && !x.clickable && x.ariaLabel ? x.ariaLabel : null}"
97
- @change="${(x) => handleControlChange(x)}"
98
- class="control checkbox"
99
- connotation="${(x) => x.connotation === "cta" ? Connotation.CTA : Connotation.Accent}"
100
- :checked="${(x) => x.checked}"
101
- inert="${(x) => x.clickableBox || x.clickable ? true : null}"
102
- ></${checkboxTag}>`
103
- )} `;
617
+ function renderPlaceholder(context) {
618
+ const optionTag = context.tagFor(ListboxOption);
619
+ return html`
620
+ <${optionTag} ${ref("placeholderOption")}
621
+ text="${(x) => x.placeholder}" hidden disabled>
622
+ </${optionTag}>`;
104
623
  }
105
- function radio(context) {
106
- const radioTag = context.tagFor(Radio);
107
- return html`${when(
108
- (x) => x.controlType === "radio",
109
- html`
110
- <${radioTag}
111
- aria-label="${(x) => !x.clickableBox && !x.clickable && x.ariaLabel ? x.ariaLabel : null}"
112
- @change="${(x) => handleControlChange(x)}"
113
- class="control radio"
114
- connotation="${(x) => x.connotation === "cta" ? Connotation.CTA : Connotation.Accent}"
115
- :checked="${(x) => x.checked}"
116
- inert="${(x) => x.clickableBox || x.clickable ? true : null}"
117
- ></${radioTag}>`
118
- )} `;
624
+ function selectValue(context) {
625
+ const affixIconTemplate = affixIconTemplateFactory(context);
626
+ return html` <div
627
+ class="control ${getStateClasses}"
628
+ ${ref("_anchor")}
629
+ id="control"
630
+ ?disabled="${(x) => x.disabled}"
631
+ >
632
+ <div class="selected-value">
633
+ ${(x) => affixIconTemplate(x.icon, IconWrapper.Slot)}
634
+ <span class="text">${(x) => x.displayValue}</span>
635
+ <slot name="meta" ${slotted("metaSlottedContent")}></slot>
636
+ </div>
637
+ ${() => affixIconTemplate("chevron-down-line")}
638
+ </div>`;
119
639
  }
120
- const SelectableBoxTemplate = (context) => {
121
- return html`<template role="presentation">
122
- <div
123
- class="${getClasses}"
124
- tabindex="${(x) => x.clickableBox || x.clickable ? "0" : null}"
125
- role="${(x) => x.clickableBox || x.clickable ? "button" : null}"
126
- aria-pressed="${(x) => (x.clickableBox || x.clickable) && x.checked ? x.checked : null}"
127
- aria-label="${(x) => x.clickableBox || x.clickable ? x.ariaLabel : null}"
128
- @keydown="${(x, c) => x._handleKeydown(c.event)}"
129
- @click="${(x) => x.clickableBox || x.clickable ? x._handleCheckedChange() : null}"
640
+ function setFixedDropdownVarWidth(x) {
641
+ return x.open && x.fixedDropdown ? `--_select-fixed-width: ${Math.round(x.getBoundingClientRect().width)}px` : null;
642
+ }
643
+ function renderControl(context) {
644
+ const popupTag = context.tagFor(Popup);
645
+ return html`
646
+ ${when((x) => x.label, renderLabel())}
647
+ <div class="control-wrapper">
648
+ ${when((x) => !x.multiple, selectValue(context))}
649
+ <${popupTag} class="popup"
650
+ style="${setFixedDropdownVarWidth}"
651
+ ?open="${(x) => x.collapsible ? x.open : true}"
652
+ :anchor="${(x) => x._anchor}"
653
+ placement="bottom-start"
654
+ strategy="${(x) => x.fixedDropdown ? null : "absolute"}">
655
+ <div class="listbox"
656
+ id="${(x) => x.listboxId}"
657
+ role="listbox"
658
+ ?disabled="${(x) => x.disabled}"
659
+ ?hidden="${(x) => x.collapsible ? !x.open : false}"
660
+ ${ref("listbox")}>
661
+ ${when((x) => x.placeholder, renderPlaceholder(context))}
662
+ <slot
663
+ ${slotted({
664
+ filter: Listbox$1.slottedOptionFilter,
665
+ flatten: true,
666
+ property: "slottedOptions"
667
+ })}>
668
+ </slot>
669
+ </div>
670
+ </${popupTag}>
671
+ </div>
672
+ `;
673
+ }
674
+ function ifNotFromFeedback(handler) {
675
+ return (x, c) => {
676
+ if (!c.event.composedPath().includes(x._feedbackWrapper)) {
677
+ return handler(x, c.event);
678
+ }
679
+ return true;
680
+ };
681
+ }
682
+ const SelectTemplate = (context) => {
683
+ return html`
684
+ <template
685
+ class="base"
686
+ aria-label="${(x) => x.ariaLabel}"
687
+ aria-activedescendant="${(x) => x.ariaActiveDescendant}"
688
+ aria-controls="${(x) => x.ariaControls}"
689
+ aria-disabled="${(x) => x.ariaDisabled}"
690
+ aria-expanded="${(x) => x.ariaExpanded}"
691
+ aria-haspopup="${(x) => x.collapsible ? "listbox" : null}"
692
+ aria-multiselectable="${(x) => x.ariaMultiSelectable}"
693
+ role="combobox"
694
+ tabindex="${(x) => !x.disabled ? "0" : null}"
695
+ @click="${ifNotFromFeedback((x, e) => x.clickHandler(e))}"
696
+ @focusin="${ifNotFromFeedback((x, e) => x.focusinHandler(e))}"
697
+ @focusout="${ifNotFromFeedback(
698
+ (x, e) => x.focusoutHandler(e)
699
+ )}"
700
+ @keydown="${ifNotFromFeedback(
701
+ (x, e) => x.keydownHandler(e)
702
+ )}"
703
+ @mousedown="${ifNotFromFeedback(
704
+ (x, e) => x.mousedownHandler(e)
705
+ )}"
130
706
  >
131
- ${checkbox(context)} ${radio(context)}
132
- <slot></slot>
133
- </div>
134
- </template>`;
707
+ ${renderControl(context)}
708
+ <div class="feedback-wrapper" ${ref("_feedbackWrapper")}>
709
+ ${getFeedbackTemplate(context)}
710
+ </div>
711
+ </template>
712
+ `;
135
713
  };
136
714
 
137
- const selectableBoxDefinition = SelectableBox.compose({
138
- baseName: "selectable-box",
139
- template: SelectableBoxTemplate,
140
- styles,
141
- shadowOptions: {
142
- delegatesFocus: true
143
- }
715
+ const selectDefinition = Select.compose({
716
+ baseName: "select",
717
+ template: SelectTemplate,
718
+ styles
144
719
  });
145
- const selectableBoxRegistries = [
146
- selectableBoxDefinition(),
147
- ...checkboxRegistries,
148
- ...radioRegistries
720
+ const selectRegistries = [
721
+ selectDefinition(),
722
+ ...popupRegistries,
723
+ ...iconRegistries,
724
+ ...listboxOptionRegistries
149
725
  ];
150
- const registerSelectableBox = registerFactory(selectableBoxRegistries);
726
+ const registerSelect = registerFactory(selectRegistries);
151
727
 
152
- export { selectableBoxRegistries as a, registerSelectableBox as r, selectableBoxDefinition as s };
728
+ export { selectRegistries as a, registerSelect as r, selectDefinition as s };