@webtides/element-library 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (398) hide show
  1. package/CHANGELOG.md +399 -3
  2. package/README.md +61 -41
  3. package/all.js +28 -0
  4. package/catalog.d.ts +14 -0
  5. package/catalog.js +55 -27
  6. package/custom-elements.json +16676 -3457
  7. package/package.json +35 -28
  8. package/src/components/accordion/accordion.changelog.md +10 -0
  9. package/src/components/accordion/accordion.js +10 -7
  10. package/src/components/accordion/accordion.readme.md +2 -0
  11. package/src/components/accordion/accordion.style.js +8 -0
  12. package/src/components/amount-field/amount-field.changelog.md +23 -3
  13. package/src/components/amount-field/amount-field.js +53 -26
  14. package/src/components/amount-field/amount-field.readme.md +82 -20
  15. package/src/components/amount-field/amount-field.style.js +111 -47
  16. package/src/components/avatar/avatar.changelog.md +23 -0
  17. package/src/components/avatar/avatar.define.js +3 -0
  18. package/src/components/avatar/avatar.js +115 -0
  19. package/src/components/avatar/avatar.readme.md +132 -0
  20. package/src/components/avatar/avatar.style.js +67 -0
  21. package/src/components/badge/badge.changelog.md +23 -0
  22. package/src/components/badge/badge.define.js +3 -0
  23. package/src/components/badge/badge.js +59 -0
  24. package/src/components/badge/badge.readme.md +109 -0
  25. package/src/components/badge/badge.style.js +63 -0
  26. package/src/components/breadcrumb/breadcrumb.changelog.md +22 -0
  27. package/src/components/breadcrumb/breadcrumb.define.js +3 -0
  28. package/src/components/breadcrumb/breadcrumb.js +47 -0
  29. package/src/components/breadcrumb/breadcrumb.readme.md +108 -0
  30. package/src/components/breadcrumb/breadcrumb.style.js +20 -0
  31. package/src/components/breadcrumb-item/breadcrumb-item.changelog.md +23 -0
  32. package/src/components/breadcrumb-item/breadcrumb-item.define.js +3 -0
  33. package/src/components/breadcrumb-item/breadcrumb-item.js +82 -0
  34. package/src/components/breadcrumb-item/breadcrumb-item.readme.md +106 -0
  35. package/src/components/breadcrumb-item/breadcrumb-item.style.js +92 -0
  36. package/src/components/button/button.changelog.md +44 -1
  37. package/src/components/button/button.js +338 -29
  38. package/src/components/button/button.readme.md +138 -10
  39. package/src/components/button/button.style.js +99 -120
  40. package/src/components/button-group/button-group.changelog.md +24 -0
  41. package/src/components/button-group/button-group.define.js +3 -0
  42. package/src/components/button-group/button-group.js +53 -0
  43. package/src/components/button-group/button-group.readme.md +114 -0
  44. package/src/components/button-group/button-group.style.js +41 -0
  45. package/src/components/card/card.changelog.md +23 -0
  46. package/src/components/card/card.define.js +3 -0
  47. package/src/components/card/card.js +73 -0
  48. package/src/components/card/card.readme.md +136 -0
  49. package/src/components/card/card.style.js +99 -0
  50. package/src/components/carousel/carousel.changelog.md +20 -0
  51. package/src/components/carousel/carousel.js +89 -40
  52. package/src/components/carousel/carousel.readme.md +39 -6
  53. package/src/components/carousel/carousel.style.js +21 -77
  54. package/src/components/carousel/glide/components/ShadowAnchors.js +3 -1
  55. package/src/components/carousel/glide/components/ShadowClones.js +21 -24
  56. package/src/components/carousel/glide/components/ShadowGaps.js +2 -2
  57. package/src/components/carousel/glide/components/ShadowHtml.js +22 -3
  58. package/src/components/checkbox-field/checkbox-field.changelog.md +25 -0
  59. package/src/components/checkbox-field/checkbox-field.js +32 -11
  60. package/src/components/checkbox-field/checkbox-field.readme.md +17 -4
  61. package/src/components/checkbox-field/checkbox-field.style.js +15 -3
  62. package/src/components/checkbox-group-field/checkbox-group-field.changelog.md +25 -0
  63. package/src/components/checkbox-group-field/checkbox-group-field.define.js +3 -0
  64. package/src/components/checkbox-group-field/checkbox-group-field.js +217 -0
  65. package/src/components/checkbox-group-field/checkbox-group-field.readme.md +95 -0
  66. package/src/components/checkbox-group-field/checkbox-group-field.style.js +62 -0
  67. package/src/components/color-field/color-field.changelog.md +24 -0
  68. package/src/components/color-field/color-field.define.js +3 -0
  69. package/src/components/color-field/color-field.js +184 -0
  70. package/src/components/color-field/color-field.readme.md +95 -0
  71. package/src/components/color-field/color-field.style.js +39 -0
  72. package/src/components/combobox-field/combobox-field.changelog.md +23 -0
  73. package/src/components/combobox-field/combobox-field.define.js +3 -0
  74. package/src/components/combobox-field/combobox-field.js +97 -0
  75. package/src/components/combobox-field/combobox-field.readme.md +93 -0
  76. package/src/components/combobox-field/combobox-field.style.js +56 -0
  77. package/src/components/copy-button/copy-button.changelog.md +24 -0
  78. package/src/components/copy-button/copy-button.define.js +3 -0
  79. package/src/components/copy-button/copy-button.events.js +4 -0
  80. package/src/components/copy-button/copy-button.js +237 -0
  81. package/src/components/copy-button/copy-button.readme.md +134 -0
  82. package/src/components/copy-button/copy-button.style.js +109 -0
  83. package/src/components/date-field/date-field.changelog.md +24 -0
  84. package/src/components/date-field/date-field.define.js +3 -0
  85. package/src/components/date-field/date-field.js +119 -0
  86. package/src/components/date-field/date-field.readme.md +110 -0
  87. package/src/components/date-field/date-field.style.js +53 -0
  88. package/src/components/dialog/dialog.changelog.md +16 -1
  89. package/src/components/dialog/dialog.js +252 -57
  90. package/src/components/dialog/dialog.readme.md +36 -4
  91. package/src/components/dialog/dialog.style.js +9 -109
  92. package/src/components/divider/divider.changelog.md +23 -0
  93. package/src/components/divider/divider.define.js +3 -0
  94. package/src/components/divider/divider.js +48 -0
  95. package/src/components/divider/divider.readme.md +101 -0
  96. package/src/components/divider/divider.style.js +50 -0
  97. package/src/components/drawer/drawer.changelog.md +25 -0
  98. package/src/components/drawer/drawer.define.js +3 -0
  99. package/src/components/drawer/drawer.events.js +8 -0
  100. package/src/components/drawer/drawer.js +80 -0
  101. package/src/components/drawer/drawer.readme.md +194 -0
  102. package/src/components/drawer/drawer.style.js +83 -0
  103. package/src/components/dropdown/dropdown.js +9 -7
  104. package/src/components/empty-state/empty-state.changelog.md +22 -0
  105. package/src/components/empty-state/empty-state.define.js +3 -0
  106. package/src/components/empty-state/empty-state.js +55 -0
  107. package/src/components/empty-state/empty-state.readme.md +114 -0
  108. package/src/components/empty-state/empty-state.style.js +60 -0
  109. package/src/components/file-field/file-field.changelog.md +24 -0
  110. package/src/components/file-field/file-field.define.js +3 -0
  111. package/src/components/file-field/file-field.js +205 -0
  112. package/src/components/file-field/file-field.readme.md +103 -0
  113. package/src/components/file-field/file-field.style.js +28 -0
  114. package/src/components/form-field/form-field.changelog.md +25 -0
  115. package/src/components/form-field/form-field.js +212 -15
  116. package/src/components/form-field/form-field.readme.md +82 -18
  117. package/src/components/form-field/form-field.style.js +6 -24
  118. package/src/components/input-field/input-field.changelog.md +24 -0
  119. package/src/components/input-field/input-field.js +82 -6
  120. package/src/components/input-field/input-field.readme.md +34 -5
  121. package/src/components/input-field/input-field.style.js +32 -13
  122. package/src/components/notification/notification.changelog.md +21 -1
  123. package/src/components/notification/notification.js +80 -74
  124. package/src/components/notification/notification.readme.md +54 -13
  125. package/src/components/notification/notification.style.js +37 -22
  126. package/src/components/otp-field/otp-field.changelog.md +23 -0
  127. package/src/components/otp-field/otp-field.define.js +3 -0
  128. package/src/components/otp-field/otp-field.events.js +3 -0
  129. package/src/components/otp-field/otp-field.js +172 -0
  130. package/src/components/otp-field/otp-field.readme.md +111 -0
  131. package/src/components/otp-field/otp-field.style.js +53 -0
  132. package/src/components/pagination/pagination.changelog.md +30 -0
  133. package/src/components/pagination/pagination.define.js +3 -0
  134. package/src/components/pagination/pagination.events.js +3 -0
  135. package/src/components/pagination/pagination.js +282 -0
  136. package/src/components/pagination/pagination.readme.md +167 -0
  137. package/src/components/pagination/pagination.style.js +162 -0
  138. package/src/components/password-field/password-field.changelog.md +24 -0
  139. package/src/components/password-field/password-field.js +7 -1
  140. package/src/components/password-field/password-field.readme.md +15 -6
  141. package/src/components/password-field/password-field.style.js +36 -13
  142. package/src/components/popover/popover.changelog.md +24 -0
  143. package/src/components/popover/popover.define.js +3 -0
  144. package/src/components/popover/popover.events.js +4 -0
  145. package/src/components/popover/popover.js +255 -0
  146. package/src/components/popover/popover.readme.md +132 -0
  147. package/src/components/popover/popover.style.js +41 -0
  148. package/src/components/progress-bar/progress-bar.changelog.md +23 -0
  149. package/src/components/progress-bar/progress-bar.define.js +3 -0
  150. package/src/components/progress-bar/progress-bar.js +80 -0
  151. package/src/components/progress-bar/progress-bar.readme.md +110 -0
  152. package/src/components/progress-bar/progress-bar.style.js +93 -0
  153. package/src/components/progress-ring/progress-ring.changelog.md +23 -0
  154. package/src/components/progress-ring/progress-ring.define.js +3 -0
  155. package/src/components/progress-ring/progress-ring.js +83 -0
  156. package/src/components/progress-ring/progress-ring.readme.md +115 -0
  157. package/src/components/progress-ring/progress-ring.style.js +85 -0
  158. package/src/components/radio-field/radio-field.changelog.md +16 -0
  159. package/src/components/radio-field/radio-field.js +34 -11
  160. package/src/components/radio-field/radio-field.readme.md +13 -8
  161. package/src/components/radio-field/radio-field.style.js +17 -65
  162. package/src/components/range-field/range-field.changelog.md +24 -0
  163. package/src/components/range-field/range-field.define.js +3 -0
  164. package/src/components/range-field/range-field.js +167 -0
  165. package/src/components/range-field/range-field.readme.md +87 -0
  166. package/src/components/range-field/range-field.style.js +41 -0
  167. package/src/components/rating-field/rating-field.changelog.md +24 -0
  168. package/src/components/rating-field/rating-field.define.js +3 -0
  169. package/src/components/rating-field/rating-field.js +195 -0
  170. package/src/components/rating-field/rating-field.readme.md +82 -0
  171. package/src/components/rating-field/rating-field.style.js +79 -0
  172. package/src/components/select-field/select-field.changelog.md +17 -0
  173. package/src/components/select-field/select-field.js +100 -8
  174. package/src/components/select-field/select-field.readme.md +32 -6
  175. package/src/components/select-field/select-field.style.js +19 -9
  176. package/src/components/skeleton/skeleton.changelog.md +22 -0
  177. package/src/components/skeleton/skeleton.define.js +3 -0
  178. package/src/components/skeleton/skeleton.js +49 -0
  179. package/src/components/skeleton/skeleton.readme.md +115 -0
  180. package/src/components/skeleton/skeleton.style.js +79 -0
  181. package/src/components/slider/slider.changelog.md +15 -0
  182. package/src/components/slider/slider.js +37 -5
  183. package/src/components/slider/slider.readme.md +28 -6
  184. package/src/components/slider/slider.style.js +7 -71
  185. package/src/components/spinner/spinner.changelog.md +22 -0
  186. package/src/components/spinner/spinner.define.js +3 -0
  187. package/src/components/spinner/spinner.js +48 -0
  188. package/src/components/spinner/spinner.readme.md +98 -0
  189. package/src/components/spinner/spinner.style.js +44 -0
  190. package/src/components/switch-field/switch-field.changelog.md +22 -0
  191. package/src/components/switch-field/switch-field.js +24 -10
  192. package/src/components/switch-field/switch-field.readme.md +11 -4
  193. package/src/components/switch-field/switch-field.style.js +13 -13
  194. package/src/components/tab-group/tab-group.changelog.md +19 -0
  195. package/src/components/tab-group/tab-group.js +122 -10
  196. package/src/components/tab-group/tab-group.readme.md +25 -4
  197. package/src/components/tab-link/tab-link.changelog.md +16 -0
  198. package/src/components/tab-link/tab-link.js +51 -8
  199. package/src/components/tab-link/tab-link.readme.md +14 -8
  200. package/src/components/tab-link/tab-link.style.js +13 -0
  201. package/src/components/tab-panel/tab-panel.changelog.md +8 -2
  202. package/src/components/tab-panel/tab-panel.js +7 -3
  203. package/src/components/tab-panel/tab-panel.readme.md +7 -5
  204. package/src/components/tag/tag.changelog.md +24 -0
  205. package/src/components/tag/tag.define.js +3 -0
  206. package/src/components/tag/tag.events.js +3 -0
  207. package/src/components/tag/tag.js +116 -0
  208. package/src/components/tag/tag.readme.md +119 -0
  209. package/src/components/tag/tag.style.js +101 -0
  210. package/src/components/tag-field/tag-field.changelog.md +25 -0
  211. package/src/components/tag-field/tag-field.define.js +3 -0
  212. package/src/components/tag-field/tag-field.js +359 -0
  213. package/src/components/tag-field/tag-field.readme.md +113 -0
  214. package/src/components/tag-field/tag-field.style.js +62 -0
  215. package/src/components/textarea-field/textarea-field.changelog.md +28 -4
  216. package/src/components/textarea-field/textarea-field.js +68 -14
  217. package/src/components/textarea-field/textarea-field.readme.md +45 -9
  218. package/src/components/textarea-field/textarea-field.style.js +45 -2
  219. package/src/components/toast/toast.changelog.md +24 -0
  220. package/src/components/toast/toast.define.js +3 -0
  221. package/src/components/toast/toast.js +193 -0
  222. package/src/components/toast/toast.readme.md +189 -0
  223. package/src/components/toast/toast.style.js +74 -0
  224. package/src/components/tooltip/tooltip.changelog.md +24 -0
  225. package/src/components/tooltip/tooltip.define.js +3 -0
  226. package/src/components/tooltip/tooltip.events.js +4 -0
  227. package/src/components/tooltip/tooltip.js +377 -0
  228. package/src/components/tooltip/tooltip.readme.md +172 -0
  229. package/src/components/tooltip/tooltip.style.js +107 -0
  230. package/src/components/transition-classes/transition-classes.js +6 -6
  231. package/src/styles/appearance.style.js +42 -0
  232. package/src/styles/arrow.style.js +65 -0
  233. package/src/styles/choice-group.style.js +94 -0
  234. package/src/styles/form-control.style.js +79 -0
  235. package/src/styles/host.style.js +55 -0
  236. package/src/styles/layers.css +31 -0
  237. package/src/styles/modal.style.js +146 -0
  238. package/src/styles/native.css +275 -0
  239. package/src/styles/size.style.js +48 -0
  240. package/src/styles/slide-controls.style.js +225 -0
  241. package/src/styles/utilities.css +30 -0
  242. package/src/styles/variants.style.js +78 -0
  243. package/src/themes/default.css +86 -142
  244. package/src/themes/high-contrast.css +72 -129
  245. package/src/themes/sketchy.css +95 -175
  246. package/src/utils/floating.js +71 -0
  247. package/src/utils/focus.js +18 -0
  248. package/src/utils/progress.js +25 -0
  249. package/src/utils/slots.js +21 -0
  250. package/src/utils/text-entry-attributes.js +51 -0
  251. package/types/all.d.ts +54 -1
  252. package/types/index.d.ts +1 -0
  253. package/types/src/components/accordion/accordion.d.ts +6 -4
  254. package/types/src/components/accordion/accordion.events.d.ts +3 -3
  255. package/types/src/components/accordion-group/accordion-group.d.ts +4 -3
  256. package/types/src/components/amount-field/amount-field.d.ts +30 -16
  257. package/types/src/components/avatar/avatar.d.ts +57 -0
  258. package/types/src/components/avatar/avatar.define.d.ts +1 -0
  259. package/types/src/components/avatar/avatar.style.d.ts +2 -0
  260. package/types/src/components/badge/badge.d.ts +32 -0
  261. package/types/src/components/badge/badge.define.d.ts +1 -0
  262. package/types/src/components/badge/badge.style.d.ts +2 -0
  263. package/types/src/components/breadcrumb/breadcrumb.d.ts +27 -0
  264. package/types/src/components/breadcrumb/breadcrumb.define.d.ts +1 -0
  265. package/types/src/components/breadcrumb/breadcrumb.style.d.ts +2 -0
  266. package/types/src/components/breadcrumb-item/breadcrumb-item.d.ts +38 -0
  267. package/types/src/components/breadcrumb-item/breadcrumb-item.define.d.ts +1 -0
  268. package/types/src/components/breadcrumb-item/breadcrumb-item.style.d.ts +2 -0
  269. package/types/src/components/button/button.d.ts +158 -14
  270. package/types/src/components/button-group/button-group.d.ts +28 -0
  271. package/types/src/components/button-group/button-group.define.d.ts +1 -0
  272. package/types/src/components/button-group/button-group.style.d.ts +2 -0
  273. package/types/src/components/card/card.d.ts +40 -0
  274. package/types/src/components/card/card.define.d.ts +1 -0
  275. package/types/src/components/card/card.style.d.ts +2 -0
  276. package/types/src/components/carousel/carousel.d.ts +22 -8
  277. package/types/src/components/carousel/carousel.events.d.ts +3 -3
  278. package/types/src/components/carousel/glide/components/ShadowAnchors.d.ts +1 -1
  279. package/types/src/components/carousel/glide/components/ShadowClones.d.ts +8 -1
  280. package/types/src/components/carousel/glide/components/ShadowGaps.d.ts +1 -1
  281. package/types/src/components/carousel/glide/components/ShadowHtml.d.ts +1 -1
  282. package/types/src/components/carousel/glide/components/glide-html.d.ts +1 -1
  283. package/types/src/components/checkbox-field/checkbox-field.d.ts +22 -15
  284. package/types/src/components/checkbox-group-field/checkbox-group-field.d.ts +100 -0
  285. package/types/src/components/checkbox-group-field/checkbox-group-field.define.d.ts +1 -0
  286. package/types/src/components/checkbox-group-field/checkbox-group-field.style.d.ts +2 -0
  287. package/types/src/components/color-field/color-field.d.ts +102 -0
  288. package/types/src/components/color-field/color-field.define.d.ts +1 -0
  289. package/types/src/components/color-field/color-field.style.d.ts +2 -0
  290. package/types/src/components/combobox-field/combobox-field.d.ts +84 -0
  291. package/types/src/components/combobox-field/combobox-field.define.d.ts +1 -0
  292. package/types/src/components/combobox-field/combobox-field.style.d.ts +2 -0
  293. package/types/src/components/copy-button/copy-button.d.ts +93 -0
  294. package/types/src/components/copy-button/copy-button.define.d.ts +1 -0
  295. package/types/src/components/copy-button/copy-button.events.d.ts +5 -0
  296. package/types/src/components/copy-button/copy-button.style.d.ts +2 -0
  297. package/types/src/components/date-field/date-field.d.ts +102 -0
  298. package/types/src/components/date-field/date-field.define.d.ts +1 -0
  299. package/types/src/components/date-field/date-field.style.d.ts +2 -0
  300. package/types/src/components/dialog/dialog.d.ts +101 -19
  301. package/types/src/components/dialog/dialog.events.d.ts +8 -8
  302. package/types/src/components/divider/divider.d.ts +27 -0
  303. package/types/src/components/divider/divider.define.d.ts +1 -0
  304. package/types/src/components/divider/divider.style.d.ts +2 -0
  305. package/types/src/components/drawer/drawer.d.ts +70 -0
  306. package/types/src/components/drawer/drawer.define.d.ts +1 -0
  307. package/types/src/components/drawer/drawer.events.d.ts +9 -0
  308. package/types/src/components/drawer/drawer.style.d.ts +2 -0
  309. package/types/src/components/dropdown/dropdown.d.ts +5 -3
  310. package/types/src/components/empty-state/empty-state.d.ts +29 -0
  311. package/types/src/components/empty-state/empty-state.define.d.ts +1 -0
  312. package/types/src/components/empty-state/empty-state.style.d.ts +2 -0
  313. package/types/src/components/file-field/file-field.d.ts +115 -0
  314. package/types/src/components/file-field/file-field.define.d.ts +1 -0
  315. package/types/src/components/file-field/file-field.style.d.ts +2 -0
  316. package/types/src/components/form-field/form-field.d.ts +129 -14
  317. package/types/src/components/form-field/form-field.events.d.ts +4 -4
  318. package/types/src/components/input-field/input-field.d.ts +52 -5
  319. package/types/src/components/lazy-src/lazy-src.d.ts +7 -5
  320. package/types/src/components/lazy-src/lazy-src.events.d.ts +5 -5
  321. package/types/src/components/notification/notification.d.ts +18 -18
  322. package/types/src/components/notification/notification.events.d.ts +6 -6
  323. package/types/src/components/otp-field/otp-field.d.ts +130 -0
  324. package/types/src/components/otp-field/otp-field.define.d.ts +1 -0
  325. package/types/src/components/otp-field/otp-field.events.d.ts +4 -0
  326. package/types/src/components/otp-field/otp-field.style.d.ts +2 -0
  327. package/types/src/components/pagination/pagination.d.ts +117 -0
  328. package/types/src/components/pagination/pagination.define.d.ts +1 -0
  329. package/types/src/components/pagination/pagination.events.d.ts +4 -0
  330. package/types/src/components/pagination/pagination.style.d.ts +2 -0
  331. package/types/src/components/password-field/password-field.d.ts +29 -12
  332. package/types/src/components/popover/popover.d.ts +123 -0
  333. package/types/src/components/popover/popover.define.d.ts +1 -0
  334. package/types/src/components/popover/popover.events.d.ts +5 -0
  335. package/types/src/components/popover/popover.style.d.ts +2 -0
  336. package/types/src/components/progress-bar/progress-bar.d.ts +35 -0
  337. package/types/src/components/progress-bar/progress-bar.define.d.ts +1 -0
  338. package/types/src/components/progress-bar/progress-bar.style.d.ts +2 -0
  339. package/types/src/components/progress-ring/progress-ring.d.ts +40 -0
  340. package/types/src/components/progress-ring/progress-ring.define.d.ts +1 -0
  341. package/types/src/components/progress-ring/progress-ring.style.d.ts +2 -0
  342. package/types/src/components/radio-field/radio-field.d.ts +21 -9
  343. package/types/src/components/range-field/range-field.d.ts +94 -0
  344. package/types/src/components/range-field/range-field.define.d.ts +1 -0
  345. package/types/src/components/range-field/range-field.style.d.ts +2 -0
  346. package/types/src/components/rating-field/rating-field.d.ts +96 -0
  347. package/types/src/components/rating-field/rating-field.define.d.ts +1 -0
  348. package/types/src/components/rating-field/rating-field.style.d.ts +2 -0
  349. package/types/src/components/scroll-to/scroll-to.d.ts +3 -2
  350. package/types/src/components/scroll-to-top/scroll-to-top.d.ts +4 -2
  351. package/types/src/components/select-field/select-field.d.ts +55 -5
  352. package/types/src/components/skeleton/skeleton.d.ts +29 -0
  353. package/types/src/components/skeleton/skeleton.define.d.ts +1 -0
  354. package/types/src/components/skeleton/skeleton.style.d.ts +2 -0
  355. package/types/src/components/slider/slider.d.ts +14 -8
  356. package/types/src/components/slider/slider.events.d.ts +4 -4
  357. package/types/src/components/spinner/spinner.d.ts +28 -0
  358. package/types/src/components/spinner/spinner.define.d.ts +1 -0
  359. package/types/src/components/spinner/spinner.style.d.ts +2 -0
  360. package/types/src/components/sticky/sticky.d.ts +4 -2
  361. package/types/src/components/svg-use/svg-use.d.ts +4 -2
  362. package/types/src/components/switch-field/switch-field.d.ts +17 -15
  363. package/types/src/components/tab-group/tab-group.d.ts +44 -3
  364. package/types/src/components/tab-link/tab-link.d.ts +33 -10
  365. package/types/src/components/tab-panel/tab-panel.d.ts +8 -5
  366. package/types/src/components/tag/tag.d.ts +53 -0
  367. package/types/src/components/tag/tag.define.d.ts +1 -0
  368. package/types/src/components/tag/tag.events.d.ts +4 -0
  369. package/types/src/components/tag/tag.style.d.ts +2 -0
  370. package/types/src/components/tag-field/tag-field.d.ts +178 -0
  371. package/types/src/components/tag-field/tag-field.define.d.ts +1 -0
  372. package/types/src/components/tag-field/tag-field.style.d.ts +2 -0
  373. package/types/src/components/textarea-field/textarea-field.d.ts +44 -4
  374. package/types/src/components/toast/toast.d.ts +110 -0
  375. package/types/src/components/toast/toast.define.d.ts +1 -0
  376. package/types/src/components/toast/toast.style.d.ts +2 -0
  377. package/types/src/components/tooltip/tooltip.d.ts +161 -0
  378. package/types/src/components/tooltip/tooltip.define.d.ts +1 -0
  379. package/types/src/components/tooltip/tooltip.events.d.ts +5 -0
  380. package/types/src/components/tooltip/tooltip.style.d.ts +2 -0
  381. package/types/src/components/transition-classes/transition-classes.d.ts +9 -8
  382. package/types/src/styles/appearance.style.d.ts +18 -0
  383. package/types/src/styles/arrow.style.d.ts +15 -0
  384. package/types/src/styles/choice-group.style.d.ts +23 -0
  385. package/types/src/styles/form-control.style.d.ts +26 -0
  386. package/types/src/styles/host.style.d.ts +24 -0
  387. package/types/src/styles/modal.style.d.ts +20 -0
  388. package/types/src/styles/size.style.d.ts +20 -0
  389. package/types/src/styles/slide-controls.style.d.ts +20 -0
  390. package/types/src/styles/variants.style.d.ts +32 -0
  391. package/types/src/utils/body-scroll.d.ts +12 -2
  392. package/types/src/utils/floating.d.ts +36 -0
  393. package/types/src/utils/focus.d.ts +16 -0
  394. package/types/src/utils/progress.d.ts +19 -0
  395. package/types/src/utils/slots.d.ts +19 -0
  396. package/types/src/utils/text-entry-attributes.d.ts +18 -0
  397. package/types/src/utils/transitions.d.ts +2 -2
  398. package/web-types.json +6590 -1584
