@statistikzh/leu 0.22.0 → 0.23.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.
Files changed (199) 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 -28
  27. package/dist/Dropdown.js +22 -23
  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-BooZrClI.js → LeuElement-CWseJvWv.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.d.ts +16 -0
  46. package/dist/Popup.js +20 -2
  47. package/dist/ProgressBar.js +1 -1
  48. package/dist/Radio.js +1 -1
  49. package/dist/RadioGroup.js +1 -1
  50. package/dist/Range.d.ts +22 -65
  51. package/dist/Range.js +36 -37
  52. package/dist/ScrollTop.d.ts +5 -7
  53. package/dist/ScrollTop.js +10 -15
  54. package/dist/Select.d.ts +2 -1
  55. package/dist/Select.js +1 -1
  56. package/dist/Spinner.js +1 -1
  57. package/dist/Table.d.ts +1 -1
  58. package/dist/Table.js +1 -1
  59. package/dist/Tag.js +1 -1
  60. package/dist/VisuallyHidden.js +1 -1
  61. package/dist/components/chart-wrapper/leu-chart-wrapper.d.ts +5 -0
  62. package/dist/components/chart-wrapper/leu-chart-wrapper.d.ts.map +1 -1
  63. package/dist/components/chip/Chip.d.ts +1 -7
  64. package/dist/components/chip/Chip.d.ts.map +1 -1
  65. package/dist/components/chip/ChipGroup.d.ts +15 -35
  66. package/dist/components/chip/ChipGroup.d.ts.map +1 -1
  67. package/dist/components/chip/ChipLink.d.ts +4 -20
  68. package/dist/components/chip/ChipLink.d.ts.map +1 -1
  69. package/dist/components/chip/ChipRemovable.d.ts +3 -14
  70. package/dist/components/chip/ChipRemovable.d.ts.map +1 -1
  71. package/dist/components/chip/ChipSelectable.d.ts +13 -36
  72. package/dist/components/chip/ChipSelectable.d.ts.map +1 -1
  73. package/dist/components/chip/stories/chip-group.stories.d.ts +1 -1
  74. package/dist/components/chip/stories/chip-group.stories.d.ts.map +1 -1
  75. package/dist/components/chip/stories/chip-link.stories.d.ts.map +1 -1
  76. package/dist/components/chip/stories/chip-selectable.stories.d.ts.map +1 -1
  77. package/dist/components/dialog/Dialog.d.ts +5 -17
  78. package/dist/components/dialog/Dialog.d.ts.map +1 -1
  79. package/dist/components/dropdown/Dropdown.d.ts +14 -27
  80. package/dist/components/dropdown/Dropdown.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/popup/Popup.d.ts +16 -0
  100. package/dist/components/popup/Popup.d.ts.map +1 -1
  101. package/dist/components/popup/stories/popup.stories.d.ts +2 -0
  102. package/dist/components/popup/stories/popup.stories.d.ts.map +1 -1
  103. package/dist/components/progress-bar/leu-progress-bar.d.ts +5 -0
  104. package/dist/components/progress-bar/leu-progress-bar.d.ts.map +1 -1
  105. package/dist/components/range/Range.d.ts +22 -65
  106. package/dist/components/range/Range.d.ts.map +1 -1
  107. package/dist/components/scroll-top/ScrollTop.d.ts +4 -6
  108. package/dist/components/scroll-top/ScrollTop.d.ts.map +1 -1
  109. package/dist/components/tag/leu-tag.d.ts +5 -0
  110. package/dist/components/tag/leu-tag.d.ts.map +1 -1
  111. package/dist/index.d.ts +11 -0
  112. package/dist/index.d.ts.map +1 -1
  113. package/dist/index.js +13 -4
  114. package/dist/leu-accordion.js +1 -1
  115. package/dist/leu-button-group.js +1 -1
  116. package/dist/leu-button.d.ts +1 -1
  117. package/dist/leu-button.js +1 -1
  118. package/dist/leu-chart-wrapper.d.ts +10 -1
  119. package/dist/leu-chart-wrapper.js +1 -1
  120. package/dist/leu-checkbox-group.js +1 -1
  121. package/dist/leu-checkbox.d.ts +1 -1
  122. package/dist/leu-checkbox.js +1 -1
  123. package/dist/leu-chip-group.d.ts +2 -0
  124. package/dist/leu-chip-group.js +5 -1
  125. package/dist/leu-chip-link.js +3 -1
  126. package/dist/leu-chip-removable.d.ts +1 -1
  127. package/dist/leu-chip-removable.js +3 -3
  128. package/dist/leu-chip-selectable.js +3 -1
  129. package/dist/leu-dialog.d.ts +2 -1
  130. package/dist/leu-dialog.js +3 -3
  131. package/dist/leu-dropdown.d.ts +2 -1
  132. package/dist/leu-dropdown.js +3 -3
  133. package/dist/leu-file-input.d.ts +11 -2
  134. package/dist/leu-file-input.js +11 -4
  135. package/dist/leu-icon.d.ts +1 -1
  136. package/dist/leu-icon.js +1 -1
  137. package/dist/leu-input.d.ts +2 -1
  138. package/dist/leu-input.js +3 -3
  139. package/dist/leu-menu-item.d.ts +2 -2
  140. package/dist/leu-menu-item.js +3 -3
  141. package/dist/leu-menu.d.ts +1 -1
  142. package/dist/leu-menu.js +3 -3
  143. package/dist/leu-message.d.ts +11 -2
  144. package/dist/leu-message.js +1 -1
  145. package/dist/leu-pagination.d.ts +1 -1
  146. package/dist/leu-pagination.js +1 -1
  147. package/dist/leu-placeholder.d.ts +10 -1
  148. package/dist/leu-placeholder.js +1 -1
  149. package/dist/leu-popup.js +1 -1
  150. package/dist/leu-progress-bar.d.ts +10 -1
  151. package/dist/leu-progress-bar.js +1 -1
  152. package/dist/leu-radio-group.js +1 -1
  153. package/dist/leu-radio.js +1 -1
  154. package/dist/leu-range.js +3 -1
  155. package/dist/leu-scroll-top.d.ts +1 -1
  156. package/dist/leu-scroll-top.js +3 -3
  157. package/dist/leu-select.d.ts +2 -1
  158. package/dist/leu-select.js +1 -1
  159. package/dist/leu-spinner.js +1 -1
  160. package/dist/leu-table.d.ts +1 -1
  161. package/dist/leu-table.js +1 -1
  162. package/dist/leu-tag.d.ts +10 -1
  163. package/dist/leu-tag.js +1 -1
  164. package/dist/leu-visually-hidden.js +1 -1
  165. package/dist/vscode.html-custom-data.json +106 -88
  166. package/dist/vue/index.d.ts +105 -115
  167. package/dist/web-types.json +268 -243
  168. package/package.json +1 -1
  169. package/scripts/generate-component/templates/[namespace]-[name].ts +6 -0
  170. package/src/components/chart-wrapper/leu-chart-wrapper.ts +6 -0
  171. package/src/components/chip/Chip.ts +3 -9
  172. package/src/components/chip/ChipGroup.ts +26 -39
  173. package/src/components/chip/ChipLink.ts +7 -18
  174. package/src/components/chip/ChipRemovable.ts +4 -11
  175. package/src/components/chip/ChipSelectable.ts +21 -35
  176. package/src/components/chip/stories/chip-group.stories.ts +4 -7
  177. package/src/components/chip/stories/chip-link.stories.ts +2 -4
  178. package/src/components/chip/stories/chip-selectable.stories.ts +4 -6
  179. package/src/components/chip/test/chip-group.test.ts +34 -31
  180. package/src/components/dialog/Dialog.ts +9 -22
  181. package/src/components/dropdown/Dropdown.ts +19 -26
  182. package/src/components/file-input/FileInput.ts +12 -1
  183. package/src/components/file-input/leu-file-input.ts +6 -0
  184. package/src/components/file-input/stories/file-input.stories.ts +7 -0
  185. package/src/components/icon/Icon.ts +0 -4
  186. package/src/components/input/Input.ts +108 -105
  187. package/src/components/menu/Menu.ts +3 -12
  188. package/src/components/menu/MenuItem.ts +37 -41
  189. package/src/components/message/leu-message.ts +6 -0
  190. package/src/components/placeholder/leu-placeholder.ts +6 -0
  191. package/src/components/popup/Popup.ts +37 -0
  192. package/src/components/popup/stories/popup.stories.ts +10 -0
  193. package/src/components/popup/test/popup.test.ts +27 -0
  194. package/src/components/progress-bar/leu-progress-bar.ts +6 -0
  195. package/src/components/range/Range.ts +51 -59
  196. package/src/components/scroll-top/ScrollTop.ts +8 -15
  197. package/src/components/tag/leu-tag.ts +6 -0
  198. package/src/index.ts +11 -0
  199. package/web-test-runner.config.mjs +10 -0
