@swisspost/design-system-components 10.0.0-next.40 → 10.0.0-next.41

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 (436) hide show
  1. package/dist/cjs/breakpoints-DIH5Oaz7.js +186 -0
  2. package/dist/cjs/event-from-AKK8RQrn.js +107 -0
  3. package/dist/cjs/{get-root-8102fecd.js → get-root-DmyBVSJ_.js} +1 -1
  4. package/dist/cjs/{index-b60129c4.js → index-CRMt-jq2.js} +1172 -309
  5. package/dist/cjs/index.cjs.js +0 -70
  6. package/dist/cjs/loader.cjs.js +3 -6
  7. package/dist/cjs/{package-b731881e.js → package-C2pR6Vs2.js} +1 -1
  8. package/dist/cjs/post-accordion_2.cjs.entry.js +177 -10
  9. package/dist/cjs/post-avatar.cjs.entry.js +151 -8
  10. package/dist/cjs/post-back-to-top.cjs.entry.js +86 -9
  11. package/dist/cjs/post-banner.cjs.entry.js +81 -9
  12. package/dist/cjs/post-breadcrumb-item_2.cjs.entry.js +62 -8
  13. package/dist/cjs/post-breadcrumbs.cjs.entry.js +119 -7
  14. package/dist/cjs/post-card-control.cjs.entry.js +283 -8
  15. package/dist/cjs/post-closebutton_15.cjs.entry.js +4376 -30
  16. package/dist/cjs/post-collapsible_2.cjs.entry.js +196 -10
  17. package/dist/cjs/post-components.cjs.js +7 -8
  18. package/dist/cjs/post-footer.cjs.entry.js +59 -8
  19. package/dist/cjs/post-linkarea.cjs.entry.js +24 -6
  20. package/dist/cjs/post-popover.cjs.entry.js +151 -8
  21. package/dist/cjs/post-rating.cjs.entry.js +115 -8
  22. package/dist/cjs/post-tab-header.cjs.entry.js +26 -9
  23. package/dist/cjs/post-tab-panel.cjs.entry.js +28 -9
  24. package/dist/cjs/post-tabs.cjs.entry.js +165 -7
  25. package/dist/cjs/post-tag.cjs.entry.js +50 -8
  26. package/dist/cjs/post-tooltip-trigger.cjs.entry.js +5195 -7
  27. package/dist/cjs/post-tooltip.cjs.entry.js +78 -9
  28. package/dist/collection/collection-manifest.json +4 -4
  29. package/dist/collection/components/post-accordion/post-accordion.js +39 -23
  30. package/dist/collection/components/post-accordion-item/post-accordion-item.js +26 -11
  31. package/dist/collection/components/post-avatar/post-avatar.js +12 -9
  32. package/dist/collection/components/post-back-to-top/post-back-to-top.js +4 -3
  33. package/dist/collection/components/post-banner/post-banner.js +18 -9
  34. package/dist/collection/components/post-breadcrumb-item/post-breadcrumb-item.js +4 -6
  35. package/dist/collection/components/post-breadcrumbs/post-breadcrumbs.css +1 -1
  36. package/dist/collection/components/post-breadcrumbs/post-breadcrumbs.js +13 -9
  37. package/dist/collection/components/post-card-control/post-card-control.js +33 -16
  38. package/dist/collection/components/post-collapsible/post-collapsible.js +6 -1
  39. package/dist/collection/components/post-collapsible-trigger/post-collapsible-trigger.js +21 -9
  40. package/dist/collection/components/post-footer/post-footer.js +8 -7
  41. package/dist/collection/components/post-header/post-header.css +1 -1
  42. package/dist/collection/components/post-header/post-header.js +28 -16
  43. package/dist/collection/components/post-icon/post-icon.js +66 -54
  44. package/dist/collection/components/post-language-option/post-language-option.css +1 -1
  45. package/dist/collection/components/post-language-option/post-language-option.js +17 -13
  46. package/dist/collection/components/post-language-switch/post-language-switch.css +1 -1
  47. package/dist/collection/components/post-language-switch/post-language-switch.js +43 -24
  48. package/dist/collection/components/post-list/post-list.js +12 -3
  49. package/dist/collection/components/post-logo/post-logo.js +3 -4
  50. package/dist/collection/components/post-megadropdown/post-megadropdown.js +12 -6
  51. package/dist/collection/components/post-megadropdown-trigger/post-megadropdown-trigger.js +34 -20
  52. package/dist/collection/components/post-menu/post-menu.css +1 -1
  53. package/dist/collection/components/post-menu/post-menu.js +43 -21
  54. package/dist/collection/components/post-menu-item/post-menu-item.css +1 -0
  55. package/dist/collection/components/post-menu-item/post-menu-item.js +11 -1
  56. package/dist/collection/components/post-menu-trigger/post-menu-trigger.js +9 -5
  57. package/dist/collection/components/post-popover/post-popover.js +19 -5
  58. package/dist/collection/components/post-popovercontainer/post-popovercontainer.css +1 -1
  59. package/dist/collection/components/post-popovercontainer/post-popovercontainer.js +44 -16
  60. package/dist/collection/components/post-rating/post-rating.js +25 -5
  61. package/dist/collection/components/post-tab-header/post-tab-header.js +4 -6
  62. package/dist/collection/components/post-tab-panel/post-tab-panel.js +4 -6
  63. package/dist/collection/components/post-tabs/post-tabs.js +4 -3
  64. package/dist/collection/components/post-tag/post-tag.js +11 -9
  65. package/dist/collection/components/post-togglebutton/post-togglebutton.js +7 -2
  66. package/dist/collection/components/post-tooltip/post-tooltip.js +24 -6
  67. package/dist/collection/components/post-tooltip-trigger/post-tooltip-trigger.js +20 -12
  68. package/dist/collection/index.js +1 -37
  69. package/dist/collection/utils/breakpoints.js +38 -45
  70. package/dist/collection/utils/event-from.js +103 -0
  71. package/dist/collection/utils/index.js +1 -1
  72. package/dist/components/index.js +2315 -37
  73. package/dist/components/p-1KLiMO0w.js +3 -0
  74. package/dist/components/p-8U5GFtQP.js +105 -0
  75. package/dist/components/{post-menu2.js → p-BLhBouGz.js} +51 -30
  76. package/dist/{esm/index-ffccd040.js → components/p-CV7fm1rW.js} +1 -1
  77. package/dist/components/{post-menu-trigger2.js → p-CaPj3whI.js} +14 -12
  78. package/{loaders/post-breadcrumb-item2.js → dist/components/p-Cpaqct04.js} +9 -11
  79. package/dist/components/{post-accordion-item2.js → p-CtNCtg2z.js} +32 -21
  80. package/dist/components/p-Cx0AiN2A.js +182 -0
  81. package/dist/components/{post-collapsible-trigger2.js → p-D3LhzIrC.js} +25 -14
  82. package/dist/components/{get-root.js → p-DBHo9yGF.js} +1 -1
  83. package/dist/components/p-DQuPPEca.js +31 -0
  84. package/dist/components/{post-accordion2.js → p-DlEtlaNu.js} +41 -28
  85. package/{loaders/post-collapsible2.js → dist/components/p-DphlfQse.js} +11 -8
  86. package/dist/components/{post-popovercontainer2.js → p-elg4VvHg.js} +246 -278
  87. package/{loaders/post-icon2.js → dist/components/p-fmA57Ivd.js} +52 -54
  88. package/dist/components/post-accordion-item.js +1 -1
  89. package/dist/components/post-accordion.js +1 -1
  90. package/dist/components/post-avatar.js +183 -1
  91. package/dist/components/post-back-to-top.js +115 -1
  92. package/dist/components/post-banner.js +120 -1
  93. package/dist/components/post-breadcrumb-item.js +1 -1
  94. package/dist/components/post-breadcrumbs.js +182 -1
  95. package/dist/components/post-card-control.js +322 -1
  96. package/dist/components/post-closebutton.js +37 -1
  97. package/dist/components/post-collapsible-trigger.js +1 -1
  98. package/dist/components/post-collapsible.js +1 -1
  99. package/dist/components/post-footer.js +112 -1
  100. package/dist/components/post-header.js +273 -1
  101. package/dist/components/post-icon.js +1 -1
  102. package/dist/components/post-language-option.js +96 -1
  103. package/dist/components/post-language-switch.js +154 -1
  104. package/dist/components/post-linkarea.js +41 -1
  105. package/dist/components/post-list-item.js +34 -1
  106. package/dist/components/post-list.js +57 -1
  107. package/dist/components/post-logo.js +54 -1
  108. package/dist/components/post-mainnavigation.js +181 -1
  109. package/dist/components/post-megadropdown-trigger.js +132 -1
  110. package/dist/components/post-megadropdown.js +194 -1
  111. package/dist/components/post-menu-item.js +1 -1
  112. package/dist/components/post-menu-trigger.js +1 -1
  113. package/dist/components/post-menu.js +1 -1
  114. package/dist/components/post-popover.js +184 -1
  115. package/dist/components/post-popovercontainer.js +1 -1
  116. package/dist/components/post-rating.js +148 -1
  117. package/dist/components/post-tab-header.js +48 -1
  118. package/dist/components/post-tab-panel.js +50 -1
  119. package/dist/components/post-tabs.js +186 -1
  120. package/dist/components/post-tag.js +82 -1
  121. package/dist/components/post-togglebutton.js +52 -1
  122. package/dist/components/post-tooltip-trigger.js +5218 -1
  123. package/dist/components/post-tooltip.js +110 -1
  124. package/dist/docs.d.ts +8 -0
  125. package/dist/docs.json +416 -116
  126. package/dist/esm/breakpoints-DyVir0ex.js +182 -0
  127. package/dist/esm/event-from-8U5GFtQP.js +105 -0
  128. package/{loaders/get-root.js → dist/esm/get-root-D9QC9-TY.js} +1 -1
  129. package/{loaders/index2.js → dist/esm/index-BWC0gtGU.js} +1 -1
  130. package/dist/esm/{index-f4d19816.js → index-CVhzhVv0.js} +1169 -305
  131. package/dist/esm/index.js +1 -29
  132. package/dist/esm/loader.js +3 -4
  133. package/dist/esm/package-1KLiMO0w.js +3 -0
  134. package/dist/esm/post-accordion_2.entry.js +180 -7
  135. package/dist/esm/post-avatar.entry.js +154 -5
  136. package/dist/esm/post-back-to-top.entry.js +89 -6
  137. package/dist/esm/post-banner.entry.js +85 -7
  138. package/dist/esm/post-breadcrumb-item_2.entry.js +65 -5
  139. package/dist/esm/post-breadcrumbs.entry.js +123 -5
  140. package/dist/esm/post-card-control.entry.js +286 -5
  141. package/dist/esm/post-closebutton_15.entry.js +4362 -10
  142. package/dist/esm/post-collapsible_2.entry.js +199 -7
  143. package/dist/esm/post-components.js +5 -5
  144. package/dist/esm/post-footer.entry.js +62 -5
  145. package/dist/esm/post-linkarea.entry.js +27 -3
  146. package/dist/esm/post-popover.entry.js +155 -6
  147. package/dist/esm/post-rating.entry.js +118 -5
  148. package/dist/esm/post-tab-header.entry.js +29 -6
  149. package/dist/esm/post-tab-panel.entry.js +31 -6
  150. package/dist/esm/post-tabs.entry.js +169 -5
  151. package/dist/esm/post-tag.entry.js +53 -5
  152. package/dist/esm/post-tooltip-trigger.entry.js +5199 -5
  153. package/dist/esm/post-tooltip.entry.js +81 -6
  154. package/dist/post-components/index.esm.js +0 -1
  155. package/dist/post-components/p-0d08ab13.entry.js +1 -0
  156. package/dist/post-components/p-1KLiMO0w.js +1 -0
  157. package/dist/post-components/p-1e006e29.entry.js +1 -0
  158. package/dist/post-components/p-3a5bdb7f.entry.js +1 -0
  159. package/dist/post-components/p-4214b85e.entry.js +1 -0
  160. package/dist/post-components/p-50916d48.entry.js +1 -0
  161. package/dist/post-components/p-5f4126d8.entry.js +1 -0
  162. package/dist/post-components/p-62982420.entry.js +1 -0
  163. package/dist/post-components/p-78f4dd12.entry.js +1 -0
  164. package/dist/post-components/p-7a7d237b.entry.js +1 -0
  165. package/dist/post-components/p-80174475.entry.js +1 -0
  166. package/dist/post-components/p-8U5GFtQP.js +1 -0
  167. package/dist/post-components/p-8d5a4218.entry.js +1 -0
  168. package/dist/post-components/p-8e89ccc1.entry.js +1 -0
  169. package/dist/post-components/p-9003674b.entry.js +1 -0
  170. package/dist/post-components/p-925aee3d.entry.js +1 -0
  171. package/dist/post-components/p-9b446561.entry.js +1 -0
  172. package/dist/post-components/p-9ec29527.entry.js +1 -0
  173. package/dist/post-components/{p-b176309b.js → p-BWC0gtGU.js} +1 -1
  174. package/dist/post-components/{p-6b31a76a.js → p-Bkp2QDth.js} +1 -1
  175. package/dist/post-components/p-CVhzhVv0.js +2 -0
  176. package/dist/post-components/p-DyVir0ex.js +1 -0
  177. package/dist/post-components/p-ec764922.entry.js +1 -0
  178. package/dist/post-components/p-fa550b4a.entry.js +1 -0
  179. package/dist/post-components/p-fb46e260.entry.js +1 -0
  180. package/dist/post-components/post-components.esm.js +1 -1
  181. package/dist/types/components/post-header/post-header.d.ts +1 -0
  182. package/dist/types/components/post-icon/post-icon.d.ts +0 -4
  183. package/dist/types/components/post-language-switch/post-language-switch.d.ts +1 -0
  184. package/dist/types/components/post-tag/post-tag.d.ts +1 -1
  185. package/dist/types/components.d.ts +61 -1
  186. package/dist/types/index.d.ts +10 -37
  187. package/dist/types/stencil-public-runtime.d.ts +29 -1
  188. package/dist/types/utils/breakpoints.d.ts +12 -7
  189. package/dist/types/utils/event-from.d.ts +9 -0
  190. package/dist/types/utils/index.d.ts +1 -1
  191. package/hydrate/index.d.ts +273 -0
  192. package/hydrate/index.js +32002 -0
  193. package/hydrate/index.mjs +31994 -0
  194. package/hydrate/package.json +12 -0
  195. package/package.json +45 -17
  196. package/dist/cjs/app-globals-3a1e7e63.js +0 -5
  197. package/dist/cjs/breakpoints-cdf1b747.js +0 -59
  198. package/dist/cjs/event-guard-efabc84f.js +0 -47
  199. package/dist/cjs/post-accordion-item-5c879102.js +0 -161
  200. package/dist/cjs/post-avatar-4f1681df.js +0 -162
  201. package/dist/cjs/post-back-to-top-abbb4ac4.js +0 -93
  202. package/dist/cjs/post-banner-4d99c51c.js +0 -87
  203. package/dist/cjs/post-breadcrumbs-5ceabb10.js +0 -126
  204. package/dist/cjs/post-card-control-b657aeaa.js +0 -290
  205. package/dist/cjs/post-collapsible-trigger-33f09d6c.js +0 -190
  206. package/dist/cjs/post-footer-022cf408.js +0 -66
  207. package/dist/cjs/post-linkarea-5fbb2e25.js +0 -30
  208. package/dist/cjs/post-menu-item-d4cc4742.js +0 -68
  209. package/dist/cjs/post-popover-b7cd0091.js +0 -150
  210. package/dist/cjs/post-rating-c81d1ac3.js +0 -109
  211. package/dist/cjs/post-tab-header-1db15093.js +0 -34
  212. package/dist/cjs/post-tab-panel-698981b8.js +0 -36
  213. package/dist/cjs/post-tabs-79eab811.js +0 -173
  214. package/dist/cjs/post-tag-66a52727.js +0 -60
  215. package/dist/cjs/post-togglebutton-a6b8b75d.js +0 -4491
  216. package/dist/cjs/post-tooltip-560cf42c.js +0 -74
  217. package/dist/cjs/post-tooltip-trigger-2a54e3e4.js +0 -4685
  218. package/dist/collection/utils/event-guard.js +0 -43
  219. package/dist/components/breakpoints.js +0 -56
  220. package/dist/components/event-guard.js +0 -45
  221. package/dist/components/index2.js +0 -88
  222. package/dist/components/package.js +0 -3
  223. package/dist/components/post-avatar2.js +0 -190
  224. package/dist/components/post-back-to-top2.js +0 -118
  225. package/dist/components/post-banner2.js +0 -121
  226. package/dist/components/post-breadcrumb-item2.js +0 -82
  227. package/dist/components/post-breadcrumbs2.js +0 -184
  228. package/dist/components/post-card-control2.js +0 -325
  229. package/dist/components/post-closebutton2.js +0 -39
  230. package/dist/components/post-collapsible2.js +0 -108
  231. package/dist/components/post-footer2.js +0 -115
  232. package/dist/components/post-header2.js +0 -397
  233. package/dist/components/post-icon2.js +0 -156
  234. package/dist/components/post-language-option2.js +0 -102
  235. package/dist/components/post-language-switch2.js +0 -143
  236. package/dist/components/post-linkarea2.js +0 -43
  237. package/dist/components/post-list-item2.js +0 -36
  238. package/dist/components/post-list2.js +0 -54
  239. package/dist/components/post-logo2.js +0 -57
  240. package/dist/components/post-mainnavigation2.js +0 -183
  241. package/dist/components/post-megadropdown-trigger2.js +0 -121
  242. package/dist/components/post-megadropdown2.js +0 -190
  243. package/dist/components/post-menu-item2.js +0 -27
  244. package/dist/components/post-popover2.js +0 -178
  245. package/dist/components/post-rating2.js +0 -138
  246. package/dist/components/post-tab-header2.js +0 -52
  247. package/dist/components/post-tab-panel2.js +0 -54
  248. package/dist/components/post-tabs2.js +0 -189
  249. package/dist/components/post-tag2.js +0 -88
  250. package/dist/components/post-togglebutton2.js +0 -51
  251. package/dist/components/post-tooltip-trigger2.js +0 -4703
  252. package/dist/components/post-tooltip2.js +0 -102
  253. package/dist/esm/app-globals-0f993ce5.js +0 -3
  254. package/dist/esm/breakpoints-7812702e.js +0 -56
  255. package/dist/esm/event-guard-538ee077.js +0 -45
  256. package/dist/esm/get-root-1b1af46f.js +0 -15
  257. package/dist/esm/package-9374eb90.js +0 -3
  258. package/dist/esm/post-accordion-item-f416bd95.js +0 -158
  259. package/dist/esm/post-avatar-2cb5190b.js +0 -160
  260. package/dist/esm/post-back-to-top-f877d4c6.js +0 -91
  261. package/dist/esm/post-banner-576a5adb.js +0 -85
  262. package/dist/esm/post-breadcrumbs-63223336.js +0 -124
  263. package/dist/esm/post-card-control-2eebe7b4.js +0 -288
  264. package/dist/esm/post-collapsible-trigger-561df34e.js +0 -187
  265. package/dist/esm/post-footer-a270f67b.js +0 -64
  266. package/dist/esm/post-linkarea-456ce63d.js +0 -28
  267. package/dist/esm/post-menu-item-e051284c.js +0 -65
  268. package/dist/esm/post-popover-7c3c9072.js +0 -148
  269. package/dist/esm/post-rating-2c9dd11f.js +0 -107
  270. package/dist/esm/post-tab-header-f90b2f93.js +0 -32
  271. package/dist/esm/post-tab-panel-c19b5e30.js +0 -34
  272. package/dist/esm/post-tabs-0dadedf2.js +0 -171
  273. package/dist/esm/post-tag-b8be3b0c.js +0 -58
  274. package/dist/esm/post-togglebutton-83339cc9.js +0 -4475
  275. package/dist/esm/post-tooltip-3cc82984.js +0 -72
  276. package/dist/esm/post-tooltip-trigger-898c3dbc.js +0 -4683
  277. package/dist/post-components/p-0889c759.js +0 -1
  278. package/dist/post-components/p-104ddc50.js +0 -1
  279. package/dist/post-components/p-13b41e32.entry.js +0 -1
  280. package/dist/post-components/p-1906d77c.js +0 -1
  281. package/dist/post-components/p-19d0e6ea.entry.js +0 -1
  282. package/dist/post-components/p-1b9afb34.entry.js +0 -1
  283. package/dist/post-components/p-1fbffc90.js +0 -1
  284. package/dist/post-components/p-234925fa.js +0 -1
  285. package/dist/post-components/p-23fb976f.entry.js +0 -1
  286. package/dist/post-components/p-24c42ebe.entry.js +0 -1
  287. package/dist/post-components/p-28c19671.js +0 -8
  288. package/dist/post-components/p-37aaa30f.js +0 -1
  289. package/dist/post-components/p-3baf0b40.entry.js +0 -1
  290. package/dist/post-components/p-4390192f.js +0 -1
  291. package/dist/post-components/p-4a071696.js +0 -1
  292. package/dist/post-components/p-4c2d5072.js +0 -1
  293. package/dist/post-components/p-51b6114c.entry.js +0 -1
  294. package/dist/post-components/p-5fb4fc65.js +0 -1
  295. package/dist/post-components/p-64c13aaf.entry.js +0 -1
  296. package/dist/post-components/p-66679f9d.entry.js +0 -1
  297. package/dist/post-components/p-68a98f0b.js +0 -1
  298. package/dist/post-components/p-6a4dc55e.js +0 -1
  299. package/dist/post-components/p-722ffaae.js +0 -1
  300. package/dist/post-components/p-789f9a23.entry.js +0 -1
  301. package/dist/post-components/p-7e6eae42.js +0 -1
  302. package/dist/post-components/p-8117dd0c.js +0 -1
  303. package/dist/post-components/p-814c0c4d.entry.js +0 -1
  304. package/dist/post-components/p-87e0d6fa.js +0 -1
  305. package/dist/post-components/p-988d20f4.js +0 -1
  306. package/dist/post-components/p-9b1e4e52.entry.js +0 -1
  307. package/dist/post-components/p-9e461613.js +0 -2
  308. package/dist/post-components/p-ab44a18c.entry.js +0 -1
  309. package/dist/post-components/p-b2952b0e.entry.js +0 -1
  310. package/dist/post-components/p-c10b2a2f.js +0 -1
  311. package/dist/post-components/p-c80cb846.js +0 -1
  312. package/dist/post-components/p-da4704c1.js +0 -1
  313. package/dist/post-components/p-dc4de84a.entry.js +0 -1
  314. package/dist/post-components/p-e1255160.js +0 -1
  315. package/dist/post-components/p-f1f0ace3.entry.js +0 -1
  316. package/dist/post-components/p-f34fb6c4.entry.js +0 -1
  317. package/dist/post-components/p-f6f914bb.js +0 -1
  318. package/dist/post-components/p-fe7e64cf.entry.js +0 -1
  319. package/dist/post-components/p-fee94252.entry.js +0 -1
  320. package/dist/types/popover-fn.d.ts +0 -11
  321. package/dist/types/utils/event-guard.d.ts +0 -4
  322. package/loader/package.json +0 -11
  323. package/loaders/breakpoints.js +0 -56
  324. package/loaders/event-guard.js +0 -45
  325. package/loaders/fade.js +0 -11
  326. package/loaders/get-focusable-children.js +0 -35
  327. package/loaders/heading-levels.js +0 -3
  328. package/loaders/index.browser.js +0 -14
  329. package/loaders/index.d.ts +0 -108
  330. package/loaders/index.js +0 -39
  331. package/loaders/long-press-event.js +0 -264
  332. package/loaders/package.js +0 -3
  333. package/loaders/post-accordion-item.d.ts +0 -11
  334. package/loaders/post-accordion-item.js +0 -6
  335. package/loaders/post-accordion-item2.js +0 -103
  336. package/loaders/post-accordion.d.ts +0 -11
  337. package/loaders/post-accordion.js +0 -6
  338. package/loaders/post-accordion2.js +0 -126
  339. package/loaders/post-avatar.d.ts +0 -11
  340. package/loaders/post-avatar.js +0 -193
  341. package/loaders/post-back-to-top.d.ts +0 -11
  342. package/loaders/post-back-to-top.js +0 -121
  343. package/loaders/post-banner.d.ts +0 -11
  344. package/loaders/post-banner.js +0 -124
  345. package/loaders/post-breadcrumb-item.d.ts +0 -11
  346. package/loaders/post-breadcrumb-item.js +0 -6
  347. package/loaders/post-breadcrumbs.d.ts +0 -11
  348. package/loaders/post-breadcrumbs.js +0 -187
  349. package/loaders/post-card-control.d.ts +0 -11
  350. package/loaders/post-card-control.js +0 -328
  351. package/loaders/post-closebutton.d.ts +0 -11
  352. package/loaders/post-closebutton.js +0 -42
  353. package/loaders/post-collapsible-trigger.d.ts +0 -11
  354. package/loaders/post-collapsible-trigger.js +0 -6
  355. package/loaders/post-collapsible-trigger2.js +0 -125
  356. package/loaders/post-collapsible.d.ts +0 -11
  357. package/loaders/post-collapsible.js +0 -6
  358. package/loaders/post-footer.d.ts +0 -11
  359. package/loaders/post-footer.js +0 -118
  360. package/loaders/post-header.d.ts +0 -11
  361. package/loaders/post-header.js +0 -400
  362. package/loaders/post-icon.d.ts +0 -11
  363. package/loaders/post-icon.js +0 -6
  364. package/loaders/post-language-option.d.ts +0 -11
  365. package/loaders/post-language-option.js +0 -105
  366. package/loaders/post-language-switch.d.ts +0 -11
  367. package/loaders/post-language-switch.js +0 -146
  368. package/loaders/post-linkarea.d.ts +0 -11
  369. package/loaders/post-linkarea.js +0 -46
  370. package/loaders/post-list-item.d.ts +0 -11
  371. package/loaders/post-list-item.js +0 -39
  372. package/loaders/post-list.d.ts +0 -11
  373. package/loaders/post-list.js +0 -57
  374. package/loaders/post-logo.d.ts +0 -11
  375. package/loaders/post-logo.js +0 -60
  376. package/loaders/post-mainnavigation.d.ts +0 -11
  377. package/loaders/post-mainnavigation.js +0 -186
  378. package/loaders/post-megadropdown-trigger.d.ts +0 -11
  379. package/loaders/post-megadropdown-trigger.js +0 -124
  380. package/loaders/post-megadropdown.d.ts +0 -11
  381. package/loaders/post-megadropdown.js +0 -193
  382. package/loaders/post-menu-item.d.ts +0 -11
  383. package/loaders/post-menu-item.js +0 -6
  384. package/loaders/post-menu-item2.js +0 -27
  385. package/loaders/post-menu-trigger.d.ts +0 -11
  386. package/loaders/post-menu-trigger.js +0 -6
  387. package/loaders/post-menu-trigger2.js +0 -109
  388. package/loaders/post-menu.d.ts +0 -11
  389. package/loaders/post-menu.js +0 -6
  390. package/loaders/post-menu2.js +0 -202
  391. package/loaders/post-popover.d.ts +0 -11
  392. package/loaders/post-popover.js +0 -181
  393. package/loaders/post-popovercontainer.d.ts +0 -11
  394. package/loaders/post-popovercontainer.js +0 -6
  395. package/loaders/post-popovercontainer2.js +0 -3051
  396. package/loaders/post-rating.d.ts +0 -11
  397. package/loaders/post-rating.js +0 -141
  398. package/loaders/post-tab-header.d.ts +0 -11
  399. package/loaders/post-tab-header.js +0 -55
  400. package/loaders/post-tab-panel.d.ts +0 -11
  401. package/loaders/post-tab-panel.js +0 -57
  402. package/loaders/post-tabs.d.ts +0 -11
  403. package/loaders/post-tabs.js +0 -192
  404. package/loaders/post-tag.d.ts +0 -11
  405. package/loaders/post-tag.js +0 -91
  406. package/loaders/post-togglebutton.d.ts +0 -11
  407. package/loaders/post-togglebutton.js +0 -54
  408. package/loaders/post-tooltip-trigger.d.ts +0 -11
  409. package/loaders/post-tooltip-trigger.js +0 -4706
  410. package/loaders/post-tooltip.d.ts +0 -11
  411. package/loaders/post-tooltip.js +0 -105
  412. package/loaders/slide.js +0 -25
  413. package/loaders/switch-variants.js +0 -3
  414. /package/dist/cjs/{fade-72d5ef55.js → fade-nS5zzDQS.js} +0 -0
  415. /package/dist/cjs/{index-2b2b85e5.js → index-DtvYdwe1.js} +0 -0
  416. /package/dist/cjs/{index.browser-4af21c17.js → index.browser-Doj636JV.js} +0 -0
  417. /package/dist/cjs/{long-press-event-6e62d113.js → long-press-event-Q8jMUNXD.js} +0 -0
  418. /package/dist/cjs/{placement-b2bb6ec4.js → placement-qEFR9hmI.js} +0 -0
  419. /package/dist/cjs/{slide-cd1f09b3.js → slide-CbBL7A8w.js} +0 -0
  420. /package/dist/components/{index.browser.js → p-BLchVpF6.js} +0 -0
  421. /package/dist/components/{slide.js → p-BuLMaH5t.js} +0 -0
  422. /package/dist/components/{get-focusable-children.js → p-C35MCWIp.js} +0 -0
  423. /package/dist/components/{long-press-event.js → p-C_2k3G1c.js} +0 -0
  424. /package/dist/components/{switch-variants.js → p-DjIHLduJ.js} +0 -0
  425. /package/dist/components/{fade.js → p-SbIC4aZX.js} +0 -0
  426. /package/dist/components/{heading-levels.js → p-r4txK0AC.js} +0 -0
  427. /package/dist/esm/{fade-1f3cacf4.js → fade-SbIC4aZX.js} +0 -0
  428. /package/dist/esm/{index.browser-ff103197.js → index.browser-BLchVpF6.js} +0 -0
  429. /package/dist/esm/{long-press-event-04d24397.js → long-press-event-C_2k3G1c.js} +0 -0
  430. /package/dist/esm/{placement-8d56605d.js → placement-DRiVosES.js} +0 -0
  431. /package/dist/esm/{slide-cd2850ee.js → slide-BuLMaH5t.js} +0 -0
  432. /package/dist/post-components/{p-c65f32b0.js → p-BLchVpF6.js} +0 -0
  433. /package/dist/post-components/{p-9b052461.js → p-BuLMaH5t.js} +0 -0
  434. /package/dist/post-components/{p-8db32dab.js → p-C_2k3G1c.js} +0 -0
  435. /package/dist/post-components/{p-59a38c23.js → p-DRiVosES.js} +0 -0
  436. /package/dist/post-components/{p-64e3de38.js → p-SbIC4aZX.js} +0 -0
