@statistikzh/leu 0.3.0 → 0.5.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 -6
- package/.storybook/static/logo.svg +19 -0
- package/.storybook/theme.js +7 -0
- package/CHANGELOG.md +54 -0
- package/README.md +1 -1
- package/custom-elements-manifest.config.js +46 -0
- package/dist/Accordion.d.ts +31 -0
- package/dist/Accordion.d.ts.map +1 -0
- package/dist/Accordion.js +257 -0
- package/dist/Breadcrumb.d.ts +69 -0
- package/dist/Breadcrumb.d.ts.map +1 -0
- package/dist/Breadcrumb.js +392 -0
- package/dist/Button-da11d064.d.ts +84 -0
- package/dist/Button-da11d064.d.ts.map +1 -0
- package/dist/Button-da11d064.js +542 -0
- package/dist/Button.d.ts +2 -0
- package/dist/Button.d.ts.map +1 -0
- package/dist/Button.js +6 -423
- package/dist/ButtonGroup.d.ts +24 -0
- package/dist/ButtonGroup.d.ts.map +1 -0
- package/dist/ButtonGroup.js +72 -43
- package/dist/Checkbox.d.ts +13 -0
- package/dist/Checkbox.d.ts.map +1 -0
- package/dist/Checkbox.js +101 -84
- package/dist/CheckboxGroup.d.ts +13 -0
- package/dist/CheckboxGroup.d.ts.map +1 -0
- package/dist/CheckboxGroup.js +41 -37
- package/dist/Chip.d.ts +5 -0
- package/dist/Chip.d.ts.map +1 -0
- package/dist/{Chip-5f70d04f.js → Chip.js} +21 -6
- package/dist/ChipGroup.d.ts +28 -0
- package/dist/ChipGroup.d.ts.map +1 -0
- package/dist/ChipGroup.js +64 -10
- package/dist/ChipLink.d.ts +15 -0
- package/dist/ChipLink.d.ts.map +1 -0
- package/dist/ChipLink.js +4 -7
- package/dist/ChipRemovable.d.ts +13 -0
- package/dist/ChipRemovable.d.ts.map +1 -0
- package/dist/ChipRemovable.js +5 -8
- package/dist/ChipSelectable.d.ts +22 -0
- package/dist/ChipSelectable.d.ts.map +1 -0
- package/dist/ChipSelectable.js +8 -11
- package/dist/Dropdown.d.ts +15 -0
- package/dist/Dropdown.d.ts.map +1 -0
- package/dist/Dropdown.js +73 -26
- package/dist/Input.d.ts +154 -0
- package/dist/Input.d.ts.map +1 -0
- package/dist/Input.js +42 -35
- package/dist/Menu.d.ts +8 -0
- package/dist/Menu.d.ts.map +1 -0
- package/dist/Menu.js +2 -5
- package/dist/MenuItem.d.ts +21 -0
- package/dist/MenuItem.d.ts.map +1 -0
- package/dist/MenuItem.js +32 -17
- package/dist/Pagination.d.ts +27 -0
- package/dist/Pagination.d.ts.map +1 -0
- package/dist/Pagination.js +121 -89
- package/dist/Popup.d.ts +18 -0
- package/dist/Popup.d.ts.map +1 -0
- package/dist/Popup.js +215 -0
- package/dist/Radio.d.ts +12 -0
- package/dist/Radio.d.ts.map +1 -0
- package/dist/Radio.js +9 -8
- package/dist/RadioGroup.d.ts +20 -0
- package/dist/RadioGroup.d.ts.map +1 -0
- package/dist/RadioGroup.js +41 -39
- package/dist/ScrollTop.d.ts +19 -0
- package/dist/ScrollTop.d.ts.map +1 -0
- package/dist/ScrollTop.js +122 -0
- package/dist/Select.d.ts +98 -0
- package/dist/Select.d.ts.map +1 -0
- package/dist/Select.js +79 -122
- package/dist/Table.d.ts +48 -0
- package/dist/Table.d.ts.map +1 -0
- package/dist/Table.js +141 -121
- package/dist/VisuallyHidden.d.ts +8 -0
- package/dist/VisuallyHidden.d.ts.map +1 -0
- package/dist/VisuallyHidden.js +28 -0
- package/dist/_rollupPluginBabelHelpers-20f659f4.d.ts +3 -0
- package/dist/_rollupPluginBabelHelpers-20f659f4.d.ts.map +1 -0
- package/dist/{defineElement-ba770aed.js → _rollupPluginBabelHelpers-20f659f4.js} +1 -15
- package/dist/defineElement-40372b4b.d.ts +9 -0
- package/dist/defineElement-40372b4b.d.ts.map +1 -0
- package/dist/defineElement-40372b4b.js +15 -0
- package/dist/icon-03e86700.d.ts +11 -0
- package/dist/icon-03e86700.d.ts.map +1 -0
- package/dist/index.js.d.ts +21 -0
- package/dist/index.js.d.ts.map +1 -0
- package/dist/index.js.js +42 -0
- package/dist/leu-accordion.d.ts +3 -0
- package/dist/leu-accordion.d.ts.map +1 -0
- package/dist/leu-accordion.js +9 -0
- package/dist/leu-breadcrumb.d.ts +3 -0
- package/dist/leu-breadcrumb.d.ts.map +1 -0
- package/dist/leu-breadcrumb.js +23 -0
- package/dist/leu-button-group.d.ts +3 -0
- package/dist/leu-button-group.d.ts.map +1 -0
- package/dist/leu-button-group.js +6 -6
- package/dist/leu-button.d.ts +3 -0
- package/dist/leu-button.d.ts.map +1 -0
- package/dist/leu-button.js +7 -3
- package/dist/leu-checkbox-group.d.ts +3 -0
- package/dist/leu-checkbox-group.d.ts.map +1 -0
- package/dist/leu-checkbox-group.js +6 -3
- package/dist/leu-checkbox.d.ts +3 -0
- package/dist/leu-checkbox.d.ts.map +1 -0
- package/dist/leu-checkbox.js +6 -3
- package/dist/leu-chip-group.d.ts +3 -0
- package/dist/leu-chip-group.d.ts.map +1 -0
- package/dist/leu-chip-group.js +7 -3
- package/dist/leu-chip-link.d.ts +3 -0
- package/dist/leu-chip-link.d.ts.map +1 -0
- package/dist/leu-chip-link.js +7 -4
- package/dist/leu-chip-removable.d.ts +3 -0
- package/dist/leu-chip-removable.d.ts.map +1 -0
- package/dist/leu-chip-removable.js +7 -4
- package/dist/leu-chip-selectable.d.ts +3 -0
- package/dist/leu-chip-selectable.d.ts.map +1 -0
- package/dist/leu-chip-selectable.js +7 -4
- package/dist/leu-dropdown.d.ts +3 -0
- package/dist/leu-dropdown.d.ts.map +1 -0
- package/dist/leu-dropdown.js +15 -4
- package/dist/leu-input.d.ts +3 -0
- package/dist/leu-input.d.ts.map +1 -0
- package/dist/leu-input.js +7 -3
- package/dist/leu-menu-item.d.ts +3 -0
- package/dist/leu-menu-item.d.ts.map +1 -0
- package/dist/leu-menu-item.js +8 -3
- package/dist/leu-menu.d.ts +3 -0
- package/dist/leu-menu.d.ts.map +1 -0
- package/dist/leu-menu.js +6 -3
- package/dist/leu-pagination.d.ts +3 -0
- package/dist/leu-pagination.d.ts.map +1 -0
- package/dist/leu-pagination.js +12 -4
- package/dist/leu-popup.d.ts +3 -0
- package/dist/leu-popup.d.ts.map +1 -0
- package/dist/leu-popup.js +9 -0
- package/dist/leu-radio-group.d.ts +3 -0
- package/dist/leu-radio-group.d.ts.map +1 -0
- package/dist/leu-radio-group.js +6 -3
- package/dist/leu-radio.d.ts +3 -0
- package/dist/leu-radio.d.ts.map +1 -0
- package/dist/leu-radio.js +6 -3
- package/dist/leu-scroll-top.d.ts +3 -0
- package/dist/leu-scroll-top.d.ts.map +1 -0
- package/dist/leu-scroll-top.js +14 -0
- package/dist/leu-select.d.ts +3 -0
- package/dist/leu-select.d.ts.map +1 -0
- package/dist/leu-select.js +16 -4
- package/dist/leu-table.d.ts +3 -0
- package/dist/leu-table.d.ts.map +1 -0
- package/dist/leu-table.js +13 -4
- package/dist/leu-visually-hidden.d.ts +3 -0
- package/dist/leu-visually-hidden.d.ts.map +1 -0
- package/dist/leu-visually-hidden.js +8 -0
- package/dist/theme.css +386 -2
- package/dist/utils-65469421.d.ts +16 -0
- package/dist/utils-65469421.d.ts.map +1 -0
- package/dist/utils-65469421.js +35 -0
- package/index.js +3 -0
- package/package.json +47 -17
- package/postcss.config.cjs +2 -0
- package/rollup.config.js +21 -40
- package/scripts/generate-component/templates/[Name].js +0 -5
- package/scripts/generate-component/templates/[name].css +3 -3
- package/scripts/generate-component/templates/[namespace]-[name].js +5 -2
- package/scripts/postcss-leu-font-styles.cjs +160 -0
- package/src/components/accordion/Accordion.js +0 -6
- package/src/components/accordion/accordion.css +2 -2
- package/src/components/accordion/leu-accordion.js +5 -2
- package/src/components/accordion/stories/accordion.stories.js +8 -4
- package/src/components/accordion/test/accordion.test.js +95 -3
- package/src/components/breadcrumb/Breadcrumb.js +311 -0
- package/src/components/breadcrumb/breadcrumb.css +103 -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 +76 -20
- package/src/components/button/button.css +13 -5
- package/src/components/button/leu-button.js +5 -2
- package/src/components/button/stories/button.stories.js +79 -105
- package/src/components/button/test/button.test.js +184 -3
- package/src/components/button-group/ButtonGroup.js +76 -40
- package/src/components/button-group/leu-button-group.js +5 -2
- package/src/components/button-group/stories/button-group.stories.js +19 -6
- package/src/components/button-group/test/button-group.test.js +87 -4
- package/src/components/checkbox/Checkbox.js +6 -85
- package/src/components/checkbox/CheckboxGroup.js +8 -38
- 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 +1 -0
- package/src/components/chip/ChipGroup.js +42 -7
- package/src/components/chip/ChipLink.js +1 -6
- package/src/components/chip/ChipRemovable.js +2 -7
- package/src/components/chip/ChipSelectable.js +5 -10
- package/src/components/chip/chip-group.css +12 -2
- package/src/components/chip/chip.css +14 -3
- 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 +110 -44
- 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 +72 -24
- 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 +25 -28
- package/src/components/input/input.css +11 -8
- package/src/components/input/leu-input.js +5 -2
- package/src/components/input/stories/input.stories.js +21 -2
- package/src/components/input/test/input.test.js +432 -4
- package/src/components/menu/Menu.js +0 -5
- package/src/components/menu/MenuItem.js +20 -13
- 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 +7 -4
- 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 +118 -99
- package/src/components/pagination/leu-pagination.js +5 -2
- package/src/components/pagination/pagination.css +6 -1
- package/src/components/pagination/stories/pagination.stories.js +30 -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 +2 -6
- package/src/components/radio/RadioGroup.js +6 -38
- 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/radio.css +1 -1
- 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/scroll-top/ScrollTop.js +87 -0
- package/src/components/scroll-top/leu-scroll-top.js +6 -0
- package/src/components/scroll-top/scroll-top.css +34 -0
- package/src/components/scroll-top/stories/scroll-top.stories.js +217 -0
- package/src/components/scroll-top/test/scroll-top.test.js +22 -0
- package/src/components/select/Select.js +58 -37
- package/src/components/select/leu-select.js +5 -2
- package/src/components/select/select.css +15 -15
- 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 +43 -118
- 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/components/visually-hidden/VisuallyHidden.js +13 -0
- package/src/components/visually-hidden/leu-visually-hidden.js +6 -0
- package/src/components/visually-hidden/stories/visually-hidden.stories.js +22 -0
- package/src/components/visually-hidden/test/visually-hidden.test.js +36 -0
- package/src/components/visually-hidden/visually-hidden.css +10 -0
- package/src/lib/defineElement.js +1 -1
- package/src/lib/hasSlotController.js +5 -3
- package/src/lib/utils.js +35 -0
- package/src/styles/custom-properties.css +6 -2
- package/src/styles/font-definitions.json +202 -0
- package/stylelint.config.mjs +2 -0
- package/tsconfig.build.json +21 -0
- package/tsconfig.json +16 -0
- package/{web-dev-server-storybook.config.mjs → web-dev-server.config.mjs} +1 -2
- package/web-test-runner.config.mjs +15 -2
- package/dist/index.js +0 -26
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
--group-font-regular: var(--leu-font-family-regular);
|
|
3
|
+
--group-font-black: var(--leu-font-family-black);
|
|
4
|
+
|
|
5
|
+
font-family: var(--group-font-regular);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.fieldset {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: flex-start;
|
|
11
|
+
flex-wrap: wrap;
|
|
12
|
+
gap: 0.5rem 1rem;
|
|
13
|
+
|
|
14
|
+
border: none;
|
|
15
|
+
padding: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.fieldset--vertical {
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
gap: 1rem;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.legend {
|
|
24
|
+
font-family: var(--group-font-black);
|
|
25
|
+
font-size: 1.125rem;
|
|
26
|
+
line-height: 1.5;
|
|
27
|
+
|
|
28
|
+
margin-bottom: 0.5rem;
|
|
29
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
--checkbox-color: var(--leu-color-black-40);
|
|
3
|
+
--checkbox-color-disabled: var(--leu-color-black-20);
|
|
4
|
+
--checkbox-color-focus: var(--leu-color-func-cyan);
|
|
5
|
+
|
|
6
|
+
--checkbox-label-color: var(--leu-color-black-100);
|
|
7
|
+
--checkbox-label-color-disabled: var(--checkbox-color-disabled);
|
|
8
|
+
|
|
9
|
+
--checkbox-tick-color: var(--leu-color-black-0);
|
|
10
|
+
|
|
11
|
+
--checkbox-font-regular: var(--leu-font-family-regular);
|
|
12
|
+
|
|
13
|
+
position: relative;
|
|
14
|
+
|
|
15
|
+
display: inline-flex;
|
|
16
|
+
align-items: flex-start;
|
|
17
|
+
gap: 0.5rem;
|
|
18
|
+
|
|
19
|
+
font-family: var(--checkbox-font-regular);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.checkbox {
|
|
23
|
+
--_length: 1.5rem;
|
|
24
|
+
appearance: none;
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
|
|
27
|
+
width: var(--_length);
|
|
28
|
+
height: var(--_length);
|
|
29
|
+
margin: 0;
|
|
30
|
+
|
|
31
|
+
border: 2px solid var(--checkbox-color);
|
|
32
|
+
border-radius: 2px;
|
|
33
|
+
|
|
34
|
+
flex: 1 0 var(--_length);
|
|
35
|
+
|
|
36
|
+
display: grid;
|
|
37
|
+
place-items: center;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.checkbox:checked {
|
|
41
|
+
background-color: var(--checkbox-color);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.checkbox:is(:hover, :checked, :focus) {
|
|
45
|
+
--checkbox-color: var(--checkbox-color-focus);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.checkbox:focus-visible {
|
|
49
|
+
outline: 2px solid var(--checkbox-color-focus);
|
|
50
|
+
outline-offset: 2px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.checkbox:disabled {
|
|
54
|
+
--checkbox-color: var(--checkbox-color-disabled);
|
|
55
|
+
cursor: not-allowed;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.label {
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
color: var(--checkbox-label-color);
|
|
61
|
+
font-size: 1rem;
|
|
62
|
+
line-height: 1.5;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.checkbox:disabled + .label {
|
|
66
|
+
--checkbox-label-color: var(--checkbox-label-color-disabled);
|
|
67
|
+
cursor: not-allowed;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.icon {
|
|
71
|
+
position: absolute;
|
|
72
|
+
top: 0;
|
|
73
|
+
left: 0;
|
|
74
|
+
color: var(--checkbox-tick-color);
|
|
75
|
+
pointer-events: none;
|
|
76
|
+
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineElement } from "../../lib/defineElement.js"
|
|
2
|
+
import { LeuCheckboxGroup } from "./CheckboxGroup.js"
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
export { LeuCheckboxGroup }
|
|
5
|
+
|
|
6
|
+
defineElement("checkbox-group", LeuCheckboxGroup)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { html } from "lit"
|
|
2
2
|
import "../leu-checkbox.js"
|
|
3
3
|
import "../leu-checkbox-group.js"
|
|
4
|
+
import { ifDefined } from "lit/directives/if-defined.js"
|
|
4
5
|
|
|
5
6
|
export default {
|
|
6
7
|
title: "Checkbox/Group",
|
|
@@ -12,32 +13,54 @@ export default {
|
|
|
12
13
|
control: { type: "checkbox" },
|
|
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-checkbox-group
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
>
|
|
30
|
-
<leu-checkbox
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
<leu-checkbox-group
|
|
27
|
+
orientation=${ifDefined(orientation)}
|
|
28
|
+
label=${ifDefined(label)}
|
|
29
|
+
>
|
|
30
|
+
<leu-checkbox
|
|
31
|
+
identifier="1"
|
|
32
|
+
value="1"
|
|
33
|
+
name="checkbox-button"
|
|
34
|
+
label="Kurz"
|
|
35
|
+
disabled
|
|
36
|
+
></leu-checkbox>
|
|
37
|
+
<leu-checkbox
|
|
38
|
+
identifier="2"
|
|
39
|
+
value="2"
|
|
40
|
+
name="checkbox-button"
|
|
41
|
+
label="Etwas Länger"
|
|
42
|
+
></leu-checkbox>
|
|
43
|
+
<leu-checkbox
|
|
44
|
+
identifier="3"
|
|
45
|
+
value="3"
|
|
46
|
+
name="checkbox-button"
|
|
47
|
+
disabled
|
|
48
|
+
label="Deaktiviert dazwischen"
|
|
49
|
+
></leu-checkbox>
|
|
50
|
+
<leu-checkbox
|
|
51
|
+
identifier="4"
|
|
52
|
+
value="4"
|
|
53
|
+
name="checkbox-button"
|
|
54
|
+
label="Ein langes Label um sicher ein umbruch zu erzwingen"
|
|
55
|
+
></leu-checkbox>
|
|
33
56
|
</leu-checkbox-group>
|
|
34
57
|
`
|
|
35
58
|
}
|
|
36
59
|
|
|
37
60
|
export const Horizontal = Template.bind({})
|
|
38
|
-
export const
|
|
39
|
-
|
|
40
|
-
|
|
61
|
+
export const HorizontalLabel = Template.bind({})
|
|
62
|
+
HorizontalLabel.args = {
|
|
63
|
+
label: "Anrede",
|
|
41
64
|
}
|
|
42
65
|
|
|
43
66
|
export const Vertical = Template.bind({})
|
|
@@ -45,8 +68,8 @@ Vertical.args = {
|
|
|
45
68
|
orientation: "VERTICAL",
|
|
46
69
|
}
|
|
47
70
|
|
|
48
|
-
export const
|
|
49
|
-
|
|
71
|
+
export const VerticalLabel = Template.bind({})
|
|
72
|
+
VerticalLabel.args = {
|
|
50
73
|
orientation: "VERTICAL",
|
|
51
|
-
|
|
74
|
+
label: "Anrede",
|
|
52
75
|
}
|
|
@@ -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({ label = "Label", value, checked, disabled }) {
|
|
@@ -17,9 +23,9 @@ function Template({ label = "Label", value, checked, disabled }) {
|
|
|
17
23
|
.value=${value}
|
|
18
24
|
?checked=${checked}
|
|
19
25
|
?disabled=${disabled}
|
|
26
|
+
label=${label}
|
|
20
27
|
identifier="checkbox-1"
|
|
21
28
|
>
|
|
22
|
-
${label}
|
|
23
29
|
</leu-checkbox>
|
|
24
30
|
`
|
|
25
31
|
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { html } from "lit"
|
|
2
|
+
import { fixture, expect } from "@open-wc/testing"
|
|
3
|
+
import { sendKeys } from "@web/test-runner-commands"
|
|
4
|
+
|
|
5
|
+
import "../leu-checkbox.js"
|
|
6
|
+
import "../leu-checkbox-group.js"
|
|
7
|
+
|
|
8
|
+
async function defaultFixture() {
|
|
9
|
+
return fixture(html`
|
|
10
|
+
<leu-checkbox-group>
|
|
11
|
+
<leu-checkbox
|
|
12
|
+
label="Option 1"
|
|
13
|
+
identifier="a"
|
|
14
|
+
value="1"
|
|
15
|
+
disabled
|
|
16
|
+
></leu-checkbox>
|
|
17
|
+
<leu-checkbox label="Option 2" identifier="b" value="2"></leu-checkbox>
|
|
18
|
+
<leu-checkbox label="Option 3" identifier="c" value="3"></leu-checkbox>
|
|
19
|
+
</leu-checkbox-group>
|
|
20
|
+
`)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function checkedFixture() {
|
|
24
|
+
return fixture(html`
|
|
25
|
+
<leu-checkbox-group>
|
|
26
|
+
<leu-checkbox
|
|
27
|
+
label="Option 1"
|
|
28
|
+
identifier="a"
|
|
29
|
+
value="1"
|
|
30
|
+
disabled
|
|
31
|
+
></leu-checkbox>
|
|
32
|
+
<leu-checkbox
|
|
33
|
+
label="Option 2"
|
|
34
|
+
identifier="b"
|
|
35
|
+
value="2"
|
|
36
|
+
checked
|
|
37
|
+
></leu-checkbox>
|
|
38
|
+
<leu-checkbox label="Option 3" identifier="c" value="3"></leu-checkbox>
|
|
39
|
+
</leu-checkbox-group>
|
|
40
|
+
`)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
describe("LeuCheckboxGroup", () => {
|
|
44
|
+
it("is a defined element", async () => {
|
|
45
|
+
const el = customElements.get("leu-checkbox-group")
|
|
46
|
+
|
|
47
|
+
await expect(el).not.to.be.undefined
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it("passes the a11y audit", async () => {
|
|
51
|
+
const el = await defaultFixture()
|
|
52
|
+
|
|
53
|
+
await expect(el).shadowDom.to.be.accessible()
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it("has a default value of an empty array", async () => {
|
|
57
|
+
const el = await defaultFixture()
|
|
58
|
+
|
|
59
|
+
expect(el.value).to.deep.equal([])
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it("updates the value when a checkbox is checked", async () => {
|
|
63
|
+
const el = await defaultFixture()
|
|
64
|
+
const leuCheckbox = el.querySelector('leu-checkbox[value="2"]')
|
|
65
|
+
const checkbox = leuCheckbox.shadowRoot.querySelector("input")
|
|
66
|
+
|
|
67
|
+
checkbox.click()
|
|
68
|
+
|
|
69
|
+
expect(el.value).to.deep.equal(["2"])
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it("allows multiple checkboxes to be checked", async () => {
|
|
73
|
+
const el = await defaultFixture()
|
|
74
|
+
const leuCheckbox2 = el.querySelector('leu-checkbox[value="2"]')
|
|
75
|
+
const leuCheckbox3 = el.querySelector('leu-checkbox[value="3"]')
|
|
76
|
+
const checkbox2 = leuCheckbox2.shadowRoot.querySelector("input")
|
|
77
|
+
const checkbox3 = leuCheckbox3.shadowRoot.querySelector("input")
|
|
78
|
+
|
|
79
|
+
checkbox2.click()
|
|
80
|
+
checkbox3.click()
|
|
81
|
+
|
|
82
|
+
expect(el.value).to.deep.equal(["2", "3"])
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
it("updates the value when a checkbox is unchecked", async () => {
|
|
86
|
+
const el = await defaultFixture()
|
|
87
|
+
const leuCheckbox = el.querySelector('leu-checkbox[value="2"]')
|
|
88
|
+
const checkbox = leuCheckbox.shadowRoot.querySelector("input")
|
|
89
|
+
|
|
90
|
+
checkbox.click()
|
|
91
|
+
checkbox.click()
|
|
92
|
+
|
|
93
|
+
expect(el.value).to.deep.equal([])
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
it("doesn't update the value when a disabled checkbox is clicked", async () => {
|
|
97
|
+
const el = await defaultFixture()
|
|
98
|
+
const leuCheckbox = el.querySelector('leu-checkbox[value="1"]')
|
|
99
|
+
const checkbox = leuCheckbox.shadowRoot.querySelector("input")
|
|
100
|
+
|
|
101
|
+
checkbox.click()
|
|
102
|
+
|
|
103
|
+
expect(el.value).to.deep.equal([])
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
it("has a default value that reflects all checked checkboxes", async () => {
|
|
107
|
+
const el = await checkedFixture()
|
|
108
|
+
|
|
109
|
+
expect(el.value).to.deep.equal(["2"])
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it("delegates focus to the first active checkbox", async () => {
|
|
113
|
+
const el = await defaultFixture()
|
|
114
|
+
const leuCheckbox = el.querySelector('leu-checkbox[value="2"]')
|
|
115
|
+
const checkbox = leuCheckbox.shadowRoot.querySelector("input")
|
|
116
|
+
|
|
117
|
+
await sendKeys({
|
|
118
|
+
press: "Tab",
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
expect(document.activeElement).to.equal(leuCheckbox)
|
|
122
|
+
expect(leuCheckbox.shadowRoot.activeElement).to.equal(checkbox)
|
|
123
|
+
})
|
|
124
|
+
})
|
|
@@ -1,32 +1,22 @@
|
|
|
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-checkbox.js"
|
|
5
|
-
import "../leu-checkbox-group.js"
|
|
6
6
|
|
|
7
7
|
async function defaultFixture() {
|
|
8
8
|
return fixture(html`
|
|
9
|
-
<leu-checkbox
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
`)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async function checkedFixture() {
|
|
18
|
-
return fixture(html`
|
|
19
|
-
<leu-checkbox-group>
|
|
20
|
-
<leu-checkbox identifier="a" value="1" disabled>1</leu-checkbox>
|
|
21
|
-
<leu-checkbox identifier="b" value="2" checked>2</leu-checkbox>
|
|
22
|
-
<leu-checkbox identifier="c" value="3">3</leu-checkbox>
|
|
23
|
-
</leu-checkbox-group>
|
|
9
|
+
<leu-checkbox
|
|
10
|
+
identifier="b"
|
|
11
|
+
value="2"
|
|
12
|
+
label="Das ist ein Label"
|
|
13
|
+
></leu-checkbox>
|
|
24
14
|
`)
|
|
25
15
|
}
|
|
26
16
|
|
|
27
17
|
describe("LeuCheckbox", () => {
|
|
28
18
|
it("is a defined element", async () => {
|
|
29
|
-
const el =
|
|
19
|
+
const el = customElements.get("leu-checkbox")
|
|
30
20
|
|
|
31
21
|
await expect(el).not.to.be.undefined
|
|
32
22
|
})
|
|
@@ -37,65 +27,88 @@ describe("LeuCheckbox", () => {
|
|
|
37
27
|
await expect(el).shadowDom.to.be.accessible()
|
|
38
28
|
})
|
|
39
29
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const el = await customElements.get("leu-checkbox-group")
|
|
30
|
+
it("is not checked by default", async () => {
|
|
31
|
+
const el = await defaultFixture()
|
|
43
32
|
|
|
44
|
-
|
|
45
|
-
|
|
33
|
+
expect(el.checked).to.be.false
|
|
34
|
+
})
|
|
46
35
|
|
|
47
|
-
|
|
48
|
-
|
|
36
|
+
it("toggles the checked property when clicked", async () => {
|
|
37
|
+
const el = await defaultFixture()
|
|
38
|
+
const checkbox = el.shadowRoot.querySelector("input")
|
|
39
|
+
const label = el.shadowRoot.querySelector("label")
|
|
49
40
|
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
checkbox.click()
|
|
42
|
+
await elementUpdated(el)
|
|
52
43
|
|
|
53
|
-
|
|
54
|
-
const el = await defaultFixture()
|
|
55
|
-
const leuCheckbox = el.querySelector('leu-checkbox[value="2"]')
|
|
56
|
-
const checkbox = leuCheckbox.shadowRoot.querySelector("input")
|
|
44
|
+
expect(el.checked).to.be.true
|
|
57
45
|
|
|
58
|
-
|
|
46
|
+
label.click()
|
|
47
|
+
await elementUpdated(el)
|
|
59
48
|
|
|
60
|
-
|
|
61
|
-
|
|
49
|
+
expect(el.checked).to.be.false
|
|
50
|
+
})
|
|
62
51
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
52
|
+
it("does not toggle the checked property when disabled", async () => {
|
|
53
|
+
const el = await defaultFixture()
|
|
54
|
+
const checkbox = el.shadowRoot.querySelector("input")
|
|
55
|
+
const label = el.shadowRoot.querySelector("label")
|
|
67
56
|
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
el.disabled = true
|
|
58
|
+
await elementUpdated(el)
|
|
70
59
|
|
|
71
|
-
|
|
72
|
-
|
|
60
|
+
checkbox.click()
|
|
61
|
+
await elementUpdated(el)
|
|
62
|
+
|
|
63
|
+
expect(el.checked).to.be.false
|
|
64
|
+
|
|
65
|
+
label.click()
|
|
66
|
+
await elementUpdated(el)
|
|
73
67
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const leuCheckbox = el.querySelector('leu-checkbox[value="1"]')
|
|
77
|
-
const checkbox = leuCheckbox.shadowRoot.querySelector("input")
|
|
68
|
+
expect(el.checked).to.be.false
|
|
69
|
+
})
|
|
78
70
|
|
|
79
|
-
|
|
71
|
+
it("toggles the checked property when the space key is pressed", async () => {
|
|
72
|
+
const el = await defaultFixture()
|
|
73
|
+
el.focus()
|
|
80
74
|
|
|
81
|
-
|
|
75
|
+
await sendKeys({
|
|
76
|
+
press: "Space",
|
|
82
77
|
})
|
|
83
78
|
|
|
84
|
-
|
|
85
|
-
const el = await checkedFixture()
|
|
79
|
+
expect(el.checked).to.be.true
|
|
86
80
|
|
|
87
|
-
|
|
81
|
+
await sendKeys({
|
|
82
|
+
press: "Space",
|
|
88
83
|
})
|
|
89
84
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
85
|
+
expect(el.checked).to.be.false
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it("fires a change event when clicked", async () => {
|
|
89
|
+
const el = await defaultFixture()
|
|
90
|
+
const checkbox = el.shadowRoot.querySelector("input")
|
|
94
91
|
|
|
95
|
-
|
|
92
|
+
setTimeout(() => checkbox.click())
|
|
93
|
+
const event = await oneEvent(el, "change")
|
|
96
94
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
expect(event).to.exist
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it("fires an input event when clicked", async () => {
|
|
99
|
+
const el = await defaultFixture()
|
|
100
|
+
const checkbox = el.shadowRoot.querySelector("input")
|
|
101
|
+
|
|
102
|
+
setTimeout(() => checkbox.click())
|
|
103
|
+
const event = await oneEvent(el, "input")
|
|
104
|
+
|
|
105
|
+
expect(event).to.exist
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it("applies the identifier to the input and the label", async () => {
|
|
109
|
+
const el = await defaultFixture()
|
|
110
|
+
|
|
111
|
+
expect(el.shadowRoot.querySelector("input").id).to.equal("b")
|
|
112
|
+
expect(el.shadowRoot.querySelector("label").htmlFor).to.equal("b")
|
|
100
113
|
})
|
|
101
114
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LitElement
|
|
2
|
-
import {
|
|
1
|
+
import { LitElement } from "lit"
|
|
2
|
+
import { html, unsafeStatic } from "lit/static-html.js"
|
|
3
3
|
import styles from "./chip-group.css"
|
|
4
4
|
|
|
5
5
|
/* Figma https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=131766-248643&mode=design&t=Kjo5VDiqivihn8dh-11 */
|
|
@@ -12,18 +12,26 @@ export const SELECTION_MODES = {
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @slot - Place leu-chip-* elements inside this slot
|
|
15
|
+
* @cssproperty --leu-chip-group-gap - The gap between the chips
|
|
15
16
|
* @tagname leu-chip-group
|
|
16
17
|
*/
|
|
17
18
|
export class LeuChipGroup extends LitElement {
|
|
18
19
|
static styles = styles
|
|
19
20
|
|
|
20
21
|
static properties = {
|
|
22
|
+
inverted: { type: Boolean, reflect: true },
|
|
21
23
|
selectionMode: { type: String, attribute: "selection-mode", reflect: true },
|
|
24
|
+
headingLevel: { type: Number, attribute: "heading-level", reflect: true },
|
|
25
|
+
label: { type: String, reflect: true },
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
constructor() {
|
|
25
29
|
super()
|
|
26
30
|
|
|
31
|
+
this.inverted = false
|
|
32
|
+
this.headingLevel = 2
|
|
33
|
+
this.label = ""
|
|
34
|
+
|
|
27
35
|
/** @internal */
|
|
28
36
|
this.items = []
|
|
29
37
|
}
|
|
@@ -44,6 +52,22 @@ export class LeuChipGroup extends LitElement {
|
|
|
44
52
|
return this.items.filter((i) => i.selected).map((i) => i.value)
|
|
45
53
|
}
|
|
46
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Determines the heading tag of the accordion toggle.
|
|
57
|
+
* The headingLevel shouldn't be used directly to render the heading tag
|
|
58
|
+
* in order to avoid XSS issues.
|
|
59
|
+
* @returns {String} The heading tag of the accordion toggle.
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
|
+
_getHeadingTag() {
|
|
63
|
+
let level = 2
|
|
64
|
+
if (this.headingLevel > 0 && this.headingLevel < 7) {
|
|
65
|
+
level = this.headingLevel
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return `h${level}`
|
|
69
|
+
}
|
|
70
|
+
|
|
47
71
|
/** @internal */
|
|
48
72
|
handleInput = (e) => {
|
|
49
73
|
if (this.selectionMode === SELECTION_MODES.single) {
|
|
@@ -62,10 +86,21 @@ export class LeuChipGroup extends LitElement {
|
|
|
62
86
|
}
|
|
63
87
|
|
|
64
88
|
render() {
|
|
65
|
-
|
|
89
|
+
const hTag = this._getHeadingTag()
|
|
90
|
+
|
|
91
|
+
/* The eslint rules don't recognize html import from lit/static-html.js */
|
|
92
|
+
/* eslint-disable lit/binding-positions, lit/no-invalid-html */
|
|
93
|
+
return html`
|
|
94
|
+
${this.label
|
|
95
|
+
? html`<${unsafeStatic(hTag)} class="label">
|
|
96
|
+
<span class="label">${this.label}</span>
|
|
97
|
+
</${unsafeStatic(hTag)}>`
|
|
98
|
+
: ""}
|
|
99
|
+
<slot
|
|
100
|
+
class="group"
|
|
101
|
+
part="group"
|
|
102
|
+
@slotchange=${this.handleSlotChange}
|
|
103
|
+
></slot>
|
|
104
|
+
`
|
|
66
105
|
}
|
|
67
106
|
}
|
|
68
|
-
|
|
69
|
-
export function defineChipGroupElements() {
|
|
70
|
-
defineElement("chip-group", LeuChipGroup)
|
|
71
|
-
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { html } from "lit"
|
|
2
|
-
import { defineElement } from "../../lib/defineElement.js"
|
|
3
2
|
|
|
4
3
|
import { LeuChipBase } from "./Chip.js"
|
|
5
4
|
|
|
@@ -34,11 +33,7 @@ export class LeuChipLink extends LeuChipBase {
|
|
|
34
33
|
|
|
35
34
|
render() {
|
|
36
35
|
return html`<a href=${this.href} class="button">
|
|
37
|
-
<span class="label"
|
|
36
|
+
<span class="label">${this.label}</span>
|
|
38
37
|
</a>`
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
export function defineChipLinkElements() {
|
|
43
|
-
defineElement("chip-link", LeuChipLink)
|
|
44
|
-
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { html } from "lit"
|
|
2
|
-
import { defineElement } from "../../lib/defineElement.js"
|
|
3
2
|
|
|
4
3
|
import { LeuChipBase } from "./Chip.js"
|
|
5
4
|
import { Icon } from "../icon/icon.js"
|
|
@@ -22,7 +21,7 @@ export class LeuChipRemovable extends LeuChipBase {
|
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
handleClick() {
|
|
25
|
-
const customEvent = new CustomEvent("remove", {
|
|
24
|
+
const customEvent = new CustomEvent("leu:remove", {
|
|
26
25
|
bubble: true,
|
|
27
26
|
composed: true,
|
|
28
27
|
})
|
|
@@ -31,12 +30,8 @@ export class LeuChipRemovable extends LeuChipBase {
|
|
|
31
30
|
|
|
32
31
|
render() {
|
|
33
32
|
return html`<button @click=${(e) => this.handleClick(e)} class="button">
|
|
34
|
-
<span class="label"
|
|
33
|
+
<span class="label">${this.label}</span>
|
|
35
34
|
<div class="icon">${this._removeIcon}</div>
|
|
36
35
|
</button>`
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
|
-
|
|
40
|
-
export function defineChipRemovableElements() {
|
|
41
|
-
defineElement("chip-removable", LeuChipRemovable)
|
|
42
|
-
}
|