@vonage/vivid 4.4.0 → 4.6.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 (235) hide show
  1. package/custom-elements.json +7181 -6876
  2. package/elevation/index.cjs +1 -1
  3. package/elevation/index.js +1 -1
  4. package/index.cjs +80 -74
  5. package/index.js +23 -22
  6. package/lib/components.d.ts +1 -0
  7. package/lib/fab/fab.d.ts +1 -1
  8. package/lib/icon/icon.d.ts +1 -1
  9. package/lib/menu/menu.d.ts +2 -1
  10. package/lib/number-field/number-field.d.ts +3 -1
  11. package/lib/searchable-select/definition.d.ts +4 -0
  12. package/lib/searchable-select/locale.d.ts +6 -0
  13. package/lib/searchable-select/option-tag.d.ts +14 -0
  14. package/lib/searchable-select/option-tag.template.d.ts +4 -0
  15. package/lib/searchable-select/searchable-select.d.ts +29 -0
  16. package/lib/searchable-select/searchable-select.form-associated.d.ts +10 -0
  17. package/lib/searchable-select/searchable-select.template.d.ts +4 -0
  18. package/lib/select/select.d.ts +4 -1
  19. package/lib/tab/locale.d.ts +3 -0
  20. package/lib/tab/tab.d.ts +5 -1
  21. package/lib/tabs/tabs.d.ts +2 -0
  22. package/lib/tag/definition.d.ts +1 -0
  23. package/lib/text-field/text-field.d.ts +3 -1
  24. package/lib/video-player/video-player.d.ts +0 -1
  25. package/listbox/index.cjs +1 -1
  26. package/listbox/index.js +1 -1
  27. package/locales/de-DE.cjs +12 -0
  28. package/locales/de-DE.js +12 -0
  29. package/locales/en-GB.cjs +12 -0
  30. package/locales/en-GB.js +12 -0
  31. package/locales/en-US.cjs +12 -0
  32. package/locales/en-US.js +12 -0
  33. package/locales/ja-JP.cjs +12 -0
  34. package/locales/ja-JP.js +12 -0
  35. package/locales/zh-CN.cjs +12 -0
  36. package/locales/zh-CN.js +12 -0
  37. package/package.json +6 -1
  38. package/popup/index.cjs +1 -1
  39. package/popup/index.js +1 -1
  40. package/searchable-select/index.cjs +5 -0
  41. package/searchable-select/index.js +3 -0
  42. package/select/index.cjs +1 -1
  43. package/select/index.js +1 -1
  44. package/selectable-box/index.cjs +1 -1
  45. package/selectable-box/index.js +1 -1
  46. package/shared/anchored.js +1 -1
  47. package/shared/calendar-event.js +1 -1
  48. package/shared/definition.cjs +2 -2
  49. package/shared/definition.js +2 -2
  50. package/shared/definition11.cjs +1 -1
  51. package/shared/definition11.js +1 -1
  52. package/shared/definition12.cjs +1 -1
  53. package/shared/definition12.js +1 -1
  54. package/shared/definition13.js +1 -1
  55. package/shared/definition14.cjs +1 -1
  56. package/shared/definition14.js +1 -1
  57. package/shared/definition15.cjs +7 -8
  58. package/shared/definition15.js +2 -3
  59. package/shared/definition16.cjs +11 -7
  60. package/shared/definition16.js +10 -6
  61. package/shared/definition17.cjs +2 -2
  62. package/shared/definition17.js +2 -2
  63. package/shared/definition18.cjs +5 -6
  64. package/shared/definition18.js +3 -4
  65. package/shared/definition19.cjs +5 -6
  66. package/shared/definition19.js +3 -4
  67. package/shared/definition20.cjs +16 -38
  68. package/shared/definition20.js +17 -39
  69. package/shared/definition21.cjs +7 -6
  70. package/shared/definition21.js +8 -7
  71. package/shared/definition23.cjs +1 -1
  72. package/shared/definition23.js +2 -2
  73. package/shared/definition24.cjs +2 -2
  74. package/shared/definition24.js +2 -2
  75. package/shared/definition25.cjs +6 -7
  76. package/shared/definition25.js +2 -3
  77. package/shared/definition26.cjs +1 -1
  78. package/shared/definition26.js +2 -2
  79. package/shared/definition27.cjs +1 -1
  80. package/shared/definition27.js +1 -1
  81. package/shared/definition28.js +1 -1
  82. package/shared/definition29.cjs +8 -4
  83. package/shared/definition29.js +8 -4
  84. package/shared/definition3.cjs +1 -1
  85. package/shared/definition3.js +2 -2
  86. package/shared/definition30.cjs +4 -2
  87. package/shared/definition30.js +4 -2
  88. package/shared/definition31.cjs +1 -1
  89. package/shared/definition31.js +2 -2
  90. package/shared/definition32.cjs +1 -1
  91. package/shared/definition32.js +1 -1
  92. package/shared/definition34.cjs +2 -3
  93. package/shared/definition34.js +2 -3
  94. package/shared/definition35.cjs +21 -16
  95. package/shared/definition35.js +16 -11
  96. package/shared/definition36.cjs +50 -207
  97. package/shared/definition36.js +51 -207
  98. package/shared/definition37.js +1 -1
  99. package/shared/definition38.cjs +1 -1
  100. package/shared/definition38.js +1 -1
  101. package/shared/definition4.cjs +6 -4
  102. package/shared/definition4.js +7 -5
  103. package/shared/definition41.cjs +1 -1
  104. package/shared/definition41.js +1 -1
  105. package/shared/definition42.cjs +6 -7
  106. package/shared/definition42.js +6 -7
  107. package/shared/definition43.cjs +998 -643
  108. package/shared/definition43.js +992 -638
  109. package/shared/definition44.cjs +723 -112
  110. package/shared/definition44.js +722 -111
  111. package/shared/definition45.cjs +121 -79
  112. package/shared/definition45.js +120 -78
  113. package/shared/definition46.cjs +81 -616
  114. package/shared/definition46.js +80 -614
  115. package/shared/definition47.cjs +609 -116
  116. package/shared/definition47.js +607 -115
  117. package/shared/definition48.cjs +116 -134
  118. package/shared/definition48.js +115 -133
  119. package/shared/definition49.cjs +149 -19
  120. package/shared/definition49.js +148 -18
  121. package/shared/definition5.cjs +5 -6
  122. package/shared/definition5.js +5 -6
  123. package/shared/definition50.cjs +21 -82
  124. package/shared/definition50.js +20 -81
  125. package/shared/definition51.cjs +78 -494
  126. package/shared/definition51.js +77 -493
  127. package/shared/definition52.cjs +568 -28
  128. package/shared/definition52.js +567 -27
  129. package/shared/definition53.cjs +28 -123
  130. package/shared/definition53.js +27 -123
  131. package/shared/definition54.cjs +115 -296
  132. package/shared/definition54.js +114 -295
  133. package/shared/definition55.cjs +258 -318
  134. package/shared/definition55.js +252 -312
  135. package/shared/definition56.cjs +303 -784
  136. package/shared/definition56.js +298 -779
  137. package/shared/definition57.cjs +802 -95
  138. package/shared/definition57.js +801 -94
  139. package/shared/definition58.cjs +95 -60
  140. package/shared/definition58.js +94 -59
  141. package/shared/definition59.cjs +117 -75
  142. package/shared/definition59.js +116 -74
  143. package/shared/definition6.cjs +1 -1
  144. package/shared/definition6.js +1 -1
  145. package/shared/definition60.cjs +70 -285
  146. package/shared/definition60.js +71 -286
  147. package/shared/definition61.cjs +296 -325
  148. package/shared/definition61.js +295 -324
  149. package/shared/definition62.cjs +66160 -27
  150. package/shared/definition62.js +66159 -26
  151. package/shared/definition63.cjs +24 -1952
  152. package/shared/definition63.js +23 -1950
  153. package/shared/definition64.cjs +1976 -0
  154. package/shared/definition64.js +1971 -0
  155. package/shared/definition7.cjs +1 -1
  156. package/shared/definition7.js +1 -1
  157. package/shared/definition8.cjs +2 -3
  158. package/shared/definition8.js +3 -4
  159. package/shared/definition9.cjs +1 -1
  160. package/shared/definition9.js +1 -1
  161. package/shared/dialog/index.d.ts +1 -0
  162. package/shared/form-elements.cjs +236 -0
  163. package/shared/form-elements.js +229 -0
  164. package/shared/icon.js +1 -1
  165. package/shared/index2.cjs +6 -256
  166. package/shared/index2.js +6 -249
  167. package/shared/listbox-option.cjs +204 -0
  168. package/shared/listbox-option.js +201 -0
  169. package/shared/listbox.cjs +3 -3
  170. package/shared/listbox.js +1 -1
  171. package/shared/localization/Locale.d.ts +4 -0
  172. package/shared/localized.cjs +26 -2
  173. package/shared/localized.js +25 -2
  174. package/shared/playbackRates.cjs +13 -0
  175. package/shared/playbackRates.js +11 -0
  176. package/shared/presentationDate.cjs +11 -11
  177. package/shared/presentationDate.js +11 -11
  178. package/shared/scrollIntoView.cjs +51 -0
  179. package/shared/scrollIntoView.js +49 -0
  180. package/shared/slider.template.cjs +1 -1
  181. package/shared/slider.template.js +1 -1
  182. package/shared/text-anchor.cjs +1 -1
  183. package/shared/text-anchor.js +1 -1
  184. package/shared/text-field.cjs +1 -1
  185. package/shared/text-field.js +1 -1
  186. package/shared/utils/playbackRates.d.ts +1 -0
  187. package/shared/utils/scrollIntoView.d.ts +1 -0
  188. package/side-drawer/index.cjs +1 -1
  189. package/side-drawer/index.js +1 -1
  190. package/slider/index.cjs +1 -1
  191. package/slider/index.js +1 -1
  192. package/split-button/index.cjs +1 -1
  193. package/split-button/index.js +1 -1
  194. package/styles/core/all.css +1 -1
  195. package/styles/core/theme.css +1 -1
  196. package/styles/core/typography.css +1 -1
  197. package/styles/tokens/theme-dark.css +4 -4
  198. package/styles/tokens/theme-light.css +4 -4
  199. package/styles/tokens/vivid-2-compat.css +1 -1
  200. package/switch/index.cjs +1 -1
  201. package/switch/index.js +1 -1
  202. package/tab/index.cjs +1 -1
  203. package/tab/index.js +1 -1
  204. package/tab-panel/index.cjs +1 -1
  205. package/tab-panel/index.js +1 -1
  206. package/tabs/index.cjs +1 -1
  207. package/tabs/index.js +1 -1
  208. package/tag/index.cjs +1 -1
  209. package/tag/index.js +1 -1
  210. package/tag-group/index.cjs +1 -1
  211. package/tag-group/index.js +1 -1
  212. package/text-area/index.cjs +1 -1
  213. package/text-area/index.js +1 -1
  214. package/text-field/index.cjs +1 -1
  215. package/text-field/index.js +1 -1
  216. package/time-picker/index.cjs +1 -1
  217. package/time-picker/index.js +1 -1
  218. package/toggletip/index.cjs +1 -1
  219. package/toggletip/index.js +1 -1
  220. package/tooltip/index.cjs +1 -1
  221. package/tooltip/index.js +1 -1
  222. package/tree-item/index.cjs +1 -1
  223. package/tree-item/index.js +1 -1
  224. package/tree-view/index.cjs +1 -1
  225. package/tree-view/index.js +1 -1
  226. package/video-player/index.cjs +1 -1
  227. package/video-player/index.js +1 -1
  228. package/vivid.api.json +312 -8
  229. package/appearance-ui/index.cjs +0 -102
  230. package/appearance-ui/index.js +0 -100
  231. package/lib/appearance-ui/appearance-ui.d.ts +0 -12
  232. package/lib/appearance-ui/appearance-ui.template.d.ts +0 -4
  233. package/lib/appearance-ui/definition.d.ts +0 -3
  234. package/shared/video-player.cjs +0 -65860
  235. package/shared/video-player.js +0 -65857
