@webtides/element-library 0.2.0 → 0.3.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 (398) hide show
  1. package/CHANGELOG.md +384 -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 +16604 -3420
  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 +34 -1
  37. package/src/components/button/button.js +285 -29
  38. package/src/components/button/button.readme.md +130 -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 +19 -0
  59. package/src/components/checkbox-field/checkbox-field.js +25 -10
  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 +16 -0
  191. package/src/components/switch-field/switch-field.js +17 -9
  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 +129 -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,41 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
12
12
 
13
13
  ## Unreleased
14
14
 
15
+ ## [0.3.0] - 2026-11-17
16
+
17
+ ### Added
18
+
19
+ - `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))
20
+ - `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))
21
+ - 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.
22
+ - 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))
23
+ - 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))
24
+
25
+ ### Changed
26
+
27
+ - 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))
28
+ - 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))
29
+ - 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))
30
+ - 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.
31
+ - 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))
32
+ - `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))
33
+ - 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))
34
+
35
+ ### Fixed
36
+
37
+ - 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))
38
+ - 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))
39
+ - 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))
40
+ - 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))
41
+ - 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))
42
+ - 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))
43
+ - The `hidden` attribute hides the button. Before, the `display` of the element won over it. ([#69](https://github.com/webtides/element-library/issues/69))
44
+ - 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.
45
+ - 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)`).
46
+ - 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))
47
+
15
48
  ## [0.1.0] - 2026-06-03
16
49
 
17
50
  ### Added
