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