@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
|
@@ -1,40 +1,59 @@
|
|
|
1
1
|
import { html } from "lit"
|
|
2
2
|
import "../leu-radio.js"
|
|
3
3
|
import "../leu-radio-group.js"
|
|
4
|
+
import { ifDefined } from "lit/directives/if-defined.js"
|
|
4
5
|
|
|
5
6
|
export default {
|
|
6
7
|
title: "Radio/Group",
|
|
7
8
|
component: "leu-radio-group",
|
|
8
9
|
argTypes: {
|
|
9
|
-
|
|
10
|
+
label: { control: "text" },
|
|
10
11
|
orientation: {
|
|
11
12
|
options: ["VERTICAL", "HORIZONTAL"],
|
|
12
13
|
control: { type: "radio" },
|
|
13
14
|
},
|
|
14
15
|
},
|
|
16
|
+
parameters: {
|
|
17
|
+
design: {
|
|
18
|
+
type: "figma",
|
|
19
|
+
url: "https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=17340-81935&mode=design&t=lzVrtq8lxYVJU5TB-11",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
15
22
|
}
|
|
16
23
|
|
|
17
|
-
function Template({
|
|
24
|
+
function Template({ label, orientation }) {
|
|
18
25
|
return html`
|
|
19
|
-
<leu-radio-group
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
>
|
|
26
|
+
<leu-radio-group
|
|
27
|
+
orientation=${ifDefined(orientation)}
|
|
28
|
+
label=${ifDefined(label)}
|
|
29
|
+
>
|
|
30
|
+
<leu-radio
|
|
31
|
+
identifier="1"
|
|
32
|
+
value="1"
|
|
33
|
+
name="radio-button"
|
|
34
|
+
label="Kurz"
|
|
35
|
+
disabled
|
|
36
|
+
></leu-radio>
|
|
37
|
+
<leu-radio
|
|
38
|
+
identifier="2"
|
|
39
|
+
value="2"
|
|
40
|
+
name="radio-button"
|
|
41
|
+
label="Etwas Länger"
|
|
42
|
+
></leu-radio>
|
|
43
|
+
<leu-radio
|
|
44
|
+
identifier="3"
|
|
45
|
+
value="3"
|
|
46
|
+
name="radio-button"
|
|
47
|
+
label="Ein langes Label um sicher ein umbruch zu erzwingen"
|
|
48
|
+
></leu-radio>
|
|
30
49
|
</leu-radio-group>
|
|
31
50
|
`
|
|
32
51
|
}
|
|
33
52
|
|
|
34
53
|
export const Horizontal = Template.bind({})
|
|
35
|
-
export const
|
|
36
|
-
|
|
37
|
-
|
|
54
|
+
export const HorizontalLabel = Template.bind({})
|
|
55
|
+
HorizontalLabel.args = {
|
|
56
|
+
label: "Anrede",
|
|
38
57
|
}
|
|
39
58
|
|
|
40
59
|
export const Vertical = Template.bind({})
|
|
@@ -42,8 +61,8 @@ Vertical.args = {
|
|
|
42
61
|
orientation: "VERTICAL",
|
|
43
62
|
}
|
|
44
63
|
|
|
45
|
-
export const
|
|
46
|
-
|
|
64
|
+
export const VerticalLabel = Template.bind({})
|
|
65
|
+
VerticalLabel.args = {
|
|
47
66
|
orientation: "VERTICAL",
|
|
48
|
-
|
|
67
|
+
label: "Anrede",
|
|
49
68
|
}
|
|
@@ -9,6 +9,12 @@ export default {
|
|
|
9
9
|
control: "text",
|
|
10
10
|
},
|
|
11
11
|
},
|
|
12
|
+
parameters: {
|
|
13
|
+
design: {
|
|
14
|
+
type: "figma",
|
|
15
|
+
url: "https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=17340-81935&mode=design&t=lzVrtq8lxYVJU5TB-11",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
12
18
|
}
|
|
13
19
|
|
|
14
20
|
function Template({
|
|
@@ -23,8 +29,8 @@ function Template({
|
|
|
23
29
|
?checked=${checked}
|
|
24
30
|
?disabled=${disabled}
|
|
25
31
|
identifier=${"radio-1"}
|
|
32
|
+
label=${label}
|
|
26
33
|
>
|
|
27
|
-
${label}
|
|
28
34
|
</leu-radio>
|
|
29
35
|
`
|
|
30
36
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { html } from "lit"
|
|
2
|
+
import { fixture, expect } from "@open-wc/testing"
|
|
3
|
+
|
|
4
|
+
import "../leu-radio.js"
|
|
5
|
+
import "../leu-radio-group.js"
|
|
6
|
+
|
|
7
|
+
async function defaultFixture(args = {}) {
|
|
8
|
+
return fixture(html`
|
|
9
|
+
<leu-radio-group>
|
|
10
|
+
<span slot="legend">Legende</span>
|
|
11
|
+
<leu-radio
|
|
12
|
+
identifier="1"
|
|
13
|
+
value="1"
|
|
14
|
+
name="radio-button"
|
|
15
|
+
disabled
|
|
16
|
+
label="Kurz"
|
|
17
|
+
?checked=${args.checkedValue === "1"}
|
|
18
|
+
></leu-radio>
|
|
19
|
+
<leu-radio
|
|
20
|
+
identifier="2"
|
|
21
|
+
value="2"
|
|
22
|
+
name="radio-button"
|
|
23
|
+
label="Etwas Länger"
|
|
24
|
+
?checked=${args.checkedValue === "2"}
|
|
25
|
+
></leu-radio>
|
|
26
|
+
<leu-radio
|
|
27
|
+
identifier="3"
|
|
28
|
+
value="3"
|
|
29
|
+
name="radio-button"
|
|
30
|
+
label="Ein langes Label um sicher ein umbruch zu erzwingen"
|
|
31
|
+
?checked=${args.checkedValue === "3"}
|
|
32
|
+
></leu-radio>
|
|
33
|
+
</leu-radio-group>
|
|
34
|
+
`)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
describe("LeuRadio", () => {
|
|
38
|
+
it("is a defined element", async () => {
|
|
39
|
+
const elRadioGroup = customElements.get("leu-radio-group")
|
|
40
|
+
|
|
41
|
+
await expect(elRadioGroup).not.to.be.undefined
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it("passes the a11y audit", async () => {
|
|
45
|
+
const el = await defaultFixture()
|
|
46
|
+
|
|
47
|
+
await expect(el).shadowDom.to.be.accessible()
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it("has an empty default value", async () => {
|
|
51
|
+
const el = await defaultFixture()
|
|
52
|
+
|
|
53
|
+
expect(el.value).to.equal("")
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it("updates the value when a radio button is checked", async () => {
|
|
57
|
+
const el = await defaultFixture()
|
|
58
|
+
const leuRadio = el.querySelector('leu-radio[value="2"]')
|
|
59
|
+
const radio = leuRadio.shadowRoot.querySelector("input")
|
|
60
|
+
|
|
61
|
+
radio.click()
|
|
62
|
+
|
|
63
|
+
expect(el.value).to.equal("2")
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it("doesn't allow multiple radio buttons to be checked", async () => {
|
|
67
|
+
const el = await defaultFixture()
|
|
68
|
+
const leuRadio2 = el.querySelector('leu-radio[value="2"]')
|
|
69
|
+
const leuRadio3 = el.querySelector('leu-radio[value="3"]')
|
|
70
|
+
const radio2 = leuRadio2.shadowRoot.querySelector("input")
|
|
71
|
+
const radio3 = leuRadio3.shadowRoot.querySelector("input")
|
|
72
|
+
|
|
73
|
+
radio2.click()
|
|
74
|
+
radio3.click()
|
|
75
|
+
|
|
76
|
+
expect(el.value).to.equal("3")
|
|
77
|
+
expect(leuRadio2.checked).to.be.false
|
|
78
|
+
expect(leuRadio3.checked).to.be.true
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it("has a default value that reflects the checked radio button", async () => {
|
|
82
|
+
const el = await defaultFixture({ checkedValue: "2" })
|
|
83
|
+
|
|
84
|
+
expect(el.value).to.deep.equal("2")
|
|
85
|
+
})
|
|
86
|
+
})
|
|
@@ -1,33 +1,25 @@
|
|
|
1
1
|
import { html } from "lit"
|
|
2
|
-
import { fixture, expect } from "@open-wc/testing"
|
|
2
|
+
import { fixture, expect, elementUpdated, oneEvent } from "@open-wc/testing"
|
|
3
|
+
import { sendKeys } from "@web/test-runner-commands"
|
|
3
4
|
|
|
4
5
|
import "../leu-radio.js"
|
|
5
|
-
import "../leu-radio-group.js"
|
|
6
6
|
|
|
7
7
|
async function defaultFixture() {
|
|
8
8
|
return fixture(html`
|
|
9
|
-
<leu-radio
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
>Etwas Länger</leu-radio
|
|
16
|
-
>
|
|
17
|
-
<leu-radio identifier="3" value="3" name="radio-button"
|
|
18
|
-
>Ein langes Label um sicher ein umbruch zu erzwingen</leu-radio
|
|
19
|
-
>
|
|
20
|
-
</leu-radio-group>
|
|
9
|
+
<leu-radio
|
|
10
|
+
identifier="b"
|
|
11
|
+
value="3"
|
|
12
|
+
name="radio-button"
|
|
13
|
+
label="Ein langes Label um sicher ein umbruch zu erzwingen"
|
|
14
|
+
></leu-radio>
|
|
21
15
|
`)
|
|
22
16
|
}
|
|
23
17
|
|
|
24
18
|
describe("LeuRadio", () => {
|
|
25
19
|
it("is a defined element", async () => {
|
|
26
|
-
const elRadio =
|
|
27
|
-
const elRadioGroup = await customElements.get("leu-radio-group")
|
|
20
|
+
const elRadio = customElements.get("leu-radio")
|
|
28
21
|
|
|
29
22
|
await expect(elRadio).not.to.be.undefined
|
|
30
|
-
await expect(elRadioGroup).not.to.be.undefined
|
|
31
23
|
})
|
|
32
24
|
|
|
33
25
|
it("passes the a11y audit", async () => {
|
|
@@ -35,4 +27,103 @@ describe("LeuRadio", () => {
|
|
|
35
27
|
|
|
36
28
|
await expect(el).shadowDom.to.be.accessible()
|
|
37
29
|
})
|
|
30
|
+
|
|
31
|
+
it("is not checked by default", async () => {
|
|
32
|
+
const el = await defaultFixture()
|
|
33
|
+
|
|
34
|
+
expect(el.checked).to.be.false
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
it("sets the checked property when the checkbox", async () => {
|
|
38
|
+
const el = await defaultFixture()
|
|
39
|
+
const checkbox = el.shadowRoot.querySelector("input")
|
|
40
|
+
|
|
41
|
+
checkbox.click()
|
|
42
|
+
await elementUpdated(el)
|
|
43
|
+
|
|
44
|
+
expect(el.checked).to.be.true
|
|
45
|
+
|
|
46
|
+
checkbox.click()
|
|
47
|
+
await elementUpdated(el)
|
|
48
|
+
|
|
49
|
+
expect(el.checked).to.be.true
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it("sets the checked property when the checkbox", async () => {
|
|
53
|
+
const el = await defaultFixture()
|
|
54
|
+
const label = el.shadowRoot.querySelector("label")
|
|
55
|
+
|
|
56
|
+
label.click()
|
|
57
|
+
await elementUpdated(el)
|
|
58
|
+
|
|
59
|
+
expect(el.checked).to.be.true
|
|
60
|
+
|
|
61
|
+
label.click()
|
|
62
|
+
await elementUpdated(el)
|
|
63
|
+
|
|
64
|
+
expect(el.checked).to.be.true
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
it("does not set the checked property when disabled", async () => {
|
|
68
|
+
const el = await defaultFixture()
|
|
69
|
+
const checkbox = el.shadowRoot.querySelector("input")
|
|
70
|
+
const label = el.shadowRoot.querySelector("label")
|
|
71
|
+
|
|
72
|
+
el.disabled = true
|
|
73
|
+
await elementUpdated(el)
|
|
74
|
+
|
|
75
|
+
checkbox.click()
|
|
76
|
+
await elementUpdated(el)
|
|
77
|
+
|
|
78
|
+
expect(el.checked).to.be.false
|
|
79
|
+
|
|
80
|
+
label.click()
|
|
81
|
+
await elementUpdated(el)
|
|
82
|
+
|
|
83
|
+
expect(el.checked).to.be.false
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it("toggles the checked property when the space key is pressed", async () => {
|
|
87
|
+
const el = await defaultFixture()
|
|
88
|
+
el.focus()
|
|
89
|
+
|
|
90
|
+
await sendKeys({
|
|
91
|
+
press: "Space",
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
expect(el.checked).to.be.true
|
|
95
|
+
|
|
96
|
+
await sendKeys({
|
|
97
|
+
press: "Space",
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
expect(el.checked).to.be.true
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
it("fires a change event when clicked", async () => {
|
|
104
|
+
const el = await defaultFixture()
|
|
105
|
+
const checkbox = el.shadowRoot.querySelector("input")
|
|
106
|
+
|
|
107
|
+
setTimeout(() => checkbox.click())
|
|
108
|
+
const event = await oneEvent(el, "change")
|
|
109
|
+
|
|
110
|
+
expect(event).to.exist
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
it("fires an input event when clicked", async () => {
|
|
114
|
+
const el = await defaultFixture()
|
|
115
|
+
const checkbox = el.shadowRoot.querySelector("input")
|
|
116
|
+
|
|
117
|
+
setTimeout(() => checkbox.click())
|
|
118
|
+
const event = await oneEvent(el, "input")
|
|
119
|
+
|
|
120
|
+
expect(event).to.exist
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
it("applies the identifier to the input and the label", async () => {
|
|
124
|
+
const el = await defaultFixture()
|
|
125
|
+
|
|
126
|
+
expect(el.shadowRoot.querySelector("input").id).to.equal("b")
|
|
127
|
+
expect(el.shadowRoot.querySelector("label").htmlFor).to.equal("b")
|
|
128
|
+
})
|
|
38
129
|
})
|
|
@@ -6,12 +6,12 @@ import { ifDefined } from "lit/directives/if-defined.js"
|
|
|
6
6
|
import { createRef, ref } from "lit/directives/ref.js"
|
|
7
7
|
|
|
8
8
|
import { Icon } from "../icon/icon.js"
|
|
9
|
-
import { defineElement } from "../../lib/defineElement.js"
|
|
10
9
|
import { HasSlotController } from "../../lib/hasSlotController.js"
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
10
|
+
import "../button/leu-button.js"
|
|
11
|
+
import "../menu/leu-menu.js"
|
|
12
|
+
import "../menu/leu-menu-item.js"
|
|
13
|
+
import "../input/leu-input.js"
|
|
14
|
+
import "../popup/leu-popup.js"
|
|
15
15
|
|
|
16
16
|
import styles from "./select.css"
|
|
17
17
|
|
|
@@ -27,14 +27,14 @@ export class LeuSelect extends LitElement {
|
|
|
27
27
|
return {
|
|
28
28
|
open: { type: Boolean, attribute: "open" },
|
|
29
29
|
|
|
30
|
-
label: { type: String },
|
|
30
|
+
label: { type: String, reflect: true },
|
|
31
31
|
options: { type: Array },
|
|
32
32
|
value: { type: Array },
|
|
33
33
|
clearable: { type: Boolean, reflect: true },
|
|
34
34
|
disabled: { type: Boolean, reflect: true },
|
|
35
35
|
filterable: { type: Boolean, reflect: true },
|
|
36
36
|
multiple: { type: Boolean, reflect: true },
|
|
37
|
-
optionFilter: {
|
|
37
|
+
optionFilter: { state: true },
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -251,17 +251,18 @@ export class LeuSelect extends LitElement {
|
|
|
251
251
|
before=${ifDefined(beforeIcon)}
|
|
252
252
|
@click=${() => this.selectOption(option)}
|
|
253
253
|
role="option"
|
|
254
|
+
label=${LeuSelect.getOptionLabel(option)}
|
|
254
255
|
?active=${isSelected}
|
|
255
256
|
aria-selected=${isSelected}
|
|
256
257
|
>
|
|
257
|
-
${LeuSelect.getOptionLabel(option)}
|
|
258
258
|
</leu-menu-item>`
|
|
259
259
|
})
|
|
260
|
-
: html`<leu-menu-item
|
|
261
|
-
|
|
260
|
+
: html`<leu-menu-item
|
|
261
|
+
label=${this.optionFilter === ""
|
|
262
262
|
? "Keine Optionen"
|
|
263
|
-
: "Keine Resultate"}
|
|
264
|
-
|
|
263
|
+
: "Keine Resultate"}
|
|
264
|
+
disabled
|
|
265
|
+
></leu-menu-item>`}
|
|
265
266
|
</leu-menu>
|
|
266
267
|
`
|
|
267
268
|
}
|
|
@@ -274,8 +275,8 @@ export class LeuSelect extends LitElement {
|
|
|
274
275
|
@input=${this.handleFilterInput}
|
|
275
276
|
clearable
|
|
276
277
|
ref=${ref(this.optionFilterRef)}
|
|
277
|
-
|
|
278
|
-
>`
|
|
278
|
+
label="Nach Stichwort filtern"
|
|
279
|
+
></leu-input>`
|
|
279
280
|
}
|
|
280
281
|
|
|
281
282
|
return nothing
|
|
@@ -314,6 +315,7 @@ export class LeuSelect extends LitElement {
|
|
|
314
315
|
aria-expanded="${this.open}"
|
|
315
316
|
role="combobox"
|
|
316
317
|
ref=${ref(this.toggleButtonRef)}
|
|
318
|
+
slot="anchor"
|
|
317
319
|
>
|
|
318
320
|
<span class="label" id="select-label">${this.label}</span>
|
|
319
321
|
<span class="value"> ${this.getDisplayValue(this.value)} </span>
|
|
@@ -346,25 +348,26 @@ export class LeuSelect extends LitElement {
|
|
|
346
348
|
aria-labelledby="select-label"
|
|
347
349
|
@keydown=${this.handleKeyDown}
|
|
348
350
|
>
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
351
|
+
<leu-popup
|
|
352
|
+
?active=${this.open}
|
|
353
|
+
placement="bottom-start"
|
|
354
|
+
flip
|
|
355
|
+
matchSize="width"
|
|
356
|
+
autoSize="height"
|
|
357
|
+
autoSizePadding="8"
|
|
354
358
|
>
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
359
|
+
${this.renderToggleButton()}
|
|
360
|
+
<dialog
|
|
361
|
+
id="select-dialog"
|
|
362
|
+
class="select-menu-container"
|
|
363
|
+
?open=${this.open}
|
|
364
|
+
>
|
|
365
|
+
<slot name="before" class="before"></slot>
|
|
366
|
+
${this.renderFilterInput()} ${this.renderMenu()}
|
|
367
|
+
${this.renderApplyButton()}
|
|
368
|
+
<slot name="after" class="after"></slot>
|
|
369
|
+
</dialog>
|
|
370
|
+
</leu-popup>
|
|
360
371
|
</div> `
|
|
361
372
|
}
|
|
362
373
|
}
|
|
363
|
-
|
|
364
|
-
export function defineSelectElements() {
|
|
365
|
-
defineButtonElements()
|
|
366
|
-
defineMenuElements()
|
|
367
|
-
defineMenuItemElements()
|
|
368
|
-
defineInputElements()
|
|
369
|
-
defineElement("select", LeuSelect)
|
|
370
|
-
}
|
|
@@ -165,18 +165,22 @@
|
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
.select-menu-container {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
position: static;
|
|
169
|
+
overflow: auto;
|
|
170
|
+
|
|
171
|
+
display: flex;
|
|
172
|
+
flex-direction: column;
|
|
173
|
+
|
|
171
174
|
width: 100%;
|
|
172
|
-
|
|
173
|
-
|
|
175
|
+
max-height: var(--auto-size-available-height);
|
|
176
|
+
|
|
174
177
|
padding: 0;
|
|
175
178
|
margin: 0;
|
|
176
|
-
|
|
177
|
-
|
|
179
|
+
|
|
180
|
+
border: none;
|
|
181
|
+
border-radius: 1px;
|
|
182
|
+
background-color: white;
|
|
178
183
|
box-shadow: var(--select-box-shadow-regular), var(--select-box-shadow-short);
|
|
179
|
-
overflow: auto;
|
|
180
184
|
}
|
|
181
185
|
|
|
182
186
|
.select-menu {
|
|
@@ -184,11 +188,7 @@
|
|
|
184
188
|
padding: 0;
|
|
185
189
|
margin: 0;
|
|
186
190
|
overflow: auto;
|
|
187
|
-
max-height:
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
.select-menu.multiple {
|
|
191
|
-
max-height: 21rem;
|
|
191
|
+
max-height: 100%;
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
.before,
|