@statistikzh/leu 0.5.0 → 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 +48 -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-da11d064.d.ts → Button-9692e403.d.ts} +10 -11
- package/dist/Button-9692e403.d.ts.map +1 -0
- package/dist/{Button-da11d064.js → Button-9692e403.js} +65 -62
- 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 +73 -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.js.d.ts → index.d.ts} +3 -3
- package/dist/index.d.ts.map +1 -0
- package/dist/{index.js.js → 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 +616 -0
- package/dist/vue/index.d.ts +682 -0
- package/dist/web-types.json +1211 -0
- package/package.json +10 -13
- package/rollup.config.js +1 -1
- 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 +19 -4
- 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 +80 -26
- package/src/components/dropdown/dropdown.css +4 -0
- 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-da11d064.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/dist/index.js.d.ts.map +0 -1
- package/src/lib/defineElement.js +0 -13
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "UI component library of the canton of zurich",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "statistikzh",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.6.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"module": "dist/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"homepage": "https://github.com/statistikzh/leu/",
|
|
25
25
|
"scripts": {
|
|
26
26
|
"analyze": "cem analyze --config custom-elements-manifest.config.js",
|
|
27
|
-
"build": "rimraf dist && npm run build:js && npm run build:types && npm run build:css",
|
|
27
|
+
"build": "rimraf dist && npm run build:js && npm run build:types && npm run build:css && npm run analyze",
|
|
28
28
|
"build:js": "rollup -c rollup.config.js",
|
|
29
29
|
"build:types": "tsc -p tsconfig.build.json",
|
|
30
30
|
"build:css": "postcss src/styles/theme.css -o dist/theme.css && cp dist/theme.css .storybook/static/",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"format:prettier": "prettier \"**/*.{js,mjs,md,html,json}\" --write --ignore-path .gitignore",
|
|
40
40
|
"test": "web-test-runner --coverage",
|
|
41
41
|
"test:watch": "web-test-runner --watch",
|
|
42
|
-
"prepare": "husky
|
|
42
|
+
"prepare": "husky",
|
|
43
43
|
"storybook": "npm run storybook:start",
|
|
44
44
|
"storybook:start": "npm run analyze && npm run watch:css & storybook dev -p 8080 --no-open",
|
|
45
45
|
"storybook:build": "npm run analyze && npm run build:css && storybook build --output-dir docs"
|
|
@@ -64,11 +64,11 @@
|
|
|
64
64
|
"@storybook/addon-links": "^7.6.17",
|
|
65
65
|
"@storybook/blocks": "^7.6.17",
|
|
66
66
|
"@storybook/web-components": "^7.6.17",
|
|
67
|
-
"@web/dev-server": "^0.
|
|
68
|
-
"@web/dev-server-rollup": "^0.
|
|
69
|
-
"@web/storybook-builder": "^0.1.
|
|
70
|
-
"@web/storybook-framework-web-components": "^0.1.
|
|
71
|
-
"@web/test-runner": "^0.18.
|
|
67
|
+
"@web/dev-server": "^0.4.6",
|
|
68
|
+
"@web/dev-server-rollup": "^0.6.4",
|
|
69
|
+
"@web/storybook-builder": "^0.1.16",
|
|
70
|
+
"@web/storybook-framework-web-components": "^0.1.2",
|
|
71
|
+
"@web/test-runner": "^0.18.2",
|
|
72
72
|
"@web/test-runner-commands": "^0.9.0",
|
|
73
73
|
"@web/test-runner-playwright": "^0.11.0",
|
|
74
74
|
"@whitespace/storybook-addon-html": "^5.1.6",
|
|
@@ -76,14 +76,12 @@
|
|
|
76
76
|
"custom-element-jet-brains-integration": "^1.4.4",
|
|
77
77
|
"custom-element-vs-code-integration": "^1.2.3",
|
|
78
78
|
"custom-element-vuejs-integration": "^1.1.0",
|
|
79
|
-
"es-dev-server": "^2.1.0",
|
|
80
|
-
"esbuild": "^0.20.0",
|
|
81
79
|
"eslint": "^8.31.0",
|
|
82
80
|
"eslint-config-prettier": "^8.3.0",
|
|
83
81
|
"eslint-plugin-storybook": "^0.6.14",
|
|
84
82
|
"glob": "^10.3.10",
|
|
85
|
-
"husky": "^
|
|
86
|
-
"lint-staged": "^
|
|
83
|
+
"husky": "^9.0.11",
|
|
84
|
+
"lint-staged": "^15.2.7",
|
|
87
85
|
"nodemon": "^3.0.2",
|
|
88
86
|
"postcss": "^8.4.31",
|
|
89
87
|
"postcss-cli": "^10.1.0",
|
|
@@ -96,7 +94,6 @@
|
|
|
96
94
|
"react-syntax-highlighter": "^15.5.0",
|
|
97
95
|
"rimraf": "^5.0.5",
|
|
98
96
|
"rollup": "^3.29.4",
|
|
99
|
-
"rollup-plugin-esbuild": "^6.0.2",
|
|
100
97
|
"rollup-plugin-postcss": "^4.0.2",
|
|
101
98
|
"rollup-plugin-postcss-lit": "^2.1.0",
|
|
102
99
|
"sinon": "^17.0.1",
|
package/rollup.config.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { html
|
|
1
|
+
import { html } from "lit"
|
|
2
|
+
|
|
3
|
+
import { LeuElement } from "../../lib/LeuElement.js"
|
|
4
|
+
|
|
2
5
|
import styles from "./[name].css"
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
* @tagname [namespace]-[name]
|
|
6
9
|
*/
|
|
7
|
-
export class Leu[Name] extends
|
|
10
|
+
export class Leu[Name] extends LeuElement {
|
|
8
11
|
static styles = styles
|
|
9
12
|
|
|
10
13
|
static shadowRootOptions = {
|
|
11
|
-
...
|
|
14
|
+
...LeuElement.shadowRootOptions,
|
|
12
15
|
delegatesFocus: true,
|
|
13
16
|
}
|
|
14
17
|
|
|
@@ -4,7 +4,7 @@ import { fixture, expect } from "@open-wc/testing"
|
|
|
4
4
|
import "../[namespace]-[name].js"
|
|
5
5
|
|
|
6
6
|
async function defaultFixture() {
|
|
7
|
-
return fixture(html
|
|
7
|
+
return fixture(html`<[namespace]-[name]></[namespace]-[name]>`)
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
describe("[Namespace][Name]", () => {
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { nothing } from "lit"
|
|
2
2
|
import { html, unsafeStatic } from "lit/static-html.js"
|
|
3
|
+
import { LeuElement } from "../../lib/LeuElement.js"
|
|
3
4
|
|
|
5
|
+
// @ts-ignore
|
|
4
6
|
import styles from "./accordion.css"
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* @tagname leu-accordion
|
|
8
10
|
* @slot content - The content of the accordion. No styles will be applied to the content.
|
|
9
|
-
* @prop {
|
|
10
|
-
* @prop {
|
|
11
|
-
* @prop {
|
|
12
|
-
* @prop {
|
|
13
|
-
* @attr {
|
|
14
|
-
* @attr {
|
|
11
|
+
* @prop {number} headingLevel - The heading level of the accordion title. Must be between 1 and 6.
|
|
12
|
+
* @prop {boolean} open - The expanded state of the accordion.
|
|
13
|
+
* @prop {string} label - The label (title) of the accordion.
|
|
14
|
+
* @prop {string} labelPrefix - The prefix of the accordion label. e.g. "01"
|
|
15
|
+
* @attr {number} heading-level - The heading level of the accordion title. Must be between 1 and 6.
|
|
16
|
+
* @attr {string} label-prefix - The prefix of the accordion label. e.g. "01"
|
|
15
17
|
*/
|
|
16
|
-
export class LeuAccordion extends
|
|
18
|
+
export class LeuAccordion extends LeuElement {
|
|
17
19
|
static styles = styles
|
|
18
20
|
|
|
19
21
|
/** @internal */
|
|
20
22
|
static shadowRootOptions = {
|
|
21
|
-
...
|
|
23
|
+
...LeuElement.shadowRootOptions,
|
|
22
24
|
delegatesFocus: true,
|
|
23
25
|
}
|
|
24
26
|
|
|
@@ -34,13 +36,14 @@ export class LeuAccordion extends LitElement {
|
|
|
34
36
|
this.headingLevel = 2
|
|
35
37
|
this.open = false
|
|
36
38
|
this.label = ""
|
|
39
|
+
this.labelPrefix = ""
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
/**
|
|
40
43
|
* Determines the heading tag of the accordion toggle.
|
|
41
44
|
* The headingLevel shouldn't be used directly to render the heading tag
|
|
42
45
|
* in order to avoid XSS issues.
|
|
43
|
-
* @returns {
|
|
46
|
+
* @returns {string} The heading tag of the accordion toggle.
|
|
44
47
|
* @internal
|
|
45
48
|
*/
|
|
46
49
|
_getHeadingTag() {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { html,
|
|
1
|
+
import { html, nothing } from "lit"
|
|
2
2
|
import { createRef, ref } from "lit/directives/ref.js"
|
|
3
3
|
import { classMap } from "lit/directives/class-map.js"
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import { Icon } from "../icon/icon.js"
|
|
7
|
-
import "../menu/leu-menu.js"
|
|
8
|
-
import "../menu/leu-menu-item.js"
|
|
9
|
-
import "../popup/leu-popup.js"
|
|
10
|
-
import "../visually-hidden/leu-visually-hidden.js"
|
|
5
|
+
import { LeuElement } from "../../lib/LeuElement.js"
|
|
11
6
|
import { debounce } from "../../lib/utils.js"
|
|
7
|
+
import { LeuIcon } from "../icon/Icon.js"
|
|
8
|
+
import { LeuMenu } from "../menu/Menu.js"
|
|
9
|
+
import { LeuMenuItem } from "../menu/MenuItem.js"
|
|
10
|
+
import { LeuPopup } from "../popup/Popup.js"
|
|
11
|
+
import { LeuVisuallyHidden } from "../visually-hidden/VisuallyHidden.js"
|
|
12
|
+
|
|
13
|
+
import styles from "./breadcrumb.css"
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* A Breadcrumb Navigation.
|
|
@@ -40,11 +42,19 @@ import { debounce } from "../../lib/utils.js"
|
|
|
40
42
|
*
|
|
41
43
|
*
|
|
42
44
|
* @prop {Array} items - Object array with { label, href }
|
|
43
|
-
* @prop {
|
|
45
|
+
* @prop {boolean} inverted - invert color on dark background
|
|
44
46
|
*
|
|
45
47
|
* @tagname leu-breadcrumb
|
|
46
48
|
*/
|
|
47
|
-
export class LeuBreadcrumb extends
|
|
49
|
+
export class LeuBreadcrumb extends LeuElement {
|
|
50
|
+
static dependencies = {
|
|
51
|
+
"leu-icon": LeuIcon,
|
|
52
|
+
"leu-menu": LeuMenu,
|
|
53
|
+
"leu-menu-item": LeuMenuItem,
|
|
54
|
+
"leu-popup": LeuPopup,
|
|
55
|
+
"leu-visually-hidden": LeuVisuallyHidden,
|
|
56
|
+
}
|
|
57
|
+
|
|
48
58
|
static styles = styles
|
|
49
59
|
|
|
50
60
|
static properties = {
|
|
@@ -63,7 +73,7 @@ export class LeuBreadcrumb extends LitElement {
|
|
|
63
73
|
super()
|
|
64
74
|
/** @type {Array} */
|
|
65
75
|
this.items = []
|
|
66
|
-
/** @type {
|
|
76
|
+
/** @type {boolean} - will be used on dark Background */
|
|
67
77
|
this.inverted = false
|
|
68
78
|
|
|
69
79
|
/** @internal */
|
|
@@ -225,7 +235,9 @@ export class LeuBreadcrumb extends LitElement {
|
|
|
225
235
|
|
|
226
236
|
return html`
|
|
227
237
|
<li class="breadcrumbs__item" data-dropdown-toggle>
|
|
228
|
-
<span class="breadcrumbs__icon"
|
|
238
|
+
<span class="breadcrumbs__icon"
|
|
239
|
+
><leu-icon name="angleRight"></leu-icon
|
|
240
|
+
></span>
|
|
229
241
|
<leu-popup
|
|
230
242
|
?active=${this._isDropdownOpen}
|
|
231
243
|
placement="bottom-start"
|
|
@@ -248,10 +260,9 @@ export class LeuBreadcrumb extends LitElement {
|
|
|
248
260
|
${this._dropdownItems.map(
|
|
249
261
|
(item) =>
|
|
250
262
|
html`
|
|
251
|
-
<leu-menu-item
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
></leu-menu-item>
|
|
263
|
+
<leu-menu-item href=${item.href}
|
|
264
|
+
>${item.label}</leu-menu-item
|
|
265
|
+
>
|
|
255
266
|
`
|
|
256
267
|
)}
|
|
257
268
|
</leu-menu>
|
|
@@ -281,7 +292,9 @@ export class LeuBreadcrumb extends LitElement {
|
|
|
281
292
|
<ol class="breadcrumbs__list" ref=${ref(this._containerRef)}>
|
|
282
293
|
${showBackOnly
|
|
283
294
|
? html` <li class="breadcrumbs__item breadcrumbs__item--back">
|
|
284
|
-
<span class="breadcrumbs__icon"
|
|
295
|
+
<span class="breadcrumbs__icon"
|
|
296
|
+
><leu-icon name="arrowLeft"></leu-icon
|
|
297
|
+
></span>
|
|
285
298
|
<a class="breadcrumbs__link" href=${parentItem.href}
|
|
286
299
|
>${parentItem.label}</a
|
|
287
300
|
>
|
|
@@ -292,8 +305,8 @@ export class LeuBreadcrumb extends LitElement {
|
|
|
292
305
|
<li class="breadcrumbs__item">
|
|
293
306
|
${index > 0
|
|
294
307
|
? html`<span class="breadcrumbs__icon"
|
|
295
|
-
|
|
296
|
-
>` // First list item doesn't have an arrow
|
|
308
|
+
><leu-icon name="angleRight"></leu-icon
|
|
309
|
+
></span>` // First list item doesn't have an arrow
|
|
297
310
|
: nothing}
|
|
298
311
|
${index === list.length - 1
|
|
299
312
|
? item.label // Last list item doesn't contain a link
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { html, nothing
|
|
1
|
+
import { html, nothing } from "lit"
|
|
2
2
|
import { classMap } from "lit/directives/class-map.js"
|
|
3
3
|
import { ifDefined } from "lit/directives/if-defined.js"
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { LeuIcon } from "../icon/Icon.js"
|
|
6
|
+
import { LeuElement } from "../../lib/LeuElement.js"
|
|
6
7
|
import { HasSlotController } from "../../lib/hasSlotController.js"
|
|
8
|
+
import { ARIA_CHECKED_ROLES, ARIA_SELECTED_ROLES } from "../../lib/a11y.js"
|
|
7
9
|
|
|
10
|
+
// @ts-ignore
|
|
8
11
|
import styles from "./button.css"
|
|
9
12
|
|
|
10
13
|
/*
|
|
@@ -27,56 +30,38 @@ export { BUTTON_TYPES }
|
|
|
27
30
|
export const BUTTON_EXPANDED_OPTIONS = ["true", "false"]
|
|
28
31
|
Object.freeze(BUTTON_EXPANDED_OPTIONS)
|
|
29
32
|
|
|
30
|
-
/**
|
|
31
|
-
* All roles that are associated with a aria-checked attribute
|
|
32
|
-
* @link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-checked
|
|
33
|
-
*/
|
|
34
|
-
const ARIA_ROLES_CHECKED = [
|
|
35
|
-
"checkbox",
|
|
36
|
-
"menuitemcheckbox",
|
|
37
|
-
"menuitemradio",
|
|
38
|
-
"option",
|
|
39
|
-
"radio",
|
|
40
|
-
"switch",
|
|
41
|
-
]
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* All roles that are associated with a aria-selected attribute
|
|
45
|
-
* @link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-selected
|
|
46
|
-
*/
|
|
47
|
-
const ARIA_ROLES_SELECTED = [
|
|
48
|
-
"gridcell",
|
|
49
|
-
"option",
|
|
50
|
-
"row",
|
|
51
|
-
"tab",
|
|
52
|
-
"columnheader",
|
|
53
|
-
"rowheader",
|
|
54
|
-
"treeitem",
|
|
55
|
-
]
|
|
56
|
-
|
|
57
33
|
/**
|
|
58
34
|
* @tagname leu-button
|
|
35
|
+
* @slot before - The icon to display before the label
|
|
36
|
+
* @slot after - The icon to display after the label
|
|
37
|
+
* @slot - The label of the button or the icon if no label is set
|
|
59
38
|
*/
|
|
60
|
-
export class LeuButton extends
|
|
39
|
+
export class LeuButton extends LeuElement {
|
|
40
|
+
static dependencies = {
|
|
41
|
+
"leu-icon": LeuIcon,
|
|
42
|
+
}
|
|
43
|
+
|
|
61
44
|
static styles = styles
|
|
62
45
|
|
|
63
46
|
/**
|
|
64
47
|
* @internal
|
|
65
48
|
*/
|
|
66
49
|
static shadowRootOptions = {
|
|
67
|
-
...
|
|
50
|
+
...LeuElement.shadowRootOptions,
|
|
68
51
|
delegatesFocus: true,
|
|
69
52
|
}
|
|
70
53
|
|
|
71
54
|
/**
|
|
72
55
|
* @internal
|
|
73
56
|
*/
|
|
74
|
-
hasSlotController = new HasSlotController(this, [
|
|
57
|
+
hasSlotController = new HasSlotController(this, [
|
|
58
|
+
"before",
|
|
59
|
+
"after",
|
|
60
|
+
"[default]",
|
|
61
|
+
])
|
|
75
62
|
|
|
76
63
|
static properties = {
|
|
77
64
|
label: { type: String, reflect: true },
|
|
78
|
-
icon: { type: String, reflect: true },
|
|
79
|
-
iconPosition: { type: String, reflect: true },
|
|
80
65
|
size: { type: String, reflect: true },
|
|
81
66
|
variant: { type: String, reflect: true },
|
|
82
67
|
type: { type: String, reflect: true },
|
|
@@ -95,16 +80,15 @@ export class LeuButton extends LitElement {
|
|
|
95
80
|
/** @type {string} */
|
|
96
81
|
this.label = null
|
|
97
82
|
/** @type {string} */
|
|
98
|
-
this.icon = null
|
|
99
|
-
/** @type {("before" | "after")} - Only taken into account if Label and no Icon is set */
|
|
100
|
-
this.iconPosition = "before"
|
|
101
|
-
/** @type {string} */
|
|
102
83
|
this.size = "regular"
|
|
103
84
|
/** @type {string} */
|
|
104
85
|
this.variant = "primary"
|
|
105
86
|
/** @type {"button" | "submit" | "reset"} */
|
|
106
87
|
this.type = "button"
|
|
107
88
|
|
|
89
|
+
/** @type {string} */
|
|
90
|
+
this.componentRole = undefined
|
|
91
|
+
|
|
108
92
|
/** @type {boolean} */
|
|
109
93
|
this.disabled = false
|
|
110
94
|
/** @type {boolean} - Only taken into account if no Label and an Icon is set */
|
|
@@ -124,34 +108,10 @@ export class LeuButton extends LitElement {
|
|
|
124
108
|
this.expanded = undefined
|
|
125
109
|
}
|
|
126
110
|
|
|
127
|
-
getIconSize() {
|
|
128
|
-
return this.size === "small" || this.variant === "ghost" ? 16 : 24
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
renderIconBefore() {
|
|
132
|
-
if (this.icon && this.iconPosition === "before") {
|
|
133
|
-
return html`<div class="icon-wrapper icon-wrapper--before">
|
|
134
|
-
${Icon(this.icon, this.getIconSize())}
|
|
135
|
-
</div>`
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return nothing
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
renderIconAfter() {
|
|
142
|
-
if (this.icon && this.iconPosition === "after") {
|
|
143
|
-
return html`<div class="icon-wrapper icon-wrapper--after">
|
|
144
|
-
${Icon(this.icon, this.getIconSize())}
|
|
145
|
-
</div>`
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return nothing
|
|
149
|
-
}
|
|
150
|
-
|
|
151
111
|
renderExpandingIcon() {
|
|
152
112
|
if (typeof this.expanded !== "undefined" && this.variant === "ghost") {
|
|
153
113
|
return html`<div class="icon-wrapper icon-wrapper--expanded">
|
|
154
|
-
|
|
114
|
+
<leu-icon name="angleDropDown" size="24"></leu-icon>
|
|
155
115
|
</div>`
|
|
156
116
|
}
|
|
157
117
|
|
|
@@ -165,9 +125,9 @@ export class LeuButton extends LitElement {
|
|
|
165
125
|
}
|
|
166
126
|
|
|
167
127
|
if (this.componentRole) {
|
|
168
|
-
if (
|
|
128
|
+
if (ARIA_CHECKED_ROLES.includes(this.componentRole)) {
|
|
169
129
|
attributes.checked = this.active ? "true" : "false"
|
|
170
|
-
} else if (
|
|
130
|
+
} else if (ARIA_SELECTED_ROLES.includes(this.componentRole)) {
|
|
171
131
|
attributes.selected = this.active ? "true" : "false"
|
|
172
132
|
}
|
|
173
133
|
}
|
|
@@ -175,13 +135,25 @@ export class LeuButton extends LitElement {
|
|
|
175
135
|
return attributes
|
|
176
136
|
}
|
|
177
137
|
|
|
138
|
+
hasTextContent() {
|
|
139
|
+
return Array.from(this.childNodes).some(
|
|
140
|
+
(node) =>
|
|
141
|
+
node.nodeType === node.TEXT_NODE && node.textContent.trim() !== ""
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
|
|
178
145
|
render() {
|
|
179
|
-
const
|
|
146
|
+
const hasTextContent = this.hasTextContent()
|
|
147
|
+
const hasIconDefault = Boolean(this.querySelector("leu-icon"))
|
|
148
|
+
const hasIconBefore = this.hasSlotController.test("before")
|
|
149
|
+
const hasIconAfter = this.hasSlotController.test("after")
|
|
180
150
|
const aria = this.getAriaAttributes()
|
|
181
151
|
|
|
182
152
|
const cssClasses = {
|
|
183
|
-
icon:
|
|
184
|
-
|
|
153
|
+
"icon-only": hasIconDefault && !hasTextContent,
|
|
154
|
+
"icon-before": hasIconBefore,
|
|
155
|
+
"icon-after": hasIconAfter,
|
|
156
|
+
round: this.round,
|
|
185
157
|
active: this.active,
|
|
186
158
|
inverted: this.inverted,
|
|
187
159
|
[this.variant]: true,
|
|
@@ -192,14 +164,16 @@ export class LeuButton extends LitElement {
|
|
|
192
164
|
aria-label=${ifDefined(aria.label)}
|
|
193
165
|
aria-selected=${ifDefined(aria.selected)}
|
|
194
166
|
aria-checked=${ifDefined(aria.checked)}
|
|
167
|
+
aria-expanded=${ifDefined(this.expanded)}
|
|
195
168
|
role=${ifDefined(aria.role)}
|
|
196
169
|
class=${classMap(cssClasses)}
|
|
197
170
|
?disabled=${this.disabled}
|
|
198
171
|
type=${this.type}
|
|
199
172
|
>
|
|
200
|
-
|
|
201
|
-
<slot></slot>
|
|
202
|
-
|
|
173
|
+
<slot name="before" class="icon-wrapper icon-wrapper--before"></slot>
|
|
174
|
+
<span class="content"><slot></slot></span>
|
|
175
|
+
<slot name="after" class="icon-wrapper icon-wrapper--after"></slot>
|
|
176
|
+
${this.renderExpandingIcon()}
|
|
203
177
|
</button>
|
|
204
178
|
`
|
|
205
179
|
}
|
|
@@ -10,11 +10,20 @@ button {
|
|
|
10
10
|
cursor: pointer;
|
|
11
11
|
border: 1px solid transparent;
|
|
12
12
|
border-radius: 2px;
|
|
13
|
+
|
|
14
|
+
max-width: 100%;
|
|
13
15
|
display: flex;
|
|
14
16
|
align-items: center;
|
|
15
17
|
column-gap: 8px;
|
|
16
18
|
}
|
|
17
19
|
|
|
20
|
+
.content {
|
|
21
|
+
flex: 1 1 0;
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
text-overflow: ellipsis;
|
|
24
|
+
white-space: nowrap;
|
|
25
|
+
}
|
|
26
|
+
|
|
18
27
|
button.round {
|
|
19
28
|
border-radius: 50%;
|
|
20
29
|
}
|
|
@@ -45,7 +54,7 @@ button.regular {
|
|
|
45
54
|
line-height: 24px;
|
|
46
55
|
}
|
|
47
56
|
|
|
48
|
-
button.regular.icon {
|
|
57
|
+
button.regular.icon-only {
|
|
49
58
|
padding: 12px;
|
|
50
59
|
}
|
|
51
60
|
|
|
@@ -54,9 +63,11 @@ button.small {
|
|
|
54
63
|
padding: 6px 24px;
|
|
55
64
|
font-size: 14px;
|
|
56
65
|
line-height: 20px;
|
|
66
|
+
|
|
67
|
+
--leu-icon-size: 1rem;
|
|
57
68
|
}
|
|
58
69
|
|
|
59
|
-
button.small.icon {
|
|
70
|
+
button.small.icon-only {
|
|
60
71
|
padding: 8px;
|
|
61
72
|
}
|
|
62
73
|
|
|
@@ -112,6 +123,8 @@ button.secondary:disabled {
|
|
|
112
123
|
|
|
113
124
|
/* ghost */
|
|
114
125
|
button.ghost {
|
|
126
|
+
--leu-icon-size: 1rem;
|
|
127
|
+
|
|
115
128
|
background: transparent;
|
|
116
129
|
padding: 0 0.5rem;
|
|
117
130
|
color: var(--leu-color-black-60);
|
|
@@ -190,11 +203,13 @@ button.ghost.inverted:disabled {
|
|
|
190
203
|
}
|
|
191
204
|
|
|
192
205
|
/* icon-wrapper */
|
|
193
|
-
.icon-wrapper
|
|
206
|
+
.icon-wrapper leu-icon {
|
|
194
207
|
display: block;
|
|
195
208
|
}
|
|
196
209
|
|
|
197
|
-
.ghost
|
|
210
|
+
.ghost.icon-before .icon-wrapper--before,
|
|
211
|
+
.ghost.icon-after .icon-wrapper--after {
|
|
212
|
+
display: block;
|
|
198
213
|
padding: 0.5rem;
|
|
199
214
|
border-radius: 50%;
|
|
200
215
|
background: var(--leu-color-black-transp-10);
|