@statistikzh/leu 0.24.1 → 0.25.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 (536) hide show
  1. package/.github/workflows/publish.yml +1 -8
  2. package/.release-please-manifest.json +1 -1
  3. package/.storybook/main.ts +18 -53
  4. package/.storybook/manager.ts +1 -4
  5. package/.storybook/preview.ts +23 -16
  6. package/.storybook/theme.ts +1 -1
  7. package/CHANGELOG.md +21 -0
  8. package/dist/Accordion-CDNyrB8d.js +241 -0
  9. package/dist/Accordion.d.ts +44 -44
  10. package/dist/Accordion.js +2 -249
  11. package/dist/Button-DSGPIcjm.d.ts +93 -0
  12. package/dist/Button-EdS9xr2J.js +524 -0
  13. package/dist/Button.d.ts +2 -85
  14. package/dist/Button.js +4 -504
  15. package/dist/ButtonGroup-BQqf8o_d.js +88 -0
  16. package/dist/ButtonGroup.d.ts +19 -19
  17. package/dist/ButtonGroup.js +5 -101
  18. package/dist/ChartWrapper-LiNHTNRw.js +158 -0
  19. package/dist/ChartWrapper.d.ts +26 -26
  20. package/dist/ChartWrapper.js +3 -163
  21. package/dist/Checkbox-BtDWmPab.js +198 -0
  22. package/dist/Checkbox.d.ts +35 -27
  23. package/dist/Checkbox.js +4 -157
  24. package/dist/CheckboxGroup-C8MbwW9u.js +81 -0
  25. package/dist/CheckboxGroup.d.ts +18 -18
  26. package/dist/CheckboxGroup.js +5 -82
  27. package/dist/Chip-Ch09jjYi.js +171 -0
  28. package/dist/Chip-DLKM9P7v.d.ts +18 -0
  29. package/dist/Chip.d.ts +2 -18
  30. package/dist/Chip.js +2 -166
  31. package/dist/ChipGroup-PvqVW-tm.js +125 -0
  32. package/dist/ChipGroup-Ta8Ht4jc.d.ts +42 -0
  33. package/dist/ChipGroup.d.ts +2 -43
  34. package/dist/ChipGroup.js +3 -132
  35. package/dist/ChipLink-BAxyQO2M.d.ts +17 -0
  36. package/dist/ChipLink.d.ts +2 -18
  37. package/dist/ChipLink.js +28 -28
  38. package/dist/ChipRemovable-DBjwt0CH.d.ts +25 -0
  39. package/dist/ChipRemovable.d.ts +2 -26
  40. package/dist/ChipRemovable.js +42 -43
  41. package/dist/ChipSelectable-CMJNcE4U.d.ts +32 -0
  42. package/dist/ChipSelectable.d.ts +2 -33
  43. package/dist/ChipSelectable.js +63 -72
  44. package/dist/Dialog-CV1JTkCn.js +241 -0
  45. package/dist/Dialog.d.ts +28 -28
  46. package/dist/Dialog.js +3 -240
  47. package/dist/Dropdown-DpFdFbA1.js +155 -0
  48. package/dist/Dropdown.d.ts +39 -41
  49. package/dist/Dropdown.js +8 -157
  50. package/dist/FileInput-5apX17JT.js +344 -0
  51. package/dist/FileInput.d.ts +56 -57
  52. package/dist/FileInput.js +6 -383
  53. package/dist/FormAssociatedMixin-BbFlza53.js +58 -0
  54. package/dist/FormAssociatedMixin-Cc74LjbC.d.ts +22 -0
  55. package/dist/Icon-DhAvH0XM.js +186 -0
  56. package/dist/Icon-Op80LrrO.d.ts +151 -0
  57. package/dist/Icon.d.ts +2 -4
  58. package/dist/Icon.js +2 -188
  59. package/dist/Input-CnEz-2dK.js +610 -0
  60. package/dist/Input-D2THgo7c.d.ts +169 -0
  61. package/dist/Input.d.ts +2 -166
  62. package/dist/Input.js +4 -626
  63. package/dist/LeuElement-B7NJzWwP.js +46 -0
  64. package/dist/LeuElement-pJFU18Xm.d.ts +11 -0
  65. package/dist/Menu-CQdx1ef3.d.ts +43 -0
  66. package/dist/Menu-DpiheIPk.js +136 -0
  67. package/dist/Menu.d.ts +2 -44
  68. package/dist/Menu.js +4 -157
  69. package/dist/MenuItem-CZTqGg5R.js +219 -0
  70. package/dist/MenuItem-QcgnRk_7.d.ts +63 -0
  71. package/dist/MenuItem.d.ts +2 -64
  72. package/dist/MenuItem.js +3 -227
  73. package/dist/Message-J4Kj7yHE.js +252 -0
  74. package/dist/Message.d.ts +53 -53
  75. package/dist/Message.js +3 -267
  76. package/dist/Pagination-Be8TcBoC.d.ts +76 -0
  77. package/dist/Pagination-CWqgusWZ.js +226 -0
  78. package/dist/Pagination.d.ts +2 -76
  79. package/dist/Pagination.js +6 -240
  80. package/dist/Placeholder-DMN6sMbp.js +95 -0
  81. package/dist/Placeholder.d.ts +15 -15
  82. package/dist/Placeholder.js +2 -89
  83. package/dist/Popup-Btgm2a3D.d.ts +61 -0
  84. package/dist/Popup-JQjuj26v.js +195 -0
  85. package/dist/Popup.d.ts +2 -62
  86. package/dist/Popup.js +2 -233
  87. package/dist/ProgressBar-CzN3fqiH.js +167 -0
  88. package/dist/ProgressBar.d.ts +21 -21
  89. package/dist/ProgressBar.js +2 -165
  90. package/dist/Radio-CX8aCsff.js +160 -0
  91. package/dist/Radio.d.ts +22 -22
  92. package/dist/Radio.js +2 -151
  93. package/dist/RadioGroup-CgEWQnC4.js +171 -0
  94. package/dist/RadioGroup.d.ts +35 -35
  95. package/dist/RadioGroup.js +3 -182
  96. package/dist/Range-DoW_ZdKm.js +496 -0
  97. package/dist/Range.d.ts +112 -112
  98. package/dist/Range.js +2 -586
  99. package/dist/ScrollTop-DxChetWq.js +130 -0
  100. package/dist/ScrollTop.d.ts +21 -21
  101. package/dist/ScrollTop.js +5 -118
  102. package/dist/Select-BCx79gOH.js +618 -0
  103. package/dist/Select.d.ts +130 -132
  104. package/dist/Select.js +9 -675
  105. package/dist/Spinner-CMo_o6Fy.d.ts +14 -0
  106. package/dist/Spinner-DJR4gv3Y.js +56 -0
  107. package/dist/Spinner.d.ts +2 -14
  108. package/dist/Spinner.js +2 -52
  109. package/dist/Table-DZz1ic3j.js +392 -0
  110. package/dist/Table.d.ts +61 -63
  111. package/dist/Table.js +7 -427
  112. package/dist/Tag-DsZS_8pl.js +76 -0
  113. package/dist/Tag.d.ts +8 -8
  114. package/dist/Tag.js +2 -74
  115. package/dist/VisuallyHidden-BkllVjlz.js +29 -0
  116. package/dist/VisuallyHidden-OeQvhxYn.d.ts +13 -0
  117. package/dist/VisuallyHidden.d.ts +2 -13
  118. package/dist/VisuallyHidden.js +2 -25
  119. package/dist/decorate-DwpAc4D0.js +9 -0
  120. package/dist/hasSlotController-BLtZurRh.d.ts +19 -0
  121. package/dist/hasSlotController-DjdfnOQp.js +38 -0
  122. package/dist/index.d.ts +33 -30
  123. package/dist/index.js +35 -45
  124. package/dist/leu-accordion.d.ts +7 -10
  125. package/dist/leu-accordion.js +4 -8
  126. package/dist/leu-button-group.d.ts +7 -10
  127. package/dist/leu-button-group.js +7 -12
  128. package/dist/leu-button.d.ts +7 -11
  129. package/dist/leu-button.js +6 -11
  130. package/dist/leu-chart-wrapper.d.ts +7 -12
  131. package/dist/leu-chart-wrapper.js +5 -9
  132. package/dist/leu-checkbox-group.d.ts +7 -10
  133. package/dist/leu-checkbox-group.js +7 -10
  134. package/dist/leu-checkbox.d.ts +7 -11
  135. package/dist/leu-checkbox.js +6 -8
  136. package/dist/leu-chip-group.d.ts +7 -12
  137. package/dist/leu-chip-group.js +5 -10
  138. package/dist/leu-chip-link.d.ts +7 -11
  139. package/dist/leu-chip-link.js +5 -8
  140. package/dist/leu-chip-removable.d.ts +7 -12
  141. package/dist/leu-chip-removable.js +6 -9
  142. package/dist/leu-chip-selectable.d.ts +7 -11
  143. package/dist/leu-chip-selectable.js +5 -8
  144. package/dist/leu-dialog.d.ts +7 -13
  145. package/dist/leu-dialog.js +5 -11
  146. package/dist/leu-dropdown.d.ts +7 -18
  147. package/dist/leu-dropdown.js +10 -17
  148. package/dist/leu-file-input.d.ts +7 -13
  149. package/dist/leu-file-input.js +8 -13
  150. package/dist/leu-icon.d.ts +7 -10
  151. package/dist/leu-icon.js +4 -7
  152. package/dist/leu-input.d.ts +7 -12
  153. package/dist/leu-input.js +6 -12
  154. package/dist/leu-menu-item.d.ts +7 -11
  155. package/dist/leu-menu-item.js +5 -9
  156. package/dist/leu-menu.d.ts +7 -12
  157. package/dist/leu-menu.js +6 -10
  158. package/dist/leu-message.d.ts +7 -11
  159. package/dist/leu-message.js +5 -10
  160. package/dist/leu-pagination.d.ts +7 -13
  161. package/dist/leu-pagination.js +8 -14
  162. package/dist/leu-placeholder.d.ts +7 -10
  163. package/dist/leu-placeholder.js +4 -5
  164. package/dist/leu-popup.d.ts +7 -11
  165. package/dist/leu-popup.js +4 -8
  166. package/dist/leu-progress-bar.d.ts +7 -10
  167. package/dist/leu-progress-bar.js +4 -8
  168. package/dist/leu-radio-group.d.ts +7 -10
  169. package/dist/leu-radio-group.js +5 -9
  170. package/dist/leu-radio.d.ts +7 -10
  171. package/dist/leu-radio.js +4 -7
  172. package/dist/leu-range.d.ts +7 -10
  173. package/dist/leu-range.js +4 -9
  174. package/dist/leu-scroll-top.d.ts +7 -12
  175. package/dist/leu-scroll-top.js +7 -13
  176. package/dist/leu-select.d.ts +7 -19
  177. package/dist/leu-select.js +11 -19
  178. package/dist/leu-spinner.d.ts +7 -10
  179. package/dist/leu-spinner.js +4 -5
  180. package/dist/leu-table.d.ts +7 -14
  181. package/dist/leu-table.js +9 -17
  182. package/dist/leu-tag.d.ts +7 -10
  183. package/dist/leu-tag.js +4 -7
  184. package/dist/leu-visually-hidden.d.ts +7 -10
  185. package/dist/leu-visually-hidden.js +4 -5
  186. package/dist/theme.css +1 -0
  187. package/dist/utils-hfk5Nwy8.js +28 -0
  188. package/dist/vscode.html-custom-data.json +43 -49
  189. package/dist/vue/index.d.ts +54 -60
  190. package/dist/web-types.json +89 -105
  191. package/eslint.config.mjs +79 -0
  192. package/package.json +45 -62
  193. package/scripts/generate-component/templates/stories/[name].stories.ts +1 -1
  194. package/src/components/accordion/Accordion.ts +1 -1
  195. package/src/components/button/Button.ts +62 -3
  196. package/src/components/button/test/button.test.ts +185 -7
  197. package/src/components/button-group/ButtonGroup.ts +1 -6
  198. package/src/components/button-group/stories/button-group.stories.ts +1 -1
  199. package/src/components/chart-wrapper/ChartWrapper.ts +1 -1
  200. package/src/components/chart-wrapper/stories/chart-wrapper.stories.ts +1 -1
  201. package/src/components/checkbox/Checkbox.ts +76 -12
  202. package/src/components/checkbox/CheckboxGroup.ts +1 -1
  203. package/src/components/checkbox/checkbox.css +4 -0
  204. package/src/components/checkbox/stories/checkbox.stories.ts +26 -3
  205. package/src/components/checkbox/test/checkbox.test.ts +147 -3
  206. package/src/components/chip/Chip.ts +1 -1
  207. package/src/components/chip/ChipGroup.ts +2 -2
  208. package/src/components/chip/stories/chip-removable.stories.ts +1 -1
  209. package/src/components/chip/test/chip-removable.test.ts +2 -2
  210. package/src/components/dialog/Dialog.ts +1 -1
  211. package/src/components/dialog/stories/dialog.stories.ts +0 -2
  212. package/src/components/dropdown/Dropdown.ts +1 -1
  213. package/src/components/dropdown/stories/dropdown.stories.ts +1 -1
  214. package/src/components/file-input/FileInput.ts +18 -20
  215. package/src/components/file-input/stories/file-input.stories.ts +2 -2
  216. package/src/components/file-input/test/file-input.test.ts +14 -1
  217. package/src/components/icon/Icon.ts +1 -1
  218. package/src/components/input/Input.ts +18 -7
  219. package/src/components/input/stories/input.stories.ts +24 -21
  220. package/src/components/menu/Menu.ts +4 -4
  221. package/src/components/menu/MenuItem.ts +1 -1
  222. package/src/components/menu/stories/menu-item.stories.ts +0 -2
  223. package/src/components/message/Message.ts +1 -1
  224. package/src/components/message/stories/message.stories.ts +2 -2
  225. package/src/components/pagination/Pagination.ts +1 -1
  226. package/src/components/pagination/stories/pagination.stories.ts +3 -3
  227. package/src/components/pagination/test/pagination.test.ts +1 -1
  228. package/src/components/placeholder/Placeholder.ts +1 -1
  229. package/src/components/placeholder/stories/placeholder.stories.ts +1 -1
  230. package/src/components/popup/Popup.ts +1 -1
  231. package/src/components/progress-bar/ProgressBar.ts +1 -1
  232. package/src/components/progress-bar/stories/progress-bar.stories.ts +1 -1
  233. package/src/components/radio/Radio.ts +1 -1
  234. package/src/components/radio/RadioGroup.ts +5 -5
  235. package/src/components/range/Range.ts +1 -1
  236. package/src/components/range/stories/range.stories.ts +2 -2
  237. package/src/components/scroll-top/ScrollTop.ts +1 -1
  238. package/src/components/scroll-top/scroll-top.css +20 -4
  239. package/src/components/select/Select.ts +2 -5
  240. package/src/components/spinner/Spinner.ts +1 -1
  241. package/src/components/table/Table.ts +1 -1
  242. package/src/components/tag/Tag.ts +1 -1
  243. package/src/components/tag/stories/tag.stories.ts +1 -1
  244. package/src/components/visually-hidden/VisuallyHidden.ts +1 -1
  245. package/src/docs/contributing.mdx +1 -1
  246. package/src/docs/installation.mdx +1 -1
  247. package/src/docs/theme.mdx +1 -1
  248. package/src/docs/usage.mdx +1 -1
  249. package/src/global.d.ts +1 -1
  250. package/src/lib/LeuElement.ts +1 -1
  251. package/src/lib/mixins/FormAssociatedMixin.ts +115 -0
  252. package/src/lib/styleMap.ts +1 -1
  253. package/src/styles/theme.css +1 -0
  254. package/tsdown.config.ts +35 -0
  255. package/web-test-runner.config.mjs +20 -2
  256. package/.eslintrc.json +0 -57
  257. package/dist/Icon.d-itcQ94ym.d.ts +0 -151
  258. package/dist/LeuElement-jrR2M5pZ.js +0 -42
  259. package/dist/LeuElement.d-BevHqLUu.d.ts +0 -10
  260. package/dist/_tslib-CNEFicEt.js +0 -30
  261. package/dist/components/accordion/Accordion.d.ts +0 -49
  262. package/dist/components/accordion/Accordion.d.ts.map +0 -1
  263. package/dist/components/accordion/leu-accordion.d.ts +0 -8
  264. package/dist/components/accordion/leu-accordion.d.ts.map +0 -1
  265. package/dist/components/accordion/stories/accordion.stories.d.ts +0 -26
  266. package/dist/components/accordion/stories/accordion.stories.d.ts.map +0 -1
  267. package/dist/components/accordion/test/accordion.test.d.ts +0 -2
  268. package/dist/components/accordion/test/accordion.test.d.ts.map +0 -1
  269. package/dist/components/button/Button.d.ts +0 -81
  270. package/dist/components/button/Button.d.ts.map +0 -1
  271. package/dist/components/button/leu-button.d.ts +0 -8
  272. package/dist/components/button/leu-button.d.ts.map +0 -1
  273. package/dist/components/button/stories/button.stories.d.ts +0 -19
  274. package/dist/components/button/stories/button.stories.d.ts.map +0 -1
  275. package/dist/components/button/test/button.test.d.ts +0 -3
  276. package/dist/components/button/test/button.test.d.ts.map +0 -1
  277. package/dist/components/button-group/ButtonGroup.d.ts +0 -25
  278. package/dist/components/button-group/ButtonGroup.d.ts.map +0 -1
  279. package/dist/components/button-group/leu-button-group.d.ts +0 -8
  280. package/dist/components/button-group/leu-button-group.d.ts.map +0 -1
  281. package/dist/components/button-group/stories/button-group.stories.d.ts +0 -15
  282. package/dist/components/button-group/stories/button-group.stories.d.ts.map +0 -1
  283. package/dist/components/button-group/test/button-group.test.d.ts +0 -3
  284. package/dist/components/button-group/test/button-group.test.d.ts.map +0 -1
  285. package/dist/components/chart-wrapper/ChartWrapper.d.ts +0 -34
  286. package/dist/components/chart-wrapper/ChartWrapper.d.ts.map +0 -1
  287. package/dist/components/chart-wrapper/leu-chart-wrapper.d.ts +0 -8
  288. package/dist/components/chart-wrapper/leu-chart-wrapper.d.ts.map +0 -1
  289. package/dist/components/chart-wrapper/stories/chart-wrapper.stories.d.ts +0 -47
  290. package/dist/components/chart-wrapper/stories/chart-wrapper.stories.d.ts.map +0 -1
  291. package/dist/components/chart-wrapper/test/chart-wrapper.test.d.ts +0 -2
  292. package/dist/components/chart-wrapper/test/chart-wrapper.test.d.ts.map +0 -1
  293. package/dist/components/checkbox/Checkbox.d.ts +0 -28
  294. package/dist/components/checkbox/Checkbox.d.ts.map +0 -1
  295. package/dist/components/checkbox/CheckboxGroup.d.ts +0 -22
  296. package/dist/components/checkbox/CheckboxGroup.d.ts.map +0 -1
  297. package/dist/components/checkbox/leu-checkbox-group.d.ts +0 -8
  298. package/dist/components/checkbox/leu-checkbox-group.d.ts.map +0 -1
  299. package/dist/components/checkbox/leu-checkbox.d.ts +0 -8
  300. package/dist/components/checkbox/leu-checkbox.d.ts.map +0 -1
  301. package/dist/components/checkbox/stories/checkbox-group.stories.d.ts +0 -29
  302. package/dist/components/checkbox/stories/checkbox-group.stories.d.ts.map +0 -1
  303. package/dist/components/checkbox/stories/checkbox.stories.d.ts +0 -22
  304. package/dist/components/checkbox/stories/checkbox.stories.d.ts.map +0 -1
  305. package/dist/components/checkbox/test/checkbox-group.test.d.ts +0 -3
  306. package/dist/components/checkbox/test/checkbox-group.test.d.ts.map +0 -1
  307. package/dist/components/checkbox/test/checkbox.test.d.ts +0 -2
  308. package/dist/components/checkbox/test/checkbox.test.d.ts.map +0 -1
  309. package/dist/components/chip/Chip.d.ts +0 -15
  310. package/dist/components/chip/Chip.d.ts.map +0 -1
  311. package/dist/components/chip/ChipGroup.d.ts +0 -38
  312. package/dist/components/chip/ChipGroup.d.ts.map +0 -1
  313. package/dist/components/chip/ChipLink.d.ts +0 -13
  314. package/dist/components/chip/ChipLink.d.ts.map +0 -1
  315. package/dist/components/chip/ChipRemovable.d.ts +0 -21
  316. package/dist/components/chip/ChipRemovable.d.ts.map +0 -1
  317. package/dist/components/chip/ChipSelectable.d.ts +0 -28
  318. package/dist/components/chip/ChipSelectable.d.ts.map +0 -1
  319. package/dist/components/chip/exports.d.ts +0 -5
  320. package/dist/components/chip/exports.d.ts.map +0 -1
  321. package/dist/components/chip/leu-chip-group.d.ts +0 -8
  322. package/dist/components/chip/leu-chip-group.d.ts.map +0 -1
  323. package/dist/components/chip/leu-chip-link.d.ts +0 -8
  324. package/dist/components/chip/leu-chip-link.d.ts.map +0 -1
  325. package/dist/components/chip/leu-chip-removable.d.ts +0 -8
  326. package/dist/components/chip/leu-chip-removable.d.ts.map +0 -1
  327. package/dist/components/chip/leu-chip-selectable.d.ts +0 -8
  328. package/dist/components/chip/leu-chip-selectable.d.ts.map +0 -1
  329. package/dist/components/chip/stories/chip-group.stories.d.ts +0 -40
  330. package/dist/components/chip/stories/chip-group.stories.d.ts.map +0 -1
  331. package/dist/components/chip/stories/chip-link.stories.d.ts +0 -27
  332. package/dist/components/chip/stories/chip-link.stories.d.ts.map +0 -1
  333. package/dist/components/chip/stories/chip-removable.stories.d.ts +0 -21
  334. package/dist/components/chip/stories/chip-removable.stories.d.ts.map +0 -1
  335. package/dist/components/chip/stories/chip-selectable.stories.d.ts +0 -35
  336. package/dist/components/chip/stories/chip-selectable.stories.d.ts.map +0 -1
  337. package/dist/components/chip/test/chip-group.test.d.ts +0 -4
  338. package/dist/components/chip/test/chip-group.test.d.ts.map +0 -1
  339. package/dist/components/chip/test/chip-link.test.d.ts +0 -2
  340. package/dist/components/chip/test/chip-link.test.d.ts.map +0 -1
  341. package/dist/components/chip/test/chip-removable.test.d.ts +0 -2
  342. package/dist/components/chip/test/chip-removable.test.d.ts.map +0 -1
  343. package/dist/components/chip/test/chip-selectable.test.d.ts +0 -2
  344. package/dist/components/chip/test/chip-selectable.test.d.ts.map +0 -1
  345. package/dist/components/chip/test/chip.test.d.ts +0 -2
  346. package/dist/components/chip/test/chip.test.d.ts.map +0 -1
  347. package/dist/components/dialog/Dialog.d.ts +0 -29
  348. package/dist/components/dialog/Dialog.d.ts.map +0 -1
  349. package/dist/components/dialog/leu-dialog.d.ts +0 -8
  350. package/dist/components/dialog/leu-dialog.d.ts.map +0 -1
  351. package/dist/components/dialog/stories/dialog.stories.d.ts +0 -19
  352. package/dist/components/dialog/stories/dialog.stories.d.ts.map +0 -1
  353. package/dist/components/dialog/test/dialog.test.d.ts +0 -2
  354. package/dist/components/dialog/test/dialog.test.d.ts.map +0 -1
  355. package/dist/components/dropdown/Dropdown.d.ts +0 -40
  356. package/dist/components/dropdown/Dropdown.d.ts.map +0 -1
  357. package/dist/components/dropdown/leu-dropdown.d.ts +0 -8
  358. package/dist/components/dropdown/leu-dropdown.d.ts.map +0 -1
  359. package/dist/components/dropdown/stories/dropdown.stories.d.ts +0 -25
  360. package/dist/components/dropdown/stories/dropdown.stories.d.ts.map +0 -1
  361. package/dist/components/dropdown/test/dropdown.test.d.ts +0 -2
  362. package/dist/components/dropdown/test/dropdown.test.d.ts.map +0 -1
  363. package/dist/components/file-input/FileInput.d.ts +0 -62
  364. package/dist/components/file-input/FileInput.d.ts.map +0 -1
  365. package/dist/components/file-input/leu-file-input.d.ts +0 -8
  366. package/dist/components/file-input/leu-file-input.d.ts.map +0 -1
  367. package/dist/components/file-input/stories/file-input.stories.d.ts +0 -34
  368. package/dist/components/file-input/stories/file-input.stories.d.ts.map +0 -1
  369. package/dist/components/file-input/test/file-input.test.d.ts +0 -2
  370. package/dist/components/file-input/test/file-input.test.d.ts.map +0 -1
  371. package/dist/components/icon/Icon.d.ts +0 -20
  372. package/dist/components/icon/Icon.d.ts.map +0 -1
  373. package/dist/components/icon/leu-icon.d.ts +0 -8
  374. package/dist/components/icon/leu-icon.d.ts.map +0 -1
  375. package/dist/components/icon/paths.d.ts +0 -127
  376. package/dist/components/icon/paths.d.ts.map +0 -1
  377. package/dist/components/icon/stories/icon.stories.d.ts +0 -32
  378. package/dist/components/icon/stories/icon.stories.d.ts.map +0 -1
  379. package/dist/components/icon/test/icon.test.d.ts +0 -2
  380. package/dist/components/icon/test/icon.test.d.ts.map +0 -1
  381. package/dist/components/input/Input.d.ts +0 -163
  382. package/dist/components/input/Input.d.ts.map +0 -1
  383. package/dist/components/input/leu-input.d.ts +0 -8
  384. package/dist/components/input/leu-input.d.ts.map +0 -1
  385. package/dist/components/input/stories/input.stories.d.ts +0 -35
  386. package/dist/components/input/stories/input.stories.d.ts.map +0 -1
  387. package/dist/components/input/test/input.test.d.ts +0 -2
  388. package/dist/components/input/test/input.test.d.ts.map +0 -1
  389. package/dist/components/menu/Menu.d.ts +0 -39
  390. package/dist/components/menu/Menu.d.ts.map +0 -1
  391. package/dist/components/menu/MenuItem.d.ts +0 -61
  392. package/dist/components/menu/MenuItem.d.ts.map +0 -1
  393. package/dist/components/menu/leu-menu-item.d.ts +0 -8
  394. package/dist/components/menu/leu-menu-item.d.ts.map +0 -1
  395. package/dist/components/menu/leu-menu.d.ts +0 -8
  396. package/dist/components/menu/leu-menu.d.ts.map +0 -1
  397. package/dist/components/menu/stories/menu-item.stories.d.ts +0 -24
  398. package/dist/components/menu/stories/menu-item.stories.d.ts.map +0 -1
  399. package/dist/components/menu/stories/menu.stories.d.ts +0 -26
  400. package/dist/components/menu/stories/menu.stories.d.ts.map +0 -1
  401. package/dist/components/menu/test/menu-item.test.d.ts +0 -3
  402. package/dist/components/menu/test/menu-item.test.d.ts.map +0 -1
  403. package/dist/components/menu/test/menu.test.d.ts +0 -4
  404. package/dist/components/menu/test/menu.test.d.ts.map +0 -1
  405. package/dist/components/message/Message.d.ts +0 -59
  406. package/dist/components/message/Message.d.ts.map +0 -1
  407. package/dist/components/message/leu-message.d.ts +0 -8
  408. package/dist/components/message/leu-message.d.ts.map +0 -1
  409. package/dist/components/message/stories/message.stories.d.ts +0 -179
  410. package/dist/components/message/stories/message.stories.d.ts.map +0 -1
  411. package/dist/components/message/test/message.test.d.ts +0 -2
  412. package/dist/components/message/test/message.test.d.ts.map +0 -1
  413. package/dist/components/pagination/Pagination.d.ts +0 -72
  414. package/dist/components/pagination/Pagination.d.ts.map +0 -1
  415. package/dist/components/pagination/leu-pagination.d.ts +0 -8
  416. package/dist/components/pagination/leu-pagination.d.ts.map +0 -1
  417. package/dist/components/pagination/stories/pagination.stories.d.ts +0 -25
  418. package/dist/components/pagination/stories/pagination.stories.d.ts.map +0 -1
  419. package/dist/components/pagination/test/pagination.test.d.ts +0 -2
  420. package/dist/components/pagination/test/pagination.test.d.ts.map +0 -1
  421. package/dist/components/placeholder/Placeholder.d.ts +0 -23
  422. package/dist/components/placeholder/Placeholder.d.ts.map +0 -1
  423. package/dist/components/placeholder/leu-placeholder.d.ts +0 -8
  424. package/dist/components/placeholder/leu-placeholder.d.ts.map +0 -1
  425. package/dist/components/placeholder/stories/placeholder.stories.d.ts +0 -27
  426. package/dist/components/placeholder/stories/placeholder.stories.d.ts.map +0 -1
  427. package/dist/components/placeholder/test/placeholder.test.d.ts +0 -2
  428. package/dist/components/placeholder/test/placeholder.test.d.ts.map +0 -1
  429. package/dist/components/popup/Popup.d.ts +0 -57
  430. package/dist/components/popup/Popup.d.ts.map +0 -1
  431. package/dist/components/popup/leu-popup.d.ts +0 -8
  432. package/dist/components/popup/leu-popup.d.ts.map +0 -1
  433. package/dist/components/popup/stories/popup.stories.d.ts +0 -28
  434. package/dist/components/popup/stories/popup.stories.d.ts.map +0 -1
  435. package/dist/components/popup/test/popup.test.d.ts +0 -2
  436. package/dist/components/popup/test/popup.test.d.ts.map +0 -1
  437. package/dist/components/progress-bar/ProgressBar.d.ts +0 -25
  438. package/dist/components/progress-bar/ProgressBar.d.ts.map +0 -1
  439. package/dist/components/progress-bar/leu-progress-bar.d.ts +0 -8
  440. package/dist/components/progress-bar/leu-progress-bar.d.ts.map +0 -1
  441. package/dist/components/progress-bar/stories/progress-bar.stories.d.ts +0 -48
  442. package/dist/components/progress-bar/stories/progress-bar.stories.d.ts.map +0 -1
  443. package/dist/components/progress-bar/test/progress-bar.test.d.ts +0 -2
  444. package/dist/components/progress-bar/test/progress-bar.test.d.ts.map +0 -1
  445. package/dist/components/radio/Radio.d.ts +0 -24
  446. package/dist/components/radio/Radio.d.ts.map +0 -1
  447. package/dist/components/radio/RadioGroup.d.ts +0 -39
  448. package/dist/components/radio/RadioGroup.d.ts.map +0 -1
  449. package/dist/components/radio/leu-radio-group.d.ts +0 -8
  450. package/dist/components/radio/leu-radio-group.d.ts.map +0 -1
  451. package/dist/components/radio/leu-radio.d.ts +0 -8
  452. package/dist/components/radio/leu-radio.d.ts.map +0 -1
  453. package/dist/components/radio/stories/radio-group.stories.d.ts +0 -29
  454. package/dist/components/radio/stories/radio-group.stories.d.ts.map +0 -1
  455. package/dist/components/radio/stories/radio.stories.d.ts +0 -22
  456. package/dist/components/radio/stories/radio.stories.d.ts.map +0 -1
  457. package/dist/components/radio/test/radio-group.test.d.ts +0 -3
  458. package/dist/components/radio/test/radio-group.test.d.ts.map +0 -1
  459. package/dist/components/radio/test/radio.test.d.ts +0 -2
  460. package/dist/components/radio/test/radio.test.d.ts.map +0 -1
  461. package/dist/components/range/Range.d.ts +0 -116
  462. package/dist/components/range/Range.d.ts.map +0 -1
  463. package/dist/components/range/leu-range.d.ts +0 -8
  464. package/dist/components/range/leu-range.d.ts.map +0 -1
  465. package/dist/components/range/stories/range.stories.d.ts +0 -231
  466. package/dist/components/range/stories/range.stories.d.ts.map +0 -1
  467. package/dist/components/range/test/range.test.d.ts +0 -2
  468. package/dist/components/range/test/range.test.d.ts.map +0 -1
  469. package/dist/components/scroll-top/ScrollTop.d.ts +0 -23
  470. package/dist/components/scroll-top/ScrollTop.d.ts.map +0 -1
  471. package/dist/components/scroll-top/leu-scroll-top.d.ts +0 -8
  472. package/dist/components/scroll-top/leu-scroll-top.d.ts.map +0 -1
  473. package/dist/components/scroll-top/stories/scroll-top.stories.d.ts +0 -8
  474. package/dist/components/scroll-top/stories/scroll-top.stories.d.ts.map +0 -1
  475. package/dist/components/scroll-top/test/scroll-top.test.d.ts +0 -2
  476. package/dist/components/scroll-top/test/scroll-top.test.d.ts.map +0 -1
  477. package/dist/components/select/Select.d.ts +0 -145
  478. package/dist/components/select/Select.d.ts.map +0 -1
  479. package/dist/components/select/leu-select.d.ts +0 -8
  480. package/dist/components/select/leu-select.d.ts.map +0 -1
  481. package/dist/components/select/stories/select.stories.d.ts +0 -23
  482. package/dist/components/select/stories/select.stories.d.ts.map +0 -1
  483. package/dist/components/select/test/fixtures.d.ts +0 -2
  484. package/dist/components/select/test/fixtures.d.ts.map +0 -1
  485. package/dist/components/select/test/select.test.d.ts +0 -3
  486. package/dist/components/select/test/select.test.d.ts.map +0 -1
  487. package/dist/components/spinner/Spinner.d.ts +0 -10
  488. package/dist/components/spinner/Spinner.d.ts.map +0 -1
  489. package/dist/components/spinner/leu-spinner.d.ts +0 -8
  490. package/dist/components/spinner/leu-spinner.d.ts.map +0 -1
  491. package/dist/components/spinner/stories/spinner.stories.d.ts +0 -16
  492. package/dist/components/spinner/stories/spinner.stories.d.ts.map +0 -1
  493. package/dist/components/spinner/test/spinner.test.d.ts +0 -2
  494. package/dist/components/spinner/test/spinner.test.d.ts.map +0 -1
  495. package/dist/components/table/Table.d.ts +0 -65
  496. package/dist/components/table/Table.d.ts.map +0 -1
  497. package/dist/components/table/leu-table.d.ts +0 -8
  498. package/dist/components/table/leu-table.d.ts.map +0 -1
  499. package/dist/components/table/stories/table.stories.d.ts +0 -15
  500. package/dist/components/table/stories/table.stories.d.ts.map +0 -1
  501. package/dist/components/table/test/table.test.d.ts +0 -2
  502. package/dist/components/table/test/table.test.d.ts.map +0 -1
  503. package/dist/components/tag/Tag.d.ts +0 -13
  504. package/dist/components/tag/Tag.d.ts.map +0 -1
  505. package/dist/components/tag/leu-tag.d.ts +0 -8
  506. package/dist/components/tag/leu-tag.d.ts.map +0 -1
  507. package/dist/components/tag/stories/tag.stories.d.ts +0 -136
  508. package/dist/components/tag/stories/tag.stories.d.ts.map +0 -1
  509. package/dist/components/tag/test/tag.test.d.ts +0 -2
  510. package/dist/components/tag/test/tag.test.d.ts.map +0 -1
  511. package/dist/components/visually-hidden/VisuallyHidden.d.ts +0 -9
  512. package/dist/components/visually-hidden/VisuallyHidden.d.ts.map +0 -1
  513. package/dist/components/visually-hidden/leu-visually-hidden.d.ts +0 -8
  514. package/dist/components/visually-hidden/leu-visually-hidden.d.ts.map +0 -1
  515. package/dist/components/visually-hidden/stories/visually-hidden.stories.d.ts +0 -13
  516. package/dist/components/visually-hidden/stories/visually-hidden.stories.d.ts.map +0 -1
  517. package/dist/components/visually-hidden/test/visually-hidden.test.d.ts +0 -2
  518. package/dist/components/visually-hidden/test/visually-hidden.test.d.ts.map +0 -1
  519. package/dist/hasSlotController-Bm2tipvG.js +0 -53
  520. package/dist/hasSlotController.d-emXwVXWF.d.ts +0 -23
  521. package/dist/index.d.ts.map +0 -1
  522. package/dist/lib/LeuElement.d.ts +0 -8
  523. package/dist/lib/LeuElement.d.ts.map +0 -1
  524. package/dist/lib/a11y.d.ts +0 -11
  525. package/dist/lib/a11y.d.ts.map +0 -1
  526. package/dist/lib/hasSlotController.d.ts +0 -20
  527. package/dist/lib/hasSlotController.d.ts.map +0 -1
  528. package/dist/lib/styleMap.d.ts +0 -61
  529. package/dist/lib/styleMap.d.ts.map +0 -1
  530. package/dist/lib/utils.d.ts +0 -23
  531. package/dist/lib/utils.d.ts.map +0 -1
  532. package/dist/styles/style.stories.d.ts +0 -6
  533. package/dist/styles/style.stories.d.ts.map +0 -1
  534. package/dist/utils-DBGsNSJW.js +0 -33
  535. package/rollup.config.js +0 -94
  536. package/web-dev-server.config.mjs +0 -30