@@ -1,750 +1,1105 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- const definition = require('./definition63.cjs');
5
- const definition$3 = require('./definition27.cjs');
6
- const definition$1 = require('./definition36.cjs');
4
+ const definition$1 = require('./definition11.cjs');
5
+ const definition = require('./definition64.cjs');
6
+ const definition$2 = require('./definition27.cjs');
7
+ const applyMixinsWithObservables = require('./applyMixinsWithObservables.cjs');
8
+ const scrollIntoView = require('./scrollIntoView.cjs');
9
+ const formAssociated = require('./form-associated.cjs');
7
10
  const affix = require('./affix.cjs');
8
- const index$1 = require('./index2.cjs');
11
+ const formElements = require('./form-elements.cjs');
12
+ const localized = require('./localized.cjs');
9
13
  const listbox = require('./listbox.cjs');
10
- const applyMixinsWithObservables = require('./applyMixinsWithObservables.cjs');
11
- const startEnd = require('./start-end.cjs');
12
14
  const applyMixins = require('./apply-mixins.cjs');
13
- const formAssociated = require('./form-associated.cjs');
14
- const select_options = require('./select.options.cjs');
15
- const strings = require('./strings.cjs');
16
- const keyCodes = require('./key-codes.cjs');
17
- const definition$2 = require('./definition11.cjs');
18
- const ref = require('./ref.cjs');
19
15
  const when = require('./when.cjs');
16
+ const ref = require('./ref.cjs');
20
17
  const slotted = require('./slotted.cjs');
18
+ const button = require('./button.cjs');
19
+ const repeat = require('./repeat.cjs');
21
20
  const classNames = require('./class-names.cjs');
21
+ const icon = require('./icon.cjs');
22
22
 
23
- class _Select extends listbox.ListboxElement {
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-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:100%}slot[name=icon]{font-size:20px}";
24
+
25
+ const optionTagStyles = ".base{--_connotation-color-contrast: var(--vvd-option-tag-accent-contrast, var(--vvd-color-neutral-800));--_connotation-color-soft: var(--vvd-option-tag-accent-soft, var(--vvd-color-neutral-100));--_connotation-color-pale: var(--vvd-option-tag-accent-pale, var(--vvd-color-neutral-300));--_connotation-color-fierce: var(--vvd-option-tag-accent-fierce, var(--vvd-color-neutral-700));--_connotation-color-firm-all: var(--vvd-option-tag-accent-firm-all, var(--vvd-color-neutral-600));--_connotation-color-faint: var(--vvd-option-tag-accent-faint, var(--vvd-color-neutral-50));--_connotation-color-dim: var(--vvd-option-tag-accent-dim, var(--vvd-color-neutral-200))}.base{--_appearance-color-text: var(--_connotation-color-contrast);--_appearance-color-fill: var(--_connotation-color-soft);--_appearance-color-outline: transparent}.base:where(.disabled,:disabled){--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: var(--vvd-color-neutral-100);--_appearance-color-outline: transparent}.base{position:relative;display:inline-flex;box-sizing:border-box;align-items:center;background-color:var(--_appearance-color-fill);block-size:calc(1px*(24 + 4*clamp(-1,var(--vvd-size-density, 0),2)));box-shadow:inset 0 0 0 1px var(--_appearance-color-outline);color:var(--_appearance-color-text);column-gap:8px;font:var(--vvd-typography-base-bold);max-inline-size:100%;padding-inline:8px;user-select:none;vertical-align:middle}.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}";
26
+
27
+ class _SearchableSelect extends index.FoundationElement {
24
28
  }