18
51
 
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.
52
+ - 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,55 @@
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` keeps a hidden native
48
+ * `<button type="submit">` in its content, which is what the form is submitted with: it is the
49
+ * `submitter` of the `submit` event, its `name` and `value` are in the data of the form, and Enter in
50
+ * a field of the form finds it. The attributes `form`, `formaction`, `formenctype`, `formmethod`,
51
+ * `formnovalidate` and `formtarget` of the element do what they do on a native button. A `click`
52
+ * listener of the page that calls `preventDefault()` keeps the button from submitting or resetting.
9
53
  *
10
54
  * @element el-button
11
55
  *
@@ -20,34 +64,75 @@ import style from './button.style.js';
20
64
  * @csspart caret - The dropdown caret, present only while `caret` is `true`.
21
65
  * @csspart spinner - The loading spinner, present only while `loading` is `true`.
22
66
  *
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).
67
+ * @property {'neutral'|'brand'|'success'|'warning'|'danger'} variant - Semantic variant, which
68
+ * picks the colours. Default `'neutral'`. Reflected to the `variant` attribute.
69
+ * @property {'filled'|'outlined'|'plain'} appearance - How the colours of the variant are painted:
70
+ * as a fill, as a border around a transparent button, or as text only. Default `'filled'`.
71
+ * Reflected to the `appearance` attribute.
72
+ * @property {'small'|'medium'|'large'} size - Button size. Default `'medium'`. Reflected to the
73
+ * `size` attribute.
27
74
  * @property {boolean} pill - Fully rounded ends.
28
75
  * @property {boolean} circle - Renders a square, fully-rounded icon button (use with a single icon).
29
76
  * @property {boolean} caret - Appends a dropdown caret after the label.
30
77
  * @property {boolean} loading - Shows a spinner and blocks interaction.
31
- * @property {boolean} disabled - Disables the button.
78
+ * @property {boolean} disabled - Disables the button. Reflected to the `disabled` attribute, which is
79
+ * there while the button is disabled and gone while it is not.
32
80
  * @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).
81
+ * the form of the button: the nearest ancestor `<form>`, or the one its `form` attribute names.
82
+ * Ignored when `href` is set. Default `'button'`.
83
+ * @property {string} name - Name submitted with the form, when the form is submitted with this
84
+ * button (button mode only).
85
+ * @property {string} value - Value submitted under that name (button mode only).
36
86
  * @property {string} href - When set, the button renders as a link to this URL.
37
87
  * @property {string} target - Where to open the linked URL (link mode only).
38
88
  * @property {string} rel - `rel` attribute for the link (link mode only). Default `'noreferrer noopener'`.
39
89
  * @property {string} download - Tells the browser to download the linked URL (link mode only).
40
90
  */
41
91
  export default class Button extends TemplateElement {
92
+ /**
93
+ * The platform tells a form-associated element when a `<fieldset disabled>` around it disables
94
+ * it, and resolves its `form` attribute.
95
+ */
96
+ static formAssociated = true;
97
+
98
+ static get observedAttributes() {
99
+ return [...ARIA_ATTRIBUTES, ...Object.keys(ARIA_RELATIONS), ...SUBMITTER_ATTRIBUTES, 'disabled'];
100
+ }
101
+
102
+ /**
103
+ * The native submit button of a button of the type `submit`, see `_syncSubmitter()`.
104
+ * @private
105
+ * @type {HTMLButtonElement | undefined}
106
+ */
107
+ _submitter = undefined;
108
+
42
109
  constructor() {
43
- super({ styles: [style], shadowRender: true });
110
+ super({
111
+ styles: [style],
112
+ shadowRender: true,
113
+ // The native submit button is in the content of the element. When the page replaces
114
+ // the content, the next render puts it back.
115
+ mutationObserverOptions: { childList: true },
116
+ // The shared style modules select the host by these attributes.
117
+ propertyOptions: {
118
+ variant: { reflect: true },
119
+ appearance: { reflect: true },
120
+ size: { reflect: true },
121
+ // For the platform the attribute is what disables the element, see `reflectProperty()`.
122
+ disabled: { reflect: true },
123
+ // What a form submits is text. element-js parses every attribute, so that text which
124
+ // reads as a number arrives as one: "1.50" as 1.5.
125
+ name: { parse: false },
126
+ value: { parse: false },
127
+ },
128
+ });
44
129
  }
45
130
 
46
131
  properties() {
47
132
  return {
48
- variant: 'default',
133
+ variant: 'neutral',
134
+ appearance: 'filled',
49
135
  size: 'medium',
50
- outline: false,
51
136
  pill: false,
52
137
  circle: false,
53
138
  caret: false,
@@ -68,6 +153,54 @@ export default class Button extends TemplateElement {
68
153
  return !!this.href;
69
154
  }
70
155
 
156
+ /**
157
+ * An ARIA attribute of the element, or one it shares with a native submit button, was set,
158
+ * changed or removed. They are no properties of the component: the template and the submit
159
+ * button read them from the element, so a change asks for a new render. Before the first render
160
+ * there is nothing to do, it reads them anyway.
161
+ *
162
+ * `disabled` is a property. For the platform an attribute that is there disables a
163
+ * form-associated element, whatever it says: the browser then keeps every click from it. The
164
+ * library reads `disabled="false"` and an attribute without a value as not disabled, so those
165
+ * are taken off the element.
166
+ */
167
+ attributeChangedCallback(name, oldValue, newValue) {
168
+ if (name === 'disabled') {
169
+ if (newValue === 'false' || newValue === '') this.removeAttribute('disabled');
170
+ return;
171
+ }
172
+ if (oldValue !== newValue && this.$refs?.control) this.requestUpdate();
173
+ }
174
+
175
+ /**
176
+ * The platform says that the element is disabled, or no longer is: by its own attribute, or by a
177
+ * `<fieldset disabled>` around it. The template asks the platform, see `_isDisabled()`.
178
+ */
179
+ formDisabledCallback() {
180
+ if (this.$refs?.control) this.requestUpdate();
181
+ }
182
+
183
+ /**
184
+ * `disabled` is reflected as the platform reads it: the attribute is there while the button is
185
+ * disabled, and gone while it is not. element-js would write `disabled="false"`.
186
+ * @param {{ property: string, newValue: unknown }} options
187
+ */
188
+ reflectProperty(options) {
189
+ if (options.property !== 'disabled') {
190
+ super.reflectProperty(options);
191
+ return;
192
+ }
193
+ if (!options.newValue) this.removeAttribute('disabled');
194
+ else if (!this.hasAttribute('disabled')) this.setAttribute('disabled', 'true');
195
+ // element-js reads an attribute that is gone as `null`. The property stays a boolean.
196
+ if (options.newValue === null) this.disabled = false;
197
+ }
198
+
199
+ afterUpdate() {
200
+ this._syncAriaRelations();
201
+ this._syncSubmitter();
202
+ }
203
+
71
204
  /** Focuses the underlying control. */
72
205
  focus(options) {
73
206
  this.$refs.control?.focus(options);
@@ -87,24 +220,147 @@ export default class Button extends TemplateElement {
87
220
  return {
88
221
  '.button': {
89
222
  click: (event) => {
90
- if (this.disabled || this.loading) {
223
+ // Enter in a field of the form clicks the native submit button, which is in the
224
+ // label slot: that click passes the control, and has submitted the form already.
225
+ if (event.target === this._submitter) return;
226
+ if (this._isDisabled() || this.loading) {
91
227
  event.preventDefault();
92
228
  event.stopImmediatePropagation();
93
229
  return;
94
230
  }
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
- }
231
+ if (this.isLink) return;
232
+ // The control is in the shadow root, where it has no form. A submit goes through
233
+ // the native submit button of the element, a reset to the form of the element.
234
+ // Both are taken here, while the button is not disabled, and act once the page
235
+ // has had the click.
236
+ if (this.type === 'submit') {
237
+ const submitter = this._syncSubmitter();
238
+ this._afterListeners(event, () => submitter?.form?.requestSubmit(submitter));
239
+ } else if (this.type === 'reset') {
240
+ const form = this._internals.form;
241
+ this._afterListeners(event, () => form?.reset());
102
242
  }
103
243
  },
104
244
  },
105
245
  };
106
246
  }
107
247
 
248
+ /**
249
+ * Runs `action` once every listener has had `event`, and not when one of them has prevented it:
250
+ * what the platform does with the activation of a native control. The listener of the control
251
+ * is the first on the path of a click, before every listener of the page.
252
+ *
253
+ * The last target on the path is the window, and a listener that is added there now comes after
254
+ * the ones it has: `action` runs inside of the click, as a caller of `click()` expects. A
255
+ * listener on the way that stops the event keeps it from getting there. The platform acts all
256
+ * the same, so `action` runs a task later then.
257
+ * @private
258
+ * @param {Event} event
259
+ * @param {() => void} action
260
+ */
261
+ _afterListeners(event, action) {
262
+ const end = event.composedPath().at(-1);
263
+ let timer;
264
+ const act = () => {
265
+ clearTimeout(timer);
266
+ end.removeEventListener(event.type, act);
267
+ if (!event.defaultPrevented) action();
268
+ };
269
+ end.addEventListener(event.type, act);
270
+ timer = setTimeout(act);
271
+ }
272
+
273
+ /**
274
+ * Whether the button is disabled: by its own `disabled`, or by a `<fieldset disabled>` around
275
+ * it. The platform knows the second, and counts the attribute of the element as well. On the
276
+ * server there is no tree to ask.
277
+ * @private
278
+ * @returns {boolean}
279
+ */
280
+ _isDisabled() {
281
+ return !!this.disabled || !!this.matches?.(':disabled');
282
+ }
283
+
284
+ /**
285
+ * Keeps the native submit button of a button of the type `submit`: a hidden
286
+ * `<button type="submit">` in the content of the element, in the page, where it belongs to the
287
+ * form. A form is submitted with a submit button that belongs to it, and with nothing else: the
288
+ * button is the `submitter` of the `submit` event, its `name` and `value` are in the data, it
289
+ * says how to submit (`formmethod`, `formnovalidate`, …), and Enter in a field looks for it.
290
+ * The control in the shadow root has no form, and the element itself is no submit button for the
291
+ * platform.
292
+ *
293
+ * The button takes over `name`, `value` and the attributes of the element that a native submit
294
+ * button has. It is disabled while the element is disabled or loading, which keeps Enter from
295
+ * submitting as well. One that is in the content already is taken: written by the page, for a
296
+ * form that is submitted with Enter before the script has run, or copied with the element.
297
+ * @private
298
+ * @returns {HTMLButtonElement | null} The submit button, or `null` for a button of another type.
299
+ */
300
+ _syncSubmitter() {
301
+ const ours = this._submitter?.parentNode === this ? this._submitter : null;
302
+ let submitter = ours ?? this.querySelector(':scope > button[type="submit"][hidden]');
303
+
304
+ if (this.isLink || this.type !== 'submit') {
305
+ ours?.remove();
306
+ this._submitter = undefined;
307
+ return null;
308
+ }
309
+
310
+ if (!submitter) {
311
+ submitter = document.createElement('button');
312
+ submitter.type = 'submit';
313
+ submitter.hidden = true;
314
+ this.append(submitter);
315
+ }
316
+ this._submitter = submitter;
317
+
318
+ // A rule of the page for buttons does not show it.
319
+ submitter.style.setProperty('display', 'none', 'important');
320
+ submitter.disabled = this._isDisabled() || !!this.loading;
321
+
322
+ // A script may set a number. An empty text is no attribute, as on the control.
323
+ const text = (value) => (value === '' || value === null || value === undefined ? null : String(value));
324
+ const attributes = { name: text(this.name), value: text(this.value) };
325
+ for (const name of SUBMITTER_ATTRIBUTES) attributes[name] = this.getAttribute(name);
326
+ for (const [name, value] of Object.entries(attributes)) {
327
+ if (value === null) submitter.removeAttribute(name);
328
+ else if (submitter.getAttribute(name) !== value) submitter.setAttribute(name, value);
329
+ }
330
+ return submitter;
331
+ }
332
+
333
+ /**
334
+ * The ARIA attributes of the element, for the control. An empty one counts as not set: none of
335
+ * them has an empty value, and element-js writes an attribute that was there from the start
336
+ * back as an empty one when it is removed.
337
+ * @private
338
+ * @returns {Object<string, string | undefined>}
339
+ */
340
+ _ariaAttributes() {
341
+ return Object.fromEntries(ARIA_ATTRIBUTES.map((name) => [name, this.getAttribute(name) || undefined]));
342
+ }
343
+
344
+ /**
345
+ * Hands the control the elements that the element names by id in `aria-labelledby`,
346
+ * `aria-describedby` and `aria-controls`. They are looked up when the button renders, so an
347
+ * element that comes into the page later is found once the attribute is set again.
348
+ * @private
349
+ */
350
+ _syncAriaRelations() {
351
+ const control = this.$refs.control;
352
+ if (!control) return;
353
+
354
+ const root = this.getRootNode();
355
+ for (const [attribute, property] of Object.entries(ARIA_RELATIONS)) {
356
+ // A browser without element references stays where it was: without the relation.
357
+ if (!(property in control)) continue;
358
+ const ids = this.getAttribute(attribute)?.trim().split(/\s+/) ?? [];
359
+ const elements = ids.map((id) => root.getElementById?.(id)).filter(Boolean);
360
+ control[property] = elements.length > 0 ? elements : null;
361
+ }
362
+ }
363
+
108
364
  /** @private */
109
365
  contentTemplate() {
110
366
  return html`
