@vonage/vivid 4.17.0 → 4.19.0-preview.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 (364) hide show
  1. package/custom-elements.json +4248 -4149
  2. package/date-time-picker/index.cjs +5 -0
  3. package/date-time-picker/index.js +3 -0
  4. package/dial-pad/index.cjs +1 -1
  5. package/dial-pad/index.js +1 -1
  6. package/dialog/index.cjs +1 -1
  7. package/dialog/index.js +1 -1
  8. package/divider/index.cjs +1 -1
  9. package/divider/index.js +1 -1
  10. package/elevation/index.cjs +1 -1
  11. package/elevation/index.js +1 -1
  12. package/empty-state/index.cjs +1 -1
  13. package/empty-state/index.js +1 -1
  14. package/fab/index.cjs +1 -1
  15. package/fab/index.js +1 -1
  16. package/file-picker/index.cjs +1 -1
  17. package/file-picker/index.js +1 -1
  18. package/header/index.cjs +1 -1
  19. package/header/index.js +1 -1
  20. package/icon/index.cjs +1 -1
  21. package/icon/index.js +1 -1
  22. package/index.cjs +136 -133
  23. package/index.js +45 -44
  24. package/layout/index.cjs +1 -1
  25. package/layout/index.js +1 -1
  26. package/lib/action-group/action-group.d.ts +449 -3
  27. package/lib/banner/banner.d.ts +449 -3
  28. package/lib/breadcrumb-item/breadcrumb-item.d.ts +449 -1
  29. package/lib/checkbox/checkbox.d.ts +449 -4
  30. package/lib/components.d.ts +1 -0
  31. package/lib/date-picker/date-picker.d.ts +2182 -4
  32. package/lib/date-picker/date-picker.template.d.ts +2 -0
  33. package/lib/date-range-picker/date-range-picker.d.ts +1110 -4
  34. package/lib/date-range-picker/date-range-picker.template.d.ts +2 -0
  35. package/lib/date-time-picker/date-time-picker.d.ts +2175 -0
  36. package/lib/date-time-picker/date-time-picker.template.d.ts +2 -0
  37. package/lib/date-time-picker/definition.d.ts +1 -0
  38. package/lib/date-time-picker/locale.d.ts +9 -0
  39. package/lib/dialog/dialog.d.ts +449 -2
  40. package/lib/divider/divider.d.ts +448 -1
  41. package/lib/menu/menu.d.ts +446 -1
  42. package/lib/nav-disclosure/nav-disclosure.d.ts +449 -2
  43. package/lib/number-field/number-field.d.ts +450 -3
  44. package/lib/option/option.d.ts +4 -11
  45. package/lib/progress/progress.d.ts +449 -2
  46. package/lib/progress-ring/progress-ring.d.ts +449 -2
  47. package/lib/rich-text-editor/facades/vivid-prose-mirror.facade.d.ts +1 -0
  48. package/lib/rich-text-editor/rich-text-editor.d.ts +7 -4
  49. package/lib/searchable-select/searchable-select.d.ts +3 -0
  50. package/lib/select/select.d.ts +1 -5
  51. package/lib/selectable-box/selectable-box.d.ts +449 -2
  52. package/lib/slider/slider.d.ts +449 -3
  53. package/lib/split-button/split-button.d.ts +449 -3
  54. package/lib/switch/switch.d.ts +449 -2
  55. package/lib/tag-group/tag-group.d.ts +449 -2
  56. package/lib/text-anchor/text-anchor.d.ts +449 -1
  57. package/lib/text-area/text-area.d.ts +450 -3
  58. package/lib/text-field/text-field.d.ts +450 -7
  59. package/lib/time-picker/locale.d.ts +0 -2
  60. package/lib/time-picker/time-picker.d.ts +1053 -9
  61. package/lib/time-picker/time-picker.template.d.ts +2 -1
  62. package/locales/de-DE.cjs +29 -5
  63. package/locales/de-DE.js +29 -5
  64. package/locales/en-GB.cjs +29 -5
  65. package/locales/en-GB.js +29 -5
  66. package/locales/en-US.cjs +29 -5
  67. package/locales/en-US.js +29 -5
  68. package/locales/ja-JP.cjs +29 -5
  69. package/locales/ja-JP.js +29 -5
  70. package/locales/zh-CN.cjs +29 -5
  71. package/locales/zh-CN.js +29 -5
  72. package/menu/index.cjs +1 -1
  73. package/menu/index.js +1 -1
  74. package/menu-item/index.cjs +1 -1
  75. package/menu-item/index.js +1 -1
  76. package/nav/index.cjs +1 -1
  77. package/nav/index.js +1 -1
  78. package/nav-disclosure/index.cjs +1 -1
  79. package/nav-disclosure/index.js +1 -1
  80. package/nav-item/index.cjs +1 -1
  81. package/nav-item/index.js +1 -1
  82. package/note/index.cjs +1 -1
  83. package/note/index.js +1 -1
  84. package/number-field/index.cjs +1 -1
  85. package/number-field/index.js +1 -1
  86. package/option/index.cjs +1 -1
  87. package/option/index.js +1 -1
  88. package/package.json +1 -1
  89. package/pagination/index.cjs +1 -1
  90. package/pagination/index.js +1 -1
  91. package/popup/index.cjs +1 -1
  92. package/popup/index.js +1 -1
  93. package/progress/index.cjs +1 -1
  94. package/progress/index.js +1 -1
  95. package/progress-ring/index.cjs +1 -1
  96. package/progress-ring/index.js +1 -1
  97. package/radio/index.cjs +1 -1
  98. package/radio/index.js +1 -1
  99. package/radio-group/index.cjs +1 -1
  100. package/radio-group/index.js +1 -1
  101. package/range-slider/index.cjs +1 -1
  102. package/range-slider/index.js +1 -1
  103. package/rich-text-editor/index.cjs +1 -1
  104. package/rich-text-editor/index.js +1 -1
  105. package/searchable-select/index.cjs +1 -1
  106. package/searchable-select/index.js +1 -1
  107. package/select/index.cjs +1 -1
  108. package/select/index.js +1 -1
  109. package/selectable-box/index.cjs +1 -1
  110. package/selectable-box/index.js +1 -1
  111. package/shared/Reflector.cjs +71 -0
  112. package/shared/Reflector.js +69 -0
  113. package/shared/affix.cjs +1 -1
  114. package/shared/affix.js +1 -1
  115. package/shared/anchor.cjs +0 -10
  116. package/shared/anchor.js +0 -10
  117. package/shared/aria/delegates-aria.d.ts +454 -0
  118. package/shared/base-progress.js +1 -1
  119. package/shared/breadcrumb-item.cjs +2 -1
  120. package/shared/breadcrumb-item.js +2 -1
  121. package/shared/button.cjs +2 -13
  122. package/shared/button.js +2 -13
  123. package/shared/{presentationDate.cjs → calendar-picker.template.cjs} +730 -900
  124. package/shared/{presentationDate.js → calendar-picker.template.js} +672 -845
  125. package/shared/datetime/dateTimeStr.d.ts +6 -0
  126. package/shared/datetime/presentationDate.d.ts +4 -0
  127. package/shared/{date-picker/calendar → datetime}/presentationDateRange.d.ts +3 -3
  128. package/shared/datetime/presentationDateTime.d.ts +4 -0
  129. package/{lib/time-picker/time → shared/datetime}/time.d.ts +1 -0
  130. package/shared/definition.cjs +1 -1
  131. package/shared/definition.js +1 -1
  132. package/shared/definition11.cjs +8 -11
  133. package/shared/definition11.js +8 -11
  134. package/shared/definition14.cjs +2 -2
  135. package/shared/definition14.js +2 -2
  136. package/shared/definition15.cjs +3 -10
  137. package/shared/definition15.js +3 -10
  138. package/shared/definition16.cjs +29 -33
  139. package/shared/definition16.js +29 -33
  140. package/shared/definition17.cjs +1 -1
  141. package/shared/definition17.js +1 -1
  142. package/shared/definition18.cjs +56 -91
  143. package/shared/definition18.js +56 -91
  144. package/shared/definition19.cjs +68 -32
  145. package/shared/definition19.js +58 -22
  146. package/shared/definition20.cjs +253 -220
  147. package/shared/definition20.js +254 -220
  148. package/shared/definition21.cjs +200 -286
  149. package/shared/definition21.js +198 -284
  150. package/shared/definition22.cjs +302 -31
  151. package/shared/definition22.js +301 -30
  152. package/shared/definition23.cjs +37 -58
  153. package/shared/definition23.js +36 -57
  154. package/shared/definition24.cjs +50 -70
  155. package/shared/definition24.js +49 -69
  156. package/shared/definition25.cjs +75 -2475
  157. package/shared/definition25.js +74 -2475
  158. package/shared/definition26.cjs +2480 -50
  159. package/shared/definition26.js +2479 -48
  160. package/shared/definition27.cjs +53 -271
  161. package/shared/definition27.js +52 -269
  162. package/shared/definition28.cjs +271 -48
  163. package/shared/definition28.js +269 -47
  164. package/shared/definition29.cjs +37 -764
  165. package/shared/definition29.js +36 -758
  166. package/shared/definition3.cjs +2 -9
  167. package/shared/definition3.js +2 -9
  168. package/shared/definition30.cjs +739 -57
  169. package/shared/definition30.js +733 -56
  170. package/shared/definition31.cjs +93 -22
  171. package/shared/definition31.js +92 -21
  172. package/shared/definition32.cjs +28 -10
  173. package/shared/definition32.js +27 -9
  174. package/shared/definition33.cjs +10 -52
  175. package/shared/definition33.js +9 -51
  176. package/shared/definition34.cjs +30 -411
  177. package/shared/definition34.js +30 -412
  178. package/shared/definition35.cjs +422 -52
  179. package/shared/definition35.js +423 -53
  180. package/shared/definition36.cjs +54 -216
  181. package/shared/definition36.js +54 -215
  182. package/shared/definition37.cjs +201 -71
  183. package/shared/definition37.js +200 -70
  184. package/shared/definition38.cjs +53 -48
  185. package/shared/definition38.js +51 -46
  186. package/shared/definition39.cjs +57 -263
  187. package/shared/definition39.js +56 -262
  188. package/shared/definition4.cjs +2 -2
  189. package/shared/definition4.js +2 -2
  190. package/shared/definition40.cjs +220 -148
  191. package/shared/definition40.js +220 -148
  192. package/shared/definition41.cjs +143 -567
  193. package/shared/definition41.js +143 -568
  194. package/shared/definition42.cjs +596 -12573
  195. package/shared/definition42.js +596 -12573
  196. package/shared/definition43.cjs +13489 -1058
  197. package/shared/definition43.js +13489 -1059
  198. package/shared/definition44.cjs +968 -696
  199. package/shared/definition44.js +970 -697
  200. package/shared/definition45.cjs +850 -105
  201. package/shared/definition45.js +850 -104
  202. package/shared/definition46.cjs +110 -90
  203. package/shared/definition46.js +108 -88
  204. package/shared/definition47.cjs +88 -464
  205. package/shared/definition47.js +87 -463
  206. package/shared/definition48.cjs +457 -111
  207. package/shared/definition48.js +456 -110
  208. package/shared/definition49.cjs +103 -109
  209. package/shared/definition49.js +102 -108
  210. package/shared/definition5.cjs +3 -3
  211. package/shared/definition5.js +3 -3
  212. package/shared/definition50.cjs +136 -14
  213. package/shared/definition50.js +135 -13
  214. package/shared/definition51.cjs +16 -115
  215. package/shared/definition51.js +15 -114
  216. package/shared/definition52.cjs +79 -486
  217. package/shared/definition52.js +78 -485
  218. package/shared/definition53.cjs +503 -24
  219. package/shared/definition53.js +502 -23
  220. package/shared/definition54.cjs +23 -137
  221. package/shared/definition54.js +22 -136
  222. package/shared/definition55.cjs +96 -241
  223. package/shared/definition55.js +95 -241
  224. package/shared/definition56.cjs +261 -61
  225. package/shared/definition56.js +260 -60
  226. package/shared/definition57.cjs +419 -788
  227. package/shared/definition57.js +420 -789
  228. package/shared/definition58.cjs +27 -144
  229. package/shared/definition58.js +27 -143
  230. package/shared/definition59.cjs +83 -54
  231. package/shared/definition59.js +82 -53
  232. package/shared/definition6.cjs +1 -1
  233. package/shared/definition6.js +1 -1
  234. package/shared/definition60.cjs +80 -165
  235. package/shared/definition60.js +79 -163
  236. package/shared/definition61.cjs +143 -230
  237. package/shared/definition61.js +141 -229
  238. package/shared/definition62.cjs +233 -69344
  239. package/shared/definition62.js +232 -69343
  240. package/shared/definition63.cjs +69381 -28
  241. package/shared/definition63.js +69379 -26
  242. package/shared/definition64.cjs +28 -2168
  243. package/shared/definition64.js +27 -2166
  244. package/shared/definition65.cjs +2195 -0
  245. package/shared/definition65.js +2190 -0
  246. package/shared/definition7.cjs +1 -1
  247. package/shared/definition7.js +1 -1
  248. package/shared/definition8.cjs +3 -9
  249. package/shared/definition8.js +3 -9
  250. package/shared/definition9.cjs +1 -1
  251. package/shared/definition9.js +1 -1
  252. package/shared/delegates-aria.cjs +69 -0
  253. package/shared/delegates-aria.js +67 -0
  254. package/shared/form-associated.js +1 -1
  255. package/shared/form-elements.cjs +1 -1
  256. package/shared/form-elements.js +1 -1
  257. package/shared/foundation/anchor/anchor.d.ts +0 -8
  258. package/shared/foundation/button/button.d.ts +449 -7
  259. package/shared/foundation/listbox/listbox.d.ts +0 -9
  260. package/shared/listbox.cjs +4 -30
  261. package/shared/listbox.js +4 -30
  262. package/shared/localization/Locale.d.ts +6 -2
  263. package/shared/option.cjs +38 -50
  264. package/shared/option.js +39 -51
  265. package/shared/picker-field/locale.d.ts +4 -0
  266. package/shared/picker-field/mixins/calendar-picker.d.ts +558 -0
  267. package/shared/{date-picker/locale.d.ts → picker-field/mixins/calendar-picker.locale.d.ts} +1 -3
  268. package/shared/picker-field/mixins/calendar-picker.template.d.ts +555 -0
  269. package/shared/picker-field/mixins/calendar-segments/calendarGrid.d.ts +17 -0
  270. package/shared/{date-picker/calendar → picker-field/mixins/calendar-segments}/monthPickerGrid.d.ts +3 -3
  271. package/{lib/time-picker → shared/picker-field/mixins}/inline-time-picker/columns.d.ts +1 -1
  272. package/{lib/time-picker → shared/picker-field/mixins}/inline-time-picker/inline-time-picker.d.ts +2 -2
  273. package/{lib/time-picker/time/picker.d.ts → shared/picker-field/mixins/inline-time-picker/picker-option.d.ts} +1 -1
  274. package/shared/picker-field/mixins/min-max-calendar-picker.d.ts +1110 -0
  275. package/shared/picker-field/mixins/single-date-picker.d.ts +1626 -0
  276. package/shared/picker-field/mixins/single-value-picker.d.ts +518 -0
  277. package/shared/picker-field/mixins/time-selection-picker.d.ts +1053 -0
  278. package/shared/picker-field/mixins/time-selection-picker.template.d.ts +1050 -0
  279. package/shared/picker-field/picker-field.d.ts +11 -0
  280. package/shared/picker-field/picker-field.form-associated.d.ts +11 -0
  281. package/shared/picker-field/picker-field.template.d.ts +7 -0
  282. package/shared/picker-field.template.cjs +315 -0
  283. package/shared/picker-field.template.js +310 -0
  284. package/shared/single-date-picker.cjs +46 -0
  285. package/shared/single-date-picker.js +44 -0
  286. package/shared/single-value-picker.cjs +77 -0
  287. package/shared/single-value-picker.js +75 -0
  288. package/shared/slider.template.cjs +3 -3
  289. package/shared/slider.template.js +3 -3
  290. package/shared/text-anchor.cjs +2 -1
  291. package/shared/text-anchor.js +2 -1
  292. package/shared/text-anchor.template.cjs +3 -5
  293. package/shared/text-anchor.template.js +3 -5
  294. package/shared/text-field.cjs +2 -555
  295. package/shared/text-field.js +2 -554
  296. package/shared/time-selection-picker.template.cjs +776 -0
  297. package/shared/time-selection-picker.template.js +767 -0
  298. package/shared/vivid-element.cjs +1 -1
  299. package/shared/vivid-element.js +1 -1
  300. package/side-drawer/index.cjs +1 -1
  301. package/side-drawer/index.js +1 -1
  302. package/slider/index.cjs +1 -1
  303. package/slider/index.js +1 -1
  304. package/split-button/index.cjs +1 -1
  305. package/split-button/index.js +1 -1
  306. package/styles/core/all.css +1 -1
  307. package/styles/core/theme.css +1 -1
  308. package/styles/core/typography.css +1 -1
  309. package/styles/tokens/theme-dark.css +4 -4
  310. package/styles/tokens/theme-light.css +4 -4
  311. package/styles/tokens/vivid-2-compat.css +1 -1
  312. package/switch/index.cjs +1 -1
  313. package/switch/index.js +1 -1
  314. package/tab/index.cjs +1 -1
  315. package/tab/index.js +1 -1
  316. package/tab-panel/index.cjs +1 -1
  317. package/tab-panel/index.js +1 -1
  318. package/tabs/index.cjs +1 -1
  319. package/tabs/index.js +1 -1
  320. package/tag/index.cjs +1 -1
  321. package/tag/index.js +1 -1
  322. package/tag-group/index.cjs +1 -1
  323. package/tag-group/index.js +1 -1
  324. package/text-anchor/index.cjs +1 -1
  325. package/text-anchor/index.js +1 -1
  326. package/text-area/index.cjs +1 -1
  327. package/text-area/index.js +1 -1
  328. package/text-field/index.cjs +1 -1
  329. package/text-field/index.js +1 -1
  330. package/time-picker/index.cjs +1 -1
  331. package/time-picker/index.js +1 -1
  332. package/toggletip/index.cjs +1 -1
  333. package/toggletip/index.js +1 -1
  334. package/tooltip/index.cjs +1 -1
  335. package/tooltip/index.js +1 -1
  336. package/tree-item/index.cjs +1 -1
  337. package/tree-item/index.js +1 -1
  338. package/tree-view/index.cjs +1 -1
  339. package/tree-view/index.js +1 -1
  340. package/video-player/index.cjs +1 -1
  341. package/video-player/index.js +1 -1
  342. package/vivid.api.json +286 -1144
  343. package/lib/time-picker/time-picker.form-associated.d.ts +0 -11
  344. package/shared/aria-global.cjs +0 -93
  345. package/shared/aria-global.js +0 -91
  346. package/shared/date-picker/calendar/calendarGrid.d.ts +0 -17
  347. package/shared/date-picker/calendar/presentationDate.d.ts +0 -4
  348. package/shared/date-picker/date-picker-base.d.ts +0 -21
  349. package/shared/date-picker/date-picker-base.form-associated.d.ts +0 -11
  350. package/shared/date-picker/date-picker-base.template.d.ts +0 -3
  351. package/shared/foundation/patterns/aria-global.d.ts +0 -21
  352. package/shared/foundation/patterns/index.d.ts +0 -1
  353. package/shared/text-field2.cjs +0 -5
  354. package/shared/text-field2.js +0 -3
  355. package/shared/trapped-focus.cjs +0 -35
  356. package/shared/trapped-focus.js +0 -33
  357. /package/shared/{date-picker/calendar → datetime}/dateRange.d.ts +0 -0
  358. /package/shared/{date-picker/calendar → datetime}/dateStr.d.ts +0 -0
  359. /package/shared/{date-picker/calendar → datetime}/month.d.ts +0 -0
  360. /package/{lib/time-picker/time → shared/datetime}/presentationTime.d.ts +0 -0
  361. /package/shared/{date-picker/calendar → datetime}/year.d.ts +0 -0
  362. /package/shared/{date-picker/calendar → picker-field/mixins/calendar-segments}/segment.d.ts +0 -0
  363. /package/{lib/time-picker → shared/picker-field/mixins}/inline-time-picker/definition.d.ts +0 -0
  364. /package/{lib/time-picker → shared/picker-field/mixins}/inline-time-picker/inline-time-picker.template.d.ts +0 -0
