@webtides/element-library 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (398) hide show
  1. package/CHANGELOG.md +399 -3
  2. package/README.md +61 -41
  3. package/all.js +28 -0
  4. package/catalog.d.ts +14 -0
  5. package/catalog.js +55 -27
  6. package/custom-elements.json +16676 -3457
  7. package/package.json +35 -28
  8. package/src/components/accordion/accordion.changelog.md +10 -0
  9. package/src/components/accordion/accordion.js +10 -7
  10. package/src/components/accordion/accordion.readme.md +2 -0
  11. package/src/components/accordion/accordion.style.js +8 -0
  12. package/src/components/amount-field/amount-field.changelog.md +23 -3
  13. package/src/components/amount-field/amount-field.js +53 -26
  14. package/src/components/amount-field/amount-field.readme.md +82 -20
  15. package/src/components/amount-field/amount-field.style.js +111 -47
  16. package/src/components/avatar/avatar.changelog.md +23 -0
  17. package/src/components/avatar/avatar.define.js +3 -0
  18. package/src/components/avatar/avatar.js +115 -0
  19. package/src/components/avatar/avatar.readme.md +132 -0
  20. package/src/components/avatar/avatar.style.js +67 -0
  21. package/src/components/badge/badge.changelog.md +23 -0
  22. package/src/components/badge/badge.define.js +3 -0
  23. package/src/components/badge/badge.js +59 -0
  24. package/src/components/badge/badge.readme.md +109 -0
  25. package/src/components/badge/badge.style.js +63 -0
  26. package/src/components/breadcrumb/breadcrumb.changelog.md +22 -0
  27. package/src/components/breadcrumb/breadcrumb.define.js +3 -0
  28. package/src/components/breadcrumb/breadcrumb.js +47 -0
  29. package/src/components/breadcrumb/breadcrumb.readme.md +108 -0
  30. package/src/components/breadcrumb/breadcrumb.style.js +20 -0
  31. package/src/components/breadcrumb-item/breadcrumb-item.changelog.md +23 -0
  32. package/src/components/breadcrumb-item/breadcrumb-item.define.js +3 -0
  33. package/src/components/breadcrumb-item/breadcrumb-item.js +82 -0
  34. package/src/components/breadcrumb-item/breadcrumb-item.readme.md +106 -0
  35. package/src/components/breadcrumb-item/breadcrumb-item.style.js +92 -0
  36. package/src/components/button/button.changelog.md +44 -1
  37. package/src/components/button/button.js +338 -29
  38. package/src/components/button/button.readme.md +138 -10
  39. package/src/components/button/button.style.js +99 -120
  40. package/src/components/button-group/button-group.changelog.md +24 -0
  41. package/src/components/button-group/button-group.define.js +3 -0
  42. package/src/components/button-group/button-group.js +53 -0
  43. package/src/components/button-group/button-group.readme.md +114 -0
  44. package/src/components/button-group/button-group.style.js +41 -0
  45. package/src/components/card/card.changelog.md +23 -0
  46. package/src/components/card/card.define.js +3 -0
  47. package/src/components/card/card.js +73 -0
  48. package/src/components/card/card.readme.md +136 -0
  49. package/src/components/card/card.style.js +99 -0
  50. package/src/components/carousel/carousel.changelog.md +20 -0
  51. package/src/components/carousel/carousel.js +89 -40
  52. package/src/components/carousel/carousel.readme.md +39 -6
  53. package/src/components/carousel/carousel.style.js +21 -77
  54. package/src/components/carousel/glide/components/ShadowAnchors.js +3 -1
  55. package/src/components/carousel/glide/components/ShadowClones.js +21 -24
  56. package/src/components/carousel/glide/components/ShadowGaps.js +2 -2
  57. package/src/components/carousel/glide/components/ShadowHtml.js +22 -3
  58. package/src/components/checkbox-field/checkbox-field.changelog.md +25 -0
  59. package/src/components/checkbox-field/checkbox-field.js +32 -11
  60. package/src/components/checkbox-field/checkbox-field.readme.md +17 -4
  61. package/src/components/checkbox-field/checkbox-field.style.js +15 -3
  62. package/src/components/checkbox-group-field/checkbox-group-field.changelog.md +25 -0
  63. package/src/components/checkbox-group-field/checkbox-group-field.define.js +3 -0
  64. package/src/components/checkbox-group-field/checkbox-group-field.js +217 -0
  65. package/src/components/checkbox-group-field/checkbox-group-field.readme.md +95 -0
  66. package/src/components/checkbox-group-field/checkbox-group-field.style.js +62 -0
  67. package/src/components/color-field/color-field.changelog.md +24 -0
  68. package/src/components/color-field/color-field.define.js +3 -0
  69. package/src/components/color-field/color-field.js +184 -0
  70. package/src/components/color-field/color-field.readme.md +95 -0
  71. package/src/components/color-field/color-field.style.js +39 -0
  72. package/src/components/combobox-field/combobox-field.changelog.md +23 -0
  73. package/src/components/combobox-field/combobox-field.define.js +3 -0
  74. package/src/components/combobox-field/combobox-field.js +97 -0
  75. package/src/components/combobox-field/combobox-field.readme.md +93 -0
  76. package/src/components/combobox-field/combobox-field.style.js +56 -0
  77. package/src/components/copy-button/copy-button.changelog.md +24 -0
  78. package/src/components/copy-button/copy-button.define.js +3 -0
  79. package/src/components/copy-button/copy-button.events.js +4 -0
  80. package/src/components/copy-button/copy-button.js +237 -0
  81. package/src/components/copy-button/copy-button.readme.md +134 -0
  82. package/src/components/copy-button/copy-button.style.js +109 -0
  83. package/src/components/date-field/date-field.changelog.md +24 -0
  84. package/src/components/date-field/date-field.define.js +3 -0
  85. package/src/components/date-field/date-field.js +119 -0
  86. package/src/components/date-field/date-field.readme.md +110 -0
  87. package/src/components/date-field/date-field.style.js +53 -0
  88. package/src/components/dialog/dialog.changelog.md +16 -1
  89. package/src/components/dialog/dialog.js +252 -57
  90. package/src/components/dialog/dialog.readme.md +36 -4
  91. package/src/components/dialog/dialog.style.js +9 -109
  92. package/src/components/divider/divider.changelog.md +23 -0
  93. package/src/components/divider/divider.define.js +3 -0
  94. package/src/components/divider/divider.js +48 -0
  95. package/src/components/divider/divider.readme.md +101 -0
  96. package/src/components/divider/divider.style.js +50 -0
  97. package/src/components/drawer/drawer.changelog.md +25 -0
  98. package/src/components/drawer/drawer.define.js +3 -0
  99. package/src/components/drawer/drawer.events.js +8 -0
  100. package/src/components/drawer/drawer.js +80 -0
  101. package/src/components/drawer/drawer.readme.md +194 -0
  102. package/src/components/drawer/drawer.style.js +83 -0
  103. package/src/components/dropdown/dropdown.js +9 -7
  104. package/src/components/empty-state/empty-state.changelog.md +22 -0
  105. package/src/components/empty-state/empty-state.define.js +3 -0
  106. package/src/components/empty-state/empty-state.js +55 -0
  107. package/src/components/empty-state/empty-state.readme.md +114 -0
  108. package/src/components/empty-state/empty-state.style.js +60 -0
  109. package/src/components/file-field/file-field.changelog.md +24 -0
  110. package/src/components/file-field/file-field.define.js +3 -0
  111. package/src/components/file-field/file-field.js +205 -0
  112. package/src/components/file-field/file-field.readme.md +103 -0
  113. package/src/components/file-field/file-field.style.js +28 -0
  114. package/src/components/form-field/form-field.changelog.md +25 -0
  115. package/src/components/form-field/form-field.js +212 -15
  116. package/src/components/form-field/form-field.readme.md +82 -18
  117. package/src/components/form-field/form-field.style.js +6 -24
  118. package/src/components/input-field/input-field.changelog.md +24 -0
  119. package/src/components/input-field/input-field.js +82 -6
  120. package/src/components/input-field/input-field.readme.md +34 -5
  121. package/src/components/input-field/input-field.style.js +32 -13
  122. package/src/components/notification/notification.changelog.md +21 -1
  123. package/src/components/notification/notification.js +80 -74
  124. package/src/components/notification/notification.readme.md +54 -13
  125. package/src/components/notification/notification.style.js +37 -22
  126. package/src/components/otp-field/otp-field.changelog.md +23 -0
  127. package/src/components/otp-field/otp-field.define.js +3 -0
  128. package/src/components/otp-field/otp-field.events.js +3 -0
  129. package/src/components/otp-field/otp-field.js +172 -0
  130. package/src/components/otp-field/otp-field.readme.md +111 -0
  131. package/src/components/otp-field/otp-field.style.js +53 -0
  132. package/src/components/pagination/pagination.changelog.md +30 -0
  133. package/src/components/pagination/pagination.define.js +3 -0
  134. package/src/components/pagination/pagination.events.js +3 -0
  135. package/src/components/pagination/pagination.js +282 -0
  136. package/src/components/pagination/pagination.readme.md +167 -0
  137. package/src/components/pagination/pagination.style.js +162 -0
  138. package/src/components/password-field/password-field.changelog.md +24 -0
  139. package/src/components/password-field/password-field.js +7 -1
  140. package/src/components/password-field/password-field.readme.md +15 -6
  141. package/src/components/password-field/password-field.style.js +36 -13
  142. package/src/components/popover/popover.changelog.md +24 -0
  143. package/src/components/popover/popover.define.js +3 -0
  144. package/src/components/popover/popover.events.js +4 -0
  145. package/src/components/popover/popover.js +255 -0
  146. package/src/components/popover/popover.readme.md +132 -0
  147. package/src/components/popover/popover.style.js +41 -0
  148. package/src/components/progress-bar/progress-bar.changelog.md +23 -0
  149. package/src/components/progress-bar/progress-bar.define.js +3 -0
  150. package/src/components/progress-bar/progress-bar.js +80 -0
  151. package/src/components/progress-bar/progress-bar.readme.md +110 -0
  152. package/src/components/progress-bar/progress-bar.style.js +93 -0
  153. package/src/components/progress-ring/progress-ring.changelog.md +23 -0
  154. package/src/components/progress-ring/progress-ring.define.js +3 -0
  155. package/src/components/progress-ring/progress-ring.js +83 -0
  156. package/src/components/progress-ring/progress-ring.readme.md +115 -0
  157. package/src/components/progress-ring/progress-ring.style.js +85 -0
  158. package/src/components/radio-field/radio-field.changelog.md +16 -0
  159. package/src/components/radio-field/radio-field.js +34 -11
  160. package/src/components/radio-field/radio-field.readme.md +13 -8
  161. package/src/components/radio-field/radio-field.style.js +17 -65
  162. package/src/components/range-field/range-field.changelog.md +24 -0
  163. package/src/components/range-field/range-field.define.js +3 -0
  164. package/src/components/range-field/range-field.js +167 -0
  165. package/src/components/range-field/range-field.readme.md +87 -0
  166. package/src/components/range-field/range-field.style.js +41 -0
  167. package/src/components/rating-field/rating-field.changelog.md +24 -0
  168. package/src/components/rating-field/rating-field.define.js +3 -0
  169. package/src/components/rating-field/rating-field.js +195 -0
  170. package/src/components/rating-field/rating-field.readme.md +82 -0
  171. package/src/components/rating-field/rating-field.style.js +79 -0
  172. package/src/components/select-field/select-field.changelog.md +17 -0
  173. package/src/components/select-field/select-field.js +100 -8
  174. package/src/components/select-field/select-field.readme.md +32 -6
  175. package/src/components/select-field/select-field.style.js +19 -9
  176. package/src/components/skeleton/skeleton.changelog.md +22 -0
  177. package/src/components/skeleton/skeleton.define.js +3 -0
  178. package/src/components/skeleton/skeleton.js +49 -0
  179. package/src/components/skeleton/skeleton.readme.md +115 -0
  180. package/src/components/skeleton/skeleton.style.js +79 -0
  181. package/src/components/slider/slider.changelog.md +15 -0
  182. package/src/components/slider/slider.js +37 -5
  183. package/src/components/slider/slider.readme.md +28 -6
  184. package/src/components/slider/slider.style.js +7 -71
  185. package/src/components/spinner/spinner.changelog.md +22 -0
  186. package/src/components/spinner/spinner.define.js +3 -0
  187. package/src/components/spinner/spinner.js +48 -0
  188. package/src/components/spinner/spinner.readme.md +98 -0
  189. package/src/components/spinner/spinner.style.js +44 -0
  190. package/src/components/switch-field/switch-field.changelog.md +22 -0
  191. package/src/components/switch-field/switch-field.js +24 -10
  192. package/src/components/switch-field/switch-field.readme.md +11 -4
  193. package/src/components/switch-field/switch-field.style.js +13 -13
  194. package/src/components/tab-group/tab-group.changelog.md +19 -0
  195. package/src/components/tab-group/tab-group.js +122 -10
  196. package/src/components/tab-group/tab-group.readme.md +25 -4
  197. package/src/components/tab-link/tab-link.changelog.md +16 -0
  198. package/src/components/tab-link/tab-link.js +51 -8
  199. package/src/components/tab-link/tab-link.readme.md +14 -8
  200. package/src/components/tab-link/tab-link.style.js +13 -0
  201. package/src/components/tab-panel/tab-panel.changelog.md +8 -2
  202. package/src/components/tab-panel/tab-panel.js +7 -3
  203. package/src/components/tab-panel/tab-panel.readme.md +7 -5
  204. package/src/components/tag/tag.changelog.md +24 -0
  205. package/src/components/tag/tag.define.js +3 -0
  206. package/src/components/tag/tag.events.js +3 -0
  207. package/src/components/tag/tag.js +116 -0
  208. package/src/components/tag/tag.readme.md +119 -0
  209. package/src/components/tag/tag.style.js +101 -0
  210. package/src/components/tag-field/tag-field.changelog.md +25 -0
  211. package/src/components/tag-field/tag-field.define.js +3 -0
  212. package/src/components/tag-field/tag-field.js +359 -0
  213. package/src/components/tag-field/tag-field.readme.md +113 -0
  214. package/src/components/tag-field/tag-field.style.js +62 -0
  215. package/src/components/textarea-field/textarea-field.changelog.md +28 -4
  216. package/src/components/textarea-field/textarea-field.js +68 -14
  217. package/src/components/textarea-field/textarea-field.readme.md +45 -9
  218. package/src/components/textarea-field/textarea-field.style.js +45 -2
  219. package/src/components/toast/toast.changelog.md +24 -0
  220. package/src/components/toast/toast.define.js +3 -0
  221. package/src/components/toast/toast.js +193 -0
  222. package/src/components/toast/toast.readme.md +189 -0
  223. package/src/components/toast/toast.style.js +74 -0
  224. package/src/components/tooltip/tooltip.changelog.md +24 -0
  225. package/src/components/tooltip/tooltip.define.js +3 -0
  226. package/src/components/tooltip/tooltip.events.js +4 -0
  227. package/src/components/tooltip/tooltip.js +377 -0
  228. package/src/components/tooltip/tooltip.readme.md +172 -0
  229. package/src/components/tooltip/tooltip.style.js +107 -0
  230. package/src/components/transition-classes/transition-classes.js +6 -6
  231. package/src/styles/appearance.style.js +42 -0
  232. package/src/styles/arrow.style.js +65 -0
  233. package/src/styles/choice-group.style.js +94 -0
  234. package/src/styles/form-control.style.js +79 -0
  235. package/src/styles/host.style.js +55 -0
  236. package/src/styles/layers.css +31 -0
  237. package/src/styles/modal.style.js +146 -0
  238. package/src/styles/native.css +275 -0
  239. package/src/styles/size.style.js +48 -0
  240. package/src/styles/slide-controls.style.js +225 -0
  241. package/src/styles/utilities.css +30 -0
  242. package/src/styles/variants.style.js +78 -0
  243. package/src/themes/default.css +86 -142
  244. package/src/themes/high-contrast.css +72 -129
  245. package/src/themes/sketchy.css +95 -175
  246. package/src/utils/floating.js +71 -0
  247. package/src/utils/focus.js +18 -0
  248. package/src/utils/progress.js +25 -0
  249. package/src/utils/slots.js +21 -0
  250. package/src/utils/text-entry-attributes.js +51 -0
  251. package/types/all.d.ts +54 -1
  252. package/types/index.d.ts +1 -0
  253. package/types/src/components/accordion/accordion.d.ts +6 -4
  254. package/types/src/components/accordion/accordion.events.d.ts +3 -3
  255. package/types/src/components/accordion-group/accordion-group.d.ts +4 -3
  256. package/types/src/components/amount-field/amount-field.d.ts +30 -16
  257. package/types/src/components/avatar/avatar.d.ts +57 -0
  258. package/types/src/components/avatar/avatar.define.d.ts +1 -0
  259. package/types/src/components/avatar/avatar.style.d.ts +2 -0
  260. package/types/src/components/badge/badge.d.ts +32 -0
  261. package/types/src/components/badge/badge.define.d.ts +1 -0
  262. package/types/src/components/badge/badge.style.d.ts +2 -0
  263. package/types/src/components/breadcrumb/breadcrumb.d.ts +27 -0
  264. package/types/src/components/breadcrumb/breadcrumb.define.d.ts +1 -0
  265. package/types/src/components/breadcrumb/breadcrumb.style.d.ts +2 -0
  266. package/types/src/components/breadcrumb-item/breadcrumb-item.d.ts +38 -0
  267. package/types/src/components/breadcrumb-item/breadcrumb-item.define.d.ts +1 -0
  268. package/types/src/components/breadcrumb-item/breadcrumb-item.style.d.ts +2 -0
  269. package/types/src/components/button/button.d.ts +158 -14
  270. package/types/src/components/button-group/button-group.d.ts +28 -0
  271. package/types/src/components/button-group/button-group.define.d.ts +1 -0
  272. package/types/src/components/button-group/button-group.style.d.ts +2 -0
  273. package/types/src/components/card/card.d.ts +40 -0
  274. package/types/src/components/card/card.define.d.ts +1 -0
  275. package/types/src/components/card/card.style.d.ts +2 -0
  276. package/types/src/components/carousel/carousel.d.ts +22 -8
  277. package/types/src/components/carousel/carousel.events.d.ts +3 -3
  278. package/types/src/components/carousel/glide/components/ShadowAnchors.d.ts +1 -1
  279. package/types/src/components/carousel/glide/components/ShadowClones.d.ts +8 -1
  280. package/types/src/components/carousel/glide/components/ShadowGaps.d.ts +1 -1
  281. package/types/src/components/carousel/glide/components/ShadowHtml.d.ts +1 -1
  282. package/types/src/components/carousel/glide/components/glide-html.d.ts +1 -1
  283. package/types/src/components/checkbox-field/checkbox-field.d.ts +22 -15
  284. package/types/src/components/checkbox-group-field/checkbox-group-field.d.ts +100 -0
  285. package/types/src/components/checkbox-group-field/checkbox-group-field.define.d.ts +1 -0
  286. package/types/src/components/checkbox-group-field/checkbox-group-field.style.d.ts +2 -0
  287. package/types/src/components/color-field/color-field.d.ts +102 -0
  288. package/types/src/components/color-field/color-field.define.d.ts +1 -0
  289. package/types/src/components/color-field/color-field.style.d.ts +2 -0
  290. package/types/src/components/combobox-field/combobox-field.d.ts +84 -0
  291. package/types/src/components/combobox-field/combobox-field.define.d.ts +1 -0
  292. package/types/src/components/combobox-field/combobox-field.style.d.ts +2 -0
  293. package/types/src/components/copy-button/copy-button.d.ts +93 -0
  294. package/types/src/components/copy-button/copy-button.define.d.ts +1 -0
  295. package/types/src/components/copy-button/copy-button.events.d.ts +5 -0
  296. package/types/src/components/copy-button/copy-button.style.d.ts +2 -0
  297. package/types/src/components/date-field/date-field.d.ts +102 -0
  298. package/types/src/components/date-field/date-field.define.d.ts +1 -0
  299. package/types/src/components/date-field/date-field.style.d.ts +2 -0
  300. package/types/src/components/dialog/dialog.d.ts +101 -19
  301. package/types/src/components/dialog/dialog.events.d.ts +8 -8
  302. package/types/src/components/divider/divider.d.ts +27 -0
  303. package/types/src/components/divider/divider.define.d.ts +1 -0
  304. package/types/src/components/divider/divider.style.d.ts +2 -0
  305. package/types/src/components/drawer/drawer.d.ts +70 -0
  306. package/types/src/components/drawer/drawer.define.d.ts +1 -0
  307. package/types/src/components/drawer/drawer.events.d.ts +9 -0
  308. package/types/src/components/drawer/drawer.style.d.ts +2 -0
  309. package/types/src/components/dropdown/dropdown.d.ts +5 -3
  310. package/types/src/components/empty-state/empty-state.d.ts +29 -0
  311. package/types/src/components/empty-state/empty-state.define.d.ts +1 -0
  312. package/types/src/components/empty-state/empty-state.style.d.ts +2 -0
  313. package/types/src/components/file-field/file-field.d.ts +115 -0
  314. package/types/src/components/file-field/file-field.define.d.ts +1 -0
  315. package/types/src/components/file-field/file-field.style.d.ts +2 -0
  316. package/types/src/components/form-field/form-field.d.ts +129 -14
  317. package/types/src/components/form-field/form-field.events.d.ts +4 -4
  318. package/types/src/components/input-field/input-field.d.ts +52 -5
  319. package/types/src/components/lazy-src/lazy-src.d.ts +7 -5
  320. package/types/src/components/lazy-src/lazy-src.events.d.ts +5 -5
  321. package/types/src/components/notification/notification.d.ts +18 -18
  322. package/types/src/components/notification/notification.events.d.ts +6 -6
  323. package/types/src/components/otp-field/otp-field.d.ts +130 -0
  324. package/types/src/components/otp-field/otp-field.define.d.ts +1 -0
  325. package/types/src/components/otp-field/otp-field.events.d.ts +4 -0
  326. package/types/src/components/otp-field/otp-field.style.d.ts +2 -0
  327. package/types/src/components/pagination/pagination.d.ts +117 -0
  328. package/types/src/components/pagination/pagination.define.d.ts +1 -0
  329. package/types/src/components/pagination/pagination.events.d.ts +4 -0
  330. package/types/src/components/pagination/pagination.style.d.ts +2 -0
  331. package/types/src/components/password-field/password-field.d.ts +29 -12
  332. package/types/src/components/popover/popover.d.ts +123 -0
  333. package/types/src/components/popover/popover.define.d.ts +1 -0
  334. package/types/src/components/popover/popover.events.d.ts +5 -0
  335. package/types/src/components/popover/popover.style.d.ts +2 -0
  336. package/types/src/components/progress-bar/progress-bar.d.ts +35 -0
  337. package/types/src/components/progress-bar/progress-bar.define.d.ts +1 -0
  338. package/types/src/components/progress-bar/progress-bar.style.d.ts +2 -0
  339. package/types/src/components/progress-ring/progress-ring.d.ts +40 -0
  340. package/types/src/components/progress-ring/progress-ring.define.d.ts +1 -0
  341. package/types/src/components/progress-ring/progress-ring.style.d.ts +2 -0
  342. package/types/src/components/radio-field/radio-field.d.ts +21 -9
  343. package/types/src/components/range-field/range-field.d.ts +94 -0
  344. package/types/src/components/range-field/range-field.define.d.ts +1 -0
  345. package/types/src/components/range-field/range-field.style.d.ts +2 -0
  346. package/types/src/components/rating-field/rating-field.d.ts +96 -0
  347. package/types/src/components/rating-field/rating-field.define.d.ts +1 -0
  348. package/types/src/components/rating-field/rating-field.style.d.ts +2 -0
  349. package/types/src/components/scroll-to/scroll-to.d.ts +3 -2
  350. package/types/src/components/scroll-to-top/scroll-to-top.d.ts +4 -2
  351. package/types/src/components/select-field/select-field.d.ts +55 -5
  352. package/types/src/components/skeleton/skeleton.d.ts +29 -0
  353. package/types/src/components/skeleton/skeleton.define.d.ts +1 -0
  354. package/types/src/components/skeleton/skeleton.style.d.ts +2 -0
  355. package/types/src/components/slider/slider.d.ts +14 -8
  356. package/types/src/components/slider/slider.events.d.ts +4 -4
  357. package/types/src/components/spinner/spinner.d.ts +28 -0
  358. package/types/src/components/spinner/spinner.define.d.ts +1 -0
  359. package/types/src/components/spinner/spinner.style.d.ts +2 -0
  360. package/types/src/components/sticky/sticky.d.ts +4 -2
  361. package/types/src/components/svg-use/svg-use.d.ts +4 -2
  362. package/types/src/components/switch-field/switch-field.d.ts +17 -15
  363. package/types/src/components/tab-group/tab-group.d.ts +44 -3
  364. package/types/src/components/tab-link/tab-link.d.ts +33 -10
  365. package/types/src/components/tab-panel/tab-panel.d.ts +8 -5
  366. package/types/src/components/tag/tag.d.ts +53 -0
  367. package/types/src/components/tag/tag.define.d.ts +1 -0
  368. package/types/src/components/tag/tag.events.d.ts +4 -0
  369. package/types/src/components/tag/tag.style.d.ts +2 -0
  370. package/types/src/components/tag-field/tag-field.d.ts +178 -0
  371. package/types/src/components/tag-field/tag-field.define.d.ts +1 -0
  372. package/types/src/components/tag-field/tag-field.style.d.ts +2 -0
  373. package/types/src/components/textarea-field/textarea-field.d.ts +44 -4
  374. package/types/src/components/toast/toast.d.ts +110 -0
  375. package/types/src/components/toast/toast.define.d.ts +1 -0
  376. package/types/src/components/toast/toast.style.d.ts +2 -0
  377. package/types/src/components/tooltip/tooltip.d.ts +161 -0
  378. package/types/src/components/tooltip/tooltip.define.d.ts +1 -0
  379. package/types/src/components/tooltip/tooltip.events.d.ts +5 -0
  380. package/types/src/components/tooltip/tooltip.style.d.ts +2 -0
  381. package/types/src/components/transition-classes/transition-classes.d.ts +9 -8
  382. package/types/src/styles/appearance.style.d.ts +18 -0
  383. package/types/src/styles/arrow.style.d.ts +15 -0
  384. package/types/src/styles/choice-group.style.d.ts +23 -0
  385. package/types/src/styles/form-control.style.d.ts +26 -0
  386. package/types/src/styles/host.style.d.ts +24 -0
  387. package/types/src/styles/modal.style.d.ts +20 -0
  388. package/types/src/styles/size.style.d.ts +20 -0
  389. package/types/src/styles/slide-controls.style.d.ts +20 -0
  390. package/types/src/styles/variants.style.d.ts +32 -0
  391. package/types/src/utils/body-scroll.d.ts +12 -2
  392. package/types/src/utils/floating.d.ts +36 -0
  393. package/types/src/utils/focus.d.ts +16 -0
  394. package/types/src/utils/progress.d.ts +19 -0
  395. package/types/src/utils/slots.d.ts +19 -0
  396. package/types/src/utils/text-entry-attributes.d.ts +18 -0
  397. package/types/src/utils/transitions.d.ts +2 -2
  398. package/web-types.json +6590 -1584
