@swisspost/internet-header 1.9.1 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/dist/cjs/{language.service-9334ca5d.js → language.service-672abba5.js} +2 -2
  2. package/dist/cjs/language.service-672abba5.js.map +1 -0
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/post-klp-login-widget.cjs.entry.js +1 -1
  5. package/dist/cjs/post-klp-login-widget.cjs.entry.js.map +1 -1
  6. package/dist/cjs/post-language-switch.cjs.entry.js +1 -1
  7. package/dist/cjs/post-main-navigation.cjs.entry.js +2 -2
  8. package/dist/cjs/post-main-navigation.cjs.entry.js.map +1 -1
  9. package/dist/cjs/post-search.cjs.entry.js +4 -1
  10. package/dist/cjs/post-search.cjs.entry.js.map +1 -1
  11. package/dist/cjs/post-skiplinks.cjs.entry.js +1 -1
  12. package/dist/cjs/swisspost-internet-breadcrumbs.cjs.entry.js +1328 -8
  13. package/dist/cjs/swisspost-internet-breadcrumbs.cjs.entry.js.map +1 -1
  14. package/dist/cjs/swisspost-internet-footer.cjs.entry.js +2 -2
  15. package/dist/cjs/swisspost-internet-footer.cjs.entry.js.map +1 -1
  16. package/dist/cjs/swisspost-internet-header.cjs.entry.js +65 -35
  17. package/dist/cjs/swisspost-internet-header.cjs.entry.js.map +1 -1
  18. package/dist/cjs/swisspost-internet-header.cjs.js +1 -1
  19. package/dist/collection/components/post-internet-breadcrumbs/post-internet-breadcrumbs.css +35 -27
  20. package/dist/collection/components/post-internet-breadcrumbs/post-internet-breadcrumbs.js +57 -6
  21. package/dist/collection/components/post-internet-breadcrumbs/post-internet-breadcrumbs.js.map +1 -1
  22. package/dist/collection/components/post-internet-footer/post-internet-footer.css +29 -21
  23. package/dist/collection/components/post-internet-header/logo-animation/logo-animation.js +6 -3
  24. package/dist/collection/components/post-internet-header/logo-animation/logo-animation.js.map +1 -1
  25. package/dist/collection/components/post-internet-header/post-internet-header.js +33 -26
  26. package/dist/collection/components/post-internet-header/post-internet-header.js.map +1 -1
  27. package/dist/collection/components/post-klp-login-widget/post-klp-login-widget.css +8 -4
  28. package/dist/collection/components/post-main-navigation/post-main-navigation.css +6 -2
  29. package/dist/collection/components/post-search/post-search.css +119 -564
  30. package/dist/collection/components/post-search/post-search.js +3 -0
  31. package/dist/collection/components/post-search/post-search.js.map +1 -1
  32. package/dist/collection/services/language.service.js +1 -1
  33. package/dist/collection/services/language.service.js.map +1 -1
  34. package/dist/collection/utils/scrollparent.js +21 -0
  35. package/dist/collection/utils/scrollparent.js.map +1 -0
  36. package/dist/components/language.service.js +1 -1
  37. package/dist/components/language.service.js.map +1 -1
  38. package/dist/components/post-klp-login-widget2.js +1 -1
  39. package/dist/components/post-klp-login-widget2.js.map +1 -1
  40. package/dist/components/post-main-navigation2.js +1 -1
  41. package/dist/components/post-main-navigation2.js.map +1 -1
  42. package/dist/components/post-search2.js +4 -1
  43. package/dist/components/post-search2.js.map +1 -1
  44. package/dist/components/swisspost-internet-breadcrumbs.js +1329 -8
  45. package/dist/components/swisspost-internet-breadcrumbs.js.map +1 -1
  46. package/dist/components/swisspost-internet-footer.js +1 -1
  47. package/dist/components/swisspost-internet-footer.js.map +1 -1
  48. package/dist/components/swisspost-internet-header.js +66 -36
  49. package/dist/components/swisspost-internet-header.js.map +1 -1
  50. package/dist/docs.json +34 -4
  51. package/dist/esm/{language.service-bd0f3b6f.js → language.service-4289815d.js} +2 -2
  52. package/dist/esm/language.service-4289815d.js.map +1 -0
  53. package/dist/esm/loader.js +1 -1
  54. package/dist/esm/post-klp-login-widget.entry.js +1 -1
  55. package/dist/esm/post-klp-login-widget.entry.js.map +1 -1
  56. package/dist/esm/post-language-switch.entry.js +1 -1
  57. package/dist/esm/post-main-navigation.entry.js +2 -2
  58. package/dist/esm/post-main-navigation.entry.js.map +1 -1
  59. package/dist/esm/post-search.entry.js +4 -1
  60. package/dist/esm/post-search.entry.js.map +1 -1
  61. package/dist/esm/post-skiplinks.entry.js +1 -1
  62. package/dist/esm/swisspost-internet-breadcrumbs.entry.js +1328 -8
  63. package/dist/esm/swisspost-internet-breadcrumbs.entry.js.map +1 -1
  64. package/dist/esm/swisspost-internet-footer.entry.js +2 -2
  65. package/dist/esm/swisspost-internet-footer.entry.js.map +1 -1
  66. package/dist/esm/swisspost-internet-header.entry.js +65 -35
  67. package/dist/esm/swisspost-internet-header.entry.js.map +1 -1
  68. package/dist/esm/swisspost-internet-header.js +1 -1
  69. package/dist/esm-es5/language.service-4289815d.js +2 -0
  70. package/dist/esm-es5/language.service-4289815d.js.map +1 -0
  71. package/dist/esm-es5/loader.js +1 -1
  72. package/dist/esm-es5/loader.js.map +1 -1
  73. package/dist/esm-es5/post-klp-login-widget.entry.js +1 -1
  74. package/dist/esm-es5/post-klp-login-widget.entry.js.map +1 -1
  75. package/dist/esm-es5/post-language-switch.entry.js +1 -1
  76. package/dist/esm-es5/post-main-navigation.entry.js +1 -1
  77. package/dist/esm-es5/post-main-navigation.entry.js.map +1 -1
  78. package/dist/esm-es5/post-search.entry.js +1 -1
  79. package/dist/esm-es5/post-search.entry.js.map +1 -1
  80. package/dist/esm-es5/post-skiplinks.entry.js +1 -1
  81. package/dist/esm-es5/swisspost-internet-breadcrumbs.entry.js +2 -2
  82. package/dist/esm-es5/swisspost-internet-breadcrumbs.entry.js.map +1 -1
  83. package/dist/esm-es5/swisspost-internet-footer.entry.js +1 -1
  84. package/dist/esm-es5/swisspost-internet-footer.entry.js.map +1 -1
  85. package/dist/esm-es5/swisspost-internet-header.entry.js +1 -1
  86. package/dist/esm-es5/swisspost-internet-header.entry.js.map +1 -1
  87. package/dist/esm-es5/swisspost-internet-header.js +1 -1
  88. package/dist/esm-es5/swisspost-internet-header.js.map +1 -1
  89. package/dist/swisspost-internet-header/{p-0dd2de97.entry.js → p-02df8ca4.entry.js} +2 -2
  90. package/dist/swisspost-internet-header/p-0de024c6.system.entry.js +2 -0
  91. package/dist/swisspost-internet-header/{p-0bfadd54.system.entry.js.map → p-0de024c6.system.entry.js.map} +1 -1
  92. package/dist/swisspost-internet-header/p-2ab12ef9.entry.js +2 -0
  93. package/dist/swisspost-internet-header/{p-273fd39b.entry.js.map → p-2ab12ef9.entry.js.map} +1 -1
  94. package/dist/swisspost-internet-header/p-33f6c69f.entry.js +2 -0
  95. package/dist/swisspost-internet-header/{p-9ab24fb3.entry.js.map → p-33f6c69f.entry.js.map} +1 -1
  96. package/dist/swisspost-internet-header/p-34da85e6.system.entry.js +2 -0
  97. package/dist/swisspost-internet-header/{p-e2df6e93.system.entry.js.map → p-34da85e6.system.entry.js.map} +1 -1
  98. package/dist/swisspost-internet-header/p-3cfe4534.entry.js +2 -0
  99. package/dist/swisspost-internet-header/p-3cfe4534.entry.js.map +1 -0
  100. package/dist/swisspost-internet-header/p-43320028.system.entry.js +2 -0
  101. package/dist/swisspost-internet-header/p-43320028.system.entry.js.map +1 -0
  102. package/dist/swisspost-internet-header/p-55fbc914.entry.js +2 -0
  103. package/dist/swisspost-internet-header/{p-64e1182b.entry.js.map → p-55fbc914.entry.js.map} +1 -1
  104. package/dist/swisspost-internet-header/p-5d893017.system.js +1 -1
  105. package/dist/swisspost-internet-header/p-5d893017.system.js.map +1 -1
  106. package/dist/swisspost-internet-header/p-6dc0fc47.system.entry.js +2 -0
  107. package/dist/swisspost-internet-header/p-6dc0fc47.system.entry.js.map +1 -0
  108. package/dist/swisspost-internet-header/p-75dde9a2.entry.js +7 -0
  109. package/dist/swisspost-internet-header/p-75dde9a2.entry.js.map +1 -0
  110. package/dist/swisspost-internet-header/{p-6f69aff4.system.entry.js → p-781ea7c2.system.entry.js} +2 -2
  111. package/dist/swisspost-internet-header/p-a5f5bb55.js +2 -0
  112. package/dist/swisspost-internet-header/p-a5f5bb55.js.map +1 -0
  113. package/dist/swisspost-internet-header/{p-131078ce.system.entry.js → p-a691c791.system.entry.js} +2 -2
  114. package/dist/swisspost-internet-header/p-b5758d6a.system.entry.js +7 -0
  115. package/dist/swisspost-internet-header/p-b5758d6a.system.entry.js.map +1 -0
  116. package/dist/swisspost-internet-header/p-bf99c127.system.js +2 -0
  117. package/dist/swisspost-internet-header/p-bf99c127.system.js.map +1 -0
  118. package/dist/swisspost-internet-header/{p-9ec1f474.entry.js → p-cbba35a8.entry.js} +2 -2
  119. package/dist/swisspost-internet-header/p-cf9fb780.system.entry.js +2 -0
  120. package/dist/swisspost-internet-header/{p-a366648c.system.entry.js.map → p-cf9fb780.system.entry.js.map} +1 -1
  121. package/dist/swisspost-internet-header/p-db8023e1.entry.js +2 -0
  122. package/dist/swisspost-internet-header/{p-262611f7.entry.js.map → p-db8023e1.entry.js.map} +1 -1
  123. package/dist/swisspost-internet-header/swisspost-internet-header.css +1 -3
  124. package/dist/swisspost-internet-header/swisspost-internet-header.esm.js +1 -1
  125. package/dist/swisspost-internet-header/swisspost-internet-header.esm.js.map +1 -1
  126. package/dist/types/components/post-internet-breadcrumbs/post-internet-breadcrumbs.d.ts +8 -3
  127. package/dist/types/components/post-internet-header/post-internet-header.d.ts +4 -3
  128. package/dist/types/components.d.ts +11 -6
  129. package/dist/types/services/language.service.d.ts +2 -5
  130. package/dist/types/utils/scrollparent.d.ts +1 -0
  131. package/package.json +12 -11
  132. package/dist/cjs/language.service-9334ca5d.js.map +0 -1
  133. package/dist/esm/language.service-bd0f3b6f.js.map +0 -1
  134. package/dist/esm-es5/language.service-bd0f3b6f.js +0 -2
  135. package/dist/esm-es5/language.service-bd0f3b6f.js.map +0 -1
  136. package/dist/swisspost-internet-header/p-06d32a28.entry.js +0 -7
  137. package/dist/swisspost-internet-header/p-06d32a28.entry.js.map +0 -1
  138. package/dist/swisspost-internet-header/p-0bfadd54.system.entry.js +0 -2
  139. package/dist/swisspost-internet-header/p-1078e964.system.entry.js +0 -2
  140. package/dist/swisspost-internet-header/p-1078e964.system.entry.js.map +0 -1
  141. package/dist/swisspost-internet-header/p-262611f7.entry.js +0 -2
  142. package/dist/swisspost-internet-header/p-273fd39b.entry.js +0 -2
  143. package/dist/swisspost-internet-header/p-4099b274.system.js +0 -2
  144. package/dist/swisspost-internet-header/p-4099b274.system.js.map +0 -1
  145. package/dist/swisspost-internet-header/p-5baac371.system.entry.js +0 -2
  146. package/dist/swisspost-internet-header/p-5baac371.system.entry.js.map +0 -1
  147. package/dist/swisspost-internet-header/p-64e1182b.entry.js +0 -2
  148. package/dist/swisspost-internet-header/p-7bed0797.js +0 -2
  149. package/dist/swisspost-internet-header/p-7bed0797.js.map +0 -1
  150. package/dist/swisspost-internet-header/p-97c90e22.system.entry.js +0 -7
  151. package/dist/swisspost-internet-header/p-97c90e22.system.entry.js.map +0 -1
  152. package/dist/swisspost-internet-header/p-9ab24fb3.entry.js +0 -2
  153. package/dist/swisspost-internet-header/p-a366648c.system.entry.js +0 -2
  154. package/dist/swisspost-internet-header/p-e2df6e93.system.entry.js +0 -2
  155. package/dist/swisspost-internet-header/p-f531c1ea.entry.js +0 -2
  156. package/dist/swisspost-internet-header/p-f531c1ea.entry.js.map +0 -1
  157. /package/dist/swisspost-internet-header/{p-0dd2de97.entry.js.map → p-02df8ca4.entry.js.map} +0 -0
  158. /package/dist/swisspost-internet-header/{p-6f69aff4.system.entry.js.map → p-781ea7c2.system.entry.js.map} +0 -0
  159. /package/dist/swisspost-internet-header/{p-131078ce.system.entry.js.map → p-a691c791.system.entry.js.map} +0 -0
  160. /package/dist/swisspost-internet-header/{p-9ec1f474.entry.js.map → p-cbba35a8.entry.js.map} +0 -0