25
- /**
26
- * A form-associated base class for the {@link @microsoft/fast-foundation#(Select:class)} component.
27
- *
28
- * @internal
29
- */
30
- class FormAssociatedSelect extends formAssociated.FormAssociated(_Select) {
31
- constructor() {
32
- super(...arguments);
33
- this.proxy = document.createElement("select");
34
- }
29
+ class FormAssociatedSearchableSelect extends formAssociated.FormAssociated(
30
+ _SearchableSelect
31
+ ) {
32
+ constructor() {
33
+ super(...arguments);
34
+ this.proxy = document.createElement("input");
35
+ }
35
36
  }
36
37
 
37
- /**
38
- * A Select Custom HTML Element.
39
- * Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#select | ARIA select }.
40
- *
41
- * @slot start - Content which can be provided before the button content
42
- * @slot end - Content which can be provided after the button content
43
- * @slot button-container - The element representing the select button
44
- * @slot selected-value - The selected value
45
- * @slot indicator - The visual indicator for the expand/collapse state of the button
46
- * @slot - The default slot for slotted options
47
- * @csspart control - The element representing the select invoking element
48
- * @csspart selected-value - The element wrapping the selected value
49
- * @csspart indicator - The element wrapping the visual indicator
50
- * @csspart listbox - The listbox element
51
- * @fires input - Fires a custom 'input' event when the value updates
52
- * @fires change - Fires a custom 'change' event when the value updates
53
- *
54
- * @public
55
- */
56
- let Select$1 = class Select extends FormAssociatedSelect {
57
- constructor() {
58
- super(...arguments);
59
- /**
60
- * The open attribute.
61
- *
62
- * @public
63
- * @remarks
64
- * HTML Attribute: open
65
- */
66
- this.open = false;
67
- /**
68
- * Indicates the initial state of the position attribute.
69
- *
70
- * @internal
71
- */
72
- this.forcedPosition = false;
73
- /**
74
- * The unique id for the internal listbox element.
75
- *
76
- * @internal
77
- */
78
- this.listboxId = strings.uniqueId("listbox-");
79
- /**
80
- * The max height for the listbox when opened.
81
- *
82
- * @internal
83
- */
84
- this.maxHeight = 0;
85
- }
38
+ var __defProp$1 = Object.defineProperty;
39
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
40
+ var __typeError = (msg) => {
41
+ throw TypeError(msg);
42
+ };
43
+ var __decorateClass$1 = (decorators, target, key, kind) => {
44
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
45
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
46
+ if (decorator = decorators[i])
47
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
48
+ if (kind && result) __defProp$1(target, key, result);
49
+ return result;
50
+ };
51
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
52
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
53
+ 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);
54
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
55
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
56
+ var _SearchableSelect_instances, updateValuesThroughUserInteraction_fn, updateValuesWhileMaintainingOrder_fn, isValidValue_fn, _slottedOptionsChangeHandler, updateSelectedOnSlottedOptions_fn, handleOptionInteraction_fn, _clonedTagIcons, tagIconOfOption_fn, updateClonedTagIconOfOption_fn, _suppressFilter, 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;
57
+ const TagGapPx = 8;
58
+ const InputMinWidthPx = 100;
59
+ const PageSize = 10;
60
+ const isFormAssociatedTryingToSetFormValue = (value) => typeof value === "string";
61
+ let SearchableSelect = class extends FormAssociatedSearchableSelect {
62
+ constructor() {
63
+ super(...arguments);
64
+ __privateAdd(this, _SearchableSelect_instances);
65
+ this.fixedDropdown = false;
66
+ this.open = false;
67
+ this.multiple = false;
68
+ this.externalTags = false;
69
+ this.maxLines = null;
70
+ this.values = [];
71
+ this.initialValues = [];
72
+ this._inputValue = "";
73
+ // --- Slotted options ---
86
74
  /**
87
- * Sets focus and synchronizes ARIA attributes when the open property changes.
88
- *
89
- * @param prev - the previous open value
90
- * @param next - the current open value
91
- *
92
75
  * @internal
93
76
  */
94
- openChanged(prev, next) {
95
- if (!this.collapsible) {
96
- return;
97
- }
98
- if (this.open) {
99
- this.ariaControls = this.listboxId;
100
- this.ariaExpanded = "true";
101
- this.setPositioning();
102
- this.focusAndScrollOptionIntoView();
103
- this.indexWhenOpened = this.selectedIndex;
104
- // focus is directed to the element when `open` is changed programmatically
105
- index.DOM.queueUpdate(() => this.focus());
106
- return;
77
+ this._areOptionsInitialized = false;
78
+ __privateAdd(this, _slottedOptionsChangeHandler, {
79
+ handleChange: (source, _) => {
80
+ if (source.selected && !this.values.includes(source.value)) {
81
+ this.values = [...this.values, source.value];
82
+ } else if (!source.selected && this.values.includes(source.value)) {
83
+ this.values = this.values.filter((option) => option !== source.value);
107
84
  }
108
- this.ariaControls = "";
109
- this.ariaExpanded = "false";
110
- }
85
+ }
86
+ });
87
+ // --- Option tag icons ---
88
+ __privateAdd(this, _clonedTagIcons, /* @__PURE__ */ new Map());
89
+ this._filteredOptions = [];
90
+ this._filteredEnabledOptions = [];
91
+ __privateAdd(this, _suppressFilter, false);
92
+ // --- Highlighted option (visual focus) ---
111
93
  /**
112
- * The component is collapsible when in single-selection mode with no size attribute.
113
- *
94
+ * Currently visually highlighted option as an index into _filteredEnabledOptions
114
95
  * @internal
115
96
  */
116
- get collapsible() {
117
- return !(this.multiple || typeof this.size === "number");
97
+ this._highlightedOptionIndex = null;
98
+ this._numEllidedTags = 0;
99
+ this._tagRows = [];
100
+ this._lastTagRow = [];
101
+ this.clearable = false;
102
+ this.setFormValue = (value, state) => {
103
+ if (isFormAssociatedTryingToSetFormValue(value)) {
104
+ return;
105
+ }
106
+ super.setFormValue(value, state);
107
+ };
108
+ // --- Core ---
109
+ __privateAdd(this, _resizeObserver, new ResizeObserver(() => {
110
+ __privateMethod(this, _SearchableSelect_instances, updateTagLayout_fn).call(this);
111
+ }));
112
+ }
113
+ /**
114
+ * @internal
115
+ */
116
+ valuesChanged() {
117
+ if (!this._areOptionsInitialized) {
118
+ return;
118
119
  }
119
- /**
120
- * The value property.
121
- *
122
- * @public
123
- */
124
- get value() {
125
- index.Observable.track(this, "value");
126
- return this._value;
127
- }
128
- set value(next) {
129
- var _a, _b, _c, _d, _e, _f, _g;
130
- const prev = `${this._value}`;
131
- if ((_a = this._options) === null || _a === void 0 ? void 0 : _a.length) {
132
- const selectedIndex = this._options.findIndex(el => el.value === next);
133
- const prevSelectedValue = (_c = (_b = this._options[this.selectedIndex]) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : null;
134
- const nextSelectedValue = (_e = (_d = this._options[selectedIndex]) === null || _d === void 0 ? void 0 : _d.value) !== null && _e !== void 0 ? _e : null;
135
- if (selectedIndex === -1 || prevSelectedValue !== nextSelectedValue) {
136
- next = "";
137
- this.selectedIndex = selectedIndex;
138
- }
139
- next = (_g = (_f = this.firstSelectedOption) === null || _f === void 0 ? void 0 : _f.value) !== null && _g !== void 0 ? _g : next;
140
- }
141
- if (prev !== next) {
142
- this._value = next;
143
- super.valueChanged(prev, next);
144
- index.Observable.notify(this, "value");
145
- this.updateDisplayValue();
146
- }
120
+ if (!this.multiple && this.values.length > 1) {
121
+ this.values = [this.values[0]];
122
+ return;
147
123
  }
148
- /**
149
- * Sets the value and display value to match the first selected option.
150
- *
151
- * @param shouldEmit - if true, the input and change events will be emitted
152
- *
153
- * @internal
154
- */
155
- updateValue(shouldEmit) {
156
- var _a, _b;
157
- if (this.$fastController.isConnected) {
158
- this.value = (_b = (_a = this.firstSelectedOption) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : "";
159
- }
160
- if (shouldEmit) {
161
- this.$emit("input");
162
- this.$emit("change", this, {
163
- bubbles: true,
164
- composed: undefined,
165
- });
166
- }
124
+ if (this.values.some((value) => !__privateMethod(this, _SearchableSelect_instances, isValidValue_fn).call(this, value))) {
125
+ this.values = this.values.filter((value) => __privateMethod(this, _SearchableSelect_instances, isValidValue_fn).call(this, value));
126
+ return;
167
127
  }
168
- /**
169
- * Updates the proxy value when the selected index changes.
170
- *
171
- * @param prev - the previous selected index
172
- * @param next - the next selected index
173
- *
174
- * @internal
175
- */
176
- selectedIndexChanged(prev, next) {
177
- super.selectedIndexChanged(prev, next);
178
- this.updateValue();
128
+ if (!this.multiple) {
129
+ if (this.values.length) {
130
+ __privateSet(this, _suppressFilter, true);
131
+ this._inputValue = __privateMethod(this, _SearchableSelect_instances, textForValue_fn).call(this, this.values[0]);
132
+ } else {
133
+ this._inputValue = "";
134
+ }
179
135
  }
180
- positionChanged(prev, next) {
181
- this.positionAttribute = next;
182
- this.setPositioning();
136
+ this.value = this.values.length ? this.values[0] : "";
137
+ __privateMethod(this, _SearchableSelect_instances, updateSelectedOnSlottedOptions_fn).call(this);
138
+ if (this.$fastController.isConnected) {
139
+ __privateMethod(this, _SearchableSelect_instances, updateTagLayout_fn).call(this);
183
140
  }
184
- /**
185
- * Calculate and apply listbox positioning based on available viewport space.
186
- *
187
- * @public
188
- */
189
- setPositioning() {
190
- const currentBox = this.getBoundingClientRect();
191
- const viewportHeight = window.innerHeight;
192
- const availableBottom = viewportHeight - currentBox.bottom;
193
- this.position = this.forcedPosition
194
- ? this.positionAttribute
195
- : currentBox.top > availableBottom
196
- ? select_options.SelectPosition.above
197
- : select_options.SelectPosition.below;
198
- this.positionAttribute = this.forcedPosition
199
- ? this.positionAttribute
200
- : this.position;
201
- this.maxHeight =
202
- this.position === select_options.SelectPosition.above ? ~~currentBox.top : ~~availableBottom;
141
+ __privateMethod(this, _SearchableSelect_instances, updateFormValue_fn).call(this);
142
+ }
143
+ /**
144
+ * @internal
145
+ */
146
+ initialValuesChanged() {
147
+ if (!this.dirtyValue) {
148
+ this.values = this.initialValues;
149
+ this.dirtyValue = false;
203
150
  }
204
- /**
205
- * The value displayed on the button.
206
- *
207
- * @public
208
- */
209
- get displayValue() {
210
- var _a, _b;
211
- index.Observable.track(this, "displayValue");
212
- return (_b = (_a = this.firstSelectedOption) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : "";
151
+ }
152
+ /**
153
+ * @internal
154
+ */
155
+ valueChanged(prev, next) {
156
+ super.valueChanged(prev, next);
157
+ if (!this._areOptionsInitialized) {
158
+ return;
213
159
  }
214
- /**
215
- * Synchronize the `aria-disabled` property when the `disabled` property changes.
216
- *
217
- * @param prev - The previous disabled value
218
- * @param next - The next disabled value
219
- *
220
- * @internal
221
- */
222
- disabledChanged(prev, next) {
223
- if (super.disabledChanged) {
224
- super.disabledChanged(prev, next);
225
- }
226
- this.ariaDisabled = this.disabled ? "true" : "false";
160
+ const isValidValue = this._slottedOptions.some(
161
+ (option) => option.value === next
162
+ );
163
+ if (this.values[0] !== next) {
164
+ this.values = isValidValue ? [next] : [];
227
165
  }
228
- /**
229
- * Reset the element to its first selectable option when its parent form is reset.
230
- *
231
- * @internal
232
- */
233
- formResetCallback() {
234
- this.setProxyOptions();
235
- // Call the base class's implementation setDefaultSelectedOption instead of the select's
236
- // override, in order to reset the selectedIndex without using the value property.
237
- super.setDefaultSelectedOption();
238
- if (this.selectedIndex === -1) {
239
- this.selectedIndex = 0;
240
- }
166
+ }
167
+ get selectedIndex() {
168
+ if (this.values.length) {
169
+ return this._slottedOptions.findIndex(
170
+ (option) => option.value === this.values[0]
171
+ );
172
+ } else {
173
+ return -1;
241
174
  }
242
- /**
243
- * Handle opening and closing the listbox when the select is clicked.
244
- *
245
- * @param e - the mouse event
246
- * @internal
247
- */
248
- clickHandler(e) {
249
- // do nothing if the select is disabled
250
- if (this.disabled) {
251
- return;
175
+ }
176
+ set selectedIndex(index) {
177
+ this.value = this._slottedOptions[index]?.value ?? "";
178
+ }
179
+ get options() {
180
+ return [...this._slottedOptions];
181
+ }
182
+ get selectedOptions() {
183
+ return this._slottedOptions.filter(
184
+ (option) => this.values.includes(option.value)
185
+ );
186
+ }
187
+ /**
188
+ * @internal
189
+ */
190
+ _inputValueChanged() {
191
+ __privateMethod(this, _SearchableSelect_instances, updateFilteredOptions_fn).call(this);
192
+ }
193
+ /**
194
+ * @internal
195
+ */
196
+ _onInputInput(event) {
197
+ __privateSet(this, _suppressFilter, false);
198
+ this._inputValue = event.target.value;
199
+ }
200
+ /**
201
+ * @internal
202
+ */
203
+ _onInputFocus(_) {
204
+ __privateSet(this, _suppressFilter, true);
205
+ __privateMethod(this, _SearchableSelect_instances, updateFilteredOptions_fn).call(this);
206
+ this.open = true;
207
+ }
208
+ /**
209
+ * @internal
210
+ */
211
+ _onInputBlur(_) {
212
+ this.open = false;
213
+ if (this.multiple) {
214
+ this._inputValue = "";
215
+ } else {
216
+ if (this.values.length === 0) {
217
+ this._inputValue = "";
218
+ } else {
219
+ this._inputValue = __privateMethod(this, _SearchableSelect_instances, textForValue_fn).call(this, this.values[0]);
220
+ }
221
+ }
222
+ }
223
+ /**
224
+ * @internal
225
+ */
226
+ _onInputKeydown(e) {
227
+ if (e.ctrlKey || e.shiftKey) {
228
+ return true;
229
+ }
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;
252
241
  }
253
- if (this.open) {
254
- const captured = e.target.closest(`option,[role=option]`);
255
- if (captured && captured.disabled) {
256
- return;
257
- }
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;
258
248
  }
259
- super.clickHandler(e);
260
- this.open = this.collapsible && !this.open;
261
- if (!this.open && this.indexWhenOpened !== this.selectedIndex) {
262
- this.updateValue(true);
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;
263
255
  }
264
- return true;
265
- }
266
- /**
267
- * Handles focus state when the element or its children lose focus.
268
- *
269
- * @param e - The focus event
270
- * @internal
271
- */
272
- focusoutHandler(e) {
273
- var _a;
274
- super.focusoutHandler(e);
256
+ __privateMethod(this, _SearchableSelect_instances, highlightPrevPage_fn).call(this);
257
+ return false;
258
+ case "PageDown":
275
259
  if (!this.open) {
276
- return true;
260
+ this.open = true;
261
+ break;
277
262
  }
278
- const focusTarget = e.relatedTarget;
279
- if (this.isSameNode(focusTarget)) {
280
- this.focus();
281
- return;
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;
282
269
  }
283
- if (!((_a = this.options) === null || _a === void 0 ? void 0 : _a.includes(focusTarget))) {
284
- this.open = false;
285
- if (this.indexWhenOpened !== this.selectedIndex) {
286
- this.updateValue(true);
287
- }
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;
288
276
  }
289
- }
290
- /**
291
- * Updates the value when an option's value changes.
292
- *
293
- * @param source - the source object
294
- * @param propertyName - the property to evaluate
295
- *
296
- * @internal
297
- * @override
298
- */
299
- handleChange(source, propertyName) {
300
- super.handleChange(source, propertyName);
301
- if (propertyName === "value") {
302
- this.updateValue();
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;
303
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;
304
296
  }
305
- /**
306
- * Synchronize the form-associated proxy and updates the value property of the element.
307
- *
308
- * @param prev - the previous collection of slotted option elements
309
- * @param next - the next collection of slotted option elements
310
- *
311
- * @internal
312
- */
313
- slottedOptionsChanged(prev, next) {
314
- this.options.forEach(o => {
315
- const notifier = index.Observable.getNotifier(o);
316
- notifier.unsubscribe(this, "value");
317
- });
318
- super.slottedOptionsChanged(prev, next);
319
- this.options.forEach(o => {
320
- const notifier = index.Observable.getNotifier(o);
321
- notifier.subscribe(this, "value");
322
- });
323
- this.setProxyOptions();
324
- this.updateValue();
297
+ return true;
298
+ }
299
+ /**
300
+ * @internal
301
+ */
302
+ _slottedOptionsChanged(oldValue, newValue) {
303
+ const hasSlottedOptions = Boolean(
304
+ this.querySelectorAll(`:not([slot])`).length
305
+ );
306
+ if (!newValue.length && hasSlottedOptions) {
307
+ return;
325
308
  }
326
- /**
327
- * Prevents focus when size is set and a scrollbar is clicked.
328
- *
329
- * @param e - the mouse event object
330
- *
331
- * @override
332
- * @internal
333
- */
334
- mousedownHandler(e) {
335
- var _a;
336
- if (e.offsetX >= 0 && e.offsetX <= ((_a = this.listbox) === null || _a === void 0 ? void 0 : _a.scrollWidth)) {
337
- return super.mousedownHandler(e);
338
- }
339
- return this.collapsible;
309
+ this._areOptionsInitialized = true;
310
+ if (oldValue) {
311
+ for (const option of oldValue) {
312
+ const notifier = index.Observable.getNotifier(option);
313
+ notifier.unsubscribe(__privateGet(this, _slottedOptionsChangeHandler), "selected");
314
+ }
340
315
  }
341
- /**
342
- * Sets the multiple property on the proxy element.
343
- *
344
- * @param prev - the previous multiple value
345
- * @param next - the current multiple value
346
- */
347
- multipleChanged(prev, next) {
348
- super.multipleChanged(prev, next);
349
- if (this.proxy) {
350
- this.proxy.multiple = next;
351
- }
316
+ if (newValue) {
317
+ for (const option of newValue) {
318
+ option._displayCheckmark = true;
319
+ const notifier = index.Observable.getNotifier(option);
320
+ notifier.subscribe(__privateGet(this, _slottedOptionsChangeHandler), "selected");
321
+ }
352
322
  }
353
- /**
354
- * Updates the selectedness of each option when the list of selected options changes.
355
- *
356
- * @param prev - the previous list of selected options
357
- * @param next - the current list of selected options
358
- *
359
- * @override
360
- * @internal
361
- */
362
- selectedOptionsChanged(prev, next) {
363
- var _a;
364
- super.selectedOptionsChanged(prev, next);
365
- (_a = this.options) === null || _a === void 0 ? void 0 : _a.forEach((o, i) => {
366
- var _a;
367
- const proxyOption = (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.options.item(i);
368
- if (proxyOption) {
369
- proxyOption.selected = o.selected;
370
- }
371
- });
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
+ }
372
328
  }
373
- /**
374
- * Sets the selected index to match the first option with the selected attribute, or
375
- * the first selectable option.
376
- *
377
- * @override
378
- * @internal
379
- */
380
- setDefaultSelectedOption() {
381
- var _a;
382
- const options = (_a = this.options) !== null && _a !== void 0 ? _a : Array.from(this.children).filter(listbox.Listbox$1.slottedOptionFilter);
383
- const selectedIndex = options === null || options === void 0 ? void 0 : options.findIndex(el => el.hasAttribute("selected") || el.selected || el.value === this.value);
384
- if (selectedIndex !== -1) {
385
- this.selectedIndex = selectedIndex;
386
- return;
387
- }
388
- this.selectedIndex = 0;
329
+ __privateMethod(this, _SearchableSelect_instances, updateValuesWhileMaintainingOrder_fn).call(this, values);
330
+ __privateMethod(this, _SearchableSelect_instances, updateFilteredOptions_fn).call(this);
331
+ }
332
+ /**
333
+ * @internal
334
+ */
335
+ _tagIconSlotName(value) {
336
+ return `_tag-icon-${this.values.indexOf(value)}`;
337
+ }
338
+ // --- Tags ---
339
+ /**
340
+ * @internal
341
+ */
342
+ _tagLabelForValue(value) {
343
+ const option = this._slottedOptions.find(
344
+ (option2) => option2.value === value
345
+ );
346
+ return option.label;
347
+ }
348
+ /**
349
+ * @internal
350
+ */
351
+ _isTagDisabled(value) {
352
+ const option = this._slottedOptions.find(
353
+ (option2) => option2.value === value
354
+ );
355
+ return this.disabled || option.disabled;
356
+ }
357
+ /**
358
+ * @internal
359
+ */
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);
363
+ }
364
+ /**
365
+ * @internal
366
+ */
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
+ index.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;
389
385
  }
390
- /**
391
- * Resets and fills the proxy to match the component's options.
392
- *
393
- * @internal
394
- */
395
- setProxyOptions() {
396
- if (this.proxy instanceof HTMLSelectElement && this.options) {
397
- this.proxy.options.length = 0;
398
- this.options.forEach(option => {
399
- const proxyOption = option.proxy ||
400
- (option instanceof HTMLOptionElement ? option.cloneNode() : null);
401
- if (proxyOption) {
402
- this.proxy.options.add(proxyOption);
403
- }
404
- });
405
- }
386
+ return true;
387
+ }
388
+ /**
389
+ * @internal
390
+ */
391
+ _onListboxClick(e) {
392
+ if (this.disabled) {
393
+ return;
406
394
  }
407
- /**
408
- * Handle keyboard interaction for the select.
409
- *
410
- * @param e - the keyboard event
411
- * @internal
412
- */
413
- keydownHandler(e) {
414
- super.keydownHandler(e);
415
- const key = e.key || e.key.charCodeAt(0);
416
- switch (key) {
417
- case keyCodes.keySpace: {
418
- e.preventDefault();
419
- if (this.collapsible && this.typeAheadExpired) {
420
- this.open = !this.open;
421
- }
422
- break;
423
- }
424
- case keyCodes.keyHome:
425
- case keyCodes.keyEnd: {
426
- e.preventDefault();
427
- break;
428
- }
429
- case keyCodes.keyEnter: {
430
- e.preventDefault();
431
- this.open = !this.open;
432
- break;
433
- }
434
- case keyCodes.keyEscape: {
435
- if (this.collapsible && this.open) {
436
- e.preventDefault();
437
- this.open = false;
438
- }
439
- break;
440
- }
441
- case keyCodes.keyTab: {
442
- if (this.collapsible && this.open) {
443
- e.preventDefault();
444
- this.open = false;
445
- }
446
- return true;
447
- }
448
- }
449
- if (!this.open && this.indexWhenOpened !== this.selectedIndex) {
450
- this.updateValue(true);
451
- this.indexWhenOpened = this.selectedIndex;
452
- }
453
- return !(key === keyCodes.keyArrowDown || key === keyCodes.keyArrowUp);
395
+ const capturedOption = e.target.closest(
396
+ `option,[role=option]`
397
+ );
398
+ if (capturedOption && !capturedOption.disabled) {
399
+ __privateMethod(this, _SearchableSelect_instances, handleOptionInteraction_fn).call(this, capturedOption);
400
+ }
401
+ }
402
+ /**
403
+ * @internal
404
+ */
405
+ get _shouldShowClearButton() {
406
+ return this.clearable && this.values.length > 0;
407
+ }
408
+ /**
409
+ * @internal
410
+ */
411
+ _onClearButtonClick() {
412
+ __privateMethod(this, _SearchableSelect_instances, updateValuesThroughUserInteraction_fn).call(this, this.selectedOptions.filter((option) => option.disabled).map((option) => option.value));
413
+ }
414
+ /**
415
+ * @internal
416
+ */
417
+ nameChanged(previous, next) {
418
+ super.nameChanged(previous, next);
419
+ __privateMethod(this, _SearchableSelect_instances, updateFormValue_fn).call(this);
420
+ }
421
+ /**
422
+ * @internal
423
+ */
424
+ formResetCallback() {
425
+ super.formResetCallback();
426
+ __privateMethod(this, _SearchableSelect_instances, updateValuesThroughUserInteraction_fn).call(this, __privateMethod(this, _SearchableSelect_instances, determineInitialValues_fn).call(this));
427
+ }
428
+ /**
429
+ * @internal
430
+ */
431
+ _onFieldsetClick(e) {
432
+ if (this.disabled) {
433
+ return;
454
434
  }
455
- connectedCallback() {
456
- super.connectedCallback();
457
- this.forcedPosition = !!this.positionAttribute;
458
- this.addEventListener("contentchange", this.updateDisplayValue);
435
+ if (!e.defaultPrevented) {
436
+ this._input.focus();
459
437
  }
460
- disconnectedCallback() {
461
- this.removeEventListener("contentchange", this.updateDisplayValue);
462
- super.disconnectedCallback();
438
+ }
439
+ connectedCallback() {
440
+ super.connectedCallback();
441
+ if (!this.values.length) {
442
+ this.values = __privateMethod(this, _SearchableSelect_instances, determineInitialValues_fn).call(this);
463
443
  }
464
- /**
465
- * Updates the proxy's size property when the size attribute changes.
466
- *
467
- * @param prev - the previous size
468
- * @param next - the current size
469
- *
470
- * @override
471
- * @internal
472
- */
473
- sizeChanged(prev, next) {
474
- super.sizeChanged(prev, next);
475
- if (this.proxy) {
476
- this.proxy.size = next;
477
- }
444
+ __privateGet(this, _resizeObserver).observe(this._contentArea);
445
+ }
446
+ disconnectedCallback() {
447
+ super.disconnectedCallback();
448
+ __privateGet(this, _resizeObserver).disconnect();
449
+ }
450
+ /**
451
+ * @internal
452
+ */
453
+ validate() {
454
+ super.validate(this._input ?? void 0);
455
+ }
456
+ };
457
+ _SearchableSelect_instances = new WeakSet();
458
+ updateValuesThroughUserInteraction_fn = function(newValues) {
459
+ this.values = newValues;
460
+ this.$emit("change", void 0, {
461
+ bubbles: false
462
+ });
463
+ this.$emit("input", void 0, {
464
+ bubbles: false
465
+ });
466
+ };
467
+ updateValuesWhileMaintainingOrder_fn = function(newValues) {
468
+ const oldSet = new Set(this.values);
469
+ const newSet = new Set(newValues);
470
+ this.values = [...this.values].filter((v) => newSet.has(v)).concat([...newValues].filter((v) => !oldSet.has(v)));
471
+ };
472
+ isValidValue_fn = function(value) {
473
+ return this._slottedOptions.some((option) => option.value === value);
474
+ };
475
+ _slottedOptionsChangeHandler = new WeakMap();
476
+ updateSelectedOnSlottedOptions_fn = function() {
477
+ for (const option of this._slottedOptions) {
478
+ option.selected = this.values.includes(option.value);
479
+ __privateMethod(this, _SearchableSelect_instances, updateClonedTagIconOfOption_fn).call(this, option);
480
+ }
481
+ };
482
+ handleOptionInteraction_fn = function(option) {
483
+ const value = option.value;
484
+ let newValues;
485
+ if (this.multiple) {
486
+ if (!this.values.includes(value)) {
487
+ newValues = [...this.values, value];
488
+ } else {
489
+ newValues = this.values.filter((option2) => option2 !== value);
478
490
  }
479
- /**
480
- *
481
- * @internal
482
- */
483
- updateDisplayValue() {
484
- if (this.collapsible) {
485
- index.Observable.notify(this, "displayValue");
486
- }
491
+ this._inputValue = "";
492
+ } else {
493
+ if (this.values.includes(value)) {
494
+ newValues = [];
495
+ } else {
496
+ newValues = [value];
497
+ this._inputValue = option.text;
498
+ }
499
+ this.open = false;
500
+ }
501
+ __privateMethod(this, _SearchableSelect_instances, updateValuesThroughUserInteraction_fn).call(this, newValues);
502
+ };
503
+ _clonedTagIcons = new WeakMap();
504
+ tagIconOfOption_fn = function(option) {
505
+ return option.querySelector('[slot="tag-icon"]');
506
+ };
507
+ updateClonedTagIconOfOption_fn = function(option) {
508
+ if (option.selected && __privateMethod(this, _SearchableSelect_instances, tagIconOfOption_fn).call(this, option)) {
509
+ let clone = __privateGet(this, _clonedTagIcons).get(option);
510
+ if (!clone) {
511
+ clone = __privateMethod(this, _SearchableSelect_instances, tagIconOfOption_fn).call(this, option).cloneNode(true);
512
+ __privateGet(this, _clonedTagIcons).set(option, clone);
513
+ }
514
+ clone.slot = this._tagIconSlotName(option.value);
515
+ this.appendChild(clone);
516
+ } else {
517
+ const clone = __privateGet(this, _clonedTagIcons).get(option);
518
+ if (clone) {
519
+ clone.remove();
520
+ __privateGet(this, _clonedTagIcons).delete(option);
521
+ }
522
+ }
523
+ };
524
+ _suppressFilter = new WeakMap();
525
+ updateFilteredOptions_fn = function() {
526
+ const newFilteredOptions = [];
527
+ for (const option of this._slottedOptions ?? []) {
528
+ if (__privateGet(this, _suppressFilter) || this._inputValue === "") {
529
+ option.hidden = false;
530
+ option._matchedRange = null;
531
+ } else {
532
+ const matchIndex = option.text.toLowerCase().indexOf(this._inputValue.toLowerCase());
533
+ const matchedRange = matchIndex === -1 ? null : { from: matchIndex, to: matchIndex + this._inputValue.length };
534
+ option.hidden = !matchedRange;
535
+ option._matchedRange = matchedRange;
487
536
  }
537
+ if (!option.hidden) {
538
+ newFilteredOptions.push(option);
539
+ }
540
+ }
541
+ __privateMethod(this, _SearchableSelect_instances, transitionHighlightedOptionTo_fn).call(this, null);
542
+ this._filteredOptions = newFilteredOptions;
543
+ this._filteredEnabledOptions = newFilteredOptions.filter(
544
+ (option) => !option.disabled
545
+ );
546
+ };
547
+ transitionHighlightedOptionTo_fn = function(index) {
548
+ if (typeof this._highlightedOptionIndex === "number") {
549
+ this._filteredEnabledOptions[this._highlightedOptionIndex]._highlighted = false;
550
+ }
551
+ if (typeof index === "number") {
552
+ if (!this._filteredEnabledOptions.length) {
553
+ index = null;
554
+ } else {
555
+ index = Math.max(
556
+ 0,
557
+ Math.min(this._filteredEnabledOptions.length - 1, index)
558
+ );
559
+ }
560
+ }
561
+ this._highlightedOptionIndex = index;
562
+ if (typeof this._highlightedOptionIndex === "number") {
563
+ const highlightedOption = this._filteredEnabledOptions[this._highlightedOptionIndex];
564
+ highlightedOption._highlighted = true;
565
+ scrollIntoView.scrollIntoView(highlightedOption, this._listbox, "nearest");
566
+ }
567
+ };
568
+ selectHighlightedOption_fn = function() {
569
+ if (this._highlightedOptionIndex === null) {
570
+ return;
571
+ }
572
+ __privateMethod(this, _SearchableSelect_instances, handleOptionInteraction_fn).call(this, this._filteredEnabledOptions[this._highlightedOptionIndex]);
573
+ };
574
+ highlightFirstOption_fn = function() {
575
+ __privateMethod(this, _SearchableSelect_instances, transitionHighlightedOptionTo_fn).call(this, 0);
576
+ };
577
+ highlightLastOption_fn = function() {
578
+ __privateMethod(this, _SearchableSelect_instances, transitionHighlightedOptionTo_fn).call(this, this._filteredEnabledOptions.length - 1);
579
+ };
580
+ highlightPrevPage_fn = function() {
581
+ __privateMethod(this, _SearchableSelect_instances, transitionHighlightedOptionTo_fn).call(this, (this._highlightedOptionIndex ?? this._filteredEnabledOptions.length) - PageSize);
582
+ };
583
+ highlightNextPage_fn = function() {
584
+ __privateMethod(this, _SearchableSelect_instances, transitionHighlightedOptionTo_fn).call(this, (this._highlightedOptionIndex ?? -1) + PageSize);
585
+ };
586
+ highlightPreviousOption_fn = function() {
587
+ __privateMethod(this, _SearchableSelect_instances, transitionHighlightedOptionTo_fn).call(this, (this._highlightedOptionIndex ?? this._filteredEnabledOptions.length) - 1);
588
+ };
589
+ highlightNextOption_fn = function() {
590
+ __privateMethod(this, _SearchableSelect_instances, transitionHighlightedOptionTo_fn).call(this, (this._highlightedOptionIndex ?? -1) + 1);
591
+ };
592
+ textForValue_fn = function(value) {
593
+ const option = this._slottedOptions.find(
594
+ (option2) => option2.value === value
595
+ );
596
+ return option.text;
488
597
  };
489
- index.__decorate([
490
- index.attr({ attribute: "open", mode: "boolean" })
491
- ], Select$1.prototype, "open", void 0);
492
- index.__decorate([
493
- index.volatile
494
- ], Select$1.prototype, "collapsible", null);
495
- index.__decorate([
496
- index.observable
497
- ], Select$1.prototype, "control", void 0);
498
- index.__decorate([
499
- index.attr({ attribute: "position" })
500
- ], Select$1.prototype, "positionAttribute", void 0);
501
- index.__decorate([
502
- index.observable
503
- ], Select$1.prototype, "position", void 0);
504
- index.__decorate([
505
- index.observable
506
- ], Select$1.prototype, "maxHeight", void 0);
507
598
  /**
508
- * Includes ARIA states and properties relating to the ARIA select role.
509
- *
510
- * @public
599
+ * @internal
511
600
  */
512
- class DelegatesARIASelect {
513
- }
514
- index.__decorate([
515
- index.observable
516
- ], DelegatesARIASelect.prototype, "ariaControls", void 0);
517
- applyMixins.applyMixins(DelegatesARIASelect, listbox.DelegatesARIAListbox);
518
- applyMixins.applyMixins(Select$1, startEnd.StartEnd, DelegatesARIASelect);
519
-
520
- 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{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{display:flex;align-items:center;justify-content:space-between;border-radius:var(--_select-control-border-radius);background-color:var(--_appearance-color-fill);block-size:calc(1px*(40 + 4*clamp(-1,var(--vvd-size-density, 0),2)));box-shadow:inset 0 0 0 1px var(--_appearance-color-outline);color:var(--_appearance-color-text);font:var(--vvd-typography-base);gap:8px;padding-inline:16px;transition:box-shadow .2s,background-color .2s}.control{--_appearance-color-text: var(--vvd-color-canvas-text);--_appearance-color-fill: var(--vvd-color-canvas);--_appearance-color-outline: var(--_connotation-color-intermediate)}.control.appearance-ghost{--_appearance-color-text: var(--_connotation-color-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-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 20px;font-size:20px;line-height:1}.control.has-meta .selected-value{padding-inline-end:8px}.feedback-wrapper{display:contents}::part(popup-base){inline-size:max-content;min-inline-size:var(--_select-fixed-width, 100%)}:host([multiple]) ::part(popup-base){position:static}";
521
-
522
- var __defProp = Object.defineProperty;
523
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
524
- var __decorateClass = (decorators, target, key, kind) => {
525
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
526
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
527
- if (decorator = decorators[i])
528
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
529
- if (kind && result) __defProp(target, key, result);
530
- return result;
601
+ measureTagWidth_fn = function(label, removable, hasIcon) {
602
+ const tag = document.createElement(this._optionTagTagName);
603
+ tag.label = label;
604
+ tag.removable = removable;
605
+ tag.style.cssText = "position: absolute; visibility: hidden;";
606
+ tag.hasIconPlaceholder = hasIcon;
607
+ this.shadowRoot.appendChild(tag);
608
+ const width = tag.getBoundingClientRect().width;
609
+ tag.remove();
610
+ return width;
531
611
  };
532
- let Select = class extends Select$1 {
533
- constructor() {
534
- super(...arguments);
535
- this.fixedDropdown = false;
536
- this.placeholderOption = null;
537
- this._feedbackWrapper = null;
612
+ updateTagLayout_fn = function() {
613
+ if (!this.multiple) {
614
+ this._numEllidedTags = 0;
615
+ this._tagRows = [];
616
+ this._lastTagRow = [];
617
+ return;
538
618
  }
539
- connectedCallback() {
540
- super.connectedCallback();
619
+ if (this.externalTags) {
620
+ this._numEllidedTags = this.values.length;
621
+ this._tagRows = [];
622
+ this._lastTagRow = [];
623
+ return;
541
624
  }
542
- get displayValue() {
543
- index.Observable.track(this, "displayValue");
544
- return this.firstSelectedOption?.getAttribute("label") ?? this.firstSelectedOption?.text ?? this.placeholder ?? "";
625
+ const rowWidth = this._contentArea.getBoundingClientRect().width;
626
+ const rows = [[]];
627
+ let currentRowIndex = 0;
628
+ let currentRowWidth = InputMinWidthPx;
629
+ let i;
630
+ for (i = this.values.length - 1; i >= 0; i--) {
631
+ const isLastRow = this.maxLines && currentRowIndex === this.maxLines - 1;
632
+ 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);
633
+ const entry = {
634
+ value: this.values[i],
635
+ width: tagWidth
636
+ };
637
+ let elidedTagCounterWidth = 0;
638
+ if (isLastRow) {
639
+ const numElidedTags = i;
640
+ if (numElidedTags) {
641
+ elidedTagCounterWidth = TagGapPx + __privateMethod(this, _SearchableSelect_instances, measureTagWidth_fn).call(this, numElidedTags.toString(), false, false);
642
+ }
643
+ }
644
+ const totalWidthNeeded = currentRowWidth + TagGapPx + tagWidth + elidedTagCounterWidth;
645
+ if (totalWidthNeeded > rowWidth) {
646
+ if (isLastRow) {
647
+ if (i === this.values.length - 1) {
648
+ rows[currentRowIndex].unshift(entry);
649
+ currentRowWidth += TagGapPx + tagWidth;
650
+ } else {
651
+ break;
652
+ }
653
+ } else {
654
+ rows.push([]);
655
+ currentRowIndex++;
656
+ rows[currentRowIndex].unshift(entry);
657
+ currentRowWidth = tagWidth;
658
+ }
659
+ continue;
660
+ }
661
+ rows[currentRowIndex].unshift(entry);
662
+ currentRowWidth += TagGapPx + tagWidth;
545
663
  }
546
- setDefaultSelectedOption() {
547
- const options = Array.from(this.children).filter(
548
- listbox.Listbox.slottedOptionFilter
549
- );
550
- const selectedIndex = options.findIndex(
551
- (el) => el.hasAttribute("selected") || el.selected || el.value === this.value
552
- );
553
- if (selectedIndex === -1 && !this.placeholderOption) {
554
- this.selectedIndex = 0;
555
- return;
664
+ this._numEllidedTags = i + 1;
665
+ rows.reverse();
666
+ for (let i2 = 0; i2 < rows.length - 1; i2++) {
667
+ let lineWidth = rows[i2].map((e) => e.width).reduce((a, b) => a + b, 0) + (rows[i2].length - 1) * TagGapPx;
668
+ if (i2 === 0 && this._numEllidedTags) {
669
+ lineWidth += TagGapPx + __privateMethod(this, _SearchableSelect_instances, measureTagWidth_fn).call(this, this._numEllidedTags.toString(), false, false);
556
670
  }
557
- if (selectedIndex !== -1 || this.placeholder !== "") {
558
- this.selectedIndex = selectedIndex;
559
- return;
671
+ while (rows[i2 + 1].length && lineWidth + TagGapPx + rows[i2 + 1][0].width <= rowWidth) {
672
+ const nextTag = rows[i2 + 1].shift();
673
+ rows[i2].push(nextTag);
674
+ lineWidth += TagGapPx + nextTag.width;
560
675
  }
561
676
  }
562
- /*
563
- * @internal
564
- */
565
- slottedOptionsChanged(prev, next) {
566
- super.slottedOptionsChanged(prev, next);
567
- this.proxy.value = this.value;
568
- this.validate();
677
+ const rowValues = rows.map((line) => line.map((entry) => entry.value));
678
+ this._tagRows = rowValues.slice(0, -1);
679
+ this._lastTagRow = rowValues.slice(-1)[0];
680
+ };
681
+ moveTagFocusTo_fn = function(index) {
682
+ if (index === null) {
683
+ this._input.focus();
684
+ } else {
685
+ this.shadowRoot.querySelector(`[data-index="${index}"]`).focus();
569
686
  }
570
- formResetCallback() {
571
- super.formResetCallback();
572
- if (this.placeholder) {
573
- this.selectedIndex = -1;
687
+ };
688
+ nextTagIndexLeft_fn = function(index) {
689
+ if (!this.values.length) {
690
+ return null;
691
+ }
692
+ for (let i = index - 1; i >= 0; i--) {
693
+ if (!this._isTagDisabled(this.values[i])) {
694
+ return i;
574
695
  }
575
696
  }
697
+ return null;
576
698
  };
577
- __decorateClass([
578
- index.observable
579
- ], Select.prototype, "_anchor", 2);
580
- __decorateClass([
699
+ nextTagIndexRight_fn = function(index) {
700
+ if (!this.values.length) {
701
+ return null;
702
+ }
703
+ for (let i = index + 1; i < this.values.length; i++) {
704
+ if (!this._isTagDisabled(this.values[i])) {
705
+ return i;
706
+ }
707
+ }
708
+ return null;
709
+ };
710
+ nextTagIndexForRemoved_fn = function(index) {
711
+ return __privateMethod(this, _SearchableSelect_instances, nextTagIndexRight_fn).call(this, index - 1) ?? __privateMethod(this, _SearchableSelect_instances, nextTagIndexLeft_fn).call(this, index);
712
+ };
713
+ // --- Form handling ---
714
+ determineInitialValues_fn = function() {
715
+ return this.initialValues.length ? this.initialValues : this.initialValue ? [this.initialValue] : [];
716
+ };
717
+ updateFormValue_fn = function() {
718
+ if (!this.name) {
719
+ this.setFormValue(null);
720
+ } else {
721
+ const formData = new FormData();
722
+ for (const value of this.values) {
723
+ formData.append(this.name, value);
724
+ }
725
+ this.setFormValue(formData);
726
+ }
727
+ };
728
+ _resizeObserver = new WeakMap();
729
+ __decorateClass$1([
581
730
  index.attr
582
- ], Select.prototype, "appearance", 2);
583
- __decorateClass([
731
+ ], SearchableSelect.prototype, "appearance", 2);
732
+ __decorateClass$1([
584
733
  index.attr
585
- ], Select.prototype, "shape", 2);
586
- __decorateClass([
734
+ ], SearchableSelect.prototype, "shape", 2);
735
+ __decorateClass$1([
587
736
  index.attr({ mode: "boolean", attribute: "fixed-dropdown" })
588
- ], Select.prototype, "fixedDropdown", 2);
589
- __decorateClass([
737
+ ], SearchableSelect.prototype, "fixedDropdown", 2);
738
+ __decorateClass$1([
590
739
  index.attr
591
- ], Select.prototype, "placeholder", 2);
592
- __decorateClass([
740
+ ], SearchableSelect.prototype, "placeholder", 2);
741
+ __decorateClass$1([
742
+ index.attr({ mode: "boolean" })
743
+ ], SearchableSelect.prototype, "open", 2);
744
+ __decorateClass$1([
745
+ index.attr({ mode: "boolean" })
746
+ ], SearchableSelect.prototype, "multiple", 2);
747
+ __decorateClass$1([
748
+ index.attr({ attribute: "external-tags", mode: "boolean" })
749
+ ], SearchableSelect.prototype, "externalTags", 2);
750
+ __decorateClass$1([
751
+ index.attr({ attribute: "max-lines", converter: index.nullableNumberConverter })
752
+ ], SearchableSelect.prototype, "maxLines", 2);
753
+ __decorateClass$1([
593
754
  index.observable
594
- ], Select.prototype, "placeholderOption", 2);
595
- __decorateClass([
755
+ ], SearchableSelect.prototype, "values", 2);
756
+ __decorateClass$1([
596
757
  index.observable
597
- ], Select.prototype, "_feedbackWrapper", 2);
598
- __decorateClass([
758
+ ], SearchableSelect.prototype, "initialValues", 2);
759
+ __decorateClass$1([
760
+ index.observable
761
+ ], SearchableSelect.prototype, "_input", 2);
762
+ __decorateClass$1([
599
763
  index.observable
600
- ], Select.prototype, "metaSlottedContent", 2);
601
- Select = __decorateClass([
602
- index$1.errorText,
603
- index$1.formElements
604
- ], Select);
764
+ ], SearchableSelect.prototype, "_inputValue", 2);
765
+ __decorateClass$1([
766
+ index.observable
767
+ ], SearchableSelect.prototype, "_slottedOptions", 2);
768
+ __decorateClass$1([
769
+ index.observable
770
+ ], SearchableSelect.prototype, "_filteredOptions", 2);
771
+ __decorateClass$1([
772
+ index.observable
773
+ ], SearchableSelect.prototype, "_filteredEnabledOptions", 2);
774
+ __decorateClass$1([
775
+ index.observable
776
+ ], SearchableSelect.prototype, "_contentArea", 2);
777
+ __decorateClass$1([
778
+ index.observable
779
+ ], SearchableSelect.prototype, "_numEllidedTags", 2);
780
+ __decorateClass$1([
781
+ index.observable
782
+ ], SearchableSelect.prototype, "_tagRows", 2);
783
+ __decorateClass$1([
784
+ index.observable
785
+ ], SearchableSelect.prototype, "_lastTagRow", 2);
786
+ __decorateClass$1([
787
+ index.observable
788
+ ], SearchableSelect.prototype, "_listbox", 2);
789
+ __decorateClass$1([
790
+ index.attr({ mode: "boolean" })
791
+ ], SearchableSelect.prototype, "clearable", 2);
792
+ __decorateClass$1([
793
+ index.observable
794
+ ], SearchableSelect.prototype, "_anchor", 2);
795
+ SearchableSelect = __decorateClass$1([
796
+ formElements.errorText,
797
+ formElements.formElements
798
+ ], SearchableSelect);
605
799
  applyMixinsWithObservables.applyMixinsWithObservables(
606
- Select,
800
+ SearchableSelect,
607
801
  affix.AffixIconWithTrailing,
608
- index$1.FormElementHelperText,
609
- index$1.FormElementSuccessText
802
+ formElements.FormElementHelperText,
803
+ formElements.FormElementSuccessText,
804
+ localized.Localized
610
805
  );
611
806
 
612
- const getStateClasses = ({
613
- shape,
614
- disabled,
615
- appearance,
616
- metaSlottedContent,
617
- errorValidationMessage,
618
- successText,
619
- placeholder,
620
- value
621
- }) => classNames.classNames(
622
- ["disabled", disabled],
623
- [`appearance-${appearance}`, Boolean(appearance)],
624
- [`shape-${shape}`, Boolean(shape)],
625
- ["has-meta", Boolean(metaSlottedContent?.length)],
626
- ["error", Boolean(errorValidationMessage)],
627
- ["success", !!successText],
628
- ["has-meta", Boolean(metaSlottedContent?.length)],
629
- ["shows-placeholder", Boolean(placeholder) && !value]
807
+ var __defProp = Object.defineProperty;
808
+ var __decorateClass = (decorators, target, key, kind) => {
809
+ var result = void 0 ;
810
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
811
+ if (decorator = decorators[i])
812
+ result = (decorator(target, key, result) ) || result;
813
+ if (result) __defProp(target, key, result);
814
+ return result;
815
+ };
816
+ class OptionTag extends index.FoundationElement {
817
+ constructor() {
818
+ super(...arguments);
819
+ this.removable = false;
820
+ this.disabled = false;
821
+ this.hasIconPlaceholder = false;
822
+ }
823
+ _onClickRemove() {
824
+ this.$emit("remove", void 0, {
825
+ bubbles: false
826
+ });
827
+ }
828
+ }
829
+ __decorateClass([
830
+ index.attr
831
+ ], OptionTag.prototype, "shape");
832
+ __decorateClass([
833
+ index.attr
834
+ ], OptionTag.prototype, "label");
835
+ __decorateClass([
836
+ index.attr({ mode: "boolean" })
837
+ ], OptionTag.prototype, "removable");
838
+ __decorateClass([
839
+ index.attr({ mode: "boolean" })
840
+ ], OptionTag.prototype, "disabled");
841
+ __decorateClass([
842
+ index.observable
843
+ ], OptionTag.prototype, "hasIconPlaceholder");
844
+ applyMixins.applyMixins(OptionTag, localized.Localized);
845
+
846
+ const getStateClasses = (x) => classNames.classNames(
847
+ ["disabled", x.disabled],
848
+ [`appearance-${x.appearance}`, Boolean(x.appearance)],
849
+ [`shape-${x.shape}`, Boolean(x.shape)],
850
+ ["error", Boolean(x.errorValidationMessage)],
851
+ ["success", !!x.successText]
630
852
  );
631
853
  function renderLabel() {
632
- return index.html` <label for="control" class="label" id="label">
633
- ${(x) => x.label}
634
- </label>`;
635
- }
636
- function renderPlaceholder(context) {
637
- const optionTag = context.tagFor(definition$1.ListboxOption);
638
854
  return index.html`
639
- <${optionTag} ${ref.ref("placeholderOption")}
640
- text="${(x) => x.placeholder}" hidden disabled>
641
- </${optionTag}>`;
855
+ <label for="control" class="label" id="label"> ${(x) => x.label} </label>
856
+ `;
642
857
  }
643
- function selectValue(context) {
858
+ const tagTemplateFactory = (context, getComponent) => {
859
+ const optionTagTag = context.tagFor(OptionTag);
860
+ return index.html`
861
+ <div class="tag-wrapper">
862
+ <${optionTagTag}
863
+ class="tag"
864
+ tabindex="-1"
865
+ data-index="${(x, c) => getComponent(c).values.indexOf(x)}"
866
+ removable
867
+ :label="${(x, c) => getComponent(c)._tagLabelForValue(x)}"
868
+ :shape="${(_, c) => getComponent(c).shape}"
869
+ ?disabled="${(x, c) => getComponent(c)._isTagDisabled(x)}"
870
+ @remove="${(x, c) => getComponent(c)._onTagRemoved(x)}"
871
+ @keydown="${(_, c) => getComponent(c)._onTagKeydown(c.event)}"
872
+ @mousedown="${() => false}">
873
+ <slot slot="icon" name="${(x, c) => getComponent(c)._tagIconSlotName(x)}"></slot>
874
+ </${optionTagTag}>
875
+ </div>
876
+ `;
877
+ };
878
+ const ellidedTagTemplateFactory = (context, getComponent) => {
879
+ const optionTagTag = context.tagFor(OptionTag);
880
+ return index.html`
881
+ <${optionTagTag}
882
+ class="tag"
883
+ tabindex="-1"
884
+ :label="${(x, c) => getComponent(x, c)._numEllidedTags.toString()}"
885
+ :shape="${(x, c) => getComponent(x, c).shape}"
886
+ ?disabled="${(x, c) => getComponent(x, c).disabled}"
887
+ @mousedown="${() => false}">
888
+ </${optionTagTag}>
889
+ `;
890
+ };
891
+ function renderFieldset(context) {
892
+ const buttonTag = context.tagFor(button.Button);
644
893
  const affixIconTemplate = affix.affixIconTemplateFactory(context);
645
- const chevronTemplate = definition$2.chevronTemplateFactory(context);
646
- return index.html` <div
647
- class="control ${getStateClasses}"
648
- ${ref.ref("_anchor")}
649
- id="control"
650
- ?disabled="${(x) => x.disabled}"
651
- >
652
- <div class="selected-value">
894
+ const chevronTemplate = definition$1.chevronTemplateFactory(context);
895
+ const tagTemplate = tagTemplateFactory(context, (c) => c.parent);
896
+ const nestedTagTemplate = tagTemplateFactory(
897
+ context,
898
+ (c) => c.parentContext.parent
899
+ );
900
+ const ellidedTagTemplate = ellidedTagTemplateFactory(context, (x, _) => x);
901
+ const nestedEllidedTagTemplate = ellidedTagTemplateFactory(
902
+ context,
903
+ (_, c) => c.parent
904
+ );
905
+ return index.html`
906
+ <div
907
+ class="fieldset ${getStateClasses}"
908
+ @click="${(x, c) => x._onFieldsetClick(c.event)}"
909
+ ${ref.ref("_anchor")}
910
+ >
653
911
  ${(x) => affixIconTemplate(x.icon, affix.IconWrapper.Slot)}
654
- <span class="text">${(x) => x.displayValue}</span>
655
- <slot name="meta" ${slotted.slotted("metaSlottedContent")}></slot>
912
+ <div class="content-area" ${ref.ref("_contentArea")}>
913
+ ${repeat.repeat(
914
+ (x) => x._tagRows,
915
+ index.html`
916
+ <div class="tag-row">
917
+ ${when.when(
918
+ (_, c) => c.isFirst && c.parent._numEllidedTags,
919
+ nestedEllidedTagTemplate
920
+ )}
921
+ ${repeat.repeat((x) => x, nestedTagTemplate)}
922
+ </div>
923
+ `,
924
+ { positioning: true }
925
+ )}
926
+ <div
927
+ class="tag-row ${(x) => classNames.classNames([
928
+ "contains-only-input",
929
+ x._tagRows.length > 0 && x._lastTagRow.length === 0
930
+ ])}"
931
+ >
932
+ ${when.when(
933
+ (x) => x._tagRows.length === 0 && x._numEllidedTags,
934
+ ellidedTagTemplate
935
+ )}
936
+ ${repeat.repeat((x) => x._lastTagRow, tagTemplate)}
937
+ <input
938
+ id="control"
939
+ class="control"
940
+ autofocus
941
+ autocomplete="off"
942
+ aria-autocomplete="${(x) => x.ariaAutoComplete}"
943
+ aria-disabled="${(x) => x.ariaDisabled}"
944
+ aria-expanded="${(x) => x.ariaExpanded}"
945
+ aria-haspopup="listbox"
946
+ placeholder="${(x) => x.multiple && x.values.length ? "" : x.placeholder}"
947
+ role="combobox"
948
+ type="text"
949
+ ?disabled="${(x) => x.disabled}"
950
+ :value="${(x) => x._inputValue}"
951
+ @input="${(x, c) => x._onInputInput(c.event)}"
952
+ @focus="${(x, c) => x._onInputFocus(c.event)}"
953
+ @blur="${(x, c) => x._onInputBlur(c.event)}"
954
+ @keydown="${(x, c) => x._onInputKeydown(c.event)}"
955
+ ${ref.ref("_input")}
956
+ />
957
+ </div>
958
+ </div>
959
+ <slot name="meta"></slot>
960
+ ${when.when(
961
+ (x) => x._shouldShowClearButton,
962
+ index.html`<${buttonTag}
963
+ aria-label="${(x) => x.locale.searchableSelect.clearButtonLabel}"
964
+ @click="${(x) => x._onClearButtonClick()}"
965
+ @mousedown="${() => false}"
966
+ ?disabled="${(x) => x.disabled}"
967
+ :shape="${(x) => x.shape}"
968
+ size="super-condensed"
969
+ icon="close-line"
970
+ variant="ghost"
971
+ tabindex="-1"
972
+ ></${buttonTag}>`
973
+ )}
974
+ ${chevronTemplate}
656
975
  </div>
657
- ${chevronTemplate}
658
- </div>`;
659
- }
660
- function setFixedDropdownVarWidth(x) {
661
- return x.open && x.fixedDropdown ? `--_select-fixed-width: ${Math.round(x.getBoundingClientRect().width)}px` : null;
976
+ `;
662
977
  }
663
978
  function renderControl(context) {
664
979
  const popupTag = context.tagFor(definition.Popup);
665
980
  return index.html`
666
- ${when.when((x) => x.label, renderLabel())}
667
- <div class="control-wrapper">
668
- ${when.when((x) => !x.multiple, selectValue(context))}
669
- <${popupTag} class="popup"
670
- style="${setFixedDropdownVarWidth}"
671
- ?open="${(x) => x.collapsible ? x.open : true}"
981
+ ${when.when((x) => x.label, renderLabel())}
982
+ <div>
983
+ ${renderFieldset(context)}
984
+ <div class="popup-wrapper">
985
+ <${popupTag}
672
986
  :anchor="${(x) => x._anchor}"
987
+ :open="${(x) => x.open}"
988
+ class="popup"
673
989
  placement="bottom-start"
674
- strategy="${(x) => x.fixedDropdown ? null : "absolute"}">
675
- <div class="listbox"
676
- id="${(x) => x.listboxId}"
990
+ strategy="${(x) => x.fixedDropdown ? "fixed" : "absolute"}">
991
+ <div
992
+ class="listbox"
677
993
  role="listbox"
678
- ?disabled="${(x) => x.disabled}"
679
- ?hidden="${(x) => x.collapsible ? !x.open : false}"
680
- ${ref.ref("listbox")}>
681
- ${when.when((x) => x.placeholder, renderPlaceholder(context))}
994
+ ${ref.ref("_listbox")}
995
+ @click="${(x, c) => x._onListboxClick(c.event)}"
996
+ @mousedown="${() => false}"
997
+ >
682
998
  <slot
683
999
  ${slotted.slotted({
684
1000
  filter: listbox.Listbox.slottedOptionFilter,
685
1001
  flatten: true,
686
- property: "slottedOptions"
1002
+ property: "_slottedOptions"
687
1003
  })}>
688
1004
  </slot>
689
- </div>
1005
+ ${when.when(
1006
+ (x) => x._filteredOptions.length === 0,
1007
+ index.html`<div class="empty-message">
1008
+ ${when.when(
1009
+ (x) => x._inputValue === "",
1010
+ index.html`<slot name="no-options">
1011
+ ${(x) => x.locale.searchableSelect.noOptionsMessage}
1012
+ </slot>`
1013
+ )}
1014
+ ${when.when(
1015
+ (x) => x._inputValue !== "",
1016
+ index.html`<slot name="no-matches">
1017
+ ${(x) => x.locale.searchableSelect.noMatchesMessage}
1018
+ </slot>`
1019
+ )}
1020
+ </div>`
1021
+ )}
1022
+ </div>
690
1023
  </${popupTag}>
691
1024
  </div>
692
- `;
693
- }
694
- function ifNotFromFeedback(handler) {
695
- return (x, c) => {
696
- if (!c.event.composedPath().includes(x._feedbackWrapper)) {
697
- return handler(x, c.event);
698
- }
699
- return true;
700
- };
1025
+ </div>
1026
+ `;
701
1027
  }
702
- const SelectTemplate = (context) => {
1028
+ const SearchableSelectTemplate = (context) => {
1029
+ const optionTagTag = context.tagFor(OptionTag);
703
1030
  return index.html`
704
- <template
705
- class="base"
706
- aria-label="${(x) => x.ariaLabel}"
707
- aria-activedescendant="${(x) => x.ariaActiveDescendant}"
708
- aria-controls="${(x) => x.ariaControls}"
709
- aria-disabled="${(x) => x.ariaDisabled}"
710
- aria-expanded="${(x) => x.ariaExpanded}"
711
- aria-haspopup="${(x) => x.collapsible ? "listbox" : null}"
712
- aria-multiselectable="${(x) => x.ariaMultiSelectable}"
713
- role="combobox"
714
- tabindex="${(x) => !x.disabled ? "0" : null}"
715
- @click="${ifNotFromFeedback((x, e) => x.clickHandler(e))}"
716
- @focusin="${ifNotFromFeedback((x, e) => x.focusinHandler(e))}"
717
- @focusout="${ifNotFromFeedback(
718
- (x, e) => x.focusoutHandler(e)
719
- )}"
720
- @keydown="${ifNotFromFeedback(
721
- (x, e) => x.keydownHandler(e)
722
- )}"
723
- @mousedown="${ifNotFromFeedback(
724
- (x, e) => x.mousedownHandler(e)
725
- )}"
726
- >
727
- ${renderControl(context)}
728
- <div class="feedback-wrapper" ${ref.ref("_feedbackWrapper")}>
729
- ${index$1.getFeedbackTemplate(context)}
1031
+ <template :_optionTagTagName="${() => optionTagTag}">
1032
+ <div class="control-wrapper">
1033
+ ${renderControl(context)} ${formElements.getFeedbackTemplate(context)}
730
1034
  </div>
731
1035
  </template>
732
1036
  `;
733
1037
  };
734
1038
 
735
- const selectDefinition = Select.compose({
736
- baseName: "select",
737
- template: SelectTemplate,
738
- styles
1039
+ const getClasses = ({ shape, disabled, removable }) => classNames.classNames(
1040
+ "base",
1041
+ ["disabled", disabled],
1042
+ ["removable", removable],
1043
+ [`shape-${shape}`, Boolean(shape)]
1044
+ );
1045
+ function renderRemoveButton(iconTag) {
1046
+ return index.html`
1047
+ <span
1048
+ class="remove-button"
1049
+ aria-label="${(x) => x.locale.searchableSelect.removeTagButtonLabel(x.label)}"
1050
+ role="button"
1051
+ tabindex="${(x) => x.disabled ? null : 0}"
1052
+ @click="${(x) => x._onClickRemove()}"
1053
+ >
1054
+ <${iconTag} name="close-line"></${iconTag}>
1055
+ </span>
1056
+ `;
1057
+ }
1058
+ const optionTagTemplate = (context) => {
1059
+ const iconTag = context.tagFor(icon.Icon);
1060
+ return index.html`<span class="${getClasses}" aria-disabled="${(x) => x.disabled}">
1061
+ <slot name="icon" aria-hidden="true">
1062
+ ${when.when(
1063
+ (x) => x.hasIconPlaceholder,
1064
+ index.html`<div class="icon-placeholder"></div>`
1065
+ )}
1066
+ </slot>
1067
+ ${when.when(
1068
+ (x) => x.label,
1069
+ (x) => index.html`<span class="label">${x.label}</span>`
1070
+ )}
1071
+ ${when.when((x) => x.removable, renderRemoveButton(iconTag))}
1072
+ </span>`;
1073
+ };
1074
+
1075
+ const optionTagDefinition = OptionTag.compose({
1076
+ baseName: "option-tag",
1077
+ template: optionTagTemplate,
1078
+ styles: [optionTagStyles],
1079
+ shadowOptions: {
1080
+ delegatesFocus: true
1081
+ }
739
1082
  });
740
- const selectRegistries = [
741
- selectDefinition(),
1083
+ const searchableSelectDefinition = SearchableSelect.compose({
1084
+ baseName: "searchable-select",
1085
+ template: SearchableSelectTemplate,
1086
+ styles: [styles],
1087
+ shadowOptions: {
1088
+ delegatesFocus: true
1089
+ }
1090
+ });
1091
+ const searchableSelectRegistries = [
1092
+ ...definition$1.buttonRegistries,
742
1093
  ...definition.popupRegistries,
743
- ...definition$3.iconRegistries,
744
- ...definition$1.listboxOptionRegistries
1094
+ ...definition$2.iconRegistries,
1095
+ optionTagDefinition(),
1096
+ searchableSelectDefinition()
745
1097
  ];
746
- const registerSelect = index.registerFactory(selectRegistries);
1098
+ const registerSearchableSelect = index.registerFactory(
1099
+ searchableSelectRegistries
1100
+ );
747
1101
 
748
- exports.registerSelect = registerSelect;
749
- exports.selectDefinition = selectDefinition;
750
- exports.selectRegistries = selectRegistries;
1102
+ exports.optionTagDefinition = optionTagDefinition;
1103
+ exports.registerSearchableSelect = registerSearchableSelect;
1104
+ exports.searchableSelectDefinition = searchableSelectDefinition;
1105
+ exports.searchableSelectRegistries = searchableSelectRegistries;