@@ -119,14 +375,12 @@ export default class Button extends TemplateElement {
119
375
  template() {
120
376
  const classes = {
121
377
  button: true,
122
- [`button--${this.variant}`]: true,
123
- [`button--${this.size}`]: true,
124
- 'button--outline': !!this.outline,
125
378
  'button--pill': !!this.pill,
126
379
  'button--circle': !!this.circle,
127
380
  'button--loading': !!this.loading,
128
381
  'button--caret': !!this.caret,
129
382
  };
383
+ const disabled = this._isDisabled();
130
384
 
131
385
  if (this.isLink) {
132
386
  return html`
@@ -135,14 +389,15 @@ export default class Button extends TemplateElement {
135
389
  part="base"
136
390
  class="${classMap(classes)}"
137
391
  role="button"
138
- aria-disabled="${this.disabled ? 'true' : 'false'}"
392
+ aria-disabled="${disabled ? 'true' : 'false'}"
139
393
  aria-busy="${this.loading ? 'true' : 'false'}"
140
- tabindex="${this.disabled ? '-1' : '0'}"
394
+ tabindex="${disabled ? '-1' : '0'}"
141
395
  ${spreadAttributes({
142
- href: this.disabled ? undefined : this.href,
396
+ href: disabled ? undefined : this.href,
143
397
  target: this.target || undefined,
144
398
  rel: this.target ? this.rel : undefined,
145
399
  download: this.download || undefined,
400
+ ...this._ariaAttributes(),
146
401
  })}
147
402
  >
148
403
  ${this.contentTemplate()}
@@ -156,11 +411,12 @@ export default class Button extends TemplateElement {
156
411
  part="base"
157
412
  class="${classMap(classes)}"
158
413
  type="${this.type}"
159
- ?disabled="${this.disabled}"
414
+ ?disabled="${disabled}"
160
415
  aria-busy="${this.loading ? 'true' : 'false'}"
161
416
  ${spreadAttributes({
162
417
  name: this.name || undefined,
163
418
  value: this.value || undefined,
419
+ ...this._ariaAttributes(),
164
420
  })}
165
421
  >
166
422
  ${this.contentTemplate()}