@@ -1,10 +1,10 @@
1
1
  import { Host, h } from '@stencil/core';
2
2
  import { debounce } from 'throttle-debounce';
3
- import { disableBodyScroll, enableBodyScroll, clearAllBodyScrollLocks } from 'body-scroll-lock';
3
+ import { clearAllBodyScrollLocks, disableBodyScroll, enableBodyScroll } from 'body-scroll-lock';
4
4
  import { SvgIcon } from '../../utils/svg-icon.component';
5
5
  import { state } from '../../data/store';
6
6
  import { OverlayComponent } from './components/overlay.component';
7
- import iframeResizer from 'iframe-resizer/js/iframeResizer';
7
+ import { iframeResizer } from 'iframe-resizer';
8
8
  import { SvgSprite } from '../../utils/svg-sprite.component';
9
9
  import { BreadcrumbList } from './components/breadcrumb-list.component';
10
10
  import { prefersReducedMotion } from '../../utils/utils';
@@ -17,6 +17,20 @@ export class PostInternetBreadcrumbs {
17
17
  this.dropdownOpen = false;
18
18
  this.refsReady = false;
19
19
  }
20
+ /**
21
+ * Toggle an overlay associated with a button.
22
+ * @param {IBreadcrumbOverlay['id']} overlayId
23
+ */
24
+ async toggleOverlayById(overlayId) {
25
+ var _a, _b;
26
+ const buttons = (_a = state.localizedConfig) === null || _a === void 0 ? void 0 : _a.breadcrumb.buttons;
27
+ const overlay = (_b = buttons === null || buttons === void 0 ? void 0 : buttons.find(button => button.overlay.id === overlayId)) === null || _b === void 0 ? void 0 : _b.overlay;
28
+ if (!overlay) {
29
+ console.warn(`Internet Header: Failed to toggle overlay with id #${overlayId} as it was not found in the breadcrumb buttons config.`);
30
+ return;
31
+ }
32
+ this.toggleOverlay(overlay);
33
+ }
20
34
  connectedCallback() {
21
35
  this.debouncedResize = debounce(200, this.handleResize.bind(this));
22
36
  window.addEventListener('resize', this.debouncedResize, { passive: true });
@@ -42,7 +56,7 @@ export class PostInternetBreadcrumbs {
42
56
  this.handleResize();
43
57
  });
44
58
  }
