@synergy-design-system/components 1.4.0 → 1.5.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 (176) hide show
  1. package/dist/chunks/chunk.3B24TYVN.js +51 -0
  2. package/dist/chunks/chunk.3B24TYVN.js.map +7 -0
  3. package/dist/chunks/chunk.3HPG73GG.js +132 -0
  4. package/dist/chunks/chunk.3HPG73GG.js.map +7 -0
  5. package/dist/chunks/chunk.4KLCSMRA.js +96 -0
  6. package/dist/chunks/chunk.4KLCSMRA.js.map +7 -0
  7. package/dist/chunks/{chunk.BOURWTS5.js → chunk.4ZO3EKCL.js} +2 -2
  8. package/dist/chunks/{chunk.JFCQYLZB.js → chunk.5NJ7WWJW.js} +2 -2
  9. package/dist/chunks/{chunk.C2S53NYE.js → chunk.63IJYG6Q.js} +2 -2
  10. package/dist/chunks/chunk.6XU6OLZ3.js +310 -0
  11. package/dist/chunks/chunk.6XU6OLZ3.js.map +7 -0
  12. package/dist/chunks/{chunk.MMNPLBTH.js → chunk.7BHGTNHS.js} +2 -2
  13. package/dist/chunks/chunk.7HS3TULI.js +12 -0
  14. package/dist/chunks/chunk.7HS3TULI.js.map +7 -0
  15. package/dist/chunks/{chunk.VYKSU5VJ.js → chunk.A4YWJJLD.js} +2 -2
  16. package/dist/chunks/{chunk.43NPPDUU.js → chunk.AVJQ2BSM.js} +2 -2
  17. package/dist/chunks/{chunk.W46CFM2R.js → chunk.B2EJGIGY.js} +7 -13
  18. package/dist/chunks/chunk.B2EJGIGY.js.map +7 -0
  19. package/dist/chunks/chunk.BQG5LF7J.js +47 -0
  20. package/dist/chunks/chunk.BQG5LF7J.js.map +7 -0
  21. package/dist/chunks/{chunk.SNP6OECI.js → chunk.C5W2Y6KW.js} +8 -8
  22. package/dist/chunks/{chunk.SNP6OECI.js.map → chunk.C5W2Y6KW.js.map} +2 -2
  23. package/dist/chunks/{chunk.NZAZG5AN.js → chunk.CUHMPG7E.js} +3 -3
  24. package/dist/chunks/{chunk.7CKINLE4.js → chunk.DLDE3BC5.js} +2 -2
  25. package/dist/chunks/{chunk.RSGJ7C32.js → chunk.DPTZN6HY.js} +2 -2
  26. package/dist/chunks/{chunk.GKFUZ44I.js → chunk.ELPJP6AL.js} +2 -2
  27. package/dist/chunks/{chunk.4NG4BW3G.js → chunk.FLCUFEHS.js} +2 -2
  28. package/dist/chunks/chunk.FOTO5B4G.js +12 -0
  29. package/dist/chunks/chunk.FOTO5B4G.js.map +7 -0
  30. package/dist/chunks/{chunk.3CAAVHZZ.js → chunk.GAMJZXEL.js} +2 -2
  31. package/dist/chunks/{chunk.QT64OSWO.js → chunk.GGNKDYC2.js} +7 -7
  32. package/dist/chunks/{chunk.POZGJMTS.js → chunk.GYDJFPHM.js} +2 -2
  33. package/dist/chunks/{chunk.YL6PYHOS.js → chunk.IESSP23D.js} +7 -7
  34. package/dist/chunks/{chunk.62GAQV3Z.js → chunk.IYKQTZIY.js} +3 -3
  35. package/dist/chunks/{chunk.I2JLECCQ.js → chunk.JEOPTEUQ.js} +3 -3
  36. package/dist/chunks/{chunk.QBM7YT5M.js → chunk.JLTYAQFG.js} +2 -2
  37. package/dist/chunks/chunk.JN7CLMQZ.js +53 -0
  38. package/dist/chunks/chunk.JN7CLMQZ.js.map +7 -0
  39. package/dist/chunks/{chunk.7DUTGUSD.js → chunk.JQWJ7PHD.js} +2 -2
  40. package/dist/chunks/chunk.JXOHBU6V.js +334 -0
  41. package/dist/chunks/chunk.JXOHBU6V.js.map +7 -0
  42. package/dist/chunks/chunk.KG52EHDB.js +60 -0
  43. package/dist/chunks/chunk.KG52EHDB.js.map +7 -0
  44. package/dist/chunks/{chunk.OXUFFH57.js → chunk.KUZJTGHQ.js} +2 -2
  45. package/dist/chunks/{chunk.T27ALSOE.js → chunk.LL3V6HVM.js} +2 -2
  46. package/dist/chunks/{chunk.A4KYHNIH.js → chunk.LTCRPIZ5.js} +2 -2
  47. package/dist/chunks/{chunk.2Z2FGA3I.js → chunk.OPVDSHPD.js} +2 -2
  48. package/dist/chunks/chunk.OWMT6OL2.js +82 -0
  49. package/dist/chunks/chunk.OWMT6OL2.js.map +7 -0
  50. package/dist/chunks/{chunk.FSHPI6B5.js → chunk.PQLAXTRQ.js} +3 -3
  51. package/dist/chunks/{chunk.SHF6MEDK.js → chunk.RU7P5HHF.js} +2 -2
  52. package/dist/chunks/chunk.SS46QCYH.js +811 -0
  53. package/dist/chunks/chunk.SS46QCYH.js.map +7 -0
  54. package/dist/chunks/{chunk.ZKVZHEJM.js → chunk.TY5F2VTK.js} +2 -2
  55. package/dist/chunks/{chunk.533DZ5GZ.js → chunk.UGYBBM5O.js} +3 -3
  56. package/dist/chunks/chunk.UXUMV3TL.js +12 -0
  57. package/dist/chunks/chunk.UXUMV3TL.js.map +7 -0
  58. package/dist/chunks/chunk.W6V7TPGK.js +104 -0
  59. package/dist/chunks/chunk.W6V7TPGK.js.map +7 -0
  60. package/dist/chunks/{chunk.NQZRYJEZ.js → chunk.Y6HNLEFW.js} +2 -2
  61. package/dist/components/button/button.component.js +5 -5
  62. package/dist/components/button/button.js +6 -6
  63. package/dist/components/button-group/button-group.component.js +2 -2
  64. package/dist/components/button-group/button-group.js +3 -3
  65. package/dist/components/checkbox/checkbox.component.js +3 -3
  66. package/dist/components/checkbox/checkbox.js +4 -4
  67. package/dist/components/divider/divider.component.js +2 -2
  68. package/dist/components/divider/divider.js +3 -3
  69. package/dist/components/icon/icon.component.js +2 -2
  70. package/dist/components/icon/icon.js +3 -3
  71. package/dist/components/icon-button/icon-button.component.js +3 -3
  72. package/dist/components/icon-button/icon-button.js +4 -4
  73. package/dist/components/input/input.component.js +6 -6
  74. package/dist/components/input/input.custom.styles.js +1 -1
  75. package/dist/components/input/input.js +7 -7
  76. package/dist/components/input/input.styles.js +2 -2
  77. package/dist/components/optgroup/optgroup.component.d.ts +47 -0
  78. package/dist/components/optgroup/optgroup.component.js +16 -0
  79. package/dist/components/optgroup/optgroup.component.js.map +7 -0
  80. package/dist/components/optgroup/optgroup.d.ts +8 -0
  81. package/dist/components/optgroup/optgroup.js +17 -0
  82. package/dist/components/optgroup/optgroup.js.map +7 -0
  83. package/dist/components/optgroup/optgroup.styles.d.ts +2 -0
  84. package/dist/components/optgroup/optgroup.styles.js +8 -0
  85. package/dist/components/optgroup/optgroup.styles.js.map +7 -0
  86. package/dist/components/option/option.component.d.ts +51 -0
  87. package/dist/components/option/option.component.js +22 -0
  88. package/dist/components/option/option.component.js.map +7 -0
  89. package/dist/components/option/option.custom.styles.d.ts +2 -0
  90. package/dist/components/option/option.custom.styles.js +8 -0
  91. package/dist/components/option/option.custom.styles.js.map +7 -0
  92. package/dist/components/option/option.d.ts +8 -0
  93. package/dist/components/option/option.js +23 -0
  94. package/dist/components/option/option.js.map +7 -0
  95. package/dist/components/option/option.styles.d.ts +2 -0
  96. package/dist/components/option/option.styles.js +10 -0
  97. package/dist/components/option/option.styles.js.map +7 -0
  98. package/dist/components/popup/popup.component.d.ts +139 -0
  99. package/dist/components/popup/popup.component.js +11 -0
  100. package/dist/components/popup/popup.component.js.map +7 -0
  101. package/dist/components/popup/popup.styles.d.ts +2 -0
  102. package/dist/components/popup/popup.styles.js +9 -0
  103. package/dist/components/popup/popup.styles.js.map +7 -0
  104. package/dist/components/radio/radio.component.js +3 -3
  105. package/dist/components/radio/radio.js +4 -4
  106. package/dist/components/radio-button/radio-button.component.js +2 -2
  107. package/dist/components/radio-button/radio-button.js +3 -3
  108. package/dist/components/radio-group/radio-group.component.js +3 -3
  109. package/dist/components/radio-group/radio-group.js +4 -4
  110. package/dist/components/select/select.component.d.ts +180 -0
  111. package/dist/components/select/select.component.js +35 -0
  112. package/dist/components/select/select.component.js.map +7 -0
  113. package/dist/components/select/select.custom.styles.d.ts +2 -0
  114. package/dist/components/select/select.custom.styles.js +8 -0
  115. package/dist/components/select/select.custom.styles.js.map +7 -0
  116. package/dist/components/select/select.d.ts +8 -0
  117. package/dist/components/select/select.js +36 -0
  118. package/dist/components/select/select.js.map +7 -0
  119. package/dist/components/select/select.styles.d.ts +2 -0
  120. package/dist/components/select/select.styles.js +11 -0
  121. package/dist/components/select/select.styles.js.map +7 -0
  122. package/dist/components/spinner/spinner.component.js +2 -2
  123. package/dist/components/switch/switch.component.js +2 -2
  124. package/dist/components/switch/switch.js +3 -3
  125. package/dist/components/tag/tag.component.js +4 -4
  126. package/dist/components/tag/tag.js +5 -5
  127. package/dist/components/textarea/textarea.component.js +2 -2
  128. package/dist/components/textarea/textarea.js +3 -3
  129. package/dist/custom-elements.json +2376 -556
  130. package/dist/events/events.d.ts +5 -0
  131. package/dist/events/syn-after-hide.d.ts +6 -0
  132. package/dist/events/syn-after-show.d.ts +6 -0
  133. package/dist/events/syn-hide.d.ts +6 -0
  134. package/dist/events/syn-reposition.d.ts +6 -0
  135. package/dist/events/syn-show.d.ts +6 -0
  136. package/dist/internal/animate.d.ts +22 -0
  137. package/dist/internal/event.d.ts +2 -0
  138. package/dist/internal/offset.d.ts +11 -0
  139. package/dist/internal/scroll.d.ts +11 -0
  140. package/dist/synergy.d.ts +3 -0
  141. package/dist/synergy.js +63 -40
  142. package/dist/utilities/animation-registry.d.ts +24 -0
  143. package/dist/utilities/animation-registry.js +12 -0
  144. package/dist/utilities/animation-registry.js.map +7 -0
  145. package/dist/vscode.html-custom-data.json +304 -17
  146. package/dist/web-types.json +664 -30
  147. package/package.json +32 -31
  148. package/dist/chunks/chunk.W46CFM2R.js.map +0 -7
  149. /package/dist/chunks/{chunk.BOURWTS5.js.map → chunk.4ZO3EKCL.js.map} +0 -0
  150. /package/dist/chunks/{chunk.JFCQYLZB.js.map → chunk.5NJ7WWJW.js.map} +0 -0
  151. /package/dist/chunks/{chunk.C2S53NYE.js.map → chunk.63IJYG6Q.js.map} +0 -0
  152. /package/dist/chunks/{chunk.MMNPLBTH.js.map → chunk.7BHGTNHS.js.map} +0 -0
  153. /package/dist/chunks/{chunk.VYKSU5VJ.js.map → chunk.A4YWJJLD.js.map} +0 -0
  154. /package/dist/chunks/{chunk.43NPPDUU.js.map → chunk.AVJQ2BSM.js.map} +0 -0
  155. /package/dist/chunks/{chunk.NZAZG5AN.js.map → chunk.CUHMPG7E.js.map} +0 -0
  156. /package/dist/chunks/{chunk.7CKINLE4.js.map → chunk.DLDE3BC5.js.map} +0 -0
  157. /package/dist/chunks/{chunk.RSGJ7C32.js.map → chunk.DPTZN6HY.js.map} +0 -0
  158. /package/dist/chunks/{chunk.GKFUZ44I.js.map → chunk.ELPJP6AL.js.map} +0 -0
  159. /package/dist/chunks/{chunk.4NG4BW3G.js.map → chunk.FLCUFEHS.js.map} +0 -0
  160. /package/dist/chunks/{chunk.3CAAVHZZ.js.map → chunk.GAMJZXEL.js.map} +0 -0
  161. /package/dist/chunks/{chunk.QT64OSWO.js.map → chunk.GGNKDYC2.js.map} +0 -0
  162. /package/dist/chunks/{chunk.POZGJMTS.js.map → chunk.GYDJFPHM.js.map} +0 -0
  163. /package/dist/chunks/{chunk.YL6PYHOS.js.map → chunk.IESSP23D.js.map} +0 -0
  164. /package/dist/chunks/{chunk.62GAQV3Z.js.map → chunk.IYKQTZIY.js.map} +0 -0
  165. /package/dist/chunks/{chunk.I2JLECCQ.js.map → chunk.JEOPTEUQ.js.map} +0 -0
  166. /package/dist/chunks/{chunk.QBM7YT5M.js.map → chunk.JLTYAQFG.js.map} +0 -0
  167. /package/dist/chunks/{chunk.7DUTGUSD.js.map → chunk.JQWJ7PHD.js.map} +0 -0
  168. /package/dist/chunks/{chunk.OXUFFH57.js.map → chunk.KUZJTGHQ.js.map} +0 -0
  169. /package/dist/chunks/{chunk.T27ALSOE.js.map → chunk.LL3V6HVM.js.map} +0 -0
  170. /package/dist/chunks/{chunk.A4KYHNIH.js.map → chunk.LTCRPIZ5.js.map} +0 -0
  171. /package/dist/chunks/{chunk.2Z2FGA3I.js.map → chunk.OPVDSHPD.js.map} +0 -0
  172. /package/dist/chunks/{chunk.FSHPI6B5.js.map → chunk.PQLAXTRQ.js.map} +0 -0
  173. /package/dist/chunks/{chunk.SHF6MEDK.js.map → chunk.RU7P5HHF.js.map} +0 -0
  174. /package/dist/chunks/{chunk.ZKVZHEJM.js.map → chunk.TY5F2VTK.js.map} +0 -0
  175. /package/dist/chunks/{chunk.533DZ5GZ.js.map → chunk.UGYBBM5O.js.map} +0 -0
  176. /package/dist/chunks/{chunk.NQZRYJEZ.js.map → chunk.Y6HNLEFW.js.map} +0 -0