@@ -1,25 +1,22 @@
1
- import { html, nothing } from "lit"
1
+ import { html, nothing, TemplateResult } from "lit"
2
2
  import { ifDefined } from "lit/directives/if-defined.js"
3
+ import { property } from "lit/decorators.js"
3
4
 
4
5
  import { LeuElement } from "../../lib/LeuElement.js"
5
6
  import { LeuIcon } from "../icon/Icon.js"
6
7
 
7
8
  import styles from "./menu-item.css"
8
9
 
9
- /**
10
- * @typedef {'menuitem' | 'menuitemcheckbox' | 'menuitemradio' | 'option' | 'none'} MenuItemRole
11
- */
10
+ type MenuItemRole =
11
+ | "menuitem"
12
+ | "menuitemcheckbox"
13
+ | "menuitemradio"
14
+ | "option"
15
+ | "none"
12
16
 
13
17
  /**
14
18
  * @tagname leu-menu-item
15
19
  * @slot - The label of the menu item
16
- * @property {boolean} active - Defines if the item is selected or checked
17
- * @property {boolean} multipleSelection - If the item is part of a multiple selection. Renders a checkmark before the label when active
18
- * @property {boolean} disabled - Disables the underlying button or link
19
- * @property {string} value - The value of the item. It must not contain commas. See `getValue()`
20
- * @property {string} href - The href of the underlying link
21
- * @property {boolean} tabbable - If the item should be focusable. Will be reflected as `tabindex` to the underlying button or link
22
- * @property {MenuItemRole} componentRole - The role of the item. This will be reflected as `role` to the underlying button or link. Default is `'menuitem'.`
23
20
  */
