@swisspost/design-system-components 9.0.0-next.31 → 9.0.0-next.33
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/event-guard-efabc84f.js +47 -0
- package/dist/cjs/index.cjs.js +21 -20
- package/dist/cjs/{package-a1fbac54.js → package-3562c265.js} +1 -1
- package/dist/cjs/{post-accordion-b9b8560b.js → post-accordion-6c5681ba.js} +6 -8
- package/dist/cjs/{post-accordion-item-0901683a.js → post-accordion-item-05a78451.js} +7 -7
- package/dist/cjs/post-accordion-item.cjs.entry.js +3 -2
- package/dist/cjs/post-accordion.cjs.entry.js +3 -2
- package/dist/cjs/{post-avatar-cfdfe811.js → post-avatar-6710a77a.js} +1 -1
- package/dist/cjs/post-avatar.cjs.entry.js +2 -2
- package/dist/cjs/post-back-to-top-d0662842.js +96 -0
- package/dist/cjs/post-back-to-top.cjs.entry.js +2 -2
- package/dist/cjs/{post-banner-404dc94a.js → post-banner-bd97db9c.js} +1 -1
- package/dist/cjs/post-banner.cjs.entry.js +2 -2
- package/dist/cjs/{post-breadcrumb-c21c84f4.js → post-breadcrumb-36ab841c.js} +1 -1
- package/dist/cjs/post-breadcrumb-item_2.cjs.entry.js +2 -2
- package/dist/cjs/post-breadcrumb.cjs.entry.js +2 -2
- package/dist/cjs/{post-card-control-a6318276.js → post-card-control-155fb433.js} +1 -1
- package/dist/cjs/post-card-control.cjs.entry.js +2 -2
- package/dist/cjs/post-closebutton_15.cjs.entry.js +3 -2
- package/dist/cjs/{post-collapsible-trigger-be86fb6c.js → post-collapsible-trigger-6601c554.js} +16 -6
- package/dist/cjs/post-collapsible_2.cjs.entry.js +3 -2
- package/dist/cjs/{post-footer-b2d22ab2.js → post-footer-23699aef.js} +1 -1
- package/dist/cjs/post-footer.cjs.entry.js +2 -2
- package/dist/cjs/{post-linkarea-32b1ad0e.js → post-linkarea-8e5e1a9f.js} +1 -1
- package/dist/cjs/post-linkarea.cjs.entry.js +2 -2
- package/dist/cjs/{post-menu-item-de3b5248.js → post-menu-item-8dd94792.js} +1 -1
- package/dist/cjs/{post-popover-18867edc.js → post-popover-858cbd12.js} +1 -1
- package/dist/cjs/post-popover.cjs.entry.js +2 -2
- package/dist/cjs/{post-rating-af90656e.js → post-rating-ef592484.js} +1 -1
- package/dist/cjs/post-rating.cjs.entry.js +2 -2
- package/dist/cjs/{post-tab-header-0204f3de.js → post-tab-header-d785e7fc.js} +1 -1
- package/dist/cjs/post-tab-header.cjs.entry.js +2 -2
- package/dist/cjs/{post-tab-panel-72bc27b9.js → post-tab-panel-41ea371e.js} +1 -1
- package/dist/cjs/post-tab-panel.cjs.entry.js +2 -2
- package/dist/cjs/{post-tabs-fa187aec.js → post-tabs-c6f00130.js} +1 -1
- package/dist/cjs/post-tabs.cjs.entry.js +2 -2
- package/dist/cjs/{post-tag-bbc449d9.js → post-tag-d1a1176c.js} +1 -1
- package/dist/cjs/post-tag.cjs.entry.js +2 -2
- package/dist/cjs/{post-togglebutton-b9e25ee3.js → post-togglebutton-02c56b7b.js} +72 -49
- package/dist/cjs/{post-tooltip-41fd9477.js → post-tooltip-3176e280.js} +1 -1
- package/dist/cjs/post-tooltip.cjs.entry.js +2 -2
- package/dist/collection/components/post-accordion/post-accordion.js +5 -7
- package/dist/collection/components/post-accordion-item/post-accordion-item.js +6 -6
- package/dist/collection/components/post-back-to-top/post-back-to-top.css +1 -1
- package/dist/collection/components/post-back-to-top/post-back-to-top.js +32 -12
- package/dist/collection/components/post-collapsible-trigger/post-collapsible-trigger.js +15 -5
- package/dist/collection/components/post-header/post-header.css +1 -1
- package/dist/collection/components/post-header/post-header.js +12 -6
- package/dist/collection/components/post-icon/post-icon.js +2 -2
- package/dist/collection/components/post-language-switch/post-language-switch.css +1 -1
- package/dist/collection/components/post-language-switch/post-language-switch.js +19 -13
- package/dist/collection/components/post-mainnavigation/post-mainnavigation.css +1 -1
- package/dist/collection/components/post-megadropdown/post-megadropdown.css +1 -1
- package/dist/collection/components/post-megadropdown-trigger/post-megadropdown-trigger.js +13 -6
- package/dist/collection/components/post-menu/post-menu.js +24 -17
- package/dist/collection/utils/event-guard.js +43 -0
- package/dist/components/event-guard.js +45 -0
- package/dist/components/package.js +1 -1
- package/dist/components/post-accordion-item2.js +6 -6
- package/dist/components/post-accordion2.js +5 -7
- package/dist/components/post-back-to-top2.js +33 -13
- package/dist/components/post-collapsible-trigger2.js +15 -5
- package/dist/components/post-header2.js +13 -7
- package/dist/components/post-icon2.js +2 -2
- package/dist/components/post-language-switch2.js +20 -14
- package/dist/components/post-mainnavigation2.js +1 -1
- package/dist/components/post-megadropdown-trigger2.js +13 -6
- package/dist/components/post-megadropdown2.js +1 -1
- package/dist/components/post-menu2.js +24 -17
- package/dist/docs.json +1 -1
- package/dist/esm/event-guard-538ee077.js +45 -0
- package/dist/esm/index.js +21 -20
- package/dist/esm/package-da68ab5a.js +3 -0
- package/dist/esm/{post-accordion-3cfa5952.js → post-accordion-024451fa.js} +6 -8
- package/dist/esm/{post-accordion-item-3c760745.js → post-accordion-item-19b996d1.js} +7 -7
- package/dist/esm/post-accordion-item.entry.js +3 -2
- package/dist/esm/post-accordion.entry.js +3 -2
- package/dist/esm/{post-avatar-ea5b904a.js → post-avatar-33aed045.js} +1 -1
- package/dist/esm/post-avatar.entry.js +2 -2
- package/dist/esm/post-back-to-top-7dd43c3b.js +94 -0
- package/dist/esm/post-back-to-top.entry.js +2 -2
- package/dist/esm/{post-banner-a55185e3.js → post-banner-28d18721.js} +1 -1
- package/dist/esm/post-banner.entry.js +2 -2
- package/dist/esm/{post-breadcrumb-53aebbe1.js → post-breadcrumb-d86fae7b.js} +1 -1
- package/dist/esm/post-breadcrumb-item_2.entry.js +2 -2
- package/dist/esm/post-breadcrumb.entry.js +2 -2
- package/dist/esm/{post-card-control-667d0db8.js → post-card-control-aa043898.js} +1 -1
- package/dist/esm/post-card-control.entry.js +2 -2
- package/dist/esm/post-closebutton_15.entry.js +3 -2
- package/dist/esm/{post-collapsible-trigger-a8dae8e5.js → post-collapsible-trigger-b1612866.js} +16 -6
- package/dist/esm/post-collapsible_2.entry.js +3 -2
- package/dist/esm/{post-footer-72fa9233.js → post-footer-2ed5e520.js} +1 -1
- package/dist/esm/post-footer.entry.js +2 -2
- package/dist/esm/{post-linkarea-ec7139a7.js → post-linkarea-802bf774.js} +1 -1
- package/dist/esm/post-linkarea.entry.js +2 -2
- package/dist/esm/{post-menu-item-663b69ea.js → post-menu-item-d97611d8.js} +1 -1
- package/dist/esm/{post-popover-33b11e03.js → post-popover-e51a7a18.js} +1 -1
- package/dist/esm/post-popover.entry.js +2 -2
- package/dist/esm/{post-rating-4b878fdb.js → post-rating-e1ac47ce.js} +1 -1
- package/dist/esm/post-rating.entry.js +2 -2
- package/dist/esm/{post-tab-header-cc1a5af4.js → post-tab-header-06dcbf7f.js} +1 -1
- package/dist/esm/post-tab-header.entry.js +2 -2
- package/dist/esm/{post-tab-panel-4d075c9a.js → post-tab-panel-75932601.js} +1 -1
- package/dist/esm/post-tab-panel.entry.js +2 -2
- package/dist/esm/{post-tabs-435d6842.js → post-tabs-3ef2ea23.js} +1 -1
- package/dist/esm/post-tabs.entry.js +2 -2
- package/dist/esm/{post-tag-3302db4b.js → post-tag-a3b989e0.js} +1 -1
- package/dist/esm/post-tag.entry.js +2 -2
- package/dist/esm/{post-togglebutton-fdda47b1.js → post-togglebutton-db251030.js} +72 -49
- package/dist/esm/{post-tooltip-d501e42e.js → post-tooltip-c256d714.js} +1 -1
- package/dist/esm/post-tooltip.entry.js +2 -2
- package/dist/post-components/index.esm.js +1 -1
- package/dist/post-components/p-0889c759.js +1 -0
- package/dist/post-components/{p-66dcff86.js → p-1376c653.js} +1 -1
- package/dist/post-components/{p-dbd973a2.js → p-13835969.js} +1 -1
- package/dist/post-components/p-13fdbaf6.entry.js +1 -0
- package/dist/post-components/{p-8e989dc8.entry.js → p-1e2169ae.entry.js} +1 -1
- package/dist/post-components/p-23e4c270.entry.js +1 -0
- package/dist/post-components/{p-1e3f36d8.js → p-2641e06b.js} +1 -1
- package/dist/post-components/p-2d3b16c7.js +1 -0
- package/dist/post-components/{p-ff87f8cb.js → p-33c35e15.js} +1 -1
- package/dist/post-components/p-3b247d71.entry.js +1 -0
- package/dist/post-components/p-42a5fdf8.js +1 -0
- package/dist/post-components/{p-d9609f91.js → p-4ed7bab6.js} +1 -1
- package/dist/post-components/p-5c518421.js +1 -0
- package/dist/post-components/p-6db1a2e0.entry.js +1 -0
- package/dist/post-components/p-6fe98184.entry.js +1 -0
- package/dist/post-components/p-7d731077.entry.js +1 -0
- package/dist/post-components/p-7ee47334.entry.js +1 -0
- package/dist/post-components/{p-a7ca86ab.js → p-8223e97b.js} +1 -1
- package/dist/post-components/p-8a8376d0.js +1 -0
- package/dist/post-components/p-8bb828cf.entry.js +1 -0
- package/dist/post-components/{p-4dfe5596.js → p-8e55ddd2.js} +1 -1
- package/dist/post-components/{p-f2d8b5b9.js → p-9681efce.js} +1 -1
- package/dist/post-components/p-96a59372.entry.js +1 -0
- package/dist/post-components/p-99c8fd43.entry.js +1 -0
- package/dist/post-components/p-ac042f7a.entry.js +1 -0
- package/dist/post-components/p-c34cacb7.js +1 -0
- package/dist/post-components/{p-b6e2ef6b.js → p-c3a970c5.js} +1 -1
- package/dist/post-components/p-c4651d32.entry.js +1 -0
- package/dist/post-components/p-c9b61d31.entry.js +1 -0
- package/dist/post-components/{p-8a5e87de.js → p-d16dd7f9.js} +1 -1
- package/dist/post-components/p-d81c5908.entry.js +1 -0
- package/dist/post-components/{p-23bbd444.js → p-dbe31632.js} +1 -1
- package/dist/post-components/{p-b3f80a8d.js → p-e2294014.js} +1 -1
- package/dist/post-components/{p-945dfe27.js → p-e8ff8122.js} +1 -1
- package/dist/post-components/p-ed78d04a.entry.js +1 -0
- package/dist/post-components/{p-ff6877b8.js → p-f1c0924a.js} +1 -1
- package/dist/post-components/p-f1db96d0.entry.js +1 -0
- package/dist/post-components/p-f7aa917f.entry.js +1 -0
- package/dist/post-components/p-f96b80cc.entry.js +1 -0
- package/dist/post-components/p-fd78716d.js +1 -0
- package/dist/post-components/post-components.esm.js +1 -1
- package/dist/types/components/post-back-to-top/post-back-to-top.d.ts +3 -1
- package/dist/types/components/post-collapsible-trigger/post-collapsible-trigger.d.ts +5 -0
- package/dist/types/components/post-language-switch/post-language-switch.d.ts +3 -0
- package/dist/types/components/post-megadropdown-trigger/post-megadropdown-trigger.d.ts +2 -0
- package/dist/types/components/post-menu/post-menu.d.ts +1 -0
- package/dist/types/utils/event-guard.d.ts +4 -0
- package/loaders/event-guard.js +45 -0
- package/loaders/package.js +1 -1
- package/loaders/post-accordion-item2.js +6 -6
- package/loaders/post-accordion.js +5 -7
- package/loaders/post-back-to-top.js +33 -13
- package/loaders/post-collapsible-trigger2.js +15 -5
- package/loaders/post-header.js +13 -7
- package/loaders/post-icon2.js +2 -2
- package/loaders/post-language-switch.js +20 -14
- package/loaders/post-mainnavigation.js +1 -1
- package/loaders/post-megadropdown-trigger.js +13 -6
- package/loaders/post-megadropdown.js +1 -1
- package/loaders/post-menu2.js +24 -17
- package/package.json +3 -3
- package/dist/cjs/post-back-to-top-6f1e9011.js +0 -76
- package/dist/esm/package-8a1c1ec5.js +0 -3
- package/dist/esm/post-back-to-top-472452ca.js +0 -74
- package/dist/post-components/p-0c945b7d.js +0 -1
- package/dist/post-components/p-0fc4c0f7.entry.js +0 -1
- package/dist/post-components/p-251361a3.entry.js +0 -1
- package/dist/post-components/p-338e7b28.js +0 -1
- package/dist/post-components/p-37d32092.js +0 -1
- package/dist/post-components/p-44bf0821.entry.js +0 -1
- package/dist/post-components/p-4766cb56.entry.js +0 -1
- package/dist/post-components/p-4859cf12.entry.js +0 -1
- package/dist/post-components/p-5beca2e1.js +0 -1
- package/dist/post-components/p-5c52db92.entry.js +0 -1
- package/dist/post-components/p-5e612dc3.entry.js +0 -1
- package/dist/post-components/p-77a4c79d.js +0 -1
- package/dist/post-components/p-8442e784.entry.js +0 -1
- package/dist/post-components/p-8926be2f.entry.js +0 -1
- package/dist/post-components/p-8b7112e2.js +0 -1
- package/dist/post-components/p-913e3850.entry.js +0 -1
- package/dist/post-components/p-9513a8cc.entry.js +0 -1
- package/dist/post-components/p-9e0a5dee.entry.js +0 -1
- package/dist/post-components/p-a357201d.entry.js +0 -1
- package/dist/post-components/p-ac77dc5d.entry.js +0 -1
- package/dist/post-components/p-b030fea7.entry.js +0 -1
- package/dist/post-components/p-baaa2cdd.entry.js +0 -1
- package/dist/post-components/p-f5f8a7a5.entry.js +0 -1
- package/dist/post-components/p-f9322b9f.entry.js +0 -1
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const postTooltip = require('./post-tooltip-
|
|
5
|
+
const postTooltip = require('./post-tooltip-3176e280.js');
|
|
6
6
|
require('./index-d6bf2c66.js');
|
|
7
|
-
require('./package-
|
|
7
|
+
require('./package-3562c265.js');
|
|
8
8
|
require('./attribute-observer-6d8b886b.js');
|
|
9
9
|
require('./index-23e36ff7.js');
|
|
10
10
|
require('./constants-238701d3.js');
|
|
@@ -2,6 +2,7 @@ import { h, Host } from "@stencil/core";
|
|
|
2
2
|
import { version } from "../../../../package";
|
|
3
3
|
import { HEADING_LEVELS } from "../../types/index";
|
|
4
4
|
import { checkOneOf } from "../../utils/index";
|
|
5
|
+
import { eventGuard } from "../../utils/event-gua"; // Import eventGuard
|
|
5
6
|
/**
|
|
6
7
|
* @slot default - Slot for placing post-accordion-item components.
|
|
7
8
|
*/
|
|
@@ -26,10 +27,7 @@ export class PostAccordion {
|
|
|
26
27
|
this.validateHeadingLevel();
|
|
27
28
|
}
|
|
28
29
|
collapseToggleHandler(event) {
|
|
29
|
-
event
|
|
30
|
-
const toggledItem = event.target;
|
|
31
|
-
const closestParentAccordion = toggledItem.closest('post-accordion');
|
|
32
|
-
if (closestParentAccordion === this.host && toggledItem.localName === 'post-accordion-item') {
|
|
30
|
+
eventGuard(this.host, event, { targetLocalName: 'post-accordion-item', delegatorSelector: 'post-accordion' }, () => {
|
|
33
31
|
const toggledAccordionItem = event.target;
|
|
34
32
|
const isClosing = this.expandedItems.has(toggledAccordionItem);
|
|
35
33
|
if (isClosing) {
|
|
@@ -40,13 +38,13 @@ export class PostAccordion {
|
|
|
40
38
|
}
|
|
41
39
|
if (this.multiple || isClosing)
|
|
42
40
|
return;
|
|
43
|
-
//
|
|
41
|
+
// Close other open accordion items to ensure only one is open at a time
|
|
44
42
|
Array.from(this.expandedItems.values())
|
|
45
43
|
.filter(item => item !== toggledAccordionItem)
|
|
46
44
|
.forEach(item => {
|
|
47
45
|
item.toggle(false);
|
|
48
46
|
});
|
|
49
|
-
}
|
|
47
|
+
});
|
|
50
48
|
}
|
|
51
49
|
/**
|
|
52
50
|
* Toggles the `post-accordion-item` with the given id.
|
|
@@ -92,7 +90,7 @@ export class PostAccordion {
|
|
|
92
90
|
});
|
|
93
91
|
}
|
|
94
92
|
render() {
|
|
95
|
-
return (h(Host, { key: '
|
|
93
|
+
return (h(Host, { key: '80e15cf7835f213cfee1ca7cf83cc2fd24bba3ff', "data-version": version }, h("div", { key: '1cf03d4960115b52394b5cb07cd2286747c728dd', class: "accordion" }, h("slot", { key: 'b94328a45a3cba6a8d3b418061036eb8af2cf027', onSlotchange: () => this.registerAccordionItems() }))));
|
|
96
94
|
}
|
|
97
95
|
static get is() { return "post-accordion"; }
|
|
98
96
|
static get encapsulation() { return "shadow"; }
|
|
@@ -3,6 +3,7 @@ import { version } from "../../../../package";
|
|
|
3
3
|
import { HEADING_LEVELS } from "../../types/index";
|
|
4
4
|
import { checkEmptyOrOneOf } from "../../utils/index";
|
|
5
5
|
import { nanoid } from "nanoid";
|
|
6
|
+
import { eventGuard } from "../../utils/event-gua";
|
|
6
7
|
/**
|
|
7
8
|
* @part button - The pseudo-element, used to override styles on the components internal header `button` element.
|
|
8
9
|
* @part body - The pseudo-element, used to override styles on the components internal `body` element.
|
|
@@ -28,12 +29,11 @@ export class PostAccordionItem {
|
|
|
28
29
|
componentDidLoad() {
|
|
29
30
|
this.validateHeadingLevel();
|
|
30
31
|
}
|
|
31
|
-
//
|
|
32
|
+
// Capture to make sure the "collapsed" property is updated before the event is consumed
|
|
32
33
|
onCollapseToggle(event) {
|
|
33
|
-
|
|
34
|
-
event.target.localName === 'post-accordion-item') {
|
|
34
|
+
eventGuard(this.host, event, { targetLocalName: 'post-collapsible', delegatorSelector: 'post-accordion-item' }, () => {
|
|
35
35
|
this.collapsed = !event.detail;
|
|
36
|
-
}
|
|
36
|
+
});
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
39
|
* Triggers the collapse programmatically.
|
|
@@ -50,10 +50,10 @@ export class PostAccordionItem {
|
|
|
50
50
|
render() {
|
|
51
51
|
const headingLevel = this.host.closest('post-accordion')?.getAttribute('heading-level');
|
|
52
52
|
const HeadingTag = `h${headingLevel ?? this.headingLevel ?? 2}`;
|
|
53
|
-
return (h(Host, { key: '
|
|
53
|
+
return (h(Host, { key: '725d3710f7937f82c2382938d15770001e923b61', id: this.id, "data-version": version }, h("div", { key: '679d25d8278fbf9ae68546ee50c27a86ded95999', part: "accordion-item", class: "accordion-item" }, h("post-collapsible-trigger", { key: '7c2af8dc6a1f5265b4ae2cad066be7d2e0bf6a78', for: `${this.id}--collapse` }, h(HeadingTag, { key: 'a10e59a17fdb272fe6308d2ba98f37f90490fab8', class: "accordion-header", id: `${this.id}--header` }, h("button", { key: 'e2b527850c8342a8adf99453d0ac330b6a94760f', type: "button", class: `accordion-button${this.collapsed ? ' collapsed' : ''}`, part: "button" }, h("span", { key: 'b722a4bc51757546eefa58c7c3ea3a688838298a', class: {
|
|
54
54
|
'logo-container': true,
|
|
55
55
|
'has-image': !!this.slottedLogo,
|
|
56
|
-
} }, h("slot", { key: '
|
|
56
|
+
} }, h("slot", { key: '1a42494db72a7b437b1d98fa2e8159d73ece22fa', name: "logo", onSlotchange: this.onSlotLogoChange.bind(this) })), h("slot", { key: '049865bb25f833780ef8e27fe8477e06476a2427', name: "header" }), h("post-icon", { key: 'da0cf7078e4f51710dbfd39c0afa90465fcb53c6', name: "2051" })))), h("post-collapsible", { key: '7c3b268e34d3e4f52820b11a6c090aefbc16e3b9', id: `${this.id}--collapse`, collapsed: this.collapsed, ref: el => (this.collapsible = el) }, h("div", { key: '993a7fffbccb557aed2842305f3927e5c3b5047a', class: "accordion-body", part: "body" }, h("slot", { key: '580eb87b1cb4f88acd7dddddecaa1c1982b7f6e3' }))))));
|
|
57
57
|
}
|
|
58
58
|
static get is() { return "post-accordion-item"; }
|
|
59
59
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:host{--post-floating-button-
|
|
1
|
+
:host{--post-floating-button-position-top: var(--post-device-position-4);--post-back-to-top-position-top: calc( var(--post-header-height) + var(--post-floating-button-position-top) );--post-back-to-top-elevation: var(--post-device-elevation-300);position:fixed;inset-block-start:var(--post-back-to-top-position-top);inset-inline-end:var(--post-device-position-1)}:host .back-to-top{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;box-shadow:var(--post-back-to-top-elevation);cursor:pointer;border-radius:var(--post-device-border-radius-round);width:var(--post-device-sizing-interactive-button-height-2);height:var(--post-device-sizing-interactive-button-height-2);border:var(--post-device-border-width-default) solid var(--post-scheme-color-interactive-button-secondary-enabled-stroke);color:var(--post-scheme-color-interactive-button-secondary-enabled-fg);background-color:var(--post-scheme-color-interactive-button-secondary-enabled-bg);display:flex;align-items:center;justify-content:center}@media(forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){:host .back-to-top{background-color:ButtonFace !important}:host .back-to-top:hover{background-color:Highlight !important}}:host .back-to-top{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 .back-to-top: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){:host .back-to-top:is(:focus-visible,:has(:focus-visible),.pretend-focus){outline-color:Highlight !important}}@supports not selector(:has(:focus-visible)){:host .back-to-top: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){:host .back-to-top:is(:focus-visible,:focus-within,.pretend-focus){outline-color:Highlight !important}}}:host .back-to-top:hover{border-color:var(--post-scheme-color-interactive-button-secondary-hover-stroke);color:var(--post-scheme-color-interactive-button-secondary-hover-fg);background-color:var(--post-scheme-color-interactive-button-secondary-hover-bg)}@media(forced-colors: active),(-ms-high-contrast: active),(-ms-high-contrast: white-on-black){:host .back-to-top:hover{color:HighlightText !important}}:host .back-to-top post-icon{height:var(--post-device-sizing-interactive-button-icon-3);width:var(--post-device-sizing-interactive-button-icon-3)}:host .visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);border:0}
|
|
@@ -15,7 +15,7 @@ export class PostBackToTop {
|
|
|
15
15
|
handleScroll = () => {
|
|
16
16
|
this.belowFold = this.isBelowFold();
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
/*Watch for changes in belowFold to show/hide the back to top button*/
|
|
19
19
|
watchBelowFold(newValue) {
|
|
20
20
|
if (newValue) {
|
|
21
21
|
slideDown(this.host, this.translateY);
|
|
@@ -27,8 +27,37 @@ export class PostBackToTop {
|
|
|
27
27
|
scrollToTop() {
|
|
28
28
|
window.scrollTo({
|
|
29
29
|
top: 0,
|
|
30
|
+
behavior: 'smooth',
|
|
30
31
|
});
|
|
31
32
|
}
|
|
33
|
+
getSecondPixelValue(parts) {
|
|
34
|
+
for (const part of parts) {
|
|
35
|
+
const pixelValues = part.match(/\b\d+px\b/g);
|
|
36
|
+
if (pixelValues && pixelValues.length > 1) {
|
|
37
|
+
return pixelValues[1];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
animateButton() {
|
|
42
|
+
// Get the back-to-top button top postiion
|
|
43
|
+
const positionTop = window.getComputedStyle(this.host).getPropertyValue('top');
|
|
44
|
+
const buttonElement = this.host.shadowRoot.querySelector('button');
|
|
45
|
+
// Extract the elevation height from the back-to-top button elevation token
|
|
46
|
+
const elevation = getComputedStyle(buttonElement).getPropertyValue('--post-back-to-top-elevation');
|
|
47
|
+
const elevationParts = elevation.split(',');
|
|
48
|
+
const elevationHeight = this.getSecondPixelValue(elevationParts);
|
|
49
|
+
// The translateY is calculated as => -100% (btt button height) - topPosition - elevationHeight
|
|
50
|
+
this.translateY =
|
|
51
|
+
String((-1 * 100) / 100 -
|
|
52
|
+
parseFloat(positionTop.replace('px', '')) -
|
|
53
|
+
parseFloat(elevationHeight.replace('px', ''))) + 'px';
|
|
54
|
+
if (this.belowFold) {
|
|
55
|
+
slideDown(this.host, this.translateY);
|
|
56
|
+
}
|
|
57
|
+
if (!this.belowFold) {
|
|
58
|
+
this.host.style.transform = `translateY(${this.translateY})`;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
32
61
|
// Validate the label
|
|
33
62
|
validateLabel() {
|
|
34
63
|
checkType(this, 'label', 'string');
|
|
@@ -40,23 +69,14 @@ export class PostBackToTop {
|
|
|
40
69
|
}
|
|
41
70
|
componentDidLoad() {
|
|
42
71
|
window.addEventListener('scroll', this.handleScroll, false);
|
|
43
|
-
this.
|
|
44
|
-
.getComputedStyle(this.host)
|
|
45
|
-
.getPropertyValue('--post-floating-button-translate-y');
|
|
46
|
-
if (!this.belowFold) {
|
|
47
|
-
this.host.style.transform = `translateY(${this.translateY})`;
|
|
48
|
-
}
|
|
49
|
-
// Initial load
|
|
50
|
-
if (this.belowFold) {
|
|
51
|
-
slideUp(this.host, this.translateY);
|
|
52
|
-
}
|
|
72
|
+
this.animateButton();
|
|
53
73
|
this.validateLabel();
|
|
54
74
|
}
|
|
55
75
|
disconnectedCallback() {
|
|
56
76
|
window.removeEventListener('scroll', this.handleScroll);
|
|
57
77
|
}
|
|
58
78
|
render() {
|
|
59
|
-
return (h(Host, { key: '
|
|
79
|
+
return (h(Host, { key: '2198e7aaf2259ea49e4d1037770960e010fb33c9', "data-version": version }, h("button", { key: 'f2e5f0dc2ea445a7fdc89171c7ca3a11ff716916', class: "back-to-top", "aria-hidden": this.belowFold ? 'false' : 'true', tabindex: this.belowFold ? '0' : '-1', onClick: this.scrollToTop }, h("post-icon", { key: '1c749482ad6ea4be61f10973197df9b65a949b82', "aria-hidden": "true", name: "3026" }), h("span", { key: '67d90bbcbfa72b9d593e24ba75d78d55e5d78b18', class: "visually-hidden" }, this.label))));
|
|
60
80
|
}
|
|
61
81
|
static get is() { return "post-back-to-top"; }
|
|
62
82
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { version } from "../../../../package";
|
|
2
2
|
import { checkNonEmpty, checkType, debounce, getRoot } from "../../utils/index";
|
|
3
|
+
import { eventGuard } from "../../utils/event-gua";
|
|
3
4
|
export class PostCollapsibleTrigger {
|
|
4
5
|
constructor() {
|
|
5
6
|
this.for = undefined;
|
|
@@ -20,6 +21,8 @@ export class PostCollapsibleTrigger {
|
|
|
20
21
|
* Initiate a mutation observer that updates the trigger whenever necessary
|
|
21
22
|
*/
|
|
22
23
|
connectedCallback() {
|
|
24
|
+
this.root = getRoot(this.host);
|
|
25
|
+
this.root.addEventListener('postToggle', this.handlePostToggle);
|
|
23
26
|
this.observer.observe(this.host, { childList: true, subtree: true });
|
|
24
27
|
}
|
|
25
28
|
/**
|
|
@@ -28,11 +31,6 @@ export class PostCollapsibleTrigger {
|
|
|
28
31
|
*/
|
|
29
32
|
componentWillLoad() {
|
|
30
33
|
this.root = getRoot(this.host);
|
|
31
|
-
this.root.addEventListener('postToggle', (e) => {
|
|
32
|
-
if (!this.trigger || !e.target.isEqualNode(this.collapsible))
|
|
33
|
-
return;
|
|
34
|
-
this.trigger.setAttribute('aria-expanded', `${e.detail}`);
|
|
35
|
-
});
|
|
36
34
|
}
|
|
37
35
|
/**
|
|
38
36
|
* Add the "data-version" to the host element and set the trigger
|
|
@@ -48,6 +46,7 @@ export class PostCollapsibleTrigger {
|
|
|
48
46
|
*/
|
|
49
47
|
disconnectedCallback() {
|
|
50
48
|
this.observer.disconnect();
|
|
49
|
+
this.root.removeEventListener('postToggle', this.handlePostToggle);
|
|
51
50
|
}
|
|
52
51
|
/**
|
|
53
52
|
* Update the "aria-controls" and "aria-expanded" attributes on the trigger button
|
|
@@ -55,6 +54,17 @@ export class PostCollapsibleTrigger {
|
|
|
55
54
|
async update() {
|
|
56
55
|
this.debouncedUpdate();
|
|
57
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Private handler for the 'postToggle' event.
|
|
59
|
+
* This updates the trigger's "aria-expanded" attribute based on the event detail.
|
|
60
|
+
*/
|
|
61
|
+
handlePostToggle(e) {
|
|
62
|
+
eventGuard(this.host, e, { targetLocalName: 'post-collapsible' }, () => {
|
|
63
|
+
if (this.trigger) {
|
|
64
|
+
this.trigger.setAttribute('aria-expanded', `${e.detail}`);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
58
68
|
debouncedUpdate = debounce(() => {
|
|
59
69
|
if (!this.trigger)
|
|
60
70
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
*,::before,::after{box-sizing:border-box}:host{z-index:1020;position:relative;--global-header-top: calc( (var(--global-header-height) - var(--global-header-reduced-height)) * -1 );--local-header-top: calc( -1 * (var(--local-header-height) - var(--main-navigation-height)) + var(--global-header-reduced-height) );--logo-height: calc(var(--global-header-height) - var(--header-scroll-top));--global-controls-top: calc(min((var(--header-scroll-top) / 4), 20px) * -1)}:host:has(.global-sub>*:not(.logo):focus-within),:host:has(.local-sub:focus-within){--global-header-top: 0;--local-header-top: var(--global-header-height);--logo-height: var(--global-header-height);--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(--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(--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(--global-controls-top)}}.align-end{align-items:flex-end}.logo{flex:1 0 auto;height:var(--global-header-height);width:var(--global-header-height);min-height:var(--global-header-reduced-height);align-self:flex-end}@media screen and (min-width: 1024px){.logo{transition:height .2 ease-in-out;height:var(--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(--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(--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(--global-header-height);padding-block:
|
|
1
|
+
*,::before,::after{box-sizing:border-box}:host{z-index:1020;position:relative;--global-header-top: calc( (var(--post-global-header-height) - var(--post-global-header-reduced-height)) * -1 );--local-header-top: calc( -1 * (var(--post-local-header-height) - var(--post-main-navigation-height)) + var(--post-global-header-reduced-height) );--logo-height: calc(var(--post-global-header-height) - var(--post-header-scroll-top));--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){--global-header-top: 0;--local-header-top: var(--post-global-header-height);--logo-height: var(--post-global-header-height);--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(--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(--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(--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(--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(--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}}
|
|
@@ -3,6 +3,7 @@ import { throttle } from "throttle-debounce";
|
|
|
3
3
|
import { version } from "../../../../package";
|
|
4
4
|
import { slideDown, slideUp } from "../../animations/slide";
|
|
5
5
|
import { getFocusableChildren } from "../../utils/get-focusable-children";
|
|
6
|
+
import { eventGuard } from "../../utils/event-gua";
|
|
6
7
|
/**
|
|
7
8
|
* @slot post-logo - Should be used together with the `<post-logo>` component.
|
|
8
9
|
* @slot meta-navigation - Holds an `<ul>` with meta navigation links.
|
|
@@ -122,9 +123,14 @@ export class PostHeader {
|
|
|
122
123
|
});
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
|
-
megedropdownStateHandler(event) {
|
|
126
|
-
this.
|
|
127
|
-
|
|
126
|
+
megedropdownStateHandler = (event) => {
|
|
127
|
+
eventGuard(this.host, event, {
|
|
128
|
+
targetLocalName: 'post-megadropdown',
|
|
129
|
+
delegatorSelector: 'post-header',
|
|
130
|
+
}, () => {
|
|
131
|
+
this.megadropdownOpen = event.detail.isVisible;
|
|
132
|
+
});
|
|
133
|
+
};
|
|
128
134
|
// Get all the focusable elements in the post-header mobile menu
|
|
129
135
|
getFocusableElements() {
|
|
130
136
|
// Get elements in the correct order (different as the DOM order)
|
|
@@ -157,11 +163,11 @@ export class PostHeader {
|
|
|
157
163
|
}
|
|
158
164
|
handleScrollEvent() {
|
|
159
165
|
const scrollTop = this.scrollParent === document.body ? window.scrollY : this.scrollParent.scrollTop;
|
|
160
|
-
|
|
166
|
+
document.documentElement.style.setProperty('--post-header-scroll-top', `${scrollTop}px`);
|
|
161
167
|
}
|
|
162
168
|
updateLocalHeaderHeight() {
|
|
163
169
|
const localHeaderHeight = this.host.shadowRoot.querySelector('.local-header')?.clientHeight || 0;
|
|
164
|
-
|
|
170
|
+
document.documentElement.style.setProperty('--post-local-header-height', `${localHeaderHeight}px`);
|
|
165
171
|
}
|
|
166
172
|
updateScrollParentHeight() {
|
|
167
173
|
this.host.style.setProperty('--header-scroll-parent-height', `${this.scrollParent.clientHeight}px`);
|
|
@@ -236,7 +242,7 @@ export class PostHeader {
|
|
|
236
242
|
return (h("div", { class: navigationClasses.join(' '), style: { '--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" }))))));
|
|
237
243
|
}
|
|
238
244
|
render() {
|
|
239
|
-
return (h(Host, { key: '
|
|
245
|
+
return (h(Host, { key: 'd4e9cc7d4e61f9c6223651b73fdab93e44f868f2', version: version }, h("div", { key: 'be40a49df865621d9a31808d468a2bb342803600', class: "global-header" }, h("div", { key: '776d797b9235211bd283fb0ecb29722f2776f2cd', class: "global-sub" }, h("div", { key: '3e89049f43d0de844674db985c3c9e55d510f054', class: "logo" }, h("slot", { key: 'c96d915df7930d15c316e8761c0cf24ed6b44b95', name: "post-logo" }))), h("div", { key: '8aa06d67efef853e2a913c23703a73e38f2ec779', class: "global-sub" }, this.device === 'desktop' && h("slot", { key: 'cdd0b21cd9c6be0ec5a3aeb29b3b29b3034897a0', name: "meta-navigation" }), h("slot", { key: 'da4c5e8c6db482b031ba3b7ae1cf91f112bda75f', name: "global-controls" }), this.device === 'desktop' && h("slot", { key: '8980fdfa5f5e90d3786b5727ff6a9368dea709c6', name: "post-language-switch" }), h("div", { key: '013e2ad6b5bfd6b61f42b1d6c33c9ac6f0af98c0', onClick: () => this.toggleMobileMenu(), class: "mobile-toggle" }, h("slot", { key: 'cdac00dcf2cfb182bc8cefe0181054fac65c64be', name: "post-togglebutton" })))), h("div", { key: '0bdaa1b3fe2b9a460c7437b950afe8ce4c2237af', class: 'local-header ' + (this.mobileMenuExtended ? 'local-header-mobile-extended' : '') }, h("slot", { key: '1adc944fce891f85deb00dd40ad58dc0402491a9', name: "title" }), h("div", { key: '70f9a42f940b231a6e0dd89ee8e67d34f3b98eb6', class: "local-sub" }, h("slot", { key: 'd0106f5ec6ed548e1dbd5ca7f78b1ac5bcf5d2d4', name: "local-controls" }), h("slot", { key: '62e91cc83b232238ac3dcc1166f4a006754c95c9' })), this.device === 'desktop' && this.renderNavigation()), this.device !== 'desktop' && this.renderNavigation()));
|
|
240
246
|
}
|
|
241
247
|
static get is() { return "post-header"; }
|
|
242
248
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
2
|
import { checkNonEmpty, checkType, checkEmptyOrType, checkEmptyOrOneOf } from "../../utils/index";
|
|
3
3
|
import { version } from "../../../../package";
|
|
4
|
-
const CDN_URL =
|
|
4
|
+
const CDN_URL = `https://unpkg.com/@swisspost/design-system-icons@${version}/public/post-icons/`;
|
|
5
5
|
const ANIMATION_NAMES = [
|
|
6
6
|
'cylon',
|
|
7
7
|
'cylon-vertical',
|
|
@@ -120,7 +120,7 @@ export class PostIcon {
|
|
|
120
120
|
this.validateAnimation();
|
|
121
121
|
}
|
|
122
122
|
render() {
|
|
123
|
-
return (h(Host, { key: '
|
|
123
|
+
return (h(Host, { key: '60f27d2a489e5649aa6ff06a771a146f1b83480d', "data-version": version }, h("span", { key: 'd1e7fe17b1c4b522bf091f248dfe51f838b87896', style: this.getStyles() })));
|
|
124
124
|
}
|
|
125
125
|
static get is() { return "post-icon"; }
|
|
126
126
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
: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
|
|
1
|
+
: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}}
|
|
@@ -3,6 +3,7 @@ import { checkEmptyOrOneOf, checkType } from "../../utils/index";
|
|
|
3
3
|
import { version } from "../../../../package";
|
|
4
4
|
import { SWITCH_VARIANTS } from "./switch-variants";
|
|
5
5
|
import { nanoid } from "nanoid";
|
|
6
|
+
import { eventGuard } from "../../utils/event-gua";
|
|
6
7
|
export class PostLanguageSwitch {
|
|
7
8
|
constructor() {
|
|
8
9
|
this.caption = undefined;
|
|
@@ -30,22 +31,27 @@ export class PostLanguageSwitch {
|
|
|
30
31
|
this.updateChildrenVariant();
|
|
31
32
|
this.updateActiveLanguage();
|
|
32
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Listen for the postChange event and guard it to run only for events originating from a <post-language-option> element.
|
|
36
|
+
*/
|
|
33
37
|
handlePostChange(event) {
|
|
34
|
-
this.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
lang.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
eventGuard(this.host, event, { targetLocalName: 'post-language-option', delegatorSelector: 'post-language-switch' }, () => {
|
|
39
|
+
this.activeLang = event.detail;
|
|
40
|
+
// Update the active state in the children post-language-option components
|
|
41
|
+
this.languageOptions.forEach(lang => {
|
|
42
|
+
if (lang.code && lang.code === this.activeLang) {
|
|
43
|
+
lang.setAttribute('active', '');
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
lang.removeAttribute('active');
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
// Hides the dropdown when an option has been clicked
|
|
50
|
+
if (this.variant === 'menu') {
|
|
51
|
+
const menu = this.host.shadowRoot.querySelector('post-menu');
|
|
52
|
+
menu.hide();
|
|
42
53
|
}
|
|
43
54
|
});
|
|
44
|
-
// Hides the dropdown when an option has been clicked
|
|
45
|
-
if (this.variant === 'menu') {
|
|
46
|
-
const menu = this.host.shadowRoot.querySelector('post-menu');
|
|
47
|
-
menu.hide();
|
|
48
|
-
}
|
|
49
55
|
}
|
|
50
56
|
/**
|
|
51
57
|
* Handles cases where the language switch is being rendered before options are available
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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}post-mainnavigation .back-button post-icon{transform:rotate(180deg)}@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;overflow-x:hidden}post-mainnavigation nav{max-width:100%;background:#fff;max-height:var(--main-navigation-height);user-select:none;transition:margin 250ms cubic-bezier(0.4, 0, 0.2, 1)}post-mainnavigation .left-scroll-button,post-mainnavigation .right-scroll-button{z-index:4;position:absolute;inset-block-end:0;overflow:hidden}post-mainnavigation .left-scroll-button button,post-mainnavigation .right-scroll-button 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;background:#fff;padding:16px;box-shadow:var(--post-device-elevation-500);line-height:100%;height:var(--main-navigation-height)}}@media screen and (min-width: 1024px)and (forced-colors: active),screen and (min-width: 1024px)and (-ms-high-contrast: active),screen and (min-width: 1024px)and (-ms-high-contrast: white-on-black){post-mainnavigation .left-scroll-button button,post-mainnavigation .right-scroll-button button{background-color:ButtonFace !important}post-mainnavigation .left-scroll-button button:hover,post-mainnavigation .right-scroll-button button:hover{background-color:Highlight !important}}@media screen and (min-width: 1024px){post-mainnavigation .left-scroll-button button post-icon,post-mainnavigation .right-scroll-button button post-icon{font-size:1rem}}@media screen and (min-width: 1024px){post-mainnavigation .left-scroll-button.d-none,post-mainnavigation .right-scroll-button.d-none{display:none}}@media screen and (min-width: 1024px){post-mainnavigation .left-scroll-button{inset-inline-start:0;padding-inline-end:2rem}}@media screen and (min-width: 1024px){post-mainnavigation .right-scroll-button{inset-inline-end:0;padding-inline-start:2rem}}@media screen and (min-width: 1024px){post-mainnavigation post-list>[role=list]{flex-direction:row;max-width:100vw}}@media screen and (min-width: 1024px){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(--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 .left-scroll-button,post-mainnavigation .right-scroll-button{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}
|
|
1
|
+
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}post-mainnavigation .back-button post-icon{transform:rotate(180deg)}@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;overflow-x:hidden}post-mainnavigation nav{max-width:100%;background:#fff;max-height:var(--post-main-navigation-height);user-select:none;transition:margin 250ms cubic-bezier(0.4, 0, 0.2, 1)}post-mainnavigation .left-scroll-button,post-mainnavigation .right-scroll-button{z-index:4;position:absolute;inset-block-end:0;overflow:hidden}post-mainnavigation .left-scroll-button button,post-mainnavigation .right-scroll-button 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;background:#fff;padding:16px;box-shadow:var(--post-device-elevation-500);line-height:100%;height:var(--post-main-navigation-height)}}@media screen and (min-width: 1024px)and (forced-colors: active),screen and (min-width: 1024px)and (-ms-high-contrast: active),screen and (min-width: 1024px)and (-ms-high-contrast: white-on-black){post-mainnavigation .left-scroll-button button,post-mainnavigation .right-scroll-button button{background-color:ButtonFace !important}post-mainnavigation .left-scroll-button button:hover,post-mainnavigation .right-scroll-button button:hover{background-color:Highlight !important}}@media screen and (min-width: 1024px){post-mainnavigation .left-scroll-button button post-icon,post-mainnavigation .right-scroll-button button post-icon{font-size:1rem}}@media screen and (min-width: 1024px){post-mainnavigation .left-scroll-button.d-none,post-mainnavigation .right-scroll-button.d-none{display:none}}@media screen and (min-width: 1024px){post-mainnavigation .left-scroll-button{inset-inline-start:0;padding-inline-end:2rem}}@media screen and (min-width: 1024px){post-mainnavigation .right-scroll-button{inset-inline-end:0;padding-inline-start:2rem}}@media screen and (min-width: 1024px){post-mainnavigation post-list>[role=list]{flex-direction:row;max-width:100vw}}@media screen and (min-width: 1024px){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 .left-scroll-button,post-mainnavigation .right-scroll-button{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}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@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(--header-navigation-current-inset);inset-inline:0;height:calc(min(var(--header-scroll-parent-height, 100dvh),100dvh) - var(--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(--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}}
|
|
1
|
+
@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(--header-navigation-current-inset);inset-inline:0;height:calc(min(var(--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}}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { h, Host } from "@stencil/core";
|
|
2
2
|
import { version } from "../../../../package";
|
|
3
3
|
import { checkType } from "../../utils/index";
|
|
4
|
+
import { eventGuard } from "../../utils/event-gua";
|
|
4
5
|
export class PostMegadropdownTrigger {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.for = undefined;
|
|
@@ -47,13 +48,11 @@ export class PostMegadropdownTrigger {
|
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
};
|
|
50
|
-
|
|
51
|
-
this.
|
|
52
|
-
// Check if the mega dropdown attached to the trigger is expanded or not
|
|
53
|
-
document.addEventListener('postToggleMegadropdown', (event) => {
|
|
51
|
+
handleToggleMegadropdown = (event) => {
|
|
52
|
+
eventGuard(this.host, event, { targetLocalName: 'post-megadropdown' }, () => {
|
|
54
53
|
if (event.target.id === this.for) {
|
|
55
54
|
this.ariaExpanded = event.detail.isVisible;
|
|
56
|
-
// Focus on the trigger parent of the dropdown after it's closed if close button had been clicked
|
|
55
|
+
// Focus on the trigger parent of the dropdown after it's closed if the close button had been clicked
|
|
57
56
|
if (this.wasExpanded && !this.ariaExpanded && event.detail.focusParent) {
|
|
58
57
|
setTimeout(() => {
|
|
59
58
|
this.slottedButton?.focus();
|
|
@@ -65,6 +64,11 @@ export class PostMegadropdownTrigger {
|
|
|
65
64
|
}
|
|
66
65
|
}
|
|
67
66
|
});
|
|
67
|
+
};
|
|
68
|
+
componentDidLoad() {
|
|
69
|
+
this.validateControlFor();
|
|
70
|
+
// Check if the mega dropdown attached to the trigger is expanded or not
|
|
71
|
+
document.addEventListener('postToggleMegadropdown', this.handleToggleMegadropdown);
|
|
68
72
|
this.slottedButton = this.host.querySelector('button');
|
|
69
73
|
if (this.slottedButton) {
|
|
70
74
|
this.slottedButton.setAttribute('aria-haspopup', 'menu');
|
|
@@ -77,8 +81,11 @@ export class PostMegadropdownTrigger {
|
|
|
77
81
|
console.warn('No button found within post-megadropdown-trigger');
|
|
78
82
|
}
|
|
79
83
|
}
|
|
84
|
+
disconnectedCallback() {
|
|
85
|
+
document.removeEventListener('postToggleMegadropdown', this.handleToggleMegadropdown);
|
|
86
|
+
}
|
|
80
87
|
render() {
|
|
81
|
-
return (h(Host, { key: '
|
|
88
|
+
return (h(Host, { key: '86b85efede8d9b19f3f0560f500f33f5e172177f', "data-version": version, "tab-index": "-1" }, h("button", { key: '0f810e4c38bc4abf23ac60ab27b36d408e7ced0d' }, h("slot", { key: '2a522ac7e15ef8ac077b73cdebf629b89ea173c6' }))));
|
|
82
89
|
}
|
|
83
90
|
static get is() { return "post-megadropdown-trigger"; }
|
|
84
91
|
static get originalStyleUrls() {
|
|
@@ -2,6 +2,7 @@ import { h, Host, } from "@stencil/core";
|
|
|
2
2
|
import { version } from "../../../../package";
|
|
3
3
|
import { getFocusableChildren } from "../../utils/get-focusable-children";
|
|
4
4
|
import { getRoot } from "../../utils/index";
|
|
5
|
+
import { eventGuard } from "../../utils/event-gua";
|
|
5
6
|
export class PostMenu {
|
|
6
7
|
constructor() {
|
|
7
8
|
this.placement = 'bottom';
|
|
@@ -34,24 +35,12 @@ export class PostMenu {
|
|
|
34
35
|
disconnectedCallback() {
|
|
35
36
|
this.host.removeEventListener('keydown', this.handleKeyDown);
|
|
36
37
|
this.host.removeEventListener('click', this.handleClick);
|
|
38
|
+
this.popoverRef?.removeEventListener('postToggle', this.handlePostToggle);
|
|
37
39
|
}
|
|
38
40
|
componentDidLoad() {
|
|
39
|
-
this.popoverRef
|
|
40
|
-
this.
|
|
41
|
-
|
|
42
|
-
requestAnimationFrame(() => {
|
|
43
|
-
if (this.isVisible) {
|
|
44
|
-
this.lastFocusedElement = this.root.activeElement;
|
|
45
|
-
const menuItems = this.getSlottedItems();
|
|
46
|
-
if (menuItems.length > 0) {
|
|
47
|
-
menuItems[0].focus();
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
else if (this.lastFocusedElement) {
|
|
51
|
-
this.lastFocusedElement.focus();
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
});
|
|
41
|
+
if (this.popoverRef) {
|
|
42
|
+
this.popoverRef.addEventListener('postToggle', this.handlePostToggle);
|
|
43
|
+
}
|
|
55
44
|
}
|
|
56
45
|
/**
|
|
57
46
|
* Toggles the menu visibility based on its current state.
|
|
@@ -98,6 +87,24 @@ export class PostMenu {
|
|
|
98
87
|
this.controlKeyDownHandler(e);
|
|
99
88
|
}
|
|
100
89
|
};
|
|
90
|
+
handlePostToggle = (event) => {
|
|
91
|
+
eventGuard(this.host, event, { targetLocalName: 'post-popovercontainer', delegatorSelector: 'post-menu' }, () => {
|
|
92
|
+
this.isVisible = event.detail;
|
|
93
|
+
this.toggleMenu.emit(this.isVisible);
|
|
94
|
+
requestAnimationFrame(() => {
|
|
95
|
+
if (this.isVisible) {
|
|
96
|
+
this.lastFocusedElement = this.root?.activeElement;
|
|
97
|
+
const menuItems = this.getSlottedItems();
|
|
98
|
+
if (menuItems.length > 0) {
|
|
99
|
+
menuItems[0].focus();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else if (this.lastFocusedElement) {
|
|
103
|
+
this.lastFocusedElement.focus();
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
};
|
|
101
108
|
handleClick = (e) => {
|
|
102
109
|
const target = e.target;
|
|
103
110
|
if (['BUTTON', 'A', 'INPUT', 'SELECT', 'TEXTAREA'].includes(target.tagName)) {
|
|
@@ -152,7 +159,7 @@ export class PostMenu {
|
|
|
152
159
|
.flatMap(el => Array.from(getFocusableChildren(el))));
|
|
153
160
|
}
|
|
154
161
|
render() {
|
|
155
|
-
return (h(Host, { key: '
|
|
162
|
+
return (h(Host, { key: 'a86276a1fefccbb1f2b50f1ad74dd98ddcbdae5d', "data-version": version, role: "menu" }, h("post-popovercontainer", { key: 'a0b2a35714ba370b7a73d92d1d6c036aa7039aea', placement: this.placement, ref: e => (this.popoverRef = e) }, h("div", { key: '98da2e21f8e4b4e02b4c347bc4f9238edc635b77', class: "popover-container", part: "popover-container" }, h("slot", { key: 'd3060c46482c5f3179827b8996a9a4b24abf49fa' })))));
|
|
156
163
|
}
|
|
157
164
|
static get is() { return "post-menu"; }
|
|
158
165
|
static get encapsulation() { return "shadow"; }
|