@vonage/vivid 4.5.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 (170) hide show
  1. package/custom-elements.json +1091 -187
  2. package/elevation/index.cjs +1 -1
  3. package/elevation/index.js +1 -1
  4. package/index.cjs +62 -56
  5. package/index.js +20 -19
  6. package/lib/components.d.ts +1 -0
  7. package/lib/menu/menu.d.ts +2 -1
  8. package/lib/number-field/number-field.d.ts +3 -1
  9. package/lib/searchable-select/definition.d.ts +4 -0
  10. package/lib/searchable-select/locale.d.ts +6 -0
  11. package/lib/searchable-select/option-tag.d.ts +14 -0
  12. package/lib/searchable-select/option-tag.template.d.ts +4 -0
  13. package/lib/searchable-select/searchable-select.d.ts +29 -0
  14. package/lib/searchable-select/searchable-select.form-associated.d.ts +10 -0
  15. package/lib/searchable-select/searchable-select.template.d.ts +4 -0
  16. package/lib/select/select.d.ts +3 -1
  17. package/lib/tab/locale.d.ts +3 -0
  18. package/lib/tab/tab.d.ts +5 -1
  19. package/lib/tag/definition.d.ts +1 -0
  20. package/lib/text-field/text-field.d.ts +3 -1
  21. package/locales/de-DE.cjs +12 -0
  22. package/locales/de-DE.js +12 -0
  23. package/locales/en-GB.cjs +12 -0
  24. package/locales/en-GB.js +12 -0
  25. package/locales/en-US.cjs +12 -0
  26. package/locales/en-US.js +12 -0
  27. package/locales/ja-JP.cjs +12 -0
  28. package/locales/ja-JP.js +12 -0
  29. package/locales/zh-CN.cjs +12 -0
  30. package/locales/zh-CN.js +12 -0
  31. package/package.json +1 -1
  32. package/popup/index.cjs +1 -1
  33. package/popup/index.js +1 -1
  34. package/searchable-select/index.cjs +5 -0
  35. package/searchable-select/index.js +3 -0
  36. package/select/index.cjs +1 -1
  37. package/select/index.js +1 -1
  38. package/selectable-box/index.cjs +1 -1
  39. package/selectable-box/index.js +1 -1
  40. package/shared/definition11.cjs +1 -1
  41. package/shared/definition11.js +1 -1
  42. package/shared/definition14.cjs +1 -1
  43. package/shared/definition14.js +1 -1
  44. package/shared/definition16.cjs +1 -1
  45. package/shared/definition16.js +1 -1
  46. package/shared/definition18.cjs +2 -2
  47. package/shared/definition18.js +2 -2
  48. package/shared/definition19.cjs +2 -2
  49. package/shared/definition19.js +2 -2
  50. package/shared/definition20.cjs +14 -34
  51. package/shared/definition20.js +14 -34
  52. package/shared/definition21.cjs +1 -1
  53. package/shared/definition21.js +1 -1
  54. package/shared/definition26.cjs +1 -1
  55. package/shared/definition26.js +1 -1
  56. package/shared/definition29.cjs +4 -0
  57. package/shared/definition29.js +4 -0
  58. package/shared/definition30.cjs +2 -1
  59. package/shared/definition30.js +2 -1
  60. package/shared/definition35.cjs +12 -7
  61. package/shared/definition35.js +12 -7
  62. package/shared/definition36.cjs +50 -207
  63. package/shared/definition36.js +51 -207
  64. package/shared/definition4.cjs +1 -1
  65. package/shared/definition4.js +1 -1
  66. package/shared/definition42.cjs +1 -1
  67. package/shared/definition42.js +1 -1
  68. package/shared/definition43.cjs +993 -645
  69. package/shared/definition43.js +989 -642
  70. package/shared/definition44.cjs +723 -112
  71. package/shared/definition44.js +722 -111
  72. package/shared/definition45.cjs +121 -80
  73. package/shared/definition45.js +119 -78
  74. package/shared/definition46.cjs +81 -614
  75. package/shared/definition46.js +80 -612
  76. package/shared/definition47.cjs +608 -114
  77. package/shared/definition47.js +606 -113
  78. package/shared/definition48.cjs +116 -134
  79. package/shared/definition48.js +115 -133
  80. package/shared/definition49.cjs +149 -19
  81. package/shared/definition49.js +148 -18
  82. package/shared/definition5.cjs +1 -1
  83. package/shared/definition5.js +1 -1
  84. package/shared/definition50.cjs +21 -82
  85. package/shared/definition50.js +20 -81
  86. package/shared/definition51.cjs +77 -539
  87. package/shared/definition51.js +76 -538
  88. package/shared/definition52.cjs +568 -28
  89. package/shared/definition52.js +567 -27
  90. package/shared/definition53.cjs +28 -123
  91. package/shared/definition53.js +26 -122
  92. package/shared/definition54.cjs +115 -295
  93. package/shared/definition54.js +114 -294
  94. package/shared/definition55.cjs +251 -311
  95. package/shared/definition55.js +251 -311
  96. package/shared/definition56.cjs +299 -780
  97. package/shared/definition56.js +298 -779
  98. package/shared/definition57.cjs +800 -102
  99. package/shared/definition57.js +799 -101
  100. package/shared/definition58.cjs +92 -63
  101. package/shared/definition58.js +91 -62
  102. package/shared/definition59.cjs +117 -75
  103. package/shared/definition59.js +116 -74
  104. package/shared/definition60.cjs +70 -285
  105. package/shared/definition60.js +71 -286
  106. package/shared/definition61.cjs +274 -66146
  107. package/shared/definition61.js +273 -66145
  108. package/shared/definition62.cjs +66160 -27
  109. package/shared/definition62.js +66158 -25
  110. package/shared/definition63.cjs +24 -1952
  111. package/shared/definition63.js +23 -1950
  112. package/shared/definition64.cjs +1976 -0
  113. package/shared/definition64.js +1971 -0
  114. package/shared/listbox-option.cjs +204 -0
  115. package/shared/listbox-option.js +201 -0
  116. package/shared/listbox.cjs +3 -3
  117. package/shared/listbox.js +1 -1
  118. package/shared/localization/Locale.d.ts +4 -0
  119. package/shared/presentationDate.cjs +2 -2
  120. package/shared/presentationDate.js +2 -2
  121. package/shared/scrollIntoView.cjs +51 -0
  122. package/shared/scrollIntoView.js +49 -0
  123. package/shared/slider.template.cjs +1 -1
  124. package/shared/slider.template.js +1 -1
  125. package/shared/text-field.cjs +1 -1
  126. package/shared/text-field.js +1 -1
  127. package/shared/utils/scrollIntoView.d.ts +1 -0
  128. package/side-drawer/index.cjs +1 -1
  129. package/side-drawer/index.js +1 -1
  130. package/slider/index.cjs +1 -1
  131. package/slider/index.js +1 -1
  132. package/split-button/index.cjs +1 -1
  133. package/split-button/index.js +1 -1
  134. package/styles/core/all.css +1 -1
  135. package/styles/core/theme.css +1 -1
  136. package/styles/core/typography.css +1 -1
  137. package/styles/tokens/theme-dark.css +4 -4
  138. package/styles/tokens/theme-light.css +4 -4
  139. package/styles/tokens/vivid-2-compat.css +1 -1
  140. package/switch/index.cjs +1 -1
  141. package/switch/index.js +1 -1
  142. package/tab/index.cjs +1 -1
  143. package/tab/index.js +1 -1
  144. package/tab-panel/index.cjs +1 -1
  145. package/tab-panel/index.js +1 -1
  146. package/tabs/index.cjs +1 -1
  147. package/tabs/index.js +1 -1
  148. package/tag/index.cjs +1 -1
  149. package/tag/index.js +1 -1
  150. package/tag-group/index.cjs +1 -1
  151. package/tag-group/index.js +1 -1
  152. package/text-area/index.cjs +1 -1
  153. package/text-area/index.js +1 -1
  154. package/text-field/index.cjs +1 -1
  155. package/text-field/index.js +1 -1
  156. package/time-picker/index.cjs +1 -1
  157. package/time-picker/index.js +1 -1
  158. package/toggletip/index.cjs +1 -1
  159. package/toggletip/index.js +1 -1
  160. package/tooltip/index.cjs +1 -1
  161. package/tooltip/index.js +1 -1
  162. package/tree-item/index.cjs +1 -1
  163. package/tree-item/index.js +1 -1
  164. package/tree-view/index.cjs +1 -1
  165. package/tree-view/index.js +1 -1
  166. package/video-player/index.cjs +1 -1
  167. package/video-player/index.js +1 -1
  168. package/vivid.api.json +295 -0
  169. package/api-extractor.json +0 -25
  170. package/tsdoc-metadata.json +0 -11
