@swisspost/design-system-components 1.6.3 → 1.7.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 (309) hide show
  1. package/dist/cjs/{check-non-empty-ae713942.js → check-non-empty-eeaa8f77.js} +4 -4
  2. package/dist/cjs/check-non-empty-eeaa8f77.js.map +1 -0
  3. package/dist/cjs/index-8c288b1a.js +45 -0
  4. package/dist/cjs/index-8c288b1a.js.map +1 -0
  5. package/dist/cjs/{index-b619e205.js → index-c07c0cdb.js} +144 -65
  6. package/dist/cjs/index-c07c0cdb.js.map +1 -0
  7. package/dist/cjs/index.cjs.js +17 -12
  8. package/dist/cjs/index.cjs.js.map +1 -1
  9. package/dist/cjs/loader.cjs.js +2 -2
  10. package/dist/cjs/package-989e0b36.js +7 -0
  11. package/dist/cjs/package-989e0b36.js.map +1 -0
  12. package/dist/cjs/post-accordion-bc0c6f31.js +87 -0
  13. package/dist/cjs/post-accordion-bc0c6f31.js.map +1 -0
  14. package/dist/cjs/post-accordion.cjs.entry.js +4 -80
  15. package/dist/cjs/post-accordion.cjs.entry.js.map +1 -1
  16. package/dist/cjs/post-alert-39ac30a4.js +101 -0
  17. package/dist/cjs/{post-alert-b46943e0.js.map → post-alert-39ac30a4.js.map} +1 -1
  18. package/dist/cjs/post-alert.cjs.entry.js +5 -6
  19. package/dist/cjs/post-alert.cjs.entry.js.map +1 -1
  20. package/dist/cjs/{post-collapsible-04364cda.js → post-collapsible-85f8ace5.js} +69 -69
  21. package/dist/cjs/{post-collapsible-04364cda.js.map → post-collapsible-85f8ace5.js.map} +1 -1
  22. package/dist/cjs/post-collapsible.cjs.entry.js +4 -5
  23. package/dist/cjs/post-collapsible.cjs.entry.js.map +1 -1
  24. package/dist/cjs/post-components.cjs.js +3 -3
  25. package/dist/cjs/post-components.cjs.js.map +1 -1
  26. package/dist/cjs/post-icon-53e50c15.js +105 -0
  27. package/dist/cjs/post-icon-53e50c15.js.map +1 -0
  28. package/dist/cjs/post-icon.cjs.entry.js +5 -6
  29. package/dist/cjs/post-icon.cjs.entry.js.map +1 -1
  30. package/dist/cjs/post-popover-5a75c1b2.js +118 -0
  31. package/dist/cjs/post-popover-5a75c1b2.js.map +1 -0
  32. package/dist/cjs/post-popover.cjs.entry.js +13 -0
  33. package/dist/cjs/post-popover.cjs.entry.js.map +1 -0
  34. package/dist/cjs/post-popovercontainer-84378594.js +1878 -0
  35. package/dist/cjs/post-popovercontainer-84378594.js.map +1 -0
  36. package/dist/cjs/post-popovercontainer.cjs.entry.js +13 -0
  37. package/dist/cjs/post-popovercontainer.cjs.entry.js.map +1 -0
  38. package/dist/cjs/post-tab-header-02c6e31e.js +33 -0
  39. package/dist/cjs/{post-tab-header-805c0a52.js.map → post-tab-header-02c6e31e.js.map} +1 -1
  40. package/dist/cjs/post-tab-header.cjs.entry.js +4 -4
  41. package/dist/cjs/post-tab-panel-3973b707.js +27 -0
  42. package/dist/cjs/{post-tab-panel-caa44a77.js.map → post-tab-panel-3973b707.js.map} +1 -1
  43. package/dist/cjs/post-tab-panel.cjs.entry.js +3 -3
  44. package/dist/cjs/post-tabs-7a4fead7.js +153 -0
  45. package/dist/cjs/post-tabs-7a4fead7.js.map +1 -0
  46. package/dist/cjs/post-tabs.cjs.entry.js +3 -3
  47. package/dist/cjs/{post-tooltip-32a9c549.js → post-tooltip-79a9c96d.js} +78 -1754
  48. package/dist/cjs/post-tooltip-79a9c96d.js.map +1 -0
  49. package/dist/cjs/post-tooltip.cjs.entry.js +3 -4
  50. package/dist/cjs/post-tooltip.cjs.entry.js.map +1 -1
  51. package/dist/collection/animations/collapse.js +5 -5
  52. package/dist/collection/animations/collapse.js.map +1 -1
  53. package/dist/collection/collection-manifest.json +5 -3
  54. package/dist/collection/components/post-accordion/post-accordion.js +167 -166
  55. package/dist/collection/components/post-accordion/post-accordion.js.map +1 -1
  56. package/dist/collection/components/post-alert/post-alert.css +2 -2
  57. package/dist/collection/components/post-alert/post-alert.js +246 -246
  58. package/dist/collection/components/post-alert/post-alert.js.map +1 -1
  59. package/dist/collection/components/post-collapsible/post-collapsible.js +169 -168
  60. package/dist/collection/components/post-collapsible/post-collapsible.js.map +1 -1
  61. package/dist/collection/components/post-icon/post-icon.css +1 -1
  62. package/dist/collection/components/post-icon/post-icon.js +250 -250
  63. package/dist/collection/components/post-icon/post-icon.js.map +1 -1
  64. package/dist/collection/components/post-popover/post-popover.css +3 -0
  65. package/dist/collection/components/post-popover/post-popover.js +267 -0
  66. package/dist/collection/components/post-popover/post-popover.js.map +1 -0
  67. package/dist/collection/components/post-popovercontainer/post-popovercontainer.css +1 -0
  68. package/dist/collection/components/post-popovercontainer/post-popovercontainer.js +288 -0
  69. package/dist/collection/components/post-popovercontainer/post-popovercontainer.js.map +1 -0
  70. package/dist/collection/components/post-tab-header/post-tab-header.css +1 -1
  71. package/dist/collection/components/post-tab-header/post-tab-header.js +62 -62
  72. package/dist/collection/components/post-tab-header/post-tab-header.js.map +1 -1
  73. package/dist/collection/components/post-tab-panel/post-tab-panel.js +50 -50
  74. package/dist/collection/components/post-tab-panel/post-tab-panel.js.map +1 -1
  75. package/dist/collection/components/post-tabs/post-tabs.css +1 -1
  76. package/dist/collection/components/post-tabs/post-tabs.js +224 -223
  77. package/dist/collection/components/post-tabs/post-tabs.js.map +1 -1
  78. package/dist/collection/components/post-tooltip/post-tooltip.css +1 -1
  79. package/dist/collection/components/post-tooltip/post-tooltip.js +192 -325
  80. package/dist/collection/components/post-tooltip/post-tooltip.js.map +1 -1
  81. package/dist/collection/index.js +3 -0
  82. package/dist/collection/index.js.map +1 -1
  83. package/dist/collection/utils/is-motion-reduced.js +1 -1
  84. package/dist/collection/utils/is-motion-reduced.js.map +1 -1
  85. package/dist/collection/utils/property-checkers/check-non-empty.js +3 -3
  86. package/dist/collection/utils/property-checkers/check-non-empty.js.map +1 -1
  87. package/dist/collection/utils/property-checkers/check-one-of.js +2 -2
  88. package/dist/collection/utils/property-checkers/check-one-of.js.map +1 -1
  89. package/dist/collection/utils/property-checkers/check-pattern.js +2 -2
  90. package/dist/collection/utils/property-checkers/check-pattern.js.map +1 -1
  91. package/dist/collection/utils/property-checkers/check-type.js +10 -10
  92. package/dist/collection/utils/property-checkers/check-type.js.map +1 -1
  93. package/dist/collection/utils/property-checkers/empty-or.js +5 -5
  94. package/dist/collection/utils/property-checkers/empty-or.js.map +1 -1
  95. package/dist/components/check-non-empty.js +3 -3
  96. package/dist/components/check-non-empty.js.map +1 -1
  97. package/dist/components/index.js +3 -0
  98. package/dist/components/index.js.map +1 -1
  99. package/dist/components/index2.js +22 -18
  100. package/dist/components/index2.js.map +1 -1
  101. package/dist/components/package.js +1 -1
  102. package/dist/components/post-accordion.d.ts +2 -2
  103. package/dist/components/post-accordion.js +1 -101
  104. package/dist/components/post-accordion.js.map +1 -1
  105. package/dist/components/post-accordion2.js +105 -0
  106. package/dist/components/post-accordion2.js.map +1 -0
  107. package/dist/components/post-alert.d.ts +2 -2
  108. package/dist/components/post-alert2.js +119 -119
  109. package/dist/components/post-alert2.js.map +1 -1
  110. package/dist/components/post-collapsible.d.ts +2 -2
  111. package/dist/components/post-collapsible2.js +90 -90
  112. package/dist/components/post-collapsible2.js.map +1 -1
  113. package/dist/components/post-icon.d.ts +2 -2
  114. package/dist/components/post-icon2.js +118 -118
  115. package/dist/components/post-icon2.js.map +1 -1
  116. package/dist/components/post-popover.d.ts +11 -0
  117. package/dist/components/post-popover.js +8 -0
  118. package/dist/components/post-popover.js.map +1 -0
  119. package/dist/components/post-popover2.js +144 -0
  120. package/dist/components/post-popover2.js.map +1 -0
  121. package/dist/components/post-popovercontainer.d.ts +11 -0
  122. package/dist/components/post-popovercontainer.js +8 -0
  123. package/dist/components/post-popovercontainer.js.map +1 -0
  124. package/dist/components/post-popovercontainer2.js +1897 -0
  125. package/dist/components/post-popovercontainer2.js.map +1 -0
  126. package/dist/components/post-tab-header.d.ts +2 -2
  127. package/dist/components/post-tab-header2.js +38 -38
  128. package/dist/components/post-tab-header2.js.map +1 -1
  129. package/dist/components/post-tab-panel.d.ts +2 -2
  130. package/dist/components/post-tab-panel2.js +30 -30
  131. package/dist/components/post-tab-panel2.js.map +1 -1
  132. package/dist/components/post-tabs.d.ts +2 -2
  133. package/dist/components/post-tabs2.js +147 -147
  134. package/dist/components/post-tabs2.js.map +1 -1
  135. package/dist/components/post-tooltip.d.ts +2 -2
  136. package/dist/components/post-tooltip2.js +100 -1774
  137. package/dist/components/post-tooltip2.js.map +1 -1
  138. package/dist/docs.d.ts +1 -21
  139. package/dist/docs.json +604 -77
  140. package/dist/esm/check-non-empty-58bd6b17.js +11 -0
  141. package/dist/esm/{check-non-empty-09c39561.js.map → check-non-empty-58bd6b17.js.map} +1 -1
  142. package/dist/esm/index-1427953c.js +40 -0
  143. package/dist/esm/index-1427953c.js.map +1 -0
  144. package/dist/esm/{index-4eff5fc5.js → index-35998e08.js} +144 -65
  145. package/dist/esm/index-35998e08.js.map +1 -0
  146. package/dist/esm/index.js +14 -12
  147. package/dist/esm/index.js.map +1 -1
  148. package/dist/esm/loader.js +3 -3
  149. package/dist/esm/package-e13ef9ad.js +5 -0
  150. package/dist/esm/package-e13ef9ad.js.map +1 -0
  151. package/dist/esm/post-accordion-8e96598a.js +85 -0
  152. package/dist/esm/post-accordion-8e96598a.js.map +1 -0
  153. package/dist/esm/post-accordion.entry.js +3 -83
  154. package/dist/esm/post-accordion.entry.js.map +1 -1
  155. package/dist/esm/post-alert-5e352303.js +99 -0
  156. package/dist/esm/{post-alert-e457e249.js.map → post-alert-5e352303.js.map} +1 -1
  157. package/dist/esm/post-alert.entry.js +5 -6
  158. package/dist/esm/post-alert.entry.js.map +1 -1
  159. package/dist/esm/{post-collapsible-c0a826b2.js → post-collapsible-3cc5dd87.js} +69 -69
  160. package/dist/esm/{post-collapsible-c0a826b2.js.map → post-collapsible-3cc5dd87.js.map} +1 -1
  161. package/dist/esm/post-collapsible.entry.js +4 -5
  162. package/dist/esm/post-collapsible.entry.js.map +1 -1
  163. package/dist/esm/post-components.js +4 -4
  164. package/dist/esm/post-components.js.map +1 -1
  165. package/dist/esm/post-icon-fdda3f99.js +103 -0
  166. package/dist/esm/post-icon-fdda3f99.js.map +1 -0
  167. package/dist/esm/post-icon.entry.js +5 -6
  168. package/dist/esm/post-icon.entry.js.map +1 -1
  169. package/dist/esm/post-popover-ff2c259f.js +116 -0
  170. package/dist/esm/post-popover-ff2c259f.js.map +1 -0
  171. package/dist/esm/post-popover.entry.js +5 -0
  172. package/dist/esm/post-popover.entry.js.map +1 -0
  173. package/dist/esm/post-popovercontainer-f4cd18cd.js +1876 -0
  174. package/dist/esm/post-popovercontainer-f4cd18cd.js.map +1 -0
  175. package/dist/esm/post-popovercontainer.entry.js +5 -0
  176. package/dist/esm/post-popovercontainer.entry.js.map +1 -0
  177. package/dist/esm/post-tab-header-486b267b.js +31 -0
  178. package/dist/esm/{post-tab-header-f0c355d6.js.map → post-tab-header-486b267b.js.map} +1 -1
  179. package/dist/esm/post-tab-header.entry.js +4 -4
  180. package/dist/esm/post-tab-panel-13940300.js +25 -0
  181. package/dist/esm/{post-tab-panel-46f02247.js.map → post-tab-panel-13940300.js.map} +1 -1
  182. package/dist/esm/post-tab-panel.entry.js +3 -3
  183. package/dist/esm/post-tabs-6f44ed1d.js +151 -0
  184. package/dist/esm/post-tabs-6f44ed1d.js.map +1 -0
  185. package/dist/esm/post-tabs.entry.js +3 -3
  186. package/dist/esm/{post-tooltip-fa7b4a0a.js → post-tooltip-1d99cd0c.js} +78 -1754
  187. package/dist/esm/post-tooltip-1d99cd0c.js.map +1 -0
  188. package/dist/esm/post-tooltip.entry.js +3 -4
  189. package/dist/esm/post-tooltip.entry.js.map +1 -1
  190. package/dist/post-components/index.esm.js +1 -1
  191. package/dist/post-components/p-169b8ef7.entry.js +2 -0
  192. package/dist/post-components/p-28be44d7.js +2 -0
  193. package/dist/post-components/{p-8b6fe20d.js.map → p-28be44d7.js.map} +1 -1
  194. package/dist/post-components/p-3ef3a1d2.js +2 -0
  195. package/dist/post-components/p-3ef3a1d2.js.map +1 -0
  196. package/dist/post-components/p-4b94c2a1.entry.js +2 -0
  197. package/dist/post-components/p-4cbb5212.entry.js +2 -0
  198. package/dist/post-components/p-51ae6f46.entry.js +2 -0
  199. package/dist/post-components/p-668bf58c.entry.js +2 -0
  200. package/dist/post-components/p-67d0a4fa.entry.js +2 -0
  201. package/dist/post-components/p-6b3a5063.entry.js +2 -0
  202. package/dist/post-components/{p-3604be27.js → p-6cdc82c6.js} +2 -2
  203. package/dist/post-components/p-723336f2.js +2 -0
  204. package/dist/post-components/{p-ca1e407c.js.map → p-723336f2.js.map} +1 -1
  205. package/dist/post-components/p-7d08e4f1.js +2 -0
  206. package/dist/post-components/p-7d08e4f1.js.map +1 -0
  207. package/dist/post-components/p-81591ad0.js +3 -0
  208. package/dist/post-components/p-81591ad0.js.map +1 -0
  209. package/dist/post-components/p-96f4ebc4.js +2 -0
  210. package/dist/post-components/p-96f4ebc4.js.map +1 -0
  211. package/dist/post-components/p-9b1b6e06.entry.js +2 -0
  212. package/dist/post-components/{p-9f71d450.js → p-a5a23448.js} +2 -2
  213. package/dist/post-components/p-aca6e9c1.js +2 -0
  214. package/dist/post-components/{p-fffce1d7.js.map → p-aca6e9c1.js.map} +1 -1
  215. package/dist/post-components/{p-b531475e.js → p-b095519d.js} +1 -1
  216. package/dist/post-components/p-bc27f061.js +9 -0
  217. package/dist/post-components/p-bc27f061.js.map +1 -0
  218. package/dist/post-components/p-bd1d0117.js +2 -0
  219. package/dist/post-components/p-bd1d0117.js.map +1 -0
  220. package/dist/post-components/p-d3ed113e.js +2 -0
  221. package/dist/post-components/p-d3ed113e.js.map +1 -0
  222. package/dist/post-components/p-d8365401.entry.js +2 -0
  223. package/dist/post-components/p-d8365401.entry.js.map +1 -0
  224. package/dist/post-components/p-e78d158d.entry.js +2 -0
  225. package/dist/post-components/p-e78d158d.entry.js.map +1 -0
  226. package/dist/post-components/{p-7b8797c6.entry.js → p-f695aab4.js} +2 -2
  227. package/dist/post-components/post-components.esm.js +1 -1
  228. package/dist/post-components/post-components.esm.js.map +1 -1
  229. package/dist/types/components/post-accordion/post-accordion.d.ts +26 -26
  230. package/dist/types/components/post-alert/post-alert.d.ts +45 -45
  231. package/dist/types/components/post-collapsible/post-collapsible.d.ts +31 -31
  232. package/dist/types/components/post-icon/post-icon.d.ts +43 -43
  233. package/dist/types/components/post-popover/post-popover.d.ts +53 -0
  234. package/dist/types/components/post-popovercontainer/post-popovercontainer.d.ts +62 -0
  235. package/dist/types/components/post-tab-header/post-tab-header.d.ts +9 -9
  236. package/dist/types/components/post-tab-panel/post-tab-panel.d.ts +8 -8
  237. package/dist/types/components/post-tabs/post-tabs.d.ts +32 -32
  238. package/dist/types/components/post-tooltip/post-tooltip.d.ts +35 -62
  239. package/dist/types/components.d.ts +115 -10
  240. package/dist/types/index.d.ts +3 -0
  241. package/dist/types/stencil-public-runtime.d.ts +8 -0
  242. package/package.json +15 -13
  243. package/dist/cjs/check-non-empty-ae713942.js.map +0 -1
  244. package/dist/cjs/check-one-of-27ad3154.js +0 -10
  245. package/dist/cjs/check-one-of-27ad3154.js.map +0 -1
  246. package/dist/cjs/index-b38a23e0.js +0 -41
  247. package/dist/cjs/index-b38a23e0.js.map +0 -1
  248. package/dist/cjs/index-b619e205.js.map +0 -1
  249. package/dist/cjs/package-4e9ab85c.js +0 -7
  250. package/dist/cjs/package-4e9ab85c.js.map +0 -1
  251. package/dist/cjs/post-alert-b46943e0.js +0 -101
  252. package/dist/cjs/post-icon-5b36814e.js +0 -105
  253. package/dist/cjs/post-icon-5b36814e.js.map +0 -1
  254. package/dist/cjs/post-tab-header-805c0a52.js +0 -33
  255. package/dist/cjs/post-tab-panel-caa44a77.js +0 -27
  256. package/dist/cjs/post-tabs-29d4dc70.js +0 -153
  257. package/dist/cjs/post-tabs-29d4dc70.js.map +0 -1
  258. package/dist/cjs/post-tooltip-32a9c549.js.map +0 -1
  259. package/dist/components/check-one-of.js +0 -8
  260. package/dist/components/check-one-of.js.map +0 -1
  261. package/dist/esm/check-non-empty-09c39561.js +0 -11
  262. package/dist/esm/check-one-of-74750af9.js +0 -8
  263. package/dist/esm/check-one-of-74750af9.js.map +0 -1
  264. package/dist/esm/index-35921354.js +0 -36
  265. package/dist/esm/index-35921354.js.map +0 -1
  266. package/dist/esm/index-4eff5fc5.js.map +0 -1
  267. package/dist/esm/package-b9b10dd3.js +0 -5
  268. package/dist/esm/package-b9b10dd3.js.map +0 -1
  269. package/dist/esm/post-alert-e457e249.js +0 -99
  270. package/dist/esm/post-icon-b34da686.js +0 -103
  271. package/dist/esm/post-icon-b34da686.js.map +0 -1
  272. package/dist/esm/post-tab-header-f0c355d6.js +0 -31
  273. package/dist/esm/post-tab-panel-46f02247.js +0 -25
  274. package/dist/esm/post-tabs-5dd55290.js +0 -151
  275. package/dist/esm/post-tabs-5dd55290.js.map +0 -1
  276. package/dist/esm/post-tooltip-fa7b4a0a.js.map +0 -1
  277. package/dist/post-components/p-1339f8cd.js +0 -2
  278. package/dist/post-components/p-1339f8cd.js.map +0 -1
  279. package/dist/post-components/p-195b8c88.entry.js +0 -2
  280. package/dist/post-components/p-3225e008.entry.js +0 -2
  281. package/dist/post-components/p-61ffffa9.entry.js +0 -2
  282. package/dist/post-components/p-88262544.js +0 -2
  283. package/dist/post-components/p-8b6fe20d.js +0 -2
  284. package/dist/post-components/p-a7649277.js +0 -3
  285. package/dist/post-components/p-a7649277.js.map +0 -1
  286. package/dist/post-components/p-a7c78dea.entry.js +0 -2
  287. package/dist/post-components/p-b2c3ed97.entry.js +0 -2
  288. package/dist/post-components/p-ba9aba3a.entry.js +0 -2
  289. package/dist/post-components/p-bd293ff3.entry.js +0 -2
  290. package/dist/post-components/p-ca1e407c.js +0 -2
  291. package/dist/post-components/p-d407b1c3.js +0 -2
  292. package/dist/post-components/p-d407b1c3.js.map +0 -1
  293. package/dist/post-components/p-dfe29f7f.js +0 -2
  294. package/dist/post-components/p-dfe29f7f.js.map +0 -1
  295. package/dist/post-components/p-fd7015ae.js +0 -9
  296. package/dist/post-components/p-fd7015ae.js.map +0 -1
  297. package/dist/post-components/p-fffce1d7.js +0 -2
  298. /package/dist/post-components/{p-195b8c88.entry.js.map → p-169b8ef7.entry.js.map} +0 -0
  299. /package/dist/post-components/{p-3225e008.entry.js.map → p-4b94c2a1.entry.js.map} +0 -0
  300. /package/dist/post-components/{p-61ffffa9.entry.js.map → p-4cbb5212.entry.js.map} +0 -0
  301. /package/dist/post-components/{p-88262544.js.map → p-51ae6f46.entry.js.map} +0 -0
  302. /package/dist/post-components/{p-a7c78dea.entry.js.map → p-668bf58c.entry.js.map} +0 -0
  303. /package/dist/post-components/{p-b2c3ed97.entry.js.map → p-67d0a4fa.entry.js.map} +0 -0
  304. /package/dist/post-components/{p-ba9aba3a.entry.js.map → p-6b3a5063.entry.js.map} +0 -0
  305. /package/dist/post-components/{p-3604be27.js.map → p-6cdc82c6.js.map} +0 -0
  306. /package/dist/post-components/{p-bd293ff3.entry.js.map → p-9b1b6e06.entry.js.map} +0 -0
  307. /package/dist/post-components/{p-9f71d450.js.map → p-a5a23448.js.map} +0 -0
  308. /package/dist/post-components/{p-b531475e.js.map → p-b095519d.js.map} +0 -0
  309. /package/dist/post-components/{p-7b8797c6.entry.js.map → p-f695aab4.js.map} +0 -0
