@swisspost/internet-header 1.12.1 → 1.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs.js +36 -0
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/{klp-widget.controller-59fd5d5e.js → klp-widget.controller-8baf3b8a.js} +12 -14
- package/dist/cjs/klp-widget.controller-8baf3b8a.js.map +1 -0
- package/dist/cjs/post-internet-breadcrumbs-e3ee842c.js +3616 -0
- package/dist/cjs/post-internet-breadcrumbs-e3ee842c.js.map +1 -0
- package/dist/cjs/post-internet-footer-16117586.js +161 -0
- package/dist/cjs/post-internet-footer-16117586.js.map +1 -0
- package/dist/cjs/post-internet-header-08840fbe.js +828 -0
- package/dist/cjs/post-internet-header-08840fbe.js.map +1 -0
- package/dist/cjs/post-klp-login-widget-5380708a.js +63 -0
- package/dist/cjs/post-klp-login-widget-5380708a.js.map +1 -0
- package/dist/cjs/post-klp-login-widget.cjs.entry.js +6 -56
- package/dist/cjs/post-klp-login-widget.cjs.entry.js.map +1 -1
- package/dist/cjs/post-language-switch-422af4d0.js +106 -0
- package/dist/cjs/post-language-switch-422af4d0.js.map +1 -0
- package/dist/cjs/post-language-switch.cjs.entry.js +8 -99
- package/dist/cjs/post-language-switch.cjs.entry.js.map +1 -1
- package/dist/cjs/post-logo-5867ad55.js +25 -0
- package/dist/cjs/post-logo-5867ad55.js.map +1 -0
- package/dist/cjs/post-logo.cjs.entry.js +4 -18
- package/dist/cjs/post-logo.cjs.entry.js.map +1 -1
- package/dist/cjs/post-main-navigation-2c9e953e.js +240 -0
- package/dist/cjs/post-main-navigation-2c9e953e.js.map +1 -0
- package/dist/cjs/post-main-navigation.cjs.entry.js +9 -233
- package/dist/cjs/post-main-navigation.cjs.entry.js.map +1 -1
- package/dist/cjs/post-meta-navigation-0b73779f.js +26 -0
- package/dist/cjs/post-meta-navigation-0b73779f.js.map +1 -0
- package/dist/cjs/post-meta-navigation.cjs.entry.js +4 -19
- package/dist/cjs/post-meta-navigation.cjs.entry.js.map +1 -1
- package/dist/cjs/post-search-7eb0a7a2.js +597 -0
- package/dist/cjs/post-search-7eb0a7a2.js.map +1 -0
- package/dist/cjs/post-search.cjs.entry.js +11 -590
- package/dist/cjs/post-search.cjs.entry.js.map +1 -1
- package/dist/cjs/post-skiplinks-3db1d214.js +52 -0
- package/dist/cjs/post-skiplinks-3db1d214.js.map +1 -0
- package/dist/cjs/post-skiplinks.cjs.entry.js +6 -45
- package/dist/cjs/post-skiplinks.cjs.entry.js.map +1 -1
- package/dist/cjs/{svg-sprite.component-4b5677ef.js → svg-sprite.component-68369645.js} +2 -2
- package/dist/cjs/{svg-sprite.component-4b5677ef.js.map → svg-sprite.component-68369645.js.map} +1 -1
- package/dist/cjs/swisspost-internet-breadcrumbs.cjs.entry.js +11 -3609
- package/dist/cjs/swisspost-internet-breadcrumbs.cjs.entry.js.map +1 -1
- package/dist/cjs/swisspost-internet-footer.cjs.entry.js +6 -154
- package/dist/cjs/swisspost-internet-footer.cjs.entry.js.map +1 -1
- package/dist/cjs/swisspost-internet-header.cjs.entry.js +10 -824
- package/dist/cjs/swisspost-internet-header.cjs.entry.js.map +1 -1
- package/dist/collection/assets/js/klp-login-widget.js +11 -13
- package/dist/collection/collection-manifest.json +4 -4
- package/dist/collection/components/post-internet-breadcrumbs/post-internet-breadcrumbs.css +2 -2
- package/dist/collection/components/post-internet-footer/post-internet-footer.css +1 -1
- package/dist/collection/components/post-klp-login-widget/post-klp-login-widget.css +1 -1
- package/dist/collection/components/post-main-navigation/post-main-navigation.css +1 -1
- package/dist/collection/components/post-search/post-search.css +10 -6
- package/dist/collection/index.js +11 -1
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/utils/svg-sprite.component.js +1 -1
- package/dist/collection/utils/svg-sprite.component.js.map +1 -1
- package/dist/components/index.js +10 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/klp-widget.controller.js +11 -13
- package/dist/components/klp-widget.controller.js.map +1 -1
- package/dist/components/post-klp-login-widget2.js +1 -1
- package/dist/components/post-klp-login-widget2.js.map +1 -1
- package/dist/components/post-main-navigation2.js +1 -1
- package/dist/components/post-main-navigation2.js.map +1 -1
- package/dist/components/post-search2.js +1 -1
- package/dist/components/post-search2.js.map +1 -1
- package/dist/components/svg-sprite.component.js +1 -1
- package/dist/components/svg-sprite.component.js.map +1 -1
- package/dist/components/swisspost-internet-breadcrumbs.js +2 -2
- package/dist/components/swisspost-internet-breadcrumbs.js.map +1 -1
- package/dist/components/swisspost-internet-footer.js +2 -2
- package/dist/components/swisspost-internet-footer.js.map +1 -1
- package/dist/components/swisspost-internet-header.js +21 -24
- package/dist/components/swisspost-internet-header.js.map +1 -1
- package/dist/docs.json +11 -11
- package/dist/esm/index.js +21 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/{klp-widget.controller-2a0a5183.js → klp-widget.controller-668f7e8d.js} +12 -14
- package/dist/esm/klp-widget.controller-668f7e8d.js.map +1 -0
- package/dist/esm/post-internet-breadcrumbs-f268030c.js +3614 -0
- package/dist/esm/post-internet-breadcrumbs-f268030c.js.map +1 -0
- package/dist/esm/post-internet-footer-3a501420.js +159 -0
- package/dist/esm/post-internet-footer-3a501420.js.map +1 -0
- package/dist/esm/post-internet-header-36aaba35.js +826 -0
- package/dist/esm/post-internet-header-36aaba35.js.map +1 -0
- package/dist/esm/post-klp-login-widget-57a4fdb5.js +61 -0
- package/dist/esm/post-klp-login-widget-57a4fdb5.js.map +1 -0
- package/dist/esm/post-klp-login-widget.entry.js +5 -59
- package/dist/esm/post-klp-login-widget.entry.js.map +1 -1
- package/dist/esm/post-language-switch-997ee4f9.js +104 -0
- package/dist/esm/post-language-switch-997ee4f9.js.map +1 -0
- package/dist/esm/post-language-switch.entry.js +7 -102
- package/dist/esm/post-language-switch.entry.js.map +1 -1
- package/dist/esm/post-logo-cde3c44d.js +23 -0
- package/dist/esm/post-logo-cde3c44d.js.map +1 -0
- package/dist/esm/post-logo.entry.js +3 -21
- package/dist/esm/post-logo.entry.js.map +1 -1
- package/dist/esm/post-main-navigation-77520c14.js +238 -0
- package/dist/esm/post-main-navigation-77520c14.js.map +1 -0
- package/dist/esm/post-main-navigation.entry.js +8 -236
- package/dist/esm/post-main-navigation.entry.js.map +1 -1
- package/dist/esm/post-meta-navigation-09e9bdc8.js +24 -0
- package/dist/esm/post-meta-navigation-09e9bdc8.js.map +1 -0
- package/dist/esm/post-meta-navigation.entry.js +3 -22
- package/dist/esm/post-meta-navigation.entry.js.map +1 -1
- package/dist/esm/post-search-a7f2e856.js +595 -0
- package/dist/esm/post-search-a7f2e856.js.map +1 -0
- package/dist/esm/post-search.entry.js +10 -593
- package/dist/esm/post-search.entry.js.map +1 -1
- package/dist/esm/post-skiplinks-b3c32a77.js +50 -0
- package/dist/esm/post-skiplinks-b3c32a77.js.map +1 -0
- package/dist/esm/post-skiplinks.entry.js +5 -48
- package/dist/esm/post-skiplinks.entry.js.map +1 -1
- package/dist/esm/{svg-sprite.component-29439a18.js → svg-sprite.component-cfc05f90.js} +2 -2
- package/dist/esm/{svg-sprite.component-29439a18.js.map → svg-sprite.component-cfc05f90.js.map} +1 -1
- package/dist/esm/swisspost-internet-breadcrumbs.entry.js +10 -3612
- package/dist/esm/swisspost-internet-breadcrumbs.entry.js.map +1 -1
- package/dist/esm/swisspost-internet-footer.entry.js +5 -157
- package/dist/esm/swisspost-internet-footer.entry.js.map +1 -1
- package/dist/esm/swisspost-internet-header.entry.js +9 -827
- package/dist/esm/swisspost-internet-header.entry.js.map +1 -1
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{klp-widget.controller-2a0a5183.js → klp-widget.controller-668f7e8d.js} +2 -2
- package/dist/esm-es5/{klp-widget.controller-2a0a5183.js.map → klp-widget.controller-668f7e8d.js.map} +1 -1
- package/dist/esm-es5/post-internet-breadcrumbs-f268030c.js +7 -0
- package/dist/esm-es5/post-internet-breadcrumbs-f268030c.js.map +1 -0
- package/dist/esm-es5/post-internet-footer-3a501420.js +2 -0
- package/dist/esm-es5/post-internet-footer-3a501420.js.map +1 -0
- package/dist/esm-es5/post-internet-header-36aaba35.js +2 -0
- package/dist/esm-es5/post-internet-header-36aaba35.js.map +1 -0
- package/dist/esm-es5/post-klp-login-widget-57a4fdb5.js +2 -0
- package/dist/esm-es5/post-klp-login-widget-57a4fdb5.js.map +1 -0
- package/dist/esm-es5/post-klp-login-widget.entry.js +1 -1
- package/dist/esm-es5/post-klp-login-widget.entry.js.map +1 -1
- package/dist/esm-es5/post-language-switch-997ee4f9.js +2 -0
- package/dist/esm-es5/post-language-switch-997ee4f9.js.map +1 -0
- package/dist/esm-es5/post-language-switch.entry.js +1 -1
- package/dist/esm-es5/post-language-switch.entry.js.map +1 -1
- package/dist/esm-es5/post-logo-cde3c44d.js +2 -0
- package/dist/esm-es5/post-logo-cde3c44d.js.map +1 -0
- package/dist/esm-es5/post-logo.entry.js +1 -1
- package/dist/esm-es5/post-logo.entry.js.map +1 -1
- package/dist/esm-es5/post-main-navigation-77520c14.js +2 -0
- package/dist/esm-es5/post-main-navigation-77520c14.js.map +1 -0
- package/dist/esm-es5/post-main-navigation.entry.js +1 -1
- package/dist/esm-es5/post-main-navigation.entry.js.map +1 -1
- package/dist/esm-es5/post-meta-navigation-09e9bdc8.js +2 -0
- package/dist/esm-es5/post-meta-navigation-09e9bdc8.js.map +1 -0
- package/dist/esm-es5/post-meta-navigation.entry.js +1 -1
- package/dist/esm-es5/post-meta-navigation.entry.js.map +1 -1
- package/dist/esm-es5/post-search-a7f2e856.js +2 -0
- package/dist/esm-es5/post-search-a7f2e856.js.map +1 -0
- package/dist/esm-es5/post-search.entry.js +1 -1
- package/dist/esm-es5/post-search.entry.js.map +1 -1
- package/dist/esm-es5/post-skiplinks-b3c32a77.js +2 -0
- package/dist/esm-es5/post-skiplinks-b3c32a77.js.map +1 -0
- package/dist/esm-es5/post-skiplinks.entry.js +1 -1
- package/dist/esm-es5/post-skiplinks.entry.js.map +1 -1
- package/dist/esm-es5/svg-sprite.component-cfc05f90.js +2 -0
- package/dist/esm-es5/svg-sprite.component-cfc05f90.js.map +1 -0
- package/dist/esm-es5/swisspost-internet-breadcrumbs.entry.js +1 -6
- package/dist/esm-es5/swisspost-internet-breadcrumbs.entry.js.map +1 -1
- package/dist/esm-es5/swisspost-internet-footer.entry.js +1 -1
- package/dist/esm-es5/swisspost-internet-footer.entry.js.map +1 -1
- package/dist/esm-es5/swisspost-internet-header.entry.js +1 -1
- package/dist/esm-es5/swisspost-internet-header.entry.js.map +1 -1
- package/dist/swisspost-internet-header/index.esm.js +1 -1
- package/dist/swisspost-internet-header/{p-f5a1e4a6.entry.js → p-0096509c.js} +2 -2
- package/dist/swisspost-internet-header/p-094eab7e.system.entry.js +2 -0
- package/dist/swisspost-internet-header/p-0f1f2469.system.js +2 -0
- package/dist/swisspost-internet-header/{p-65cd41a6.system.entry.js.map → p-0f1f2469.system.js.map} +1 -1
- package/dist/swisspost-internet-header/p-16676174.system.js +2 -0
- package/dist/swisspost-internet-header/{p-6b18b251.system.entry.js.map → p-16676174.system.js.map} +1 -1
- package/dist/swisspost-internet-header/p-18e9ce89.system.js +2 -0
- package/dist/swisspost-internet-header/{p-c201f1b3.system.entry.js.map → p-18e9ce89.system.js.map} +1 -1
- package/dist/swisspost-internet-header/p-1a6d00a4.system.entry.js +2 -0
- package/dist/swisspost-internet-header/p-1a6d00a4.system.entry.js.map +1 -0
- package/dist/swisspost-internet-header/p-1bdc4b7b.js +2 -0
- package/dist/swisspost-internet-header/{p-b3ad4f8a.entry.js.map → p-1bdc4b7b.js.map} +1 -1
- package/dist/swisspost-internet-header/p-2340f9f1.entry.js +2 -0
- package/dist/swisspost-internet-header/p-2340f9f1.entry.js.map +1 -0
- package/dist/swisspost-internet-header/p-236420dc.js +2 -0
- package/dist/swisspost-internet-header/{p-04b1cab7.entry.js.map → p-236420dc.js.map} +1 -1
- package/dist/swisspost-internet-header/p-2c612086.entry.js +2 -0
- package/dist/swisspost-internet-header/p-2c612086.entry.js.map +1 -0
- package/dist/swisspost-internet-header/p-2eb179a7.entry.js +2 -0
- package/dist/swisspost-internet-header/p-2eb179a7.entry.js.map +1 -0
- package/dist/swisspost-internet-header/{p-a097e677.system.entry.js → p-34fe9d92.system.js} +2 -2
- package/dist/swisspost-internet-header/{p-a097e677.system.entry.js.map → p-34fe9d92.system.js.map} +1 -1
- package/dist/swisspost-internet-header/p-3672587a.entry.js +2 -0
- package/dist/swisspost-internet-header/p-3672587a.entry.js.map +1 -0
- package/dist/swisspost-internet-header/{p-2e334cfc.entry.js → p-3a7f9457.js} +2 -2
- package/dist/swisspost-internet-header/p-3bdf4efd.entry.js +2 -0
- package/dist/swisspost-internet-header/p-3bdf4efd.entry.js.map +1 -0
- package/dist/swisspost-internet-header/p-40806042.system.js +2 -0
- package/dist/swisspost-internet-header/p-40806042.system.js.map +1 -0
- package/dist/swisspost-internet-header/p-4248f499.system.entry.js +2 -0
- package/dist/swisspost-internet-header/p-4248f499.system.entry.js.map +1 -0
- package/dist/swisspost-internet-header/p-46f2c38c.js +2 -0
- package/dist/swisspost-internet-header/{p-069dbe32.entry.js.map → p-46f2c38c.js.map} +1 -1
- package/dist/swisspost-internet-header/p-5adcdd91.system.js +1 -1
- package/dist/swisspost-internet-header/{p-bcd01683.system.js → p-5f246e59.system.js} +2 -2
- package/dist/swisspost-internet-header/{p-bcd01683.system.js.map → p-5f246e59.system.js.map} +1 -1
- package/dist/swisspost-internet-header/p-606bd3f1.entry.js +2 -0
- package/dist/swisspost-internet-header/p-606bd3f1.entry.js.map +1 -0
- package/dist/swisspost-internet-header/p-619bb76e.system.entry.js +2 -0
- package/dist/swisspost-internet-header/p-619bb76e.system.entry.js.map +1 -0
- package/dist/swisspost-internet-header/p-65ce36ba.entry.js +2 -0
- package/dist/swisspost-internet-header/p-65ce36ba.entry.js.map +1 -0
- package/dist/swisspost-internet-header/p-669ed0d2.entry.js +2 -0
- package/dist/swisspost-internet-header/p-669ed0d2.entry.js.map +1 -0
- package/dist/swisspost-internet-header/{p-9d827167.system.entry.js → p-69d380ec.system.js} +2 -2
- package/dist/swisspost-internet-header/{p-9d827167.system.entry.js.map → p-69d380ec.system.js.map} +1 -1
- package/dist/swisspost-internet-header/p-6e3b3c7a.system.js +2 -0
- package/dist/swisspost-internet-header/p-6e3b3c7a.system.js.map +1 -0
- package/dist/swisspost-internet-header/{p-b8368eca.entry.js → p-70df9137.js} +2 -2
- package/dist/swisspost-internet-header/{p-21d8e5bc.entry.js → p-788cf356.js} +2 -2
- package/dist/swisspost-internet-header/{p-21d8e5bc.entry.js.map → p-788cf356.js.map} +1 -1
- package/dist/swisspost-internet-header/{p-61074cb4.entry.js → p-78e8a405.js} +2 -2
- package/dist/swisspost-internet-header/p-7ab3cbcb.js +2 -0
- package/dist/swisspost-internet-header/p-7ab3cbcb.js.map +1 -0
- package/dist/swisspost-internet-header/{p-5a897619.js → p-7eaa5689.js} +2 -2
- package/dist/swisspost-internet-header/{p-5a897619.js.map → p-7eaa5689.js.map} +1 -1
- package/dist/swisspost-internet-header/p-837fe525.system.entry.js +2 -0
- package/dist/swisspost-internet-header/p-837fe525.system.entry.js.map +1 -0
- package/dist/swisspost-internet-header/p-83de3104.system.entry.js +2 -0
- package/dist/swisspost-internet-header/p-83de3104.system.entry.js.map +1 -0
- package/dist/swisspost-internet-header/{p-d2fd2ff6.entry.js → p-8ceafc83.js} +2 -2
- package/dist/swisspost-internet-header/p-8ceafc83.js.map +1 -0
- package/dist/swisspost-internet-header/{p-5ec6e2de.system.entry.js → p-96618f42.system.js} +2 -2
- package/dist/swisspost-internet-header/{p-5ec6e2de.system.entry.js.map → p-96618f42.system.js.map} +1 -1
- package/dist/swisspost-internet-header/p-a0f5c014.system.entry.js +2 -0
- package/dist/swisspost-internet-header/p-a0f5c014.system.entry.js.map +1 -0
- package/dist/swisspost-internet-header/p-a290e3e2.system.entry.js +2 -0
- package/dist/swisspost-internet-header/p-a290e3e2.system.entry.js.map +1 -0
- package/dist/swisspost-internet-header/p-a5eda6dc.entry.js +2 -0
- package/dist/swisspost-internet-header/p-a5eda6dc.entry.js.map +1 -0
- package/dist/swisspost-internet-header/p-bd893111.system.js +7 -0
- package/dist/swisspost-internet-header/{p-50da051d.system.entry.js.map → p-bd893111.system.js.map} +1 -1
- package/dist/swisspost-internet-header/p-c0705313.system.entry.js +2 -0
- package/dist/swisspost-internet-header/p-c0705313.system.entry.js.map +1 -0
- package/dist/swisspost-internet-header/p-c6bf4781.system.entry.js +2 -0
- package/dist/swisspost-internet-header/p-c6bf4781.system.entry.js.map +1 -0
- package/dist/swisspost-internet-header/p-d294420b.system.js +2 -0
- package/dist/swisspost-internet-header/{p-64b3fabe.system.entry.js.map → p-d294420b.system.js.map} +1 -1
- package/dist/swisspost-internet-header/p-e81673c2.entry.js +2 -0
- package/dist/swisspost-internet-header/p-e81673c2.entry.js.map +1 -0
- package/dist/swisspost-internet-header/p-ea99866e.system.js +2 -0
- package/dist/swisspost-internet-header/p-ea99866e.system.js.map +1 -0
- package/dist/swisspost-internet-header/{p-9acc06ba.system.entry.js → p-ee5e0cc6.system.js} +2 -2
- package/dist/swisspost-internet-header/{p-9acc06ba.system.entry.js.map → p-ee5e0cc6.system.js.map} +1 -1
- package/dist/swisspost-internet-header/p-f6a2a74f.js +7 -0
- package/dist/swisspost-internet-header/{p-76e3cd9c.entry.js.map → p-f6a2a74f.js.map} +1 -1
- package/dist/swisspost-internet-header/swisspost-internet-header.css +1 -1
- package/dist/swisspost-internet-header/swisspost-internet-header.esm.js +1 -1
- package/dist/types/index.d.ts +10 -0
- package/package.json +20 -22
- package/dist/cjs/klp-widget.controller-59fd5d5e.js.map +0 -1
- package/dist/esm/klp-widget.controller-2a0a5183.js.map +0 -1
- package/dist/esm-es5/svg-sprite.component-29439a18.js +0 -2
- package/dist/esm-es5/svg-sprite.component-29439a18.js.map +0 -1
- package/dist/swisspost-internet-header/p-04b1cab7.entry.js +0 -2
- package/dist/swisspost-internet-header/p-069dbe32.entry.js +0 -2
- package/dist/swisspost-internet-header/p-50da051d.system.entry.js +0 -7
- package/dist/swisspost-internet-header/p-50ea2036.system.js +0 -2
- package/dist/swisspost-internet-header/p-60ea6000.js +0 -2
- package/dist/swisspost-internet-header/p-60ea6000.js.map +0 -1
- package/dist/swisspost-internet-header/p-62ae68ad.system.entry.js +0 -2
- package/dist/swisspost-internet-header/p-62ae68ad.system.entry.js.map +0 -1
- package/dist/swisspost-internet-header/p-64b3fabe.system.entry.js +0 -2
- package/dist/swisspost-internet-header/p-65cd41a6.system.entry.js +0 -2
- package/dist/swisspost-internet-header/p-6b18b251.system.entry.js +0 -2
- package/dist/swisspost-internet-header/p-74fea9b8.system.js +0 -2
- package/dist/swisspost-internet-header/p-74fea9b8.system.js.map +0 -1
- package/dist/swisspost-internet-header/p-76e3cd9c.entry.js +0 -7
- package/dist/swisspost-internet-header/p-b3ad4f8a.entry.js +0 -2
- package/dist/swisspost-internet-header/p-c201f1b3.system.entry.js +0 -2
- package/dist/swisspost-internet-header/p-d2fd2ff6.entry.js.map +0 -1
- /package/dist/swisspost-internet-header/{p-f5a1e4a6.entry.js.map → p-0096509c.js.map} +0 -0
- /package/dist/swisspost-internet-header/{p-50ea2036.system.js.map → p-094eab7e.system.entry.js.map} +0 -0
- /package/dist/swisspost-internet-header/{p-2e334cfc.entry.js.map → p-3a7f9457.js.map} +0 -0
- /package/dist/swisspost-internet-header/{p-b8368eca.entry.js.map → p-70df9137.js.map} +0 -0
- /package/dist/swisspost-internet-header/{p-61074cb4.entry.js.map → p-78e8a405.js.map} +0 -0
|
@@ -0,0 +1,826 @@
|
|
|
1
|
+
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-2b83f5e9.js';
|
|
2
|
+
import { d as debounce, t as throttle } from './index-d2256e06.js';
|
|
3
|
+
import { g as getUserLang, p as persistLanguageChoice, t as translate } from './language.service-501b09a8.js';
|
|
4
|
+
import { u as uniqueId } from './utils-3a8ff48f.js';
|
|
5
|
+
import { s as state, d as dispose } from './store-80b19c12.js';
|
|
6
|
+
import { S as SvgSprite } from './svg-sprite.component-cfc05f90.js';
|
|
7
|
+
import { S as SvgIcon } from './svg-icon.component-7295f7cc.js';
|
|
8
|
+
import { I as If } from './if.component-3a779aca.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Activate the current route based on the config and the match mode
|
|
12
|
+
* @param config Main Navigation Config
|
|
13
|
+
* @param activeRouteProp Match mode
|
|
14
|
+
* @returns Modified Main Navigation Config
|
|
15
|
+
*/
|
|
16
|
+
const markActiveRoute = (config, activeRouteProp) => {
|
|
17
|
+
// Don't highlight any route
|
|
18
|
+
if (activeRouteProp === false) {
|
|
19
|
+
return config;
|
|
20
|
+
}
|
|
21
|
+
// Set compare URL and check if activeRouteProp is valid
|
|
22
|
+
let compareUrl;
|
|
23
|
+
config = resetOverrideConfig(config);
|
|
24
|
+
if (activeRouteProp === 'auto' || activeRouteProp === 'exact') {
|
|
25
|
+
// Check if an active route is already configured, set override to that and return
|
|
26
|
+
if (hasActivePortalRoute(config)) {
|
|
27
|
+
return resetActiveStateToPortalConfig(config);
|
|
28
|
+
}
|
|
29
|
+
compareUrl = new URL(window.location.href);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
try {
|
|
33
|
+
compareUrl = new URL(activeRouteProp, document.location.origin);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
console.warn(`Active Route: ${activeRouteProp} is not a valid URL. Navigation highlighting has been disabled.`);
|
|
37
|
+
return config;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const scoreList = compileScoreList(config, compareUrl, activeRouteProp);
|
|
41
|
+
if (scoreList.length === 0) {
|
|
42
|
+
// No match found or already active links defined
|
|
43
|
+
return config;
|
|
44
|
+
}
|
|
45
|
+
const winnerPair = scoreList[0];
|
|
46
|
+
winnerPair.main.isActiveOverride = true;
|
|
47
|
+
if (winnerPair.sub)
|
|
48
|
+
winnerPair.sub.isActiveOverride = true;
|
|
49
|
+
return config;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Check if the portal config set any active route
|
|
53
|
+
* @param config Main navigation config
|
|
54
|
+
* @returns True if portal set any route as active
|
|
55
|
+
*/
|
|
56
|
+
const hasActivePortalRoute = (config) => {
|
|
57
|
+
return config.filter(nav => nav.isActive).length > 0;
|
|
58
|
+
};
|
|
59
|
+
const resetActiveStateToPortalConfig = (config) => {
|
|
60
|
+
return config.map(nav => (Object.assign(Object.assign({}, nav), { isActiveOverride: nav.isActive, flyout: nav.flyout.map(flyout => (Object.assign(Object.assign({}, flyout), { linkList: flyout.linkList.map(link => (Object.assign(Object.assign({}, link), { isActiveOverride: link.isActive }))) }))) })));
|
|
61
|
+
};
|
|
62
|
+
const resetOverrideConfig = (config) => {
|
|
63
|
+
return config.map(nav => (Object.assign(Object.assign({}, nav), { isActiveOverride: false, flyout: nav.flyout.map(flyout => (Object.assign(Object.assign({}, flyout), { linkList: flyout.linkList.map(link => (Object.assign(Object.assign({}, link), { isActiveOverride: false }))) }))) })));
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Compile a list of scores based on the map mode, sorted in descending order
|
|
67
|
+
* @param config Main Nav Config
|
|
68
|
+
* @param compareUrl Current Browser URL or a custom URL
|
|
69
|
+
* @param activeRouteProp Match mode
|
|
70
|
+
* @returns A list of scored URLs if any matched
|
|
71
|
+
*/
|
|
72
|
+
const compileScoreList = (config, compareUrl, activeRouteProp) => {
|
|
73
|
+
// Flag to check if the Portal set any active links or if there are any exact matches
|
|
74
|
+
let hadAnyActiveLink = false;
|
|
75
|
+
const scoreList = [];
|
|
76
|
+
config
|
|
77
|
+
.filter(mainNav => !hadAnyActiveLink && mainNav)
|
|
78
|
+
.forEach(mainNav => {
|
|
79
|
+
try {
|
|
80
|
+
const score = compareRoutes(compareUrl, new URL(mainNav.url), activeRouteProp);
|
|
81
|
+
hadAnyActiveLink = updateScoreList(scoreList, score, { main: mainNav, score }, hadAnyActiveLink);
|
|
82
|
+
}
|
|
83
|
+
catch (_a) {
|
|
84
|
+
// Not a valid url, continue
|
|
85
|
+
}
|
|
86
|
+
// Loop through flyout links 2nd level
|
|
87
|
+
mainNav.flyout.forEach(flyout => {
|
|
88
|
+
var _a;
|
|
89
|
+
(_a = flyout.linkList) === null || _a === void 0 ? void 0 : _a.forEach(linklist => {
|
|
90
|
+
// Don't override if any link is already active
|
|
91
|
+
if (linklist.isActive && (activeRouteProp === 'auto' || activeRouteProp === 'exact')) {
|
|
92
|
+
hadAnyActiveLink = true;
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
const url = new URL(linklist.url);
|
|
97
|
+
const score = compareRoutes(compareUrl, url, activeRouteProp);
|
|
98
|
+
hadAnyActiveLink = updateScoreList(scoreList, score, { main: mainNav, sub: linklist, score }, hadAnyActiveLink);
|
|
99
|
+
}
|
|
100
|
+
catch (_a) {
|
|
101
|
+
// Not a valid URL, continue
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
return scoreList.sort((a, b) => b.score - a.score);
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Update score list
|
|
110
|
+
*/
|
|
111
|
+
function updateScoreList(scoreList, score, scoreListItem, hadAnyActiveLink) {
|
|
112
|
+
let hadActiveLink = hadAnyActiveLink;
|
|
113
|
+
if (score > 0) {
|
|
114
|
+
if (score === Infinity)
|
|
115
|
+
hadActiveLink = true;
|
|
116
|
+
// Push score
|
|
117
|
+
scoreList.push(scoreListItem);
|
|
118
|
+
}
|
|
119
|
+
return hadActiveLink;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Compare two URLs for similarity based on a match mode
|
|
123
|
+
* @param baseUrl Browser URL
|
|
124
|
+
* @param compareUrl Navigatgion URL
|
|
125
|
+
* @param matchMode exact or auto matching
|
|
126
|
+
* @returns Score
|
|
127
|
+
*/
|
|
128
|
+
const compareRoutes = (baseUrl, compareUrl, matchMode) => {
|
|
129
|
+
// One url is not defined or they don't share the same orign
|
|
130
|
+
if (baseUrl === null || compareUrl === null || baseUrl.origin !== compareUrl.origin) {
|
|
131
|
+
return 0;
|
|
132
|
+
}
|
|
133
|
+
const baseUrlPath = baseUrl.pathname.toLocaleLowerCase();
|
|
134
|
+
const compareUrlPath = compareUrl.pathname.toLocaleLowerCase();
|
|
135
|
+
// Exact match, origin and pathname are the same
|
|
136
|
+
if (baseUrlPath === compareUrlPath) {
|
|
137
|
+
return Infinity;
|
|
138
|
+
}
|
|
139
|
+
// The basepath is longer than the comparison, a match is impossible
|
|
140
|
+
if (baseUrl.pathname.length < compareUrl.pathname.length) {
|
|
141
|
+
return 0;
|
|
142
|
+
}
|
|
143
|
+
if (matchMode === 'auto') {
|
|
144
|
+
const baseSegments = [
|
|
145
|
+
baseUrl.origin.toLocaleLowerCase(),
|
|
146
|
+
...baseUrlPath.split('/').filter(x => x !== null && x !== ''),
|
|
147
|
+
];
|
|
148
|
+
const compareSegments = [
|
|
149
|
+
compareUrl.origin.toLocaleLowerCase(),
|
|
150
|
+
...compareUrlPath.split('/').filter(x => x !== null && x !== ''),
|
|
151
|
+
];
|
|
152
|
+
const score = getSimilarityScore(baseSegments, compareSegments);
|
|
153
|
+
// If only some segments match, but not the whole smaller array, it's not a match
|
|
154
|
+
return Math.min(baseSegments.length, compareSegments.length) === score ? score : 0;
|
|
155
|
+
}
|
|
156
|
+
return 0;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Check how many items in an array match
|
|
160
|
+
* @param a Base array
|
|
161
|
+
* @param b Compare array
|
|
162
|
+
* @returns Score
|
|
163
|
+
*/
|
|
164
|
+
const getSimilarityScore = (a, b) => {
|
|
165
|
+
if (a == null || b == null || a.length === 0 || b.length === 0) {
|
|
166
|
+
return 0;
|
|
167
|
+
}
|
|
168
|
+
let i = 0;
|
|
169
|
+
for (; i < Math.min(a.length, b.length); i++) {
|
|
170
|
+
if (a[i] !== b[i]) {
|
|
171
|
+
return 0;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return i;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// Prevent double requests
|
|
178
|
+
let request = null;
|
|
179
|
+
// Cache the original os flyout to use it for updates
|
|
180
|
+
let osFlyoutCache = null;
|
|
181
|
+
const getPPMConfig = () => {
|
|
182
|
+
const ppmConfigScript = document.querySelector('#PPM_HEADER_DATA');
|
|
183
|
+
if ((ppmConfigScript === null || ppmConfigScript === void 0 ? void 0 : ppmConfigScript.textContent) != null) {
|
|
184
|
+
return JSON.parse(ppmConfigScript.textContent);
|
|
185
|
+
}
|
|
186
|
+
return null;
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Get a localized config object
|
|
190
|
+
*
|
|
191
|
+
* @param projectId String identifying the project
|
|
192
|
+
* @param language [optional] Preferred language
|
|
193
|
+
* @returns Localized config object
|
|
194
|
+
*/
|
|
195
|
+
const getLocalizedConfig = async ({ projectId, environment, language, cookieKey, localStorageKey, activeRouteProp, localizedCustomConfig, osFlyoutOverrides, }) => {
|
|
196
|
+
var _a, _b;
|
|
197
|
+
const ppmConfig = getPPMConfig();
|
|
198
|
+
let localizedConfig;
|
|
199
|
+
let config = null;
|
|
200
|
+
let lang;
|
|
201
|
+
if (ppmConfig) {
|
|
202
|
+
localizedConfig = ppmConfig;
|
|
203
|
+
lang = document.documentElement.lang;
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
if (request == null) {
|
|
207
|
+
request = fetchConfig(projectId, environment);
|
|
208
|
+
}
|
|
209
|
+
config = await request;
|
|
210
|
+
lang = getUserLang(Object.keys(config), language, localStorageKey, cookieKey);
|
|
211
|
+
if (lang === undefined) {
|
|
212
|
+
throw new Error('Internet Header: unable to determine current language');
|
|
213
|
+
}
|
|
214
|
+
// Clone config for more predictable state updates
|
|
215
|
+
localizedConfig = Object.assign({}, config[lang]);
|
|
216
|
+
}
|
|
217
|
+
// Merge custom config with portal config
|
|
218
|
+
if (localizedCustomConfig) {
|
|
219
|
+
const header = ((_a = localizedCustomConfig === null || localizedCustomConfig === void 0 ? void 0 : localizedCustomConfig.header) === null || _a === void 0 ? void 0 : _a.navMain)
|
|
220
|
+
? Object.assign(Object.assign({}, localizedConfig.header), { navMain: [...localizedConfig.header.navMain, ...localizedCustomConfig.header.navMain] }) : localizedConfig.header;
|
|
221
|
+
localizedConfig = Object.assign(Object.assign({}, localizedConfig), { header });
|
|
222
|
+
}
|
|
223
|
+
// Add entries to flyout_os
|
|
224
|
+
if (osFlyoutOverrides)
|
|
225
|
+
localizedConfig.header.navMain = mergeOsFlyoutOverrides(localizedConfig, osFlyoutOverrides);
|
|
226
|
+
// Mark active route
|
|
227
|
+
if (activeRouteProp != null)
|
|
228
|
+
localizedConfig.header.navMain = markActiveRoute(localizedConfig.header.navMain, activeRouteProp);
|
|
229
|
+
setMainNavigationIds((_b = localizedConfig === null || localizedConfig === void 0 ? void 0 : localizedConfig.header) === null || _b === void 0 ? void 0 : _b.navMain);
|
|
230
|
+
// Set the new language choice
|
|
231
|
+
persistLanguageChoice(lang, cookieKey, localStorageKey);
|
|
232
|
+
return localizedConfig;
|
|
233
|
+
};
|
|
234
|
+
/**
|
|
235
|
+
* Merge portal config with custom os flyout overrides
|
|
236
|
+
* @param config Localized config
|
|
237
|
+
* @param osFlyoutOverrides Overrides for the flyout
|
|
238
|
+
* @returns Merged localized config
|
|
239
|
+
*/
|
|
240
|
+
const mergeOsFlyoutOverrides = (config, osFlyoutOverrides) => {
|
|
241
|
+
if (osFlyoutOverrides == null)
|
|
242
|
+
return config.header.navMain;
|
|
243
|
+
return config.header.navMain.map(mainNav => {
|
|
244
|
+
var _a, _b;
|
|
245
|
+
if (mainNav.id !== 'flyout_os')
|
|
246
|
+
return mainNav;
|
|
247
|
+
if (osFlyoutCache === null) {
|
|
248
|
+
osFlyoutCache = JSON.parse(JSON.stringify(mainNav));
|
|
249
|
+
}
|
|
250
|
+
const mainNavText = (_a = osFlyoutOverrides.text) !== null && _a !== void 0 ? _a : osFlyoutCache.text;
|
|
251
|
+
const mainNavTitle = (_b = osFlyoutOverrides.title) !== null && _b !== void 0 ? _b : osFlyoutCache.title;
|
|
252
|
+
if (osFlyoutCache.flyout == null ||
|
|
253
|
+
osFlyoutCache.flyout.length === 0 ||
|
|
254
|
+
osFlyoutOverrides.flyout == null ||
|
|
255
|
+
osFlyoutOverrides.flyout.length === 0)
|
|
256
|
+
return Object.assign(Object.assign({}, mainNav), { title: mainNavTitle, text: mainNavText });
|
|
257
|
+
// Add entries for os flyout columns without overriding existing config
|
|
258
|
+
const mainNavFlyout = [
|
|
259
|
+
...osFlyoutCache.flyout.map((col, index) => {
|
|
260
|
+
var _a;
|
|
261
|
+
const overrides = osFlyoutOverrides.flyout[index];
|
|
262
|
+
const title = (_a = overrides.title) !== null && _a !== void 0 ? _a : col.title;
|
|
263
|
+
const linkList = overrides.linkList != null ? osFlyoutOverrides.flyout[index].linkList : [];
|
|
264
|
+
return {
|
|
265
|
+
title,
|
|
266
|
+
linkList: [...col.linkList, ...linkList],
|
|
267
|
+
};
|
|
268
|
+
}),
|
|
269
|
+
...osFlyoutOverrides.flyout.slice(osFlyoutCache.flyout.length),
|
|
270
|
+
];
|
|
271
|
+
return Object.assign(Object.assign({}, mainNav), { text: mainNavText, title: mainNavTitle, flyout: mainNavFlyout });
|
|
272
|
+
});
|
|
273
|
+
};
|
|
274
|
+
/**
|
|
275
|
+
* Fetch the general config based on project id
|
|
276
|
+
*
|
|
277
|
+
* @returns Promise for Post Portal general config
|
|
278
|
+
*/
|
|
279
|
+
const fetchConfig = async (projectId, environment) => {
|
|
280
|
+
// Check if project id is sanitized
|
|
281
|
+
if (!isValidProjectId(projectId)) {
|
|
282
|
+
throw new Error(`Internet Header: invalid project id "${projectId}"`);
|
|
283
|
+
}
|
|
284
|
+
if (projectId === 'test') {
|
|
285
|
+
environment = 'int01';
|
|
286
|
+
}
|
|
287
|
+
let url = generateConfigUrl(projectId, environment);
|
|
288
|
+
// Get the config if cache is invalid
|
|
289
|
+
try {
|
|
290
|
+
const res = await fetch(url);
|
|
291
|
+
return (await res.json());
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
throw new Error(`Internet Header: fetching config failed. ${error.message}`);
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* Generate an URL with all necessary query params to get the configuration.
|
|
299
|
+
* Project id "test" will return a test configuration
|
|
300
|
+
* @param projectId string
|
|
301
|
+
* @param environment int01, int02 or prod
|
|
302
|
+
* @returns URL pointing to the project config
|
|
303
|
+
*/
|
|
304
|
+
const generateConfigUrl = (projectId, environment) => {
|
|
305
|
+
if (projectId === 'test')
|
|
306
|
+
return 'assets/config/test-configuration.json';
|
|
307
|
+
const parsedEnvironment = environment.toLowerCase();
|
|
308
|
+
const isProd = parsedEnvironment === 'prod';
|
|
309
|
+
const host = `https://${isProd ? 'www' : 'int'}.post.ch`;
|
|
310
|
+
try {
|
|
311
|
+
// Use URL to validate the generated URL
|
|
312
|
+
return new URL(`${host}/api/headerjs/Json?serviceid=${encodeURIComponent(projectId)}${!isProd ? '&environment=' + parsedEnvironment : ''}`).toString();
|
|
313
|
+
}
|
|
314
|
+
catch (error) {
|
|
315
|
+
throw new Error(`Internet Header: Config URL is invalid.`);
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
/**
|
|
319
|
+
* Check if project id contains only URL safe characters
|
|
320
|
+
*
|
|
321
|
+
* @param projectId Project Id string
|
|
322
|
+
* @returns The valid project id
|
|
323
|
+
*/
|
|
324
|
+
const isValidProjectId = (projectId) => {
|
|
325
|
+
return projectId !== '' && projectId.length > 0 && /^[a-zA-Z][\w-]*[a-zA-Z0-9]$/.test(projectId);
|
|
326
|
+
};
|
|
327
|
+
/**
|
|
328
|
+
* Get the localized config object from a custom config
|
|
329
|
+
*
|
|
330
|
+
* @param config String or json object of the custom config
|
|
331
|
+
* @param language Specific language
|
|
332
|
+
* @returns Localized custom config object
|
|
333
|
+
*/
|
|
334
|
+
const getLocalizedCustomConfig = (config, language) => {
|
|
335
|
+
var _a;
|
|
336
|
+
let customConfig;
|
|
337
|
+
try {
|
|
338
|
+
customConfig = typeof config === 'string' ? JSON.parse(config) : config;
|
|
339
|
+
}
|
|
340
|
+
catch (error) {
|
|
341
|
+
throw new Error(`Internet Header: Custom config is invalid. Make sure your custom config contains valid JSON syntax and matches the definition. `);
|
|
342
|
+
}
|
|
343
|
+
let localizedCustomConfig = customConfig[language];
|
|
344
|
+
if ((_a = localizedCustomConfig === null || localizedCustomConfig === void 0 ? void 0 : localizedCustomConfig.header) === null || _a === void 0 ? void 0 : _a.navMain)
|
|
345
|
+
setMainNavigationIds(localizedCustomConfig.header.navMain);
|
|
346
|
+
return localizedCustomConfig;
|
|
347
|
+
};
|
|
348
|
+
/**
|
|
349
|
+
* Set unique ID's on main navigation entities but conserve flyout_os to be able to
|
|
350
|
+
* identify the online-service flyout, which can be configured by osFlyoutOverrides
|
|
351
|
+
*/
|
|
352
|
+
const setMainNavigationIds = (navMainEntities) => {
|
|
353
|
+
navMainEntities.forEach(navMainEntity => {
|
|
354
|
+
navMainEntity.id = navMainEntity.id === 'flyout_os' ? navMainEntity.id : uniqueId('main-nav-');
|
|
355
|
+
});
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
const name = "@swisspost/internet-header";
|
|
359
|
+
const version = "1.13.1";
|
|
360
|
+
const description = "The header for client facing applications.";
|
|
361
|
+
const author = "Swiss Post <oss@post.ch>";
|
|
362
|
+
const license = "Apache-2.0";
|
|
363
|
+
const repository = {
|
|
364
|
+
type: "git",
|
|
365
|
+
url: "https://github.com/swisspost/design-system.git"
|
|
366
|
+
};
|
|
367
|
+
const homepage = "https://next.design-system.post.ch";
|
|
368
|
+
const bugs = {
|
|
369
|
+
url: "https://github.com/swisspost/design-system/issues"
|
|
370
|
+
};
|
|
371
|
+
const main = "loader/index.cjs.js";
|
|
372
|
+
const module = "loader/index.js";
|
|
373
|
+
const es2017 = "loader/index.es2017.js";
|
|
374
|
+
const types = "loader/index.d.ts";
|
|
375
|
+
const collection = "dist/collection/collection-manifest.json";
|
|
376
|
+
const unpkg = "dist/swisspost-internet-header/swisspost-internet-header.esm.js";
|
|
377
|
+
const publishConfig = {
|
|
378
|
+
access: "public"
|
|
379
|
+
};
|
|
380
|
+
const files = [
|
|
381
|
+
"dist/",
|
|
382
|
+
"loader/"
|
|
383
|
+
];
|
|
384
|
+
const scripts = {
|
|
385
|
+
dev: "stencil build --serve --port 9310 --watch --docs-readme",
|
|
386
|
+
start: "stencil build --watch --docs-readme",
|
|
387
|
+
build: "stencil build --docs-readme",
|
|
388
|
+
clean: "rimraf www dist loader",
|
|
389
|
+
test: "npm run unit",
|
|
390
|
+
unit: "jest",
|
|
391
|
+
"unit:watch": "jest --watch",
|
|
392
|
+
e2e: "cypress run",
|
|
393
|
+
"e2e:watch": "cypress open",
|
|
394
|
+
lint: "eslint src/**/*{.ts,.tsx}",
|
|
395
|
+
"lint:fix": "eslint src/**/*{.ts,.tsx} --fix",
|
|
396
|
+
generate: "stencil generate"
|
|
397
|
+
};
|
|
398
|
+
const dependencies = {
|
|
399
|
+
"@swisspost/design-system-styles": "workspace:6.5.0",
|
|
400
|
+
"body-scroll-lock": "4.0.0-beta.0",
|
|
401
|
+
"iframe-resizer": "4.3.9",
|
|
402
|
+
jquery: "3.7.1",
|
|
403
|
+
tabbable: "6.2.0",
|
|
404
|
+
"throttle-debounce": "5.0.0",
|
|
405
|
+
"url-polyfill": "1.1.12"
|
|
406
|
+
};
|
|
407
|
+
const devDependencies = {
|
|
408
|
+
"@babel/core": "7.23.5",
|
|
409
|
+
"@percy/cli": "1.27.4",
|
|
410
|
+
"@percy/cypress": "3.1.2",
|
|
411
|
+
"@stencil-community/eslint-plugin": "0.7.1",
|
|
412
|
+
"@stencil/core": "4.6.0",
|
|
413
|
+
"@stencil/sass": "3.0.7",
|
|
414
|
+
"@stencil/store": "2.0.11",
|
|
415
|
+
"@types/body-scroll-lock": "3.1.2",
|
|
416
|
+
"@types/iframe-resizer": "3.5.13",
|
|
417
|
+
"@types/jest": "27.5.2",
|
|
418
|
+
"@types/jquery": "3.5.29",
|
|
419
|
+
"@types/node": "18.19.2",
|
|
420
|
+
"@types/throttle-debounce": "5.0.2",
|
|
421
|
+
"babel-loader": "9.1.3",
|
|
422
|
+
bootstrap: "5.3.2",
|
|
423
|
+
cypress: "13.6.0",
|
|
424
|
+
"cypress-each": "1.13.3",
|
|
425
|
+
"cypress-storybook": "0.5.1",
|
|
426
|
+
"eslint-plugin-react": "7.33.2",
|
|
427
|
+
globby: "14.0.0",
|
|
428
|
+
jest: "27.5.1",
|
|
429
|
+
rimraf: "5.0.5",
|
|
430
|
+
"rollup-plugin-node-polyfills": "0.2.1",
|
|
431
|
+
"rollup-plugin-scss": "4.0.0",
|
|
432
|
+
"rollup-plugin-visualizer": "5.10.0",
|
|
433
|
+
sass: "1.69.5",
|
|
434
|
+
"start-server-and-test": "2.0.3",
|
|
435
|
+
"ts-jest": "27.1.5",
|
|
436
|
+
typescript: "4.9.5"
|
|
437
|
+
};
|
|
438
|
+
const packageJson = {
|
|
439
|
+
name: name,
|
|
440
|
+
version: version,
|
|
441
|
+
description: description,
|
|
442
|
+
author: author,
|
|
443
|
+
license: license,
|
|
444
|
+
repository: repository,
|
|
445
|
+
homepage: homepage,
|
|
446
|
+
bugs: bugs,
|
|
447
|
+
main: main,
|
|
448
|
+
module: module,
|
|
449
|
+
es2017: es2017,
|
|
450
|
+
types: types,
|
|
451
|
+
collection: collection,
|
|
452
|
+
"collection:main": "dist/collection/index.js",
|
|
453
|
+
unpkg: unpkg,
|
|
454
|
+
publishConfig: publishConfig,
|
|
455
|
+
files: files,
|
|
456
|
+
scripts: scripts,
|
|
457
|
+
dependencies: dependencies,
|
|
458
|
+
devDependencies: devDependencies
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
const isScrollable = (node) => {
|
|
462
|
+
if (!(node instanceof HTMLElement || node instanceof SVGElement)) {
|
|
463
|
+
return false;
|
|
464
|
+
}
|
|
465
|
+
const style = getComputedStyle(node);
|
|
466
|
+
return ['overflow', 'overflow-x', 'overflow-y'].some(propertyName => {
|
|
467
|
+
const value = style.getPropertyValue(propertyName);
|
|
468
|
+
return value === 'auto' || value === 'scroll';
|
|
469
|
+
});
|
|
470
|
+
};
|
|
471
|
+
const getScrollParent = (node) => {
|
|
472
|
+
let currentParent = node.parentElement;
|
|
473
|
+
while (currentParent) {
|
|
474
|
+
if (isScrollable(currentParent)) {
|
|
475
|
+
return currentParent;
|
|
476
|
+
}
|
|
477
|
+
currentParent = currentParent.parentElement;
|
|
478
|
+
}
|
|
479
|
+
return document;
|
|
480
|
+
};
|
|
481
|
+
|
|
482
|
+
const registerLogoAnimationObserver = (target, headerRef) => {
|
|
483
|
+
const scrollParent = getScrollParent(headerRef);
|
|
484
|
+
/**
|
|
485
|
+
* Set intersection ratio as CSS custom property
|
|
486
|
+
*/
|
|
487
|
+
const handleScroll = () => {
|
|
488
|
+
const fullStickyness = state.stickyness === 'full';
|
|
489
|
+
let scale = 1;
|
|
490
|
+
// Minus 1px border at the bottom that the logo is not covering
|
|
491
|
+
const adjustedHeaderHeight = headerRef.clientHeight - 1;
|
|
492
|
+
const scrollDistance = scrollParent instanceof Element ? scrollParent.scrollTop : scrollParent.documentElement.scrollTop;
|
|
493
|
+
const scrollY = fullStickyness ? 0 : scrollDistance;
|
|
494
|
+
// If meta navigation is not visible (mobile, not configured), scale should just be 1
|
|
495
|
+
if (target.clientHeight > 0) {
|
|
496
|
+
scale = Math.max((adjustedHeaderHeight - Math.max(scrollY, 0)) /
|
|
497
|
+
(adjustedHeaderHeight - target.clientHeight), 1);
|
|
498
|
+
}
|
|
499
|
+
headerRef.style.setProperty('--logo-scale', scale.toString());
|
|
500
|
+
};
|
|
501
|
+
const debounced = debounce(150, handleScroll);
|
|
502
|
+
/**
|
|
503
|
+
* Observe the meta navigation in order to not track scroll events throughout the whole page.
|
|
504
|
+
* This ensures that the scroll listener is only active while the meta navigation is visible.
|
|
505
|
+
*/
|
|
506
|
+
const observer = new IntersectionObserver(entries => {
|
|
507
|
+
entries.forEach(entry => {
|
|
508
|
+
if (entry.isIntersecting && entry.intersectionRatio > 0) {
|
|
509
|
+
scrollParent.addEventListener('scroll', handleScroll, { passive: true });
|
|
510
|
+
window.addEventListener('resize', debounced);
|
|
511
|
+
// Ensure callback is called at least once in case main thread is too busy while scrolling up
|
|
512
|
+
window.requestAnimationFrame(handleScroll);
|
|
513
|
+
}
|
|
514
|
+
else {
|
|
515
|
+
scrollParent.removeEventListener('scroll', handleScroll);
|
|
516
|
+
window.removeEventListener('resize', debounced);
|
|
517
|
+
window.requestAnimationFrame(handleScroll);
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
}, {
|
|
521
|
+
// Fires when element leaves viewport (0) and when it just about enters it (0.001)
|
|
522
|
+
threshold: [0, 0.001],
|
|
523
|
+
});
|
|
524
|
+
observer.observe(target);
|
|
525
|
+
return handleScroll;
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
const postInternetHeaderCss = "@font-face{font-display:swap;font-family:\"Frutiger Neue For Post\";font-weight:700;src:url(\"https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-Bold.woff2\") format(\"woff2\"),url(\"https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-Bold.woff\") format(\"woff\")}@font-face{font-display:swap;font-family:\"Frutiger Neue For Post\";font-weight:700;font-style:italic;src:url(\"https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-BdIt.woff2\") format(\"woff2\"),url(\"https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-BdIt.woff\") format(\"woff\")}@font-face{font-display:swap;font-family:\"Frutiger Neue For Post\";font-weight:400;src:url(\"https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-Rg.woff2\") format(\"woff2\"),url(\"https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-Rg.woff\") format(\"woff\")}@font-face{font-display:swap;font-family:\"Frutiger Neue For Post\";font-weight:400;font-style:italic;src:url(\"https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-It.woff2\") format(\"woff2\"),url(\"https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-It.woff\") format(\"woff\")}@font-face{font-display:swap;font-family:\"Frutiger Neue For Post\";font-weight:300;src:url(\"https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-Lt.woff2\") format(\"woff2\"),url(\"https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-Lt.woff\") format(\"woff\")}@font-face{font-display:swap;font-family:\"Frutiger Neue For Post\";font-weight:300;font-style:italic;src:url(\"https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-LtIt.woff2\") format(\"woff2\"),url(\"https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-LtIt.woff\") format(\"woff\")}.visually-hidden{position:absolute;width:1px;height:1px;border:0;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0)}.btn-blank{background-color:rgba(0,0,0,0);border:none;border-radius:0;padding:0}.nav-link{outline:none;outline-offset:2px;text-decoration:none;color:rgba(0,0,0,.8);-webkit-transition:color 200ms;transition:color 200ms;background-color:rgba(0,0,0,0);-webkit-box-shadow:none;box-shadow:none;border:0;margin:0;cursor:pointer;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;gap:.5rem}.nav-link:is(:focus-visible,:focus-within,.pretend-focus){outline:2px solid var(--post-contrast-color)}.nav-link:hover,.nav-link:focus{color:#000}.nav-link:is(:focus-visible,:focus-within,.pretend-focus){z-index:1;position:relative}.nav-link>svg{width:1.4em;height:1.4em;-ms-flex-negative:0;flex-shrink:0}.nav-link>span{-ms-flex-negative:1;flex-shrink:1}.no-list{list-style:none;padding-left:0;margin-top:0;margin-bottom:0}*,:host,*::before,*::after{-webkit-box-sizing:border-box;box-sizing:border-box}:host{font-family:\"Frutiger Neue For Post\",system-ui,sans-serif}button{font:inherit;padding:0}a,button{border-radius:4px;outline:none;outline-offset:2px}a:is(:focus-visible,:focus-within,.pretend-focus),button:is(:focus-visible,:focus-within,.pretend-focus){outline:2px solid var(--post-contrast-color);border-radius:4px}img,svg{max-width:100%;max-height:100%}@media (forced-colors: active){svg{color:#fff}}.box>*:first-child{margin-top:0}.box>*:last-child{margin-bottom:0}.mirrored{-webkit-transform:scaleX(-1);transform:scaleX(-1)}.rotate-270{-webkit-transform:rotate(270deg);transform:rotate(270deg)}.bold{font-weight:700}.light{font-weight:300}.d-flex{display:-ms-flexbox;display:flex}.d-inline-flex{display:-ms-inline-flexbox;display:inline-flex}.align-items-center{-ms-flex-align:center;align-items:center}@media (min-width: 1441px){.wide-container{margin:0 auto;max-width:1440px}}@media (max-width: 599.98px){.container{padding-right:16px;padding-left:16px}}@media (min-width: 600px)and (max-width: 1023.98px){.container{padding-right:32px;padding-left:32px}}@media (min-width: 1024px){.container{padding-right:40px;padding-left:40px}}@media (max-width: -0.02px){.hidden-xs{display:none}}@media (max-width: 399.98px){.hidden-sm{display:none}}@media (max-width: 599.98px){.hidden-rg{display:none}}@media (max-width: 779.98px){.hidden-md{display:none}}@media (max-width: 1023.98px){.hidden-lg{display:none}}@media (max-width: 1279.98px){.hidden-xl{display:none}}@media (max-width: 1440.98px){.hidden-xxl{display:none}}:host{--logo-scale:1}@media (max-width: 1023.98px){:host{--logo-scale:1 !important}}post-logo{height:var(--header-height);-webkit-transform-origin:bottom left;transform-origin:bottom left;-webkit-transform:scale(var(--logo-scale));transform:scale(var(--logo-scale))}post-main-navigation{margin-left:calc(var(--header-height)*var(--logo-scale) - var(--header-height))}:host{display:block;position:relative;font-size:1rem;font-weight:300;z-index:var(--header-z-index, 10);--header-height:3.5rem;--meta-header-height:0px;--language-dropdown-margin-top:0px}@media (min-width: 1024px){:host{--meta-header-height:3rem;--header-height:4rem}}@media (min-width: 1280px){:host{--header-height:4.5rem}}:host([meta=false]){--meta-header-height:0px;--language-dropdown-margin-top:1px}@supports ((position: -webkit-sticky) or (position: sticky)){:host(:not(.stickyness-none)){position:-webkit-sticky;position:sticky}:host(.stickyness-full){top:0}:host(.stickyness-main){top:calc(var(--meta-header-height, 0px)*-1)}:host(.stickyness-minimal){top:calc((var(--header-height, 0px) + var(--meta-header-height, 0px) + 1px)*-1);-webkit-transition:top 200ms ease-in;transition:top 200ms ease-in}:host(.stickyness-minimal.scrolling-up),:host(.stickyness-minimal.dropdown-open){top:calc(var(--meta-header-height, 0px)*-1);-webkit-transition:top 200ms ease-out;transition:top 200ms ease-out}}.post-internet-header{border-bottom:1px solid #e6e6e6;background-color:#fff}.main-navigation-container{display:-ms-flexbox;display:flex}.main-navigation-container>.main-navigation-controls{-ms-flex:0 0 auto;flex:0 0 auto}.main-navigation{display:-ms-flexbox;display:flex}.sub-navigation-container{position:absolute;top:100%;left:0;width:100%;display:-ms-flexbox;display:flex;background:#fff;visibility:hidden}.main-navigation-item:hover .sub-navigation-container{visibility:visible}.main-navigation-controls{display:-ms-flexbox;display:flex;margin-left:auto}@media (max-width: 1023.98px){.main-navigation-controls{font-weight:400}}@media (min-width: 1024px){.main-navigation-controls{font-size:1.0625rem}}.main-navigation-controls>*{border-left:1px solid #e6e6e6}.menu-button{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;padding:0 calc(1rem - 1px);font-weight:300;cursor:pointer;border-left:1px solid #e6e6e6;-ms-flex-order:1;order:1}@media (min-width: 1024px){.menu-button{display:none}}@media (min-width: 600px)and (max-width: 1023.98px){.menu-button .visually-hidden{position:static;width:auto;height:auto;margin:auto;overflow:visible;clip:auto;visibility:visible;margin-right:.5rem}}.menu-button svg{width:1.5rem;height:1.5rem}.full-width .wide-container{max-width:none}";
|
|
529
|
+
|
|
530
|
+
const PostInternetHeader = class {
|
|
531
|
+
/**
|
|
532
|
+
* Get the currently set language as a two letter string ("de", "fr" "it" or "en")
|
|
533
|
+
* @returns string
|
|
534
|
+
*/
|
|
535
|
+
async getCurrentLanguage() {
|
|
536
|
+
var _a;
|
|
537
|
+
return (_a = state.currentLanguage) !== null && _a !== void 0 ? _a : 'de';
|
|
538
|
+
}
|
|
539
|
+
constructor(hostRef) {
|
|
540
|
+
registerInstance(this, hostRef);
|
|
541
|
+
this.headerLoaded = createEvent(this, "headerLoaded", 7);
|
|
542
|
+
this.lastScrollTop = window.scrollY || document.documentElement.scrollTop;
|
|
543
|
+
this.lastWindowWidth = window.innerWidth;
|
|
544
|
+
this.handleClickOutsideBound = this.handleClickOutside.bind(this);
|
|
545
|
+
this.project = undefined;
|
|
546
|
+
this.stickyness = 'minimal';
|
|
547
|
+
this.language = undefined;
|
|
548
|
+
this.meta = true;
|
|
549
|
+
this.login = true;
|
|
550
|
+
this.search = true;
|
|
551
|
+
this.skiplinks = true;
|
|
552
|
+
this.configProxy = undefined;
|
|
553
|
+
this.environment = 'prod';
|
|
554
|
+
this.languageSwitchOverrides = undefined;
|
|
555
|
+
this.customConfig = undefined;
|
|
556
|
+
this.languageCookieKey = undefined;
|
|
557
|
+
this.languageLocalStorageKey = 'swisspost-internet-header-language';
|
|
558
|
+
this.logoutUrl = undefined;
|
|
559
|
+
this.activeRoute = 'auto';
|
|
560
|
+
this.osFlyoutOverrides = undefined;
|
|
561
|
+
this.fullWidth = false;
|
|
562
|
+
this.activeFlyout = null;
|
|
563
|
+
this.activeDropdownElement = null;
|
|
564
|
+
if (this.project === undefined || this.project === '' || !isValidProjectId(this.project)) {
|
|
565
|
+
throw new Error(`Internet Header project key is "${this.project}". Please provide a valid project key.`);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
connectedCallback() {
|
|
569
|
+
this.throttledScroll = throttle(300, () => this.handleScrollEvent());
|
|
570
|
+
this.debouncedResize = debounce(200, () => this.handleResize());
|
|
571
|
+
}
|
|
572
|
+
disconnectedCallback() {
|
|
573
|
+
this.scrollParent.removeEventListener('scroll', this.throttledScroll);
|
|
574
|
+
this.scrollParent.removeEventListener('resize', this.debouncedResize);
|
|
575
|
+
// Reset the store to its original state
|
|
576
|
+
dispose();
|
|
577
|
+
}
|
|
578
|
+
async componentWillLoad() {
|
|
579
|
+
this.scrollParent = getScrollParent(this.host);
|
|
580
|
+
this.scrollParent.addEventListener('scroll', this.throttledScroll, { passive: true });
|
|
581
|
+
this.scrollParent.addEventListener('resize', this.debouncedResize, { passive: true });
|
|
582
|
+
// Wait for the config to arrive, then render the header
|
|
583
|
+
try {
|
|
584
|
+
state.projectId = this.project;
|
|
585
|
+
state.stickyness = this.stickyness;
|
|
586
|
+
state.environment = this.environment.toLocaleLowerCase();
|
|
587
|
+
if (this.language !== undefined)
|
|
588
|
+
state.currentLanguage = this.language;
|
|
589
|
+
state.languageSwitchOverrides =
|
|
590
|
+
typeof this.languageSwitchOverrides === 'string'
|
|
591
|
+
? JSON.parse(this.languageSwitchOverrides)
|
|
592
|
+
: this.languageSwitchOverrides;
|
|
593
|
+
state.osFlyoutOverrides =
|
|
594
|
+
typeof this.osFlyoutOverrides === 'string'
|
|
595
|
+
? JSON.parse(this.osFlyoutOverrides)
|
|
596
|
+
: this.osFlyoutOverrides;
|
|
597
|
+
if (this.customConfig !== undefined) {
|
|
598
|
+
const langs = Object.keys(typeof this.customConfig === 'string' ? JSON.parse(this.customConfig) : this.customConfig);
|
|
599
|
+
const lang = state.currentLanguage || getUserLang(langs, this.language);
|
|
600
|
+
state.localizedCustomConfig = getLocalizedCustomConfig(this.customConfig, lang);
|
|
601
|
+
}
|
|
602
|
+
state.localizedConfig = await getLocalizedConfig({
|
|
603
|
+
projectId: this.project,
|
|
604
|
+
environment: state.environment,
|
|
605
|
+
language: this.language,
|
|
606
|
+
cookieKey: this.languageCookieKey,
|
|
607
|
+
localStorageKey: this.languageLocalStorageKey,
|
|
608
|
+
activeRouteProp: this.activeRoute,
|
|
609
|
+
localizedCustomConfig: state.localizedCustomConfig,
|
|
610
|
+
osFlyoutOverrides: state.osFlyoutOverrides,
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
catch (error) {
|
|
614
|
+
console.error(error);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
componentDidLoad() {
|
|
618
|
+
window.requestAnimationFrame(() => {
|
|
619
|
+
this.handleResize();
|
|
620
|
+
this.headerLoaded.emit();
|
|
621
|
+
this.host.classList.add('header-loaded');
|
|
622
|
+
if (this.meta && this.metaNav) {
|
|
623
|
+
this.updateLogoAnimation = registerLogoAnimationObserver(this.metaNav, this.host);
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
if (this.stickyness === 'full')
|
|
627
|
+
console.warn('Internet Header: The stickyness="full" option is deprecated.');
|
|
628
|
+
}
|
|
629
|
+
async handleLanguageChange(newValue) {
|
|
630
|
+
state.currentLanguage = newValue;
|
|
631
|
+
state.localizedConfig = await getLocalizedConfig({
|
|
632
|
+
projectId: this.project,
|
|
633
|
+
environment: this.environment,
|
|
634
|
+
language: newValue,
|
|
635
|
+
cookieKey: this.languageCookieKey,
|
|
636
|
+
localStorageKey: this.languageLocalStorageKey,
|
|
637
|
+
activeRouteProp: this.activeRoute,
|
|
638
|
+
localizedCustomConfig: state.localizedCustomConfig,
|
|
639
|
+
osFlyoutOverrides: state.osFlyoutOverrides,
|
|
640
|
+
});
|
|
641
|
+
if (this.customConfig)
|
|
642
|
+
state.localizedCustomConfig = getLocalizedCustomConfig(this.customConfig, newValue);
|
|
643
|
+
}
|
|
644
|
+
handleAvailableLanguagesChange(newValue) {
|
|
645
|
+
state.languageSwitchOverrides = typeof newValue === 'string' ? JSON.parse(newValue) : newValue;
|
|
646
|
+
}
|
|
647
|
+
async handleOsFlyoutOverrides(newValue) {
|
|
648
|
+
state.osFlyoutOverrides = typeof newValue === 'string' ? JSON.parse(newValue) : newValue;
|
|
649
|
+
state.localizedConfig = await getLocalizedConfig({
|
|
650
|
+
projectId: this.project,
|
|
651
|
+
environment: this.environment,
|
|
652
|
+
language: this.language,
|
|
653
|
+
cookieKey: this.languageCookieKey,
|
|
654
|
+
localStorageKey: this.languageLocalStorageKey,
|
|
655
|
+
activeRouteProp: this.activeRoute,
|
|
656
|
+
localizedCustomConfig: state.localizedCustomConfig,
|
|
657
|
+
osFlyoutOverrides: state.osFlyoutOverrides,
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
async handleActiveRouteChange(newValue) {
|
|
661
|
+
state.localizedConfig = await getLocalizedConfig({
|
|
662
|
+
projectId: this.project,
|
|
663
|
+
environment: this.environment,
|
|
664
|
+
language: this.language,
|
|
665
|
+
cookieKey: this.languageCookieKey,
|
|
666
|
+
localStorageKey: this.languageLocalStorageKey,
|
|
667
|
+
activeRouteProp: newValue,
|
|
668
|
+
localizedCustomConfig: state.localizedCustomConfig,
|
|
669
|
+
osFlyoutOverrides: state.osFlyoutOverrides,
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
async handleCustomConfigChange(newValue) {
|
|
673
|
+
if (this.language === undefined)
|
|
674
|
+
return;
|
|
675
|
+
const localizedCustomConfig = getLocalizedCustomConfig(newValue, this.language);
|
|
676
|
+
state.localizedCustomConfig = localizedCustomConfig;
|
|
677
|
+
state.localizedConfig = await getLocalizedConfig({
|
|
678
|
+
projectId: this.project,
|
|
679
|
+
environment: this.environment,
|
|
680
|
+
language: this.language,
|
|
681
|
+
cookieKey: this.languageCookieKey,
|
|
682
|
+
localStorageKey: this.languageLocalStorageKey,
|
|
683
|
+
activeRouteProp: this.activeRoute,
|
|
684
|
+
localizedCustomConfig: localizedCustomConfig,
|
|
685
|
+
osFlyoutOverrides: state.osFlyoutOverrides,
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
handleSearchChange(newValue) {
|
|
689
|
+
state.search = newValue;
|
|
690
|
+
}
|
|
691
|
+
handleLoginChange(newValue) {
|
|
692
|
+
state.login = newValue;
|
|
693
|
+
}
|
|
694
|
+
handleMetaChange(newValue) {
|
|
695
|
+
state.meta = newValue;
|
|
696
|
+
}
|
|
697
|
+
handleLanguageChangeEvent(event) {
|
|
698
|
+
void this.handleLanguageChange(event.detail);
|
|
699
|
+
}
|
|
700
|
+
handleStickynessChange(newValue) {
|
|
701
|
+
state.stickyness = newValue;
|
|
702
|
+
if (typeof this.updateLogoAnimation === 'function')
|
|
703
|
+
this.updateLogoAnimation();
|
|
704
|
+
}
|
|
705
|
+
handleClickOutside(event) {
|
|
706
|
+
// Close active dropdown element on click outside of it
|
|
707
|
+
if (this.activeDropdownElement && !event.composedPath().includes(this.activeDropdownElement)) {
|
|
708
|
+
void this.activeDropdownElement.toggleDropdown(false);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
handleKeyUp(event) {
|
|
712
|
+
if (event.key === 'Escape') {
|
|
713
|
+
if (this.activeDropdownElement) {
|
|
714
|
+
void this.activeDropdownElement.toggleDropdown(false);
|
|
715
|
+
}
|
|
716
|
+
if (this.activeFlyout !== null && this.mainNav) {
|
|
717
|
+
void this.mainNav.toggleDropdown(false);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
handleScrollEvent() {
|
|
722
|
+
// Credits: "https://github.com/qeremy/so/blob/master/so.dom.js#L426"
|
|
723
|
+
const st = this.scrollParent instanceof Document
|
|
724
|
+
? this.scrollParent.documentElement.scrollTop
|
|
725
|
+
: this.scrollParent.scrollTop;
|
|
726
|
+
// Toggle class without re-rendering the component if stickyness is minimal
|
|
727
|
+
// the other stickyness modes do not need the class
|
|
728
|
+
if (this.stickyness === 'minimal') {
|
|
729
|
+
this.host.classList.toggle('scrolling-up', st <= this.lastScrollTop);
|
|
730
|
+
}
|
|
731
|
+
// For Mobile or negative scrolling
|
|
732
|
+
this.lastScrollTop = st <= 0 ? 0 : st;
|
|
733
|
+
}
|
|
734
|
+
handleResize() {
|
|
735
|
+
var _a;
|
|
736
|
+
// Close main navigation dropdown if size changed to bigger than 1024px (search dropdown will be kept open)
|
|
737
|
+
if (this.isMainNavOpen() && this.lastWindowWidth < 1024 && window.innerWidth >= 1024) {
|
|
738
|
+
(_a = this.activeDropdownElement) === null || _a === void 0 ? void 0 : _a.toggleDropdown(false);
|
|
739
|
+
}
|
|
740
|
+
this.lastWindowWidth = window.innerWidth;
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Close open dropdown menus if another is being opened
|
|
744
|
+
*
|
|
745
|
+
* @param event Dropdown toggled event
|
|
746
|
+
* @returns void
|
|
747
|
+
*/
|
|
748
|
+
handleDropdownToggled(event) {
|
|
749
|
+
if (!event.detail.open && this.activeDropdownElement !== event.detail.element) {
|
|
750
|
+
// Some dropdown got closed programmatically (possibly by this function). To prevent
|
|
751
|
+
// a circle or an outdated state, we'll not handle this event
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
if (event.detail.open) {
|
|
755
|
+
if (this.activeDropdownElement) {
|
|
756
|
+
void this.activeDropdownElement.toggleDropdown(false);
|
|
757
|
+
}
|
|
758
|
+
this.activeDropdownElement = event.detail.element;
|
|
759
|
+
if (window.innerWidth >= 1024) {
|
|
760
|
+
// Add event listener to close active dropdown element on click outside of it
|
|
761
|
+
// Also adds 10ms delay in case of an external interaction:
|
|
762
|
+
// Some button on the page calls toggleDropdown() -> dropdown opens
|
|
763
|
+
// Click event bubbles to the window, this.handleClickOutsideBound closes dropdown again
|
|
764
|
+
window.setTimeout(() => {
|
|
765
|
+
window.addEventListener('click', this.handleClickOutsideBound);
|
|
766
|
+
}, 10);
|
|
767
|
+
}
|
|
768
|
+
if (this.activeFlyout !== null && this.mainNav) {
|
|
769
|
+
void this.mainNav.setActiveFlyout(null);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
else {
|
|
773
|
+
this.activeDropdownElement = null;
|
|
774
|
+
// Remove event listener as it is not needed if no dropdown element is active
|
|
775
|
+
window.removeEventListener('click', this.handleClickOutsideBound);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
/**
|
|
779
|
+
* Close open dropdowns if the flyout is being opened
|
|
780
|
+
* @param event Flyout toggle event
|
|
781
|
+
*/
|
|
782
|
+
handleFlyoutToggled(event) {
|
|
783
|
+
this.activeFlyout = event.detail;
|
|
784
|
+
if (this.activeDropdownElement && event.detail && !this.isMainNavOpen()) {
|
|
785
|
+
void this.activeDropdownElement.toggleDropdown(false);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
toggleMobileDropdown() {
|
|
789
|
+
var _a;
|
|
790
|
+
(_a = this.mainNav) === null || _a === void 0 ? void 0 : _a.toggleDropdown();
|
|
791
|
+
}
|
|
792
|
+
isMainNavOpen() {
|
|
793
|
+
return (this.activeDropdownElement && this.activeDropdownElement.tagName === 'POST-MAIN-NAVIGATION');
|
|
794
|
+
}
|
|
795
|
+
render() {
|
|
796
|
+
var _a, _b, _c;
|
|
797
|
+
if (!((_a = state.localizedConfig) === null || _a === void 0 ? void 0 : _a.header)) {
|
|
798
|
+
console.error(new Error('Internet Header: Config cannot be loaded'));
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
const config = state.localizedConfig;
|
|
802
|
+
const renderMetaNavigation = this.meta &&
|
|
803
|
+
config.header.navMeta !== undefined &&
|
|
804
|
+
((_b = config.header.navMeta) === null || _b === void 0 ? void 0 : _b.filter(meta => !meta.isHomeLink).length) > 0;
|
|
805
|
+
const renderLogin = ((_c = this.login) !== null && _c !== void 0 ? _c : !config.header.isLoginWidgetHidden) && config.header.loginWidgetOptions;
|
|
806
|
+
const renderLanguageSwitch = config.header.navLang.length > 1;
|
|
807
|
+
return (h(Host, { class: `stickyness-${this.stickyness} ${Boolean(this.activeDropdownElement) || Boolean(this.activeFlyout) ? 'dropdown-open' : ''}`, "data-version": packageJson.version, onKeyup: (e) => this.handleKeyUp(e) }, h("header", { class: `post-internet-header${this.fullWidth ? ' full-width' : ''}` }, h(SvgSprite, null), h("h1", { class: "visually-hidden" }, translate('Navigate on post.ch')), h(If, { condition: this.skiplinks }, h("post-skiplinks", null)), h(If, { condition: renderMetaNavigation }, h("post-meta-navigation", { orientation: "horizontal", class: "hidden-lg", "full-width": this.fullWidth, ref: el => (this.metaNav = el) }, h(If, { condition: renderLanguageSwitch }, h("post-language-switch", { id: "post-language-switch-desktop", mode: "dropdown", onDropdownToggled: e => this.handleDropdownToggled(e) })))), h("div", { class: "main-navigation-container wide-container" }, h("post-logo", null), h("button", { class: "menu-button nav-link", onClick: () => this.toggleMobileDropdown(), "aria-haspopup": "menu", "aria-controls": "post-internet-header-main-navigation", "aria-expanded": this.activeDropdownElement ? 'true' : 'false' }, h("span", { class: "menu-button-text visually-hidden" }, config.header.mobileMenu.text), h(SvgIcon, { name: this.isMainNavOpen() ? 'pi-close' : 'pi-menu' })), h("post-main-navigation", { onDropdownToggled: e => this.handleDropdownToggled(e), onFlyoutToggled: e => this.handleFlyoutToggled(e), ref: el => (this.mainNav = el) }, h(If, { condition: renderMetaNavigation }, h("post-meta-navigation", { orientation: "vertical" }, h(If, { condition: renderLanguageSwitch }, h("post-language-switch", { id: "post-language-switch-mobile", mode: "list" }))))), h("div", { class: "main-navigation-controls" }, h(If, { condition: this.search }, h("post-search", { onDropdownToggled: e => this.handleDropdownToggled(e) })), h(If, { condition: !!renderLogin }, h("post-klp-login-widget", { "logout-url": this.logoutUrl }, h("slot", { name: "login-widget" }))), h(If, { condition: !renderMetaNavigation && renderLanguageSwitch }, h("post-language-switch", { id: "post-language-switch-no-meta", onDropdownToggled: e => this.handleDropdownToggled(e), mode: "dropdown" })), h("slot", { name: "main" }))))));
|
|
808
|
+
}
|
|
809
|
+
get host() { return getElement(this); }
|
|
810
|
+
static get watchers() { return {
|
|
811
|
+
"language": ["handleLanguageChange"],
|
|
812
|
+
"languageSwitchOverrides": ["handleAvailableLanguagesChange"],
|
|
813
|
+
"osFlyoutOverrides": ["handleOsFlyoutOverrides"],
|
|
814
|
+
"activeRoute": ["handleActiveRouteChange"],
|
|
815
|
+
"customConfig": ["handleCustomConfigChange"],
|
|
816
|
+
"search": ["handleSearchChange"],
|
|
817
|
+
"login": ["handleLoginChange"],
|
|
818
|
+
"meta": ["handleMetaChange"],
|
|
819
|
+
"stickyness": ["handleStickynessChange"]
|
|
820
|
+
}; }
|
|
821
|
+
};
|
|
822
|
+
PostInternetHeader.style = postInternetHeaderCss;
|
|
823
|
+
|
|
824
|
+
export { PostInternetHeader as P };
|
|
825
|
+
|
|
826
|
+
//# sourceMappingURL=post-internet-header-36aaba35.js.map
|