@ds-autonomie/web-components 1.0.1 → 1.1.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 (149) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/chunks/{chunk.K6WCEYZI.js → chunk.2CCKS3CP.js} +1 -1
  3. package/dist/chunks/{chunk.HH63FIEF.js → chunk.2DGAEK66.js} +12 -3
  4. package/dist/chunks/{chunk.O73OYTYJ.js → chunk.2HV2U4RQ.js} +2 -4
  5. package/dist/chunks/{chunk.EHVJT7BH.js → chunk.2R6P5TGQ.js} +1 -1
  6. package/dist/chunks/{chunk.KOH5V4C6.js → chunk.4MC32HP7.js} +21 -17
  7. package/dist/chunks/{chunk.BLPP3Q5H.js → chunk.5324JGM4.js} +11 -4
  8. package/dist/chunks/{chunk.WIEJJS3W.js → chunk.6BJBVSW4.js} +1 -1
  9. package/dist/chunks/{chunk.D7CATJYB.js → chunk.6IH66JBY.js} +1 -1
  10. package/dist/chunks/{chunk.YS7MY5CH.js → chunk.7EWUWW3E.js} +18 -24
  11. package/dist/chunks/chunk.7HGZSZJK.js +409 -0
  12. package/dist/chunks/{chunk.ODSCDJDO.js → chunk.ARVWTY56.js} +5 -4
  13. package/dist/chunks/{chunk.KDAK2GXX.js → chunk.AYXPVAYS.js} +1 -1
  14. package/dist/chunks/{chunk.WSVP75MH.js → chunk.CBMFAOZI.js} +1 -1
  15. package/dist/chunks/chunk.CMJ2SRTL.js +26 -0
  16. package/dist/chunks/{chunk.DURVPB6M.js → chunk.D6DEGG4H.js} +25 -6
  17. package/dist/chunks/{chunk.MY434P47.js → chunk.DFTZEFHF.js} +2 -2
  18. package/dist/chunks/{chunk.4XT2OJD2.js → chunk.DZWH4V6H.js} +8 -4
  19. package/dist/chunks/{chunk.NDEZEB3Z.js → chunk.EDRQ2QWB.js} +10 -5
  20. package/dist/chunks/{chunk.XSCX6TC5.js → chunk.EXIGM5NV.js} +4 -1
  21. package/dist/chunks/{chunk.OVK7QCA7.js → chunk.F4XMSVNF.js} +13 -9
  22. package/dist/chunks/{chunk.4A3WMGMZ.js → chunk.FHDPJN6L.js} +1 -1
  23. package/dist/chunks/{chunk.ABGBXXKA.js → chunk.FTWZNCEH.js} +1 -1
  24. package/dist/chunks/{chunk.6FAUBLR3.js → chunk.G3ESG6Q5.js} +1 -1
  25. package/dist/chunks/{chunk.PWWER3ZK.js → chunk.GJCVGGCP.js} +48 -24
  26. package/dist/chunks/{chunk.WHK7EFIM.js → chunk.GP5Z27QB.js} +7 -4
  27. package/dist/chunks/{chunk.UA32LJYW.js → chunk.HEOTAAPU.js} +2 -2
  28. package/dist/chunks/{chunk.JETXIC4F.js → chunk.HPK6C7NJ.js} +1 -1
  29. package/dist/chunks/{chunk.A2PAK6VF.js → chunk.ILUHEJYG.js} +2 -2
  30. package/dist/chunks/{chunk.5XL2LZLC.js → chunk.IQ7SDYSC.js} +4 -0
  31. package/dist/chunks/{chunk.GYTA2LJC.js → chunk.J6XP4AFN.js} +1 -1
  32. package/dist/chunks/{chunk.UZLQVFDR.js → chunk.L6LQN6AI.js} +2 -2
  33. package/dist/chunks/{chunk.BEB47LM2.js → chunk.LSKBY2HF.js} +2 -2
  34. package/dist/chunks/{chunk.WNHQYL5W.js → chunk.MTZZV3NB.js} +4 -20
  35. package/dist/chunks/{chunk.7ZCCXTFG.js → chunk.NBQ3AEK6.js} +2 -2
  36. package/dist/chunks/{chunk.HC5BO5YV.js → chunk.NHYFVEGM.js} +5 -16
  37. package/dist/chunks/{chunk.QKNNLZ2M.js → chunk.NKPNQBLW.js} +5 -5
  38. package/dist/chunks/{chunk.MOWTZFON.js → chunk.NKVYNBAI.js} +1 -1
  39. package/dist/chunks/{chunk.7NWAYDYI.js → chunk.NOEQVLAW.js} +3 -3
  40. package/dist/chunks/{chunk.INCGVIAQ.js → chunk.QSPKKO3T.js} +1 -1
  41. package/dist/chunks/chunk.R37CT3PN.js +865 -0
  42. package/dist/chunks/{chunk.IRQOFNJE.js → chunk.RSJYKNXT.js} +8 -3
  43. package/dist/chunks/{chunk.5XUV3SRW.js → chunk.ST2QYN4S.js} +11 -6
  44. package/dist/chunks/{chunk.LT7JMZ3T.js → chunk.T7JSALXE.js} +2 -2
  45. package/dist/chunks/{chunk.N6VVY6XD.js → chunk.U5KRBVRP.js} +6 -3
  46. package/dist/chunks/{chunk.5LT3B7MI.js → chunk.UQYPPFBJ.js} +1 -1
  47. package/dist/chunks/{chunk.2HUORR44.js → chunk.V6V7AGDB.js} +1 -1
  48. package/dist/chunks/{chunk.UV53JTE3.js → chunk.VIULAG23.js} +1 -1
  49. package/dist/chunks/{chunk.42W4S2HN.js → chunk.VM355VAS.js} +1 -1
  50. package/dist/chunks/{chunk.G7AELPSO.js → chunk.VRU3XH45.js} +4 -4
  51. package/dist/chunks/{chunk.HLYGKGDG.js → chunk.W74UQSZJ.js} +8 -5
  52. package/dist/chunks/{chunk.AR5HJD7F.js → chunk.X6RQ2SQC.js} +1 -1
  53. package/dist/chunks/chunk.ZQJVCRB2.js +10 -0
  54. package/dist/chunks/{chunk.RIJQGADY.js → chunk.ZW4JE66G.js} +11 -4
  55. package/dist/components/accordion/accordion.js +7 -7
  56. package/dist/components/alert/alert.js +9 -8
  57. package/dist/components/animation/animation.js +2 -2
  58. package/dist/components/avatar/avatar.d.ts +1 -1
  59. package/dist/components/avatar/avatar.js +7 -6
  60. package/dist/components/avatar-group/avatar-group.d.ts +1 -1
  61. package/dist/components/badge/badge.d.ts +1 -1
  62. package/dist/components/breadcrumb/breadcrumb.js +7 -7
  63. package/dist/components/breadcrumb-item/breadcrumb-item.js +2 -2
  64. package/dist/components/button/button.js +9 -8
  65. package/dist/components/checkbox/checkbox.js +8 -7
  66. package/dist/components/checkbox-button/checkbox-button.js +6 -6
  67. package/dist/components/checkbox-group/checkbox-group.d.ts +1 -0
  68. package/dist/components/checkbox-group/checkbox-group.js +3 -3
  69. package/dist/components/combobox/combobox.d.ts +175 -0
  70. package/dist/components/combobox/combobox.js +37 -0
  71. package/dist/components/combobox/combobox.styles.d.ts +2 -0
  72. package/dist/components/combobox/combobox.styles.js +9 -0
  73. package/dist/components/dialog/dialog.js +9 -8
  74. package/dist/components/divider/divider.d.ts +1 -1
  75. package/dist/components/drawer/drawer.js +10 -9
  76. package/dist/components/dropdown/dropdown.js +3 -3
  77. package/dist/components/format-bytes/format-bytes.js +2 -2
  78. package/dist/components/format-date/format-date.js +2 -2
  79. package/dist/components/format-number/format-number.js +2 -2
  80. package/dist/components/icon/icon.js +5 -5
  81. package/dist/components/icon-button/icon-button.d.ts +1 -1
  82. package/dist/components/icon-button/icon-button.js +7 -6
  83. package/dist/components/include/include.js +2 -2
  84. package/dist/components/input/input.d.ts +1 -1
  85. package/dist/components/input/input.js +10 -9
  86. package/dist/components/input/input.styles.js +1 -1
  87. package/dist/components/input-mask/input-mask.d.ts +1 -0
  88. package/dist/components/input-mask/input-mask.js +6 -5
  89. package/dist/components/input-mask/input-mask.styles.js +1 -1
  90. package/dist/components/input-phone/input-phone.d.ts +1 -1
  91. package/dist/components/input-phone/input-phone.js +24 -23
  92. package/dist/components/input-phone/input-phone.styles.js +1 -1
  93. package/dist/components/menu/menu.d.ts +1 -1
  94. package/dist/components/menu-item/menu-item.d.ts +1 -1
  95. package/dist/components/menu-item/menu-item.js +6 -6
  96. package/dist/components/menu-label/menu-label.d.ts +1 -1
  97. package/dist/components/mutation-observer/mutation-observer.js +2 -2
  98. package/dist/components/option/option.js +8 -8
  99. package/dist/components/option/option.styles.js +1 -1
  100. package/dist/components/progress-bar/progress-bar.d.ts +1 -1
  101. package/dist/components/progress-bar/progress-bar.js +3 -2
  102. package/dist/components/progress-ring/progress-ring.d.ts +1 -2
  103. package/dist/components/progress-ring/progress-ring.js +2 -2
  104. package/dist/components/radio/radio.js +6 -6
  105. package/dist/components/radio-button/radio-button.js +2 -2
  106. package/dist/components/radio-group/radio-group.js +2 -2
  107. package/dist/components/relative-time/relative-time.js +2 -2
  108. package/dist/components/resize-observer/resize-observer.js +2 -2
  109. package/dist/components/select/select.d.ts +4 -0
  110. package/dist/components/select/select.js +13 -12
  111. package/dist/components/select/select.styles.js +1 -1
  112. package/dist/components/skeleton/skeleton.d.ts +1 -1
  113. package/dist/components/spinner/spinner.js +2 -2
  114. package/dist/components/tab/tab.d.ts +1 -1
  115. package/dist/components/tab/tab.js +3 -3
  116. package/dist/components/tab-group/tab-group.d.ts +1 -1
  117. package/dist/components/tab-group/tab-group.js +3 -3
  118. package/dist/components/tab-panel/tab-panel.d.ts +1 -1
  119. package/dist/components/tab-panel/tab-panel.js +2 -2
  120. package/dist/components/tag/tag.js +9 -8
  121. package/dist/components/textarea/textarea.d.ts +1 -0
  122. package/dist/components/textarea/textarea.js +4 -3
  123. package/dist/components/tooltip/tooltip.js +3 -3
  124. package/dist/components/tree/tree.d.ts +2 -1
  125. package/dist/components/tree/tree.js +12 -11
  126. package/dist/components/tree-item/tree-item.d.ts +1 -1
  127. package/dist/components/tree-item/tree-item.js +11 -10
  128. package/dist/custom-elements.json +1104 -74
  129. package/dist/design-system.d.ts +1 -0
  130. package/dist/design-system.js +96 -90
  131. package/dist/internal/debounce.d.ts +1 -1
  132. package/dist/internal/debounce.js +3 -3
  133. package/dist/internal/default-value.d.ts +1 -1
  134. package/dist/internal/default-value.js +24 -21
  135. package/dist/internal/watch.js +1 -1
  136. package/dist/themes/dsa-wc-theme.css +37 -6
  137. package/dist/themes/dsa-wc-theme.min.css +1 -1
  138. package/dist/themes/dsa-wc-theme.styles.js +43 -6
  139. package/dist/translations/en-gb.js +1 -1
  140. package/dist/translations/en.js +1 -1
  141. package/dist/translations/fr.js +1 -1
  142. package/dist/utilities/directives.d.ts +1 -0
  143. package/dist/utilities/directives.js +7 -0
  144. package/dist/utilities/localize.d.ts +2 -0
  145. package/dist/utilities/localize.js +1 -1
  146. package/dist/vscode.html-custom-data.json +130 -6
  147. package/dist/web-types.json +618 -9
  148. package/package.json +1 -1
  149. package/dist/chunks/chunk.GI7VDIWX.js +0 -24
