@statistikzh/leu 0.26.0 → 0.28.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 (209) hide show
  1. package/.release-please-manifest.json +1 -1
  2. package/.storybook/main.ts +1 -1
  3. package/.storybook/preview.ts +6 -4
  4. package/.storybook/static/global.css +5 -0
  5. package/CHANGELOG.md +44 -0
  6. package/dist/{Accordion-B04QkmHz.js → Accordion-D9kLsiBW.js} +1 -1
  7. package/dist/Accordion.d.ts +1 -1
  8. package/dist/Accordion.js +2 -2
  9. package/dist/{Button-BgNUxmo_.d.ts → Button-DcuvEVkC.d.ts} +14 -12
  10. package/dist/{Button-BkhqVjug.js → Button-DyNVOHCd.js} +90 -82
  11. package/dist/Button.d.ts +1 -1
  12. package/dist/Button.js +4 -4
  13. package/dist/{ButtonGroup-B8U9fDvM.js → ButtonGroup-MEh4vb5a.js} +2 -2
  14. package/dist/ButtonGroup.d.ts +1 -1
  15. package/dist/ButtonGroup.js +5 -5
  16. package/dist/{ChartWrapper-CSMFwz9e.js → ChartWrapper-DAl91BIN.js} +2 -2
  17. package/dist/ChartWrapper.d.ts +3 -3
  18. package/dist/ChartWrapper.js +3 -3
  19. package/dist/{Checkbox-Dd1QLpfn.js → Checkbox-CGGyUW9U.js} +2 -2
  20. package/dist/Checkbox.d.ts +3 -3
  21. package/dist/Checkbox.js +3 -3
  22. package/dist/{CheckboxGroup-Bz2eWEFL.js → CheckboxGroup-DXt5iMdj.js} +2 -2
  23. package/dist/CheckboxGroup.d.ts +1 -1
  24. package/dist/CheckboxGroup.js +4 -4
  25. package/dist/{Chip-XAQIIsXq.js → Chip-BGs71WGH.js} +1 -1
  26. package/dist/{Chip-DLKM9P7v.d.ts → Chip-DVGjEPJE.d.ts} +1 -1
  27. package/dist/Chip.d.ts +1 -1
  28. package/dist/Chip.js +2 -2
  29. package/dist/{ChipGroup-Ta8Ht4jc.d.ts → ChipGroup-BK5BYM0X.d.ts} +2 -2
  30. package/dist/{ChipGroup-DLqfK2kn.js → ChipGroup-BcGyusP-.js} +1 -1
  31. package/dist/ChipGroup.d.ts +1 -1
  32. package/dist/ChipGroup.js +3 -3
  33. package/dist/{ChipLink-BAxyQO2M.d.ts → ChipLink-BdG2o-nk.d.ts} +1 -1
  34. package/dist/ChipLink.d.ts +1 -1
  35. package/dist/ChipLink.js +2 -2
  36. package/dist/{ChipRemovable-DBjwt0CH.d.ts → ChipRemovable-CCwSQTAL.d.ts} +2 -2
  37. package/dist/ChipRemovable.d.ts +1 -1
  38. package/dist/ChipRemovable.js +3 -3
  39. package/dist/{ChipSelectable-CMJNcE4U.d.ts → ChipSelectable-BQ3VLVi5.d.ts} +1 -1
  40. package/dist/ChipSelectable.d.ts +1 -1
  41. package/dist/ChipSelectable.js +2 -2
  42. package/dist/{Dialog-DHuXR_oo.js → Dialog-BzuyL1U3.js} +2 -2
  43. package/dist/Dialog.d.ts +3 -3
  44. package/dist/Dialog.js +3 -3
  45. package/dist/{Dropdown-DtFTePbc.js → Dropdown-plyBTM15.js} +5 -5
  46. package/dist/Dropdown.d.ts +6 -6
  47. package/dist/Dropdown.js +8 -8
  48. package/dist/{FileInput-b8sbLDPI.js → FileInput-BT3Fe-0J.js} +22 -7
  49. package/dist/FileInput.d.ts +16 -5
  50. package/dist/FileInput.js +6 -6
  51. package/dist/{Icon-Op80LrrO.d.ts → Icon-CUfh3eb3.d.ts} +1 -1
  52. package/dist/{Icon-C_yYuynf.js → Icon-D83qesg5.js} +1 -1
  53. package/dist/Icon.d.ts +1 -1
  54. package/dist/Icon.js +2 -2
  55. package/dist/{Input-DEOVocTa.js → Input-D7zS50oz.js} +32 -11
  56. package/dist/{Input-D2THgo7c.d.ts → Input-fEiQvGDF.d.ts} +9 -5
  57. package/dist/Input.d.ts +1 -1
  58. package/dist/Input.js +3 -3
  59. package/dist/{LeuElement-BeFrgKes.js → LeuElement-DQI8cqZV.js} +1 -1
  60. package/dist/{Menu-BeqqtCw6.js → Menu-DRU1LiMM.js} +2 -2
  61. package/dist/{Menu-CQdx1ef3.d.ts → Menu-Z2b7dsB5.d.ts} +2 -2
  62. package/dist/Menu.d.ts +1 -1
  63. package/dist/Menu.js +4 -4
  64. package/dist/{MenuItem-DVg8-1Bq.js → MenuItem-DCttylRO.js} +2 -2
  65. package/dist/{MenuItem-QcgnRk_7.d.ts → MenuItem-LY4TRIho.d.ts} +2 -2
  66. package/dist/MenuItem.d.ts +1 -1
  67. package/dist/MenuItem.js +3 -3
  68. package/dist/{Message-BhknWvAF.js → Message-0NxnKEqw.js} +2 -2
  69. package/dist/Message.d.ts +2 -2
  70. package/dist/Message.js +3 -3
  71. package/dist/{Pagination-CqkHh-Vd.d.ts → Pagination-9eZ8WMvR.d.ts} +4 -4
  72. package/dist/{Pagination-DJI5MIi_.js → Pagination-CIy7YvWE.js} +4 -4
  73. package/dist/Pagination.d.ts +1 -1
  74. package/dist/Pagination.js +6 -6
  75. package/dist/{Placeholder-BJybFwSg.js → Placeholder-Dol_X5Hp.js} +1 -1
  76. package/dist/Placeholder.d.ts +1 -1
  77. package/dist/Placeholder.js +2 -2
  78. package/dist/{Popup-Btgm2a3D.d.ts → Popup-B5iDSLIO.d.ts} +1 -1
  79. package/dist/{Popup-DNlm_9AA.js → Popup-nJrJHGSy.js} +1 -1
  80. package/dist/Popup.d.ts +1 -1
  81. package/dist/Popup.js +2 -2
  82. package/dist/{ProgressBar-B0wYj1KF.js → ProgressBar-Dmq9veqU.js} +1 -1
  83. package/dist/ProgressBar.d.ts +1 -1
  84. package/dist/ProgressBar.js +2 -2
  85. package/dist/{Radio-DMCL8c4D.js → Radio-W5ck_IJI.js} +1 -1
  86. package/dist/Radio.d.ts +1 -1
  87. package/dist/Radio.js +2 -2
  88. package/dist/{RadioGroup-CM6IyBlq.js → RadioGroup-De5x2YCO.js} +2 -2
  89. package/dist/RadioGroup.d.ts +1 -1
  90. package/dist/RadioGroup.js +3 -3
  91. package/dist/{Range-B72rtfln.js → Range-NCdfDkeD.js} +1 -1
  92. package/dist/Range.d.ts +1 -1
  93. package/dist/Range.js +2 -2
  94. package/dist/{ScrollTop-BFAqBVDR.js → ScrollTop-DwcNIKmN.js} +20 -20
  95. package/dist/ScrollTop.d.ts +8 -8
  96. package/dist/ScrollTop.js +5 -5
  97. package/dist/{Select-vxl3BvD4.js → Select-Bpicra9q.js} +153 -134
  98. package/dist/Select.d.ts +80 -78
  99. package/dist/Select.js +9 -9
  100. package/dist/{Spinner-DDTqijTO.js → Spinner-BBiVZxFH.js} +1 -1
  101. package/dist/{Spinner-CrM1enM0.d.ts → Spinner-DHYaX6-Y.d.ts} +1 -1
  102. package/dist/Spinner.d.ts +1 -1
  103. package/dist/Spinner.js +2 -2
  104. package/dist/Tab-CN97q0nj.d.ts +30 -0
  105. package/dist/Tab-Ce9nrDok.js +117 -0
  106. package/dist/Tab.d.ts +2 -0
  107. package/dist/Tab.js +3 -0
  108. package/dist/TabGroup-C-cd4Wcx.js +248 -0
  109. package/dist/TabGroup.d.ts +64 -0
  110. package/dist/TabGroup.js +5 -0
  111. package/dist/TabPanel-BW1ydVBT.js +65 -0
  112. package/dist/TabPanel-DQgWP7LO.d.ts +26 -0
  113. package/dist/TabPanel.d.ts +2 -0
  114. package/dist/TabPanel.js +3 -0
  115. package/dist/{Table-BgCxfBcm.js → Table-DiYqIzBu.js} +3 -3
  116. package/dist/Table.d.ts +3 -3
  117. package/dist/Table.js +7 -7
  118. package/dist/{Tag-DK2KkPIQ.js → Tag-Ct8Hhv7W.js} +1 -1
  119. package/dist/Tag.d.ts +1 -1
  120. package/dist/Tag.js +2 -2
  121. package/dist/{VisuallyHidden-OeQvhxYn.d.ts → VisuallyHidden-CB7aRJzF.d.ts} +1 -1
  122. package/dist/{VisuallyHidden-pll3amXE.js → VisuallyHidden-CpYXyuC7.js} +1 -1
  123. package/dist/VisuallyHidden.d.ts +1 -1
  124. package/dist/VisuallyHidden.js +2 -2
  125. package/dist/index.d.ts +14 -14
  126. package/dist/index.js +30 -30
  127. package/dist/leu-accordion.js +2 -2
  128. package/dist/leu-button-group.js +5 -5
  129. package/dist/leu-button.d.ts +1 -1
  130. package/dist/leu-button.js +4 -4
  131. package/dist/leu-chart-wrapper.js +3 -3
  132. package/dist/leu-checkbox-group.js +4 -4
  133. package/dist/leu-checkbox.js +3 -3
  134. package/dist/leu-chip-group.d.ts +1 -1
  135. package/dist/leu-chip-group.js +3 -3
  136. package/dist/leu-chip-link.d.ts +1 -1
  137. package/dist/leu-chip-link.js +2 -2
  138. package/dist/leu-chip-removable.d.ts +1 -1
  139. package/dist/leu-chip-removable.js +3 -3
  140. package/dist/leu-chip-selectable.d.ts +1 -1
  141. package/dist/leu-chip-selectable.js +2 -2
  142. package/dist/leu-dialog.js +3 -3
  143. package/dist/leu-dropdown.js +8 -8
  144. package/dist/leu-file-input.js +6 -6
  145. package/dist/leu-icon.d.ts +1 -1
  146. package/dist/leu-icon.js +2 -2
  147. package/dist/leu-input.d.ts +1 -1
  148. package/dist/leu-input.js +3 -3
  149. package/dist/leu-menu-item.d.ts +1 -1
  150. package/dist/leu-menu-item.js +3 -3
  151. package/dist/leu-menu.d.ts +1 -1
  152. package/dist/leu-menu.js +4 -4
  153. package/dist/leu-message.js +3 -3
  154. package/dist/leu-pagination.d.ts +1 -1
  155. package/dist/leu-pagination.js +6 -6
  156. package/dist/leu-placeholder.js +2 -2
  157. package/dist/leu-popup.d.ts +1 -1
  158. package/dist/leu-popup.js +2 -2
  159. package/dist/leu-progress-bar.js +2 -2
  160. package/dist/leu-radio-group.js +3 -3
  161. package/dist/leu-radio.js +2 -2
  162. package/dist/leu-range.js +2 -2
  163. package/dist/leu-scroll-top.js +5 -5
  164. package/dist/leu-select.js +9 -9
  165. package/dist/leu-spinner.d.ts +1 -1
  166. package/dist/leu-spinner.js +2 -2
  167. package/dist/leu-tab-group.d.ts +10 -0
  168. package/dist/leu-tab-group.js +8 -0
  169. package/dist/leu-tab-panel.d.ts +10 -0
  170. package/dist/leu-tab-panel.js +6 -0
  171. package/dist/leu-tab.d.ts +10 -0
  172. package/dist/leu-tab.js +6 -0
  173. package/dist/leu-table.js +7 -7
  174. package/dist/leu-tag.js +2 -2
  175. package/dist/leu-visually-hidden.d.ts +1 -1
  176. package/dist/leu-visually-hidden.js +2 -2
  177. package/dist/vscode.html-custom-data.json +90 -35
  178. package/dist/vue/index.d.ts +89 -29
  179. package/dist/web-types.json +182 -76
  180. package/package.json +1 -2
  181. package/src/components/button/Button.ts +45 -30
  182. package/src/components/button/button.css +55 -54
  183. package/src/components/button/stories/button.stories.ts +17 -20
  184. package/src/components/button/test/button.test.ts +46 -0
  185. package/src/components/file-input/FileInput.ts +24 -5
  186. package/src/components/input/Input.ts +43 -8
  187. package/src/components/input/test/input.test.ts +106 -1
  188. package/src/components/scroll-top/ScrollTop.ts +18 -16
  189. package/src/components/select/Select.ts +198 -125
  190. package/src/components/select/select.css +4 -0
  191. package/src/components/select/stories/select.stories.ts +10 -0
  192. package/src/components/select/test/select.test.ts +440 -35
  193. package/src/components/tab/Tab.ts +72 -0
  194. package/src/components/tab/TabGroup.ts +267 -0
  195. package/src/components/tab/TabPanel.ts +59 -0
  196. package/src/components/tab/leu-tab-group.ts +11 -0
  197. package/src/components/tab/leu-tab-panel.ts +11 -0
  198. package/src/components/tab/leu-tab.ts +11 -0
  199. package/src/components/tab/stories/tab.stories.ts +97 -0
  200. package/src/components/tab/tab-group.css +63 -0
  201. package/src/components/tab/tab-panel.css +10 -0
  202. package/src/components/tab/tab.css +54 -0
  203. package/src/components/tab/test/tab-group.test.ts +426 -0
  204. package/src/components/tab/test/tab-panel.test.ts +102 -0
  205. package/src/components/tab/test/tab.test.ts +139 -0
  206. package/tsconfig.json +1 -0
  207. /package/dist/{FormAssociatedMixin-Cc74LjbC.d.ts → FormAssociatedMixin-Cw7LsSUE.d.ts} +0 -0
  208. /package/dist/{LeuElement-pJFU18Xm.d.ts → LeuElement-DK1jntuu.d.ts} +0 -0
  209. /package/dist/{hasSlotController-DWPyZ52b.d.ts → hasSlotController-BjKyhJm-.d.ts} +0 -0
