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