@@ -1,757 +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');
7
- const listbox = require('./listbox.cjs');
4
+ const definition$1 = require('./definition11.cjs');
5
+ const definition = require('./definition64.cjs');
6
+ const definition$2 = require('./definition27.cjs');
8
7
  const applyMixinsWithObservables = require('./applyMixinsWithObservables.cjs');
9
- const startEnd = require('./start-end.cjs');
10
- const applyMixins = require('./apply-mixins.cjs');
8
+ const scrollIntoView = require('./scrollIntoView.cjs');
11
9
  const formAssociated = require('./form-associated.cjs');
12
- const select_options = require('./select.options.cjs');
13
- const strings = require('./strings.cjs');
14
- const keyCodes = require('./key-codes.cjs');
15
10
  const affix = require('./affix.cjs');
16
11
  const formElements = require('./form-elements.cjs');
17
- const definition$2 = require('./definition11.cjs');
18
- const index$1 = require('./index2.cjs');
19
- const ref = require('./ref.cjs');
12
+ const localized = require('./localized.cjs');
13
+ const listbox = require('./listbox.cjs');
14
+ const applyMixins = require('./apply-mixins.cjs');
20
15
  const when = require('./when.cjs');
16
+ const ref = require('./ref.cjs');
21
17
  const slotted = require('./slotted.cjs');