@@ -1,345 +1,212 @@
1
1
  import { h, Host } from "@stencil/core";
2
- import { arrow, autoUpdate, computePosition, flip, inline, offset, shift, } from "@floating-ui/dom";
3
2
  import isFocusable from "ally.js/esm/is/focusable";
4
- // Polyfill for popovers, can be removed when https://caniuse.com/?search=popover is green
5
- import "@oddbird/popover-polyfill";
6
3
  // Patch for long press on touch devices
7
4
  import "long-press-event";
8
5
  import { version } from "../../../package.json";
9
- import { checkOneOf } from "../../utils";
10
- import { BACKGROUND_COLOR } from "./types";
11
- const SIDE_MAP = {
12
- top: 'bottom',
13
- right: 'left',
14
- bottom: 'top',
15
- left: 'right',
16
- };
17
6
  export class PostTooltip {
18
- validateBackgroundColor(newValue = this.backgroundColor) {
19
- checkOneOf(newValue, BACKGROUND_COLOR, `The post-tooltip "background-color" prop should contain one of those values: ${BACKGROUND_COLOR.join(', ')}`);
20
- if (newValue === 'yellow') {
21
- this.tooltipClasses = 'bg-yellow';
7
+ constructor() {
8
+ this.placement = 'top';
9
+ // Create local versions of event handlers for de-registration
10
+ // https://stackoverflow.com/questions/33859113/javascript-removeeventlistener-not-working-inside-a-class
11
+ this.localShowTooltip = e => this.show(e.target);
12
+ this.localHideTooltip = this.hide.bind(this);
22
13
  }
23
- else {
24
- this.tooltipClasses = 'bg-primary';
14
+ connectedCallback() {
15
+ if (!this.host.id) {
16
+ throw new Error('No id set: <post-tooltip> must have an id, linking it to it\'s target element using the data-tooltip-target attribute.');
17
+ }
18
+ if (!this.triggers) {
19
+ throw new Error(`No trigger found for <post-tooltip id="${this.host.id}">, please add the 'data-tooltip-target="${this.host.id}" attribute to the trigger element.`);
20
+ }
21
+ // Patch popovertargetaction="interest" until it's implemented
22
+ // https://github.com/openui/open-ui/issues/767#issuecomment-1654177227
23
+ this.triggers.forEach(trigger => this.patchPopoverTargetActionInterest(trigger));
25
24
  }
26
- }
27
- constructor() {
28
- this.tooltipClasses = undefined;
29
- this.backgroundColor = 'primary';
30
- this.placement = 'top';
31
- // Create local versions of event handlers for de-registration
32
- // https://stackoverflow.com/questions/33859113/javascript-removeeventlistener-not-working-inside-a-class
33
- this.localShowTooltip = e => this.show(e.target);
34
- this.localHideTooltip = this.hide.bind(this);
35
- this.localToggleTooltip = this.toggle.bind(this);
36
- }
37
- componentWillLoad() {
38
- this.validateBackgroundColor();
39
- // Append tooltip host to the end of the body to get around overflow: hidden restrictions
40
- // for browsers that don't support popover yet
41
- document.body.appendChild(this.host);
42
- }
43
- connectedCallback() {
44
- if (!this.host.id) {
45
- throw new Error('No id set: <post-tooltip> must have an id, linking it to it\'s target element using the data-tooltip-target attribute.');
25
+ /**
26
+ * Remove a bunch of event listeners if the tooltip gets removed from the DOM
27
+ */
28
+ disconnectedCallback() {
29
+ this.triggers.forEach(trigger => {
30
+ trigger.removeEventListener('mouseenter', this.localShowTooltip);
31
+ trigger.removeEventListener('mouseleave', this.localHideTooltip);
32
+ trigger.removeEventListener('focus', this.localShowTooltip);
33
+ trigger.removeEventListener('blur', this.localHideTooltip);
34
+ trigger.removeEventListener('long-press', this.localShowTooltip);
35
+ });
46
36
  }
47
- if (!this.triggers) {
48
- throw new Error(`No trigger found for <post-tooltip id="${this.host.id}">, please add the 'data-tooltip-target="${this.host.id}" attribute to the trigger element.`);
37
+ componentWillLoad() {
38
+ // Append tooltip host to the end of the body to get around overflow: hidden restrictions
39
+ // for browsers that don't support popover yet
40
+ document.body.appendChild(this.host);
49
41
  }
50
- // Patch popovertargetaction="interest" until it's implemented
51
- // https://github.com/openui/open-ui/issues/767#issuecomment-1654177227
52
- this.triggers.forEach(trigger => this.patchPopoverTargetActionInterest(trigger));
53
- }
54
- /**
55
- * Remove a bunch of event listeners if the tooltip gets removed from the DOM
56
- */
57
- disconnectedCallback() {
58
- this.triggers.forEach(trigger => {
59
- trigger.removeEventListener('mouseenter', this.localShowTooltip);
60
- trigger.removeEventListener('mouseleave', this.localHideTooltip);
61
- trigger.removeEventListener('focus', this.localShowTooltip);
62
- trigger.removeEventListener('blur', this.localHideTooltip);
63
- trigger.removeEventListener('long-press', this.localShowTooltip);
64
- });
65
- if (this.tooltipRef)
66
- this.tooltipRef.removeEventListener('beforetoggle', this.localToggleTooltip);
67
- if (typeof this.clearAutoUpdate === 'function')
68
- this.clearAutoUpdate();
69
- }
70
- componentDidLoad() {
71
- // Has the benefit of rendering the tooltip without the popover attribute which
72
- // causes the tooltip to show up on the page if it's not linked to a target. This makes
73
- // the error obvious.
74
- if (!this.host.id || !this.triggers)
75
- return false;
76
- this.tooltipRef.setAttribute('popover', '');
77
- this.tooltipRef.addEventListener('beforetoggle', this.handleToggle.bind(this));
78
- }
79
- /**
80
- * Programmatically display the tooltip
81
- * @param target An element with [data-tooltip-target="id"] where the tooltip should be shown
82
- */
83
- async show(target) {
84
- this.eventTarget = target;
85
- this.tooltipRef.showPopover();
86
- }
87
- /**
88
- * Programmatically hide this tooltip
89
- */
90
- async hide() {
91
- this.eventTarget = null;
92
- this.tooltipRef.hidePopover();
93
- }
94
- /**
95
- * Toggle tooltip display
96
- * @param target An element with [data-tooltip-target="id"] where the tooltip should be shown
97
- * @param force Pass true to always show or false to always hide
98
- */
99
- async toggle(target, force) {
100
- this.eventTarget = target;
101
- this.tooltipRef.togglePopover(force);
102
- }
103
- get triggers() {
104
- return document.querySelectorAll(`[data-tooltip-target="${this.host.id}"]`);
105
- }
106
- patchPopoverTargetActionInterest(trigger) {
107
- trigger.addEventListener('mouseenter', this.localShowTooltip);
108
- trigger.addEventListener('mouseleave', this.localHideTooltip);
109
- trigger.addEventListener('focus', this.localShowTooltip);
110
- trigger.addEventListener('blur', this.localHideTooltip);
111
- trigger.addEventListener('long-press', this.localShowTooltip);
112
- // Patch missing aria-describedby attribute on the trigger without overriding existing values
113
- const describedBy = trigger.getAttribute('aria-describedby');
114
- if (!(describedBy === null || describedBy === void 0 ? void 0 : describedBy.includes(this.host.id))) {
115
- const newDescribedBy = describedBy ? `${describedBy} ${this.host.id}` : this.host.id;
116
- trigger.setAttribute('aria-describedby', newDescribedBy);
42
+ /**
43
+ * Programmatically display the tooltip
44
+ * @param target An element with [data-tooltip-target="id"] where the tooltip should be shown
45
+ */
46
+ async show(target) {
47
+ this.popoverRef.show(target);
117
48
  }
118
- // Patch missing focus ability on the trigger element
119
- if (!isFocusable(trigger)) {
120
- trigger.setAttribute('tabindex', '0');
49
+ /**
50
+ * Programmatically hide this tooltip
51
+ */
52
+ async hide() {
53
+ this.popoverRef.hide();
121
54
  }
122
- }
123
- /**
124
- * Start or stop auto updates based on tooltip events.
125
- * Tooltips can be closed or opened with other methods than class members,
126
- * therefore listening to the toggle event is safer for cleaning up.
127
- * @param e ToggleEvent
128
- */
129
- handleToggle(e) {
130
- const isOpen = e.newState === 'open';
131
- if (isOpen) {
132
- this.startAutoupdates();
55
+ /**
56
+ * Toggle tooltip display
57
+ * @param target An element with [data-tooltip-target="id"] where the tooltip should be shown
58
+ * @param force Pass true to always show or false to always hide
59
+ */
60
+ async toggle(target, force) {
61
+ this.popoverRef.toggle(target, force);
133
62
  }
134
- else {
135
- if (typeof this.clearAutoUpdate === 'function')
136
- this.clearAutoUpdate();
63
+ get triggers() {
64
+ return document.querySelectorAll(`[data-tooltip-target="${this.host.id}"]`);
137
65
  }
138
- }
139
- /**
140
- * Start listening for DOM updates, scroll events etc. that have
141
- * an influence on tooltip positioning
142
- */
143
- startAutoupdates() {
144
- this.clearAutoUpdate = autoUpdate(this.eventTarget, this.tooltipRef, this.positionTooltip.bind(this));
145
- }
146
- // Tooltip and arrow positioning with floating-ui
147
- // Docs: https://floating-ui.com/docs/computePosition
148
- async positionTooltip() {
149
- const { x, y, middlewareData, placement: currentPlacement, } = await computePosition(this.eventTarget, this.tooltipRef, {
150
- placement: this.placement || 'top',
151
- middleware: [
152
- flip(),
153
- inline(),
154
- shift({ padding: 8 }),
155
- offset(12),
156
- arrow({ element: this.arrowRef, padding: 8 }),
157
- ],
158
- });
159
- // Tooltip
160
- this.tooltipRef.style.left = `${x}px`;
161
- this.tooltipRef.style.top = `${y}px`;
162
- // Arrow
163
- // Tutorial: https://codesandbox.io/s/mystifying-kare-ee3hmh?file=/src/index.js
164
- const side = currentPlacement.split('-')[0];
165
- const { x: arrowX, y: arrowY } = middlewareData.arrow;
166
- const staticSide = SIDE_MAP[side];
167
- Object.assign(this.arrowRef.style, {
168
- top: arrowY ? `${arrowY}px` : '',
169
- left: arrowX ? `${arrowX}px` : '',
170
- [staticSide]: `${-this.arrowRef.offsetWidth / 2}px`,
171
- });
172
- }
173
- render() {
174
- return (h(Host, { "data-version": version }, h("div", { role: "tooltip", tabindex: "-1", class: this.tooltipClasses, ref: (el) => (this.tooltipRef = el) }, h("span", { class: "arrow", ref: el => {
175
- this.arrowRef = el;
176
- } }), h("slot", null))));
177
- }
178
- static get is() { return "post-tooltip"; }
179
- static get encapsulation() { return "shadow"; }
180
- static get originalStyleUrls() {
181
- return {
182
- "$": ["post-tooltip.scss"]
183
- };
184
- }
185
- static get styleUrls() {
186
- return {
187
- "$": ["post-tooltip.css"]
188
- };
189
- }
190
- static get properties() {
191
- return {
192
- "backgroundColor": {
193
- "type": "string",
194
- "mutable": false,
195
- "complexType": {
196
- "original": "BackgroundColor",
197
- "resolved": "\"primary\" | \"yellow\"",
198
- "references": {
199
- "BackgroundColor": {
200
- "location": "import",
201
- "path": "./types",
202
- "id": "src/components/post-tooltip/types.ts::BackgroundColor"
203
- }
204
- }
205
- },
206
- "required": false,
207
- "optional": true,
208
- "docs": {
209
- "tags": [],
210
- "text": "Defines the background color of the tooltip.\nChoose the one that provides the best contrast in your scenario."
211
- },
212
- "attribute": "background-color",
213
- "reflect": false,
214
- "defaultValue": "'primary'"
215
- },
216
- "placement": {
217
- "type": "string",
218
- "mutable": false,
219
- "complexType": {
220
- "original": "Placement",
221
- "resolved": "\"bottom\" | \"bottom-end\" | \"bottom-start\" | \"left\" | \"left-end\" | \"left-start\" | \"right\" | \"right-end\" | \"right-start\" | \"top\" | \"top-end\" | \"top-start\"",
222
- "references": {
223
- "Placement": {
224
- "location": "import",
225
- "path": "@floating-ui/dom",
226
- "id": "../../node_modules/.pnpm/@floating-ui+dom@1.5.3/node_modules/@floating-ui/dom/src/types.d.ts::Placement"
227
- }
228
- }
229
- },
230
- "required": false,
231
- "optional": true,
232
- "docs": {
233
- "tags": [],
234
- "text": "Defines the placement of the tooltip according to the floating-ui options available at https://floating-ui.com/docs/computePosition#placement.\nTooltips are automatically flipped to the opposite side if there is not enough available space and are shifted\ntowards the viewport if they would overlap edge boundaries."
235
- },
236
- "attribute": "placement",
237
- "reflect": false,
238
- "defaultValue": "'top'"
239
- }
240
- };
241
- }
242
- static get states() {
243
- return {
244
- "tooltipClasses": {}
245
- };
246
- }
247
- static get methods() {
248
- return {
249
- "show": {
250
- "complexType": {
251
- "signature": "(target: HTMLElement) => Promise<void>",
252
- "parameters": [{
253
- "tags": [{
254
- "name": "param",
255
- "text": "target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown"
256
- }],
257
- "text": "An element with [data-tooltip-target=\"id\"] where the tooltip should be shown"
258
- }],
259
- "references": {
260
- "Promise": {
261
- "location": "global",
262
- "id": "global::Promise"
263
- },
264
- "HTMLElement": {
265
- "location": "global",
266
- "id": "global::HTMLElement"
267
- }
268
- },
269
- "return": "Promise<void>"
270
- },
271
- "docs": {
272
- "text": "Programmatically display the tooltip",
273
- "tags": [{
274
- "name": "param",
275
- "text": "target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown"
276
- }]
66
+ patchPopoverTargetActionInterest(trigger) {
67
+ trigger.addEventListener('mouseenter', this.localShowTooltip);
68
+ trigger.addEventListener('mouseleave', this.localHideTooltip);
69
+ trigger.addEventListener('focus', this.localShowTooltip);
70
+ trigger.addEventListener('blur', this.localHideTooltip);
71
+ trigger.addEventListener('long-press', this.localShowTooltip);
72
+ // Patch missing aria-describedby attribute on the trigger without overriding existing values
73
+ const describedBy = trigger.getAttribute('aria-describedby');
74
+ if (!(describedBy === null || describedBy === void 0 ? void 0 : describedBy.includes(this.host.id))) {
75
+ const newDescribedBy = describedBy ? `${describedBy} ${this.host.id}` : this.host.id;
76
+ trigger.setAttribute('aria-describedby', newDescribedBy);
277
77
  }
278
- },
279
- "hide": {
280
- "complexType": {
281
- "signature": "() => Promise<void>",
282
- "parameters": [],
283
- "references": {
284
- "Promise": {
285
- "location": "global",
286
- "id": "global::Promise"
287
- }
288
- },
289
- "return": "Promise<void>"
290
- },
291
- "docs": {
292
- "text": "Programmatically hide this tooltip",
293
- "tags": []
78
+ // Patch missing focus ability on the trigger element
79
+ if (!isFocusable(trigger)) {
80
+ trigger.setAttribute('tabindex', '0');
294
81
  }
295
- },
296
- "toggle": {
297
- "complexType": {
298
- "signature": "(target: HTMLElement, force?: boolean) => Promise<void>",
299
- "parameters": [{
300
- "tags": [{
301
- "name": "param",
302
- "text": "target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown"
303
- }],
304
- "text": "An element with [data-tooltip-target=\"id\"] where the tooltip should be shown"
305
- }, {
306
- "tags": [{
307
- "name": "param",
308
- "text": "force Pass true to always show or false to always hide"
309
- }],
310
- "text": "Pass true to always show or false to always hide"
311
- }],
312
- "references": {
313
- "Promise": {
314
- "location": "global",
315
- "id": "global::Promise"
82
+ }
83
+ render() {
84
+ return (h(Host, { "data-version": version }, h("post-popovercontainer", { role: "tooltip", tabindex: "-1", arrow: true, placement: this.placement, ref: (el) => (this.popoverRef = el) }, h("slot", null))));
85
+ }
86
+ static get is() { return "post-tooltip"; }
87
+ static get encapsulation() { return "shadow"; }
88
+ static get originalStyleUrls() {
89
+ return {
90
+ "$": ["post-tooltip.scss"]
91
+ };
92
+ }
93
+ static get styleUrls() {
94
+ return {
95
+ "$": ["post-tooltip.css"]
96
+ };
97
+ }
98
+ static get properties() {
99
+ return {
100
+ "placement": {
101
+ "type": "string",
102
+ "mutable": false,
103
+ "complexType": {
104
+ "original": "Placement",
105
+ "resolved": "\"bottom\" | \"bottom-end\" | \"bottom-start\" | \"left\" | \"left-end\" | \"left-start\" | \"right\" | \"right-end\" | \"right-start\" | \"top\" | \"top-end\" | \"top-start\"",
106
+ "references": {
107
+ "Placement": {
108
+ "location": "import",
109
+ "path": "@floating-ui/dom",
110
+ "id": "../../node_modules/.pnpm/@floating-ui+dom@1.5.4/node_modules/@floating-ui/dom/dist/floating-ui.dom.d.ts::Placement"
111
+ }
112
+ }
113
+ },
114
+ "required": false,
115
+ "optional": true,
116
+ "docs": {
117
+ "tags": [],
118
+ "text": "Defines the placement of the tooltip according to the floating-ui options available at https://floating-ui.com/docs/computePosition#placement.\nTooltips are automatically flipped to the opposite side if there is not enough available space and are shifted\ntowards the viewport if they would overlap edge boundaries."
119
+ },
120
+ "attribute": "placement",
121
+ "reflect": false,
122
+ "defaultValue": "'top'"
123
+ }
124
+ };
125
+ }
126
+ static get methods() {
127
+ return {
128
+ "show": {
129
+ "complexType": {
130
+ "signature": "(target: HTMLElement) => Promise<void>",
131
+ "parameters": [{
132
+ "name": "target",
133
+ "type": "HTMLElement",
134
+ "docs": "An element with [data-tooltip-target=\"id\"] where the tooltip should be shown"
135
+ }],
136
+ "references": {
137
+ "Promise": {
138
+ "location": "global",
139
+ "id": "global::Promise"
140
+ },
141
+ "HTMLElement": {
142
+ "location": "global",
143
+ "id": "global::HTMLElement"
144
+ }
145
+ },
146
+ "return": "Promise<void>"
147
+ },
148
+ "docs": {
149
+ "text": "Programmatically display the tooltip",
150
+ "tags": [{
151
+ "name": "param",
152
+ "text": "target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown"
153
+ }]
154
+ }
155
+ },
156
+ "hide": {
157
+ "complexType": {
158
+ "signature": "() => Promise<void>",
159
+ "parameters": [],
160
+ "references": {
161
+ "Promise": {
162
+ "location": "global",
163
+ "id": "global::Promise"
164
+ }
165
+ },
166
+ "return": "Promise<void>"
167
+ },
168
+ "docs": {
169
+ "text": "Programmatically hide this tooltip",
170
+ "tags": []
171
+ }
316
172
  },
317
- "HTMLElement": {
318
- "location": "global",
319
- "id": "global::HTMLElement"
173
+ "toggle": {
174
+ "complexType": {
175
+ "signature": "(target: HTMLElement, force?: boolean) => Promise<void>",
176
+ "parameters": [{
177
+ "name": "target",
178
+ "type": "HTMLElement",
179
+ "docs": "An element with [data-tooltip-target=\"id\"] where the tooltip should be shown"
180
+ }, {
181
+ "name": "force",
182
+ "type": "boolean",
183
+ "docs": "Pass true to always show or false to always hide"
184
+ }],
185
+ "references": {
186
+ "Promise": {
187
+ "location": "global",
188
+ "id": "global::Promise"
189
+ },
190
+ "HTMLElement": {
191
+ "location": "global",
192
+ "id": "global::HTMLElement"
193
+ }
194
+ },
195
+ "return": "Promise<void>"
196
+ },
197
+ "docs": {
198
+ "text": "Toggle tooltip display",
199
+ "tags": [{
200
+ "name": "param",
201
+ "text": "target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown"
202
+ }, {
203
+ "name": "param",
204
+ "text": "force Pass true to always show or false to always hide"
205
+ }]
206
+ }
320
207
  }
321
- },
322
- "return": "Promise<void>"
323
- },
324
- "docs": {
325
- "text": "Toggle tooltip display",
326
- "tags": [{
327
- "name": "param",
328
- "text": "target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown"
329
- }, {
330
- "name": "param",
331
- "text": "force Pass true to always show or false to always hide"
332
- }]
333
- }
334
- }
335
- };
336
- }
337
- static get elementRef() { return "host"; }
338
- static get watchers() {
339
- return [{
340
- "propName": "backgroundColor",
341
- "methodName": "validateBackgroundColor"
342
- }];
343
- }
208
+ };
209
+ }
210
+ static get elementRef() { return "host"; }
344
211
  }
345
212
  //# sourceMappingURL=post-tooltip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"post-tooltip.js","sourceRoot":"","sources":["../../../../src/components/post-tooltip/post-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EACL,KAAK,EACL,UAAU,EACV,eAAe,EACf,IAAI,EACJ,MAAM,EACN,MAAM,EAEN,KAAK,GACN,MAAM,kBAAkB,CAAC;AAC1B,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD,0FAA0F;AAC1F,OAAO,2BAA2B,CAAC;AAEnC,wCAAwC;AACxC,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAmB,MAAM,SAAS,CAAC;AAE5D,MAAM,QAAQ,GAAG;EACf,GAAG,EAAE,QAAQ;EACb,KAAK,EAAE,MAAM;EACb,MA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,CACD,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, h, Host, Method, Prop, State, Watch } from '@stencil/core';\nimport {\n arrow,\n autoUpdate,\n computePosition,\n flip,\n inline,\n offset,\n Placement,\n shift,\n} from '@floating-ui/dom';\nimport isFocusable from 'ally.js/esm/is/focusable';\n\n// Polyfill for popovers, can be removed when https://caniuse.com/?search=popover is green\nimport '@oddbird/popover-polyfill';\n\n// Patch for long press on touch devices\nimport 'long-press-event';\n\nimport { version } from '../../../package.json';\nimport { checkOneOf } from '../../utils';\nimport { BACKGROUND_COLOR, BackgroundColor } from './types';\n\nconst SIDE_MAP = {\n top: 'bottom',\n right: 'left',\n bottom: 'top',\n left: 'right',\n};\n\ninterface PopoverElement {\n showPopover: () => void;\n hidePopover: () => void;\n togglePopover: (force?: boolean) => boolean;\n}\n\n@Component({\n tag: 'post-tooltip',\n styleUrl: 'post-tooltip.scss',\n shadow: true,\n})\nexport class PostTooltip {\n private tooltipRef: HTMLDivElement & PopoverElement;\n private arrowRef: HTMLElement;\n private clearAutoUpdate: () => void;\n private readonly localShowTooltip: (e: Event) => Promise<void>;\n private readonly localHideTooltip: () => Promise<void>;\n private readonly localToggleTooltip: () => Promise<void>;\n private eventTarget: Element;\n\n @Element() host: HTMLPostTooltipElement;\n\n @State() tooltipClasses: string;\n\n /**\n * Defines the background color of the tooltip.\n * Choose the one that provides the best contrast in your scenario.\n */\n @Prop() readonly backgroundColor?: BackgroundColor = 'primary';\n\n /**\n * Defines the placement of the tooltip according to the floating-ui options available at https://floating-ui.com/docs/computePosition#placement.\n * Tooltips are automatically flipped to the opposite side if there is not enough available space and are shifted\n * towards the viewport if they would overlap edge boundaries.\n */\n @Prop() readonly placement?: Placement = 'top';\n\n @Watch('backgroundColor')\n validateBackgroundColor(newValue = this.backgroundColor) {\n checkOneOf(\n newValue,\n BACKGROUND_COLOR,\n `The post-tooltip \"background-color\" prop should contain one of those values: ${BACKGROUND_COLOR.join(\n ', ',\n )}`,\n );\n\n if (newValue === 'yellow') {\n this.tooltipClasses = 'bg-yellow';\n } else {\n this.tooltipClasses = 'bg-primary';\n }\n }\n\n constructor() {\n // Create local versions of event handlers for de-registration\n // https://stackoverflow.com/questions/33859113/javascript-removeeventlistener-not-working-inside-a-class\n this.localShowTooltip = e => this.show(e.target as HTMLElement);\n this.localHideTooltip = this.hide.bind(this);\n this.localToggleTooltip = this.toggle.bind(this);\n }\n\n componentWillLoad() {\n this.validateBackgroundColor();\n\n // Append tooltip host to the end of the body to get around overflow: hidden restrictions\n // for browsers that don't support popover yet\n document.body.appendChild(this.host);\n }\n\n connectedCallback() {\n if (!this.host.id) {\n throw new Error(\n 'No id set: <post-tooltip> must have an id, linking it to it\\'s target element using the data-tooltip-target attribute.',\n );\n }\n\n if (!this.triggers) {\n throw new Error(\n `No trigger found for <post-tooltip id=\"${this.host.id}\">, please add the 'data-tooltip-target=\"${this.host.id}\" attribute to the trigger element.`,\n );\n }\n\n // Patch popovertargetaction=\"interest\" until it's implemented\n // https://github.com/openui/open-ui/issues/767#issuecomment-1654177227\n this.triggers.forEach(trigger => this.patchPopoverTargetActionInterest(trigger));\n }\n\n /**\n * Remove a bunch of event listeners if the tooltip gets removed from the DOM\n */\n disconnectedCallback() {\n this.triggers.forEach(trigger => {\n trigger.removeEventListener('mouseenter', this.localShowTooltip);\n trigger.removeEventListener('mouseleave', this.localHideTooltip);\n trigger.removeEventListener('focus', this.localShowTooltip);\n trigger.removeEventListener('blur', this.localHideTooltip);\n trigger.removeEventListener('long-press', this.localShowTooltip);\n });\n if (this.tooltipRef)\n this.tooltipRef.removeEventListener('beforetoggle', this.localToggleTooltip);\n if (typeof this.clearAutoUpdate === 'function') this.clearAutoUpdate();\n }\n\n componentDidLoad() {\n // Has the benefit of rendering the tooltip without the popover attribute which\n // causes the tooltip to show up on the page if it's not linked to a target. This makes\n // the error obvious.\n if (!this.host.id || !this.triggers) return false;\n\n this.tooltipRef.setAttribute('popover', '');\n this.tooltipRef.addEventListener('beforetoggle', this.handleToggle.bind(this));\n }\n\n /**\n * Programmatically display the tooltip\n * @param target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown\n */\n @Method()\n async show(target: HTMLElement) {\n this.eventTarget = target;\n this.tooltipRef.showPopover();\n }\n\n /**\n * Programmatically hide this tooltip\n */\n @Method()\n async hide() {\n this.eventTarget = null;\n this.tooltipRef.hidePopover();\n }\n\n /**\n * Toggle tooltip display\n * @param target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown\n * @param force Pass true to always show or false to always hide\n */\n @Method()\n async toggle(target: HTMLElement, force?: boolean) {\n this.eventTarget = target;\n this.tooltipRef.togglePopover(force);\n }\n\n private get triggers() {\n return document.querySelectorAll(`[data-tooltip-target=\"${this.host.id}\"]`);\n }\n\n private patchPopoverTargetActionInterest(trigger: Element) {\n trigger.addEventListener('mouseenter', this.localShowTooltip);\n trigger.addEventListener('mouseleave', this.localHideTooltip);\n trigger.addEventListener('focus', this.localShowTooltip);\n trigger.addEventListener('blur', this.localHideTooltip);\n trigger.addEventListener('long-press', this.localShowTooltip);\n\n // Patch missing aria-describedby attribute on the trigger without overriding existing values\n const describedBy = trigger.getAttribute('aria-describedby');\n if (!describedBy?.includes(this.host.id)) {\n const newDescribedBy = describedBy ? `${describedBy} ${this.host.id}` : this.host.id;\n trigger.setAttribute('aria-describedby', newDescribedBy);\n }\n\n // Patch missing focus ability on the trigger element\n if (!isFocusable(trigger)) {\n trigger.setAttribute('tabindex', '0');\n }\n }\n\n /**\n * Start or stop auto updates based on tooltip events.\n * Tooltips can be closed or opened with other methods than class members,\n * therefore listening to the toggle event is safer for cleaning up.\n * @param e ToggleEvent\n */\n private handleToggle(e: ToggleEvent) {\n const isOpen = e.newState === 'open';\n if (isOpen) {\n this.startAutoupdates();\n } else {\n if (typeof this.clearAutoUpdate === 'function') this.clearAutoUpdate();\n }\n }\n\n /**\n * Start listening for DOM updates, scroll events etc. that have\n * an influence on tooltip positioning\n */\n private startAutoupdates() {\n this.clearAutoUpdate = autoUpdate(\n this.eventTarget,\n this.tooltipRef,\n this.positionTooltip.bind(this),\n );\n }\n\n // Tooltip and arrow positioning with floating-ui\n // Docs: https://floating-ui.com/docs/computePosition\n private async positionTooltip() {\n const {\n x,\n y,\n middlewareData,\n placement: currentPlacement,\n } = await computePosition(this.eventTarget, this.tooltipRef, {\n placement: this.placement || 'top',\n middleware: [\n flip(),\n inline(),\n shift({ padding: 8 }),\n offset(12), // 4px outside of element to account for focus outline + ~arrow size\n arrow({ element: this.arrowRef, padding: 8 }),\n ],\n });\n\n // Tooltip\n this.tooltipRef.style.left = `${x}px`;\n this.tooltipRef.style.top = `${y}px`;\n\n // Arrow\n // Tutorial: https://codesandbox.io/s/mystifying-kare-ee3hmh?file=/src/index.js\n const side = currentPlacement.split('-')[0];\n const { x: arrowX, y: arrowY } = middlewareData.arrow;\n const staticSide = SIDE_MAP[side];\n\n Object.assign(this.arrowRef.style, {\n top: arrowY ? `${arrowY}px` : '',\n left: arrowX ? `${arrowX}px` : '',\n [staticSide]: `${-this.arrowRef.offsetWidth / 2}px`,\n });\n }\n\n render() {\n return (\n <Host data-version={version}>\n <div\n role=\"tooltip\"\n tabindex=\"-1\"\n class={this.tooltipClasses}\n ref={(el: HTMLDivElement & PopoverElement) => (this.tooltipRef = el)}\n >\n <span\n class=\"arrow\"\n ref={el => {\n this.arrowRef = el;\n }}\n ></span>\n <slot></slot>\n </div>\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"post-tooltip.js","sourceRoot":"","sources":["../../../../src/components/post-tooltip/post-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,IAA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AAC;QAE9D,6FAA6F;QAC7F,MAAM,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;QAC7D,IAAI,CAAC,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA,EAAE;YACxC,MAAM,cAAc,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,WAAW,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACrF,OAAO,CAAC,YAAY,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC;SAC1D;QAED,qDAAqD;QACrD,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE;YACzB,OAAO,CAAC,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;SACvC;IACH,CAAC;IAED,MAAM;QACJ,OAAO,CACL,EAAC,IAAI,oBAAe,OAAO;YACzB,6BACE,IAAI,EAAC,SAAS,EACd,QAAQ,EAAC,IAAI,EACb,KAAK,QACL,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,GAAG,EAAE,CAAC,EAAmC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;gBAEpE,eAAa,CACS,CACnB,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, h, Host, Method, Prop } from '@stencil/core';\nimport { Placement } from '@floating-ui/dom';\nimport isFocusable from 'ally.js/esm/is/focusable';\n\n// Patch for long press on touch devices\nimport 'long-press-event';\n\nimport { version } from '../../../package.json';\n@Component({\n tag: 'post-tooltip',\n styleUrl: 'post-tooltip.scss',\n shadow: true,\n})\nexport class PostTooltip {\n private popoverRef: HTMLPostPopovercontainerElement;\n private readonly localShowTooltip: (e: Event) => Promise<void>;\n private readonly localHideTooltip: () => Promise<void>;\n\n @Element() host: HTMLPostTooltipElement;\n\n /**\n * Defines the placement of the tooltip according to the floating-ui options available at https://floating-ui.com/docs/computePosition#placement.\n * Tooltips are automatically flipped to the opposite side if there is not enough available space and are shifted\n * towards the viewport if they would overlap edge boundaries.\n */\n @Prop() readonly placement?: Placement = 'top';\n\n constructor() {\n // Create local versions of event handlers for de-registration\n // https://stackoverflow.com/questions/33859113/javascript-removeeventlistener-not-working-inside-a-class\n this.localShowTooltip = e => this.show(e.target as HTMLElement);\n this.localHideTooltip = this.hide.bind(this);\n }\n\n connectedCallback() {\n if (!this.host.id) {\n throw new Error(\n 'No id set: <post-tooltip> must have an id, linking it to it\\'s target element using the data-tooltip-target attribute.',\n );\n }\n\n if (!this.triggers) {\n throw new Error(\n `No trigger found for <post-tooltip id=\"${this.host.id}\">, please add the 'data-tooltip-target=\"${this.host.id}\" attribute to the trigger element.`,\n );\n }\n\n // Patch popovertargetaction=\"interest\" until it's implemented\n // https://github.com/openui/open-ui/issues/767#issuecomment-1654177227\n this.triggers.forEach(trigger => this.patchPopoverTargetActionInterest(trigger));\n }\n\n /**\n * Remove a bunch of event listeners if the tooltip gets removed from the DOM\n */\n disconnectedCallback() {\n this.triggers.forEach(trigger => {\n trigger.removeEventListener('mouseenter', this.localShowTooltip);\n trigger.removeEventListener('mouseleave', this.localHideTooltip);\n trigger.removeEventListener('focus', this.localShowTooltip);\n trigger.removeEventListener('blur', this.localHideTooltip);\n trigger.removeEventListener('long-press', this.localShowTooltip);\n });\n }\n\n componentWillLoad() {\n // Append tooltip host to the end of the body to get around overflow: hidden restrictions\n // for browsers that don't support popover yet\n document.body.appendChild(this.host);\n }\n\n /**\n * Programmatically display the tooltip\n * @param target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown\n */\n @Method()\n async show(target: HTMLElement) {\n this.popoverRef.show(target);\n }\n\n /**\n * Programmatically hide this tooltip\n */\n @Method()\n async hide() {\n this.popoverRef.hide();\n }\n\n /**\n * Toggle tooltip display\n * @param target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown\n * @param force Pass true to always show or false to always hide\n */\n @Method()\n async toggle(target: HTMLElement, force?: boolean) {\n this.popoverRef.toggle(target, force);\n }\n\n private get triggers() {\n return document.querySelectorAll(`[data-tooltip-target=\"${this.host.id}\"]`);\n }\n\n private patchPopoverTargetActionInterest(trigger: Element) {\n trigger.addEventListener('mouseenter', this.localShowTooltip);\n trigger.addEventListener('mouseleave', this.localHideTooltip);\n trigger.addEventListener('focus', this.localShowTooltip);\n trigger.addEventListener('blur', this.localHideTooltip);\n trigger.addEventListener('long-press', this.localShowTooltip);\n\n // Patch missing aria-describedby attribute on the trigger without overriding existing values\n const describedBy = trigger.getAttribute('aria-describedby');\n if (!describedBy?.includes(this.host.id)) {\n const newDescribedBy = describedBy ? `${describedBy} ${this.host.id}` : this.host.id;\n trigger.setAttribute('aria-describedby', newDescribedBy);\n }\n\n // Patch missing focus ability on the trigger element\n if (!isFocusable(trigger)) {\n trigger.setAttribute('tabindex', '0');\n }\n }\n\n render() {\n return (\n <Host data-version={version}>\n <post-popovercontainer\n role=\"tooltip\"\n tabindex=\"-1\"\n arrow\n placement={this.placement}\n ref={(el: HTMLPostPopovercontainerElement) => (this.popoverRef = el)}\n >\n <slot></slot>\n </post-popovercontainer>\n </Host>\n );\n }\n}\n"]}
@@ -1,7 +1,10 @@
1
1
  // Export every single component so it gets included in the dist output
2
+ export { PostAccordion } from './components/post-accordion/post-accordion';
2
3
  export { PostAlert } from './components/post-alert/post-alert';
3
4
  export { PostCollapsible } from './components/post-collapsible/post-collapsible';
4
5
  export { PostIcon } from './components/post-icon/post-icon';
6
+ export { PostPopover } from './components/post-popover/post-popover';
7
+ export { PostPopovercontainer } from './components/post-popovercontainer/post-popovercontainer';
5
8
  export { PostTabs } from './components/post-tabs/post-tabs';
6
9
  export { PostTabHeader } from './components/post-tab-header/post-tab-header';
7
10
  export { PostTabPanel } from './components/post-tab-panel/post-tab-panel';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,uEAAuE;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC","sourcesContent":["export { Components, JSX } from './components';\n\n// Export every single component so it gets included in the dist output\nexport { PostAlert } from './components/post-alert/post-alert';\nexport { PostCollapsible } from './components/post-collapsible/post-collapsible';\nexport { PostIcon } from './components/post-icon/post-icon';\nexport { PostTabs } from './components/post-tabs/post-tabs';\nexport { PostTabHeader } from './components/post-tab-header/post-tab-header';\nexport { PostTabPanel } from './components/post-tab-panel/post-tab-panel';\nexport { PostTooltip } from './components/post-tooltip/post-tooltip';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,uEAAuE;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0DAA0D,CAAC;AAChG,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC","sourcesContent":["export { Components, JSX } from './components';\n\n// Export every single component so it gets included in the dist output\nexport { PostAccordion } from './components/post-accordion/post-accordion';\nexport { PostAlert } from './components/post-alert/post-alert';\nexport { PostCollapsible } from './components/post-collapsible/post-collapsible';\nexport { PostIcon } from './components/post-icon/post-icon';\nexport { PostPopover } from './components/post-popover/post-popover';\nexport { PostPopovercontainer } from './components/post-popovercontainer/post-popovercontainer';\nexport { PostTabs } from './components/post-tabs/post-tabs';\nexport { PostTabHeader } from './components/post-tab-header/post-tab-header';\nexport { PostTabPanel } from './components/post-tab-panel/post-tab-panel';\nexport { PostTooltip } from './components/post-tooltip/post-tooltip';\n"]}
@@ -1,4 +1,4 @@
1
1
  export function isMotionReduced() {
2
- return window.matchMedia('(prefers-reduced-motion: reduce)').matches;
2
+ return window.matchMedia('(prefers-reduced-motion: reduce)').matches;
3
3
  }
4
4
  //# sourceMappingURL=is-motion-reduced.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-motion-reduced.js","sourceRoot":"","sources":["../../../src/utils/is-motion-reduced.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe;EAC7B,OAAO,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAC;AACvE,CAAC","sourcesContent":["export function isMotionReduced(): boolean {\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n"]}
1
+ {"version":3,"file":"is-motion-reduced.js","sourceRoot":"","sources":["../../../src/utils/is-motion-reduced.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe;IAC7B,OAAO,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAC;AACvE,CAAC","sourcesContent":["export function isMotionReduced(): boolean {\n return window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { EMPTY_VALUES } from "./constants";
2
2
  export function checkNonEmpty(value, error) {
3
- if (EMPTY_VALUES.some(v => v === value)) {
4
- throw new Error(error);
5
- }
3
+ if (EMPTY_VALUES.some(v => v === value)) {
4
+ throw new Error(error);
5
+ }
6
6
  }
7
7
  //# sourceMappingURL=check-non-empty.js.map