@@ -1,12 +1,15 @@
1
- import { t as LeuElement } from "./LeuElement-BeFrgKes.js";
2
- import { t as LeuIcon } from "./Icon-C_yYuynf.js";
1
+ import { t as LeuElement } from "./LeuElement-DQI8cqZV.js";
2
+ import { t as __decorate } from "./decorate-DwpAc4D0.js";
3
+ import { t as LeuIcon } from "./Icon-D83qesg5.js";
3
4
  import { t as HasSlotController } from "./hasSlotController-DSBCVzPD.js";
4
- import { t as LeuButton } from "./Button-BkhqVjug.js";
5
- import { t as LeuMenuItem } from "./MenuItem-DVg8-1Bq.js";
6
- import { t as LeuMenu } from "./Menu-BeqqtCw6.js";
7
- import { t as LeuPopup } from "./Popup-DNlm_9AA.js";
8
- import { t as LeuInput } from "./Input-DEOVocTa.js";
5
+ import { t as LeuButton } from "./Button-DyNVOHCd.js";
6
+ import { t as FormAssociatedMixin } from "./FormAssociatedMixin-DLPvFtbT.js";
7
+ import { t as LeuMenuItem } from "./MenuItem-DCttylRO.js";
8
+ import { t as LeuMenu } from "./Menu-DRU1LiMM.js";
9
+ import { t as LeuPopup } from "./Popup-nJrJHGSy.js";
10
+ import { t as LeuInput } from "./Input-D7zS50oz.js";
9
11
  import { css, html, nothing } from "lit";