@@ -0,0 +1,189 @@
1
+ # Toast
2
+
3
+ `toast` is the region of a page where toasts appear: short messages about something that has just happened, which come by themselves and leave by themselves. A toast is an [`el-notification`](../notification/notification.readme.md). The region gives it its place at an edge of the viewport, puts several of them into a stack and lets no more than `max` of them show at once; the rest wait for their turn.
4
+
5
+ ## How to use
6
+
7
+ #### Install
8
+
9
+ ```sh
10
+ npm i --save @webtides/element-library
11
+ ```
12
+
13
+ #### Use
14
+
15
+ With the function, which needs no element in the page:
16
+
17
+ ```js
18
+ import { toast } from '@webtides/element-library/toast';
19
+
20
+ toast('Your changes are saved.', { variant: 'success' });
21
+ ```
22
+
23
+ Or with a region of your own, for a place and a limit:
24
+
25
+ ```js
26
+ import '@webtides/element-library/toast/define';
27
+ ```
28
+
29
+ ```html
30
+ <el-toast placement="bottom" max="3"></el-toast>
31
+ ```
32
+
33
+ ```js
34
+ document.querySelector('el-toast').toast('Your changes are saved.', { variant: 'success' });
35
+ ```
36
+
37
+ The function uses the first `el-toast` of the document. A page without one gets one at the end of its body, with the defaults.
38
+
39
+ ## API
40
+
41
+ #### Properties/Attributes
42
+
43
+ | Name | Type | Default | Description |
44
+ | --- | --- | --- | --- |
45
+ | `placement` | `string` | `'top-end'` | `top-start`, `top`, `top-end`, `bottom-start`, `bottom` or `bottom-end`: the edge of the viewport the toasts appear at, and the corner. Reflected. |
46
+ | `max` | `number` | `Infinity` | How many toasts show at once. The ones beyond that wait until a place is free. |
47
+ | `label` | `string` | `'Notifications'` | The name of the landmark. |
48
+
49
+ #### Methods
50
+
51
+ | Name | Returns | Description |
52
+ | -------------------------- | ------------- | ------------------------------------------------------------- |
53
+ | `toast(message, options?)` | `HTMLElement` | Shows a message as a toast and returns its `el-notification`. |
54
+
55
+ The module exports a function of the same name and with the same arguments: `import { toast } from '@webtides/element-library/toast'`.
56
+
57
+ | Argument | Type | Description |
58
+ | --- | --- | --- |
59
+ | `message` | `string \| Node` | A text, a node for a message with markup, or an `el-notification` that is shown as it is. |
60
+ | `options.variant` | `string` | The variant of the notification: `neutral`, `brand`, `success`, `warning` or `danger`, as on `el-button`. |
61
+ | `options.duration` | `number` | How long the toast stays, in milliseconds. `Infinity` keeps it until it is closed. Default `5000` for a text or a node. |
62
+ | `options.closable` | `boolean` | Whether the toast has a close button. Default `true` for a text or a node. |
63
+ | `options.closeLabel` | `string` | The accessible label of the close button. |
64
+
65
+ #### Events
66
+
67
+ _None of its own._ A toast fires the events of a notification (`notification-show`, `notification-after-show`, `notification-hide`, `notification-after-hide`), which bubble through the region.
68
+
69
+ #### Slots
70
+
71
+ | Name | Description |
72
+ | ----------- | ----------------------------------------------------------------- |
73
+ | _(default)_ | The toasts, `el-notification` elements. `toast()` puts them here. |
74
+
75
+ #### CSS Parts
76
+
77
+ | Name | Description |
78
+ | ------ | --------------------------------------------------------------------- |
79
+ | `base` | The stack of the toasts. It is the landmark with the name in `label`. |
80
+
81
+ #### CSS Custom Properties
82
+
83
+ | Name | Description |
84
+ | ------------------ | -------------------------------------------------------------------------------------- |
85
+ | `--el-toast-inset` | The distance of the stack from the edges of the viewport. Unset, it is `--el-space-4`. |
86
+
87
+ Reads the standard library design tokens `--el-space-4` and `--el-space-2` (the gap between two toasts). The look of a toast is the look of `el-notification`.
88
+
89
+ ## A toast
90
+
91
+ `toast()` takes a text, or a node for a message with markup, and makes a notification of it that can be closed and leaves by itself after five seconds. The options change that:
92
+
93
+ ```js
94
+ // Stays until it is closed
95
+ toast('The connection is lost.', { variant: 'danger', duration: Infinity });
96
+
97
+ // With markup
98
+ const message = document.createElement('span');
99
+ message.innerHTML = 'Moved to <strong>Archive</strong>.';
100
+ toast(message);
101
+ ```
102
+
103
+ Never put text from a user into `innerHTML`. A text that is passed as a string is shown as text.
104
+
105
+ An `el-notification` is shown as it is, with its own variant, icon and duration; options are set on top of it:
106
+
107
+ ```js
108
+ const note = document.createElement('el-notification');
109
+ note.variant = 'brand';
110
+ note.innerHTML = '<svg slot="icon" …></svg>You have a new message.';
111
+ toast(note, { duration: 8000 });
112
+ ```
113
+
114
+ `toast()` returns the notification. `hide()` on it takes the toast away early, and it fires the events of a notification:
115
+
116
+ ```js
117
+ const saving = toast('Saving …', { duration: Infinity, closable: false });
118
+ await save();
119
+ saving.hide();
120
+ ```
121
+
122
+ A toast that has left is taken out of the page. The countdown of a toast stops while the pointer or the focus is on it, as that of every notification does.
123
+
124
+ ## Places and the stack
125
+
126
+ | `placement` | Where the toasts appear |
127
+ | -------------- | --------------------------------------- |
128
+ | `top-start` | At the top, at the start of the line |
129
+ | `top` | At the top, in the middle |
130
+ | `top-end` | At the top, at the end. The default. |
131
+ | `bottom-start` | At the bottom, at the start of the line |
132
+ | `bottom` | At the bottom, in the middle |
133
+ | `bottom-end` | At the bottom, at the end |
134
+
135
+ Start and end follow the reading direction: in a text that runs from right to left the start is at the right.
136
+
137
+ The first toast is at the edge, the next ones follow towards the middle of the viewport. The stack keeps a distance of `--el-toast-inset` from the edges and is never wider than the viewport between these distances: on a phone a toast is as wide as the screen allows and its text wraps.
138
+
139
+ The region lets the pointer through: what is beside and between the toasts can be clicked.
140
+
141
+ ## More toasts than places
142
+
143
+ With `max` the region shows no more than that many toasts at once. A toast beyond that waits, in the order the toasts came, and is shown when a place is free: when a toast before it is gone, not when it starts to leave.
144
+
145
+ A toast that stays until it is closed (`duration: Infinity`) and cannot be closed keeps its place until a script hides it. With a limit, the toasts behind it wait that long.
146
+
147
+ Without `max` there is no limit, and a `max` that is no number of at least 1 counts as none.
148
+
149
+ ## The top layer
150
+
151
+ While it has toasts the element is a native popover of the platform (`popover="manual"`), which owns the top layer: nothing of the page lies on top of a toast, whatever `z-index` it has. Without toasts the region is not shown.
152
+
153
+ The top layer is a stack: what is opened later lies above. Every new toast brings the region to the front, so a toast lies above a dialog or a popover that was opened before it. What is opened afterwards lies above the toasts that are shown, until the next one comes.
154
+
155
+ **In a modal dialog.** An open modal dialog makes the rest of the page inert, a region outside of the dialog included: its toasts can be seen but not clicked, and assistive technology does not reach them. A dialog that shows toasts while it is open has a region of its own inside:
156
+
157
+ ```html
158
+ <el-dialog label="Settings">
159
+ …
160
+ <el-toast placement="bottom"></el-toast>
161
+ </el-dialog>
162
+ ```
163
+
164
+ ```js
165
+ dialog.querySelector('el-toast').toast('Saved.', { variant: 'success' });
166
+ ```
167
+
168
+ ## Toasts in the markup
169
+
170
+ A notification that the page puts into the region itself is a toast like any other: the region shows itself for it, counts it as a place that is taken and takes it out of the page when it has left.
171
+
172
+ ```html
173
+ <el-toast>
174
+ <el-notification open="true" variant="success" closable="true">Welcome back.</el-notification>
175
+ </el-toast>
176
+ ```
177
+
178
+ ## Accessibility
179
+
180
+ - The stack is a landmark (`role="region"`) with the name in `label`, by which a screen reader finds the toasts. It is there only while there are toasts.
181
+ - Every toast is a notification and with that a live region of its own: `role="alert"` for `danger` and `warning`, `role="status"` for the others. The region adds no second live region around them.
182
+ - A toast does not take the focus. Its close button is reached with `Tab`, where the region stands in the page: at the end for a region that `toast()` has added.
183
+ - A message that leaves by itself must not be the only place where something is said. Give an error that needs an answer `duration: Infinity`, or show it where the error is.
184
+ - The names are English by default. For another language set `label` on the region and `closeLabel` in the options.
185
+ - There is no `variant` and no `size` on the region: the variant belongs to the toast.
186
+
187
+ ## Server-side rendering
188
+
189
+ The region is part of the server-rendered markup (Declarative Shadow DOM), and so is a notification in it: before the JavaScript has arrived it is shown in its place, as a fixed box. With the element it goes into the top layer, in the same place.
@@ -0,0 +1,74 @@
1
+ import hostStyle from '../../styles/host.style.js';
2
+
3
+ const css = String.raw;
4
+
5
+ const style = css`
6
+ /* The element is the box at the edge of the viewport, and a popover while it has toasts. What
7
+ the platform gives a popover (a centred place, a border, a padding, a background, a scroll
8
+ bar) goes. Before the script has run it is a fixed box in the same place. */
9
+ :host {
10
+ --_el-toast-inset: var(--el-toast-inset, var(--el-space-4, 1rem));
11
+
12
+ position: fixed;
13
+ inset: auto;
14
+ /* The default, top-end. */
15
+ top: var(--_el-toast-inset);
16
+ inset-inline-end: var(--_el-toast-inset);
17
+ /* Never wider than the viewport between the two distances. */
18
+ max-width: calc(100% - 2 * var(--_el-toast-inset));
19
+ padding: 0;
20
+ border: 0;
21
+ background: none;
22
+ color: inherit;
23
+ overflow: visible;
24
+ /* The box lets the pointer through to the page; a notification takes it back. */
25
+ pointer-events: none;
26
+ }
27
+
28
+ :host([placement^='bottom']) {
29
+ top: auto;
30
+ bottom: var(--_el-toast-inset);
31
+ }
32
+
33
+ :host([placement$='-start']) {
34
+ inset-inline-end: auto;
35
+ inset-inline-start: var(--_el-toast-inset);
36
+ }
37
+
38
+ /* In the middle: the box reaches from one side to the other, and the stack puts the toasts
39
+ into its middle. Not with auto margins: a page that resets the margin of every element
40
+ takes them from the host. */
41
+ :host([placement='top']),
42
+ :host([placement='bottom']) {
43
+ inset-inline: var(--_el-toast-inset);
44
+ width: auto;
45
+ }
46
+
47
+ /* The first toast is at the edge, the next ones follow towards the middle of the viewport. */
48
+ .stack {
49
+ display: flex;
50
+ flex-direction: column;
51
+ align-items: flex-end;
52
+ gap: var(--el-space-2, 0.5rem);
53
+ }
54
+
55
+ :host([placement^='bottom']) .stack {
56
+ flex-direction: column-reverse;
57
+ }
58
+
59
+ :host([placement$='-start']) .stack {
60
+ align-items: flex-start;
61
+ }
62
+
63
+ :host([placement='top']) .stack,
64
+ :host([placement='bottom']) .stack {
65
+ align-items: center;
66
+ }
67
+
68
+ /* A toast is no wider than the stack, which is no wider than the viewport. */
69
+ ::slotted(*) {
70
+ max-width: 100%;
71
+ }
72
+ `;
73
+
74
+ export default [hostStyle(), 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-tooltip`: a short text that explains another element, its anchor. It stands next to the anchor in the page and names it by id with `for`, the way a `<label>` names its field. ([#71](https://github.com/webtides/element-library/issues/71))
20
+ - Opens while the pointer rests on the anchor (after `show-delay`, 150 ms by default) or while the anchor has the focus of the keyboard (at once); closes when they leave (after `hide-delay`) or with `Escape`. The pointer can go from the anchor onto the text without the tooltip closing. A finger opens nothing.
21
+ - The tooltip is the description of its anchor for a screen reader (`aria-describedby`), open or closed, also for an `el-button`. It has the role `tooltip`.
22
+ - The element is a native popover of the platform (`popover="manual"`), in the top layer: nothing clips the tooltip or lies on top of it.
23
+ - `placement` (`top`, `bottom`, `left`, `right`, each also with `-start` or `-end`; `top` by default), `distance` (8 px by default) and `arrow`, as for `el-popover`. The tooltip goes to the opposite side when it has no room, stays inside the viewport, and follows its anchor while it is open.
24
+ - `open` (reflected, with the `open` custom state), `show()` and `hide()`, and the events `tooltip-show` and `tooltip-hide`. With `disabled` the pointer and the focus neither open nor close the tooltip, and it is left to a script.
@@ -0,0 +1,3 @@
1
+ import { define } from './tooltip.js';
2
+
3
+ define();
@@ -0,0 +1,4 @@
1
+ export default {
2
+ SHOW: 'tooltip-show',
3
+ HIDE: 'tooltip-hide',
4
+ };
@@ -0,0 +1,377 @@
1
+ import { TemplateElement, defineElement, html } from '@webtides/element-js';
2
+ import style from './tooltip.style.js';
3
+ import Events from './tooltip.events.js';
4
+ import { followAnchor, placeAtAnchor } from '../../utils/floating.js';
5
+
6
+ /** For the ids of the tooltips that have none of their own. */
7
+ let count = 0;
8
+
9
+ /**
10
+ * Whether the element that has the focus shows it, which a browser does for the keyboard and not
11
+ * for a click on a button. The question goes to the innermost element with the focus: a custom
12
+ * element with the focus on a control inside its shadow root does not match `:focus-visible` itself.
13
+ * @returns {boolean}
14
+ */
15
+ function focusIsVisible() {
16
+ let active = document.activeElement;
17
+ while (active?.shadowRoot?.activeElement) active = active.shadowRoot.activeElement;
18
+ return !!active?.matches(':focus-visible');
19
+ }
20
+
21
+ /**
22
+ * A short text that explains another element, its anchor. It appears next to the anchor while the
23
+ * pointer is over it or while it has the focus of the keyboard, and `Escape` closes it. The
24
+ * tooltip names its anchor by id with `for`, the way a `<label>` does, and is the description of
25
+ * that element for a screen reader (`aria-describedby`), open or not.
26
+ *
27
+ * The element is a native popover of the platform (`popover="manual"`), which owns the top layer:
28
+ * nothing clips the tooltip or lies on top of it. The component adds the opening and closing and
29
+ * the place: at the side of the anchor that `placement` names, on the other side when there is no
30
+ * room, and never outside the viewport.
31
+ *
32
+ * @element el-tooltip
33
+ *
34
+ * @fires {CustomEvent} tooltip-show - Fired when the tooltip has opened.
35
+ * @fires {CustomEvent} tooltip-hide - Fired when the tooltip has closed.
36
+ *
37
+ * @slot - The text of the tooltip.
38
+ *
39
+ * @csspart body - The surface of the tooltip: background, text colour, padding, radius.
40
+ * @csspart arrow - The arrow that points to the anchor, present only while `arrow` is `true`.
41
+ *
42
+ * @cssstate open - Set while the tooltip is shown. Style with `:host(:state(open))` or
43
+ * `el-tooltip:state(open)` from outside.
44
+ *
45
+ * @property {string} for - The id of the anchor: the element the tooltip explains and opens from.
46
+ * It is looked up in the document or the shadow root the tooltip is in.
47
+ * @property {boolean} open - Whether the tooltip is shown. Reflected to the `open` attribute.
48
+ * @property {'top'|'top-start'|'top-end'|'bottom'|'bottom-start'|'bottom-end'|'left'|'left-start'|'left-end'|'right'|'right-start'|'right-end'} placement -
49
+ * The side of the anchor the tooltip is placed at, and with `-start` or `-end` the edge of the
50
+ * anchor it is aligned with. Without room there, the tooltip goes to the opposite side. Default
51
+ * `'top'`.
52
+ * @property {number} distance - The gap between the anchor and the tooltip, or the tip of its
53
+ * arrow, in pixels. Default `8`.
54
+ * @property {number} showDelay - How long the pointer has to rest on the anchor before the tooltip
55
+ * opens, in milliseconds. Default `150`. The focus of the keyboard opens it at once.
56
+ * @property {number} hideDelay - How long the tooltip stays after the pointer has left, in
57
+ * milliseconds. Default `0`.
58
+ * @property {boolean} arrow - Whether the tooltip has an arrow that points to the anchor. Default
59
+ * `false`.
60
+ * @property {boolean} disabled - Takes the pointer and the focus out of it: the tooltip no longer
61
+ * opens or closes for them, only for a script and for `Escape`. A tooltip that is open when it
62
+ * becomes disabled closes. It stays the description of its anchor. Default `false`.
63
+ */
64
+ export default class Tooltip extends TemplateElement {
65
+ constructor() {
66
+ super({ styles: [style], shadowRender: true, propertyOptions: { open: { reflect: true } } });
67
+
68
+ /**
69
+ * Why the tooltip is wanted right now: the pointer is over the `anchor` or over the
70
+ * `tooltip`, or the anchor has the `focus` of the keyboard.
71
+ * @private
72
+ * @type {Set<'anchor' | 'tooltip' | 'focus'>}
73
+ */
74
+ this._reasons = new Set();
75
+ }
76
+
77
+ properties() {
78
+ return {
79
+ for: '',
80
+ open: false,
81
+ placement: 'top',
82
+ distance: 8,
83
+ showDelay: 150,
84
+ hideDelay: 0,
85
+ arrow: false,
86
+ disabled: false,
87
+ };
88
+ }
89
+
90
+ connected() {
91
+ this._attach();
92
+ // The watcher does not run for the first value, so a tooltip that is open from the start is
93
+ // shown here.
94
+ if (this.open) this._applyOpen();
95
+ }
96
+
97
+ disconnected() {
98
+ // A tooltip that leaves the page is closed, and stays closed when it comes back: what
99
+ // opened it, a pointer or the focus on its anchor, is not known to be there any more.
100
+ this._detach();
101
+ clearTimeout(this._timer);
102
+ this._reasons.clear();
103
+ this._applyClose();
104
+ if (this.open) this.open = false;
105
+ }
106
+
107
+ afterUpdate() {
108
+ // A new placement or distance, an arrow that came or went.
109
+ if (this.open) this._position();
110
+ }
111
+
112
+ watch() {
113
+ return {
114
+ open: (open) => {
115
+ if (open) this._applyOpen();
116
+ else this._applyClose();
117
+ },
118
+ for: () => {
119
+ if (!this.isConnected) return;
120
+ // What opened the tooltip, a pointer or the focus, was on the anchor it had.
121
+ this._dismiss();
122
+ this._attach();
123
+ },
124
+ disabled: (disabled) => {
125
+ if (disabled) this._dismiss();
126
+ },
127
+ };
128
+ }
129
+
130
+ /**
131
+ * Opens the tooltip. A tooltip without an anchor in the page stays closed.
132
+ * @returns {void}
133
+ */
134
+ show() {
135
+ this.open = true;
136
+ }
137
+
138
+ /**
139
+ * Closes the tooltip.
140
+ * @returns {void}
141
+ */
142
+ hide() {
143
+ this.open = false;
144
+ }
145
+
146
+ /**
147
+ * Makes the element what a tooltip is to the platform: a popover that only a script opens and
148
+ * closes, with the role of a tooltip and an id by which its anchor can name it.
149
+ * @private
150
+ */
151
+ _prepare() {
152
+ if (!this.hasAttribute('popover')) this.setAttribute('popover', 'manual');
153
+ if (!this.id) this.id = `el-tooltip-${++count}`;
154
+ this._internals.role = 'tooltip';
155
+ }
156
+
157
+ /**
158
+ * Looks the anchor up and binds the tooltip to it: the anchor is described by the tooltip, and
159
+ * the pointer and the focus on it open and close the tooltip. The pointer on the tooltip itself
160
+ * counts as well, so that it can be moved onto the text.
161
+ * @private
162
+ */
163
+ _attach() {
164
+ this._prepare();
165
+ this._detach();
166
+
167
+ const id = String(this.for ?? '');
168
+ const anchor = id ? (this.getRootNode().getElementById?.(id) ?? null) : null;
169
+ if (!anchor) {
170
+ // Nothing to be placed at.
171
+ if (this.open) this.open = false;
172
+ return;
173
+ }
174
+
175
+ this._anchor = anchor;
176
+ this._describe(anchor, true);
177
+
178
+ this._anchorListeners = new AbortController();
179
+ const options = { signal: this._anchorListeners.signal };
180
+ for (const target of [anchor, this]) {
181
+ target.addEventListener('pointerenter', (event) => this._onPointerEnter(event), options);
182
+ target.addEventListener('pointerleave', (event) => this._onPointerLeave(event), options);
183
+ }
184
+ anchor.addEventListener('focusin', () => this._onFocusIn(), options);
185
+ anchor.addEventListener('focusout', () => this._onFocusOut(), options);
186
+ this.addEventListener('toggle', (event) => this._onToggle(event), options);
187
+ }
188
+
189
+ /** @private */
190
+ _detach() {
191
+ this._anchorListeners?.abort();
192
+ this._anchorListeners = undefined;
193
+ if (this._anchor) this._describe(this._anchor, false);
194
+ this._anchor = undefined;
195
+ }
196
+
197
+ /**
198
+ * Adds the id of the tooltip to the `aria-describedby` of its anchor, or takes it away again.
199
+ * What else the anchor is described by stays.
200
+ * @private
201
+ * @param {Element} anchor
202
+ * @param {boolean} described
203
+ */
204
+ _describe(anchor, described) {
205
+ const others = (anchor.getAttribute('aria-describedby') ?? '')
206
+ .split(/\s+/)
207
+ .filter((id) => id && id !== this.id);
208
+ const ids = described ? [...others, this.id] : others;
209
+ if (ids.length > 0) anchor.setAttribute('aria-describedby', ids.join(' '));
210
+ else anchor.removeAttribute('aria-describedby');
211
+ }
212
+
213
+ /** @private */
214
+ _onPointerEnter(event) {
215
+ // A finger has no hover: it would open the tooltip together with the press on the anchor.
216
+ if (event.pointerType === 'touch') return;
217
+ this._reasons.add(event.currentTarget === this ? 'tooltip' : 'anchor');
218
+ this._schedule(this.showDelay);
219
+ }
220
+
221
+ /** @private */
222
+ _onPointerLeave(event) {
223
+ this._reasons.delete(event.currentTarget === this ? 'tooltip' : 'anchor');
224
+ this._schedule(this.hideDelay);
225
+ }
226
+
227
+ /** @private */
228
+ _onFocusIn() {
229
+ // The focus of the keyboard only. A button that was clicked keeps the focus, and the
230
+ // tooltip would stay open after the pointer has left.
231
+ if (!focusIsVisible()) return;
232
+ this._reasons.add('focus');
233
+ this._schedule(0);
234
+ }
235
+
236
+ /** @private */
237
+ _onFocusOut() {
238
+ this._reasons.delete('focus');
239
+ this._schedule(0);
240
+ }
241
+
242
+ /**
243
+ * The platform has opened or closed the popover, by `showPopover()` or `hidePopover()` on the
244
+ * element.
245
+ * @private
246
+ */
247
+ _onToggle(event) {
248
+ const open = event.newState === 'open';
249
+ if (open !== this.open) this.open = open;
250
+ }
251
+
252
+ /** @private */
253
+ _onKeyDown(event) {
254
+ if (event.key !== 'Escape' || event.isComposing) return;
255
+ // Escape closes one thing at a time: a dialog or a popover around the anchor stays open.
256
+ event.preventDefault();
257
+ this._dismiss();
258
+ }
259
+
260
+ /**
261
+ * Opens or closes the tooltip after a delay, by what is the case then. The decision is always
262
+ * taken in a task of its own, also without a delay: a pointer that goes from the anchor onto
263
+ * the tooltip leaves the one before it enters the other.
264
+ * @private
265
+ * @param {number} delay - In milliseconds.
266
+ */
267
+ _schedule(delay) {
268
+ clearTimeout(this._timer);
269
+ this._timer = setTimeout(
270
+ () => {
271
+ // A disabled tooltip is left to the script that opens and closes it.
272
+ if (this.disabled) return;
273
+ const wanted = this._reasons.size > 0;
274
+ if (wanted !== this.open) this.open = wanted;
275
+ },
276
+ Math.max(0, Number(delay) || 0),
277
+ );
278
+ }
279
+
280
+ /**
281
+ * Closes the tooltip now. It opens again when the pointer or the focus comes anew, not for the
282
+ * one that is still on the anchor.
283
+ * @private
284
+ */
285
+ _dismiss() {
286
+ clearTimeout(this._timer);
287
+ this._reasons.clear();
288
+ this.open = false;
289
+ }
290
+
291
+ /** @private */
292
+ _applyOpen() {
293
+ if (!this.isConnected) return;
294
+
295
+ // An anchor that came into the page after the tooltip.
296
+ if (!this._anchor) this._attach();
297
+ if (!this._anchor) {
298
+ this.open = false;
299
+ return;
300
+ }
301
+
302
+ if (!this.matches(':popover-open')) this.showPopover();
303
+ this._internals.states.add('open');
304
+ this._startPositioning();
305
+
306
+ // On the document, before anything else sees the key: the focus need not be on the anchor.
307
+ this._openListeners?.abort();
308
+ this._openListeners = new AbortController();
309
+ document.addEventListener('keydown', (event) => this._onKeyDown(event), {
310
+ capture: true,
311
+ signal: this._openListeners.signal,
312
+ });
313
+
314
+ this.dispatch(Events.SHOW);
315
+ }
316
+
317
+ /** @private */
318
+ _applyClose() {
319
+ // Not shown: nothing to undo and nothing to report.
320
+ if (!this._internals.states.has('open')) return;
321
+
322
+ this._stopPositioning();
323
+ this._openListeners?.abort();
324
+ this._openListeners = undefined;
325
+ if (this.matches(':popover-open')) this.hidePopover();
326
+ this._internals.states.delete('open');
327
+ this.dispatch(Events.HIDE);
328
+ }
329
+
330
+ /**
331
+ * Places the tooltip now, and again whenever the anchor moves: on scroll, on resize, when the
332
+ * anchor or the tooltip changes its size.
333
+ * @private
334
+ */
335
+ _startPositioning() {
336
+ this._stopPositioning();
337
+ this._stopFollowing = followAnchor(this._anchor, this, () => this._position());
338
+ }
339
+
340
+ /** @private */
341
+ _stopPositioning() {
342
+ this._stopFollowing?.();
343
+ this._stopFollowing = undefined;
344
+ }
345
+
346
+ /** @private */
347
+ async _position() {
348
+ if (!this.open || !this._anchor) return;
349
+
350
+ const { gap } = await placeAtAnchor(this._anchor, this, {
351
+ placement: this.placement,
352
+ distance: this.distance,
353
+ arrowElement: this.$refs?.arrow,
354
+ });
355
+
356
+ // The stylesheet lets the surface reach across the gap to the anchor, for the pointer.
357
+ if (gap !== this._gap) {
358
+ this._gap = gap;
359
+ this.style.setProperty('--_el-tooltip-gap', `${gap}px`);
360
+ }
361
+ }
362
+
363
+ template() {
364
+ return html`
365
+ <div part="body" class="body">
366
+ <slot></slot>
367
+ ${this.arrow ? html`<div part="arrow" ref="arrow" class="arrow"></div>` : ''}
368
+ </div>
369
+ `;
370
+ }
371
+ }
372
+
373
+ export function define() {
374
+ defineElement('el-tooltip', Tooltip);
375
+ }
376
+
377
+ export { Events };