@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.
Files changed (193) hide show
  1. package/.github/workflows/release-please.yml +1 -2
  2. package/.nvmrc +1 -1
  3. package/.release-please-manifest.json +1 -1
  4. package/CHANGELOG.md +16 -0
  5. package/README.md +15 -10
  6. package/dist/Accordion.js +1 -1
  7. package/dist/Button.d.ts +1 -1
  8. package/dist/Button.js +1 -1
  9. package/dist/ButtonGroup.js +1 -1
  10. package/dist/ChartWrapper.js +1 -1
  11. package/dist/Checkbox.d.ts +1 -1
  12. package/dist/Checkbox.js +1 -1
  13. package/dist/CheckboxGroup.js +1 -1
  14. package/dist/Chip.d.ts +1 -7
  15. package/dist/Chip.js +7 -5
  16. package/dist/ChipGroup.d.ts +17 -36
  17. package/dist/ChipGroup.js +35 -33
  18. package/dist/ChipLink.d.ts +5 -21
  19. package/dist/ChipLink.js +14 -15
  20. package/dist/ChipRemovable.d.ts +4 -15
  21. package/dist/ChipRemovable.js +7 -9
  22. package/dist/ChipSelectable.d.ts +14 -37
  23. package/dist/ChipSelectable.js +24 -28
  24. package/dist/Dialog.d.ts +7 -18
  25. package/dist/Dialog.js +15 -18
  26. package/dist/Dropdown.d.ts +16 -24
  27. package/dist/Dropdown.js +23 -21
  28. package/dist/FileInput.d.ts +2 -1
  29. package/dist/FileInput.js +19 -5
  30. package/dist/Icon.d-itcQ94ym.d.ts +151 -0
  31. package/dist/Icon.d.ts +4 -156
  32. package/dist/Icon.js +1 -4
  33. package/dist/Input.d.ts +73 -141
  34. package/dist/Input.js +91 -88
  35. package/dist/{LeuElement-BLUQU9Eu.js → LeuElement-DfsEye-A.js} +1 -1
  36. package/dist/Menu.d.ts +2 -8
  37. package/dist/Menu.js +7 -9
  38. package/dist/MenuItem.d.ts +31 -59
  39. package/dist/MenuItem.js +30 -33
  40. package/dist/Message.d.ts +1 -1
  41. package/dist/Message.js +1 -1
  42. package/dist/Pagination.d.ts +1 -1
  43. package/dist/Pagination.js +1 -1
  44. package/dist/Placeholder.js +1 -1
  45. package/dist/Popup.js +1 -1
  46. package/dist/ProgressBar.js +1 -1
  47. package/dist/Radio.js +1 -1
  48. package/dist/RadioGroup.js +1 -1
  49. package/dist/Range.d.ts +22 -65
  50. package/dist/Range.js +36 -37
  51. package/dist/ScrollTop.d.ts +5 -7
  52. package/dist/ScrollTop.js +10 -15
  53. package/dist/Select.d.ts +2 -1
  54. package/dist/Select.js +1 -1
  55. package/dist/Spinner.js +1 -1
  56. package/dist/Table.d.ts +1 -1
  57. package/dist/Table.js +1 -1
  58. package/dist/Tag.js +1 -1
  59. package/dist/VisuallyHidden.js +1 -1
  60. package/dist/components/chart-wrapper/leu-chart-wrapper.d.ts +5 -0
  61. package/dist/components/chart-wrapper/leu-chart-wrapper.d.ts.map +1 -1
  62. package/dist/components/chip/Chip.d.ts +1 -7
  63. package/dist/components/chip/Chip.d.ts.map +1 -1
  64. package/dist/components/chip/ChipGroup.d.ts +15 -35
  65. package/dist/components/chip/ChipGroup.d.ts.map +1 -1
  66. package/dist/components/chip/ChipLink.d.ts +4 -20
  67. package/dist/components/chip/ChipLink.d.ts.map +1 -1
  68. package/dist/components/chip/ChipRemovable.d.ts +3 -14
  69. package/dist/components/chip/ChipRemovable.d.ts.map +1 -1
  70. package/dist/components/chip/ChipSelectable.d.ts +13 -36
  71. package/dist/components/chip/ChipSelectable.d.ts.map +1 -1
  72. package/dist/components/chip/stories/chip-group.stories.d.ts +1 -1
  73. package/dist/components/chip/stories/chip-group.stories.d.ts.map +1 -1
  74. package/dist/components/chip/stories/chip-link.stories.d.ts.map +1 -1
  75. package/dist/components/chip/stories/chip-selectable.stories.d.ts.map +1 -1
  76. package/dist/components/dialog/Dialog.d.ts +5 -17
  77. package/dist/components/dialog/Dialog.d.ts.map +1 -1
  78. package/dist/components/dropdown/Dropdown.d.ts +14 -23
  79. package/dist/components/dropdown/Dropdown.d.ts.map +1 -1
  80. package/dist/components/dropdown/stories/dropdown.stories.d.ts.map +1 -1
  81. package/dist/components/file-input/FileInput.d.ts +1 -0
  82. package/dist/components/file-input/FileInput.d.ts.map +1 -1
  83. package/dist/components/file-input/leu-file-input.d.ts +5 -0
  84. package/dist/components/file-input/leu-file-input.d.ts.map +1 -1
  85. package/dist/components/file-input/stories/file-input.stories.d.ts +4 -0
  86. package/dist/components/file-input/stories/file-input.stories.d.ts.map +1 -1
  87. package/dist/components/icon/Icon.d.ts +0 -6
  88. package/dist/components/icon/Icon.d.ts.map +1 -1
  89. package/dist/components/input/Input.d.ts +73 -140
  90. package/dist/components/input/Input.d.ts.map +1 -1
  91. package/dist/components/menu/Menu.d.ts +1 -7
  92. package/dist/components/menu/Menu.d.ts.map +1 -1
  93. package/dist/components/menu/MenuItem.d.ts +30 -57
  94. package/dist/components/menu/MenuItem.d.ts.map +1 -1
  95. package/dist/components/message/leu-message.d.ts +5 -0
  96. package/dist/components/message/leu-message.d.ts.map +1 -1
  97. package/dist/components/placeholder/leu-placeholder.d.ts +5 -0
  98. package/dist/components/placeholder/leu-placeholder.d.ts.map +1 -1
  99. package/dist/components/progress-bar/leu-progress-bar.d.ts +5 -0
  100. package/dist/components/progress-bar/leu-progress-bar.d.ts.map +1 -1
  101. package/dist/components/range/Range.d.ts +22 -65
  102. package/dist/components/range/Range.d.ts.map +1 -1
  103. package/dist/components/scroll-top/ScrollTop.d.ts +4 -6
  104. package/dist/components/scroll-top/ScrollTop.d.ts.map +1 -1
  105. package/dist/components/tag/leu-tag.d.ts +5 -0
  106. package/dist/components/tag/leu-tag.d.ts.map +1 -1
  107. package/dist/index.d.ts +11 -0
  108. package/dist/index.d.ts.map +1 -1
  109. package/dist/index.js +13 -4
  110. package/dist/leu-accordion.js +1 -1
  111. package/dist/leu-button-group.js +1 -1
  112. package/dist/leu-button.d.ts +1 -1
  113. package/dist/leu-button.js +1 -1
  114. package/dist/leu-chart-wrapper.d.ts +10 -1
  115. package/dist/leu-chart-wrapper.js +1 -1
  116. package/dist/leu-checkbox-group.js +1 -1
  117. package/dist/leu-checkbox.d.ts +1 -1
  118. package/dist/leu-checkbox.js +1 -1
  119. package/dist/leu-chip-group.d.ts +2 -0
  120. package/dist/leu-chip-group.js +5 -1
  121. package/dist/leu-chip-link.js +3 -1
  122. package/dist/leu-chip-removable.d.ts +1 -1
  123. package/dist/leu-chip-removable.js +3 -3
  124. package/dist/leu-chip-selectable.js +3 -1
  125. package/dist/leu-dialog.d.ts +2 -1
  126. package/dist/leu-dialog.js +3 -3
  127. package/dist/leu-dropdown.d.ts +2 -1
  128. package/dist/leu-dropdown.js +3 -3
  129. package/dist/leu-file-input.d.ts +11 -2
  130. package/dist/leu-file-input.js +11 -4
  131. package/dist/leu-icon.d.ts +1 -1
  132. package/dist/leu-icon.js +1 -1
  133. package/dist/leu-input.d.ts +2 -1
  134. package/dist/leu-input.js +3 -3
  135. package/dist/leu-menu-item.d.ts +2 -2
  136. package/dist/leu-menu-item.js +3 -3
  137. package/dist/leu-menu.d.ts +1 -1
  138. package/dist/leu-menu.js +3 -3
  139. package/dist/leu-message.d.ts +11 -2
  140. package/dist/leu-message.js +1 -1
  141. package/dist/leu-pagination.d.ts +1 -1
  142. package/dist/leu-pagination.js +1 -1
  143. package/dist/leu-placeholder.d.ts +10 -1
  144. package/dist/leu-placeholder.js +1 -1
  145. package/dist/leu-popup.js +1 -1
  146. package/dist/leu-progress-bar.d.ts +10 -1
  147. package/dist/leu-progress-bar.js +1 -1
  148. package/dist/leu-radio-group.js +1 -1
  149. package/dist/leu-radio.js +1 -1
  150. package/dist/leu-range.js +3 -1
  151. package/dist/leu-scroll-top.d.ts +1 -1
  152. package/dist/leu-scroll-top.js +3 -3
  153. package/dist/leu-select.d.ts +2 -1
  154. package/dist/leu-select.js +1 -1
  155. package/dist/leu-spinner.js +1 -1
  156. package/dist/leu-table.d.ts +1 -1
  157. package/dist/leu-table.js +1 -1
  158. package/dist/leu-tag.d.ts +10 -1
  159. package/dist/leu-tag.js +1 -1
  160. package/dist/leu-visually-hidden.js +1 -1
  161. package/dist/vscode.html-custom-data.json +115 -111
  162. package/dist/vue/index.d.ts +116 -131
  163. package/dist/web-types.json +303 -303
  164. package/package.json +1 -1
  165. package/scripts/generate-component/templates/[namespace]-[name].ts +6 -0
  166. package/src/components/chart-wrapper/leu-chart-wrapper.ts +6 -0
  167. package/src/components/chip/Chip.ts +3 -9
  168. package/src/components/chip/ChipGroup.ts +26 -39
  169. package/src/components/chip/ChipLink.ts +7 -18
  170. package/src/components/chip/ChipRemovable.ts +4 -11
  171. package/src/components/chip/ChipSelectable.ts +21 -35
  172. package/src/components/chip/stories/chip-group.stories.ts +4 -7
  173. package/src/components/chip/stories/chip-link.stories.ts +2 -4
  174. package/src/components/chip/stories/chip-selectable.stories.ts +4 -6
  175. package/src/components/chip/test/chip-group.test.ts +34 -31
  176. package/src/components/dialog/Dialog.ts +9 -22
  177. package/src/components/dropdown/Dropdown.ts +20 -24
  178. package/src/components/dropdown/stories/dropdown.stories.ts +6 -2
  179. package/src/components/dropdown/test/dropdown.test.ts +14 -2
  180. package/src/components/file-input/FileInput.ts +12 -1
  181. package/src/components/file-input/leu-file-input.ts +6 -0
  182. package/src/components/file-input/stories/file-input.stories.ts +7 -0
  183. package/src/components/icon/Icon.ts +0 -4
  184. package/src/components/input/Input.ts +108 -105
  185. package/src/components/menu/Menu.ts +3 -12
  186. package/src/components/menu/MenuItem.ts +37 -41
  187. package/src/components/message/leu-message.ts +6 -0
  188. package/src/components/placeholder/leu-placeholder.ts +6 -0
  189. package/src/components/progress-bar/leu-progress-bar.ts +6 -0
  190. package/src/components/range/Range.ts +51 -59
  191. package/src/components/scroll-top/ScrollTop.ts +8 -15
  192. package/src/components/tag/leu-tag.ts +6 -0
  193. package/src/index.ts +11 -0
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.21.1",
6
+ "version": "0.22.1",
7
7
  "type": "module",