@@ -0,0 +1,865 @@
1
+ import {
2
+ scrollIntoView
3
+ } from "./chunk.EMIT7S33.js";
4
+ import {
5
+ defaultValue
6
+ } from "./chunk.CMJ2SRTL.js";
7
+ import {
8
+ combobox_styles_default
9
+ } from "./chunk.7HGZSZJK.js";
10
+ import {
11
+ FormControlController
12
+ } from "./chunk.KIFBWPW5.js";
13
+ import {
14
+ HasSlotController
15
+ } from "./chunk.YIY5RM53.js";
16
+ import {
17
+ waitForEvent
18
+ } from "./chunk.B4BZKR24.js";
19
+ import {
20
+ animateTo,
21
+ stopAnimations
22
+ } from "./chunk.2FK6USFR.js";
23
+ import {
24
+ getAnimation,
25
+ setDefaultAnimation
26
+ } from "./chunk.V7RJROLH.js";
27
+ import {
28
+ LocalizeController
29
+ } from "./chunk.IQ7SDYSC.js";
30
+ import {
31
+ watch
32
+ } from "./chunk.6IH66JBY.js";
33
+ import {
34
+ ShoelaceElement
35
+ } from "./chunk.YCXTCVAZ.js";
36
+ import {
37
+ __decorateClass
38
+ } from "./chunk.6M63UXML.js";
39
+
40
+ // src/components/combobox/combobox.ts
41
+ import { html } from "lit";
42
+ import { customElement, property, query, state } from "lit/decorators.js";
43
+ import { classMap } from "lit/directives/class-map.js";
44
+ var OPTION_TAG = "dsa-option";
45
+ var DSACombobox = class extends ShoelaceElement {
46
+ constructor() {
47
+ super(...arguments);
48
+ this.formControlController = new FormControlController(this, {
49
+ assumeInteractionOn: ["dsa-blur", "dsa-input"]
50
+ });
51
+ this.hasSlotController = new HasSlotController(
52
+ this,
53
+ "help-text",
54
+ "label"
55
+ );
56
+ this.localize = new LocalizeController(this);
57
+ this.hasVisualFocus = false;
58
+ this.displayLabel = "";
59
+ this.selectedOptions = [];
60
+ this.allOptions = [];
61
+ this.filteredOptions = [];
62
+ this.name = "";
63
+ this.title = "";
64
+ this.open = false;
65
+ this.value = "";
66
+ this.defaultValue = "";
67
+ this.size = "medium";
68
+ this.placeholder = "";
69
+ this.label = "";
70
+ this.variant = "base";
71
+ this.hoist = false;
72
+ this.placement = "bottom";
73
+ this.helpText = "";
74
+ this.disabled = false;
75
+ this.clearable = false;
76
+ this.form = "";
77
+ this.required = false;
78
+ this.error = false;
79
+ this.errorMessage = "";
80
+ this.noSyncWidth = false;
81
+ this.items = void 0;
82
+ this.multiple = false;
83
+ this.maxOptionsVisible = 3;
84
+ }
85
+ /** Gets the validity state object */
86
+ get validity() {
87
+ return this.valueInput.validity;
88
+ }
89
+ /** Gets the validation message */
90
+ get validationMessage() {
91
+ return this.valueInput.validationMessage;
92
+ }
93
+ connectedCallback() {
94
+ super.connectedCallback();
95
+ this.handleDocumentFocusIn = this.handleDocumentFocusIn.bind(this);
96
+ this.handleDocumentMouseDown = this.handleDocumentMouseDown.bind(this);
97
+ this.handleDocumentKeyDown = this.handleDocumentKeyDown.bind(this);
98
+ this.open = false;
99
+ this.allOptions = this.getAllOptions();
100
+ this.filteredOptions = [...this.allOptions];
101
+ }
102
+ /** Input events */
103
+ handleBlur() {
104
+ this.hasVisualFocus = false;
105
+ this.emit("dsa-blur");
106
+ }
107
+ handleFocus() {
108
+ this.hasVisualFocus = true;
109
+ this.emit("dsa-focus");
110
+ }
111
+ handleComboboxMouseDown(event) {
112
+ if (this.disabled) {
113
+ return;
114
+ }
115
+ const path = event.composedPath();
116
+ const iconButtonIndex = path.findIndex(
117
+ (el) => el instanceof Element && el.tagName.toLowerCase() === "dsa-icon-button"
118
+ );
119
+ const isFromTag = iconButtonIndex > -1 ? path.slice(iconButtonIndex, iconButtonIndex + 5).some(
120
+ (el) => el instanceof Element && el.tagName.toLowerCase() === "dsa-tag"
121
+ ) : false;
122
+ if (isFromTag) {
123
+ return;
124
+ }
125
+ event.preventDefault();
126
+ this.displayInput.focus({ preventScroll: true });
127
+ this.open = !this.open;
128
+ }
129
+ handleComboboxKeyDown(event) {
130
+ event.stopPropagation();
131
+ this.filterOptions(this.displayLabel);
132
+ this.handleDocumentKeyDown(event);
133
+ }
134
+ handleChange() {
135
+ var _a;
136
+ this.displayLabel = this.displayInput.value;
137
+ this.emit("dsa-change");
138
+ if (!this.multiple) {
139
+ if (this.displayLabel !== ((_a = this.selectedOptions[0]) == null ? void 0 : _a.getTextLabel())) {
140
+ this.clearSelectedOptions();
141
+ }
142
+ }
143
+ this.filterOptions(this.displayLabel);
144
+ }
145
+ handleInput() {
146
+ var _a;
147
+ this.displayLabel = this.displayInput.value;
148
+ this.show();
149
+ this.emit("dsa-input");
150
+ if (!this.multiple) {
151
+ if (this.displayLabel !== ((_a = this.selectedOptions[0]) == null ? void 0 : _a.getTextLabel())) {
152
+ this.clearSelectedOptions();
153
+ }
154
+ }
155
+ this.filterOptions(this.displayLabel);
156
+ }
157
+ handleClearClick(event) {
158
+ event.stopPropagation();
159
+ if (this.value !== "") {
160
+ this.setSelectedOptions([]);
161
+ this.displayInput.focus({ preventScroll: true });
162
+ this.updateComplete.then(() => {
163
+ this.emit("dsa-clear");
164
+ this.emit("dsa-input");
165
+ this.emit("dsa-change");
166
+ });
167
+ }
168
+ }
169
+ filterOptions(filter) {
170
+ this.filteredOptions = this.allOptions.filter((option) => {
171
+ return option.innerText.toLowerCase().includes(filter.toLowerCase());
172
+ });
173
+ }
174
+ // Toggles an option's selected state
175
+ toggleOptionSelection(option, force) {
176
+ option.selected = force || !option.selected;
177
+ this.selectionChanged();
178
+ }
179
+ handleOptionClick(event) {
180
+ const target = event.target;
181
+ const option = target.closest(OPTION_TAG);
182
+ if (option !== null && !option.disabled) {
183
+ const oldValue = this.value;
184
+ if (this.multiple) {
185
+ this.toggleOptionSelection(option);
186
+ } else {
187
+ this.setSelectedOptions(option);
188
+ this.filterOptions(this.displayLabel);
189
+ }
190
+ this.updateComplete.then(() => {
191
+ if (this.value !== oldValue) {
192
+ this.emit("dsa-input");
193
+ this.emit("dsa-change");
194
+ }
195
+ });
196
+ if (!this.multiple) {
197
+ this.hide();
198
+ this.displayInput.focus({ preventScroll: true });
199
+ this.hasVisualFocus = true;
200
+ }
201
+ }
202
+ }
203
+ handleDefaultSlotChange() {
204
+ const value = Array.isArray(this.value) ? this.value : [this.value];
205
+ if (customElements.get(OPTION_TAG)) {
206
+ this.setSelectedOptions(
207
+ this.allOptions.filter((el) => value.includes(el.value))
208
+ );
209
+ } else {
210
+ customElements.whenDefined(OPTION_TAG).then(() => this.handleDefaultSlotChange());
211
+ }
212
+ }
213
+ handleTagRemove(event, option) {
214
+ event.stopPropagation();
215
+ if (!this.disabled) {
216
+ this.toggleOptionSelection(option, false);
217
+ this.updateComplete.then(() => {
218
+ this.emit("dsa-input");
219
+ this.emit("dsa-change");
220
+ });
221
+ }
222
+ }
223
+ // Gets an array of all <dsa-option> elements
224
+ getAllOptions() {
225
+ if (this.items !== void 0) {
226
+ return this.items;
227
+ }
228
+ return [...this.querySelectorAll(OPTION_TAG)];
229
+ }
230
+ clearSelectedOptions() {
231
+ this.allOptions.forEach((el) => {
232
+ el.selected = false;
233
+ });
234
+ this.selectedOptions = [];
235
+ }
236
+ // Sets the current option, which is the option the user is currently interacting with (e.g. via keyboard). Only one
237
+ // option may be "current" at a time.
238
+ setCurrentOption(option, focus = false) {
239
+ this.allOptions.forEach((el) => {
240
+ el.current = false;
241
+ el.tabIndex = -1;
242
+ });
243
+ if (option !== void 0) {
244
+ this.currentOption = option;
245
+ option.current = true;
246
+ option.tabIndex = 0;
247
+ if (focus) {
248
+ option.focus();
249
+ }
250
+ } else {
251
+ this.currentOption = void 0;
252
+ }
253
+ }
254
+ // Sets the selected option(s)
255
+ setSelectedOptions(option) {
256
+ const newSelectedOptions = Array.isArray(option) ? option : [option];
257
+ this.clearSelectedOptions();
258
+ newSelectedOptions.forEach((el) => {
259
+ el.selected = true;
260
+ });
261
+ this.selectionChanged();
262
+ }
263
+ handleClearMouseDown(event) {
264
+ event.stopPropagation();
265
+ event.preventDefault();
266
+ }
267
+ // This method must be called whenever the selection changes. It will update the selected options cache, the current
268
+ // value, and the display value
269
+ selectionChanged() {
270
+ var _a, _b, _c, _d;
271
+ this.selectedOptions = this.allOptions.filter((el) => el.selected);
272
+ if (this.multiple) {
273
+ this.value = this.selectedOptions.map((el) => el.value);
274
+ this.displayLabel = "";
275
+ } else {
276
+ this.value = (_b = (_a = this.selectedOptions[0]) == null ? void 0 : _a.value) != null ? _b : "";
277
+ this.displayLabel = (_d = (_c = this.selectedOptions[0]) == null ? void 0 : _c.getTextLabel()) != null ? _d : "";
278
+ }
279
+ this.updateComplete.then(() => {
280
+ this.formControlController.updateValidity();
281
+ this.filterOptions(this.displayLabel);
282
+ });
283
+ }
284
+ handleInvalid(event) {
285
+ this.formControlController.setValidity(false);
286
+ this.formControlController.emitInvalidEvent(event);
287
+ }
288
+ /** Listeners */
289
+ addOpenListeners() {
290
+ document.addEventListener("focusin", this.handleDocumentFocusIn);
291
+ document.addEventListener("mousedown", this.handleDocumentMouseDown);
292
+ document.addEventListener("keydown", this.handleDocumentKeyDown);
293
+ }
294
+ removeOpenListeners() {
295
+ document.removeEventListener("focusin", this.handleDocumentFocusIn);
296
+ document.removeEventListener("mousedown", this.handleDocumentMouseDown);
297
+ document.removeEventListener("keydown", this.handleDocumentKeyDown);
298
+ }
299
+ handleDocumentFocusIn(event) {
300
+ const path = event.composedPath();
301
+ if (this && !path.includes(this)) {
302
+ this.hide();
303
+ }
304
+ }
305
+ handleDocumentMouseDown(event) {
306
+ const path = event.composedPath();
307
+ if (this && !path.includes(this)) {
308
+ this.hide();
309
+ }
310
+ }
311
+ handleDocumentKeyDown(event) {
312
+ switch (event.key) {
313
+ case "Escape":
314
+ case "Tab":
315
+ this.handleEscapeAndTabKeys(event.key);
316
+ break;
317
+ case "Enter":
318
+ this.handleEnterKey(event);
319
+ break;
320
+ case "ArrowLeft":
321
+ case "ArrowRight":
322
+ this.handleArrowKeys();
323
+ break;
324
+ case "ArrowUp":
325
+ case "ArrowDown":
326
+ case "Home":
327
+ case "End":
328
+ this.handleNavigationKeys(event);
329
+ break;
330
+ default:
331
+ break;
332
+ }
333
+ }
334
+ handleEscapeAndTabKeys(key) {
335
+ if (this.open) {
336
+ this.hide();
337
+ this.displayInput.focus({ preventScroll: true });
338
+ this.hasVisualFocus = true;
339
+ } else if (key === "Escape" && !this.open) {
340
+ if (this.multiple) {
341
+ this.displayLabel = "";
342
+ } else {
343
+ this.setSelectedOptions([]);
344
+ }
345
+ }
346
+ }
347
+ handleEnterKey(event) {
348
+ event.preventDefault();
349
+ event.stopImmediatePropagation();
350
+ if (this.open && this.currentOption !== void 0 && !this.currentOption.disabled) {
351
+ if (this.multiple) {
352
+ this.toggleOptionSelection(this.currentOption);
353
+ } else {
354
+ this.setSelectedOptions(this.currentOption);
355
+ }
356
+ this.updateComplete.then(() => {
357
+ this.emit("dsa-input");
358
+ this.emit("dsa-change");
359
+ });
360
+ if (!this.multiple) {
361
+ this.hide();
362
+ this.hasVisualFocus = true;
363
+ this.displayInput.focus({ preventScroll: true });
364
+ }
365
+ }
366
+ }
367
+ handleArrowKeys() {
368
+ this.hasVisualFocus = true;
369
+ this.displayInput.focus({ preventScroll: true });
370
+ this.setCurrentOption(void 0);
371
+ }
372
+ handleNavigationKeys(event) {
373
+ const currentIndex = this.currentOption !== void 0 ? this.filteredOptions.indexOf(this.currentOption) : -1;
374
+ let newIndex = Math.max(0, currentIndex);
375
+ event.preventDefault();
376
+ if (!this.open) {
377
+ this.show();
378
+ }
379
+ if (event.key === "ArrowDown") {
380
+ newIndex = currentIndex + 1;
381
+ if (newIndex > this.filteredOptions.length - 1) {
382
+ newIndex = 0;
383
+ }
384
+ } else if (event.key === "ArrowUp") {
385
+ newIndex = currentIndex - 1;
386
+ if (newIndex < 0) {
387
+ newIndex = this.filteredOptions.length - 1;
388
+ }
389
+ } else if (event.key === "Home") {
390
+ newIndex = 0;
391
+ } else if (event.key === "End") {
392
+ newIndex = this.filteredOptions.length - 1;
393
+ }
394
+ this.setCurrentOption(this.filteredOptions[newIndex], true);
395
+ this.hasVisualFocus = false;
396
+ }
397
+ handleDisabledChange() {
398
+ if (this.disabled) {
399
+ this.open = false;
400
+ this.handleOpenChange();
401
+ }
402
+ }
403
+ handleItemsChange() {
404
+ this.allOptions = this.items !== void 0 ? this.items : [];
405
+ this.filterOptions(this.displayLabel);
406
+ }
407
+ handleValueChange() {
408
+ const value = Array.isArray(this.value) ? this.value : [this.value];
409
+ this.setSelectedOptions(
410
+ this.allOptions.filter((el) => value.includes(el.value))
411
+ );
412
+ }
413
+ async handleOpenChange() {
414
+ if (this.open && !this.disabled) {
415
+ this.emit("dsa-show");
416
+ this.addOpenListeners();
417
+ await stopAnimations(this);
418
+ this.listbox.hidden = false;
419
+ this.popup.active = true;
420
+ this.displayInput.focus({ preventScroll: true });
421
+ requestAnimationFrame(() => {
422
+ this.setCurrentOption(this.currentOption, true);
423
+ });
424
+ const { keyframes, options } = getAnimation(this, "select.show", {
425
+ dir: this.localize.dir()
426
+ });
427
+ await animateTo(this.popup.popup, keyframes, options);
428
+ if (this.currentOption) {
429
+ scrollIntoView(this.currentOption, this.listbox, "vertical", "auto");
430
+ }
431
+ this.emit("dsa-after-show");
432
+ } else {
433
+ this.emit("dsa-hide");
434
+ this.removeOpenListeners();
435
+ await stopAnimations(this);
436
+ const { keyframes, options } = getAnimation(this, "select.hide", {
437
+ dir: this.localize.dir()
438
+ });
439
+ await animateTo(this.popup.popup, keyframes, options);
440
+ this.listbox.hidden = true;
441
+ this.popup.active = false;
442
+ this.emit("dsa-after-hide");
443
+ }
444
+ }
445
+ /** Shows the listbox. */
446
+ async show() {
447
+ if (this.open || this.disabled) {
448
+ return void 0;
449
+ }
450
+ this.open = true;
451
+ return await waitForEvent(this, "dsa-after-show");
452
+ }
453
+ /** Hides the listbox. */
454
+ async hide() {
455
+ if (!this.open || this.disabled) {
456
+ this.open = false;
457
+ return void 0;
458
+ }
459
+ this.open = false;
460
+ this.currentOption = void 0;
461
+ return await waitForEvent(this, "dsa-after-hide");
462
+ }
463
+ /** Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. */
464
+ checkValidity() {
465
+ return this.valueInput.checkValidity();
466
+ }
467
+ /** Gets the associated form, if one exists. */
468
+ getForm() {
469
+ return this.formControlController.getForm();
470
+ }
471
+ /** Checks for validity and shows the browser's validation message if the control is invalid. */
472
+ reportValidity() {
473
+ return this.valueInput.reportValidity();
474
+ }
475
+ /** Sets a custom validation message. Pass an empty string to restore validity. */
476
+ setCustomValidity(message) {
477
+ this.valueInput.setCustomValidity(message);
478
+ this.formControlController.updateValidity();
479
+ }
480
+ /** Sets focus on the control. */
481
+ focus(options) {
482
+ this.hasVisualFocus = true;
483
+ this.displayInput.focus(options);
484
+ }
485
+ /** Removes focus from the control. */
486
+ blur() {
487
+ this.hasVisualFocus = false;
488
+ this.displayInput.blur();
489
+ }
490
+ render() {
491
+ var _a, _b;
492
+ const isValueDefined = this.value.length > 0;
493
+ const hasLabelSlot = this.hasSlotController.test("label");
494
+ const hasHelpTextSlot = this.hasSlotController.test("help-text");
495
+ const hasLabel = this.label ? true : !!hasLabelSlot;
496
+ const hasHelpText = this.helpText ? true : !!hasHelpTextSlot;
497
+ const hasClearIcon = this.clearable && !this.disabled && isValueDefined;
498
+ const isPlaceholderVisible = this.placeholder && this.value.length === 0;
499
+ const selectInputWidth = this.value ? isValueDefined ? this.value.length : 1 : void 0;
500
+ return html`
501
+ <div
502
+ part="form-control"
503
+ class=${classMap({
504
+ "form-control": true,
505
+ "form-control--error": this.error,
506
+ "form-control--disabled": this.disabled,
507
+ "form-control--small": this.size === "small",
508
+ "form-control--medium": this.size === "medium",
509
+ "form-control--large": this.size === "large",
510
+ "form-control--has-label": hasLabel,
511
+ "form-control--has-help-text": hasHelpText
512
+ })}
513
+ >
514
+ <label
515
+ id="label"
516
+ for="input"
517
+ part="form-control-label"
518
+ class="form-control__label"
519
+ aria-hidden=${hasLabel ? "false" : "true"}
520
+ >
521
+ ${this.required ? html`<span class="form-control__label-required">*</span>` : ""}
522
+ <slot name="label">${this.label}</slot>
523
+ </label>
524
+ <slot name="tooltip" class="form-control__tooltip"></slot>
525
+
526
+ <div
527
+ part="form-control-input"
528
+ class="form-control-input form-control__field"
529
+ >
530
+ <dsa-popup
531
+ class=${classMap({
532
+ select: true,
533
+ "select--error": this.error,
534
+ "select--open": this.open,
535
+ "select--disabled": this.disabled,
536
+ "select--multiple": this.multiple,
537
+ "select--focused": this.hasVisualFocus,
538
+ "select--placeholder-visible": isPlaceholderVisible,
539
+ "select--top": ["top", "top-start", "top-end"].includes(
540
+ this.placement
541
+ ),
542
+ "select--bottom": [
543
+ "bottom",
544
+ "bottom-start",
545
+ "bottom-end"
546
+ ].includes(this.placement),
547
+ "select--small": this.size === "small",
548
+ "select--medium": this.size === "medium",
549
+ "select--large": this.size === "large",
550
+ "select--on-base": this.variant === "base",
551
+ "select--on-layer": this.variant === "layer"
552
+ })}
553
+ part="popup"
554
+ placement=${this.placement}
555
+ strategy=${this.hoist ? "fixed" : "absolute"}
556
+ flip
557
+ shift
558
+ sync=${this.noSyncWidth ? void 0 : "width"}
559
+ auto-size="vertical"
560
+ auto-size-padding="10"
561
+ >
562
+ <div
563
+ part="combobox"
564
+ class="select__combobox"
565
+ slot="anchor"
566
+ @click=${this.handleComboboxMouseDown}
567
+ @keydown=${this.handleComboboxKeyDown}
568
+ >
569
+ <slot part="prefix" name="prefix" class="select__prefix"></slot>
570
+ <div
571
+ class=${classMap({
572
+ "input-container": true
573
+ })}
574
+ >
575
+ ${this.multiple && this.value.length > 0 ? html`
576
+ <div part="tags" class="select__tags">
577
+ ${this.selectedOptions.map((option, index) => {
578
+ if (index < this.maxOptionsVisible || this.maxOptionsVisible <= 0) {
579
+ return html`
580
+ <dsa-tag
581
+ part="tag"
582
+ exportparts="
583
+ base:tag__base,
584
+ content:tag__content,
585
+ remove-button:tag__remove-button,
586
+ remove-button__base:tag__remove-button__base
587
+ "
588
+ size=${this.size}
589
+ removable
590
+ disable-removable-focus
591
+ @dsa-remove=${(event) => this.handleTagRemove(event, option)}
592
+ label=${option.getTextLabel()}
593
+ >
594
+ </dsa-tag>
595
+ `;
596
+ } else if (index === this.maxOptionsVisible) {
597
+ return html`
598
+ <dsa-tag
599
+ disable-removable-focus
600
+ size=${this.size}
601
+ label="+${this.selectedOptions.length - index}"
602
+ >
603
+ </dsa-tag>
604
+ `;
605
+ } else {
606
+ return null;
607
+ }
608
+ })}
609
+ </div>
610
+ ` : ""}
611
+
612
+ <input
613
+ id="input"
614
+ part="display-input"
615
+ class="select__display-input"
616
+ type="text"
617
+ .value=${this.displayLabel}
618
+ placeholder=${this.placeholder}
619
+ .disabled=${this.disabled}
620
+ size=${selectInputWidth}
621
+ autocomplete="off"
622
+ spellcheck="false"
623
+ autocapitalize="off"
624
+ title=${hasLabel ? void 0 : this.title}
625
+ aria-controls="listbox"
626
+ aria-autocomplete="list"
627
+ aria-expanded=${this.open ? "true" : "false"}
628
+ aria-haspopup="listbox"
629
+ aria-labelledby=${hasLabel ? "label" : void 0}
630
+ aria-label=${hasLabel ? void 0 : this.title}
631
+ aria-disabled=${this.disabled ? "true" : "false"}
632
+ aria-describedby="help-text"
633
+ aria-activedescendant=${(_b = (_a = this.currentOption) == null ? void 0 : _a.id) != null ? _b : ""}
634
+ role="combobox"
635
+ tabindex="0"
636
+ @change=${this.handleChange}
637
+ @input=${this.handleInput}
638
+ @focus=${this.handleFocus}
639
+ @blur=${this.handleBlur}
640
+ @invalid=${this.handleInvalid}
641
+ />
642
+ </div>
643
+
644
+ <input
645
+ class="select__value-input"
646
+ type="text"
647
+ ?disabled=${this.disabled}
648
+ ?required=${this.required}
649
+ .value=${this.value}
650
+ tabindex="-1"
651
+ aria-hidden="true"
652
+ @focus=${() => this.focus()}
653
+ @invalid=${this.handleInvalid}
654
+ />
655
+
656
+ ${hasClearIcon ? html`
657
+ <button
658
+ part="clear-button"
659
+ class="select__clear"
660
+ type="button"
661
+ aria-label=${this.localize.term("clearEntry")}
662
+ @mousedown=${this.handleClearMouseDown}
663
+ @click=${this.handleClearClick}
664
+ tabindex="-1"
665
+ >
666
+ <dsa-icon name="close"></dsa-icon>
667
+ </button>
668
+ ` : ""}
669
+
670
+ <dsa-icon
671
+ class="select__expand-icon"
672
+ name="arrow_drop_down"
673
+ ></dsa-icon>
674
+ </div>
675
+ <ul
676
+ id="listbox"
677
+ role="listbox"
678
+ aria-expanded=${this.open ? "true" : "false"}
679
+ aria-multiselectable="false"
680
+ aria-labelledby="label"
681
+ part="listbox"
682
+ class="select__listbox"
683
+ tabindex="-1"
684
+ @mouseup=${this.handleOptionClick}
685
+ @slotchange=${this.handleDefaultSlotChange}
686
+ >
687
+ ${this.filteredOptions.length > 0 ? this.filteredOptions : html`
688
+ <div class="select__empty_text">
689
+ <p>${this.localize.term("noMatchFound")}</p>
690
+ </div>
691
+ `}
692
+ </ul>
693
+
694
+ <slot
695
+ class="slot_options"
696
+ tabindex="-1"
697
+ @mouseup=${this.handleOptionClick}
698
+ @slotchange=${this.handleDefaultSlotChange}
699
+ >
700
+ </slot>
701
+ </dsa-popup>
702
+ </div>
703
+ <slot
704
+ name="help-text"
705
+ part="form-control-help-text"
706
+ id="help-text"
707
+ class="form-control__help-text"
708
+ aria-hidden=${hasHelpText ? "false" : "true"}
709
+ >
710
+ ${this.helpText}
711
+ </slot>
712
+
713
+ ${this.error && !this.disabled ? html`<dsa-error-text
714
+ part="form-control-error-text"
715
+ class="form-control__error-text"
716
+ >${this.errorMessage}</dsa-error-text
717
+ >` : ""}
718
+ </div>
719
+ `;
720
+ }
721
+ };
722
+ DSACombobox.styles = combobox_styles_default;
723
+ __decorateClass([
724
+ query(".select")
725
+ ], DSACombobox.prototype, "popup", 2);
726
+ __decorateClass([
727
+ query(".select__combobox")
728
+ ], DSACombobox.prototype, "combobox", 2);
729
+ __decorateClass([
730
+ query(".select__display-input")
731
+ ], DSACombobox.prototype, "displayInput", 2);
732
+ __decorateClass([
733
+ query(".select__value-input")
734
+ ], DSACombobox.prototype, "valueInput", 2);
735
+ __decorateClass([
736
+ query(".select__listbox")
737
+ ], DSACombobox.prototype, "listbox", 2);
738
+ __decorateClass([
739
+ state()
740
+ ], DSACombobox.prototype, "hasVisualFocus", 2);
741
+ __decorateClass([
742
+ state()
743
+ ], DSACombobox.prototype, "displayLabel", 2);
744
+ __decorateClass([
745
+ state()
746
+ ], DSACombobox.prototype, "currentOption", 2);
747
+ __decorateClass([
748
+ state()
749
+ ], DSACombobox.prototype, "selectedOptions", 2);
750
+ __decorateClass([
751
+ state()
752
+ ], DSACombobox.prototype, "allOptions", 2);
753
+ __decorateClass([
754
+ state()
755
+ ], DSACombobox.prototype, "filteredOptions", 2);
756
+ __decorateClass([
757
+ property()
758
+ ], DSACombobox.prototype, "name", 2);
759
+ __decorateClass([
760
+ property()
761
+ ], DSACombobox.prototype, "title", 2);
762
+ __decorateClass([
763
+ property({ type: Boolean, reflect: true })
764
+ ], DSACombobox.prototype, "open", 2);
765
+ __decorateClass([
766
+ property({
767
+ converter: {
768
+ fromAttribute: (value) => value.split(" "),
769
+ toAttribute: (value) => {
770
+ if (typeof value === "string") {
771
+ return value;
772
+ } else {
773
+ return value.join(" ");
774
+ }
775
+ }
776
+ }
777
+ })
778
+ ], DSACombobox.prototype, "value", 2);
779
+ __decorateClass([
780
+ defaultValue()
781
+ ], DSACombobox.prototype, "defaultValue", 2);
782
+ __decorateClass([
783
+ property()
784
+ ], DSACombobox.prototype, "size", 2);
785
+ __decorateClass([
786
+ property()
787
+ ], DSACombobox.prototype, "placeholder", 2);
788
+ __decorateClass([
789
+ property()
790
+ ], DSACombobox.prototype, "label", 2);
791
+ __decorateClass([
792
+ property({ reflect: true })
793
+ ], DSACombobox.prototype, "variant", 2);
794
+ __decorateClass([
795
+ property({ type: Boolean })
796
+ ], DSACombobox.prototype, "hoist", 2);
797
+ __decorateClass([
798
+ property({ reflect: true })
799
+ ], DSACombobox.prototype, "placement", 2);
800
+ __decorateClass([
801
+ property({ attribute: "help-text" })
802
+ ], DSACombobox.prototype, "helpText", 2);
803
+ __decorateClass([
804
+ property({ type: Boolean, reflect: true })
805
+ ], DSACombobox.prototype, "disabled", 2);
806
+ __decorateClass([
807
+ property({ type: Boolean })
808
+ ], DSACombobox.prototype, "clearable", 2);
809
+ __decorateClass([
810
+ property({ reflect: true })
811
+ ], DSACombobox.prototype, "form", 2);
812
+ __decorateClass([
813
+ property({ type: Boolean, reflect: true })
814
+ ], DSACombobox.prototype, "required", 2);
815
+ __decorateClass([
816
+ property({ type: Boolean })
817
+ ], DSACombobox.prototype, "error", 2);
818
+ __decorateClass([
819
+ property({ attribute: "error-message" })
820
+ ], DSACombobox.prototype, "errorMessage", 2);
821
+ __decorateClass([
822
+ property({ attribute: "no-sync-width", type: Boolean })
823
+ ], DSACombobox.prototype, "noSyncWidth", 2);
824
+ __decorateClass([
825
+ property({ type: Array, attribute: false })
826
+ ], DSACombobox.prototype, "items", 2);
827
+ __decorateClass([
828
+ property({ type: Boolean })
829
+ ], DSACombobox.prototype, "multiple", 2);
830
+ __decorateClass([
831
+ property({ attribute: "max-options-visible", type: Number })
832
+ ], DSACombobox.prototype, "maxOptionsVisible", 2);
833
+ __decorateClass([
834
+ watch("disabled", { waitUntilFirstUpdate: true })
835
+ ], DSACombobox.prototype, "handleDisabledChange", 1);
836
+ __decorateClass([
837
+ watch("items")
838
+ ], DSACombobox.prototype, "handleItemsChange", 1);
839
+ __decorateClass([
840
+ watch("value", { waitUntilFirstUpdate: true })
841
+ ], DSACombobox.prototype, "handleValueChange", 1);
842
+ __decorateClass([
843
+ watch("open", { waitUntilFirstUpdate: true })
844
+ ], DSACombobox.prototype, "handleOpenChange", 1);
845
+ DSACombobox = __decorateClass([
846
+ customElement("dsa-combobox")
847
+ ], DSACombobox);
848
+ setDefaultAnimation("select.show", {
849
+ keyframes: [
850
+ { opacity: 0, scale: 0.9 },
851
+ { opacity: 1, scale: 1 }
852
+ ],
853
+ options: { duration: 100, easing: "ease" }
854
+ });
855
+ setDefaultAnimation("select.hide", {
856
+ keyframes: [
857
+ { opacity: 1, scale: 1 },
858
+ { opacity: 0, scale: 0.9 }
859
+ ],
860
+ options: { duration: 100, easing: "ease" }
861
+ });
862
+
863
+ export {
864
+ DSACombobox
865
+ };