@webtides/element-library 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (398) hide show
  1. package/CHANGELOG.md +384 -3
  2. package/README.md +61 -41
  3. package/all.js +28 -0
  4. package/catalog.d.ts +14 -0
  5. package/catalog.js +55 -27
  6. package/custom-elements.json +16604 -3420
  7. package/package.json +35 -28
  8. package/src/components/accordion/accordion.changelog.md +10 -0
  9. package/src/components/accordion/accordion.js +10 -7
  10. package/src/components/accordion/accordion.readme.md +2 -0
  11. package/src/components/accordion/accordion.style.js +8 -0
  12. package/src/components/amount-field/amount-field.changelog.md +23 -3
  13. package/src/components/amount-field/amount-field.js +53 -26
  14. package/src/components/amount-field/amount-field.readme.md +82 -20
  15. package/src/components/amount-field/amount-field.style.js +111 -47
  16. package/src/components/avatar/avatar.changelog.md +23 -0
  17. package/src/components/avatar/avatar.define.js +3 -0
  18. package/src/components/avatar/avatar.js +115 -0
  19. package/src/components/avatar/avatar.readme.md +132 -0
  20. package/src/components/avatar/avatar.style.js +67 -0
  21. package/src/components/badge/badge.changelog.md +23 -0
  22. package/src/components/badge/badge.define.js +3 -0
  23. package/src/components/badge/badge.js +59 -0
  24. package/src/components/badge/badge.readme.md +109 -0
  25. package/src/components/badge/badge.style.js +63 -0
  26. package/src/components/breadcrumb/breadcrumb.changelog.md +22 -0
  27. package/src/components/breadcrumb/breadcrumb.define.js +3 -0
  28. package/src/components/breadcrumb/breadcrumb.js +47 -0
  29. package/src/components/breadcrumb/breadcrumb.readme.md +108 -0
  30. package/src/components/breadcrumb/breadcrumb.style.js +20 -0
  31. package/src/components/breadcrumb-item/breadcrumb-item.changelog.md +23 -0
  32. package/src/components/breadcrumb-item/breadcrumb-item.define.js +3 -0
  33. package/src/components/breadcrumb-item/breadcrumb-item.js +82 -0
  34. package/src/components/breadcrumb-item/breadcrumb-item.readme.md +106 -0
  35. package/src/components/breadcrumb-item/breadcrumb-item.style.js +92 -0
  36. package/src/components/button/button.changelog.md +34 -1
  37. package/src/components/button/button.js +285 -29
  38. package/src/components/button/button.readme.md +130 -10
  39. package/src/components/button/button.style.js +99 -120
  40. package/src/components/button-group/button-group.changelog.md +24 -0
  41. package/src/components/button-group/button-group.define.js +3 -0
  42. package/src/components/button-group/button-group.js +53 -0
  43. package/src/components/button-group/button-group.readme.md +114 -0
  44. package/src/components/button-group/button-group.style.js +41 -0
  45. package/src/components/card/card.changelog.md +23 -0
  46. package/src/components/card/card.define.js +3 -0
  47. package/src/components/card/card.js +73 -0
  48. package/src/components/card/card.readme.md +136 -0
  49. package/src/components/card/card.style.js +99 -0
  50. package/src/components/carousel/carousel.changelog.md +20 -0
  51. package/src/components/carousel/carousel.js +89 -40
  52. package/src/components/carousel/carousel.readme.md +39 -6
  53. package/src/components/carousel/carousel.style.js +21 -77
  54. package/src/components/carousel/glide/components/ShadowAnchors.js +3 -1
  55. package/src/components/carousel/glide/components/ShadowClones.js +21 -24
  56. package/src/components/carousel/glide/components/ShadowGaps.js +2 -2
  57. package/src/components/carousel/glide/components/ShadowHtml.js +22 -3
  58. package/src/components/checkbox-field/checkbox-field.changelog.md +19 -0
  59. package/src/components/checkbox-field/checkbox-field.js +25 -10
  60. package/src/components/checkbox-field/checkbox-field.readme.md +17 -4
  61. package/src/components/checkbox-field/checkbox-field.style.js +15 -3
  62. package/src/components/checkbox-group-field/checkbox-group-field.changelog.md +25 -0
  63. package/src/components/checkbox-group-field/checkbox-group-field.define.js +3 -0
  64. package/src/components/checkbox-group-field/checkbox-group-field.js +217 -0
  65. package/src/components/checkbox-group-field/checkbox-group-field.readme.md +95 -0
  66. package/src/components/checkbox-group-field/checkbox-group-field.style.js +62 -0
  67. package/src/components/color-field/color-field.changelog.md +24 -0
  68. package/src/components/color-field/color-field.define.js +3 -0
  69. package/src/components/color-field/color-field.js +184 -0
  70. package/src/components/color-field/color-field.readme.md +95 -0
  71. package/src/components/color-field/color-field.style.js +39 -0
  72. package/src/components/combobox-field/combobox-field.changelog.md +23 -0
  73. package/src/components/combobox-field/combobox-field.define.js +3 -0
  74. package/src/components/combobox-field/combobox-field.js +97 -0
  75. package/src/components/combobox-field/combobox-field.readme.md +93 -0
  76. package/src/components/combobox-field/combobox-field.style.js +56 -0
  77. package/src/components/copy-button/copy-button.changelog.md +24 -0
  78. package/src/components/copy-button/copy-button.define.js +3 -0
  79. package/src/components/copy-button/copy-button.events.js +4 -0
  80. package/src/components/copy-button/copy-button.js +237 -0
  81. package/src/components/copy-button/copy-button.readme.md +134 -0
  82. package/src/components/copy-button/copy-button.style.js +109 -0
  83. package/src/components/date-field/date-field.changelog.md +24 -0
  84. package/src/components/date-field/date-field.define.js +3 -0
  85. package/src/components/date-field/date-field.js +119 -0
  86. package/src/components/date-field/date-field.readme.md +110 -0
  87. package/src/components/date-field/date-field.style.js +53 -0
  88. package/src/components/dialog/dialog.changelog.md +16 -1
  89. package/src/components/dialog/dialog.js +252 -57
  90. package/src/components/dialog/dialog.readme.md +36 -4
  91. package/src/components/dialog/dialog.style.js +9 -109
  92. package/src/components/divider/divider.changelog.md +23 -0
  93. package/src/components/divider/divider.define.js +3 -0
  94. package/src/components/divider/divider.js +48 -0
  95. package/src/components/divider/divider.readme.md +101 -0
  96. package/src/components/divider/divider.style.js +50 -0
  97. package/src/components/drawer/drawer.changelog.md +25 -0
  98. package/src/components/drawer/drawer.define.js +3 -0
  99. package/src/components/drawer/drawer.events.js +8 -0
  100. package/src/components/drawer/drawer.js +80 -0
  101. package/src/components/drawer/drawer.readme.md +194 -0
  102. package/src/components/drawer/drawer.style.js +83 -0
  103. package/src/components/dropdown/dropdown.js +9 -7
  104. package/src/components/empty-state/empty-state.changelog.md +22 -0
  105. package/src/components/empty-state/empty-state.define.js +3 -0
  106. package/src/components/empty-state/empty-state.js +55 -0
  107. package/src/components/empty-state/empty-state.readme.md +114 -0
  108. package/src/components/empty-state/empty-state.style.js +60 -0
  109. package/src/components/file-field/file-field.changelog.md +24 -0
  110. package/src/components/file-field/file-field.define.js +3 -0
  111. package/src/components/file-field/file-field.js +205 -0
  112. package/src/components/file-field/file-field.readme.md +103 -0
  113. package/src/components/file-field/file-field.style.js +28 -0
  114. package/src/components/form-field/form-field.changelog.md +25 -0
  115. package/src/components/form-field/form-field.js +212 -15
  116. package/src/components/form-field/form-field.readme.md +82 -18
  117. package/src/components/form-field/form-field.style.js +6 -24
  118. package/src/components/input-field/input-field.changelog.md +24 -0
  119. package/src/components/input-field/input-field.js +82 -6
  120. package/src/components/input-field/input-field.readme.md +34 -5
  121. package/src/components/input-field/input-field.style.js +32 -13
  122. package/src/components/notification/notification.changelog.md +21 -1
  123. package/src/components/notification/notification.js +80 -74
  124. package/src/components/notification/notification.readme.md +54 -13
  125. package/src/components/notification/notification.style.js +37 -22
  126. package/src/components/otp-field/otp-field.changelog.md +23 -0
  127. package/src/components/otp-field/otp-field.define.js +3 -0
  128. package/src/components/otp-field/otp-field.events.js +3 -0
  129. package/src/components/otp-field/otp-field.js +172 -0
  130. package/src/components/otp-field/otp-field.readme.md +111 -0
  131. package/src/components/otp-field/otp-field.style.js +53 -0
  132. package/src/components/pagination/pagination.changelog.md +30 -0
  133. package/src/components/pagination/pagination.define.js +3 -0
  134. package/src/components/pagination/pagination.events.js +3 -0
  135. package/src/components/pagination/pagination.js +282 -0
  136. package/src/components/pagination/pagination.readme.md +167 -0
  137. package/src/components/pagination/pagination.style.js +162 -0
  138. package/src/components/password-field/password-field.changelog.md +24 -0
  139. package/src/components/password-field/password-field.js +7 -1
  140. package/src/components/password-field/password-field.readme.md +15 -6
  141. package/src/components/password-field/password-field.style.js +36 -13
  142. package/src/components/popover/popover.changelog.md +24 -0
  143. package/src/components/popover/popover.define.js +3 -0
  144. package/src/components/popover/popover.events.js +4 -0
  145. package/src/components/popover/popover.js +255 -0
  146. package/src/components/popover/popover.readme.md +132 -0
  147. package/src/components/popover/popover.style.js +41 -0
  148. package/src/components/progress-bar/progress-bar.changelog.md +23 -0
  149. package/src/components/progress-bar/progress-bar.define.js +3 -0
  150. package/src/components/progress-bar/progress-bar.js +80 -0
  151. package/src/components/progress-bar/progress-bar.readme.md +110 -0
  152. package/src/components/progress-bar/progress-bar.style.js +93 -0
  153. package/src/components/progress-ring/progress-ring.changelog.md +23 -0
  154. package/src/components/progress-ring/progress-ring.define.js +3 -0
  155. package/src/components/progress-ring/progress-ring.js +83 -0
  156. package/src/components/progress-ring/progress-ring.readme.md +115 -0
  157. package/src/components/progress-ring/progress-ring.style.js +85 -0
  158. package/src/components/radio-field/radio-field.changelog.md +16 -0
  159. package/src/components/radio-field/radio-field.js +34 -11
  160. package/src/components/radio-field/radio-field.readme.md +13 -8
  161. package/src/components/radio-field/radio-field.style.js +17 -65
  162. package/src/components/range-field/range-field.changelog.md +24 -0
  163. package/src/components/range-field/range-field.define.js +3 -0
  164. package/src/components/range-field/range-field.js +167 -0
  165. package/src/components/range-field/range-field.readme.md +87 -0
  166. package/src/components/range-field/range-field.style.js +41 -0
  167. package/src/components/rating-field/rating-field.changelog.md +24 -0
  168. package/src/components/rating-field/rating-field.define.js +3 -0
  169. package/src/components/rating-field/rating-field.js +195 -0
  170. package/src/components/rating-field/rating-field.readme.md +82 -0
  171. package/src/components/rating-field/rating-field.style.js +79 -0
  172. package/src/components/select-field/select-field.changelog.md +17 -0
  173. package/src/components/select-field/select-field.js +100 -8
  174. package/src/components/select-field/select-field.readme.md +32 -6
  175. package/src/components/select-field/select-field.style.js +19 -9
  176. package/src/components/skeleton/skeleton.changelog.md +22 -0
  177. package/src/components/skeleton/skeleton.define.js +3 -0
  178. package/src/components/skeleton/skeleton.js +49 -0
  179. package/src/components/skeleton/skeleton.readme.md +115 -0
  180. package/src/components/skeleton/skeleton.style.js +79 -0
  181. package/src/components/slider/slider.changelog.md +15 -0
  182. package/src/components/slider/slider.js +37 -5
  183. package/src/components/slider/slider.readme.md +28 -6
  184. package/src/components/slider/slider.style.js +7 -71
  185. package/src/components/spinner/spinner.changelog.md +22 -0
  186. package/src/components/spinner/spinner.define.js +3 -0
  187. package/src/components/spinner/spinner.js +48 -0
  188. package/src/components/spinner/spinner.readme.md +98 -0
  189. package/src/components/spinner/spinner.style.js +44 -0
  190. package/src/components/switch-field/switch-field.changelog.md +16 -0
  191. package/src/components/switch-field/switch-field.js +17 -9
  192. package/src/components/switch-field/switch-field.readme.md +11 -4
  193. package/src/components/switch-field/switch-field.style.js +13 -13
  194. package/src/components/tab-group/tab-group.changelog.md +19 -0
  195. package/src/components/tab-group/tab-group.js +122 -10
  196. package/src/components/tab-group/tab-group.readme.md +25 -4
  197. package/src/components/tab-link/tab-link.changelog.md +16 -0
  198. package/src/components/tab-link/tab-link.js +51 -8
  199. package/src/components/tab-link/tab-link.readme.md +14 -8
  200. package/src/components/tab-link/tab-link.style.js +13 -0
  201. package/src/components/tab-panel/tab-panel.changelog.md +8 -2
  202. package/src/components/tab-panel/tab-panel.js +7 -3
  203. package/src/components/tab-panel/tab-panel.readme.md +7 -5
  204. package/src/components/tag/tag.changelog.md +24 -0
  205. package/src/components/tag/tag.define.js +3 -0
  206. package/src/components/tag/tag.events.js +3 -0
  207. package/src/components/tag/tag.js +116 -0
  208. package/src/components/tag/tag.readme.md +119 -0
  209. package/src/components/tag/tag.style.js +101 -0
  210. package/src/components/tag-field/tag-field.changelog.md +25 -0
  211. package/src/components/tag-field/tag-field.define.js +3 -0
  212. package/src/components/tag-field/tag-field.js +359 -0
  213. package/src/components/tag-field/tag-field.readme.md +113 -0
  214. package/src/components/tag-field/tag-field.style.js +62 -0
  215. package/src/components/textarea-field/textarea-field.changelog.md +28 -4
  216. package/src/components/textarea-field/textarea-field.js +68 -14
  217. package/src/components/textarea-field/textarea-field.readme.md +45 -9
  218. package/src/components/textarea-field/textarea-field.style.js +45 -2
  219. package/src/components/toast/toast.changelog.md +24 -0
  220. package/src/components/toast/toast.define.js +3 -0
  221. package/src/components/toast/toast.js +193 -0
  222. package/src/components/toast/toast.readme.md +189 -0
  223. package/src/components/toast/toast.style.js +74 -0
  224. package/src/components/tooltip/tooltip.changelog.md +24 -0
  225. package/src/components/tooltip/tooltip.define.js +3 -0
  226. package/src/components/tooltip/tooltip.events.js +4 -0
  227. package/src/components/tooltip/tooltip.js +377 -0
  228. package/src/components/tooltip/tooltip.readme.md +172 -0
  229. package/src/components/tooltip/tooltip.style.js +107 -0
  230. package/src/components/transition-classes/transition-classes.js +6 -6
  231. package/src/styles/appearance.style.js +42 -0
  232. package/src/styles/arrow.style.js +65 -0
  233. package/src/styles/choice-group.style.js +94 -0
  234. package/src/styles/form-control.style.js +79 -0
  235. package/src/styles/host.style.js +55 -0
  236. package/src/styles/layers.css +31 -0
  237. package/src/styles/modal.style.js +146 -0
  238. package/src/styles/native.css +275 -0
  239. package/src/styles/size.style.js +48 -0
  240. package/src/styles/slide-controls.style.js +225 -0
  241. package/src/styles/utilities.css +30 -0
  242. package/src/styles/variants.style.js +78 -0
  243. package/src/themes/default.css +86 -142
  244. package/src/themes/high-contrast.css +72 -129
  245. package/src/themes/sketchy.css +95 -175
  246. package/src/utils/floating.js +71 -0
  247. package/src/utils/focus.js +18 -0
  248. package/src/utils/progress.js +25 -0
  249. package/src/utils/slots.js +21 -0
  250. package/src/utils/text-entry-attributes.js +51 -0
  251. package/types/all.d.ts +54 -1
  252. package/types/index.d.ts +1 -0
  253. package/types/src/components/accordion/accordion.d.ts +6 -4
  254. package/types/src/components/accordion/accordion.events.d.ts +3 -3
  255. package/types/src/components/accordion-group/accordion-group.d.ts +4 -3
  256. package/types/src/components/amount-field/amount-field.d.ts +30 -16
  257. package/types/src/components/avatar/avatar.d.ts +57 -0
  258. package/types/src/components/avatar/avatar.define.d.ts +1 -0
  259. package/types/src/components/avatar/avatar.style.d.ts +2 -0
  260. package/types/src/components/badge/badge.d.ts +32 -0
  261. package/types/src/components/badge/badge.define.d.ts +1 -0
  262. package/types/src/components/badge/badge.style.d.ts +2 -0
  263. package/types/src/components/breadcrumb/breadcrumb.d.ts +27 -0
  264. package/types/src/components/breadcrumb/breadcrumb.define.d.ts +1 -0
  265. package/types/src/components/breadcrumb/breadcrumb.style.d.ts +2 -0
  266. package/types/src/components/breadcrumb-item/breadcrumb-item.d.ts +38 -0
  267. package/types/src/components/breadcrumb-item/breadcrumb-item.define.d.ts +1 -0
  268. package/types/src/components/breadcrumb-item/breadcrumb-item.style.d.ts +2 -0
  269. package/types/src/components/button/button.d.ts +129 -14
  270. package/types/src/components/button-group/button-group.d.ts +28 -0
  271. package/types/src/components/button-group/button-group.define.d.ts +1 -0
  272. package/types/src/components/button-group/button-group.style.d.ts +2 -0
  273. package/types/src/components/card/card.d.ts +40 -0
  274. package/types/src/components/card/card.define.d.ts +1 -0
  275. package/types/src/components/card/card.style.d.ts +2 -0
  276. package/types/src/components/carousel/carousel.d.ts +22 -8
  277. package/types/src/components/carousel/carousel.events.d.ts +3 -3
  278. package/types/src/components/carousel/glide/components/ShadowAnchors.d.ts +1 -1
  279. package/types/src/components/carousel/glide/components/ShadowClones.d.ts +8 -1
  280. package/types/src/components/carousel/glide/components/ShadowGaps.d.ts +1 -1
  281. package/types/src/components/carousel/glide/components/ShadowHtml.d.ts +1 -1
  282. package/types/src/components/carousel/glide/components/glide-html.d.ts +1 -1
  283. package/types/src/components/checkbox-field/checkbox-field.d.ts +22 -15
  284. package/types/src/components/checkbox-group-field/checkbox-group-field.d.ts +100 -0
  285. package/types/src/components/checkbox-group-field/checkbox-group-field.define.d.ts +1 -0
  286. package/types/src/components/checkbox-group-field/checkbox-group-field.style.d.ts +2 -0
  287. package/types/src/components/color-field/color-field.d.ts +102 -0
  288. package/types/src/components/color-field/color-field.define.d.ts +1 -0
  289. package/types/src/components/color-field/color-field.style.d.ts +2 -0
  290. package/types/src/components/combobox-field/combobox-field.d.ts +84 -0
  291. package/types/src/components/combobox-field/combobox-field.define.d.ts +1 -0
  292. package/types/src/components/combobox-field/combobox-field.style.d.ts +2 -0
  293. package/types/src/components/copy-button/copy-button.d.ts +93 -0
  294. package/types/src/components/copy-button/copy-button.define.d.ts +1 -0
  295. package/types/src/components/copy-button/copy-button.events.d.ts +5 -0
  296. package/types/src/components/copy-button/copy-button.style.d.ts +2 -0
  297. package/types/src/components/date-field/date-field.d.ts +102 -0
  298. package/types/src/components/date-field/date-field.define.d.ts +1 -0
  299. package/types/src/components/date-field/date-field.style.d.ts +2 -0
  300. package/types/src/components/dialog/dialog.d.ts +101 -19
  301. package/types/src/components/dialog/dialog.events.d.ts +8 -8
  302. package/types/src/components/divider/divider.d.ts +27 -0
  303. package/types/src/components/divider/divider.define.d.ts +1 -0
  304. package/types/src/components/divider/divider.style.d.ts +2 -0
  305. package/types/src/components/drawer/drawer.d.ts +70 -0
  306. package/types/src/components/drawer/drawer.define.d.ts +1 -0
  307. package/types/src/components/drawer/drawer.events.d.ts +9 -0
  308. package/types/src/components/drawer/drawer.style.d.ts +2 -0
  309. package/types/src/components/dropdown/dropdown.d.ts +5 -3
  310. package/types/src/components/empty-state/empty-state.d.ts +29 -0
  311. package/types/src/components/empty-state/empty-state.define.d.ts +1 -0
  312. package/types/src/components/empty-state/empty-state.style.d.ts +2 -0
  313. package/types/src/components/file-field/file-field.d.ts +115 -0
  314. package/types/src/components/file-field/file-field.define.d.ts +1 -0
  315. package/types/src/components/file-field/file-field.style.d.ts +2 -0
  316. package/types/src/components/form-field/form-field.d.ts +129 -14
  317. package/types/src/components/form-field/form-field.events.d.ts +4 -4
  318. package/types/src/components/input-field/input-field.d.ts +52 -5
  319. package/types/src/components/lazy-src/lazy-src.d.ts +7 -5
  320. package/types/src/components/lazy-src/lazy-src.events.d.ts +5 -5
  321. package/types/src/components/notification/notification.d.ts +18 -18
  322. package/types/src/components/notification/notification.events.d.ts +6 -6
  323. package/types/src/components/otp-field/otp-field.d.ts +130 -0
  324. package/types/src/components/otp-field/otp-field.define.d.ts +1 -0
  325. package/types/src/components/otp-field/otp-field.events.d.ts +4 -0
  326. package/types/src/components/otp-field/otp-field.style.d.ts +2 -0
  327. package/types/src/components/pagination/pagination.d.ts +117 -0
  328. package/types/src/components/pagination/pagination.define.d.ts +1 -0
  329. package/types/src/components/pagination/pagination.events.d.ts +4 -0
  330. package/types/src/components/pagination/pagination.style.d.ts +2 -0
  331. package/types/src/components/password-field/password-field.d.ts +29 -12
  332. package/types/src/components/popover/popover.d.ts +123 -0
  333. package/types/src/components/popover/popover.define.d.ts +1 -0
  334. package/types/src/components/popover/popover.events.d.ts +5 -0
  335. package/types/src/components/popover/popover.style.d.ts +2 -0
  336. package/types/src/components/progress-bar/progress-bar.d.ts +35 -0
  337. package/types/src/components/progress-bar/progress-bar.define.d.ts +1 -0
  338. package/types/src/components/progress-bar/progress-bar.style.d.ts +2 -0
  339. package/types/src/components/progress-ring/progress-ring.d.ts +40 -0
  340. package/types/src/components/progress-ring/progress-ring.define.d.ts +1 -0
  341. package/types/src/components/progress-ring/progress-ring.style.d.ts +2 -0
  342. package/types/src/components/radio-field/radio-field.d.ts +21 -9
  343. package/types/src/components/range-field/range-field.d.ts +94 -0
  344. package/types/src/components/range-field/range-field.define.d.ts +1 -0
  345. package/types/src/components/range-field/range-field.style.d.ts +2 -0
  346. package/types/src/components/rating-field/rating-field.d.ts +96 -0
  347. package/types/src/components/rating-field/rating-field.define.d.ts +1 -0
  348. package/types/src/components/rating-field/rating-field.style.d.ts +2 -0
  349. package/types/src/components/scroll-to/scroll-to.d.ts +3 -2
  350. package/types/src/components/scroll-to-top/scroll-to-top.d.ts +4 -2
  351. package/types/src/components/select-field/select-field.d.ts +55 -5
  352. package/types/src/components/skeleton/skeleton.d.ts +29 -0
  353. package/types/src/components/skeleton/skeleton.define.d.ts +1 -0
  354. package/types/src/components/skeleton/skeleton.style.d.ts +2 -0
  355. package/types/src/components/slider/slider.d.ts +14 -8
  356. package/types/src/components/slider/slider.events.d.ts +4 -4
  357. package/types/src/components/spinner/spinner.d.ts +28 -0
  358. package/types/src/components/spinner/spinner.define.d.ts +1 -0
  359. package/types/src/components/spinner/spinner.style.d.ts +2 -0
  360. package/types/src/components/sticky/sticky.d.ts +4 -2
  361. package/types/src/components/svg-use/svg-use.d.ts +4 -2
  362. package/types/src/components/switch-field/switch-field.d.ts +17 -15
  363. package/types/src/components/tab-group/tab-group.d.ts +44 -3
  364. package/types/src/components/tab-link/tab-link.d.ts +33 -10
  365. package/types/src/components/tab-panel/tab-panel.d.ts +8 -5
  366. package/types/src/components/tag/tag.d.ts +53 -0
  367. package/types/src/components/tag/tag.define.d.ts +1 -0
  368. package/types/src/components/tag/tag.events.d.ts +4 -0
  369. package/types/src/components/tag/tag.style.d.ts +2 -0
  370. package/types/src/components/tag-field/tag-field.d.ts +178 -0
  371. package/types/src/components/tag-field/tag-field.define.d.ts +1 -0
  372. package/types/src/components/tag-field/tag-field.style.d.ts +2 -0
  373. package/types/src/components/textarea-field/textarea-field.d.ts +44 -4
  374. package/types/src/components/toast/toast.d.ts +110 -0
  375. package/types/src/components/toast/toast.define.d.ts +1 -0
  376. package/types/src/components/toast/toast.style.d.ts +2 -0
  377. package/types/src/components/tooltip/tooltip.d.ts +161 -0
  378. package/types/src/components/tooltip/tooltip.define.d.ts +1 -0
  379. package/types/src/components/tooltip/tooltip.events.d.ts +5 -0
  380. package/types/src/components/tooltip/tooltip.style.d.ts +2 -0
  381. package/types/src/components/transition-classes/transition-classes.d.ts +9 -8
  382. package/types/src/styles/appearance.style.d.ts +18 -0
  383. package/types/src/styles/arrow.style.d.ts +15 -0
  384. package/types/src/styles/choice-group.style.d.ts +23 -0
  385. package/types/src/styles/form-control.style.d.ts +26 -0
  386. package/types/src/styles/host.style.d.ts +24 -0
  387. package/types/src/styles/modal.style.d.ts +20 -0
  388. package/types/src/styles/size.style.d.ts +20 -0
  389. package/types/src/styles/slide-controls.style.d.ts +20 -0
  390. package/types/src/styles/variants.style.d.ts +32 -0
  391. package/types/src/utils/body-scroll.d.ts +12 -2
  392. package/types/src/utils/floating.d.ts +36 -0
  393. package/types/src/utils/focus.d.ts +16 -0
  394. package/types/src/utils/progress.d.ts +19 -0
  395. package/types/src/utils/slots.d.ts +19 -0
  396. package/types/src/utils/text-entry-attributes.d.ts +18 -0
  397. package/types/src/utils/transitions.d.ts +2 -2
  398. package/web-types.json +6590 -1584