@@ -0,0 +1,811 @@
1
+ import {
2
+ getAnimation,
3
+ setDefaultAnimation
4
+ } from "./chunk.BQG5LF7J.js";
5
+ import {
6
+ SynTag
7
+ } from "./chunk.CUHMPG7E.js";
8
+ import {
9
+ select_styles_default
10
+ } from "./chunk.6XU6OLZ3.js";
11
+ import {
12
+ SynPopup
13
+ } from "./chunk.JXOHBU6V.js";
14
+ import {
15
+ defaultValue
16
+ } from "./chunk.WFAJR3FN.js";
17
+ import {
18
+ HasSlotController
19
+ } from "./chunk.XGXFE6IF.js";
20
+ import {
21
+ LocalizeController
22
+ } from "./chunk.LAB4YJYE.js";
23
+ import {
24
+ FormControlController
25
+ } from "./chunk.AMTCNRDE.js";
26
+ import {
27
+ SynIcon
28
+ } from "./chunk.63IJYG6Q.js";
29
+ import {
30
+ watch
31
+ } from "./chunk.VZ7S7YYN.js";
32
+ import {
33
+ SynergyElement
34
+ } from "./chunk.C5W2Y6KW.js";
35
+ import {
36
+ __decorateClass,
37
+ __spreadProps,
38
+ __spreadValues
39
+ } from "./chunk.DJOAQ4JU.js";
40
+
41
+ // src/internal/animate.ts
42
+ function animateTo(el, keyframes, options) {
43
+ return new Promise((resolve) => {
44
+ if ((options == null ? void 0 : options.duration) === Infinity) {
45
+ throw new Error("Promise-based animations must be finite.");
46
+ }
47
+ const animation = el.animate(keyframes, __spreadProps(__spreadValues({}, options), {
48
+ duration: prefersReducedMotion() ? 0 : options.duration
49
+ }));
50
+ animation.addEventListener("cancel", resolve, { once: true });
51
+ animation.addEventListener("finish", resolve, { once: true });
52
+ });
53
+ }
54
+ function prefersReducedMotion() {
55
+ const query2 = window.matchMedia("(prefers-reduced-motion: reduce)");
56
+ return query2.matches;
57
+ }
58
+ function stopAnimations(el) {
59
+ return Promise.all(
60
+ el.getAnimations().map((animation) => {
61
+ return new Promise((resolve) => {
62
+ const handleAnimationEvent = requestAnimationFrame(resolve);
63
+ animation.addEventListener("cancel", () => handleAnimationEvent, { once: true });
64
+ animation.addEventListener("finish", () => handleAnimationEvent, { once: true });
65
+ animation.cancel();
66
+ });
67
+ })
68
+ );
69
+ }
70
+
71
+ // src/components/select/select.component.ts
72
+ import { classMap } from "lit/directives/class-map.js";
73
+ import { html } from "lit";
74
+ import { property, query, state } from "lit/decorators.js";
75
+
76
+ // src/internal/offset.ts
77
+ function getOffset(element, parent) {
78
+ return {
79
+ top: Math.round(element.getBoundingClientRect().top - parent.getBoundingClientRect().top),
80
+ left: Math.round(element.getBoundingClientRect().left - parent.getBoundingClientRect().left)
81
+ };
82
+ }
83
+
84
+ // src/internal/scroll.ts
85
+ function scrollIntoView(element, container, direction = "vertical", behavior = "smooth") {
86
+ const offset = getOffset(element, container);
87
+ const offsetTop = offset.top + container.scrollTop;
88
+ const offsetLeft = offset.left + container.scrollLeft;
89
+ const minX = container.scrollLeft;
90
+ const maxX = container.scrollLeft + container.offsetWidth;
91
+ const minY = container.scrollTop;
92
+ const maxY = container.scrollTop + container.offsetHeight;
93
+ if (direction === "horizontal" || direction === "both") {
94
+ if (offsetLeft < minX) {
95
+ container.scrollTo({ left: offsetLeft, behavior });
96
+ } else if (offsetLeft + element.clientWidth > maxX) {
97
+ container.scrollTo({ left: offsetLeft - container.offsetWidth + element.clientWidth, behavior });
98
+ }
99
+ }
100
+ if (direction === "vertical" || direction === "both") {
101
+ if (offsetTop < minY) {
102
+ container.scrollTo({ top: offsetTop, behavior });
103
+ } else if (offsetTop + element.clientHeight > maxY) {
104
+ container.scrollTo({ top: offsetTop - container.offsetHeight + element.clientHeight, behavior });
105
+ }
106
+ }
107
+ }
108
+
109
+ // src/components/select/select.component.ts
110
+ import { unsafeHTML } from "lit/directives/unsafe-html.js";
111
+
112
+ // src/internal/event.ts
113
+ function waitForEvent(el, eventName) {
114
+ return new Promise((resolve) => {
115
+ function done(event) {
116
+ if (event.target === el) {
117
+ el.removeEventListener(eventName, done);
118
+ resolve();
119
+ }
120
+ }
121
+ el.addEventListener(eventName, done);
122
+ });
123
+ }
124
+
125
+ // src/components/select/select.component.ts
126
+ var SynSelect = class extends SynergyElement {
127
+ constructor() {
128
+ super(...arguments);
129
+ this.formControlController = new FormControlController(this, {
130
+ assumeInteractionOn: ["syn-blur", "syn-input"]
131
+ });
132
+ this.hasSlotController = new HasSlotController(this, "help-text", "label");
133
+ this.localize = new LocalizeController(this);
134
+ this.typeToSelectString = "";
135
+ this.hasFocus = false;
136
+ this.displayLabel = "";
137
+ this.selectedOptions = [];
138
+ this.name = "";
139
+ this.value = "";
140
+ this.defaultValue = "";
141
+ this.size = "medium";
142
+ this.placeholder = "";
143
+ this.multiple = false;
144
+ this.maxOptionsVisible = 3;
145
+ this.disabled = false;
146
+ this.clearable = false;
147
+ this.open = false;
148
+ this.hoist = false;
149
+ this.label = "";
150
+ this.placement = "bottom";
151
+ this.helpText = "";
152
+ this.form = "";
153
+ this.required = false;
154
+ this.getTag = (option) => {
155
+ return html`
156
+ <syn-tag
157
+ part="tag"
158
+ exportparts="
159
+ base:tag__base,
160
+ content:tag__content,
161
+ remove-button:tag__remove-button,
162
+ remove-button__base:tag__remove-button__base
163
+ "
164
+ size=${this.size}
165
+ removable
166
+ @syn-remove=${(event) => this.handleTagRemove(event, option)}
167
+ >
168
+ ${option.getTextLabel()}
169
+ </syn-tag>
170
+ `;
171
+ };
172
+ this.handleDocumentFocusIn = (event) => {
173
+ const path = event.composedPath();
174
+ if (this && !path.includes(this)) {
175
+ this.hide();
176
+ }
177
+ };
178
+ this.handleDocumentKeyDown = (event) => {
179
+ const target = event.target;
180
+ const isClearButton = target.closest(".select__clear") !== null;
181
+ const isIconButton = target.closest("syn-icon-button") !== null;
182
+ if (isClearButton || isIconButton) {
183
+ return;
184
+ }
185
+ if (event.key === "Escape" && this.open) {
186
+ event.preventDefault();
187
+ event.stopPropagation();
188
+ this.hide();
189
+ this.displayInput.focus({ preventScroll: true });
190
+ }
191
+ if (event.key === "Enter" || event.key === " " && this.typeToSelectString === "") {
192
+ event.preventDefault();
193
+ event.stopImmediatePropagation();
194
+ if (!this.open) {
195
+ this.show();
196
+ return;
197
+ }
198
+ if (this.currentOption && !this.currentOption.disabled) {
199
+ if (this.multiple) {
200
+ this.toggleOptionSelection(this.currentOption);
201
+ } else {
202
+ this.setSelectedOptions(this.currentOption);
203
+ }
204
+ this.updateComplete.then(() => {
205
+ this.emit("syn-input");
206
+ this.emit("syn-change");
207
+ });
208
+ if (!this.multiple) {
209
+ this.hide();
210
+ this.displayInput.focus({ preventScroll: true });
211
+ }
212
+ }
213
+ return;
214
+ }
215
+ if (["ArrowUp", "ArrowDown", "Home", "End"].includes(event.key)) {
216
+ const allOptions = this.getAllOptions();
217
+ const currentIndex = allOptions.indexOf(this.currentOption);
218
+ let newIndex = Math.max(0, currentIndex);
219
+ event.preventDefault();
220
+ if (!this.open) {
221
+ this.show();
222
+ if (this.currentOption) {
223
+ return;
224
+ }
225
+ }
226
+ if (event.key === "ArrowDown") {
227
+ newIndex = currentIndex + 1;
228
+ if (newIndex > allOptions.length - 1)
229
+ newIndex = 0;
230
+ } else if (event.key === "ArrowUp") {
231
+ newIndex = currentIndex - 1;
232
+ if (newIndex < 0)
233
+ newIndex = allOptions.length - 1;
234
+ } else if (event.key === "Home") {
235
+ newIndex = 0;
236
+ } else if (event.key === "End") {
237
+ newIndex = allOptions.length - 1;
238
+ }
239
+ this.setCurrentOption(allOptions[newIndex]);
240
+ }
241
+ if (event.key.length === 1 || event.key === "Backspace") {
242
+ const allOptions = this.getAllOptions();
243
+ if (event.metaKey || event.ctrlKey || event.altKey) {
244
+ return;
245
+ }
246
+ if (!this.open) {
247
+ if (event.key === "Backspace") {
248
+ return;
249
+ }
250
+ this.show();
251
+ }
252
+ event.stopPropagation();
253
+ event.preventDefault();
254
+ clearTimeout(this.typeToSelectTimeout);
255
+ this.typeToSelectTimeout = window.setTimeout(() => this.typeToSelectString = "", 1e3);
256
+ if (event.key === "Backspace") {
257
+ this.typeToSelectString = this.typeToSelectString.slice(0, -1);
258
+ } else {
259
+ this.typeToSelectString += event.key.toLowerCase();
260
+ }
261
+ for (const option of allOptions) {
262
+ const label = option.getTextLabel().toLowerCase();
263
+ if (label.startsWith(this.typeToSelectString)) {
264
+ this.setCurrentOption(option);
265
+ break;
266
+ }
267
+ }
268
+ }
269
+ };
270
+ this.handleDocumentMouseDown = (event) => {
271
+ const path = event.composedPath();
272
+ if (this && !path.includes(this)) {
273
+ this.hide();
274
+ }
275
+ };
276
+ }
277
+ /** Gets the validity state object */
278
+ get validity() {
279
+ return this.valueInput.validity;
280
+ }
281
+ /** Gets the validation message */
282
+ get validationMessage() {
283
+ return this.valueInput.validationMessage;
284
+ }
285
+ connectedCallback() {
286
+ super.connectedCallback();
287
+ this.open = false;
288
+ }
289
+ addOpenListeners() {
290
+ document.addEventListener("focusin", this.handleDocumentFocusIn);
291
+ document.addEventListener("keydown", this.handleDocumentKeyDown);
292
+ document.addEventListener("mousedown", this.handleDocumentMouseDown);
293
+ }
294
+ removeOpenListeners() {
295
+ document.removeEventListener("focusin", this.handleDocumentFocusIn);
296
+ document.removeEventListener("keydown", this.handleDocumentKeyDown);
297
+ document.removeEventListener("mousedown", this.handleDocumentMouseDown);
298
+ }
299
+ handleFocus() {
300
+ this.hasFocus = true;
301
+ this.displayInput.setSelectionRange(0, 0);
302
+ this.emit("syn-focus");
303
+ }
304
+ handleBlur() {
305
+ this.hasFocus = false;
306
+ this.emit("syn-blur");
307
+ }
308
+ handleLabelClick() {
309
+ this.displayInput.focus();
310
+ }
311
+ handleComboboxMouseDown(event) {
312
+ const path = event.composedPath();
313
+ const isIconButton = path.some((el) => el instanceof Element && el.tagName.toLowerCase() === "syn-icon-button");
314
+ if (this.disabled || isIconButton) {
315
+ return;
316
+ }
317
+ event.preventDefault();
318
+ this.displayInput.focus({ preventScroll: true });
319
+ this.open = !this.open;
320
+ }
321
+ handleComboboxKeyDown(event) {
322
+ event.stopPropagation();
323
+ this.handleDocumentKeyDown(event);
324
+ }
325
+ handleClearClick(event) {
326
+ event.stopPropagation();
327
+ if (this.value !== "") {
328
+ this.setSelectedOptions([]);
329
+ this.displayInput.focus({ preventScroll: true });
330
+ this.updateComplete.then(() => {
331
+ this.emit("syn-clear");
332
+ this.emit("syn-input");
333
+ this.emit("syn-change");
334
+ });
335
+ }
336
+ }
337
+ handleClearMouseDown(event) {
338
+ event.stopPropagation();
339
+ event.preventDefault();
340
+ }
341
+ handleOptionClick(event) {
342
+ const target = event.target;
343
+ const option = target.closest("syn-option");
344
+ const oldValue = this.value;
345
+ if (option && !option.disabled) {
346
+ if (this.multiple) {
347
+ this.toggleOptionSelection(option);
348
+ } else {
349
+ this.setSelectedOptions(option);
350
+ }
351
+ this.updateComplete.then(() => this.displayInput.focus({ preventScroll: true }));
352
+ if (this.value !== oldValue) {
353
+ this.updateComplete.then(() => {
354
+ this.emit("syn-input");
355
+ this.emit("syn-change");
356
+ });
357
+ }
358
+ if (!this.multiple) {
359
+ this.hide();
360
+ this.displayInput.focus({ preventScroll: true });
361
+ }
362
+ }
363
+ }
364
+ handleDefaultSlotChange() {
365
+ const allOptions = this.getAllOptions();
366
+ const value = Array.isArray(this.value) ? this.value : [this.value];
367
+ const values = [];
368
+ if (customElements.get("syn-option")) {
369
+ allOptions.forEach((option) => values.push(option.value));
370
+ this.setSelectedOptions(allOptions.filter((el) => value.includes(el.value)));
371
+ } else {
372
+ customElements.whenDefined("syn-option").then(() => this.handleDefaultSlotChange());
373
+ }
374
+ }
375
+ handleTagRemove(event, option) {
376
+ event.stopPropagation();
377
+ if (!this.disabled) {
378
+ this.toggleOptionSelection(option, false);
379
+ this.updateComplete.then(() => {
380
+ this.emit("syn-input");
381
+ this.emit("syn-change");
382
+ });
383
+ }
384
+ }
385
+ // Gets an array of all <syn-option> elements
386
+ getAllOptions() {
387
+ return [...this.querySelectorAll("syn-option")];
388
+ }
389
+ // Gets the first <syn-option> element
390
+ getFirstOption() {
391
+ return this.querySelector("syn-option");
392
+ }
393
+ // Sets the current option, which is the option the user is currently interacting with (e.g. via keyboard). Only one
394
+ // option may be "current" at a time.
395
+ setCurrentOption(option) {
396
+ const allOptions = this.getAllOptions();
397
+ allOptions.forEach((el) => {
398
+ el.current = false;
399
+ el.tabIndex = -1;
400
+ });
401
+ if (option) {
402
+ this.currentOption = option;
403
+ option.current = true;
404
+ option.tabIndex = 0;
405
+ option.focus();
406
+ }
407
+ }
408
+ // Sets the selected option(s)
409
+ setSelectedOptions(option) {
410
+ const allOptions = this.getAllOptions();
411
+ const newSelectedOptions = Array.isArray(option) ? option : [option];
412
+ allOptions.forEach((el) => el.selected = false);
413
+ if (newSelectedOptions.length) {
414
+ newSelectedOptions.forEach((el) => el.selected = true);
415
+ }
416
+ this.selectionChanged();
417
+ }
418
+ // Toggles an option's selected state
419
+ toggleOptionSelection(option, force) {
420
+ if (force === true || force === false) {
421
+ option.selected = force;
422
+ } else {
423
+ option.selected = !option.selected;
424
+ }
425
+ this.selectionChanged();
426
+ }
427
+ // This method must be called whenever the selection changes. It will update the selected options cache, the current
428
+ // value, and the display value
429
+ selectionChanged() {
430
+ var _a, _b, _c, _d;
431
+ this.selectedOptions = this.getAllOptions().filter((el) => el.selected);
432
+ if (this.multiple) {
433
+ this.value = this.selectedOptions.map((el) => el.value);
434
+ if (this.placeholder && this.value.length === 0) {
435
+ this.displayLabel = "";
436
+ } else {
437
+ this.displayLabel = this.localize.term("numOptionsSelected", this.selectedOptions.length);
438
+ }
439
+ } else {
440
+ this.value = (_b = (_a = this.selectedOptions[0]) == null ? void 0 : _a.value) != null ? _b : "";
441
+ this.displayLabel = (_d = (_c = this.selectedOptions[0]) == null ? void 0 : _c.getTextLabel()) != null ? _d : "";
442
+ }
443
+ this.updateComplete.then(() => {
444
+ this.formControlController.updateValidity();
445
+ });
446
+ }
447
+ get tags() {
448
+ return this.selectedOptions.map((option, index) => {
449
+ if (index < this.maxOptionsVisible || this.maxOptionsVisible <= 0) {
450
+ const tag = this.getTag(option, index);
451
+ return html`<div @syn-remove=${(e) => this.handleTagRemove(e, option)}>
452
+ ${typeof tag === "string" ? unsafeHTML(tag) : tag}
453
+ </div>`;
454
+ } else if (index === this.maxOptionsVisible) {
455
+ return html`<syn-tag>+${this.selectedOptions.length - index}</syn-tag>`;
456
+ }
457
+ return html``;
458
+ });
459
+ }
460
+ handleInvalid(event) {
461
+ this.formControlController.setValidity(false);
462
+ this.formControlController.emitInvalidEvent(event);
463
+ }
464
+ handleDisabledChange() {
465
+ if (this.disabled) {
466
+ this.open = false;
467
+ this.handleOpenChange();
468
+ }
469
+ }
470
+ handleValueChange() {
471
+ const allOptions = this.getAllOptions();
472
+ const value = Array.isArray(this.value) ? this.value : [this.value];
473
+ this.setSelectedOptions(allOptions.filter((el) => value.includes(el.value)));
474
+ }
475
+ async handleOpenChange() {
476
+ if (this.open && !this.disabled) {
477
+ this.setCurrentOption(this.selectedOptions[0] || this.getFirstOption());
478
+ this.emit("syn-show");
479
+ this.addOpenListeners();
480
+ await stopAnimations(this);
481
+ this.listbox.hidden = false;
482
+ this.popup.active = true;
483
+ requestAnimationFrame(() => {
484
+ this.setCurrentOption(this.currentOption);
485
+ });
486
+ const { keyframes, options } = getAnimation(this, "select.show", { dir: this.localize.dir() });
487
+ await animateTo(this.popup.popup, keyframes, options);
488
+ if (this.currentOption) {
489
+ scrollIntoView(this.currentOption, this.listbox, "vertical", "auto");
490
+ }
491
+ this.emit("syn-after-show");
492
+ } else {
493
+ this.emit("syn-hide");
494
+ this.removeOpenListeners();
495
+ await stopAnimations(this);
496
+ const { keyframes, options } = getAnimation(this, "select.hide", { dir: this.localize.dir() });
497
+ await animateTo(this.popup.popup, keyframes, options);
498
+ this.listbox.hidden = true;
499
+ this.popup.active = false;
500
+ this.emit("syn-after-hide");
501
+ }
502
+ }
503
+ /** Shows the listbox. */
504
+ async show() {
505
+ if (this.open || this.disabled) {
506
+ this.open = false;
507
+ return void 0;
508
+ }
509
+ this.open = true;
510
+ return waitForEvent(this, "syn-after-show");
511
+ }
512
+ /** Hides the listbox. */
513
+ async hide() {
514
+ if (!this.open || this.disabled) {
515
+ this.open = false;
516
+ return void 0;
517
+ }
518
+ this.open = false;
519
+ return waitForEvent(this, "syn-after-hide");
520
+ }
521
+ /** Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid. */
522
+ checkValidity() {
523
+ return this.valueInput.checkValidity();
524
+ }
525
+ /** Gets the associated form, if one exists. */
526
+ getForm() {
527
+ return this.formControlController.getForm();
528
+ }
529
+ /** Checks for validity and shows the browser's validation message if the control is invalid. */
530
+ reportValidity() {
531
+ return this.valueInput.reportValidity();
532
+ }
533
+ /** Sets a custom validation message. Pass an empty string to restore validity. */
534
+ setCustomValidity(message) {
535
+ this.valueInput.setCustomValidity(message);
536
+ this.formControlController.updateValidity();
537
+ }
538
+ /** Sets focus on the control. */
539
+ focus(options) {
540
+ this.displayInput.focus(options);
541
+ }
542
+ /** Removes focus from the control. */
543
+ blur() {
544
+ this.displayInput.blur();
545
+ }
546
+ render() {
547
+ const hasLabelSlot = this.hasSlotController.test("label");
548
+ const hasHelpTextSlot = this.hasSlotController.test("help-text");
549
+ const hasLabel = this.label ? true : !!hasLabelSlot;
550
+ const hasHelpText = this.helpText ? true : !!hasHelpTextSlot;
551
+ const hasClearIcon = this.clearable && !this.disabled && this.value.length > 0;
552
+ const isPlaceholderVisible = this.placeholder && this.value.length === 0;
553
+ return html`
554
+ <div
555
+ part="form-control"
556
+ class=${classMap({
557
+ "form-control": true,
558
+ "form-control--small": this.size === "small",
559
+ "form-control--medium": this.size === "medium",
560
+ "form-control--large": this.size === "large",
561
+ "form-control--has-label": hasLabel,
562
+ "form-control--has-help-text": hasHelpText
563
+ })}
564
+ >
565
+ <label
566
+ id="label"
567
+ part="form-control-label"
568
+ class="form-control__label"
569
+ aria-hidden=${hasLabel ? "false" : "true"}
570
+ @click=${this.handleLabelClick}
571
+ >
572
+ <slot name="label">${this.label}</slot>
573
+ </label>
574
+
575
+ <div part="form-control-input" class="form-control-input">
576
+ <syn-popup
577
+ class=${classMap({
578
+ select: true,
579
+ "select--standard": true,
580
+ "select--open": this.open,
581
+ "select--disabled": this.disabled,
582
+ "select--multiple": this.multiple,
583
+ "select--focused": this.hasFocus,
584
+ "select--placeholder-visible": isPlaceholderVisible,
585
+ "select--top": this.placement === "top",
586
+ "select--bottom": this.placement === "bottom",
587
+ "select--small": this.size === "small",
588
+ "select--medium": this.size === "medium",
589
+ "select--large": this.size === "large"
590
+ })}
591
+ placement=${this.placement}
592
+ strategy=${this.hoist ? "fixed" : "absolute"}
593
+ flip
594
+ shift
595
+ sync="width"
596
+ auto-size="vertical"
597
+ auto-size-padding="10"
598
+ >
599
+ <div
600
+ part="combobox"
601
+ class="select__combobox"
602
+ slot="anchor"
603
+ @keydown=${this.handleComboboxKeyDown}
604
+ @mousedown=${this.handleComboboxMouseDown}
605
+ >
606
+ <slot part="prefix" name="prefix" class="select__prefix"></slot>
607
+
608
+ <input
609
+ part="display-input"
610
+ class="select__display-input"
611
+ type="text"
612
+ placeholder=${this.placeholder}
613
+ .disabled=${this.disabled}
614
+ .value=${this.displayLabel}
615
+ autocomplete="off"
616
+ spellcheck="false"
617
+ autocapitalize="off"
618
+ readonly
619
+ aria-controls="listbox"
620
+ aria-expanded=${this.open ? "true" : "false"}
621
+ aria-haspopup="listbox"
622
+ aria-labelledby="label"
623
+ aria-disabled=${this.disabled ? "true" : "false"}
624
+ aria-describedby="help-text"
625
+ role="combobox"
626
+ tabindex="0"
627
+ @focus=${this.handleFocus}
628
+ @blur=${this.handleBlur}
629
+ />
630
+
631
+ ${this.multiple ? html`<div part="tags" class="select__tags">${this.tags}</div>` : ""}
632
+
633
+ <input
634
+ class="select__value-input"
635
+ type="text"
636
+ ?disabled=${this.disabled}
637
+ ?required=${this.required}
638
+ .value=${Array.isArray(this.value) ? this.value.join(", ") : this.value}
639
+ tabindex="-1"
640
+ aria-hidden="true"
641
+ @focus=${() => this.focus()}
642
+ @invalid=${this.handleInvalid}
643
+ />
644
+
645
+ ${hasClearIcon ? html`
646
+ <button
647
+ part="clear-button"
648
+ class="select__clear"
649
+ type="button"
650
+ aria-label=${this.localize.term("clearEntry")}
651
+ @mousedown=${this.handleClearMouseDown}
652
+ @click=${this.handleClearClick}
653
+ tabindex="-1"
654
+ >
655
+ <slot name="clear-icon">
656
+ <syn-icon name="x-circle-fill" library="system"></syn-icon>
657
+ </slot>
658
+ </button>
659
+ ` : ""}
660
+
661
+ <slot name="expand-icon" part="expand-icon" class="select__expand-icon">
662
+ <syn-icon library="system" name="chevron-down"></syn-icon>
663
+ </slot>
664
+ </div>
665
+
666
+ <div
667
+ id="listbox"
668
+ role="listbox"
669
+ aria-expanded=${this.open ? "true" : "false"}
670
+ aria-multiselectable=${this.multiple ? "true" : "false"}
671
+ aria-labelledby="label"
672
+ part="listbox"
673
+ class="select__listbox"
674
+ tabindex="-1"
675
+ @mouseup=${this.handleOptionClick}
676
+ @slotchange=${this.handleDefaultSlotChange}
677
+ >
678
+ <slot></slot>
679
+ </div>
680
+ </syn-popup>
681
+ </div>
682
+
683
+ <div
684
+ part="form-control-help-text"
685
+ id="help-text"
686
+ class="form-control__help-text"
687
+ aria-hidden=${hasHelpText ? "false" : "true"}
688
+ >
689
+ <slot name="help-text">${this.helpText}</slot>
690
+ </div>
691
+ </div>
692
+ `;
693
+ }
694
+ };
695
+ SynSelect.styles = select_styles_default;
696
+ SynSelect.dependencies = {
697
+ "syn-icon": SynIcon,
698
+ "syn-popup": SynPopup,
699
+ "syn-tag": SynTag
700
+ };
701
+ __decorateClass([
702
+ query(".select")
703
+ ], SynSelect.prototype, "popup", 2);
704
+ __decorateClass([
705
+ query(".select__combobox")
706
+ ], SynSelect.prototype, "combobox", 2);
707
+ __decorateClass([
708
+ query(".select__display-input")
709
+ ], SynSelect.prototype, "displayInput", 2);
710
+ __decorateClass([
711
+ query(".select__value-input")
712
+ ], SynSelect.prototype, "valueInput", 2);
713
+ __decorateClass([
714
+ query(".select__listbox")
715
+ ], SynSelect.prototype, "listbox", 2);
716
+ __decorateClass([
717
+ state()
718
+ ], SynSelect.prototype, "hasFocus", 2);
719
+ __decorateClass([
720
+ state()
721
+ ], SynSelect.prototype, "displayLabel", 2);
722
+ __decorateClass([
723
+ state()
724
+ ], SynSelect.prototype, "currentOption", 2);
725
+ __decorateClass([
726
+ state()
727
+ ], SynSelect.prototype, "selectedOptions", 2);
728
+ __decorateClass([
729
+ property()
730
+ ], SynSelect.prototype, "name", 2);
731
+ __decorateClass([
732
+ property({
733
+ converter: {
734
+ fromAttribute: (value) => value.split(" "),
735
+ toAttribute: (value) => value.join(" ")
736
+ }
737
+ })
738
+ ], SynSelect.prototype, "value", 2);
739
+ __decorateClass([
740
+ defaultValue()
741
+ ], SynSelect.prototype, "defaultValue", 2);
742
+ __decorateClass([
743
+ property({ reflect: true })
744
+ ], SynSelect.prototype, "size", 2);
745
+ __decorateClass([
746
+ property()
747
+ ], SynSelect.prototype, "placeholder", 2);
748
+ __decorateClass([
749
+ property({ type: Boolean, reflect: true })
750
+ ], SynSelect.prototype, "multiple", 2);
751
+ __decorateClass([
752
+ property({ attribute: "max-options-visible", type: Number })
753
+ ], SynSelect.prototype, "maxOptionsVisible", 2);
754
+ __decorateClass([
755
+ property({ type: Boolean, reflect: true })
756
+ ], SynSelect.prototype, "disabled", 2);
757
+ __decorateClass([
758
+ property({ type: Boolean })
759
+ ], SynSelect.prototype, "clearable", 2);
760
+ __decorateClass([
761
+ property({ type: Boolean, reflect: true })
762
+ ], SynSelect.prototype, "open", 2);
763
+ __decorateClass([
764
+ property({ type: Boolean })
765
+ ], SynSelect.prototype, "hoist", 2);
766
+ __decorateClass([
767
+ property()
768
+ ], SynSelect.prototype, "label", 2);
769
+ __decorateClass([
770
+ property({ reflect: true })
771
+ ], SynSelect.prototype, "placement", 2);
772
+ __decorateClass([
773
+ property({ attribute: "help-text" })
774
+ ], SynSelect.prototype, "helpText", 2);
775
+ __decorateClass([
776
+ property({ reflect: true })
777
+ ], SynSelect.prototype, "form", 2);
778
+ __decorateClass([
779
+ property({ type: Boolean, reflect: true })
780
+ ], SynSelect.prototype, "required", 2);
781
+ __decorateClass([
782
+ property()
783
+ ], SynSelect.prototype, "getTag", 2);
784
+ __decorateClass([
785
+ watch("disabled", { waitUntilFirstUpdate: true })
786
+ ], SynSelect.prototype, "handleDisabledChange", 1);
787
+ __decorateClass([
788
+ watch("value", { waitUntilFirstUpdate: true })
789
+ ], SynSelect.prototype, "handleValueChange", 1);
790
+ __decorateClass([
791
+ watch("open", { waitUntilFirstUpdate: true })
792
+ ], SynSelect.prototype, "handleOpenChange", 1);
793
+ setDefaultAnimation("select.show", {
794
+ keyframes: [
795
+ { opacity: 0, scale: 0.9 },
796
+ { opacity: 1, scale: 1 }
797
+ ],
798
+ options: { duration: 100, easing: "ease" }
799
+ });
800
+ setDefaultAnimation("select.hide", {
801
+ keyframes: [
802
+ { opacity: 1, scale: 1 },
803
+ { opacity: 0, scale: 0.9 }
804
+ ],
805
+ options: { duration: 100, easing: "ease" }
806
+ });
807
+
808
+ export {
809
+ SynSelect
810
+ };
811
+ //# sourceMappingURL=chunk.SS46QCYH.js.map