@@ -1,920 +1,1192 @@
1
1
  'use strict';
2
2
 
3
- const definition = require('./definition64.cjs');
4
- const definition$2 = require('./definition27.cjs');
5
- const definition$3 = require('./definition35.cjs');
3
+ const definition$1 = require('./definition11.cjs');
4
+ const definition = require('./definition65.cjs');
5
+ const definition$3 = require('./definition28.cjs');
6
6
  const vividElement = require('./vivid-element.cjs');
7
7
  const applyMixinsWithObservables = require('./applyMixinsWithObservables.cjs');
8
- const listbox = require('./listbox.cjs');
8
+ const scrollIntoView = require('./scrollIntoView.cjs');
9
9
  const formAssociated = require('./form-associated.cjs');
10
- const numbers = require('./numbers.cjs');
11
- const strings = require('./strings.cjs');
12
- const keyCodes = require('./key-codes.cjs');
13
- const formElements = require('./form-elements.cjs');
14
10
  const affix = require('./affix.cjs');
11
+ const localized = require('./localized.cjs');
12
+ const formElements = require('./form-elements.cjs');
13
+ const applyMixins = require('./apply-mixins.cjs');
15
14
  const option = require('./option.cjs');
16
- const definition$1 = require('./definition11.cjs');
17
- const index = require('./index.cjs');
18
- const ref = require('./ref.cjs');
15
+ const definition$2 = require('./definition38.cjs');
19
16
  const when = require('./when.cjs');
17
+ const ref = require('./ref.cjs');
20
18
  const slotted = require('./slotted.cjs');
21
19
  const classNames = require('./class-names.cjs');
20
+ const repeat = require('./repeat.cjs');
22
21
 
23
- const styles = ".chevron{display:flex;flex-shrink:0;font:var(--vvd-typography-base-extended);transform:rotate(0);transition:transform .2s}:host([aria-expanded=true]) .chevron,:host([open]) .chevron{transform:rotate(180deg)}:host(:focus-visible){outline:none}:host{display:inline-flex;flex-direction:column;gap:4px;--_low-ink-color: var(--vvd-color-neutral-600);--focus-stroke-gap-color: transparent}:host([disabled]){--_low-ink-color: var(--vvd-color-neutral-400);cursor:not-allowed}.label{color:var(--vvd-color-canvas-text);contain:inline-size;font:var(--vvd-typography-base)}.control{--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--vvd-color-canvas);--_appearance-color-outline: var(--_connotation-color-intermediate)}.control.appearance-ghost{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--vvd-color-canvas);--_appearance-color-outline: var(--_connotation-color-fierce)}.control:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)).appearance-ghost{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: var(--_connotation-color-faint);--_appearance-color-outline: transparent}.control:where(.disabled,:disabled){--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: var(--vvd-color-neutral-100);--_appearance-color-outline: var(--vvd-color-neutral-300)}.control:where(.disabled,:disabled).appearance-ghost{--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control:where(.readonly):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--vvd-color-neutral-200);--_appearance-color-outline: var(--vvd-color-neutral-400)}.control:where(.readonly):where(:not(.disabled,:disabled)).appearance-ghost{--_appearance-color-text: var(--vvd-color-neutral-600);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.control:where(.error):where(:not(.disabled,:disabled)){--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-alert-50);--_appearance-color-outline: var(--vvd-color-alert-500)}.control:where(.error):where(:not(.disabled,:disabled)).appearance-ghost{--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-alert-50);--_appearance-color-outline: transparent}.control:where(.success):where(:not(.disabled,:disabled)){--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-success-50);--_appearance-color-outline: var(--vvd-color-success-500)}.control:where(.success):where(:not(.disabled,:disabled)).appearance-ghost{--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-success-50);--_appearance-color-outline: transparent}.control{--_connotation-color-primary: var(--vvd-select-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-primary-text: var(--vvd-select-accent-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-select-accent-primary-increment, var(--vvd-color-neutral-800));--_connotation-color-intermediate: var(--vvd-select-accent-intermediate, var(--vvd-color-neutral-500));--_connotation-color-faint: var(--vvd-select-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-select-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-firm: var(--vvd-select-accent-firm, var(--vvd-color-canvas-text));--_connotation-color-fierce: var(--vvd-select-accent-fierce, var(--vvd-color-neutral-700))}.control{border-radius:var(--_select-control-border-radius);block-size:var(--_select-block-size);padding-inline:var(--_select-padding-inline)}.control{--_select-icon-size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))/2) ;--_select-block-size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) ;--_select-padding-inline: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))*.4) ;display:flex;align-items:center;justify-content:space-between;background-color:var(--_appearance-color-fill);box-shadow:inset 0 0 0 1px var(--_appearance-color-outline);color:var(--_appearance-color-text);font:var(--vvd-typography-base);gap:8px;transition:box-shadow .2s,background-color .2s}.control.size-condensed{--_select-icon-size: calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2))*.4) ;--_select-block-size: calc(1px*(32 + 4*clamp(-1, var(--vvd-size-density, 0), 2))) ;--_select-padding-inline: calc(1px*(24 + 4*clamp(-1, var(--vvd-size-density, 0), 2))/2) }.control-wrapper{position:relative}.control:not(.disabled){cursor:pointer}.control.disabled{pointer-events:none}.control:not(.shape-pill){--_select-control-border-radius: 8px}.control.shape-pill{--_select-control-border-radius: 24px}:host(:focus-visible) .control{box-shadow:inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));outline-offset:calc(-2px - var(--focus-inset, 0px))}.listbox{display:flex;max-height:var(--select-height, 408px);flex-direction:column;padding:4px;gap:2px;overflow-y:auto}:host([multiple]:focus-visible) .listbox{box-shadow:inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));outline-offset:calc(-2px - var(--focus-inset, 0px));border-radius:8px}.selected-value{display:flex;overflow:hidden;flex-grow:1;align-items:center;column-gap:12px;white-space:nowrap}.selected-value .text{overflow:hidden;max-inline-size:100%;text-overflow:ellipsis}.control.shows-placeholder .selected-value .text{color:var(--vvd-color-neutral-600)}.selected-value slot[name=icon]{flex:0 0 var(--_select-icon-size);font-size:var(--_select-icon-size);line-height:1}.control.has-meta .selected-value{padding-inline-end:8px}.feedback-wrapper{display:contents}::part(popup-base){inline-size:max-content;min-inline-size:var(--_select-fixed-width, 100%)}:host([multiple]) ::part(popup-base){position:static}";
22
+ 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)}:not(.disabled) .chevron{cursor:pointer}.disabled .chevron{color:var(--_low-ink-color);cursor:not-allowed}:host(:focus-visible){outline:none}:host{display:inline-block;inline-size:300px;--_low-ink-color: var(--vvd-color-neutral-600)}:host([disabled]){--_low-ink-color: var(--vvd-color-neutral-400);cursor:not-allowed}.control-wrapper{display:flex;flex-direction:column;gap:4px}.label{color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base)}.fieldset{--_connotation-color-primary: var(--vvd-searchable-select-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-primary-text: var(--vvd-searchable-select-accent-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-searchable-select-accent-primary-increment, var(--vvd-color-neutral-800));--_connotation-color-intermediate: var(--vvd-searchable-select-accent-intermediate, var(--vvd-color-neutral-500));--_connotation-color-faint: var(--vvd-searchable-select-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-soft: var(--vvd-searchable-select-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-firm: var(--vvd-searchable-select-accent-firm, var(--vvd-color-canvas-text));--_connotation-color-fierce: var(--vvd-searchable-select-accent-fierce, var(--vvd-color-neutral-700))}.fieldset{--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--vvd-color-canvas);--_appearance-color-outline: var(--_connotation-color-intermediate)}.fieldset.appearance-ghost{--_appearance-color-text: var(--_connotation-color-firm);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.fieldset: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)}.fieldset: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}.fieldset: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)}.fieldset:where(.disabled,:disabled).appearance-ghost{--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.fieldset: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)}.fieldset:where(.readonly):where(:not(.disabled,:disabled)).appearance-ghost{--_appearance-color-text: var(--vvd-color-neutral-600);--_appearance-color-fill: transparent;--_appearance-color-outline: transparent}.fieldset: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)}.fieldset:where(.error):where(:not(.disabled,:disabled)).appearance-ghost{--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-alert-50);--_appearance-color-outline: transparent}.fieldset: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)}.fieldset:where(.success):where(:not(.disabled,:disabled)).appearance-ghost{--_appearance-color-text: notSet;--_appearance-color-fill: var(--vvd-color-success-50);--_appearance-color-outline: transparent}.fieldset{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;padding-block:8px;padding-inline:16px;transition:box-shadow .2s,background-color .2s}.fieldset:focus-within{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));--focus-stroke-gap-color: transparent}:host(:not([shape=pill])) .fieldset{border-radius:8px}:host([shape=pill]) .fieldset{border-radius:24px}.popup-wrapper{position:relative}.content-area{display:flex;overflow:hidden;flex:1;flex-direction:column;gap:8px;min-block-size:24px}.tag-row{display:flex;gap:8px;inline-size:100%}.tag-row.contains-only-input:not(:focus-within){display:contents}.tag-wrapper{overflow:hidden}.tag{max-inline-size:100%}input{box-sizing:border-box;flex:1;border:none;background:none;block-size:24px;font:var(--vvd-typography-base);max-inline-size:100%;min-inline-size:100px;outline:none}.contains-only-input input:not(:focus){position:absolute;block-size:0;inline-size:0;min-inline-size:0;opacity:0;pointer-events:none}.listbox{display:flex;flex-direction:column;padding:4px;gap:2px;max-block-size:var(--searchable-select-height, 408px);overflow-y:auto}.empty-message{display:flex;align-items:center;justify-content:center;color:var(--vvd-color-neutral-300);min-block-size:40px;text-align:center}::part(popup-base){inline-size:max-content;min-inline-size:var(--_searchable-select-fixed-width, 100%)}slot[name=icon]{font-size:20px}.visually-hidden{position:absolute;overflow:hidden;width:1px;height:1px;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap}";
24
23
 
