@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
@@ -13,9 +13,9 @@ import style from './form-field.style.js';
13
13
  * @fires {CustomEvent<string>} input-change - Fired when the field's `value` changes.
14
14
  * `detail` is the new value. Bubbles.
15
15
  *
16
- * @cssstate touched - Set on the host once the user has focused and blurred the field.
17
- * Inherited by all subclasses (`InputField`, `CheckboxField`, `TextareaField`,
18
- * `AmountField`, `SelectField`).
16
+ * @cssstate touched - Set on the host once the user has focused and blurred the field, or the
17
+ * browser has refused a submit because of it. Inherited by all subclasses (`InputField`,
18
+ * `CheckboxField`, `TextareaField`, `AmountField`, `SelectField`).
19
19
  * @cssstate valid - Set on the host while the field currently passes validation.
20
20
  * @cssstate invalid - Set on the host while the field currently fails validation.
21
21
  *
@@ -28,14 +28,57 @@ import style from './form-field.style.js';
28
28
  * still announced to screen readers (via an `sr-only` class).
29
29
  * @property {string} errorMessage - Error message displayed when the field is invalid and has
30
30
  * been touched.
31
- * @property {string} helpMessage - Helper text displayed below the field.
31
+ * @property {string} helpMessage - Helper text. Displayed between the label and the control; a
32
+ * checkbox and a switch display it below the control and its label.
32
33
  * @property {boolean} valid - Whether the field currently passes validation.
33
34
  * @property {boolean} touched - Whether the user has interacted with the field (focused and
34
- * blurred). Validation messages only surface when this is `true`.
35
+ * blurred), or the browser has refused a submit because of it. Validation messages only surface
36
+ * when this is `true`.
35
37
  */