8
8
  "main": "dist/index.js",
9
9
  "module": "dist/index.js",
@@ -3,3 +3,9 @@ import { [Namespace][Name] } from "./[Name].js"
3
3
  export { [Namespace][Name] }
4
4
 
5
5
  [Namespace][Name].define("[namespace]-[name]")
6
+
7
+ declare global {
8
+ interface HTMLElementTagNameMap {
9
+ "[namespace]-[name]": [Namespace][Name]
10
+ }
11
+ }
@@ -3,3 +3,9 @@ import { LeuChartWrapper } from "./ChartWrapper.js"
3
3
  export { LeuChartWrapper }
4
4
 
5
5
  LeuChartWrapper.define("leu-chart-wrapper")
6
+
7
+ declare global {
8
+ interface HTMLElementTagNameMap {
9
+ "leu-chart-wrapper": LeuChartWrapper
10
+ }
11
+ }
@@ -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
- static properties = {
17
- inverted: { type: Boolean, reflect: true },
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
- static properties = {
24
- inverted: { type: Boolean, reflect: true },
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
- constructor() {
31
- super()
20
+ @property({ type: String, attribute: "selection-mode", reflect: true })
21
+ selectionMode: "single" | "multiple" | "none" = "none"
32
22
 
33
- this.inverted = false
34
- this.headingLevel = 2
35
- this.label = ""
23
+ @property({ type: Number, attribute: "heading-level", reflect: true })
24
+ headingLevel: number = 2
36
25
 
37
- /** @internal */
38
- this.items = []
26
+ @property({ type: String, reflect: true })
27
+ label: string = ""
39
28
 
40
- /** @type {"single" | "multiple" | "none"} */
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.items.filter((i) => i.checked).map((i) => i.getValue())
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.items) {
63
+ for (const item of this.selectableItems) {
76
64
  item.checked = hasChanged ? false : valueList.includes(item.value)
77
65
 
78
- if (this.selectionMode === SELECTION_MODES.single && item.checked) {
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
- /** @internal */
101
- handleInput = (e) => {
102
- if (this.selectionMode === SELECTION_MODES.single) {
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
- /** @internal */
110
- handleSlotChange = (e) => {
95
+ protected handleSlotChange = (e: Event & { target: HTMLSlotElement }) => {
111
96
  const slot = e.target
112
- const items = slot.assignedElements({ flatten: true })
97
+ const items = slot
98
+ .assignedElements({ flatten: true })
99
+ .filter((el) => el instanceof LeuChipSelectable)
113
100
 
114
- this.items = items
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
- static properties = {
17
- ...LeuChipBase.properties,
18
- size: { type: String, reflect: true },
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
- constructor() {
23
- super()
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
- static properties = {
18
- ...LeuChipBase.properties,
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
- static properties = {
26
- ...LeuChipBase.properties,
27
- size: { type: String, reflect: true },
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
- checked: { type: Boolean, reflect: true },
31
- value: { type: String, reflect: true },
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 === VARIANTS.radio && this.size === SIZES.small) {
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 === VARIANTS.radio) {
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: Object.values(SELECTION_MODES),
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=${SELECTABLE_VARIANTS.radio}
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: SELECTION_MODES.single }
153
+ Single.args = { selectionMode: "single" }
157
154
 
158
155
  export const Multiple = MultipleTemplate.bind({})
159
- Multiple.args = { selectionMode: SELECTION_MODES.multiple }
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: Object.values(SIZES) },
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: SIZES.large }
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: Object.values(VARIANTS) },
13
- size: { control: "select", options: Object.values(SIZES) },
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: SIZES.small, label: "Publikationen Region" }
51
+ Small.args = { size: "small", label: "Publikationen Region" }
54
52
 
55
53
  export const Radio = Template.bind({})
56
- Radio.args = { variant: VARIANTS.radio }
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(el.items[0].checked).to.be.false
106
- expect(el.items[1].checked).to.be.false
107
- expect(el.items[2].checked).to.be.false
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(el.items[0].checked).to.be.false
112
- expect(el.items[1].checked).to.be.true
113
- expect(el.items[2].checked).to.be.false
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(el.items[0].checked).to.be.true
119
- expect(el.items[1].checked).to.be.false
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(el.items[0].checked).to.be.false
124
- expect(el.items[1].checked).to.be.false
125
- expect(el.items[2].checked).to.be.false
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(el.items[0].checked).to.be.false
130
- expect(el.items[1].checked).to.be.false
131
- expect(el.items[2].checked).to.be.false
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(el.items[0].checked).to.be.false
139
- expect(el.items[1].checked).to.be.false
140
- expect(el.items[2].checked).to.be.false
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(el.items[0].checked).to.be.false
145
- expect(el.items[1].checked).to.be.true
146
- expect(el.items[2].checked).to.be.false
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(el.items[0].checked).to.be.true
152
- expect(el.items[1].checked).to.be.true
153
- expect(el.items[2].checked).to.be.false
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(el.items[0].checked).to.be.false
158
- expect(el.items[1].checked).to.be.false
159
- expect(el.items[2].checked).to.be.false
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(el.items[0].checked).to.be.false
164
- expect(el.items[1].checked).to.be.false
165
- expect(el.items[2].checked).to.be.false
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
- * @internal
30
- */
31
- hasSlotController = new HasSlotController(this, ["toolbar"])
27
+ @property({ type: String })
28
+ label: string = ""
32
29
 
33
- static properties = {
34
- label: { type: String },
35
- sublabel: { type: String },
36
- open: { type: Boolean, open: true },
37
- }
30
+ @property({ type: String })
31
+ sublabel: string = ""
38
32
 
39
- constructor() {
40
- super()
33
+ @property({ type: Boolean, reflect: true })
34
+ open: boolean = false
41
35
 
42
- /** @type {import("lit/directives/ref").Ref<HTMLDialogElement>} */
43
- this._dialogRef = createRef()
36
+ protected _dialogRef = createRef<HTMLDialogElement>()
44
37
 
45
- /** @type {string} */
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()