@@ -1,4475 +0,0 @@
1
- import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-f4d19816.js';
2
- import { v as version } from './package-9374eb90.js';
3
- import { b as breakpoint, I as IS_BROWSER } from './breakpoints-7812702e.js';
4
- import { a as slideUp, s as slideDown } from './slide-cd2850ee.js';
5
- import { e as eventGuard } from './event-guard-538ee077.js';
6
- import { a as checkEmptyOrOneOf, d as checkEmptyOrType, b as checkRequiredAndType, g as checkEmptyOrUrl } from './index-ffccd040.js';
7
- import { n as nanoid } from './index.browser-ff103197.js';
8
- import { P as PLACEMENT_TYPES } from './placement-8d56605d.js';
9
- import { g as getRoot } from './get-root-1b1af46f.js';
10
-
11
- const focusableSelector = `:where(${[
12
- 'button',
13
- 'input:not([type="hidden"])',
14
- '[tabindex]',
15
- 'select',
16
- 'textarea',
17
- '[contenteditable]',
18
- 'a[href]',
19
- 'iframe',
20
- 'audio[controls]',
21
- 'video[controls]',
22
- 'area[href]',
23
- 'details > summary:first-of-type',
24
- ].join(',')})`;
25
- const focusDisablingSelector = `:where(${[
26
- '[inert]',
27
- '[inert] *',
28
- ':disabled',
29
- 'dialog:not([open]) *',
30
- '[popover]:not(:popover-open) *',
31
- 'details:not([open]) > *:not(details > summary:first-of-type)',
32
- 'details:not([open]) > *:not(details > summary:first-of-type) *',
33
- '[tabindex^="-"]',
34
- '[hidden]:not([hidden="false"])',
35
- ].join(',')})`;
36
- function getFocusableChildren(element) {
37
- const focusableChildren = element.querySelectorAll(`${focusableSelector}:not(${focusDisablingSelector})`);
38
- const visibleFocusableChildren = Array.from(focusableChildren).filter(child => {
39
- const style = window.getComputedStyle(child.parentElement);
40
- return style.display !== 'none' && style.visibility !== 'hidden';
41
- });
42
- return visibleFocusableChildren;
43
- }
44
-
45
- const postClosebuttonCss = ".btn-icon-close{padding:0;border:unset;min-height:unset;min-width:unset;width:var(--post-device-sizing-notification-1);height:var(--post-device-sizing-notification-1);border-radius:var(--post-device-border-radius-round);background-color:var(--post-scheme-color-interactive-button-tertiary-enabled-bg);color:var(--post-scheme-color-interactive-button-tertiary-enabled-fg)}.btn-icon-close>post-icon{min-width:var(--post-device-sizing-interactive-icon-size4);width:var(--post-device-sizing-interactive-icon-size4);height:var(--post-device-sizing-interactive-icon-size4)}.btn-icon-close:not(:disabled):hover,.btn-icon-close.pretend-hover{cursor:pointer;background-color:var(--post-scheme-color-interactive-button-tertiary-hover-bg);color:var(--post-scheme-color-interactive-button-tertiary-hover-fg)}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.btn-icon-close:not(:disabled):hover,.btn-icon-close.pretend-hover{color:HighlightText !important}}.visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);border:0}";
46
- const PostClosebuttonStyle0 = postClosebuttonCss;
47
-
48
- const PostClosebutton = class {
49
- constructor(hostRef) {
50
- registerInstance(this, hostRef);
51
- }
52
- render() {
53
- return (h(Host, { key: '7b5e179b42eefd1823b2b2ef7ee17c94bd9f0ddd', "data-version": version }, h("button", { key: '471e68d1ddcfe741f5450d002b2daa86cec0f986', class: "btn btn-icon-close", type: "button" }, h("post-icon", { key: '928fa7460988cffa269a29506e68e056f84bcef8', "aria-hidden": "true", name: "closex" }), h("span", { key: 'c1501f4a8b7d8d95be7d02576b10143b9e6b0654', class: "visually-hidden" }, h("slot", { key: 'a9f1ab8db57486d420db0981090ad2ba5183c289' })))));
54
- }
55
- get host() { return getElement(this); }
56
- };
57
- PostClosebutton.style = PostClosebuttonStyle0;
58
-
59
- /* eslint-disable no-undefined,no-param-reassign,no-shadow */
60
-
61
- /**
62
- * Throttle execution of a function. Especially useful for rate limiting
63
- * execution of handlers on events like resize and scroll.
64
- *
65
- * @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher)
66
- * are most useful.
67
- * @param {Function} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through,
68
- * as-is, to `callback` when the throttled-function is executed.
69
- * @param {object} [options] - An object to configure options.
70
- * @param {boolean} [options.noTrailing] - Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds
71
- * while the throttled-function is being called. If noTrailing is false or unspecified, callback will be executed
72
- * one final time after the last throttled-function call. (After the throttled-function has not been called for
73
- * `delay` milliseconds, the internal counter is reset).
74
- * @param {boolean} [options.noLeading] - Optional, defaults to false. If noLeading is false, the first throttled-function call will execute callback
75
- * immediately. If noLeading is true, the first the callback execution will be skipped. It should be noted that
76
- * callback will never executed if both noLeading = true and noTrailing = true.
77
- * @param {boolean} [options.debounceMode] - If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is
78
- * false (at end), schedule `callback` to execute after `delay` ms.
79
- *
80
- * @returns {Function} A new, throttled, function.
81
- */
82
- function throttle (delay, callback, options) {
83
- var _ref = options || {},
84
- _ref$noTrailing = _ref.noTrailing,
85
- noTrailing = _ref$noTrailing === void 0 ? false : _ref$noTrailing,
86
- _ref$noLeading = _ref.noLeading,
87
- noLeading = _ref$noLeading === void 0 ? false : _ref$noLeading,
88
- _ref$debounceMode = _ref.debounceMode,
89
- debounceMode = _ref$debounceMode === void 0 ? undefined : _ref$debounceMode;
90
- /*
91
- * After wrapper has stopped being called, this timeout ensures that
92
- * `callback` is executed at the proper times in `throttle` and `end`
93
- * debounce modes.
94
- */
95
- var timeoutID;
96
- var cancelled = false;
97
-
98
- // Keep track of the last time `callback` was executed.
99
- var lastExec = 0;
100
-
101
- // Function to clear existing timeout
102
- function clearExistingTimeout() {
103
- if (timeoutID) {
104
- clearTimeout(timeoutID);
105
- }
106
- }
107
-
108
- // Function to cancel next exec
109
- function cancel(options) {
110
- var _ref2 = options || {},
111
- _ref2$upcomingOnly = _ref2.upcomingOnly,
112
- upcomingOnly = _ref2$upcomingOnly === void 0 ? false : _ref2$upcomingOnly;
113
- clearExistingTimeout();
114
- cancelled = !upcomingOnly;
115
- }
116
-
117
- /*
118
- * The `wrapper` function encapsulates all of the throttling / debouncing
119
- * functionality and when executed will limit the rate at which `callback`
120
- * is executed.
121
- */
122
- function wrapper() {
123
- for (var _len = arguments.length, arguments_ = new Array(_len), _key = 0; _key < _len; _key++) {
124
- arguments_[_key] = arguments[_key];
125
- }
126
- var self = this;
127
- var elapsed = Date.now() - lastExec;
128
- if (cancelled) {
129
- return;
130
- }
131
-
132
- // Execute `callback` and update the `lastExec` timestamp.
133
- function exec() {
134
- lastExec = Date.now();
135
- callback.apply(self, arguments_);
136
- }
137
-
138
- /*
139
- * If `debounceMode` is true (at begin) this is used to clear the flag
140
- * to allow future `callback` executions.
141
- */
142
- function clear() {
143
- timeoutID = undefined;
144
- }
145
- if (!noLeading && debounceMode && !timeoutID) {
146
- /*
147
- * Since `wrapper` is being called for the first time and
148
- * `debounceMode` is true (at begin), execute `callback`
149
- * and noLeading != true.
150
- */
151
- exec();
152
- }
153
- clearExistingTimeout();
154
- if (debounceMode === undefined && elapsed > delay) {
155
- if (noLeading) {
156
- /*
157
- * In throttle mode with noLeading, if `delay` time has
158
- * been exceeded, update `lastExec` and schedule `callback`
159
- * to execute after `delay` ms.
160
- */
161
- lastExec = Date.now();
162
- if (!noTrailing) {
163
- timeoutID = setTimeout(debounceMode ? clear : exec, delay);
164
- }
165
- } else {
166
- /*
167
- * In throttle mode without noLeading, if `delay` time has been exceeded, execute
168
- * `callback`.
169
- */
170
- exec();
171
- }
172
- } else if (noTrailing !== true) {
173
- /*
174
- * In trailing throttle mode, since `delay` time has not been
175
- * exceeded, schedule `callback` to execute `delay` ms after most
176
- * recent execution.
177
- *
178
- * If `debounceMode` is true (at begin), schedule `clear` to execute
179
- * after `delay` ms.
180
- *
181
- * If `debounceMode` is false (at end), schedule `callback` to
182
- * execute after `delay` ms.
183
- */
184
- timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === undefined ? delay - elapsed : delay);
185
- }
186
- }
187
- wrapper.cancel = cancel;
188
-
189
- // Return the wrapper function.
190
- return wrapper;
191
- }
192
-
193
- const postHeaderCss = "*,::before,::after{box-sizing:border-box}:host{z-index:1020;position:relative;--post-global-header-top:calc( (var(--post-global-header-height) - var(--post-global-header-reduced-height)) * -1 );--post-local-header-top:calc( -1 * (var(--post-local-header-height) - var(--post-main-navigation-height)) + var(--post-global-header-reduced-height) );--post-logo-height:calc(var(--post-global-header-height) - var(--post-header-scroll-top, 0px));--post-global-controls-top:calc(min((var(--post-header-scroll-top) / 4), 20px) * -1)}:host:has(.global-sub>*:not(.logo):focus-within),:host:has(.local-sub:focus-within){--post-global-header-top:0;--post-local-header-top:var(--post-global-header-height);--post-logo-height:var(--post-global-header-height);--post-global-controls-top:0}@media screen and (max-width: 1023.98px){:host{position:fixed;inset:0;bottom:auto}}:host(:not(:has([slot=title]))) .local-header{padding-block-start:0}:host(:not(:has([slot=title]))) .local-sub{display:none}.d-flex{display:flex}.space-between{justify-content:space-between}.global-header{background-color:#fc0;display:flex;justify-content:space-between;position:sticky;padding-inline:4px;height:var(--post-global-header-height)}@media screen and (max-width: 1023.98px){.global-header{z-index:4;inset-block-start:0;position:relative}}@media screen and (min-width: 1024px){.global-header{z-index:5;padding-inline-end:12px;inset-block-start:var(--post-global-header-top);transition:inset-block-start .2s ease-in-out}}.global-sub{display:flex;align-items:center;gap:24px}@media screen and (min-width: 1024px){.global-sub:not(:has(.logo)){position:relative;transition:inset-block-start .2s ease-in-out;inset-block-start:var(--post-global-controls-top)}}.align-end{align-items:flex-end}.logo{flex:1 0 auto;height:var(--post-global-header-height);width:var(--post-global-header-height);min-height:var(--post-global-header-reduced-height);align-self:flex-end}@media screen and (min-width: 1024px){.logo{transition:height .2 ease-in-out;height:var(--post-logo-height)}}::slotted(ul){margin-block:0 !important;list-style:none;display:flex;padding-inline-start:0;gap:1rem;flex-shrink:0 !important}.local-header{display:flex;position:sticky;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:4px;min-height:var(--post-local-header-min-height);background:#fff;transition:box-shadow .2s ease-in-out}.local-header::after{content:\"\";position:absolute;width:100%;height:1px;background-color:#e1e0dc;inset-block-end:-1px;z-index:1}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.local-header::after{background-color:Highlight}}@media screen and (min-width: 1024px){.local-header{z-index:3;inset-block-start:var(--post-local-header-top);padding-block-start:18px;box-shadow:var(--post-device-elevation-300);transition:box-shadow .2s ease-in-out,inset-block-start .2s ease-in-out}}@media screen and (max-width: 1023.98px){.local-header{z-index:3;position:relative;padding-block:8px;flex-wrap:wrap;gap:12px}.local-header.local-header-mobile-extended::after{inset-block-end:0}.local-header:not(.local-header-mobile-extended){box-shadow:var(--post-device-elevation-300)}}.local-sub{margin-inline-end:8px}@media screen and (max-width: 1023.98px){.local-sub{margin-inline-end:4px}}::slotted(.list-inline){margin:0 !important;z-index:3 !important;position:relative !important}@media screen and (min-width: 1024px){.mobile-toggle{display:none}}.navigation{width:100%}@media screen and (min-width: 1024px){.navigation{inset-block-start:var(--post-global-header-reduced-height)}.navigation::before{display:block;content:\"\";position:absolute;inset:0;z-index:2;background:#fff}}@media screen and (max-width: 1023.98px){.navigation{position:sticky;z-index:2;inset-inline:0;inset-block-start:var(--post-header-height)}.mobile-menu{background-color:#fafafa}::slotted(post-mainnavigation),.navigation-footer{display:none;flex-direction:column;padding-block:16px 24px;padding-inline:32px}.navigation.extended ::slotted(post-mainnavigation),.navigation.extended .navigation-footer{display:flex}.navigation.extended>div{display:flex;flex-direction:column;overflow-y:auto;overflow-x:hidden;height:calc(min(var(--post-header-scroll-parent-height, 100dvh),100dvh) - var(--post-header-height))}.navigation.extended.megadropdown-open>div{overflow-y:hidden}.navigation.extended ::slotted(post-mainnavigation){flex-grow:1 !important}::slotted(post-mainnavigation){gap:32px}.navigation-footer{background-color:#f0efed;gap:24px}}@media screen and (max-width: 599.98px){::slotted(post-mainnavigation),.navigation-footer{padding-inline:16px}}";
194
- const PostHeaderStyle0 = postHeaderCss;
195
-
196
- const PostHeader = class {
197
- get scrollParent() {
198
- const frozenScrollParent = document.querySelector('[data-post-scroll-locked]');
199
- if (frozenScrollParent)
200
- return frozenScrollParent;
201
- let element = this.host.parentElement;
202
- while (element) {
203
- const overflow = getComputedStyle(element).overflowY;
204
- if (['auto', 'scroll'].includes(overflow)) {
205
- return element;
206
- }
207
- element = element.parentElement;
208
- }
209
- return document.body;
210
- }
211
- lockBody(newValue, _oldValue, propName) {
212
- const scrollParent = this.scrollParent;
213
- const mobileMenuExtended = propName === 'mobileMenuExtended' ? newValue : this.mobileMenuExtended;
214
- if (this.device !== 'desktop' && mobileMenuExtended) {
215
- scrollParent.setAttribute('data-post-scroll-locked', '');
216
- this.host.addEventListener('keydown', this.keyboardHandler);
217
- }
218
- else {
219
- scrollParent.removeAttribute('data-post-scroll-locked');
220
- this.host.removeEventListener('keydown', this.keyboardHandler);
221
- }
222
- }
223
- constructor(hostRef) {
224
- registerInstance(this, hostRef);
225
- this.throttledResize = throttle(50, () => this.updateLocalHeaderHeight());
226
- this.breakpointChange = (e) => {
227
- this.device = e.detail;
228
- this.switchLanguageSwitchMode();
229
- if (this.device === 'desktop' && this.mobileMenuExtended) {
230
- this.closeMobileMenu();
231
- }
232
- };
233
- this.megadropdownStateHandler = (event) => {
234
- eventGuard(this.host, event, {
235
- targetLocalName: 'post-megadropdown',
236
- delegatorSelector: 'post-header',
237
- }, () => {
238
- this.megadropdownOpen = event.detail.isVisible;
239
- });
240
- };
241
- this.device = breakpoint.get('name');
242
- this.mobileMenuExtended = false;
243
- this.megadropdownOpen = false;
244
- this.handleScrollEvent = this.handleScrollEvent.bind(this);
245
- this.updateScrollParentHeight = this.updateScrollParentHeight.bind(this);
246
- this.updateLocalHeaderHeight = this.updateLocalHeaderHeight.bind(this);
247
- this.keyboardHandler = this.keyboardHandler.bind(this);
248
- this.handleLinkClick = this.handleLinkClick.bind(this);
249
- }
250
- connectedCallback() {
251
- window.addEventListener('resize', this.throttledResize, { passive: true });
252
- window.addEventListener('scroll', this.handleScrollEvent, {
253
- passive: true,
254
- });
255
- this.scrollParent.addEventListener('scroll', this.handleScrollEvent, {
256
- passive: true,
257
- });
258
- document.addEventListener('postToggleMegadropdown', this.megadropdownStateHandler);
259
- this.host.addEventListener('click', this.handleLinkClick);
260
- window.addEventListener('postBreakpoint:name', this.breakpointChange);
261
- this.switchLanguageSwitchMode();
262
- this.updateLocalHeaderHeight();
263
- this.handleScrollParentResize();
264
- this.lockBody(false, this.mobileMenuExtended, 'mobileMenuExtended');
265
- }
266
- componentWillRender() {
267
- this.handleScrollEvent();
268
- }
269
- componentDidRender() {
270
- this.getFocusableElements();
271
- this.handleLocalHeaderResize();
272
- }
273
- // Clean up possible side effects when post-header is disconnected
274
- disconnectedCallback() {
275
- const scrollParent = this.scrollParent;
276
- window.removeEventListener('postBreakpoint:name', this.breakpointChange);
277
- window.removeEventListener('resize', this.throttledResize);
278
- window.removeEventListener('scroll', this.handleScrollEvent);
279
- scrollParent.removeEventListener('scroll', this.handleScrollEvent);
280
- document.removeEventListener('postToggleMegadropdown', this.megadropdownStateHandler);
281
- this.host.removeEventListener('keydown', this.keyboardHandler);
282
- this.host.removeEventListener('click', this.handleLinkClick);
283
- if (this.scrollParentResizeObserver) {
284
- this.scrollParentResizeObserver.disconnect();
285
- this.scrollParentResizeObserver = null;
286
- }
287
- if (this.localHeaderResizeObserver) {
288
- this.localHeaderResizeObserver.disconnect();
289
- this.localHeaderResizeObserver = null;
290
- }
291
- this.mobileMenuExtended = false;
292
- }
293
- async closeMobileMenu() {
294
- this.mobileMenuAnimation.finish();
295
- const menuButton = this.getMenuButton();
296
- if (menuButton) {
297
- menuButton.toggled = false;
298
- }
299
- this.mobileMenuExtended = false;
300
- }
301
- /**
302
- * Toggles the mobile navigation.
303
- */
304
- async toggleMobileMenu(force) {
305
- if (this.device === 'desktop')
306
- return;
307
- this.mobileMenuAnimation = this.mobileMenuExtended
308
- ? slideUp(this.mobileMenu)
309
- : slideDown(this.mobileMenu);
310
- // Update the state of the toggle button
311
- const menuButton = this.host.querySelector('post-togglebutton');
312
- menuButton.toggled = force ?? !this.mobileMenuExtended;
313
- // Toggle menu visibility before it slides down and after it slides back up
314
- if (this.mobileMenuExtended)
315
- await this.mobileMenuAnimation.finished;
316
- this.mobileMenuExtended = force ?? !this.mobileMenuExtended;
317
- if (this.mobileMenuExtended === false) {
318
- Array.from(this.host.querySelectorAll('post-megadropdown')).forEach(dropdown => {
319
- dropdown.hide(false, true);
320
- });
321
- }
322
- }
323
- // Get all the focusable elements in the post-header mobile menu
324
- getFocusableElements() {
325
- // Get elements in the correct order (different as the DOM order)
326
- const focusableEls = [
327
- ...Array.from(this.host.querySelectorAll('.list-inline:not([slot="meta-navigation"]) > li')),
328
- ...Array.from(this.host.querySelectorAll('nav > post-list > div > post-list-item, post-mainnavigation > .back-button, post-megadropdown-trigger')),
329
- ...Array.from(this.host.querySelectorAll('.list-inline[slot="meta-navigation"] > li, post-language-option')),
330
- ];
331
- // Add the main toggle menu button to the list of focusable children
332
- const focusableChildren = [
333
- this.host.querySelector('post-togglebutton'),
334
- ...focusableEls.flatMap(el => Array.from(getFocusableChildren(el))),
335
- ];
336
- this.firstFocusableEl = focusableChildren[0];
337
- this.lastFocusableEl = focusableChildren[focusableChildren.length - 1];
338
- }
339
- getMenuButton() {
340
- return this.host.querySelector('post-togglebutton');
341
- }
342
- keyboardHandler(e) {
343
- if (e.key === 'Tab' && this.mobileMenuExtended) {
344
- if (e.shiftKey && document.activeElement === this.firstFocusableEl) {
345
- // If back tab (Tab + Shift) and first element is focused, focus goes to the last element of the megadropdown
346
- e.preventDefault();
347
- this.lastFocusableEl.focus();
348
- }
349
- else if (!e.shiftKey && document.activeElement === this.lastFocusableEl) {
350
- // If Tab and last element is focused, focus goes back to the first element of the megadropdown
351
- e.preventDefault();
352
- this.firstFocusableEl.focus();
353
- }
354
- }
355
- }
356
- handleScrollEvent() {
357
- const scrollTop = this.scrollParent === document.body ? window.scrollY : this.scrollParent.scrollTop;
358
- document.documentElement.style.setProperty('--post-header-scroll-top', `${scrollTop}px`);
359
- }
360
- updateLocalHeaderHeight() {
361
- const localHeaderHeight = this.host.shadowRoot.querySelector('.local-header')?.clientHeight || 0;
362
- document.documentElement.style.setProperty('--post-local-header-height', `${localHeaderHeight}px`);
363
- }
364
- updateScrollParentHeight() {
365
- this.host.style.setProperty('--post-header-scroll-parent-height', `${this.scrollParent.clientHeight}px`);
366
- }
367
- handleLinkClick(event) {
368
- const target = event.target;
369
- const isLinkInMainNav = target.closest('post-mainnavigation a');
370
- const isLinkInMegadropdown = target.closest('post-megadropdown a');
371
- if (!isLinkInMainNav && !isLinkInMegadropdown) {
372
- return;
373
- }
374
- if (this.mobileMenuExtended && (isLinkInMainNav || isLinkInMegadropdown)) {
375
- this.toggleMobileMenu(false);
376
- }
377
- if (this.device === 'desktop' && isLinkInMegadropdown) {
378
- const megadropdownLink = target.closest('post-megadropdown a');
379
- if (megadropdownLink) {
380
- target.closest('post-megadropdown').hide(true);
381
- }
382
- }
383
- }
384
- handleScrollParentResize() {
385
- if (this.scrollParent) {
386
- this.scrollParentResizeObserver = new ResizeObserver(this.updateScrollParentHeight);
387
- this.scrollParentResizeObserver.observe(this.scrollParent);
388
- }
389
- }
390
- handleLocalHeaderResize() {
391
- const localHeader = this.host.shadowRoot.querySelector('.local-header');
392
- if (localHeader && !this.localHeaderResizeObserver) {
393
- this.localHeaderResizeObserver = new ResizeObserver(this.updateLocalHeaderHeight);
394
- this.localHeaderResizeObserver.observe(localHeader);
395
- }
396
- }
397
- switchLanguageSwitchMode() {
398
- const variant = this.device === 'desktop' ? 'menu' : 'list';
399
- Array.from(this.host.querySelectorAll('post-language-switch')).forEach(languageSwitch => {
400
- languageSwitch?.setAttribute('variant', variant);
401
- });
402
- }
403
- renderNavigation() {
404
- const navigationClasses = ['navigation'];
405
- const mobileMenuScrollTop = this.mobileMenu?.scrollTop ?? 0;
406
- if (this.mobileMenuExtended) {
407
- navigationClasses.push('extended');
408
- }
409
- if (this.megadropdownOpen) {
410
- navigationClasses.push('megadropdown-open');
411
- }
412
- return (h("div", { class: navigationClasses.join(' '), style: { '--post-header-navigation-current-inset': `${mobileMenuScrollTop}px` } }, h("div", { class: "mobile-menu", ref: el => (this.mobileMenu = el) }, h("slot", { name: "post-mainnavigation" }), (this.device === 'mobile' || this.device === 'tablet') && (h("div", { class: "navigation-footer" }, h("slot", { name: "meta-navigation" }), h("slot", { name: "post-language-switch" }))))));
413
- }
414
- render() {
415
- return (h(Host, { key: 'b552e09d25f9d69217f47b31931553edabcb3b5b', "data-version": version }, h("div", { key: 'b7bb569991b4c50101b80a907aff823ed64f93c3', class: "global-header" }, h("div", { key: 'bd88a1b5cc75cbb9832da4082fc6bc2405342421', class: "global-sub" }, h("div", { key: '0f338f37c57cdad900f0b9654ef16a26e60385d9', class: "logo" }, h("slot", { key: '8f5faf2470aee5a7c3d5ebb4157009f32e679085', name: "post-logo" }))), h("div", { key: 'f97a893b1dd7bce09f57e8199bd584fd6e28b71c', class: "global-sub" }, this.device === 'desktop' && h("slot", { key: '5edf8a7834d42b89a5c0bb5e4b53ff75cef78fd7', name: "meta-navigation" }), h("slot", { key: '196cf8c24e02cac8fc8215f9ab2e9efed46dced3', name: "global-controls" }), this.device === 'desktop' && h("slot", { key: 'bce4b98e5ac9f7afba6b88a9da3fbe91b69aadf3', name: "post-language-switch" }), h("div", { key: '1c4b51f44882f55a5fe5386ed33b696c81289d14', onClick: () => this.toggleMobileMenu(), class: "mobile-toggle" }, h("slot", { key: '56625102ad896e624e6a879f203e6b2cac4455a3', name: "post-togglebutton" })))), h("div", { key: 'd1a3961046902fa6026b065b9a013a341188d0e5', class: 'local-header ' + (this.mobileMenuExtended ? 'local-header-mobile-extended' : '') }, h("slot", { key: '28d1be43cae56c53468e51e9b62cf92652431dcd', name: "title" }), h("div", { key: '09729387f1de16c4052c87956112b2aa64148f9a', class: "local-sub" }, h("slot", { key: 'fa0f247d960522d617dfadcfb0576f875eca45c6', name: "local-controls" }), h("slot", { key: 'b49e7647e428efbe3adea6f4302f023a1d6fe2bd' })), this.device === 'desktop' && this.renderNavigation()), this.device !== 'desktop' && this.renderNavigation()));
416
- }
417
- get host() { return getElement(this); }
418
- static get watchers() { return {
419
- "device": ["lockBody"],
420
- "mobileMenuExtended": ["lockBody"]
421
- }; }
422
- };
423
- PostHeader.style = PostHeaderStyle0;
424
-
425
- const postIconCss = ":host{display:inline-block;width:1em;height:1em;vertical-align:-0.15em}span{display:block;width:100%;height:100%;fill:currentColor;forced-color-adjust:preserve-parent-color;background-color:currentColor;-webkit-mask-position:center center;mask-position:center center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;-webkit-mask-size:100%;mask-size:100%}:host([flip-h]:not([flip-h=false])){scale:-1 1}:host([flip-v]:not([flip-v=false])){scale:1 -1}:host([flip-h][flip-v]:not([flip-h=false],[flip-v=false])){scale:-1}:host([animation]){transform-origin:center}:host([animation=cylon]){animation:icon-animation-cylon .75s ease-in-out infinite alternate}:host([animation=cylon-vertical]){animation:icon-animation-cylon-vertical .75s ease-in-out infinite alternate}:host([animation=spin]){animation:icon-animation-spin 2s linear infinite normal}:host([animation=spin-reverse]){animation:icon-animation-spin 2s linear infinite reverse}:host([animation=fade]){animation:icon-animation-fade .75s ease-in-out infinite alternate}:host([animation=throb]){animation:icon-animation-throb .75s ease-in-out infinite alternate}@keyframes icon-animation-cylon{from{transform:translateX(-25%)}to{transform:translateX(25%)}}@keyframes icon-animation-cylon-vertical{from{transform:translateY(25%)}to{transform:translateY(-25%)}}@keyframes icon-animation-fade{from{opacity:.1}to{opacity:1}}@keyframes icon-animation-spin{from{transform:rotate(0deg)}to{transform:rotate(359deg)}}@keyframes icon-animation-throb{from{opacity:.5;transform:scale(0.5)}to{opacity:1;transform:scale(1)}}";
426
- const PostIconStyle0 = postIconCss;
427
-
428
- const CDN_URL = `https://unpkg.com/@swisspost/design-system-icons@${version}/public/post-icons/`;
429
- const ANIMATION_NAMES = [
430
- 'cylon',
431
- 'cylon-vertical',
432
- 'spin',
433
- 'spin-reverse',
434
- 'fade',
435
- 'throb',
436
- ];
437
- const ANIMATION_KEYS = [...ANIMATION_NAMES];
438
- const PostIcon = class {
439
- constructor(hostRef) {
440
- registerInstance(this, hostRef);
441
- this.animation = undefined;
442
- this.base = undefined;
443
- this.flipH = false;
444
- this.flipV = false;
445
- this.name = undefined;
446
- this.rotate = undefined;
447
- this.scale = undefined;
448
- }
449
- validateAnimation() {
450
- checkEmptyOrOneOf(this, 'animation', ANIMATION_KEYS);
451
- }
452
- validateBase() {
453
- checkEmptyOrType(this, 'base', 'string');
454
- }
455
- validateName() {
456
- checkRequiredAndType(this, 'name', 'string');
457
- }
458
- validateRotate() {
459
- checkEmptyOrType(this, 'rotate', 'number');
460
- }
461
- validateScale() {
462
- checkEmptyOrType(this, 'scale', 'number');
463
- }
464
- // Construct the icon url from different possible sources
465
- getUrl() {
466
- let url;
467
- const file = `${this.name}.svg`;
468
- // the first definition object which defines a domain, will be used to set the domain of the file url
469
- // the first definition object which defines a slug, will be used to set the slug of the file url
470
- const urlDefinitions = [this.getUrlDefinition(this.base, 'both')];
471
- if (IS_BROWSER) {
472
- urlDefinitions.push(this.getUrlDefinition(document.head
473
- .querySelector('meta[name="design-system-settings"][data-post-icon-base]')
474
- ?.getAttribute('data-post-icon-base'), 'relative'));
475
- urlDefinitions.push(this.getUrlDefinition(document.querySelector('base[href]')?.getAttribute('href'), 'both'));
476
- }
477
- // in case no definition defines a domain, a relative url is used to load the icon
478
- const origin = urlDefinitions.find(d => d.definesDomain)?.url?.origin;
479
- // in case no definition defines a slug either, the cdn url is used as a fallback
480
- const slug = urlDefinitions.find(d => d.definesSlug)?.url?.pathname;
481
- if (origin && slug) {
482
- url = `${origin}${slug}${file}`;
483
- }
484
- else if (!origin && slug) {
485
- url = `${slug}${file}`;
486
- }
487
- else {
488
- url = `${CDN_URL}${file}`;
489
- }
490
- return url;
491
- }
492
- getUrlDefinition(url, allow) {
493
- return {
494
- url: this.getUrlObject(url),
495
- definesDomain: allow !== 'relative' ? this.definesDomain(url) : false,
496
- definesSlug: allow !== 'absolute' ? this.definesSlug(url) : false,
497
- };
498
- }
499
- getUrlObject(url) {
500
- if (url) {
501
- url = url?.endsWith('/') ? url : `${url}/`;
502
- return new URL(url, 'https://url.base');
503
- }
504
- else {
505
- return null;
506
- }
507
- }
508
- definesDomain(url) {
509
- return url ? /^https?:\/\//.test(url) : false;
510
- }
511
- definesSlug(url) {
512
- return Boolean(/^\/.+/.test(this.getUrlObject(url)?.pathname));
513
- }
514
- getStyles() {
515
- const url = this.getUrl();
516
- return Object.entries({
517
- '-webkit-mask-image': `url(${url})`,
518
- 'mask-image': `url('${url}')`,
519
- 'transform': (this.scale && !isNaN(Number(this.scale)) ? 'scale(' + this.scale + ')' : '') +
520
- (this.rotate && !isNaN(Number(this.rotate)) ? ' rotate(' + this.rotate + 'deg)' : ''),
521
- })
522
- .filter(([_key, value]) => value !== null)
523
- .reduce((styles, [key, value]) => Object.assign(styles, { [key]: value }), {});
524
- }
525
- componentDidLoad() {
526
- this.validateBase();
527
- this.validateName();
528
- this.validateScale();
529
- this.validateRotate();
530
- this.validateAnimation();
531
- }
532
- render() {
533
- return (h(Host, { key: '7fe2d83b8d3c46bf31f451b7b06a8366c49971de', "data-version": version }, h("span", { key: '3b3e474985eef7697e4c05f75fc6abd3e96dbbc9', style: this.getStyles() })));
534
- }
535
- get host() { return getElement(this); }
536
- static get watchers() { return {
537
- "animation": ["validateAnimation"],
538
- "base": ["validateBase"],
539
- "name": ["validateName"],
540
- "rotate": ["validateRotate"],
541
- "scale": ["validateScale"]
542
- }; }
543
- };
544
- PostIcon.style = PostIconStyle0;
545
-
546
- const SWITCH_VARIANTS = ['list', 'menu'];
547
-
548
- const postLanguageOptionCss = "@keyframes popIn{from{transform:scale(0.9);opacity:0;transition-property:transform,opacity,overlay,display;transition-behavior:allow-discrete;transition-duration:var(--post-transition-duration, 0.35s);transition-timing-function:linear(0, 0.007, 0.029 2.2%, 0.118 4.7%, 0.625 14.4%, 0.826 19%, 0.902, 0.962, 1.008 26.1%, 1.041 28.7%, 1.064 32.1%, 1.07 36%, 1.061 40.5%, 1.015 53.4%, 0.999 61.6%, 0.995 71.2%, 1)}to{opacity:1;transform:scale(1)}}post-language-option{display:inline-block}post-language-option button{padding:0;overflow:visible;border:0;background:none;color:var(--post-scheme-color-interactive-button-secondary-enabled-fg);font:inherit;-webkit-user-select:none;user-select:none;appearance:button}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){post-language-option button{background-color:ButtonFace !important}post-language-option button:hover{background-color:Highlight !important}}post-language-option a{color:var(--post-scheme-color-surface-default-fg);text-decoration:none}post-language-option :is(a,button){cursor:pointer;display:flex;align-items:center;justify-content:center;width:100%;height:100%;border-radius:2px;text-transform:uppercase}post-language-option :is(a,button){outline-offset:var(--post-device-spacing-padding-2) !important;outline:var(--post-scheme-color-interactive-focus-stroke) none var(--post-device-border-width-focus) !important}post-language-option :is(a,button):is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){post-language-option :is(a,button):is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-color:Highlight !important}}@supports not selector(:has(:focus-visible)){post-language-option :is(a,button):is(:focus-visible,:focus-within,.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){post-language-option :is(a,button):is(:focus-visible,:focus-within,.pretend-focus){outline-color:Highlight !important}}}post-language-option:where([variant=list]) :is(a,button){padding-inline:0;width:40px;height:40px;border-radius:2px}post-language-option:where([variant=list]) :is(a,button):hover{color:#504f4b}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){post-language-option:where([variant=list]) :is(a,button){border:1px solid ButtonBorder;color:ButtonText}}post-language-option:where([variant=list])[active]:not([active=false]) :is(a,button){background-color:#050400 !important;color:#fff;pointer-events:none}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){post-language-option:where([variant=list])[active]:not([active=false]) :is(a,button){background-color:Highlight !important;color:HighlightText}}post-language-option:where([variant=menu]){min-width:72px}post-language-option:where([variant=menu])[active]:not([active=false]){display:none}post-language-option:where([variant=menu]) :is(a,button){padding-block:13px;padding-inline:16px;box-sizing:border-box;justify-content:flex-start;position:relative}post-language-option:where([variant=menu]) :is(a,button):hover{color:#fff;background-color:#504f4b}";
549
- const PostLanguageOptionStyle0 = postLanguageOptionCss;
550
-
551
- const PostLanguageOption = class {
552
- constructor(hostRef) {
553
- registerInstance(this, hostRef);
554
- this.postChange = createEvent(this, "postChange", 7);
555
- this.postLanguageOptionInitiallyActive = createEvent(this, "postLanguageOptionInitiallyActive", 7);
556
- this.code = undefined;
557
- this.active = undefined;
558
- this.variant = undefined;
559
- this.name = undefined;
560
- this.url = undefined;
561
- }
562
- validateCode() {
563
- checkRequiredAndType(this, 'code', 'string');
564
- }
565
- validateVariant() {
566
- checkEmptyOrOneOf(this, 'variant', SWITCH_VARIANTS);
567
- }
568
- validateName() {
569
- checkEmptyOrType(this, 'name', 'string');
570
- }
571
- validateUrl() {
572
- checkEmptyOrUrl(this, 'url');
573
- }
574
- componentDidLoad() {
575
- this.validateCode();
576
- this.validateName();
577
- this.validateUrl();
578
- if (!this.name && this.isNameRequired()) {
579
- throw new Error('The "name" property of the post-language-option component is required when the full language name is not displayed.');
580
- }
581
- if (this.active) {
582
- this.postLanguageOptionInitiallyActive.emit(this.code);
583
- }
584
- }
585
- /**
586
- * Selects the language option programmatically.
587
- */
588
- async select() {
589
- this.active = true;
590
- this.emitChange();
591
- }
592
- emitChange() {
593
- this.postChange.emit(this.code);
594
- }
595
- isNameRequired() {
596
- return this.host.textContent.toLowerCase() === this.code.toLowerCase();
597
- }
598
- render() {
599
- const lang = this.code.toLowerCase();
600
- const emitOnKeyDown = (e) => {
601
- if (e.key === 'Enter' || e.key === ' ') {
602
- this.emitChange();
603
- }
604
- };
605
- return (h(Host, { key: 'fe37c9aed573664a2f70b25b5d25e5bb58a23702', "data-version": version }, this.url ? (h("a", { "aria-current": this.active ? 'page' : undefined, "aria-label": this.name, href: this.url, hrefLang: lang, lang: lang, onClick: () => this.emitChange(), onKeyDown: emitOnKeyDown }, h("slot", null))) : (h("button", { "aria-current": this.active ? 'true' : undefined, "aria-label": this.name, lang: lang, onClick: () => this.emitChange(), onKeyDown: emitOnKeyDown }, h("slot", null)))));
606
- }
607
- get host() { return getElement(this); }
608
- static get watchers() { return {
609
- "code": ["validateCode"],
610
- "variant": ["validateVariant"],
611
- "name": ["validateName"],
612
- "url": ["validateUrl"]
613
- }; }
614
- };
615
- PostLanguageOption.style = PostLanguageOptionStyle0;
616
-
617
- const postLanguageSwitchCss = ":host{display:flex !important;flex-wrap:wrap;gap:.5rem}.post-language-switch-dropdown-container{display:flex;flex-direction:column}.post-language-switch-trigger{cursor:pointer;text-transform:uppercase;padding:0;overflow:visible;border:0;background:none;color:var(--post-scheme-color-interactive-button-secondary-enabled-fg);font:inherit;-webkit-user-select:none;user-select:none;appearance:button;text-decoration:none;display:inline-flex;align-items:center;gap:6px;border-radius:24px;font-size:16px;padding:3px 10px}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.post-language-switch-trigger{background-color:ButtonFace !important}.post-language-switch-trigger:hover{background-color:Highlight !important}}.post-language-switch-trigger{outline-offset:var(--post-device-spacing-padding-2) !important;outline:var(--post-scheme-color-interactive-focus-stroke) none var(--post-device-border-width-focus) !important}.post-language-switch-trigger:is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.post-language-switch-trigger:is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-color:Highlight !important}}@supports not selector(:has(:focus-visible)){.post-language-switch-trigger:is(:focus-visible,:focus-within,.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.post-language-switch-trigger:is(:focus-visible,:focus-within,.pretend-focus){outline-color:Highlight !important}}}.post-language-switch-trigger:not(:disabled):hover,.post-language-switch-trigger.pretend-hover{border-color:var(--post-scheme-color-interactive-button-tertiary-hover-stroke);background-color:var(--post-scheme-color-interactive-button-tertiary-hover-bg);color:var(--post-scheme-color-interactive-button-tertiary-hover-fg)}.post-language-switch-trigger post-icon{height:24px;width:24px}.post-language-switch-trigger[aria-expanded=true]{background-color:#050400;color:#fff}.post-language-switch-trigger[aria-expanded=true] post-icon{transform:rotate(180deg)}.post-language-switch-trigger[aria-expanded=true]:hover{background-color:#504f4b;color:#fff}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.post-language-switch-trigger{border:1px solid ButtonBorder}.post-language-switch-trigger[aria-expanded=true] post-icon,.post-language-switch-trigger:hover post-icon{color:HighlightText}}";
618
- const PostLanguageSwitchStyle0 = postLanguageSwitchCss;
619
-
620
- const PostLanguageSwitch = class {
621
- constructor(hostRef) {
622
- registerInstance(this, hostRef);
623
- this.menuId = `p${nanoid(11)}`;
624
- this.caption = undefined;
625
- this.description = undefined;
626
- this.variant = 'list';
627
- this.activeLang = undefined;
628
- }
629
- get languageOptions() {
630
- return Array.from(this.host.querySelectorAll('post-language-option'));
631
- }
632
- validateCaption() {
633
- checkRequiredAndType(this, 'caption', 'string');
634
- }
635
- validateDescription() {
636
- checkRequiredAndType(this, 'description', 'string');
637
- }
638
- validateVariant() {
639
- checkEmptyOrOneOf(this, 'variant', SWITCH_VARIANTS);
640
- this.updateChildrenVariant();
641
- }
642
- componentDidLoad() {
643
- this.validateCaption();
644
- this.validateDescription();
645
- this.validateVariant();
646
- // Initially set variants and active language
647
- // Handles cases where the language-switch is rendered after the language-options have been rendered
648
- this.updateChildrenVariant();
649
- }
650
- /**
651
- * Listen for the postChange event and guard it to run only for events originating from a <post-language-option> element.
652
- */
653
- handlePostChange(event) {
654
- eventGuard(this.host, event, { targetLocalName: 'post-language-option', delegatorSelector: 'post-language-switch' }, () => {
655
- this.activeLang = event.detail;
656
- // Update the active state in the children post-language-option components
657
- this.languageOptions.forEach(lang => {
658
- if (lang.code && lang.code === this.activeLang) {
659
- lang.setAttribute('active', '');
660
- }
661
- else {
662
- lang.removeAttribute('active');
663
- }
664
- });
665
- // Hides the dropdown when an option has been clicked
666
- if (this.variant === 'menu') {
667
- const menu = this.host.shadowRoot.querySelector('post-menu');
668
- menu.hide();
669
- }
670
- });
671
- }
672
- /**
673
- * Handles cases where the language switch is being rendered before options are available
674
- * @param event Initially emitted by <post-langauge-option>
675
- */
676
- handleInitiallyActive(event) {
677
- this.activeLang = event.detail;
678
- }
679
- // Update post-language-option variant to have the correct style
680
- updateChildrenVariant() {
681
- this.languageOptions.forEach(el => {
682
- el.setAttribute('variant', this.variant);
683
- });
684
- }
685
- renderList() {
686
- return (h(Host, { "data-version": version, role: "list", "aria-label": this.caption }, h("div", { class: "post-language-switch-list", role: "group", "aria-label": this.description }, h("slot", null))));
687
- }
688
- renderDropdown() {
689
- return (h(Host, { "data-version": version }, h("post-menu-trigger", { for: this.menuId }, h("button", { class: "post-language-switch-trigger", "aria-label": this.description }, this.activeLang, h("post-icon", { "aria-hidden": "true", name: "chevrondown" }))), h("post-menu", { id: this.menuId, class: "post-language-switch-dropdown-container", "aria-label": this.caption }, h("slot", null))));
690
- }
691
- render() {
692
- return this.variant === 'list' ? this.renderList() : this.renderDropdown();
693
- }
694
- get host() { return getElement(this); }
695
- static get watchers() { return {
696
- "caption": ["validateCaption"],
697
- "description": ["validateDescription"],
698
- "variant": ["validateVariant"]
699
- }; }
700
- };
701
- PostLanguageSwitch.style = PostLanguageSwitchStyle0;
702
-
703
- const postListCss = "@keyframes popIn{from{transform:scale(0.9);opacity:0;transition-property:transform,opacity,overlay,display;transition-behavior:allow-discrete;transition-duration:var(--post-transition-duration, 0.35s);transition-timing-function:linear(0, 0.007, 0.029 2.2%, 0.118 4.7%, 0.625 14.4%, 0.826 19%, 0.902, 0.962, 1.008 26.1%, 1.041 28.7%, 1.064 32.1%, 1.07 36%, 1.061 40.5%, 1.015 53.4%, 0.999 61.6%, 0.995 71.2%, 1)}to{opacity:1;transform:scale(1)}}post-list{display:flex;flex-direction:column;gap:var(--post-list-title-gap, 0)}post-list>[role=list]{display:flex;flex-direction:column;gap:var(--post-list-item-gap, 0)}post-list:where([horizontal]:not([horizontal=false])){flex-direction:row;align-items:center}post-list:where([horizontal]:not([horizontal=false]))>[role=list]{flex-direction:row;align-items:center}post-list>.list-title.visually-hidden{width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}post-list>.list-title.visually-hidden:not(caption){position:absolute !important}";
704
- const PostListStyle0 = postListCss;
705
-
706
- const PostList = class {
707
- constructor(hostRef) {
708
- registerInstance(this, hostRef);
709
- this.titleId = undefined;
710
- this.titleHidden = false;
711
- this.horizontal = false;
712
- }
713
- componentWillLoad() {
714
- /**
715
- * Get the id set on the host element or use a random id by default
716
- */
717
- this.titleId = `title-${this.host.id || nanoid(6)}`;
718
- }
719
- componentDidLoad() {
720
- this.checkTitle();
721
- }
722
- checkTitle() {
723
- if (!this.titleEl.textContent.trim()) {
724
- console.error('Please provide a title to the list component. Title is mandatory for accessibility purposes.');
725
- }
726
- }
727
- render() {
728
- return (h(Host, { key: '9c840e19d92cb7417aaa8395a1d15248dbe274dc', "data-version": version }, h("div", { key: '973c24857b843c96ae41e6937042ca968bf16d09', ref: el => (this.titleEl = el), id: this.titleId, class: `list-title${this.titleHidden ? ' visually-hidden' : ''}` }, h("slot", { key: '594403d0d7ce9bdf7d7b2b6a5bd6a4b75f305ac2' })), h("div", { key: '76cb68b6913f8a574c998d9554a68788170a5fa1', role: "list", "aria-labelledby": this.titleId }, h("slot", { key: '3b7f42ddec020297ac1bdd615274089bc4300f09', name: "post-list-item" }))));
729
- }
730
- get host() { return getElement(this); }
731
- };
732
- PostList.style = PostListStyle0;
733
-
734
- const postListItemCss = ":host{display:flex}";
735
- const PostListItemStyle0 = postListItemCss;
736
-
737
- const PostListItem = class {
738
- constructor(hostRef) {
739
- registerInstance(this, hostRef);
740
- }
741
- connectedCallback() {
742
- this.host.setAttribute('slot', 'post-list-item');
743
- }
744
- render() {
745
- return (h(Host, { key: '83d78cdee7b19cd48bd2d601d4ae8fd288027918', role: "listitem", slot: "post-list-item", version: version }, h("slot", { key: '7b5900ae509b8ad98aa5e5d4f2053ee61889b140' })));
746
- }
747
- get host() { return getElement(this); }
748
- };
749
- PostListItem.style = PostListItemStyle0;
750
-
751
- const postLogoCss = ":host,.logo{display:inline-block}:host,:host .logo>svg,.logo,.logo .logo>svg{height:100%}.description{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);border:0}.logo-link{outline-offset:var(--post-device-spacing-padding-2) !important;outline:var(--post-scheme-color-interactive-focus-stroke) none var(--post-device-border-width-focus) !important}.logo-link:is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.logo-link:is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-color:Highlight !important}}@supports not selector(:has(:focus-visible)){.logo-link:is(:focus-visible,:focus-within,.pretend-focus){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.logo-link:is(:focus-visible,:focus-within,.pretend-focus){outline-color:Highlight !important}}}.logo-link :focus,:focus-visible{border-radius:2px}";
752
- const PostLogoStyle0 = postLogoCss;
753
-
754
- const PostLogo = class {
755
- constructor(hostRef) {
756
- registerInstance(this, hostRef);
757
- this.url = undefined;
758
- }
759
- validateUrl() {
760
- checkEmptyOrUrl(this, 'url');
761
- }
762
- componentDidLoad() {
763
- this.validateUrl();
764
- this.checkDescription();
765
- }
766
- checkDescription() {
767
- if (!this.host.textContent) {
768
- console.warn('Be sure to add descriptive text in the post-logo to ensure good accessibility of the component.');
769
- }
770
- }
771
- render() {
772
- const logoLink = this.url && (typeof this.url === 'string' ? this.url : this.url.href);
773
- const LogoTag = logoLink ? 'a' : 'span';
774
- return (h(Host, { key: 'acbb3910083a3a8ba6250096f2a7330c0bae19bc', "data-version": version }, h(LogoTag, { key: 'db6e237031f4d58e50cf56e9bd63124e9b8811d8', class: `logo ${logoLink ? 'logo-link' : ''}`, ...(logoLink ? { href: logoLink } : {}) }, h("span", { key: '439f8c6fca5647bf36eab69361089bba97830933', class: "description" }, h("slot", { key: 'fbbd95d221c91dd6a22823802cbcd680fb3d2210', onSlotchange: () => this.checkDescription() })), h("svg", { key: '4c12add52030e6bb414246acb073b4b5cb88cd8f', xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 72 72", "aria-hidden": "true" }, h("g", { key: 'a103907694067c20eff3db5695a85daa78f8e293', id: "Logo" }, h("rect", { key: 'bba502be5b0598df7a7a9be11ec878c4c98f813e', fill: "#ffcc00", x: "0", y: "0", width: "72", height: "72" }), h("polygon", { key: 'd5b8cdf3ba35ff13ac037a59347f5decbd5266fe', fill: "#ff0000", points: "34,32.3 34,19 19.7,19 19.7,29.1 10,29.1 10,42.9 19.7,42.9 19.7,53 34,53 34,39.7 30.6,39.7 30.6,49.8 23.1,49.8 23.1,39.7 13.4,39.7 13.4,32.3 23.1,32.3 23.1,22.2 30.6,22.2 30.6,32.3" }), h("path", { key: '4dd42726bd15f4a47054e79c4b66093a5f1d088a', d: "M53.56234,31.10526c0,2.41272-1.99154,4.29475-4.51723,4.29475H45.2v-8.3h3.84511C51.66802,27.1,53.56234,28.78889,53.56234,31.10526z M50.69666,19H36v34h9.2V42.9h5.49666c6.75131,0,11.9971-5.15137,11.9971-11.8057C62.69376,24.39136,57.35099,19,50.69666,19z" }))))));
775
- }
776
- get host() { return getElement(this); }
777
- static get watchers() { return {
778
- "url": ["validateUrl"]
779
- }; }
780
- };
781
- PostLogo.style = PostLogoStyle0;
782
-
783
- const postMainnavigationCss = "post-mainnavigation post-list-item>a{text-decoration:none;border-radius:0}post-mainnavigation post-list-item post-megadropdown-trigger button{padding:0;overflow:visible;border:0;background:none;color:var(--post-scheme-color-interactive-button-secondary-enabled-fg);font:inherit;-webkit-user-select:none;user-select:none;appearance:button;text-align:start}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){post-mainnavigation post-list-item post-megadropdown-trigger button{background-color:ButtonFace !important}post-mainnavigation post-list-item post-megadropdown-trigger button:hover{background-color:Highlight !important}}post-mainnavigation post-list-item>a,post-mainnavigation post-list-item post-megadropdown-trigger button{flex:0 0 fit-content;white-space:nowrap;display:flex;align-items:center;justify-content:space-between}post-mainnavigation post-list-item>a:hover,post-mainnavigation post-list-item post-megadropdown-trigger button:hover{color:var(--post-scheme-color-interactive-primary-hover-fg1)}post-mainnavigation post-list-item>a:focus-visible,post-mainnavigation post-list-item post-megadropdown-trigger button:focus-visible{border-radius:4px;outline-offset:-2px !important}@media screen and (max-width: 1023.98px){post-mainnavigation .back-button{font-size:16px}}@media screen and (max-width: 599.98px){post-mainnavigation .back-button{font-size:14px}}post-mainnavigation>button::after,post-mainnavigation post-megadropdown-trigger button::after{content:\"\";mask-image:url(\"data:image/svg+xml,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='m23.6 13.2-7.5 7.6-7.6-7.6.9-.9 6.6 6.6 6.6-6.6z'/%3E%3C/svg%3E\");background-color:currentColor;color:currentColor;forced-color-adjust:preserve-parent-color;height:24px;width:24px}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){post-mainnavigation>button,post-mainnavigation post-megadropdown-trigger button{border:1px solid ButtonBorder !important}post-mainnavigation>button:hover::after,post-mainnavigation>button[aria-expanded=true]::after,post-mainnavigation post-megadropdown-trigger button:hover::after,post-mainnavigation post-megadropdown-trigger button[aria-expanded=true]::after{color:HighlightText}}@media screen and (min-width: 1024px){post-mainnavigation{display:block;position:relative;height:var(--post-main-navigation-height);background:#fff;user-select:none}post-mainnavigation nav{flex:1 1 auto;overflow:hidden;scroll-behavior:smooth}post-mainnavigation .scroll-control{cursor:pointer;position:absolute;inset-block:0;z-index:5;padding:16px;background:#fff;box-shadow:var(--post-device-elevation-500);line-height:1}post-mainnavigation .scroll-control.scroll-left{inset-inline-start:0}post-mainnavigation .scroll-control.scroll-right{inset-inline-end:0}post-mainnavigation .scroll-control.d-none{display:none}post-mainnavigation .scroll-control post-icon{font-size:1rem}post-mainnavigation post-list>[role=list]{flex-direction:row;max-width:100vw}post-mainnavigation post-list-item>a,post-mainnavigation post-list-item>button,post-mainnavigation post-list-item post-megadropdown-trigger button{position:sticky;padding-inline:12px;height:var(--post-main-navigation-height);gap:4px;font-size:16px;z-index:4}}@media screen and (min-width: 1024px)and (max-width: 1023.98px){post-mainnavigation post-list-item>a,post-mainnavigation post-list-item>button,post-mainnavigation post-list-item post-megadropdown-trigger button{z-index:5}}@media screen and (min-width: 1024px){post-mainnavigation post-list-item>a .nav-el-active,post-mainnavigation post-list-item>button .nav-el-active,post-mainnavigation post-list-item post-megadropdown-trigger button .nav-el-active{font-weight:700;text-align:center;opacity:0}}@media screen and (min-width: 1024px){post-mainnavigation post-list-item>a .nav-el-inactive,post-mainnavigation post-list-item>button .nav-el-inactive,post-mainnavigation post-list-item post-megadropdown-trigger button .nav-el-inactive{position:absolute;opacity:1;text-align:center;width:100%;inset-inline-start:0}}@media screen and (min-width: 1024px){post-mainnavigation post-list-item>a.selected,post-mainnavigation post-list-item>a[aria-expanded=true],post-mainnavigation post-list-item>button.selected,post-mainnavigation post-list-item>button[aria-expanded=true],post-mainnavigation post-list-item post-megadropdown-trigger button.selected,post-mainnavigation post-list-item post-megadropdown-trigger button[aria-expanded=true]{background-color:#050400;color:#fff;font-weight:700}post-mainnavigation post-list-item>a.selected .nav-el-active,post-mainnavigation post-list-item>a[aria-expanded=true] .nav-el-active,post-mainnavigation post-list-item>button.selected .nav-el-active,post-mainnavigation post-list-item>button[aria-expanded=true] .nav-el-active,post-mainnavigation post-list-item post-megadropdown-trigger button.selected .nav-el-active,post-mainnavigation post-list-item post-megadropdown-trigger button[aria-expanded=true] .nav-el-active{opacity:1}post-mainnavigation post-list-item>a.selected .nav-el-inactive,post-mainnavigation post-list-item>a[aria-expanded=true] .nav-el-inactive,post-mainnavigation post-list-item>button.selected .nav-el-inactive,post-mainnavigation post-list-item>button[aria-expanded=true] .nav-el-inactive,post-mainnavigation post-list-item post-megadropdown-trigger button.selected .nav-el-inactive,post-mainnavigation post-list-item post-megadropdown-trigger button[aria-expanded=true] .nav-el-inactive{opacity:0}}@media screen and (min-width: 1024px){post-mainnavigation post-list-item>a:hover,post-mainnavigation post-list-item>button:hover,post-mainnavigation post-list-item post-megadropdown-trigger button:hover{background-color:#504f4b;color:#fff}}@media screen and (min-width: 1024px)and (max-width: 599.98px){post-mainnavigation post-list-item>a,post-mainnavigation post-list-item>button,post-mainnavigation post-list-item post-megadropdown-trigger button{font-size:14px}}@media screen and (min-width: 1024px){post-mainnavigation post-list-item>button,post-mainnavigation post-list-item post-megadropdown-trigger button{padding-inline-end:12px;transition:border-block-end-color 250ms cubic-bezier(0.4, 0, 0.2, 1)}post-mainnavigation post-list-item>button .nav-el-inactive,post-mainnavigation post-list-item post-megadropdown-trigger button .nav-el-inactive{width:calc(100% - 28px)}post-mainnavigation post-list-item>button::after,post-mainnavigation post-list-item post-megadropdown-trigger button::after{transition:transform 250ms cubic-bezier(0.4, 0, 0.2, 1)}post-mainnavigation post-list-item>button.selected::after,post-mainnavigation post-list-item>button[aria-expanded=true]::after,post-mainnavigation post-list-item post-megadropdown-trigger button.selected::after,post-mainnavigation post-list-item post-megadropdown-trigger button[aria-expanded=true]::after{transform:rotate(180deg)}}@media screen and (min-width: 1024px){post-mainnavigation post-megadropdown button:not(.btn-icon-close),post-mainnavigation post-megadropdown a{width:100%;min-width:100%;height:48px;padding-inline:8px 12px;gap:16px;font-weight:400;position:relative}post-mainnavigation post-megadropdown button:not(.btn-icon-close)::before,post-mainnavigation post-megadropdown a::before{content:\"\";background-color:#050400;bottom:0;width:100%;height:1px;position:absolute;left:0}post-mainnavigation post-megadropdown button:not(.btn-icon-close).selected,post-mainnavigation post-megadropdown button:not(.btn-icon-close)[aria-expanded=true],post-mainnavigation post-megadropdown a.selected,post-mainnavigation post-megadropdown a[aria-expanded=true]{background-color:#050400;color:#fff}post-mainnavigation post-megadropdown button:not(.btn-icon-close):hover,post-mainnavigation post-megadropdown a:hover{background-color:#504f4b;color:#fff}post-mainnavigation post-megadropdown button:not(.btn-icon-close):hover::before,post-mainnavigation post-megadropdown a:hover::before{background-color:#504f4b}}@media screen and (min-width: 1024px){post-mainnavigation [slot=back-button]{display:none}}@media screen and (max-width: 1023.98px){post-mainnavigation nav{transform:none !important}post-mainnavigation .scroll-control{display:none}post-mainnavigation post-list-item>a,post-mainnavigation post-list-item>button,post-mainnavigation post-list-item post-megadropdown-trigger button{width:100%;min-width:100%;height:48px;padding-inline:8px 12px;gap:16px;font-weight:400;position:relative}post-mainnavigation post-list-item>a::before,post-mainnavigation post-list-item>button::before,post-mainnavigation post-list-item post-megadropdown-trigger button::before{content:\"\";background-color:#050400;bottom:0;width:100%;height:1px;position:absolute;left:0}post-mainnavigation post-list-item>a.selected,post-mainnavigation post-list-item>a[aria-expanded=true],post-mainnavigation post-list-item>button.selected,post-mainnavigation post-list-item>button[aria-expanded=true],post-mainnavigation post-list-item post-megadropdown-trigger button.selected,post-mainnavigation post-list-item post-megadropdown-trigger button[aria-expanded=true]{background-color:#050400;color:#fff}post-mainnavigation post-list-item>a:hover,post-mainnavigation post-list-item>button:hover,post-mainnavigation post-list-item post-megadropdown-trigger button:hover{background-color:#504f4b;color:#fff}post-mainnavigation post-list-item>a:hover::before,post-mainnavigation post-list-item>button:hover::before,post-mainnavigation post-list-item post-megadropdown-trigger button:hover::before{background-color:#504f4b}post-mainnavigation post-list-item>a .nav-el-inactive,post-mainnavigation post-list-item>button .nav-el-inactive,post-mainnavigation post-list-item post-megadropdown-trigger button .nav-el-inactive{display:none}post-mainnavigation>button::after,post-mainnavigation post-megadropdown-trigger button::after{transform:rotate(-90deg)}}post-mainnavigation .back-button .btn{padding-inline:0}";
784
- const PostMainnavigationStyle0 = postMainnavigationCss;
785
-
786
- const SCROLL_REPEAT_INTERVAL = 100; // Interval for repeated scrolling when holding down scroll button
787
- const NAVBAR_DISABLE_DURATION = 400; // Duration to temporarily disable navbar interactions during scrolling
788
- const PostMainnavigation = class {
789
- constructor(hostRef) {
790
- registerInstance(this, hostRef);
791
- this.canScrollLeft = false;
792
- this.canScrollRight = false;
793
- this.scrollRight = this.scrollRight.bind(this);
794
- this.scrollLeft = this.scrollLeft.bind(this);
795
- this.handleMutations = this.handleMutations.bind(this);
796
- this.checkScrollability = this.checkScrollability.bind(this);
797
- this.resizeObserver = new ResizeObserver(this.checkScrollability);
798
- this.mutationObserver = new MutationObserver(this.handleMutations);
799
- }
800
- componentDidLoad() {
801
- setTimeout(() => {
802
- this.fixLayoutShift();
803
- this.checkScrollability();
804
- });
805
- // Observe the navbar for size changes
806
- this.resizeObserver.observe(this.navbar);
807
- // Observe the navabar for mutation changes
808
- this.mutationObserver.observe(this.navbar, { subtree: true, childList: true }); // Recheck scrollability when navigation list changes
809
- // Ensure the scroll buttons are correctly displayed or hidden whenever the navbar is scrolled
810
- this.navbar.addEventListener('scrollend', this.checkScrollability);
811
- }
812
- /**
813
- * Disconnects observers and remove event listeners when the main navigation is removed from the DOM.
814
- */
815
- disconnectedCallback() {
816
- this.mutationObserver.disconnect();
817
- this.resizeObserver.disconnect();
818
- this.navbar.removeEventListener('scrollend', this.checkScrollability);
819
- }
820
- /**
821
- * Stops the repeated scrolling when the mouse button is released.
822
- */
823
- stopScrolling() {
824
- if (this.scrollRepeatInterval)
825
- clearInterval(this.scrollRepeatInterval);
826
- }
827
- async handleMutations(mutations) {
828
- const addedNodes = mutations.flatMap((mutation) => {
829
- return Array.from(mutation.addedNodes);
830
- });
831
- // Wait for all elements to be hydrated
832
- await Promise.all(addedNodes.map((item) => item.componentOnReady ? item.componentOnReady() : Promise.resolve(item)));
833
- this.fixLayoutShift();
834
- this.checkScrollability();
835
- }
836
- get navigationItems() {
837
- return Array.from(this.navbar.querySelectorAll(':is(a, button):not(post-megadropdown *)'));
838
- }
839
- /**
840
- * Hack to fix the layout shift due to bold text on active elements
841
- */
842
- fixLayoutShift() {
843
- this.navigationItems
844
- .filter(item => !item.matches(':has(.nav-el-active)'))
845
- .forEach(item => {
846
- item.innerHTML = `
847
- <span class="nav-el-active">${item.innerHTML}</span>
848
- <span class="nav-el-inactive" aria-hidden="true">${item.innerHTML}</span>
849
- `;
850
- });
851
- }
852
- handleBackButtonClick() {
853
- const header = this.navbar.closest('post-header');
854
- if (header)
855
- header.toggleMobileMenu();
856
- }
857
- /**
858
- * Returns whether scrolling is enabled in either the left or right direction.
859
- */
860
- get canScroll() {
861
- return this.canScrollLeft || this.canScrollRight;
862
- }
863
- /**
864
- * Checks if scrolling is possible in either direction (left or right) and updates the state accordingly.
865
- */
866
- checkScrollability() {
867
- const { scrollLeft, scrollWidth, clientWidth } = this.navbar;
868
- if (scrollWidth === clientWidth) {
869
- // If scroll width equals client width, scrolling is disabled in both directions
870
- this.canScrollLeft = this.canScrollRight = false;
871
- }
872
- else {
873
- this.canScrollLeft = Math.floor(scrollLeft) > 0; // Scrolling left is possible if not at the start
874
- this.canScrollRight = Math.ceil(clientWidth + scrollLeft) < scrollWidth; // Scrolling right is possible if not at the end
875
- }
876
- }
877
- /**
878
- * Handles the scrolling behavior when a user clicks on the left or right scroll buttons.
879
- */
880
- handleScrollButtonClick(e, direction) {
881
- if (!this.canScroll || e.button !== 0)
882
- return;
883
- // Disable interaction with the navbar during scrolling
884
- this.temporarilyDisableNavbar();
885
- // Set up the correct scroll function
886
- const scroll = direction === 'right' ? this.scrollRight : this.scrollLeft;
887
- scroll();
888
- // Repeat the scrolling action while the button is held down
889
- this.scrollRepeatInterval = setInterval(() => {
890
- scroll();
891
- }, SCROLL_REPEAT_INTERVAL);
892
- }
893
- scrollRight() {
894
- const scrollRightLeftEdge = document
895
- .querySelector('.scroll-right')
896
- .getBoundingClientRect().left;
897
- for (const navigationItem of this.navigationItems) {
898
- const { right, width } = navigationItem.getBoundingClientRect();
899
- // Scroll to the first navigation item that is less than 75% visible
900
- const isThreeQuartersVisible = right - 0.25 * width < scrollRightLeftEdge;
901
- if (!isThreeQuartersVisible) {
902
- this.navbar.scrollBy({ left: right - scrollRightLeftEdge });
903
- return;
904
- }
905
- }
906
- }
907
- scrollLeft() {
908
- const scrollLeftRightEdge = document
909
- .querySelector('.scroll-left')
910
- .getBoundingClientRect().right;
911
- for (const navigationItem of this.navigationItems.reverse()) {
912
- const { left, width } = navigationItem.getBoundingClientRect();
913
- // Scroll to the first navigation item that is less than 75% visible
914
- const isThreeQuartersVisible = left + 0.25 * width > scrollLeftRightEdge;
915
- if (!isThreeQuartersVisible) {
916
- this.navbar.scrollBy({ left: left - scrollLeftRightEdge });
917
- return;
918
- }
919
- }
920
- }
921
- /**
922
- * Temporarily disables interactions with the navbar during scrolling to prevent accidental clicks.
923
- * Re-enables interactions after a brief delay to avoid blocking the user entirely.
924
- */
925
- temporarilyDisableNavbar() {
926
- if (this.navbarDisableTimer)
927
- clearTimeout(this.navbarDisableTimer);
928
- this.navbar.setAttribute('inert', '');
929
- this.navbarDisableTimer = setTimeout(() => {
930
- this.navbar.removeAttribute('inert');
931
- }, NAVBAR_DISABLE_DURATION);
932
- }
933
- render() {
934
- return (h(Host, { key: '0aaf98ec2144bec91f4eec42ab367a419e406681', slot: "post-mainnavigation", version: version }, h("div", { key: 'b09cff2d01eb4bbc75824368433c7d730cbb2230', onClick: () => this.handleBackButtonClick(), class: "back-button" }, h("slot", { key: '0270f7b3fcd2702d44159d0325604c02b582a89e', name: "back-button" })), h("div", { key: '70f46db7348b1e8b34ec57a055763637fbde68e6', "aria-hidden": "true", class: { 'scroll-control scroll-left': true, 'd-none': !this.canScrollLeft }, onMouseDown: e => this.handleScrollButtonClick(e, 'left') }, h("post-icon", { key: '4326ec1115371476986e594556127f2710543b4f', "aria-hidden": "true", name: "chevronleft" })), h("nav", { key: 'e20213b2b307f29ea2ff6d39a766144bae5dff3b', ref: el => (this.navbar = el) }, h("slot", { key: '17c5b51c7a29ead6635f72df25bb5457d4b86ecf' })), h("div", { key: '9b8a2033a772315167c0c28b5ba769a4c5a957e8', "aria-hidden": "true", class: { 'scroll-control scroll-right': true, 'd-none': !this.canScrollRight }, onMouseDown: e => this.handleScrollButtonClick(e, 'right') }, h("post-icon", { key: 'f941e874a0b28b784f248e0e6ec8eeb5feb61ef7', "aria-hidden": "true", name: "chevronright" }))));
935
- }
936
- };
937
- PostMainnavigation.style = PostMainnavigationStyle0;
938
-
939
- const postMegadropdownCss = "@keyframes slide-in{0%{transform:translateX(100%)}100%{transform:translateX(0%)}}@keyframes slide-out{from{transform:translateX(0%)}to{transform:translateX(100%)}}@keyframes slide-down{from{transform:translateY(-100%)}to{transform:translateY(0%)}}@keyframes slide-up{0%{transform:translateY(0%)}100%{transform:translateY(-100%)}}*,::before,::after{box-sizing:border-box}.megadropdown-container{box-shadow:0 8px 6px rgba(0,0,0,.16);position:absolute;background-color:#fafafa;border:none;z-index:1;width:100%;inset-block-start:100%;inset-inline-start:0;border-radius:0}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){.megadropdown-container{border-block-end:1px solid CanvasText}}.megadropdown-container.slide-in{animation:slide-down 350ms forwards}.megadropdown-container.slide-out{animation:slide-up 350ms forwards}@media screen and (max-width: 1023.98px){.megadropdown-container{z-index:5;position:fixed;inset-block-start:var(--post-header-navigation-current-inset);inset-inline:0;height:calc(min(var(--post-header-scroll-parent-height, 100dvh),100dvh) - var(--post-header-height));border-block-start:unset;overflow-y:auto;overscroll-behavior:contain}.megadropdown-container.slide-in{animation:slide-in 350ms forwards}.megadropdown-container.slide-out{animation:slide-out 350ms forwards}}@media screen and (min-width: 1024px){.megadropdown-container{max-height:calc(100vh - var(--post-header-height) - 48px);overflow-y:auto}}.megadropdown{padding:31px 40px 40px;background-color:#fafafa}@media screen and (max-width: 1023.98px){.megadropdown{display:flex;flex-direction:column;width:inherit;padding:16px 32px 24px}}@media screen and (max-width: 599.98px){.megadropdown{padding-inline:16px}}.megadropdown .megadropdown-content{gap:1.5rem;display:grid;grid-template-columns:repeat(auto-fit, minmax(min(15vw, 100%), 1fr));grid-auto-rows:1fr auto;grid-auto-flow:dense}@media screen and (max-width: 1023.98px){.megadropdown .megadropdown-content{grid-template-columns:repeat(auto-fit, minmax(min(35vw, 100%), 1fr))}}@media screen and (max-width: 599.98px){.megadropdown .megadropdown-content{grid-template-columns:1fr}}.megadropdown h2{display:none;margin-block:0 8px;font-weight:900}.megadropdown h2 a{text-decoration:none;display:none;font-weight:inherit;border-block:0}@media screen and (max-width: 1023.98px){.megadropdown h2{display:block;font-size:1.25rem}}@media screen and (max-width: 599.98px){.megadropdown h2{font-size:1.125rem}}.megadropdown post-list{display:grid;grid-row:span 2;grid-template-rows:subgrid;row-gap:0px}.megadropdown post-list>[role=list]{flex-direction:unset;display:unset}.megadropdown post-list>*{width:100%}.megadropdown post-list .list-title{display:flex;flex-direction:column-reverse;height:100%}.megadropdown post-list .list-title h3{font-size:20px;display:block;font-weight:900}.megadropdown post-list .list-title h3:not(:has(a)),.megadropdown post-list .list-title h3 a{padding:16px 12px 14px 8px}.megadropdown post-list .list-title h3:not(:has(a)){position:relative}.megadropdown post-list .list-title h3:not(:has(a))::before{content:\"\";background-color:#050400;inset-block-end:0;inset-inline-start:0;width:100%;height:2px;position:absolute}.megadropdown post-list .list-title h3 a{border-radius:0;text-decoration:none;font-size:inherit;display:flex;align-items:center;justify-content:space-between;min-height:53px;width:100%;min-width:100%;height:48px;padding-inline:8px 12px;gap:16px;font-weight:400;position:relative;height:unset;font-weight:900}.megadropdown post-list .list-title h3 a::before{content:\"\";background-color:#050400;bottom:0;width:100%;height:1px;position:absolute;left:0}.megadropdown post-list .list-title h3 a.selected,.megadropdown post-list .list-title h3 a[aria-expanded=true]{background-color:#050400;color:#fff}.megadropdown post-list .list-title h3 a:hover{background-color:#504f4b;color:#fff}.megadropdown post-list .list-title h3 a:hover::before{background-color:#504f4b}.megadropdown post-list .list-title h3 a::before{height:2px}@media screen and (max-width: 1023.98px){.megadropdown post-list .list-title h3{font-size:1rem}.megadropdown post-list .list-title h3:not(:has(a)),.megadropdown post-list .list-title h3 a{padding:14px 12px 12px 8px}}@media screen and (max-width: 599.98px){.megadropdown post-list .list-title h3{font-size:.875rem}}.megadropdown post-list-item>a{padding-block:13px 12px;padding-inline-start:8px;display:flex;text-decoration:none;width:100%;min-width:100%;height:auto;min-height:48px;white-space:normal;word-break:break-word}.megadropdown post-list-item>a:hover{border-block-width:0}@media screen and (min-width: 1024px){.megadropdown post-list-item>a{font-size:1.25rem}}@media screen and (max-width: 1023.98px){.megadropdown post-list-item>a{padding-block:12px 11px}}@media screen and (max-width: 599.98px){.megadropdown post-list-item>a{font-size:.875rem}}.megadropdown .back-button{display:none;margin-block-end:2rem}.megadropdown .back-button .btn{width:auto}@media screen and (max-width: 1023.98px){.megadropdown .back-button{order:-1;display:block}}.megadropdown .close-button{position:absolute;inset-block-start:1rem;inset-inline-end:1rem}@media screen and (max-width: 1023.98px){.megadropdown .close-button{display:none}}";
940
- const PostMegadropdownStyle0 = postMegadropdownCss;
941
-
942
- const PostMegadropdown = class {
943
- constructor(hostRef) {
944
- registerInstance(this, hostRef);
945
- this.postToggleMegadropdown = createEvent(this, "postToggleMegadropdown", 7);
946
- this.handleClickOutside = (event) => {
947
- if (this.device !== 'desktop')
948
- return;
949
- const target = event.target;
950
- if (this.host.contains(target)) {
951
- return;
952
- }
953
- if (target instanceof HTMLElement) {
954
- const trigger = target.closest('post-megadropdown-trigger');
955
- if (trigger) {
956
- const targetDropdownId = trigger.getAttribute('for');
957
- if (targetDropdownId !== this.host.id) {
958
- return;
959
- }
960
- }
961
- }
962
- this.hide(false);
963
- };
964
- this.device = breakpoint.get('name');
965
- this.isVisible = false;
966
- this.animationClass = null;
967
- }
968
- breakpointChange(e) {
969
- this.device = e.detail;
970
- if (this.device === 'desktop' && this.isVisible) {
971
- this.animationClass = null;
972
- }
973
- }
974
- disconnectedCallback() {
975
- this.removeListeners();
976
- window.removeEventListener('postBreakpoint:name', this.breakpointChange.bind(this));
977
- if (PostMegadropdown.activeDropdown === this) {
978
- PostMegadropdown.activeDropdown = null;
979
- }
980
- }
981
- componentWillRender() {
982
- this.getFocusableElements();
983
- }
984
- /**
985
- * Toggles the dropdown visibility based on its current state.
986
- */
987
- async toggle() {
988
- if (this.isVisible) {
989
- this.hide();
990
- }
991
- else {
992
- await this.show();
993
- }
994
- }
995
- /**
996
- * Displays the dropdown.
997
- */
998
- async show() {
999
- if (PostMegadropdown.activeDropdown && PostMegadropdown.activeDropdown !== this) {
1000
- // Close the previously active dropdown without animation
1001
- PostMegadropdown.activeDropdown.forceClose();
1002
- }
1003
- else {
1004
- this.animationClass = 'slide-in';
1005
- }
1006
- this.isVisible = true;
1007
- PostMegadropdown.activeDropdown = this;
1008
- this.postToggleMegadropdown.emit({ isVisible: this.isVisible });
1009
- if (this.firstFocusableEl &&
1010
- window.getComputedStyle(this.firstFocusableEl).display !== 'none') {
1011
- this.firstFocusableEl.focus();
1012
- }
1013
- this.addListeners();
1014
- }
1015
- /**
1016
- * Hides the dropdown with an animation.
1017
- */
1018
- async hide(focusParent = true, forceClose = false) {
1019
- this.postToggleMegadropdown.emit({ isVisible: false, focusParent: focusParent });
1020
- if (forceClose) {
1021
- this.forceClose();
1022
- }
1023
- else {
1024
- this.animationClass = 'slide-out';
1025
- }
1026
- }
1027
- /**
1028
- * Sets focus to the first focusable element within the component.
1029
- */
1030
- async focusFirst() {
1031
- this.firstFocusableEl?.focus();
1032
- }
1033
- connectedCallback() {
1034
- window.addEventListener('postBreakpoint:name', this.breakpointChange.bind(this));
1035
- }
1036
- /**
1037
- * Forces the dropdown to close without animation.
1038
- */
1039
- forceClose() {
1040
- this.isVisible = false;
1041
- this.animationClass = null;
1042
- this.postToggleMegadropdown.emit({ isVisible: this.isVisible, focusParent: false });
1043
- this.removeListeners();
1044
- }
1045
- handleAnimationEnd() {
1046
- if (this.animationClass === 'slide-out') {
1047
- this.isVisible = false;
1048
- this.animationClass = null;
1049
- PostMegadropdown.activeDropdown = null;
1050
- this.removeListeners();
1051
- }
1052
- }
1053
- addListeners() {
1054
- this.host.addEventListener('keydown', e => this.keyboardHandler(e));
1055
- document.addEventListener('keyup', e => this.handleTabOutside(e));
1056
- document.addEventListener('mousedown', this.handleClickOutside);
1057
- }
1058
- removeListeners() {
1059
- this.host.removeEventListener('keydown', e => this.keyboardHandler(e));
1060
- document.removeEventListener('keyup', e => this.handleTabOutside(e));
1061
- document.removeEventListener('mousedown', this.handleClickOutside);
1062
- }
1063
- getFocusableElements() {
1064
- const focusableEls = Array.from(this.host.querySelectorAll('post-list-item, h3, .back-button'));
1065
- const focusableChildren = focusableEls.flatMap(el => Array.from(getFocusableChildren(el)));
1066
- this.firstFocusableEl = focusableChildren[0];
1067
- this.lastFocusableEl = focusableChildren[focusableChildren.length - 1];
1068
- }
1069
- // Loop through the focusable children
1070
- keyboardHandler(e) {
1071
- if (e.key === 'Tab' && this.device !== 'desktop') {
1072
- if (e.shiftKey && document.activeElement === this.firstFocusableEl) {
1073
- // If back tab (TAB + Shift) and first element is focused, focus goes to the last element of the megadropdown
1074
- e.preventDefault();
1075
- this.lastFocusableEl.focus();
1076
- }
1077
- else if (!e.shiftKey && document.activeElement === this.lastFocusableEl) {
1078
- // If TAB and last element is focused, focus goes back to the first element of the megadropdown
1079
- e.preventDefault();
1080
- this.firstFocusableEl.focus();
1081
- }
1082
- }
1083
- }
1084
- handleTabOutside(e) {
1085
- if (e.key === 'Tab' && this.device === 'desktop') {
1086
- if (!this.host.contains(e.target)) {
1087
- this.hide(false);
1088
- }
1089
- }
1090
- }
1091
- render() {
1092
- const containerStyle = this.isVisible ? {} : { display: 'none' };
1093
- return (h(Host, { key: 'e860446551f08b3a7088c0bc76a18e6ed41d9222', version: version }, h("div", { key: 'e751ca57df7333a18a53f960d3ef51f76cea1cad', class: `megadropdown-container ${this.animationClass || ''}`, style: containerStyle, onAnimationEnd: () => this.handleAnimationEnd() }, h("div", { key: '75c3196c0b1ba5e1cb2ec18e6252704085c19760', class: "megadropdown" }, h("slot", { key: 'ab81352d1f4114cba1b34aeec5cc3b96074ac20f', name: "megadropdown-title" }), h("div", { key: '05fb088c749a53cd52265b703b7abc54e1be17f0', class: "megadropdown-content" }, h("slot", { key: 'a44dae9c90010501979f1ffc952bf4cc8432b788' })), h("div", { key: 'd7f8ca6f372ca4474852ec36008c8a25802b0d76', onClick: () => this.hide(true), class: "back-button" }, h("slot", { key: 'c2b815a8b4dff84457f22a1b2b6efdd53d14a102', name: "back-button" })), h("div", { key: '36416cd916c6424ee61c7d25f5eff9dff6b9d163', onClick: () => this.hide(true), class: "close-button" }, h("slot", { key: 'a3e3ff53229c9986167f25cf6c7cd78bccbeb635', name: "close-button" }))))));
1094
- }
1095
- get host() { return getElement(this); }
1096
- };
1097
- /** Tracks the currently active dropdown instance. */
1098
- PostMegadropdown.activeDropdown = null;
1099
- PostMegadropdown.style = PostMegadropdownStyle0;
1100
-
1101
- const postMegadropdownTriggerCss = "post-megadropdown-trigger{width:100%;position:relative;z-index:3}@media screen and (max-width: 1023.98px){post-megadropdown-trigger{z-index:4}}";
1102
- const PostMegadropdownTriggerStyle0 = postMegadropdownTriggerCss;
1103
-
1104
- const PostMegadropdownTrigger = class {
1105
- constructor(hostRef) {
1106
- registerInstance(this, hostRef);
1107
- /**
1108
- * Reference to the slotted button within the trigger, if present.
1109
- * Used to manage click and key events for mega dropdown control.
1110
- */
1111
- this.slottedButton = null;
1112
- /**
1113
- * Tracks whether this trigger's dropdown was expanded before a state change.
1114
- * Used to determine if this trigger should handle focus when its dropdown closes.
1115
- */
1116
- this.wasExpanded = false;
1117
- this.handleKeyDown = (event) => {
1118
- if (event.key === 'Enter' || event.key === ' ') {
1119
- event.preventDefault();
1120
- this.handleToggle();
1121
- if (this.megadropdown && !this.ariaExpanded) {
1122
- setTimeout(() => this.megadropdown.focusFirst(), 100);
1123
- }
1124
- }
1125
- };
1126
- this.handleToggleMegadropdown = (event) => {
1127
- eventGuard(this.host, event, { targetLocalName: 'post-megadropdown' }, () => {
1128
- if (event.target.id === this.for) {
1129
- this.ariaExpanded = event.detail.isVisible;
1130
- // Focus on the trigger parent of the dropdown after it's closed if the close button had been clicked
1131
- if (this.wasExpanded && !this.ariaExpanded && event.detail.focusParent) {
1132
- setTimeout(() => {
1133
- this.slottedButton?.focus();
1134
- }, 100);
1135
- }
1136
- this.wasExpanded = this.ariaExpanded;
1137
- if (this.slottedButton) {
1138
- this.slottedButton.setAttribute('aria-expanded', this.ariaExpanded.toString());
1139
- }
1140
- }
1141
- });
1142
- };
1143
- this.for = undefined;
1144
- this.ariaExpanded = false;
1145
- }
1146
- /**
1147
- * Watch for changes to the `for` property to validate its type and ensure it is a string.
1148
- * @param forValue - The new value of the `for` property.
1149
- */
1150
- validateControlFor() {
1151
- checkRequiredAndType(this, 'for', 'string');
1152
- }
1153
- get megadropdown() {
1154
- const ref = document.getElementById(this.for);
1155
- return ref && ref.localName === 'post-megadropdown'
1156
- ? ref
1157
- : null;
1158
- }
1159
- handleToggle() {
1160
- if (this.megadropdown) {
1161
- this.megadropdown.toggle();
1162
- }
1163
- else {
1164
- console.warn(`No post-megadropdown found with ID: ${this.for}`);
1165
- }
1166
- }
1167
- componentDidLoad() {
1168
- this.validateControlFor();
1169
- // Check if the mega dropdown attached to the trigger is expanded or not
1170
- document.addEventListener('postToggleMegadropdown', this.handleToggleMegadropdown);
1171
- this.slottedButton = this.host.querySelector('button');
1172
- if (this.slottedButton) {
1173
- this.slottedButton.setAttribute('aria-haspopup', 'menu');
1174
- this.slottedButton.addEventListener('click', () => {
1175
- this.handleToggle();
1176
- });
1177
- this.slottedButton.addEventListener('keydown', this.handleKeyDown);
1178
- }
1179
- else {
1180
- console.warn('No button found within post-megadropdown-trigger');
1181
- }
1182
- }
1183
- disconnectedCallback() {
1184
- document.removeEventListener('postToggleMegadropdown', this.handleToggleMegadropdown);
1185
- }
1186
- render() {
1187
- return (h(Host, { key: '54824c6e5d6d8f6bd44caf3e5b5e578d62f5e1e2', "data-version": version, "tab-index": "-1" }, h("button", { key: '54bb8740ba2f04d6d7f128436210b489e2d56bd8' }, h("slot", { key: 'fb58922d62496196ed50543b664b98c1ba2c4d4b' }))));
1188
- }
1189
- get host() { return getElement(this); }
1190
- static get watchers() { return {
1191
- "for": ["validateControlFor"]
1192
- }; }
1193
- };
1194
- PostMegadropdownTrigger.style = PostMegadropdownTriggerStyle0;
1195
-
1196
- const postMenuCss = "@keyframes popIn{from{transform:scale(0.9);opacity:0;transition-property:transform,opacity,overlay,display;transition-behavior:allow-discrete;transition-duration:var(--post-transition-duration, 0.35s);transition-timing-function:linear(0, 0.007, 0.029 2.2%, 0.118 4.7%, 0.625 14.4%, 0.826 19%, 0.902, 0.962, 1.008 26.1%, 1.041 28.7%, 1.064 32.1%, 1.07 36%, 1.061 40.5%, 1.015 53.4%, 0.999 61.6%, 0.995 71.2%, 1)}to{opacity:1;transform:scale(1)}}:host{display:block}post-popovercontainer{padding:var(--post-menu-padding);background-color:var(--post-menu-bg, #ffffff);border-color:var(--post-menu-bg, #ffffff)}.popover-container{display:flex;flex-direction:column}";
1197
- const PostMenuStyle0 = postMenuCss;
1198
-
1199
- const PostMenu = class {
1200
- constructor(hostRef) {
1201
- registerInstance(this, hostRef);
1202
- this.toggleMenu = createEvent(this, "toggleMenu", 7);
1203
- this.lastFocusedElement = null;
1204
- this.KEYCODES = {
1205
- SPACE: ' ',
1206
- ENTER: 'Enter',
1207
- UP: 'ArrowUp',
1208
- DOWN: 'ArrowDown',
1209
- TAB: 'Tab',
1210
- HOME: 'Home',
1211
- END: 'End',
1212
- ESCAPE: 'Escape',
1213
- };
1214
- this.handleKeyDown = (e) => {
1215
- e.stopPropagation();
1216
- if (e.key === this.KEYCODES.ESCAPE) {
1217
- this.toggle(this.host);
1218
- return;
1219
- }
1220
- if (Object.values(this.KEYCODES).includes(e.key)) {
1221
- this.controlKeyDownHandler(e);
1222
- }
1223
- };
1224
- this.handlePostToggle = (event) => {
1225
- eventGuard(this.host, event, { targetLocalName: 'post-popovercontainer', delegatorSelector: 'post-menu' }, () => {
1226
- this.isVisible = event.detail;
1227
- this.toggleMenu.emit(this.isVisible);
1228
- requestAnimationFrame(() => {
1229
- if (this.isVisible) {
1230
- this.lastFocusedElement = this.root?.activeElement;
1231
- const menuItems = this.getSlottedItems();
1232
- if (menuItems.length > 0) {
1233
- menuItems[0].focus();
1234
- }
1235
- }
1236
- else if (this.lastFocusedElement) {
1237
- this.lastFocusedElement.focus();
1238
- }
1239
- });
1240
- });
1241
- };
1242
- this.handleClick = (e) => {
1243
- const target = e.target;
1244
- if (['BUTTON', 'A', 'INPUT', 'SELECT', 'TEXTAREA'].includes(target.tagName)) {
1245
- this.toggle(this.host);
1246
- }
1247
- };
1248
- this.placement = 'bottom';
1249
- this.isVisible = false;
1250
- }
1251
- validatePlacement() {
1252
- checkEmptyOrOneOf(this, 'placement', PLACEMENT_TYPES);
1253
- }
1254
- connectedCallback() {
1255
- this.root = getRoot(this.host);
1256
- this.host.addEventListener('keydown', this.handleKeyDown);
1257
- this.host.addEventListener('click', this.handleClick);
1258
- }
1259
- disconnectedCallback() {
1260
- this.host.removeEventListener('keydown', this.handleKeyDown);
1261
- this.host.removeEventListener('click', this.handleClick);
1262
- this.popoverRef?.removeEventListener('postToggle', this.handlePostToggle);
1263
- }
1264
- componentDidLoad() {
1265
- this.validatePlacement();
1266
- if (this.popoverRef) {
1267
- this.popoverRef.addEventListener('postToggle', this.handlePostToggle);
1268
- }
1269
- }
1270
- /**
1271
- * Toggles the menu visibility based on its current state.
1272
- */
1273
- async toggle(target) {
1274
- if (this.popoverRef) {
1275
- await this.popoverRef.toggle(target);
1276
- }
1277
- else {
1278
- console.error('toggle: popoverRef is null or undefined');
1279
- }
1280
- }
1281
- /**
1282
- * Displays the popover menu, focusing the first menu item.
1283
- *
1284
- * @param target - The HTML element relative to which the popover menu should be displayed.
1285
- */
1286
- async show(target) {
1287
- if (this.popoverRef) {
1288
- await this.popoverRef.show(target);
1289
- }
1290
- else {
1291
- console.error('show: popoverRef is null or undefined');
1292
- }
1293
- }
1294
- /**
1295
- * Hides the popover menu and restores focus to the previously focused element.
1296
- */
1297
- async hide() {
1298
- if (this.popoverRef) {
1299
- await this.popoverRef.hide();
1300
- }
1301
- else {
1302
- console.error('hide: popoverRef is null or undefined');
1303
- }
1304
- }
1305
- controlKeyDownHandler(e) {
1306
- const menuItems = this.getSlottedItems();
1307
- if (!menuItems.length) {
1308
- return;
1309
- }
1310
- let currentIndex = menuItems.findIndex(el => {
1311
- // Check if the item is currently focused within its rendered scope (document or shadow root)
1312
- return el === getRoot(el).activeElement;
1313
- });
1314
- switch (e.key) {
1315
- case this.KEYCODES.UP:
1316
- e.preventDefault();
1317
- currentIndex = (currentIndex - 1 + menuItems.length) % menuItems.length;
1318
- break;
1319
- case this.KEYCODES.DOWN:
1320
- e.preventDefault();
1321
- currentIndex = (currentIndex + 1) % menuItems.length;
1322
- break;
1323
- case this.KEYCODES.HOME:
1324
- currentIndex = 0;
1325
- break;
1326
- case this.KEYCODES.END:
1327
- e.preventDefault();
1328
- currentIndex = menuItems.length - 1;
1329
- break;
1330
- case this.KEYCODES.SPACE:
1331
- this.toggle(this.host);
1332
- return;
1333
- case this.KEYCODES.TAB:
1334
- this.toggle(this.host);
1335
- break;
1336
- }
1337
- if (menuItems[currentIndex]) {
1338
- menuItems[currentIndex].focus();
1339
- }
1340
- }
1341
- getSlottedItems() {
1342
- const slot = this.host.shadowRoot.querySelector('slot');
1343
- const slottedElements = slot ? slot.assignedElements() : [];
1344
- return (slottedElements
1345
- // If the element is a slot, get the assigned elements
1346
- .flatMap(el => (el instanceof HTMLSlotElement ? el.assignedElements() : el))
1347
- // For each menu item, get any focusable children (e.g., buttons, links)
1348
- .flatMap(el => Array.from(getFocusableChildren(el))));
1349
- }
1350
- render() {
1351
- return (h(Host, { key: 'a66db7a05d72ddb3f139339a6afa46a6eb29eac6', "data-version": version, role: "menu" }, h("post-popovercontainer", { key: '9b9eab1d709ca42dae36cd04edf8aa98cf6d1b47', placement: this.placement, ref: e => (this.popoverRef = e) }, h("div", { key: '55ccf7663ebb5dd467b42065631aec2be92fc9da', class: "popover-container", part: "popover-container" }, h("slot", { key: 'b15306e711b53535fb62827a0b6fca37f143e55f' })))));
1352
- }
1353
- get host() { return getElement(this); }
1354
- static get watchers() { return {
1355
- "placement": ["validatePlacement"]
1356
- }; }
1357
- };
1358
- PostMenu.style = PostMenuStyle0;
1359
-
1360
- const postMenuTriggerCss = ":host{display:inline-block}";
1361
- const PostMenuTriggerStyle0 = postMenuTriggerCss;
1362
-
1363
- const PostMenuTrigger = class {
1364
- constructor(hostRef) {
1365
- registerInstance(this, hostRef);
1366
- /**
1367
- * Reference to the slotted button within the trigger, if present.
1368
- * Used to manage click and key events for menu control.
1369
- */
1370
- this.slottedButton = null;
1371
- this.handleKeyDown = (e) => {
1372
- if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
1373
- e.preventDefault();
1374
- this.handleToggle();
1375
- }
1376
- };
1377
- this.for = undefined;
1378
- this.ariaExpanded = false;
1379
- }
1380
- /**
1381
- * Watch for changes to the `for` property to validate its type and ensure it is a string.
1382
- * @param forValue - The new value of the `for` property.
1383
- */
1384
- validateControlFor() {
1385
- checkRequiredAndType(this, 'for', 'string');
1386
- }
1387
- get menu() {
1388
- const ref = this.root.getElementById(this.for);
1389
- return ref && ref.localName === 'post-menu' ? ref : null;
1390
- }
1391
- handleToggle() {
1392
- if (this.menu) {
1393
- this.menu.toggle(this.host);
1394
- }
1395
- else {
1396
- console.warn(`No post-menu found with ID: ${this.for}`);
1397
- }
1398
- }
1399
- connectedCallback() {
1400
- this.root = getRoot(this.host);
1401
- }
1402
- componentDidLoad() {
1403
- this.validateControlFor();
1404
- this.slottedButton = this.host.querySelector('button');
1405
- // Check if the slottedButton is within a web component
1406
- if (!this.slottedButton) {
1407
- const webComponent = this.host.querySelector('.menu-trigger-webc');
1408
- if (webComponent.shadowRoot) {
1409
- const slottedButton = webComponent.shadowRoot.querySelector('button');
1410
- if (slottedButton) {
1411
- this.slottedButton = slottedButton;
1412
- }
1413
- }
1414
- }
1415
- if (this.slottedButton) {
1416
- this.slottedButton.setAttribute('aria-haspopup', 'menu');
1417
- // Listen to the `toggleMenu` event emitted by the `post-menu` component
1418
- if (this.menu && this.slottedButton) {
1419
- this.menu.addEventListener('toggleMenu', (event) => {
1420
- this.ariaExpanded = event.detail;
1421
- this.slottedButton.setAttribute('aria-expanded', this.ariaExpanded.toString());
1422
- });
1423
- }
1424
- this.slottedButton.addEventListener('click', () => {
1425
- this.handleToggle();
1426
- });
1427
- this.slottedButton.addEventListener('keydown', this.handleKeyDown);
1428
- }
1429
- else {
1430
- console.warn('No button found within post-menu-trigger');
1431
- }
1432
- }
1433
- render() {
1434
- return (h(Host, { key: '61d2f4b4703acd195db0ac005cdf882150e499ba', "data-version": version, "tab-index": "-1" }, h("slot", { key: 'b7f8ea683af5e3473e4ba12f6d4ac36ae55aad57' })));
1435
- }
1436
- get host() { return getElement(this); }
1437
- static get watchers() { return {
1438
- "for": ["validateControlFor"]
1439
- }; }
1440
- };
1441
- PostMenuTrigger.style = PostMenuTriggerStyle0;
1442
-
1443
- /**
1444
- * Custom positioning reference element.
1445
- * @see https://floating-ui.com/docs/virtual-elements
1446
- */
1447
-
1448
- const sides = ['top', 'right', 'bottom', 'left'];
1449
- const alignments = ['start', 'end'];
1450
- const placements = /*#__PURE__*/sides.reduce((acc, side) => acc.concat(side, side + "-" + alignments[0], side + "-" + alignments[1]), []);
1451
- const min = Math.min;
1452
- const max = Math.max;
1453
- const round = Math.round;
1454
- const floor = Math.floor;
1455
- const createCoords = v => ({
1456
- x: v,
1457
- y: v
1458
- });
1459
- const oppositeSideMap = {
1460
- left: 'right',
1461
- right: 'left',
1462
- bottom: 'top',
1463
- top: 'bottom'
1464
- };
1465
- const oppositeAlignmentMap = {
1466
- start: 'end',
1467
- end: 'start'
1468
- };
1469
- function clamp(start, value, end) {
1470
- return max(start, min(value, end));
1471
- }
1472
- function evaluate(value, param) {
1473
- return typeof value === 'function' ? value(param) : value;
1474
- }
1475
- function getSide(placement) {
1476
- return placement.split('-')[0];
1477
- }
1478
- function getAlignment(placement) {
1479
- return placement.split('-')[1];
1480
- }
1481
- function getOppositeAxis(axis) {
1482
- return axis === 'x' ? 'y' : 'x';
1483
- }
1484
- function getAxisLength(axis) {
1485
- return axis === 'y' ? 'height' : 'width';
1486
- }
1487
- function getSideAxis(placement) {
1488
- return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
1489
- }
1490
- function getAlignmentAxis(placement) {
1491
- return getOppositeAxis(getSideAxis(placement));
1492
- }
1493
- function getAlignmentSides(placement, rects, rtl) {
1494
- if (rtl === void 0) {
1495
- rtl = false;
1496
- }
1497
- const alignment = getAlignment(placement);
1498
- const alignmentAxis = getAlignmentAxis(placement);
1499
- const length = getAxisLength(alignmentAxis);
1500
- let mainAlignmentSide = alignmentAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
1501
- if (rects.reference[length] > rects.floating[length]) {
1502
- mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
1503
- }
1504
- return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
1505
- }
1506
- function getExpandedPlacements(placement) {
1507
- const oppositePlacement = getOppositePlacement(placement);
1508
- return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
1509
- }
1510
- function getOppositeAlignmentPlacement(placement) {
1511
- return placement.replace(/start|end/g, alignment => oppositeAlignmentMap[alignment]);
1512
- }
1513
- function getSideList(side, isStart, rtl) {
1514
- const lr = ['left', 'right'];
1515
- const rl = ['right', 'left'];
1516
- const tb = ['top', 'bottom'];
1517
- const bt = ['bottom', 'top'];
1518
- switch (side) {
1519
- case 'top':
1520
- case 'bottom':
1521
- if (rtl) return isStart ? rl : lr;
1522
- return isStart ? lr : rl;
1523
- case 'left':
1524
- case 'right':
1525
- return isStart ? tb : bt;
1526
- default:
1527
- return [];
1528
- }
1529
- }
1530
- function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
1531
- const alignment = getAlignment(placement);
1532
- let list = getSideList(getSide(placement), direction === 'start', rtl);
1533
- if (alignment) {
1534
- list = list.map(side => side + "-" + alignment);
1535
- if (flipAlignment) {
1536
- list = list.concat(list.map(getOppositeAlignmentPlacement));
1537
- }
1538
- }
1539
- return list;
1540
- }
1541
- function getOppositePlacement(placement) {
1542
- return placement.replace(/left|right|bottom|top/g, side => oppositeSideMap[side]);
1543
- }
1544
- function expandPaddingObject(padding) {
1545
- return {
1546
- top: 0,
1547
- right: 0,
1548
- bottom: 0,
1549
- left: 0,
1550
- ...padding
1551
- };
1552
- }
1553
- function getPaddingObject(padding) {
1554
- return typeof padding !== 'number' ? expandPaddingObject(padding) : {
1555
- top: padding,
1556
- right: padding,
1557
- bottom: padding,
1558
- left: padding
1559
- };
1560
- }
1561
- function rectToClientRect(rect) {
1562
- const {
1563
- x,
1564
- y,
1565
- width,
1566
- height
1567
- } = rect;
1568
- return {
1569
- width,
1570
- height,
1571
- top: y,
1572
- left: x,
1573
- right: x + width,
1574
- bottom: y + height,
1575
- x,
1576
- y
1577
- };
1578
- }
1579
-
1580
- function computeCoordsFromPlacement(_ref, placement, rtl) {
1581
- let {
1582
- reference,
1583
- floating
1584
- } = _ref;
1585
- const sideAxis = getSideAxis(placement);
1586
- const alignmentAxis = getAlignmentAxis(placement);
1587
- const alignLength = getAxisLength(alignmentAxis);
1588
- const side = getSide(placement);
1589
- const isVertical = sideAxis === 'y';
1590
- const commonX = reference.x + reference.width / 2 - floating.width / 2;
1591
- const commonY = reference.y + reference.height / 2 - floating.height / 2;
1592
- const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
1593
- let coords;
1594
- switch (side) {
1595
- case 'top':
1596
- coords = {
1597
- x: commonX,
1598
- y: reference.y - floating.height
1599
- };
1600
- break;
1601
- case 'bottom':
1602
- coords = {
1603
- x: commonX,
1604
- y: reference.y + reference.height
1605
- };
1606
- break;
1607
- case 'right':
1608
- coords = {
1609
- x: reference.x + reference.width,
1610
- y: commonY
1611
- };
1612
- break;
1613
- case 'left':
1614
- coords = {
1615
- x: reference.x - floating.width,
1616
- y: commonY
1617
- };
1618
- break;
1619
- default:
1620
- coords = {
1621
- x: reference.x,
1622
- y: reference.y
1623
- };
1624
- }
1625
- switch (getAlignment(placement)) {
1626
- case 'start':
1627
- coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
1628
- break;
1629
- case 'end':
1630
- coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
1631
- break;
1632
- }
1633
- return coords;
1634
- }
1635
-
1636
- /**
1637
- * Computes the `x` and `y` coordinates that will place the floating element
1638
- * next to a given reference element.
1639
- *
1640
- * This export does not have any `platform` interface logic. You will need to
1641
- * write one for the platform you are using Floating UI with.
1642
- */
1643
- const computePosition$1 = async (reference, floating, config) => {
1644
- const {
1645
- placement = 'bottom',
1646
- strategy = 'absolute',
1647
- middleware = [],
1648
- platform
1649
- } = config;
1650
- const validMiddleware = middleware.filter(Boolean);
1651
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
1652
- let rects = await platform.getElementRects({
1653
- reference,
1654
- floating,
1655
- strategy
1656
- });
1657
- let {
1658
- x,
1659
- y
1660
- } = computeCoordsFromPlacement(rects, placement, rtl);
1661
- let statefulPlacement = placement;
1662
- let middlewareData = {};
1663
- let resetCount = 0;
1664
- for (let i = 0; i < validMiddleware.length; i++) {
1665
- const {
1666
- name,
1667
- fn
1668
- } = validMiddleware[i];
1669
- const {
1670
- x: nextX,
1671
- y: nextY,
1672
- data,
1673
- reset
1674
- } = await fn({
1675
- x,
1676
- y,
1677
- initialPlacement: placement,
1678
- placement: statefulPlacement,
1679
- strategy,
1680
- middlewareData,
1681
- rects,
1682
- platform,
1683
- elements: {
1684
- reference,
1685
- floating
1686
- }
1687
- });
1688
- x = nextX != null ? nextX : x;
1689
- y = nextY != null ? nextY : y;
1690
- middlewareData = {
1691
- ...middlewareData,
1692
- [name]: {
1693
- ...middlewareData[name],
1694
- ...data
1695
- }
1696
- };
1697
- if (reset && resetCount <= 50) {
1698
- resetCount++;
1699
- if (typeof reset === 'object') {
1700
- if (reset.placement) {
1701
- statefulPlacement = reset.placement;
1702
- }
1703
- if (reset.rects) {
1704
- rects = reset.rects === true ? await platform.getElementRects({
1705
- reference,
1706
- floating,
1707
- strategy
1708
- }) : reset.rects;
1709
- }
1710
- ({
1711
- x,
1712
- y
1713
- } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
1714
- }
1715
- i = -1;
1716
- }
1717
- }
1718
- return {
1719
- x,
1720
- y,
1721
- placement: statefulPlacement,
1722
- strategy,
1723
- middlewareData
1724
- };
1725
- };
1726
-
1727
- /**
1728
- * Resolves with an object of overflow side offsets that determine how much the
1729
- * element is overflowing a given clipping boundary on each side.
1730
- * - positive = overflowing the boundary by that number of pixels
1731
- * - negative = how many pixels left before it will overflow
1732
- * - 0 = lies flush with the boundary
1733
- * @see https://floating-ui.com/docs/detectOverflow
1734
- */
1735
- async function detectOverflow(state, options) {
1736
- var _await$platform$isEle;
1737
- if (options === void 0) {
1738
- options = {};
1739
- }
1740
- const {
1741
- x,
1742
- y,
1743
- platform,
1744
- rects,
1745
- elements,
1746
- strategy
1747
- } = state;
1748
- const {
1749
- boundary = 'clippingAncestors',
1750
- rootBoundary = 'viewport',
1751
- elementContext = 'floating',
1752
- altBoundary = false,
1753
- padding = 0
1754
- } = evaluate(options, state);
1755
- const paddingObject = getPaddingObject(padding);
1756
- const altContext = elementContext === 'floating' ? 'reference' : 'floating';
1757
- const element = elements[altBoundary ? altContext : elementContext];
1758
- const clippingClientRect = rectToClientRect(await platform.getClippingRect({
1759
- element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
1760
- boundary,
1761
- rootBoundary,
1762
- strategy
1763
- }));
1764
- const rect = elementContext === 'floating' ? {
1765
- x,
1766
- y,
1767
- width: rects.floating.width,
1768
- height: rects.floating.height
1769
- } : rects.reference;
1770
- const offsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating));
1771
- const offsetScale = (await (platform.isElement == null ? void 0 : platform.isElement(offsetParent))) ? (await (platform.getScale == null ? void 0 : platform.getScale(offsetParent))) || {
1772
- x: 1,
1773
- y: 1
1774
- } : {
1775
- x: 1,
1776
- y: 1
1777
- };
1778
- const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
1779
- elements,
1780
- rect,
1781
- offsetParent,
1782
- strategy
1783
- }) : rect);
1784
- return {
1785
- top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
1786
- bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
1787
- left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
1788
- right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
1789
- };
1790
- }
1791
-
1792
- /**
1793
- * Provides data to position an inner element of the floating element so that it
1794
- * appears centered to the reference element.
1795
- * @see https://floating-ui.com/docs/arrow
1796
- */
1797
- const arrow$1 = options => ({
1798
- name: 'arrow',
1799
- options,
1800
- async fn(state) {
1801
- const {
1802
- x,
1803
- y,
1804
- placement,
1805
- rects,
1806
- platform,
1807
- elements,
1808
- middlewareData
1809
- } = state;
1810
- // Since `element` is required, we don't Partial<> the type.
1811
- const {
1812
- element,
1813
- padding = 0
1814
- } = evaluate(options, state) || {};
1815
- if (element == null) {
1816
- return {};
1817
- }
1818
- const paddingObject = getPaddingObject(padding);
1819
- const coords = {
1820
- x,
1821
- y
1822
- };
1823
- const axis = getAlignmentAxis(placement);
1824
- const length = getAxisLength(axis);
1825
- const arrowDimensions = await platform.getDimensions(element);
1826
- const isYAxis = axis === 'y';
1827
- const minProp = isYAxis ? 'top' : 'left';
1828
- const maxProp = isYAxis ? 'bottom' : 'right';
1829
- const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
1830
- const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
1831
- const startDiff = coords[axis] - rects.reference[axis];
1832
- const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
1833
- let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
1834
-
1835
- // DOM platform can return `window` as the `offsetParent`.
1836
- if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
1837
- clientSize = elements.floating[clientProp] || rects.floating[length];
1838
- }
1839
- const centerToReference = endDiff / 2 - startDiff / 2;
1840
-
1841
- // If the padding is large enough that it causes the arrow to no longer be
1842
- // centered, modify the padding so that it is centered.
1843
- const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
1844
- const minPadding = min(paddingObject[minProp], largestPossiblePadding);
1845
- const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
1846
-
1847
- // Make sure the arrow doesn't overflow the floating element if the center
1848
- // point is outside the floating element's bounds.
1849
- const min$1 = minPadding;
1850
- const max = clientSize - arrowDimensions[length] - maxPadding;
1851
- const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
1852
- const offset = clamp(min$1, center, max);
1853
-
1854
- // If the reference is small enough that the arrow's padding causes it to
1855
- // to point to nothing for an aligned placement, adjust the offset of the
1856
- // floating element itself. To ensure `shift()` continues to take action,
1857
- // a single reset is performed when this is true.
1858
- const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
1859
- const alignmentOffset = shouldAddOffset ? center < min$1 ? center - min$1 : center - max : 0;
1860
- return {
1861
- [axis]: coords[axis] + alignmentOffset,
1862
- data: {
1863
- [axis]: offset,
1864
- centerOffset: center - offset - alignmentOffset,
1865
- ...(shouldAddOffset && {
1866
- alignmentOffset
1867
- })
1868
- },
1869
- reset: shouldAddOffset
1870
- };
1871
- }
1872
- });
1873
-
1874
- function getPlacementList(alignment, autoAlignment, allowedPlacements) {
1875
- const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getSide(placement) === placement);
1876
- return allowedPlacementsSortedByAlignment.filter(placement => {
1877
- if (alignment) {
1878
- return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
1879
- }
1880
- return true;
1881
- });
1882
- }
1883
- /**
1884
- * Optimizes the visibility of the floating element by choosing the placement
1885
- * that has the most space available automatically, without needing to specify a
1886
- * preferred placement. Alternative to `flip`.
1887
- * @see https://floating-ui.com/docs/autoPlacement
1888
- */
1889
- const autoPlacement = function (options) {
1890
- if (options === void 0) {
1891
- options = {};
1892
- }
1893
- return {
1894
- name: 'autoPlacement',
1895
- options,
1896
- async fn(state) {
1897
- var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
1898
- const {
1899
- rects,
1900
- middlewareData,
1901
- placement,
1902
- platform,
1903
- elements
1904
- } = state;
1905
- const {
1906
- crossAxis = false,
1907
- alignment,
1908
- allowedPlacements = placements,
1909
- autoAlignment = true,
1910
- ...detectOverflowOptions
1911
- } = evaluate(options, state);
1912
- const placements$1 = alignment !== undefined || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
1913
- const overflow = await detectOverflow(state, detectOverflowOptions);
1914
- const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
1915
- const currentPlacement = placements$1[currentIndex];
1916
- if (currentPlacement == null) {
1917
- return {};
1918
- }
1919
- const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
1920
-
1921
- // Make `computeCoords` start from the right place.
1922
- if (placement !== currentPlacement) {
1923
- return {
1924
- reset: {
1925
- placement: placements$1[0]
1926
- }
1927
- };
1928
- }
1929
- const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
1930
- const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
1931
- placement: currentPlacement,
1932
- overflows: currentOverflows
1933
- }];
1934
- const nextPlacement = placements$1[currentIndex + 1];
1935
-
1936
- // There are more placements to check.
1937
- if (nextPlacement) {
1938
- return {
1939
- data: {
1940
- index: currentIndex + 1,
1941
- overflows: allOverflows
1942
- },
1943
- reset: {
1944
- placement: nextPlacement
1945
- }
1946
- };
1947
- }
1948
- const placementsSortedByMostSpace = allOverflows.map(d => {
1949
- const alignment = getAlignment(d.placement);
1950
- return [d.placement, alignment && crossAxis ?
1951
- // Check along the mainAxis and main crossAxis side.
1952
- d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
1953
- // Check only the mainAxis.
1954
- d.overflows[0], d.overflows];
1955
- }).sort((a, b) => a[1] - b[1]);
1956
- const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
1957
- // Aligned placements should not check their opposite crossAxis
1958
- // side.
1959
- getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
1960
- const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
1961
- if (resetPlacement !== placement) {
1962
- return {
1963
- data: {
1964
- index: currentIndex + 1,
1965
- overflows: allOverflows
1966
- },
1967
- reset: {
1968
- placement: resetPlacement
1969
- }
1970
- };
1971
- }
1972
- return {};
1973
- }
1974
- };
1975
- };
1976
-
1977
- /**
1978
- * Optimizes the visibility of the floating element by flipping the `placement`
1979
- * in order to keep it in view when the preferred placement(s) will overflow the
1980
- * clipping boundary. Alternative to `autoPlacement`.
1981
- * @see https://floating-ui.com/docs/flip
1982
- */
1983
- const flip$1 = function (options) {
1984
- if (options === void 0) {
1985
- options = {};
1986
- }
1987
- return {
1988
- name: 'flip',
1989
- options,
1990
- async fn(state) {
1991
- var _middlewareData$arrow, _middlewareData$flip;
1992
- const {
1993
- placement,
1994
- middlewareData,
1995
- rects,
1996
- initialPlacement,
1997
- platform,
1998
- elements
1999
- } = state;
2000
- const {
2001
- mainAxis: checkMainAxis = true,
2002
- crossAxis: checkCrossAxis = true,
2003
- fallbackPlacements: specifiedFallbackPlacements,
2004
- fallbackStrategy = 'bestFit',
2005
- fallbackAxisSideDirection = 'none',
2006
- flipAlignment = true,
2007
- ...detectOverflowOptions
2008
- } = evaluate(options, state);
2009
-
2010
- // If a reset by the arrow was caused due to an alignment offset being
2011
- // added, we should skip any logic now since `flip()` has already done its
2012
- // work.
2013
- // https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
2014
- if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
2015
- return {};
2016
- }
2017
- const side = getSide(placement);
2018
- const initialSideAxis = getSideAxis(initialPlacement);
2019
- const isBasePlacement = getSide(initialPlacement) === initialPlacement;
2020
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
2021
- const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
2022
- const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== 'none';
2023
- if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
2024
- fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
2025
- }
2026
- const placements = [initialPlacement, ...fallbackPlacements];
2027
- const overflow = await detectOverflow(state, detectOverflowOptions);
2028
- const overflows = [];
2029
- let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
2030
- if (checkMainAxis) {
2031
- overflows.push(overflow[side]);
2032
- }
2033
- if (checkCrossAxis) {
2034
- const sides = getAlignmentSides(placement, rects, rtl);
2035
- overflows.push(overflow[sides[0]], overflow[sides[1]]);
2036
- }
2037
- overflowsData = [...overflowsData, {
2038
- placement,
2039
- overflows
2040
- }];
2041
-
2042
- // One or more sides is overflowing.
2043
- if (!overflows.every(side => side <= 0)) {
2044
- var _middlewareData$flip2, _overflowsData$filter;
2045
- const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
2046
- const nextPlacement = placements[nextIndex];
2047
- if (nextPlacement) {
2048
- var _overflowsData$;
2049
- const ignoreCrossAxisOverflow = checkCrossAxis === 'alignment' ? initialSideAxis !== getSideAxis(nextPlacement) : false;
2050
- const hasInitialMainAxisOverflow = ((_overflowsData$ = overflowsData[0]) == null ? void 0 : _overflowsData$.overflows[0]) > 0;
2051
- if (!ignoreCrossAxisOverflow || hasInitialMainAxisOverflow) {
2052
- // Try next placement and re-run the lifecycle.
2053
- return {
2054
- data: {
2055
- index: nextIndex,
2056
- overflows: overflowsData
2057
- },
2058
- reset: {
2059
- placement: nextPlacement
2060
- }
2061
- };
2062
- }
2063
- }
2064
-
2065
- // First, find the candidates that fit on the mainAxis side of overflow,
2066
- // then find the placement that fits the best on the main crossAxis side.
2067
- let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
2068
-
2069
- // Otherwise fallback.
2070
- if (!resetPlacement) {
2071
- switch (fallbackStrategy) {
2072
- case 'bestFit':
2073
- {
2074
- var _overflowsData$filter2;
2075
- const placement = (_overflowsData$filter2 = overflowsData.filter(d => {
2076
- if (hasFallbackAxisSideDirection) {
2077
- const currentSideAxis = getSideAxis(d.placement);
2078
- return currentSideAxis === initialSideAxis ||
2079
- // Create a bias to the `y` side axis due to horizontal
2080
- // reading directions favoring greater width.
2081
- currentSideAxis === 'y';
2082
- }
2083
- return true;
2084
- }).map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
2085
- if (placement) {
2086
- resetPlacement = placement;
2087
- }
2088
- break;
2089
- }
2090
- case 'initialPlacement':
2091
- resetPlacement = initialPlacement;
2092
- break;
2093
- }
2094
- }
2095
- if (placement !== resetPlacement) {
2096
- return {
2097
- reset: {
2098
- placement: resetPlacement
2099
- }
2100
- };
2101
- }
2102
- }
2103
- return {};
2104
- }
2105
- };
2106
- };
2107
-
2108
- function getSideOffsets(overflow, rect) {
2109
- return {
2110
- top: overflow.top - rect.height,
2111
- right: overflow.right - rect.width,
2112
- bottom: overflow.bottom - rect.height,
2113
- left: overflow.left - rect.width
2114
- };
2115
- }
2116
- function isAnySideFullyClipped(overflow) {
2117
- return sides.some(side => overflow[side] >= 0);
2118
- }
2119
- /**
2120
- * Provides data to hide the floating element in applicable situations, such as
2121
- * when it is not in the same clipping context as the reference element.
2122
- * @see https://floating-ui.com/docs/hide
2123
- */
2124
- const hide = function (options) {
2125
- if (options === void 0) {
2126
- options = {};
2127
- }
2128
- return {
2129
- name: 'hide',
2130
- options,
2131
- async fn(state) {
2132
- const {
2133
- rects
2134
- } = state;
2135
- const {
2136
- strategy = 'referenceHidden',
2137
- ...detectOverflowOptions
2138
- } = evaluate(options, state);
2139
- switch (strategy) {
2140
- case 'referenceHidden':
2141
- {
2142
- const overflow = await detectOverflow(state, {
2143
- ...detectOverflowOptions,
2144
- elementContext: 'reference'
2145
- });
2146
- const offsets = getSideOffsets(overflow, rects.reference);
2147
- return {
2148
- data: {
2149
- referenceHiddenOffsets: offsets,
2150
- referenceHidden: isAnySideFullyClipped(offsets)
2151
- }
2152
- };
2153
- }
2154
- case 'escaped':
2155
- {
2156
- const overflow = await detectOverflow(state, {
2157
- ...detectOverflowOptions,
2158
- altBoundary: true
2159
- });
2160
- const offsets = getSideOffsets(overflow, rects.floating);
2161
- return {
2162
- data: {
2163
- escapedOffsets: offsets,
2164
- escaped: isAnySideFullyClipped(offsets)
2165
- }
2166
- };
2167
- }
2168
- default:
2169
- {
2170
- return {};
2171
- }
2172
- }
2173
- }
2174
- };
2175
- };
2176
-
2177
- function getBoundingRect(rects) {
2178
- const minX = min(...rects.map(rect => rect.left));
2179
- const minY = min(...rects.map(rect => rect.top));
2180
- const maxX = max(...rects.map(rect => rect.right));
2181
- const maxY = max(...rects.map(rect => rect.bottom));
2182
- return {
2183
- x: minX,
2184
- y: minY,
2185
- width: maxX - minX,
2186
- height: maxY - minY
2187
- };
2188
- }
2189
- function getRectsByLine(rects) {
2190
- const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
2191
- const groups = [];
2192
- let prevRect = null;
2193
- for (let i = 0; i < sortedRects.length; i++) {
2194
- const rect = sortedRects[i];
2195
- if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
2196
- groups.push([rect]);
2197
- } else {
2198
- groups[groups.length - 1].push(rect);
2199
- }
2200
- prevRect = rect;
2201
- }
2202
- return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
2203
- }
2204
- /**
2205
- * Provides improved positioning for inline reference elements that can span
2206
- * over multiple lines, such as hyperlinks or range selections.
2207
- * @see https://floating-ui.com/docs/inline
2208
- */
2209
- const inline$1 = function (options) {
2210
- if (options === void 0) {
2211
- options = {};
2212
- }
2213
- return {
2214
- name: 'inline',
2215
- options,
2216
- async fn(state) {
2217
- const {
2218
- placement,
2219
- elements,
2220
- rects,
2221
- platform,
2222
- strategy
2223
- } = state;
2224
- // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
2225
- // ClientRect's bounds, despite the event listener being triggered. A
2226
- // padding of 2 seems to handle this issue.
2227
- const {
2228
- padding = 2,
2229
- x,
2230
- y
2231
- } = evaluate(options, state);
2232
- const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
2233
- const clientRects = getRectsByLine(nativeClientRects);
2234
- const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
2235
- const paddingObject = getPaddingObject(padding);
2236
- function getBoundingClientRect() {
2237
- // There are two rects and they are disjoined.
2238
- if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
2239
- // Find the first rect in which the point is fully inside.
2240
- return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
2241
- }
2242
-
2243
- // There are 2 or more connected rects.
2244
- if (clientRects.length >= 2) {
2245
- if (getSideAxis(placement) === 'y') {
2246
- const firstRect = clientRects[0];
2247
- const lastRect = clientRects[clientRects.length - 1];
2248
- const isTop = getSide(placement) === 'top';
2249
- const top = firstRect.top;
2250
- const bottom = lastRect.bottom;
2251
- const left = isTop ? firstRect.left : lastRect.left;
2252
- const right = isTop ? firstRect.right : lastRect.right;
2253
- const width = right - left;
2254
- const height = bottom - top;
2255
- return {
2256
- top,
2257
- bottom,
2258
- left,
2259
- right,
2260
- width,
2261
- height,
2262
- x: left,
2263
- y: top
2264
- };
2265
- }
2266
- const isLeftSide = getSide(placement) === 'left';
2267
- const maxRight = max(...clientRects.map(rect => rect.right));
2268
- const minLeft = min(...clientRects.map(rect => rect.left));
2269
- const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
2270
- const top = measureRects[0].top;
2271
- const bottom = measureRects[measureRects.length - 1].bottom;
2272
- const left = minLeft;
2273
- const right = maxRight;
2274
- const width = right - left;
2275
- const height = bottom - top;
2276
- return {
2277
- top,
2278
- bottom,
2279
- left,
2280
- right,
2281
- width,
2282
- height,
2283
- x: left,
2284
- y: top
2285
- };
2286
- }
2287
- return fallback;
2288
- }
2289
- const resetRects = await platform.getElementRects({
2290
- reference: {
2291
- getBoundingClientRect
2292
- },
2293
- floating: elements.floating,
2294
- strategy
2295
- });
2296
- if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
2297
- return {
2298
- reset: {
2299
- rects: resetRects
2300
- }
2301
- };
2302
- }
2303
- return {};
2304
- }
2305
- };
2306
- };
2307
-
2308
- // For type backwards-compatibility, the `OffsetOptions` type was also
2309
- // Derivable.
2310
-
2311
- async function convertValueToCoords(state, options) {
2312
- const {
2313
- placement,
2314
- platform,
2315
- elements
2316
- } = state;
2317
- const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
2318
- const side = getSide(placement);
2319
- const alignment = getAlignment(placement);
2320
- const isVertical = getSideAxis(placement) === 'y';
2321
- const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
2322
- const crossAxisMulti = rtl && isVertical ? -1 : 1;
2323
- const rawValue = evaluate(options, state);
2324
-
2325
- // eslint-disable-next-line prefer-const
2326
- let {
2327
- mainAxis,
2328
- crossAxis,
2329
- alignmentAxis
2330
- } = typeof rawValue === 'number' ? {
2331
- mainAxis: rawValue,
2332
- crossAxis: 0,
2333
- alignmentAxis: null
2334
- } : {
2335
- mainAxis: rawValue.mainAxis || 0,
2336
- crossAxis: rawValue.crossAxis || 0,
2337
- alignmentAxis: rawValue.alignmentAxis
2338
- };
2339
- if (alignment && typeof alignmentAxis === 'number') {
2340
- crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
2341
- }
2342
- return isVertical ? {
2343
- x: crossAxis * crossAxisMulti,
2344
- y: mainAxis * mainAxisMulti
2345
- } : {
2346
- x: mainAxis * mainAxisMulti,
2347
- y: crossAxis * crossAxisMulti
2348
- };
2349
- }
2350
-
2351
- /**
2352
- * Modifies the placement by translating the floating element along the
2353
- * specified axes.
2354
- * A number (shorthand for `mainAxis` or distance), or an axes configuration
2355
- * object may be passed.
2356
- * @see https://floating-ui.com/docs/offset
2357
- */
2358
- const offset$1 = function (options) {
2359
- if (options === void 0) {
2360
- options = 0;
2361
- }
2362
- return {
2363
- name: 'offset',
2364
- options,
2365
- async fn(state) {
2366
- var _middlewareData$offse, _middlewareData$arrow;
2367
- const {
2368
- x,
2369
- y,
2370
- placement,
2371
- middlewareData
2372
- } = state;
2373
- const diffCoords = await convertValueToCoords(state, options);
2374
-
2375
- // If the placement is the same and the arrow caused an alignment offset
2376
- // then we don't need to change the positioning coordinates.
2377
- if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
2378
- return {};
2379
- }
2380
- return {
2381
- x: x + diffCoords.x,
2382
- y: y + diffCoords.y,
2383
- data: {
2384
- ...diffCoords,
2385
- placement
2386
- }
2387
- };
2388
- }
2389
- };
2390
- };
2391
-
2392
- /**
2393
- * Optimizes the visibility of the floating element by shifting it in order to
2394
- * keep it in view when it will overflow the clipping boundary.
2395
- * @see https://floating-ui.com/docs/shift
2396
- */
2397
- const shift$1 = function (options) {
2398
- if (options === void 0) {
2399
- options = {};
2400
- }
2401
- return {
2402
- name: 'shift',
2403
- options,
2404
- async fn(state) {
2405
- const {
2406
- x,
2407
- y,
2408
- placement
2409
- } = state;
2410
- const {
2411
- mainAxis: checkMainAxis = true,
2412
- crossAxis: checkCrossAxis = false,
2413
- limiter = {
2414
- fn: _ref => {
2415
- let {
2416
- x,
2417
- y
2418
- } = _ref;
2419
- return {
2420
- x,
2421
- y
2422
- };
2423
- }
2424
- },
2425
- ...detectOverflowOptions
2426
- } = evaluate(options, state);
2427
- const coords = {
2428
- x,
2429
- y
2430
- };
2431
- const overflow = await detectOverflow(state, detectOverflowOptions);
2432
- const crossAxis = getSideAxis(getSide(placement));
2433
- const mainAxis = getOppositeAxis(crossAxis);
2434
- let mainAxisCoord = coords[mainAxis];
2435
- let crossAxisCoord = coords[crossAxis];
2436
- if (checkMainAxis) {
2437
- const minSide = mainAxis === 'y' ? 'top' : 'left';
2438
- const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
2439
- const min = mainAxisCoord + overflow[minSide];
2440
- const max = mainAxisCoord - overflow[maxSide];
2441
- mainAxisCoord = clamp(min, mainAxisCoord, max);
2442
- }
2443
- if (checkCrossAxis) {
2444
- const minSide = crossAxis === 'y' ? 'top' : 'left';
2445
- const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
2446
- const min = crossAxisCoord + overflow[minSide];
2447
- const max = crossAxisCoord - overflow[maxSide];
2448
- crossAxisCoord = clamp(min, crossAxisCoord, max);
2449
- }
2450
- const limitedCoords = limiter.fn({
2451
- ...state,
2452
- [mainAxis]: mainAxisCoord,
2453
- [crossAxis]: crossAxisCoord
2454
- });
2455
- return {
2456
- ...limitedCoords,
2457
- data: {
2458
- x: limitedCoords.x - x,
2459
- y: limitedCoords.y - y,
2460
- enabled: {
2461
- [mainAxis]: checkMainAxis,
2462
- [crossAxis]: checkCrossAxis
2463
- }
2464
- }
2465
- };
2466
- }
2467
- };
2468
- };
2469
- /**
2470
- * Built-in `limiter` that will stop `shift()` at a certain point.
2471
- */
2472
- const limitShift$1 = function (options) {
2473
- if (options === void 0) {
2474
- options = {};
2475
- }
2476
- return {
2477
- options,
2478
- fn(state) {
2479
- const {
2480
- x,
2481
- y,
2482
- placement,
2483
- rects,
2484
- middlewareData
2485
- } = state;
2486
- const {
2487
- offset = 0,
2488
- mainAxis: checkMainAxis = true,
2489
- crossAxis: checkCrossAxis = true
2490
- } = evaluate(options, state);
2491
- const coords = {
2492
- x,
2493
- y
2494
- };
2495
- const crossAxis = getSideAxis(placement);
2496
- const mainAxis = getOppositeAxis(crossAxis);
2497
- let mainAxisCoord = coords[mainAxis];
2498
- let crossAxisCoord = coords[crossAxis];
2499
- const rawOffset = evaluate(offset, state);
2500
- const computedOffset = typeof rawOffset === 'number' ? {
2501
- mainAxis: rawOffset,
2502
- crossAxis: 0
2503
- } : {
2504
- mainAxis: 0,
2505
- crossAxis: 0,
2506
- ...rawOffset
2507
- };
2508
- if (checkMainAxis) {
2509
- const len = mainAxis === 'y' ? 'height' : 'width';
2510
- const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
2511
- const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
2512
- if (mainAxisCoord < limitMin) {
2513
- mainAxisCoord = limitMin;
2514
- } else if (mainAxisCoord > limitMax) {
2515
- mainAxisCoord = limitMax;
2516
- }
2517
- }
2518
- if (checkCrossAxis) {
2519
- var _middlewareData$offse, _middlewareData$offse2;
2520
- const len = mainAxis === 'y' ? 'width' : 'height';
2521
- const isOriginSide = ['top', 'left'].includes(getSide(placement));
2522
- const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
2523
- const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
2524
- if (crossAxisCoord < limitMin) {
2525
- crossAxisCoord = limitMin;
2526
- } else if (crossAxisCoord > limitMax) {
2527
- crossAxisCoord = limitMax;
2528
- }
2529
- }
2530
- return {
2531
- [mainAxis]: mainAxisCoord,
2532
- [crossAxis]: crossAxisCoord
2533
- };
2534
- }
2535
- };
2536
- };
2537
-
2538
- /**
2539
- * Provides data that allows you to change the size of the floating element —
2540
- * for instance, prevent it from overflowing the clipping boundary or match the
2541
- * width of the reference element.
2542
- * @see https://floating-ui.com/docs/size
2543
- */
2544
- const size$1 = function (options) {
2545
- if (options === void 0) {
2546
- options = {};
2547
- }
2548
- return {
2549
- name: 'size',
2550
- options,
2551
- async fn(state) {
2552
- var _state$middlewareData, _state$middlewareData2;
2553
- const {
2554
- placement,
2555
- rects,
2556
- platform,
2557
- elements
2558
- } = state;
2559
- const {
2560
- apply = () => {},
2561
- ...detectOverflowOptions
2562
- } = evaluate(options, state);
2563
- const overflow = await detectOverflow(state, detectOverflowOptions);
2564
- const side = getSide(placement);
2565
- const alignment = getAlignment(placement);
2566
- const isYAxis = getSideAxis(placement) === 'y';
2567
- const {
2568
- width,
2569
- height
2570
- } = rects.floating;
2571
- let heightSide;
2572
- let widthSide;
2573
- if (side === 'top' || side === 'bottom') {
2574
- heightSide = side;
2575
- widthSide = alignment === ((await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating))) ? 'start' : 'end') ? 'left' : 'right';
2576
- } else {
2577
- widthSide = side;
2578
- heightSide = alignment === 'end' ? 'top' : 'bottom';
2579
- }
2580
- const maximumClippingHeight = height - overflow.top - overflow.bottom;
2581
- const maximumClippingWidth = width - overflow.left - overflow.right;
2582
- const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
2583
- const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
2584
- const noShift = !state.middlewareData.shift;
2585
- let availableHeight = overflowAvailableHeight;
2586
- let availableWidth = overflowAvailableWidth;
2587
- if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
2588
- availableWidth = maximumClippingWidth;
2589
- }
2590
- if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
2591
- availableHeight = maximumClippingHeight;
2592
- }
2593
- if (noShift && !alignment) {
2594
- const xMin = max(overflow.left, 0);
2595
- const xMax = max(overflow.right, 0);
2596
- const yMin = max(overflow.top, 0);
2597
- const yMax = max(overflow.bottom, 0);
2598
- if (isYAxis) {
2599
- availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
2600
- } else {
2601
- availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
2602
- }
2603
- }
2604
- await apply({
2605
- ...state,
2606
- availableWidth,
2607
- availableHeight
2608
- });
2609
- const nextDimensions = await platform.getDimensions(elements.floating);
2610
- if (width !== nextDimensions.width || height !== nextDimensions.height) {
2611
- return {
2612
- reset: {
2613
- rects: true
2614
- }
2615
- };
2616
- }
2617
- return {};
2618
- }
2619
- };
2620
- };
2621
-
2622
- function hasWindow() {
2623
- return typeof window !== 'undefined';
2624
- }
2625
- function getNodeName(node) {
2626
- if (isNode(node)) {
2627
- return (node.nodeName || '').toLowerCase();
2628
- }
2629
- // Mocked nodes in testing environments may not be instances of Node. By
2630
- // returning `#document` an infinite loop won't occur.
2631
- // https://github.com/floating-ui/floating-ui/issues/2317
2632
- return '#document';
2633
- }
2634
- function getWindow(node) {
2635
- var _node$ownerDocument;
2636
- return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2637
- }
2638
- function getDocumentElement(node) {
2639
- var _ref;
2640
- return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2641
- }
2642
- function isNode(value) {
2643
- if (!hasWindow()) {
2644
- return false;
2645
- }
2646
- return value instanceof Node || value instanceof getWindow(value).Node;
2647
- }
2648
- function isElement(value) {
2649
- if (!hasWindow()) {
2650
- return false;
2651
- }
2652
- return value instanceof Element || value instanceof getWindow(value).Element;
2653
- }
2654
- function isHTMLElement(value) {
2655
- if (!hasWindow()) {
2656
- return false;
2657
- }
2658
- return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2659
- }
2660
- function isShadowRoot(value) {
2661
- if (!hasWindow() || typeof ShadowRoot === 'undefined') {
2662
- return false;
2663
- }
2664
- return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2665
- }
2666
- function isOverflowElement(element) {
2667
- const {
2668
- overflow,
2669
- overflowX,
2670
- overflowY,
2671
- display
2672
- } = getComputedStyle$1(element);
2673
- return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
2674
- }
2675
- function isTableElement(element) {
2676
- return ['table', 'td', 'th'].includes(getNodeName(element));
2677
- }
2678
- function isTopLayer(element) {
2679
- return [':popover-open', ':modal'].some(selector => {
2680
- try {
2681
- return element.matches(selector);
2682
- } catch (e) {
2683
- return false;
2684
- }
2685
- });
2686
- }
2687
- function isContainingBlock(elementOrCss) {
2688
- const webkit = isWebKit();
2689
- const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
2690
-
2691
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
2692
- // https://drafts.csswg.org/css-transforms-2/#individual-transforms
2693
- return ['transform', 'translate', 'scale', 'rotate', 'perspective'].some(value => css[value] ? css[value] !== 'none' : false) || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'translate', 'scale', 'rotate', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
2694
- }
2695
- function getContainingBlock(element) {
2696
- let currentNode = getParentNode(element);
2697
- while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2698
- if (isContainingBlock(currentNode)) {
2699
- return currentNode;
2700
- } else if (isTopLayer(currentNode)) {
2701
- return null;
2702
- }
2703
- currentNode = getParentNode(currentNode);
2704
- }
2705
- return null;
2706
- }
2707
- function isWebKit() {
2708
- if (typeof CSS === 'undefined' || !CSS.supports) return false;
2709
- return CSS.supports('-webkit-backdrop-filter', 'none');
2710
- }
2711
- function isLastTraversableNode(node) {
2712
- return ['html', 'body', '#document'].includes(getNodeName(node));
2713
- }
2714
- function getComputedStyle$1(element) {
2715
- return getWindow(element).getComputedStyle(element);
2716
- }
2717
- function getNodeScroll(element) {
2718
- if (isElement(element)) {
2719
- return {
2720
- scrollLeft: element.scrollLeft,
2721
- scrollTop: element.scrollTop
2722
- };
2723
- }
2724
- return {
2725
- scrollLeft: element.scrollX,
2726
- scrollTop: element.scrollY
2727
- };
2728
- }
2729
- function getParentNode(node) {
2730
- if (getNodeName(node) === 'html') {
2731
- return node;
2732
- }
2733
- const result =
2734
- // Step into the shadow DOM of the parent of a slotted node.
2735
- node.assignedSlot ||
2736
- // DOM Element detected.
2737
- node.parentNode ||
2738
- // ShadowRoot detected.
2739
- isShadowRoot(node) && node.host ||
2740
- // Fallback.
2741
- getDocumentElement(node);
2742
- return isShadowRoot(result) ? result.host : result;
2743
- }
2744
- function getNearestOverflowAncestor(node) {
2745
- const parentNode = getParentNode(node);
2746
- if (isLastTraversableNode(parentNode)) {
2747
- return node.ownerDocument ? node.ownerDocument.body : node.body;
2748
- }
2749
- if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2750
- return parentNode;
2751
- }
2752
- return getNearestOverflowAncestor(parentNode);
2753
- }
2754
- function getOverflowAncestors(node, list, traverseIframes) {
2755
- var _node$ownerDocument2;
2756
- if (list === void 0) {
2757
- list = [];
2758
- }
2759
- if (traverseIframes === void 0) {
2760
- traverseIframes = true;
2761
- }
2762
- const scrollableAncestor = getNearestOverflowAncestor(node);
2763
- const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2764
- const win = getWindow(scrollableAncestor);
2765
- if (isBody) {
2766
- const frameElement = getFrameElement(win);
2767
- return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
2768
- }
2769
- return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
2770
- }
2771
- function getFrameElement(win) {
2772
- return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
2773
- }
2774
-
2775
- function getCssDimensions(element) {
2776
- const css = getComputedStyle$1(element);
2777
- // In testing environments, the `width` and `height` properties are empty
2778
- // strings for SVG elements, returning NaN. Fallback to `0` in this case.
2779
- let width = parseFloat(css.width) || 0;
2780
- let height = parseFloat(css.height) || 0;
2781
- const hasOffset = isHTMLElement(element);
2782
- const offsetWidth = hasOffset ? element.offsetWidth : width;
2783
- const offsetHeight = hasOffset ? element.offsetHeight : height;
2784
- const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
2785
- if (shouldFallback) {
2786
- width = offsetWidth;
2787
- height = offsetHeight;
2788
- }
2789
- return {
2790
- width,
2791
- height,
2792
- $: shouldFallback
2793
- };
2794
- }
2795
-
2796
- function unwrapElement(element) {
2797
- return !isElement(element) ? element.contextElement : element;
2798
- }
2799
-
2800
- function getScale(element) {
2801
- const domElement = unwrapElement(element);
2802
- if (!isHTMLElement(domElement)) {
2803
- return createCoords(1);
2804
- }
2805
- const rect = domElement.getBoundingClientRect();
2806
- const {
2807
- width,
2808
- height,
2809
- $
2810
- } = getCssDimensions(domElement);
2811
- let x = ($ ? round(rect.width) : rect.width) / width;
2812
- let y = ($ ? round(rect.height) : rect.height) / height;
2813
-
2814
- // 0, NaN, or Infinity should always fallback to 1.
2815
-
2816
- if (!x || !Number.isFinite(x)) {
2817
- x = 1;
2818
- }
2819
- if (!y || !Number.isFinite(y)) {
2820
- y = 1;
2821
- }
2822
- return {
2823
- x,
2824
- y
2825
- };
2826
- }
2827
-
2828
- const noOffsets = /*#__PURE__*/createCoords(0);
2829
- function getVisualOffsets(element) {
2830
- const win = getWindow(element);
2831
- if (!isWebKit() || !win.visualViewport) {
2832
- return noOffsets;
2833
- }
2834
- return {
2835
- x: win.visualViewport.offsetLeft,
2836
- y: win.visualViewport.offsetTop
2837
- };
2838
- }
2839
- function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
2840
- if (isFixed === void 0) {
2841
- isFixed = false;
2842
- }
2843
- if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
2844
- return false;
2845
- }
2846
- return isFixed;
2847
- }
2848
-
2849
- function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
2850
- if (includeScale === void 0) {
2851
- includeScale = false;
2852
- }
2853
- if (isFixedStrategy === void 0) {
2854
- isFixedStrategy = false;
2855
- }
2856
- const clientRect = element.getBoundingClientRect();
2857
- const domElement = unwrapElement(element);
2858
- let scale = createCoords(1);
2859
- if (includeScale) {
2860
- if (offsetParent) {
2861
- if (isElement(offsetParent)) {
2862
- scale = getScale(offsetParent);
2863
- }
2864
- } else {
2865
- scale = getScale(element);
2866
- }
2867
- }
2868
- const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
2869
- let x = (clientRect.left + visualOffsets.x) / scale.x;
2870
- let y = (clientRect.top + visualOffsets.y) / scale.y;
2871
- let width = clientRect.width / scale.x;
2872
- let height = clientRect.height / scale.y;
2873
- if (domElement) {
2874
- const win = getWindow(domElement);
2875
- const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
2876
- let currentWin = win;
2877
- let currentIFrame = getFrameElement(currentWin);
2878
- while (currentIFrame && offsetParent && offsetWin !== currentWin) {
2879
- const iframeScale = getScale(currentIFrame);
2880
- const iframeRect = currentIFrame.getBoundingClientRect();
2881
- const css = getComputedStyle$1(currentIFrame);
2882
- const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
2883
- const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
2884
- x *= iframeScale.x;
2885
- y *= iframeScale.y;
2886
- width *= iframeScale.x;
2887
- height *= iframeScale.y;
2888
- x += left;
2889
- y += top;
2890
- currentWin = getWindow(currentIFrame);
2891
- currentIFrame = getFrameElement(currentWin);
2892
- }
2893
- }
2894
- return rectToClientRect({
2895
- width,
2896
- height,
2897
- x,
2898
- y
2899
- });
2900
- }
2901
-
2902
- // If <html> has a CSS width greater than the viewport, then this will be
2903
- // incorrect for RTL.
2904
- function getWindowScrollBarX(element, rect) {
2905
- const leftScroll = getNodeScroll(element).scrollLeft;
2906
- if (!rect) {
2907
- return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
2908
- }
2909
- return rect.left + leftScroll;
2910
- }
2911
-
2912
- function getHTMLOffset(documentElement, scroll, ignoreScrollbarX) {
2913
- if (ignoreScrollbarX === void 0) {
2914
- ignoreScrollbarX = false;
2915
- }
2916
- const htmlRect = documentElement.getBoundingClientRect();
2917
- const x = htmlRect.left + scroll.scrollLeft - (ignoreScrollbarX ? 0 :
2918
- // RTL <body> scrollbar.
2919
- getWindowScrollBarX(documentElement, htmlRect));
2920
- const y = htmlRect.top + scroll.scrollTop;
2921
- return {
2922
- x,
2923
- y
2924
- };
2925
- }
2926
-
2927
- function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
2928
- let {
2929
- elements,
2930
- rect,
2931
- offsetParent,
2932
- strategy
2933
- } = _ref;
2934
- const isFixed = strategy === 'fixed';
2935
- const documentElement = getDocumentElement(offsetParent);
2936
- const topLayer = elements ? isTopLayer(elements.floating) : false;
2937
- if (offsetParent === documentElement || topLayer && isFixed) {
2938
- return rect;
2939
- }
2940
- let scroll = {
2941
- scrollLeft: 0,
2942
- scrollTop: 0
2943
- };
2944
- let scale = createCoords(1);
2945
- const offsets = createCoords(0);
2946
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
2947
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2948
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
2949
- scroll = getNodeScroll(offsetParent);
2950
- }
2951
- if (isHTMLElement(offsetParent)) {
2952
- const offsetRect = getBoundingClientRect(offsetParent);
2953
- scale = getScale(offsetParent);
2954
- offsets.x = offsetRect.x + offsetParent.clientLeft;
2955
- offsets.y = offsetRect.y + offsetParent.clientTop;
2956
- }
2957
- }
2958
- const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll, true) : createCoords(0);
2959
- return {
2960
- width: rect.width * scale.x,
2961
- height: rect.height * scale.y,
2962
- x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
2963
- y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
2964
- };
2965
- }
2966
-
2967
- function getClientRects(element) {
2968
- return Array.from(element.getClientRects());
2969
- }
2970
-
2971
- // Gets the entire size of the scrollable document area, even extending outside
2972
- // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
2973
- function getDocumentRect(element) {
2974
- const html = getDocumentElement(element);
2975
- const scroll = getNodeScroll(element);
2976
- const body = element.ownerDocument.body;
2977
- const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
2978
- const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
2979
- let x = -scroll.scrollLeft + getWindowScrollBarX(element);
2980
- const y = -scroll.scrollTop;
2981
- if (getComputedStyle$1(body).direction === 'rtl') {
2982
- x += max(html.clientWidth, body.clientWidth) - width;
2983
- }
2984
- return {
2985
- width,
2986
- height,
2987
- x,
2988
- y
2989
- };
2990
- }
2991
-
2992
- function getViewportRect(element, strategy) {
2993
- const win = getWindow(element);
2994
- const html = getDocumentElement(element);
2995
- const visualViewport = win.visualViewport;
2996
- let width = html.clientWidth;
2997
- let height = html.clientHeight;
2998
- let x = 0;
2999
- let y = 0;
3000
- if (visualViewport) {
3001
- width = visualViewport.width;
3002
- height = visualViewport.height;
3003
- const visualViewportBased = isWebKit();
3004
- if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
3005
- x = visualViewport.offsetLeft;
3006
- y = visualViewport.offsetTop;
3007
- }
3008
- }
3009
- return {
3010
- width,
3011
- height,
3012
- x,
3013
- y
3014
- };
3015
- }
3016
-
3017
- // Returns the inner client rect, subtracting scrollbars if present.
3018
- function getInnerBoundingClientRect(element, strategy) {
3019
- const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
3020
- const top = clientRect.top + element.clientTop;
3021
- const left = clientRect.left + element.clientLeft;
3022
- const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
3023
- const width = element.clientWidth * scale.x;
3024
- const height = element.clientHeight * scale.y;
3025
- const x = left * scale.x;
3026
- const y = top * scale.y;
3027
- return {
3028
- width,
3029
- height,
3030
- x,
3031
- y
3032
- };
3033
- }
3034
- function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
3035
- let rect;
3036
- if (clippingAncestor === 'viewport') {
3037
- rect = getViewportRect(element, strategy);
3038
- } else if (clippingAncestor === 'document') {
3039
- rect = getDocumentRect(getDocumentElement(element));
3040
- } else if (isElement(clippingAncestor)) {
3041
- rect = getInnerBoundingClientRect(clippingAncestor, strategy);
3042
- } else {
3043
- const visualOffsets = getVisualOffsets(element);
3044
- rect = {
3045
- x: clippingAncestor.x - visualOffsets.x,
3046
- y: clippingAncestor.y - visualOffsets.y,
3047
- width: clippingAncestor.width,
3048
- height: clippingAncestor.height
3049
- };
3050
- }
3051
- return rectToClientRect(rect);
3052
- }
3053
- function hasFixedPositionAncestor(element, stopNode) {
3054
- const parentNode = getParentNode(element);
3055
- if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
3056
- return false;
3057
- }
3058
- return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
3059
- }
3060
-
3061
- // A "clipping ancestor" is an `overflow` element with the characteristic of
3062
- // clipping (or hiding) child elements. This returns all clipping ancestors
3063
- // of the given element up the tree.
3064
- function getClippingElementAncestors(element, cache) {
3065
- const cachedResult = cache.get(element);
3066
- if (cachedResult) {
3067
- return cachedResult;
3068
- }
3069
- let result = getOverflowAncestors(element, [], false).filter(el => isElement(el) && getNodeName(el) !== 'body');
3070
- let currentContainingBlockComputedStyle = null;
3071
- const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
3072
- let currentNode = elementIsFixed ? getParentNode(element) : element;
3073
-
3074
- // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
3075
- while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
3076
- const computedStyle = getComputedStyle$1(currentNode);
3077
- const currentNodeIsContaining = isContainingBlock(currentNode);
3078
- if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
3079
- currentContainingBlockComputedStyle = null;
3080
- }
3081
- const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
3082
- if (shouldDropCurrentNode) {
3083
- // Drop non-containing blocks.
3084
- result = result.filter(ancestor => ancestor !== currentNode);
3085
- } else {
3086
- // Record last containing block for next iteration.
3087
- currentContainingBlockComputedStyle = computedStyle;
3088
- }
3089
- currentNode = getParentNode(currentNode);
3090
- }
3091
- cache.set(element, result);
3092
- return result;
3093
- }
3094
-
3095
- // Gets the maximum area that the element is visible in due to any number of
3096
- // clipping ancestors.
3097
- function getClippingRect(_ref) {
3098
- let {
3099
- element,
3100
- boundary,
3101
- rootBoundary,
3102
- strategy
3103
- } = _ref;
3104
- const elementClippingAncestors = boundary === 'clippingAncestors' ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
3105
- const clippingAncestors = [...elementClippingAncestors, rootBoundary];
3106
- const firstClippingAncestor = clippingAncestors[0];
3107
- const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
3108
- const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
3109
- accRect.top = max(rect.top, accRect.top);
3110
- accRect.right = min(rect.right, accRect.right);
3111
- accRect.bottom = min(rect.bottom, accRect.bottom);
3112
- accRect.left = max(rect.left, accRect.left);
3113
- return accRect;
3114
- }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
3115
- return {
3116
- width: clippingRect.right - clippingRect.left,
3117
- height: clippingRect.bottom - clippingRect.top,
3118
- x: clippingRect.left,
3119
- y: clippingRect.top
3120
- };
3121
- }
3122
-
3123
- function getDimensions(element) {
3124
- const {
3125
- width,
3126
- height
3127
- } = getCssDimensions(element);
3128
- return {
3129
- width,
3130
- height
3131
- };
3132
- }
3133
-
3134
- function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
3135
- const isOffsetParentAnElement = isHTMLElement(offsetParent);
3136
- const documentElement = getDocumentElement(offsetParent);
3137
- const isFixed = strategy === 'fixed';
3138
- const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
3139
- let scroll = {
3140
- scrollLeft: 0,
3141
- scrollTop: 0
3142
- };
3143
- const offsets = createCoords(0);
3144
-
3145
- // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
3146
- // Firefox with layout.scrollbar.side = 3 in about:config to test this.
3147
- function setLeftRTLScrollbarOffset() {
3148
- offsets.x = getWindowScrollBarX(documentElement);
3149
- }
3150
- if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
3151
- if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
3152
- scroll = getNodeScroll(offsetParent);
3153
- }
3154
- if (isOffsetParentAnElement) {
3155
- const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
3156
- offsets.x = offsetRect.x + offsetParent.clientLeft;
3157
- offsets.y = offsetRect.y + offsetParent.clientTop;
3158
- } else if (documentElement) {
3159
- setLeftRTLScrollbarOffset();
3160
- }
3161
- }
3162
- if (isFixed && !isOffsetParentAnElement && documentElement) {
3163
- setLeftRTLScrollbarOffset();
3164
- }
3165
- const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
3166
- const x = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
3167
- const y = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
3168
- return {
3169
- x,
3170
- y,
3171
- width: rect.width,
3172
- height: rect.height
3173
- };
3174
- }
3175
-
3176
- function isStaticPositioned(element) {
3177
- return getComputedStyle$1(element).position === 'static';
3178
- }
3179
-
3180
- function getTrueOffsetParent(element, polyfill) {
3181
- if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
3182
- return null;
3183
- }
3184
- if (polyfill) {
3185
- return polyfill(element);
3186
- }
3187
- let rawOffsetParent = element.offsetParent;
3188
-
3189
- // Firefox returns the <html> element as the offsetParent if it's non-static,
3190
- // while Chrome and Safari return the <body> element. The <body> element must
3191
- // be used to perform the correct calculations even if the <html> element is
3192
- // non-static.
3193
- if (getDocumentElement(element) === rawOffsetParent) {
3194
- rawOffsetParent = rawOffsetParent.ownerDocument.body;
3195
- }
3196
- return rawOffsetParent;
3197
- }
3198
-
3199
- // Gets the closest ancestor positioned element. Handles some edge cases,
3200
- // such as table ancestors and cross browser bugs.
3201
- function getOffsetParent(element, polyfill) {
3202
- const win = getWindow(element);
3203
- if (isTopLayer(element)) {
3204
- return win;
3205
- }
3206
- if (!isHTMLElement(element)) {
3207
- let svgOffsetParent = getParentNode(element);
3208
- while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
3209
- if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
3210
- return svgOffsetParent;
3211
- }
3212
- svgOffsetParent = getParentNode(svgOffsetParent);
3213
- }
3214
- return win;
3215
- }
3216
- let offsetParent = getTrueOffsetParent(element, polyfill);
3217
- while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
3218
- offsetParent = getTrueOffsetParent(offsetParent, polyfill);
3219
- }
3220
- if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
3221
- return win;
3222
- }
3223
- return offsetParent || getContainingBlock(element) || win;
3224
- }
3225
-
3226
- const getElementRects = async function (data) {
3227
- const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
3228
- const getDimensionsFn = this.getDimensions;
3229
- const floatingDimensions = await getDimensionsFn(data.floating);
3230
- return {
3231
- reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
3232
- floating: {
3233
- x: 0,
3234
- y: 0,
3235
- width: floatingDimensions.width,
3236
- height: floatingDimensions.height
3237
- }
3238
- };
3239
- };
3240
-
3241
- function isRTL(element) {
3242
- return getComputedStyle$1(element).direction === 'rtl';
3243
- }
3244
-
3245
- const platform = {
3246
- convertOffsetParentRelativeRectToViewportRelativeRect,
3247
- getDocumentElement,
3248
- getClippingRect,
3249
- getOffsetParent,
3250
- getElementRects,
3251
- getClientRects,
3252
- getDimensions,
3253
- getScale,
3254
- isElement,
3255
- isRTL
3256
- };
3257
-
3258
- function rectsAreEqual(a, b) {
3259
- return a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height;
3260
- }
3261
-
3262
- // https://samthor.au/2021/observing-dom/
3263
- function observeMove(element, onMove) {
3264
- let io = null;
3265
- let timeoutId;
3266
- const root = getDocumentElement(element);
3267
- function cleanup() {
3268
- var _io;
3269
- clearTimeout(timeoutId);
3270
- (_io = io) == null || _io.disconnect();
3271
- io = null;
3272
- }
3273
- function refresh(skip, threshold) {
3274
- if (skip === void 0) {
3275
- skip = false;
3276
- }
3277
- if (threshold === void 0) {
3278
- threshold = 1;
3279
- }
3280
- cleanup();
3281
- const elementRectForRootMargin = element.getBoundingClientRect();
3282
- const {
3283
- left,
3284
- top,
3285
- width,
3286
- height
3287
- } = elementRectForRootMargin;
3288
- if (!skip) {
3289
- onMove();
3290
- }
3291
- if (!width || !height) {
3292
- return;
3293
- }
3294
- const insetTop = floor(top);
3295
- const insetRight = floor(root.clientWidth - (left + width));
3296
- const insetBottom = floor(root.clientHeight - (top + height));
3297
- const insetLeft = floor(left);
3298
- const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
3299
- const options = {
3300
- rootMargin,
3301
- threshold: max(0, min(1, threshold)) || 1
3302
- };
3303
- let isFirstUpdate = true;
3304
- function handleObserve(entries) {
3305
- const ratio = entries[0].intersectionRatio;
3306
- if (ratio !== threshold) {
3307
- if (!isFirstUpdate) {
3308
- return refresh();
3309
- }
3310
- if (!ratio) {
3311
- // If the reference is clipped, the ratio is 0. Throttle the refresh
3312
- // to prevent an infinite loop of updates.
3313
- timeoutId = setTimeout(() => {
3314
- refresh(false, 1e-7);
3315
- }, 1000);
3316
- } else {
3317
- refresh(false, ratio);
3318
- }
3319
- }
3320
- if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
3321
- // It's possible that even though the ratio is reported as 1, the
3322
- // element is not actually fully within the IntersectionObserver's root
3323
- // area anymore. This can happen under performance constraints. This may
3324
- // be a bug in the browser's IntersectionObserver implementation. To
3325
- // work around this, we compare the element's bounding rect now with
3326
- // what it was at the time we created the IntersectionObserver. If they
3327
- // are not equal then the element moved, so we refresh.
3328
- refresh();
3329
- }
3330
- isFirstUpdate = false;
3331
- }
3332
-
3333
- // Older browsers don't support a `document` as the root and will throw an
3334
- // error.
3335
- try {
3336
- io = new IntersectionObserver(handleObserve, {
3337
- ...options,
3338
- // Handle <iframe>s
3339
- root: root.ownerDocument
3340
- });
3341
- } catch (_e) {
3342
- io = new IntersectionObserver(handleObserve, options);
3343
- }
3344
- io.observe(element);
3345
- }
3346
- refresh(true);
3347
- return cleanup;
3348
- }
3349
-
3350
- /**
3351
- * Automatically updates the position of the floating element when necessary.
3352
- * Should only be called when the floating element is mounted on the DOM or
3353
- * visible on the screen.
3354
- * @returns cleanup function that should be invoked when the floating element is
3355
- * removed from the DOM or hidden from the screen.
3356
- * @see https://floating-ui.com/docs/autoUpdate
3357
- */
3358
- function autoUpdate(reference, floating, update, options) {
3359
- if (options === void 0) {
3360
- options = {};
3361
- }
3362
- const {
3363
- ancestorScroll = true,
3364
- ancestorResize = true,
3365
- elementResize = typeof ResizeObserver === 'function',
3366
- layoutShift = typeof IntersectionObserver === 'function',
3367
- animationFrame = false
3368
- } = options;
3369
- const referenceEl = unwrapElement(reference);
3370
- const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
3371
- ancestors.forEach(ancestor => {
3372
- ancestorScroll && ancestor.addEventListener('scroll', update, {
3373
- passive: true
3374
- });
3375
- ancestorResize && ancestor.addEventListener('resize', update);
3376
- });
3377
- const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
3378
- let reobserveFrame = -1;
3379
- let resizeObserver = null;
3380
- if (elementResize) {
3381
- resizeObserver = new ResizeObserver(_ref => {
3382
- let [firstEntry] = _ref;
3383
- if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
3384
- // Prevent update loops when using the `size` middleware.
3385
- // https://github.com/floating-ui/floating-ui/issues/1740
3386
- resizeObserver.unobserve(floating);
3387
- cancelAnimationFrame(reobserveFrame);
3388
- reobserveFrame = requestAnimationFrame(() => {
3389
- var _resizeObserver;
3390
- (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
3391
- });
3392
- }
3393
- update();
3394
- });
3395
- if (referenceEl && !animationFrame) {
3396
- resizeObserver.observe(referenceEl);
3397
- }
3398
- resizeObserver.observe(floating);
3399
- }
3400
- let frameId;
3401
- let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
3402
- if (animationFrame) {
3403
- frameLoop();
3404
- }
3405
- function frameLoop() {
3406
- const nextRefRect = getBoundingClientRect(reference);
3407
- if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
3408
- update();
3409
- }
3410
- prevRefRect = nextRefRect;
3411
- frameId = requestAnimationFrame(frameLoop);
3412
- }
3413
- update();
3414
- return () => {
3415
- var _resizeObserver2;
3416
- ancestors.forEach(ancestor => {
3417
- ancestorScroll && ancestor.removeEventListener('scroll', update);
3418
- ancestorResize && ancestor.removeEventListener('resize', update);
3419
- });
3420
- cleanupIo == null || cleanupIo();
3421
- (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
3422
- resizeObserver = null;
3423
- if (animationFrame) {
3424
- cancelAnimationFrame(frameId);
3425
- }
3426
- };
3427
- }
3428
-
3429
- /**
3430
- * Modifies the placement by translating the floating element along the
3431
- * specified axes.
3432
- * A number (shorthand for `mainAxis` or distance), or an axes configuration
3433
- * object may be passed.
3434
- * @see https://floating-ui.com/docs/offset
3435
- */
3436
- const offset = offset$1;
3437
-
3438
- /**
3439
- * Optimizes the visibility of the floating element by choosing the placement
3440
- * that has the most space available automatically, without needing to specify a
3441
- * preferred placement. Alternative to `flip`.
3442
- * @see https://floating-ui.com/docs/autoPlacement
3443
- */
3444
- autoPlacement;
3445
-
3446
- /**
3447
- * Optimizes the visibility of the floating element by shifting it in order to
3448
- * keep it in view when it will overflow the clipping boundary.
3449
- * @see https://floating-ui.com/docs/shift
3450
- */
3451
- const shift = shift$1;
3452
-
3453
- /**
3454
- * Optimizes the visibility of the floating element by flipping the `placement`
3455
- * in order to keep it in view when the preferred placement(s) will overflow the
3456
- * clipping boundary. Alternative to `autoPlacement`.
3457
- * @see https://floating-ui.com/docs/flip
3458
- */
3459
- const flip = flip$1;
3460
-
3461
- /**
3462
- * Provides data that allows you to change the size of the floating element —
3463
- * for instance, prevent it from overflowing the clipping boundary or match the
3464
- * width of the reference element.
3465
- * @see https://floating-ui.com/docs/size
3466
- */
3467
- const size = size$1;
3468
-
3469
- /**
3470
- * Provides data to hide the floating element in applicable situations, such as
3471
- * when it is not in the same clipping context as the reference element.
3472
- * @see https://floating-ui.com/docs/hide
3473
- */
3474
- hide;
3475
-
3476
- /**
3477
- * Provides data to position an inner element of the floating element so that it
3478
- * appears centered to the reference element.
3479
- * @see https://floating-ui.com/docs/arrow
3480
- */
3481
- const arrow = arrow$1;
3482
-
3483
- /**
3484
- * Provides improved positioning for inline reference elements that can span
3485
- * over multiple lines, such as hyperlinks or range selections.
3486
- * @see https://floating-ui.com/docs/inline
3487
- */
3488
- const inline = inline$1;
3489
-
3490
- /**
3491
- * Built-in `limiter` that will stop `shift()` at a certain point.
3492
- */
3493
- const limitShift = limitShift$1;
3494
-
3495
- /**
3496
- * Computes the `x` and `y` coordinates that will place the floating element
3497
- * next to a given reference element.
3498
- */
3499
- const computePosition = (reference, floating, options) => {
3500
- // This caches the expensive `getClippingElementAncestors` function so that
3501
- // multiple lifecycle resets re-use the same result. It only lives for a
3502
- // single call. If other functions become expensive, we can add them as well.
3503
- const cache = new Map();
3504
- const mergedOptions = {
3505
- platform,
3506
- ...options
3507
- };
3508
- const platformWithCache = {
3509
- ...mergedOptions.platform,
3510
- _c: cache
3511
- };
3512
- return computePosition$1(reference, floating, {
3513
- ...mergedOptions,
3514
- platform: platformWithCache
3515
- });
3516
- };
3517
-
3518
- // src/events.ts
3519
- var ToggleEvent = class extends Event {
3520
- oldState;
3521
- newState;
3522
- constructor(type, { oldState = "", newState = "", ...init } = {}) {
3523
- super(type, init);
3524
- this.oldState = String(oldState || "");
3525
- this.newState = String(newState || "");
3526
- }
3527
- };
3528
- var popoverToggleTaskQueue = /* @__PURE__ */ new WeakMap();
3529
- function queuePopoverToggleEventTask(element, oldState, newState) {
3530
- popoverToggleTaskQueue.set(
3531
- element,
3532
- setTimeout(() => {
3533
- if (!popoverToggleTaskQueue.has(element)) return;
3534
- element.dispatchEvent(
3535
- new ToggleEvent("toggle", {
3536
- cancelable: false,
3537
- oldState,
3538
- newState
3539
- })
3540
- );
3541
- }, 0)
3542
- );
3543
- }
3544
-
3545
- // src/popover-helpers.ts
3546
- var ShadowRoot$1 = globalThis.ShadowRoot || function() {
3547
- };
3548
- var HTMLDialogElement = globalThis.HTMLDialogElement || function() {
3549
- };
3550
- var topLayerElements = /* @__PURE__ */ new WeakMap();
3551
- var autoPopoverList = /* @__PURE__ */ new WeakMap();
3552
- var visibilityState = /* @__PURE__ */ new WeakMap();
3553
- function getPopoverVisibilityState(popover) {
3554
- return visibilityState.get(popover) || "hidden";
3555
- }
3556
- var popoverInvoker = /* @__PURE__ */ new WeakMap();
3557
- function popoverTargetAttributeActivationBehavior(element) {
3558
- const popover = element.popoverTargetElement;
3559
- if (!(popover instanceof HTMLElement)) {
3560
- return;
3561
- }
3562
- const visibility = getPopoverVisibilityState(popover);
3563
- if (element.popoverTargetAction === "show" && visibility === "showing") {
3564
- return;
3565
- }
3566
- if (element.popoverTargetAction === "hide" && visibility === "hidden") return;
3567
- if (visibility === "showing") {
3568
- hidePopover(popover, true, true);
3569
- } else if (checkPopoverValidity(popover, false)) {
3570
- popoverInvoker.set(popover, element);
3571
- showPopover(popover);
3572
- }
3573
- }
3574
- function checkPopoverValidity(element, expectedToBeShowing) {
3575
- if (element.popover !== "auto" && element.popover !== "manual") {
3576
- return false;
3577
- }
3578
- if (!element.isConnected) return false;
3579
- if (expectedToBeShowing && getPopoverVisibilityState(element) !== "showing") {
3580
- return false;
3581
- }
3582
- if (!expectedToBeShowing && getPopoverVisibilityState(element) !== "hidden") {
3583
- return false;
3584
- }
3585
- if (element instanceof HTMLDialogElement && element.hasAttribute("open")) {
3586
- return false;
3587
- }
3588
- if (document.fullscreenElement === element) return false;
3589
- return true;
3590
- }
3591
- function getStackPosition(popover) {
3592
- if (!popover) return 0;
3593
- return Array.from(autoPopoverList.get(popover.ownerDocument) || []).indexOf(
3594
- popover
3595
- ) + 1;
3596
- }
3597
- function topMostClickedPopover(target) {
3598
- const clickedPopover = nearestInclusiveOpenPopover(target);
3599
- const invokerPopover = nearestInclusiveTargetPopoverForInvoker(target);
3600
- if (getStackPosition(clickedPopover) > getStackPosition(invokerPopover)) {
3601
- return clickedPopover;
3602
- }
3603
- return invokerPopover;
3604
- }
3605
- function topMostAutoPopover(document2) {
3606
- const documentPopovers = autoPopoverList.get(document2);
3607
- for (const popover of documentPopovers || []) {
3608
- if (!popover.isConnected) {
3609
- documentPopovers.delete(popover);
3610
- } else {
3611
- return popover;
3612
- }
3613
- }
3614
- return null;
3615
- }
3616
- function getRootNode(node) {
3617
- if (typeof node.getRootNode === "function") {
3618
- return node.getRootNode();
3619
- }
3620
- if (node.parentNode) return getRootNode(node.parentNode);
3621
- return node;
3622
- }
3623
- function nearestInclusiveOpenPopover(node) {
3624
- while (node) {
3625
- if (node instanceof HTMLElement && node.popover === "auto" && visibilityState.get(node) === "showing") {
3626
- return node;
3627
- }
3628
- node = node instanceof Element && node.assignedSlot || node.parentElement || getRootNode(node);
3629
- if (node instanceof ShadowRoot$1) node = node.host;
3630
- if (node instanceof Document) return;
3631
- }
3632
- }
3633
- function nearestInclusiveTargetPopoverForInvoker(node) {
3634
- while (node) {
3635
- const nodePopover = node.popoverTargetElement;
3636
- if (nodePopover instanceof HTMLElement) return nodePopover;
3637
- node = node.parentElement || getRootNode(node);
3638
- if (node instanceof ShadowRoot$1) node = node.host;
3639
- if (node instanceof Document) return;
3640
- }
3641
- }
3642
- function topMostPopoverAncestor(newPopover) {
3643
- const popoverPositions = /* @__PURE__ */ new Map();
3644
- let i = 0;
3645
- for (const popover of autoPopoverList.get(newPopover.ownerDocument) || []) {
3646
- popoverPositions.set(popover, i);
3647
- i += 1;
3648
- }
3649
- popoverPositions.set(newPopover, i);
3650
- i += 1;
3651
- let topMostPopoverAncestor2 = null;
3652
- function checkAncestor(candidate) {
3653
- const candidateAncestor = nearestInclusiveOpenPopover(candidate);
3654
- if (candidateAncestor === null) return null;
3655
- const candidatePosition = popoverPositions.get(candidateAncestor);
3656
- if (topMostPopoverAncestor2 === null || popoverPositions.get(topMostPopoverAncestor2) < candidatePosition) {
3657
- topMostPopoverAncestor2 = candidateAncestor;
3658
- }
3659
- }
3660
- checkAncestor(newPopover.parentElement || getRootNode(newPopover));
3661
- return topMostPopoverAncestor2;
3662
- }
3663
- function isFocusable(focusTarget) {
3664
- if (focusTarget.hidden || focusTarget instanceof ShadowRoot$1) return false;
3665
- if (focusTarget instanceof HTMLButtonElement || focusTarget instanceof HTMLInputElement || focusTarget instanceof HTMLSelectElement || focusTarget instanceof HTMLTextAreaElement || focusTarget instanceof HTMLOptGroupElement || focusTarget instanceof HTMLOptionElement || focusTarget instanceof HTMLFieldSetElement) {
3666
- if (focusTarget.disabled) return false;
3667
- }
3668
- if (focusTarget instanceof HTMLInputElement && focusTarget.type === "hidden") {
3669
- return false;
3670
- }
3671
- if (focusTarget instanceof HTMLAnchorElement && focusTarget.href === "") {
3672
- return false;
3673
- }
3674
- return typeof focusTarget.tabIndex === "number" && focusTarget.tabIndex !== -1;
3675
- }
3676
- function focusDelegate(focusTarget) {
3677
- if (focusTarget.shadowRoot && focusTarget.shadowRoot.delegatesFocus !== true) {
3678
- return null;
3679
- }
3680
- let whereToLook = focusTarget;
3681
- if (whereToLook.shadowRoot) {
3682
- whereToLook = whereToLook.shadowRoot;
3683
- }
3684
- let autoFocusDelegate = whereToLook.querySelector("[autofocus]");
3685
- if (autoFocusDelegate) {
3686
- return autoFocusDelegate;
3687
- } else {
3688
- const slots = whereToLook.querySelectorAll("slot");
3689
- for (const slot of slots) {
3690
- const assignedElements = slot.assignedElements({ flatten: true });
3691
- for (const el of assignedElements) {
3692
- if (el.hasAttribute("autofocus")) {
3693
- return el;
3694
- } else {
3695
- autoFocusDelegate = el.querySelector("[autofocus]");
3696
- if (autoFocusDelegate) {
3697
- return autoFocusDelegate;
3698
- }
3699
- }
3700
- }
3701
- }
3702
- }
3703
- const walker = focusTarget.ownerDocument.createTreeWalker(
3704
- whereToLook,
3705
- NodeFilter.SHOW_ELEMENT
3706
- );
3707
- let descendant = walker.currentNode;
3708
- while (descendant) {
3709
- if (isFocusable(descendant)) {
3710
- return descendant;
3711
- }
3712
- descendant = walker.nextNode();
3713
- }
3714
- }
3715
- function popoverFocusingSteps(subject) {
3716
- focusDelegate(subject)?.focus();
3717
- }
3718
- var previouslyFocusedElements = /* @__PURE__ */ new WeakMap();
3719
- function showPopover(element) {
3720
- if (!checkPopoverValidity(element, false)) {
3721
- return;
3722
- }
3723
- const document2 = element.ownerDocument;
3724
- if (!element.dispatchEvent(
3725
- new ToggleEvent("beforetoggle", {
3726
- cancelable: true,
3727
- oldState: "closed",
3728
- newState: "open"
3729
- })
3730
- )) {
3731
- return;
3732
- }
3733
- if (!checkPopoverValidity(element, false)) {
3734
- return;
3735
- }
3736
- let shouldRestoreFocus = false;
3737
- if (element.popover === "auto") {
3738
- const originalType = element.getAttribute("popover");
3739
- const ancestor = topMostPopoverAncestor(element) || document2;
3740
- hideAllPopoversUntil(ancestor, false, true);
3741
- if (originalType !== element.getAttribute("popover") || !checkPopoverValidity(element, false)) {
3742
- return;
3743
- }
3744
- }
3745
- if (!topMostAutoPopover(document2)) {
3746
- shouldRestoreFocus = true;
3747
- }
3748
- previouslyFocusedElements.delete(element);
3749
- const originallyFocusedElement = document2.activeElement;
3750
- element.classList.add(":popover-open");
3751
- visibilityState.set(element, "showing");
3752
- if (!topLayerElements.has(document2)) {
3753
- topLayerElements.set(document2, /* @__PURE__ */ new Set());
3754
- }
3755
- topLayerElements.get(document2).add(element);
3756
- popoverFocusingSteps(element);
3757
- if (element.popover === "auto") {
3758
- if (!autoPopoverList.has(document2)) {
3759
- autoPopoverList.set(document2, /* @__PURE__ */ new Set());
3760
- }
3761
- autoPopoverList.get(document2).add(element);
3762
- setInvokerAriaExpanded(popoverInvoker.get(element), true);
3763
- }
3764
- if (shouldRestoreFocus && originallyFocusedElement && element.popover === "auto") {
3765
- previouslyFocusedElements.set(element, originallyFocusedElement);
3766
- }
3767
- queuePopoverToggleEventTask(element, "closed", "open");
3768
- }
3769
- function hidePopover(element, focusPreviousElement = false, fireEvents = false) {
3770
- if (!checkPopoverValidity(element, true)) {
3771
- return;
3772
- }
3773
- const document2 = element.ownerDocument;
3774
- if (element.popover === "auto") {
3775
- hideAllPopoversUntil(element, focusPreviousElement, fireEvents);
3776
- if (!checkPopoverValidity(element, true)) {
3777
- return;
3778
- }
3779
- }
3780
- setInvokerAriaExpanded(popoverInvoker.get(element), false);
3781
- popoverInvoker.delete(element);
3782
- if (fireEvents) {
3783
- element.dispatchEvent(
3784
- new ToggleEvent("beforetoggle", {
3785
- oldState: "open",
3786
- newState: "closed"
3787
- })
3788
- );
3789
- if (!checkPopoverValidity(element, true)) {
3790
- return;
3791
- }
3792
- }
3793
- topLayerElements.get(document2)?.delete(element);
3794
- autoPopoverList.get(document2)?.delete(element);
3795
- element.classList.remove(":popover-open");
3796
- visibilityState.set(element, "hidden");
3797
- if (fireEvents) {
3798
- queuePopoverToggleEventTask(element, "open", "closed");
3799
- }
3800
- const previouslyFocusedElement = previouslyFocusedElements.get(element);
3801
- if (previouslyFocusedElement) {
3802
- previouslyFocusedElements.delete(element);
3803
- if (focusPreviousElement) {
3804
- previouslyFocusedElement.focus();
3805
- }
3806
- }
3807
- }
3808
- function closeAllOpenPopovers(document2, focusPreviousElement = false, fireEvents = false) {
3809
- let popover = topMostAutoPopover(document2);
3810
- while (popover) {
3811
- hidePopover(popover, focusPreviousElement, fireEvents);
3812
- popover = topMostAutoPopover(document2);
3813
- }
3814
- }
3815
- function hideAllPopoversUntil(endpoint, focusPreviousElement, fireEvents) {
3816
- const document2 = endpoint.ownerDocument || endpoint;
3817
- if (endpoint instanceof Document) {
3818
- return closeAllOpenPopovers(document2, focusPreviousElement, fireEvents);
3819
- }
3820
- let lastToHide = null;
3821
- let foundEndpoint = false;
3822
- for (const popover of autoPopoverList.get(document2) || []) {
3823
- if (popover === endpoint) {
3824
- foundEndpoint = true;
3825
- } else if (foundEndpoint) {
3826
- lastToHide = popover;
3827
- break;
3828
- }
3829
- }
3830
- if (!foundEndpoint) {
3831
- return closeAllOpenPopovers(document2, focusPreviousElement, fireEvents);
3832
- }
3833
- while (lastToHide && getPopoverVisibilityState(lastToHide) === "showing" && autoPopoverList.get(document2)?.size) {
3834
- hidePopover(lastToHide, focusPreviousElement, fireEvents);
3835
- }
3836
- }
3837
- var popoverPointerDownTargets = /* @__PURE__ */ new WeakMap();
3838
- function lightDismissOpenPopovers(event) {
3839
- if (!event.isTrusted) return;
3840
- const target = event.composedPath()[0];
3841
- if (!target) return;
3842
- const document2 = target.ownerDocument;
3843
- const topMostPopover = topMostAutoPopover(document2);
3844
- if (!topMostPopover) return;
3845
- const ancestor = topMostClickedPopover(target);
3846
- if (ancestor && event.type === "pointerdown") {
3847
- popoverPointerDownTargets.set(document2, ancestor);
3848
- } else if (event.type === "pointerup") {
3849
- const sameTarget = popoverPointerDownTargets.get(document2) === ancestor;
3850
- popoverPointerDownTargets.delete(document2);
3851
- if (sameTarget) {
3852
- hideAllPopoversUntil(ancestor || document2, false, true);
3853
- }
3854
- }
3855
- }
3856
- var initialAriaExpandedValue = /* @__PURE__ */ new WeakMap();
3857
- function setInvokerAriaExpanded(el, force = false) {
3858
- if (!el) return;
3859
- if (!initialAriaExpandedValue.has(el)) {
3860
- initialAriaExpandedValue.set(el, el.getAttribute("aria-expanded"));
3861
- }
3862
- const popover = el.popoverTargetElement;
3863
- if (popover instanceof HTMLElement && popover.popover === "auto") {
3864
- el.setAttribute("aria-expanded", String(force));
3865
- } else {
3866
- const initialValue = initialAriaExpandedValue.get(el);
3867
- if (!initialValue) {
3868
- el.removeAttribute("aria-expanded");
3869
- } else {
3870
- el.setAttribute("aria-expanded", initialValue);
3871
- }
3872
- }
3873
- }
3874
-
3875
- // src/popover.ts
3876
- var ShadowRoot2 = globalThis.ShadowRoot || function() {
3877
- };
3878
- function isSupported() {
3879
- return typeof HTMLElement !== "undefined" && typeof HTMLElement.prototype === "object" && "popover" in HTMLElement.prototype;
3880
- }
3881
- function patchSelectorFn(object, name, mapper) {
3882
- const original = object[name];
3883
- Object.defineProperty(object, name, {
3884
- value(selector) {
3885
- return original.call(this, mapper(selector));
3886
- }
3887
- });
3888
- }
3889
- var nonEscapedPopoverSelector = /(^|[^\\]):popover-open\b/g;
3890
- function hasLayerSupport() {
3891
- return typeof globalThis.CSSLayerBlockRule === "function";
3892
- }
3893
- function getStyles() {
3894
- const useLayer = hasLayerSupport();
3895
- return `
3896
- ${useLayer ? "@layer popover-polyfill {" : ""}
3897
- :where([popover]) {
3898
- position: fixed;
3899
- z-index: 2147483647;
3900
- inset: 0;
3901
- padding: 0.25em;
3902
- width: fit-content;
3903
- height: fit-content;
3904
- border-width: initial;
3905
- border-color: initial;
3906
- border-image: initial;
3907
- border-style: solid;
3908
- background-color: canvas;
3909
- color: canvastext;
3910
- overflow: auto;
3911
- margin: auto;
3912
- }
3913
-
3914
- :where([popover]:not(.\\:popover-open)) {
3915
- display: none;
3916
- }
3917
-
3918
- :where(dialog[popover].\\:popover-open) {
3919
- display: block;
3920
- }
3921
-
3922
- :where(dialog[popover][open]) {
3923
- display: revert;
3924
- }
3925
-
3926
- :where([anchor].\\:popover-open) {
3927
- inset: auto;
3928
- }
3929
-
3930
- :where([anchor]:popover-open) {
3931
- inset: auto;
3932
- }
3933
-
3934
- @supports not (background-color: canvas) {
3935
- :where([popover]) {
3936
- background-color: white;
3937
- color: black;
3938
- }
3939
- }
3940
-
3941
- @supports (width: -moz-fit-content) {
3942
- :where([popover]) {
3943
- width: -moz-fit-content;
3944
- height: -moz-fit-content;
3945
- }
3946
- }
3947
-
3948
- @supports not (inset: 0) {
3949
- :where([popover]) {
3950
- top: 0;
3951
- left: 0;
3952
- right: 0;
3953
- bottom: 0;
3954
- }
3955
- }
3956
- ${useLayer ? "}" : ""}
3957
- `;
3958
- }
3959
- var popoverStyleSheet = null;
3960
- function injectStyles(root) {
3961
- const styles = getStyles();
3962
- if (popoverStyleSheet === null) {
3963
- try {
3964
- popoverStyleSheet = new CSSStyleSheet();
3965
- popoverStyleSheet.replaceSync(styles);
3966
- } catch {
3967
- popoverStyleSheet = false;
3968
- }
3969
- }
3970
- if (popoverStyleSheet === false) {
3971
- const sheet = document.createElement("style");
3972
- sheet.textContent = styles;
3973
- if (root instanceof Document) {
3974
- root.head.prepend(sheet);
3975
- } else {
3976
- root.prepend(sheet);
3977
- }
3978
- } else {
3979
- root.adoptedStyleSheets = [popoverStyleSheet, ...root.adoptedStyleSheets];
3980
- }
3981
- }
3982
- function apply() {
3983
- if (typeof window === "undefined") return;
3984
- window.ToggleEvent = window.ToggleEvent || ToggleEvent;
3985
- function rewriteSelector(selector) {
3986
- if (selector?.includes(":popover-open")) {
3987
- selector = selector.replace(
3988
- nonEscapedPopoverSelector,
3989
- "$1.\\:popover-open"
3990
- );
3991
- }
3992
- return selector;
3993
- }
3994
- patchSelectorFn(Document.prototype, "querySelector", rewriteSelector);
3995
- patchSelectorFn(Document.prototype, "querySelectorAll", rewriteSelector);
3996
- patchSelectorFn(Element.prototype, "querySelector", rewriteSelector);
3997
- patchSelectorFn(Element.prototype, "querySelectorAll", rewriteSelector);
3998
- patchSelectorFn(Element.prototype, "matches", rewriteSelector);
3999
- patchSelectorFn(Element.prototype, "closest", rewriteSelector);
4000
- patchSelectorFn(
4001
- DocumentFragment.prototype,
4002
- "querySelectorAll",
4003
- rewriteSelector
4004
- );
4005
- Object.defineProperties(HTMLElement.prototype, {
4006
- popover: {
4007
- enumerable: true,
4008
- configurable: true,
4009
- get() {
4010
- if (!this.hasAttribute("popover")) return null;
4011
- const value = (this.getAttribute("popover") || "").toLowerCase();
4012
- if (value === "" || value == "auto") return "auto";
4013
- return "manual";
4014
- },
4015
- set(value) {
4016
- if (value === null) {
4017
- this.removeAttribute("popover");
4018
- } else {
4019
- this.setAttribute("popover", value);
4020
- }
4021
- }
4022
- },
4023
- showPopover: {
4024
- enumerable: true,
4025
- configurable: true,
4026
- value() {
4027
- showPopover(this);
4028
- }
4029
- },
4030
- hidePopover: {
4031
- enumerable: true,
4032
- configurable: true,
4033
- value() {
4034
- hidePopover(this, true, true);
4035
- }
4036
- },
4037
- togglePopover: {
4038
- enumerable: true,
4039
- configurable: true,
4040
- value(force) {
4041
- if (visibilityState.get(this) === "showing" && force === void 0 || force === false) {
4042
- hidePopover(this, true, true);
4043
- } else if (force === void 0 || force === true) {
4044
- showPopover(this);
4045
- }
4046
- }
4047
- }
4048
- });
4049
- const originalAttachShadow = Element.prototype.attachShadow;
4050
- if (originalAttachShadow) {
4051
- Object.defineProperties(Element.prototype, {
4052
- attachShadow: {
4053
- enumerable: true,
4054
- configurable: true,
4055
- writable: true,
4056
- value(options) {
4057
- const shadowRoot = originalAttachShadow.call(this, options);
4058
- injectStyles(shadowRoot);
4059
- return shadowRoot;
4060
- }
4061
- }
4062
- });
4063
- }
4064
- const originalAttachInternals = HTMLElement.prototype.attachInternals;
4065
- if (originalAttachInternals) {
4066
- Object.defineProperties(HTMLElement.prototype, {
4067
- attachInternals: {
4068
- enumerable: true,
4069
- configurable: true,
4070
- writable: true,
4071
- value() {
4072
- const internals = originalAttachInternals.call(this);
4073
- if (internals.shadowRoot) {
4074
- injectStyles(internals.shadowRoot);
4075
- }
4076
- return internals;
4077
- }
4078
- }
4079
- });
4080
- }
4081
- const popoverTargetAssociatedElements = /* @__PURE__ */ new WeakMap();
4082
- function applyPopoverInvokerElementMixin(ElementClass) {
4083
- Object.defineProperties(ElementClass.prototype, {
4084
- popoverTargetElement: {
4085
- enumerable: true,
4086
- configurable: true,
4087
- set(targetElement) {
4088
- if (targetElement === null) {
4089
- this.removeAttribute("popovertarget");
4090
- popoverTargetAssociatedElements.delete(this);
4091
- } else if (!(targetElement instanceof Element)) {
4092
- throw new TypeError(
4093
- `popoverTargetElement must be an element or null`
4094
- );
4095
- } else {
4096
- this.setAttribute("popovertarget", "");
4097
- popoverTargetAssociatedElements.set(this, targetElement);
4098
- }
4099
- },
4100
- get() {
4101
- if (this.localName !== "button" && this.localName !== "input") {
4102
- return null;
4103
- }
4104
- if (this.localName === "input" && this.type !== "reset" && this.type !== "image" && this.type !== "button") {
4105
- return null;
4106
- }
4107
- if (this.disabled) {
4108
- return null;
4109
- }
4110
- if (this.form && this.type === "submit") {
4111
- return null;
4112
- }
4113
- const targetElement = popoverTargetAssociatedElements.get(this);
4114
- if (targetElement && targetElement.isConnected) {
4115
- return targetElement;
4116
- } else if (targetElement && !targetElement.isConnected) {
4117
- popoverTargetAssociatedElements.delete(this);
4118
- return null;
4119
- }
4120
- const root = getRootNode(this);
4121
- const idref = this.getAttribute("popovertarget");
4122
- if ((root instanceof Document || root instanceof ShadowRoot2) && idref) {
4123
- return root.getElementById(idref) || null;
4124
- }
4125
- return null;
4126
- }
4127
- },
4128
- popoverTargetAction: {
4129
- enumerable: true,
4130
- configurable: true,
4131
- get() {
4132
- const value = (this.getAttribute("popovertargetaction") || "").toLowerCase();
4133
- if (value === "show" || value === "hide") return value;
4134
- return "toggle";
4135
- },
4136
- set(value) {
4137
- this.setAttribute("popovertargetaction", value);
4138
- }
4139
- }
4140
- });
4141
- }
4142
- applyPopoverInvokerElementMixin(HTMLButtonElement);
4143
- applyPopoverInvokerElementMixin(HTMLInputElement);
4144
- const handleInvokerActivation = (event) => {
4145
- const composedPath = event.composedPath();
4146
- const target = composedPath[0];
4147
- if (!(target instanceof Element) || target?.shadowRoot) {
4148
- return;
4149
- }
4150
- const root = getRootNode(target);
4151
- if (!(root instanceof ShadowRoot2 || root instanceof Document)) {
4152
- return;
4153
- }
4154
- const invoker = composedPath.find(
4155
- (el) => el.matches?.("[popovertargetaction],[popovertarget]")
4156
- );
4157
- if (invoker) {
4158
- popoverTargetAttributeActivationBehavior(invoker);
4159
- event.preventDefault();
4160
- return;
4161
- }
4162
- };
4163
- const onKeydown = (event) => {
4164
- const key = event.key;
4165
- const target = event.target;
4166
- if (!event.defaultPrevented && target && (key === "Escape" || key === "Esc")) {
4167
- hideAllPopoversUntil(target.ownerDocument, true, true);
4168
- }
4169
- };
4170
- const addEventListeners = (root) => {
4171
- root.addEventListener("click", handleInvokerActivation);
4172
- root.addEventListener("keydown", onKeydown);
4173
- root.addEventListener("pointerdown", lightDismissOpenPopovers);
4174
- root.addEventListener("pointerup", lightDismissOpenPopovers);
4175
- };
4176
- addEventListeners(document);
4177
- injectStyles(document);
4178
- }
4179
-
4180
- const postPopovercontainerCss = "@keyframes popIn{from{transform:scale(0.9);opacity:0;transition-property:transform,opacity,overlay,display;transition-behavior:allow-discrete;transition-duration:var(--post-transition-duration, 0.35s);transition-timing-function:linear(0, 0.007, 0.029 2.2%, 0.118 4.7%, 0.625 14.4%, 0.826 19%, 0.902, 0.962, 1.008 26.1%, 1.041 28.7%, 1.064 32.1%, 1.07 36%, 1.061 40.5%, 1.015 53.4%, 0.999 61.6%, 0.995 71.2%, 1)}to{opacity:1;transform:scale(1)}}@layer polyfill{@supports not selector(:popover-open){[popover]:not(.\\:popover-open){display:none}}}:where(post-popovercontainer){background-color:rgba(0,0,0,0);border:rgba(0,0,0,0);position:fixed;margin:0;padding:0;overflow:visible}:where(post-popovercontainer)>div{box-shadow:var(--post-device-elevation-300);width:max-content;max-width:100%;color:var(--post-current-palette-fg);background-color:var(--post-current-palette-bg);border:2px solid rgba(0,0,0,0);border-radius:4px}:where(post-popovercontainer)>div.animate-pop-in{animation:popIn .25s ease-out forwards}:where(post-popovercontainer)[tooltip]{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);border:0}:where(post-popovercontainer)[safe-space]::after{content:\"\";position:fixed;inset:0;z-index:-1;pointer-events:auto}:where(post-popovercontainer)[safe-space=triangle]::after{clip-path:polygon(var(--post-safe-space-cursor-x, 0) var(--post-safe-space-cursor-y, 0), var(--post-safe-space-popover-x-start, var(--post-safe-space-popover-x, 0)) var(--post-safe-space-popover-y, var(--post-safe-space-popover-y-start, 0)), var(--post-safe-space-popover-x-end, var(--post-safe-space-popover-x, 0)) var(--post-safe-space-popover-y, var(--post-safe-space-popover-y-end, 0)))}:where(post-popovercontainer)[safe-space=trapezoid]::after{clip-path:polygon(var(--post-safe-space-trigger-x-start, var(--post-safe-space-trigger-x, 0)) var(--post-safe-space-trigger-y, var(--post-safe-space-trigger-y-start, 0)), var(--post-safe-space-trigger-x-end, var(--post-safe-space-trigger-x, 0)) var(--post-safe-space-trigger-y, var(--post-safe-space-trigger-y-end, 0)), var(--post-safe-space-popover-x-end, var(--post-safe-space-popover-x, 0)) var(--post-safe-space-popover-y, var(--post-safe-space-popover-y-end, 0)), var(--post-safe-space-popover-x-start, var(--post-safe-space-popover-x, 0)) var(--post-safe-space-popover-y, var(--post-safe-space-popover-y-start, 0)))}:where(post-popovercontainer):not(:has(.arrow))>div{box-shadow:var(--post-device-elevation-300)}:where(post-popovercontainer):has(.arrow)>div{filter:drop-shadow(1px 2px 3px hsla(216, 9%, 11%, 0.15)) drop-shadow(2px 4px 6px hsla(225, 17%, 9%, 0.15)) drop-shadow(4px 8px 12px hsla(225, 7%, 11%, 0.15))}:where(post-popovercontainer):has(.arrow.top)>div{filter:drop-shadow(0px -2px 3px hsla(216, 9%, 11%, 0.15)) drop-shadow(0px -4px 6px hsla(225, 17%, 9%, 0.15)) drop-shadow(0px -8px 12px hsla(225, 7%, 11%, 0.15))}:where(post-popovercontainer):has(.arrow.left)>div{filter:drop-shadow(-2px 0px 3px hsla(216, 9%, 11%, 0.15)) drop-shadow(-4px 0px 6px hsla(225, 17%, 9%, 0.15)) drop-shadow(-8px 0px 12px hsla(225, 7%, 11%, 0.15))}:where(post-popovercontainer):has(.arrow.right)>div{filter:drop-shadow(2px 0px 3px hsla(216, 9%, 11%, 0.15)) drop-shadow(4px 0px 6px hsla(225, 17%, 9%, 0.15)) drop-shadow(8px 0px 12px hsla(225, 7%, 11%, 0.15))}:where(post-popovercontainer) .arrow{position:absolute;width:.5825rem;height:.5825rem;background-color:inherit;rotate:45deg;pointer-events:none;z-index:-1}:where(post-popovercontainer) .arrow.top{border-block-start:2px solid rgba(0,0,0,0);border-inline-start:2px solid rgba(0,0,0,0)}:where(post-popovercontainer) .arrow.right{border-block-start:2px solid rgba(0,0,0,0);border-inline-end:2px solid rgba(0,0,0,0)}:where(post-popovercontainer) .arrow.left{border-block-end:2px solid rgba(0,0,0,0);border-inline-start:2px solid rgba(0,0,0,0)}:where(post-popovercontainer) .arrow.bottom{border-block-end:2px solid rgba(0,0,0,0);border-inline-end:2px solid rgba(0,0,0,0)}";
4181
- const PostPopovercontainerStyle0 = postPopovercontainerCss;
4182
-
4183
- const PostPopovercontainer = class {
4184
- constructor(hostRef) {
4185
- registerInstance(this, hostRef);
4186
- this.postToggle = createEvent(this, "postToggle", 7);
4187
- this.placement = 'top';
4188
- this.edgeGap = 8;
4189
- this.animation = null;
4190
- this.arrow = false;
4191
- this.manualClose = false;
4192
- this.safeSpace = undefined;
4193
- }
4194
- validatePlacement() {
4195
- checkEmptyOrOneOf(this, 'placement', PLACEMENT_TYPES);
4196
- }
4197
- validateEdgeGap() {
4198
- checkEmptyOrType(this, 'edgeGap', 'number');
4199
- }
4200
- validateSafeSpace() {
4201
- checkEmptyOrOneOf(this, 'safeSpace', ['triangle', 'trapezoid']);
4202
- }
4203
- /**
4204
- * Updates cursor position for safe space feature when popover is open.
4205
- * Sets CSS custom properties for dynamic styling of safe area.
4206
- * @param event MouseEvent with cursor position
4207
- */
4208
- mouseTrackingHandler(event) {
4209
- this.host.style.setProperty('--post-safe-space-cursor-x', `${event.clientX}px`);
4210
- this.host.style.setProperty('--post-safe-space-cursor-y', `${event.clientY}px`);
4211
- }
4212
- connectedCallback() {
4213
- if (IS_BROWSER && !isSupported()) {
4214
- apply();
4215
- }
4216
- }
4217
- componentDidLoad() {
4218
- this.host.addEventListener('beforetoggle', this.handleToggle.bind(this));
4219
- }
4220
- disconnectedCallback() {
4221
- if (typeof this.clearAutoUpdate === 'function') {
4222
- this.clearAutoUpdate();
4223
- }
4224
- }
4225
- /**
4226
- * Programmatically display the popovercontainer
4227
- * @param target An element with [data-popover-target="id"] where the popovercontainer should be shown
4228
- */
4229
- async show(target) {
4230
- if (!this.toggleTimeoutId) {
4231
- this.eventTarget = target;
4232
- this.calculatePosition();
4233
- this.host.showPopover();
4234
- }
4235
- }
4236
- /**
4237
- * Programmatically hide the popovercontainer
4238
- */
4239
- async hide() {
4240
- if (!this.toggleTimeoutId) {
4241
- this.eventTarget = null;
4242
- this.host.hidePopover();
4243
- }
4244
- }
4245
- /**
4246
- * Toggle popovercontainer display
4247
- * @param target An element with [data-popover-target="id"] where the popovercontainer should be shown
4248
- * @param force Pass true to always show or false to always hide
4249
- */
4250
- async toggle(target, force) {
4251
- // Prevent instant double toggle
4252
- if (!this.toggleTimeoutId) {
4253
- this.eventTarget = target;
4254
- this.calculatePosition();
4255
- this.host.togglePopover(force);
4256
- this.toggleTimeoutId = null;
4257
- }
4258
- return this.host.matches(':where(:popover-open, .popover-open)');
4259
- }
4260
- /**
4261
- * Start or stop auto updates based on popovercontainer events.
4262
- * Popovercontainers can be closed or opened with other methods than class members,
4263
- * therefore listening to the toggle event is safer for cleaning up.
4264
- * @param e ToggleEvent
4265
- */
4266
- handleToggle(e) {
4267
- this.toggleTimeoutId = window.setTimeout(() => (this.toggleTimeoutId = null), 10);
4268
- const isOpen = e.newState === 'open';
4269
- if (isOpen) {
4270
- this.startAutoupdates();
4271
- if (this.safeSpace)
4272
- window.addEventListener('mousemove', this.mouseTrackingHandler.bind(this));
4273
- }
4274
- else {
4275
- if (typeof this.clearAutoUpdate === 'function')
4276
- this.clearAutoUpdate();
4277
- if (this.safeSpace)
4278
- window.removeEventListener('mousemove', this.mouseTrackingHandler.bind(this));
4279
- }
4280
- this.postToggle.emit(isOpen);
4281
- }
4282
- /**
4283
- * Start listening for DOM updates, scroll events etc. that have
4284
- * an influence on popovercontainer positioning
4285
- */
4286
- startAutoupdates() {
4287
- this.clearAutoUpdate = autoUpdate(this.eventTarget, this.host, this.calculatePosition.bind(this));
4288
- }
4289
- /**
4290
- * Retrieves the dynamic height of the header
4291
- */
4292
- getHeaderHeight() {
4293
- const header = document.querySelector('post-header');
4294
- return header ? parseFloat(getComputedStyle(header).height) : 0;
4295
- }
4296
- async calculatePosition() {
4297
- const { x, y, middlewareData, placement } = await this.computeMainPosition();
4298
- const currentPlacement = placement.split('-')[0];
4299
- // Position popover
4300
- this.host.style.left = `${x}px`;
4301
- this.host.style.top = `${y}px`;
4302
- // Position arrow if enabled
4303
- if (this.arrow && middlewareData.arrow) {
4304
- const { x: arrowX, y: arrowY } = middlewareData.arrow;
4305
- const staticSide = PostPopovercontainer.STATIC_SIDES[currentPlacement];
4306
- if (staticSide) {
4307
- Object.assign(this.arrowRef.style, {
4308
- left: arrowX ? `${arrowX}px` : '',
4309
- top: arrowY ? `${arrowY}px` : '',
4310
- [staticSide]: '-7px',
4311
- });
4312
- }
4313
- }
4314
- // Handle safe space if enabled
4315
- if (this.safeSpace && this.eventTarget) {
4316
- await this.updateSafeSpaceBoundaries(currentPlacement);
4317
- }
4318
- }
4319
- async computeMainPosition() {
4320
- const gap = this.edgeGap;
4321
- const middleware = [
4322
- flip({
4323
- padding: this.getHeaderHeight(),
4324
- }),
4325
- inline(),
4326
- shift({
4327
- padding: gap,
4328
- limiter: limitShift({
4329
- offset: 32,
4330
- }),
4331
- }),
4332
- size({
4333
- apply({ availableWidth, elements }) {
4334
- Object.assign(elements.floating.style, {
4335
- maxWidth: `${availableWidth - gap * 2}px`,
4336
- });
4337
- },
4338
- }),
4339
- offset(this.arrow ? gap + 4 : gap),
4340
- ];
4341
- if (this.arrow) {
4342
- middleware.push(arrow({ element: this.arrowRef, padding: gap }));
4343
- }
4344
- return computePosition(this.eventTarget, this.host, {
4345
- placement: this.placement || 'top',
4346
- strategy: 'fixed',
4347
- middleware,
4348
- });
4349
- }
4350
- async updateSafeSpaceBoundaries(currentPlacement) {
4351
- const targetRect = this.eventTarget.getBoundingClientRect();
4352
- const popoverRect = this.host.getBoundingClientRect();
4353
- const isVertical = currentPlacement === 'top' || currentPlacement === 'bottom';
4354
- // Helper function to get positioning data based on placement
4355
- const getPositioningData = (placement, popoverRect, targetRect) => {
4356
- if (placement === 'top' || placement === 'bottom') {
4357
- return {
4358
- popover: {
4359
- y: placement === 'top' ? popoverRect.bottom : popoverRect.top,
4360
- xStart: popoverRect.left,
4361
- xEnd: popoverRect.right,
4362
- },
4363
- trigger: {
4364
- y: placement === 'top' ? targetRect.top : targetRect.bottom,
4365
- xStart: targetRect.left,
4366
- xEnd: targetRect.right,
4367
- },
4368
- };
4369
- }
4370
- else {
4371
- // left or right
4372
- return {
4373
- popover: {
4374
- x: placement === 'left' ? popoverRect.right : popoverRect.left,
4375
- yStart: popoverRect.top,
4376
- yEnd: popoverRect.bottom,
4377
- },
4378
- trigger: {
4379
- x: placement === 'left' ? targetRect.left : targetRect.right,
4380
- yStart: targetRect.top,
4381
- yEnd: targetRect.bottom,
4382
- },
4383
- };
4384
- }
4385
- };
4386
- const posData = getPositioningData(currentPlacement, popoverRect, targetRect);
4387
- // Clear previous values
4388
- PostPopovercontainer.PROPERTIES_TO_CLEAR.forEach(prop => {
4389
- this.host.style.removeProperty(prop);
4390
- });
4391
- if (isVertical) {
4392
- // For top/bottom placement
4393
- this.host.style.setProperty('--post-safe-space-popover-y', `${posData.popover.y}px`);
4394
- this.host.style.setProperty('--post-safe-space-popover-x-start', `${posData.popover.xStart}px`);
4395
- this.host.style.setProperty('--post-safe-space-popover-x-end', `${posData.popover.xEnd}px`);
4396
- this.host.style.setProperty('--post-safe-space-trigger-y', `${posData.trigger.y}px`);
4397
- this.host.style.setProperty('--post-safe-space-trigger-x-start', `${posData.trigger.xStart}px`);
4398
- this.host.style.setProperty('--post-safe-space-trigger-x-end', `${posData.trigger.xEnd}px`);
4399
- }
4400
- else {
4401
- // For left/right placement
4402
- this.host.style.setProperty('--post-safe-space-popover-x', `${posData.popover.x}px`);
4403
- this.host.style.setProperty('--post-safe-space-popover-y-start', `${posData.popover.yStart}px`);
4404
- this.host.style.setProperty('--post-safe-space-popover-y-end', `${posData.popover.yEnd}px`);
4405
- this.host.style.setProperty('--post-safe-space-trigger-x', `${posData.trigger.x}px`);
4406
- this.host.style.setProperty('--post-safe-space-trigger-y-start', `${posData.trigger.yStart}px`);
4407
- this.host.style.setProperty('--post-safe-space-trigger-y-end', `${posData.trigger.yEnd}px`);
4408
- }
4409
- }
4410
- render() {
4411
- const animationClass = this.animation ? `animate-${this.animation}` : '';
4412
- return (h(Host, { key: 'c5f30bf3c07bbc6af797368b4951c9a1b5d596ef', "data-version": version, popover: this.manualClose ? 'manual' : 'auto' }, h("div", { key: 'afae0976b169831fe49df860d44cd80fa0ae0b3a', class: animationClass }, this.arrow && (h("span", { key: '08e89fda623b139c1b1fba283a9d508757cd1b3d', class: "arrow", ref: el => {
4413
- this.arrowRef = el;
4414
- } })), h("slot", { key: 'fa3f48c319dca350cbd456f2daf8ab5975b99d8f' }))));
4415
- }
4416
- get host() { return getElement(this); }
4417
- static get watchers() { return {
4418
- "placement": ["validatePlacement"],
4419
- "edgeGap": ["validateEdgeGap"],
4420
- "safeSpace": ["validateSafeSpace"]
4421
- }; }
4422
- };
4423
- PostPopovercontainer.STATIC_SIDES = {
4424
- top: 'bottom',
4425
- right: 'left',
4426
- bottom: 'top',
4427
- left: 'right',
4428
- };
4429
- PostPopovercontainer.PROPERTIES_TO_CLEAR = [
4430
- '--post-safe-space-popover-x',
4431
- '--post-safe-space-popover-y',
4432
- '--post-safe-space-popover-x-start',
4433
- '--post-safe-space-popover-x-end',
4434
- '--post-safe-space-popover-y-start',
4435
- '--post-safe-space-popover-y-end',
4436
- '--post-safe-space-trigger-x',
4437
- '--post-safe-space-trigger-y',
4438
- '--post-safe-space-trigger-x-start',
4439
- '--post-safe-space-trigger-x-end',
4440
- '--post-safe-space-trigger-y-start',
4441
- '--post-safe-space-trigger-y-end',
4442
- ];
4443
- PostPopovercontainer.style = PostPopovercontainerStyle0;
4444
-
4445
- const postTogglebuttonCss = ":host{cursor:pointer;outline-offset:var(--post-device-spacing-padding-2) !important;outline:var(--post-scheme-color-interactive-focus-stroke) none var(--post-device-border-width-focus) !important}:host(:focus-visible){outline-style:var(--post-core-border-style-solid) !important}@media (forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){:host(:focus-visible){outline-color:Highlight !important}}:host([aria-pressed=true]) ::slotted([data-showwhen=untoggled]){display:none}:host([aria-pressed=false]) ::slotted([data-showwhen=toggled]){display:none}";
4446
- const PostTogglebuttonStyle0 = postTogglebuttonCss;
4447
-
4448
- const PostTogglebutton = class {
4449
- constructor(hostRef) {
4450
- registerInstance(this, hostRef);
4451
- this.handleClick = () => {
4452
- this.toggled = !this.toggled;
4453
- };
4454
- this.handleKeydown = (event) => {
4455
- // perform a click when enter or spaced are pressed to mimic the button behavior
4456
- if (event.key === 'Enter' || event.key === ' ') {
4457
- event.preventDefault(); // prevents the page from scrolling when space is pressed
4458
- this.host.click();
4459
- }
4460
- };
4461
- this.toggled = false;
4462
- }
4463
- componentWillLoad() {
4464
- // add event listener to not override listener that might be set on the host
4465
- this.host.addEventListener('click', () => this.handleClick());
4466
- this.host.addEventListener('keydown', (e) => this.handleKeydown(e));
4467
- }
4468
- render() {
4469
- return (h(Host, { key: '1025fb988460e85c92e49241889363e1bcc840eb', "data-version": version, role: "button", tabindex: "0", "aria-pressed": this.toggled.toString() }, h("slot", { key: '20d3eb9415685fb9a00a5613474c432f6638692e' })));
4470
- }
4471
- get host() { return getElement(this); }
4472
- };
4473
- PostTogglebutton.style = PostTogglebuttonStyle0;
4474
-
4475
- export { PostClosebutton as P, PostHeader as a, PostIcon as b, PostLanguageOption as c, PostLanguageSwitch as d, PostList as e, PostListItem as f, PostLogo as g, PostMainnavigation as h, PostMegadropdown as i, PostMegadropdownTrigger as j, PostMenu as k, PostMenuTrigger as l, PostPopovercontainer as m, PostTogglebutton as n };