@@ -0,0 +1,172 @@
1
+ # Tooltip
2
+
3
+ `tooltip` is a short text that explains another element, its anchor. It appears next to the anchor while the pointer rests on it or while it has the focus of the keyboard, and `Escape` closes it.
4
+
5
+ The tooltip stands next to its anchor in the page and names it by id with `for`, the way a `<label>` names its field. It is the description of the anchor for a screen reader (`aria-describedby`), whether it is open or not.
6
+
7
+ The element is a native popover of the platform (`popover="manual"`), which owns the top layer: nothing clips the tooltip or lies on top of it, whatever `overflow` or `z-index` its surroundings have. The component adds the opening and closing and the place, which it computes with [Floating UI](https://floating-ui.com): at the side of the anchor that `placement` names, on the other side when there is no room, and never outside the viewport.
8
+
9
+ Without a theme imported the tooltip has the system colours, the other way round: the text colour as its background.
10
+
11
+ ## How to use
12
+
13
+ #### Install
14
+
15
+ ```sh
16
+ npm i --save @webtides/element-library
17
+ ```
18
+
19
+ #### Use
20
+
21
+ ```js
22
+ import '@webtides/element-library/tooltip/define';
23
+ ```
24
+
25
+ ```html
26
+ <button id="save" type="button">Save</button>
27
+ <el-tooltip for="save">Saves the document</el-tooltip>
28
+
29
+ <!-- Below the anchor, with an arrow -->
30
+ <el-button id="archive">Archive</el-button>
31
+ <el-tooltip for="archive" placement="bottom" arrow="true">Moves the project to the archive</el-tooltip>
32
+
33
+ <!-- An icon button: the name is on the button, the tooltip adds to it -->
34
+ <el-button id="bold" circle="true" aria-label="Bold"><strong>B</strong></el-button>
35
+ <el-tooltip for="bold">Makes the selection bold</el-tooltip>
36
+ ```
37
+
38
+ > Boolean attributes are passed as strings (`arrow="true"`), matching the rest of the library.
39
+
40
+ ## API
41
+
42
+ #### Properties/Attributes
43
+
44
+ | Name | Type | Default | Description |
45
+ | --- | --- | --- | --- |
46
+ | `for` | `string` | `''` | The id of the anchor, in the document or the shadow root the tooltip is in. |
47
+ | `open` | `boolean` | `false` | Whether the tooltip is shown. Reflected to the `open` attribute. |
48
+ | `placement` | `string` | `'top'` | `top`, `bottom`, `left` or `right`, each also with `-start` or `-end`. |
49
+ | `distance` | `number` | `8` | The gap between the anchor and the tooltip, or the tip of its arrow, in pixels. |
50
+ | `show-delay` | `number` | `150` | How long the pointer has to rest on the anchor before the tooltip opens, in milliseconds. |
51
+ | `hide-delay` | `number` | `0` | How long the tooltip stays after the pointer has left, in milliseconds. |
52
+ | `arrow` | `boolean` | `false` | Whether the tooltip has an arrow that points to the anchor. |
53
+ | `disabled` | `boolean` | `false` | Takes the pointer and the focus out of it: the tooltip opens and closes for a script only. |
54
+
55
+ The properties of the two delays are `showDelay` and `hideDelay`.
56
+
57
+ #### Methods
58
+
59
+ | Name | Description |
60
+ | -------- | ----------------------------------------------------------------- |
61
+ | `show()` | Opens the tooltip. Without an anchor in the page it stays closed. |
62
+ | `hide()` | Closes the tooltip. |
63
+
64
+ #### Events
65
+
66
+ | Name | Description |
67
+ | -------------- | ----------------------- |
68
+ | `tooltip-show` | The tooltip has opened. |
69
+ | `tooltip-hide` | The tooltip has closed. |
70
+
71
+ Both bubble and cross shadow boundaries. They fire for every way of opening and closing: the pointer, the focus, `Escape`, the methods, the `open` property.
72
+
73
+ #### Slots
74
+
75
+ | Name | Description |
76
+ | ----------- | ------------------------ |
77
+ | _(default)_ | The text of the tooltip. |
78
+
79
+ #### CSS Parts
80
+
81
+ | Name | Description |
82
+ | ------- | --------------------------------------------------------------------- |
83
+ | `body` | The surface of the tooltip: background, text colour, padding, radius. |
84
+ | `arrow` | The arrow (present only while `arrow`). |
85
+
86
+ #### CSS States
87
+
88
+ | Name | Description |
89
+ | ------ | --------------------------------------------------------------------------------------- |
90
+ | `open` | Present on the element while the tooltip is shown. Style with `el-tooltip:state(open)`. |
91
+
92
+ #### CSS Custom Properties
93
+
94
+ The body reads `--el-color-fg` for its background and `--el-color-bg` for its text (the system colours `CanvasText` and `Canvas` without a theme), `--el-space-1` and `--el-space-2` for its padding, `--el-radius-md`, `--el-border-width`, `--el-font-family`, `--el-font-size-sm` and `--el-line-height`. The arrow has the surface of the body.
95
+
96
+ The border of the body is transparent. It shows when a user forces colours (Windows contrast themes), where a background is not painted. The arrow has it on the two sides that stick out.
97
+
98
+ The look is on the part, the width on the element. A tooltip is as wide as its text, up to `20rem`, and never wider than the viewport:
99
+
100
+ ```css
101
+ el-tooltip {
102
+ max-width: 30rem;
103
+ }
104
+
105
+ el-tooltip::part(body) {
106
+ background: var(--el-color-accent);
107
+ border-radius: 999px;
108
+ }
109
+ ```
110
+
111
+ The element itself is only the box that is placed. It has no padding, border or background of its own, so a reset of the page that selects every element (`* { padding: 0 }`) does not change the tooltip.
112
+
113
+ ## Placement
114
+
115
+ `placement` names the side of the anchor: `top`, `bottom`, `left` or `right`. On that side the tooltip is centred on the anchor; with `-start` or `-end` it is aligned with that edge of the anchor instead.
116
+
117
+ The placement is a wish. The tooltip goes to the opposite side when it has no room on its own, and it is pushed back along the edge of the viewport when it would leave it, to 8 px from the edge. The arrow stays on the anchor through both.
118
+
119
+ While the tooltip is open it follows its anchor: when the page or a box around it scrolls, when the window is resized, when the anchor or the tooltip changes its size. Nothing is computed while it is closed.
120
+
121
+ `distance` is the gap between the anchor and the tooltip in pixels. With an arrow it is the gap between the anchor and the tip of the arrow.
122
+
123
+ ## Opening and closing
124
+
125
+ - **The pointer** opens the tooltip when it rests on the anchor for `show-delay`, and closes it when it leaves, after `hide-delay`. A pointer that only passes over the anchor opens nothing.
126
+ - The pointer can go from the anchor onto the tooltip, to read a long text or to select it: the gap between the two belongs to the tooltip, and it stays while the pointer is on either.
127
+ - **The focus of the keyboard** opens the tooltip at once, without the delay, and it closes when the focus moves on. A button that was clicked keeps the focus, but that does not hold the tooltip open: it goes when the pointer leaves.
128
+ - **`Escape`** closes the tooltip, wherever the focus is. It stays closed until the pointer or the focus comes to the anchor anew. The tooltip takes that key press: a dialog or a popover around the anchor stays open, and the next `Escape` is for it.
129
+ - **A finger** opens nothing: a touch screen has no hover, and the tooltip would appear together with the press on the anchor. Do not put into a tooltip what a user cannot do without.
130
+ - `open`, `show()` and `hide()` do the same from a script. A tooltip that a script has opened closes like any other, when the pointer leaves its anchor for example. With `disabled` the pointer and the focus neither open nor close it, and it is left to the script; `Escape` still closes it.
131
+ - A tooltip that is taken out of the page closes, and is closed when it comes back. One whose `for` changes closes as well.
132
+
133
+ ## The anchor
134
+
135
+ The anchor is the element whose id `for` names. The tooltip looks it up in the document, or in the shadow root it is in itself, when it is connected, when `for` changes and when it is opened. An anchor that is put into the page later than its tooltip is found with the next `show()`, or when `for` is set again; one that is replaced by another element with the same id is not noticed.
136
+
137
+ Any element can be the anchor. One that takes the focus (a button, a link, a field) is what a keyboard can reach. Several tooltips can name the same anchor, and one anchor can have a tooltip and be the anchor of an `el-popover`.
138
+
139
+ Without an anchor in the page the tooltip does not open.
140
+
141
+ ## Accessibility
142
+
143
+ - The tooltip adds its id to the `aria-describedby` of its anchor and keeps what is there. A screen reader reads the text of the tooltip after the name of the anchor, also while the tooltip is closed. A tooltip without an id gets one (`el-tooltip-1`).
144
+ - The tooltip is a description, not a name. A button that shows only an icon needs `aria-label` as well.
145
+ - An `el-button` as the anchor passes the description on to the control inside it.
146
+ - The element has the role `tooltip`.
147
+ - Put text into a tooltip, no links and no controls: the focus does not go into it, and it closes when the focus leaves the anchor. Content to interact with belongs into an `el-popover`.
148
+ - The tooltip can be dismissed with `Escape`, hovered, and it stays until the pointer or the focus leaves or the user closes it (WCAG 1.4.13, Content on Hover or Focus).
149
+ - `disabled` only keeps the tooltip from opening. It stays the description of its anchor.
150
+
151
+ ## Server-side rendering
152
+
153
+ The text of the tooltip is content of the page, and the closed tooltip is part of the server-rendered markup (Declarative Shadow DOM). Its stylesheet hides it until it is opened, so nothing flashes before the JavaScript has loaded. Opening, placing and the `aria-describedby` on the anchor need the JavaScript. To have the description without it, write it yourself:
154
+
155
+ ```html
156
+ <button id="save" type="button" aria-describedby="save-hint">Save</button>
157
+ <el-tooltip id="save-hint" for="save">Saves the document</el-tooltip>
158
+ ```
159
+
160
+ Without server-side rendering the text of a tooltip is in the page until its element is defined. Hide it until then:
161
+
162
+ ```css
163
+ el-tooltip:not(:defined) {
164
+ display: none;
165
+ }
166
+ ```
167
+
168
+ ## Browser support
169
+
170
+ The tooltip needs the native Popover API: Chrome 114, Firefox 125, Safari 17. Its place is computed in script, so it does not depend on CSS anchor positioning.
171
+
172
+ With an `el-button` as the anchor the description reaches the control through ARIA element references: Chrome 135, Firefox 136, Safari 16.4.
@@ -0,0 +1,107 @@
1
+ import hostStyle from '../../styles/host.style.js';
2
+ import arrowStyle from '../../styles/arrow.style.js';
3
+
4
+ const css = String.raw;
5
+
6
+ /* The gap between the anchor and the body, from its padding box outwards. */
7
+ const gap = 'calc(var(--_el-tooltip-gap, 0px) + var(--el-border-width, 1px))';
8
+
9
+ const style = css`
10
+ /* The element is the popover, and only the box that is placed: the script sets left and top,
11
+ in the coordinates of the viewport. What the platform gives a popover (a centred place, a
12
+ border, a padding, a background) goes. The look is on the body inside, where a reset of the
13
+ page that selects every element does not reach it. */
14
+ :host {
15
+ position: fixed;
16
+ inset: auto;
17
+ top: 0;
18
+ left: 0;
19
+ margin: 0;
20
+ padding: 0;
21
+ border: 0;
22
+ background: none;
23
+ /* The arrow sticks out. */
24
+ overflow: visible;
25
+ width: max-content;
26
+ max-width: min(20rem, calc(100vw - 1rem));
27
+ }
28
+
29
+ /* Closed. The platform hides a closed popover as well, but the element is a popover only once
30
+ its script has run. This rule is part of the server-rendered markup. */
31
+ :host(:not(:popover-open)) {
32
+ display: none;
33
+ }
34
+
35
+ /* Shown by the platform (showPopover() on the element) but not placed yet: the component hears
36
+ of that a moment later. Until then the tooltip would sit in the corner of the viewport, for
37
+ the eye and for the pointer. */
38
+ :host(:not(:state(open))) {
39
+ visibility: hidden;
40
+ pointer-events: none;
41
+ }
42
+
43
+ .body {
44
+ position: relative;
45
+ padding: var(--el-space-1, 0.25rem) var(--el-space-2, 0.5rem);
46
+ /* The colours of the page the other way round, with the system colours as the headless
47
+ fallback: a tooltip has to be readable over whatever it floats above. */
48
+ background: var(--el-color-fg, CanvasText);
49
+ color: var(--el-color-bg, Canvas);
50
+ /* Nothing to see until a user forces colours: then the background is not painted, and the
51
+ border is the outline of the tooltip. */
52
+ border: var(--el-border-width, 1px) solid transparent;
53
+ border-radius: var(--el-radius-md, 0);
54
+ /* The tooltip stands in the page next to its anchor and would take over what the text
55
+ there looks like: a heading, a table header, a line that does not wrap. */
56
+ font-family: var(--el-font-family, inherit);
57
+ font-size: var(--el-font-size-sm, 0.875rem);
58
+ font-style: normal;
59
+ font-weight: normal;
60
+ letter-spacing: normal;
61
+ line-height: var(--el-line-height, 1.5);
62
+ text-align: start;
63
+ text-transform: none;
64
+ white-space: normal;
65
+ overflow-wrap: break-word;
66
+ }
67
+
68
+ /* ── The way from the anchor to the tooltip ───────────────────────────── */
69
+
70
+ /* The gap between the two belongs to the tooltip: a pointer that goes from the anchor onto the
71
+ text never leaves both, so the tooltip stays (WCAG 1.4.13). The script sets the width of the
72
+ gap; the side is the one that faces the anchor. */
73
+ .body::before {
74
+ content: '';
75
+ position: absolute;
76
+ }
77
+
78
+ :host([data-placement^='top']) .body::before {
79
+ top: 100%;
80
+ right: 0;
81
+ left: 0;
82
+ height: ${gap};
83
+ }
84
+
85
+ :host([data-placement^='bottom']) .body::before {
86
+ right: 0;
87
+ bottom: 100%;
88
+ left: 0;
89
+ height: ${gap};
90
+ }
91
+
92
+ :host([data-placement^='left']) .body::before {
93
+ top: 0;
94
+ bottom: 0;
95
+ left: 100%;
96
+ width: ${gap};
97
+ }
98
+
99
+ :host([data-placement^='right']) .body::before {
100
+ top: 0;
101
+ right: 100%;
102
+ bottom: 0;
103
+ width: ${gap};
104
+ }
105
+ `;
106
+
107
+ export default [hostStyle(), style, arrowStyle(':host')].join('\n');
@@ -10,12 +10,12 @@ import { BaseElement, defineElement } from '@webtides/element-js';
10
10
  *
11
11
  * @slot - Default slot for the element(s) being transitioned.
12
12
  *
13
- * @attr enter - Space-separated classes added throughout the enter transition.
14
- * @attr enter-start - Classes applied at the start of the enter transition.
15
- * @attr enter-end - Classes applied at the end of the enter transition.
16
- * @attr leave - Space-separated classes added throughout the leave transition.
17
- * @attr leave-start - Classes applied at the start of the leave transition.
18
- * @attr leave-end - Classes applied at the end of the leave transition.
13
+ * @attr {string} enter - Space-separated classes added throughout the enter transition.
14
+ * @attr {string} enter-start - Classes applied at the start of the enter transition.
15
+ * @attr {string} enter-end - Classes applied at the end of the enter transition.
16
+ * @attr {string} leave - Space-separated classes added throughout the leave transition.
17
+ * @attr {string} leave-start - Classes applied at the start of the leave transition.
18
+ * @attr {string} leave-end - Classes applied at the end of the leave transition.
19
19
  *
20
20
  * @property {boolean} show - When `true` the host plays the enter transition; when `false`
21
21
  * the leave transition.
@@ -0,0 +1,42 @@
1
+ import { hostSelector } from './host.style.js';
2
+
3
+ const css = String.raw;
4
+
5
+ /**
6
+ * How a component paints the colours of its variant: `filled` (the default), `outlined` or
7
+ * `plain`, chosen with the `appearance` attribute of the host. The component declares
8
+ * `appearance` as a reflected property, so that an appearance set from a script reaches the
9
+ * attribute. Goes together with the `variants` module, which provides the colours.
10
+ *
11
+ * - `filled`: the fill of the variant, with its border and the text colour for that fill
12
+ * - `outlined`: no fill, the border and the text of the variant
13
+ * - `plain`: no fill and no border, the text of the variant
14
+ *
15
+ * The module sets the background, the border colour and the text colour of the surface. The width
16
+ * and the style of the border, and what a state like hover does, belong to the component.
17
+ * @param {string} surface - Selector of the element inside the host that is painted, `'.button'`
18
+ * for example.
19
+ * @param {string} [host] - `':host'` (the default), or the tag of a component without a shadow root.
20
+ * @returns {string}
21
+ */
22
+ export default function appearanceStyle(surface, host = ':host') {
23
+ return css`
24
+ ${hostSelector(host)} ${surface} {
25
+ background: var(--_el-variant-fill);
26
+ border-color: var(--_el-variant-fill-border);
27
+ color: var(--_el-variant-on-fill);
28
+ }
29
+
30
+ ${hostSelector(host, "[appearance='outlined']")} ${surface} {
31
+ background: transparent;
32
+ border-color: var(--_el-variant-border);
33
+ color: var(--_el-variant-text);
34
+ }
35
+
36
+ ${hostSelector(host, "[appearance='plain']")} ${surface} {
37
+ background: transparent;
38
+ border-color: transparent;
39
+ color: var(--_el-variant-text);
40
+ }
41
+ `;
42
+ }
@@ -0,0 +1,65 @@
1
+ import { hostSelector } from './host.style.js';
2
+
3
+ const css = String.raw;
4
+
5
+ const size = 'var(--_el-arrow-size)';
6
+ /* Half of the square, and the border of the surface, outside of its padding box. */
7
+ const offset = `calc(${size} / -2 - var(--el-border-width, 1px))`;
8
+
9
+ /**
10
+ * The arrow of a floating surface, which points to its anchor: an element with the class `arrow`
11
+ * inside the surface. It is a square with the background and the border of the surface, turned by
12
+ * 45 degrees, with its middle on the outer edge of the surface. Only the two sides of the square
13
+ * that stick out have a border.
14
+ *
15
+ * The surface carries `data-placement` with the side of the anchor it is at, and the arrow sits on
16
+ * the edge that faces the anchor. `placeAtAnchor()` in `utils/floating.js` sets that attribute and
17
+ * the place of the arrow along the edge. The surface has to be positioned and must not clip
18
+ * (`overflow: visible`), because the arrow sticks out.
19
+ * @param {string} [surface] - Selector of the floating surface: `':host'` (the default) when the
20
+ * component is the surface itself, or the element inside it, `"[part~='panel']"` for example.
21
+ * @returns {string}
22
+ */
23
+ export default function arrowStyle(surface = ':host') {
24
+ const placed = (side) => `${hostSelector(surface, `[data-placement^='${side}']`)} .arrow`;
25
+
26
+ return css`
27
+ .arrow {
28
+ --_el-arrow-size: 0.75rem;
29
+ position: absolute;
30
+ width: ${size};
31
+ height: ${size};
32
+ background: inherit;
33
+ border: inherit;
34
+ transform: rotate(45deg);
35
+ }
36
+
37
+ /* The two sides of the square that lie inside the surface have no border. Their width goes,
38
+ not their colour: a user who forces colours (a contrast theme of Windows) gets a colour
39
+ for every border, a transparent one as well, and the two lines would run across the
40
+ corner of the surface. */
41
+ ${placed('bottom')} {
42
+ top: ${offset};
43
+ border-right-width: 0;
44
+ border-bottom-width: 0;
45
+ }
46
+
47
+ ${placed('top')} {
48
+ bottom: ${offset};
49
+ border-top-width: 0;
50
+ border-left-width: 0;
51
+ }
52
+
53
+ ${placed('right')} {
54
+ left: ${offset};
55
+ border-top-width: 0;
56
+ border-right-width: 0;
57
+ }
58
+
59
+ ${placed('left')} {
60
+ right: ${offset};
61
+ border-bottom-width: 0;
62
+ border-left-width: 0;
63
+ }
64
+ `;
65
+ }
@@ -0,0 +1,94 @@
1
+ import { hostSelector } from './host.style.js';
2
+
3
+ const css = String.raw;
4
+
5
+ /**
6
+ * A group of choices in a field: a fieldset with a legend that holds the options, each of them a
7
+ * label around a native radio or checkbox (`el-radio-field`, `el-checkbox-group-field`,
8
+ * `el-rating-field`).
9
+ *
10
+ * - The fieldset is the column of the field. It loses the border and the padding of the browser
11
+ * and stacks the legend, the help message, the options and the error message: all of them are
12
+ * inside the group, for a screen reader.
13
+ * - An option (`.option`) is the hit area of its control: a label with the control, the element
14
+ * that is drawn in its place, and the text. On a touch screen it is at least `--el-touch-target`
15
+ * in both directions.
16
+ * - The native control is hidden from the eye. It stays focusable and in the accessibility tree.
17
+ * The element after it shows the keyboard focus, and fades while the control is disabled.
18
+ *
19
+ * How the options lie beside each other (`.options`) and what is drawn in the place of a control
20
+ * are the business of the field.
21
+ *
22
+ * It goes together with `formControlStyle()`, which makes `.field` a flex container and gives the
23
+ * texts their look.
24
+ * @param {string} [host] - `':host'` (the default), or the tag of a field without a shadow root.
25
+ * @returns {string}
26
+ */
27
+ export default function choiceGroupStyle(host = ':host') {
28
+ const field = hostSelector(host);
29
+
30
+ return css`
31
+ ${field} fieldset.field {
32
+ flex-direction: column;
33
+ align-items: stretch;
34
+ gap: var(--el-space-1, 4px);
35
+ margin: 0;
36
+ padding: 0;
37
+ border: 0;
38
+ min-width: 0;
39
+ }
40
+
41
+ /* The browser sets a legend on the border of its fieldset. It is no row of the column, so
42
+ the gap of the column is its margin. */
43
+ ${field} legend {
44
+ padding: 0;
45
+ margin-bottom: var(--el-space-1, 4px);
46
+ }
47
+
48
+ ${field} .option {
49
+ display: inline-flex;
50
+ align-items: center;
51
+ gap: var(--el-space-2, 0.5em);
52
+ cursor: pointer;
53
+ }
54
+
55
+ ${field} .option:has(input:disabled) {
56
+ cursor: not-allowed;
57
+ }
58
+
59
+ /* The native control is replaced by the element after it; hide it visually but keep it in
60
+ the accessibility tree and focusable. */
61
+ ${field} .option input {
62
+ position: absolute;
63
+ width: 1px;
64
+ height: 1px;
65
+ margin: 0;
66
+ padding: 0;
67
+ border: 0;
68
+ opacity: 0;
69
+ overflow: hidden;
70
+ white-space: nowrap;
71
+ clip: rect(0 0 0 0);
72
+ clip-path: inset(50%);
73
+ }
74
+
75
+ /* Reflect keyboard focus onto the element that is drawn in the place of the control. */
76
+ ${field} .option input:focus-visible + * {
77
+ outline: var(--el-focus-ring-width, 2px) solid var(--el-color-accent, currentColor);
78
+ outline-offset: 2px;
79
+ }
80
+
81
+ ${field} .option input:disabled + * {
82
+ opacity: 0.5;
83
+ }
84
+
85
+ /* Touch screens: the label of an option is its hit area and at least --el-touch-target
86
+ in both directions. Without the token the sizes stay as they are. */
87
+ @media (any-pointer: coarse) {
88
+ ${field} .option {
89
+ min-width: var(--el-touch-target, auto);
90
+ min-height: var(--el-touch-target, auto);
91
+ }
92
+ }
93
+ `;
94
+ }
@@ -0,0 +1,79 @@
1
+ import { hostSelector } from './host.style.js';
2
+
3
+ const css = String.raw;
4
+
5
+ /**
6
+ * The layout every form field shares, around whatever control it renders: the label, the help
7
+ * message, the row with the control (`.field`) and the error message stack in a column, with the
8
+ * same gap between them in every field.
9
+ *
10
+ * It also is the look of the texts around the control, so that no field has one of its own:
11
+ *
12
+ * - a label, and the legend of a group, has the text colour of the theme;
13
+ * - the messages are set in the small font size;
14
+ * - the help message has the muted colour of the theme, the error message its danger colour.
15
+ *
16
+ * Without a theme each of them has the colour of the text, which can be read on any background.
17
+ *
18
+ * The row is as high as its control. The mark of a touched field (\`.validity\`, a check mark or a
19
+ * cross beside the control) does not add to that height.
20
+ *
21
+ * The control itself is not touched. Without a theme a native control keeps the look of the
22
+ * browser.
23
+ *
24
+ * Every rule names the host itself, and none is nested in the rule of the host. A rule nested in
25
+ * `:host` does not reach the content of a shadow root in every browser that knows nesting (Safari
26
+ * before 18.1), so the module also works for a field that composes it for a shadow root.
27
+ * @param {string} [host] - `':host'` (the default), or the tag of a field without a shadow root.
28
+ * @returns {string}
29
+ */
30
+ export default function formControlStyle(host = ':host') {
31
+ const field = hostSelector(host);
32
+
33
+ return css`
34
+ ${field} {
35
+ display: flex;
36
+ flex-direction: column;
37
+ gap: var(--el-space-1, 4px);
38
+ }
39
+
40
+ ${field} label,
41
+ ${field} legend {
42
+ color: var(--el-color-fg, inherit);
43
+ }
44
+
45
+ ${field} .field {
46
+ display: flex;
47
+ align-items: center;
48
+ gap: var(--el-space-2, 8px);
49
+ }
50
+
51
+ /* The mark of a touched field is a line of the text of the page, and that line can be
52
+ higher than a native control: 24px to 21px for text of 16px at a line height of 1.5. The
53
+ row would grow by the difference when the mark comes, and what follows the field would
54
+ move. Half a line of margin less above and below takes the line out of the height of
55
+ the row; the mark stays in its middle. */
56
+ ${field} .validity {
57
+ margin-block: -0.5lh;
58
+ }
59
+
60
+ ${field} .message {
61
+ font-size: var(--el-font-size-sm, 14px);
62
+ }
63
+
64
+ ${field} .help-message {
65
+ color: var(--el-color-fg-muted, inherit);
66
+ }
67
+
68
+ /* A field renders the element of the help message with or without a text. Without one it
69
+ would still be a row of the column, and the gap after it would show. */
70
+ ${field} .help-message:empty {
71
+ display: none;
72
+ }
73
+
74
+ /* The keyword red on white is 4 : 1, so there is no red for a page without a theme. */
75
+ ${field} .error-message {
76
+ color: var(--el-color-danger, inherit);
77
+ }
78
+ `;
79
+ }
@@ -0,0 +1,55 @@
1
+ const css = String.raw;
2
+
3
+ /**
4
+ * The selector of a component's host, with a condition on it if one is given. A component with a
5
+ * shadow root is `:host` in its own stylesheet, a component that renders into the page is its tag:
6
+ *
7
+ * - `hostSelector(':host', "[size='small']")` is `:host([size='small'])`
8
+ * - `hostSelector('el-input-field', "[size='small']")` is `el-input-field[size='small']`
9
+ *
10
+ * The shared style modules take the host as their argument, so one module serves both kinds.
11
+ * @param {string} host - `':host'`, or the tag of a component without a shadow root.
12
+ * @param {string} [condition] - A compound selector for the host, an attribute selector for example.
13
+ * @returns {string}
14
+ */
15
+ export function hostSelector(host, condition = '') {
16
+ if (host !== ':host') return `${host}${condition}`;
17
+ return condition ? `:host(${condition})` : ':host';
18
+ }
19
+
20
+ /**
21
+ * What every component needs on its host: the `hidden` attribute hides it. A component sets a
22
+ * `display` of its own on the host, and that would win over the rule of the browser.
23
+ *
24
+ * In a shadow root the sizes also count from the border (`box-sizing: border-box`), for the host
25
+ * and everything inside. A component that renders into the page leaves the box model of its
26
+ * content alone: a native control keeps the one the page gives it.
27
+ * @param {string} [host] - `':host'` (the default), or the tag of a component without a shadow root.
28
+ * @returns {string}
29
+ */
30
+ export default function hostStyle(host = ':host') {
31
+ if (host !== ':host') {
32
+ return css`
33
+ ${host}[hidden] {
34
+ display: none !important;
35
+ }
36
+ `;
37
+ }
38
+
39
+ return css`
40
+ :host {
41
+ box-sizing: border-box;
42
+ }
43
+
44
+ :host *,
45
+ :host *::before,
46
+ :host *::after {
47
+ box-sizing: inherit;
48
+ }
49
+
50
+ [hidden],
51
+ :host([hidden]) {
52
+ display: none !important;
53
+ }
54
+ `;
55
+ }
@@ -0,0 +1,31 @@
1
+ /*
2
+ * @webtides/element-library — cascade layers
3
+ *
4
+ * The order of the library's layers, lowest priority first:
5
+ *
6
+ * el-tokens the design tokens of a theme (themes/*.css)
7
+ * el-utilities utility classes (styles/utilities.css)
8
+ *
9
+ * Every stylesheet of the library that uses a layer starts with this
10
+ * statement, so the order is the same whichever of them a page loads first.
11
+ * Import this file on its own only to place the layers among your own, for
12
+ * example before the layers of another library:
13
+ *
14
+ * import '@webtides/element-library/styles/layers.css';
15
+ *
16
+ * What a layer buys: a rule of the page that is in no layer wins over it
17
+ * whatever its specificity or position. `:root { --el-color-accent: … }` in
18
+ * your own stylesheet overrides a theme, also when it is loaded before the
19
+ * theme.
20
+ *
21
+ * Two things are in no layer, because a layer loses against every rule of the
22
+ * page that is in none, a reset included:
23
+ *
24
+ * - styles/native.css. A reset would take the border and the padding of the
25
+ * controls away again.
26
+ * - The styles of the components. element-js adopts the stylesheets of the
27
+ * page into every shadow root, where a component in a layer would lose
28
+ * against any rule of the page.
29
+ */
30
+
31
+ @layer el-tokens, el-utilities;