@@ -1,15 +1,16 @@
1
- import { html } from "lit"
1
+ import { html, PropertyValues } from "lit"
2
2
  import { property } from "lit/decorators.js"
3
3
 
4
4
  import { LeuElement } from "../../lib/LeuElement.js"
5
+ import { FormAssociatedMixin } from "../../lib/mixins/FormAssociatedMixin.js"
5
6
  import { LeuIcon } from "../icon/Icon.js"
6
7
 
7
- import styles from "./checkbox.css"
8
+ import styles from "./checkbox.css?inline"
8
9
 
9
10
  /**
10
11
  * @tagname leu-checkbox
11
12
  */
12
- export class LeuCheckbox extends LeuElement {
13
+ export class LeuCheckbox extends FormAssociatedMixin(LeuElement) {
13
14
  static dependencies = {
14
15
  "leu-icon": LeuIcon,
15
16
  }
@@ -23,18 +24,58 @@ export class LeuCheckbox extends LeuElement {
23
24
  }
24
25
 
25
26
  @property({ type: Boolean, reflect: true })
26
- checked: boolean = false
27
+ required: boolean = false
27
28
 
28
- @property({ type: Boolean, reflect: true })
29
- disabled: boolean = false
29
+ @property({ type: Boolean, reflect: true, attribute: "checked" })
30
+ defaultChecked: boolean = false
30
31
 
31
- @property({ type: String, reflect: true })
32
- value: string = ""
32
+ protected _checked: boolean
33
+
34
+ @property({ type: Boolean, attribute: false })
35
+ set checked(isChecked: boolean) {
36
+ this._checked = isChecked
37
+ }
38
+
39
+ get checked(): boolean {
40
+ if (typeof this._checked === "boolean") {
41
+ return this._checked
42
+ }
43
+
44
+ return this.defaultChecked
45
+ }
33
46
 
34
47
  @property({ type: String, reflect: true })
35
- name: string = ""
48
+ value: string
49
+
50
+ willUpdate(changedProperties: PropertyValues<this>): void {
51
+ super.willUpdate(changedProperties)
52
+ let checkedChanged = false
53
+
54
+ // Match the bevavior of native checkboxes.
55
+ // Changes to the defaultChecked property only hav an effect
56
+ // if the user has not interacted with the checkbox yet.
57
+ if (
58
+ changedProperties.has("defaultChecked") &&
59
+ !changedProperties.has("checked") &&
60
+ !this.hasInteracted
61
+ ) {
62
+ this.checked = this.defaultChecked
63
+ checkedChanged = true
64
+ }
65
+
66
+ if (
67
+ checkedChanged ||
68
+ changedProperties.has("checked") ||
69
+ changedProperties.has("value") ||
70
+ changedProperties.has("name") ||
71
+ changedProperties.has("disabled")
72
+ ) {
73
+ this.setFormValue()
74
+ }
75
+ }
36
76
 
37
77
  private handleChange(event: Event & { target: HTMLInputElement }) {
78
+ this.hasInteracted = true
38
79
  this.checked = event.target.checked
39
80
 
40
81
  const customEvent = new CustomEvent(event.type, event)
@@ -42,13 +83,35 @@ export class LeuCheckbox extends LeuElement {
42
83
  }
43
84
 
44
85
  private handleInput(event: InputEvent & { target: HTMLInputElement }) {
86
+ this.hasInteracted = true
45
87
  this.checked = event.target.checked
46
88
  }
47
89
 
90
+ public formResetCallback() {
91
+ this.checked = this.defaultChecked
92
+ super.formResetCallback()
93
+ }
94
+
95
+ setFormValue() {
96
+ this.internals.setFormValue(
97
+ this.checked && !this.disabled ? (this.value ?? "on") : null,
98
+ )
99
+
100
+ if (this.required && !this.checked) {
101
+ // @todo i18n and/or custom validation message
102
+ this.internals.setValidity(
103
+ { valueMissing: true },
104
+ "Bitte klicken Sie dieses Kästchen an, um fortfahren zu können.",
105
+ )
106
+ } else {
107
+ this.internals.setValidity({})
108
+ }
109
+ }
110
+
48
111
  render() {
49
112
  return html`
50
113
  <input
51
- id=${`checkbox-${this.name}`}
114
+ id="checkbox"
52
115
  class="checkbox"
53
116
  type="checkbox"
54
117
  name="${this.name}"
@@ -56,9 +119,10 @@ export class LeuCheckbox extends LeuElement {
56
119
  @input=${this.handleInput}
57
120
  .checked=${this.checked}
58
121
  ?disabled=${this.disabled}
59
- .value=${this.value ?? ""}
122
+ .value=${this.value}
123
+ ?required=${this.required}
60
124
  />
61
- <label for=${`checkbox-${this.name}`} class="label"><slot></slot></label>
125
+ <label for="checkbox" class="label"><slot></slot></label>
62
126
  <leu-icon class="icon" name="check"></leu-icon>
63
127
  `
64
128
  }
@@ -4,7 +4,7 @@ import { property } from "lit/decorators.js"
4
4
 
5
5
  import { LeuElement } from "../../lib/LeuElement.js"
6
6
 
7
- import styles from "./checkbox-group.css"
7
+ import styles from "./checkbox-group.css?inline"
8
8
  import { LeuCheckbox } from "./Checkbox.js"
9
9
 
10
10
  /**
@@ -67,6 +67,10 @@
67
67
  cursor: not-allowed;
68
68
  }
69
69
 
70
+ .checkbox:required + .label::after {
71
+ content: "*";
72
+ }
73
+
70
74
  .icon {
71
75
  position: absolute;
72
76
  display: block;
@@ -8,6 +8,9 @@ export default {
8
8
  label: {
9
9
  control: "text",
10
10
  },
11
+ defaultChecked: {
12
+ control: "boolean",
13
+ },
11
14
  },
12
15
  parameters: {
13
16
  design: {
@@ -17,13 +20,23 @@ export default {
17
20
  },
18
21
  }
19
22
 
20
- function Template({ label = "Label", value, checked, disabled, name = "" }) {
23
+ function Template({
24
+ label = "Label",
25
+ value,
26
+ checked,
27
+ defaultChecked,
28
+ disabled,
29
+ name = "",
30
+ required,
31
+ }) {
21
32
  return html`
22
33
  <leu-checkbox
23
- .value=${value}
24
- ?checked=${checked}
34
+ value=${value}
35
+ .checked=${checked}
36
+ ?checked=${defaultChecked}
25
37
  ?disabled=${disabled}
26
38
  name=${name}
39
+ ?required=${required}
27
40
  >
28
41
  ${label}
29
42
  </leu-checkbox>
@@ -37,6 +50,11 @@ Checked.args = {
37
50
  checked: true,
38
51
  }
39
52
 
53
+ export const DefaultChecked = Template.bind({})
54
+ DefaultChecked.args = {
55
+ defaultChecked: true,
56
+ }
57
+
40
58
  export const Disabled = Template.bind({})
41
59
  Disabled.args = {
42
60
  disabled: true,
@@ -47,3 +65,8 @@ CheckedDisabled.args = {
47
65
  checked: true,
48
66
  disabled: true,
49
67
  }
68
+
69
+ export const Required = Template.bind({})
70
+ Required.args = {
71
+ required: true,
72
+ }
@@ -3,9 +3,10 @@ import { fixture, expect, elementUpdated, oneEvent } from "@open-wc/testing"
3
3
  import { sendKeys } from "@web/test-runner-commands"
4
4
 
5
5
  import "../leu-checkbox.js"
6
+ import type { LeuCheckbox } from "../leu-checkbox.js"
6
7
 
7
8
  async function defaultFixture() {
8
- return fixture(html`
9
+ return fixture<LeuCheckbox>(html`
9
10
  <leu-checkbox value="2">Das ist ein Label</leu-checkbox>
10
11
  `)
11
12
  }
@@ -86,7 +87,7 @@ describe("LeuCheckbox", () => {
86
87
  const checkbox = el.shadowRoot.querySelector("input")
87
88
 
88
89
  setTimeout(() => checkbox.click())
89
- const event = await oneEvent(el, "change")
90
+ const event = await oneEvent(el, "change", false)
90
91
 
91
92
  expect(event).to.exist
92
93
  })
@@ -96,8 +97,151 @@ describe("LeuCheckbox", () => {
96
97
  const checkbox = el.shadowRoot.querySelector("input")
97
98
 
98
99
  setTimeout(() => checkbox.click())
99
- const event = await oneEvent(el, "input")
100
+ const event = await oneEvent(el, "input", false)
100
101
 
101
102
  expect(event).to.exist
102
103
  })
104
+
105
+ it("appends the value to the form data when checked", async () => {
106
+ const form = await fixture<HTMLFormElement>(html`
107
+ <form>
108
+ <leu-checkbox name="checkbox" value="2" checked></leu-checkbox>
109
+ </form>
110
+ `)
111
+
112
+ const formData = new FormData(form)
113
+ expect(formData.get("checkbox")).to.equal("2")
114
+ })
115
+
116
+ it("appends 'on' to the form data when checked and no value is set", async () => {
117
+ const form = await fixture<HTMLFormElement>(html`
118
+ <form>
119
+ <leu-checkbox name="checkbox" checked></leu-checkbox>
120
+ </form>
121
+ `)
122
+
123
+ let formData = new FormData(form)
124
+ expect(formData.get("checkbox")).to.equal("on")
125
+
126
+ const checkbox = form.querySelector<LeuCheckbox>("leu-checkbox")
127
+ checkbox.value = ""
128
+ await elementUpdated(checkbox)
129
+
130
+ formData = new FormData(form)
131
+ expect(formData.get("checkbox")).to.equal("")
132
+ })
133
+
134
+ it("does not append the value to the form data when unchecked", async () => {
135
+ const form = await fixture<HTMLFormElement>(html`
136
+ <form>
137
+ <leu-checkbox name="checkbox" value="2"></leu-checkbox>
138
+ </form>
139
+ `)
140
+
141
+ const formData = new FormData(form)
142
+ expect(formData.get("checkbox")).to.be.null
143
+ })
144
+
145
+ it("does not append the value to the form data when disabled", async () => {
146
+ const form = await fixture<HTMLFormElement>(html`
147
+ <form>
148
+ <leu-checkbox name="checkbox" value="2" checked disabled></leu-checkbox>
149
+ </form>
150
+ `)
151
+
152
+ const formData = new FormData(form)
153
+ expect(formData.get("checkbox")).to.be.null
154
+ })
155
+
156
+ it("resets to the default checked state when the form is reset", async () => {
157
+ const form = await fixture<HTMLFormElement>(html`
158
+ <form>
159
+ <leu-checkbox name="checkbox" value="2" checked></leu-checkbox>
160
+ <button type="reset">Reset</button>
161
+ </form>
162
+ `)
163
+
164
+ const checkbox = form.querySelector<LeuCheckbox>("leu-checkbox")
165
+ checkbox.checked = false
166
+ await elementUpdated(checkbox)
167
+
168
+ form.reset()
169
+ await elementUpdated(checkbox)
170
+
171
+ expect(checkbox.checked).to.be.true
172
+ })
173
+
174
+ it("updates the form data when the value and disabled state changes", async () => {
175
+ const form = await fixture<HTMLFormElement>(html`
176
+ <form>
177
+ <leu-checkbox name="checkbox" value="2"></leu-checkbox>
178
+ </form>
179
+ `)
180
+
181
+ const checkbox = form.querySelector<LeuCheckbox>("leu-checkbox")
182
+ checkbox.checked = true
183
+ await elementUpdated(checkbox)
184
+
185
+ let formData = new FormData(form)
186
+ expect(formData.get("checkbox")).to.equal("2")
187
+
188
+ checkbox.value = "another_value"
189
+ await elementUpdated(checkbox)
190
+
191
+ formData = new FormData(form)
192
+ expect(formData.get("checkbox")).to.be.equal("another_value")
193
+
194
+ checkbox.disabled = true
195
+ await elementUpdated(checkbox)
196
+
197
+ formData = new FormData(form)
198
+ expect(formData.get("checkbox")).to.be.null
199
+ })
200
+
201
+ it("updates the form data when the defaultChecked state changes before any interaction", async () => {
202
+ const form = await fixture<HTMLFormElement>(html`
203
+ <form>
204
+ <leu-checkbox name="checkbox" value="2" checked></leu-checkbox>
205
+ </form>
206
+ `)
207
+
208
+ // Reset the default value to unchecked. Should have an effect since the user has not interacted with the checkbox yet.
209
+ const checkbox = form.querySelector<LeuCheckbox>("leu-checkbox")
210
+ checkbox.defaultChecked = false
211
+ await elementUpdated(checkbox)
212
+
213
+ let formData = new FormData(form)
214
+ expect(formData.get("checkbox")).to.be.null
215
+
216
+ // Simulate user interaction by clicking the checkbox, which should check it and update the form data.
217
+ const innerCheckbox =
218
+ checkbox.shadowRoot.querySelector<HTMLInputElement>("input")
219
+ innerCheckbox.click()
220
+
221
+ await elementUpdated(checkbox)
222
+
223
+ formData = new FormData(form)
224
+ expect(formData.get("checkbox")).to.equal("2")
225
+
226
+ // This change of defaultChecked should not have an effect since the user has already interacted with the checkbox.
227
+ checkbox.defaultChecked = true
228
+ checkbox.checked = false
229
+ await elementUpdated(checkbox)
230
+
231
+ formData = new FormData(form)
232
+ expect(formData.get("checkbox")).to.be.null
233
+ })
234
+
235
+ it("should be invalid when the required attribute is set and not checked", async () => {
236
+ const form = await fixture<HTMLFormElement>(html`
237
+ <form>
238
+ <leu-checkbox name="checkbox" value="2" required></leu-checkbox>
239
+ </form>
240
+ `)
241
+
242
+ const checkbox = form.querySelector<LeuCheckbox>("leu-checkbox")
243
+
244
+ expect(checkbox.validity.valid).to.be.false
245
+ expect(form.checkValidity()).to.be.false
246
+ })
103
247
  })
@@ -1,7 +1,7 @@
1
1
  import { property } from "lit/decorators.js"
2
2
  import { LeuElement } from "../../lib/LeuElement.js"
3
3
 
4
- import styles from "./chip.css"
4
+ import styles from "./chip.css?inline"
5
5
 
6
6
  /* Design: https://www.figma.com/file/d6Pv21UVUbnBs3AdcZijHmbN/KTZH-Design-System?type=design&node-id=21161-184433&mode=design&t=Kjo5VDiqivihn8dh-11 */
7
7
 
@@ -3,7 +3,7 @@ import { property } from "lit/decorators.js"
3
3
 
4
4
  import { LeuElement } from "../../lib/LeuElement.js"
5
5
 
6
- import styles from "./chip-group.css"
6
+ import styles from "./chip-group.css?inline"
7
7
  import { LeuChipSelectable } from "./ChipSelectable.js"
8
8
 
9
9
  /**
@@ -87,7 +87,7 @@ export class LeuChipGroup extends LeuElement {
87
87
  protected handleInput = (e: Event & { target: LeuChipSelectable }) => {
88
88
  if (this.selectionMode === "single") {
89
89
  this.selectableItems.forEach((item) => {
90
- item.checked = item === e.target // eslint-disable-line no-param-reassign
90
+ item.checked = item === e.target
91
91
  })
92
92
  }
93
93
  }
@@ -1,5 +1,5 @@
1
1
  import { html } from "lit"
2
- import { action } from "@storybook/addon-actions"
2
+ import { action } from "storybook/actions"
3
3
 
4
4
  import "../leu-chip-removable.js"
5
5
 
@@ -77,7 +77,7 @@ describe("LeuChipRemovable", () => {
77
77
  })
78
78
 
79
79
  it("sends the value in the remove event", async () => {
80
- const el = await defaultFixture({ label: `Daten  ` }) // eslint-disable-line no-irregular-whitespace
80
+ const el = await defaultFixture({ label: `Daten  ` })
81
81
  const button = el.shadowRoot.querySelector("button")
82
82
 
83
83
  setTimeout(() => button.click())
@@ -94,7 +94,7 @@ describe("LeuChipRemovable", () => {
94
94
  })
95
95
 
96
96
  it("returns the value or label when getValue is called", async () => {
97
- const el = await defaultFixture({ label: `Daten  ` }) // eslint-disable-line no-irregular-whitespace
97
+ const el = await defaultFixture({ label: `Daten  ` })
98
98
 
99
99
  expect(el.getValue()).to.equal("Daten")
100
100
 
@@ -7,7 +7,7 @@ import { LeuElement } from "../../lib/LeuElement.js"
7
7
  import { HasSlotController } from "../../lib/hasSlotController.js"
8
8
  import { LeuIcon } from "../icon/Icon.js"
9
9
 
10
- import styles from "./dialog.css"
10
+ import styles from "./dialog.css?inline"
11
11
 
12
12
  /**
13
13
  * @tagname leu-dialog
@@ -72,7 +72,6 @@ function ActionButtonsTemplate({ label, sublabel }) {
72
72
  <leu-button
73
73
  variant="secondary"
74
74
  @click=${() => {
75
- // eslint-disable-next-line no-alert
76
75
  alert("Fenster wird geschlossen")
77
76
  closeDialog()
78
77
  }}
@@ -81,7 +80,6 @@ function ActionButtonsTemplate({ label, sublabel }) {
81
80
  </leu-button>
82
81
  <leu-button
83
82
  @click=${() => {
84
- // eslint-disable-next-line no-alert
85
83
  alert("Fenster wird offen gelassen")
86
84
  }}
87
85
  >
@@ -10,7 +10,7 @@ import { LeuMenu } from "../menu/Menu.js"
10
10
  import { LeuMenuItem } from "../menu/MenuItem.js"
11
11
  import { LeuPopup } from "../popup/Popup.js"
12
12
 
13
- import styles from "./dropdown.css"
13
+ import styles from "./dropdown.css?inline"
14
14
 
15
15
  /**
16
16
  * @tagname leu-dropdown
@@ -5,7 +5,7 @@ import "../../icon/leu-icon.js"
5
5
  import { paths as iconPaths } from "../../icon/paths.js"
6
6
 
7
7
  /**
8
- * @type {import("@storybook/web-components").Meta}
8
+ * @type {import("@storybook/web-components-vite").Meta}
9
9
  */
10
10
  export default {
11
11
  title: "Components/Dropdown",
@@ -5,10 +5,11 @@ import { classMap } from "lit/directives/class-map.js"
5
5
 
6
6
  import { LeuElement } from "../../lib/LeuElement.js"
7
7
 
8
- import styles from "./file-input.css"
8
+ import styles from "./file-input.css?inline"
9
9
  import { LeuButton } from "../button/Button.js"
10
10
  import { LeuIcon } from "../icon/Icon.js"
11
11
  import { LeuVisuallyHidden } from "../visually-hidden/VisuallyHidden.js"
12
+ import { FormAssociatedMixin } from "../../lib/mixins/FormAssociatedMixin.js"
12
13
 
13
14
  /**
14
15
  * @todo Pluralize text when multiple files are allowed
@@ -18,7 +19,7 @@ import { LeuVisuallyHidden } from "../visually-hidden/VisuallyHidden.js"
18
19
  /**
19
20
  * @tagname leu-file-input
20
21
  */
21
- export class LeuFileInput extends LeuElement {
22
+ export class LeuFileInput extends FormAssociatedMixin(LeuElement) {
22
23
  static dependencies = {
23
24
  "leu-icon": LeuIcon,
24
25
  "leu-button": LeuButton,
@@ -68,27 +69,13 @@ export class LeuFileInput extends LeuElement {
68
69
  @query('input[type="file"]')
69
70
  input: HTMLInputElement
70
71
 
71
- constructor() {
72
- super()
73
- // Initialize the ElementInternals for form association
74
- this.internals = this.attachInternals()
75
- }
76
-
77
- get form() {
78
- return this.internals.form
79
- }
80
-
81
- get name() {
82
- return this.getAttribute("name")
83
- }
84
-
85
72
  updated(changedProperties: PropertyValues<this>) {
86
73
  if (
87
74
  changedProperties.has("files") ||
88
75
  changedProperties.has("disabled") ||
89
76
  changedProperties.has("multiple")
90
77
  ) {
91
- this.updateFormValue()
78
+ this.setFormValue()
92
79
  }
93
80
  }
94
81
 
@@ -115,7 +102,7 @@ export class LeuFileInput extends LeuElement {
115
102
  this.input.value = ""
116
103
  }
117
104
 
118
- protected updateFormValue() {
105
+ protected setFormValue() {
119
106
  const formData = new FormData()
120
107
 
121
108
  const files = this.multiple ? this.files : this.files.slice(0, 1)
@@ -125,6 +112,17 @@ export class LeuFileInput extends LeuElement {
125
112
  })
126
113
 
127
114
  this.internals.setFormValue(formData)
115
+
116
+ if (this.required && files.length < 1) {
117
+ // @todo i18n and/or custom validation message
118
+ this.internals.setValidity(
119
+ { valueMissing: true },
120
+ "Bitte wählen Sie eine Datei.",
121
+ this.input,
122
+ )
123
+ } else {
124
+ this.internals.setValidity({})
125
+ }
128
126
  }
129
127
 
130
128
  protected removeFile(fileToRemove: File) {
@@ -169,7 +167,6 @@ export class LeuFileInput extends LeuElement {
169
167
  )
170
168
  }
171
169
 
172
- // eslint-disable-next-line class-methods-use-this
173
170
  protected handleDragOver = (event: DragEvent) => {
174
171
  if (this.disabled) return
175
172
 
@@ -250,8 +247,9 @@ export class LeuFileInput extends LeuElement {
250
247
  id="input"
251
248
  type="file"
252
249
  ?multiple=${this.multiple}
253
- accept=${ifDefined(this.accept)}
254
250
  ?disabled=${this.disabled}
251
+ ?required=${this.required}
252
+ accept=${ifDefined(this.accept)}
255
253
  @input=${this.handleInput}
256
254
  @change=${this.handleChange}
257
255
  />
@@ -1,5 +1,5 @@
1
- import { Meta, StoryObj } from "@storybook/web-components"
2
- import { action } from "@storybook/addon-actions"
1
+ import { Meta, StoryObj } from "@storybook/web-components-vite"
2
+ import { action } from "storybook/actions"
3
3
  import { html } from "lit"
4
4
  import { ifDefined } from "lit/directives/if-defined.js"
5
5
 
@@ -2,7 +2,7 @@ import { html } from "lit"
2
2
  import { fixture, expect } from "@open-wc/testing"
3
3
 
4
4
  import "../leu-file-input.js"
5
- import { type LeuFileInput } from "../FileInput.js"
5
+ import { LeuFileInput } from "../FileInput.js"
6
6
 
7
7
  async function defaultFixture() {
8
8
  return fixture<LeuFileInput>(
@@ -22,4 +22,17 @@ describe("LeuFileInput", () => {
22
22
 
23
23
  await expect(el).shadowDom.to.be.accessible()
24
24
  })
25
+
26
+ it("is not valid when required and no file is selected", async () => {
27
+ const form = await fixture<HTMLFormElement>(html`
28
+ <form>
29
+ <leu-file-input label="File upload" required></leu-file-input>
30
+ </form>
31
+ `)
32
+ const fileInput = form.querySelector<LeuFileInput>("leu-file-input")
33
+
34
+ expect(fileInput.validity.valid).to.be.false
35
+ expect(fileInput.validity.valueMissing).to.be.true
36
+ expect(form.checkValidity()).to.be.false
37
+ })
25
38
  })
@@ -3,7 +3,7 @@ import { property } from "lit/decorators.js"
3
3
 
4
4
  import { LeuElement } from "../../lib/LeuElement.js"
5
5
 
6
- import styles from "./icon.css"
6
+ import styles from "./icon.css?inline"
7
7
  import { paths, IconPathName } from "./paths.js"
8
8
 
9
9
  /**
@@ -1,4 +1,4 @@
1
- import { html, nothing } from "lit"
1
+ import { html, nothing, PropertyValues } from "lit"
2
2
  import { classMap } from "lit/directives/class-map.js"
3
3
  import { ifDefined } from "lit/directives/if-defined.js"
4
4
  import { live } from "lit/directives/live.js"
@@ -8,8 +8,9 @@ import { property, state } from "lit/decorators.js"
8
8
  import { LeuElement } from "../../lib/LeuElement.js"
9
9
  import { LeuIcon } from "../icon/Icon.js"
10
10
 
11
- import styles from "./input.css"
11
+ import styles from "./input.css?inline"
12
12
  import { IconPathName } from "../icon/paths.js"
13
+ import { FormAssociatedMixin } from "../../lib/mixins/FormAssociatedMixin.js"
13
14
 
14
15
  export const SIZES = Object.freeze({
15
16
  SMALL: "small",
@@ -58,7 +59,7 @@ const VALIDATION_MESSAGES = {
58
59
  *
59
60
  * @tagname leu-input
60
61
  */
61
- export class LeuInput extends LeuElement {
62
+ export class LeuInput extends FormAssociatedMixin(LeuElement) {
62
63
  static dependencies = {
63
64
  "leu-icon": LeuIcon,
64
65
  }
@@ -89,10 +90,6 @@ export class LeuInput extends LeuElement {
89
90
  @property({ type: String, reflect: true })
90
91
  value: string = ""
91
92
 
92
- /** The name of the input element. */
93
- @property({ type: String, reflect: true })
94
- name: string = ""
95
-
96
93
  /** A custom error that is completely independent of the validity state. Useful for displaying server side errors. */
97
94
  @property({ type: String, reflect: true })
98
95
  error: string = ""
@@ -173,6 +170,20 @@ export class LeuInput extends LeuElement {
173
170
  return Number(this.value)
174
171
  }
175
172
 
173
+ formResetCallback() {
174
+ this.value = ""
175
+ }
176
+
177
+ protected setFormValue(): void {
178
+ this.internals.setFormValue(this.value)
179
+ }
180
+
181
+ protected willUpdate(changedProperties: PropertyValues<this>): void {
182
+ if (changedProperties.has("value")) {
183
+ this.setFormValue()
184
+ }
185
+ }
186
+
176
187
  /**
177
188
  * Method for handling the click event of the wrapper element.
178
189
  * Redirect every click on the wrapper to the input element.