18
+ const button = require('./button.cjs');
19
+ const repeat = require('./repeat.cjs');
22
20
  const classNames = require('./class-names.cjs');
21
+ const icon = require('./icon.cjs');
23
22
 
24
- 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 {
25
28
  }
26
- /**
27
- * A form-associated base class for the {@link @microsoft/fast-foundation#(Select:class)} component.
28
- *
29
- * @internal
30
- */
31
- class FormAssociatedSelect extends formAssociated.FormAssociated(_Select) {
32
- constructor() {
33
- super(...arguments);
34
- this.proxy = document.createElement("select");
35
- }
29
+ class FormAssociatedSearchableSelect extends formAssociated.FormAssociated(
30
+ _SearchableSelect
31
+ ) {
32
+ constructor() {
33
+ super(...arguments);
34
+ this.proxy = document.createElement("input");
35
+ }
36
36
  }
37
37
 
38
- /**
39
- * A Select Custom HTML Element.
40
- * Implements the {@link https://www.w3.org/TR/wai-aria-1.1/#select | ARIA select }.
41
- *
42
- * @slot start - Content which can be provided before the button content
43
- * @slot end - Content which can be provided after the button content
44
- * @slot button-container - The element representing the select button
45
- * @slot selected-value - The selected value
46
- * @slot indicator - The visual indicator for the expand/collapse state of the button
47
- * @slot - The default slot for slotted options
48
- * @csspart control - The element representing the select invoking element
49
- * @csspart selected-value - The element wrapping the selected value
50
- * @csspart indicator - The element wrapping the visual indicator
51
- * @csspart listbox - The listbox element
52
- * @fires input - Fires a custom 'input' event when the value updates
53
- * @fires change - Fires a custom 'change' event when the value updates
54
- *
55
- * @public
56
- */
57
- let Select$1 = class Select extends FormAssociatedSelect {
58
- constructor() {
59
- super(...arguments);
60
- /**
61
- * The open attribute.
62
- *
63
- * @public
64
- * @remarks
65
- * HTML Attribute: open
66
- */
67
- this.open = false;
68
- /**
69
- * Indicates the initial state of the position attribute.
70
- *
71
- * @internal
72
- */
73
- this.forcedPosition = false;
74
- /**
75
- * The unique id for the internal listbox element.
76
- *
77
- * @internal
78
- */
79
- this.listboxId = strings.uniqueId("listbox-");
80
- /**
81
- * The max height for the listbox when opened.
82
- *
83
- * @internal
84
- */
85
- this.maxHeight = 0;
86
- }
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 ---
87
74
  /**
88
- * Sets focus and synchronizes ARIA attributes when the open property changes.
89
- *
90
- * @param prev - the previous open value
91
- * @param next - the current open value
92
- *
93
75
  * @internal
94
76
  */
95
- openChanged(prev, next) {
96
- if (!this.collapsible) {
97
- return;
98
- }
99
- if (this.open) {
100
- this.ariaControls = this.listboxId;
101
- this.ariaExpanded = "true";
102
- this.setPositioning();
103
- this.focusAndScrollOptionIntoView();
104
- this.indexWhenOpened = this.selectedIndex;
105
- // focus is directed to the element when `open` is changed programmatically
106
- index.DOM.queueUpdate(() => this.focus());
107
- 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);
108
84
  }
109
- this.ariaControls = "";
110
- this.ariaExpanded = "false";
111
- }
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) ---
112
93
  /**
113
- * The component is collapsible when in single-selection mode with no size attribute.
114
- *
94
+ * Currently visually highlighted option as an index into _filteredEnabledOptions
115
95
  * @internal
116
96
  */
117
- get collapsible() {
118
- 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;
119
119
  }