25
- class _Select extends listbox.Listbox {
24
+ const optionTagStyles = ".base{--_connotation-color-contrast: var(--vvd-option-tag-accent-contrast, var(--vvd-color-neutral-800))}.base{position:relative;display:inline-flex;box-sizing:border-box;align-items:center;background-color:var(--fill-color);block-size:calc(1px*(24 + 4*clamp(-1,var(--vvd-size-density, 0),2)));box-shadow:inset 0 0 0 1px var(--outline-color);color:var(--text-color);column-gap:8px;font:var(--vvd-typography-base-bold);max-inline-size:100%;padding-inline:8px;user-select:none;vertical-align:middle}.base:not(.disabled){--text-color: var(--_connotation-color-contrast);--fill-color: color-mix( in srgb, var(--_connotation-color-contrast), transparent 87.5% );--outline-color: transparent}.base.disabled{--text-color: var(--vvd-color-neutral-300);--fill-color: color-mix( in srgb, var(--vvd-color-neutral-800), transparent 87.5% );--outline-color: transparent}.base:not(.shape-pill){border-radius:4px}.base.shape-pill{border-radius:16px}.label{overflow:hidden;max-inline-size:100%;text-overflow:ellipsis;white-space:nowrap}slot[name=icon]{font-size:calc(calc(1px*(24 + 4*clamp(-1,var(--vvd-size-density, 0),2))) / 1.5);line-height:1}.icon-placeholder{inline-size:calc(calc(1px*(24 + 4*clamp(-1,var(--vvd-size-density, 0),2))) / 1.5)}.remove-button{display:flex;align-items:center;border-radius:inherit;cursor:pointer;outline:none}.disabled .remove-button{pointer-events:none}.remove-button:focus-visible:before{--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));position:absolute;z-index:1;display:block;border-radius:inherit;content:\"\";inset:0;pointer-events:none}";
25
+
26
+ class _SearchableSelect extends vividElement.VividElement {
26
27
  }
27
- class FormAssociatedSelect extends formAssociated.FormAssociated(_Select) {
28
+ class FormAssociatedSearchableSelect extends formAssociated.FormAssociated(
29
+ _SearchableSelect
30
+ ) {
28
31
  constructor() {
29
32
  super(...arguments);
30
- this.proxy = document.createElement("select");
33
+ this.proxy = document.createElement("input");
31
34
  }
32
35
  }
33
36
 
34
- var __defProp = Object.defineProperty;
37
+ var __defProp$1 = Object.defineProperty;
35
38
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
36
- var __decorateClass = (decorators, target, key, kind) => {
39
+ var __typeError = (msg) => {
40
+ throw TypeError(msg);
41
+ };
42
+ var __decorateClass$1 = (decorators, target, key, kind) => {
37
43
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
38
44
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
39
45
  if (decorator = decorators[i])
40
46
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
41
- if (kind && result) __defProp(target, key, result);
47
+ if (kind && result) __defProp$1(target, key, result);
42
48
  return result;
43
49
  };
44
- exports.Select = class Select extends FormAssociatedSelect {
50
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
51
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
52
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
53
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
54
+ var _SearchableSelect_instances, updateValuesThroughUserInteraction_fn, updateValuesWhileMaintainingOrder_fn, isValidValue_fn, _slottedOptionsChangeHandler, updateSelectedOnSlottedOptions_fn, handleOptionInteraction_fn, _clonedTagIcons, tagIconOfOption_fn, updateClonedTagIconOfOption_fn, updateFilteredOptions_fn, transitionHighlightedOptionTo_fn, selectHighlightedOption_fn, highlightFirstOption_fn, highlightLastOption_fn, highlightPrevPage_fn, highlightNextPage_fn, highlightPreviousOption_fn, highlightNextOption_fn, textForValue_fn, measureTagWidth_fn, updateTagLayout_fn, moveTagFocusTo_fn, nextTagIndexLeft_fn, nextTagIndexRight_fn, nextTagIndexForRemoved_fn, determineInitialValues_fn, updateFormValue_fn, _resizeObserver;
55
+ const TagGapPx = 8;
56
+ const InputMinWidthPx = 100;
57
+ const PageSize = 10;
58
+ const isFormAssociatedTryingToSetFormValue = (value) => typeof value === "string";
59
+ exports.SearchableSelect = class SearchableSelect extends FormAssociatedSearchableSelect {
45
60
  constructor() {
46
61
  super(...arguments);
47
- this.activeIndex = -1;
48
- /**
49
- * The start index when checking a range of options.
50
- *
51
- * @internal
52
- */
53
- this.rangeStartIndex = -1;
62
+ __privateAdd(this, _SearchableSelect_instances);
63
+ this.fixedDropdown = false;
54
64
  this.open = false;
65
+ this.multiple = false;
66
+ this.externalTags = false;
67
+ this.maxLines = null;
68
+ this.values = [];
69
+ this.initialValues = [];
70
+ this._internalSearchText = null;
71
+ // --- Slotted options ---
55
72
  /**
56
- * The unique id for the internal listbox element.
57
- *
58
73
  * @internal
59
74
  */
60
- this.listboxId = strings.uniqueId("listbox-");
61
- this.maxHeight = 0;
62
- this.fixedDropdown = false;
63
- this.placeholderOption = null;
64
- this._feedbackWrapper = null;
65
- }
66
- /**
67
- * Returns the last checked option.
68
- *
69
- * @internal
70
- */
71
- get activeOption() {
72
- return this.options[this.activeIndex];
75
+ this._areOptionsInitialized = false;
76
+ __privateAdd(this, _slottedOptionsChangeHandler, {
77
+ handleChange: (source, _) => {
78
+ if (source.selected && !this.values.includes(source.value)) {
79
+ this.values = [...this.values, source.value];
80
+ } else if (!source.selected && this.values.includes(source.value)) {
81
+ this.values = this.values.filter((option) => option !== source.value);
82
+ }
83
+ }
84
+ });
85
+ // --- Option tag icons ---
86
+ __privateAdd(this, _clonedTagIcons, /* @__PURE__ */ new Map());
87
+ this._filteredOptions = [];
88
+ this._filteredEnabledOptions = [];
89
+ this.loading = false;
90
+ this._highlightedOptionIndex = null;
91
+ this._numElidedTags = 0;
92
+ this._tagRows = [];
93
+ this._lastTagRow = [];
94
+ this.clearable = false;
95
+ this.setFormValue = (value, state) => {
96
+ if (isFormAssociatedTryingToSetFormValue(value)) {
97
+ return;
98
+ }
99
+ super.setFormValue(value, state);
100
+ };
101
+ this._changeDescription = "";
102
+ // --- Core ---
103
+ __privateAdd(this, _resizeObserver, new ResizeObserver(() => {
104
+ __privateMethod(this, _SearchableSelect_instances, updateTagLayout_fn).call(this);
105
+ }));
73
106
  }
74
107
  /**
75
- * Returns the list of checked options.
76
- *
77
108
  * @internal
78
109
  */
79
- get checkedOptions() {
80
- return this.options.filter((o) => o.checked);
110
+ openChanged() {
111
+ if (!this.open) {
112
+ __privateMethod(this, _SearchableSelect_instances, transitionHighlightedOptionTo_fn).call(this, null);
113
+ }
81
114
  }
82
115
  /**
83
- * Returns the index of the first selected option.
84
- *
85
116
  * @internal
86
117
  */
87
- get firstSelectedOptionIndex() {
88
- return this.options.indexOf(this.firstSelectedOption);
118
+ valuesChanged() {
119
+ if (!this._areOptionsInitialized) {
120
+ return;
121
+ }
122
+ if (!this.multiple && this.values.length > 1) {
123
+ this.values = [this.values[0]];
124
+ return;
125
+ }
126
+ if (this.values.some((value) => !__privateMethod(this, _SearchableSelect_instances, isValidValue_fn).call(this, value))) {
127
+ this.values = this.values.filter((value) => __privateMethod(this, _SearchableSelect_instances, isValidValue_fn).call(this, value));
128
+ return;
129
+ }
130
+ this.value = this.values.length ? this.values[0] : "";
131
+ __privateMethod(this, _SearchableSelect_instances, updateSelectedOnSlottedOptions_fn).call(this);
132
+ if (this.$fastController.isConnected) {
133
+ __privateMethod(this, _SearchableSelect_instances, updateTagLayout_fn).call(this);
134
+ }
135
+ __privateMethod(this, _SearchableSelect_instances, updateFormValue_fn).call(this);
89
136
  }
90
137
  /**
91
- * Updates the `ariaActiveDescendant` property when the active index changes.
92
- *
93
138
  * @internal
94
139
  */
95
- activeIndexChanged(_, next) {
96
- this.ariaActiveDescendant = this.options[next]?.id ?? "";
97
- this.focusAndScrollOptionIntoView();
140
+ initialValuesChanged() {
141
+ if (!this.dirtyValue) {
142
+ this.values = this.initialValues;
143
+ this.dirtyValue = false;
144
+ }
98
145
  }
99
146
  /**
100
- * Toggles the checked state for the currently active option.
101
- *
102
- * @remarks
103
- * Multiple-selection mode only.
104
- *
105
147
  * @internal
106
148
  */
107
- checkActiveIndex() {
108
- const activeItem = this.activeOption;
109
- if (activeItem) {
110
- activeItem.checked = true;
149
+ valueChanged(prev, next) {
150
+ super.valueChanged(prev, next);
151
+ if (!this._areOptionsInitialized) {
152
+ return;
153
+ }
154
+ const isValidValue = this._slottedOptions.some(
155
+ (option) => option.value === next
156
+ );
157
+ if (this.values[0] !== next) {
158
+ this.values = isValidValue ? [next] : [];
111
159
  }
112
160
  }
113
- /**
114
- * Sets the active index to the first option and marks it as checked.
115
- *
116
- * @remarks
117
- * Multi-selection mode only.
118
- *
119
- * @param preserveChecked - mark all options unchecked before changing the active index
120
- *
121
- * @internal
122
- */
123
- checkFirstOption(preserveChecked) {
124
- if (preserveChecked) {
125
- if (this.rangeStartIndex === -1) {
126
- this.rangeStartIndex = this.activeIndex + 1;
127
- }
128
- this.options.forEach((o, i) => {
129
- o.checked = numbers.inRange(i, this.rangeStartIndex);
130
- });
161
+ get selectedIndex() {
162
+ if (this.values.length) {
163
+ return this._slottedOptions.findIndex(
164
+ (option) => option.value === this.values[0]
165
+ );
131
166
  } else {
132
- this.uncheckAllOptions();
167
+ return -1;
133
168
  }
134
- this.activeIndex = 0;
135
- this.checkActiveIndex();
169
+ }
170
+ set selectedIndex(index) {
171
+ this.value = this._slottedOptions[index]?.value ?? "";
172
+ }
173
+ get options() {
174
+ return [...this._slottedOptions];
175
+ }
176
+ get selectedOptions() {
177
+ return this._slottedOptions.filter(
178
+ (option) => this.values.includes(option.value)
179
+ );
136
180
  }
137
181
  /**
138
- * Decrements the active index and sets the matching option as checked.
139
- *
140
- * @remarks
141
- * Multi-selection mode only.
142
- *
143
- * @param preserveChecked - mark all options unchecked before changing the active index
144
- *
145
182
  * @internal
146
183
  */
147
- checkLastOption(preserveChecked) {
148
- if (preserveChecked) {
149
- if (this.rangeStartIndex === -1) {
150
- this.rangeStartIndex = this.activeIndex;
151
- }
152
- this.options.forEach((o, i) => {
153
- o.checked = numbers.inRange(i, this.rangeStartIndex, this.length);
184
+ _internalSearchTextChanged(newValue, oldValue) {
185
+ if (oldValue !== newValue) {
186
+ __privateMethod(this, _SearchableSelect_instances, updateFilteredOptions_fn).call(this);
187
+ this.$emit("input:search-text", void 0, {
188
+ bubbles: false,
189
+ composed: false
154
190
  });
155
- } else {
156
- this.uncheckAllOptions();
157
191
  }
158
- this.activeIndex = this.length - 1;
159
- this.checkActiveIndex();
192
+ }
193
+ get searchText() {
194
+ return this._internalSearchText ?? "";
160
195
  }
161
196
  /**
162
- * Increments the active index and marks the matching option as checked.
163
- *
164
- * @remarks
165
- * Multiple-selection mode only.
166
- *
167
- * @param preserveChecked - mark all options unchecked before changing the active index
168
- *
169
197
  * @internal
170
198
  */
171
- checkNextOption(preserveChecked) {
172
- if (preserveChecked) {
173
- if (this.rangeStartIndex === -1) {
174
- this.rangeStartIndex = this.activeIndex;
175
- }
176
- this.options.forEach((o, i) => {
177
- o.checked = numbers.inRange(i, this.rangeStartIndex, this.activeIndex + 1);
178
- });
179
- } else {
180
- this.uncheckAllOptions();
181
- }
182
- this.activeIndex += this.activeIndex < this.length - 1 ? 1 : 0;
183
- this.checkActiveIndex();
199
+ get _inputValue() {
200
+ return this._internalSearchText ?? (!this.multiple && this.value !== "" ? __privateMethod(this, _SearchableSelect_instances, textForValue_fn).call(this, this.value) : "");
184
201
  }
185
202
  /**
186
- * Decrements the active index and marks the matching option as checked.
187
- *
188
- * @remarks
189
- * Multiple-selection mode only.
190
- *
191
- * @param preserveChecked - mark all options unchecked before changing the active index
192
- *
193
203
  * @internal
194
204
  */
195
- checkPreviousOption(preserveChecked) {
196
- if (preserveChecked) {
197
- if (this.rangeStartIndex === -1) {
198
- this.rangeStartIndex = this.activeIndex;
199
- }
200
- if (this.checkedOptions.length === 1) {
201
- this.rangeStartIndex += 1;
202
- }
203
- this.options.forEach((o, i) => {
204
- o.checked = numbers.inRange(i, this.activeIndex, this.rangeStartIndex);
205
- });
206
- } else {
207
- this.uncheckAllOptions();
208
- }
209
- this.activeIndex -= this.activeIndex > 0 ? 1 : 0;
210
- this.checkActiveIndex();
205
+ _onInputInput(event) {
206
+ this._internalSearchText = event.target.value;
211
207
  }
212
208
  /**
213
209
  * @internal
214
210
  */
215
- focusAndScrollOptionIntoView() {
216
- super.focusAndScrollOptionIntoView(this.activeOption);
211
+ _onInputFocus(_) {
212
+ __privateMethod(this, _SearchableSelect_instances, updateFilteredOptions_fn).call(this);
213
+ this.open = true;
217
214
  }
218
215
  /**
219
- * In multiple-selection mode:
220
- * If any options are selected, the first selected option is checked when
221
- * the listbox receives focus. If no options are selected, the first
222
- * selectable option is checked.
223
- *
224
216
  * @internal
225
217
  */
226
- focusinHandler(e) {
227
- if (!this.multiple) {
228
- return super.focusinHandler(e);
229
- }
230
- if (!this.shouldSkipFocus && e.target === e.currentTarget) {
231
- this.uncheckAllOptions();
232
- if (this.activeIndex === -1) {
233
- this.activeIndex = this.firstSelectedOptionIndex !== -1 ? this.firstSelectedOptionIndex : 0;
234
- }
235
- this.checkActiveIndex();
236
- this.setSelectedOptions();
237
- this.focusAndScrollOptionIntoView();
238
- }
239
- this.shouldSkipFocus = false;
218
+ _onInputBlur(_) {
219
+ this.open = false;
220
+ this._internalSearchText = null;
221
+ this._changeDescription = "";
240
222
  }
241
223
  /**
242
- * Sets an option as selected and gives it focus.
243
- *
244
- * @public
224
+ * @internal
245
225
  */
246
- setSelectedOptions() {
247
- if (!this.multiple) {
248
- super.setSelectedOptions();
249
- return;
226
+ _onInputKeydown(e) {
227
+ if (e.ctrlKey || e.shiftKey) {
228
+ return true;
250
229
  }
251
- if (this.$fastController.isConnected && this.options) {
252
- this.selectedOptions = this.options.filter((o) => o.selected);
253
- this.focusAndScrollOptionIntoView();
230
+ switch (e.key) {
231
+ case "Enter":
232
+ __privateMethod(this, _SearchableSelect_instances, selectHighlightedOption_fn).call(this);
233
+ return false;
234
+ case "Escape":
235
+ this.open = false;
236
+ break;
237
+ case "Home":
238
+ if (!this.open) {
239
+ this.open = true;
240
+ break;
241
+ }
242
+ __privateMethod(this, _SearchableSelect_instances, highlightFirstOption_fn).call(this);
243
+ return false;
244
+ case "End":
245
+ if (!this.open) {
246
+ this.open = true;
247
+ break;
248
+ }
249
+ __privateMethod(this, _SearchableSelect_instances, highlightLastOption_fn).call(this);
250
+ return false;
251
+ case "PageUp":
252
+ if (!this.open) {
253
+ this.open = true;
254
+ break;
255
+ }
256
+ __privateMethod(this, _SearchableSelect_instances, highlightPrevPage_fn).call(this);
257
+ return false;
258
+ case "PageDown":
259
+ if (!this.open) {
260
+ this.open = true;
261
+ break;
262
+ }
263
+ __privateMethod(this, _SearchableSelect_instances, highlightNextPage_fn).call(this);
264
+ return false;
265
+ case "ArrowUp":
266
+ if (!this.open) {
267
+ this.open = true;
268
+ break;
269
+ }
270
+ __privateMethod(this, _SearchableSelect_instances, highlightPreviousOption_fn).call(this);
271
+ return false;
272
+ case "ArrowDown":
273
+ if (!this.open) {
274
+ this.open = true;
275
+ break;
276
+ }
277
+ __privateMethod(this, _SearchableSelect_instances, highlightNextOption_fn).call(this);
278
+ return false;
279
+ case "ArrowLeft":
280
+ if (this.multiple && this._inputValue === "" && this.values.length && !this.externalTags) {
281
+ __privateMethod(this, _SearchableSelect_instances, moveTagFocusTo_fn).call(this, __privateMethod(this, _SearchableSelect_instances, nextTagIndexLeft_fn).call(this, this.values.length));
282
+ return false;
283
+ }
284
+ return true;
285
+ case "Backspace":
286
+ if (this.multiple && this._inputValue === "" && this.values.length) {
287
+ this._onTagRemoved(this.values[this.values.length - 1]);
288
+ return false;
289
+ }
290
+ return true;
291
+ default:
292
+ if (!this.open) {
293
+ this.open = true;
294
+ }
295
+ return true;
254
296
  }
297
+ return true;
255
298
  }
256
299
  /**
257
- * Toggles the selected state of the provided options. If any provided items
258
- * are in an unselected state, all items are set to selected. If every
259
- * provided item is selected, they are all unselected.
260
- *
261
300
  * @internal
262
301
  */
263
- toggleSelectedForAllCheckedOptions() {
264
- const enabledCheckedOptions = this.checkedOptions.filter(
265
- (o) => !o.disabled
266
- );
267
- const force = !enabledCheckedOptions.every((o) => o.selected);
268
- enabledCheckedOptions.forEach((o) => o.selected = force);
269
- this.selectedIndex = this.options.indexOf(
270
- enabledCheckedOptions[enabledCheckedOptions.length - 1]
302
+ _slottedOptionsChanged(oldValue, newValue) {
303
+ const hasSlottedOptions = Boolean(
304
+ this.querySelectorAll(`:not([slot])`).length
271
305
  );
272
- this.setSelectedOptions();
273
- this.updateValue(true);
274
- }
275
- /**
276
- * @internal
277
- */
278
- typeaheadBufferChanged(prev, next) {
279
- if (!this.multiple) {
280
- super.typeaheadBufferChanged(prev, next);
306
+ if (!newValue.length && hasSlottedOptions) {
281
307
  return;
282
308
  }
283
- if (this.$fastController.isConnected) {
284
- const typeaheadMatches = this.getTypeaheadMatches();
285
- const activeIndex = this.options.indexOf(typeaheadMatches[0]);
286
- if (activeIndex > -1) {
287
- this.activeIndex = activeIndex;
288
- this.uncheckAllOptions();
289
- this.checkActiveIndex();
309
+ this._areOptionsInitialized = true;
310
+ if (oldValue) {
311
+ for (const option of oldValue) {
312
+ const notifier = vividElement.Observable.getNotifier(option);
313
+ notifier.unsubscribe(__privateGet(this, _slottedOptionsChangeHandler), "selected");
290
314
  }
291
- this.typeaheadExpired = false;
292
315
  }
293
- }
294
- /**
295
- * Unchecks all options.
296
- *
297
- * @remarks
298
- * Multiple-selection mode only.
299
- *
300
- * @param preserveChecked - reset the rangeStartIndex
301
- *
302
- * @internal
303
- */
304
- uncheckAllOptions(preserveChecked = false) {
305
- this.options.forEach((o) => o.checked = false);
306
- if (!preserveChecked) {
307
- this.rangeStartIndex = -1;
316
+ if (newValue) {
317
+ for (const option of newValue) {
318
+ option._displayCheckmark = true;
319
+ const notifier = vividElement.Observable.getNotifier(option);
320
+ notifier.subscribe(__privateGet(this, _slottedOptionsChangeHandler), "selected");
321
+ }
322
+ }
323
+ const values = [];
324
+ for (const option of this._slottedOptions) {
325
+ if (option.selected || option.value === this.value || this.values.includes(option.value)) {
326
+ values.push(option.value);
327
+ }
308
328
  }
329
+ __privateMethod(this, _SearchableSelect_instances, updateValuesWhileMaintainingOrder_fn).call(this, values);
330
+ __privateMethod(this, _SearchableSelect_instances, updateFilteredOptions_fn).call(this);
309
331
  }
310
332
  /**
311
- * Sets focus and synchronizes ARIA attributes when the open property changes.
312
- *
313
333
  * @internal
314
334
  */
315
- openChanged(prev, next) {
316
- if (!this.collapsible) {
317
- return;
318
- }
319
- if (this.open) {
320
- this.ariaControls = this.listboxId;
321
- this.ariaExpanded = "true";
322
- this.focusAndScrollOptionIntoView();
323
- this.indexWhenOpened = this.selectedIndex;
324
- vividElement.DOM.queueUpdate(() => this.focus());
325
- return;
326
- }
327
- const didClose = prev === true && next === false;
328
- const selectionChangedWhileOpen = this.indexWhenOpened !== this.selectedIndex;
329
- if (didClose && selectionChangedWhileOpen) {
330
- this.updateValue(true);
331
- }
332
- this.ariaControls = "";
333
- this.ariaExpanded = "false";
334
- }
335
- get collapsible() {
336
- return !this.multiple;
335
+ _tagIconSlotName(value) {
336
+ return `_tag-icon-${this.values.indexOf(value)}`;
337
337
  }
338
+ // --- Tags ---
338
339
  /**
339
- * The value property.
340
- *
341
- * @public
340
+ * @internal
342
341
  */
343
- get value() {
344
- vividElement.Observable.track(this, "value");
345
- return this._value;
346
- }
347
- set value(next) {
348
- const prev = `${this._value}`;
349
- if (this.length) {
350
- const selectedIndex = this._options.findIndex((el) => el.value === next);
351
- const prevSelectedValue = this._options[this.selectedIndex]?.value ?? null;
352
- const nextSelectedValue = this._options[selectedIndex]?.value ?? null;
353
- if (selectedIndex === -1 || prevSelectedValue !== nextSelectedValue) {
354
- next = "";
355
- this.selectedIndex = selectedIndex;
356
- }
357
- next = this.firstSelectedOption?.value ?? next;
358
- }
359
- if (prev !== next) {
360
- this._value = next;
361
- super.valueChanged(prev, next);
362
- vividElement.Observable.notify(this, "value");
363
- this.updateDisplayValue();
364
- }
342
+ _tagLabelForValue(value) {
343
+ const option = this._slottedOptions.find(
344
+ (option2) => option2.value === value
345
+ );
346
+ return option.label;
365
347
  }
366
348
  /**
367
- * Sets the value and display value to match the first selected option.
368
- *
369
- * @param shouldEmit - if true, the input and change events will be emitted
370
- *
371
349
  * @internal
372
350
  */
373
- updateValue(shouldEmit) {
374
- if (this.$fastController.isConnected) {
375
- this.value = this.firstSelectedOption?.value ?? "";
376
- }
377
- if (shouldEmit) {
378
- this.$emit("input");
379
- this.$emit("change", this, {
380
- bubbles: true,
381
- composed: void 0
382
- });
383
- }
351
+ _isTagDisabled(value) {
352
+ const option = this._slottedOptions.find(
353
+ (option2) => option2.value === value
354
+ );
355
+ return this.disabled || option.disabled;
384
356
  }
385
357
  /**
386
- * Updates the proxy value when the selected index changes.
387
- *
388
- * @param prev - the previous selected index
389
- * @param next - the next selected index
390
- *
391
358
  * @internal
392
359
  */
393
- selectedIndexChanged(prev, next) {
394
- super.selectedIndexChanged(prev, next);
395
- this.updateValue();
360
+ _onTagRemoved(value) {
361
+ __privateMethod(this, _SearchableSelect_instances, updateValuesThroughUserInteraction_fn).call(this, this.values.filter((option) => option !== value));
362
+ __privateMethod(this, _SearchableSelect_instances, updateFilteredOptions_fn).call(this);
396
363
  }
397
364
  /**
398
- * Synchronize the `aria-disabled` property when the `disabled` property changes.
399
- *
400
- * @param prev - The previous disabled value
401
- * @param next - The next disabled value
402
- *
403
365
  * @internal
404
366
  */
405
- disabledChanged(prev, next) {
406
- if (super.disabledChanged) {
407
- super.disabledChanged(prev, next);
367
+ _onTagKeydown(event) {
368
+ const tagIndex = parseInt(event.target.dataset.index);
369
+ switch (event.key) {
370
+ case "Backspace":
371
+ case "Delete":
372
+ case "Enter":
373
+ case " ": {
374
+ this._onTagRemoved(this.values[tagIndex]);
375
+ vividElement.DOM.processUpdates();
376
+ __privateMethod(this, _SearchableSelect_instances, moveTagFocusTo_fn).call(this, __privateMethod(this, _SearchableSelect_instances, nextTagIndexForRemoved_fn).call(this, tagIndex));
377
+ break;
378
+ }
379
+ case "ArrowLeft":
380
+ __privateMethod(this, _SearchableSelect_instances, moveTagFocusTo_fn).call(this, __privateMethod(this, _SearchableSelect_instances, nextTagIndexLeft_fn).call(this, tagIndex) ?? tagIndex);
381
+ break;
382
+ case "ArrowRight":
383
+ __privateMethod(this, _SearchableSelect_instances, moveTagFocusTo_fn).call(this, __privateMethod(this, _SearchableSelect_instances, nextTagIndexRight_fn).call(this, tagIndex));
384
+ break;
408
385
  }
409
- this.ariaDisabled = this.disabled ? "true" : "false";
386
+ return true;
410
387
  }
411
388
  /**
412
- * Handle opening and closing the listbox when the select is clicked.
413
- *
414
- * @param e - the mouse event
415
389
  * @internal
416
390
  */
417
- clickHandler(e) {
391
+ _onListboxClick(e) {
418
392
  if (this.disabled) {
419
393
  return;
420
394
  }
421
- const clickedOption = e.target.closest(
395
+ const capturedOption = e.target.closest(
422
396
  `option,[role=option]`
423
397
  );
424
- if (clickedOption && clickedOption.disabled) {
425
- return;
426
- }
427
- if (this.multiple) {
428
- this.uncheckAllOptions();
429
- this.activeIndex = this.options.indexOf(clickedOption);
430
- this.checkActiveIndex();
431
- this.toggleSelectedForAllCheckedOptions();
432
- } else {
433
- super.clickHandler(e);
434
- }
435
- if (this.collapsible) {
436
- this.open = !this.open;
398
+ if (capturedOption && !capturedOption.disabled) {
399
+ __privateMethod(this, _SearchableSelect_instances, handleOptionInteraction_fn).call(this, capturedOption);
437
400
  }
438
- return true;
439
401
  }
440
402
  /**
441
- * Handles focus state when the element or its children lose focus.
442
- *
443
- * @param e - The focus event
444
403
  * @internal
445
404
  */
446
- focusoutHandler(e) {
447
- if (this.multiple) {
448
- this.uncheckAllOptions();
449
- }
450
- if (!this.open) {
451
- return true;
452
- }
453
- const focusTarget = e.relatedTarget;
454
- if (this.isSameNode(focusTarget)) {
455
- this.focus();
456
- return;
457
- }
458
- if (!this.options.includes(focusTarget)) {
459
- this.open = false;
460
- if (this.indexWhenOpened !== this.selectedIndex) {
461
- this.updateValue(true);
462
- }
463
- }
405
+ get _shouldShowClearButton() {
406
+ return this.clearable && this.values.length > 0;
464
407
  }
465
408
  /**
466
- * Updates the value when an option's value changes.
467
- *
468
- * @param source - the source object
469
- * @param propertyName - the property to evaluate
470
- *
471
409
  * @internal
472
410
  */
473
- handleChange(source, propertyName) {
474
- super.handleChange(source, propertyName);
475
- if (propertyName === "value") {
476
- this.updateValue();
477
- }
411
+ _onClearButtonClick() {
412
+ __privateMethod(this, _SearchableSelect_instances, updateValuesThroughUserInteraction_fn).call(this, this.selectedOptions.filter((option) => option.disabled).map((option) => option.value));
478
413
  }
479
414
  /**
480
- * Prevents focus when a scrollbar is clicked.
481
- *
482
- * @param e - the mouse event object
483
- *
484
415
  * @internal
485
416
  */
486
- mousedownHandler(e) {
487
- if (e.offsetX >= 0 && e.offsetX <= this.listbox.scrollWidth) {
488
- return super.mousedownHandler(e);
489
- }
490
- return this.collapsible;
491
- }
492
- multipleChanged(prev, next) {
493
- super.multipleChanged(prev, next);
494
- this.options.forEach((o) => {
495
- o.checked = next ? false : void 0;
496
- });
497
- this.setSelectedOptions();
498
- if (this.proxy) {
499
- this.proxy.multiple = next;
500
- }
417
+ nameChanged(previous, next) {
418
+ super.nameChanged(previous, next);
419
+ __privateMethod(this, _SearchableSelect_instances, updateFormValue_fn).call(this);
501
420
  }
502
421
  /**
503
- * Updates the selectedness of each option when the list of selected options changes.
504
- *
505
- * @param prev - the previous list of selected options
506
- * @param next - the current list of selected options
507
- *
508
422
  * @internal
509
423
  */
510
- selectedOptionsChanged(prev, next) {
511
- super.selectedOptionsChanged(prev, next);
512
- this.options.forEach((o, i) => {
513
- const proxyOption = this.proxy.options.item(i);
514
- if (proxyOption) {
515
- proxyOption.selected = o.selected;
516
- }
517
- });
518
- }
519
- /**
520
- * Resets and fills the proxy to match the component's options.
521
- *
522
- * @internal
523
- */
524
- setProxyOptions() {
525
- if (this.proxy instanceof HTMLSelectElement && this.options) {
526
- this.proxy.length = 0;
527
- this.options.forEach((option) => {
528
- const proxyOption = option.proxy || (option instanceof HTMLOptionElement ? option.cloneNode() : null);
529
- if (proxyOption) {
530
- this.proxy.options.add(proxyOption);
531
- }
532
- });
533
- }
424
+ formResetCallback() {
425
+ super.formResetCallback();
426
+ __privateMethod(this, _SearchableSelect_instances, updateValuesThroughUserInteraction_fn).call(this, __privateMethod(this, _SearchableSelect_instances, determineInitialValues_fn).call(this));
534
427
  }
535
428
  /**
536
- * Handles keydown actions when the select is in multiple selection mode.
537
- *
538
429
  * @internal
539
430
  */
540
- multipleKeydownHandler(e) {
431
+ _onFieldsetClick(e) {
541
432
  if (this.disabled) {
542
433
  return;
543
434
  }
544
- const { key, shiftKey } = e;
545
- this.shouldSkipFocus = false;
546
- switch (key) {
547
- case keyCodes.keyHome: {
548
- this.checkFirstOption(shiftKey);
549
- return;
550
- }
551
- case keyCodes.keyArrowDown: {
552
- this.checkNextOption(shiftKey);
553
- return;
554
- }
555
- case keyCodes.keyArrowUp: {
556
- this.checkPreviousOption(shiftKey);
557
- return;
558
- }
559
- case keyCodes.keyEnd: {
560
- this.checkLastOption(shiftKey);
561
- return;
562
- }
563
- case keyCodes.keyTab: {
564
- this.focusAndScrollOptionIntoView();
565
- return;
566
- }
567
- case keyCodes.keyEscape: {
568
- this.uncheckAllOptions();
569
- this.checkActiveIndex();
570
- return;
571
- }
572
- case keyCodes.keySpace: {
573
- e.preventDefault();
574
- if (this.typeaheadExpired) {
575
- this.toggleSelectedForAllCheckedOptions();
576
- return;
577
- }
578
- }
579
- default: {
580
- if (key.length === 1) {
581
- this.handleTypeAhead(`${key}`);
582
- }
583
- return;
584
- }
435
+ if (!e.defaultPrevented) {
436
+ this._input.focus();
437
+ this.open = true;
585
438
  }
586
439
  }
587
440
  /**
588
- * Handle keyboard interaction for the select.
589
- *
590
- * @param e - the keyboard event
591
441
  * @internal
592
442
  */
593
- keydownHandler(e) {
594
- const selectedIndexBefore = this.selectedIndex;
595
- if (this.multiple) {
596
- this.multipleKeydownHandler(e);
597
- } else {
598
- super.keydownHandler(e);
599
- }
600
- const key = e.key;
601
- switch (key) {
602
- case keyCodes.keySpace: {
603
- e.preventDefault();
604
- if (this.collapsible && this.typeaheadExpired) {
605
- this.open = !this.open;
606
- }
607
- break;
608
- }
609
- case keyCodes.keyHome:
610
- case keyCodes.keyEnd: {
611
- e.preventDefault();
612
- break;
613
- }
614
- case keyCodes.keyEnter: {
615
- e.preventDefault();
616
- this.open = !this.open;
617
- break;
618
- }
619
- case keyCodes.keyEscape: {
620
- if (this.collapsible && this.open) {
621
- e.preventDefault();
622
- this.open = false;
623
- }
624
- break;
625
- }
626
- case keyCodes.keyTab: {
627
- if (this.collapsible && this.open) {
628
- e.preventDefault();
629
- this.open = false;
630
- }
631
- return true;
632
- }
633
- }
634
- if (this.collapsible && !this.open && this.selectedIndex !== selectedIndexBefore) {
635
- this.updateValue(true);
443
+ _onChevronClick() {
444
+ if (this.open) {
445
+ this.open = false;
446
+ return false;
636
447
  }
637
- return !(e.key === keyCodes.keyArrowDown || e.key === keyCodes.keyArrowUp);
448
+ return true;
638
449
  }
639
450
  connectedCallback() {
640
451
  super.connectedCallback();
641
- this.addEventListener("focusout", this.focusoutHandler);
642
- this.addEventListener("contentchange", this.updateDisplayValue);
452
+ if (!this.values.length) {
453
+ this.values = __privateMethod(this, _SearchableSelect_instances, determineInitialValues_fn).call(this);
454
+ }
455
+ __privateGet(this, _resizeObserver).observe(this._contentArea);
643
456
  }
644
457
  disconnectedCallback() {
645
- this.removeEventListener("focusout", this.focusoutHandler);
646
- this.removeEventListener("contentchange", this.updateDisplayValue);
647
458
  super.disconnectedCallback();
459
+ __privateGet(this, _resizeObserver).disconnect();
460
+ }
461
+ /**
462
+ * @internal
463
+ */
464
+ validate() {
465
+ super.validate(this._input ?? void 0);
466
+ }
467
+ /**
468
+ * @internal
469
+ */
470
+ focus(options) {
471
+ this._input?.focus(options);
648
472
  }
649
473
  /**
650
- *
651
474
  * @internal
652
475
  */
653
- updateDisplayValue() {
654
- if (this.collapsible) {
655
- vividElement.Observable.notify(this, "displayValue");
476
+ _onMouseDown(event) {
477
+ if (!event.defaultPrevented) {
478
+ this._input.focus();
479
+ return false;
656
480
  }
481
+ return true;
657
482
  }
658
- labelChanged() {
659
- if (!this.ariaLabel) {
660
- this.ariaLabel = this.label;
483
+ };
484
+ _SearchableSelect_instances = new WeakSet();
485
+ updateValuesThroughUserInteraction_fn = function(newValues) {
486
+ this.values = newValues;
487
+ this.$emit("change", void 0, {
488
+ bubbles: false
489
+ });
490
+ this.$emit("input", void 0, {
491
+ bubbles: false
492
+ });
493
+ };
494
+ updateValuesWhileMaintainingOrder_fn = function(newValues) {
495
+ const oldSet = new Set(this.values);
496
+ const newSet = new Set(newValues);
497
+ if (oldSet.size === newSet.size && [...oldSet].every((v) => newSet.has(v))) {
498
+ return;
499
+ }
500
+ this.values = [...this.values].filter((v) => newSet.has(v)).concat([...newValues].filter((v) => !oldSet.has(v)));
501
+ };
502
+ isValidValue_fn = function(value) {
503
+ return this._slottedOptions.some((option) => option.value === value);
504
+ };
505
+ _slottedOptionsChangeHandler = new WeakMap();
506
+ updateSelectedOnSlottedOptions_fn = function() {
507
+ for (const option of this._slottedOptions) {
508
+ option.selected = this.values.includes(option.value);
509
+ __privateMethod(this, _SearchableSelect_instances, updateClonedTagIconOfOption_fn).call(this, option);
510
+ }
511
+ };
512
+ handleOptionInteraction_fn = function(option) {
513
+ const value = option.value;
514
+ let newValues;
515
+ let shouldClearSearchText = false;
516
+ const isSelection = !this.values.includes(value);
517
+ if (this.multiple) {
518
+ if (isSelection) {
519
+ newValues = [...this.values, value];
520
+ } else {
521
+ newValues = this.values.filter((option2) => option2 !== value);
661
522
  }
523
+ shouldClearSearchText = true;
524
+ } else {
525
+ if (isSelection) {
526
+ newValues = [value];
527
+ shouldClearSearchText = true;
528
+ } else {
529
+ newValues = [];
530
+ }
531
+ this.open = false;
662
532
  }
663
- get displayValue() {
664
- vividElement.Observable.track(this, "displayValue");
665
- return this.firstSelectedOption?.getAttribute("label") ?? this.firstSelectedOption?.text ?? this.placeholder ?? "";
533
+ this._changeDescription = isSelection ? this.locale.searchableSelect.optionSelectedMessage(option.text) : this.locale.searchableSelect.optionDeselectedMessage(option.text);
534
+ __privateMethod(this, _SearchableSelect_instances, updateValuesThroughUserInteraction_fn).call(this, newValues);
535
+ if (shouldClearSearchText) {
536
+ this._internalSearchText = null;
666
537
  }
667
- setDefaultSelectedOption() {
668
- const options = Array.from(this.children).filter(
669
- listbox.Listbox.slottedOptionFilter
670
- );
671
- const selectedIndex = options.findIndex(
672
- (el) => el.hasAttribute("selected") || el.selected || el.value === this.value
673
- );
674
- if (selectedIndex === -1 && !this.placeholderOption) {
675
- this.selectedIndex = 0;
676
- return;
538
+ };
539
+ _clonedTagIcons = new WeakMap();
540
+ tagIconOfOption_fn = function(option) {
541
+ return option.querySelector('[slot="tag-icon"]');
542
+ };
543
+ updateClonedTagIconOfOption_fn = function(option) {
544
+ if (option.selected && __privateMethod(this, _SearchableSelect_instances, tagIconOfOption_fn).call(this, option)) {
545
+ let clone = __privateGet(this, _clonedTagIcons).get(option);
546
+ if (!clone) {
547
+ clone = __privateMethod(this, _SearchableSelect_instances, tagIconOfOption_fn).call(this, option).cloneNode(true);
548
+ __privateGet(this, _clonedTagIcons).set(option, clone);
677
549
  }
678
- if (selectedIndex !== -1 || this.placeholder !== "") {
679
- this.selectedIndex = selectedIndex;
680
- return;
550
+ clone.slot = this._tagIconSlotName(option.value);
551
+ this.appendChild(clone);
552
+ } else {
553
+ const clone = __privateGet(this, _clonedTagIcons).get(option);
554
+ if (clone) {
555
+ clone.remove();
556
+ __privateGet(this, _clonedTagIcons).delete(option);
681
557
  }
682
558
  }
683
- /*
684
- * @internal
685
- */
686
- slottedOptionsChanged(prev, next) {
687
- this.options.forEach((o) => {
688
- const notifier = vividElement.Observable.getNotifier(o);
689
- notifier.unsubscribe(this, "value");
690
- });
691
- super.slottedOptionsChanged(prev, next);
692
- this.options.forEach((o) => {
693
- const notifier = vividElement.Observable.getNotifier(o);
694
- notifier.subscribe(this, "value");
695
- });
696
- this.setProxyOptions();
697
- this.updateValue();
698
- const scale = this.getAttribute("scale") || this.scale;
699
- next.forEach((element) => {
700
- if (scale) {
701
- element.setAttribute("scale", scale);
702
- element.scale = scale;
559
+ };
560
+ updateFilteredOptions_fn = function() {
561
+ const newFilteredOptions = [];
562
+ const filterOption = this.filterOption ?? ((option, searchText) => option.text.toLowerCase().includes(searchText.toLowerCase()));
563
+ for (const option of this._slottedOptions ?? []) {
564
+ if (this.searchText === "") {
565
+ option._hidden = false;
566
+ option._internalHighlightText = "";
567
+ } else {
568
+ const matches = filterOption(option, this.searchText);
569
+ option._hidden = !matches;
570
+ option._internalHighlightText = matches ? this.searchText : "";
571
+ }
572
+ if (!option.hidden && !option._hidden) {
573
+ newFilteredOptions.push(option);
574
+ }
575
+ }
576
+ __privateMethod(this, _SearchableSelect_instances, transitionHighlightedOptionTo_fn).call(this, null);
577
+ this._filteredOptions = newFilteredOptions;
578
+ this._filteredEnabledOptions = newFilteredOptions.filter(
579
+ (option) => !option.disabled
580
+ );
581
+ };
582
+ transitionHighlightedOptionTo_fn = function(index) {
583
+ if (typeof this._highlightedOptionIndex === "number") {
584
+ this._filteredEnabledOptions[this._highlightedOptionIndex]._highlighted = false;
585
+ }
586
+ if (typeof index === "number") {
587
+ if (!this._filteredEnabledOptions.length) {
588
+ index = null;
589
+ } else {
590
+ index = Math.max(
591
+ 0,
592
+ Math.min(this._filteredEnabledOptions.length - 1, index)
593
+ );
594
+ }
595
+ }
596
+ this._highlightedOptionIndex = index;
597
+ if (typeof this._highlightedOptionIndex === "number") {
598
+ const highlightedOption = this._filteredEnabledOptions[this._highlightedOptionIndex];
599
+ highlightedOption._highlighted = true;
600
+ scrollIntoView.scrollIntoView(highlightedOption, this._listbox, "nearest");
601
+ this._changeDescription = this.locale.searchableSelect.optionFocusedMessage(
602
+ highlightedOption.text,
603
+ this._highlightedOptionIndex + 1,
604
+ this._filteredEnabledOptions.length
605
+ );
606
+ }
607
+ };
608
+ selectHighlightedOption_fn = function() {
609
+ if (this._highlightedOptionIndex === null) {
610
+ return;
611
+ }
612
+ __privateMethod(this, _SearchableSelect_instances, handleOptionInteraction_fn).call(this, this._filteredEnabledOptions[this._highlightedOptionIndex]);
613
+ };
614
+ highlightFirstOption_fn = function() {
615
+ __privateMethod(this, _SearchableSelect_instances, transitionHighlightedOptionTo_fn).call(this, 0);
616
+ };
617
+ highlightLastOption_fn = function() {
618
+ __privateMethod(this, _SearchableSelect_instances, transitionHighlightedOptionTo_fn).call(this, this._filteredEnabledOptions.length - 1);
619
+ };
620
+ highlightPrevPage_fn = function() {
621
+ __privateMethod(this, _SearchableSelect_instances, transitionHighlightedOptionTo_fn).call(this, (this._highlightedOptionIndex ?? this._filteredEnabledOptions.length) - PageSize);
622
+ };
623
+ highlightNextPage_fn = function() {
624
+ __privateMethod(this, _SearchableSelect_instances, transitionHighlightedOptionTo_fn).call(this, (this._highlightedOptionIndex ?? -1) + PageSize);
625
+ };
626
+ highlightPreviousOption_fn = function() {
627
+ __privateMethod(this, _SearchableSelect_instances, transitionHighlightedOptionTo_fn).call(this, (this._highlightedOptionIndex ?? this._filteredEnabledOptions.length) - 1);
628
+ };
629
+ highlightNextOption_fn = function() {
630
+ __privateMethod(this, _SearchableSelect_instances, transitionHighlightedOptionTo_fn).call(this, (this._highlightedOptionIndex ?? -1) + 1);
631
+ };
632
+ textForValue_fn = function(value) {
633
+ const option = this._slottedOptions.find(
634
+ (option2) => option2.value === value
635
+ );
636
+ return option.text;
637
+ };
638
+ /**
639
+ * @internal
640
+ */
641
+ measureTagWidth_fn = function(label, removable, hasIcon) {
642
+ const tag = document.createElement(this._optionTagTagName);
643
+ tag.label = label;
644
+ tag.removable = removable;
645
+ tag.style.cssText = "position: absolute; visibility: hidden;";
646
+ tag.hasIconPlaceholder = hasIcon;
647
+ this.shadowRoot.appendChild(tag);
648
+ const width = tag.getBoundingClientRect().width;
649
+ tag.remove();
650
+ return width;
651
+ };
652
+ updateTagLayout_fn = function() {
653
+ if (!this.multiple) {
654
+ this._numElidedTags = 0;
655
+ this._tagRows = [];
656
+ this._lastTagRow = [];
657
+ return;
658
+ }
659
+ if (this.externalTags) {
660
+ this._numElidedTags = this.values.length;
661
+ this._tagRows = [];
662
+ this._lastTagRow = [];
663
+ return;
664
+ }
665
+ const rowWidth = this._contentArea.getBoundingClientRect().width;
666
+ const rows = [[]];
667
+ let currentRowIndex = 0;
668
+ let currentRowWidth = InputMinWidthPx;
669
+ let i;
670
+ for (i = this.values.length - 1; i >= 0; i--) {
671
+ const isLastRow = this.maxLines && currentRowIndex === this.maxLines - 1;
672
+ const tagWidth = __privateMethod(this, _SearchableSelect_instances, measureTagWidth_fn).call(this, this._tagLabelForValue(this.values[i]), true, __privateMethod(this, _SearchableSelect_instances, tagIconOfOption_fn).call(this, this.selectedOptions[i]) !== null);
673
+ const entry = {
674
+ value: this.values[i],
675
+ width: tagWidth
676
+ };
677
+ let elidedTagCounterWidth = 0;
678
+ if (isLastRow) {
679
+ const numElidedTags = i;
680
+ if (numElidedTags) {
681
+ elidedTagCounterWidth = TagGapPx + __privateMethod(this, _SearchableSelect_instances, measureTagWidth_fn).call(this, numElidedTags.toString(), false, false);
703
682
  }
704
- });
705
- this.proxy.value = this.value;
706
- this.validate();
683
+ }
684
+ const totalWidthNeeded = currentRowWidth + TagGapPx + tagWidth + elidedTagCounterWidth;
685
+ if (totalWidthNeeded > rowWidth) {
686
+ if (isLastRow) {
687
+ if (i === this.values.length - 1) {
688
+ rows[currentRowIndex].unshift(entry);
689
+ currentRowWidth += TagGapPx + tagWidth;
690
+ } else {
691
+ break;
692
+ }
693
+ } else {
694
+ rows.push([]);
695
+ currentRowIndex++;
696
+ rows[currentRowIndex].unshift(entry);
697
+ currentRowWidth = tagWidth;
698
+ }
699
+ continue;
700
+ }
701
+ rows[currentRowIndex].unshift(entry);
702
+ currentRowWidth += TagGapPx + tagWidth;
707
703
  }
708
- formResetCallback() {
709
- this.setProxyOptions();
710
- super.setDefaultSelectedOption();
711
- if (this.selectedIndex === -1) {
712
- this.selectedIndex = 0;
704
+ this._numElidedTags = i + 1;
705
+ rows.reverse();
706
+ for (let i2 = 0; i2 < rows.length - 1; i2++) {
707
+ let lineWidth = rows[i2].map((e) => e.width).reduce((a, b) => a + b, 0) + (rows[i2].length - 1) * TagGapPx;
708
+ if (i2 === 0 && this._numElidedTags) {
709
+ lineWidth += TagGapPx + __privateMethod(this, _SearchableSelect_instances, measureTagWidth_fn).call(this, this._numElidedTags.toString(), false, false);
713
710
  }
714
- if (this.placeholder) {
715
- this.selectedIndex = -1;
711
+ while (rows[i2 + 1].length && lineWidth + TagGapPx + rows[i2 + 1][0].width <= rowWidth) {
712
+ const nextTag = rows[i2 + 1].shift();
713
+ rows[i2].push(nextTag);
714
+ lineWidth += TagGapPx + nextTag.width;
716
715
  }
717
716
  }
717
+ const rowValues = rows.map((line) => line.map((entry) => entry.value));
718
+ this._tagRows = rowValues.slice(0, -1);
719
+ this._lastTagRow = rowValues.slice(-1)[0];
718
720
  };
719
- __decorateClass([
720
- vividElement.observable
721
- ], exports.Select.prototype, "activeIndex", 2);
722
- // @ts-expect-error Type is incorrectly non-optional
723
- __decorateClass([
724
- vividElement.attr({ mode: "boolean" })
725
- ], exports.Select.prototype, "multiple", 2);
726
- __decorateClass([
727
- vividElement.attr({ attribute: "open", mode: "boolean" })
728
- ], exports.Select.prototype, "open", 2);
729
- __decorateClass([
730
- vividElement.volatile
731
- ], exports.Select.prototype, "collapsible", 1);
732
- __decorateClass([
733
- vividElement.observable
734
- ], exports.Select.prototype, "control", 2);
735
- __decorateClass([
736
- vividElement.observable
737
- ], exports.Select.prototype, "maxHeight", 2);
738
- __decorateClass([
739
- vividElement.observable
740
- ], exports.Select.prototype, "_anchor", 2);
741
- __decorateClass([
742
- vividElement.attr()
743
- ], exports.Select.prototype, "scale", 2);
744
- __decorateClass([
721
+ moveTagFocusTo_fn = function(index) {
722
+ if (index === null) {
723
+ this._input.focus();
724
+ } else {
725
+ this.shadowRoot.querySelector(`[data-index="${index}"]`)?.focus();
726
+ }
727
+ };
728
+ nextTagIndexLeft_fn = function(index) {
729
+ if (!this.values.length) {
730
+ return null;
731
+ }
732
+ for (let i = index - 1; i >= 0; i--) {
733
+ if (!this._isTagDisabled(this.values[i])) {
734
+ return i;
735
+ }
736
+ }
737
+ return null;
738
+ };
739
+ nextTagIndexRight_fn = function(index) {
740
+ if (!this.values.length) {
741
+ return null;
742
+ }
743
+ for (let i = index + 1; i < this.values.length; i++) {
744
+ if (!this._isTagDisabled(this.values[i])) {
745
+ return i;
746
+ }
747
+ }
748
+ return null;
749
+ };
750
+ nextTagIndexForRemoved_fn = function(index) {
751
+ return __privateMethod(this, _SearchableSelect_instances, nextTagIndexRight_fn).call(this, index - 1) ?? __privateMethod(this, _SearchableSelect_instances, nextTagIndexLeft_fn).call(this, index);
752
+ };
753
+ // --- Form handling ---
754
+ determineInitialValues_fn = function() {
755
+ return this.initialValues.length ? this.initialValues : this.initialValue ? [this.initialValue] : [];
756
+ };
757
+ updateFormValue_fn = function() {
758
+ if (!this.name) {
759
+ this.setFormValue(null);
760
+ } else {
761
+ const formData = new FormData();
762
+ for (const value of this.values) {
763
+ formData.append(this.name, value);
764
+ }
765
+ this.setFormValue(formData);
766
+ }
767
+ };
768
+ _resizeObserver = new WeakMap();
769
+ __decorateClass$1([
745
770
  vividElement.attr
746
- ], exports.Select.prototype, "appearance", 2);
747
- __decorateClass([
771
+ ], exports.SearchableSelect.prototype, "appearance", 2);
772
+ __decorateClass$1([
748
773
  vividElement.attr
749
- ], exports.Select.prototype, "shape", 2);
750
- __decorateClass([
774
+ ], exports.SearchableSelect.prototype, "shape", 2);
775
+ __decorateClass$1([
751
776
  vividElement.attr({ mode: "boolean", attribute: "fixed-dropdown" })
752
- ], exports.Select.prototype, "fixedDropdown", 2);
753
- __decorateClass([
777
+ ], exports.SearchableSelect.prototype, "fixedDropdown", 2);
778
+ __decorateClass$1([
754
779
  vividElement.attr
755
- ], exports.Select.prototype, "placeholder", 2);
756
- __decorateClass([
780
+ ], exports.SearchableSelect.prototype, "placeholder", 2);
781
+ __decorateClass$1([
782
+ vividElement.attr({ mode: "boolean" })
783
+ ], exports.SearchableSelect.prototype, "open", 2);
784
+ __decorateClass$1([
785
+ vividElement.attr({ mode: "boolean" })
786
+ ], exports.SearchableSelect.prototype, "multiple", 2);
787
+ __decorateClass$1([
788
+ vividElement.attr({ attribute: "external-tags", mode: "boolean" })
789
+ ], exports.SearchableSelect.prototype, "externalTags", 2);
790
+ __decorateClass$1([
791
+ vividElement.attr({ attribute: "max-lines", converter: vividElement.nullableNumberConverter })
792
+ ], exports.SearchableSelect.prototype, "maxLines", 2);
793
+ __decorateClass$1([
757
794
  vividElement.observable
758
- ], exports.Select.prototype, "placeholderOption", 2);
759
- __decorateClass([
795
+ ], exports.SearchableSelect.prototype, "values", 2);
796
+ __decorateClass$1([
760
797
  vividElement.observable
761
- ], exports.Select.prototype, "_feedbackWrapper", 2);
762
- __decorateClass([
798
+ ], exports.SearchableSelect.prototype, "initialValues", 2);
799
+ __decorateClass$1([
800
+ vividElement.observable
801
+ ], exports.SearchableSelect.prototype, "_input", 2);
802
+ __decorateClass$1([
803
+ vividElement.observable
804
+ ], exports.SearchableSelect.prototype, "_internalSearchText", 2);
805
+ __decorateClass$1([
806
+ vividElement.observable
807
+ ], exports.SearchableSelect.prototype, "_slottedOptions", 2);
808
+ __decorateClass$1([
809
+ vividElement.observable
810
+ ], exports.SearchableSelect.prototype, "_filteredOptions", 2);
811
+ __decorateClass$1([
812
+ vividElement.observable
813
+ ], exports.SearchableSelect.prototype, "_filteredEnabledOptions", 2);
814
+ __decorateClass$1([
815
+ vividElement.observable
816
+ ], exports.SearchableSelect.prototype, "filterOption", 2);
817
+ __decorateClass$1([
818
+ vividElement.attr({
819
+ mode: "boolean"
820
+ })
821
+ ], exports.SearchableSelect.prototype, "loading", 2);
822
+ __decorateClass$1([
823
+ vividElement.observable
824
+ ], exports.SearchableSelect.prototype, "_highlightedOptionIndex", 2);
825
+ __decorateClass$1([
826
+ vividElement.observable
827
+ ], exports.SearchableSelect.prototype, "_contentArea", 2);
828
+ __decorateClass$1([
829
+ vividElement.observable
830
+ ], exports.SearchableSelect.prototype, "_numElidedTags", 2);
831
+ __decorateClass$1([
832
+ vividElement.observable
833
+ ], exports.SearchableSelect.prototype, "_tagRows", 2);
834
+ __decorateClass$1([
835
+ vividElement.observable
836
+ ], exports.SearchableSelect.prototype, "_lastTagRow", 2);
837
+ __decorateClass$1([
838
+ vividElement.observable
839
+ ], exports.SearchableSelect.prototype, "_listbox", 2);
840
+ __decorateClass$1([
841
+ vividElement.attr({ mode: "boolean" })
842
+ ], exports.SearchableSelect.prototype, "clearable", 2);
843
+ __decorateClass$1([
763
844
  vividElement.observable
764
- ], exports.Select.prototype, "metaSlottedContent", 2);
765
- exports.Select = __decorateClass([
845
+ ], exports.SearchableSelect.prototype, "_changeDescription", 2);
846
+ __decorateClass$1([
847
+ vividElement.observable
848
+ ], exports.SearchableSelect.prototype, "_anchor", 2);
849
+ exports.SearchableSelect = __decorateClass$1([
766
850
  formElements.errorText,
767
851
  formElements.formElements
768
- ], exports.Select);
769
- class DelegatesARIASelect {
770
- }
771
- // @ts-expect-error Type is incorrectly non-optional
772
- __decorateClass([
773
- vividElement.observable
774
- ], DelegatesARIASelect.prototype, "ariaControls", 2);
852
+ ], exports.SearchableSelect);
775
853
  applyMixinsWithObservables.applyMixinsWithObservables(
776
- exports.Select,
854
+ exports.SearchableSelect,
777
855
  affix.AffixIconWithTrailing,
778
856
  formElements.FormElementHelperText,
779
857
  formElements.FormElementSuccessText,
780
- DelegatesARIASelect
858
+ localized.Localized
781
859
  );
782
860
 
783
- const getStateClasses = ({
784
- shape,
785
- disabled,
786
- appearance,
787
- metaSlottedContent,
788
- errorValidationMessage,
789
- successText,
790
- placeholder,
791
- value,
792
- scale
793
- }) => classNames.classNames(
794
- ["disabled", disabled],
795
- [`appearance-${appearance}`, Boolean(appearance)],
796
- [`shape-${shape}`, Boolean(shape)],
797
- ["has-meta", Boolean(metaSlottedContent?.length)],
798
- ["error", Boolean(errorValidationMessage)],
799
- ["success", !!successText],
800
- ["shows-placeholder", Boolean(placeholder) && !value],
801
- [`size-${scale}`, Boolean(scale)]
861
+ var __defProp = Object.defineProperty;
862
+ var __decorateClass = (decorators, target, key, kind) => {
863
+ var result = void 0 ;
864
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
865
+ if (decorator = decorators[i])
866
+ result = (decorator(target, key, result) ) || result;
867
+ if (result) __defProp(target, key, result);
868
+ return result;
869
+ };
870
+ class OptionTag extends vividElement.VividElement {
871
+ constructor() {
872
+ super(...arguments);
873
+ this.removable = false;
874
+ this.disabled = false;
875
+ this.hasIconPlaceholder = false;
876
+ }
877
+ _onClickRemove() {
878
+ this.$emit("remove", void 0, {
879
+ bubbles: false
880
+ });
881
+ }
882
+ }
883
+ __decorateClass([
884
+ vividElement.attr
885
+ ], OptionTag.prototype, "shape");
886
+ __decorateClass([
887
+ vividElement.attr
888
+ ], OptionTag.prototype, "label");
889
+ __decorateClass([
890
+ vividElement.attr({ mode: "boolean" })
891
+ ], OptionTag.prototype, "removable");
892
+ __decorateClass([
893
+ vividElement.attr({ mode: "boolean" })
894
+ ], OptionTag.prototype, "disabled");
895
+ __decorateClass([
896
+ vividElement.observable
897
+ ], OptionTag.prototype, "hasIconPlaceholder");
898
+ applyMixins.applyMixins(OptionTag, localized.Localized);
899
+
900
+ const getStateClasses = (x) => classNames.classNames(
901
+ ["disabled", x.disabled],
902
+ [`appearance-${x.appearance}`, Boolean(x.appearance)],
903
+ [`shape-${x.shape}`, Boolean(x.shape)],
904
+ ["error", Boolean(x.errorValidationMessage)],
905
+ ["success", !!x.successText]
802
906
  );
803
907
  function renderLabel() {
804
- return vividElement.html` <label for="control" class="label" id="label">
805
- ${(x) => x.label}
806
- </label>`;
807
- }
808
- function renderPlaceholder(context) {
809
- const optionTag = context.tagFor(option.ListboxOption);
810
908
  return vividElement.html`
811
- <${optionTag} ${ref.ref("placeholderOption")}
812
- text="${(x) => x.placeholder}" hidden disabled>
813
- </${optionTag}>`;
909
+ <label for="control" class="label" id="label"> ${(x) => x.label} </label>
910
+ `;
814
911
  }
815
- function selectValue(context) {
912
+ const tagTemplateFactory = (context, getComponent) => {
913
+ const optionTagTag = context.tagFor(OptionTag);
914
+ return vividElement.html`
915
+ <div class="tag-wrapper">
916
+ <${optionTagTag}
917
+ class="tag"
918
+ tabindex="-1"
919
+ data-index="${(x, c) => getComponent(c).values.indexOf(x)}"
920
+ removable
921
+ :label="${(x, c) => getComponent(c)._tagLabelForValue(x)}"
922
+ :shape="${(_, c) => getComponent(c).shape}"
923
+ ?disabled="${(x, c) => getComponent(c)._isTagDisabled(x)}"
924
+ @remove="${(x, c) => getComponent(c)._onTagRemoved(x)}"
925
+ @keydown="${(_, c) => getComponent(c)._onTagKeydown(c.event)}"
926
+ @mousedown="${() => false}">
927
+ <slot slot="icon" name="${(x, c) => getComponent(c)._tagIconSlotName(x)}"></slot>
928
+ </${optionTagTag}>
929
+ </div>
930
+ `;
931
+ };
932
+ const elidedTagTemplateFactory = (context, getComponent) => {
933
+ const optionTagTag = context.tagFor(OptionTag);
934
+ return vividElement.html`
935
+ <${optionTagTag}
936
+ class="tag"
937
+ tabindex="-1"
938
+ :label="${(x, c) => getComponent(x, c)._numElidedTags.toString()}"
939
+ :shape="${(x, c) => getComponent(x, c).shape}"
940
+ ?disabled="${(x, c) => getComponent(x, c).disabled}"
941
+ @mousedown="${() => false}">
942
+ </${optionTagTag}>
943
+ `;
944
+ };
945
+ function renderFieldset(context) {
946
+ const buttonTag = context.tagFor(definition$1.Button);
947
+ const progressRingTag = context.tagFor(definition$2.ProgressRing);
816
948
  const affixIconTemplate = affix.affixIconTemplateFactory(context);
817
949
  const chevronTemplate = definition$1.chevronTemplateFactory(context);
818
- return vividElement.html` <div
819
- class="control ${getStateClasses}"
820
- ${ref.ref("_anchor")}
821
- id="control"
822
- ?disabled="${(x) => x.disabled}"
823
- >
824
- <div class="selected-value">
950
+ const tagTemplate = tagTemplateFactory(context, (c) => c.parent);
951
+ const nestedTagTemplate = tagTemplateFactory(
952
+ context,
953
+ (c) => c.parentContext.parent
954
+ );
955
+ const elidedTagTemplate = elidedTagTemplateFactory(context, (x, _) => x);
956
+ const nestedElidedTagTemplate = elidedTagTemplateFactory(
957
+ context,
958
+ (_, c) => c.parent
959
+ );
960
+ return vividElement.html`
961
+ <div
962
+ class="fieldset ${getStateClasses}"
963
+ @click="${(x, c) => x._onFieldsetClick(c.event)}"
964
+ ${ref.ref("_anchor")}
965
+ >
825
966
  ${(x) => affixIconTemplate(x.icon, affix.IconWrapper.Slot)}
826
- <span class="text">${(x) => x.displayValue}</span>
827
- <slot name="meta" ${slotted.slotted("metaSlottedContent")}></slot>
967
+ <div class="content-area" ${ref.ref("_contentArea")}>
968
+ ${repeat.repeat(
969
+ (x) => x._tagRows,
970
+ vividElement.html`
971
+ <div class="tag-row">
972
+ ${when.when(
973
+ (_, c) => c.isFirst && c.parent._numElidedTags,
974
+ nestedElidedTagTemplate
975
+ )}
976
+ ${repeat.repeat((x) => x, nestedTagTemplate)}
977
+ </div>
978
+ `,
979
+ { positioning: true }
980
+ )}
981
+ <div
982
+ class="tag-row ${(x) => classNames.classNames([
983
+ "contains-only-input",
984
+ x._tagRows.length > 0 && x._lastTagRow.length === 0
985
+ ])}"
986
+ >
987
+ ${when.when(
988
+ (x) => x._tagRows.length === 0 && x._numElidedTags,
989
+ elidedTagTemplate
990
+ )}
991
+ ${repeat.repeat((x) => x._lastTagRow, tagTemplate)}
992
+ <input
993
+ id="control"
994
+ class="control"
995
+ autocomplete="off"
996
+ aria-autocomplete="list"
997
+ aria-expanded="${(x) => x.open}"
998
+ aria-haspopup="listbox"
999
+ aria-controls="listbox"
1000
+ placeholder="${(x) => x.multiple && x.values.length ? "" : x.placeholder}"
1001
+ role="combobox"
1002
+ type="text"
1003
+ ?disabled="${(x) => x.disabled}"
1004
+ :value="${(x) => x._inputValue}"
1005
+ @input="${(x, c) => {
1006
+ x._onInputInput(c.event);
1007
+ c.event.stopPropagation();
1008
+ }}"
1009
+ @change="${(_, c) => {
1010
+ c.event.stopPropagation();
1011
+ }}"
1012
+ @focus="${(x, c) => x._onInputFocus(c.event)}"
1013
+ @blur="${(x, c) => x._onInputBlur(c.event)}"
1014
+ @keydown="${(x, c) => x._onInputKeydown(c.event)}"
1015
+ ${ref.ref("_input")}
1016
+ />
1017
+ </div>
1018
+ </div>
1019
+ <slot name="meta"></slot>
1020
+ ${when.when(
1021
+ (x) => x._shouldShowClearButton,
1022
+ vividElement.html`<${buttonTag}
1023
+ aria-label="${(x) => x.locale.searchableSelect.clearButtonLabel}"
1024
+ @click="${(x) => x._onClearButtonClick()}"
1025
+ @mousedown="${() => false}"
1026
+ ?disabled="${(x) => x.disabled}"
1027
+ :shape="${(x) => x.shape}"
1028
+ size="super-condensed"
1029
+ icon="close-line"
1030
+ appearance="ghost-light"
1031
+ tabindex="-1"
1032
+ ></${buttonTag}>`
1033
+ )}
1034
+ <div @mousedown="${() => false}" @click="${(x) => x._onChevronClick()}">
1035
+ ${when.when(
1036
+ (x) => x.loading,
1037
+ vividElement.html`<${progressRingTag} indeterminate size="-6"></${progressRingTag}>`
1038
+ )}
1039
+ ${when.when((x) => !x.loading, chevronTemplate)}
1040
+ </div>
828
1041
  </div>
829
- ${chevronTemplate}
830
- </div>`;
1042
+ `;
831
1043
  }
832
1044
  function setFixedDropdownVarWidth(x) {
833
- return x.open && x.fixedDropdown ? `--_select-fixed-width: ${Math.round(x.getBoundingClientRect().width)}px` : null;
1045
+ return x.open && x.fixedDropdown ? `--_searchable-select-fixed-width: ${Math.round(
1046
+ x.getBoundingClientRect().width
1047
+ )}px` : null;
834
1048
  }
835
1049
  function renderControl(context) {
836
1050
  const popupTag = context.tagFor(definition.Popup);
837
1051
  return vividElement.html`
838
- ${when.when((x) => x.label, renderLabel())}
839
- <div class="control-wrapper">
840
- ${when.when((x) => !x.multiple, selectValue(context))}
841
- <${popupTag} class="popup"
842
- style="${setFixedDropdownVarWidth}"
843
- ?open="${(x) => x.collapsible ? x.open : true}"
1052
+ ${when.when((x) => x.label, renderLabel())}
1053
+ <span aria-live="assertive" aria-relevant="text" class="visually-hidden">
1054
+ ${(x) => x._changeDescription}
1055
+ </span>
1056
+ <div>
1057
+ ${renderFieldset(context)}
1058
+ <div class="popup-wrapper">
1059
+ <${popupTag}
844
1060
  :anchor="${(x) => x._anchor}"
1061
+ :open="${(x) => x.open}"
1062
+ class="popup"
845
1063
  placement="bottom-start"
846
- strategy="${(x) => x.fixedDropdown ? null : "absolute"}">
847
- <div class="listbox"
848
- id="${(x) => x.listboxId}"
1064
+ style="${setFixedDropdownVarWidth}"
1065
+ strategy="${(x) => x.fixedDropdown ? "fixed" : "absolute"}">
1066
+ <div
1067
+ class="listbox"
849
1068
  role="listbox"
850
- ?disabled="${(x) => x.disabled}"
851
- ?hidden="${(x) => x.collapsible ? !x.open : false}"
852
- ${ref.ref("listbox")}>
853
- ${when.when((x) => x.placeholder, renderPlaceholder(context))}
1069
+ aria-multiselectable="${(x) => x.multiple}"
1070
+ aria-required="${(x) => x.required}"
1071
+ ${ref.ref("_listbox")}
1072
+ @click="${(x, c) => x._onListboxClick(c.event)}"
1073
+ @mousedown="${() => false}"
1074
+ >
854
1075
  <slot
855
1076
  ${slotted.slotted({
856
- filter: listbox.Listbox.slottedOptionFilter,
1077
+ filter: option.isListboxOption,
857
1078
  flatten: true,
858
- property: "slottedOptions"
1079
+ property: "_slottedOptions"
859
1080
  })}>
860
1081
  </slot>
861
- </div>
1082
+ ${when.when(
1083
+ (x) => x._filteredOptions.length === 0,
1084
+ vividElement.html`<div class="empty-message">
1085
+ ${when.when(
1086
+ (x) => x.loading,
1087
+ vividElement.html` <slot name="loading-options">
1088
+ Loading...
1089
+ </slot>`
1090
+ )}
1091
+ ${when.when(
1092
+ (x) => !x.loading && x.searchText === "",
1093
+ vividElement.html`<slot name="no-options">
1094
+ ${(x) => x.locale.searchableSelect.noOptionsMessage}
1095
+ </slot>`
1096
+ )}
1097
+ ${when.when(
1098
+ (x) => !x.loading && x.searchText !== "",
1099
+ vividElement.html`<slot name="no-matches">
1100
+ ${(x) => x.locale.searchableSelect.noMatchesMessage}
1101
+ </slot>`
1102
+ )}
1103
+ </div>`
1104
+ )}
1105
+ </div>
862
1106
  </${popupTag}>
863
1107
  </div>
864
- `;
865
- }
866
- function ifNotFromFeedback(handler) {
867
- return (x, c) => {
868
- if (!c.event.composedPath().includes(x._feedbackWrapper)) {
869
- return handler(x, c.event);
870
- }
871
- return true;
872
- };
1108
+ </div>
1109
+ `;
873
1110
  }
874
- const SelectTemplate = (context) => {
1111
+ const SearchableSelectTemplate = (context) => {
1112
+ const optionTagTag = context.tagFor(OptionTag);
875
1113
  return vividElement.html`
876
1114
  <template
877
- class="base"
878
- aria-label="${(x) => x.ariaLabel}"
879
- aria-activedescendant="${(x) => x.ariaActiveDescendant}"
880
- aria-controls="${(x) => x.ariaControls}"
881
- aria-disabled="${(x) => x.ariaDisabled}"
882
- aria-expanded="${(x) => x.ariaExpanded}"
883
- aria-haspopup="${(x) => x.collapsible ? "listbox" : null}"
884
- aria-multiselectable="${(x) => x.ariaMultiSelectable}"
885
- role="combobox"
886
- tabindex="${(x) => !x.disabled ? "0" : null}"
887
- @click="${ifNotFromFeedback((x, e) => x.clickHandler(e))}"
888
- @focusin="${ifNotFromFeedback((x, e) => x.focusinHandler(e))}"
889
- @focusout="${ifNotFromFeedback(
890
- (x, e) => x.focusoutHandler(e)
891
- )}"
892
- @keydown="${ifNotFromFeedback((x, e) => {
893
- x.open && index.handleEscapeKeyAndStopPropogation(e);
894
- return x.keydownHandler(e);
895
- })}"
896
- @mousedown="${ifNotFromFeedback(
897
- (x, e) => x.mousedownHandler(e)
898
- )}"
1115
+ :_optionTagTagName="${() => optionTagTag}"
1116
+ @mousedown="${(x, c) => x._onMouseDown(c.event)}"
899
1117
  >
900
- ${renderControl(context)}
901
- <div class="feedback-wrapper" ${ref.ref("_feedbackWrapper")}>
902
- ${formElements.getFeedbackTemplate(context)}
1118
+ <div class="control-wrapper">
1119
+ ${renderControl(context)} ${formElements.getFeedbackTemplate(context)}
903
1120
  </div>
904
1121
  </template>
905
1122
  `;
906
1123
  };
907
1124
 
908
- const selectDefinition = vividElement.defineVividComponent(
909
- "select",
910
- exports.Select,
911
- SelectTemplate,
912
- [definition.popupDefinition, definition$2.iconDefinition, definition$3.listboxOptionDefinition],
1125
+ const getClasses = ({ shape, disabled, removable }) => classNames.classNames(
1126
+ "base",
1127
+ ["disabled", disabled],
1128
+ ["removable", removable],
1129
+ [`shape-${shape}`, Boolean(shape)]
1130
+ );
1131
+ function renderRemoveButton(iconTag) {
1132
+ return vividElement.html`
1133
+ <span
1134
+ class="remove-button"
1135
+ aria-label="${(x) => x.locale.searchableSelect.removeTagButtonLabel(x.label)}"
1136
+ role="button"
1137
+ tabindex="${(x) => x.disabled ? null : 0}"
1138
+ @click="${(x) => x._onClickRemove()}"
1139
+ >
1140
+ <${iconTag} name="close-line"></${iconTag}>
1141
+ </span>
1142
+ `;
1143
+ }
1144
+ const optionTagTemplate = (context) => {
1145
+ const iconTag = context.tagFor(definition$3.Icon);
1146
+ return vividElement.html`<span class="${getClasses}" aria-disabled="${(x) => x.disabled}">
1147
+ <slot name="icon" aria-hidden="true">
1148
+ ${when.when(
1149
+ (x) => x.hasIconPlaceholder,
1150
+ vividElement.html`<div class="icon-placeholder"></div>`
1151
+ )}
1152
+ </slot>
1153
+ ${when.when(
1154
+ (x) => x.label,
1155
+ (x) => vividElement.html`<span class="label">${x.label}</span>`
1156
+ )}
1157
+ ${when.when((x) => x.removable, renderRemoveButton(iconTag))}
1158
+ </span>`;
1159
+ };
1160
+
1161
+ const optionTagDefinition = vividElement.defineVividComponent(
1162
+ "option-tag",
1163
+ OptionTag,
1164
+ optionTagTemplate,
1165
+ [definition$3.iconDefinition],
1166
+ {
1167
+ styles: [optionTagStyles],
1168
+ shadowOptions: {
1169
+ delegatesFocus: true
1170
+ }
1171
+ }
1172
+ );
1173
+ const searchableSelectDefinition = vividElement.defineVividComponent(
1174
+ "searchable-select",
1175
+ exports.SearchableSelect,
1176
+ SearchableSelectTemplate,
1177
+ [
1178
+ definition$1.buttonDefinition,
1179
+ definition.popupDefinition,
1180
+ definition$3.iconDefinition,
1181
+ optionTagDefinition,
1182
+ definition$2.progressRingDefinition
1183
+ ],
913
1184
  {
914
1185
  styles
915
1186
  }
916
1187
  );
917
- const registerSelect = vividElement.createRegisterFunction(selectDefinition);
1188
+ const registerSearchableSelect = vividElement.createRegisterFunction(
1189
+ searchableSelectDefinition
1190
+ );
918
1191
 
919
- exports.registerSelect = registerSelect;
920
- exports.selectDefinition = selectDefinition;
1192
+ exports.registerSearchableSelect = registerSearchableSelect;