24
21
  export class LeuMenuItem extends LeuElement {
25
22
  static dependencies = {
@@ -36,33 +33,33 @@ export class LeuMenuItem extends LeuElement {
36
33
  delegatesFocus: true,
37
34
  }
38
35
 
39
- static properties = {
40
- active: { type: Boolean, reflect: true },
41
- multipleSelection: {
42
- type: Boolean,
43
- reflect: true,
44
- attr: "multiple-selection",
45
- },
46
- disabled: { type: Boolean, reflect: true },
47
- tabbable: { type: Boolean, reflect: true },
48
- href: { type: String, reflect: true },
49
- value: { type: String, reflect: true },
50
- componentRole: { type: String, reflect: true },
51
- }
36
+ /** Defines if the item is selected or checked */
37
+ @property({ type: Boolean, reflect: true })
38
+ active: boolean = false
52
39
 
53
- constructor() {
54
- super()
40
+ /** If the item is part of a multiple selection. Renders a checkmark before the label when active */
41
+ @property({ type: Boolean, reflect: true })
42
+ multipleSelection: boolean = false
55
43
 
56
- this.active = false
57
- this.disabled = false
58
- this.multipleSelection = false
59
- this.value = undefined
60
- this.href = undefined
61
- this.tabbable = undefined
44
+ /** Disables the underlying button or link */
45
+ @property({ type: Boolean, reflect: true })
46
+ disabled: boolean = false
62
47
 
63
- /** @type {MenuItemRole} */
64
- this.componentRole = "menuitem"
65
- }
48
+ /** If the item should be focusable. Will be reflected as `tabindex` to the underlying button or link */
49
+ @property({ type: Boolean, reflect: true })
50
+ tabbable: boolean
51
+
52
+ /** The href of the underlying link */
53
+ @property({ type: String, reflect: true })
54
+ href: string
55
+
56
+ /** The value of the item. It must not contain commas. See `getValue()` */
57
+ @property({ type: String, reflect: true })
58
+ value: string
59
+
60
+ /** The role of the item. This will be reflected as `role` to the underlying button or link. Default is `'menuitem'.` */
61
+ @property({ type: String, reflect: true })
62
+ componentRole: MenuItemRole = "menuitem"
66
63
 
67
64
  connectedCallback() {
68
65
  super.connectedCallback()
@@ -74,7 +71,7 @@ export class LeuMenuItem extends LeuElement {
74
71
  this.removeEventListener("click", this._handleClick, true)
75
72
  }
76
73
 
77
- _handleClick(event) {
74
+ protected _handleClick(event: MouseEvent) {
78
75
  if (this.disabled) {
79
76
  event.stopPropagation()
80
77
  event.preventDefault()
@@ -83,13 +80,12 @@ export class LeuMenuItem extends LeuElement {
83
80
 
84
81
  /**
85
82
  * Returns the value of the item. If `value` is not set, it will return the inner text
86
- * @returns {string}
87
83
  */
88
84
  getValue() {
89
85
  return this.value || this.textContent.trim()
90
86
  }
91
87
 
92
- _getAria() {
88
+ protected _getAria() {
93
89
  const commonAttributes = {
94
90
  disabled: this.disabled,
95
91
  }
@@ -110,7 +106,7 @@ export class LeuMenuItem extends LeuElement {
110
106
  }
111
107
  }
112
108
 
113
- _getTabIndex() {
109
+ protected _getTabIndex() {
114
110
  if (typeof this.tabbable === "boolean") {
115
111
  return this.tabbable ? 0 : -1
116
112
  }
@@ -118,7 +114,7 @@ export class LeuMenuItem extends LeuElement {
118
114
  return undefined
119
115
  }
120
116
 
121
- _renderLink(content) {
117
+ protected _renderLink(content: TemplateResult) {
122
118
  const aria = this._getAria()
123
119
 
124
120
  return html`<a
@@ -133,7 +129,7 @@ export class LeuMenuItem extends LeuElement {
133
129
  >`
134
130
  }
135
131
 
136
- _renderButton(content) {
132
+ protected _renderButton(content: TemplateResult) {
137
133
  const aria = this._getAria()
138
134
 
139
135
  return html`<button
@@ -3,3 +3,9 @@ import { LeuMessage } from "./Message.js"
3
3
  export { LeuMessage }
4
4
 
5
5
  LeuMessage.define("leu-message")
6
+
7
+ declare global {
8
+ interface HTMLElementTagNameMap {
9
+ "leu-message": LeuMessage
10
+ }
11
+ }
@@ -3,3 +3,9 @@ import { LeuPlaceholder } from "./Placeholder.js"
3
3
  export { LeuPlaceholder }
4
4
 
5
5
  LeuPlaceholder.define("leu-placeholder")
6
+
7
+ declare global {
8
+ interface HTMLElementTagNameMap {
9
+ "leu-placeholder": LeuPlaceholder
10
+ }
11
+ }
@@ -7,6 +7,7 @@ import {
7
7
  Placement,
8
8
  shift,
9
9
  size,
10
+ offset,
10
11
  } from "@floating-ui/dom"
11
12
 
12
13
  import { LeuElement } from "../../lib/LeuElement.js"
@@ -58,6 +59,28 @@ export class LeuPopup extends LeuElement {
58
59
  @property({ type: String, reflect: true })
59
60
  matchSize?: "width" | "height" | "both"
60
61
 
62
+ /**
63
+ * Offsets the popup along the main axis.
64
+ * @link https://floating-ui.com/docs/offset#mainaxis
65
+ */
66
+ @property({ type: Number, reflect: true, attribute: "offset-main-axis" })
67
+ offsetMainAxis?: number
68
+
69
+ /**
70
+ * Offsets the popup along the cross axis.
71
+ * @link https://floating-ui.com/docs/offset#crossaxis
72
+ */
73
+ @property({ type: Number, reflect: true, attribute: "offset-cross-axis" })
74
+ offsetCrossAxis?: number
75
+
76
+ /**
77
+ * Offsets the popup along the alignment axis.
78
+ * Overrides the `offsetCrossAxis` value.
79
+ * @link https://floating-ui.com/docs/offset#alignmentaxis
80
+ */
81
+ @property({ type: Number, reflect: true, attribute: "offset-alignment-axis" })
82
+ offsetAlignmentAxis?: number
83
+
61
84
  @property({ type: String, reflect: true }) autoSize?:
62
85
  | "width"
63
86
  | "height"
@@ -116,6 +139,20 @@ export class LeuPopup extends LeuElement {
116
139
 
117
140
  const middleware = []
118
141
 
142
+ if (
143
+ this.offsetAlignmentAxis ||
144
+ this.offsetMainAxis ||
145
+ this.offsetCrossAxis
146
+ ) {
147
+ middleware.push(
148
+ offset({
149
+ mainAxis: this.offsetMainAxis,
150
+ crossAxis: this.offsetCrossAxis,
151
+ alignmentAxis: this.offsetAlignmentAxis,
152
+ }),
153
+ )
154
+ }
155
+
119
156
  if (this.matchSize) {
120
157
  middleware.push(
121
158
  size({
@@ -43,6 +43,9 @@ function Template(args = {}) {
43
43
  ?flip=${args.flip}
44
44
  ?shift=${args.shift}
45
45
  placement=${ifDefined(args.placement)}
46
+ offset-main-axis=${ifDefined(args.offsetMainAxis)}
47
+ offset-cross-axis=${ifDefined(args.offsetCrossAxis)}
48
+ offset-alignment-axis=${ifDefined(args.offsetAlignmentAxis)}
46
49
  >
47
50
  <leu-button slot="anchor">Open popup</leu-button>
48
51
  <div style=${styleMap(popupStyles)}>Popup content</div>
@@ -55,6 +58,8 @@ Regular.args = {
55
58
  placement: "bottom-start",
56
59
  flip: true,
57
60
  shift: true,
61
+ offsetMainAxis: 0,
62
+ offsetAlignmentAxis: 0,
58
63
  }
59
64
 
60
65
  export const VirtualElement = {
@@ -64,6 +69,9 @@ export const VirtualElement = {
64
69
  ?flip=${args.flip}
65
70
  ?shift=${args.shift}
66
71
  placement=${ifDefined(args.placement)}
72
+ offset-main-axis=${ifDefined(args.offsetMainAxis)}
73
+ offset-cross-axis=${ifDefined(args.offsetCrossAxis)}
74
+ offset-alignment-axis=${ifDefined(args.offsetAlignmentAxis)}
67
75
  >
68
76
  <div style=${styleMap(popupStyles)}>Popup content</div>
69
77
  </leu-popup>
@@ -103,5 +111,7 @@ export const VirtualElement = {
103
111
  placement: "bottom-start",
104
112
  flip: true,
105
113
  shift: true,
114
+ offsetMainAxis: 8,
115
+ offsetAlignmentAxis: 8,
106
116
  },
107
117
  }
@@ -60,4 +60,31 @@ describe("LeuPopup", () => {
60
60
  expect(popupContent.style.left).to.equal("32px")
61
61
  expect(popupContent.style.top).to.equal("125px")
62
62
  })
63
+
64
+ it("applies offset properties correctly", async () => {
65
+ const popup = await fixture<LeuPopup>(
66
+ html`<leu-popup
67
+ ?active=${true}
68
+ placement="bottom-start"
69
+ offset-main-axis="12"
70
+ offset-cross-axis="9"
71
+ >
72
+ <div
73
+ slot="anchor"
74
+ style="width: 16px; height: 16px; position: absolute; top: 0; left: 0;"
75
+ ></div>
76
+ <div style="background: white; padding: 0.5rem">Popup content</div>
77
+ </leu-popup>`,
78
+ )
79
+
80
+ await new Promise<void>((resolve) => {
81
+ requestAnimationFrame(() => resolve())
82
+ })
83
+
84
+ const popupContent =
85
+ popup.shadowRoot!.querySelector<HTMLDivElement>(".popup")
86
+
87
+ expect(popupContent.style.left).to.equal("9px") // offset-cross-axis
88
+ expect(popupContent.style.top).to.equal("28px") // offset-main-axis + anchor height
89
+ })
63
90
  })
@@ -3,3 +3,9 @@ import { LeuProgressBar } from "./ProgressBar.js"
3
3
  export { LeuProgressBar }
4
4
 
5
5
  LeuProgressBar.define("leu-progress-bar")
6
+
7
+ declare global {
8
+ interface HTMLElementTagNameMap {
9
+ "leu-progress-bar": LeuProgressBar
10
+ }
11
+ }
@@ -1,5 +1,6 @@
1
1
  import { html } from "lit"
2
2
 
3
+ import { property } from "lit/decorators.js"
3
4
  import styles from "./range.css"
4
5
  import { LeuElement } from "../../lib/LeuElement.js"
5
6
 
@@ -25,34 +26,41 @@ export class LeuRange extends LeuElement {
25
26
  delegatesFocus: true,
26
27
  }
27
28
 
28
- static properties = {
29
- defaultValue: { converter: defaultValueConverter, attribute: "value" },
30
- min: { type: Number, reflect: true },
31
- max: { type: Number, reflect: true },
32
- step: { type: Number, reflect: true },
33
- name: { type: String, reflect: true },
34
- label: { type: String, reflect: true },
35
- disabled: { type: Boolean, reflect: true },
36
- multiple: { type: Boolean, reflect: true },
37
- }
29
+ @property({ converter: defaultValueConverter, attribute: "value" })
30
+ defaultValue = [50]
38
31
 
39
- constructor() {
40
- super()
41
- this.defaultValue = [50]
42
- this.min = 0
43
- this.max = 100
44
- this.step = 1
45
- this.name = ""
46
- this.label = ""
47
- this.disabled = false
48
- this.multiple = false
49
- }
32
+ @property({ type: Number, reflect: true })
33
+ min: number = 0
34
+
35
+ @property({ type: Number, reflect: true })
36
+ max: number = 100
37
+
38
+ @property({ type: Number, reflect: true })
39
+ step: number = 1
40
+
41
+ @property({ type: String, reflect: true })
42
+ name: string = ""
43
+
44
+ @property({ type: String, reflect: true })
45
+ label: string = ""
46
+
47
+ @property({ type: Boolean, reflect: true })
48
+ disabled: boolean = false
49
+
50
+ @property({ type: Boolean, reflect: true })
51
+ multiple: boolean = false
50
52
 
51
53
  updated() {
52
54
  this._updateStyles()
53
55
  }
54
56
 
55
- _updateStyles() {
57
+ protected get _inputs() {
58
+ return Array.from(
59
+ this.shadowRoot.querySelectorAll<HTMLInputElement>("input"),
60
+ )
61
+ }
62
+
63
+ protected _updateStyles() {
56
64
  const normalizedRange = this._getNormalizedRange()
57
65
  this.style.setProperty("--low", normalizedRange[0].toString())
58
66
  this.style.setProperty("--high", normalizedRange[1].toString())
@@ -62,8 +70,9 @@ export class LeuRange extends LeuElement {
62
70
  : [this._getBaseInput()]
63
71
 
64
72
  inputs.forEach((input) => {
65
- /** @type {HTMLOutputElement} */
66
- const output = this.shadowRoot.querySelector(`.output[for=${input.id}]`)
73
+ const output = this.shadowRoot.querySelector<HTMLOutputElement>(
74
+ `.output[for=${input.id}]`,
75
+ )
67
76
  const normalizedValue = this._getNormalizedValue(input.valueAsNumber)
68
77
  output.style.setProperty("--value", normalizedValue.toString())
69
78
  output.value = input.value
@@ -71,19 +80,18 @@ export class LeuRange extends LeuElement {
71
80
  }
72
81
 
73
82
  get value() {
74
- const inputs = Array.from(this.shadowRoot.querySelectorAll("input"))
75
- return inputs.map((input) => input.value).join(",")
83
+ return this._inputs.map((input) => input.value).join(",")
76
84
  }
77
85
 
78
86
  /**
79
87
  * Sets the value of the underlying input element(s).
80
88
  * The value has to be an array if "multiple" range is used.
81
89
  * Otherwise it has to be a string.
82
- * @param {string | Array} value
83
90
  */
84
- set value(value) {
91
+ set value(value: string | Array<string>) {
85
92
  if (this.multiple && Array.isArray(value)) {
86
- const inputs = Array.from(this.shadowRoot.querySelectorAll("input"))
93
+ const inputs = this._inputs
94
+
87
95
  value.forEach((v, i) => {
88
96
  inputs[i].value = v
89
97
  })
@@ -95,13 +103,11 @@ export class LeuRange extends LeuElement {
95
103
  }
96
104
 
97
105
  get valueAsArray() {
98
- return Array.from(this.shadowRoot.querySelectorAll("input")).map(
99
- (input) => input.valueAsNumber,
100
- )
106
+ return this._inputs.map((input) => input.valueAsNumber)
101
107
  }
102
108
 
103
109
  get valueLow() {
104
- const inputs = Array.from(this.shadowRoot.querySelectorAll("input"))
110
+ const inputs = this._inputs
105
111
 
106
112
  if (this.multiple) {
107
113
  return inputs.map((input) => input.valueAsNumber).sort((a, b) => a - b)[0]
@@ -111,7 +117,7 @@ export class LeuRange extends LeuElement {
111
117
  }
112
118
 
113
119
  get valueHigh() {
114
- const inputs = Array.from(this.shadowRoot.querySelectorAll("input"))
120
+ const inputs = this._inputs
115
121
 
116
122
  if (this.multiple) {
117
123
  return inputs.map((input) => input.valueAsNumber).sort((a, b) => a - b)[1]
@@ -120,39 +126,26 @@ export class LeuRange extends LeuElement {
120
126
  return inputs[0].value
121
127
  }
122
128
 
123
- /**
124
- * @returns {HTMLInputElement | null}
125
- */
126
- _getBaseInput() {
127
- return this.shadowRoot.querySelector(".range--base")
129
+ protected _getBaseInput() {
130
+ return this.shadowRoot.querySelector<HTMLInputElement>(".range--base")
128
131
  }
129
132
 
130
- /**
131
- * @returns {HTMLInputElement | null}
132
- */
133
- _getGhostInput() {
134
- return this.shadowRoot.querySelector(".range--ghost")
133
+ protected _getGhostInput() {
134
+ return this.shadowRoot.querySelector<HTMLInputElement>(".range--ghost")
135
135
  }
136
136
 
137
- /**
138
- *
139
- * @param {number} _index
140
- * @param {InputEvent & {target: HTMLInputElement}} _e
141
- */
142
- _handleInput(_index, _e) {
137
+ protected _handleInput(
138
+ _index: number,
139
+ _e: InputEvent & { target: HTMLInputElement },
140
+ ) {
143
141
  this._updateStyles()
144
142
  }
145
143
 
146
- /**
147
- *
148
- * @param {number} value
149
- * @returns {number}
150
- */
151
- _getNormalizedValue(value) {
144
+ protected _getNormalizedValue(value: number) {
152
145
  return (value - this.min) / (this.max - this.min)
153
146
  }
154
147
 
155
- _getNormalizedRange() {
148
+ protected _getNormalizedRange() {
156
149
  if (this.multiple) {
157
150
  return this.valueAsArray
158
151
  .map((value) => this._getNormalizedValue(value))
@@ -165,9 +158,8 @@ export class LeuRange extends LeuElement {
165
158
  /**
166
159
  * Determine if the "click" (pointer event) is closer the
167
160
  * the value of the other input element. Swap the values if this is the case.
168
- * @param {PointerEvent & {target: HTMLInputElement}} e
169
161
  */
170
- _handlePointerDown(e) {
162
+ protected _handlePointerDown(e: PointerEvent & { target: HTMLInputElement }) {
171
163
  const clickValue =
172
164
  this.min + ((this.max - this.min) * e.offsetX) / this.offsetWidth
173
165
  const middleValue = (this.valueAsArray[0] + this.valueAsArray[1]) / 2
@@ -1,5 +1,6 @@
1
1
  import { html } from "lit"
2
2
  import { classMap } from "lit/directives/class-map.js"
3
+ import { state } from "lit/decorators.js"
3
4
 
4
5
  import { LeuElement } from "../../lib/LeuElement.js"
5
6
  import { LeuButton } from "../button/Button.js"
@@ -20,22 +21,14 @@ export class LeuScrollTop extends LeuElement {
20
21
 
21
22
  static styles = [LeuElement.styles, styles]
22
23
 
23
- static properties = {
24
- _showButton: { state: true },
25
- }
24
+ @state()
25
+ protected _showButton: boolean = false
26
26
 
27
- constructor() {
28
- super()
29
- /** @internal */
30
- this._prevYPos = 0
31
- /** @internal */
32
- this._showButton = false
33
- /** @internal */
34
- this._scrollDown = false
35
-
36
- /** @internal */
37
- this._scrollListener = undefined
38
- }
27
+ protected _prevYPos: number = 0
28
+
29
+ protected _scrollDown: boolean = false
30
+
31
+ protected _scrollListener: EventListener
39
32
 
40
33
  scroll = () => {
41
34
  const delta = window.scrollY - this._prevYPos
@@ -3,3 +3,9 @@ import { LeuTag } from "./Tag.js"
3
3
  export { LeuTag }
4
4
 
5
5
  LeuTag.define("leu-tag")
6
+
7
+ declare global {
8
+ interface HTMLElementTagNameMap {
9
+ "leu-tag": LeuTag
10
+ }
11
+ }
package/src/index.ts CHANGED
@@ -5,14 +5,25 @@ export * from "./components/chart-wrapper/ChartWrapper.js"
5
5
  export * from "./components/checkbox/Checkbox.js"
6
6
  export * from "./components/checkbox/CheckboxGroup.js"
7
7
  export * from "./components/chip/exports.js"
8
+ export * from "./components/dialog/Dialog.js"
8
9
  export * from "./components/dropdown/Dropdown.js"
10
+ export * from "./components/file-input/FileInput.js"
11
+ export * from "./components/icon/Icon.js"
9
12
  export * from "./components/input/Input.js"
10
13
  export * from "./components/menu/Menu.js"
11
14
  export * from "./components/menu/MenuItem.js"
15
+ export * from "./components/message/Message.js"
12
16
  export * from "./components/pagination/Pagination.js"
17
+ export * from "./components/placeholder/Placeholder.js"
13
18
  export * from "./components/popup/Popup.js"
19
+ export * from "./components/progress-bar/ProgressBar.js"
14
20
  export * from "./components/radio/Radio.js"
15
21
  export * from "./components/radio/RadioGroup.js"
22
+ export * from "./components/range/Range.js"
23
+ export * from "./components/scroll-top/ScrollTop.js"
16
24
  export * from "./components/select/Select.js"
25
+ export * from "./components/spinner/Spinner.js"
17
26
  export * from "./components/table/Table.js"
27
+ export * from "./components/tag/Tag.js"
28
+ export * from "./components/visually-hidden/VisuallyHidden.js"
18
29
  export * from "./lib/LeuElement.js"
@@ -64,6 +64,16 @@ export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
64
64
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
65
65
  <link rel="stylesheet" href="dist/theme.css" />
66
66
  <link rel="stylesheet" href="https://www.web.statistik.zh.ch/leu/styles/fonts.css" />
67
+ <style>
68
+ *, *::before, *::after {
69
+ box-sizing: border-box;
70
+ }
71
+
72
+ *:not(dialog) {
73
+ margin: 0;
74
+ }
75
+ </style>
76
+
67
77
  </head>
68
78
  <body>
69
79
  <script type="module" src="${testFramework}"></script>