36
38
  export default class FormField extends TemplateElement {
39
+ /**
40
+ * The state the field was rendered with, for a reset of its form. See `_stateForReset()`.
41
+ * @private
42
+ */
43
+ _renderedState = undefined;
44
+
45
+ /**
46
+ * Where the field listens for the reset of its form, see `afterUpdate()`.
47
+ * @private
48
+ */
49
+ _resetRoot = undefined;
50
+
51
+ /**
52
+ * The value the control and the `value` property last agreed on, see `_syncControlValue()`.
53
+ * @private
54
+ */
55
+ _controlValue = undefined;
56
+
57
+ /**
58
+ * What tells the ids of this field from the ids of every other field, see `_idOf()`.
59
+ * @private
60
+ */
61
+ uuid = Math.random().toString(36).substr(2, 5);
62
+
37
63
  constructor(options) {
38
- super({ shadowRender: false, styles: [style], ...options });
64
+ super({
65
+ shadowRender: false,
66
+ styles: [style],
67
+ ...options,
68
+ // The value of a field is text. element-js parses every attribute, so that text which
69
+ // reads as a number or as JSON arrives as something else: "1.50" as 1.5, a long number
70
+ // without its last digits. A subclass that takes another type says so (`AmountField`).
71
+ propertyOptions: { value: { parse: false }, ...options?.propertyOptions },
72
+ });
73
+
74
+ // element-js keeps the stylesheets of an element on its class, and looks them up there
75
+ // without asking whose they are. A field whose parent class was connected first found the
76
+ // stylesheets of that parent and never built its own: an el-password-field after an
77
+ // el-input-field had the styles of the input field only. A property of its own on every
78
+ // class makes the lookup stop there.
79
+ if (!Object.hasOwn(this.constructor, 'elementStyleSheets')) {
80
+ this.constructor.elementStyleSheets = undefined;
81
+ }
39
82
  }
40
83
 
41
84
  connected() {
@@ -45,6 +88,55 @@ export default class FormField extends TemplateElement {
45
88
  this.syncValidationStates();
46
89
  }
47
90
 
91
+ afterUpdate() {
92
+ // The first update of a field is the one that connected() comes with: every class has set
93
+ // its state up by now, the touched mark of a field with a value included.
94
+ this._renderedState ??= this._stateForReset();
95
+
96
+ // `reset` bubbles to the root of its tree, the document or a shadow root, and does not
97
+ // leave it. The control is not asked for its form yet: a radio group can get its options
98
+ // later.
99
+ if (!this._resetRoot) {
100
+ this._resetRoot = this.getRootNode();
101
+ this._resetRoot.addEventListener('reset', this._onFormReset);
102
+ }
103
+ }
104
+
105
+ disconnected() {
106
+ this._resetRoot?.removeEventListener('reset', this._onFormReset);
107
+ this._resetRoot = undefined;
108
+ }
109
+
110
+ /**
111
+ * The properties that a reset of the form puts back, with the values they have now.
112
+ * @private
113
+ * @returns {Object<string, unknown>}
114
+ */
115
+ _stateForReset() {
116
+ return { value: this.value, touched: this.touched, valid: this.valid };
117
+ }
118
+
119
+ /**
120
+ * The form of the field was reset. The browser puts every control back to its default, which
121
+ * for these fields is the value of now: a field renders its value as an attribute of the
122
+ * control, and that attribute is the default. So the field puts its own state back, to the one
123
+ * it was rendered with, and the control follows with the next render.
124
+ *
125
+ * The event comes before the browser resets the controls, and a listener after this one can
126
+ * still cancel it. A task later both are settled.
127
+ * @private
128
+ * @param {Event} event
129
+ */
130
+ _onFormReset = (event) => {
131
+ const control = this.$refs.input ?? this.querySelector('input');
132
+ if (!control || event.target !== control.form) return;
133
+
134
+ setTimeout(() => {
135
+ if (event.defaultPrevented || !this.isConnected) return;
136
+ Object.assign(this, this._renderedState);
137
+ });
138
+ };
139
+
48
140
  properties() {
49
141
  return {
50
142
  name: '',
@@ -100,9 +192,13 @@ export default class FormField extends TemplateElement {
100
192
  this.onChange();
101
193
  }
102
194
  },
195
+ // The watcher of `value` reports the change, as it does for every other way the
196
+ // value changes. An event from here as well was a second one for the same value.
103
197
  change: () => {
104
198
  this.onChange();
105
- this.dispatch(FormFieldEvents.INPUT_CHANGE, this.$refs.input.value);
199
+ },
200
+ invalid: (event) => {
201
+ this._onInvalid(event.target);
106
202
  },
107
203
  },
108
204
  '.is-invalid': {
@@ -141,23 +237,96 @@ export default class FormField extends TemplateElement {
141
237
 
142
238
  /**
143
239
  * Called when the input value changes. Updates `value` and refreshes validation.
240
+ *
241
+ * A control that is empty is no change for a field without a value: `value` stays `null`. A key
242
+ * that enters nothing (Shift, an arrow key) and the first key of a date leave the control empty.
243
+ * Taking that as the value `''` wrote it to the control as its default with the next render,
244
+ * and a control for a date or a time drops what the user has entered so far when its value is
245
+ * written: the first key was lost.
144
246
  * @returns {void}
145
247
  */
146
248
  onChange() {
147
- this.value = this.$refs.input.value;
148
- this.valid = this.$refs.input.validity.valid;
249
+ const control = this.$refs.input;
250
+ this._controlValue = control.value;
251
+ if (control.value !== String(this.value ?? '')) this.value = control.value;
252
+ this.valid = control.validity.valid;
253
+ }
254
+
255
+ /**
256
+ * Writes a value that was set from outside to the control. For the fields that take text
257
+ * (`InputField`, `PasswordField`, `TextareaField`), which call it from their `value` watcher.
258
+ *
259
+ * Such a field renders its value as the default of its control: the `value` attribute of an
260
+ * input, the text of a textarea. Once the user has typed, the browser no longer shows that
261
+ * default, so the control has to be told. A value that came from the control itself is not
262
+ * written back: text typed between a change and the next render is kept, and the caret stays
263
+ * where it is.
264
+ *
265
+ * The watcher runs a frame after the change, once for every change. By then the value can have
266
+ * changed again, so it is the value of now that counts, not the one the watcher was called
267
+ * for: writing an older one moves the caret to the end of the text.
268
+ * @private
269
+ */
270
+ _syncControlValue() {
271
+ const controlValue = String(this.value ?? '');
272
+ if (!this.$refs.input || controlValue === this._controlValue) return;
273
+ this._controlValue = controlValue;
274
+ this.$refs.input.value = controlValue;
275
+ }
276
+
277
+ /**
278
+ * The browser found the control not valid. If it did so for a submit, the field shows its error
279
+ * message, as it does once the user has left it: the form was refused, and the user has to see
280
+ * why, on every field and in the words of the page.
281
+ *
282
+ * `checkValidity()` and `reportValidity()` fire the same event without a submit. A page that asks
283
+ * on every keystroke whether its form is valid must not turn every field red. The browser tells
284
+ * the two apart itself: before it validates for a submit it marks all controls of the form as
285
+ * touched by the user, which is the state behind `:user-invalid`.
286
+ *
287
+ * The event is not cancelled, so the browser still focuses the first control and shows its
288
+ * bubble there.
289
+ * @private
290
+ * @param {HTMLElement} control
291
+ */
292
+ _onInvalid(control) {
293
+ if (!control.matches(':user-invalid')) return;
294
+ this.touched = true;
295
+ this.valid = false;
149
296
  }
150
297
 
151
298
  /**
152
- * Clears the input value, refocuses it, and resets the touched state.
299
+ * Clears the input value, refocuses it, and resets the touched state. The field follows the
300
+ * control, as it does when the user deletes the text by hand: `value` is empty, `input-change`
301
+ * reports it, and `valid` is what the control says.
153
302
  * @returns {void}
154
303
  */
155
304
  clearInput() {
156
305
  this.$refs.input.focus();
157
306
  this.$refs.input.value = '';
307
+ // A value that a script sets fires no event, so the field has to be told.
308
+ this.onChange();
158
309
  this.touched = false;
159
310
  }
160
311
 
312
+ /**
313
+ * The id of an element of this field that another one refers to: the control, which the label
314
+ * names, the two messages, which describe the control, and the list of a control that has one.
315
+ *
316
+ * It is made from a random part of the field and not from its name. A name is unique in a form
317
+ * at most, an id has to be unique in the document: two forms that each had an `email` shared
318
+ * their ids, and the second input lost its label and its messages to the first.
319
+ *
320
+ * The id is another one on every page load. Server-rendered markup has the ids of the server
321
+ * until the element starts, which writes its own to the same elements.
322
+ * @private
323
+ * @param {'input' | 'help-message' | 'error-message' | 'list'} part
324
+ * @returns {string}
325
+ */
326
+ _idOf(part) {
327
+ return `${part}-${this.uuid}`;
328
+ }
329
+
161
330
  /** @private */
162
331
  classes() {
163
332
  return {
@@ -178,7 +347,7 @@ export default class FormField extends TemplateElement {
178
347
  labelTemplate() {
179
348
  if (!this.label) return null;
180
349
  return html`
181
- <label ref="label" for="input-${this.name}" class="${this.classes().label}"> ${this.label} </label>
350
+ <label ref="label" for="${this._idOf('input')}" class="${this.classes().label}"> ${this.label} </label>
182
351
  `;
183
352
  }
184
353
 
@@ -192,14 +361,42 @@ export default class FormField extends TemplateElement {
192
361
 
193
362
  /** @private */
194
363
  helpTemplate() {
195
- return html` <span id="${this.name}-help-message" class="message help-message">${this.helpMessage}</span> `;
364
+ return html` <span id="${this._idOf('help-message')}" class="message help-message">${this.helpMessage}</span> `;
196
365
  }
197
366
 
198
- /** @private */
367
+ /**
368
+ * Whether the error message is rendered: the field has been touched, is invalid and has a message.
369
+ * @private
370
+ * @returns {boolean}
371
+ */
372
+ _showsError() {
373
+ return !!(this.touched && this.errorMessage && !this.valid);
374
+ }
375
+
376
+ /**
377
+ * The value of `aria-describedby` for the control: the help message, and the error message while
378
+ * it is rendered, so that a screen reader reads the error when the control gets focus.
379
+ * @private
380
+ * @returns {string}
381
+ */
382
+ _describedBy() {
383
+ const ids = [this._idOf('help-message')];
384
+ if (this._showsError()) ids.push(this._idOf('error-message'));
385
+ return ids.join(' ');
386
+ }
387
+
388
+ /**
389
+ * The error message is an alert, so that a screen reader announces it the moment it appears.
390
+ * @private
391
+ */
199
392
  errorTemplate() {
200
- if (!(this.touched && this.errorMessage && !this.valid)) return null;
393
+ if (!this._showsError()) return null;
201
394
 
202
- return html` <span id="${this.name}-error-message" class="message error-message">${this.errorMessage}</span> `;
395
+ return html`
396
+ <span id="${this._idOf('error-message')}" class="message error-message" role="alert"
397
+ >${this.errorMessage}</span
398
+ >
399
+ `;
203
400
  }
204
401
  }
205
402
 
@@ -36,45 +36,109 @@ This component is typically used as a base class for other form field components
36
36
  | Name | Type | Default | Description |
37
37
  | --- | --- | --- | --- |
38
38
  | `name` | `string` | `''` | The name attribute for the form field. |
39
- | `value` | `string` | `null` | The current value of the form field. |
39
+ | `value` | `string` | `null` | The current value of the form field. It is text: the attribute is taken as it is written, `value="1.50"` stays `1.50`. `el-amount-field` takes a number. A field without a value keeps `null` while its control is empty; a text that was entered and deleted is the value `''`. |
40
40
  | `required` | `boolean` | `false` | Whether the field is required for form submission. |
41
41
  | `disabled` | `boolean` | `false` | Whether the field is disabled. |
42
42
  | `label` | `string` | `''` | The label text displayed for the field. |
43
43
  | `labelScreenReaderOnly` | `boolean` | `false` | Whether to hide the label visually (but keep it accessible to screen readers). |
44
- | `errorMessage` | `string` | `''` | Error message to display when validation fails and field is touched. |
45
- | `helpMessage` | `string` | `''` | Helper text to display below the field. |
44
+ | `errorMessage` | `string` | `''` | Error message to display when validation fails and field is touched. Rendered as an alert (`role="alert"`), so screen readers announce it. |
45
+ | `helpMessage` | `string` | `''` | Helper text. Displayed between the label and the control; a checkbox and a switch display it below the control and its label. |
46
46
  | `valid` | `boolean` | `true` | Whether the field passes validation. |
47
- | `touched` | `boolean` | `false` | Whether the field has been interacted with (focused and blurred). |
47
+ | `touched` | `boolean` | `false` | Whether the field has been interacted with (focused and blurred), or the browser has refused a submit because of it. |
48
48
 
49
49
  #### Methods
50
50
 
51
- | Name | Parameters | Description |
52
- | -------------- | ---------- | ------------------------------------------------------------------------ |
53
- | `onFocus()` | None | Called when the input receives focus. Updates validation state. |
54
- | `onBlur()` | None | Called when the input loses focus. Marks field as touched and validates. |
55
- | `onChange()` | None | Called when the input value changes. Updates value and validation state. |
56
- | `clearInput()` | None | Focuses the input, clears its value, and resets the touched state. |
51
+ | Name | Parameters | Description |
52
+ | --- | --- | --- |
53
+ | `onFocus()` | None | Called when the input receives focus. Updates validation state. |
54
+ | `onBlur()` | None | Called when the input loses focus. Marks field as touched and validates. |
55
+ | `onChange()` | None | Called when the input value changes. Updates value and validation state. |
56
+ | `clearInput()` | None | Focuses the input, clears its value, and resets the touched state. `value` and `valid` of the field follow, and `input-change` reports the empty value. |
57
57
 
58
58
  #### Events
59
59
 
60
- | Name | Detail | Description |
61
- | -------------- | ------- | --------------------------------------------------------------- |
62
- | `input-change` | `value` | Fired when the field value changes. Bubbles up through the DOM. |
60
+ | Name | Detail | Description |
61
+ | --- | --- | --- |
62
+ | `input-change` | `value` | Fired when the field value changes, once for every change and with the render after it. Bubbles up through the DOM. |
63
63
 
64
64
  #### CSS States
65
65
 
66
66
  Custom states reflected on the host (and inherited by `input-field`, `select-field`, `textarea-field`, `checkbox-field` and `amount-field`). Style with `el-input-field:state(invalid)`, etc.
67
67
 
68
- | Name | Description |
69
- | --------- | ---------------------------------------------------- |
70
- | `valid` | Present while the field passes validation. |
71
- | `invalid` | Present while the field fails validation. |
72
- | `touched` | Present once the field has been focused and blurred. |
68
+ | Name | Description |
69
+ | --------- | ------------------------------------------------------------------------------------------- |
70
+ | `valid` | Present while the field passes validation. |
71
+ | `invalid` | Present while the field fails validation. |
72
+ | `touched` | Present once the field has been focused and blurred, or a submit was refused because of it. |
73
73
 
74
74
  #### CSS Custom Properties
75
75
 
76
76
  This component is headless by default and reads the library's `--el-*` design tokens (e.g. `--el-color-fg`, `--el-color-fg-muted`, `--el-space-1`). Skin it by setting these via a theme — see the Storybook _Docs / Theming_ page.
77
77
 
78
+ The error message of every field has the danger colour of the theme (`--el-color-danger`). Without a theme it has the colour of the text, which can be read on any background: a red that the library picked could not be, on every page.
79
+
80
+ #### Layout
81
+
82
+ Every field that renders into the page has the same layout around its control, `el-form-field` itself included. It comes from one shared style module (`src/styles/form-control.style.js`), which each field composes for its own tag.
83
+
84
+ - The label, the help message, the control and the error message stack in a column, with a gap of `--el-space-1` (4 px without a theme).
85
+ - A help message without a text takes no room.
86
+ - A label, and the legend of a radio group, has the text colour of the theme (`--el-color-fg`).
87
+ - The messages are set in `--el-font-size-sm` (14 px without a theme). The help message has the muted colour of the theme (`--el-color-fg-muted`), the error message its danger colour.
88
+ - Without a theme each of these texts has the colour of the text of the page.
89
+ - The `hidden` attribute hides a field.
90
+
91
+ A checkbox and a switch have their label beside the control, in its row, and none above it. Their help message explains that label, so it follows the row, and the error message follows the help message. The column of a radio group is its `<fieldset>`.
92
+
93
+ #### Ids
94
+
95
+ A field gives its control, its help message and its error message an id: `input-…`, `help-message-…` and `error-message-…`, with a part that is random for every field. The label names the control by it (`for`), and the control its messages (`aria-describedby`).
96
+
97
+ - Two fields with the same `name` on a page, in two forms for example, each keep their own label and their own messages.
98
+ - The ids are other ones on every page load. Server-rendered markup has the ids of the server, and the element writes its own to the same elements when it starts.
99
+ - Do not write one of them into a selector, a link or a `for` of the page. Reach the control through the field: `field.querySelector('input')`.
100
+
78
101
  #### Slots
79
102
 
80
103
  _None_ (Component uses template methods instead of slots)
104
+
105
+ ## In a form
106
+
107
+ The fields that render into the page take part in a native `<form>` through their native control: `el-input-field`, `el-password-field`, `el-textarea-field`, `el-select-field`, `el-checkbox-field`, `el-switch-field`, `el-radio-field` and `el-amount-field`. The control carries the `name` and belongs to the form like any other control, so no script has to collect the values.
108
+
109
+ - The value is submitted under the `name`, whether the user entered it or a script set it on the element. A checkbox or a switch submits its `value` while it is checked (`on` if it has none) and nothing while it is not; a radio group submits the selected option.
110
+ - A `disabled` field is left out.
111
+ - A `required` field that is empty keeps the form from being submitted. That is the validation of the browser.
112
+ - When the browser refuses a submit, every field that is not valid shows its `errorMessage`, as it does once the user has left it. See [A refused submit](#a-refused-submit).
113
+ - `form.reset()`, a reset button and `el-button type="reset"` put a field back to the state it was rendered with. See [Reset](#reset).
114
+
115
+ The elements themselves are not form-associated custom elements: the control already is part of the form, and a second entry under the same name would be submitted twice.
116
+
117
+ #### A refused submit
118
+
119
+ A form whose fields are not all valid is not submitted. Every field that is not valid is then `touched` and not `valid`, and shows its `errorMessage` as an alert, whether the user had been in it or not. That holds for a click on a submit button, an `el-button type="submit"` included, for Enter in a field and for `form.requestSubmit()`. A form with `novalidate` is not validated, so nothing changes there.
120
+
121
+ The browser still focuses the first control that is not valid and shows its own bubble there. To show the messages of the fields alone, cancel the `invalid` event for the whole form. It does not bubble, so listen while it is captured:
122
+
123
+ ```js
124
+ form.addEventListener('invalid', (event) => event.preventDefault(), true);
125
+ ```
126
+
127
+ The browser then shows no bubble and moves no focus; the fields show their messages as before.
128
+
129
+ `form.checkValidity()` and `form.reportValidity()` do not make a field show its message. They are questions of a script, on every keystroke for some pages, and no attempt of the user to submit. Set `touched` on a field yourself where you want its message.
130
+
131
+ #### Reset
132
+
133
+ A reset puts a field back to the state it had when it was connected: its value, its `checked` or its selected option, and with it `touched` and `valid`, so no error message of an earlier attempt is left. `input-change` reports the value the field goes back to.
134
+
135
+ That state is not an empty one: `<el-input-field value="Ada">` shows "Ada" again, a checkbox rendered with `checked="true"` is checked again. A value that a script sets later is no new default.
136
+
137
+ - A text field or a select that is rendered with a value is `touched` from the start, and so it is after a reset. A field that is rendered with `valid="false"`, for an error the server found, shows that error again.
138
+ - The field follows a moment after the event, and its control with the next render. Read the form in the frame after the reset, not in the same task.
139
+ - A reset that a listener cancels (`event.preventDefault()`) changes nothing.
140
+ - A field that was taken out of the form is left alone.
141
+
142
+ What does not work yet:
143
+
144
+ - Server-rendered markup: `@webtides/element-js-ssr-renderer` (0.4.0) parses the `value` attribute itself. A value that reads as a number is rendered as that number, `1.50` as `1.5`, and a select does not find its option, until the element starts in the browser and puts the text back.
@@ -1,25 +1,7 @@
1
- const css = String.raw;
1
+ import hostStyle from '../../styles/host.style.js';
2
+ import formControlStyle from '../../styles/form-control.style.js';
2
3
 
3
- export default css`
4
- el-form-field,
5
- el-input-field,
6
- el-password-field,
7
- el-textarea-field,
8
- el-select-field,
9
- el-amount-field,
10
- el-checkbox-field,
11
- el-radio-field,
12
- el-switch-field {
13
- display: block;
14
-
15
- > label {
16
- display: block;
17
- margin-bottom: var(--el-space-1, 0);
18
- color: var(--el-color-fg, inherit);
19
- }
20
-
21
- > .help-message {
22
- color: var(--el-color-fg-muted, inherit);
23
- }
24
- }
25
- `;
4
+ // The stylesheet of el-form-field alone. A field that extends FormField brings a stylesheet of its
5
+ // own, with the same layout module for its own tag. A rule here for the tag of another field would
6
+ // reach that field only on a page that has an el-form-field as well, and would change it there.
7
+ export default [hostStyle('el-form-field'), formControlStyle('el-form-field')].join('\n');
@@ -12,8 +12,32 @@ 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
+ - `autocomplete`, `inputmode`, `enterkeyhint`, `autocapitalize`, `autocorrect` and `spellcheck` are passed on to the native `<input>`, in server-rendered markup and on every render. Set them as attributes or properties on the element; one that is not set is left out on the `<input>`. Before, the field dropped them, so a password manager and the on-screen keyboard got no hints.
20
+ - `size` (`small`, `medium` by default, `large`): the height, the padding and the font size of the control, 0.8 and 1.25 times `--el-control-height` for small and large. Reflected to the attribute. It shows once `styles/native.css` decorates the control; a control with the look of the browser keeps its size. ([#69](https://github.com/webtides/element-library/issues/69))
21
+
22
+ ### Changed
23
+
24
+ - On a touch screen (`@media (any-pointer: coarse)`) the input is at least `--el-touch-target` high (42 px with the default theme before), and the clear cross of an invalid field at least that wide and high (9 × 18 px before). The mark beside the input takes that width while the field is valid too, so the input keeps its width when the validity changes. Unchanged on a fine pointer and without the token.
25
+ - Without a theme the error message has the colour of the text. It was `red`, which is 4 : 1 on white and below the 4.5 : 1 that small text needs, and which no page with a dark background could rely on. Every field has this fallback now. With a theme, or with `--el-color-danger` set, nothing changes. ([#128](https://github.com/webtides/element-library/issues/128))
26
+ - The label has the text colour of the theme (`--el-color-fg`) and the help message its muted colour (`--el-color-fg-muted`), as in every field now. Before, they had them only on a page that had an `el-form-field` as well; without a theme both keep the colour of the text. A help message without a text takes no room: empty it was a row of the column, and the label stood two gaps above the input instead of one (8 px instead of 4 px with the shipped themes). ([#130](https://github.com/webtides/element-library/issues/130))
27
+
28
+ ### Fixed
29
+
30
+ - The `hidden` attribute hides the field. Before, the `display` of the element won over it. ([#69](https://github.com/webtides/element-library/issues/69))
31
+ - The error message is announced by screen readers: it is an alert (`role="alert"`), and the input names it in `aria-describedby` while it is shown. Before, the input pointed at it with `aria-errormessage` only. ([#94](https://github.com/webtides/element-library/issues/94))
32
+ - The cross of a field that is not valid empties `value` as well, reports it with `input-change`, and `valid` follows the empty input. Before, only the input was emptied. See `form-field`. ([#115](https://github.com/webtides/element-library/issues/115))
33
+ - A value that a script sets on the element reaches the input also after the user has typed. The field renders its value as the `value` attribute of the input, which is only the default of the control: once the user had typed, the browser no longer showed it. After `x` was typed into a field with "first", `el.value = 'outside'` left "firstx" in the input and in what the form submitted, while `value` said "outside". The field now writes a value that was set from outside to the control as well, as `el-textarea-field` does. Text the user types is not written back, so the caret stays where it is. ([#126](https://github.com/webtides/element-library/issues/126))
34
+ - A second field with the same `name` on the page keeps its own label and its own messages. The ids of the input and of the messages are made per field, not from the name (BREAKING for a page that names `input-<name>` or `<name>-help-message` itself). See `form-field`. ([#133](https://github.com/webtides/element-library/issues/133))
35
+ - The field is as high after it was left as before in a page with high lines. The mark beside the input (✓ or ✗) made it grow by 3 px at a line height of 1.5, where the input has the look of the browser. See `form-field`. ([#116](https://github.com/webtides/element-library/issues/116))
36
+
15
37
  ## [0.1.0] - 2026-06-03
16
38
 
39
+ - `type="date"` and `type="time"` keep the first key of an empty field. Typed at the pace of a person, `11/15/2026` arrived as `2026-11-05` and `11:30 PM` as `13:00`: after the first key the field took the empty control as the value `''` and wrote it to the control, which dropped the key. Typed in one go the value was right, so no test had seen it. A field without a value now keeps it while its control is empty (see `form-field`). For a date or a time with an earliest and a latest value there is `el-date-field`. ([#147](https://github.com/webtides/element-library/issues/147))
40
+
17
41
  ### Changed
18
42
 
19
43
  - Hardcoded values in the stylesheet now reference design tokens with the previous values as fallbacks: `--el-space-1` / `--el-space-2` for gaps, `--el-color-success` / `--el-color-danger` for validity icon colors, `--el-font-size-sm` for the help/error message text.
@@ -1,5 +1,6 @@
1
- import { html, defineElement, classMap, when, optionalAttribute } from '@webtides/element-js';
1
+ import { html, defineElement, classMap, when, optionalAttribute, spreadAttributes } from '@webtides/element-js';
2
2
  import FormField from '../form-field/form-field.js';
3
+ import { shadowNativeTextEntryProperties, textEntryAttributes } from '../../utils/text-entry-attributes.js';
3
4
  import style from './input-field.style.js';
4
5
 
5
6
  /**
@@ -14,41 +15,116 @@ import style from './input-field.style.js';
14
15
  *
15
16
  * @property {string} type - Native `type` attribute of the underlying `<input>` (e.g.
16
17
  * `'text'`, `'email'`, `'password'`, `'tel'`, `'url'`).
18
+ * @property {'small'|'medium'|'large'} size - Size of the control: its height, its padding and its
19
+ * font size. Default `'medium'`. Reflected to the `size` attribute. It shows once the control is
20
+ * decorated (`styles/native.css`); a control with the look of the browser keeps its size.
17
21
  * @property {string} placeholder - Placeholder text shown while the input is empty.
18
22
  * @property {string | false} pattern - Regular expression used as the input's `pattern`
19
23
  * attribute. When `false` (the default), the `pattern` attribute is omitted entirely, so
20
24
  * the field applies no pattern constraint.
25
+ * @property {string | null} autocomplete - Passed on to the control as its `autocomplete`
26
+ * attribute (e.g. `'email'`, `'current-password'`, `'one-time-code'`). `null` (the default)
27
+ * leaves the attribute out. The same holds for the five properties below.
28
+ * @property {string | null} inputmode - Passed on as `inputmode`: the on-screen keyboard to show
29
+ * (e.g. `'numeric'`, `'email'`).
30
+ * @property {string | null} enterkeyhint - Passed on as `enterkeyhint`: the label of the enter key
31
+ * on an on-screen keyboard (e.g. `'next'`, `'send'`).
32
+ * @property {string | null} autocapitalize - Passed on as `autocapitalize` (e.g. `'none'`,
33
+ * `'sentences'`).
34
+ * @property {string | null} autocorrect - Passed on as `autocorrect` (`'on'` or `'off'`).
35
+ * @property {boolean | string | null} spellcheck - Passed on as `spellcheck` (`true` or `false`).
21
36
  */
22
37
  export default class InputField extends FormField {
23
38
  constructor(options) {
24
- super({ shadowRender: false, styles: [style], ...options });
39
+ super({
40
+ shadowRender: false,
41
+ styles: [style],
42
+ // The size module selects the host by this attribute.
43
+ propertyOptions: { size: { reflect: true } },
44
+ ...options,
45
+ });
46
+ shadowNativeTextEntryProperties(this);
25
47
  }
26
48
 
27
49
  properties() {
28
50
  return {
29
51
  ...super.properties(),
30
52
  type: 'text',
53
+ size: 'medium',
31
54
  placeholder: '',
32
55
  pattern: false,
56
+ autocomplete: null,
57
+ inputmode: null,
58
+ enterkeyhint: null,
59
+ autocapitalize: null,
60
+ autocorrect: null,
61
+ spellcheck: null,
33
62
  };
34
63
  }
35
64
 
65
+ watch() {
66
+ const watchers = super.watch();
67
+ return {
68
+ ...watchers,
69
+ value: (value, oldValue) => {
70
+ // The value attribute of an input is only its default: once the user has typed, a
71
+ // value set from outside has to be written to the control as well.
72
+ this._syncControlValue();
73
+ watchers.value(value, oldValue);
74
+ },
75
+ };
76
+ }
77
+
78
+ /**
79
+ * The pattern of the control. A field that extends this one can have a pattern of its own
80
+ * where the page gives none (`OtpField`).
81
+ * @private
82
+ * @returns {string | false}
83
+ */
84
+ _pattern() {
85
+ return this.pattern;
86
+ }
87
+
88
+ /**
89
+ * Attributes of the control that this field has no property for. A field that extends this one
90
+ * has: the list of its suggestions (`ComboboxField`), the limits and the step of a date
91
+ * (`DateField`). One that is `null` or missing is left out.
92
+ *
93
+ * Each of them is a binding of its own in the template, which writes an attribute when its
94
+ * value has changed. `spreadAttributes()` writes its attributes with every render, and that is
95
+ * not the same for these: a control for a date drops what the user has entered of a date so
96
+ * far when its limits are written again.
97
+ * @private
98
+ * @returns {{ list?: string | null, min?: string | null, max?: string | null, step?: number | string | null }}
99
+ */
100
+ _controlAttributes() {
101
+ return {};
102
+ }
103
+
36
104
  /** @private */
37
105
  fieldTemplate() {
106
+ const pattern = this._pattern();
107
+ const { list = null, min = null, max = null, step = null } = this._controlAttributes();
108
+
38
109
  return html`
39
110
  <input
40
111
  ref="input"
41
- id="input-${this.name}"
112
+ id="${this._idOf('input')}"
42
113
  name="${this.name}"
43
114
  type="${this.type}"
44
115
  value="${this.value}"
45
116
  placeholder="${this.placeholder}"
46
117
  ?required="${this.required}"
47
118
  ?disabled="${this.disabled}"
48
- ${optionalAttribute(this.pattern, 'pattern', this.pattern)}
49
- aria-describedby="${this.name}-help-message"
119
+ ${optionalAttribute(pattern, 'pattern', pattern)}
120
+ list="${list}"
121
+ min="${min}"
122
+ max="${max}"
123
+ step="${step}"
124
+ ${spreadAttributes(textEntryAttributes(this))}
125
+ aria-describedby="${this._describedBy()}"
50
126
  aria-invalid="${this.valid ? 'false' : 'true'}"
51
- aria-errormessage="${this.name}-error-message"
127
+ aria-errormessage="${this._idOf('error-message')}"
52
128
  />
53
129
  ${when(
54
130
  this.touched,