120
- /**
121
- * The value property.
122
- *
123
- * @public
124
- */
125
- get value() {
126
- index.Observable.track(this, "value");
127
- return this._value;
128
- }
129
- set value(next) {
130
- var _a, _b, _c, _d, _e, _f, _g;
131
- const prev = `${this._value}`;
132
- if ((_a = this._options) === null || _a === void 0 ? void 0 : _a.length) {
133
- const selectedIndex = this._options.findIndex(el => el.value === next);
134
- const prevSelectedValue = (_c = (_b = this._options[this.selectedIndex]) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : null;
135
- const nextSelectedValue = (_e = (_d = this._options[selectedIndex]) === null || _d === void 0 ? void 0 : _d.value) !== null && _e !== void 0 ? _e : null;
136
- if (selectedIndex === -1 || prevSelectedValue !== nextSelectedValue) {
137
- next = "";
138
- this.selectedIndex = selectedIndex;
139
- }
140
- next = (_g = (_f = this.firstSelectedOption) === null || _f === void 0 ? void 0 : _f.value) !== null && _g !== void 0 ? _g : next;
141
- }
142
- if (prev !== next) {
143
- this._value = next;
144
- super.valueChanged(prev, next);
145
- index.Observable.notify(this, "value");
146
- this.updateDisplayValue();
147
- }
120
+ if (!this.multiple && this.values.length > 1) {
121
+ this.values = [this.values[0]];
122
+ return;
148
123
  }
149
- /**
150
- * Sets the value and display value to match the first selected option.
151
- *
152
- * @param shouldEmit - if true, the input and change events will be emitted
153
- *
154
- * @internal
155
- */
156
- updateValue(shouldEmit) {
157
- var _a, _b;
158
- if (this.$fastController.isConnected) {
159
- this.value = (_b = (_a = this.firstSelectedOption) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : "";
160
- }
161
- if (shouldEmit) {
162
- this.$emit("input");
163
- this.$emit("change", this, {
164
- bubbles: true,
165
- composed: undefined,
166
- });
167
- }
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;
168
127
  }
169
- /**
170
- * Updates the proxy value when the selected index changes.
171
- *
172
- * @param prev - the previous selected index
173
- * @param next - the next selected index
174
- *
175
- * @internal
176
- */
177
- selectedIndexChanged(prev, next) {
178
- super.selectedIndexChanged(prev, next);
179
- 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
+ }
180
135
  }
181
- positionChanged(prev, next) {
182
- this.positionAttribute = next;
183
- 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);
184
140
  }
185
- /**
186
- * Calculate and apply listbox positioning based on available viewport space.
187
- *
188
- * @public
189
- */
190
- setPositioning() {
191
- const currentBox = this.getBoundingClientRect();
192
- const viewportHeight = window.innerHeight;
193
- const availableBottom = viewportHeight - currentBox.bottom;
194
- this.position = this.forcedPosition
195
- ? this.positionAttribute
196
- : currentBox.top > availableBottom
197
- ? select_options.SelectPosition.above
198
- : select_options.SelectPosition.below;
199
- this.positionAttribute = this.forcedPosition
200
- ? this.positionAttribute
201
- : this.position;
202
- this.maxHeight =
203
- 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;
204
150
  }
205
- /**
206
- * The value displayed on the button.
207
- *
208
- * @public
209
- */
210
- get displayValue() {
211
- var _a, _b;
212
- index.Observable.track(this, "displayValue");
213
- 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;
214
159
  }
215
- /**
216
- * Synchronize the `aria-disabled` property when the `disabled` property changes.
217
- *
218
- * @param prev - The previous disabled value
219
- * @param next - The next disabled value
220
- *
221
- * @internal
222
- */
223
- disabledChanged(prev, next) {
224
- if (super.disabledChanged) {
225
- super.disabledChanged(prev, next);
226
- }
227
- 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] : [];
228
165
  }
229
- /**
230
- * Reset the element to its first selectable option when its parent form is reset.
231
- *
232
- * @internal
233
- */
234
- formResetCallback() {
235
- this.setProxyOptions();
236
- // Call the base class's implementation setDefaultSelectedOption instead of the select's
237
- // override, in order to reset the selectedIndex without using the value property.
238
- super.setDefaultSelectedOption();
239
- if (this.selectedIndex === -1) {
240
- this.selectedIndex = 0;
241
- }
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;
242
174
  }
243
- /**
244
- * Handle opening and closing the listbox when the select is clicked.
245
- *
246
- * @param e - the mouse event
247
- * @internal
248
- */
249
- clickHandler(e) {
250
- // do nothing if the select is disabled
251
- if (this.disabled) {
252
- 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;
253
241
  }
254
- if (this.open) {
255
- const captured = e.target.closest(`option,[role=option]`);
256
- if (captured && captured.disabled) {
257
- return;
258
- }
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;
259
248
  }
260
- super.clickHandler(e);
261
- this.open = this.collapsible && !this.open;
262
- if (!this.open && this.indexWhenOpened !== this.selectedIndex) {
263
- 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;
264
255
  }
265
- return true;
266
- }
267
- /**
268
- * Handles focus state when the element or its children lose focus.
269
- *
270
- * @param e - The focus event
271
- * @internal
272
- */
273
- focusoutHandler(e) {
274
- var _a;
275
- super.focusoutHandler(e);
256
+ __privateMethod(this, _SearchableSelect_instances, highlightPrevPage_fn).call(this);
257
+ return false;
258
+ case "PageDown":
276
259
  if (!this.open) {
277
- return true;
260
+ this.open = true;
261
+ break;
278
262
  }
279
- const focusTarget = e.relatedTarget;
280
- if (this.isSameNode(focusTarget)) {
281
- this.focus();
282
- 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;
283
269
  }
284
- if (!((_a = this.options) === null || _a === void 0 ? void 0 : _a.includes(focusTarget))) {
285
- this.open = false;
286
- if (this.indexWhenOpened !== this.selectedIndex) {
287
- this.updateValue(true);
288
- }
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;
289
276
  }
290
- }
291
- /**
292
- * Updates the value when an option's value changes.
293
- *
294
- * @param source - the source object
295
- * @param propertyName - the property to evaluate
296
- *
297
- * @internal
298
- * @override
299
- */
300
- handleChange(source, propertyName) {
301
- super.handleChange(source, propertyName);
302
- if (propertyName === "value") {
303
- 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;
304
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;
305
296
  }
306
- /**
307
- * Synchronize the form-associated proxy and updates the value property of the element.
308
- *
309
- * @param prev - the previous collection of slotted option elements
310
- * @param next - the next collection of slotted option elements
311
- *
312
- * @internal
313
- */
314
- slottedOptionsChanged(prev, next) {
315
- this.options.forEach(o => {
316
- const notifier = index.Observable.getNotifier(o);
317
- notifier.unsubscribe(this, "value");
318
- });
319
- super.slottedOptionsChanged(prev, next);
320
- this.options.forEach(o => {
321
- const notifier = index.Observable.getNotifier(o);
322
- notifier.subscribe(this, "value");
323
- });
324
- this.setProxyOptions();
325
- 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;
326
308
  }
327
- /**
328
- * Prevents focus when size is set and a scrollbar is clicked.
329
- *
330
- * @param e - the mouse event object
331
- *
332
- * @override
333
- * @internal
334
- */
335
- mousedownHandler(e) {
336
- var _a;
337
- if (e.offsetX >= 0 && e.offsetX <= ((_a = this.listbox) === null || _a === void 0 ? void 0 : _a.scrollWidth)) {
338
- return super.mousedownHandler(e);
339
- }
340
- 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
+ }
341
315
  }
