@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
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { html, svg } from "lit"
|
|
2
|
+
|
|
3
|
+
import { LeuElement } from "../../lib/LeuElement.js"
|
|
4
|
+
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
import styles from "./icon.css"
|
|
7
|
+
import { paths } from "./paths.js"
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A component to render all defined zhWeb icons.
|
|
11
|
+
* The `fill` of the icon is set to `currentColor` and
|
|
12
|
+
* can be overriden by setting the css `color` property.
|
|
13
|
+
* If the icon name is not found, a placeholder will be displayed.
|
|
14
|
+
*
|
|
15
|
+
* @tagname leu-icon
|
|
16
|
+
* @prop {import("./paths").IconPathName} name - The name of the icon to display.
|
|
17
|
+
* @cssprop --leu-icon-size - The size of the icon.
|
|
18
|
+
*/
|
|
19
|
+
export class LeuIcon extends LeuElement {
|
|
20
|
+
static styles = styles
|
|
21
|
+
|
|
22
|
+
static properties = {
|
|
23
|
+
name: { type: String, reflect: true },
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
constructor() {
|
|
27
|
+
super()
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @type {import("./paths").IconPathName | ""}
|
|
31
|
+
*/
|
|
32
|
+
this.name = ""
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
render() {
|
|
36
|
+
if (!paths[this.name]) {
|
|
37
|
+
return html`<div class="placeholder"></div>`
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const iconPath = paths[this.name]
|
|
41
|
+
|
|
42
|
+
return html`
|
|
43
|
+
<svg
|
|
44
|
+
width="24"
|
|
45
|
+
height="24"
|
|
46
|
+
fill="currentColor"
|
|
47
|
+
viewBox="0 0 24 24"
|
|
48
|
+
fill-rule="evenodd"
|
|
49
|
+
role="presentation"
|
|
50
|
+
>
|
|
51
|
+
${svg`<path d=${iconPath} />`}
|
|
52
|
+
</svg>
|
|
53
|
+
`
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {keyof paths} IconPathName
|
|
3
|
+
*/
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
// - login into figma: https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN?node-id=311:9677
|
|
5
|
-
// - click icon and then export as svg on the right drawer
|
|
6
|
-
// - copy svg path (multiple with space between)
|
|
7
|
-
// - update @param {TYPE} with console.log() below
|
|
8
|
-
export const iconPaths = {
|
|
5
|
+
export const paths = {
|
|
9
6
|
addNew:
|
|
10
7
|
"M12 1C5.926 1 1 5.925 1 12C1 18.075 5.926 23 12 23C18.074 23 23 18.075 23 12C23 5.925 18.074 1 12 1ZM17 13H13V17H11V13H7V11H11V7H13V11H17V13Z",
|
|
11
8
|
angleDropDown: "M17 9.5L12 14.5L7 9.5L17 9.5Z",
|
|
@@ -62,9 +59,6 @@ export const iconPaths = {
|
|
|
62
59
|
"M12 1C5.926 1 1 5.926 1 12C1 18.074 5.926 23 12 23C18.074 23 23 18.074 23 12C23 5.926 18.074 1 12 1ZM11.5 6C11.898 6.00013 12.2796 6.15835 12.5609 6.43984C12.8422 6.72133 13.0001 7.10304 13 7.501C12.9999 7.89896 12.8417 8.28056 12.5602 8.56187C12.2787 8.84317 11.897 9.00113 11.499 9.001C11.101 9.00087 10.7194 8.84265 10.4381 8.56116C10.1568 8.27967 9.99887 7.89796 9.999 7.5C9.99913 7.10204 10.1573 6.72044 10.4388 6.43913C10.7203 6.15783 11.102 5.99987 11.5 6ZM15 18H9V16H11V12H9V10H13V16H15V18Z",
|
|
63
60
|
hide: "M23.7862 0.213819C23.6464 0.0767667 23.4584 0 23.2626 0C23.0668 0 22.8788 0.0767667 22.739 0.213819L16.9046 6.01077C15.3896 5.26962 13.7291 4.87365 12.0427 4.85138C5.31075 4.88878 0.598395 11.4711 0.411396 11.7329L0.112199 12.1817L0.411396 12.5931C1.81786 14.494 3.55313 16.128 5.53515 17.4177L0.299197 22.6536C0.213464 22.7179 0.142549 22.7999 0.0912528 22.894C0.0399571 22.9881 0.0094788 23.0921 0.00188187 23.199C-0.00571506 23.3059 0.00974673 23.4132 0.0472203 23.5136C0.0846938 23.614 0.143304 23.7051 0.219082 23.7809C0.29486 23.8567 0.386037 23.9153 0.486438 23.9528C0.586839 23.9903 0.694121 24.0057 0.801018 23.9981C0.907915 23.9905 1.01193 23.96 1.10602 23.9087C1.20012 23.8575 1.28209 23.7865 1.34639 23.7008L23.7862 1.26101C23.9232 1.12119 24 0.933204 24 0.737414C24 0.541625 23.9232 0.353641 23.7862 0.213819ZM7.55473 11.9947C7.55473 10.8044 8.02757 9.6629 8.86922 8.82125C9.71088 7.97959 10.8524 7.50675 12.0427 7.50675C12.9675 7.50625 13.8694 7.79383 14.6233 8.32954L8.37752 14.5753C7.84181 13.8215 7.55422 12.9195 7.55473 11.9947ZM19.56 7.61895L16.381 10.7979C16.5884 11.5629 16.5895 12.3692 16.3842 13.1347C16.1788 13.9002 15.7744 14.5978 15.2121 15.1563C14.6498 15.7148 13.9495 16.1145 13.1826 16.3146C12.4157 16.5148 11.6095 16.5082 10.8459 16.2957L8.34012 18.8014C9.52646 19.237 10.779 19.4647 12.0427 19.4746C18.7746 19.4746 23.487 12.8923 23.674 12.5931L23.9732 12.1817L23.674 11.7703C22.5141 10.1919 21.1279 8.7931 19.56 7.61895Z",
|
|
64
61
|
home: "M23 10L12.0071 1L1 10V12L11.9925 3L23 12V10Z M3.375 12V23H9V17H15V23H20.625V12L12 5L3.375 12Z",
|
|
65
|
-
layer1:
|
|
66
|
-
"M15.875 6.875H9.125V0.125H6.875V6.875H0.125V9.125H6.875V15.875H9.125V9.125H15.875V6.875Z",
|
|
67
|
-
layer11: "M0.5 0.5H16.25V2.75H0.5V0.5Z",
|
|
68
62
|
link: "M22.2237 3.63526L20.3648 1.77638C19.7075 1.11912 18.816 0.749878 17.8864 0.749878C16.9569 0.749878 16.0654 1.11912 15.408 1.77638L12.3098 4.87501C11.6526 5.53238 11.2834 6.42386 11.2834 7.35338C11.2834 8.28291 11.6526 9.17438 12.3098 9.83176L12.6192 10.1415L13.182 10.704L14.4214 9.46501L13.8589 8.90251L13.5492 8.59238C13.2205 8.26374 13.0359 7.81804 13.0358 7.35327C13.0357 6.88851 13.2203 6.44275 13.5488 6.11401L16.647 3.01576C16.9758 2.68726 17.4215 2.50274 17.8862 2.50274C18.351 2.50274 18.7967 2.68726 19.1254 3.01576L20.9843 4.87501C21.3128 5.20368 21.4973 5.64934 21.4973 6.11401C21.4973 6.57868 21.3128 7.02433 20.9843 7.35301L17.886 10.4513C17.6013 10.7359 17.2273 10.9138 16.8268 10.9551C16.4264 10.9964 16.0239 10.8986 15.687 10.6781L14.4342 11.9306C15.1072 12.4782 15.9594 12.7568 16.8259 12.7125C17.6925 12.6682 18.5118 12.3041 19.1254 11.6906L22.2237 8.59238C22.5492 8.26693 22.8073 7.88055 22.9835 7.45531C23.1597 7.03007 23.2503 6.57429 23.2503 6.11401C23.2503 5.65372 23.1597 5.19795 22.9835 4.7727C22.8073 4.34746 22.5492 3.96108 22.2237 3.63563V3.63526ZM10.4513 17.8864L7.35304 20.9843C7.0243 21.3128 6.57859 21.4973 6.11385 21.4973C5.64912 21.4973 5.2034 21.3128 4.87467 20.9843L3.01579 19.1254C2.85296 18.9627 2.72378 18.7695 2.63565 18.5569C2.54751 18.3443 2.50215 18.1164 2.50215 17.8862C2.50215 17.656 2.54751 17.4281 2.63565 17.2155C2.72378 17.0029 2.85296 16.8097 3.01579 16.647L6.11404 13.5491C6.44274 13.2204 6.88856 13.0358 7.35342 13.0358C7.81827 13.0358 8.26409 13.2204 8.59279 13.5491L8.90179 13.8589L9.46429 14.4214L10.7037 13.1824L10.1408 12.6195L9.83179 12.3098C9.1744 11.6525 8.28285 11.2832 7.35323 11.2832C6.42361 11.2832 5.53206 11.6525 4.87467 12.3098L1.77642 15.408C1.45093 15.7335 1.19273 16.1198 1.01658 16.5451C0.840422 16.9703 0.749756 17.4261 0.749756 17.8864C0.749756 18.3467 0.840422 18.8024 1.01658 19.2277C1.19273 19.6529 1.45093 20.0393 1.77642 20.3648L3.63529 22.2236C4.2927 22.881 5.18433 23.2504 6.11404 23.2504C7.04375 23.2504 7.93538 22.881 8.59279 22.2236L11.6899 19.125C12.3032 18.5113 12.6672 17.692 12.7115 16.8255C12.7558 15.959 12.4774 15.1069 11.9299 14.4338L10.6774 15.6863C10.8981 16.0232 10.996 16.4258 10.9547 16.8264C10.9134 17.2271 10.7353 17.6012 10.4505 17.886L10.4513 17.8864Z M17.0416 6.95849C17.2058 7.12289 17.2981 7.34578 17.2981 7.57817C17.2981 7.81057 17.2058 8.03346 17.0416 8.19786L8.05806 17.181C7.97671 17.2624 7.88013 17.3269 7.77384 17.3709C7.66754 17.415 7.55361 17.4376 7.43856 17.4376C7.3235 17.4376 7.20957 17.415 7.10328 17.3709C6.99698 17.3269 6.90041 17.2624 6.81906 17.181C6.65471 17.0166 6.56238 16.7937 6.56238 16.5613C6.56238 16.3289 6.65471 16.106 6.81906 15.9416L15.8026 6.95849C15.9669 6.79434 16.1898 6.70215 16.4221 6.70215C16.6544 6.70215 16.8772 6.79434 17.0416 6.95849Z",
|
|
69
63
|
list: "M5 5H2V8H5V5Z M22 5H8V8H22V5Z M2 11H5V14H2V11Z M22 11H8V14H22V11Z M2 17H5V20H2V17Z M22 17H8V20H22V17Z",
|
|
70
64
|
lock: "M4.00211 15.1855C3.94503 17.4179 4.90163 19.6403 6.77048 21.1901C9.77412 23.6808 14.2259 23.6808 17.2296 21.1901C19.0987 19.6401 20.0553 17.4173 19.9979 15.1845C19.9993 15.1232 20 15.0617 20 15C20 13.4191 19.5414 11.9452 18.75 10.7043V6.48C18.75 2.90119 15.7279 0 12 0C8.2721 0 5.25002 2.90119 5.25002 6.48V10.7042C4.4586 11.9452 4 13.419 4 15C4 15.062 4.0007 15.1238 4.00211 15.1855ZM12 17C10.8954 17 10 16.1046 10 15C10 13.8954 10.8954 13 12 13C13.1046 13 14 13.8954 14 15C14 16.1046 13.1046 17 12 17ZM16.25 8.22103C15.0186 7.44741 13.5616 7 12 7C10.4384 7 8.98137 7.44741 7.75 8.22103V6.48C7.75 4.22668 9.65279 2.4 12 2.4C14.3472 2.4 16.25 4.22668 16.25 6.48V8.22103Z",
|
|
@@ -172,30 +166,3 @@ export const iconPaths = {
|
|
|
172
166
|
smileyDevastated:
|
|
173
167
|
"M11 0.5C8.9233 0.5 6.89323 1.11581 5.16652 2.26957C3.4398 3.42332 2.09399 5.0632 1.29927 6.98182C0.504549 8.90045 0.296614 11.0116 0.701759 13.0484C1.1069 15.0852 2.10693 16.9562 3.57538 18.4246C5.04383 19.8931 6.91476 20.8931 8.95156 21.2982C10.9884 21.7034 13.0996 21.4955 15.0182 20.7007C16.9368 19.906 18.5767 18.5602 19.7304 16.8335C20.8842 15.1068 21.5 13.0767 21.5 11C21.5 8.21523 20.3938 5.54451 18.4246 3.57538C16.4555 1.60625 13.7848 0.5 11 0.5ZM5.75 11.3075L4.6925 10.25L6.1925 8.75L4.6925 7.25L5.75 6.1925L7.25 7.6925L8.75 6.1925L9.8075 7.25L8.3075 8.75L9.8075 10.25L8.75 11.3075L7.25 9.8075L5.75 11.3075ZM11 17.75C10.555 17.75 10.12 17.618 9.74997 17.3708C9.37996 17.1236 9.09157 16.7722 8.92128 16.361C8.75098 15.9499 8.70642 15.4975 8.79324 15.061C8.88005 14.6246 9.09435 14.2237 9.40901 13.909C9.72368 13.5943 10.1246 13.38 10.5611 13.2932C10.9975 13.2064 11.4499 13.251 11.861 13.4213C12.2722 13.5916 12.6236 13.88 12.8708 14.25C13.118 14.62 13.25 15.055 13.25 15.5C13.25 16.0967 13.013 16.669 12.591 17.091C12.169 17.5129 11.5967 17.75 11 17.75ZM17.3075 10.25L16.25 11.3075L14.75 9.8075L13.25 11.3075L12.1925 10.25L13.6925 8.75L12.1925 7.25L13.25 6.1925L14.75 7.6925L16.25 6.1925L17.3075 7.25L15.8075 8.75L17.3075 10.25Z",
|
|
174
168
|
}
|
|
175
|
-
const ICON_NAMES = Object.keys(iconPaths)
|
|
176
|
-
Object.freeze(ICON_NAMES)
|
|
177
|
-
export { ICON_NAMES }
|
|
178
|
-
// console.log(JSON.stringify(Object.keys(iconPaths)).replace(/"/g, "'").replace(/,/g, "|").replace(/\[/g, "").replace(/\]/g, ""))
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Returns an (ZhWeb) icon with a default size of 24px.
|
|
182
|
-
* The CSS color is inherited from the parent object.
|
|
183
|
-
* @param {'addNew'|'angleDropDown'|'angleDropup'|'angleLeft'|'angleRight'|'arrowDown'|'arrowLeft'|'arrowRight'|'arrowUp'|'calendar'|'caution'|'chatMessage'|'check'|'check1'|'clear'|'close'|'conference'|'confirm'|'confirmPlain'|'delete'|'documents'|'download'|'edit'|'email'|'file'|'fileOutline'|'files'|'filter'|'floppy'|'forward'|'getInformation'|'hide'|'home'|'layer1'|'layer11'|'link'|'list'|'lock'|'location'|'login'|'logout'|'map'|'mapLocateMe'|'mapLocation'|'mapNavigation'|'mapPin'|'menu'|'menuOverflow'|'minus'|'openMail'|'overflow'|'paperplane'|'paragraph'|'phoneCall'|'pin'|'plus'|'print'|'remove'|'resizeText'|'search'|'show'|'time'|'upload'|'cc'|'fastForward'|'fastRewind'|'fullScreen'|'next'|'pause'|'play'|'playButton'|'previews'|'skipNext'|'skipPrevious'|'stop'|'comment'|'facebook'|'google'|'instagram'|'kununu'|'like'|'linkedin'|'love'|'repost'|'share'|'snapchat'|'twitter'|'user'|'users'|'vote'|'xing'|'youtube'|'youtubeLogo'|'smileyThrilled'|'smileySmile'|'smileyIndifferent'|'smileySad'|'smileyDevastated'} name
|
|
184
|
-
* @param {number} size
|
|
185
|
-
* @returns TemplateResult<1>
|
|
186
|
-
*/
|
|
187
|
-
export const Icon = (name, size = 24) => {
|
|
188
|
-
const iconPath = iconPaths[name]
|
|
189
|
-
|
|
190
|
-
return html`
|
|
191
|
-
<svg
|
|
192
|
-
width="${size}"
|
|
193
|
-
height="${size}"
|
|
194
|
-
fill="currentColor"
|
|
195
|
-
viewBox="0 0 24 24"
|
|
196
|
-
fill-rule="evenodd"
|
|
197
|
-
>
|
|
198
|
-
${svg`<path d=${iconPath} />`}
|
|
199
|
-
</svg>
|
|
200
|
-
`
|
|
201
|
-
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { html } from "lit"
|
|
2
|
+
import "../leu-icon.js"
|
|
3
|
+
import { ifDefined } from "lit/directives/if-defined.js"
|
|
4
|
+
import { paths } from "../paths.js"
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: "Icon",
|
|
8
|
+
component: "leu-icon",
|
|
9
|
+
argTypes: {
|
|
10
|
+
name: {
|
|
11
|
+
control: "select",
|
|
12
|
+
options: Object.keys(paths),
|
|
13
|
+
},
|
|
14
|
+
color: {
|
|
15
|
+
control: {
|
|
16
|
+
type: "color",
|
|
17
|
+
presetColors: ["#009ee0", "#d93c1a", "#1a7f1f"],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function Template({ name, size, color }) {
|
|
24
|
+
return html` <leu-icon
|
|
25
|
+
style="color: ${color}; ${size ? `--leu-icon-size: ${size}px` : ""};"
|
|
26
|
+
name=${ifDefined(name)}
|
|
27
|
+
></leu-icon>`
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const Regular = Template.bind({})
|
|
31
|
+
Regular.args = {
|
|
32
|
+
size: 24,
|
|
33
|
+
name: "addNew",
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const Small = Template.bind({})
|
|
37
|
+
Small.args = {
|
|
38
|
+
size: 16,
|
|
39
|
+
name: "check",
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const Colored = Template.bind({})
|
|
43
|
+
Colored.args = {
|
|
44
|
+
name: "smileyDevastated",
|
|
45
|
+
size: 24,
|
|
46
|
+
color: "#d93c1a",
|
|
47
|
+
}
|
|
@@ -1,66 +1,49 @@
|
|
|
1
1
|
import { html } from "lit"
|
|
2
2
|
import { fixture, expect } from "@open-wc/testing"
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import "../leu-icon.js"
|
|
5
5
|
|
|
6
|
-
async function defaultFixture(
|
|
7
|
-
|
|
8
|
-
return fixture(html`${Icon(name, size)} `)
|
|
6
|
+
async function defaultFixture(name = "close") {
|
|
7
|
+
return fixture(html` <leu-icon name=${name}></leu-icon> `)
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
describe("
|
|
12
|
-
it("
|
|
13
|
-
const el = await
|
|
10
|
+
describe("LeuIcon", () => {
|
|
11
|
+
it("is a defined element", async () => {
|
|
12
|
+
const el = await customElements.get("leu-icon")
|
|
14
13
|
|
|
15
|
-
await expect(el).
|
|
14
|
+
await expect(el).not.to.be.undefined
|
|
16
15
|
})
|
|
17
16
|
|
|
18
|
-
it("
|
|
17
|
+
it("passes the a11y audit", async () => {
|
|
19
18
|
const el = await defaultFixture()
|
|
20
19
|
|
|
21
|
-
expect(el).to.
|
|
20
|
+
await expect(el).shadowDom.to.be.accessible()
|
|
22
21
|
})
|
|
23
22
|
|
|
24
|
-
it("renders a
|
|
23
|
+
it("renders a 24x24 icon by default", async () => {
|
|
25
24
|
const el = await defaultFixture()
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it("renders the correct path", async () => {
|
|
31
|
-
const el = await defaultFixture({ name: "share" })
|
|
26
|
+
const svg = el.shadowRoot.querySelector("svg")
|
|
32
27
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
expect(d).to.equal(iconPaths.share)
|
|
28
|
+
expect(svg).to.have.attribute("width", "24")
|
|
29
|
+
expect(svg).to.have.attribute("height", "24")
|
|
36
30
|
})
|
|
37
31
|
|
|
38
|
-
it("
|
|
39
|
-
const el = await defaultFixture()
|
|
40
|
-
|
|
41
|
-
const width = el.getAttribute("width")
|
|
42
|
-
const height = el.getAttribute("height")
|
|
32
|
+
it("renders the correct icon path", async () => {
|
|
33
|
+
const el = await defaultFixture("angleDropup")
|
|
43
34
|
|
|
44
|
-
|
|
45
|
-
expect(
|
|
35
|
+
const path = el.shadowRoot.querySelector("path")
|
|
36
|
+
expect(path).to.have.attribute("d", "M7 14.5L12 9.5L17 14.5H7Z")
|
|
46
37
|
})
|
|
47
38
|
|
|
48
|
-
it("
|
|
49
|
-
const el = await defaultFixture(
|
|
50
|
-
|
|
51
|
-
const width = el.getAttribute("width")
|
|
52
|
-
const height = el.getAttribute("height")
|
|
53
|
-
|
|
54
|
-
expect(width).to.equal("16")
|
|
55
|
-
expect(height).to.equal("16")
|
|
56
|
-
})
|
|
39
|
+
it("renders a placeholder if the icon is not found", async () => {
|
|
40
|
+
const el = await defaultFixture("notExisting")
|
|
57
41
|
|
|
58
|
-
|
|
59
|
-
const el = await defaultFixture({ size: "564" })
|
|
42
|
+
const placeholder = el.shadowRoot.querySelector(".placeholder")
|
|
60
43
|
|
|
61
|
-
|
|
62
|
-
const height = el.getAttribute("height")
|
|
44
|
+
expect(placeholder).to.exist
|
|
63
45
|
|
|
64
|
-
|
|
46
|
+
const svg = el.shadowRoot.querySelector("svg")
|
|
47
|
+
expect(svg).not.to.exist
|
|
65
48
|
})
|
|
66
49
|
})
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import { html,
|
|
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
|
import { live } from "lit/directives/live.js"
|
|
5
5
|
import { createRef, ref } from "lit/directives/ref.js"
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { LeuElement } from "../../lib/LeuElement.js"
|
|
8
|
+
import { LeuIcon } from "../icon/Icon.js"
|
|
8
9
|
|
|
10
|
+
// @ts-ignore
|
|
9
11
|
import styles from "./input.css"
|
|
10
12
|
|
|
11
|
-
export const SIZE_TYPES = {
|
|
12
|
-
SMALL: "small",
|
|
13
|
-
REGULAR: "regular",
|
|
14
|
-
}
|
|
15
|
-
|
|
16
13
|
/**
|
|
17
14
|
* TODO:
|
|
18
15
|
* - Add section to docs about how to mark up suffix and prefix for screenreaders
|
|
@@ -63,14 +60,18 @@ const VALIDATION_MESSAGES = {
|
|
|
63
60
|
*
|
|
64
61
|
* @tagname leu-input
|
|
65
62
|
*/
|
|
66
|
-
export class LeuInput extends
|
|
63
|
+
export class LeuInput extends LeuElement {
|
|
64
|
+
static dependencies = {
|
|
65
|
+
"leu-icon": LeuIcon,
|
|
66
|
+
}
|
|
67
|
+
|
|
67
68
|
static styles = styles
|
|
68
69
|
|
|
69
70
|
/**
|
|
70
71
|
* @internal
|
|
71
72
|
*/
|
|
72
73
|
static shadowRootOptions = {
|
|
73
|
-
...
|
|
74
|
+
...LeuElement.shadowRootOptions,
|
|
74
75
|
delegatesFocus: true,
|
|
75
76
|
}
|
|
76
77
|
|
|
@@ -100,7 +101,6 @@ export class LeuInput extends LitElement {
|
|
|
100
101
|
novalidate: { type: Boolean, reflect: true },
|
|
101
102
|
step: { type: String, reflect: true },
|
|
102
103
|
|
|
103
|
-
/** @type {ValidityState} */
|
|
104
104
|
_validity: { state: true },
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -119,8 +119,8 @@ export class LeuInput extends LitElement {
|
|
|
119
119
|
this.required = false
|
|
120
120
|
this.clearable = false
|
|
121
121
|
|
|
122
|
-
/** @type {
|
|
123
|
-
this.size =
|
|
122
|
+
/** @type {"small" | "regular"} */
|
|
123
|
+
this.size = "regular"
|
|
124
124
|
|
|
125
125
|
this.type = "text"
|
|
126
126
|
this._validity = null
|
|
@@ -130,9 +130,6 @@ export class LeuInput extends LitElement {
|
|
|
130
130
|
/** @internal */
|
|
131
131
|
this._identifier = ""
|
|
132
132
|
|
|
133
|
-
/** @internal */
|
|
134
|
-
this._clearIcon = Icon("clear")
|
|
135
|
-
|
|
136
133
|
/**
|
|
137
134
|
* @internal
|
|
138
135
|
* @type {import("lit/directives/ref.js").Ref<HTMLInputElement>}
|
|
@@ -306,10 +303,7 @@ export class LeuInput extends LitElement {
|
|
|
306
303
|
|
|
307
304
|
/**
|
|
308
305
|
* Creates an error list with an item for the given validity state.
|
|
309
|
-
* @
|
|
310
|
-
* @param {Object} validationMessages
|
|
311
|
-
* @param {String} idRef
|
|
312
|
-
* @returns
|
|
306
|
+
* @returns {import("lit").TemplateResult | nothing}
|
|
313
307
|
*/
|
|
314
308
|
renderErrorMessages() {
|
|
315
309
|
if (!this.isInvalid()) {
|
|
@@ -341,11 +335,13 @@ export class LeuInput extends LitElement {
|
|
|
341
335
|
* This can be either an icon, a clear button or an error indicator icon.
|
|
342
336
|
*
|
|
343
337
|
* @private
|
|
344
|
-
* @returns {TemplateResult}
|
|
338
|
+
* @returns {import("lit").TemplateResult | nothing}
|
|
345
339
|
*/
|
|
346
340
|
renderAfterContent() {
|
|
347
341
|
if (this.isInvalid()) {
|
|
348
|
-
return html`<div class="error-icon"
|
|
342
|
+
return html`<div class="error-icon">
|
|
343
|
+
<leu-icon name="caution"></leu-icon>
|
|
344
|
+
</div>`
|
|
349
345
|
}
|
|
350
346
|
|
|
351
347
|
if (this.clearable && this.value) {
|
|
@@ -355,12 +351,14 @@ export class LeuInput extends LitElement {
|
|
|
355
351
|
aria-label="Eingabefeld zurücksetzen"
|
|
356
352
|
?disabled=${this.disabled}
|
|
357
353
|
>
|
|
358
|
-
|
|
354
|
+
<leu-icon name="clear"></leu-icon>
|
|
359
355
|
</button>`
|
|
360
356
|
}
|
|
361
357
|
|
|
362
358
|
if (this.icon) {
|
|
363
|
-
return html`<div class="icon"
|
|
359
|
+
return html`<div class="icon">
|
|
360
|
+
<leu-icon name=${this.icon}></leu-icon>
|
|
361
|
+
</div>`
|
|
364
362
|
}
|
|
365
363
|
|
|
366
364
|
return nothing
|
|
@@ -154,7 +154,9 @@
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
/* is size small AND has no focus AND is empty */
|
|
157
|
-
:host(:not(:focus-within)[size="small"])
|
|
157
|
+
:host(:not(:focus-within)[size="small"])
|
|
158
|
+
.input-wrapper--empty:not(.input-wrapper--invalid)
|
|
159
|
+
.label {
|
|
158
160
|
top: calc(0.75rem - var(--input-border-width));
|
|
159
161
|
opacity: 1;
|
|
160
162
|
visibility: visible;
|
|
@@ -229,6 +231,6 @@
|
|
|
229
231
|
color: var(--input-color-invalid);
|
|
230
232
|
}
|
|
231
233
|
|
|
232
|
-
:is(.icon, .error-icon)
|
|
234
|
+
:is(.icon, .error-icon) leu-icon {
|
|
233
235
|
display: block;
|
|
234
236
|
}
|
|
@@ -4,7 +4,7 @@ import { ifDefined } from "lit/directives/if-defined.js"
|
|
|
4
4
|
import "../leu-input.js"
|
|
5
5
|
|
|
6
6
|
import { SIZE_TYPES } from "../Input.js"
|
|
7
|
-
import {
|
|
7
|
+
import { paths as iconPaths } from "../../icon/paths.js"
|
|
8
8
|
|
|
9
9
|
export default {
|
|
10
10
|
title: "Input",
|
|
@@ -17,7 +17,7 @@ export default {
|
|
|
17
17
|
},
|
|
18
18
|
options: Object.values(SIZE_TYPES),
|
|
19
19
|
},
|
|
20
|
-
icon: { control: "select", options:
|
|
20
|
+
icon: { control: "select", options: Object.keys(iconPaths) },
|
|
21
21
|
},
|
|
22
22
|
parameters: {
|
|
23
23
|
design: {
|
|
@@ -1,12 +1,153 @@
|
|
|
1
|
-
import { html
|
|
1
|
+
import { html } from "lit"
|
|
2
|
+
|
|
3
|
+
import { LeuElement } from "../../lib/LeuElement.js"
|
|
4
|
+
|
|
5
|
+
import { LeuMenuItem } from "./MenuItem.js"
|
|
6
|
+
|
|
7
|
+
// @ts-ignore
|
|
2
8
|
import styles from "./menu.css"
|
|
3
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {'single' | 'multiple' | 'none'} SelectsType
|
|
12
|
+
*/
|
|
13
|
+
|
|
4
14
|
/**
|
|
5
15
|
* @tagname leu-menu
|
|
16
|
+
* @property {SelectsType} selects - This has only an effect when the role is 'menu'. It defines which role the menu items will get. Default is 'none'.
|
|
6
17
|
*/
|
|
7
|
-
export class LeuMenu extends
|
|
18
|
+
export class LeuMenu extends LeuElement {
|
|
8
19
|
static styles = styles
|
|
9
20
|
|
|
21
|
+
static shadowRootOptions = {
|
|
22
|
+
...LeuElement.shadowRootOptions,
|
|
23
|
+
delegatesFocus: true,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static properties = {
|
|
27
|
+
selects: { type: String, reflect: true },
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
constructor() {
|
|
31
|
+
super()
|
|
32
|
+
|
|
33
|
+
/** @type {SelectsType} */
|
|
34
|
+
this.selects = "none"
|
|
35
|
+
|
|
36
|
+
this.value = undefined
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
connectedCallback() {
|
|
40
|
+
super.connectedCallback()
|
|
41
|
+
|
|
42
|
+
if (!this.getAttribute("role")) {
|
|
43
|
+
this.setAttribute("role", "menu")
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this.addEventListener("keydown", this._handleKeyDown)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
disconnectedCallback() {
|
|
50
|
+
super.disconnectedCallback()
|
|
51
|
+
this.removeEventListener("keydown", this._handleKeyDown)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
_handleSlotChange() {
|
|
55
|
+
this.setCurrentItem(0)
|
|
56
|
+
this._setMenuItemRoles()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_setMenuItemRoles() {
|
|
60
|
+
const menuRole = this.getAttribute("role")
|
|
61
|
+
let menuItemRole
|
|
62
|
+
|
|
63
|
+
if (menuRole === "menu") {
|
|
64
|
+
if (this.selects === "multiple") {
|
|
65
|
+
menuItemRole = "menuitemcheckbox"
|
|
66
|
+
} else if (this.selects === "single") {
|
|
67
|
+
menuItemRole = "menuitemradio"
|
|
68
|
+
} else {
|
|
69
|
+
menuItemRole = "menuitem"
|
|
70
|
+
}
|
|
71
|
+
} else if (menuRole === "listbox") {
|
|
72
|
+
menuItemRole = "option"
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (menuItemRole) {
|
|
76
|
+
this.getMenuItems().forEach((menuItem) => {
|
|
77
|
+
menuItem.componentRole = menuItemRole // eslint-disable-line no-param-reassign
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
*
|
|
84
|
+
* @returns {import("./MenuItem").LeuMenuItem[]}
|
|
85
|
+
*/
|
|
86
|
+
getMenuItems() {
|
|
87
|
+
const slot = this.shadowRoot.querySelector("slot")
|
|
88
|
+
return slot
|
|
89
|
+
.assignedElements({ flatten: true })
|
|
90
|
+
.filter((el) => el instanceof LeuMenuItem)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
getVisibleMenuItems() {
|
|
94
|
+
return this.getMenuItems().filter((menuItem) => !menuItem.hidden)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
_handleKeyDown(event) {
|
|
98
|
+
if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) {
|
|
99
|
+
event.preventDefault()
|
|
100
|
+
|
|
101
|
+
const menuItems = this.getVisibleMenuItems()
|
|
102
|
+
let index = menuItems.findIndex((menuItem) => menuItem.tabbable)
|
|
103
|
+
|
|
104
|
+
if (event.key === "ArrowDown") {
|
|
105
|
+
index += 1
|
|
106
|
+
} else if (event.key === "ArrowUp") {
|
|
107
|
+
index -= 1
|
|
108
|
+
} else if (event.key === "Home") {
|
|
109
|
+
index = 0
|
|
110
|
+
} else if (event.key === "End") {
|
|
111
|
+
index = menuItems.length - 1
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
this.focusItem(index)
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
setCurrentItem(index) {
|
|
119
|
+
const menuItems = this.getVisibleMenuItems()
|
|
120
|
+
let currentItem = null
|
|
121
|
+
|
|
122
|
+
const currentItemIndex = (index + menuItems.length) % menuItems.length
|
|
123
|
+
|
|
124
|
+
menuItems.forEach((menuItem, i) => {
|
|
125
|
+
if (i === currentItemIndex) {
|
|
126
|
+
currentItem = menuItem
|
|
127
|
+
menuItem.tabbable = true // eslint-disable-line no-param-reassign
|
|
128
|
+
} else {
|
|
129
|
+
menuItem.tabbable = false // eslint-disable-line no-param-reassign
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
return currentItem
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
focusItem(index) {
|
|
137
|
+
const currentItem = this.setCurrentItem(index)
|
|
138
|
+
currentItem.focus()
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
firstUpdated() {
|
|
142
|
+
this.setCurrentItem(0)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
updated(changedProperties) {
|
|
146
|
+
if (changedProperties.has("selects")) {
|
|
147
|
+
this._setMenuItemRoles()
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
10
151
|
render() {
|
|
11
152
|
return html`<slot></slot>`
|
|
12
153
|
}
|