@statistikzh/leu 0.2.0 → 0.4.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.
- package/.github/workflows/deploy-github-pages.yaml +33 -0
- package/.storybook/main.js +27 -1
- package/.storybook/manager-head.html +1 -0
- package/.storybook/manager.js +9 -0
- package/.storybook/preview-head.html +1 -1
- package/.storybook/preview.js +59 -5
- package/.storybook/static/logo.svg +19 -0
- package/.storybook/theme.js +7 -0
- package/CHANGELOG.md +43 -0
- package/README.md +1 -1
- package/dist/Button.js +39 -30
- package/dist/ButtonGroup.js +5 -7
- package/dist/Checkbox.js +107 -88
- package/dist/CheckboxGroup.js +43 -38
- package/dist/{Chip-389013ff.js → Chip-dac7337d.js} +7 -2
- package/dist/ChipGroup.js +4 -6
- package/dist/ChipLink.js +6 -8
- package/dist/ChipRemovable.js +4 -7
- package/dist/ChipSelectable.js +10 -10
- package/dist/Dropdown.js +57 -27
- package/dist/Input.js +59 -43
- package/dist/Menu.js +2 -5
- package/dist/MenuItem.js +34 -17
- package/dist/Pagination.js +57 -55
- package/dist/Radio.js +13 -10
- package/dist/RadioGroup.js +43 -40
- package/dist/Select.js +57 -44
- package/dist/Table.js +147 -125
- package/dist/{defineElement-ba770aed.js → _rollupPluginBabelHelpers-20f659f4.js} +1 -15
- package/dist/defineElement-47d4f665.js +15 -0
- package/dist/index.js +29 -19
- package/dist/leu-button-group.js +7 -3
- package/dist/leu-button.js +6 -3
- package/dist/leu-checkbox-group.js +6 -3
- package/dist/leu-checkbox.js +6 -3
- package/dist/leu-chip-group.js +6 -3
- package/dist/leu-chip-link.js +7 -4
- package/dist/leu-chip-removable.js +7 -4
- package/dist/leu-chip-selectable.js +7 -4
- package/dist/leu-dropdown.js +13 -3
- package/dist/leu-input.js +7 -3
- package/dist/leu-menu-item.js +8 -3
- package/dist/leu-menu.js +6 -3
- package/dist/leu-pagination.js +8 -3
- package/dist/leu-popup-4bf6f1f4.js +216 -0
- package/dist/leu-radio-group.js +6 -3
- package/dist/leu-radio.js +6 -3
- package/dist/leu-select.js +14 -3
- package/dist/leu-table.js +9 -3
- package/package.json +29 -12
- package/scripts/generate-component/templates/[Name].js +0 -5
- package/scripts/generate-component/templates/[name].css +1 -1
- package/scripts/generate-component/templates/[namespace]-[name].js +5 -2
- package/src/components/accordion/Accordion.js +3 -9
- package/src/components/accordion/leu-accordion.js +5 -2
- package/src/components/accordion/stories/accordion.stories.js +7 -4
- package/src/components/accordion/test/accordion.test.js +92 -2
- package/src/components/breadcrumb/Breadcrumb.js +310 -0
- package/src/components/breadcrumb/breadcrumb.css +114 -0
- package/src/components/breadcrumb/leu-breadcrumb.js +6 -0
- package/src/components/breadcrumb/stories/breadcrumb.stories.js +73 -0
- package/src/components/breadcrumb/test/breadcrumb.test.js +141 -0
- package/src/components/button/Button.js +22 -27
- package/src/components/button/button.css +3 -3
- package/src/components/button/leu-button.js +5 -2
- package/src/components/button/stories/button.stories.js +58 -37
- package/src/components/button/test/button.test.js +112 -2
- package/src/components/button-group/ButtonGroup.js +1 -7
- package/src/components/button-group/leu-button-group.js +5 -2
- package/src/components/button-group/stories/button-group.stories.js +6 -0
- package/src/components/button-group/test/button-group.test.js +79 -3
- package/src/components/checkbox/Checkbox.js +9 -89
- package/src/components/checkbox/CheckboxGroup.js +9 -39
- package/src/components/checkbox/checkbox-group.css +29 -0
- package/src/components/checkbox/checkbox.css +76 -0
- package/src/components/checkbox/leu-checkbox-group.js +5 -2
- package/src/components/checkbox/leu-checkbox.js +5 -2
- package/src/components/checkbox/stories/checkbox-group.stories.js +44 -21
- package/src/components/checkbox/stories/checkbox.stories.js +7 -1
- package/src/components/checkbox/test/checkbox-group.test.js +124 -0
- package/src/components/checkbox/test/checkbox.test.js +72 -59
- package/src/components/chip/Chip.js +2 -1
- package/src/components/chip/ChipGroup.js +1 -6
- package/src/components/chip/ChipLink.js +2 -8
- package/src/components/chip/ChipRemovable.js +1 -6
- package/src/components/chip/ChipSelectable.js +4 -9
- package/src/components/chip/exports.js +4 -10
- package/src/components/chip/leu-chip-group.js +5 -2
- package/src/components/chip/leu-chip-link.js +5 -2
- package/src/components/chip/leu-chip-removable.js +5 -2
- package/src/components/chip/leu-chip-selectable.js +5 -2
- package/src/components/chip/stories/chip-group.stories.js +18 -6
- package/src/components/chip/stories/chip-link.stories.js +16 -4
- package/src/components/chip/stories/chip-removable.stories.js +15 -4
- package/src/components/chip/stories/chip-selectable.stories.js +13 -3
- package/src/components/chip/test/chip-group.test.js +124 -0
- package/src/components/chip/test/chip-link.test.js +58 -0
- package/src/components/chip/test/chip-removable.test.js +79 -0
- package/src/components/chip/test/chip-selectable.test.js +95 -0
- package/src/components/chip/test/chip.test.js +1 -1
- package/src/components/dropdown/Dropdown.js +53 -25
- package/src/components/dropdown/dropdown.css +1 -2
- package/src/components/dropdown/leu-dropdown.js +5 -2
- package/src/components/dropdown/stories/dropdown.stories.js +11 -5
- package/src/components/dropdown/test/dropdown.test.js +6 -6
- package/src/components/icon/icon.js +1 -1
- package/src/components/icon/test/icon.test.js +66 -0
- package/src/components/input/Input.js +33 -39
- package/src/components/input/input.css +9 -6
- package/src/components/input/leu-input.js +5 -2
- package/src/components/input/stories/input.stories.js +8 -2
- package/src/components/input/test/input.test.js +431 -4
- package/src/components/menu/Menu.js +0 -5
- package/src/components/menu/MenuItem.js +22 -15
- package/src/components/menu/leu-menu-item.js +5 -2
- package/src/components/menu/leu-menu.js +5 -2
- package/src/components/menu/menu-item.css +5 -2
- package/src/components/menu/stories/menu-item.stories.js +13 -4
- package/src/components/menu/stories/menu.stories.js +11 -5
- package/src/components/menu/test/menu-item.test.js +180 -0
- package/src/components/menu/test/menu.test.js +10 -2
- package/src/components/pagination/Pagination.js +53 -65
- package/src/components/pagination/leu-pagination.js +5 -2
- package/src/components/pagination/stories/pagination.stories.js +17 -9
- package/src/components/pagination/test/pagination.test.js +191 -5
- package/src/components/popup/Popup.js +200 -0
- package/src/components/popup/leu-popup.js +6 -0
- package/src/components/popup/popup.css +27 -0
- package/src/components/popup/stories/popup.stories.js +58 -0
- package/src/components/popup/test/popup.test.js +29 -0
- package/src/components/radio/Radio.js +5 -10
- package/src/components/radio/RadioGroup.js +7 -39
- package/src/components/radio/leu-radio-group.js +5 -2
- package/src/components/radio/leu-radio.js +5 -2
- package/src/components/radio/radio-group.css +29 -0
- package/src/components/radio/stories/radio-group.stories.js +38 -19
- package/src/components/radio/stories/radio.stories.js +7 -1
- package/src/components/radio/test/radio-group.test.js +86 -0
- package/src/components/radio/test/radio.test.js +108 -17
- package/src/components/select/Select.js +35 -32
- package/src/components/select/leu-select.js +5 -2
- package/src/components/select/select.css +13 -13
- package/src/components/select/stories/select.stories.js +15 -168
- package/src/components/select/test/fixtures.js +162 -0
- package/src/components/select/test/select.test.js +236 -12
- package/src/components/table/Table.js +48 -123
- package/src/components/table/leu-table.js +5 -2
- package/src/components/table/stories/table.stories.js +20 -10
- package/src/components/table/table.css +99 -0
- package/src/components/table/test/table.test.js +1 -1
- package/src/lib/utils.js +17 -0
- package/{web-dev-server-storybook.config.mjs → web-dev-server.config.mjs} +1 -2
- package/web-test-runner.config.mjs +15 -2
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { html } from "lit"
|
|
2
|
+
import { fixture, expect, oneEvent } from "@open-wc/testing"
|
|
3
|
+
|
|
4
|
+
import "../leu-chip-selectable.js"
|
|
5
|
+
import "../leu-chip-removable.js"
|
|
6
|
+
import "../leu-chip-group.js"
|
|
7
|
+
|
|
8
|
+
async function removableFixture() {
|
|
9
|
+
return fixture(
|
|
10
|
+
html`
|
|
11
|
+
<leu-chip-group>
|
|
12
|
+
<leu-chip-removable label="Publikationen"></leu-chip-removable>
|
|
13
|
+
<leu-chip-removable label="Daten" value="2"></leu-chip-removable>
|
|
14
|
+
<leu-chip-removable
|
|
15
|
+
label="Schnittstellen"
|
|
16
|
+
value="3"
|
|
17
|
+
></leu-chip-removable>
|
|
18
|
+
</leu-chip-group>
|
|
19
|
+
`
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function singleSelectionFixture() {
|
|
24
|
+
return fixture(
|
|
25
|
+
html`
|
|
26
|
+
<leu-chip-group selection-mode="single">
|
|
27
|
+
<leu-chip-selectable
|
|
28
|
+
label="Publikationen"
|
|
29
|
+
value="1"
|
|
30
|
+
variant="radio"
|
|
31
|
+
></leu-chip-selectable>
|
|
32
|
+
<leu-chip-selectable
|
|
33
|
+
label="Daten"
|
|
34
|
+
value="2"
|
|
35
|
+
variant="radio"
|
|
36
|
+
></leu-chip-selectable>
|
|
37
|
+
<leu-chip-selectable
|
|
38
|
+
label="Schnittstellen"
|
|
39
|
+
value="3"
|
|
40
|
+
variant="radio"
|
|
41
|
+
></leu-chip-selectable>
|
|
42
|
+
</leu-chip-group>
|
|
43
|
+
`
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function multipleSelectionFixture() {
|
|
48
|
+
return fixture(
|
|
49
|
+
html`
|
|
50
|
+
<leu-chip-group selection-mode="multiple">
|
|
51
|
+
<leu-chip-selectable
|
|
52
|
+
label="Publikationen"
|
|
53
|
+
value="1"
|
|
54
|
+
></leu-chip-selectable>
|
|
55
|
+
<leu-chip-selectable label="Daten" value="2"></leu-chip-selectable>
|
|
56
|
+
<leu-chip-selectable
|
|
57
|
+
label="Schnittstellen"
|
|
58
|
+
value="3"
|
|
59
|
+
></leu-chip-selectable>
|
|
60
|
+
</leu-chip-group>
|
|
61
|
+
`
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
describe("LeuChipGroup", () => {
|
|
66
|
+
it("is a defined element", async () => {
|
|
67
|
+
const el = customElements.get("leu-chip-selectable")
|
|
68
|
+
|
|
69
|
+
await expect(el).not.to.be.undefined
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it("passes the a11y audit with removable chips", async () => {
|
|
73
|
+
const el = await removableFixture()
|
|
74
|
+
|
|
75
|
+
await expect(el).shadowDom.to.be.accessible()
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it("passes the a11y audit with selectable chips", async () => {
|
|
79
|
+
const el = await multipleSelectionFixture()
|
|
80
|
+
|
|
81
|
+
await expect(el).shadowDom.to.be.accessible()
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
it("passes the a11y audit with selectable radio chips", async () => {
|
|
85
|
+
const el = await singleSelectionFixture()
|
|
86
|
+
|
|
87
|
+
await expect(el).shadowDom.to.be.accessible()
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
it("updates the value when a chip is selected", async () => {
|
|
91
|
+
const el = await singleSelectionFixture()
|
|
92
|
+
const chip = el.querySelector("leu-chip-selectable")
|
|
93
|
+
const chipButton = chip.shadowRoot.querySelector("button")
|
|
94
|
+
chipButton.click()
|
|
95
|
+
|
|
96
|
+
await expect(el.value).to.deep.equal(["1"])
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it("updates the value when multiple chips are selected", async () => {
|
|
100
|
+
const el = await multipleSelectionFixture()
|
|
101
|
+
const chips = el.querySelectorAll("leu-chip-selectable")
|
|
102
|
+
const chipButton2 = chips[1].shadowRoot.querySelector("button")
|
|
103
|
+
const chipButton3 = chips[2].shadowRoot.querySelector("button")
|
|
104
|
+
|
|
105
|
+
chipButton2.click()
|
|
106
|
+
chipButton3.click()
|
|
107
|
+
|
|
108
|
+
await expect(el.value).to.deep.equal(["2", "3"])
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
it("fires an input event when a chip is selected", async () => {
|
|
112
|
+
const el = await singleSelectionFixture()
|
|
113
|
+
const chip = el.querySelector("leu-chip-selectable")
|
|
114
|
+
const chipButton = chip.shadowRoot.querySelector("button")
|
|
115
|
+
|
|
116
|
+
setTimeout(() => {
|
|
117
|
+
chipButton.click()
|
|
118
|
+
}, 0)
|
|
119
|
+
|
|
120
|
+
const event = await oneEvent(el, "input")
|
|
121
|
+
|
|
122
|
+
await expect(event).to.exist
|
|
123
|
+
})
|
|
124
|
+
})
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { html } from "lit"
|
|
2
|
+
import { fixture, expect } from "@open-wc/testing"
|
|
3
|
+
|
|
4
|
+
import "../leu-chip-link.js"
|
|
5
|
+
|
|
6
|
+
async function defaultFixture() {
|
|
7
|
+
return fixture(
|
|
8
|
+
html`
|
|
9
|
+
<leu-chip-link label="Daten" href="https://zh.ch/daten"></leu-chip-link>
|
|
10
|
+
`
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
describe("LeuChipLink", () => {
|
|
15
|
+
it("is a defined element", async () => {
|
|
16
|
+
const el = customElements.get("leu-chip-link")
|
|
17
|
+
|
|
18
|
+
await expect(el).not.to.be.undefined
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it("passes the a11y audit", async () => {
|
|
22
|
+
const el = await defaultFixture()
|
|
23
|
+
|
|
24
|
+
await expect(el).shadowDom.to.be.accessible()
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it("renders the label", async () => {
|
|
28
|
+
const el = await defaultFixture()
|
|
29
|
+
|
|
30
|
+
const link = el.shadowRoot.querySelector("a")
|
|
31
|
+
|
|
32
|
+
expect(link).to.have.trimmed.text("Daten")
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it("renders a link element", async () => {
|
|
36
|
+
const el = await defaultFixture()
|
|
37
|
+
|
|
38
|
+
expect(el.shadowRoot.querySelector("a")).to.exist
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it("passes the href attribute to the link", async () => {
|
|
42
|
+
const el = await defaultFixture()
|
|
43
|
+
|
|
44
|
+
expect(el.shadowRoot.querySelector("a").getAttribute("href")).to.equal(
|
|
45
|
+
"https://zh.ch/daten"
|
|
46
|
+
)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it("delegates the focus to the a element", async () => {
|
|
50
|
+
const el = await defaultFixture()
|
|
51
|
+
|
|
52
|
+
el.focus()
|
|
53
|
+
|
|
54
|
+
expect(el.shadowRoot.querySelector("a")).to.equal(
|
|
55
|
+
el.shadowRoot.activeElement
|
|
56
|
+
)
|
|
57
|
+
})
|
|
58
|
+
})
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { html } from "lit"
|
|
2
|
+
import { fixture, expect, oneEvent } from "@open-wc/testing"
|
|
3
|
+
import { sendKeys } from "@web/test-runner-commands"
|
|
4
|
+
|
|
5
|
+
import { iconPaths } from "../../icon/icon.js"
|
|
6
|
+
|
|
7
|
+
import "../leu-chip-group.js"
|
|
8
|
+
|
|
9
|
+
async function defaultFixture() {
|
|
10
|
+
return fixture(
|
|
11
|
+
html` <leu-chip-removable label="Daten"></leu-chip-removable> `
|
|
12
|
+
)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
describe("LeuChipRemovable", () => {
|
|
16
|
+
it("is a defined element", async () => {
|
|
17
|
+
const el = customElements.get("leu-chip-removable")
|
|
18
|
+
|
|
19
|
+
await expect(el).not.to.be.undefined
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
it("passes the a11y audit", async () => {
|
|
23
|
+
const el = await defaultFixture()
|
|
24
|
+
|
|
25
|
+
await expect(el).shadowDom.to.be.accessible()
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it("renders the label", async () => {
|
|
29
|
+
const el = await defaultFixture()
|
|
30
|
+
|
|
31
|
+
const button = el.shadowRoot.querySelector("button")
|
|
32
|
+
|
|
33
|
+
expect(button).to.have.trimmed.text("Daten")
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it("renders a button element", async () => {
|
|
37
|
+
const el = await defaultFixture()
|
|
38
|
+
|
|
39
|
+
expect(el.shadowRoot.querySelector("button")).to.exist
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it("renders a remove icon", async () => {
|
|
43
|
+
const el = await defaultFixture()
|
|
44
|
+
|
|
45
|
+
const iconPath = el.shadowRoot.querySelector("svg path")
|
|
46
|
+
|
|
47
|
+
expect(iconPath.getAttribute("d")).to.equal(iconPaths.close)
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it("delegates the focus to the button element", async () => {
|
|
51
|
+
const el = await defaultFixture()
|
|
52
|
+
|
|
53
|
+
el.focus()
|
|
54
|
+
|
|
55
|
+
expect(el.shadowRoot.querySelector("button")).to.equal(
|
|
56
|
+
el.shadowRoot.activeElement
|
|
57
|
+
)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it("fires a remove event when the button is clicked", async () => {
|
|
61
|
+
const el = await defaultFixture()
|
|
62
|
+
const button = el.shadowRoot.querySelector("button")
|
|
63
|
+
|
|
64
|
+
setTimeout(() => button.click())
|
|
65
|
+
const event = await oneEvent(el, "remove")
|
|
66
|
+
|
|
67
|
+
expect(event).to.exist
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it("fires a remove event when the enter key is pressed", async () => {
|
|
71
|
+
const el = await defaultFixture()
|
|
72
|
+
|
|
73
|
+
el.focus()
|
|
74
|
+
setTimeout(() => sendKeys({ press: "Enter" }))
|
|
75
|
+
const event = await oneEvent(el, "remove")
|
|
76
|
+
|
|
77
|
+
expect(event).to.exist
|
|
78
|
+
})
|
|
79
|
+
})
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { html } from "lit"
|
|
2
|
+
import { ifDefined } from "lit/directives/if-defined.js"
|
|
3
|
+
import { fixture, expect, oneEvent } from "@open-wc/testing"
|
|
4
|
+
import { sendKeys } from "@web/test-runner-commands"
|
|
5
|
+
|
|
6
|
+
import "../leu-chip-selectable.js"
|
|
7
|
+
|
|
8
|
+
async function defaultFixture(args = {}) {
|
|
9
|
+
return fixture(
|
|
10
|
+
html`
|
|
11
|
+
<leu-chip-selectable
|
|
12
|
+
label="Publikationen"
|
|
13
|
+
value="Publikationen"
|
|
14
|
+
variant=${ifDefined(args.variant)}
|
|
15
|
+
?selected=${args.selected}
|
|
16
|
+
></leu-chip-selectable>
|
|
17
|
+
`
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
describe("LeuChipSelectable", () => {
|
|
22
|
+
it("is a defined element", async () => {
|
|
23
|
+
const el = customElements.get("leu-chip-selectable")
|
|
24
|
+
|
|
25
|
+
await expect(el).not.to.be.undefined
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
it("passes the a11y audit", async () => {
|
|
29
|
+
const el = await defaultFixture()
|
|
30
|
+
|
|
31
|
+
await expect(el).shadowDom.to.be.accessible()
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it("renders the label", async () => {
|
|
35
|
+
const el = await defaultFixture()
|
|
36
|
+
|
|
37
|
+
const button = el.shadowRoot.querySelector("button")
|
|
38
|
+
|
|
39
|
+
expect(button).to.have.trimmed.text("Publikationen")
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it("renders a button element", async () => {
|
|
43
|
+
const el = await defaultFixture()
|
|
44
|
+
|
|
45
|
+
expect(el.shadowRoot.querySelector("button")).to.exist
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it("delegates the focus to the button element", async () => {
|
|
49
|
+
const el = await defaultFixture()
|
|
50
|
+
|
|
51
|
+
el.focus()
|
|
52
|
+
|
|
53
|
+
expect(el.shadowRoot.querySelector("button")).to.equal(
|
|
54
|
+
el.shadowRoot.activeElement
|
|
55
|
+
)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it("fires a input event when the button is clicked", async () => {
|
|
59
|
+
const el = await defaultFixture()
|
|
60
|
+
const button = el.shadowRoot.querySelector("button")
|
|
61
|
+
|
|
62
|
+
setTimeout(() => button.click())
|
|
63
|
+
const event = await oneEvent(el, "input")
|
|
64
|
+
|
|
65
|
+
expect(event).to.exist
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
it("fires a input event when the enter key is pressed", async () => {
|
|
69
|
+
const el = await defaultFixture()
|
|
70
|
+
|
|
71
|
+
el.focus()
|
|
72
|
+
setTimeout(() => sendKeys({ press: "Enter" }))
|
|
73
|
+
const event = await oneEvent(el, "input")
|
|
74
|
+
|
|
75
|
+
expect(event).to.exist
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it("removes the selected state when the button is clicked", async () => {
|
|
79
|
+
const el = await defaultFixture({ selected: true })
|
|
80
|
+
const button = el.shadowRoot.querySelector("button")
|
|
81
|
+
|
|
82
|
+
button.click()
|
|
83
|
+
|
|
84
|
+
expect(el.selected).to.be.false
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it("doesn't remove the selected state of a selected radio chip", async () => {
|
|
88
|
+
const el = await defaultFixture({ variant: "radio", selected: true })
|
|
89
|
+
|
|
90
|
+
const button = el.shadowRoot.querySelector("button")
|
|
91
|
+
button.click()
|
|
92
|
+
|
|
93
|
+
expect(el.selected).to.be.true
|
|
94
|
+
})
|
|
95
|
+
})
|
|
@@ -9,7 +9,7 @@ async function defaultFixture() {
|
|
|
9
9
|
|
|
10
10
|
describe("LeuChipLink", () => {
|
|
11
11
|
it("is a defined element", async () => {
|
|
12
|
-
const el =
|
|
12
|
+
const el = customElements.get("leu-chip-link")
|
|
13
13
|
|
|
14
14
|
await expect(el).not.to.be.undefined
|
|
15
15
|
})
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { html, LitElement } from "lit"
|
|
2
|
-
import { defineElement } from "../../lib/defineElement.js"
|
|
3
2
|
import styles from "./dropdown.css"
|
|
4
3
|
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
4
|
+
import "../button/leu-button.js"
|
|
5
|
+
import "../menu/leu-menu.js"
|
|
6
|
+
import "../menu/leu-menu-item.js"
|
|
7
|
+
import "../popup/leu-popup.js"
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @tagname leu-dropdown
|
|
@@ -13,7 +13,7 @@ export class LeuDropdown extends LitElement {
|
|
|
13
13
|
static styles = styles
|
|
14
14
|
|
|
15
15
|
static properties = {
|
|
16
|
-
label: { type: String },
|
|
16
|
+
label: { type: String, reflect: true },
|
|
17
17
|
expanded: { type: Boolean, reflect: true },
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -22,34 +22,62 @@ export class LeuDropdown extends LitElement {
|
|
|
22
22
|
|
|
23
23
|
this.label = ""
|
|
24
24
|
this.expanded = false
|
|
25
|
+
this.menuItems = []
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
disconnectedCallback() {
|
|
29
|
+
super.disconnectedCallback()
|
|
30
|
+
this._removeMenuItemListeners()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
_handleSlotChange() {
|
|
34
|
+
this._removeMenuItemListeners()
|
|
35
|
+
this.menuItems = [...this.querySelectorAll("leu-menu > leu-menu-item")]
|
|
36
|
+
|
|
37
|
+
this.menuItems.forEach((item) =>
|
|
38
|
+
item.addEventListener("click", this._handleMenuItemClick)
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
_removeMenuItemListeners() {
|
|
43
|
+
this.menuItems.forEach((item) => {
|
|
44
|
+
item.removeEventListener("click", this._handleMenuItemClick)
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
_handleMenuItemClick = () => {
|
|
49
|
+
this.expanded = false
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
_handleToggleClick() {
|
|
28
53
|
this.expanded = !this.expanded
|
|
29
54
|
}
|
|
30
55
|
|
|
31
56
|
render() {
|
|
32
57
|
return html`
|
|
33
|
-
<leu-
|
|
34
|
-
icon="download"
|
|
35
|
-
variant="ghost"
|
|
36
|
-
label=${this.label}
|
|
37
|
-
expanded=${this.expanded ? "open" : "closed"}
|
|
38
|
-
aria-expanded=${this.expanded ? "true" : "false"}
|
|
39
|
-
aria-controls="content"
|
|
58
|
+
<leu-popup
|
|
40
59
|
?active=${this.expanded}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
60
|
+
placement="bottom-start"
|
|
61
|
+
shift
|
|
62
|
+
shiftPadding="8"
|
|
63
|
+
autoSize="width"
|
|
64
|
+
autoSizePadding="8"
|
|
65
|
+
>
|
|
66
|
+
<leu-button
|
|
67
|
+
slot="anchor"
|
|
68
|
+
icon="download"
|
|
69
|
+
variant="ghost"
|
|
70
|
+
label=${this.label}
|
|
71
|
+
expanded=${this.expanded ? "open" : "closed"}
|
|
72
|
+
aria-expanded=${this.expanded ? "true" : "false"}
|
|
73
|
+
aria-controls="content"
|
|
74
|
+
?active=${this.expanded}
|
|
75
|
+
@click=${this._handleToggleClick}
|
|
76
|
+
></leu-button>
|
|
77
|
+
<div id="content" class="content" ?hidden=${!this.expanded}>
|
|
78
|
+
<slot @slotchange=${this._handleSlotChange}></slot>
|
|
79
|
+
</div>
|
|
80
|
+
</leu-popup>
|
|
46
81
|
`
|
|
47
82
|
}
|
|
48
83
|
}
|
|
49
|
-
|
|
50
|
-
export function defineDropdownElements() {
|
|
51
|
-
defineElement("dropdown", LeuDropdown)
|
|
52
|
-
defineButtonElements()
|
|
53
|
-
defineMenuElements()
|
|
54
|
-
defineMenuItemElements()
|
|
55
|
-
}
|
|
@@ -4,17 +4,23 @@ import "../leu-dropdown.js"
|
|
|
4
4
|
export default {
|
|
5
5
|
title: "Dropdown",
|
|
6
6
|
component: "leu-dropdown",
|
|
7
|
+
parameters: {
|
|
8
|
+
design: {
|
|
9
|
+
type: "figma",
|
|
10
|
+
url: "https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=136815-217650&mode=design&t=lzVrtq8lxYVJU5TB-11",
|
|
11
|
+
},
|
|
12
|
+
},
|
|
7
13
|
}
|
|
8
14
|
|
|
9
15
|
function Template({ label, expanded }) {
|
|
10
16
|
return html` <leu-dropdown label=${label} ?expanded=${expanded}>
|
|
11
17
|
<leu-menu>
|
|
12
|
-
<leu-menu-item
|
|
13
|
-
<leu-menu-item
|
|
18
|
+
<leu-menu-item label="Als CSV Tabelle"></leu-menu-item>
|
|
19
|
+
<leu-menu-item label="Als XLS Tabelle"></leu-menu-item>
|
|
14
20
|
<hr />
|
|
15
|
-
<leu-menu-item
|
|
16
|
-
<leu-menu-item
|
|
17
|
-
<leu-menu-item
|
|
21
|
+
<leu-menu-item label="Als PNG exportieren"></leu-menu-item>
|
|
22
|
+
<leu-menu-item label="Als SVG exportieren"></leu-menu-item>
|
|
23
|
+
<leu-menu-item label="Als PDF exportieren" disabled></leu-menu-item>
|
|
18
24
|
</leu-menu>
|
|
19
25
|
</leu-dropdown>`
|
|
20
26
|
}
|
|
@@ -6,19 +6,19 @@ import "../leu-dropdown.js"
|
|
|
6
6
|
async function defaultFixture() {
|
|
7
7
|
return fixture(html` <leu-dropdown label="Download">
|
|
8
8
|
<leu-menu>
|
|
9
|
-
<leu-menu-item
|
|
10
|
-
<leu-menu-item
|
|
9
|
+
<leu-menu-item label="Als CSV Tabelle"></leu-menu-item>
|
|
10
|
+
<leu-menu-item label="Als XLS Tabelle"></leu-menu-item>
|
|
11
11
|
<hr />
|
|
12
|
-
<leu-menu-item
|
|
13
|
-
<leu-menu-item
|
|
14
|
-
<leu-menu-item
|
|
12
|
+
<leu-menu-item label="Als PNG exportieren"></leu-menu-item>
|
|
13
|
+
<leu-menu-item label="Als SVG exportieren"></leu-menu-item>
|
|
14
|
+
<leu-menu-item label="Als PDF exportieren"></leu-menu-item>
|
|
15
15
|
</leu-menu>
|
|
16
16
|
</leu-dropdown>`)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
describe("LeuDropdown", () => {
|
|
20
20
|
it("is a defined element", async () => {
|
|
21
|
-
const el =
|
|
21
|
+
const el = customElements.get("leu-dropdown")
|
|
22
22
|
|
|
23
23
|
await expect(el).not.to.be.undefined
|
|
24
24
|
})
|
|
@@ -5,7 +5,7 @@ import { html, svg } from "lit"
|
|
|
5
5
|
// - click icon and then export as svg on the right drawer
|
|
6
6
|
// - copy svg path (multiple with space between)
|
|
7
7
|
// - update @param {TYPE} with console.log() below
|
|
8
|
-
const iconPaths = {
|
|
8
|
+
export const iconPaths = {
|
|
9
9
|
addNew:
|
|
10
10
|
"M12 1C5.926 1 1 5.925 1 12C1 18.075 5.926 23 12 23C18.074 23 23 18.075 23 12C23 5.925 18.074 1 12 1ZM17 13H13V17H11V13H7V11H11V7H13V11H17V13Z",
|
|
11
11
|
angleDropDown: "M17 9.5L12 14.5L7 9.5L17 9.5Z",
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { html } from "lit"
|
|
2
|
+
import { fixture, expect } from "@open-wc/testing"
|
|
3
|
+
|
|
4
|
+
import { Icon, iconPaths } from "../icon.js"
|
|
5
|
+
|
|
6
|
+
async function defaultFixture(args = {}) {
|
|
7
|
+
const { name = "edit", size } = args
|
|
8
|
+
return fixture(html`${Icon(name, size)} `)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
describe("Icon", () => {
|
|
12
|
+
it("passes the a11y audit", async () => {
|
|
13
|
+
const el = await defaultFixture()
|
|
14
|
+
|
|
15
|
+
await expect(el).shadowDom.to.be.accessible()
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it("renders an svg html element", async () => {
|
|
19
|
+
const el = await defaultFixture()
|
|
20
|
+
|
|
21
|
+
expect(el).to.have.tagName("svg")
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it("renders a single path", async () => {
|
|
25
|
+
const el = await defaultFixture()
|
|
26
|
+
|
|
27
|
+
expect(el.querySelectorAll("path")).to.have.lengthOf(1)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
it("renders the correct path", async () => {
|
|
31
|
+
const el = await defaultFixture({ name: "share" })
|
|
32
|
+
|
|
33
|
+
const d = el.querySelector("path").getAttribute("d")
|
|
34
|
+
|
|
35
|
+
expect(d).to.equal(iconPaths.share)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
it("has the size 24x24 by default", async () => {
|
|
39
|
+
const el = await defaultFixture()
|
|
40
|
+
|
|
41
|
+
const width = el.getAttribute("width")
|
|
42
|
+
const height = el.getAttribute("height")
|
|
43
|
+
|
|
44
|
+
expect(width).to.equal("24")
|
|
45
|
+
expect(height).to.equal("24")
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it("has the size 16x16", async () => {
|
|
49
|
+
const el = await defaultFixture({ size: "16" })
|
|
50
|
+
|
|
51
|
+
const width = el.getAttribute("width")
|
|
52
|
+
const height = el.getAttribute("height")
|
|
53
|
+
|
|
54
|
+
expect(width).to.equal("16")
|
|
55
|
+
expect(height).to.equal("16")
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it("has always a square size", async () => {
|
|
59
|
+
const el = await defaultFixture({ size: "564" })
|
|
60
|
+
|
|
61
|
+
const width = el.getAttribute("width")
|
|
62
|
+
const height = el.getAttribute("height")
|
|
63
|
+
|
|
64
|
+
expect(width).to.equal(height)
|
|
65
|
+
})
|
|
66
|
+
})
|