@@ -0,0 +1,92 @@
1
+ import hostStyle from '../../styles/host.style.js';
2
+
3
+ const css = String.raw;
4
+
5
+ const style = css`
6
+ :host {
7
+ display: inline-flex;
8
+ /* A long name breaks inside of its entry and does not push the row out of its container. */
9
+ min-width: 0;
10
+ }
11
+
12
+ /* The separator and the name stay together when the row breaks: a new line starts with a
13
+ separator, which says that the trail goes on. */
14
+ .item {
15
+ display: inline-flex;
16
+ align-items: center;
17
+ gap: var(--el-space-2, 0.5em);
18
+ min-width: 0;
19
+ font-family: var(--el-font-family, inherit);
20
+ }
21
+
22
+ /* ── Separator ────────────────────────────────────────────────────────── */
23
+
24
+ /* A string from a custom property, so that a page or a theme sets it once for every entry.
25
+ The element is hidden from assistive technology, and what it generates with it. */
26
+ .separator {
27
+ flex: none;
28
+ color: var(--el-color-fg-muted, inherit);
29
+ user-select: none;
30
+ }
31
+
32
+ .separator::before {
33
+ content: var(--el-breadcrumb-separator, '/');
34
+ }
35
+
36
+ /* Nothing stands in front of the first entry. */
37
+ :host(:first-of-type) .separator {
38
+ display: none;
39
+ }
40
+
41
+ /* ── Name ─────────────────────────────────────────────────────────────── */
42
+
43
+ .label {
44
+ display: inline-flex;
45
+ align-items: center;
46
+ gap: var(--el-space-1, 0.25em);
47
+ min-width: 0;
48
+ color: inherit;
49
+ text-decoration: none;
50
+ }
51
+
52
+ /* A page on the way has the accent colour of the theme. Without a theme it has the text
53
+ colour, which shows on any background, and is underlined under the pointer like the plain
54
+ button is. */
55
+ a.label {
56
+ border-radius: var(--el-radius-sm, 2px);
57
+ color: var(--el-color-accent, inherit);
58
+ }
59
+
60
+ @media (hover: hover) {
61
+ a.label:hover {
62
+ text-decoration: underline;
63
+ }
64
+ }
65
+
66
+ a.label:focus-visible {
67
+ outline: var(--el-focus-ring-width, 2px) solid var(--el-color-focus-ring, currentColor);
68
+ outline-offset: var(--el-focus-ring-offset, 2px);
69
+ }
70
+
71
+ /* The page the user is on: the text colour, and a weight that tells it from the others
72
+ without a colour. Also where it is a link. */
73
+ .label[aria-current='page'],
74
+ a.label[aria-current='page'] {
75
+ color: var(--el-color-fg, inherit);
76
+ font-weight: 600;
77
+ }
78
+
79
+ /* ── Touch screens ────────────────────────────────────────────────────── */
80
+
81
+ /* On a coarse pointer no link falls below --el-touch-target in either direction. A short name
82
+ stands in the middle of its target. Without the token the sizes stay as they are. */
83
+ @media (any-pointer: coarse) {
84
+ a.label {
85
+ justify-content: center;
86
+ min-width: var(--el-touch-target, auto);
87
+ min-height: var(--el-touch-target, auto);
88
+ }
89
+ }
90
+ `;
91
+
92
+ export default [hostStyle(), style].join('\n');
@@ -12,8 +12,51 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
12
12
 
