@swisspost/design-system-components 1.6.2 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (317) 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-e7618bb3.js → index-c07c0cdb.js} +79 -59
  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-cd0e9960.js +7 -0
  11. package/dist/cjs/package-cd0e9960.js.map +1 -0
  12. package/dist/cjs/post-accordion-f2e00198.js +87 -0
  13. package/dist/cjs/post-accordion-f2e00198.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-6d0b5e58.js +101 -0
  17. package/dist/cjs/{post-alert-1fb90f2d.js.map → post-alert-6d0b5e58.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-0b8dce97.js +93 -0
  21. package/dist/cjs/post-collapsible-0b8dce97.js.map +1 -0
  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-3dbb7728.js +105 -0
  27. package/dist/cjs/post-icon-3dbb7728.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-ea22d235.js +118 -0
  31. package/dist/cjs/post-popover-ea22d235.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-42e4ab15.js +1878 -0
  35. package/dist/cjs/post-popovercontainer-42e4ab15.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-09074905.js +33 -0
  39. package/dist/cjs/{post-tab-header-a3845fe5.js.map → post-tab-header-09074905.js.map} +1 -1
  40. package/dist/cjs/post-tab-header.cjs.entry.js +4 -4
  41. package/dist/cjs/post-tab-panel-9547b9ac.js +27 -0
  42. package/dist/cjs/{post-tab-panel-b7326ff8.js.map → post-tab-panel-9547b9ac.js.map} +1 -1
  43. package/dist/cjs/post-tab-panel.cjs.entry.js +3 -3
  44. package/dist/cjs/post-tabs-2ec2778e.js +153 -0
  45. package/dist/cjs/post-tabs-2ec2778e.js.map +1 -0
  46. package/dist/cjs/post-tabs.cjs.entry.js +3 -3
  47. package/dist/cjs/{post-tooltip-2becc97a.js → post-tooltip-c802c51f.js} +78 -1754
  48. package/dist/cjs/post-tooltip-c802c51f.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.css +1 -1
  60. package/dist/collection/components/post-collapsible/post-collapsible.js +170 -169
  61. package/dist/collection/components/post-collapsible/post-collapsible.js.map +1 -1
  62. package/dist/collection/components/post-icon/post-icon.css +1 -1
  63. package/dist/collection/components/post-icon/post-icon.js +250 -250
  64. package/dist/collection/components/post-icon/post-icon.js.map +1 -1
  65. package/dist/collection/components/post-popover/post-popover.css +3 -0
  66. package/dist/collection/components/post-popover/post-popover.js +267 -0
  67. package/dist/collection/components/post-popover/post-popover.js.map +1 -0
  68. package/dist/collection/components/post-popovercontainer/post-popovercontainer.css +1 -0
  69. package/dist/collection/components/post-popovercontainer/post-popovercontainer.js +288 -0
  70. package/dist/collection/components/post-popovercontainer/post-popovercontainer.js.map +1 -0
  71. package/dist/collection/components/post-tab-header/post-tab-header.css +1 -1
  72. package/dist/collection/components/post-tab-header/post-tab-header.js +62 -62
  73. package/dist/collection/components/post-tab-header/post-tab-header.js.map +1 -1
  74. package/dist/collection/components/post-tab-panel/post-tab-panel.js +50 -50
  75. package/dist/collection/components/post-tab-panel/post-tab-panel.js.map +1 -1
  76. package/dist/collection/components/post-tabs/post-tabs.css +1 -1
  77. package/dist/collection/components/post-tabs/post-tabs.js +224 -223
  78. package/dist/collection/components/post-tabs/post-tabs.js.map +1 -1
  79. package/dist/collection/components/post-tooltip/post-tooltip.css +1 -1
  80. package/dist/collection/components/post-tooltip/post-tooltip.js +192 -325
  81. package/dist/collection/components/post-tooltip/post-tooltip.js.map +1 -1
  82. package/dist/collection/index.js +3 -0
  83. package/dist/collection/index.js.map +1 -1
  84. package/dist/collection/utils/is-motion-reduced.js +1 -1
  85. package/dist/collection/utils/is-motion-reduced.js.map +1 -1
  86. package/dist/collection/utils/property-checkers/check-non-empty.js +3 -3
  87. package/dist/collection/utils/property-checkers/check-non-empty.js.map +1 -1
  88. package/dist/collection/utils/property-checkers/check-one-of.js +2 -2
  89. package/dist/collection/utils/property-checkers/check-one-of.js.map +1 -1
  90. package/dist/collection/utils/property-checkers/check-pattern.js +2 -2
  91. package/dist/collection/utils/property-checkers/check-pattern.js.map +1 -1
  92. package/dist/collection/utils/property-checkers/check-type.js +10 -10
  93. package/dist/collection/utils/property-checkers/check-type.js.map +1 -1
  94. package/dist/collection/utils/property-checkers/empty-or.js +5 -5
  95. package/dist/collection/utils/property-checkers/empty-or.js.map +1 -1
  96. package/dist/components/check-non-empty.js +3 -3
  97. package/dist/components/check-non-empty.js.map +1 -1
  98. package/dist/components/index.js +3 -0
  99. package/dist/components/index.js.map +1 -1
  100. package/dist/components/index2.js +22 -18
  101. package/dist/components/index2.js.map +1 -1
  102. package/dist/components/package.js +1 -1
  103. package/dist/components/post-accordion.d.ts +2 -2
  104. package/dist/components/post-accordion.js +1 -101
  105. package/dist/components/post-accordion.js.map +1 -1
  106. package/dist/components/post-accordion2.js +105 -0
  107. package/dist/components/post-accordion2.js.map +1 -0
  108. package/dist/components/post-alert.d.ts +2 -2
  109. package/dist/components/post-alert2.js +119 -119
  110. package/dist/components/post-alert2.js.map +1 -1
  111. package/dist/components/post-collapsible.d.ts +2 -2
  112. package/dist/components/post-collapsible2.js +91 -91
  113. package/dist/components/post-collapsible2.js.map +1 -1
  114. package/dist/components/post-icon.d.ts +2 -2
  115. package/dist/components/post-icon2.js +118 -118
  116. package/dist/components/post-icon2.js.map +1 -1
  117. package/dist/components/post-popover.d.ts +11 -0
  118. package/dist/components/post-popover.js +8 -0
  119. package/dist/components/post-popover.js.map +1 -0
  120. package/dist/components/post-popover2.js +144 -0
  121. package/dist/components/post-popover2.js.map +1 -0
  122. package/dist/components/post-popovercontainer.d.ts +11 -0
  123. package/dist/components/post-popovercontainer.js +8 -0
  124. package/dist/components/post-popovercontainer.js.map +1 -0
  125. package/dist/components/post-popovercontainer2.js +1897 -0
  126. package/dist/components/post-popovercontainer2.js.map +1 -0
  127. package/dist/components/post-tab-header.d.ts +2 -2
  128. package/dist/components/post-tab-header2.js +38 -38
  129. package/dist/components/post-tab-header2.js.map +1 -1
  130. package/dist/components/post-tab-panel.d.ts +2 -2
  131. package/dist/components/post-tab-panel2.js +30 -30
  132. package/dist/components/post-tab-panel2.js.map +1 -1
  133. package/dist/components/post-tabs.d.ts +2 -2
  134. package/dist/components/post-tabs2.js +147 -147
  135. package/dist/components/post-tabs2.js.map +1 -1
  136. package/dist/components/post-tooltip.d.ts +2 -2
  137. package/dist/components/post-tooltip2.js +100 -1774
  138. package/dist/components/post-tooltip2.js.map +1 -1
  139. package/dist/docs.d.ts +1 -21
  140. package/dist/docs.json +610 -78
  141. package/dist/esm/check-non-empty-58bd6b17.js +11 -0
  142. package/dist/esm/{check-non-empty-09c39561.js.map → check-non-empty-58bd6b17.js.map} +1 -1
  143. package/dist/esm/index-1427953c.js +40 -0
  144. package/dist/esm/index-1427953c.js.map +1 -0
  145. package/dist/esm/{index-08d62a75.js → index-35998e08.js} +79 -59
  146. package/dist/esm/index-35998e08.js.map +1 -0
  147. package/dist/esm/index.js +14 -12
  148. package/dist/esm/index.js.map +1 -1
  149. package/dist/esm/loader.js +3 -3
  150. package/dist/esm/package-337354c3.js +5 -0
  151. package/dist/esm/package-337354c3.js.map +1 -0
  152. package/dist/esm/post-accordion-c2013bb3.js +85 -0
  153. package/dist/esm/post-accordion-c2013bb3.js.map +1 -0
  154. package/dist/esm/post-accordion.entry.js +3 -83
  155. package/dist/esm/post-accordion.entry.js.map +1 -1
  156. package/dist/esm/post-alert-7254a70f.js +99 -0
  157. package/dist/esm/{post-alert-46926902.js.map → post-alert-7254a70f.js.map} +1 -1
  158. package/dist/esm/post-alert.entry.js +5 -6
  159. package/dist/esm/post-alert.entry.js.map +1 -1
  160. package/dist/esm/post-collapsible-4464cc98.js +91 -0
  161. package/dist/esm/post-collapsible-4464cc98.js.map +1 -0
  162. package/dist/esm/post-collapsible.entry.js +4 -5
  163. package/dist/esm/post-collapsible.entry.js.map +1 -1
  164. package/dist/esm/post-components.js +4 -4
  165. package/dist/esm/post-components.js.map +1 -1
  166. package/dist/esm/post-icon-e0bbf0f5.js +103 -0
  167. package/dist/esm/post-icon-e0bbf0f5.js.map +1 -0
  168. package/dist/esm/post-icon.entry.js +5 -6
  169. package/dist/esm/post-icon.entry.js.map +1 -1
  170. package/dist/esm/post-popover-25eb3f76.js +116 -0
  171. package/dist/esm/post-popover-25eb3f76.js.map +1 -0
  172. package/dist/esm/post-popover.entry.js +5 -0
  173. package/dist/esm/post-popover.entry.js.map +1 -0
  174. package/dist/esm/post-popovercontainer-54117eea.js +1876 -0
  175. package/dist/esm/post-popovercontainer-54117eea.js.map +1 -0
  176. package/dist/esm/post-popovercontainer.entry.js +5 -0
  177. package/dist/esm/post-popovercontainer.entry.js.map +1 -0
  178. package/dist/esm/post-tab-header-1684b507.js +31 -0
  179. package/dist/esm/{post-tab-header-84b12382.js.map → post-tab-header-1684b507.js.map} +1 -1
  180. package/dist/esm/post-tab-header.entry.js +4 -4
  181. package/dist/esm/post-tab-panel-add26fe5.js +25 -0
  182. package/dist/esm/{post-tab-panel-216c0b6e.js.map → post-tab-panel-add26fe5.js.map} +1 -1
  183. package/dist/esm/post-tab-panel.entry.js +3 -3
  184. package/dist/esm/post-tabs-d738e61f.js +151 -0
  185. package/dist/esm/post-tabs-d738e61f.js.map +1 -0
  186. package/dist/esm/post-tabs.entry.js +3 -3
  187. package/dist/esm/{post-tooltip-47f2146d.js → post-tooltip-57928808.js} +78 -1754
  188. package/dist/esm/post-tooltip-57928808.js.map +1 -0
  189. package/dist/esm/post-tooltip.entry.js +3 -4
  190. package/dist/esm/post-tooltip.entry.js.map +1 -1
  191. package/dist/post-components/index.esm.js +1 -1
  192. package/dist/post-components/p-05e85f2b.entry.js +2 -0
  193. package/dist/post-components/p-08abd53e.entry.js +2 -0
  194. package/dist/post-components/p-09892ad1.js +2 -0
  195. package/dist/post-components/{p-57b48dff.js.map → p-09892ad1.js.map} +1 -1
  196. package/dist/post-components/p-1e9ec4a9.entry.js +2 -0
  197. package/dist/post-components/p-1f55663e.js +2 -0
  198. package/dist/post-components/p-1f55663e.js.map +1 -0
  199. package/dist/post-components/p-30c60b6c.entry.js +2 -0
  200. package/dist/post-components/p-38d97f62.entry.js +2 -0
  201. package/dist/post-components/p-4c188911.entry.js +2 -0
  202. package/dist/post-components/p-568bb469.entry.js +2 -0
  203. package/dist/post-components/p-65c8bd5c.entry.js +2 -0
  204. package/dist/post-components/p-6e3158e8.js +2 -0
  205. package/dist/post-components/{p-21549a50.js.map → p-6e3158e8.js.map} +1 -1
  206. package/dist/post-components/p-7d32dfb7.js +2 -0
  207. package/dist/post-components/{p-57fdeeab.js.map → p-7d32dfb7.js.map} +1 -1
  208. package/dist/post-components/p-81591ad0.js +3 -0
  209. package/dist/post-components/p-81591ad0.js.map +1 -0
  210. package/dist/post-components/p-96f4ebc4.js +2 -0
  211. package/dist/post-components/p-96f4ebc4.js.map +1 -0
  212. package/dist/post-components/p-9bd5f824.js +2 -0
  213. package/dist/post-components/p-9bd5f824.js.map +1 -0
  214. package/dist/post-components/{p-b531475e.js → p-b095519d.js} +1 -1
  215. package/dist/post-components/p-b4b4f59a.js +2 -0
  216. package/dist/post-components/p-bd032124.js +2 -0
  217. package/dist/post-components/p-bd032124.js.map +1 -0
  218. package/dist/post-components/p-c5858d52.entry.js +2 -0
  219. package/dist/post-components/p-c5858d52.entry.js.map +1 -0
  220. package/dist/post-components/{p-ce907090.entry.js → p-dbd07f20.js} +2 -2
  221. package/dist/post-components/p-de493e36.js +2 -0
  222. package/dist/post-components/p-de493e36.js.map +1 -0
  223. package/dist/post-components/p-eaddd6cc.js +2 -0
  224. package/dist/post-components/p-eaddd6cc.js.map +1 -0
  225. package/dist/post-components/p-ed73d4c0.entry.js +2 -0
  226. package/dist/post-components/p-ed73d4c0.entry.js.map +1 -0
  227. package/dist/post-components/p-f994dce8.js +9 -0
  228. package/dist/post-components/p-f994dce8.js.map +1 -0
  229. package/dist/post-components/post-components.esm.js +1 -1
  230. package/dist/post-components/post-components.esm.js.map +1 -1
  231. package/dist/types/components/post-accordion/post-accordion.d.ts +26 -26
  232. package/dist/types/components/post-alert/post-alert.d.ts +45 -45
  233. package/dist/types/components/post-collapsible/post-collapsible.d.ts +31 -31
  234. package/dist/types/components/post-icon/post-icon.d.ts +43 -43
  235. package/dist/types/components/post-popover/post-popover.d.ts +53 -0
  236. package/dist/types/components/post-popovercontainer/post-popovercontainer.d.ts +62 -0
  237. package/dist/types/components/post-tab-header/post-tab-header.d.ts +9 -9
  238. package/dist/types/components/post-tab-panel/post-tab-panel.d.ts +8 -8
  239. package/dist/types/components/post-tabs/post-tabs.d.ts +32 -32
  240. package/dist/types/components/post-tooltip/post-tooltip.d.ts +35 -62
  241. package/dist/types/components.d.ts +115 -10
  242. package/dist/types/index.d.ts +3 -0
  243. package/dist/types/stencil-public-runtime.d.ts +8 -0
  244. package/package.json +16 -14
  245. package/dist/cjs/check-non-empty-ae713942.js.map +0 -1
  246. package/dist/cjs/check-one-of-27ad3154.js +0 -10
  247. package/dist/cjs/check-one-of-27ad3154.js.map +0 -1
  248. package/dist/cjs/index-b38a23e0.js +0 -41
  249. package/dist/cjs/index-b38a23e0.js.map +0 -1
  250. package/dist/cjs/index-e7618bb3.js.map +0 -1
  251. package/dist/cjs/package-041a8597.js +0 -7
  252. package/dist/cjs/package-041a8597.js.map +0 -1
  253. package/dist/cjs/post-alert-1fb90f2d.js +0 -101
  254. package/dist/cjs/post-collapsible-e46002bb.js +0 -93
  255. package/dist/cjs/post-collapsible-e46002bb.js.map +0 -1
  256. package/dist/cjs/post-icon-91f6603a.js +0 -105
  257. package/dist/cjs/post-icon-91f6603a.js.map +0 -1
  258. package/dist/cjs/post-tab-header-a3845fe5.js +0 -33
  259. package/dist/cjs/post-tab-panel-b7326ff8.js +0 -27
  260. package/dist/cjs/post-tabs-384a1fab.js +0 -153
  261. package/dist/cjs/post-tabs-384a1fab.js.map +0 -1
  262. package/dist/cjs/post-tooltip-2becc97a.js.map +0 -1
  263. package/dist/components/check-one-of.js +0 -8
  264. package/dist/components/check-one-of.js.map +0 -1
  265. package/dist/esm/check-non-empty-09c39561.js +0 -11
  266. package/dist/esm/check-one-of-74750af9.js +0 -8
  267. package/dist/esm/check-one-of-74750af9.js.map +0 -1
  268. package/dist/esm/index-08d62a75.js.map +0 -1
  269. package/dist/esm/index-35921354.js +0 -36
  270. package/dist/esm/index-35921354.js.map +0 -1
  271. package/dist/esm/package-a962a93d.js +0 -5
  272. package/dist/esm/package-a962a93d.js.map +0 -1
  273. package/dist/esm/post-alert-46926902.js +0 -99
  274. package/dist/esm/post-collapsible-f1b6592d.js +0 -91
  275. package/dist/esm/post-collapsible-f1b6592d.js.map +0 -1
  276. package/dist/esm/post-icon-fb627697.js +0 -103
  277. package/dist/esm/post-icon-fb627697.js.map +0 -1
  278. package/dist/esm/post-tab-header-84b12382.js +0 -31
  279. package/dist/esm/post-tab-panel-216c0b6e.js +0 -25
  280. package/dist/esm/post-tabs-e235d663.js +0 -151
  281. package/dist/esm/post-tabs-e235d663.js.map +0 -1
  282. package/dist/esm/post-tooltip-47f2146d.js.map +0 -1
  283. package/dist/post-components/p-03fe58da.js +0 -2
  284. package/dist/post-components/p-03fe58da.js.map +0 -1
  285. package/dist/post-components/p-1339f8cd.js +0 -2
  286. package/dist/post-components/p-1339f8cd.js.map +0 -1
  287. package/dist/post-components/p-151b55c0.entry.js +0 -2
  288. package/dist/post-components/p-21549a50.js +0 -2
  289. package/dist/post-components/p-4cb18ddf.js +0 -9
  290. package/dist/post-components/p-4cb18ddf.js.map +0 -1
  291. package/dist/post-components/p-4e24f13b.entry.js +0 -2
  292. package/dist/post-components/p-57b48dff.js +0 -2
  293. package/dist/post-components/p-57fdeeab.js +0 -2
  294. package/dist/post-components/p-58cc7b5a.entry.js +0 -2
  295. package/dist/post-components/p-6cafa644.entry.js +0 -2
  296. package/dist/post-components/p-7f370d77.entry.js +0 -2
  297. package/dist/post-components/p-7f4eba57.js +0 -2
  298. package/dist/post-components/p-8c006e7d.js +0 -3
  299. package/dist/post-components/p-8c006e7d.js.map +0 -1
  300. package/dist/post-components/p-aee47e1a.entry.js +0 -2
  301. package/dist/post-components/p-b5e1fd89.js +0 -2
  302. package/dist/post-components/p-b5e1fd89.js.map +0 -1
  303. package/dist/post-components/p-d13111f2.js +0 -2
  304. package/dist/post-components/p-dfe29f7f.js +0 -2
  305. package/dist/post-components/p-dfe29f7f.js.map +0 -1
  306. package/dist/post-components/p-f35c2075.entry.js +0 -2
  307. /package/dist/post-components/{p-151b55c0.entry.js.map → p-05e85f2b.entry.js.map} +0 -0
  308. /package/dist/post-components/{p-4e24f13b.entry.js.map → p-08abd53e.entry.js.map} +0 -0
  309. /package/dist/post-components/{p-58cc7b5a.entry.js.map → p-1e9ec4a9.entry.js.map} +0 -0
  310. /package/dist/post-components/{p-6cafa644.entry.js.map → p-30c60b6c.entry.js.map} +0 -0
  311. /package/dist/post-components/{p-7f370d77.entry.js.map → p-38d97f62.entry.js.map} +0 -0
  312. /package/dist/post-components/{p-aee47e1a.entry.js.map → p-4c188911.entry.js.map} +0 -0
  313. /package/dist/post-components/{p-d13111f2.js.map → p-568bb469.entry.js.map} +0 -0
  314. /package/dist/post-components/{p-f35c2075.entry.js.map → p-65c8bd5c.entry.js.map} +0 -0
  315. /package/dist/post-components/{p-b531475e.js.map → p-b095519d.js.map} +0 -0
  316. /package/dist/post-components/{p-7f4eba57.js.map → p-b4b4f59a.js.map} +0 -0
  317. /package/dist/post-components/{p-ce907090.entry.js.map → p-dbd07f20.js.map} +0 -0
@@ -0,0 +1,267 @@
1
+ import { h, Host } from "@stencil/core";
2
+ import { version } from "../../../package.json";
3
+ export class PostPopover {
4
+ constructor() {
5
+ this.placement = 'top';
6
+ this.closeButtonCaption = undefined;
7
+ this.arrow = true;
8
+ this.localTogglePopover = e => this.toggle(e.target);
9
+ this.localEnterTogglePopover = e => {
10
+ if (e.key === 'Enter')
11
+ this.toggle(e.target);
12
+ };
13
+ this.localTouchTogglePopover = e => {
14
+ e.preventDefault();
15
+ this.toggle(e.target);
16
+ };
17
+ }
18
+ connectedCallback() {
19
+ if (!this.triggers) {
20
+ throw new Error(`No trigger found for <post-popover popover-id="${this.host.id}`);
21
+ }
22
+ // As long as cross-shadow-boundary [popovertarget] and button.popoverTargetElement are not working
23
+ // we're left with listening to trigger events ourselves
24
+ // https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/popoverTargetElement
25
+ // https://github.com/whatwg/html/issues/9109#issuecomment-1494030465 (does not seem to work for now)
26
+ // https://stackoverflow.com/questions/77324143/popovertargetelement-does-not-cross-shadow-boundaries?noredirect=1#comment136318281_77324143
27
+ this.triggers.forEach(trigger => {
28
+ // See this.onToggle for one time mouse event listener
29
+ trigger.addEventListener('mouseup', this.localTogglePopover, { once: true });
30
+ trigger.addEventListener('keypress', this.localEnterTogglePopover);
31
+ trigger.addEventListener('touch', this.localTouchTogglePopover, { once: true });
32
+ trigger.setAttribute('aria-expanded', 'false');
33
+ });
34
+ }
35
+ disconnectedCallback() {
36
+ this.triggers.forEach(trigger => {
37
+ trigger.removeEventListener('mouseup', this.localTogglePopover);
38
+ trigger.removeEventListener('keypress', this.localEnterTogglePopover);
39
+ trigger.removeEventListener('touch', this.localTouchTogglePopover);
40
+ trigger.removeAttribute('aria-expanded');
41
+ });
42
+ }
43
+ /**
44
+ * Programmatically display the popover
45
+ * @param target An element with [data-popover-target="id"] where the popover should be shown
46
+ */
47
+ async show(target) {
48
+ this.currentTarget = target;
49
+ this.popoverRef.show(target);
50
+ target.setAttribute('aria-expanded', 'true');
51
+ }
52
+ /**
53
+ * Programmatically hide this popover
54
+ */
55
+ async hide() {
56
+ this.popoverRef.hide();
57
+ this.triggers.forEach(trigger => trigger.setAttribute('aria-expanded', 'false'));
58
+ }
59
+ /**
60
+ * Toggle popover display
61
+ * @param target An element with [data-popover-target="id"] where the popover should be anchored to
62
+ * @param force Pass true to always show or false to always hide
63
+ */
64
+ async toggle(target, force) {
65
+ this.currentTarget = target;
66
+ const newState = await this.popoverRef.toggle(target, force);
67
+ target.setAttribute('aria-expanded', `${newState}`);
68
+ }
69
+ get triggers() {
70
+ return document.querySelectorAll(`[data-popover-target="${this.host.id}"]`);
71
+ }
72
+ /**
73
+ * One time event handler for click events
74
+ * A permanent event listener would prevent a toggle button from working properly:
75
+ * A click opens the popover, a second click first closes it (due to light dismiss), then directly
76
+ * opens it again because of the click listener on the button. Registering a new
77
+ * one time listener after a small timeout solves this issue.
78
+ * @param e toggle event from post-popovercontainer
79
+ */
80
+ onToggle(e) {
81
+ if (this.currentTarget) {
82
+ this.currentTarget.setAttribute('aria-expanded', `${e.detail}`);
83
+ }
84
+ if (!e.detail) {
85
+ window.requestAnimationFrame(() => {
86
+ this.triggers.forEach(trigger => {
87
+ trigger.addEventListener('mouseup', this.localTogglePopover, { once: true });
88
+ trigger.addEventListener('touch', this.localTouchTogglePopover, { once: true });
89
+ });
90
+ });
91
+ // Handle missing re-focusing logic after close. Can be removed as soon as popovertarget works correctly
92
+ if (this.currentTarget) {
93
+ this.currentTarget.focus();
94
+ this.currentTarget = null;
95
+ }
96
+ }
97
+ }
98
+ // Fix for firefox to prevent the following lines from triggering
99
+ // https://github.com/oddbird/popover-polyfill/blob/main/src/popover.ts#L338
100
+ stopImmediatePropagation(e) {
101
+ e.stopImmediatePropagation();
102
+ }
103
+ render() {
104
+ return (h(Host, { "data-version": version }, h("post-popovercontainer", { arrow: this.arrow, placement: this.placement, ref: e => (this.popoverRef = e), onPostPopoverToggled: e => this.onToggle(e) }, h("div", { class: "popover-container", onPointerDown: e => this.stopImmediatePropagation(e), onPointerUp: e => this.stopImmediatePropagation(e) }, h("div", { class: "popover-content" }, h("slot", null)), h("button", { class: "btn-close", onClick: () => this.hide() }, h("span", { class: "visually-hidden" }, this.closeButtonCaption))))));
105
+ }
106
+ static get is() { return "post-popover"; }
107
+ static get encapsulation() { return "shadow"; }
108
+ static get originalStyleUrls() {
109
+ return {
110
+ "$": ["post-popover.scss"]
111
+ };
112
+ }
113
+ static get styleUrls() {
114
+ return {
115
+ "$": ["post-popover.css"]
116
+ };
117
+ }
118
+ static get properties() {
119
+ return {
120
+ "placement": {
121
+ "type": "string",
122
+ "mutable": false,
123
+ "complexType": {
124
+ "original": "Placement",
125
+ "resolved": "\"bottom\" | \"bottom-end\" | \"bottom-start\" | \"left\" | \"left-end\" | \"left-start\" | \"right\" | \"right-end\" | \"right-start\" | \"top\" | \"top-end\" | \"top-start\"",
126
+ "references": {
127
+ "Placement": {
128
+ "location": "import",
129
+ "path": "@floating-ui/dom",
130
+ "id": "../../node_modules/.pnpm/@floating-ui+dom@1.5.4/node_modules/@floating-ui/dom/dist/floating-ui.dom.d.ts::Placement"
131
+ }
132
+ }
133
+ },
134
+ "required": false,
135
+ "optional": true,
136
+ "docs": {
137
+ "tags": [],
138
+ "text": "Defines the placement of the popover according to the floating-ui options available at https://floating-ui.com/docs/computePosition#placement.\nPopoverss 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."
139
+ },
140
+ "attribute": "placement",
141
+ "reflect": false,
142
+ "defaultValue": "'top'"
143
+ },
144
+ "closeButtonCaption": {
145
+ "type": "string",
146
+ "mutable": false,
147
+ "complexType": {
148
+ "original": "string",
149
+ "resolved": "string",
150
+ "references": {}
151
+ },
152
+ "required": true,
153
+ "optional": false,
154
+ "docs": {
155
+ "tags": [],
156
+ "text": "Define the caption of the close button for assistive technology"
157
+ },
158
+ "attribute": "close-button-caption",
159
+ "reflect": false
160
+ },
161
+ "arrow": {
162
+ "type": "boolean",
163
+ "mutable": false,
164
+ "complexType": {
165
+ "original": "boolean",
166
+ "resolved": "boolean",
167
+ "references": {}
168
+ },
169
+ "required": false,
170
+ "optional": true,
171
+ "docs": {
172
+ "tags": [],
173
+ "text": "Show a little indicator arrow"
174
+ },
175
+ "attribute": "arrow",
176
+ "reflect": false,
177
+ "defaultValue": "true"
178
+ }
179
+ };
180
+ }
181
+ static get methods() {
182
+ return {
183
+ "show": {
184
+ "complexType": {
185
+ "signature": "(target: HTMLElement) => Promise<void>",
186
+ "parameters": [{
187
+ "name": "target",
188
+ "type": "HTMLElement",
189
+ "docs": "An element with [data-popover-target=\"id\"] where the popover should be shown"
190
+ }],
191
+ "references": {
192
+ "Promise": {
193
+ "location": "global",
194
+ "id": "global::Promise"
195
+ },
196
+ "HTMLElement": {
197
+ "location": "global",
198
+ "id": "global::HTMLElement"
199
+ }
200
+ },
201
+ "return": "Promise<void>"
202
+ },
203
+ "docs": {
204
+ "text": "Programmatically display the popover",
205
+ "tags": [{
206
+ "name": "param",
207
+ "text": "target An element with [data-popover-target=\"id\"] where the popover should be shown"
208
+ }]
209
+ }
210
+ },
211
+ "hide": {
212
+ "complexType": {
213
+ "signature": "() => Promise<void>",
214
+ "parameters": [],
215
+ "references": {
216
+ "Promise": {
217
+ "location": "global",
218
+ "id": "global::Promise"
219
+ }
220
+ },
221
+ "return": "Promise<void>"
222
+ },
223
+ "docs": {
224
+ "text": "Programmatically hide this popover",
225
+ "tags": []
226
+ }
227
+ },
228
+ "toggle": {
229
+ "complexType": {
230
+ "signature": "(target: HTMLElement, force?: boolean) => Promise<void>",
231
+ "parameters": [{
232
+ "name": "target",
233
+ "type": "HTMLElement",
234
+ "docs": "An element with [data-popover-target=\"id\"] where the popover should be anchored to"
235
+ }, {
236
+ "name": "force",
237
+ "type": "boolean",
238
+ "docs": "Pass true to always show or false to always hide"
239
+ }],
240
+ "references": {
241
+ "Promise": {
242
+ "location": "global",
243
+ "id": "global::Promise"
244
+ },
245
+ "HTMLElement": {
246
+ "location": "global",
247
+ "id": "global::HTMLElement"
248
+ }
249
+ },
250
+ "return": "Promise<void>"
251
+ },
252
+ "docs": {
253
+ "text": "Toggle popover display",
254
+ "tags": [{
255
+ "name": "param",
256
+ "text": "target An element with [data-popover-target=\"id\"] where the popover should be anchored to"
257
+ }, {
258
+ "name": "param",
259
+ "text": "force Pass true to always show or false to always hide"
260
+ }]
261
+ }
262
+ }
263
+ };
264
+ }
265
+ static get elementRef() { return "host"; }
266
+ }
267
+ //# sourceMappingURL=post-popover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-popover.js","sourceRoot":"","sources":["../../../../src/components/post-popover/post-popover.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAG1E,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAMhD,MAAM,OAAO,WAAW;IA0BtB;yBAZyC,KAAK;;qBAUX,IAAI;QAGrC,IAAI,CAAC,kBAAkB,GAAG,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAqB,CAAC,CAAC;QACpE,IAAI,CAAC,uBAAuB,GAAG,CAAC,CAAC,EAAE;YACjC,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO;gBAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAqB,CAAC,CAAC;QAC9D,CAAC,CAAC;QACF,IAAI,CAAC,uBAAuB,GAAG,CAAC,CAAC,EAAE;YACjC,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAqB,CAAC,CAAC;QACvC,CAAC,CAAC;KACH;IAED,iBAAiB;QACf,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAClB,MAAM,IAAI,KAAK,CAAC,kDAAkD,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;SACnF;QAED,mGAAmG;QACnG,wDAAwD;QACxD,0FAA0F;QAC1F,qGAAqG;QACrG,4IAA4I;QAC5I,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAC9B,sDAAsD;YACtD,OAAO,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,kBAAkB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAA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AC,IAAI,oBAAe,OAAO;YACzB,6BACE,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,EAC/B,oBAAoB,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAE3C,WACE,KAAK,EAAC,mBAAmB,EACzB,aAAa,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC,EACpD,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,CAAC;oBAElD,WAAK,KAAK,EAAC,iBAAiB;wBAC1B,eAAa,CACT;oBACN,cAAQ,KAAK,EAAC,WAAW,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE;wBAClD,YAAM,KAAK,EAAC,iBAAiB,IAAE,IAAI,CAAC,kBAAkB,CAAQ,CACvD,CACL,CACgB,CACnB,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, h, Host, Method, Prop } from '@stencil/core';\nimport { Placement } from '@floating-ui/dom';\n\nimport { version } from '../../../package.json';\n@Component({\n tag: 'post-popover',\n styleUrl: 'post-popover.scss',\n shadow: true,\n})\nexport class PostPopover {\n private popoverRef: HTMLPostPopovercontainerElement;\n private localTogglePopover: (e: Event) => Promise<void>;\n private localEnterTogglePopover: (e: KeyboardEvent) => void;\n private localTouchTogglePopover: (e: TouchEvent) => void;\n private currentTarget: HTMLElement;\n\n @Element() host: HTMLPostPopoverElement;\n\n /**\n * Defines the placement of the popover according to the floating-ui options available at https://floating-ui.com/docs/computePosition#placement.\n * Popoverss 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 /**\n * Define the caption of the close button for assistive technology\n */\n @Prop() readonly closeButtonCaption!: string;\n /**\n * Show a little indicator arrow\n */\n // eslint-disable-next-line @stencil-community/ban-default-true\n @Prop() readonly arrow?: boolean = true;\n\n constructor() {\n this.localTogglePopover = e => this.toggle(e.target as HTMLElement);\n this.localEnterTogglePopover = e => {\n if (e.key === 'Enter') this.toggle(e.target as HTMLElement);\n };\n this.localTouchTogglePopover = e => {\n e.preventDefault();\n this.toggle(e.target as HTMLElement);\n };\n }\n\n connectedCallback() {\n if (!this.triggers) {\n throw new Error(`No trigger found for <post-popover popover-id=\"${this.host.id}`);\n }\n\n // As long as cross-shadow-boundary [popovertarget] and button.popoverTargetElement are not working\n // we're left with listening to trigger events ourselves\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/popoverTargetElement\n // https://github.com/whatwg/html/issues/9109#issuecomment-1494030465 (does not seem to work for now)\n // https://stackoverflow.com/questions/77324143/popovertargetelement-does-not-cross-shadow-boundaries?noredirect=1#comment136318281_77324143\n this.triggers.forEach(trigger => {\n // See this.onToggle for one time mouse event listener\n trigger.addEventListener('mouseup', this.localTogglePopover, { once: true });\n trigger.addEventListener('keypress', this.localEnterTogglePopover);\n trigger.addEventListener('touch', this.localTouchTogglePopover, { once: true });\n trigger.setAttribute('aria-expanded', 'false');\n });\n }\n\n disconnectedCallback() {\n this.triggers.forEach(trigger => {\n trigger.removeEventListener('mouseup', this.localTogglePopover);\n trigger.removeEventListener('keypress', this.localEnterTogglePopover);\n trigger.removeEventListener('touch', this.localTouchTogglePopover);\n trigger.removeAttribute('aria-expanded');\n });\n }\n\n /**\n * Programmatically display the popover\n * @param target An element with [data-popover-target=\"id\"] where the popover should be shown\n */\n @Method()\n async show(target: HTMLElement) {\n this.currentTarget = target;\n this.popoverRef.show(target);\n target.setAttribute('aria-expanded', 'true');\n }\n\n /**\n * Programmatically hide this popover\n */\n @Method()\n async hide() {\n this.popoverRef.hide();\n this.triggers.forEach(trigger => trigger.setAttribute('aria-expanded', 'false'));\n }\n\n /**\n * Toggle popover display\n * @param target An element with [data-popover-target=\"id\"] where the popover should be anchored to\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.currentTarget = target;\n const newState = await this.popoverRef.toggle(target, force);\n target.setAttribute('aria-expanded', `${newState}`);\n }\n\n private get triggers() {\n return document.querySelectorAll(`[data-popover-target=\"${this.host.id}\"]`);\n }\n\n /**\n * One time event handler for click events\n * A permanent event listener would prevent a toggle button from working properly:\n * A click opens the popover, a second click first closes it (due to light dismiss), then directly\n * opens it again because of the click listener on the button. Registering a new\n * one time listener after a small timeout solves this issue.\n * @param e toggle event from post-popovercontainer\n */\n private onToggle(e: CustomEvent<boolean>) {\n if (this.currentTarget) {\n this.currentTarget.setAttribute('aria-expanded', `${e.detail}`);\n }\n if (!e.detail) {\n window.requestAnimationFrame(() => {\n this.triggers.forEach(trigger => {\n trigger.addEventListener('mouseup', this.localTogglePopover, { once: true });\n trigger.addEventListener('touch', this.localTouchTogglePopover, { once: true });\n });\n });\n\n // Handle missing re-focusing logic after close. Can be removed as soon as popovertarget works correctly\n if (this.currentTarget) {\n this.currentTarget.focus();\n this.currentTarget = null;\n }\n }\n }\n\n // Fix for firefox to prevent the following lines from triggering\n // https://github.com/oddbird/popover-polyfill/blob/main/src/popover.ts#L338\n private stopImmediatePropagation(e: PointerEvent) {\n e.stopImmediatePropagation();\n }\n\n render() {\n return (\n <Host data-version={version}>\n <post-popovercontainer\n arrow={this.arrow}\n placement={this.placement}\n ref={e => (this.popoverRef = e)}\n onPostPopoverToggled={e => this.onToggle(e)}\n >\n <div\n class=\"popover-container\"\n onPointerDown={e => this.stopImmediatePropagation(e)}\n onPointerUp={e => this.stopImmediatePropagation(e)}\n >\n <div class=\"popover-content\">\n <slot></slot>\n </div>\n <button class=\"btn-close\" onClick={() => this.hide()}>\n <span class=\"visually-hidden\">{this.closeButtonCaption}</span>\n </button>\n </div>\n </post-popovercontainer>\n </Host>\n );\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ @layer polyfill{[popover]{position:fixed;z-index:2147483647;inset:0;padding:.25em;width:fit-content;height:fit-content;border-width:initial;border-color:initial;border-image:initial;border-style:solid;background-color:canvas;color:canvastext;overflow:auto;margin:auto}[popover]:not(.\:popover-open){display:none}[popover]:is(dialog[open]){display:revert}[anchor].\:popover-open{inset:auto}@supports selector([popover]:popover-open){[popover]:not(.\:popover-open,dialog[open]){display:revert}[anchor]:is(:popover-open){inset:auto}}@supports not (background-color: canvas){[popover]{background-color:white;color:black}}@supports(width: -moz-fit-content){[popover]{width:-moz-fit-content;height:-moz-fit-content}}@supports not (inset: 0){[popover]{top:0;left:0;right:0;bottom:0}}}.popover{box-shadow:.5px 3px 4px rgba(0,0,0,.1),2px 4px 10px 4px rgba(0,0,0,.12);position:fixed;z-index:1060;width:max-content;margin:0;padding:0;box-sizing:border-box;color:var(--post-contrast-color);background-color:rgb(var(--post-bg-rgb));border:1px solid rgba(0,0,0,0);border-radius:4px;overflow:visible}.arrow{position:absolute;width:.7071067812rem;height:.7071067812rem;background-color:inherit;rotate:45deg;pointer-events:none;z-index:-1;border-right:2px solid rgba(0,0,0,0);border-bottom:2px solid rgba(0,0,0,0)}
@@ -0,0 +1,288 @@
1
+ import { h, Host } from "@stencil/core";
2
+ import { arrow, autoUpdate, computePosition, flip, inline, offset, shift, limitShift, size, } from "@floating-ui/dom";
3
+ // Polyfill for popovers, can be removed when https://caniuse.com/?search=popover is green
4
+ import "@oddbird/popover-polyfill";
5
+ import { version } from "../../../package.json";
6
+ const SIDE_MAP = {
7
+ top: 'bottom',
8
+ right: 'left',
9
+ bottom: 'top',
10
+ left: 'right',
11
+ };
12
+ export class PostPopovercontainer {
13
+ constructor() {
14
+ this.placement = 'top';
15
+ this.arrow = false;
16
+ }
17
+ componentDidLoad() {
18
+ this.popoverRef.setAttribute('popover', '');
19
+ this.popoverRef.addEventListener('beforetoggle', this.handleToggle.bind(this));
20
+ }
21
+ disconnectedCallback() {
22
+ if (this.popoverRef)
23
+ this.popoverRef.removeEventListener('beforetoggle', e => this.toggle(e.target));
24
+ if (typeof this.clearAutoUpdate === 'function')
25
+ this.clearAutoUpdate();
26
+ }
27
+ /**
28
+ * Programmatically display the tooltip
29
+ * @param target An element with [data-tooltip-target="id"] where the tooltip should be shown
30
+ */
31
+ async show(target) {
32
+ this.eventTarget = target;
33
+ this.popoverRef.showPopover();
34
+ }
35
+ /**
36
+ * Programmatically hide this tooltip
37
+ */
38
+ async hide() {
39
+ this.eventTarget = null;
40
+ this.popoverRef.hidePopover();
41
+ }
42
+ /**
43
+ * Toggle tooltip display
44
+ * @param target An element with [data-tooltip-target="id"] where the tooltip should be shown
45
+ * @param force Pass true to always show or false to always hide
46
+ */
47
+ async toggle(target, force) {
48
+ this.eventTarget = target;
49
+ this.popoverRef.togglePopover(force);
50
+ return this.popoverRef.matches(':popover-open');
51
+ }
52
+ /**
53
+ * Start or stop auto updates based on tooltip events.
54
+ * Tooltips can be closed or opened with other methods than class members,
55
+ * therefore listening to the toggle event is safer for cleaning up.
56
+ * @param e ToggleEvent
57
+ */
58
+ handleToggle(e) {
59
+ const isOpen = e.newState === 'open';
60
+ if (isOpen) {
61
+ this.startAutoupdates();
62
+ }
63
+ else {
64
+ if (typeof this.clearAutoUpdate === 'function')
65
+ this.clearAutoUpdate();
66
+ }
67
+ this.postPopoverToggled.emit(isOpen);
68
+ }
69
+ /**
70
+ * Start listening for DOM updates, scroll events etc. that have
71
+ * an influence on tooltip positioning
72
+ */
73
+ startAutoupdates() {
74
+ this.clearAutoUpdate = autoUpdate(this.eventTarget, this.popoverRef, this.calculatePosition.bind(this));
75
+ }
76
+ async calculatePosition() {
77
+ const middleware = [
78
+ flip(),
79
+ inline(),
80
+ shift({
81
+ padding: 8,
82
+ // Prevents shifting away from the anchor too far, while shifting as far as possible
83
+ // https://floating-ui.com/docs/shift#limiter
84
+ limiter: limitShift({
85
+ offset: 32,
86
+ }),
87
+ }),
88
+ size({
89
+ apply({ availableWidth, elements }) {
90
+ Object.assign(elements.floating.style, {
91
+ maxWidth: `${availableWidth - 16}px`,
92
+ });
93
+ },
94
+ }),
95
+ offset(this.arrow ? 12 : 8), // 4px outside of element to account for focus outline + ~arrow size
96
+ ];
97
+ if (this.arrow) {
98
+ middleware.push(arrow({ element: this.arrowRef, padding: 8 }));
99
+ }
100
+ const { x, y, middlewareData, placement: currentPlacement, } = await computePosition(this.eventTarget, this.popoverRef, {
101
+ placement: this.placement || 'top',
102
+ strategy: 'fixed',
103
+ middleware,
104
+ });
105
+ // Tooltip
106
+ this.popoverRef.style.left = `${x}px`;
107
+ this.popoverRef.style.top = `${y}px`;
108
+ // Arrow
109
+ if (this.arrow) {
110
+ // Tutorial: https://codesandbox.io/s/mystifying-kare-ee3hmh?file=/src/index.js
111
+ const side = currentPlacement.split('-')[0];
112
+ const { x: arrowX, y: arrowY } = middlewareData.arrow;
113
+ const staticSide = SIDE_MAP[side];
114
+ Object.assign(this.arrowRef.style, {
115
+ top: arrowY ? `${arrowY}px` : '',
116
+ left: arrowX ? `${arrowX}px` : '',
117
+ [staticSide]: `${-this.arrowRef.offsetWidth / 2}px`,
118
+ });
119
+ }
120
+ }
121
+ render() {
122
+ return (h(Host, { "data-version": version }, h("div", { class: "popover", part: "popover", ref: (el) => (this.popoverRef = el) }, this.arrow && (h("span", { class: "arrow", ref: el => {
123
+ this.arrowRef = el;
124
+ } })), h("slot", null))));
125
+ }
126
+ static get is() { return "post-popovercontainer"; }
127
+ static get encapsulation() { return "shadow"; }
128
+ static get originalStyleUrls() {
129
+ return {
130
+ "$": ["post-popovercontainer.scss"]
131
+ };
132
+ }
133
+ static get styleUrls() {
134
+ return {
135
+ "$": ["post-popovercontainer.css"]
136
+ };
137
+ }
138
+ static get properties() {
139
+ return {
140
+ "placement": {
141
+ "type": "string",
142
+ "mutable": false,
143
+ "complexType": {
144
+ "original": "Placement",
145
+ "resolved": "\"bottom\" | \"bottom-end\" | \"bottom-start\" | \"left\" | \"left-end\" | \"left-start\" | \"right\" | \"right-end\" | \"right-start\" | \"top\" | \"top-end\" | \"top-start\"",
146
+ "references": {
147
+ "Placement": {
148
+ "location": "import",
149
+ "path": "@floating-ui/dom",
150
+ "id": "../../node_modules/.pnpm/@floating-ui+dom@1.5.4/node_modules/@floating-ui/dom/dist/floating-ui.dom.d.ts::Placement"
151
+ }
152
+ }
153
+ },
154
+ "required": false,
155
+ "optional": true,
156
+ "docs": {
157
+ "tags": [],
158
+ "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."
159
+ },
160
+ "attribute": "placement",
161
+ "reflect": false,
162
+ "defaultValue": "'top'"
163
+ },
164
+ "arrow": {
165
+ "type": "boolean",
166
+ "mutable": false,
167
+ "complexType": {
168
+ "original": "boolean",
169
+ "resolved": "boolean",
170
+ "references": {}
171
+ },
172
+ "required": false,
173
+ "optional": true,
174
+ "docs": {
175
+ "tags": [],
176
+ "text": "Wheter or not to display a little pointer arrow"
177
+ },
178
+ "attribute": "arrow",
179
+ "reflect": false,
180
+ "defaultValue": "false"
181
+ }
182
+ };
183
+ }
184
+ static get events() {
185
+ return [{
186
+ "method": "postPopoverToggled",
187
+ "name": "postPopoverToggled",
188
+ "bubbles": true,
189
+ "cancelable": true,
190
+ "composed": true,
191
+ "docs": {
192
+ "tags": [],
193
+ "text": "Fires whenever the popover gets shown or hidden, passing the new state in event.details as a boolean"
194
+ },
195
+ "complexType": {
196
+ "original": "boolean",
197
+ "resolved": "boolean",
198
+ "references": {}
199
+ }
200
+ }];
201
+ }
202
+ static get methods() {
203
+ return {
204
+ "show": {
205
+ "complexType": {
206
+ "signature": "(target: HTMLElement) => Promise<void>",
207
+ "parameters": [{
208
+ "name": "target",
209
+ "type": "HTMLElement",
210
+ "docs": "An element with [data-tooltip-target=\"id\"] where the tooltip should be shown"
211
+ }],
212
+ "references": {
213
+ "Promise": {
214
+ "location": "global",
215
+ "id": "global::Promise"
216
+ },
217
+ "HTMLElement": {
218
+ "location": "global",
219
+ "id": "global::HTMLElement"
220
+ }
221
+ },
222
+ "return": "Promise<void>"
223
+ },
224
+ "docs": {
225
+ "text": "Programmatically display the tooltip",
226
+ "tags": [{
227
+ "name": "param",
228
+ "text": "target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown"
229
+ }]
230
+ }
231
+ },
232
+ "hide": {
233
+ "complexType": {
234
+ "signature": "() => Promise<void>",
235
+ "parameters": [],
236
+ "references": {
237
+ "Promise": {
238
+ "location": "global",
239
+ "id": "global::Promise"
240
+ }
241
+ },
242
+ "return": "Promise<void>"
243
+ },
244
+ "docs": {
245
+ "text": "Programmatically hide this tooltip",
246
+ "tags": []
247
+ }
248
+ },
249
+ "toggle": {
250
+ "complexType": {
251
+ "signature": "(target: HTMLElement, force?: boolean) => Promise<boolean>",
252
+ "parameters": [{
253
+ "name": "target",
254
+ "type": "HTMLElement",
255
+ "docs": "An element with [data-tooltip-target=\"id\"] where the tooltip should be shown"
256
+ }, {
257
+ "name": "force",
258
+ "type": "boolean",
259
+ "docs": "Pass true to always show or false to always hide"
260
+ }],
261
+ "references": {
262
+ "Promise": {
263
+ "location": "global",
264
+ "id": "global::Promise"
265
+ },
266
+ "HTMLElement": {
267
+ "location": "global",
268
+ "id": "global::HTMLElement"
269
+ }
270
+ },
271
+ "return": "Promise<boolean>"
272
+ },
273
+ "docs": {
274
+ "text": "Toggle tooltip display",
275
+ "tags": [{
276
+ "name": "param",
277
+ "text": "target An element with [data-tooltip-target=\"id\"] where the tooltip should be shown"
278
+ }, {
279
+ "name": "param",
280
+ "text": "force Pass true to always show or false to always hide"
281
+ }]
282
+ }
283
+ }
284
+ };
285
+ }
286
+ static get elementRef() { return "host"; }
287
+ }
288
+ //# sourceMappingURL=post-popovercontainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-popovercontainer.js","sourceRoot":"","sources":["../../../../src/components/post-popovercontainer/post-popovercontainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EACL,KAAK,EACL,UAAU,EACV,eAAe,EACf,IAAI,EACJ,MAAM,EACN,MAAM,EAEN,KAAK,EACL,UAAU,EACV,IAAI,GACL,MAAM,kBAAkB,CAAC;AAE1B,0FAA0F;AAC1F,OAAO,2BAA2B,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,MAAM,QAAQ,GAAG;IACf,GAAG,EAAE,QAAQ;IACb,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,OAAO;CACd,CAAC;AAeF,MAAM,OAAO,oBAAoB;;yBAiBU,KAAK;qBAKX,KAAK;;IAExC,gBAAgB;QACd,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAC5C,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACjF,CAAC;IAED,oBAAoB;QAClB,IAAI,IAAI,CAAC,UAAU;YACjB,IAAI,CAAC,UAAU,CAAC,mBAAmB,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,CACtD,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAyC,CAAC,CACzD,CAAC;QAEJ,IAAI,OAAO,IAAI,CAAC,eAAe,KAAK,UAAU;YAAE,IAAI,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AAE,CAAC,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC,KAAK,CAAC;YACtD,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;YAElC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE;gBACjC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,CAAC,CAAC,EAAE;gBAChC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,CAAC,CAAC,EAAE;gBACjC,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,GAAG,CAAC,IAAI;aACpD,CAAC,CAAC;SACJ;IACH,CAAC;IAED,MAAM;QACJ,OAAO,CACL,EAAC,IAAI,oBAAe,OAAO;YACzB,WACE,KAAK,EAAC,SAAS,EACf,IAAI,EAAC,SAAS,EACd,GAAG,EAAE,CAAC,EAAuC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;gBAEvE,IAAI,CAAC,KAAK,IAAI,CACb,YACE,KAAK,EAAC,OAAO,EACb,GAAG,EAAE,EAAE,CAAC,EAAE;wBACR,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;oBACrB,CAAC,GACK,CACT;gBACD,eAAa,CACT,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Host, Method, Prop } from '@stencil/core';\nimport {\n arrow,\n autoUpdate,\n computePosition,\n flip,\n inline,\n offset,\n Placement,\n shift,\n limitShift,\n size,\n} from '@floating-ui/dom';\n\n// Polyfill for popovers, can be removed when https://caniuse.com/?search=popover is green\nimport '@oddbird/popover-polyfill';\n\nimport { version } from '../../../package.json';\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\nexport type PostPopoverElement = HTMLElement & PopoverElement;\n\n@Component({\n tag: 'post-popovercontainer',\n styleUrl: 'post-popovercontainer.scss',\n shadow: true,\n})\nexport class PostPopovercontainer {\n @Element() host: HTMLPostPopovercontainerElement;\n private popoverRef: PostPopoverElement;\n private arrowRef: HTMLElement;\n private eventTarget: Element;\n private clearAutoUpdate: () => void;\n\n /**\n * Fires whenever the popover gets shown or hidden, passing the new state in event.details as a boolean\n */\n @Event() postPopoverToggled: EventEmitter<boolean>;\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 /**\n * Wheter or not to display a little pointer arrow\n */\n @Prop() readonly arrow?: boolean = false;\n\n componentDidLoad() {\n this.popoverRef.setAttribute('popover', '');\n this.popoverRef.addEventListener('beforetoggle', this.handleToggle.bind(this));\n }\n\n disconnectedCallback() {\n if (this.popoverRef)\n this.popoverRef.removeEventListener('beforetoggle', e =>\n this.toggle(e.target as HTMLPostPopovercontainerElement),\n );\n\n if (typeof this.clearAutoUpdate === 'function') this.clearAutoUpdate();\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.popoverRef.showPopover();\n }\n\n /**\n * Programmatically hide this tooltip\n */\n @Method()\n async hide() {\n this.eventTarget = null;\n this.popoverRef.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): Promise<boolean> {\n this.eventTarget = target;\n this.popoverRef.togglePopover(force);\n return this.popoverRef.matches(':popover-open');\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 this.postPopoverToggled.emit(isOpen);\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.popoverRef,\n this.calculatePosition.bind(this),\n );\n }\n\n private async calculatePosition() {\n const middleware = [\n flip(),\n inline(),\n shift({\n padding: 8,\n\n // Prevents shifting away from the anchor too far, while shifting as far as possible\n // https://floating-ui.com/docs/shift#limiter\n limiter: limitShift({\n offset: 32,\n }),\n }),\n size({\n apply({ availableWidth, elements }) {\n Object.assign(elements.floating.style, {\n maxWidth: `${availableWidth - 16}px`,\n });\n },\n }),\n offset(this.arrow ? 12 : 8), // 4px outside of element to account for focus outline + ~arrow size\n ];\n\n if (this.arrow) {\n middleware.push(arrow({ element: this.arrowRef, padding: 8 }));\n }\n\n const {\n x,\n y,\n middlewareData,\n placement: currentPlacement,\n } = await computePosition(this.eventTarget, this.popoverRef, {\n placement: this.placement || 'top',\n strategy: 'fixed',\n middleware,\n });\n\n // Tooltip\n this.popoverRef.style.left = `${x}px`;\n this.popoverRef.style.top = `${y}px`;\n\n // Arrow\n if (this.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\n render() {\n return (\n <Host data-version={version}>\n <div\n class=\"popover\"\n part=\"popover\"\n ref={(el: HTMLDivElement & PostPopoverElement) => (this.popoverRef = el)}\n >\n {this.arrow && (\n <span\n class=\"arrow\"\n ref={el => {\n this.arrowRef = el;\n }}\n ></span>\n )}\n <slot></slot>\n </div>\n </Host>\n );\n }\n}\n"]}
@@ -1,3 +1,3 @@
1
- .tab-title[role=tab]{display:inline-block;position:relative;box-sizing:border-box;padding:1rem;transition:background-color 100ms;border-right:1px solid rgba(0,0,0,0);border-left:1px solid rgba(0,0,0,0);outline-color:currentColor;opacity:.7;color:var(--post-contrast-color);text-decoration:none}.tab-title[role=tab]:focus{background-color:unset;color:var(--post-contrast-color)}.tab-title[role=tab]:hover{opacity:1;background-color:#fff;color:var(--post-contrast-color)}.tab-title[role=tab]:focus-visible{outline:rgba(0,0,0,0);opacity:1;background-color:#fff;color:var(--post-contrast-color);box-shadow:none}.tab-title[role=tab]:focus-visible::after{content:"";display:block;position:absolute;top:2px;right:1px;bottom:0;left:1px;box-shadow:0 0 0 1px #fff,0 0 0 2px #333}.tab-title[role=tab].active{z-index:1;border-right-color:#ccc;border-left-color:#ccc;opacity:1;background-color:#fff;color:var(--post-contrast-color);font-weight:700}.tab-title[role=tab].active::before{content:"";display:block;position:absolute;top:0;right:-1px;left:-1px;height:.25rem;background-color:#fc0}:is(.bg-dark,.bg-primary,.bg-black,.bg-danger,.bg-nightblue,.bg-nightblue-bright,.bg-petrol,.bg-coral,.bg-olive,.bg-purple,.bg-purple-bright,.bg-aubergine,.bg-aubergine-bright) .tab-title[role=tab]:hover{background-color:rgba(255,255,255,.2)}:is(.bg-dark,.bg-primary,.bg-black,.bg-danger,.bg-nightblue,.bg-nightblue-bright,.bg-petrol,.bg-coral,.bg-olive,.bg-purple,.bg-purple-bright,.bg-aubergine,.bg-aubergine-bright) .tab-title[role=tab]:focus-visible{background-color:rgba(255,255,255,.2)}@media(forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.tab-title[role=tab]{opacity:1;border-left-color:Canvas;border-right-color:Canvas;color:LinkText}.tab-title[role=tab]:hover,.tab-title[role=tab]:focus,.tab-title[role=tab]:focus-within,.tab-title[role=tab]:focus-visible{outline:2px solid Highlight;outline-offset:-0.25rem}.tab-title[role=tab].active{border-left-color:ButtonText;border-right-color:ButtonText;color:Highlight}.tab-title[role=tab].active::before{background-color:Highlight}}.bg-yellow .tab-title{background-color:#fc0}.bg-yellow .tab-title.active{background-color:#fc0}.bg-yellow .nav-item{background-color:#fc0}.bg-light .tab-title{background-color:#faf9f8}.bg-light .tab-title.active{background-color:#faf9f8}.bg-light .nav-item{background-color:#faf9f8}.bg-gray .tab-title{background-color:#f4f3f1}.bg-gray .tab-title.active{background-color:#f4f3f1}.bg-gray .nav-item{background-color:#f4f3f1}.bg-dark .tab-title{background-color:#333}.bg-dark .tab-title.active{background-color:#333}.bg-dark .nav-item{background-color:#333}.bg-primary .tab-title{background-color:#333}.bg-primary .tab-title.active{background-color:#333}.bg-primary .nav-item{background-color:#333}.bg-white .tab-title{background-color:#fff}.bg-white .tab-title.active{background-color:#fff}.bg-white .nav-item{background-color:#fff}.bg-black .tab-title{background-color:#000}.bg-black .tab-title.active{background-color:#000}.bg-black .nav-item{background-color:#000}.bg-success .tab-title{background-color:#2c911c}.bg-success .tab-title.active{background-color:#2c911c}.bg-success .nav-item{background-color:#2c911c}.bg-info .tab-title{background-color:#cce4ee}.bg-info .tab-title.active{background-color:#cce4ee}.bg-info .nav-item{background-color:#cce4ee}.bg-warning .tab-title{background-color:#f49e00}.bg-warning .tab-title.active{background-color:#f49e00}.bg-warning .nav-item{background-color:#f49e00}.bg-danger .tab-title{background-color:#a51728}.bg-danger .tab-title.active{background-color:#a51728}.bg-danger .nav-item{background-color:#a51728}.bg-nightblue .tab-title{background-color:#004976}.bg-nightblue .tab-title.active{background-color:#004976}.bg-nightblue .nav-item{background-color:#004976}.bg-nightblue-bright .tab-title{background-color:#0076a8}.bg-nightblue-bright .tab-title.active{background-color:#0076a8}.bg-nightblue-bright .nav-item{background-color:#0076a8}.bg-petrol .tab-title{background-color:#006d68}.bg-petrol .tab-title.active{background-color:#006d68}.bg-petrol .nav-item{background-color:#006d68}.bg-petrol-bright .tab-title{background-color:#00968f}.bg-petrol-bright .tab-title.active{background-color:#00968f}.bg-petrol-bright .nav-item{background-color:#00968f}.bg-coral .tab-title{background-color:#9e2a2f}.bg-coral .tab-title.active{background-color:#9e2a2f}.bg-coral .nav-item{background-color:#9e2a2f}.bg-coral-bright .tab-title{background-color:#e03c31}.bg-coral-bright .tab-title.active{background-color:#e03c31}.bg-coral-bright .nav-item{background-color:#e03c31}.bg-olive .tab-title{background-color:#716135}.bg-olive .tab-title.active{background-color:#716135}.bg-olive .nav-item{background-color:#716135}.bg-olive-bright .tab-title{background-color:#aa9d2e}.bg-olive-bright .tab-title.active{background-color:#aa9d2e}.bg-olive-bright .nav-item{background-color:#aa9d2e}.bg-purple .tab-title{background-color:#80276c}.bg-purple .tab-title.active{background-color:#80276c}.bg-purple .nav-item{background-color:#80276c}.bg-purple-bright .tab-title{background-color:#c5299b}.bg-purple-bright .tab-title.active{background-color:#c5299b}.bg-purple-bright .nav-item{background-color:#c5299b}.bg-aubergine .tab-title{background-color:#523178}.bg-aubergine .tab-title.active{background-color:#523178}.bg-aubergine .nav-item{background-color:#523178}.bg-aubergine-bright .tab-title{background-color:#7566a0}.bg-aubergine-bright .tab-title.active{background-color:#7566a0}.bg-aubergine-bright .nav-item{background-color:#7566a0}[class*=bg-] .tab-title.active:focus::after{background-color:rgba(255,255,255,.2)}@supports selector(*:focus-visible){[class*=bg-] .tab-title.active:focus::after{background-color:unset}[class*=bg-] .tab-title.active:focus-visible::after{background-color:rgba(255,255,255,.2)}}/*!
1
+ .tab-title[role=tab]{display:inline-block;position:relative;box-sizing:border-box;padding:1rem;transition:background-color 100ms;border-right:1px solid rgba(0,0,0,0);border-left:1px solid rgba(0,0,0,0);outline-color:currentColor;opacity:.7;color:var(--post-contrast-color);text-decoration:none}.tab-title[role=tab]:focus{background-color:unset;color:var(--post-contrast-color)}.tab-title[role=tab]:hover{opacity:1;background-color:#fff;color:var(--post-contrast-color)}.tab-title[role=tab]:focus-visible{outline:rgba(0,0,0,0);opacity:1;background-color:#fff;color:var(--post-contrast-color);box-shadow:none}.tab-title[role=tab]:focus-visible::after{content:"";display:block;position:absolute;top:2px;right:1px;bottom:0;left:1px;box-shadow:0 0 0 1px #fff,0 0 0 2px #333}.tab-title[role=tab].active{z-index:1;border-right-color:#ccc;border-left-color:#ccc;opacity:1;background-color:#fff;color:var(--post-contrast-color);font-weight:700}.tab-title[role=tab].active::before{content:"";display:block;position:absolute;top:0;right:-1px;left:-1px;height:.25rem;background-color:#fc0}:is(.bg-dark,.bg-primary,.bg-black,.bg-success,.bg-danger,.bg-nightblue,.bg-nightblue-bright,.bg-petrol,.bg-coral,.bg-olive,.bg-purple,.bg-purple-bright,.bg-aubergine,.bg-aubergine-bright,.bg-error-red) .tab-title[role=tab]:hover{background-color:rgba(255,255,255,.2)}:is(.bg-dark,.bg-primary,.bg-black,.bg-success,.bg-danger,.bg-nightblue,.bg-nightblue-bright,.bg-petrol,.bg-coral,.bg-olive,.bg-purple,.bg-purple-bright,.bg-aubergine,.bg-aubergine-bright,.bg-error-red) .tab-title[role=tab]:focus-visible{background-color:rgba(255,255,255,.2)}@media(forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.tab-title[role=tab]{opacity:1;border-left-color:Canvas;border-right-color:Canvas;color:LinkText}.tab-title[role=tab]:hover,.tab-title[role=tab]:focus,.tab-title[role=tab]:focus-within,.tab-title[role=tab]:focus-visible{outline:2px solid Highlight;outline-offset:-0.25rem}.tab-title[role=tab].active{border-left-color:ButtonText;border-right-color:ButtonText;color:Highlight}.tab-title[role=tab].active::before{background-color:Highlight}}.bg-yellow .tab-title{background-color:#fc0}.bg-yellow .tab-title.active{background-color:#fc0}.bg-yellow .nav-item{background-color:#fc0}.bg-light .tab-title{background-color:#faf9f8}.bg-light .tab-title.active{background-color:#faf9f8}.bg-light .nav-item{background-color:#faf9f8}.bg-gray .tab-title{background-color:#f4f3f1}.bg-gray .tab-title.active{background-color:#f4f3f1}.bg-gray .nav-item{background-color:#f4f3f1}.bg-dark .tab-title{background-color:#333}.bg-dark .tab-title.active{background-color:#333}.bg-dark .nav-item{background-color:#333}.bg-primary .tab-title{background-color:#333}.bg-primary .tab-title.active{background-color:#333}.bg-primary .nav-item{background-color:#333}.bg-white .tab-title{background-color:#fff}.bg-white .tab-title.active{background-color:#fff}.bg-white .nav-item{background-color:#fff}.bg-black .tab-title{background-color:#000}.bg-black .tab-title.active{background-color:#000}.bg-black .nav-item{background-color:#000}.bg-info .tab-title{background-color:#cce4ee}.bg-info .tab-title.active{background-color:#cce4ee}.bg-info .nav-item{background-color:#cce4ee}.bg-success .tab-title{background-color:#2c911c}.bg-success .tab-title.active{background-color:#2c911c}.bg-success .nav-item{background-color:#2c911c}.bg-warning .tab-title{background-color:#f49e00}.bg-warning .tab-title.active{background-color:#f49e00}.bg-warning .nav-item{background-color:#f49e00}.bg-danger .tab-title{background-color:#a51728}.bg-danger .tab-title.active{background-color:#a51728}.bg-danger .nav-item{background-color:#a51728}.bg-nightblue .tab-title{background-color:#004976}.bg-nightblue .tab-title.active{background-color:#004976}.bg-nightblue .nav-item{background-color:#004976}.bg-nightblue-bright .tab-title{background-color:#0076a8}.bg-nightblue-bright .tab-title.active{background-color:#0076a8}.bg-nightblue-bright .nav-item{background-color:#0076a8}.bg-petrol .tab-title{background-color:#006d68}.bg-petrol .tab-title.active{background-color:#006d68}.bg-petrol .nav-item{background-color:#006d68}.bg-petrol-bright .tab-title{background-color:#00968f}.bg-petrol-bright .tab-title.active{background-color:#00968f}.bg-petrol-bright .nav-item{background-color:#00968f}.bg-coral .tab-title{background-color:#9e2a2f}.bg-coral .tab-title.active{background-color:#9e2a2f}.bg-coral .nav-item{background-color:#9e2a2f}.bg-coral-bright .tab-title{background-color:#e03c31}.bg-coral-bright .tab-title.active{background-color:#e03c31}.bg-coral-bright .nav-item{background-color:#e03c31}.bg-olive .tab-title{background-color:#716135}.bg-olive .tab-title.active{background-color:#716135}.bg-olive .nav-item{background-color:#716135}.bg-olive-bright .tab-title{background-color:#aa9d2e}.bg-olive-bright .tab-title.active{background-color:#aa9d2e}.bg-olive-bright .nav-item{background-color:#aa9d2e}.bg-purple .tab-title{background-color:#80276c}.bg-purple .tab-title.active{background-color:#80276c}.bg-purple .nav-item{background-color:#80276c}.bg-purple-bright .tab-title{background-color:#c5299b}.bg-purple-bright .tab-title.active{background-color:#c5299b}.bg-purple-bright .nav-item{background-color:#c5299b}.bg-aubergine .tab-title{background-color:#523178}.bg-aubergine .tab-title.active{background-color:#523178}.bg-aubergine .nav-item{background-color:#523178}.bg-aubergine-bright .tab-title{background-color:#7566a0}.bg-aubergine-bright .tab-title.active{background-color:#7566a0}.bg-aubergine-bright .nav-item{background-color:#7566a0}.bg-success-green .tab-title{background-color:#2c871d}.bg-success-green .tab-title.active{background-color:#2c871d}.bg-success-green .nav-item{background-color:#2c871d}.bg-error-red .tab-title{background-color:#a51728}.bg-error-red .tab-title.active{background-color:#a51728}.bg-error-red .nav-item{background-color:#a51728}.bg-warning-orange .tab-title{background-color:#f49e00}.bg-warning-orange .tab-title.active{background-color:#f49e00}.bg-warning-orange .nav-item{background-color:#f49e00}.bg-success-background .tab-title{background-color:#c0debb}.bg-success-background .tab-title.active{background-color:#c0debb}.bg-success-background .nav-item{background-color:#c0debb}.bg-error-background .tab-title{background-color:#ffdade}.bg-error-background .tab-title.active{background-color:#ffdade}.bg-error-background .nav-item{background-color:#ffdade}.bg-warning-background .tab-title{background-color:#fce2b2}.bg-warning-background .tab-title.active{background-color:#fce2b2}.bg-warning-background .nav-item{background-color:#fce2b2}[class*=bg-] .tab-title.active:focus::after{background-color:rgba(255,255,255,.2)}@supports selector(*:focus-visible){[class*=bg-] .tab-title.active:focus::after{background-color:unset}[class*=bg-] .tab-title.active:focus-visible::after{background-color:rgba(255,255,255,.2)}}/*!
2
2
  * Copyright 2021 by Swiss Post, Information Technology
3
3
  */:host{display:block}.tab-title{padding:0;overflow:visible;border:0;background:none;color:inherit;font:inherit;-webkit-user-select:none;user-select:none;-webkit-appearance:button;appearance:button}