@statistikzh/leu 0.6.0 → 0.8.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 (126) hide show
  1. package/.eslintrc.json +4 -1
  2. package/CHANGELOG.md +30 -0
  3. package/dist/Accordion.d.ts +1 -1
  4. package/dist/Accordion.js +1 -1
  5. package/dist/Breadcrumb.d.ts +1 -1
  6. package/dist/Breadcrumb.d.ts.map +1 -1
  7. package/dist/Breadcrumb.js +3 -1
  8. package/dist/{Button-9692e403.d.ts → Button-3adfb3ed.d.ts} +2 -2
  9. package/dist/Button-3adfb3ed.d.ts.map +1 -0
  10. package/dist/{Button-9692e403.js → Button-3adfb3ed.js} +1 -1
  11. package/dist/Button.d.ts +1 -1
  12. package/dist/Button.js +2 -2
  13. package/dist/ButtonGroup.d.ts +1 -1
  14. package/dist/ButtonGroup.d.ts.map +1 -1
  15. package/dist/ButtonGroup.js +1 -1
  16. package/dist/Checkbox.d.ts +1 -1
  17. package/dist/Checkbox.d.ts.map +1 -1
  18. package/dist/Checkbox.js +3 -1
  19. package/dist/CheckboxGroup.d.ts +3 -2
  20. package/dist/CheckboxGroup.d.ts.map +1 -1
  21. package/dist/CheckboxGroup.js +6 -3
  22. package/dist/Chip.d.ts +1 -1
  23. package/dist/Chip.d.ts.map +1 -1
  24. package/dist/Chip.js +19 -17
  25. package/dist/ChipGroup.d.ts +8 -2
  26. package/dist/ChipGroup.d.ts.map +1 -1
  27. package/dist/ChipGroup.js +32 -5
  28. package/dist/ChipLink.js +1 -1
  29. package/dist/ChipRemovable.d.ts +7 -0
  30. package/dist/ChipRemovable.d.ts.map +1 -1
  31. package/dist/ChipRemovable.js +23 -3
  32. package/dist/ChipSelectable.d.ts +9 -1
  33. package/dist/ChipSelectable.d.ts.map +1 -1
  34. package/dist/ChipSelectable.js +23 -11
  35. package/dist/Dropdown.d.ts +1 -1
  36. package/dist/Dropdown.d.ts.map +1 -1
  37. package/dist/Dropdown.js +2 -2
  38. package/dist/Icon.d.ts +98 -2
  39. package/dist/Icon.d.ts.map +1 -1
  40. package/dist/Icon.js +1 -1
  41. package/dist/Input.d.ts +7 -2
  42. package/dist/Input.d.ts.map +1 -1
  43. package/dist/Input.js +16 -3
  44. package/dist/{LeuElement-6de6f209.d.ts → LeuElement-a20c5fd6.d.ts} +2 -2
  45. package/dist/LeuElement-a20c5fd6.d.ts.map +1 -0
  46. package/dist/LeuElement-a20c5fd6.js +52 -0
  47. package/dist/Menu.d.ts +2 -2
  48. package/dist/Menu.js +1 -1
  49. package/dist/MenuItem.d.ts +2 -2
  50. package/dist/MenuItem.js +4 -4
  51. package/dist/Pagination.d.ts +1 -1
  52. package/dist/Pagination.js +2 -2
  53. package/dist/Popup.d.ts +1 -1
  54. package/dist/Popup.d.ts.map +1 -1
  55. package/dist/Popup.js +3 -1
  56. package/dist/Radio.d.ts +1 -1
  57. package/dist/Radio.d.ts.map +1 -1
  58. package/dist/Radio.js +3 -1
  59. package/dist/RadioGroup.d.ts +1 -1
  60. package/dist/RadioGroup.d.ts.map +1 -1
  61. package/dist/RadioGroup.js +22 -10
  62. package/dist/ScrollTop.d.ts +1 -1
  63. package/dist/ScrollTop.js +2 -2
  64. package/dist/Select.d.ts +1 -1
  65. package/dist/Select.d.ts.map +1 -1
  66. package/dist/Select.js +4 -2
  67. package/dist/Table.d.ts +1 -1
  68. package/dist/Table.d.ts.map +1 -1
  69. package/dist/Table.js +4 -3
  70. package/dist/VisuallyHidden.d.ts +1 -1
  71. package/dist/VisuallyHidden.d.ts.map +1 -1
  72. package/dist/VisuallyHidden.js +5 -3
  73. package/dist/index.d.ts +2 -2
  74. package/dist/index.js +3 -3
  75. package/dist/leu-accordion.js +1 -1
  76. package/dist/leu-breadcrumb.js +1 -1
  77. package/dist/leu-button-group.js +1 -1
  78. package/dist/leu-button.d.ts +1 -1
  79. package/dist/leu-button.js +2 -2
  80. package/dist/leu-checkbox-group.js +1 -1
  81. package/dist/leu-checkbox.js +1 -1
  82. package/dist/leu-chip-group.js +1 -1
  83. package/dist/leu-chip-link.js +1 -1
  84. package/dist/leu-chip-removable.js +1 -1
  85. package/dist/leu-chip-selectable.js +1 -1
  86. package/dist/leu-dropdown.js +2 -2
  87. package/dist/leu-icon.js +1 -1
  88. package/dist/leu-input.js +1 -1
  89. package/dist/leu-menu-item.js +1 -1
  90. package/dist/leu-menu.js +1 -1
  91. package/dist/leu-pagination.js +2 -2
  92. package/dist/leu-popup.js +1 -1
  93. package/dist/leu-radio-group.js +1 -1
  94. package/dist/leu-radio.js +1 -1
  95. package/dist/leu-scroll-top.js +2 -2
  96. package/dist/leu-select.js +2 -2
  97. package/dist/leu-table.js +2 -2
  98. package/dist/leu-visually-hidden.js +1 -1
  99. package/dist/vscode.html-custom-data.json +32 -8
  100. package/dist/vue/index.d.ts +29 -9
  101. package/dist/web-types.json +236 -235
  102. package/package.json +4 -3
  103. package/rollup.config.js +9 -0
  104. package/src/components/checkbox/CheckboxGroup.js +3 -2
  105. package/src/components/checkbox/stories/checkbox-group.stories.js +3 -3
  106. package/src/components/chip/ChipGroup.js +28 -4
  107. package/src/components/chip/ChipRemovable.js +18 -0
  108. package/src/components/chip/ChipSelectable.js +24 -10
  109. package/src/components/chip/chip.css +16 -16
  110. package/src/components/chip/stories/chip-group.stories.js +6 -9
  111. package/src/components/chip/stories/chip-removable.stories.js +6 -2
  112. package/src/components/chip/stories/chip-selectable.stories.js +1 -1
  113. package/src/components/chip/test/chip-group.test.js +67 -0
  114. package/src/components/chip/test/chip-removable.test.js +36 -2
  115. package/src/components/chip/test/chip-selectable.test.js +18 -8
  116. package/src/components/input/Input.js +14 -1
  117. package/src/components/input/stories/input.stories.js +3 -3
  118. package/src/components/input/test/input.test.js +20 -0
  119. package/src/components/menu/MenuItem.js +1 -1
  120. package/src/components/menu/menu-item.css +2 -2
  121. package/src/components/radio/RadioGroup.js +15 -11
  122. package/src/components/radio/stories/radio-group.stories.js +3 -3
  123. package/src/lib/LeuElement.js +19 -11
  124. package/dist/Button-9692e403.d.ts.map +0 -1
  125. package/dist/LeuElement-6de6f209.d.ts.map +0 -1
  126. package/dist/LeuElement-6de6f209.js +0 -43
