@statistikzh/leu 0.21.1 → 0.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/release-please.yml +1 -2
- package/.nvmrc +1 -1
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +16 -0
- package/README.md +15 -10
- package/dist/Accordion.js +1 -1
- package/dist/Button.d.ts +1 -1
- package/dist/Button.js +1 -1
- package/dist/ButtonGroup.js +1 -1
- package/dist/ChartWrapper.js +1 -1
- package/dist/Checkbox.d.ts +1 -1
- package/dist/Checkbox.js +1 -1
- package/dist/CheckboxGroup.js +1 -1
- package/dist/Chip.d.ts +1 -7
- package/dist/Chip.js +7 -5
- package/dist/ChipGroup.d.ts +17 -36
- package/dist/ChipGroup.js +35 -33
- package/dist/ChipLink.d.ts +5 -21
- package/dist/ChipLink.js +14 -15
- package/dist/ChipRemovable.d.ts +4 -15
- package/dist/ChipRemovable.js +7 -9
- package/dist/ChipSelectable.d.ts +14 -37
- package/dist/ChipSelectable.js +24 -28
- package/dist/Dialog.d.ts +7 -18
- package/dist/Dialog.js +15 -18
- package/dist/Dropdown.d.ts +16 -24
- package/dist/Dropdown.js +23 -21
- package/dist/FileInput.d.ts +2 -1
- package/dist/FileInput.js +19 -5
- package/dist/Icon.d-itcQ94ym.d.ts +151 -0
- package/dist/Icon.d.ts +4 -156
- package/dist/Icon.js +1 -4
- package/dist/Input.d.ts +73 -141
- package/dist/Input.js +91 -88
- package/dist/{LeuElement-BLUQU9Eu.js → LeuElement-DfsEye-A.js} +1 -1
- package/dist/Menu.d.ts +2 -8
- package/dist/Menu.js +7 -9
- package/dist/MenuItem.d.ts +31 -59
- package/dist/MenuItem.js +30 -33
- package/dist/Message.d.ts +1 -1
- package/dist/Message.js +1 -1
- package/dist/Pagination.d.ts +1 -1
- package/dist/Pagination.js +1 -1
- package/dist/Placeholder.js +1 -1
- package/dist/Popup.js +1 -1
- package/dist/ProgressBar.js +1 -1
- package/dist/Radio.js +1 -1
- package/dist/RadioGroup.js +1 -1
- package/dist/Range.d.ts +22 -65
- package/dist/Range.js +36 -37
- package/dist/ScrollTop.d.ts +5 -7
- package/dist/ScrollTop.js +10 -15
- package/dist/Select.d.ts +2 -1
- package/dist/Select.js +1 -1
- package/dist/Spinner.js +1 -1
- package/dist/Table.d.ts +1 -1
- package/dist/Table.js +1 -1
- package/dist/Tag.js +1 -1
- package/dist/VisuallyHidden.js +1 -1
- package/dist/components/chart-wrapper/leu-chart-wrapper.d.ts +5 -0
- package/dist/components/chart-wrapper/leu-chart-wrapper.d.ts.map +1 -1
- package/dist/components/chip/Chip.d.ts +1 -7
- package/dist/components/chip/Chip.d.ts.map +1 -1
- package/dist/components/chip/ChipGroup.d.ts +15 -35
- package/dist/components/chip/ChipGroup.d.ts.map +1 -1
- package/dist/components/chip/ChipLink.d.ts +4 -20
- package/dist/components/chip/ChipLink.d.ts.map +1 -1
- package/dist/components/chip/ChipRemovable.d.ts +3 -14
- package/dist/components/chip/ChipRemovable.d.ts.map +1 -1
- package/dist/components/chip/ChipSelectable.d.ts +13 -36
- package/dist/components/chip/ChipSelectable.d.ts.map +1 -1
- package/dist/components/chip/stories/chip-group.stories.d.ts +1 -1
- package/dist/components/chip/stories/chip-group.stories.d.ts.map +1 -1
- package/dist/components/chip/stories/chip-link.stories.d.ts.map +1 -1
- package/dist/components/chip/stories/chip-selectable.stories.d.ts.map +1 -1
- package/dist/components/dialog/Dialog.d.ts +5 -17
- package/dist/components/dialog/Dialog.d.ts.map +1 -1
- package/dist/components/dropdown/Dropdown.d.ts +14 -23
- package/dist/components/dropdown/Dropdown.d.ts.map +1 -1
- package/dist/components/dropdown/stories/dropdown.stories.d.ts.map +1 -1
- package/dist/components/file-input/FileInput.d.ts +1 -0
- package/dist/components/file-input/FileInput.d.ts.map +1 -1
- package/dist/components/file-input/leu-file-input.d.ts +5 -0
- package/dist/components/file-input/leu-file-input.d.ts.map +1 -1
- package/dist/components/file-input/stories/file-input.stories.d.ts +4 -0
- package/dist/components/file-input/stories/file-input.stories.d.ts.map +1 -1
- package/dist/components/icon/Icon.d.ts +0 -6
- package/dist/components/icon/Icon.d.ts.map +1 -1
- package/dist/components/input/Input.d.ts +73 -140
- package/dist/components/input/Input.d.ts.map +1 -1
- package/dist/components/menu/Menu.d.ts +1 -7
- package/dist/components/menu/Menu.d.ts.map +1 -1
- package/dist/components/menu/MenuItem.d.ts +30 -57
- package/dist/components/menu/MenuItem.d.ts.map +1 -1
- package/dist/components/message/leu-message.d.ts +5 -0
- package/dist/components/message/leu-message.d.ts.map +1 -1
- package/dist/components/placeholder/leu-placeholder.d.ts +5 -0
- package/dist/components/placeholder/leu-placeholder.d.ts.map +1 -1
- package/dist/components/progress-bar/leu-progress-bar.d.ts +5 -0
- package/dist/components/progress-bar/leu-progress-bar.d.ts.map +1 -1
- package/dist/components/range/Range.d.ts +22 -65
- package/dist/components/range/Range.d.ts.map +1 -1
- package/dist/components/scroll-top/ScrollTop.d.ts +4 -6
- package/dist/components/scroll-top/ScrollTop.d.ts.map +1 -1
- package/dist/components/tag/leu-tag.d.ts +5 -0
- package/dist/components/tag/leu-tag.d.ts.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -4
- package/dist/leu-accordion.js +1 -1
- package/dist/leu-button-group.js +1 -1
- package/dist/leu-button.d.ts +1 -1
- package/dist/leu-button.js +1 -1
- package/dist/leu-chart-wrapper.d.ts +10 -1
- package/dist/leu-chart-wrapper.js +1 -1
- package/dist/leu-checkbox-group.js +1 -1
- package/dist/leu-checkbox.d.ts +1 -1
- package/dist/leu-checkbox.js +1 -1
- package/dist/leu-chip-group.d.ts +2 -0
- package/dist/leu-chip-group.js +5 -1
- package/dist/leu-chip-link.js +3 -1
- package/dist/leu-chip-removable.d.ts +1 -1
- package/dist/leu-chip-removable.js +3 -3
- package/dist/leu-chip-selectable.js +3 -1
- package/dist/leu-dialog.d.ts +2 -1
- package/dist/leu-dialog.js +3 -3
- package/dist/leu-dropdown.d.ts +2 -1
- package/dist/leu-dropdown.js +3 -3
- package/dist/leu-file-input.d.ts +11 -2
- package/dist/leu-file-input.js +11 -4
- package/dist/leu-icon.d.ts +1 -1
- package/dist/leu-icon.js +1 -1
- package/dist/leu-input.d.ts +2 -1
- package/dist/leu-input.js +3 -3
- package/dist/leu-menu-item.d.ts +2 -2
- package/dist/leu-menu-item.js +3 -3
- package/dist/leu-menu.d.ts +1 -1
- package/dist/leu-menu.js +3 -3
- package/dist/leu-message.d.ts +11 -2
- package/dist/leu-message.js +1 -1
- package/dist/leu-pagination.d.ts +1 -1
- package/dist/leu-pagination.js +1 -1
- package/dist/leu-placeholder.d.ts +10 -1
- package/dist/leu-placeholder.js +1 -1
- package/dist/leu-popup.js +1 -1
- package/dist/leu-progress-bar.d.ts +10 -1
- package/dist/leu-progress-bar.js +1 -1
- package/dist/leu-radio-group.js +1 -1
- package/dist/leu-radio.js +1 -1
- package/dist/leu-range.js +3 -1
- package/dist/leu-scroll-top.d.ts +1 -1
- package/dist/leu-scroll-top.js +3 -3
- package/dist/leu-select.d.ts +2 -1
- package/dist/leu-select.js +1 -1
- package/dist/leu-spinner.js +1 -1
- package/dist/leu-table.d.ts +1 -1
- package/dist/leu-table.js +1 -1
- package/dist/leu-tag.d.ts +10 -1
- package/dist/leu-tag.js +1 -1
- package/dist/leu-visually-hidden.js +1 -1
- package/dist/vscode.html-custom-data.json +115 -111
- package/dist/vue/index.d.ts +116 -131
- package/dist/web-types.json +303 -303
- package/package.json +1 -1
- package/scripts/generate-component/templates/[namespace]-[name].ts +6 -0
- package/src/components/chart-wrapper/leu-chart-wrapper.ts +6 -0
- package/src/components/chip/Chip.ts +3 -9
- package/src/components/chip/ChipGroup.ts +26 -39
- package/src/components/chip/ChipLink.ts +7 -18
- package/src/components/chip/ChipRemovable.ts +4 -11
- package/src/components/chip/ChipSelectable.ts +21 -35
- package/src/components/chip/stories/chip-group.stories.ts +4 -7
- package/src/components/chip/stories/chip-link.stories.ts +2 -4
- package/src/components/chip/stories/chip-selectable.stories.ts +4 -6
- package/src/components/chip/test/chip-group.test.ts +34 -31
- package/src/components/dialog/Dialog.ts +9 -22
- package/src/components/dropdown/Dropdown.ts +20 -24
- package/src/components/dropdown/stories/dropdown.stories.ts +6 -2
- package/src/components/dropdown/test/dropdown.test.ts +14 -2
- package/src/components/file-input/FileInput.ts +12 -1
- package/src/components/file-input/leu-file-input.ts +6 -0
- package/src/components/file-input/stories/file-input.stories.ts +7 -0
- package/src/components/icon/Icon.ts +0 -4
- package/src/components/input/Input.ts +108 -105
- package/src/components/menu/Menu.ts +3 -12
- package/src/components/menu/MenuItem.ts +37 -41
- package/src/components/message/leu-message.ts +6 -0
- package/src/components/placeholder/leu-placeholder.ts +6 -0
- package/src/components/progress-bar/leu-progress-bar.ts +6 -0
- package/src/components/range/Range.ts +51 -59
- package/src/components/scroll-top/ScrollTop.ts +8 -15
- package/src/components/tag/leu-tag.ts +6 -0
- package/src/index.ts +11 -0
package/package.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { property } from "lit/decorators.js"
|
|
1
2
|
import { LeuElement } from "../../lib/LeuElement.js"
|
|
2
3
|
|
|
3
4
|
import styles from "./chip.css"
|
|
@@ -13,13 +14,6 @@ export class LeuChipBase extends LeuElement {
|
|
|
13
14
|
delegatesFocus: true,
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
constructor() {
|
|
21
|
-
super()
|
|
22
|
-
|
|
23
|
-
this.inverted = false
|
|
24
|
-
}
|
|
17
|
+
@property({ type: Boolean, reflect: true })
|
|
18
|
+
inverted: boolean = false
|
|
25
19
|
}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import { html, unsafeStatic } from "lit/static-html.js"
|
|
2
|
+
import { property } from "lit/decorators.js"
|
|
2
3
|
|
|
3
4
|
import { LeuElement } from "../../lib/LeuElement.js"
|
|
4
5
|
|
|
5
6
|
import styles from "./chip-group.css"
|
|
6
|
-
|
|
7
|
-
/* Figma https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=131766-248643&mode=design&t=Kjo5VDiqivihn8dh-11 */
|
|
8
|
-
|
|
9
|
-
export const SELECTION_MODES = Object.freeze({
|
|
10
|
-
single: "single",
|
|
11
|
-
multiple: "multiple",
|
|
12
|
-
none: "none",
|
|
13
|
-
})
|
|
7
|
+
import { LeuChipSelectable } from "./ChipSelectable.js"
|
|
14
8
|
|
|
15
9
|
/**
|
|
16
10
|
* @slot - Place leu-chip-* elements inside this slot
|
|
@@ -20,26 +14,19 @@ export const SELECTION_MODES = Object.freeze({
|
|
|
20
14
|
export class LeuChipGroup extends LeuElement {
|
|
21
15
|
static styles = [LeuElement.styles, styles]
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
selectionMode: { type: String, attribute: "selection-mode", reflect: true },
|
|
26
|
-
headingLevel: { type: Number, attribute: "heading-level", reflect: true },
|
|
27
|
-
label: { type: String, reflect: true },
|
|
28
|
-
}
|
|
17
|
+
@property({ type: Boolean, reflect: true })
|
|
18
|
+
inverted: boolean = false
|
|
29
19
|
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
@property({ type: String, attribute: "selection-mode", reflect: true })
|
|
21
|
+
selectionMode: "single" | "multiple" | "none" = "none"
|
|
32
22
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
this.label = ""
|
|
23
|
+
@property({ type: Number, attribute: "heading-level", reflect: true })
|
|
24
|
+
headingLevel: number = 2
|
|
36
25
|
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
@property({ type: String, reflect: true })
|
|
27
|
+
label: string = ""
|
|
39
28
|
|
|
40
|
-
|
|
41
|
-
this.selectionMode = SELECTION_MODES.none
|
|
42
|
-
}
|
|
29
|
+
protected selectableItems: Array<LeuChipSelectable> = []
|
|
43
30
|
|
|
44
31
|
connectedCallback() {
|
|
45
32
|
super.connectedCallback()
|
|
@@ -61,21 +48,22 @@ export class LeuChipGroup extends LeuElement {
|
|
|
61
48
|
}
|
|
62
49
|
|
|
63
50
|
get value() {
|
|
64
|
-
return this.
|
|
51
|
+
return this.selectableItems
|
|
52
|
+
.filter((i) => i.checked)
|
|
53
|
+
.map((i) => i.getValue())
|
|
65
54
|
}
|
|
66
55
|
|
|
67
56
|
/**
|
|
68
57
|
* Checks the items with the given values.
|
|
69
58
|
* If the selectionMode is single, only the first item with the given value is checked.
|
|
70
|
-
* @param {string[]} valueList
|
|
71
59
|
*/
|
|
72
|
-
set value(valueList) {
|
|
60
|
+
set value(valueList: string[]) {
|
|
73
61
|
let hasChanged = false
|
|
74
62
|
|
|
75
|
-
for (const item of this.
|
|
63
|
+
for (const item of this.selectableItems) {
|
|
76
64
|
item.checked = hasChanged ? false : valueList.includes(item.value)
|
|
77
65
|
|
|
78
|
-
if (this.selectionMode ===
|
|
66
|
+
if (this.selectionMode === "single" && item.checked) {
|
|
79
67
|
hasChanged = true
|
|
80
68
|
}
|
|
81
69
|
}
|
|
@@ -85,10 +73,9 @@ export class LeuChipGroup extends LeuElement {
|
|
|
85
73
|
* Determines the heading tag of the accordion toggle.
|
|
86
74
|
* The headingLevel shouldn't be used directly to render the heading tag
|
|
87
75
|
* in order to avoid XSS issues.
|
|
88
|
-
* @returns {String} The heading tag of the accordion toggle.
|
|
89
76
|
* @internal
|
|
90
77
|
*/
|
|
91
|
-
_getHeadingTag() {
|
|
78
|
+
protected _getHeadingTag() {
|
|
92
79
|
let level = 2
|
|
93
80
|
if (this.headingLevel > 0 && this.headingLevel < 7) {
|
|
94
81
|
level = this.headingLevel
|
|
@@ -97,21 +84,21 @@ export class LeuChipGroup extends LeuElement {
|
|
|
97
84
|
return `h${level}`
|
|
98
85
|
}
|
|
99
86
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
this.items.forEach((item) => {
|
|
87
|
+
protected handleInput = (e: Event & { target: LeuChipSelectable }) => {
|
|
88
|
+
if (this.selectionMode === "single") {
|
|
89
|
+
this.selectableItems.forEach((item) => {
|
|
104
90
|
item.checked = item === e.target // eslint-disable-line no-param-reassign
|
|
105
91
|
})
|
|
106
92
|
}
|
|
107
93
|
}
|
|
108
94
|
|
|
109
|
-
|
|
110
|
-
handleSlotChange = (e) => {
|
|
95
|
+
protected handleSlotChange = (e: Event & { target: HTMLSlotElement }) => {
|
|
111
96
|
const slot = e.target
|
|
112
|
-
const items = slot
|
|
97
|
+
const items = slot
|
|
98
|
+
.assignedElements({ flatten: true })
|
|
99
|
+
.filter((el) => el instanceof LeuChipSelectable)
|
|
113
100
|
|
|
114
|
-
this.
|
|
101
|
+
this.selectableItems = items
|
|
115
102
|
}
|
|
116
103
|
|
|
117
104
|
render() {
|
|
@@ -1,31 +1,20 @@
|
|
|
1
1
|
import { html } from "lit"
|
|
2
|
+
import { property } from "lit/decorators.js"
|
|
2
3
|
|
|
3
4
|
import { LeuChipBase } from "./Chip.js"
|
|
4
5
|
|
|
5
|
-
export const SIZES = {
|
|
6
|
-
regular: "regular",
|
|
7
|
-
large: "large",
|
|
8
|
-
}
|
|
9
|
-
|
|
10
6
|
/**
|
|
11
7
|
* @tagname leu-chip-link
|
|
12
8
|
* @slot - The content of the chip
|
|
13
|
-
* @prop {keyof typeof SIZES} size - The size of the chip
|
|
14
9
|
*/
|
|
15
10
|
export class LeuChipLink extends LeuChipBase {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
href: { type: String, reflect: true },
|
|
20
|
-
}
|
|
11
|
+
/** The size of the chip */
|
|
12
|
+
@property({ type: String, reflect: true })
|
|
13
|
+
size: "regular" | "large" = "regular"
|
|
21
14
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.inverted = false
|
|
26
|
-
this.size = SIZES.regular
|
|
27
|
-
this.href = ""
|
|
28
|
-
}
|
|
15
|
+
/** The URL that the chip links to */
|
|
16
|
+
@property({ type: String, reflect: true })
|
|
17
|
+
href: string = ""
|
|
29
18
|
|
|
30
19
|
render() {
|
|
31
20
|
return html`<a href=${this.href} class="button">
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { html } from "lit"
|
|
2
|
+
import { property } from "lit/decorators.js"
|
|
2
3
|
|
|
3
4
|
import { LeuChipBase } from "./Chip.js"
|
|
4
5
|
import { LeuIcon } from "../icon/Icon.js"
|
|
@@ -14,25 +15,17 @@ export class LeuChipRemovable extends LeuChipBase {
|
|
|
14
15
|
"leu-icon": LeuIcon,
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
value: { type: String, reflect: true },
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
constructor() {
|
|
23
|
-
super()
|
|
24
|
-
this.value = ""
|
|
25
|
-
}
|
|
18
|
+
@property({ type: String, reflect: true })
|
|
19
|
+
value: string = ""
|
|
26
20
|
|
|
27
21
|
/**
|
|
28
22
|
* Returns the value of the chip. If `value` is not set, it will return the text content
|
|
29
|
-
* @returns {string}
|
|
30
23
|
*/
|
|
31
24
|
getValue() {
|
|
32
25
|
return this.value || this.textContent.trim()
|
|
33
26
|
}
|
|
34
27
|
|
|
35
|
-
handleClick() {
|
|
28
|
+
protected handleClick() {
|
|
36
29
|
const customEvent = new CustomEvent("leu:remove", {
|
|
37
30
|
bubbles: true,
|
|
38
31
|
composed: true,
|
|
@@ -1,59 +1,45 @@
|
|
|
1
1
|
import { html } from "lit"
|
|
2
|
+
import { property } from "lit/decorators.js"
|
|
2
3
|
|
|
3
4
|
import { LeuChipBase } from "./Chip.js"
|
|
4
5
|
|
|
5
|
-
export const SIZES = {
|
|
6
|
-
small: "small",
|
|
7
|
-
regular: "regular",
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const VARIANTS = {
|
|
11
|
-
toggle: "toggle",
|
|
12
|
-
radio: "radio",
|
|
13
|
-
}
|
|
14
|
-
|
|
15
6
|
/**
|
|
16
7
|
* A chip component that can be selected.
|
|
17
8
|
* @tagname leu-chip-selectable
|
|
18
9
|
* @slot - The content of the chip
|
|
19
|
-
* @prop {keyof typeof SIZES} size - The size of the chip. Not supported for radio variant.
|
|
20
|
-
* @prop {keyof typeof VARIANTS} variant - `toggle` or `radio`. Determines if only one or multiple chips can be selected.
|
|
21
|
-
* @prop {boolean} checked - Whether the chip is selected.
|
|
22
|
-
* @prop {string} value - The value of the chip.
|
|
23
10
|
*/
|
|
24
11
|
export class LeuChipSelectable extends LeuChipBase {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
variant: { type: String, reflect: true },
|
|
12
|
+
/** The size of the chip. Has no effect when variant is "radio" */
|
|
13
|
+
@property({ type: String, reflect: true })
|
|
14
|
+
size: "small" | "regular" = "regular"
|
|
29
15
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
16
|
+
/**
|
|
17
|
+
* The variant of the chip. Determines if only one or multiple chips can be selected.
|
|
18
|
+
* @default "toggle"
|
|
19
|
+
*/
|
|
20
|
+
@property({ type: String, reflect: true })
|
|
21
|
+
variant: "toggle" | "radio" = "toggle"
|
|
22
|
+
|
|
23
|
+
/** Whether the chip is selected */
|
|
24
|
+
@property({ type: Boolean, reflect: true })
|
|
25
|
+
checked: boolean = false
|
|
26
|
+
|
|
27
|
+
/** The value of the chip */
|
|
28
|
+
@property({ type: String, reflect: true })
|
|
29
|
+
value: string = ""
|
|
33
30
|
|
|
34
31
|
constructor() {
|
|
35
32
|
super()
|
|
36
|
-
this.size = SIZES.regular
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* The variant of the chip. Has an effect not only on the visual appearance but also on the behavior.
|
|
40
|
-
* - `toggle`: The chip behaves like a toggle button.
|
|
41
|
-
* - `radio`: The chip behaves like a radio button.
|
|
42
|
-
* @default "toggle"
|
|
43
|
-
*/
|
|
44
|
-
this.variant = VARIANTS.toggle
|
|
45
|
-
this.checked = false
|
|
46
|
-
this.value = ""
|
|
47
33
|
|
|
48
|
-
if (this.variant ===
|
|
34
|
+
if (this.variant === "radio" && this.size === "small") {
|
|
49
35
|
console.warn("Small size has no effect on radio variant")
|
|
50
36
|
}
|
|
51
37
|
}
|
|
52
38
|
|
|
53
|
-
handleClick() {
|
|
39
|
+
protected handleClick() {
|
|
54
40
|
let nextcheckedState = this.checked
|
|
55
41
|
|
|
56
|
-
if (this.variant ===
|
|
42
|
+
if (this.variant === "radio") {
|
|
57
43
|
nextcheckedState = true
|
|
58
44
|
} else {
|
|
59
45
|
nextcheckedState = !this.checked
|
|
@@ -7,16 +7,13 @@ import "../leu-chip-removable.js"
|
|
|
7
7
|
import "../leu-chip-link.js"
|
|
8
8
|
import "../leu-chip-group.js"
|
|
9
9
|
|
|
10
|
-
import { SELECTION_MODES } from "../ChipGroup.js"
|
|
11
|
-
import { VARIANTS as SELECTABLE_VARIANTS } from "../ChipSelectable.js"
|
|
12
|
-
|
|
13
10
|
export default {
|
|
14
11
|
title: "Components/Chip/Group",
|
|
15
12
|
component: "leu-chip-group",
|
|
16
13
|
argTypes: {
|
|
17
14
|
selectionMode: {
|
|
18
15
|
control: "select",
|
|
19
|
-
options:
|
|
16
|
+
options: ["single", "multiple", "none"],
|
|
20
17
|
},
|
|
21
18
|
headingLevel: {
|
|
22
19
|
control: "select",
|
|
@@ -111,7 +108,7 @@ function SingleTemplate(args) {
|
|
|
111
108
|
(chip) => html`
|
|
112
109
|
<leu-chip-selectable
|
|
113
110
|
?inverted=${args.inverted}
|
|
114
|
-
variant
|
|
111
|
+
variant="radio"
|
|
115
112
|
value="chip-${chip}"
|
|
116
113
|
>
|
|
117
114
|
${chip}
|
|
@@ -153,10 +150,10 @@ export const Default = DefaultTemplate.bind({})
|
|
|
153
150
|
Default.args = {}
|
|
154
151
|
|
|
155
152
|
export const Single = SingleTemplate.bind({})
|
|
156
|
-
Single.args = { selectionMode:
|
|
153
|
+
Single.args = { selectionMode: "single" }
|
|
157
154
|
|
|
158
155
|
export const Multiple = MultipleTemplate.bind({})
|
|
159
|
-
Multiple.args = { selectionMode:
|
|
156
|
+
Multiple.args = { selectionMode: "multiple" }
|
|
160
157
|
|
|
161
158
|
export const Labeled = LabeledTemplate.bind({})
|
|
162
159
|
Labeled.args = { label: "Top Themen" }
|
|
@@ -3,13 +3,11 @@ import { ifDefined } from "lit/directives/if-defined.js"
|
|
|
3
3
|
|
|
4
4
|
import "../leu-chip-link.js"
|
|
5
5
|
|
|
6
|
-
import { SIZES } from "../ChipLink.js"
|
|
7
|
-
|
|
8
6
|
export default {
|
|
9
7
|
title: "Components/Chip/Link",
|
|
10
8
|
component: "leu-chip-link",
|
|
11
9
|
argTypes: {
|
|
12
|
-
size: { control: "select", options:
|
|
10
|
+
size: { control: "select", options: ["regular", "large"] },
|
|
13
11
|
},
|
|
14
12
|
args: {
|
|
15
13
|
label: "Publikationen",
|
|
@@ -44,4 +42,4 @@ export const Default = Template.bind({})
|
|
|
44
42
|
Default.args = {}
|
|
45
43
|
|
|
46
44
|
export const Large = Template.bind({})
|
|
47
|
-
Large.args = { size:
|
|
45
|
+
Large.args = { size: "large" }
|
|
@@ -3,14 +3,12 @@ import { ifDefined } from "lit/directives/if-defined.js"
|
|
|
3
3
|
|
|
4
4
|
import "../leu-chip-selectable.js"
|
|
5
5
|
|
|
6
|
-
import { SIZES, VARIANTS } from "../ChipSelectable.js"
|
|
7
|
-
|
|
8
6
|
export default {
|
|
9
7
|
title: "Components/Chip/Selectable",
|
|
10
8
|
component: "leu-chip-selectable",
|
|
11
9
|
argTypes: {
|
|
12
|
-
variant: { control: "select", options:
|
|
13
|
-
size: { control: "select", options:
|
|
10
|
+
variant: { control: "select", options: ["toggle", "radio"] },
|
|
11
|
+
size: { control: "select", options: ["small", "regular"] },
|
|
14
12
|
label: { control: "text" },
|
|
15
13
|
},
|
|
16
14
|
args: {
|
|
@@ -50,7 +48,7 @@ export const Default = Template.bind({})
|
|
|
50
48
|
Default.args = {}
|
|
51
49
|
|
|
52
50
|
export const Small = Template.bind({})
|
|
53
|
-
Small.args = { size:
|
|
51
|
+
Small.args = { size: "small", label: "Publikationen Region" }
|
|
54
52
|
|
|
55
53
|
export const Radio = Template.bind({})
|
|
56
|
-
Radio.args = { variant:
|
|
54
|
+
Radio.args = { variant: "radio" }
|
|
@@ -4,6 +4,7 @@ import { fixture, expect, oneEvent } from "@open-wc/testing"
|
|
|
4
4
|
import "../leu-chip-selectable.js"
|
|
5
5
|
import "../leu-chip-removable.js"
|
|
6
6
|
import "../leu-chip-group.js"
|
|
7
|
+
import type { LeuChipGroup } from "../leu-chip-group.js"
|
|
7
8
|
|
|
8
9
|
async function removableFixture() {
|
|
9
10
|
return fixture(html`
|
|
@@ -16,7 +17,7 @@ async function removableFixture() {
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
async function singleSelectionFixture() {
|
|
19
|
-
return fixture(html`
|
|
20
|
+
return fixture<LeuChipGroup>(html`
|
|
20
21
|
<leu-chip-group selection-mode="single">
|
|
21
22
|
<leu-chip-selectable value="1" variant="radio"
|
|
22
23
|
>Publikationen</leu-chip-selectable
|
|
@@ -30,7 +31,7 @@ async function singleSelectionFixture() {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
async function multipleSelectionFixture() {
|
|
33
|
-
return fixture(html`
|
|
34
|
+
return fixture<LeuChipGroup>(html`
|
|
34
35
|
<leu-chip-group selection-mode="multiple">
|
|
35
36
|
<leu-chip-selectable value="1">Publikationen</leu-chip-selectable>
|
|
36
37
|
<leu-chip-selectable value="2">Daten</leu-chip-selectable>
|
|
@@ -101,68 +102,70 @@ describe("LeuChipGroup", () => {
|
|
|
101
102
|
|
|
102
103
|
it("checks only chip when the value of the group is set (selection-mode=single)", async () => {
|
|
103
104
|
const el = await singleSelectionFixture()
|
|
105
|
+
const items = el.querySelectorAll("leu-chip-selectable")
|
|
104
106
|
|
|
105
|
-
expect(
|
|
106
|
-
expect(
|
|
107
|
-
expect(
|
|
107
|
+
expect(items[0].checked).to.be.false
|
|
108
|
+
expect(items[1].checked).to.be.false
|
|
109
|
+
expect(items[2].checked).to.be.false
|
|
108
110
|
|
|
109
111
|
el.value = ["2"]
|
|
110
112
|
|
|
111
|
-
expect(
|
|
112
|
-
expect(
|
|
113
|
-
expect(
|
|
113
|
+
expect(items[0].checked).to.be.false
|
|
114
|
+
expect(items[1].checked).to.be.true
|
|
115
|
+
expect(items[2].checked).to.be.false
|
|
114
116
|
|
|
115
117
|
// Should check the first item with the given value and not first item of the value list
|
|
116
118
|
el.value = ["2", "1"]
|
|
117
119
|
|
|
118
|
-
expect(
|
|
119
|
-
expect(
|
|
120
|
+
expect(items[0].checked).to.be.true
|
|
121
|
+
expect(items[1].checked).to.be.false
|
|
120
122
|
|
|
121
123
|
el.value = []
|
|
122
124
|
|
|
123
|
-
expect(
|
|
124
|
-
expect(
|
|
125
|
-
expect(
|
|
125
|
+
expect(items[0].checked).to.be.false
|
|
126
|
+
expect(items[1].checked).to.be.false
|
|
127
|
+
expect(items[2].checked).to.be.false
|
|
126
128
|
|
|
127
129
|
el.value = ["asdf"]
|
|
128
130
|
|
|
129
|
-
expect(
|
|
130
|
-
expect(
|
|
131
|
-
expect(
|
|
131
|
+
expect(items[0].checked).to.be.false
|
|
132
|
+
expect(items[1].checked).to.be.false
|
|
133
|
+
expect(items[2].checked).to.be.false
|
|
132
134
|
expect(el.value).to.deep.equal([])
|
|
133
135
|
})
|
|
134
136
|
|
|
135
137
|
it("checks chips when the value of the group is set (selection-mode=multiple)", async () => {
|
|
136
138
|
const el = await multipleSelectionFixture()
|
|
139
|
+
const items = el.querySelectorAll("leu-chip-selectable")
|
|
137
140
|
|
|
138
|
-
expect(
|
|
139
|
-
expect(
|
|
140
|
-
expect(
|
|
141
|
+
expect(items[0].checked).to.be.false
|
|
142
|
+
expect(items[1].checked).to.be.false
|
|
143
|
+
expect(items[2].checked).to.be.false
|
|
141
144
|
|
|
142
145
|
el.value = ["2"]
|
|
143
146
|
|
|
144
|
-
expect(
|
|
145
|
-
expect(
|
|
146
|
-
expect(
|
|
147
|
+
expect(items[0].checked).to.be.false
|
|
148
|
+
expect(items[1].checked).to.be.true
|
|
149
|
+
expect(items[2].checked).to.be.false
|
|
147
150
|
|
|
148
151
|
// Should check the first item with the given value and not first item of the value list
|
|
149
152
|
el.value = ["2", "1"]
|
|
150
153
|
|
|
151
|
-
expect(
|
|
152
|
-
expect(
|
|
153
|
-
expect(
|
|
154
|
+
expect(items[0].checked).to.be.true
|
|
155
|
+
expect(items[1].checked).to.be.true
|
|
156
|
+
expect(items[2].checked).to.be.false
|
|
154
157
|
|
|
155
158
|
el.value = []
|
|
156
159
|
|
|
157
|
-
expect(
|
|
158
|
-
expect(
|
|
159
|
-
expect(
|
|
160
|
+
expect(items[0].checked).to.be.false
|
|
161
|
+
expect(items[1].checked).to.be.false
|
|
162
|
+
expect(items[2].checked).to.be.false
|
|
160
163
|
|
|
161
164
|
el.value = ["asdf"]
|
|
162
165
|
|
|
163
|
-
expect(
|
|
164
|
-
expect(
|
|
165
|
-
expect(
|
|
166
|
+
expect(items[0].checked).to.be.false
|
|
167
|
+
expect(items[1].checked).to.be.false
|
|
168
|
+
expect(items[2].checked).to.be.false
|
|
166
169
|
expect(el.value).to.deep.equal([])
|
|
167
170
|
})
|
|
168
171
|
})
|
|
@@ -1,13 +1,12 @@
|
|
|
1
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
|
+
import { property } from "lit/decorators.js"
|
|
4
5
|
|
|
5
6
|
import { LeuElement } from "../../lib/LeuElement.js"
|
|
6
7
|
import { HasSlotController } from "../../lib/hasSlotController.js"
|
|
7
8
|
import { LeuIcon } from "../icon/Icon.js"
|
|
8
9
|
|
|
9
|
-
// design: https://www.figma.com/design/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?node-id=21161-186812&node-type=FRAME
|
|
10
|
-
|
|
11
10
|
import styles from "./dialog.css"
|
|
12
11
|
|
|
13
12
|
/**
|
|
@@ -25,30 +24,18 @@ export class LeuDialog extends LeuElement {
|
|
|
25
24
|
delegatesFocus: true,
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*/
|
|
31
|
-
hasSlotController = new HasSlotController(this, ["toolbar"])
|
|
27
|
+
@property({ type: String })
|
|
28
|
+
label: string = ""
|
|
32
29
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
sublabel: { type: String },
|
|
36
|
-
open: { type: Boolean, open: true },
|
|
37
|
-
}
|
|
30
|
+
@property({ type: String })
|
|
31
|
+
sublabel: string = ""
|
|
38
32
|
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
@property({ type: Boolean, reflect: true })
|
|
34
|
+
open: boolean = false
|
|
41
35
|
|
|
42
|
-
|
|
43
|
-
this._dialogRef = createRef()
|
|
36
|
+
protected _dialogRef = createRef<HTMLDialogElement>()
|
|
44
37
|
|
|
45
|
-
|
|
46
|
-
this.label = ""
|
|
47
|
-
/** @type {string} */
|
|
48
|
-
this.sublabel = ""
|
|
49
|
-
/** @type {boolean} */
|
|
50
|
-
this.open = false
|
|
51
|
-
}
|
|
38
|
+
protected hasSlotController = new HasSlotController(this, ["toolbar"])
|
|
52
39
|
|
|
53
40
|
show() {
|
|
54
41
|
this._dialogRef.value.showModal()
|