342
- /**
343
- * Sets the multiple property on the proxy element.
344
- *
345
- * @param prev - the previous multiple value
346
- * @param next - the current multiple value
347
- */
348
- multipleChanged(prev, next) {
349
- super.multipleChanged(prev, next);
350
- if (this.proxy) {
351
- this.proxy.multiple = next;
352
- }
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
+ }
353
322
  }
354
- /**
355
- * Updates the selectedness of each option when the list of selected options changes.
356
- *
357
- * @param prev - the previous list of selected options
358
- * @param next - the current list of selected options
359
- *
360
- * @override
361
- * @internal
362
- */
363
- selectedOptionsChanged(prev, next) {
364
- var _a;
365
- super.selectedOptionsChanged(prev, next);
366
- (_a = this.options) === null || _a === void 0 ? void 0 : _a.forEach((o, i) => {
367
- var _a;
368
- const proxyOption = (_a = this.proxy) === null || _a === void 0 ? void 0 : _a.options.item(i);
369
- if (proxyOption) {
370
- proxyOption.selected = o.selected;
371
- }
372
- });
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
+ }
373
328
  }
374
- /**
375
- * Sets the selected index to match the first option with the selected attribute, or
376
- * the first selectable option.
377
- *
378
- * @override
379
- * @internal
380
- */
381
- setDefaultSelectedOption() {
382
- var _a;
383
- const options = (_a = this.options) !== null && _a !== void 0 ? _a : Array.from(this.children).filter(listbox.Listbox$1.slottedOptionFilter);
384
- const selectedIndex = options === null || options === void 0 ? void 0 : options.findIndex(el => el.hasAttribute("selected") || el.selected || el.value === this.value);
385
- if (selectedIndex !== -1) {
386
- this.selectedIndex = selectedIndex;
387
- return;
388
- }
389
- 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;
390
385
  }
