@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
@@ -1,61 +1,22 @@
1
+ import hostStyle from '../../styles/host.style.js';
2
+ import formControlStyle from '../../styles/form-control.style.js';
3
+ import choiceGroupStyle from '../../styles/choice-group.style.js';
4
+
1
5
  const css = String.raw;
2
6
 
3
- export default css`
7
+ /**
8
+ * The fieldset as the column of the field, the option as the hit area of its radio and the hidden
9
+ * native radio are the shared module `choice-group`. Here: the options below each other, and the
10
+ * circle that is drawn in the place of a radio.
11
+ */
12
+ const style = css`
4
13
  el-radio-field {
5
- display: block;
6
-
7
- fieldset.field {
8
- margin: 0;
9
- padding: 0;
10
- border: 0;
11
- min-width: 0;
12
- }
13
-
14
- legend {
15
- padding: 0;
16
- margin-bottom: var(--el-space-1, 0);
17
- color: var(--el-color-fg, inherit);
18
- }
19
-
20
14
  .options {
21
15
  display: flex;
22
16
  flex-direction: column;
23
17
  gap: var(--el-space-2, 0.5em);
24
18
  }
25
19
 
26
- .option {
27
- display: inline-flex;
28
- align-items: center;
29
- gap: var(--el-space-2, 0.5em);
30
- cursor: pointer;
31
- }
32
-
33
- .option:has(input:disabled) {
34
- cursor: not-allowed;
35
- }
36
-
37
- /* The native radio is replaced by .radio-indicator; hide it visually but keep it in the
38
- accessibility tree and focusable. */
39
- input[type='radio'] {
40
- position: absolute;
41
- width: 1px;
42
- height: 1px;
43
- margin: 0;
44
- padding: 0;
45
- border: 0;
46
- opacity: 0;
47
- overflow: hidden;
48
- white-space: nowrap;
49
- clip: rect(0 0 0 0);
50
- clip-path: inset(50%);
51
- }
52
-
53
- /* Reflect keyboard focus onto the custom indicator. */
54
- input[type='radio']:focus-visible + .radio-indicator {
55
- outline: var(--el-focus-ring-width, 2px) solid var(--el-color-accent, currentColor);
56
- outline-offset: 2px;
57
- }
58
-
59
20
  .radio-indicator {
60
21
  display: inline-flex;
61
22
  align-items: center;
@@ -88,21 +49,12 @@ export default css`
88
49
  input[type='radio']:checked + .radio-indicator::after {
89
50
  transform: scale(1);
90
51
  }
91
-
92
- input[type='radio']:disabled + .radio-indicator {
93
- opacity: 0.5;
94
- }
95
-
96
- .message {
97
- display: block;
98
- }
99
-
100
- .help-message {
101
- color: var(--el-color-fg-muted, inherit);
102
- }
103
-
104
- .error-message {
105
- color: var(--el-color-danger, inherit);
106
- }
107
52
  }
108
53
  `;
54
+
55
+ export default [
56
+ hostStyle('el-radio-field'),
57
+ formControlStyle('el-radio-field'),
58
+ choiceGroupStyle('el-radio-field'),
59
+ style,
60
+ ].join('\n');
@@ -0,0 +1,24 @@
1
+ # Change Log
2
+
3
+ All notable changes to this component live here. Versions refer to the parent `@webtides/element-library` release (see root [`CHANGELOG.md`](../../../CHANGELOG.md)); components no longer version independently.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/).
6
+
7
+ <!--
8
+ When your PR touches this component, add an entry under Unreleased and
9
+ mirror it (prefixed with the component name) in root CHANGELOG.md.
10
+ Uncomment headings as needed.
11
+ -->
12
+
13
+ ## Unreleased
14
+
15
+ ## [0.3.0] - 2026-11-17
16
+
17
+ ### Added
18
+
19
+ - Initial `el-range-field`: a number from a span, picked with a thumb on a track. A native `<input type="range">` with the label, the help message, the error message and the layout of every field; it is submitted with its form by the control. ([#136](https://github.com/webtides/element-library/issues/136))
20
+ - `min`, `max` and `step` are the span and reach the control (`0`, `100` and `1` by default; `step="any"` takes every value). `value` is the text the form submits.
21
+ - A field without a `value` takes over the value of the control, the middle of the span, and so does a field whose value does not fit the span or a step. `value` says what the form submits.
22
+ - `value` follows the thumb while it moves; `input-change` reports every value once. A value set from a script moves the thumb, also after the user has moved it.
23
+ - `show-value` shows the value beside the control. It keeps the room of the longest value of the span, and it is hidden from a screen reader, which reads the value from the control.
24
+ - The control keeps the look of the browser. With `styles/native.css` it is as wide as the field, has the accent colour of the theme and shows keyboard focus with the ring of the theme. On a touch screen it is at least `--el-touch-target` high.
@@ -0,0 +1,3 @@
1
+ import { define } from './range-field.js';
2
+
3
+ define();
@@ -0,0 +1,167 @@
1
+ import { html, defineElement } from '@webtides/element-js';
2
+ import FormField, { FormFieldEvents } from '../form-field/form-field.js';
3
+ import style from './range-field.style.js';
4
+
5
+ /**
6
+ * A number from a span, picked with a thumb on a track. Renders a native `<input type="range">`,
7
+ * so the keyboard, the touch handling and the form submission are the ones of the browser. Extends
8
+ * `FormField` and inherits its label / help / error surface.
9
+ *
10
+ * The control always has a value: without one it puts its thumb in the middle of the span. The
11
+ * field takes that value over, so that `value` says what the form submits.
12
+ *
13
+ * @element el-range-field
14
+ *
15
+ * @fires {CustomEvent<string>} input-change - Fired when the value changes, also while the thumb
16
+ * moves. `detail` is the new value. Bubbles.
17
+ *
18
+ * @cssstate touched - Set on the host once the user has focused and left the control. Inherits
19
+ * `valid` and `invalid` from `FormField`.
20
+ *
21
+ * @property {string | null} value - The value, as the text the form submits. A field without one
22
+ * takes over the value of the control, the middle of the span.
23
+ * @property {number} min - The lower end of the span. Default `0`.
24
+ * @property {number} max - The upper end of the span. Default `100`.
25
+ * @property {number | 'any'} step - The distance between two values. Default `1`; `'any'` takes
26
+ * every value of the span.
27
+ * @property {boolean} showValue - Shows the value beside the control. Default `false`.
28
+ */
29
+ export default class RangeField extends FormField {
30
+ /**
31
+ * The value that `input-change` last reported, or that the field started with. See `watch()`.
32
+ * @private
33
+ */
34
+ _reportedValue = undefined;
35
+
36
+ constructor(options) {
37
+ super({ shadowRender: false, styles: [style], ...options });
38
+ }
39
+
40
+ properties() {
41
+ return {
42
+ ...super.properties(),
43
+ min: 0,
44
+ max: 100,
45
+ step: 1,
46
+ showValue: false,
47
+ };
48
+ }
49
+
50
+ /**
51
+ * A form field takes a control with a value as touched: someone has filled it in. The control
52
+ * of this field always has a value, so that says nothing here.
53
+ */
54
+ connected() {
55
+ if (this.valid === false) this.touched = true;
56
+ this.syncValidationStates();
57
+ }
58
+
59
+ afterUpdate() {
60
+ // Before the form field keeps the state for a reset: what the field takes over from the
61
+ // control is part of it.
62
+ this._matchControl();
63
+ if (this._reportedValue === undefined) this._reportedValue = this.value;
64
+ super.afterUpdate();
65
+ }
66
+
67
+ watch() {
68
+ return {
69
+ ...super.watch(),
70
+ // The watcher runs a frame after the change, once for every change, and the field can
71
+ // have taken another value over from the control by then. So it is the value of now
72
+ // that is reported, and each one once.
73
+ value: () => {
74
+ this._matchControl();
75
+ if (this.value === this._reportedValue) return;
76
+ this._reportedValue = this.value;
77
+ this.dispatch(FormFieldEvents.INPUT_CHANGE, this.value);
78
+ },
79
+ };
80
+ }
81
+
82
+ events() {
83
+ return {
84
+ '[ref=input]': {
85
+ // The value follows the thumb while it moves. `change`, at the end of a move, has
86
+ // nothing new to say.
87
+ input: () => this.onChange(),
88
+ focus: () => this.onFocus(),
89
+ blur: () => this.onBlur(),
90
+ invalid: (event) => this._onInvalid(event.target),
91
+ },
92
+ };
93
+ }
94
+
95
+ /**
96
+ * Makes the control and `value` say the same, after every render and every change of `value`.
97
+ *
98
+ * The `value` attribute of the control is only its default: once the user has moved the thumb,
99
+ * a value from outside has to be written to the control. The control in turn keeps its value
100
+ * inside the span and on a step, and has one in the middle of the span when it is given none.
101
+ * The field takes over what the control made of the value: that is what the form submits.
102
+ * @private
103
+ */
104
+ _matchControl() {
105
+ const control = this.$refs.input;
106
+ if (!control) return;
107
+
108
+ const wanted = String(this.value ?? '');
109
+ if (control.value !== wanted) control.value = wanted;
110
+ if (control.value !== wanted) this.value = control.value;
111
+ }
112
+
113
+ /**
114
+ * The longest text the value can have, which keeps the room for it: the control would change
115
+ * its length with every digit that comes or goes while the thumb moves.
116
+ * @private
117
+ * @returns {string}
118
+ */
119
+ _longestValue() {
120
+ const decimals = (number) => String(number).split('.')[1]?.length ?? 0;
121
+ const places = Math.max(decimals(this.min), decimals(this.step));
122
+ const ends = [this.min, this.max].map((end) => Number(end)).filter((end) => Number.isFinite(end));
123
+ return ends
124
+ .map((end) => end.toFixed(Math.min(places, 20)))
125
+ .reduce((longest, text) => (text.length > longest.length ? text : longest), '');
126
+ }
127
+
128
+ /** @private */
129
+ fieldTemplate() {
130
+ return html`
131
+ <input
132
+ ref="input"
133
+ type="range"
134
+ id="${this._idOf('input')}"
135
+ name="${this.name}"
136
+ min="${this.min}"
137
+ max="${this.max}"
138
+ step="${this.step}"
139
+ value="${this.value}"
140
+ ?disabled="${this.disabled}"
141
+ aria-describedby="${this._describedBy()}"
142
+ aria-invalid="${this.valid ? 'false' : 'true'}"
143
+ aria-errormessage="${this._idOf('error-message')}"
144
+ />
145
+ ${this.valueTemplate()}
146
+ `;
147
+ }
148
+
149
+ /**
150
+ * The value beside the control. It is hidden from assistive technology: the control says its
151
+ * value itself, and would be heard twice.
152
+ * @private
153
+ */
154
+ valueTemplate() {
155
+ if (!this.showValue) return null;
156
+ return html`
157
+ <span class="value" aria-hidden="true">
158
+ <span class="value-room">${this._longestValue()}</span>
159
+ <span class="value-now">${this.value}</span>
160
+ </span>
161
+ `;
162
+ }
163
+ }
164
+
165
+ export function define() {
166
+ defineElement('el-range-field', RangeField);
167
+ }
@@ -0,0 +1,87 @@
1
+ # RangeField
2
+
3
+ `range-field` takes a number from a span, picked with a thumb on a track: a volume, a price limit, an opacity. It renders a native `<input type="range">`, so the keyboard, the touch handling and the form submission are the ones of the browser. It extends `form-field`, inheriting the label, help text, error message and touched-state handling.
4
+
5
+ It is headless by default: the control keeps the look of the browser. `styles/native.css` makes it as wide as the field and gives it the accent colour of the theme.
6
+
7
+ ## How to use
8
+
9
+ #### Install
10
+
11
+ ```sh
12
+ npm i --save @webtides/element-library
13
+ ```
14
+
15
+ #### Use
16
+
17
+ ```js
18
+ import '@webtides/element-library/range-field/define';
19
+ ```
20
+
21
+ ```html
22
+ <el-range-field name="volume" label="Volume" value="40"></el-range-field>
23
+
24
+ <el-range-field
25
+ name="opacity"
26
+ label="Opacity"
27
+ min="0"
28
+ max="1"
29
+ step="0.05"
30
+ value="0.5"
31
+ show-value="true"
32
+ ></el-range-field>
33
+ ```
34
+
35
+ #### The value
36
+
37
+ A range always has a value. Without a `value` the control puts its thumb in the middle of the span, and the field takes that value over: `value` says what the form submits. That is no change, so no `input-change` reports it.
38
+
39
+ The control also keeps its value inside the span and on a step. A value from outside that does not fit, such as `80` in a span up to `50`, becomes the value the control makes of it, and the field takes that over as well.
40
+
41
+ ## API
42
+
43
+ #### Properties/Attributes
44
+
45
+ Inherits all of `form-field`'s properties (`name`, `value`, `disabled`, `label`, `labelScreenReaderOnly`, `errorMessage`, `helpMessage`, `valid`, `touched`) and adds:
46
+
47
+ | Name | Type | Default | Description |
48
+ | --- | --- | --- | --- |
49
+ | `value` | `string` | `null` | The value, as the text the form submits. Without one: the value of the control, see above. |
50
+ | `min` | `number` | `0` | The lower end of the span. |
51
+ | `max` | `number` | `100` | The upper end of the span. |
52
+ | `step` | `number \| 'any'` | `1` | The distance between two values. `'any'` takes every value of the span. |
53
+ | `showValue` | `boolean` | `false` | Shows the value beside the control (`show-value`). |
54
+
55
+ `required` has no effect: the control always has a value. The browser never finds a range invalid, so the error message shows when the page sets `valid="false"` after a check of its own.
56
+
57
+ #### Events
58
+
59
+ | Name | Detail | Description |
60
+ | -------------- | -------------------- | -------------------------------------------------------------------------- |
61
+ | `input-change` | `string` (the value) | Fired when the value changes, also while the thumb moves. Each value once. |
62
+
63
+ #### CSS States
64
+
65
+ | Name | Description |
66
+ | --------- | ----------------------------------------------------------------------------------------- |
67
+ | `touched` | Set once the control has been focused and left. A value alone does not set it. |
68
+ | `valid` | Set while the field passes validation. |
69
+ | `invalid` | Set while the field fails validation, which for this field is when the page says it does. |
70
+
71
+ #### CSS Custom Properties
72
+
73
+ Headless by default. The texts read the tokens every field reads (`--el-color-fg`, `--el-color-fg-muted`, `--el-color-danger`, `--el-font-size-sm`, `--el-space-1`, `--el-space-2`). With `styles/native.css` the control is as wide as the field, has `--el-color-accent` on its track and its thumb, and shows keyboard focus with the ring of the theme (`--el-focus-ring-width`, `--el-focus-ring-offset`, `--el-color-focus-ring`). The track and the thumb stay the ones the browser draws.
74
+
75
+ The label, the help message, the control and the error message stack in a column, and the texts have one look in every field: see [Layout](../form-field/form-field.readme.md#layout) in the readme of `form-field`.
76
+
77
+ The shown value stands after the control, in its row. It keeps the room of the longest value of the span, so the control does not change its length while the thumb moves.
78
+
79
+ On a touch screen (`@media (any-pointer: coarse)`) the control is at least `--el-touch-target` high. Without that token, and on a fine pointer, the size stays as it is.
80
+
81
+ ## Accessibility
82
+
83
+ - The native control is a slider for a screen reader, named by the label, and it says its value itself. Arrow keys move the thumb by a step, Home and End to the ends of the span.
84
+ - The shown value is hidden from assistive technology (`aria-hidden`): the control already says it, and it would be heard twice.
85
+ - The control names the help message in `aria-describedby`, and the error message while that is shown.
86
+ - The control says whether the field is valid (`aria-invalid`).
87
+ - The error message is an alert (`role="alert"`): a screen reader announces it when it appears.
@@ -0,0 +1,41 @@
1
+ import hostStyle from '../../styles/host.style.js';
2
+ import formControlStyle from '../../styles/form-control.style.js';
3
+
4
+ const css = String.raw;
5
+
6
+ /**
7
+ * The control keeps the look of the browser, as the control of every field does: `styles/native.css`
8
+ * makes it as wide as the field and gives it the accent colour of the theme.
9
+ */
10
+ const style = css`
11
+ el-range-field {
12
+ /* The value beside the control. Two texts lie in the same cell: the value of now, and the
13
+ longest one the field can have, which is not seen and keeps the room. The control does
14
+ not change its length while the thumb moves. */
15
+ .value {
16
+ display: inline-grid;
17
+ flex: none;
18
+ color: var(--el-color-fg, inherit);
19
+ font-variant-numeric: tabular-nums;
20
+ }
21
+
22
+ .value > * {
23
+ grid-area: 1 / 1;
24
+ text-align: end;
25
+ }
26
+
27
+ .value-room {
28
+ visibility: hidden;
29
+ }
30
+
31
+ /* Touch screens: the control is at least --el-touch-target high. Without the token the
32
+ size stays as it is. */
33
+ @media (any-pointer: coarse) {
34
+ input {
35
+ min-height: var(--el-touch-target, auto);
36
+ }
37
+ }
38
+ }
39
+ `;
40
+
41
+ export default [hostStyle('el-range-field'), formControlStyle('el-range-field'), style].join('\n');
@@ -0,0 +1,24 @@
1
+ # Change Log
2
+
3
+ All notable changes to this component live here. Versions refer to the parent `@webtides/element-library` release (see root [`CHANGELOG.md`](../../../CHANGELOG.md)); components no longer version independently.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/).
6
+
7
+ <!--
8
+ When your PR touches this component, add an entry under Unreleased and
9
+ mirror it (prefixed with the component name) in root CHANGELOG.md.
10
+ Uncomment headings as needed.
11
+ -->
12
+
13
+ ## Unreleased
14
+
15
+ ## [0.3.0] - 2026-11-17
16
+
17
+ ### Added
18
+
19
+ - Initial `el-rating-field`: a rating as a number from 1 to `max`, drawn as a row of stars. A native `<fieldset>`/`<legend>` wrapping one `<input type="radio">` per step, with the label, the help message, the error message and the layout of every field; grouping, arrow keys and form submission are native. ([#138](https://github.com/webtides/element-library/issues/138))
20
+ - `max` is the number of stars (`5` by default). `value` is the chosen step as text, `null` while nothing is chosen; a value that is no step of the scale chooses nothing. `input-change` reports the value.
21
+ - The stars up to the chosen one are filled, the others are an outline: the two differ in their shape, not in their colour alone. With a mouse, the stars up to the one under the pointer are shown as on before the click.
22
+ - `--el-rating-color` is the colour of a filled star (the accent colour of the theme without it), `--el-rating-size` the size of a star (`--el-space-5` without it).
23
+ - `required` keeps the form from being submitted without a rating, and `form.reset()` brings back the rendered one.
24
+ - Every radio is named by its number, which needs no translation. The group is touched once the user has left it, not while the focus moves from one star to the next. On a touch screen every star is at least `--el-touch-target` wide and high.
@@ -0,0 +1,3 @@
1
+ import { define } from './rating-field.js';
2
+
3
+ define();
@@ -0,0 +1,195 @@
1
+ import { html, defineElement } from '@webtides/element-js';
2
+ import FormField from '../form-field/form-field.js';
3
+ import { focusLeft } from '../../utils/focus.js';
4
+ import style from './rating-field.style.js';
5
+
6
+ /**
7
+ * A rating as a number from 1 to `max`, drawn as a row of stars: the stars up to the chosen one
8
+ * are filled. Renders a native `<fieldset>`/`<legend>` wrapping one `<input type="radio">` per
9
+ * step, so the grouping, the arrow keys and the form submission are native. Extends `FormField`
10
+ * and inherits its help / error / required / touched-state surface; the `label` becomes the
11
+ * `<legend>` of the group.
12
+ *
13
+ * @element el-rating-field
14
+ *
15
+ * @fires {CustomEvent<string>} input-change - Fired when the rating changes. `detail` is the
16
+ * chosen step. Bubbles.
17
+ *
18
+ * @cssstate touched - Set once the user has left the group, or the browser has refused a submit
19
+ * because of it. Inherits `valid` and `invalid` from `FormField`.
20
+ *
21
+ * @cssproperty --el-rating-color - The colour of a filled star. Unset, it is the accent colour of
22
+ * the theme.
23
+ * @cssproperty --el-rating-size - The width and the height of a star. Unset, it is `--el-space-5`,
24
+ * and `1.5em` without a theme.
25
+ *
26
+ * @property {string | null} value - The chosen step, as the text the form submits (`'3'`), or
27
+ * `null` while nothing is chosen.
28
+ * @property {number} max - The number of stars. Default `5`.
29
+ */
30
+ export default class RatingField extends FormField {
31
+ constructor(options) {
32
+ super({ shadowRender: false, styles: [style], ...options });
33
+ }
34
+
35
+ properties() {
36
+ return {
37
+ ...super.properties(),
38
+ max: 5,
39
+ };
40
+ }
41
+
42
+ connected() {
43
+ // The page can render the field as not valid, after a check of its own.
44
+ const renderedInvalid = this.valid === false;
45
+ super.connected();
46
+ // Reflect validity (required and nothing chosen) so :state(invalid) is correct from the
47
+ // start; the message stays hidden until the group is touched.
48
+ if (!renderedInvalid) this.valid = this._computeValid();
49
+ }
50
+
51
+ afterUpdate() {
52
+ // Before the form field keeps the state for a reset.
53
+ this._syncControls();
54
+ super.afterUpdate();
55
+ }
56
+
57
+ events() {
58
+ return {
59
+ 'input[type="radio"]': {
60
+ change: (event) => {
61
+ this.value = event.target.value;
62
+ this.valid = this._computeValid();
63
+ },
64
+ focus: () => this.onFocus(),
65
+ // The group is touched once the user has left it, not while the focus moves from
66
+ // one star to the next.
67
+ blur: (event) => focusLeft(this, event) && this.onBlur(),
68
+ invalid: (event) => this._onInvalid(event.target),
69
+ },
70
+ };
71
+ }
72
+
73
+ /**
74
+ * The steps of the scale: 1 to `max`. A `max` that is no number of stars gives the five of
75
+ * the default.
76
+ * @private
77
+ * @returns {number[]}
78
+ */
79
+ _steps() {
80
+ const max = Math.floor(Number(this.max));
81
+ return Array.from({ length: max >= 1 ? max : 5 }, (_, index) => index + 1);
82
+ }
83
+
84
+ /**
85
+ * The chosen step as a number, or 0 while nothing is chosen. A value that is no step of the
86
+ * scale chooses nothing: no radio has it, and nothing would be submitted for it.
87
+ * @private
88
+ * @returns {number}
89
+ */
90
+ _chosen() {
91
+ const value = Number(this.value);
92
+ return this.value != null && this.value !== '' && this._steps().includes(value) ? value : 0;
93
+ }
94
+
95
+ /**
96
+ * Whether the group currently passes validation: required means a chosen step.
97
+ * @private
98
+ */
99
+ _computeValid() {
100
+ if (this.required) return this.value != null && this.value !== '';
101
+ return true;
102
+ }
103
+
104
+ /**
105
+ * Makes the radios say what the field says, after every render. The `checked` attribute the
106
+ * template writes is only the default of a radio: once the user has chosen, the browser no
107
+ * longer follows the attribute, so a value from outside is written to the radios as well.
108
+ * @private
109
+ */
110
+ _syncControls() {
111
+ const chosen = this._chosen();
112
+ for (const radio of this.querySelectorAll('input[type="radio"]')) {
113
+ const checked = Number(radio.value) === chosen;
114
+ if (radio.checked !== checked) radio.checked = checked;
115
+ }
116
+ }
117
+
118
+ onFocus() {
119
+ this.valid = this._computeValid();
120
+ }
121
+
122
+ onBlur() {
123
+ this.touched = true;
124
+ this.valid = this._computeValid();
125
+ }
126
+
127
+ /**
128
+ * The label is rendered as the group's `<legend>` (see `template`), so the base FormField
129
+ * `<label>` is suppressed.
130
+ * @returns {null}
131
+ */
132
+ labelTemplate() {
133
+ return null;
134
+ }
135
+
136
+ template() {
137
+ return html`
138
+ <fieldset
139
+ class="field ${this.classes().field}"
140
+ aria-describedby="${this._describedBy()}"
141
+ aria-errormessage="${this._idOf('error-message')}"
142
+ aria-invalid="${this.valid ? 'false' : 'true'}"
143
+ >
144
+ ${this.legendTemplate()} ${this.helpTemplate()}
145
+ <div class="options ${this.disabled ? 'is-disabled' : ''}">${this.fieldTemplate()}</div>
146
+ ${this.errorTemplate()}
147
+ </fieldset>
148
+ `;
149
+ }
150
+
151
+ /** @private */
152
+ legendTemplate() {
153
+ if (!this.label) return null;
154
+ return html` <legend class="${this.classes().label}">${this.label}</legend> `;
155
+ }
156
+
157
+ /**
158
+ * One radio per step, each in a label that shows a star. A radio is named by its number, which
159
+ * needs no translation. The star is hidden from assistive technology: the radio says whether it
160
+ * is chosen. The stars up to the chosen one carry `is-on`, which fills them.
161
+ * @private
162
+ */
163
+ fieldTemplate() {
164
+ const chosen = this._chosen();
165
+
166
+ return this._steps().map((step) => {
167
+ const id = `rating-${this.uuid}-${step}`;
168
+
169
+ return html`
170
+ <label class="option ${step <= chosen ? 'is-on' : ''}" for="${id}">
171
+ <input
172
+ type="radio"
173
+ id="${id}"
174
+ name="${this.name}"
175
+ value="${step}"
176
+ aria-label="${step}"
177
+ ?checked="${step === chosen}"
178
+ ?disabled="${this.disabled}"
179
+ ?required="${this.required}"
180
+ aria-describedby="${this._describedBy()}"
181
+ />
182
+ <svg class="star" viewBox="0 0 24 24" aria-hidden="true" focusable="false">
183
+ <path
184
+ d="M12 2.8l2.84 5.76 6.36.92-4.6 4.49 1.09 6.33L12 17.31l-5.69 2.99 1.09-6.33-4.6-4.49 6.36-.92z"
185
+ />
186
+ </svg>
187
+ </label>
188
+ `;
189
+ });
190
+ }
191
+ }
192
+
193
+ export function define() {
194
+ defineElement('el-rating-field', RatingField);
195
+ }