@statistikzh/leu 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/.husky/commit-msg +0 -3
  2. package/.husky/pre-commit +0 -3
  3. package/CHANGELOG.md +48 -0
  4. package/dist/Accordion.d.ts +10 -9
  5. package/dist/Accordion.d.ts.map +1 -1
  6. package/dist/Accordion.js +12 -11
  7. package/dist/Breadcrumb.d.ts +4 -4
  8. package/dist/Breadcrumb.d.ts.map +1 -1
  9. package/dist/Breadcrumb.js +28 -26
  10. package/dist/{Button-da11d064.d.ts → Button-9692e403.d.ts} +10 -11
  11. package/dist/Button-9692e403.d.ts.map +1 -0
  12. package/dist/{Button-da11d064.js → Button-9692e403.js} +65 -62
  13. package/dist/Button.d.ts +1 -1
  14. package/dist/Button.js +3 -3
  15. package/dist/ButtonGroup.d.ts +2 -2
  16. package/dist/ButtonGroup.d.ts.map +1 -1
  17. package/dist/ButtonGroup.js +3 -3
  18. package/dist/Checkbox.d.ts +4 -3
  19. package/dist/Checkbox.d.ts.map +1 -1
  20. package/dist/Checkbox.js +14 -19
  21. package/dist/CheckboxGroup.d.ts +2 -2
  22. package/dist/CheckboxGroup.d.ts.map +1 -1
  23. package/dist/CheckboxGroup.js +4 -6
  24. package/dist/Chip.d.ts +2 -2
  25. package/dist/Chip.d.ts.map +1 -1
  26. package/dist/Chip.js +6 -13
  27. package/dist/ChipGroup.d.ts +9 -7
  28. package/dist/ChipGroup.d.ts.map +1 -1
  29. package/dist/ChipGroup.js +8 -5
  30. package/dist/ChipLink.d.ts +2 -1
  31. package/dist/ChipLink.d.ts.map +1 -1
  32. package/dist/ChipLink.js +4 -7
  33. package/dist/ChipRemovable.d.ts +0 -2
  34. package/dist/ChipRemovable.d.ts.map +1 -1
  35. package/dist/ChipRemovable.js +8 -11
  36. package/dist/ChipSelectable.d.ts +9 -1
  37. package/dist/ChipSelectable.d.ts.map +1 -1
  38. package/dist/ChipSelectable.js +12 -16
  39. package/dist/Dropdown.d.ts +9 -5
  40. package/dist/Dropdown.d.ts.map +1 -1
  41. package/dist/Dropdown.js +73 -32
  42. package/dist/Icon.d.ts +20 -0
  43. package/dist/Icon.d.ts.map +1 -0
  44. package/dist/{icon-03e86700.js → Icon.js} +61 -32
  45. package/dist/Input.d.ts +7 -16
  46. package/dist/Input.d.ts.map +1 -1
  47. package/dist/Input.js +24 -28
  48. package/dist/LeuElement-6de6f209.d.ts +7 -0
  49. package/dist/LeuElement-6de6f209.d.ts.map +1 -0
  50. package/dist/LeuElement-6de6f209.js +43 -0
  51. package/dist/Menu.d.ts +24 -2
  52. package/dist/Menu.d.ts.map +1 -1
  53. package/dist/Menu.js +120 -3
  54. package/dist/MenuItem.d.ts +28 -11
  55. package/dist/MenuItem.d.ts.map +1 -1
  56. package/dist/MenuItem.js +110 -63
  57. package/dist/Pagination.d.ts +10 -3
  58. package/dist/Pagination.d.ts.map +1 -1
  59. package/dist/Pagination.js +24 -21
  60. package/dist/Popup.d.ts +21 -3
  61. package/dist/Popup.d.ts.map +1 -1
  62. package/dist/Popup.js +44 -19
  63. package/dist/Radio.d.ts +4 -2
  64. package/dist/Radio.d.ts.map +1 -1
  65. package/dist/Radio.js +9 -16
  66. package/dist/RadioGroup.d.ts +2 -2
  67. package/dist/RadioGroup.d.ts.map +1 -1
  68. package/dist/RadioGroup.js +4 -6
  69. package/dist/ScrollTop.d.ts +2 -2
  70. package/dist/ScrollTop.d.ts.map +1 -1
  71. package/dist/ScrollTop.js +10 -8
  72. package/dist/Select.d.ts +75 -37
  73. package/dist/Select.d.ts.map +1 -1
  74. package/dist/Select.js +279 -183
  75. package/dist/Table.d.ts +2 -6
  76. package/dist/Table.d.ts.map +1 -1
  77. package/dist/Table.js +17 -18
  78. package/dist/VisuallyHidden.d.ts +2 -2
  79. package/dist/VisuallyHidden.d.ts.map +1 -1
  80. package/dist/VisuallyHidden.js +5 -7
  81. package/dist/{index.js.d.ts → index.d.ts} +3 -3
  82. package/dist/index.d.ts.map +1 -0
  83. package/dist/{index.js.js → index.js} +5 -14
  84. package/dist/leu-accordion.d.ts.map +1 -1
  85. package/dist/leu-accordion.js +2 -3
  86. package/dist/leu-breadcrumb.d.ts.map +1 -1
  87. package/dist/leu-breadcrumb.js +4 -10
  88. package/dist/leu-button-group.d.ts.map +1 -1
  89. package/dist/leu-button-group.js +2 -3
  90. package/dist/leu-button.d.ts +1 -1
  91. package/dist/leu-button.d.ts.map +1 -1
  92. package/dist/leu-button.js +4 -5
  93. package/dist/leu-checkbox-group.d.ts.map +1 -1
  94. package/dist/leu-checkbox-group.js +2 -3
  95. package/dist/leu-checkbox.d.ts.map +1 -1
  96. package/dist/leu-checkbox.js +3 -4
  97. package/dist/leu-chip-group.d.ts.map +1 -1
  98. package/dist/leu-chip-group.js +2 -3
  99. package/dist/leu-chip-link.d.ts.map +1 -1
  100. package/dist/leu-chip-link.js +2 -3
  101. package/dist/leu-chip-removable.d.ts.map +1 -1
  102. package/dist/leu-chip-removable.js +3 -4
  103. package/dist/leu-chip-selectable.d.ts.map +1 -1
  104. package/dist/leu-chip-selectable.js +2 -3
  105. package/dist/leu-dropdown.d.ts.map +1 -1
  106. package/dist/leu-dropdown.js +5 -10
  107. package/dist/leu-icon.d.ts +3 -0
  108. package/dist/leu-icon.d.ts.map +1 -0
  109. package/dist/leu-icon.js +7 -0
  110. package/dist/leu-input.d.ts.map +1 -1
  111. package/dist/leu-input.js +3 -4
  112. package/dist/leu-menu-item.d.ts.map +1 -1
  113. package/dist/leu-menu-item.js +3 -5
  114. package/dist/leu-menu.d.ts.map +1 -1
  115. package/dist/leu-menu.js +5 -3
  116. package/dist/leu-pagination.d.ts.map +1 -1
  117. package/dist/leu-pagination.js +4 -7
  118. package/dist/leu-popup.d.ts.map +1 -1
  119. package/dist/leu-popup.js +2 -3
  120. package/dist/leu-radio-group.d.ts.map +1 -1
  121. package/dist/leu-radio-group.js +2 -3
  122. package/dist/leu-radio.d.ts.map +1 -1
  123. package/dist/leu-radio.js +2 -3
  124. package/dist/leu-scroll-top.d.ts.map +1 -1
  125. package/dist/leu-scroll-top.js +4 -6
  126. package/dist/leu-select.d.ts.map +1 -1
  127. package/dist/leu-select.js +5 -13
  128. package/dist/leu-table.d.ts.map +1 -1
  129. package/dist/leu-table.js +4 -8
  130. package/dist/leu-visually-hidden.d.ts.map +1 -1
  131. package/dist/leu-visually-hidden.js +2 -3
  132. package/dist/theme.css +2 -0
  133. package/dist/vscode.html-custom-data.json +616 -0
  134. package/dist/vue/index.d.ts +682 -0
  135. package/dist/web-types.json +1211 -0
  136. package/package.json +10 -13
  137. package/rollup.config.js +1 -1
  138. package/scripts/generate-component/templates/[Name].js +6 -3
  139. package/scripts/generate-component/templates/test/[name].test.js +1 -1
  140. package/src/components/accordion/Accordion.js +13 -10
  141. package/src/components/accordion/leu-accordion.js +1 -2
  142. package/src/components/breadcrumb/Breadcrumb.js +31 -18
  143. package/src/components/breadcrumb/leu-breadcrumb.js +1 -2
  144. package/src/components/button/Button.js +45 -71
  145. package/src/components/button/button.css +19 -4
  146. package/src/components/button/leu-button.js +1 -2
  147. package/src/components/button/stories/button.stories.js +60 -19
  148. package/src/components/button/test/button.test.js +26 -63
  149. package/src/components/button-group/ButtonGroup.js +4 -2
  150. package/src/components/button-group/leu-button-group.js +1 -2
  151. package/src/components/checkbox/Checkbox.js +17 -11
  152. package/src/components/checkbox/CheckboxGroup.js +6 -3
  153. package/src/components/checkbox/leu-checkbox-group.js +1 -2
  154. package/src/components/checkbox/leu-checkbox.js +1 -2
  155. package/src/components/checkbox/stories/checkbox-group.stories.js +10 -26
  156. package/src/components/checkbox/stories/checkbox.stories.js +2 -7
  157. package/src/components/checkbox/test/checkbox-group.test.js +6 -21
  158. package/src/components/checkbox/test/checkbox.test.js +1 -12
  159. package/src/components/chip/Chip.js +5 -4
  160. package/src/components/chip/ChipGroup.js +10 -4
  161. package/src/components/chip/ChipLink.js +3 -7
  162. package/src/components/chip/ChipRemovable.js +8 -11
  163. package/src/components/chip/ChipSelectable.js +11 -17
  164. package/src/components/chip/chip.css +3 -4
  165. package/src/components/chip/leu-chip-group.js +1 -2
  166. package/src/components/chip/leu-chip-link.js +1 -2
  167. package/src/components/chip/leu-chip-removable.js +1 -2
  168. package/src/components/chip/leu-chip-selectable.js +1 -2
  169. package/src/components/chip/stories/chip-link.stories.js +3 -5
  170. package/src/components/chip/stories/chip-removable.stories.js +3 -4
  171. package/src/components/chip/stories/chip-selectable.stories.js +2 -2
  172. package/src/components/chip/test/chip-group.test.js +15 -30
  173. package/src/components/chip/test/chip-link.test.js +2 -6
  174. package/src/components/chip/test/chip-removable.test.js +4 -10
  175. package/src/components/chip/test/chip-selectable.test.js +3 -5
  176. package/src/components/dropdown/Dropdown.js +80 -26
  177. package/src/components/dropdown/dropdown.css +4 -0
  178. package/src/components/dropdown/leu-dropdown.js +1 -2
  179. package/src/components/dropdown/stories/dropdown.stories.js +30 -7
  180. package/src/components/dropdown/test/dropdown.test.js +5 -5
  181. package/src/components/icon/Icon.js +55 -0
  182. package/src/components/icon/icon.css +6 -0
  183. package/src/components/icon/leu-icon.js +5 -0
  184. package/src/components/icon/{icon.js → paths.js} +4 -37
  185. package/src/components/icon/stories/icon.stories.js +47 -0
  186. package/src/components/icon/test/icon.test.js +23 -40
  187. package/src/components/input/Input.js +21 -23
  188. package/src/components/input/input.css +4 -2
  189. package/src/components/input/leu-input.js +1 -2
  190. package/src/components/input/stories/input.stories.js +2 -2
  191. package/src/components/input/test/input.test.js +2 -0
  192. package/src/components/menu/Menu.js +143 -2
  193. package/src/components/menu/MenuItem.js +104 -52
  194. package/src/components/menu/leu-menu-item.js +1 -2
  195. package/src/components/menu/leu-menu.js +1 -2
  196. package/src/components/menu/menu-item.css +11 -4
  197. package/src/components/menu/stories/menu-item.stories.js +15 -4
  198. package/src/components/menu/stories/menu.stories.js +34 -7
  199. package/src/components/menu/test/menu-item.test.js +88 -82
  200. package/src/components/menu/test/menu.test.js +101 -8
  201. package/src/components/pagination/Pagination.js +27 -18
  202. package/src/components/pagination/leu-pagination.js +1 -2
  203. package/src/components/popup/Popup.js +39 -16
  204. package/src/components/popup/leu-popup.js +1 -2
  205. package/src/components/popup/popup.css +1 -0
  206. package/src/components/radio/Radio.js +12 -7
  207. package/src/components/radio/RadioGroup.js +6 -3
  208. package/src/components/radio/leu-radio-group.js +1 -2
  209. package/src/components/radio/leu-radio.js +1 -2
  210. package/src/components/radio/stories/radio-group.stories.js +5 -19
  211. package/src/components/radio/stories/radio.stories.js +2 -7
  212. package/src/components/radio/test/radio-group.test.js +6 -9
  213. package/src/components/radio/test/radio.test.js +3 -13
  214. package/src/components/scroll-top/ScrollTop.js +15 -5
  215. package/src/components/scroll-top/leu-scroll-top.js +1 -2
  216. package/src/components/select/Select.js +279 -175
  217. package/src/components/select/leu-select.js +1 -2
  218. package/src/components/select/select.css +20 -12
  219. package/src/components/select/stories/select.stories.js +16 -2
  220. package/src/components/select/test/select.test.js +191 -37
  221. package/src/components/table/Table.js +15 -9
  222. package/src/components/table/leu-table.js +1 -2
  223. package/src/components/table/table.css +3 -1
  224. package/src/components/visually-hidden/VisuallyHidden.js +6 -2
  225. package/src/components/visually-hidden/leu-visually-hidden.js +1 -2
  226. package/src/lib/LeuElement.js +23 -0
  227. package/src/lib/a11y.js +26 -0
  228. package/src/styles/custom-properties.css +2 -0
  229. package/web-test-runner.config.mjs +2 -0
  230. package/dist/Button-da11d064.d.ts.map +0 -1
  231. package/dist/_rollupPluginBabelHelpers-20f659f4.d.ts +0 -3
  232. package/dist/_rollupPluginBabelHelpers-20f659f4.d.ts.map +0 -1
  233. package/dist/_rollupPluginBabelHelpers-20f659f4.js +0 -30
  234. package/dist/defineElement-40372b4b.d.ts +0 -9
  235. package/dist/defineElement-40372b4b.d.ts.map +0 -1
  236. package/dist/defineElement-40372b4b.js +0 -15
  237. package/dist/icon-03e86700.d.ts +0 -11
  238. package/dist/icon-03e86700.d.ts.map +0 -1
  239. package/dist/index.js.d.ts.map +0 -1
  240. package/src/lib/defineElement.js +0 -13
