@statistikzh/leu 0.7.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 (104) hide show
  1. package/.eslintrc.json +4 -1
  2. package/CHANGELOG.md +16 -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.js +1 -1
  7. package/dist/{Button-7370f901.d.ts → Button-3adfb3ed.d.ts} +2 -2
  8. package/dist/{Button-7370f901.d.ts.map → Button-3adfb3ed.d.ts.map} +1 -1
  9. package/dist/{Button-7370f901.js → Button-3adfb3ed.js} +1 -1
  10. package/dist/Button.d.ts +1 -1
  11. package/dist/Button.js +2 -2
  12. package/dist/ButtonGroup.d.ts +1 -1
  13. package/dist/ButtonGroup.js +1 -1
  14. package/dist/Checkbox.d.ts +1 -1
  15. package/dist/Checkbox.js +1 -1
  16. package/dist/CheckboxGroup.d.ts +3 -2
  17. package/dist/CheckboxGroup.d.ts.map +1 -1
  18. package/dist/CheckboxGroup.js +4 -3
  19. package/dist/Chip.d.ts +1 -1
  20. package/dist/Chip.js +1 -1
  21. package/dist/ChipGroup.d.ts +1 -1
  22. package/dist/ChipGroup.js +2 -2
  23. package/dist/ChipLink.js +1 -1
  24. package/dist/ChipRemovable.d.ts +7 -0
  25. package/dist/ChipRemovable.d.ts.map +1 -1
  26. package/dist/ChipRemovable.js +23 -3
  27. package/dist/ChipSelectable.d.ts +6 -0
  28. package/dist/ChipSelectable.d.ts.map +1 -1
  29. package/dist/ChipSelectable.js +12 -2
  30. package/dist/Dropdown.d.ts +1 -1
  31. package/dist/Dropdown.js +2 -2
  32. package/dist/Icon.d.ts +1 -1
  33. package/dist/Icon.js +1 -1
  34. package/dist/Input.d.ts +1 -1
  35. package/dist/Input.js +1 -1
  36. package/dist/{LeuElement-ba5ea33d.d.ts → LeuElement-a20c5fd6.d.ts} +1 -1
  37. package/dist/LeuElement-a20c5fd6.d.ts.map +1 -0
  38. package/dist/{LeuElement-ba5ea33d.js → LeuElement-a20c5fd6.js} +12 -9
  39. package/dist/Menu.d.ts +1 -1
  40. package/dist/Menu.js +1 -1
  41. package/dist/MenuItem.d.ts +1 -1
  42. package/dist/MenuItem.js +4 -4
  43. package/dist/Pagination.d.ts +1 -1
  44. package/dist/Pagination.js +2 -2
  45. package/dist/Popup.d.ts +1 -1
  46. package/dist/Popup.js +1 -1
  47. package/dist/Radio.d.ts +1 -1
  48. package/dist/Radio.js +1 -1
  49. package/dist/RadioGroup.d.ts +1 -1
  50. package/dist/RadioGroup.d.ts.map +1 -1
  51. package/dist/RadioGroup.js +4 -3
  52. package/dist/ScrollTop.d.ts +1 -1
  53. package/dist/ScrollTop.js +2 -2
  54. package/dist/Select.d.ts +1 -1
  55. package/dist/Select.js +2 -2
  56. package/dist/Table.d.ts +1 -1
  57. package/dist/Table.js +2 -2
  58. package/dist/VisuallyHidden.d.ts +1 -1
  59. package/dist/VisuallyHidden.js +1 -1
  60. package/dist/index.d.ts +1 -1
  61. package/dist/index.js +2 -2
  62. package/dist/leu-accordion.js +1 -1
  63. package/dist/leu-breadcrumb.js +1 -1
  64. package/dist/leu-button-group.js +1 -1
  65. package/dist/leu-button.d.ts +1 -1
  66. package/dist/leu-button.js +2 -2
  67. package/dist/leu-checkbox-group.js +1 -1
  68. package/dist/leu-checkbox.js +1 -1
  69. package/dist/leu-chip-group.js +1 -1
  70. package/dist/leu-chip-link.js +1 -1
  71. package/dist/leu-chip-removable.js +1 -1
  72. package/dist/leu-chip-selectable.js +1 -1
  73. package/dist/leu-dropdown.js +2 -2
  74. package/dist/leu-icon.js +1 -1
  75. package/dist/leu-input.js +1 -1
  76. package/dist/leu-menu-item.js +1 -1
  77. package/dist/leu-menu.js +1 -1
  78. package/dist/leu-pagination.js +2 -2
  79. package/dist/leu-popup.js +1 -1
  80. package/dist/leu-radio-group.js +1 -1
  81. package/dist/leu-radio.js +1 -1
  82. package/dist/leu-scroll-top.js +2 -2
  83. package/dist/leu-select.js +2 -2
  84. package/dist/leu-table.js +2 -2
  85. package/dist/leu-visually-hidden.js +1 -1
  86. package/dist/vscode.html-custom-data.json +15 -4
  87. package/dist/vue/index.d.ts +8 -0
  88. package/dist/web-types.json +30 -8
  89. package/package.json +2 -1
  90. package/rollup.config.js +9 -0
  91. package/src/components/checkbox/CheckboxGroup.js +3 -2
  92. package/src/components/checkbox/stories/checkbox-group.stories.js +3 -3
  93. package/src/components/chip/ChipGroup.js +1 -1
  94. package/src/components/chip/ChipRemovable.js +18 -0
  95. package/src/components/chip/ChipSelectable.js +13 -1
  96. package/src/components/chip/stories/chip-removable.stories.js +6 -2
  97. package/src/components/chip/test/chip-removable.test.js +36 -2
  98. package/src/components/chip/test/chip-selectable.test.js +11 -1
  99. package/src/components/menu/MenuItem.js +1 -1
  100. package/src/components/menu/menu-item.css +2 -2
  101. package/src/components/radio/RadioGroup.js +3 -2
  102. package/src/components/radio/stories/radio-group.stories.js +3 -3
  103. package/src/lib/LeuElement.js +19 -11
  104. package/dist/LeuElement-ba5ea33d.d.ts.map +0 -1