391
- /**
392
- * Resets and fills the proxy to match the component's options.
393
- *
394
- * @internal
395
- */
396
- setProxyOptions() {
397
- if (this.proxy instanceof HTMLSelectElement && this.options) {
398
- this.proxy.options.length = 0;
399
- this.options.forEach(option => {
400
- const proxyOption = option.proxy ||
401
- (option instanceof HTMLOptionElement ? option.cloneNode() : null);
402
- if (proxyOption) {
403
- this.proxy.options.add(proxyOption);
404
- }
405
- });
406
- }
386
+ return true;
387
+ }
388
+ /**
389
+ * @internal
390
+ */
391
+ _onListboxClick(e) {
392
+ if (this.disabled) {
393
+ return;
407
394
  }
408
- /**
409
- * Handle keyboard interaction for the select.
410
- *
411
- * @param e - the keyboard event
412
- * @internal
413
- */
414
- keydownHandler(e) {
415
- super.keydownHandler(e);
416
- const key = e.key || e.key.charCodeAt(0);
417
- switch (key) {
418
- case keyCodes.keySpace: {
419
- e.preventDefault();
420
- if (this.collapsible && this.typeAheadExpired) {
421
- this.open = !this.open;
422
- }
423
- break;
424
- }
425
- case keyCodes.keyHome:
426
- case keyCodes.keyEnd: {
427
- e.preventDefault();
428
- break;
429
- }
430
- case keyCodes.keyEnter: {
431
- e.preventDefault();
432
- this.open = !this.open;
433
- break;
434
- }
435
- case keyCodes.keyEscape: {
436
- if (this.collapsible && this.open) {
437
- e.preventDefault();
438
- this.open = false;
439
- }
440
- break;
441
- }
442
- case keyCodes.keyTab: {
443
- if (this.collapsible && this.open) {
444
- e.preventDefault();
445
- this.open = false;
446
- }
447
- return true;
448
- }
449
- }
450
- if (!this.open && this.indexWhenOpened !== this.selectedIndex) {
451
- this.updateValue(true);
452
- this.indexWhenOpened = this.selectedIndex;
453
- }
454
- 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;
455
434
  }
456
- connectedCallback() {
457
- super.connectedCallback();
458
- this.forcedPosition = !!this.positionAttribute;
459
- this.addEventListener("contentchange", this.updateDisplayValue);
435
+ if (!e.defaultPrevented) {
436
+ this._input.focus();
460
437
  }
461
- disconnectedCallback() {
462
- this.removeEventListener("contentchange", this.updateDisplayValue);
463
- super.disconnectedCallback();
438
+ }
439
+ connectedCallback() {
440
+ super.connectedCallback();
441
+ if (!this.values.length) {
442
+ this.values = __privateMethod(this, _SearchableSelect_instances, determineInitialValues_fn).call(this);
464
443
  }
465
- /**
466
- * Updates the proxy's size property when the size attribute changes.
467
- *
468
- * @param prev - the previous size
469
- * @param next - the current size
470
- *
471
- * @override
472
- * @internal
473
- */
474
- sizeChanged(prev, next) {
475
- super.sizeChanged(prev, next);
476
- if (this.proxy) {
477
- this.proxy.size = next;
478
- }
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);
479
490
  }
480
- /**
481
- *
482
- * @internal
483
- */
484
- updateDisplayValue() {
485
- if (this.collapsible) {
486
- index.Observable.notify(this, "displayValue");
487
- }
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;
488
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;
489
597
  };
490
- index.__decorate([
491
- index.attr({ attribute: "open", mode: "boolean" })
492
- ], Select$1.prototype, "open", void 0);
493
- index.__decorate([
494
- index.volatile
495
- ], Select$1.prototype, "collapsible", null);
496
- index.__decorate([
497
- index.observable
498
- ], Select$1.prototype, "control", void 0);
499
- index.__decorate([
500
- index.attr({ attribute: "position" })
501
- ], Select$1.prototype, "positionAttribute", void 0);
502
- index.__decorate([
503
- index.observable
504
- ], Select$1.prototype, "position", void 0);
505
- index.__decorate([
506
- index.observable
507
- ], Select$1.prototype, "maxHeight", void 0);
508
598
  /**
509
- * Includes ARIA states and properties relating to the ARIA select role.
510
- *
511
- * @public
599
+ * @internal
512
600
  */
513
- class DelegatesARIASelect {
514
- }
515
- index.__decorate([
516
- index.observable
517
- ], DelegatesARIASelect.prototype, "ariaControls", void 0);
518
- applyMixins.applyMixins(DelegatesARIASelect, listbox.DelegatesARIAListbox);
519
- applyMixins.applyMixins(Select$1, startEnd.StartEnd, DelegatesARIASelect);
520
-
521
- 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{--_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{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-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}";
522
-
523
- var __defProp = Object.defineProperty;
524
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
525
- var __decorateClass = (decorators, target, key, kind) => {
526
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
527
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
528
- if (decorator = decorators[i])
529
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
530
- if (kind && result) __defProp(target, key, result);
531
- 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;
532
611
  };
533
- let Select = class extends Select$1 {
534
- constructor() {
535
- super(...arguments);
536
- this.fixedDropdown = false;
537
- this.placeholderOption = null;
538
- this._feedbackWrapper = null;
612
+ updateTagLayout_fn = function() {
613
+ if (!this.multiple) {
614
+ this._numEllidedTags = 0;
615
+ this._tagRows = [];
616
+ this._lastTagRow = [];
617
+ return;
539
618
  }
540
- labelChanged() {
541
- if (!this.ariaLabel) {
542
- this.ariaLabel = this.label;
619
+ if (this.externalTags) {
620
+ this._numEllidedTags = this.values.length;
621
+ this._tagRows = [];
622
+ this._lastTagRow = [];
623
+ return;
624
+ }
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;
543
660
  }
661
+ rows[currentRowIndex].unshift(entry);
662
+ currentRowWidth += TagGapPx + tagWidth;
544
663
  }
545
- connectedCallback() {
546
- super.connectedCallback();
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);
670
+ }
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;
675
+ }
547
676
  }
548
- get displayValue() {
549
- index.Observable.track(this, "displayValue");
550
- return this.firstSelectedOption?.getAttribute("label") ?? this.firstSelectedOption?.text ?? this.placeholder ?? "";
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();
551
686
  }
552
- setDefaultSelectedOption() {
553
- const options = Array.from(this.children).filter(
554
- listbox.Listbox.slottedOptionFilter
555
- );
556
- const selectedIndex = options.findIndex(
557
- (el) => el.hasAttribute("selected") || el.selected || el.value === this.value
558
- );
559
- if (selectedIndex === -1 && !this.placeholderOption) {
560
- this.selectedIndex = 0;
561
- return;
562
- }
563
- if (selectedIndex !== -1 || this.placeholder !== "") {
564
- this.selectedIndex = selectedIndex;
565
- return;
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;
566
695
  }
567
696
  }
568
- /*
569
- * @internal
570
- */
571
- slottedOptionsChanged(prev, next) {
572
- super.slottedOptionsChanged(prev, next);
573
- this.proxy.value = this.value;
574
- this.validate();
697
+ return null;
698
+ };
699
+ nextTagIndexRight_fn = function(index) {
700
+ if (!this.values.length) {
701
+ return null;
575
702
  }
576
- formResetCallback() {
577
- super.formResetCallback();
578
- if (this.placeholder) {
579
- this.selectedIndex = -1;
703
+ for (let i = index + 1; i < this.values.length; i++) {
704
+ if (!this._isTagDisabled(this.values[i])) {
705
+ return i;
580
706
  }
581
707
  }
708
+ return null;
582
709
  };
583
- __decorateClass([
584
- index.observable
585
- ], Select.prototype, "_anchor", 2);
586
- __decorateClass([
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([
587
730
  index.attr
588
- ], Select.prototype, "appearance", 2);
589
- __decorateClass([
731
+ ], SearchableSelect.prototype, "appearance", 2);
732
+ __decorateClass$1([
590
733
  index.attr
591
- ], Select.prototype, "shape", 2);
592
- __decorateClass([
734
+ ], SearchableSelect.prototype, "shape", 2);
735
+ __decorateClass$1([
593
736
  index.attr({ mode: "boolean", attribute: "fixed-dropdown" })
594
- ], Select.prototype, "fixedDropdown", 2);
595
- __decorateClass([
737
+ ], SearchableSelect.prototype, "fixedDropdown", 2);
738
+ __decorateClass$1([
596
739
  index.attr
597
- ], Select.prototype, "placeholder", 2);
598
- __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([
599
754
  index.observable
600
- ], Select.prototype, "placeholderOption", 2);
601
- __decorateClass([
755
+ ], SearchableSelect.prototype, "values", 2);
756
+ __decorateClass$1([
602
757
  index.observable
603
- ], Select.prototype, "_feedbackWrapper", 2);
604
- __decorateClass([
758
+ ], SearchableSelect.prototype, "initialValues", 2);
759
+ __decorateClass$1([
760
+ index.observable
761
+ ], SearchableSelect.prototype, "_input", 2);
762
+ __decorateClass$1([
605
763
  index.observable
606
- ], Select.prototype, "metaSlottedContent", 2);
607
- Select = __decorateClass([
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([
608
796
  formElements.errorText,
609
797
  formElements.formElements
610
- ], Select);
798
+ ], SearchableSelect);
611
799
  applyMixinsWithObservables.applyMixinsWithObservables(
612
- Select,
800
+ SearchableSelect,
613
801
  affix.AffixIconWithTrailing,
614
802
  formElements.FormElementHelperText,
615
- formElements.FormElementSuccessText
803
+ formElements.FormElementSuccessText,
804
+ localized.Localized
616
805
  );
617
806
 
618
- const getStateClasses = ({
619
- shape,
620
- disabled,
621
- appearance,
622
- metaSlottedContent,
623
- errorValidationMessage,
624
- successText,
625
- placeholder,
626
- value
627
- }) => classNames.classNames(
628
- ["disabled", disabled],
629
- [`appearance-${appearance}`, Boolean(appearance)],
630
- [`shape-${shape}`, Boolean(shape)],
631
- ["has-meta", Boolean(metaSlottedContent?.length)],
632
- ["error", Boolean(errorValidationMessage)],
633
- ["success", !!successText],
634
- ["has-meta", Boolean(metaSlottedContent?.length)],
635
- ["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]
636
852
  );
637
853
  function renderLabel() {
638
- return index.html` <label for="control" class="label" id="label">
639
- ${(x) => x.label}
640
- </label>`;
641
- }
642
- function renderPlaceholder(context) {
643
- const optionTag = context.tagFor(definition$1.ListboxOption);
644
854
  return index.html`
645
- <${optionTag} ${ref.ref("placeholderOption")}
646
- text="${(x) => x.placeholder}" hidden disabled>
647
- </${optionTag}>`;
855
+ <label for="control" class="label" id="label"> ${(x) => x.label} </label>
856
+ `;
648
857
  }
649
- 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);
650
893
  const affixIconTemplate = affix.affixIconTemplateFactory(context);
651
- const chevronTemplate = definition$2.chevronTemplateFactory(context);
652
- return index.html` <div
653
- class="control ${getStateClasses}"
654
- ${ref.ref("_anchor")}
655
- id="control"
656
- ?disabled="${(x) => x.disabled}"
657
- >
658
- <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
+ >
659
911
  ${(x) => affixIconTemplate(x.icon, affix.IconWrapper.Slot)}
660
- <span class="text">${(x) => x.displayValue}</span>
661
- <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}
662
975
  </div>
663
- ${chevronTemplate}
664
- </div>`;
665
- }
666
- function setFixedDropdownVarWidth(x) {
667
- return x.open && x.fixedDropdown ? `--_select-fixed-width: ${Math.round(x.getBoundingClientRect().width)}px` : null;
976
+ `;
668
977
  }
669
978
  function renderControl(context) {
670
979
  const popupTag = context.tagFor(definition.Popup);
671
980
  return index.html`
672
- ${when.when((x) => x.label, renderLabel())}
673
- <div class="control-wrapper">
674
- ${when.when((x) => !x.multiple, selectValue(context))}
675
- <${popupTag} class="popup"
676
- style="${setFixedDropdownVarWidth}"
677
- ?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}
678
986
  :anchor="${(x) => x._anchor}"
987
+ :open="${(x) => x.open}"
988
+ class="popup"
679
989
  placement="bottom-start"
680
- strategy="${(x) => x.fixedDropdown ? null : "absolute"}">
681
- <div class="listbox"
682
- id="${(x) => x.listboxId}"
990
+ strategy="${(x) => x.fixedDropdown ? "fixed" : "absolute"}">
991
+ <div
992
+ class="listbox"
683
993
  role="listbox"
684
- ?disabled="${(x) => x.disabled}"
685
- ?hidden="${(x) => x.collapsible ? !x.open : false}"
686
- ${ref.ref("listbox")}>
687
- ${when.when((x) => x.placeholder, renderPlaceholder(context))}
994
+ ${ref.ref("_listbox")}
995
+ @click="${(x, c) => x._onListboxClick(c.event)}"
996
+ @mousedown="${() => false}"
997
+ >
688
998
  <slot
689
999
  ${slotted.slotted({
690
1000
  filter: listbox.Listbox.slottedOptionFilter,
691
1001
  flatten: true,
692
- property: "slottedOptions"
1002
+ property: "_slottedOptions"
693
1003
  })}>
694
1004
  </slot>
695
- </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>
696
1023
  </${popupTag}>
697
1024
  </div>
698
- `;
699
- }
700
- function ifNotFromFeedback(handler) {
701
- return (x, c) => {
702
- if (!c.event.composedPath().includes(x._feedbackWrapper)) {
703
- return handler(x, c.event);
704
- }
705
- return true;
706
- };
1025
+ </div>
1026
+ `;
707
1027
  }
708
- const SelectTemplate = (context) => {
1028
+ const SearchableSelectTemplate = (context) => {
1029
+ const optionTagTag = context.tagFor(OptionTag);
709
1030
  return index.html`
710
- <template
711
- class="base"
712
- aria-label="${(x) => x.ariaLabel}"
713
- aria-activedescendant="${(x) => x.ariaActiveDescendant}"
714
- aria-controls="${(x) => x.ariaControls}"
715
- aria-disabled="${(x) => x.ariaDisabled}"
716
- aria-expanded="${(x) => x.ariaExpanded}"
717
- aria-haspopup="${(x) => x.collapsible ? "listbox" : null}"
718
- aria-multiselectable="${(x) => x.ariaMultiSelectable}"
719
- role="combobox"
720
- tabindex="${(x) => !x.disabled ? "0" : null}"
721
- @click="${ifNotFromFeedback((x, e) => x.clickHandler(e))}"
722
- @focusin="${ifNotFromFeedback((x, e) => x.focusinHandler(e))}"
723
- @focusout="${ifNotFromFeedback(
724
- (x, e) => x.focusoutHandler(e)
725
- )}"
726
- @keydown="${ifNotFromFeedback((x, e) => {
727
- x.open && index$1.handleEscapeKeyAndStopPropogation(e);
728
- return x.keydownHandler(e);
729
- })}"
730
- @mousedown="${ifNotFromFeedback(
731
- (x, e) => x.mousedownHandler(e)
732
- )}"
733
- >
734
- ${renderControl(context)}
735
- <div class="feedback-wrapper" ${ref.ref("_feedbackWrapper")}>
736
- ${formElements.getFeedbackTemplate(context)}
1031
+ <template :_optionTagTagName="${() => optionTagTag}">
1032
+ <div class="control-wrapper">
1033
+ ${renderControl(context)} ${formElements.getFeedbackTemplate(context)}
737
1034
  </div>
738
1035
  </template>
739
1036
  `;
740
1037
  };
741
1038
 
742
- const selectDefinition = Select.compose({
743
- baseName: "select",
744
- template: SelectTemplate,
745
- 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
+ }
746
1082
  });
747
- const selectRegistries = [
748
- 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,
749
1093
  ...definition.popupRegistries,
750
- ...definition$3.iconRegistries,
751
- ...definition$1.listboxOptionRegistries
1094
+ ...definition$2.iconRegistries,
1095
+ optionTagDefinition(),
1096
+ searchableSelectDefinition()
752
1097
  ];
753
- const registerSelect = index.registerFactory(selectRegistries);
1098
+ const registerSearchableSelect = index.registerFactory(
1099
+ searchableSelectRegistries
1100
+ );
754
1101
 
755
- exports.registerSelect = registerSelect;
756
- exports.selectDefinition = selectDefinition;
757
- exports.selectRegistries = selectRegistries;
1102
+ exports.optionTagDefinition = optionTagDefinition;
1103
+ exports.registerSearchableSelect = registerSearchableSelect;
1104
+ exports.searchableSelectDefinition = searchableSelectDefinition;
1105
+ exports.searchableSelectRegistries = searchableSelectRegistries;