@@ -80,7 +80,7 @@ export class LeuMenuItem extends LeuElement {
80
80
  * @returns {string}
81
81
  */
82
82
  getValue() {
83
- return this.value || this.innerText
83
+ return this.value || this.textContent.trim()
84
84
  }
85
85
 
86
86
  _getAria() {
@@ -6,10 +6,10 @@
6
6
  :host {
7
7
  --background: var(--leu-color-black-0);
8
8
  --background-hover: var(--leu-color-black-10);
9
- --background-active: var(--leu-color-accent-blue);
9
+ --background-active: var(--leu-color-func-cyan);
10
10
  --background-disabled: var(--leu-color-black-black-0);
11
11
  --color: var(--leu-color-black-transp-60);
12
- --color-active: var(--leu-color-black-0);
12
+ --color-active: var(--leu-color-black-100);
13
13
  --color-disabled: var(--leu-color-black-transp-20);
14
14
  --font-regular: var(--leu-font-family-regular);
15
15
  --font-black: var(--leu-font-family-black);
@@ -19,7 +19,8 @@ export class LeuRadioGroup extends LeuElement {
19
19
 
20
20
  constructor() {
21
21
  super()
22
- this.orientation = "HORIZONTAL"
22
+ /** @type {"horizontal" | "vertical"} */
23
+ this.orientation = "horizontal"
23
24
  this._currentIndex = 0
24
25
  this.items = []
25
26
  }
@@ -43,13 +44,20 @@ export class LeuRadioGroup extends LeuElement {
43
44
  }
44
45
 
45
46
  addEventListeners() {
46
- this.addEventListener("input", this.handleInput)
47
+ /**
48
+ * It is technically possible to add an event listener to the host element
49
+ * before it is connected to the dom. In that case the outside event listener would
50
+ * be called before the following event listener. But at this point multiple
51
+ * radio buttons could be selected at the same time because `handleInput` hasn't been
52
+ * called yet. That's why we use the capture phase.
53
+ */
54
+ this.addEventListener("input", this.handleInput, { capture: true })
47
55
  this.addEventListener("focusin", this.handleFocusIn)
48
56
  this.addEventListener("keydown", this.handleKeyDown)
49
57
  }
50
58
 
51
59
  removeEventListeners() {
52
- this.removeEventListener("input", this.handleInput)
60
+ this.removeEventListener("input", this.handleInput, { capture: true })
53
61
  this.removeEventListener("focusin", this.handleFocusIn)
54
62
  this.removeEventListener("keydown", this.handleKeyDown)
55
63
  }
@@ -87,13 +95,9 @@ export class LeuRadioGroup extends LeuElement {
87
95
  }
88
96
 
89
97
  handleInput = (e) => {
90
- if (e.target.checked) {
91
- this.items
92
- .filter((item) => item !== e.target)
93
- .forEach((item) => {
94
- item.checked = false // eslint-disable-line no-param-reassign
95
- })
96
- }
98
+ this.items.forEach((item) => {
99
+ item.checked = item === e.target // eslint-disable-line no-param-reassign
100
+ })
97
101
  }
98
102
 
99
103
  selectItem(selectingItem) {
@@ -151,7 +155,7 @@ export class LeuRadioGroup extends LeuElement {
151
155
  render() {
152
156
  const fieldsetClasses = {
153
157
  fieldset: "true",
154
- "fieldset--vertical": this.orientation === "VERTICAL",
158
+ "fieldset--vertical": this.orientation === "vertical",
155
159
  }
156
160
 
157
161
  return html`
@@ -9,7 +9,7 @@ export default {
9
9
  argTypes: {
10
10
  label: { control: "text" },
11
11
  orientation: {
12
- options: ["VERTICAL", "HORIZONTAL"],
12
+ options: ["vertical", "horizontal"],
13
13
  control: { type: "radio" },
14
14
  },
15
15
  },
@@ -44,11 +44,11 @@ HorizontalLabel.args = {
44
44
 
45
45
  export const Vertical = Template.bind({})
46
46
  Vertical.args = {
47
- orientation: "VERTICAL",
47
+ orientation: "vertical",
48
48
  }
49
49
 
50
50
  export const VerticalLabel = Template.bind({})
51
51
  VerticalLabel.args = {
52
- orientation: "VERTICAL",
52
+ orientation: "vertical",
53
53
  label: "Anrede",
54
54
  }
@@ -1,23 +1,31 @@
1
1
  import { LitElement } from "lit"
2
2
 
3
3
  export class LeuElement extends LitElement {
4
+ static version = __LEU_VERSION__
5
+
4
6
  static dependencies = {}
5
7
 
6
8
  static define(name, constructor = this, options = {}) {
7
- if (!customElements.get(name)) {
9
+ Object.entries(this.dependencies).forEach(([n, c]) => c.define(n))
10
+
11
+ const currentlyRegisteredConstructor = customElements.get(name)
12
+
13
+ if (currentlyRegisteredConstructor === undefined) {
8
14
  customElements.define(name, constructor, options)
9
- } else {
10
- console.info(`${name} is already defined`)
15
+ return
11
16
  }
12
- }
13
17
 
14
- constructor() {
15
- super()
18
+ if (currentlyRegisteredConstructor !== constructor) {
19
+ console.warn(
20
+ `The custom element with the name <${name}> is already registered with a different constructor. This can happen when the same element has been loaded from different modules (e.g. multiple CDN requests or bundles).`
21
+ )
22
+ return
23
+ }
16
24
 
17
- Object.entries(this.constructor.dependencies).forEach(
18
- ([name, component]) => {
19
- this.constructor.define(name, component)
20
- }
21
- )
25
+ if (currentlyRegisteredConstructor.version !== constructor.version) {
26
+ console.warn(
27
+ `The custom element with the name <${name}> is already defined with the same constructor but a different version (${currentlyRegisteredConstructor.version}).`
28
+ )
29
+ }
22
30
  }
23
31
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"Button-9692e403.d.ts","sourceRoot":"","sources":["Button-9692e403.js"],"names":[],"mappings":";;;iCAaa,OAAO,KAAK,EAAE,kBAAkB;AAyW7C,wCAA0D;AAhX1D;;;GAGG;AAEH;;;;GAIG;AACH,2CAFgB,kBAAkB;IAGhC,uCAcC;IAHC,UAAgB;IAEhB,eAA0B;IAG5B;;;OAGG;IACH,uBAeC;IAED;;;;OAIG;IACH,qBAEC;IAED;;;OAGG;IACH,gCAEC;IACD,sBAEC;IACD,yBAEC;CACF;AAmTD;;;;;GAKG;AACH;IAQI,WAAiB;IACjB,qBAAqB;IACrB,MADW,MAAM,CACI;IACrB,qBAAqB;IACrB,SADW,MAAM,CACO;IACxB,4CAA4C;IAC5C,MADW,QAAQ,GAAG,QAAQ,GAAG,OAAO,CACpB;IAEpB,qBAAqB;IACrB,eADW,MAAM,CACa;IAE9B,sBAAsB;IACtB,UADW,OAAO,CACG;IACrB,+EAA+E;IAC/E,OADW,OAAO,CACA;IAClB,sBAAsB;IACtB,QADW,OAAO,CACC;IACnB,wDAAwD;IACxD,UADW,OAAO,CACG;IAErB,gGAAgG;IAChG,OADW,OAAO,CACA;IAElB;;;OAGG;IACH,UAFU,CAAC,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAEf;IAE3B,6EAOC;IACD;;;MAaC;IACD,0BAEC;IACD,+CAiCC;CACF;AA7GD,qCAA0C;AAE1C,qCAAmD;AAEnD,gDAAkD;gCA5XI,0BAA0B;wBAC7C,KAAK"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"LeuElement-6de6f209.d.ts","sourceRoot":"","sources":["LeuElement-6de6f209.js"],"names":[],"mappings":"AAyBA;IACE,8EAMC;CAOF;AArCD,8DAOC;2BAT0B,KAAK"}
@@ -1,43 +0,0 @@
1
- import { LitElement } from 'lit';
2
-
3
- function _defineProperty(e, r, t) {
4
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
5
- value: t,
6
- enumerable: !0,
7
- configurable: !0,
8
- writable: !0
9
- }) : e[r] = t, e;
10
- }
11
- function _toPrimitive(t, r) {
12
- if ("object" != typeof t || !t) return t;
13
- var e = t[Symbol.toPrimitive];
14
- if (void 0 !== e) {
15
- var i = e.call(t, r || "default");
16
- if ("object" != typeof i) return i;
17
- throw new TypeError("@@toPrimitive must return a primitive value.");
18
- }
19
- return ("string" === r ? String : Number)(t);
20
- }
21
- function _toPropertyKey(t) {
22
- var i = _toPrimitive(t, "string");
23
- return "symbol" == typeof i ? i : i + "";
24
- }
25
-
26
- class LeuElement extends LitElement {
27
- static define(name, constructor = this, options = {}) {
28
- if (!customElements.get(name)) {
29
- customElements.define(name, constructor, options);
30
- } else {
31
- console.info(`${name} is already defined`);
32
- }
33
- }
34
- constructor() {
35
- super();
36
- Object.entries(this.constructor.dependencies).forEach(([name, component]) => {
37
- this.constructor.define(name, component);
38
- });
39
- }
40
- }
41
- _defineProperty(LeuElement, "dependencies", {});
42
-
43
- export { LeuElement as L, _defineProperty as _ };