@@ -1,17 +1,35 @@
1
1
  import { html } from "lit"
2
+ import { ifDefined } from "lit/directives/if-defined.js"
2
3
  import { fixture, expect } from "@open-wc/testing"
4
+ import { sendKeys } from "@web/test-runner-commands"
3
5
 
4
6
  import "../leu-menu.js"
5
7
  import "../leu-menu-item.js"
8
+ import "../../icon/leu-icon.js"
6
9
 
7
- async function defaultFixture() {
8
- return fixture(html` <leu-menu>
9
- <leu-menu-item label="Menu Item 1" before="EMPTY"></leu-menu-item>
10
- <leu-menu-item label="Menu Item 2" before="check" active></leu-menu-item>
11
- <leu-menu-item label="Menu Item 3" before="EMPTY"></leu-menu-item>
10
+ async function defaultFixture(args = {}) {
11
+ return fixture(html` <leu-menu
12
+ role=${ifDefined(args.role)}
13
+ selects=${ifDefined(args.selects)}
14
+ >
15
+ <leu-menu-item
16
+ ><leu-icon slot="before"></leu-icon>Menu Item 1</leu-menu-item
17
+ >
18
+ <leu-menu-item active
19
+ ><leu-icon slot="before" name="check"></leu-icon>Menu Item
20
+ 2</leu-menu-item
21
+ >
22
+ <leu-menu-item
23
+ ><leu-icon slot="before"></leu-icon>Menu Item 3</leu-menu-item
24
+ >
12
25
  <hr />
13
- <leu-menu-item label="Menu Item 3" before="pin" after="CH"></leu-menu-item>
14
- <leu-menu-item label="Menu Item 4"></leu-menu-item>
26
+ <leu-menu-item
27
+ ><leu-icon name="pin" slot="before"></leu-icon>Menu Item 3<slot
28
+ name="after"
29
+ >CH</slot
30
+ ></leu-menu-item
31
+ >
32
+ <leu-menu-item>Menu Item 4</leu-menu-item>
15
33
  </leu-menu>`)
16
34
  }
17
35
 
@@ -25,6 +43,81 @@ describe("LeuMenu", () => {
25
43
  it("passes the a11y audit", async () => {
26
44
  const el = await defaultFixture()
27
45
 
28
- await expect(el).shadowDom.to.be.accessible()
46
+ await expect(el).dom.to.be.accessible()
47
+ })
48
+
49
+ it("sets 'menu' as the default role", async () => {
50
+ const el = await defaultFixture()
51
+
52
+ expect(el.getAttribute("role")).to.equal("menu")
53
+ })
54
+
55
+ it("sets 'menuitem' as the default role for menu items", async () => {
56
+ const el = await defaultFixture()
57
+
58
+ const menuItems = el.querySelectorAll("leu-menu-item")
59
+
60
+ menuItems.forEach((menuItem) => {
61
+ expect(menuItem.componentRole).to.equal("menuitem")
62
+ })
63
+ })
64
+
65
+ it("sets 'menuitemradio' as the role for menu items when only one item can be selected", async () => {
66
+ const el = await defaultFixture({ selects: "single" })
67
+
68
+ const menuItems = el.querySelectorAll("leu-menu-item")
69
+
70
+ menuItems.forEach((menuItem) => {
71
+ expect(menuItem.componentRole).to.equal("menuitemradio")
72
+ })
73
+ })
74
+
75
+ it("sets 'menuitemcheckbox' as the role for menu items when multiple items can be selected", async () => {
76
+ const el = await defaultFixture({ selects: "multiple" })
77
+
78
+ const menuItems = el.querySelectorAll("leu-menu-item")
79
+
80
+ menuItems.forEach((menuItem) => {
81
+ expect(menuItem.componentRole).to.equal("menuitemcheckbox")
82
+ })
83
+ })
84
+
85
+ it("sets 'option' as the role for menu items when the menu role is 'listbox'", async () => {
86
+ const el = await defaultFixture({ role: "listbox" })
87
+
88
+ const menuItems = el.querySelectorAll("leu-menu-item")
89
+
90
+ menuItems.forEach((menuItem) => {
91
+ expect(menuItem.componentRole).to.equal("option")
92
+ })
93
+ })
94
+
95
+ it("moves the focus when the arrow keys are pressed", async () => {
96
+ const el = await defaultFixture()
97
+
98
+ const menuItems = Array.from(el.querySelectorAll("leu-menu-item"))
99
+
100
+ await sendKeys({ press: "Tab" })
101
+ expect(document.activeElement).to.equal(menuItems[0])
102
+
103
+ await sendKeys({ press: "ArrowDown" })
104
+ await sendKeys({ press: "ArrowDown" })
105
+
106
+ expect(document.activeElement).to.equal(menuItems[2])
107
+
108
+ await sendKeys({ press: "ArrowUp" })
109
+ await sendKeys({ press: "ArrowUp" })
110
+ await sendKeys({ press: "ArrowUp" })
111
+
112
+ expect(document.activeElement).to.equal(menuItems.at(-1))
113
+
114
+ await sendKeys({ press: "Home" })
115
+ expect(document.activeElement).to.equal(menuItems[0])
116
+
117
+ await sendKeys({ press: "End" })
118
+ expect(document.activeElement).to.equal(menuItems.at(-1))
119
+
120
+ await sendKeys({ press: "ArrowDown" })
121
+ expect(document.activeElement).to.equal(menuItems[0])
29
122
  })
30
123
  })
@@ -1,24 +1,33 @@
1
- import { html, LitElement } from "lit"
1
+ import { html } from "lit"
2
2
  import { live } from "lit/directives/live.js"
3
3
 
4
- import "../button/leu-button.js"
5
- import styles from "./pagination.css"
4
+ import { LeuElement } from "../../lib/LeuElement.js"
5
+ import { LeuButton } from "../button/Button.js"
6
+ import { LeuVisuallyHidden } from "../visually-hidden/VisuallyHidden.js"
7
+ import { LeuIcon } from "../icon/Icon.js"
6
8
 
7
- import "../visually-hidden/leu-visually-hidden.js"
9
+ // @ts-ignore
10
+ import styles from "./pagination.css"
8
11
 
9
12
  const MIN_PAGE = 1
10
13
 
11
14
  /**
12
15
  * @tagname leu-pagination
13
16
  */
14
- export class LeuPagination extends LitElement {
17
+ export class LeuPagination extends LeuElement {
18
+ static dependencies = {
19
+ "leu-button": LeuButton,
20
+ "leu-icon": LeuIcon,
21
+ "leu-visually-hidden": LeuVisuallyHidden,
22
+ }
23
+
15
24
  static styles = styles
16
25
 
17
26
  /**
18
27
  * @internal
19
28
  */
20
29
  static shadowRootOptions = {
21
- ...LitElement.shadowRootOptions,
30
+ ...LeuElement.shadowRootOptions,
22
31
  delegatesFocus: true,
23
32
  }
24
33
 
@@ -26,15 +35,6 @@ export class LeuPagination extends LitElement {
26
35
  defaultPage: { type: Number, reflect: true },
27
36
  itemsPerPage: { type: Number, reflect: true },
28
37
  numOfItems: { type: Number, reflect: true },
29
-
30
- /**
31
- * Internal page state that contains an
32
- * already clamped page number. Should only
33
- * be accessed through the `page` getter and
34
- * setter.
35
- * @type {Number}
36
- * @internal
37
- */
38
38
  _page: { state: true },
39
39
  }
40
40
 
@@ -43,9 +43,18 @@ export class LeuPagination extends LitElement {
43
43
 
44
44
  /** @type {Number} */
45
45
  this.numOfItems = 1
46
+
46
47
  /** @type {Number} */
47
48
  this.itemsPerPage = 1
48
- /** @type {Number} */
49
+
50
+ /**
51
+ * Internal page state that contains an
52
+ * already clamped page number. Should only
53
+ * be accessed through the `page` getter and
54
+ * setter.
55
+ * @type {Number}
56
+ * @internal
57
+ */
49
58
  this._page = 1
50
59
  }
51
60
 
@@ -148,22 +157,22 @@ export class LeuPagination extends LitElement {
148
157
  <div class="label">von ${this._maxPage}</div>
149
158
  <div class="button-group">
150
159
  <leu-button
151
- icon="angleLeft"
152
160
  variant="secondary"
153
161
  label="Vorherige Seite"
154
162
  @click=${(_) => {
155
163
  this._updatePage(this.page - 1)
156
164
  }}
157
165
  ?disabled=${this._isFirstPage()}
166
+ ><leu-icon name="angleLeft"></leu-icon
158
167
  ></leu-button>
159
168
  <leu-button
160
- icon="angleRight"
161
169
  variant="secondary"
162
170
  label="Nächste Seite"
163
171
  @click=${(_) => {
164
172
  this._updatePage(this.page + 1)
165
173
  }}
166
174
  ?disabled=${this._isLastPage()}
175
+ ><leu-icon name="angleRight"></leu-icon
167
176
  ></leu-button>
168
177
  </div>
169
178
  `
@@ -1,6 +1,5 @@
1
- import { defineElement } from "../../lib/defineElement.js"
2
1
  import { LeuPagination } from "./Pagination.js"
3
2
 
4
3
  export { LeuPagination }
5
4
 
6
- defineElement("pagination", LeuPagination)
5
+ LeuPagination.define("leu-pagination")
@@ -1,4 +1,4 @@
1
- import { html, LitElement } from "lit"
1
+ import { html } from "lit"
2
2
  import {
3
3
  autoUpdate,
4
4
  computePosition,
@@ -6,34 +6,37 @@ import {
6
6
  shift,
7
7
  size,
8
8
  } from "@floating-ui/dom"
9
+
10
+ import { LeuElement } from "../../lib/LeuElement.js"
11
+
12
+ // @ts-ignore
9
13
  import styles from "./popup.css"
10
14
 
15
+ /**
16
+ * @typedef {"top"|"top-start"|"top-end"|"bottom"|"bottom-start"|"bottom-end"|"left"|"left-start"|"left-end"|"right"|"right-start"|"right-end"} Placement
17
+ */
18
+
11
19
  /**
12
20
  * @tagname leu-popup
13
21
  */
14
- export class LeuPopup extends LitElement {
22
+ export class LeuPopup extends LeuElement {
15
23
  static styles = styles
16
24
 
17
25
  static shadowRootOptions = {
18
- ...LitElement.shadowRootOptions,
26
+ ...LeuElement.shadowRootOptions,
19
27
  delegatesFocus: true,
20
28
  }
21
29
 
22
30
  static properties = {
23
31
  anchor: {},
24
- active: { type: Boolean },
25
- /**
26
- * @type {"top"|"top-start"|"top-end"|"bottom"|"bottom-start"|"bottom-end"|"left"|"left-start"|"left-end"|"right"|"right-start"|"right-end"}
27
- */
28
- placement: { type: String },
29
- flip: { type: Boolean },
30
- shift: { type: Boolean },
31
- shiftPadding: { type: Number },
32
- /** @type {"width" | "height" | "both"} */
33
- matchSize: { type: String },
34
- /** @type {"width" | "height" | "both"} */
35
- autoSize: { type: String },
36
- autoSizePadding: { type: Number },
32
+ active: { type: Boolean, reflect: true },
33
+ placement: { type: String, reflect: true },
34
+ flip: { type: Boolean, reflect: true },
35
+ shift: { type: Boolean, reflect: true },
36
+ shiftPadding: { type: Number, reflect: true },
37
+ matchSize: { type: String, reflect: true },
38
+ autoSize: { type: String, reflect: true },
39
+ autoSizePadding: { type: Number, reflect: true },
37
40
  }
38
41
 
39
42
  constructor() {
@@ -43,6 +46,23 @@ export class LeuPopup extends LitElement {
43
46
  this.cleanup = undefined
44
47
  this.flip = false
45
48
  this.shift = false
49
+
50
+ this.active = false
51
+
52
+ /** @type {Placement} */
53
+ this.placement = undefined
54
+
55
+ /** @type {"width" | "height" | "both"} */
56
+ this.matchSize = undefined
57
+
58
+ /** @type {"width" | "height" | "both"} */
59
+ this.autoSize = undefined
60
+
61
+ this.shiftPadding = 0
62
+ this.autoSizePadding = 0
63
+
64
+ /** @type {string | HTMLElement} */
65
+ this.anchor = undefined
46
66
  }
47
67
 
48
68
  disconnectedCallback() {
@@ -68,6 +88,9 @@ export class LeuPopup extends LitElement {
68
88
  }
69
89
  }
70
90
 
91
+ /**
92
+ * @returns {HTMLElement | null}
93
+ */
71
94
  get popupEl() {
72
95
  return this.renderRoot?.querySelector(".popup") ?? null
73
96
  }
@@ -1,6 +1,5 @@
1
- import { defineElement } from "../../lib/defineElement.js"
2
1
  import { LeuPopup } from "./Popup.js"
3
2
 
4
3
  export { LeuPopup }
5
4
 
6
- defineElement("popup", LeuPopup)
5
+ LeuPopup.define("leu-popup")
@@ -19,6 +19,7 @@
19
19
  position: absolute;
20
20
  top: 0;
21
21
  left: 0;
22
+ z-index: var(--leu-z-index-popup);
22
23
  }
23
24
 
24
25
  /* TODO: Should visibility be a matter of the popup component? */
@@ -1,30 +1,35 @@
1
- import { html, LitElement } from "lit"
1
+ import { html } from "lit"
2
+
3
+ import { LeuElement } from "../../lib/LeuElement.js"
4
+
5
+ // @ts-ignore
2
6
  import styles from "./radio.css"
3
7
 
4
8
  /**
5
9
  * @tagname leu-radio
6
10
  */
7
- export class LeuRadio extends LitElement {
11
+ export class LeuRadio extends LeuElement {
8
12
  static styles = styles
9
13
 
14
+ /** @internal */
10
15
  static shadowRootOptions = {
11
- ...LitElement.shadowRootOptions,
16
+ ...LeuElement.shadowRootOptions,
12
17
  delegatesFocus: true,
13
18
  }
14
19
 
15
20
  static properties = {
16
21
  checked: { type: Boolean, reflect: true },
17
22
  disabled: { type: Boolean, reflect: true },
18
- identifier: { type: String, reflect: true },
19
23
  value: { type: String, reflect: true },
20
24
  name: { type: String, reflect: true },
21
- label: { type: String, reflect: true },
22
25
  }
23
26
 
24
27
  constructor() {
25
28
  super()
26
29
  this.checked = false
27
30
  this.disabled = false
31
+ this.name = ""
32
+ this.value = ""
28
33
  }
29
34
 
30
35
  handleChange(event) {
@@ -41,7 +46,7 @@ export class LeuRadio extends LitElement {
41
46
  render() {
42
47
  return html`
43
48
  <input
44
- id=${this.identifier}
49
+ id=${`radio-${this.name}`}
45
50
  class="radio"
46
51
  type="radio"
47
52
  name="${this.name}"
@@ -51,7 +56,7 @@ export class LeuRadio extends LitElement {
51
56
  ?disabled=${this.disabled}
52
57
  .value=${this.value}
53
58
  />
54
- <label for=${this.identifier} class="label">${this.label}</label>
59
+ <label for=${`radio-${this.name}`} class="label"><slot></slot></label>
55
60
  `
56
61
  }
57
62
  }
@@ -1,12 +1,15 @@
1
- import { html, LitElement } from "lit"
1
+ import { html } from "lit"
2
2
  import { classMap } from "lit/directives/class-map.js"
3
3
 
4
+ import { LeuElement } from "../../lib/LeuElement.js"
5
+
6
+ // @ts-ignore
4
7
  import styles from "./radio-group.css"
5
8
 
6
9
  /**
7
10
  * @tagname leu-radio-group
8
11
  */
9
- export class LeuRadioGroup extends LitElement {
12
+ export class LeuRadioGroup extends LeuElement {
10
13
  static styles = styles
11
14
 
12
15
  static properties = {
@@ -129,7 +132,7 @@ export class LeuRadioGroup extends LitElement {
129
132
  }
130
133
 
131
134
  handleItems() {
132
- this.items = [...this.querySelectorAll(":scope > *:not([slot])")]
135
+ this.items = Array.from(this.querySelectorAll(":scope > *:not([slot])"))
133
136
  this.initializeIndex()
134
137
  this.setTabIndex()
135
138
  }
@@ -1,6 +1,5 @@
1
- import { defineElement } from "../../lib/defineElement.js"
2
1
  import { LeuRadioGroup } from "./RadioGroup.js"
3
2
 
4
3
  export { LeuRadioGroup }
5
4
 
6
- defineElement("radio-group", LeuRadioGroup)
5
+ LeuRadioGroup.define("leu-radio-group")
@@ -1,6 +1,5 @@
1
- import { defineElement } from "../../lib/defineElement.js"
2
1
  import { LeuRadio } from "./Radio.js"
3
2
 
4
3
  export { LeuRadio }
5
4
 
6
- defineElement("radio", LeuRadio)
5
+ LeuRadio.define("leu-radio")
@@ -27,25 +27,11 @@ function Template({ label, orientation }) {
27
27
  orientation=${ifDefined(orientation)}
28
28
  label=${ifDefined(label)}
29
29
  >
30
- <leu-radio
31
- identifier="1"
32
- value="1"
33
- name="radio-button"
34
- label="Kurz"
35
- disabled
36
- ></leu-radio>
37
- <leu-radio
38
- identifier="2"
39
- value="2"
40
- name="radio-button"
41
- label="Etwas Länger"
42
- ></leu-radio>
43
- <leu-radio
44
- identifier="3"
45
- value="3"
46
- name="radio-button"
47
- label="Ein langes Label um sicher ein umbruch zu erzwingen"
48
- ></leu-radio>
30
+ <leu-radio value="1" name="radio-button" disabled>Kurz</leu-radio>
31
+ <leu-radio value="2" name="radio-button">Etwas Länger</leu-radio>
32
+ <leu-radio value="3" name="radio-button"
33
+ >Ein langes Label um sicher ein umbruch zu erzwingen</leu-radio
34
+ >
49
35
  </leu-radio-group>
50
36
  `
51
37
  }
@@ -24,13 +24,8 @@ function Template({
24
24
  disabled = false,
25
25
  }) {
26
26
  return html`
27
- <leu-radio
28
- .value=${value}
29
- ?checked=${checked}
30
- ?disabled=${disabled}
31
- identifier=${"radio-1"}
32
- label=${label}
33
- >
27
+ <leu-radio .value=${value} ?checked=${checked} ?disabled=${disabled}>
28
+ ${label}
34
29
  </leu-radio>
35
30
  `
36
31
  }
@@ -9,27 +9,24 @@ async function defaultFixture(args = {}) {
9
9
  <leu-radio-group>
10
10
  <span slot="legend">Legende</span>
11
11
  <leu-radio
12
- identifier="1"
13
12
  value="1"
14
13
  name="radio-button"
15
14
  disabled
16
- label="Kurz"
17
15
  ?checked=${args.checkedValue === "1"}
18
- ></leu-radio>
16
+ >Kurz</leu-radio
17
+ >
19
18
  <leu-radio
20
- identifier="2"
21
19
  value="2"
22
20
  name="radio-button"
23
- label="Etwas Länger"
24
21
  ?checked=${args.checkedValue === "2"}
25
- ></leu-radio>
22
+ >Etwas Länger</leu-radio
23
+ >
26
24
  <leu-radio
27
- identifier="3"
28
25
  value="3"
29
26
  name="radio-button"
30
- label="Ein langes Label um sicher ein umbruch zu erzwingen"
31
27
  ?checked=${args.checkedValue === "3"}
32
- ></leu-radio>
28
+ >Ein langes Label um sicher ein umbruch zu erzwingen</leu-radio
29
+ >
33
30
  </leu-radio-group>
34
31
  `)
35
32
  }
@@ -6,12 +6,9 @@ import "../leu-radio.js"
6
6
 
7
7
  async function defaultFixture() {
8
8
  return fixture(html`
9
- <leu-radio
10
- identifier="b"
11
- value="3"
12
- name="radio-button"
13
- label="Ein langes Label um sicher ein umbruch zu erzwingen"
14
- ></leu-radio>
9
+ <leu-radio identifier="b" value="3" name="radio-button"
10
+ >Ein langes Label um sicher ein umbruch zu erzwingen</leu-radio
11
+ >
15
12
  `)
16
13
  }
17
14
 
@@ -119,11 +116,4 @@ describe("LeuRadio", () => {
119
116
 
120
117
  expect(event).to.exist
121
118
  })
122
-
123
- it("applies the identifier to the input and the label", async () => {
124
- const el = await defaultFixture()
125
-
126
- expect(el.shadowRoot.querySelector("input").id).to.equal("b")
127
- expect(el.shadowRoot.querySelector("label").htmlFor).to.equal("b")
128
- })
129
119
  })
@@ -1,14 +1,24 @@
1
- import { html, LitElement } from "lit"
1
+ import { html } from "lit"
2
2
  import { classMap } from "lit/directives/class-map.js"
3
3
 
4
- import styles from "./scroll-top.css"
5
- import "../button/leu-button.js"
4
+ import { LeuElement } from "../../lib/LeuElement.js"
5
+ import { LeuButton } from "../button/Button.js"
6
+ import { LeuIcon } from "../icon/Icon.js"
7
+
6
8
  import { throttle } from "../../lib/utils.js"
7
9
 
10
+ // @ts-ignore
11
+ import styles from "./scroll-top.css"
12
+
8
13
  /**
9
14
  * @tagname leu-scroll-top
10
15
  */
11
- export class LeuScrollTop extends LitElement {
16
+ export class LeuScrollTop extends LeuElement {
17
+ static dependencies = {
18
+ "leu-button": LeuButton,
19
+ "leu-icon": LeuIcon,
20
+ }
21
+
12
22
  static styles = styles
13
23
 
14
24
  static properties = {
@@ -75,11 +85,11 @@ export class LeuScrollTop extends LitElement {
75
85
  return html`
76
86
  <div class=${classMap(cssClasses)}>
77
87
  <leu-button
78
- icon="arrowUp"
79
88
  label="Zum Seitenanfang"
80
89
  round
81
90
  @click="${() => LeuScrollTop.scrollToTop()}"
82
91
  >
92
+ <leu-icon name="arrowUp"></leu-icon>
83
93
  </leu-button>
84
94
  </div>
85
95
  `
@@ -1,6 +1,5 @@
1
- import { defineElement } from "../../lib/defineElement.js"
2
1
  import { LeuScrollTop } from "./ScrollTop.js"
3
2
 
4
3
  export { LeuScrollTop }
5
4
 
6
- defineElement("scroll-top", LeuScrollTop)
5
+ LeuScrollTop.define("leu-scroll-top")