12
+ import { property, state } from "lit/decorators.js";
10
13
  import { classMap } from "lit/directives/class-map.js";
11
14
  import { ifDefined } from "lit/directives/if-defined.js";
12
15
  import { createRef, ref } from "lit/directives/ref.js";
@@ -107,6 +110,10 @@ var select_default = css`:host {
107
110
  font-family: var(--select-font-regular);
108
111
  }
109
112
 
113
+ :host([required]) .label::after {
114
+ content: "*";
115
+ }
116
+
110
117
  .clear-button {
111
118
  --_length: 1.5rem;
112
119
 
@@ -248,17 +255,33 @@ var select_default = css`:host {
248
255
  * @tagname leu-select
249
256
  * @slot before - Optional content the appears before the option list
250
257
  * @slot after - Optional content the appears after the option list
251
- * @property {string} name - Reflects to the name attribute of the hidden input field that would be used in a form
252
- * @property {boolean} open - The expanded state of the popup
253
- * @property {string} label - The label of the select
254
- * @property {array} value - List of selected values. If they're set from outside the component, the select element tries to find all the options with the given values and selects them.
255
- * @property {boolean} clearable - Show a clearable button to reset the value
256
- * @property {boolean} disabled - If the select should be disabled
257
- * @property {boolean} filterable - Show an input field to filter the options inside the popup
258
- * @property {boolean} multiple - Allow multiple selections
259
258
  * @attribute {string} value - The selected values separated by commas.
260
259
  */
261
- var LeuSelect = class extends LeuElement {
260
+ var LeuSelect = class extends FormAssociatedMixin(LeuElement) {
261
+ constructor(..._args) {
262
+ super(..._args);
263
+ this.label = "";
264
+ this.defaultValue = [];
265
+ this.clearable = false;
266
+ this.filterable = false;
267
+ this.multiple = false;
268
+ this.required = false;
269
+ this.open = false;
270
+ this._optionFilter = "";
271
+ this._hasFilterResults = true;
272
+ this._displayValue = "";
273
+ this._deferedChangeEvent = false;
274
+ this._optionFilterRef = createRef();
275
+ this._toggleButtonRef = createRef();
276
+ this._menuRef = createRef();
277
+ this.hasSlotController = new HasSlotController(this, ["before", "after"]);
278
+ this._handleDocumentClick = (event) => {
279
+ if (!event.composedPath().includes(this) && this.open) this._closeDropdown();
280
+ };
281
+ this._handleKeyDown = (event) => {
282
+ if (event.key === "Escape") this._closeDropdown();
283
+ };
284
+ }
262
285
  static {
263
286
  this.dependencies = {
264
287
  "leu-button": LeuButton,
@@ -272,90 +295,49 @@ var LeuSelect = class extends LeuElement {
272
295
  static {
273
296
  this.styles = [LeuElement.styles, select_default];
274
297
  }
275
- static get properties() {
276
- return {
277
- name: {
278
- type: String,
279
- reflect: true
280
- },
281
- open: {
282
- type: Boolean,
283
- reflect: true
284
- },
285
- label: {
286
- type: String,
287
- reflect: true
288
- },
289
- value: {
290
- type: Array,
291
- converter: { fromAttribute(value) {
292
- if (value) return value.split(",").map((v) => v.trim());
293
- return value;
294
- } }
295
- },
296
- clearable: {
297
- type: Boolean,
298
- reflect: true
299
- },
300
- disabled: {
301
- type: Boolean,
302
- reflect: true
303
- },
304
- filterable: {
305
- type: Boolean,
306
- reflect: true
307
- },
308
- multiple: {
309
- type: Boolean,
310
- reflect: true
311
- },
312
- _optionFilter: { state: true },
313
- _hasFilterResults: { state: true },
314
- _displayValue: { state: true }
298
+ static {
299
+ this.shadowRootOptions = {
300
+ ...LeuElement.shadowRootOptions,
301
+ delegatesFocus: true
315
302
  };
316
303
  }
304
+ /**
305
+ * List of selected values. If they're set from outside the component, the select element
306
+ * finds all the options that match the given values and selects them.
307
+ */
308
+ set value(value) {
309
+ /**
310
+ * @todo Check if all of the value items are actually present in the options
311
+ */
312
+ this._value = value;
313
+ }
314
+ get value() {
315
+ return this._value ?? this.defaultValue;
316
+ }
317
317
  static getOptionLabel(option) {
318
318
  if (typeof option === "object" && option !== null) return option.label;
319
319
  return option;
320
320
  }
321
- constructor() {
322
- super();
323
- this.hasSlotController = new HasSlotController(this, ["before", "after"]);
324
- this._handleDocumentClick = (event) => {
325
- if (!event.composedPath().includes(this) && this.open) this._closeDropdown();
326
- };
327
- this._handleKeyDown = (event) => {
328
- if (event.key === "Escape") this._closeDropdown();
329
- };
330
- this.open = false;
331
- this.disabled = false;
332
- this.open = false;
333
- this.multiple = false;
334
- this.clearable = false;
335
- this.filterable = false;
336
- this.value = [];
337
- this.label = "";
338
- this.name = "";
339
- /** @internal */
340
- this._optionFilter = "";
341
- /** @internal */
342
- this._hasFilterResults = true;
343
- /** @internal */
344
- this._deferedChangeEvent = false;
345
- /** @internal */
321
+ setFormValue() {
322
+ const isEmpty = this.value.length === 0 || !this.value.some((v) => v !== "");
323
+ if (isEmpty || this.disabled) this.internals.setFormValue(null);
324
+ else if (this.multiple) {
325
+ const formData = new FormData();
326
+ this.value.forEach((v) => formData.append(this.name ?? "", v));
327
+ this.internals.setFormValue(formData);
328
+ } else this.internals.setFormValue(this.value[0]);
329
+ if (this.required && isEmpty) this.internals.setValidity({ valueMissing: true }, "Bitte wählen Sie eine Option aus.");
330
+ else this.internals.setValidity({});
331
+ }
332
+ formResetCallback() {
333
+ super.formResetCallback();
334
+ this.value = this.defaultValue;
346
335
  this._displayValue = "";
347
- /**
348
- * @type {import("lit/directives/ref").Ref<import("../input/Input").LeuInput>}
349
- */
350
- this._optionFilterRef = createRef();
351
- /**
352
- * @type {import("lit/directives/ref").Ref<HTMLButtonElement>}
353
- */
354
- this._toggleButtonRef = createRef();
355
- /**
356
- * @type {import("lit/directives/ref").Ref<import("../menu/Menu").LeuMenu>}
357
- */
358
- this._menuRef = createRef();
336
+ }
337
+ willUpdate(changedProperties) {
338
+ super.willUpdate(changedProperties);
339
+ if (changedProperties.has("defaultValue") && !changedProperties.has("value") && !this.hasInteracted) this.value = this.defaultValue;
340
+ if (changedProperties.has("value") || changedProperties.has("defaultValue") || changedProperties.has("name") || changedProperties.has("disabled") || changedProperties.has("required")) this.setFormValue();
359
341
  }
360
342
  connectedCallback() {
361
343
  super.connectedCallback();
@@ -375,13 +357,15 @@ var LeuSelect = class extends LeuElement {
375
357
  multiple: changedProperties.has("multiple")
376
358
  });
377
359
  }
360
+ click() {
361
+ this._toggleButtonRef.value?.click();
362
+ }
378
363
  /**
379
364
  * Apply the current state to the menu items.
380
365
  * - Set the active property when the value property has changed.
381
366
  * - Hide menu items that do not match the filter.
382
367
  */
383
368
  async _updateMenuItems(changed) {
384
- /** @type {LeuMenu} */
385
369
  const menu = this._menuRef.value;
386
370
  await menu.updateComplete;
387
371
  const menuItems = menu.getMenuItems();
@@ -418,7 +402,6 @@ var LeuSelect = class extends LeuElement {
418
402
  }
419
403
  /**
420
404
  * @internal
421
- * @param {KeyboardEvent} event
422
405
  */
423
406
  async _handleToggleKeyDown(event) {
424
407
  if ([
@@ -437,7 +420,6 @@ var LeuSelect = class extends LeuElement {
437
420
  }
438
421
  /**
439
422
  * @internal
440
- * @param {KeyboardEvent} event
441
423
  */
442
424
  _handleFilterInputKeyDown(event) {
443
425
  if (event.key === "ArrowDown") this._menuRef.value.focusItem(0);
@@ -445,7 +427,6 @@ var LeuSelect = class extends LeuElement {
445
427
  }
446
428
  /**
447
429
  * Determines the value or label that should be displayed inside the toggle button.
448
- * @returns {String | nothing}
449
430
  */
450
431
  _getDisplayValue() {
451
432
  if (this.multiple) return this.value.length === 0 ? `` : `${this.value.length} gewählt`;
@@ -468,6 +449,7 @@ var LeuSelect = class extends LeuElement {
468
449
  _clearValue(event) {
469
450
  if (!this.disabled) {
470
451
  event.stopPropagation();
452
+ this.hasInteracted = true;
471
453
  this.value = [];
472
454
  }
473
455
  this._emitInputEvent();
@@ -488,18 +470,16 @@ var LeuSelect = class extends LeuElement {
488
470
  }
489
471
  /**
490
472
  * Checks if the given value is selected.
491
- * @param {String} menuItemValue
492
- * @returns {Boolean}
493
473
  */
494
474
  _isSelected(menuItemValue) {
495
475
  return this.value.includes(menuItemValue);
496
476
  }
497
477
  _handleMenuItemClick(event) {
498
478
  if (!(event.target instanceof LeuMenuItem) || event.target.disabled) return;
499
- /** @type {LeuMenuItem} */
500
479
  const menuItem = event.target;
501
480
  const value = menuItem.getValue();
502
481
  const isSelected = this._isSelected(value);
482
+ this.hasInteracted = true;
503
483
  if (this.multiple) {
504
484
  this.value = isSelected ? this.value.filter((v) => v !== value) : this.value.concat(value);
505
485
  this._deferedChangeEvent = true;
@@ -529,7 +509,6 @@ var LeuSelect = class extends LeuElement {
529
509
  type="button"
530
510
  class="apply-button"
531
511
  @click=${this._closeDropdown}
532
- fluid
533
512
  >Anwenden</leu-button
534
513
  >
535
514
  </div>
@@ -574,45 +553,85 @@ var LeuSelect = class extends LeuElement {
574
553
  }
575
554
  render() {
576
555
  return html`<div
577
- class=${classMap({
556
+ class=${classMap({
578
557
  select: true,
579
558
  "select--has-before": this.hasSlotController.test("before"),
580
559
  "select--has-after": this.hasSlotController.test("after")
581
560
  })}
582
- @keydown=${this._handleKeyDown}
561
+ @keydown=${this._handleKeyDown}
562
+ >
563
+ <leu-popup
564
+ ?active=${this.open}
565
+ placement="bottom-start"
566
+ flip
567
+ matchSize="width"
568
+ autoSize="height"
569
+ autoSizePadding="8"
583
570
  >
584
- <leu-popup
585
- ?active=${this.open}
586
- placement="bottom-start"
587
- flip
588
- matchSize="width"
589
- autoSize="height"
590
- autoSizePadding="8"
591
- >
592
- ${this._renderToggleButton()}
593
- <div id="select-popup" class="select-menu-container">
594
- <slot name="before" class="before"></slot>
595
- ${this._renderFilterInput()}
596
- <leu-menu
597
- ref=${ref(this._menuRef)}
598
- role="listbox"
599
- aria-multiselectable=${ifDefined(this.multiple ? "true" : void 0)}
600
- class="menu"
601
- @click=${this._handleMenuItemClick}
602
- aria-labelledby="select-label"
603
- >
604
- <slot @slotchange=${this._handleItemSlotChange}> </slot>
605
- </leu-menu>
606
- ${this._hasFilterResults || this._optionFilter === "" ? nothing : html` <p class="filter-message-empty" aria-live="polite">
607
- Keine Resultate
608
- </p>`}
609
- ${this._renderApplyButton()}
610
- <slot name="after" class="after"></slot>
611
- </div>
612
- </leu-popup>
613
- </div>
614
- <input type="hidden" name=${this.name} .value=${this.value.join(",")} />`;
571
+ ${this._renderToggleButton()}
572
+ <div id="select-popup" class="select-menu-container">
573
+ <slot name="before" class="before"></slot>
574
+ ${this._renderFilterInput()}
575
+ <leu-menu
576
+ ref=${ref(this._menuRef)}
577
+ role="listbox"
578
+ aria-multiselectable=${ifDefined(this.multiple ? "true" : void 0)}
579
+ class="menu"
580
+ @click=${this._handleMenuItemClick}
581
+ aria-labelledby="select-label"
582
+ >
583
+ <slot @slotchange=${this._handleItemSlotChange}> </slot>
584
+ </leu-menu>
585
+ ${this._hasFilterResults || this._optionFilter === "" ? nothing : html` <p class="filter-message-empty" aria-live="polite">
586
+ Keine Resultate
587
+ </p>`}
588
+ ${this._renderApplyButton()}
589
+ <slot name="after" class="after"></slot>
590
+ </div>
591
+ </leu-popup>
592
+ </div>`;
615
593
  }
616
594
  };
595
+ __decorate([property({
596
+ type: String,
597
+ reflect: true
598
+ })], LeuSelect.prototype, "label", void 0);
599
+ __decorate([property({
600
+ reflect: true,
601
+ attribute: "value",
602
+ converter: {
603
+ fromAttribute(value) {
604
+ if (value) return value.split(",").map((v) => v.trim());
605
+ return [];
606
+ },
607
+ toAttribute(value) {
608
+ return value.length > 0 ? value.join(",") : null;
609
+ }
610
+ }
611
+ })], LeuSelect.prototype, "defaultValue", void 0);
612
+ __decorate([property({
613
+ type: Array,
614
+ attribute: false
615
+ })], LeuSelect.prototype, "value", null);
616
+ __decorate([property({
617
+ type: Boolean,
618
+ reflect: true
619
+ })], LeuSelect.prototype, "clearable", void 0);
620
+ __decorate([property({
621
+ type: Boolean,
622
+ reflect: true
623
+ })], LeuSelect.prototype, "filterable", void 0);
624
+ __decorate([property({
625
+ type: Boolean,
626
+ reflect: true
627
+ })], LeuSelect.prototype, "multiple", void 0);
628
+ __decorate([property({
629
+ type: Boolean,
630
+ reflect: true
631
+ })], LeuSelect.prototype, "required", void 0);
632
+ __decorate([state()], LeuSelect.prototype, "open", void 0);
633
+ __decorate([state()], LeuSelect.prototype, "_optionFilter", void 0);
634
+ __decorate([state()], LeuSelect.prototype, "_hasFilterResults", void 0);
635
+ __decorate([state()], LeuSelect.prototype, "_displayValue", void 0);
617
636
  //#endregion
618
637
  export { LeuSelect as t };
package/dist/Select.d.ts CHANGED
@@ -1,30 +1,25 @@
1
- import { t as LeuElement } from "./LeuElement-pJFU18Xm.js";
2
- import { t as LeuIcon } from "./Icon-Op80LrrO.js";
3
- import { t as LeuButton } from "./Button-BgNUxmo_.js";
4
- import { t as HasSlotController } from "./hasSlotController-DWPyZ52b.js";
5
- import { t as LeuMenuItem } from "./MenuItem-QcgnRk_7.js";
6
- import { t as LeuMenu } from "./Menu-CQdx1ef3.js";
7
- import { t as LeuPopup } from "./Popup-Btgm2a3D.js";
8
- import { t as LeuInput } from "./Input-D2THgo7c.js";
1
+ import { t as LeuElement } from "./LeuElement-DK1jntuu.js";
2
+ import { t as FormAssociatedMixinType } from "./FormAssociatedMixin-Cw7LsSUE.js";
3
+ import { t as LeuIcon } from "./Icon-CUfh3eb3.js";
4
+ import { t as LeuButton } from "./Button-DcuvEVkC.js";
5
+ import { t as HasSlotController } from "./hasSlotController-BjKyhJm-.js";
6
+ import { t as LeuMenuItem } from "./MenuItem-LY4TRIho.js";
7
+ import { t as LeuMenu } from "./Menu-Z2b7dsB5.js";
8
+ import { t as LeuPopup } from "./Popup-B5iDSLIO.js";
9
+ import { t as LeuInput } from "./Input-fEiQvGDF.js";
9
10
  import { PropertyValues, nothing } from "lit";
10
11
  import * as lit_html0 from "lit-html";
12
+ import * as lit_html_directives_ref_js0 from "lit-html/directives/ref.js";
11
13
 
12
14
  //#region src/components/select/Select.d.ts
15
+ declare const LeuSelect_base: (abstract new (...args: any[]) => FormAssociatedMixinType) & typeof LeuElement;
13
16
  /**
14
17
  * @tagname leu-select
15
18
  * @slot before - Optional content the appears before the option list
16
19
  * @slot after - Optional content the appears after the option list
17
- * @property {string} name - Reflects to the name attribute of the hidden input field that would be used in a form
18
- * @property {boolean} open - The expanded state of the popup
19
- * @property {string} label - The label of the select
20
- * @property {array} value - List of selected values. If they're set from outside the component, the select element tries to find all the options with the given values and selects them.
21
- * @property {boolean} clearable - Show a clearable button to reset the value
22
- * @property {boolean} disabled - If the select should be disabled
23
- * @property {boolean} filterable - Show an input field to filter the options inside the popup
24
- * @property {boolean} multiple - Allow multiple selections
25
20
  * @attribute {string} value - The selected values separated by commas.
26
21
  */
27
- declare class LeuSelect extends LeuElement {
22
+ declare class LeuSelect extends LeuSelect_base {
28
23
  static dependencies: {
29
24
  "leu-button": typeof LeuButton;
30
25
  "leu-menu": typeof LeuMenu;
@@ -34,60 +29,74 @@ declare class LeuSelect extends LeuElement {
34
29
  "leu-popup": typeof LeuPopup;
35
30
  };
36
31
  static styles: any[];
37
- static get properties(): {
38
- name: {
39
- type: StringConstructor;
40
- reflect: boolean;
41
- };
42
- open: {
43
- type: BooleanConstructor;
44
- reflect: boolean;
45
- };
46
- label: {
47
- type: StringConstructor;
48
- reflect: boolean;
49
- };
50
- value: {
51
- type: ArrayConstructor;
52
- converter: {
53
- fromAttribute(value: any): any;
54
- };
55
- };
56
- clearable: {
57
- type: BooleanConstructor;
58
- reflect: boolean;
59
- };
60
- disabled: {
61
- type: BooleanConstructor;
62
- reflect: boolean;
63
- };
64
- filterable: {
65
- type: BooleanConstructor;
66
- reflect: boolean;
67
- };
68
- multiple: {
69
- type: BooleanConstructor;
70
- reflect: boolean;
71
- };
72
- _optionFilter: {
73
- state: boolean;
74
- };
75
- _hasFilterResults: {
76
- state: boolean;
77
- };
78
- _displayValue: {
79
- state: boolean;
80
- };
32
+ /**
33
+ * @internal
34
+ */
35
+ static shadowRootOptions: {
36
+ delegatesFocus: boolean;
37
+ clonable?: boolean;
38
+ customElementRegistry?: CustomElementRegistry;
39
+ mode: ShadowRootMode;
40
+ serializable?: boolean;
41
+ slotAssignment?: SlotAssignmentMode;
81
42
  };
43
+ /**
44
+ * The label of the select
45
+ */
46
+ label: string;
47
+ /**
48
+ * The default value of the select. Corresponds to the `value` HTML attribute.
49
+ */
50
+ defaultValue: Array<string>;
51
+ /** @internal */
52
+ protected _value: Array<string> | undefined;
53
+ /**
54
+ * List of selected values. If they're set from outside the component, the select element
55
+ * finds all the options that match the given values and selects them.
56
+ */
57
+ set value(value: Array<string>);
58
+ get value(): Array<string>;
59
+ /**
60
+ * Show a clearable button to reset the value
61
+ */
62
+ clearable: boolean;
63
+ /**
64
+ * Show an input field to filter the options inside the popup
65
+ */
66
+ filterable: boolean;
67
+ /**
68
+ * Allow multiple selections
69
+ */
70
+ multiple: boolean;
71
+ /** Marks the input element as required */
72
+ required: boolean;
73
+ /**
74
+ * The expanded state of the popup
75
+ */
76
+ protected open: boolean;
77
+ protected _optionFilter: string;
78
+ protected _hasFilterResults: boolean;
79
+ protected _displayValue: string;
82
80
  static getOptionLabel(option: any): any;
81
+ /** @internal */
82
+ protected _deferedChangeEvent: boolean;
83
+ /** @internal */
84
+ protected _optionFilterRef: lit_html_directives_ref_js0.Ref<LeuInput>;
85
+ /** @internal */
86
+ protected _toggleButtonRef: lit_html_directives_ref_js0.Ref<HTMLButtonElement>;
87
+ /** @internal */
88
+ protected _menuRef: lit_html_directives_ref_js0.Ref<LeuMenu>;
83
89
  /**
84
90
  * @internal
85
91
  */
86
92
  hasSlotController: HasSlotController;
87
- constructor();
93
+ protected setFormValue(): void;
94
+ formResetCallback(): void;
95
+ protected willUpdate(changedProperties: PropertyValues<this>): void;
88
96
  connectedCallback(): void;
89
97
  disconnectedCallback(): void;
90
98
  updated(changedProperties: PropertyValues<this>): void;
99
+ click(): void;
91
100
  /**
92
101
  * Apply the current state to the menu items.
93
102
  * - Set the active property when the value property has changed.
@@ -104,42 +113,35 @@ declare class LeuSelect extends LeuElement {
104
113
  /**
105
114
  * Handles clicks outside of the component to close the dropdown.
106
115
  * @internal
107
- * @param {MouseEvent} event
108
116
  */
109
- _handleDocumentClick: (event: any) => void;
117
+ _handleDocumentClick: (event: MouseEvent) => void;
110
118
  /**
111
119
  * @internal
112
- * @param {KeyboardEvent} event
113
120
  */
114
- _handleKeyDown: (event: any) => void;
121
+ _handleKeyDown: (event: KeyboardEvent) => void;
115
122
  /**
116
123
  * @internal
117
- * @param {KeyboardEvent} event
118
124
  */
119
- _handleToggleKeyDown(event: any): Promise<void>;
125
+ _handleToggleKeyDown(event: KeyboardEvent): Promise<void>;
120
126
  /**
121
127
  * @internal
122
- * @param {KeyboardEvent} event
123
128
  */
124
- _handleFilterInputKeyDown(event: any): void;
129
+ _handleFilterInputKeyDown(event: KeyboardEvent): void;
125
130
  /**
126
131
  * Determines the value or label that should be displayed inside the toggle button.
127
- * @returns {String | nothing}
128
132
  */
129
- _getDisplayValue(): any;
133
+ _getDisplayValue(): string | typeof nothing;
130
134
  _emitInputEvent(): void;
131
135
  _emitChangeEvent(): void;
132
- _clearValue(event: any): void;
136
+ _clearValue(event: MouseEvent): void;
133
137
  _toggleDropdown(): void;
134
138
  _closeDropdown(): void;
135
- _handleFilterInput(event: any): void;
139
+ _handleFilterInput(event: InputEvent): void;
136
140
  /**
137
141
  * Checks if the given value is selected.
138
- * @param {String} menuItemValue
139
- * @returns {Boolean}
140
142
  */
141
- _isSelected(menuItemValue: any): any;
142
- _handleMenuItemClick(event: any): void;
143
+ _isSelected(menuItemValue: string): boolean;
144
+ _handleMenuItemClick(event: MouseEvent): void;
143
145
  _renderFilterInput(): lit_html0.TemplateResult<1> | typeof nothing;
144
146
  _renderApplyButton(): lit_html0.TemplateResult<1> | typeof nothing;
145
147
  _renderToggleButton(): lit_html0.TemplateResult<1>;
package/dist/Select.js CHANGED
@@ -1,11 +1,11 @@
1
- import "./LeuElement-BeFrgKes.js";
2
- import "./Icon-C_yYuynf.js";
3
- import "./Spinner-DDTqijTO.js";
4
- import "./Button-BkhqVjug.js";
1
+ import "./LeuElement-DQI8cqZV.js";
2
+ import "./Icon-D83qesg5.js";
3
+ import "./Spinner-BBiVZxFH.js";
4
+ import "./Button-DyNVOHCd.js";
5
5
  import "./FormAssociatedMixin-DLPvFtbT.js";
6
- import "./MenuItem-DVg8-1Bq.js";
7
- import "./Menu-BeqqtCw6.js";
8
- import "./Popup-DNlm_9AA.js";
9
- import "./Input-DEOVocTa.js";
10
- import { t as LeuSelect } from "./Select-vxl3BvD4.js";
6
+ import "./MenuItem-DCttylRO.js";
7
+ import "./Menu-DRU1LiMM.js";
8
+ import "./Popup-nJrJHGSy.js";
9
+ import "./Input-D7zS50oz.js";
10
+ import { t as LeuSelect } from "./Select-Bpicra9q.js";
11
11
  export { LeuSelect };
@@ -1,4 +1,4 @@
1
- import { t as LeuElement } from "./LeuElement-BeFrgKes.js";
1
+ import { t as LeuElement } from "./LeuElement-DQI8cqZV.js";
2
2
  import { css, html } from "lit";
3
3
  //#region src/components/spinner/spinner.css?inline
4
4
  var spinner_default = css`@keyframes leu-spinner-rotate {
@@ -1,4 +1,4 @@
1
- import { t as LeuElement } from "./LeuElement-pJFU18Xm.js";
1
+ import { t as LeuElement } from "./LeuElement-DK1jntuu.js";
2
2
  import * as lit_html0 from "lit-html";
3
3
 
4
4
  //#region src/components/spinner/Spinner.d.ts
package/dist/Spinner.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { t as LeuSpinner } from "./Spinner-CrM1enM0.js";
1
+ import { t as LeuSpinner } from "./Spinner-DHYaX6-Y.js";
2
2
  export { LeuSpinner };
package/dist/Spinner.js CHANGED
@@ -1,3 +1,3 @@
1
- import "./LeuElement-BeFrgKes.js";
2
- import { t as LeuSpinner } from "./Spinner-DDTqijTO.js";
1
+ import "./LeuElement-DQI8cqZV.js";
2
+ import { t as LeuSpinner } from "./Spinner-BBiVZxFH.js";
3
3
  export { LeuSpinner };