@@ -43,6 +43,7 @@ export class LeuChipSelectable extends LeuChipBase {
43
43
  */
44
44
  this.variant = VARIANTS.toggle
45
45
  this.checked = false
46
+ this.value = ""
46
47
 
47
48
  if (this.variant === VARIANTS.radio && this.size === SIZES.small) {
48
49
  console.warn("Small size has no effect on radio variant")
@@ -62,7 +63,10 @@ export class LeuChipSelectable extends LeuChipBase {
62
63
  this.checked = nextcheckedState
63
64
  this.dispatchEvent(
64
65
  new CustomEvent("input", {
65
- detail: { checked: this.checked },
66
+ detail: {
67
+ checked: this.checked,
68
+ value: this.getValue(),
69
+ },
66
70
  bubbles: true,
67
71
  composed: true,
68
72
  })
@@ -70,6 +74,14 @@ export class LeuChipSelectable extends LeuChipBase {
70
74
  }
71
75
  }
72
76
 
77
+ /**
78
+ * Returns the value of the chip. If `value` is not set, it will return the text content
79
+ * @returns {string}
80
+ */
81
+ getValue() {
82
+ return this.value || this.textContent.trim()
83
+ }
84
+
73
85
  render() {
74
86
  return html`<button
75
87
  @click=${() => this.handleClick()}
@@ -1,4 +1,5 @@
1
1
  import { html } from "lit"
2
+ import { action } from "@storybook/addon-actions"
2
3
 
3
4
  import "../leu-chip-removable.js"
4
5
 
@@ -6,7 +7,8 @@ export default {
6
7
  title: "Chip/Removable",
7
8
  component: "leu-chip-removable",
8
9
  args: {
9
- label: "Publikationen",
10
+ label: "Daten",
11
+ onRemove: action("leu:remove"),
10
12
  },
11
13
  parameters: {
12
14
  design: {
@@ -27,7 +29,9 @@ function Template(args) {
27
29
  : "var(--leu-color-black-5)"}; padding: 1rem;"
28
30
  data-root
29
31
  >
30
- <leu-chip-removable ?inverted=${args.inverted}
32
+ <leu-chip-removable
33
+ @leu:remove=${args.onRemove}
34
+ ?inverted=${args.inverted}
31
35
  >${args.label}</leu-chip-removable
32
36
  >
33
37
  </div>
@@ -1,11 +1,18 @@
1
1
  import { html } from "lit"
2
2
  import { fixture, expect, oneEvent } from "@open-wc/testing"
3
3
  import { sendKeys } from "@web/test-runner-commands"
4
+ import { ifDefined } from "lit/directives/if-defined.js"
4
5
 
5
6
  import "../leu-chip-removable.js"
6
7
 
7
- async function defaultFixture() {
8
- return fixture(html` <leu-chip-removable>Daten</leu-chip-removable> `)
8
+ async function defaultFixture(args = {}) {
9
+ return fixture(
10
+ html`
11
+ <leu-chip-removable value=${ifDefined(args.value)}
12
+ >${args.label ?? "Daten"}</leu-chip-removable
13
+ >
14
+ `
15
+ )
9
16
  }
10
17
 
11
18
  describe("LeuChipRemovable", () => {
@@ -70,4 +77,31 @@ describe("LeuChipRemovable", () => {
70
77
 
71
78
  expect(event).to.exist
72
79
  })
80
+
81
+ it("sends the value in the remove event", async () => {
82
+ const el = await defaultFixture({ label: `Daten  ` }) // eslint-disable-line no-irregular-whitespace
83
+ const button = el.shadowRoot.querySelector("button")
84
+
85
+ setTimeout(() => button.click())
86
+ const event = await oneEvent(el, "leu:remove")
87
+
88
+ expect(event.detail.value).to.equal("Daten")
89
+
90
+ el.value = "test"
91
+
92
+ setTimeout(() => button.click())
93
+ const event2 = await oneEvent(el, "leu:remove")
94
+
95
+ expect(event2.detail.value).to.equal("test")
96
+ })
97
+
98
+ it("returns the value or label when getValue is called", async () => {
99
+ const el = await defaultFixture({ label: `Daten  ` }) // eslint-disable-line no-irregular-whitespace
100
+
101
+ expect(el.getValue()).to.equal("Daten")
102
+
103
+ el.value = "daten-01"
104
+
105
+ expect(el.getValue()).to.equal("daten-01")
106
+ })
73
107
  })
@@ -9,7 +9,7 @@ async function defaultFixture(args = {}) {
9
9
  return fixture(
10
10
  html`
11
11
  <leu-chip-selectable
12
- value="Publikationen"
12
+ value=${ifDefined(args.value)}
13
13
  variant=${ifDefined(args.variant)}
14
14
  ?checked=${args.checked}
15
15
  >Publikationen</leu-chip-selectable
@@ -90,4 +90,14 @@ describe("LeuChipSelectable", () => {
90
90
 
91
91
  expect(el.checked).to.be.true
92
92
  })
93
+
94
+ it("returns the value or label when getValue is called", async () => {
95
+ const el = await defaultFixture()
96
+
97
+ expect(el.getValue()).to.equal("Publikationen")
98
+
99
+ el.value = "publikationen-01"
100
+
101
+ expect(el.getValue()).to.equal("publikationen-01")
102
+ })
93
103
  })
@@ -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
  }
@@ -154,7 +155,7 @@ export class LeuRadioGroup extends LeuElement {
154
155
  render() {
155
156
  const fieldsetClasses = {
156
157
  fieldset: "true",
157
- "fieldset--vertical": this.orientation === "VERTICAL",
158
+ "fieldset--vertical": this.orientation === "vertical",
158
159
  }
159
160
 
160
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":"LeuElement-ba5ea33d.d.ts","sourceRoot":"","sources":["LeuElement-ba5ea33d.js"],"names":[],"mappings":"AA+BA;IACE,8EAMC;CAOF;AA3CD,sEAaC;2BAf0B,KAAK"}