@statistikzh/leu 0.5.1 → 0.6.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/.husky/commit-msg +0 -3
- package/.husky/pre-commit +0 -3
- package/CHANGELOG.md +40 -0
- package/dist/Accordion.d.ts +10 -9
- package/dist/Accordion.d.ts.map +1 -1
- package/dist/Accordion.js +12 -11
- package/dist/Breadcrumb.d.ts +4 -4
- package/dist/Breadcrumb.d.ts.map +1 -1
- package/dist/Breadcrumb.js +28 -26
- package/dist/{Button-5326c982.d.ts → Button-9692e403.d.ts} +10 -11
- package/dist/Button-9692e403.d.ts.map +1 -0
- package/dist/{Button-5326c982.js → Button-9692e403.js} +57 -67
- package/dist/Button.d.ts +1 -1
- package/dist/Button.js +3 -3
- package/dist/ButtonGroup.d.ts +2 -2
- package/dist/ButtonGroup.d.ts.map +1 -1
- package/dist/ButtonGroup.js +3 -3
- package/dist/Checkbox.d.ts +4 -3
- package/dist/Checkbox.d.ts.map +1 -1
- package/dist/Checkbox.js +14 -19
- package/dist/CheckboxGroup.d.ts +2 -2
- package/dist/CheckboxGroup.d.ts.map +1 -1
- package/dist/CheckboxGroup.js +4 -6
- package/dist/Chip.d.ts +2 -2
- package/dist/Chip.d.ts.map +1 -1
- package/dist/Chip.js +6 -13
- package/dist/ChipGroup.d.ts +9 -7
- package/dist/ChipGroup.d.ts.map +1 -1
- package/dist/ChipGroup.js +8 -5
- package/dist/ChipLink.d.ts +2 -1
- package/dist/ChipLink.d.ts.map +1 -1
- package/dist/ChipLink.js +4 -7
- package/dist/ChipRemovable.d.ts +0 -2
- package/dist/ChipRemovable.d.ts.map +1 -1
- package/dist/ChipRemovable.js +8 -11
- package/dist/ChipSelectable.d.ts +9 -1
- package/dist/ChipSelectable.d.ts.map +1 -1
- package/dist/ChipSelectable.js +12 -16
- package/dist/Dropdown.d.ts +9 -5
- package/dist/Dropdown.d.ts.map +1 -1
- package/dist/Dropdown.js +68 -32
- package/dist/Icon.d.ts +20 -0
- package/dist/Icon.d.ts.map +1 -0
- package/dist/{icon-03e86700.js → Icon.js} +61 -32
- package/dist/Input.d.ts +7 -16
- package/dist/Input.d.ts.map +1 -1
- package/dist/Input.js +24 -28
- package/dist/LeuElement-6de6f209.d.ts +7 -0
- package/dist/LeuElement-6de6f209.d.ts.map +1 -0
- package/dist/LeuElement-6de6f209.js +43 -0
- package/dist/Menu.d.ts +24 -2
- package/dist/Menu.d.ts.map +1 -1
- package/dist/Menu.js +120 -3
- package/dist/MenuItem.d.ts +28 -11
- package/dist/MenuItem.d.ts.map +1 -1
- package/dist/MenuItem.js +110 -63
- package/dist/Pagination.d.ts +10 -3
- package/dist/Pagination.d.ts.map +1 -1
- package/dist/Pagination.js +24 -21
- package/dist/Popup.d.ts +21 -3
- package/dist/Popup.d.ts.map +1 -1
- package/dist/Popup.js +44 -19
- package/dist/Radio.d.ts +4 -2
- package/dist/Radio.d.ts.map +1 -1
- package/dist/Radio.js +9 -16
- package/dist/RadioGroup.d.ts +2 -2
- package/dist/RadioGroup.d.ts.map +1 -1
- package/dist/RadioGroup.js +4 -6
- package/dist/ScrollTop.d.ts +2 -2
- package/dist/ScrollTop.d.ts.map +1 -1
- package/dist/ScrollTop.js +10 -8
- package/dist/Select.d.ts +75 -37
- package/dist/Select.d.ts.map +1 -1
- package/dist/Select.js +279 -183
- package/dist/Table.d.ts +2 -6
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +17 -18
- package/dist/VisuallyHidden.d.ts +2 -2
- package/dist/VisuallyHidden.d.ts.map +1 -1
- package/dist/VisuallyHidden.js +5 -7
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -14
- package/dist/leu-accordion.d.ts.map +1 -1
- package/dist/leu-accordion.js +2 -3
- package/dist/leu-breadcrumb.d.ts.map +1 -1
- package/dist/leu-breadcrumb.js +4 -10
- package/dist/leu-button-group.d.ts.map +1 -1
- package/dist/leu-button-group.js +2 -3
- package/dist/leu-button.d.ts +1 -1
- package/dist/leu-button.d.ts.map +1 -1
- package/dist/leu-button.js +4 -5
- package/dist/leu-checkbox-group.d.ts.map +1 -1
- package/dist/leu-checkbox-group.js +2 -3
- package/dist/leu-checkbox.d.ts.map +1 -1
- package/dist/leu-checkbox.js +3 -4
- package/dist/leu-chip-group.d.ts.map +1 -1
- package/dist/leu-chip-group.js +2 -3
- package/dist/leu-chip-link.d.ts.map +1 -1
- package/dist/leu-chip-link.js +2 -3
- package/dist/leu-chip-removable.d.ts.map +1 -1
- package/dist/leu-chip-removable.js +3 -4
- package/dist/leu-chip-selectable.d.ts.map +1 -1
- package/dist/leu-chip-selectable.js +2 -3
- package/dist/leu-dropdown.d.ts.map +1 -1
- package/dist/leu-dropdown.js +5 -10
- package/dist/leu-icon.d.ts +3 -0
- package/dist/leu-icon.d.ts.map +1 -0
- package/dist/leu-icon.js +7 -0
- package/dist/leu-input.d.ts.map +1 -1
- package/dist/leu-input.js +3 -4
- package/dist/leu-menu-item.d.ts.map +1 -1
- package/dist/leu-menu-item.js +3 -5
- package/dist/leu-menu.d.ts.map +1 -1
- package/dist/leu-menu.js +5 -3
- package/dist/leu-pagination.d.ts.map +1 -1
- package/dist/leu-pagination.js +4 -7
- package/dist/leu-popup.d.ts.map +1 -1
- package/dist/leu-popup.js +2 -3
- package/dist/leu-radio-group.d.ts.map +1 -1
- package/dist/leu-radio-group.js +2 -3
- package/dist/leu-radio.d.ts.map +1 -1
- package/dist/leu-radio.js +2 -3
- package/dist/leu-scroll-top.d.ts.map +1 -1
- package/dist/leu-scroll-top.js +4 -6
- package/dist/leu-select.d.ts.map +1 -1
- package/dist/leu-select.js +5 -13
- package/dist/leu-table.d.ts.map +1 -1
- package/dist/leu-table.js +4 -8
- package/dist/leu-visually-hidden.d.ts.map +1 -1
- package/dist/leu-visually-hidden.js +2 -3
- package/dist/theme.css +2 -0
- package/dist/vscode.html-custom-data.json +116 -79
- package/dist/vue/index.d.ts +80 -76
- package/dist/web-types.json +405 -270
- package/package.json +9 -12
- package/scripts/generate-component/templates/[Name].js +6 -3
- package/scripts/generate-component/templates/test/[name].test.js +1 -1
- package/src/components/accordion/Accordion.js +13 -10
- package/src/components/accordion/leu-accordion.js +1 -2
- package/src/components/breadcrumb/Breadcrumb.js +31 -18
- package/src/components/breadcrumb/leu-breadcrumb.js +1 -2
- package/src/components/button/Button.js +45 -71
- package/src/components/button/button.css +11 -9
- package/src/components/button/leu-button.js +1 -2
- package/src/components/button/stories/button.stories.js +60 -19
- package/src/components/button/test/button.test.js +26 -63
- package/src/components/button-group/ButtonGroup.js +4 -2
- package/src/components/button-group/leu-button-group.js +1 -2
- package/src/components/checkbox/Checkbox.js +17 -11
- package/src/components/checkbox/CheckboxGroup.js +6 -3
- package/src/components/checkbox/leu-checkbox-group.js +1 -2
- package/src/components/checkbox/leu-checkbox.js +1 -2
- package/src/components/checkbox/stories/checkbox-group.stories.js +10 -26
- package/src/components/checkbox/stories/checkbox.stories.js +2 -7
- package/src/components/checkbox/test/checkbox-group.test.js +6 -21
- package/src/components/checkbox/test/checkbox.test.js +1 -12
- package/src/components/chip/Chip.js +5 -4
- package/src/components/chip/ChipGroup.js +10 -4
- package/src/components/chip/ChipLink.js +3 -7
- package/src/components/chip/ChipRemovable.js +8 -11
- package/src/components/chip/ChipSelectable.js +11 -17
- package/src/components/chip/chip.css +3 -4
- package/src/components/chip/leu-chip-group.js +1 -2
- package/src/components/chip/leu-chip-link.js +1 -2
- package/src/components/chip/leu-chip-removable.js +1 -2
- package/src/components/chip/leu-chip-selectable.js +1 -2
- package/src/components/chip/stories/chip-link.stories.js +3 -5
- package/src/components/chip/stories/chip-removable.stories.js +3 -4
- package/src/components/chip/stories/chip-selectable.stories.js +2 -2
- package/src/components/chip/test/chip-group.test.js +15 -30
- package/src/components/chip/test/chip-link.test.js +2 -6
- package/src/components/chip/test/chip-removable.test.js +4 -10
- package/src/components/chip/test/chip-selectable.test.js +3 -5
- package/src/components/dropdown/Dropdown.js +79 -26
- package/src/components/dropdown/leu-dropdown.js +1 -2
- package/src/components/dropdown/stories/dropdown.stories.js +30 -7
- package/src/components/dropdown/test/dropdown.test.js +5 -5
- package/src/components/icon/Icon.js +55 -0
- package/src/components/icon/icon.css +6 -0
- package/src/components/icon/leu-icon.js +5 -0
- package/src/components/icon/{icon.js → paths.js} +4 -37
- package/src/components/icon/stories/icon.stories.js +47 -0
- package/src/components/icon/test/icon.test.js +23 -40
- package/src/components/input/Input.js +21 -23
- package/src/components/input/input.css +4 -2
- package/src/components/input/leu-input.js +1 -2
- package/src/components/input/stories/input.stories.js +2 -2
- package/src/components/input/test/input.test.js +2 -0
- package/src/components/menu/Menu.js +143 -2
- package/src/components/menu/MenuItem.js +104 -52
- package/src/components/menu/leu-menu-item.js +1 -2
- package/src/components/menu/leu-menu.js +1 -2
- package/src/components/menu/menu-item.css +11 -4
- package/src/components/menu/stories/menu-item.stories.js +15 -4
- package/src/components/menu/stories/menu.stories.js +34 -7
- package/src/components/menu/test/menu-item.test.js +88 -82
- package/src/components/menu/test/menu.test.js +101 -8
- package/src/components/pagination/Pagination.js +27 -18
- package/src/components/pagination/leu-pagination.js +1 -2
- package/src/components/popup/Popup.js +39 -16
- package/src/components/popup/leu-popup.js +1 -2
- package/src/components/popup/popup.css +1 -0
- package/src/components/radio/Radio.js +12 -7
- package/src/components/radio/RadioGroup.js +6 -3
- package/src/components/radio/leu-radio-group.js +1 -2
- package/src/components/radio/leu-radio.js +1 -2
- package/src/components/radio/stories/radio-group.stories.js +5 -19
- package/src/components/radio/stories/radio.stories.js +2 -7
- package/src/components/radio/test/radio-group.test.js +6 -9
- package/src/components/radio/test/radio.test.js +3 -13
- package/src/components/scroll-top/ScrollTop.js +15 -5
- package/src/components/scroll-top/leu-scroll-top.js +1 -2
- package/src/components/select/Select.js +279 -175
- package/src/components/select/leu-select.js +1 -2
- package/src/components/select/select.css +20 -12
- package/src/components/select/stories/select.stories.js +16 -2
- package/src/components/select/test/select.test.js +191 -37
- package/src/components/table/Table.js +15 -9
- package/src/components/table/leu-table.js +1 -2
- package/src/components/table/table.css +3 -1
- package/src/components/visually-hidden/VisuallyHidden.js +6 -2
- package/src/components/visually-hidden/leu-visually-hidden.js +1 -2
- package/src/lib/LeuElement.js +23 -0
- package/src/lib/a11y.js +26 -0
- package/src/styles/custom-properties.css +2 -0
- package/web-test-runner.config.mjs +2 -0
- package/dist/Button-5326c982.d.ts.map +0 -1
- package/dist/_rollupPluginBabelHelpers-20f659f4.d.ts +0 -3
- package/dist/_rollupPluginBabelHelpers-20f659f4.d.ts.map +0 -1
- package/dist/_rollupPluginBabelHelpers-20f659f4.js +0 -30
- package/dist/defineElement-40372b4b.d.ts +0 -9
- package/dist/defineElement-40372b4b.d.ts.map +0 -1
- package/dist/defineElement-40372b4b.js +0 -15
- package/dist/icon-03e86700.d.ts +0 -11
- package/dist/icon-03e86700.d.ts.map +0 -1
- package/src/lib/defineElement.js +0 -13
|
@@ -1,17 +1,35 @@
|
|
|
1
1
|
import { html } from "lit"
|
|
2
|
+
import { ifDefined } from "lit/directives/if-defined.js"
|
|
2
3
|
import { fixture, expect } from "@open-wc/testing"
|
|
4
|
+
import { sendKeys } from "@web/test-runner-commands"
|
|
3
5
|
|
|
4
6
|
import "../leu-menu.js"
|
|
5
7
|
import "../leu-menu-item.js"
|
|
8
|
+
import "../../icon/leu-icon.js"
|
|
6
9
|
|
|
7
|
-
async function defaultFixture() {
|
|
8
|
-
return fixture(html` <leu-menu
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
async function defaultFixture(args = {}) {
|
|
11
|
+
return fixture(html` <leu-menu
|
|
12
|
+
role=${ifDefined(args.role)}
|
|
13
|
+
selects=${ifDefined(args.selects)}
|
|
14
|
+
>
|
|
15
|
+
<leu-menu-item
|
|
16
|
+
><leu-icon slot="before"></leu-icon>Menu Item 1</leu-menu-item
|
|
17
|
+
>
|
|
18
|
+
<leu-menu-item active
|
|
19
|
+
><leu-icon slot="before" name="check"></leu-icon>Menu Item
|
|
20
|
+
2</leu-menu-item
|
|
21
|
+
>
|
|
22
|
+
<leu-menu-item
|
|
23
|
+
><leu-icon slot="before"></leu-icon>Menu Item 3</leu-menu-item
|
|
24
|
+
>
|
|
12
25
|
<hr />
|
|
13
|
-
<leu-menu-item
|
|
14
|
-
|
|
26
|
+
<leu-menu-item
|
|
27
|
+
><leu-icon name="pin" slot="before"></leu-icon>Menu Item 3<slot
|
|
28
|
+
name="after"
|
|
29
|
+
>CH</slot
|
|
30
|
+
></leu-menu-item
|
|
31
|
+
>
|
|
32
|
+
<leu-menu-item>Menu Item 4</leu-menu-item>
|
|
15
33
|
</leu-menu>`)
|
|
16
34
|
}
|
|
17
35
|
|
|
@@ -25,6 +43,81 @@ describe("LeuMenu", () => {
|
|
|
25
43
|
it("passes the a11y audit", async () => {
|
|
26
44
|
const el = await defaultFixture()
|
|
27
45
|
|
|
28
|
-
await expect(el).
|
|
46
|
+
await expect(el).dom.to.be.accessible()
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it("sets 'menu' as the default role", async () => {
|
|
50
|
+
const el = await defaultFixture()
|
|
51
|
+
|
|
52
|
+
expect(el.getAttribute("role")).to.equal("menu")
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it("sets 'menuitem' as the default role for menu items", async () => {
|
|
56
|
+
const el = await defaultFixture()
|
|
57
|
+
|
|
58
|
+
const menuItems = el.querySelectorAll("leu-menu-item")
|
|
59
|
+
|
|
60
|
+
menuItems.forEach((menuItem) => {
|
|
61
|
+
expect(menuItem.componentRole).to.equal("menuitem")
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it("sets 'menuitemradio' as the role for menu items when only one item can be selected", async () => {
|
|
66
|
+
const el = await defaultFixture({ selects: "single" })
|
|
67
|
+
|
|
68
|
+
const menuItems = el.querySelectorAll("leu-menu-item")
|
|
69
|
+
|
|
70
|
+
menuItems.forEach((menuItem) => {
|
|
71
|
+
expect(menuItem.componentRole).to.equal("menuitemradio")
|
|
72
|
+
})
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
it("sets 'menuitemcheckbox' as the role for menu items when multiple items can be selected", async () => {
|
|
76
|
+
const el = await defaultFixture({ selects: "multiple" })
|
|
77
|
+
|
|
78
|
+
const menuItems = el.querySelectorAll("leu-menu-item")
|
|
79
|
+
|
|
80
|
+
menuItems.forEach((menuItem) => {
|
|
81
|
+
expect(menuItem.componentRole).to.equal("menuitemcheckbox")
|
|
82
|
+
})
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
it("sets 'option' as the role for menu items when the menu role is 'listbox'", async () => {
|
|
86
|
+
const el = await defaultFixture({ role: "listbox" })
|
|
87
|
+
|
|
88
|
+
const menuItems = el.querySelectorAll("leu-menu-item")
|
|
89
|
+
|
|
90
|
+
menuItems.forEach((menuItem) => {
|
|
91
|
+
expect(menuItem.componentRole).to.equal("option")
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it("moves the focus when the arrow keys are pressed", async () => {
|
|
96
|
+
const el = await defaultFixture()
|
|
97
|
+
|
|
98
|
+
const menuItems = Array.from(el.querySelectorAll("leu-menu-item"))
|
|
99
|
+
|
|
100
|
+
await sendKeys({ press: "Tab" })
|
|
101
|
+
expect(document.activeElement).to.equal(menuItems[0])
|
|
102
|
+
|
|
103
|
+
await sendKeys({ press: "ArrowDown" })
|
|
104
|
+
await sendKeys({ press: "ArrowDown" })
|
|
105
|
+
|
|
106
|
+
expect(document.activeElement).to.equal(menuItems[2])
|
|
107
|
+
|
|
108
|
+
await sendKeys({ press: "ArrowUp" })
|
|
109
|
+
await sendKeys({ press: "ArrowUp" })
|
|
110
|
+
await sendKeys({ press: "ArrowUp" })
|
|
111
|
+
|
|
112
|
+
expect(document.activeElement).to.equal(menuItems.at(-1))
|
|
113
|
+
|
|
114
|
+
await sendKeys({ press: "Home" })
|
|
115
|
+
expect(document.activeElement).to.equal(menuItems[0])
|
|
116
|
+
|
|
117
|
+
await sendKeys({ press: "End" })
|
|
118
|
+
expect(document.activeElement).to.equal(menuItems.at(-1))
|
|
119
|
+
|
|
120
|
+
await sendKeys({ press: "ArrowDown" })
|
|
121
|
+
expect(document.activeElement).to.equal(menuItems[0])
|
|
29
122
|
})
|
|
30
123
|
})
|
|
@@ -1,24 +1,33 @@
|
|
|
1
|
-
import { html
|
|
1
|
+
import { html } from "lit"
|
|
2
2
|
import { live } from "lit/directives/live.js"
|
|
3
3
|
|
|
4
|
-
import "
|
|
5
|
-
import
|
|
4
|
+
import { LeuElement } from "../../lib/LeuElement.js"
|
|
5
|
+
import { LeuButton } from "../button/Button.js"
|
|
6
|
+
import { LeuVisuallyHidden } from "../visually-hidden/VisuallyHidden.js"
|
|
7
|
+
import { LeuIcon } from "../icon/Icon.js"
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
import styles from "./pagination.css"
|
|
8
11
|
|
|
9
12
|
const MIN_PAGE = 1
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
* @tagname leu-pagination
|
|
13
16
|
*/
|
|
14
|
-
export class LeuPagination extends
|
|
17
|
+
export class LeuPagination extends LeuElement {
|
|
18
|
+
static dependencies = {
|
|
19
|
+
"leu-button": LeuButton,
|
|
20
|
+
"leu-icon": LeuIcon,
|
|
21
|
+
"leu-visually-hidden": LeuVisuallyHidden,
|
|
22
|
+
}
|
|
23
|
+
|
|
15
24
|
static styles = styles
|
|
16
25
|
|
|
17
26
|
/**
|
|
18
27
|
* @internal
|
|
19
28
|
*/
|
|
20
29
|
static shadowRootOptions = {
|
|
21
|
-
...
|
|
30
|
+
...LeuElement.shadowRootOptions,
|
|
22
31
|
delegatesFocus: true,
|
|
23
32
|
}
|
|
24
33
|
|
|
@@ -26,15 +35,6 @@ export class LeuPagination extends LitElement {
|
|
|
26
35
|
defaultPage: { type: Number, reflect: true },
|
|
27
36
|
itemsPerPage: { type: Number, reflect: true },
|
|
28
37
|
numOfItems: { type: Number, reflect: true },
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Internal page state that contains an
|
|
32
|
-
* already clamped page number. Should only
|
|
33
|
-
* be accessed through the `page` getter and
|
|
34
|
-
* setter.
|
|
35
|
-
* @type {Number}
|
|
36
|
-
* @internal
|
|
37
|
-
*/
|
|
38
38
|
_page: { state: true },
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -43,9 +43,18 @@ export class LeuPagination extends LitElement {
|
|
|
43
43
|
|
|
44
44
|
/** @type {Number} */
|
|
45
45
|
this.numOfItems = 1
|
|
46
|
+
|
|
46
47
|
/** @type {Number} */
|
|
47
48
|
this.itemsPerPage = 1
|
|
48
|
-
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Internal page state that contains an
|
|
52
|
+
* already clamped page number. Should only
|
|
53
|
+
* be accessed through the `page` getter and
|
|
54
|
+
* setter.
|
|
55
|
+
* @type {Number}
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
49
58
|
this._page = 1
|
|
50
59
|
}
|
|
51
60
|
|
|
@@ -148,22 +157,22 @@ export class LeuPagination extends LitElement {
|
|
|
148
157
|
<div class="label">von ${this._maxPage}</div>
|
|
149
158
|
<div class="button-group">
|
|
150
159
|
<leu-button
|
|
151
|
-
icon="angleLeft"
|
|
152
160
|
variant="secondary"
|
|
153
161
|
label="Vorherige Seite"
|
|
154
162
|
@click=${(_) => {
|
|
155
163
|
this._updatePage(this.page - 1)
|
|
156
164
|
}}
|
|
157
165
|
?disabled=${this._isFirstPage()}
|
|
166
|
+
><leu-icon name="angleLeft"></leu-icon
|
|
158
167
|
></leu-button>
|
|
159
168
|
<leu-button
|
|
160
|
-
icon="angleRight"
|
|
161
169
|
variant="secondary"
|
|
162
170
|
label="Nächste Seite"
|
|
163
171
|
@click=${(_) => {
|
|
164
172
|
this._updatePage(this.page + 1)
|
|
165
173
|
}}
|
|
166
174
|
?disabled=${this._isLastPage()}
|
|
175
|
+
><leu-icon name="angleRight"></leu-icon
|
|
167
176
|
></leu-button>
|
|
168
177
|
</div>
|
|
169
178
|
`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { html
|
|
1
|
+
import { html } from "lit"
|
|
2
2
|
import {
|
|
3
3
|
autoUpdate,
|
|
4
4
|
computePosition,
|
|
@@ -6,34 +6,37 @@ import {
|
|
|
6
6
|
shift,
|
|
7
7
|
size,
|
|
8
8
|
} from "@floating-ui/dom"
|
|
9
|
+
|
|
10
|
+
import { LeuElement } from "../../lib/LeuElement.js"
|
|
11
|
+
|
|
12
|
+
// @ts-ignore
|
|
9
13
|
import styles from "./popup.css"
|
|
10
14
|
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {"top"|"top-start"|"top-end"|"bottom"|"bottom-start"|"bottom-end"|"left"|"left-start"|"left-end"|"right"|"right-start"|"right-end"} Placement
|
|
17
|
+
*/
|
|
18
|
+
|
|
11
19
|
/**
|
|
12
20
|
* @tagname leu-popup
|
|
13
21
|
*/
|
|
14
|
-
export class LeuPopup extends
|
|
22
|
+
export class LeuPopup extends LeuElement {
|
|
15
23
|
static styles = styles
|
|
16
24
|
|
|
17
25
|
static shadowRootOptions = {
|
|
18
|
-
...
|
|
26
|
+
...LeuElement.shadowRootOptions,
|
|
19
27
|
delegatesFocus: true,
|
|
20
28
|
}
|
|
21
29
|
|
|
22
30
|
static properties = {
|
|
23
31
|
anchor: {},
|
|
24
|
-
active: { type: Boolean },
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/** @type {"width" | "height" | "both"} */
|
|
33
|
-
matchSize: { type: String },
|
|
34
|
-
/** @type {"width" | "height" | "both"} */
|
|
35
|
-
autoSize: { type: String },
|
|
36
|
-
autoSizePadding: { type: Number },
|
|
32
|
+
active: { type: Boolean, reflect: true },
|
|
33
|
+
placement: { type: String, reflect: true },
|
|
34
|
+
flip: { type: Boolean, reflect: true },
|
|
35
|
+
shift: { type: Boolean, reflect: true },
|
|
36
|
+
shiftPadding: { type: Number, reflect: true },
|
|
37
|
+
matchSize: { type: String, reflect: true },
|
|
38
|
+
autoSize: { type: String, reflect: true },
|
|
39
|
+
autoSizePadding: { type: Number, reflect: true },
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
constructor() {
|
|
@@ -43,6 +46,23 @@ export class LeuPopup extends LitElement {
|
|
|
43
46
|
this.cleanup = undefined
|
|
44
47
|
this.flip = false
|
|
45
48
|
this.shift = false
|
|
49
|
+
|
|
50
|
+
this.active = false
|
|
51
|
+
|
|
52
|
+
/** @type {Placement} */
|
|
53
|
+
this.placement = undefined
|
|
54
|
+
|
|
55
|
+
/** @type {"width" | "height" | "both"} */
|
|
56
|
+
this.matchSize = undefined
|
|
57
|
+
|
|
58
|
+
/** @type {"width" | "height" | "both"} */
|
|
59
|
+
this.autoSize = undefined
|
|
60
|
+
|
|
61
|
+
this.shiftPadding = 0
|
|
62
|
+
this.autoSizePadding = 0
|
|
63
|
+
|
|
64
|
+
/** @type {string | HTMLElement} */
|
|
65
|
+
this.anchor = undefined
|
|
46
66
|
}
|
|
47
67
|
|
|
48
68
|
disconnectedCallback() {
|
|
@@ -68,6 +88,9 @@ export class LeuPopup extends LitElement {
|
|
|
68
88
|
}
|
|
69
89
|
}
|
|
70
90
|
|
|
91
|
+
/**
|
|
92
|
+
* @returns {HTMLElement | null}
|
|
93
|
+
*/
|
|
71
94
|
get popupEl() {
|
|
72
95
|
return this.renderRoot?.querySelector(".popup") ?? null
|
|
73
96
|
}
|
|
@@ -1,30 +1,35 @@
|
|
|
1
|
-
import { html
|
|
1
|
+
import { html } from "lit"
|
|
2
|
+
|
|
3
|
+
import { LeuElement } from "../../lib/LeuElement.js"
|
|
4
|
+
|
|
5
|
+
// @ts-ignore
|
|
2
6
|
import styles from "./radio.css"
|
|
3
7
|
|
|
4
8
|
/**
|
|
5
9
|
* @tagname leu-radio
|
|
6
10
|
*/
|
|
7
|
-
export class LeuRadio extends
|
|
11
|
+
export class LeuRadio extends LeuElement {
|
|
8
12
|
static styles = styles
|
|
9
13
|
|
|
14
|
+
/** @internal */
|
|
10
15
|
static shadowRootOptions = {
|
|
11
|
-
...
|
|
16
|
+
...LeuElement.shadowRootOptions,
|
|
12
17
|
delegatesFocus: true,
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
static properties = {
|
|
16
21
|
checked: { type: Boolean, reflect: true },
|
|
17
22
|
disabled: { type: Boolean, reflect: true },
|
|
18
|
-
identifier: { type: String, reflect: true },
|
|
19
23
|
value: { type: String, reflect: true },
|
|
20
24
|
name: { type: String, reflect: true },
|
|
21
|
-
label: { type: String, reflect: true },
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
constructor() {
|
|
25
28
|
super()
|
|
26
29
|
this.checked = false
|
|
27
30
|
this.disabled = false
|
|
31
|
+
this.name = ""
|
|
32
|
+
this.value = ""
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
handleChange(event) {
|
|
@@ -41,7 +46,7 @@ export class LeuRadio extends LitElement {
|
|
|
41
46
|
render() {
|
|
42
47
|
return html`
|
|
43
48
|
<input
|
|
44
|
-
id=${this.
|
|
49
|
+
id=${`radio-${this.name}`}
|
|
45
50
|
class="radio"
|
|
46
51
|
type="radio"
|
|
47
52
|
name="${this.name}"
|
|
@@ -51,7 +56,7 @@ export class LeuRadio extends LitElement {
|
|
|
51
56
|
?disabled=${this.disabled}
|
|
52
57
|
.value=${this.value}
|
|
53
58
|
/>
|
|
54
|
-
<label for=${this.
|
|
59
|
+
<label for=${`radio-${this.name}`} class="label"><slot></slot></label>
|
|
55
60
|
`
|
|
56
61
|
}
|
|
57
62
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { html
|
|
1
|
+
import { html } from "lit"
|
|
2
2
|
import { classMap } from "lit/directives/class-map.js"
|
|
3
3
|
|
|
4
|
+
import { LeuElement } from "../../lib/LeuElement.js"
|
|
5
|
+
|
|
6
|
+
// @ts-ignore
|
|
4
7
|
import styles from "./radio-group.css"
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* @tagname leu-radio-group
|
|
8
11
|
*/
|
|
9
|
-
export class LeuRadioGroup extends
|
|
12
|
+
export class LeuRadioGroup extends LeuElement {
|
|
10
13
|
static styles = styles
|
|
11
14
|
|
|
12
15
|
static properties = {
|
|
@@ -129,7 +132,7 @@ export class LeuRadioGroup extends LitElement {
|
|
|
129
132
|
}
|
|
130
133
|
|
|
131
134
|
handleItems() {
|
|
132
|
-
this.items =
|
|
135
|
+
this.items = Array.from(this.querySelectorAll(":scope > *:not([slot])"))
|
|
133
136
|
this.initializeIndex()
|
|
134
137
|
this.setTabIndex()
|
|
135
138
|
}
|
|
@@ -27,25 +27,11 @@ function Template({ label, orientation }) {
|
|
|
27
27
|
orientation=${ifDefined(orientation)}
|
|
28
28
|
label=${ifDefined(label)}
|
|
29
29
|
>
|
|
30
|
-
<leu-radio
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
+
<leu-radio value="1" name="radio-button" disabled>Kurz</leu-radio>
|
|
31
|
+
<leu-radio value="2" name="radio-button">Etwas Länger</leu-radio>
|
|
32
|
+
<leu-radio value="3" name="radio-button"
|
|
33
|
+
>Ein langes Label um sicher ein umbruch zu erzwingen</leu-radio
|
|
34
|
+
>
|
|
49
35
|
</leu-radio-group>
|
|
50
36
|
`
|
|
51
37
|
}
|
|
@@ -24,13 +24,8 @@ function Template({
|
|
|
24
24
|
disabled = false,
|
|
25
25
|
}) {
|
|
26
26
|
return html`
|
|
27
|
-
<leu-radio
|
|
28
|
-
|
|
29
|
-
?checked=${checked}
|
|
30
|
-
?disabled=${disabled}
|
|
31
|
-
identifier=${"radio-1"}
|
|
32
|
-
label=${label}
|
|
33
|
-
>
|
|
27
|
+
<leu-radio .value=${value} ?checked=${checked} ?disabled=${disabled}>
|
|
28
|
+
${label}
|
|
34
29
|
</leu-radio>
|
|
35
30
|
`
|
|
36
31
|
}
|
|
@@ -9,27 +9,24 @@ async function defaultFixture(args = {}) {
|
|
|
9
9
|
<leu-radio-group>
|
|
10
10
|
<span slot="legend">Legende</span>
|
|
11
11
|
<leu-radio
|
|
12
|
-
identifier="1"
|
|
13
12
|
value="1"
|
|
14
13
|
name="radio-button"
|
|
15
14
|
disabled
|
|
16
|
-
label="Kurz"
|
|
17
15
|
?checked=${args.checkedValue === "1"}
|
|
18
|
-
|
|
16
|
+
>Kurz</leu-radio
|
|
17
|
+
>
|
|
19
18
|
<leu-radio
|
|
20
|
-
identifier="2"
|
|
21
19
|
value="2"
|
|
22
20
|
name="radio-button"
|
|
23
|
-
label="Etwas Länger"
|
|
24
21
|
?checked=${args.checkedValue === "2"}
|
|
25
|
-
|
|
22
|
+
>Etwas Länger</leu-radio
|
|
23
|
+
>
|
|
26
24
|
<leu-radio
|
|
27
|
-
identifier="3"
|
|
28
25
|
value="3"
|
|
29
26
|
name="radio-button"
|
|
30
|
-
label="Ein langes Label um sicher ein umbruch zu erzwingen"
|
|
31
27
|
?checked=${args.checkedValue === "3"}
|
|
32
|
-
|
|
28
|
+
>Ein langes Label um sicher ein umbruch zu erzwingen</leu-radio
|
|
29
|
+
>
|
|
33
30
|
</leu-radio-group>
|
|
34
31
|
`)
|
|
35
32
|
}
|
|
@@ -6,12 +6,9 @@ import "../leu-radio.js"
|
|
|
6
6
|
|
|
7
7
|
async function defaultFixture() {
|
|
8
8
|
return fixture(html`
|
|
9
|
-
<leu-radio
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
name="radio-button"
|
|
13
|
-
label="Ein langes Label um sicher ein umbruch zu erzwingen"
|
|
14
|
-
></leu-radio>
|
|
9
|
+
<leu-radio identifier="b" value="3" name="radio-button"
|
|
10
|
+
>Ein langes Label um sicher ein umbruch zu erzwingen</leu-radio
|
|
11
|
+
>
|
|
15
12
|
`)
|
|
16
13
|
}
|
|
17
14
|
|
|
@@ -119,11 +116,4 @@ describe("LeuRadio", () => {
|
|
|
119
116
|
|
|
120
117
|
expect(event).to.exist
|
|
121
118
|
})
|
|
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
|
-
})
|
|
129
119
|
})
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import { html
|
|
1
|
+
import { html } from "lit"
|
|
2
2
|
import { classMap } from "lit/directives/class-map.js"
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
import "../button/
|
|
4
|
+
import { LeuElement } from "../../lib/LeuElement.js"
|
|
5
|
+
import { LeuButton } from "../button/Button.js"
|
|
6
|
+
import { LeuIcon } from "../icon/Icon.js"
|
|
7
|
+
|
|
6
8
|
import { throttle } from "../../lib/utils.js"
|
|
7
9
|
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
import styles from "./scroll-top.css"
|
|
12
|
+
|
|
8
13
|
/**
|
|
9
14
|
* @tagname leu-scroll-top
|
|
10
15
|
*/
|
|
11
|
-
export class LeuScrollTop extends
|
|
16
|
+
export class LeuScrollTop extends LeuElement {
|
|
17
|
+
static dependencies = {
|
|
18
|
+
"leu-button": LeuButton,
|
|
19
|
+
"leu-icon": LeuIcon,
|
|
20
|
+
}
|
|
21
|
+
|
|
12
22
|
static styles = styles
|
|
13
23
|
|
|
14
24
|
static properties = {
|
|
@@ -75,11 +85,11 @@ export class LeuScrollTop extends LitElement {
|
|
|
75
85
|
return html`
|
|
76
86
|
<div class=${classMap(cssClasses)}>
|
|
77
87
|
<leu-button
|
|
78
|
-
icon="arrowUp"
|
|
79
88
|
label="Zum Seitenanfang"
|
|
80
89
|
round
|
|
81
90
|
@click="${() => LeuScrollTop.scrollToTop()}"
|
|
82
91
|
>
|
|
92
|
+
<leu-icon name="arrowUp"></leu-icon>
|
|
83
93
|
</leu-button>
|
|
84
94
|
</div>
|
|
85
95
|
`
|