45
- handleCustomConfigChage(newValue) {
59
+ handleCustomConfigChange(newValue) {
46
60
  try {
47
61
  this.customBreadcrumbItems = typeof newValue === 'string' ? JSON.parse(newValue) : newValue;
48
62
  }
@@ -73,7 +87,7 @@ export class PostInternetBreadcrumbs {
73
87
  var _a;
74
88
  const newVisibility = force !== null && force !== void 0 ? force : !this.overlayVisible;
75
89
  if (newVisibility) {
76
- // Will trigger overlayRef() once the HTLM is rendered
90
+ // Will trigger overlayRef() once the HTML is rendered
77
91
  this.overlayVisible = newVisibility;
78
92
  this.currentOverlay = overlay;
79
93
  this.setBodyScroll(overlay);
@@ -99,9 +113,11 @@ export class PostInternetBreadcrumbs {
99
113
  */
100
114
  setBodyScroll(overlay) {
101
115
  if (this.overlayVisible) {
116
+ // @ts-ignore
102
117
  disableBodyScroll(overlay, { reserveScrollBarGap: true });
103
118
  }
104
119
  else {
120
+ // @ts-ignore
105
121
  enableBodyScroll(overlay);
106
122
  }
107
123
  }
@@ -173,6 +189,7 @@ export class PostInternetBreadcrumbs {
173
189
  }
174
190
  render() {
175
191
  // There is something wrong entirely
192
+ // eslint-disable-next-line @stencil/strict-boolean-conditions
176
193
  if (!state) {
177
194
  console.warn(`Internet Breadcrumbs: Could not load config. Please make sure that you included the <swisspost-internet-header></swisspost-internet-header> component.`);
178
195
  return null;
@@ -182,6 +199,7 @@ export class PostInternetBreadcrumbs {
182
199
  return null;
183
200
  }
184
201
  // Config has loaded but there is no breadcrumbs config
202
+ // eslint-disable-next-line @stencil/strict-boolean-conditions
185
203
  if (!state.localizedConfig.breadcrumb) {
186
204
  console.warn(`Internet Header: Current project "${state.projectId}" does not include a breadcrumb config. The breadcrumbs will not be rendered. Remove `, document.querySelector('swisspost-internet-breadcrumbs'), `from your markup or configure the breadcrumbs in your portal config to stop seeing this warning.`);
187
205
  return null;
@@ -193,7 +211,7 @@ export class PostInternetBreadcrumbs {
193
211
  return (h(Host, null, h(SvgSprite, null), h("div", { class: "breadcrumbs" }, h("div", { class: "hidden-control-breadcrumbs", "aria-hidden": "true", tabindex: "-1" }, h("nav", { class: "breadcrumbs-nav", ref: e => e !== undefined && this.handleControlNavRef(e) }, h(BreadcrumbList, { items: items, focusable: false, clickHandler: () => { } }))), h("nav", { "aria-label": breadcrumbConfig.a11yLabel, ref: e => e !== undefined && this.handleVisibleNavRef(e), class: {
194
212
  'breadcrumbs-nav': true,
195
213
  'visually-hidden': !this.refsReady,
196
- } }, h(BreadcrumbList, { items: items, dropdownOpen: this.dropdownOpen, isConcatenated: this.isConcatenated, clickHandler: () => this.handleToggleDropdown() })), h("div", { class: "breadcrumb-buttons" }, breadcrumbConfig.buttons.map(button => (h("button", { class: "btn btn-secondary btn-icon", key: button.text, "aria-expanded": `${!!this.overlayVisible && this.currentOverlay === button.overlay}`, onClick: () => this.toggleOverlay(button.overlay, true) }, h(SvgIcon, { name: button.svgIcon.name }), h("span", { class: "visually-hidden" }, button.text))))), this.overlayVisible && (h(OverlayComponent, { overlayRef: e => e !== undefined && this.overlayRef(e), iFrameRef: e => e !== undefined && this.registerIFrameResizer(e), overlay: this.currentOverlay, onClick: () => this.handleToggleOverlay(), onKeyDown: (e) => this.handleKeyDown(e), closeButtonText: state.localizedConfig.header.translations.closeButtonText }))), h("slot", null)));
214
+ } }, h(BreadcrumbList, { items: items, dropdownOpen: this.dropdownOpen, isConcatenated: this.isConcatenated, clickHandler: () => this.handleToggleDropdown() })), h("div", { class: "breadcrumb-buttons" }, breadcrumbConfig.buttons.map(button => (h("button", { class: "btn btn-secondary btn-icon", key: button.text, "aria-expanded": `${this.overlayVisible && this.currentOverlay === button.overlay}`, onClick: () => this.toggleOverlay(button.overlay, true) }, h(SvgIcon, { name: button.svgIcon.name }), h("span", { class: "visually-hidden" }, button.text))))), this.overlayVisible && (h(OverlayComponent, { overlayRef: e => e !== undefined && this.overlayRef(e), iFrameRef: e => e !== undefined && this.registerIFrameResizer(e), overlay: this.currentOverlay, onClick: () => this.handleToggleOverlay(), onKeyDown: (e) => this.handleKeyDown(e), closeButtonText: state.localizedConfig.header.translations.closeButtonText }))), h("slot", null)));
197
215
  }
198
216
  static get is() { return "swisspost-internet-breadcrumbs"; }
199
217
  static get encapsulation() { return "shadow"; }
@@ -242,11 +260,44 @@ export class PostInternetBreadcrumbs {
242
260
  "refsReady": {}
243
261
  };
244
262
  }
263
+ static get methods() {
264
+ return {
265
+ "toggleOverlayById": {
266
+ "complexType": {
267
+ "signature": "(overlayId: IBreadcrumbOverlay['id']) => Promise<void>",
268
+ "parameters": [{
269
+ "tags": [{
270
+ "name": "param",
271
+ "text": "overlayId"
272
+ }],
273
+ "text": ""
274
+ }],
275
+ "references": {
276
+ "Promise": {
277
+ "location": "global"
278
+ },
279
+ "IBreadcrumbOverlay": {
280
+ "location": "import",
281
+ "path": "../../models/breadcrumbs.model"
282
+ }
283
+ },
284
+ "return": "Promise<void>"
285
+ },
286
+ "docs": {
287
+ "text": "Toggle an overlay associated with a button.",
288
+ "tags": [{
289
+ "name": "param",
290
+ "text": "overlayId"
291
+ }]
292
+ }
293
+ }
294
+ };
295
+ }
245
296
  static get elementRef() { return "host"; }
246
297
  static get watchers() {
247
298
  return [{
248
299
  "propName": "customItems",
249
- "methodName": "handleCustomConfigChage"
300
+ "methodName": "handleCustomConfigChange"
250
301
  }];
251
302
  }
252
303
  }