13
13
  ## Unreleased
14
14
 
15
+ ## [0.3.1] - 2026-11-17
16
+
17
+ ### Changed
18
+
19
+ - A button of the type `submit` makes its hidden native `<button type="submit">` when the form is first submitted with it: with a click, or with Enter in an `<input>` or a `<select>` of the form. Before, it appended that button as soon as it started. Until the first submit the children of the `el-button` are what the page wrote, and `form.querySelector('[type="submit"]')` does not find a native button in it. When the page replaces the content of the button, the native button is made again with the next submit, and no longer with the next render. A native submit button that the page writes is taken as before. ([#184](https://github.com/webtides/element-library/issues/184))
20
+
21
+ ### Fixed
22
+
23
+ - A server-rendered `el-button` of the type `submit` no longer breaks the hydration of its page. The element appended its native submit button as soon as it started, and a framework that hydrated after that found a child it had not rendered (Svelte 5: `hydration_mismatch`, the page was built again, and what the user had typed into the form by then was gone). See "On a page that a framework hydrates" in the readme. ([#184](https://github.com/webtides/element-library/issues/184))
24
+
25
+ ## [0.3.0] - 2026-11-17
26
+
27
+ ### Added
28
+
29
+ - `appearance` (`filled` by default, `outlined` or `plain`): how the colours of the variant are painted. It works with every variant, so a `plain` button, text only, exists in every colour; before, only the `text` variant in the brand colour did. ([#69](https://github.com/webtides/element-library/issues/69))
30
+ - `variant`, `appearance` and `size` are reflected to attributes of the same name, the defaults included, so a stylesheet can select them (`el-button[variant='brand']`). ([#69](https://github.com/webtides/element-library/issues/69))
31
+ - A pressed style: a button that is pressed (`:active`) is darker than a hovered one; an `outlined` or `plain` button gets a tint of its text color instead. Before, pressing a button on a touch screen showed nothing.
32
+ - In an `el-button-group` a button is joined with its neighbours: the corners that face a neighbour are square, and a filled button with a neighbour in front of it draws the line between the two as its border at the start. Outside of a group the button looks as before. ([#124](https://github.com/webtides/element-library/issues/124))
33
+ - The attributes `form`, `formaction`, `formenctype`, `formmethod`, `formnovalidate` and `formtarget` do what they do on a native button. A button of the type `submit` or `reset` outside of a form acts on the form its `form` attribute names, from the footer slot of an `el-dialog` for example, and a "Cancel" with `formnovalidate` submits a form that is not valid. ([#113](https://github.com/webtides/element-library/issues/113))
34
+
35
+ ### Changed
36
+
37
+ - BREAKING: the button speaks the library's shared vocabulary. `variant` is `neutral` (the default), `brand`, `success`, `warning` or `danger`, and the new `appearance` replaces the `outline` flag and the `text` variant. The old values are not mapped, a button that still uses them is painted neutral and filled. Rename `variant="primary"` to `variant="brand"`, `variant="default"` to `variant="neutral"` (or leave it out), `variant="text"` to `variant="brand" appearance="plain"` and `outline="true"` to `appearance="outlined"`. Buttons that are renamed this way look as before, in every theme. ([#69](https://github.com/webtides/element-library/issues/69))
38
+ - BREAKING: the dark `neutral` button, filled in the text colour, is gone. `neutral` now is what `default` was: the muted fill with the border of the theme. There is no successor for the dark fill. ([#69](https://github.com/webtides/element-library/issues/69))
39
+ - The control inside the shadow root no longer has classes for the variant, the size and the outline (`button--primary`, `button--small`, `button--outline`). Select the host by its attributes instead. ([#69](https://github.com/webtides/element-library/issues/69))
40
+ - On a touch screen (`@media (any-pointer: coarse)`) the button is at least `--el-touch-target` wide and high, in every size and shape. With the default theme a small button was 32 px high, a medium one 42 px and a small `circle` 32 × 32 px. A circle stays round. Unchanged on a fine pointer and without the token.
41
+ - The element is form-associated. It is listed in the `elements` of its form, and its `disabled` property is reflected as the platform reads it: the element has `disabled="true"` while it is disabled, set from a script as well, and no `disabled` attribute while it is not. `disabled="false"` and a `disabled` without a value are read as not disabled, as before, and are now taken off the element: for the platform an attribute that is there disables a form-associated element, whatever its value. ([#114](https://github.com/webtides/element-library/issues/114))
42
+ - `name` and `value` are text, as on a native button: `value="1.50"` is submitted as `1.50` and read as the string `'1.50'`. Before, the attribute was parsed, and the property was the number `1.5`. ([#113](https://github.com/webtides/element-library/issues/113))
43
+ - A button of the type `submit` keeps a hidden native `<button type="submit">` as its last child, which is what the form is submitted with. A selector or a script that counts the children of an `el-button` sees it. Enter in a field clicks that button, so a `click` listener on the `el-button` hears that click as well, as a native submit button does. While the button is disabled or loading, Enter does not submit the form. ([#113](https://github.com/webtides/element-library/issues/113))
44
+
45
+ ### Fixed
46
+
47
+ - An `el-button` of the type `submit` is the submit button of its form. The `submit` event has a `submitter`, the native submit button inside the `el-button`, and the `name` and `value` of the button are in the data of the form. Before, the form was submitted without a submitter and without that entry, although the readme promised it: a form with several submit buttons could not tell them apart. ([#113](https://github.com/webtides/element-library/issues/113))
48
+ - Enter in a field submits a form whose submit button is an `el-button`, with any number of fields. Before, only a form with a single field was submitted: the platform found no submit button in the form. ([#113](https://github.com/webtides/element-library/issues/113))
49
+ - An `el-button` inside of a `<fieldset disabled>` is disabled, as a native button is: it fires no click, does not submit, takes no focus and is painted as disabled. Before, the fieldset did not reach it. A link button (`href`) is disabled there as by its own `disabled`. ([#114](https://github.com/webtides/element-library/issues/114))
50
+ - A `click` listener of the page that calls `preventDefault()` keeps a button of the type `submit` from submitting its form, and one of the type `reset` from resetting it, as it does with a native button: on the `el-button`, on an element in it or around it. Before, the form was submitted before the page had the click. The button acts once every listener has had the click, still inside of it; after a listener that stops the click on its way (`stopPropagation()`), it acts a task later. ([#155](https://github.com/webtides/element-library/issues/155))
51
+ - Without a theme, the keyboard focus of the button can be seen on every page. The ring is inside of the button then, in the colour of its label, which can be read on the surface of the button: 5.02 : 1 or more in every variant and appearance, on a light and on a dark page. Before, the ring was around the button in the colour of its label: white on a white page for a brand, a success and a danger button (1.00 : 1), and dark on a dark page for a warning button (1.07 : 1). With `--el-color-focus-ring`, as in the three themes, the ring is around the button as before, and so it is in both cases where the user forces colours. ([#159](https://github.com/webtides/element-library/issues/159))
52
+ - An ARIA attribute on `el-button` reaches the control inside it, the `<button>` or `<a>` that has the focus and that a screen reader announces. Before, it stayed on the element, which has no role: an icon button with `aria-label="Add"` was announced by its content ("+"), and `aria-expanded` or `aria-pressed` said nothing. `aria-label`, `aria-description`, `aria-expanded`, `aria-haspopup`, `aria-pressed` and `aria-current` are passed on as they are, with every change. `aria-labelledby`, `aria-describedby` and `aria-controls` name elements by id, which does not reach out of the shadow root; the control gets references to those elements instead (Chrome 135, Firefox 136, Safari 16.4; without them the relation is missing, as before). The attributes stay on the element as well. ([#108](https://github.com/webtides/element-library/issues/108))
53
+ - The `hidden` attribute hides the button. Before, the `display` of the element won over it. ([#69](https://github.com/webtides/element-library/issues/69))
54
+ - A server-rendered `el-button` no longer writes unset attributes as the string `undefined` onto its control. A link button (`href` set) carried `target='undefined'`, `rel='undefined'` and `download='undefined'` in the Declarative Shadow DOM, and a `download` attribute makes the browser save the link target instead of navigating to it. A native button carried `name='undefined'` and `value='undefined'`. The fix is in `@webtides/element-js` 1.3.1 ([element-js#192](https://github.com/webtides/element-js/issues/192)), which the library now requires.
55
+ - No hover style stays on the button after a tap. A touch screen leaves `:hover` on the element that was tapped last, so the button looked hovered until the next tap elsewhere. The hover styles now only apply where the pointer can hover (`@media (hover: hover)`).
56
+ - The label of an outlined `warning` button is readable on a light background. Its colour is `--el-color-warning` mixed half and half with `--el-color-fg` now, which makes it darker in a light scheme and lighter in a dark one; the border keeps the token. Before, the label had the colour of the token, which has to be light for the dark text of the filled button: `#d97706` was 3.18 : 1 on white as a label and is 7.86 : 1 now. ([#94](https://github.com/webtides/element-library/issues/94))
57
+
15
58
  ## [0.1.0] - 2026-06-03
16
59
 
17
60
  ### Added
18
61
 
19
- - Initial `el-button` — a themeable button modelled on Shoelace's `<sl-button>`. Renders a native `<button>`, or an `<a>` when `href` is set. Supports `variant` (`default / primary / success / neutral / warning / danger / text`), `size` (`small / medium / large`), `outline`, `pill`, `circle`, `caret`, `loading` and `disabled`; `prefix` / `suffix` icon slots; `base / prefix / label / suffix / caret / spinner` CSS parts; and `focus()` / `blur()` / `click()` methods. `type="submit"` / `type="reset"` drive the nearest ancestor `<form>` across the shadow boundary. Styling reads the `--el-*` design tokens, so it re-skins with every theme.
62
+ - Initial `el-button` — a themeable button. Renders a native `<button>`, or an `<a>` when `href` is set. Supports `variant` (`default / primary / success / neutral / warning / danger / text`), `size` (`small / medium / large`), `outline`, `pill`, `circle`, `caret`, `loading` and `disabled`; `prefix` / `suffix` icon slots; `base / prefix / label / suffix / caret / spinner` CSS parts; and `focus()` / `blur()` / `click()` methods. `type="submit"` / `type="reset"` drive the nearest ancestor `<form>` across the shadow boundary. Styling reads the `--el-*` design tokens, so it re-skins with every theme.
@@ -1,11 +1,58 @@
1
1
  import { TemplateElement, defineElement, html, classMap, spreadAttributes } from '@webtides/element-js';
2
2
  import style from './button.style.js';
3
3
 
4
+ /**
5
+ * The ARIA attributes of the element that its control takes over. The control is what has the
6
+ * focus and what a screen reader announces; the element itself has no role. `aria-disabled` and
7
+ * `aria-busy` are not among them: the button sets those itself, from `disabled` and `loading`.
8
+ */
9
+ const ARIA_ATTRIBUTES = [
10
+ 'aria-label',
11
+ 'aria-description',
12
+ 'aria-expanded',
13
+ 'aria-haspopup',
14
+ 'aria-pressed',
15
+ 'aria-current',
16
+ ];
17
+
18
+ /**
19
+ * The ARIA attributes that name other elements by id, and the property of the control that takes
20
+ * those elements. An id does not reach out of the shadow root the control is in, a reference to
21
+ * the element does.
22
+ */
23
+ const ARIA_RELATIONS = {
24
+ 'aria-labelledby': 'ariaLabelledByElements',
25
+ 'aria-describedby': 'ariaDescribedByElements',
26
+ 'aria-controls': 'ariaControlsElements',
27
+ };
28
+
29
+ /**
30
+ * The attributes of the element that a native submit button has as well, and that the submit button
31
+ * of the element takes over: the form it belongs to, and what it says for the one submit it starts.
32
+ */
33
+ const SUBMITTER_ATTRIBUTES = ['form', 'formaction', 'formenctype', 'formmethod', 'formnovalidate', 'formtarget'];
34
+
4
35
  /**
5
36
  * A themeable button that renders a native `<button>` — or an `<a>` when `href` is set — and
6
- * decorates it with the `--el-*` design tokens. Supports semantic variants, sizes, outline /
7
- * pill / circle shapes, an optional dropdown caret and a loading spinner. API modelled on
8
- * Shoelace's `<sl-button>`.
37
+ * decorates it with the `--el-*` design tokens. Speaks the library's shared vocabulary: a semantic
38
+ * `variant`, an `appearance` and a `size`. Also supports pill / circle shapes, an optional
39
+ * dropdown caret and a loading spinner.
40
+ *
41
+ * ARIA attributes on the element reach the control inside it, which is what has the focus and what
42
+ * a screen reader announces: `aria-label`, `aria-description`, `aria-expanded`, `aria-haspopup`,
43
+ * `aria-pressed` and `aria-current` as they are, `aria-labelledby`, `aria-describedby` and
44
+ * `aria-controls` as references to the elements they name.
45
+ *
46
+ * The element is form-associated: a `<fieldset disabled>` around it disables it, and it is listed in
47
+ * the `elements` of its form. A button of the type `submit` submits its form with a hidden native
48
+ * `<button type="submit">` in its content: it is the `submitter` of the `submit` event, its `name`
49
+ * and `value` are in the data of the form, and Enter in a field of the form finds it. The element
50
+ * makes that button when the form is first submitted with it, by a click or by Enter in a field.
51
+ * Until then its content is what the page wrote, so a framework can hydrate a server-rendered
52
+ * button, also when the element has started before the framework does. The attributes `form`,
53
+ * `formaction`, `formenctype`, `formmethod`, `formnovalidate` and `formtarget` of the element do
54
+ * what they do on a native button. A `click` listener of the page that calls `preventDefault()`
55
+ * keeps the button from submitting or resetting.
9
56
  *
10
57
  * @element el-button
11
58
  *
@@ -20,34 +67,82 @@ import style from './button.style.js';
20
67
  * @csspart caret - The dropdown caret, present only while `caret` is `true`.
21
68
  * @csspart spinner - The loading spinner, present only while `loading` is `true`.
22
69
  *
23
- * @property {'default'|'primary'|'success'|'neutral'|'warning'|'danger'|'text'} variant - Visual
24
- * variant. Default `'default'`.
25
- * @property {'small'|'medium'|'large'} size - Button size. Default `'medium'`.
26
- * @property {boolean} outline - Draws the button as an outline (transparent fill, colored border).
70
+ * @property {'neutral'|'brand'|'success'|'warning'|'danger'} variant - Semantic variant, which
71
+ * picks the colours. Default `'neutral'`. Reflected to the `variant` attribute.
72
+ * @property {'filled'|'outlined'|'plain'} appearance - How the colours of the variant are painted:
73
+ * as a fill, as a border around a transparent button, or as text only. Default `'filled'`.
74
+ * Reflected to the `appearance` attribute.
75
+ * @property {'small'|'medium'|'large'} size - Button size. Default `'medium'`. Reflected to the
76
+ * `size` attribute.
27
77
  * @property {boolean} pill - Fully rounded ends.
28
78
  * @property {boolean} circle - Renders a square, fully-rounded icon button (use with a single icon).
29
79
  * @property {boolean} caret - Appends a dropdown caret after the label.
30
80
  * @property {boolean} loading - Shows a spinner and blocks interaction.
31
- * @property {boolean} disabled - Disables the button.
81
+ * @property {boolean} disabled - Disables the button. Reflected to the `disabled` attribute, which is
82
+ * there while the button is disabled and gone while it is not.
32
83
  * @property {'button'|'submit'|'reset'} type - Behaviour when activated. `submit` / `reset` act on
33
- * the nearest ancestor `<form>`. Ignored when `href` is set. Default `'button'`.
34
- * @property {string} name - Name submitted with the owning form (button mode only).
35
- * @property {string} value - Value submitted with the owning form (button mode only).
84
+ * the form of the button: the nearest ancestor `<form>`, or the one its `form` attribute names.
85
+ * Ignored when `href` is set. Default `'button'`.
86
+ * @property {string} name - Name submitted with the form, when the form is submitted with this
87
+ * button (button mode only).
88
+ * @property {string} value - Value submitted under that name (button mode only).
36
89
  * @property {string} href - When set, the button renders as a link to this URL.
37
90
  * @property {string} target - Where to open the linked URL (link mode only).
38
91
  * @property {string} rel - `rel` attribute for the link (link mode only). Default `'noreferrer noopener'`.
39
92
  * @property {string} download - Tells the browser to download the linked URL (link mode only).
40
93
  */
41
94
  export default class Button extends TemplateElement {
95
+ /**
96
+ * The platform tells a form-associated element when a `<fieldset disabled>` around it disables
97
+ * it, and resolves its `form` attribute.
98
+ */
99
+ static formAssociated = true;
100
+
101
+ static get observedAttributes() {
102
+ return [...ARIA_ATTRIBUTES, ...Object.keys(ARIA_RELATIONS), ...SUBMITTER_ATTRIBUTES, 'disabled'];
103
+ }
104
+
105
+ /**
106
+ * The native submit button of a button of the type `submit`, see `_syncSubmitter()`.
107
+ * @private
108
+ * @type {HTMLButtonElement | undefined}
109
+ */
110
+ _submitter = undefined;
111
+
112
+ /**
113
+ * Where the element listens for Enter in a field of its form, see `afterUpdate()`.
114
+ * @private
115
+ * @type {Node | undefined}
116
+ */
117
+ _keydownRoot = undefined;
118
+
42
119
  constructor() {
43
- super({ styles: [style], shadowRender: true });
120
+ super({
121
+ styles: [style],
122
+ shadowRender: true,
123
+ // A native submit button that the page writes into the content of the element is
124
+ // taken with the next render, see `_syncSubmitter()`.
125
+ mutationObserverOptions: { childList: true },
126
+ // The shared style modules select the host by these attributes.
127
+ propertyOptions: {
128
+ variant: { reflect: true },
129
+ appearance: { reflect: true },
130
+ size: { reflect: true },
131
+ // For the platform the attribute is what disables the element, see `reflectProperty()`.
132
+ disabled: { reflect: true },
133
+ // What a form submits is text. element-js parses every attribute, so that text which
134
+ // reads as a number arrives as one: "1.50" as 1.5.
135
+ name: { parse: false },
136
+ value: { parse: false },
137
+ },
138
+ });
44
139
  }
45
140
 
46
141
  properties() {
47
142
  return {
48
- variant: 'default',
143
+ variant: 'neutral',
144
+ appearance: 'filled',
49
145
  size: 'medium',
50
- outline: false,
51
146
  pill: false,
52
147
  circle: false,
53
148
  caret: false,
@@ -68,6 +163,85 @@ export default class Button extends TemplateElement {
68
163
  return !!this.href;
69
164
  }
70
165
 
166
+ /**
167
+ * An ARIA attribute of the element, or one it shares with a native submit button, was set,
168
+ * changed or removed. They are no properties of the component: the template and the submit
169
+ * button read them from the element, so a change asks for a new render. Before the first render
170
+ * there is nothing to do, it reads them anyway.
171
+ *
172
+ * `disabled` is a property. For the platform an attribute that is there disables a
173
+ * form-associated element, whatever it says: the browser then keeps every click from it. The
174
+ * library reads `disabled="false"` and an attribute without a value as not disabled, so those
175
+ * are taken off the element.
176
+ */
177
+ attributeChangedCallback(name, oldValue, newValue) {
178
+ if (name === 'disabled') {
179
+ if (newValue === 'false' || newValue === '') this.removeAttribute('disabled');
180
+ return;
181
+ }
182
+ if (oldValue !== newValue && this.$refs?.control) this.requestUpdate();
183
+ }
184
+
185
+ /**
186
+ * The platform says that the element is disabled, or no longer is: by its own attribute, or by a
187
+ * `<fieldset disabled>` around it. The template asks the platform, see `_isDisabled()`.
188
+ */
189
+ formDisabledCallback() {
190
+ if (this.$refs?.control) this.requestUpdate();
191
+ }
192
+
193
+ /**
194
+ * `disabled` is reflected as the platform reads it: the attribute is there while the button is
195
+ * disabled, and gone while it is not. element-js would write `disabled="false"`.
196
+ * @param {{ property: string, newValue: unknown }} options
197
+ */
198
+ reflectProperty(options) {
199
+ if (options.property !== 'disabled') {
200
+ super.reflectProperty(options);
201
+ return;
202
+ }
203
+ if (!options.newValue) this.removeAttribute('disabled');
204
+ else if (!this.hasAttribute('disabled')) this.setAttribute('disabled', 'true');
205
+ // element-js reads an attribute that is gone as `null`. The property stays a boolean.
206
+ if (options.newValue === null) this.disabled = false;
207
+ }
208
+
209
+ afterUpdate() {
210
+ this._syncAriaRelations();
211
+ this._syncSubmitter();
212
+
213
+ // `keydown` passes the root of its tree on the way to the field, the document or a shadow
214
+ // root: there the element hears Enter before the browser looks for the submit button.
215
+ if (!this._keydownRoot) {
216
+ this._keydownRoot = this.getRootNode();
217
+ this._keydownRoot.addEventListener('keydown', this._onRootKeydown, true);
218
+ }
219
+ }
220
+
221
+ disconnected() {
222
+ this._keydownRoot?.removeEventListener('keydown', this._onRootKeydown, true);
223
+ this._keydownRoot = undefined;
224
+ }
225
+
226
+ /**
227
+ * Enter in a field of the form submits the form with its first submit button, and without one
228
+ * only a form with a single field. The browser looks for that button once every listener has
229
+ * had the key, so the native submit button of the element is made here, if it is not there yet.
230
+ *
231
+ * Only for a key the browser may submit with: Enter in an `<input>` or a `<select>` of the
232
+ * form, and not while a text is being composed. Enter in a `<textarea>` is a line break, and
233
+ * leaves the content of the element as it is.
234
+ * @private
235
+ * @param {KeyboardEvent} event
236
+ */
237
+ _onRootKeydown = (event) => {
238
+ if (event.key !== 'Enter' || event.isComposing || this.isLink || this.type !== 'submit') return;
239
+ const field = event.target;
240
+ const form = this._internals.form;
241
+ if (!form || field?.form !== form || !field.matches('input, select')) return;
242
+ this._syncSubmitter(true);
243
+ };
244
+
71
245
  /** Focuses the underlying control. */
72
246
  focus(options) {
73
247
  this.$refs.control?.focus(options);
@@ -87,24 +261,159 @@ export default class Button extends TemplateElement {
87
261
  return {
88
262
  '.button': {
89
263
  click: (event) => {
90
- if (this.disabled || this.loading) {
264
+ // Enter in a field of the form clicks the native submit button, which is in the
265
+ // label slot: that click passes the control, and has submitted the form already.
266
+ if (event.target === this._submitter) return;
267
+ if (this._isDisabled() || this.loading) {
91
268
  event.preventDefault();
92
269
  event.stopImmediatePropagation();
93
270
  return;
94
271
  }
95
- // Shadow DOM swallows the native submit/reset, so drive the nearest form by hand.
96
- if (!this.isLink && (this.type === 'submit' || this.type === 'reset')) {
97
- const form = this.closest('form');
98
- if (form) {
99
- if (this.type === 'submit') form.requestSubmit();
100
- else form.reset();
101
- }
272
+ if (this.isLink) return;
273
+ // The control is in the shadow root, where it has no form. A submit goes through
274
+ // the native submit button of the element, a reset to the form of the element.
275
+ // Both are taken here, while the button is not disabled, and act once the page
276
+ // has had the click.
277
+ if (this.type === 'submit') {
278
+ const submitter = this._syncSubmitter(true);
279
+ this._afterListeners(event, () => submitter?.form?.requestSubmit(submitter));
280
+ } else if (this.type === 'reset') {
281
+ const form = this._internals.form;
282
+ this._afterListeners(event, () => form?.reset());
102
283
  }
103
284
  },
104
285
  },
105
286
  };
106
287
  }
107
288
 
289
+ /**
290
+ * Runs `action` once every listener has had `event`, and not when one of them has prevented it:
291
+ * what the platform does with the activation of a native control. The listener of the control
292
+ * is the first on the path of a click, before every listener of the page.
293
+ *
294
+ * The last target on the path is the window, and a listener that is added there now comes after
295
+ * the ones it has: `action` runs inside of the click, as a caller of `click()` expects. A
296
+ * listener on the way that stops the event keeps it from getting there. The platform acts all
297
+ * the same, so `action` runs a task later then.
298
+ * @private
299
+ * @param {Event} event
300
+ * @param {() => void} action
301
+ */
302
+ _afterListeners(event, action) {
303
+ const end = event.composedPath().at(-1);
304
+ let timer;
305
+ const act = () => {
306
+ clearTimeout(timer);
307
+ end.removeEventListener(event.type, act);
308
+ if (!event.defaultPrevented) action();
309
+ };
310
+ end.addEventListener(event.type, act);
311
+ timer = setTimeout(act);
312
+ }
313
+
314
+ /**
315
+ * Whether the button is disabled: by its own `disabled`, or by a `<fieldset disabled>` around
316
+ * it. The platform knows the second, and counts the attribute of the element as well. On the
317
+ * server there is no tree to ask.
318
+ * @private
319
+ * @returns {boolean}
320
+ */
321
+ _isDisabled() {
322
+ return !!this.disabled || !!this.matches?.(':disabled');
323
+ }
324
+
325
+ /**
326
+ * Keeps the native submit button of a button of the type `submit`: a hidden
327
+ * `<button type="submit">` in the content of the element, in the page, where it belongs to the
328
+ * form. A form is submitted with a submit button that belongs to it, and with nothing else: the
329
+ * button is the `submitter` of the `submit` event, its `name` and `value` are in the data, it
330
+ * says how to submit (`formmethod`, `formnovalidate`, …), and Enter in a field looks for it.
331
+ * The control in the shadow root has no form, and the element itself is no submit button for the
332
+ * platform.
333
+ *
334
+ * The button takes over `name`, `value` and the attributes of the element that a native submit
335
+ * button has. It is disabled while the element is disabled or loading, which keeps Enter from
336
+ * submitting as well. One that is in the content already is taken: written by the page, for a
337
+ * form that is submitted with Enter before the script has run, or copied with the element.
338
+ *
339
+ * The element makes the button only when the form is about to be submitted with it (`create`):
340
+ * with a click, or with Enter in a field. A render does not. The content of the element is what
341
+ * the page wrote until then: a framework that hydrates a server-rendered page after the element
342
+ * has started finds the children it rendered, and no other.
343
+ * @private
344
+ * @param {boolean} [create] - Whether to make the button when there is none.
345
+ * @returns {HTMLButtonElement | null} The submit button, or `null`: for a button of another
346
+ * type, and while there is none and none was asked for.
347
+ */
348
+ _syncSubmitter(create = false) {
349
+ const ours = this._submitter?.parentNode === this ? this._submitter : null;
350
+ let submitter = ours ?? this.querySelector(':scope > button[type="submit"][hidden]');
351
+
352
+ if (this.isLink || this.type !== 'submit') {
353
+ ours?.remove();
354
+ this._submitter = undefined;
355
+ return null;
356
+ }
357
+
358
+ if (!submitter && !create) {
359
+ this._submitter = undefined;
360
+ return null;
361
+ }
362
+
363
+ if (!submitter) {
364
+ submitter = document.createElement('button');
365
+ submitter.type = 'submit';
366
+ submitter.hidden = true;
367
+ this.append(submitter);
368
+ }
369
+ this._submitter = submitter;
370
+
371
+ // A rule of the page for buttons does not show it.
372
+ submitter.style.setProperty('display', 'none', 'important');
373
+ submitter.disabled = this._isDisabled() || !!this.loading;
374
+
375
+ // A script may set a number. An empty text is no attribute, as on the control.
376
+ const text = (value) => (value === '' || value === null || value === undefined ? null : String(value));
377
+ const attributes = { name: text(this.name), value: text(this.value) };
378
+ for (const name of SUBMITTER_ATTRIBUTES) attributes[name] = this.getAttribute(name);
379
+ for (const [name, value] of Object.entries(attributes)) {
380
+ if (value === null) submitter.removeAttribute(name);
381
+ else if (submitter.getAttribute(name) !== value) submitter.setAttribute(name, value);
382
+ }
383
+ return submitter;
384
+ }
385
+
386
+ /**
387
+ * The ARIA attributes of the element, for the control. An empty one counts as not set: none of
388
+ * them has an empty value, and element-js writes an attribute that was there from the start
389
+ * back as an empty one when it is removed.
390
+ * @private
391
+ * @returns {Object<string, string | undefined>}
392
+ */
393
+ _ariaAttributes() {
394
+ return Object.fromEntries(ARIA_ATTRIBUTES.map((name) => [name, this.getAttribute(name) || undefined]));
395
+ }
396
+
397
+ /**
398
+ * Hands the control the elements that the element names by id in `aria-labelledby`,
399
+ * `aria-describedby` and `aria-controls`. They are looked up when the button renders, so an
400
+ * element that comes into the page later is found once the attribute is set again.
401
+ * @private
402
+ */
403
+ _syncAriaRelations() {
404
+ const control = this.$refs.control;
405
+ if (!control) return;
406
+
407
+ const root = this.getRootNode();
408
+ for (const [attribute, property] of Object.entries(ARIA_RELATIONS)) {
409
+ // A browser without element references stays where it was: without the relation.
410
+ if (!(property in control)) continue;
411
+ const ids = this.getAttribute(attribute)?.trim().split(/\s+/) ?? [];
412
+ const elements = ids.map((id) => root.getElementById?.(id)).filter(Boolean);
413
+ control[property] = elements.length > 0 ? elements : null;
414
+ }
415
+ }
416
+
108
417
  /** @private */
109
418
  contentTemplate() {
110
419
  return html`
@@ -119,14 +428,12 @@ export default class Button extends TemplateElement {
119
428
  template() {
120
429
  const classes = {
121
430
  button: true,
122
- [`button--${this.variant}`]: true,
123
- [`button--${this.size}`]: true,
124
- 'button--outline': !!this.outline,
125
431
  'button--pill': !!this.pill,
126
432
  'button--circle': !!this.circle,
127
433
  'button--loading': !!this.loading,
128
434
  'button--caret': !!this.caret,
129
435
  };
436
+ const disabled = this._isDisabled();
130
437
 
131
438
  if (this.isLink) {
132
439
  return html`
@@ -135,14 +442,15 @@ export default class Button extends TemplateElement {
135
442
  part="base"
136
443
  class="${classMap(classes)}"
137
444
  role="button"
138
- aria-disabled="${this.disabled ? 'true' : 'false'}"
445
+ aria-disabled="${disabled ? 'true' : 'false'}"
139
446
  aria-busy="${this.loading ? 'true' : 'false'}"
140
- tabindex="${this.disabled ? '-1' : '0'}"
447
+ tabindex="${disabled ? '-1' : '0'}"
141
448
  ${spreadAttributes({
142
- href: this.disabled ? undefined : this.href,
449
+ href: disabled ? undefined : this.href,
143
450
  target: this.target || undefined,
144
451
  rel: this.target ? this.rel : undefined,
145
452
  download: this.download || undefined,
453
+ ...this._ariaAttributes(),
146
454
  })}
147
455
  >
148
456
  ${this.contentTemplate()}
@@ -156,11 +464,12 @@ export default class Button extends TemplateElement {
156
464
  part="base"
157
465
  class="${classMap(classes)}"
158
466
  type="${this.type}"
159
- ?disabled="${this.disabled}"
467
+ ?disabled="${disabled}"
160
468
  aria-busy="${this.loading ? 'true' : 'false'}"
161
469
  ${spreadAttributes({
162
470
  name: this.name || undefined,
163
471
  value: this.value || undefined,
472
+ ...this._ariaAttributes(),
164
473
  })}
165
474
  >
166
475
  ${this.contentTemplate()}