@@ -1 +1 @@
1
- {"version":3,"file":"post-internet-breadcrumbs.js","sourceRoot":"","sources":["../../../../src/components/post-internet-breadcrumbs/post-internet-breadcrumbs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAChG,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,aAAa,MAAM,iCAAiC,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAOzD,MAAM,OAAO,uBAAuB;;;;;;wBAKD,KAAK;qBACR,KAAK;;EAWnC,iBAAiB;IACf,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAC,GAA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,SAAS,IAAI,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAChE,OAAO,EAAE,IAAI,CAAC,cAAc,EAC5B,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,mBAAmB,EAAE,EACzC,SAAS,EAAE,CAAC,CAAgB,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EACtD,eAAe,EAAE,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,eAAe,GACxD,CACrB,CACG;MACN,eAAa,CACR,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, State, Element, Watch } from '@stencil/core';\nimport { debounce } from 'throttle-debounce';\nimport { disableBodyScroll, enableBodyScroll, clearAllBodyScrollLocks } from 'body-scroll-lock';\nimport { SvgIcon } from '../../utils/svg-icon.component';\nimport { state } from '../../data/store';\nimport { OverlayComponent } from './components/overlay.component';\nimport iframeResizer from 'iframe-resizer/js/iframeResizer';\nimport { IBreadcrumbOverlay, IBreadcrumbItem } from '../../models/breadcrumbs.model';\nimport { SvgSprite } from '../../utils/svg-sprite.component';\nimport { BreadcrumbList } from './components/breadcrumb-list.component';\nimport { prefersReducedMotion } from '../../utils/utils';\n\n@Component({\n tag: 'swisspost-internet-breadcrumbs',\n styleUrl: 'post-internet-breadcrumbs.scss',\n shadow: true,\n})\nexport class PostInternetBreadcrumbs {\n @Prop() customItems?: string | IBreadcrumbItem[];\n @State() customBreadcrumbItems?: IBreadcrumbItem[];\n @State() overlayVisible: boolean;\n @State() isConcatenated: boolean; // Don't set an initial value, this has to be calculated first, otherwise reactivity problems ensue\n @State() dropdownOpen: boolean = false;\n @State() refsReady: boolean = false;\n @Element() host: Element;\n\n private controlNavRef?: HTMLElement;\n private visibleNavRef?: HTMLElement;\n private currentOverlay: IBreadcrumbOverlay;\n private debouncedResize: debounce<() => void>;\n private lastWindowWidth: number;\n private openAnimation: Animation;\n private loadedAnimation: Animation | undefined;\n\n connectedCallback() {\n this.debouncedResize = debounce(200, this.handleResize.bind(this));\n window.addEventListener('resize', this.debouncedResize, { passive: true });\n }\n\n disconnectedCallback() {\n window.removeEventListener('resize', this.debouncedResize);\n window.removeEventListener('click', this.handleWindowClick);\n clearAllBodyScrollLocks();\n }\n\n async componentWillLoad() {\n // Wait for the config to arrive, then render the header\n try {\n this.customBreadcrumbItems =\n typeof this.customItems === 'string' ? JSON.parse(this.customItems) : this.customItems;\n } catch (error) {\n console.error(error);\n }\n }\n\n componentDidLoad() {\n // Initially check if breadcrumb items are concatenated\n window.requestAnimationFrame(() => {\n this.handleResize();\n });\n }\n\n @Watch('customItems')\n handleCustomConfigChage(newValue: string | IBreadcrumbItem[]) {\n try {\n this.customBreadcrumbItems = typeof newValue === 'string' ? JSON.parse(newValue) : newValue;\n } catch (error) {\n console.error(error);\n }\n }\n\n handleResize() {\n // Catch and exclude vertical resize events, e.g. scrolling in iPhone\n if (window.innerWidth === this.lastWindowWidth) {\n return;\n }\n this.lastWindowWidth = window.innerWidth;\n this.checkConcatenation();\n }\n\n checkConcatenation() {\n if (this.controlNavRef && this.visibleNavRef) {\n this.refsReady = true;\n\n // Delay the check\n window.requestAnimationFrame(() => {\n if (this.controlNavRef && this.visibleNavRef) {\n this.isConcatenated = this.controlNavRef.clientWidth > this.visibleNavRef.clientWidth;\n }\n });\n }\n }\n\n toggleOverlay(overlay: IBreadcrumbOverlay, force?: boolean) {\n const newVisibility = force ?? !this.overlayVisible;\n\n if (newVisibility) {\n // Will trigger overlayRef() once the HTLM is rendered\n this.overlayVisible = newVisibility;\n this.currentOverlay = overlay;\n this.setBodyScroll(overlay);\n } else {\n const activeToggler = this.host.shadowRoot?.querySelector<HTMLElement>(\n '.breadcrumb-buttons [aria-expanded=\"true\"]',\n );\n\n if (this.openAnimation && this.loadedAnimation) {\n this.openAnimation.reverse();\n this.loadedAnimation.reverse();\n\n // Delay hiding overlay until after the animation finishes\n Promise.all([this.openAnimation.finished, this.loadedAnimation.finished]).then(() => {\n if (activeToggler) {\n activeToggler.focus();\n }\n this.overlayVisible = newVisibility;\n this.setBodyScroll(overlay);\n });\n }\n }\n }\n\n /**\n * Disable or re-enable body scrolling, depending on whether overlay is visible or not\n */\n setBodyScroll(overlay: IBreadcrumbOverlay) {\n if (this.overlayVisible) {\n disableBodyScroll(overlay, { reserveScrollBarGap: true });\n } else {\n enableBodyScroll(overlay);\n }\n }\n\n toggleDropdown(force?: boolean) {\n this.dropdownOpen = force ?? !this.dropdownOpen;\n\n if (this.dropdownOpen) {\n requestAnimationFrame(() => {\n document.addEventListener('click', this.handleWindowClick.bind(this), { once: true });\n });\n }\n }\n\n handleWindowClick() {\n this.toggleDropdown(false);\n }\n\n registerIFrameResizer(iFrame: HTMLIFrameElement) {\n if (!iFrame) {\n return;\n }\n\n iFrame.addEventListener('load', () => {\n iframeResizer(\n {\n heightCalculationMethod: 'taggedElement',\n scrolling: true,\n checkOrigin: false,\n },\n iFrame,\n );\n const duration = prefersReducedMotion ? 0 : 300;\n this.loadedAnimation = iFrame.parentElement?.animate(\n [{ opacity: 1, visibility: 'visible', transform: 'translateY(0px)' }],\n { duration, fill: 'forwards' },\n );\n iFrame.parentElement?.classList.add('loaded');\n this.loadedAnimation?.finished.then(() => {\n iFrame.parentElement?.focus();\n });\n });\n }\n\n /**\n * Reference function for the overlay element got called. It is either null (overlay closed)\n * or contains the overlay element as parameter.\n * @param e Overlay element or null\n * @returns void\n */\n overlayRef(e: HTMLElement | undefined) {\n if (!e) {\n return;\n }\n\n const duration = prefersReducedMotion ? 0 : 500;\n this.openAnimation = e.animate([{ opacity: 1, visibility: 'visible' }], {\n duration,\n fill: 'forwards',\n });\n }\n\n private handleKeyDown(event: KeyboardEvent) {\n if (event.key.toLowerCase() === 'escape') {\n this.toggleOverlay(this.currentOverlay, false);\n }\n }\n\n private handleToggleDropdown() {\n this.toggleDropdown();\n }\n\n private handleToggleOverlay() {\n this.toggleOverlay(this.currentOverlay, false);\n }\n\n private handleControlNavRef(element: HTMLElement) {\n this.controlNavRef = element;\n this.checkConcatenation();\n }\n\n private handleVisibleNavRef(element: HTMLElement) {\n this.visibleNavRef = element;\n this.checkConcatenation();\n }\n\n render() {\n // There is something wrong entirely\n if (!state) {\n console.warn(\n `Internet Breadcrumbs: Could not load config. Please make sure that you included the <swisspost-internet-header></swisspost-internet-header> component.`,\n );\n return null;\n }\n\n // Config is not loaded yet\n if (!state.localizedConfig) {\n return null;\n }\n\n // Config has loaded but there is no breadcrumbs config\n if (!state.localizedConfig.breadcrumb) {\n console.warn(\n `Internet Header: Current project \"${state.projectId}\" does not include a breadcrumb config. The breadcrumbs will not be rendered. Remove `,\n document.querySelector('swisspost-internet-breadcrumbs'),\n `from your markup or configure the breadcrumbs in your portal config to stop seeing this warning.`,\n );\n return null;\n }\n\n const breadcrumbConfig = state.localizedConfig.breadcrumb;\n const items =\n this.customBreadcrumbItems !== undefined\n ? [...breadcrumbConfig.items, ...this.customBreadcrumbItems]\n : breadcrumbConfig.items;\n\n return (\n <Host>\n <SvgSprite />\n <div class=\"breadcrumbs\">\n <div class=\"hidden-control-breadcrumbs\" aria-hidden=\"true\" tabindex=\"-1\">\n <nav class=\"breadcrumbs-nav\" ref={e => e !== undefined && this.handleControlNavRef(e)}>\n <BreadcrumbList\n items={items}\n focusable={false}\n clickHandler={() => {}}\n ></BreadcrumbList>\n </nav>\n </div>\n <nav\n aria-label={breadcrumbConfig.a11yLabel}\n ref={e => e !== undefined && this.handleVisibleNavRef(e)}\n class={{\n 'breadcrumbs-nav': true,\n 'visually-hidden': !this.refsReady,\n }}\n >\n <BreadcrumbList\n items={items}\n dropdownOpen={this.dropdownOpen}\n isConcatenated={this.isConcatenated}\n clickHandler={() => this.handleToggleDropdown()}\n ></BreadcrumbList>\n </nav>\n <div class=\"breadcrumb-buttons\">\n {breadcrumbConfig.buttons.map(button => (\n <button\n class=\"btn btn-secondary btn-icon\"\n key={button.text}\n aria-expanded={`${!!this.overlayVisible && this.currentOverlay === button.overlay}`}\n onClick={() => this.toggleOverlay(button.overlay, true)}\n >\n <SvgIcon name={button.svgIcon.name}></SvgIcon>\n <span class=\"visually-hidden\">{button.text}</span>\n </button>\n ))}\n </div>\n {this.overlayVisible && (\n <OverlayComponent\n overlayRef={e => e !== undefined && this.overlayRef(e)}\n iFrameRef={e => e !== undefined && this.registerIFrameResizer(e)}\n overlay={this.currentOverlay}\n onClick={() => this.handleToggleOverlay()}\n onKeyDown={(e: KeyboardEvent) => this.handleKeyDown(e)}\n closeButtonText={state.localizedConfig.header.translations.closeButtonText}\n ></OverlayComponent>\n )}\n </div>\n <slot></slot>\n </Host>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"post-internet-breadcrumbs.js","sourceRoot":"","sources":["../../../../src/components/post-internet-breadcrumbs/post-internet-breadcrumbs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAChG,OAAO,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAOzD,MAAM,OAAO,uBAAuB;;;;;;wBAK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,EAAC,4BAA4B,EAClC,GAAG,EAAE,MAAM,CAAC,IAAI,mBACD,GAAG,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,cAAc,KAAK,MAAM,CAAC,OAAO,EAAE,EACjF,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC;UAEvD,EAAC,OAAO,IAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,GAAY;UAC9C,YAAM,KAAK,EAAC,iBAAiB,IAAE,MAAM,CAAC,IAAI,CAAQ,CAC3C,CACV,CAAC,CACE;QACL,IAAI,CAAC,cAAc,IAAI,CACtB,EAAC,gBAAgB,IACf,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,SAAS,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,EACtD,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,SAAS,IAAI,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAChE,OAAO,EAAE,IAAI,CAAC,cAAc,EAC5B,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,mBAAmB,EAAE,EACzC,SAAS,EAAE,CAAC,CAAgB,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,EACtD,eAAe,EAAE,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,eAAe,GACxD,CACrB,CACG;MACN,eAAa,CACR,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, h, Prop, State, Element, Watch, Method } from '@stencil/core';\nimport { debounce } from 'throttle-debounce';\nimport { clearAllBodyScrollLocks, disableBodyScroll, enableBodyScroll } from 'body-scroll-lock';\nimport { SvgIcon } from '../../utils/svg-icon.component';\nimport { state } from '../../data/store';\nimport { OverlayComponent } from './components/overlay.component';\nimport { iframeResizer } from 'iframe-resizer';\nimport { IBreadcrumbItem, IBreadcrumbOverlay } from '../../models/breadcrumbs.model';\nimport { SvgSprite } from '../../utils/svg-sprite.component';\nimport { BreadcrumbList } from './components/breadcrumb-list.component';\nimport { prefersReducedMotion } from '../../utils/utils';\n\n@Component({\n tag: 'swisspost-internet-breadcrumbs',\n styleUrl: 'post-internet-breadcrumbs.scss',\n shadow: true,\n})\nexport class PostInternetBreadcrumbs {\n @Prop() customItems?: string | IBreadcrumbItem[];\n @State() customBreadcrumbItems?: IBreadcrumbItem[];\n @State() overlayVisible: boolean;\n @State() isConcatenated: boolean; // Don't set an initial value, this has to be calculated first, otherwise reactivity problems ensue\n @State() dropdownOpen: boolean = false;\n @State() refsReady: boolean = false;\n @Element() host: Element;\n\n\n /**\n * Toggle an overlay associated with a button.\n * @param {IBreadcrumbOverlay['id']} overlayId\n */\n @Method()\n async toggleOverlayById(overlayId: IBreadcrumbOverlay['id']): Promise<void> {\n const buttons = state.localizedConfig?.breadcrumb.buttons;\n const overlay = buttons?.find(button => button.overlay.id === overlayId)?.overlay;\n\n if(!overlay){\n console.warn(\n `Internet Header: Failed to toggle overlay with id #${overlayId} as it was not found in the breadcrumb buttons config.`,\n );\n return;\n }\n\n this.toggleOverlay(overlay)\n }\n\n private controlNavRef?: HTMLElement;\n private visibleNavRef?: HTMLElement;\n private currentOverlay: IBreadcrumbOverlay;\n private debouncedResize: debounce<() => void>;\n private lastWindowWidth: number;\n private openAnimation: Animation;\n private loadedAnimation: Animation | undefined;\n\n connectedCallback() {\n this.debouncedResize = debounce(200, this.handleResize.bind(this));\n window.addEventListener('resize', this.debouncedResize, { passive: true });\n }\n\n disconnectedCallback() {\n window.removeEventListener('resize', this.debouncedResize);\n window.removeEventListener('click', this.handleWindowClick);\n clearAllBodyScrollLocks();\n }\n\n async componentWillLoad() {\n // Wait for the config to arrive, then render the header\n try {\n this.customBreadcrumbItems =\n typeof this.customItems === 'string' ? JSON.parse(this.customItems) : this.customItems;\n } catch (error) {\n console.error(error);\n }\n }\n\n componentDidLoad() {\n // Initially check if breadcrumb items are concatenated\n window.requestAnimationFrame(() => {\n this.handleResize();\n });\n }\n\n @Watch('customItems')\n handleCustomConfigChange(newValue: string | IBreadcrumbItem[]) {\n try {\n this.customBreadcrumbItems = typeof newValue === 'string' ? JSON.parse(newValue) : newValue;\n } catch (error) {\n console.error(error);\n }\n }\n\n handleResize() {\n // Catch and exclude vertical resize events, e.g. scrolling in iPhone\n if (window.innerWidth === this.lastWindowWidth) {\n return;\n }\n this.lastWindowWidth = window.innerWidth;\n this.checkConcatenation();\n }\n\n checkConcatenation() {\n if (this.controlNavRef && this.visibleNavRef) {\n this.refsReady = true;\n\n // Delay the check\n window.requestAnimationFrame(() => {\n if (this.controlNavRef && this.visibleNavRef) {\n this.isConcatenated = this.controlNavRef.clientWidth > this.visibleNavRef.clientWidth;\n }\n });\n }\n }\n\n toggleOverlay(overlay: IBreadcrumbOverlay, force?: boolean) {\n const newVisibility = force ?? !this.overlayVisible;\n\n if (newVisibility) {\n // Will trigger overlayRef() once the HTML is rendered\n this.overlayVisible = newVisibility;\n this.currentOverlay = overlay;\n this.setBodyScroll(overlay);\n } else {\n const activeToggler = this.host.shadowRoot?.querySelector<HTMLElement>(\n '.breadcrumb-buttons [aria-expanded=\"true\"]',\n );\n\n if (this.openAnimation && this.loadedAnimation) {\n this.openAnimation.reverse();\n this.loadedAnimation.reverse();\n\n // Delay hiding overlay until after the animation finishes\n Promise.all([this.openAnimation.finished, this.loadedAnimation.finished]).then(() => {\n if (activeToggler) {\n activeToggler.focus();\n }\n this.overlayVisible = newVisibility;\n this.setBodyScroll(overlay);\n });\n }\n }\n }\n\n /**\n * Disable or re-enable body scrolling, depending on whether overlay is visible or not\n */\n setBodyScroll(overlay: IBreadcrumbOverlay) {\n if (this.overlayVisible) {\n // @ts-ignore\n disableBodyScroll(overlay, { reserveScrollBarGap: true });\n } else {\n // @ts-ignore\n enableBodyScroll(overlay);\n }\n }\n\n toggleDropdown(force?: boolean) {\n this.dropdownOpen = force ?? !this.dropdownOpen;\n\n if (this.dropdownOpen) {\n requestAnimationFrame(() => {\n document.addEventListener('click', this.handleWindowClick.bind(this), { once: true });\n });\n }\n }\n\n handleWindowClick() {\n this.toggleDropdown(false);\n }\n\n registerIFrameResizer(iFrame: HTMLIFrameElement | undefined) {\n if (!iFrame) {\n return;\n }\n\n iFrame.addEventListener('load', () => {\n iframeResizer(\n {\n heightCalculationMethod: 'taggedElement',\n scrolling: true,\n checkOrigin: false,\n },\n iFrame,\n );\n const duration = prefersReducedMotion ? 0 : 300;\n this.loadedAnimation = iFrame.parentElement?.animate(\n [{ opacity: 1, visibility: 'visible', transform: 'translateY(0px)' }],\n { duration, fill: 'forwards' },\n );\n iFrame.parentElement?.classList.add('loaded');\n this.loadedAnimation?.finished.then(() => {\n iFrame.parentElement?.focus();\n });\n });\n }\n\n /**\n * Reference function for the overlay element got called. It is either null (overlay closed)\n * or contains the overlay element as parameter.\n * @param e Overlay element or null\n * @returns void\n */\n overlayRef(e: HTMLElement | undefined) {\n if (!e) {\n return;\n }\n\n const duration = prefersReducedMotion ? 0 : 500;\n this.openAnimation = e.animate([{ opacity: 1, visibility: 'visible' }], {\n duration,\n fill: 'forwards',\n });\n }\n\n private handleKeyDown(event: KeyboardEvent) {\n if (event.key.toLowerCase() === 'escape') {\n this.toggleOverlay(this.currentOverlay, false);\n }\n }\n\n private handleToggleDropdown() {\n this.toggleDropdown();\n }\n\n private handleToggleOverlay() {\n this.toggleOverlay(this.currentOverlay, false);\n }\n\n private handleControlNavRef(element: HTMLElement) {\n this.controlNavRef = element;\n this.checkConcatenation();\n }\n\n private handleVisibleNavRef(element: HTMLElement) {\n this.visibleNavRef = element;\n this.checkConcatenation();\n }\n\n render() {\n // There is something wrong entirely\n // eslint-disable-next-line @stencil/strict-boolean-conditions\n if (!state) {\n console.warn(\n `Internet Breadcrumbs: Could not load config. Please make sure that you included the <swisspost-internet-header></swisspost-internet-header> component.`,\n );\n return null;\n }\n\n // Config is not loaded yet\n if (!state.localizedConfig) {\n return null;\n }\n\n // Config has loaded but there is no breadcrumbs config\n // eslint-disable-next-line @stencil/strict-boolean-conditions\n if (!state.localizedConfig.breadcrumb) {\n console.warn(\n `Internet Header: Current project \"${state.projectId}\" does not include a breadcrumb config. The breadcrumbs will not be rendered. Remove `,\n document.querySelector('swisspost-internet-breadcrumbs'),\n `from your markup or configure the breadcrumbs in your portal config to stop seeing this warning.`,\n );\n return null;\n }\n\n const breadcrumbConfig = state.localizedConfig.breadcrumb;\n const items =\n this.customBreadcrumbItems !== undefined\n ? [...breadcrumbConfig.items, ...this.customBreadcrumbItems]\n : breadcrumbConfig.items;\n\n return (\n <Host>\n <SvgSprite />\n <div class=\"breadcrumbs\">\n <div class=\"hidden-control-breadcrumbs\" aria-hidden=\"true\" tabindex=\"-1\">\n <nav class=\"breadcrumbs-nav\" ref={e => e !== undefined && this.handleControlNavRef(e)}>\n <BreadcrumbList\n items={items}\n focusable={false}\n clickHandler={() => {}}\n ></BreadcrumbList>\n </nav>\n </div>\n <nav\n aria-label={breadcrumbConfig.a11yLabel}\n ref={e => e !== undefined && this.handleVisibleNavRef(e)}\n class={{\n 'breadcrumbs-nav': true,\n 'visually-hidden': !this.refsReady,\n }}\n >\n <BreadcrumbList\n items={items}\n dropdownOpen={this.dropdownOpen}\n isConcatenated={this.isConcatenated}\n clickHandler={() => this.handleToggleDropdown()}\n ></BreadcrumbList>\n </nav>\n <div class=\"breadcrumb-buttons\">\n {breadcrumbConfig.buttons.map(button => (\n <button\n class=\"btn btn-secondary btn-icon\"\n key={button.text}\n aria-expanded={`${this.overlayVisible && this.currentOverlay === button.overlay}`}\n onClick={() => this.toggleOverlay(button.overlay, true)}\n >\n <SvgIcon name={button.svgIcon.name}></SvgIcon>\n <span class=\"visually-hidden\">{button.text}</span>\n </button>\n ))}\n </div>\n {this.overlayVisible && (\n <OverlayComponent\n overlayRef={e => e !== undefined && this.overlayRef(e)}\n iFrameRef={e => e !== undefined && this.registerIFrameResizer(e)}\n overlay={this.currentOverlay}\n onClick={() => this.handleToggleOverlay()}\n onKeyDown={(e: KeyboardEvent) => this.handleKeyDown(e)}\n closeButtonText={state.localizedConfig.header.translations.closeButtonText}\n ></OverlayComponent>\n )}\n </div>\n <slot></slot>\n </Host>\n );\n }\n}\n"]}
@@ -43,6 +43,13 @@
43
43
  * will be available as sass-variables
44
44
  * but should not be used.
45
45
  */
46
+ /**
47
+ * Colors used by the post style guide
48
+ */
49
+ /**
50
+ * Maps. Allow maps to have custom colors from the project
51
+ * by always merging into a default empty map
52
+ */
46
53
  :root {
47
54
  --bs-breakpoint-xs: 0;
48
55
  --bs-breakpoint-sm: 400px;
@@ -92,7 +99,7 @@
92
99
 
93
100
  .row-cols-3 > * {
94
101
  flex: 0 0 auto;
95
- width: 33.3333333333%;
102
+ width: 33.33333333%;
96
103
  }
97
104
 
98
105
  .row-cols-4 > * {
@@ -107,7 +114,7 @@
107
114
 
108
115
  .row-cols-6 > * {
109
116
  flex: 0 0 auto;
110
- width: 16.6666666667%;
117
+ width: 16.66666667%;
111
118
  }
112
119
 
113
120
  .col-auto {
@@ -297,7 +304,7 @@
297
304
  }
298
305
  .row-cols-sm-3 > * {
299
306
  flex: 0 0 auto;
300
- width: 33.3333333333%;
307
+ width: 33.33333333%;
301
308
  }
302
309
  .row-cols-sm-4 > * {
303
310
  flex: 0 0 auto;
@@ -309,7 +316,7 @@
309
316
  }
310
317
  .row-cols-sm-6 > * {
311
318
  flex: 0 0 auto;
312
- width: 16.6666666667%;
319
+ width: 16.66666667%;
313
320
  }
314
321
  .col-sm-auto {
315
322
  flex: 0 0 auto;
@@ -466,7 +473,7 @@
466
473
  }
467
474
  .row-cols-rg-3 > * {
468
475
  flex: 0 0 auto;
469
- width: 33.3333333333%;
476
+ width: 33.33333333%;
470
477
  }
471
478
  .row-cols-rg-4 > * {
472
479
  flex: 0 0 auto;
@@ -478,7 +485,7 @@
478
485
  }
479
486
  .row-cols-rg-6 > * {
480
487
  flex: 0 0 auto;
481
- width: 16.6666666667%;
488
+ width: 16.66666667%;
482
489
  }
483
490
  .col-rg-auto {
484
491
  flex: 0 0 auto;
@@ -635,7 +642,7 @@
635
642
  }
636
643
  .row-cols-md-3 > * {
637
644
  flex: 0 0 auto;
638
- width: 33.3333333333%;
645
+ width: 33.33333333%;
639
646
  }
640
647
  .row-cols-md-4 > * {
641
648
  flex: 0 0 auto;
@@ -647,7 +654,7 @@
647
654
  }
648
655
  .row-cols-md-6 > * {
649
656
  flex: 0 0 auto;
650
- width: 16.6666666667%;
657
+ width: 16.66666667%;
651
658
  }
652
659
  .col-md-auto {
653
660
  flex: 0 0 auto;
@@ -804,7 +811,7 @@
804
811
  }
805
812
  .row-cols-lg-3 > * {
806
813
  flex: 0 0 auto;
807
- width: 33.3333333333%;
814
+ width: 33.33333333%;
808
815
  }
809
816
  .row-cols-lg-4 > * {
810
817
  flex: 0 0 auto;
@@ -816,7 +823,7 @@
816
823
  }
817
824
  .row-cols-lg-6 > * {
818
825
  flex: 0 0 auto;
819
- width: 16.6666666667%;
826
+ width: 16.66666667%;
820
827
  }
821
828
  .col-lg-auto {
822
829
  flex: 0 0 auto;
@@ -973,7 +980,7 @@
973
980
  }
974
981
  .row-cols-xl-3 > * {
975
982
  flex: 0 0 auto;
976
- width: 33.3333333333%;
983
+ width: 33.33333333%;
977
984
  }
978
985
  .row-cols-xl-4 > * {
979
986
  flex: 0 0 auto;
@@ -985,7 +992,7 @@
985
992
  }
986
993
  .row-cols-xl-6 > * {
987
994
  flex: 0 0 auto;
988
- width: 16.6666666667%;
995
+ width: 16.66666667%;
989
996
  }
990
997
  .col-xl-auto {
991
998
  flex: 0 0 auto;
@@ -1142,7 +1149,7 @@
1142
1149
  }
1143
1150
  .row-cols-xxl-3 > * {
1144
1151
  flex: 0 0 auto;
1145
- width: 33.3333333333%;
1152
+ width: 33.33333333%;
1146
1153
  }
1147
1154
  .row-cols-xxl-4 > * {
1148
1155
  flex: 0 0 auto;
@@ -1154,7 +1161,7 @@
1154
1161
  }
1155
1162
  .row-cols-xxl-6 > * {
1156
1163
  flex: 0 0 auto;
1157
- width: 16.6666666667%;
1164
+ width: 16.66666667%;
1158
1165
  }
1159
1166
  .col-xxl-auto {
1160
1167
  flex: 0 0 auto;
@@ -1507,9 +1514,6 @@
1507
1514
  }
1508
1515
  }
1509
1516
 
1510
- /*!
1511
- * Copyright 2021 by Swiss Post, Information Technology
1512
- */
1513
1517
  /**
1514
1518
  * Generate responsive size properties for things like height, width, margin, padding, etc.
1515
1519
  * @param $curve-size One of the curve sizes predefined at https://www.experience-hub.ch/document/2307#/grundlagen-web/abstaende
@@ -1585,7 +1589,8 @@
1585
1589
  .btn:where(:not(.btn-link, .btn-tertiary)) {
1586
1590
  padding: 0 1rem;
1587
1591
  }
1588
- .btn > .pi {
1592
+ .btn > .pi,
1593
+ .btn > post-icon {
1589
1594
  width: 1.25rem;
1590
1595
  height: 1.25rem;
1591
1596
  }
@@ -1728,7 +1733,8 @@
1728
1733
  .btn-sm:where(:not(.btn-link, .btn-tertiary)) {
1729
1734
  padding: 0 0.75rem;
1730
1735
  }
1731
- .btn-sm > .pi {
1736
+ .btn-sm > .pi,
1737
+ .btn-sm > post-icon {
1732
1738
  width: 1rem;
1733
1739
  height: 1rem;
1734
1740
  }
@@ -1741,7 +1747,8 @@
1741
1747
  .btn-rg:where(:not(.btn-link, .btn-tertiary)) {
1742
1748
  padding: 0 0.875rem;
1743
1749
  }
1744
- .btn-rg > .pi {
1750
+ .btn-rg > .pi,
1751
+ .btn-rg > post-icon {
1745
1752
  width: 1.125rem;
1746
1753
  height: 1.125rem;
1747
1754
  }
@@ -1754,7 +1761,8 @@
1754
1761
  .btn-lg:where(:not(.btn-link, .btn-tertiary)) {
1755
1762
  padding: 0 1.125rem;
1756
1763
  }
1757
- .btn-lg > .pi {
1764
+ .btn-lg > .pi,
1765
+ .btn-lg > post-icon {
1758
1766
  width: 1.375rem;
1759
1767
  height: 1.375rem;
1760
1768
  }
@@ -1,6 +1,8 @@
1
1
  import { debounce } from 'throttle-debounce';
2
2
  import { state } from '../../../data/store';
3
+ import { getScrollParent } from '../../../utils/scrollparent';
3
4
  export const registerLogoAnimationObserver = (target, headerRef) => {
5
+ const scrollParent = getScrollParent(headerRef);
4
6
  /**
5
7
  * Set intersection ratio as CSS custom property
6
8
  */
@@ -9,7 +11,8 @@ export const registerLogoAnimationObserver = (target, headerRef) => {
9
11
  let scale = 1;
10
12
  // Minus 1px border at the bottom that the logo is not covering
11
13
  const adjustedHeaderHeight = headerRef.clientHeight - 1;
12
- const scrollY = fullStickyness ? 0 : window.scrollY;
14
+ const scrollDistance = scrollParent instanceof Element ? scrollParent.scrollTop : scrollParent.documentElement.scrollTop;
15
+ const scrollY = fullStickyness ? 0 : scrollDistance;
13
16
  // If meta navigation is not visible (mobile, not configured), scale should just be 1
14
17
  if (target.clientHeight > 0) {
15
18
  scale = Math.max((adjustedHeaderHeight - Math.max(scrollY, 0)) /
@@ -25,13 +28,13 @@ export const registerLogoAnimationObserver = (target, headerRef) => {
25
28
  const observer = new IntersectionObserver(entries => {
26
29
  entries.forEach(entry => {
27
30
  if (entry.isIntersecting && entry.intersectionRatio > 0) {
28
- window.addEventListener('scroll', handleScroll, { passive: true });
31
+ scrollParent.addEventListener('scroll', handleScroll, { passive: true });
29
32
  window.addEventListener('resize', debounced);
30
33
  // Ensure callback is called at least once in case main thread is too busy while scrolling up
31
34
  window.requestAnimationFrame(handleScroll);
32
35
  }
33
36
  else {
34
- window.removeEventListener('scroll', handleScroll);
37
+ scrollParent.removeEventListener('scroll', handleScroll);
35
38
  window.removeEventListener('resize', debounced);
36
39
  window.requestAnimationFrame(handleScroll);
37
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"logo-animation.js","sourceRoot":"","sources":["../../../../../src/components/post-internet-header/logo-animation/logo-animation.ts"],"names":[],"mappings":"AAAA,OAAO,E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AM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAE7C,6FAA6F;QAC7F,MAAM,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;OAC5C;WAAM;QACL,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QACnD,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAChD,MAAM,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;OAC5C;IACH,CAAC,CAAC,CAAC;EACL,CAAC,EACD;IACE,kFAAkF;IAClF,SAAS,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC;GACtB,CACF,CAAC;EACF,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;EAEzB,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC","sourcesContent":["import { debounce } from 'throttle-debounce';\nimport { state } from '../../../data/store';\n\nexport const registerLogoAnimationObserver = (\n target: HTMLElement,\n headerRef: HTMLSwisspostInternetHeaderElement,\n) => {\n /**\n * Set intersection ratio as CSS custom property\n */\n const handleScroll = () => {\n const fullStickyness = state.stickyness === 'full';\n let scale = 1;\n // Minus 1px border at the bottom that the logo is not covering\n const adjustedHeaderHeight = headerRef.clientHeight - 1;\n const scrollY = fullStickyness ? 0 : window.scrollY;\n\n // If meta navigation is not visible (mobile, not configured), scale should just be 1\n if (target.clientHeight > 0) {\n scale = Math.max(\n (adjustedHeaderHeight - Math.max(scrollY, 0)) /\n (adjustedHeaderHeight - target.clientHeight),\n 1,\n );\n }\n headerRef.style.setProperty('--logo-scale', scale.toString());\n };\n\n const debounced = debounce(150, handleScroll);\n\n /**\n * Observe the meta navigation in order to not track scroll events throughout the whole page.\n * This ensures that the scroll listener is only active while the meta navigation is visible.\n */\n const observer = new IntersectionObserver(\n entries => {\n entries.forEach(entry => {\n if (entry.isIntersecting && entry.intersectionRatio > 0) {\n window.addEventListener('scroll', handleScroll, { passive: true });\n window.addEventListener('resize', debounced);\n\n // Ensure callback is called at least once in case main thread is too busy while scrolling up\n window.requestAnimationFrame(handleScroll);\n } else {\n window.removeEventListener('scroll', handleScroll);\n window.removeEventListener('resize', debounced);\n window.requestAnimationFrame(handleScroll);\n }\n });\n },\n {\n // Fires when element leaves viewport (0) and when it just about enters it (0.001)\n threshold: [0, 0.001],\n },\n );\n observer.observe(target);\n\n return handleScroll;\n};\n"]}
1
+ {"version":3,"file":"logo-animation.js","sourceRoot":"","sources":["../../../../../src/components/post-internet-header/logo-animation/logo-animation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,MAAmB,EACnB,SAA6C,EAC7C,EAAE;EACF,MAAM,YAAY,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;EAEhD;;KAEG;EACH,MAAM,YAAY,GAAG,GAAG,EAAE;IACxB,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,KAAK,MAAM,CAAC;IACnD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,+DAA+D;IAC/D,MAAM,oBAAoB,GAAG,SAAS,CAAC,YAAY,GAAG,CAAC,CAAC;IACxD,MAAM,cAAc,GAAG,YAAY,YAAY,OAAO,CAAE,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,eAAe,CAAC,SAAS,CAAC;IAC1H,MAAM,OAAO,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;IAEpD,qFAAqF;IACrF,IAAI,MAAM,CAAC,YAAY,GAAG,CAAC,EAAE;MAC3B,KAAK,GAAG,IAAI,CAAC,GAAG,CACd,CAAC,oBAAoB,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC3C,CAAC,oBAAoB,GAAG,MAAM,CAAC,YAAY,CAAC,EAC9C,CAAC,CACF,CAAC;KACH;IACD,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,cAAc,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;EAChE,CAAC,CAAC;EAEF,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;EAE9C;;;KAGG;EACH,MAAM,QAAQ,GAAG,IAAI,oBAAoB,CACvC,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;MACtB,IAAI,KAAK,CAAC,cAAc,IAAI,KAAK,CAAC,iBAAiB,GAAG,CAAC,EAAE;QACvD,YAAY,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACzE,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAE7C,6FAA6F;QAC7F,MAAM,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;OAC5C;WAAM;QACL,YAAY,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QACzD,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAChD,MAAM,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;OAC5C;IACH,CAAC,CAAC,CAAC;EACL,CAAC,EACD;IACE,kFAAkF;IAClF,SAAS,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC;GACtB,CACF,CAAC;EACF,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;EAEzB,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC","sourcesContent":["import { debounce } from 'throttle-debounce';\nimport { state } from '../../../data/store';\nimport { getScrollParent } from '../../../utils/scrollparent';\n\nexport const registerLogoAnimationObserver = (\n target: HTMLElement,\n headerRef: HTMLSwisspostInternetHeaderElement,\n) => {\n const scrollParent = getScrollParent(headerRef);\n\n /**\n * Set intersection ratio as CSS custom property\n */\n const handleScroll = () => {\n const fullStickyness = state.stickyness === 'full';\n let scale = 1;\n // Minus 1px border at the bottom that the logo is not covering\n const adjustedHeaderHeight = headerRef.clientHeight - 1;\n const scrollDistance = scrollParent instanceof Element ? scrollParent.scrollTop : scrollParent.documentElement.scrollTop;\n const scrollY = fullStickyness ? 0 : scrollDistance;\n\n // If meta navigation is not visible (mobile, not configured), scale should just be 1\n if (target.clientHeight > 0) {\n scale = Math.max(\n (adjustedHeaderHeight - Math.max(scrollY, 0)) /\n (adjustedHeaderHeight - target.clientHeight),\n 1,\n );\n }\n headerRef.style.setProperty('--logo-scale', scale.toString());\n };\n\n const debounced = debounce(150, handleScroll);\n\n /**\n * Observe the meta navigation in order to not track scroll events throughout the whole page.\n * This ensures that the scroll listener is only active while the meta navigation is visible.\n */\n const observer = new IntersectionObserver(\n entries => {\n entries.forEach(entry => {\n if (entry.isIntersecting && entry.intersectionRatio > 0) {\n scrollParent.addEventListener('scroll', handleScroll, { passive: true });\n window.addEventListener('resize', debounced);\n\n // Ensure callback is called at least once in case main thread is too busy while scrolling up\n window.requestAnimationFrame(handleScroll);\n } else {\n scrollParent.removeEventListener('scroll', handleScroll);\n window.removeEventListener('resize', debounced);\n window.requestAnimationFrame(handleScroll);\n }\n });\n },\n {\n // Fires when element leaves viewport (0) and when it just about enters it (0.001)\n threshold: [0, 0.001],\n },\n );\n observer.observe(target);\n\n return handleScroll;\n};\n"]}
@@ -1,13 +1,14 @@
1
- import { Host, h, } from '@stencil/core';
1
+ import { h, Host, } from '@stencil/core';
2
2
  import { debounce, throttle } from 'throttle-debounce';
3
3
  import { getLocalizedConfig, getLocalizedCustomConfig, isValidProjectId, } from '../../services/config.service';
4
- import { state, dispose } from '../../data/store';
4
+ import { dispose, state } from '../../data/store';
5
5
  import { SvgSprite } from '../../utils/svg-sprite.component';
6
6
  import { SvgIcon } from '../../utils/svg-icon.component';
7
- import { translate } from '../../services/language.service';
7
+ import { getUserLang, translate } from '../../services/language.service';
8
8
  import { If } from '../../utils/if.component';
9
9
  import packageJson from '../../../package.json';
10
10
  import { registerLogoAnimationObserver } from './logo-animation/logo-animation';
11
+ import { getScrollParent } from '../../utils/scrollparent';
11
12
  export class PostInternetHeader {
12
13
  /**
13
14
  * Get the currently set language as a two letter string ("de", "fr" "it" or "en")
@@ -46,16 +47,17 @@ export class PostInternetHeader {
46
47
  connectedCallback() {
47
48
  this.throttledScroll = throttle(300, () => this.handleScrollEvent());
48
49
  this.debouncedResize = debounce(200, () => this.handleResize());
49
- window.addEventListener('scroll', this.throttledScroll, { passive: true });
50
- window.addEventListener('resize', this.debouncedResize, { passive: true });
51
50
  }
52
51
  disconnectedCallback() {
53
- window.removeEventListener('scroll', this.throttledScroll);
54
- window.removeEventListener('resize', this.debouncedResize);
52
+ this.scrollParent.removeEventListener('scroll', this.throttledScroll);
53
+ this.scrollParent.removeEventListener('resize', this.debouncedResize);
55
54
  // Reset the store to its original state
56
55
  dispose();
57
56
  }
58
57
  async componentWillLoad() {
58
+ this.scrollParent = getScrollParent(this.host);
59
+ this.scrollParent.addEventListener('scroll', this.throttledScroll, { passive: true });
60
+ this.scrollParent.addEventListener('resize', this.debouncedResize, { passive: true });
59
61
  // Wait for the config to arrive, then render the header
60
62
  try {
61
63
  state.projectId = this.project;
@@ -71,8 +73,10 @@ export class PostInternetHeader {
71
73
  typeof this.osFlyoutOverrides === 'string'
72
74
  ? JSON.parse(this.osFlyoutOverrides)
73
75
  : this.osFlyoutOverrides;
74
- if (this.customConfig !== undefined && state.currentLanguage !== null) {
75
- state.localizedCustomConfig = getLocalizedCustomConfig(this.customConfig, state.currentLanguage);
76
+ if (this.customConfig !== undefined) {
77
+ const langs = Object.keys(typeof this.customConfig === 'string' ? JSON.parse(this.customConfig) : this.customConfig);
78
+ const lang = state.currentLanguage || getUserLang(langs, this.language);
79
+ state.localizedCustomConfig = getLocalizedCustomConfig(this.customConfig, lang);
76
80
  }
77
81
  state.localizedConfig = await getLocalizedConfig({
78
82
  projectId: this.project,
@@ -116,7 +120,7 @@ export class PostInternetHeader {
116
120
  if (this.customConfig)
117
121
  state.localizedCustomConfig = getLocalizedCustomConfig(this.customConfig, newValue);
118
122
  }
119
- handleAvailableLanguagesChage(newValue) {
123
+ handleAvailableLanguagesChange(newValue) {
120
124
  state.languageSwitchOverrides = typeof newValue === 'string' ? JSON.parse(newValue) : newValue;
121
125
  }
122
126
  async handleOsFlyoutOverrides(newValue) {
@@ -170,31 +174,34 @@ export class PostInternetHeader {
170
174
  state.meta = newValue;
171
175
  }
172
176
  handleLanguageChangeEvent(event) {
173
- this.handleLanguageChange(event.detail);
177
+ void this.handleLanguageChange(event.detail);
174
178
  }
175
179
  handleStickynessChange(newValue) {
176
180
  state.stickyness = newValue;
177
- this.updateLogoAnimation();
181
+ if (typeof this.updateLogoAnimation === 'function')
182
+ this.updateLogoAnimation();
178
183
  }
179
184
  handleClickOutside(event) {
180
185
  // Close active dropdown element on click outside of it
181
186
  if (this.activeDropdownElement && !event.composedPath().includes(this.activeDropdownElement)) {
182
- this.activeDropdownElement.toggleDropdown(false);
187
+ void this.activeDropdownElement.toggleDropdown(false);
183
188
  }
184
189
  }
185
190
  handleKeyUp(event) {
186
191
  if (event.key === 'Escape') {
187
192
  if (this.activeDropdownElement) {
188
- this.activeDropdownElement.toggleDropdown(false);
193
+ void this.activeDropdownElement.toggleDropdown(false);
189
194
  }
190
195
  if (this.activeFlyout !== null && this.mainNav) {
191
- this.mainNav.toggleDropdown(false);
196
+ void this.mainNav.toggleDropdown(false);
192
197
  }
193
198
  }
194
199
  }
195
200
  handleScrollEvent() {
196
201
  // Credits: "https://github.com/qeremy/so/blob/master/so.dom.js#L426"
197
- const st = window.scrollY || document.documentElement.scrollTop;
202
+ const st = this.scrollParent instanceof Document
203
+ ? this.scrollParent.documentElement.scrollTop
204
+ : this.scrollParent.scrollTop;
198
205
  // Toggle class without re-rendering the component if stickyness is minimal
199
206
  // the other stickyness modes do not need the class
200
207
  if (this.stickyness === 'minimal') {
@@ -223,13 +230,13 @@ export class PostInternetHeader {
223
230
  // a circle or an outdated state, we'll not handle this event
224
231
  return;
225
232
  }
226
- if (event.detail.open === true) {
233
+ if (event.detail.open) {
227
234
  if (this.activeDropdownElement) {
228
- this.activeDropdownElement.toggleDropdown(false);
235
+ void this.activeDropdownElement.toggleDropdown(false);
229
236
  }
230
237
  this.activeDropdownElement = event.detail.element;
231
238
  if (window.innerWidth >= 1024) {
232
- // Add event listener to close active dropdown element on click outsite of it
239
+ // Add event listener to close active dropdown element on click outside of it
233
240
  // Also adds 10ms delay in case of an external interaction:
234
241
  // Some button on the page calls toggleDropdown() -> dropdown opens
235
242
  // Click event bubbles to the window, this.handleClickOutsideBound closes dropdown again
@@ -238,7 +245,7 @@ export class PostInternetHeader {
238
245
  }, 10);
239
246
  }
240
247
  if (this.activeFlyout !== null && this.mainNav) {
241
- this.mainNav.setActiveFlyout(null);
248
+ void this.mainNav.setActiveFlyout(null);
242
249
  }
243
250
  }
244
251
  else {
@@ -254,7 +261,7 @@ export class PostInternetHeader {
254
261
  handleFlyoutToggled(event) {
255
262
  this.activeFlyout = event.detail;
256
263
  if (this.activeDropdownElement && event.detail && !this.isMainNavOpen()) {
257
- this.activeDropdownElement.toggleDropdown(false);
264
+ void this.activeDropdownElement.toggleDropdown(false);
258
265
  }
259
266
  }
260
267
  toggleMobileDropdown() {
@@ -276,7 +283,7 @@ export class PostInternetHeader {
276
283
  ((_b = config.header.navMeta) === null || _b === void 0 ? void 0 : _b.filter(meta => !meta.isHomeLink).length) > 0;
277
284
  const renderLogin = ((_c = this.login) !== null && _c !== void 0 ? _c : !config.header.isLoginWidgetHidden) && config.header.loginWidgetOptions;
278
285
  const renderLanguageSwitch = config.header.navLang.length > 1;
279
- return (h(Host, { class: `stickyness-${this.stickyness} ${this.activeDropdownElement || 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 === true }, h("post-skiplinks", null)), h(If, { condition: renderMetaNavigation === true }, h("post-meta-navigation", { orientation: "horizontal", class: "hidden-lg", "full-width": this.fullWidth, ref: el => (this.metaNav = el) }, h(If, { condition: renderLanguageSwitch === true }, 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 === true }, h("post-meta-navigation", { orientation: "vertical" }, h(If, { condition: renderLanguageSwitch === true }, h("post-language-switch", { id: "post-language-switch-mobile", mode: "list" }))))), h("div", { class: "main-navigation-controls" }, h(If, { condition: this.search !== false }, h("post-search", { onDropdownToggled: e => this.handleDropdownToggled(e) })), h(If, { condition: !!renderLogin }, h("post-klp-login-widget", null, h("slot", { name: "login-widget" }))), h(If, { condition: renderMetaNavigation === false && renderLanguageSwitch === true }, h("post-language-switch", { id: "post-language-switch-no-meta", onDropdownToggled: e => this.handleDropdownToggled(e), mode: "dropdown" })), h("slot", { name: "main" }))))));
286
+ 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", null, 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" }))))));
280
287
  }
281
288
  static get is() { return "swisspost-internet-header"; }
282
289
  static get encapsulation() { return "shadow"; }
@@ -336,8 +343,8 @@ export class PostInternetHeader {
336
343
  "type": "string",
337
344
  "mutable": false,
338
345
  "complexType": {
339
- "original": "string",
340
- "resolved": "string | undefined",
346
+ "original": "'de' | 'fr' | 'it' | 'en'",
347
+ "resolved": "\"de\" | \"en\" | \"fr\" | \"it\" | undefined",
341
348
  "references": {}
342
349
  },
343
350
  "required": false,
@@ -478,7 +485,7 @@ export class PostInternetHeader {
478
485
  "optional": true,
479
486
  "docs": {
480
487
  "tags": [],
481
- "text": "Override the language switch links with custom URLs. Helpful when your application contains sub-pages and you\nwould like to stay on subpages when the user changes language."
488
+ "text": "Override the language switch links with custom URLs. Helpful when your application contains sub-pages, and you\nwould like to stay on subpages when the user changes language."
482
489
  },
483
490
  "attribute": "language-switch-overrides",
484
491
  "reflect": false
@@ -654,7 +661,7 @@ export class PostInternetHeader {
654
661
  "methodName": "handleLanguageChange"
655
662
  }, {
656
663
  "propName": "languageSwitchOverrides",
657
- "methodName": "handleAvailableLanguagesChage"
664
+ "methodName": "handleAvailableLanguagesChange"
658
665
  }, {
659
666
  "propName": "osFlyoutOverrides",
660
667
  "methodName": "handleOsFlyoutOverrides"