@postnord/pn-marketweb-components 2.0.90 → 2.0.91

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.
@@ -1,15 +1,15 @@
1
- import { Component, Prop, h, State, Element, Listen, Watch, Host, Event } from "@stencil/core";
2
- import { translations } from "./translations";
3
- import { MarketWebContextService } from "../../../globals/MarketWebContextService";
4
- import { MarketWebLoginManager } from "../../../globals/MarketWebLoginManager";
5
- import { FetchHelper } from "../../../globals/FetchHelper";
1
+ import { Component, Element, Event, h, Host, Listen, Prop, State, Watch, } from '@stencil/core';
2
+ import { FetchHelper } from '../../../globals/FetchHelper';
3
+ import { MarketWebContextService } from '../../../globals/MarketWebContextService';
4
+ import { MarketWebLoginManager } from '../../../globals/MarketWebLoginManager';
5
+ import { translations } from './translations';
6
6
  export class PnMarketwebSiteheader {
7
7
  constructor() {
8
- this.endpointPath = "/api/navigation/header";
8
+ this.endpointPath = '/api/navigation/header';
9
9
  // allowedLanguages = ["sv","da","fi","no","en"];
10
10
  // allowedMarkets = ["se","dk","fi","no","com", "tpl"];
11
11
  /** Specifies which market we want to show (se,dk,fi,no,com) */
12
- this.market = null; //se
12
+ this.market = null; //se
13
13
  /** Specifies which language we want to show (sv,da,fi,no,en) */
14
14
  this.language = null; //sv
15
15
  /** Specifies the current site id (guid) */
@@ -17,9 +17,9 @@ export class PnMarketwebSiteheader {
17
17
  /** Specifies which environment we're fetching data from. (production, preproduction, integration, localhost) */
18
18
  this.environment = null; //sv
19
19
  /** Access token passed from backend */
20
- this.userToken = "";
20
+ this.userToken = '';
21
21
  /** User Fullname */
22
- this.userFullname = "";
22
+ this.userFullname = '';
23
23
  /** User Logged in state from the backend */
24
24
  this.userLoggedin = false;
25
25
  /** Specifies which endpoint domain we should load from */
@@ -37,17 +37,26 @@ export class PnMarketwebSiteheader {
37
37
  /** Adjusts the menus URLs */
38
38
  this.siteDomainInUrls = false;
39
39
  /** Autocomplete endpoint */
40
- this.AutocompleteEndpoint = "";
40
+ this.AutocompleteEndpoint = '';
41
41
  /** Forward session to backend */
42
42
  this.sessionForward = false;
43
43
  /** If the component should use cached requests */
44
44
  this.cache = false;
45
45
  /** Event based only language switch */
46
46
  this.spaMode = false;
47
- this.i18n = { "searchlabel": "", "searchplaceholder": "", "searchbuttontext": "", "menuHomeButton": "", "menuGoBackButton": "", "mainMenuButton": "", "menuStartButton": "", "profileSelectionFlyoutHeading": "" };
47
+ this.i18n = {
48
+ searchlabel: '',
49
+ searchplaceholder: '',
50
+ searchbuttontext: '',
51
+ menuHomeButton: '',
52
+ menuGoBackButton: '',
53
+ mainMenuButton: '',
54
+ menuStartButton: '',
55
+ profileSelectionFlyoutHeading: '',
56
+ };
48
57
  this.gotData = false;
49
58
  this.fetchingData = false;
50
- this.homePageLink = "/";
59
+ this.homePageLink = '/';
51
60
  // Menu state
52
61
  this.menuItems = [];
53
62
  // Search
@@ -62,7 +71,7 @@ export class PnMarketwebSiteheader {
62
71
  this.minimizeSearch = false;
63
72
  this.loggedIn = false;
64
73
  // FetchHelper
65
- this.fetchHelper = new FetchHelper("siteheader");
74
+ this.fetchHelper = new FetchHelper('siteheader');
66
75
  // Login manager
67
76
  this.loginManager = null;
68
77
  }
@@ -90,13 +99,15 @@ export class PnMarketwebSiteheader {
90
99
  this.endpoint = await marketWebContextService.getEndpoint(this.environment, this.market);
91
100
  }
92
101
  if (!this.endpoint) {
93
- this.endpoint = "";
102
+ this.endpoint = '';
94
103
  }
95
104
  }
96
105
  async init() {
97
106
  this.setTranslations();
98
107
  await this.fetchData();
99
- window.setTimeout(() => { this.checkMenuOverflow(); }, 50);
108
+ window.setTimeout(() => {
109
+ this.checkMenuOverflow();
110
+ }, 50);
100
111
  }
101
112
  setTranslations() {
102
113
  if (this.language && translations[this.language]) {
@@ -122,11 +133,11 @@ export class PnMarketwebSiteheader {
122
133
  return;
123
134
  }
124
135
  this.fetchingData = true;
125
- const endpointBase = (this.endpoint.lastIndexOf("/") === this.endpoint.length - 1) ? this.endpoint.substring(0, this.endpoint.length - 1) : this.endpoint;
136
+ const endpointBase = this.endpoint.lastIndexOf('/') === this.endpoint.length - 1 ? this.endpoint.substring(0, this.endpoint.length - 1) : this.endpoint;
126
137
  const fetchUrl = `${endpointBase}${this.endpointPath}?market=${this.market}&language=${this.language}`;
127
- const data = await this.fetchHelper.fetchJson(fetchUrl, {
128
- 'mode': 'cors'
129
- }, this.cache, this.onFetchRefreshed.bind(this));
138
+ const data = (await this.fetchHelper.fetchJson(fetchUrl, {
139
+ mode: 'cors',
140
+ }, this.cache, this.onFetchRefreshed.bind(this)));
130
141
  await this.setStateFromData(data);
131
142
  }
132
143
  onFetchRefreshed(data) {
@@ -142,18 +153,20 @@ export class PnMarketwebSiteheader {
142
153
  }
143
154
  const siteUrl = this.siteDefinition.url;
144
155
  // Add trailing slash to domain if it's missing
145
- return siteUrl + ((siteUrl.lastIndexOf("/") !== siteUrl.length - 1) ? "/" : "") + item.twoLetterISOLanguageName;
156
+ return siteUrl + (siteUrl.lastIndexOf('/') !== siteUrl.length - 1 ? '/' : '') + item.twoLetterISOLanguageName;
146
157
  }
147
158
  async setStateFromData(data) {
148
159
  var _a, _b, _c;
149
- if (typeof data !== "object") {
160
+ if (typeof data !== 'object') {
150
161
  console.warn('Data was not valid', data);
151
162
  }
152
163
  // Set site definition
153
164
  this.siteDefinition = data.sitedefinition;
154
165
  // Set navigation information
155
166
  if (this.siteDomainInUrls) {
156
- this.menuItems = data.mainMenu.menuItems.map((item) => { return this.adjustMenuItemUrls(item); });
167
+ this.menuItems = data.mainMenu.menuItems.map(item => {
168
+ return this.adjustMenuItemUrls(item);
169
+ });
157
170
  }
158
171
  else {
159
172
  this.menuItems = data.mainMenu.menuItems;
@@ -166,7 +179,7 @@ export class PnMarketwebSiteheader {
166
179
  id: 'homelink',
167
180
  open: false,
168
181
  selected: false,
169
- children: []
182
+ children: [],
170
183
  });
171
184
  }
172
185
  // Set search
@@ -178,29 +191,41 @@ export class PnMarketwebSiteheader {
178
191
  this.setLanguageOptions();
179
192
  let loginDialog = data.loginViewModel;
180
193
  if (loginDialog && this.siteDomainInUrls) {
181
- loginDialog.loggedInLinks = loginDialog.loggedInLinks.map((item) => { item.href = this.adjustHref(item.href); return item; });
182
- loginDialog.loginMenuLinks = loginDialog.loginMenuLinks.map((item) => { item.href = this.adjustHref(item.href); return item; });
194
+ loginDialog.loggedInLinks = loginDialog.loggedInLinks.map(item => {
195
+ item.href = this.adjustHref(item.href);
196
+ return item;
197
+ });
198
+ loginDialog.loginMenuLinks = loginDialog.loginMenuLinks.map(item => {
199
+ item.href = this.adjustHref(item.href);
200
+ return item;
201
+ });
183
202
  }
184
203
  this.loginDialog = loginDialog;
185
204
  await this.spaModeAdjustments();
186
205
  this.gotData = true;
187
206
  this.fetchingData = true;
188
207
  this.homePageLink = (_c = (_b = this.siteDefinition) === null || _b === void 0 ? void 0 : _b.url) !== null && _c !== void 0 ? _c : document.location.hostname;
189
- window.setTimeout(() => { this.checkMenuOverflow(); }, 100);
208
+ window.setTimeout(() => {
209
+ this.checkMenuOverflow();
210
+ }, 100);
190
211
  }
191
212
  adjustMenuItemUrls(item) {
192
213
  item.href = this.adjustHref(item.href);
193
214
  if (item.children && item.children.length > 0) {
194
- let adjustedItems = item.children.map((item) => { return this.adjustMenuItemUrls(item); });
215
+ let adjustedItems = item.children.map(item => {
216
+ return this.adjustMenuItemUrls(item);
217
+ });
195
218
  item.children = adjustedItems;
196
219
  }
197
220
  return item;
198
221
  }
199
222
  adjustHref(href) {
200
- if (href.indexOf("http") === 0) {
223
+ if (href.indexOf('http') === 0) {
201
224
  return href;
202
225
  }
203
- const domainUrl = (this.siteDefinition.url.lastIndexOf("/") === this.siteDefinition.url.length - 1) ? this.siteDefinition.url.substring(0, this.siteDefinition.url.length - 1) : this.siteDefinition.url;
226
+ const domainUrl = this.siteDefinition.url.lastIndexOf('/') === this.siteDefinition.url.length - 1
227
+ ? this.siteDefinition.url.substring(0, this.siteDefinition.url.length - 1)
228
+ : this.siteDefinition.url;
204
229
  href = domainUrl + href;
205
230
  return href;
206
231
  }
@@ -210,14 +235,14 @@ export class PnMarketwebSiteheader {
210
235
  return;
211
236
  }
212
237
  const hrefLangsTags = (_a = Array.prototype.slice.call(document.querySelectorAll('link[rel="alternate"][hreflang]'))) !== null && _a !== void 0 ? _a : [];
213
- const hrefLangs = hrefLangsTags.map((tag) => {
214
- let hrefLangValue = tag.getAttribute("hreflang");
215
- if (hrefLangValue.indexOf("en-") !== -1 || hrefLangValue.indexOf("en_") !== -1) {
238
+ const hrefLangs = hrefLangsTags.map(tag => {
239
+ let hrefLangValue = tag.getAttribute('hreflang');
240
+ if (hrefLangValue.indexOf('en-') !== -1 || hrefLangValue.indexOf('en_') !== -1) {
216
241
  hrefLangValue = hrefLangValue.substring(0, 2);
217
242
  }
218
243
  return hrefLangValue;
219
244
  });
220
- let languageOptions = []; // Reset language options
245
+ let languageOptions = []; // Reset language options
221
246
  this.languageSelector.languages.map((languageOption) => {
222
247
  // In case there are language links present on the page we only show languages that have those tags
223
248
  if (hrefLangs && hrefLangs.length > 0) {
@@ -250,7 +275,7 @@ export class PnMarketwebSiteheader {
250
275
  }
251
276
  }
252
277
  promotedItemId(item) {
253
- return "promo-" + item.linkText.replace(/[^A-Za-z0-9.\\\/]/igm, "");
278
+ return 'promo-' + item.linkText.replace(/[^A-Za-z0-9.\\\/]/gim, '');
254
279
  }
255
280
  handleResize() {
256
281
  requestAnimationFrame(() => {
@@ -267,12 +292,12 @@ export class PnMarketwebSiteheader {
267
292
  return;
268
293
  }
269
294
  const parent = firstMenuLevel.parentElement;
270
- if (parent.tagName.toLocaleLowerCase() !== "nav") {
295
+ if (parent.tagName.toLocaleLowerCase() !== 'nav') {
271
296
  return;
272
297
  }
273
298
  const parentWidth = parent.scrollWidth;
274
299
  const elmWidth = firstMenuLevel.clientWidth;
275
- const isOverFlowed = parentWidth < (elmWidth);
300
+ const isOverFlowed = parentWidth < elmWidth;
276
301
  if (isOverFlowed && this.minimizeSearch === false) {
277
302
  this.minimizeSearch = true;
278
303
  }
@@ -282,7 +307,9 @@ export class PnMarketwebSiteheader {
282
307
  return href;
283
308
  }
284
309
  const loginDomains = ['portal.postnord.com'];
285
- const matchedHref = loginDomains.filter((domain) => { return href.indexOf(domain) !== -1; });
310
+ const matchedHref = loginDomains.filter(domain => {
311
+ return href.indexOf(domain) !== -1;
312
+ });
286
313
  if (matchedHref.length === 0) {
287
314
  return href;
288
315
  }
@@ -295,11 +322,11 @@ export class PnMarketwebSiteheader {
295
322
  h("div", { class: "siteheader-row" },
296
323
  h("div", { class: "siteheader-topleft" },
297
324
  h("slot", { name: "topleft" }),
298
- (this.gotData && this.siteSelector && !this.hideSiteSelector) &&
299
- h("pn-site-selector", { language: this.language, buttontext: (_b = (_a = this.siteSelector) === null || _a === void 0 ? void 0 : _a.currentSiteTitle) !== null && _b !== void 0 ? _b : 'postnord' },
300
- (this.gotData && ((_c = this.siteSelector) === null || _c === void 0 ? void 0 : _c.currentSiteTitle)) &&
301
- h("pn-site-selector-item", { heading: this.siteSelector.currentSiteTitle + ' ', description: this.siteSelector.currentSiteDescription }),
302
- (this.gotData && ((_d = this.siteSelector) === null || _d === void 0 ? void 0 : _d.siteSelections)) && this.siteSelector.siteSelections.map((site) => h("pn-site-selector-item", { heading: site.linkText + ' ', description: site.linkDescription, url: this.adjustSiteSelectorUrl(site.href), newwindow: site.openInNewWindow })))),
325
+ this.gotData && this.siteSelector && !this.hideSiteSelector && (h("pn-site-selector", { language: this.language, buttontext: (_b = (_a = this.siteSelector) === null || _a === void 0 ? void 0 : _a.currentSiteTitle) !== null && _b !== void 0 ? _b : 'postnord' },
326
+ this.gotData && ((_c = this.siteSelector) === null || _c === void 0 ? void 0 : _c.currentSiteTitle) && (h("pn-site-selector-item", { heading: this.siteSelector.currentSiteTitle + ' ', description: this.siteSelector.currentSiteDescription })),
327
+ this.gotData &&
328
+ ((_d = this.siteSelector) === null || _d === void 0 ? void 0 : _d.siteSelections) &&
329
+ this.siteSelector.siteSelections.map(site => (h("pn-site-selector-item", { heading: site.linkText + ' ', description: site.linkDescription, url: this.adjustSiteSelectorUrl(site.href), newwindow: site.openInNewWindow })))))),
303
330
  h("div", { class: "siteheader-logocontainer" },
304
331
  h("a", { href: this.homePageLink, title: "Home", class: "siteheader-logolink" },
305
332
  h("slot", { name: "logo" },
@@ -307,36 +334,32 @@ export class PnMarketwebSiteheader {
307
334
  h("path", { d: "M108.84,13.35c0,6.34-5.17,9-10,9S89,19.76,89,13.63c0-6.28,5.08-9,10-9S108.84,7.25,108.84,13.35Zm-6.56.18a3.4,3.4,0,1,0-6.8,0,3.29,3.29,0,0,0,3.42,3.41A3.24,3.24,0,0,0,102.28,13.54Zm-83,0c0,4.83-3.32,8.82-8.49,8.82a6.54,6.54,0,0,1-4.65-1.57v5.86H0V5.16H6.17V6.8a6.43,6.43,0,0,1,5.11-2.18C16.41,4.62,19.31,8.58,19.31,13.54Zm-6.53,0A3.27,3.27,0,0,0,9.4,10,3.28,3.28,0,0,0,6,13.54,3.29,3.29,0,0,0,9.4,16.95,3.24,3.24,0,0,0,12.78,13.54Zm103.69,0.27c0-2.54,1.54-3.32,3.6-3.32a6.56,6.56,0,0,1,2.08.3L122.3,5.1a3.92,3.92,0,0,0-1.45-.18c-3.45,0-4.38,2.18-4.38,2.18V5.16H110.3V21.84h6.17v-8ZM141.73,0V21.84h-6.16V20.21a6.43,6.43,0,0,1-5.11,2.18c-5.14,0-8-4-8-8.91s3.32-8.82,8.49-8.82a6.54,6.54,0,0,1,4.65,1.57v-5Zm-6,13.48a3.28,3.28,0,0,0-3.41-3.41A3.24,3.24,0,0,0,129,13.47,3.4,3.4,0,1,0,135.75,13.47ZM81.35,4.62c-3.6,0-4.9,2.18-4.9,2.18V5.16H70.29V21.84h6.16V13.29c0-2.11.79-3.08,2.69-3.08s2.18,1.57,2.18,3.57v8.07h6.22V11.6C87.55,7,85.34,4.62,81.35,4.62ZM64.07,1.42H57.9V21.84h6.16V10.36H67l2.81-5.2H64.07V1.42ZM50.26,11.21c-2-.3-2.87-0.3-2.87-1.09s0.81-.94,2.42-0.94a16.15,16.15,0,0,1,5.11.91L56,5.41a24.56,24.56,0,0,0-6.13-.75c-5.89,0-9,2.27-9,5.89,0,2.81,1.66,4.47,6.53,5.11,2.06,0.27,2.81.39,2.81,1.15s-0.82,1-2.24,1a16.67,16.67,0,0,1-6-1.3L40.77,21.3a22.14,22.14,0,0,0,6.68,1c6.35,0,9.28-2.24,9.28-5.89C56.72,13.54,55.15,12,50.26,11.21ZM40.19,13.35c0,6.34-5.17,9-10,9s-9.82-2.6-9.82-8.73c0-6.28,5.08-9,10-9S40.19,7.25,40.19,13.35Zm-6.56.18a3.4,3.4,0,1,0-6.8,0,3.28,3.28,0,0,0,3.41,3.41A3.24,3.24,0,0,0,33.63,13.54Z", fill: "#00A0D6", transform: "translate(0 0)" }))))),
308
335
  h("div", { class: "siteheader-topright" },
309
336
  h("slot", { name: "toprightstart" }),
310
- (this.gotData && this.loginDialog && !this.hideLogin) && (h("pn-marketweb-siteheader-login", { token: this.userToken, fullname: this.userFullname, loggedin: this.userLoggedin, loginDialog: this.loginDialog, endpoint: this.endpoint, i18n: this.i18n, showProfileSelection: this.showProfileSelection })),
311
- (this.gotData && this.languageOptions && this.languageOptions.length) && !this.hideLanguageSelector &&
312
- h("pn-language-selector", { value: this.language }, this.languageOptions.map(language => h("pn-language-selector-option", { name: language.nativeName, code: language.twoLetterISOLanguageName, selected: language.isCurrent, url: this.getLanguageVersionUrl(language) }))),
337
+ this.gotData && this.loginDialog && !this.hideLogin && (h("pn-marketweb-siteheader-login", { token: this.userToken, fullname: this.userFullname, loggedin: this.userLoggedin, loginDialog: this.loginDialog, endpoint: this.endpoint, i18n: this.i18n, showProfileSelection: this.showProfileSelection })),
338
+ this.gotData && this.languageOptions && this.languageOptions.length && !this.hideLanguageSelector && (h("pn-language-selector", { value: this.language }, this.languageOptions.map(language => (h("pn-language-selector-option", { name: language.nativeName, code: language.twoLetterISOLanguageName, selected: language.isCurrent, url: this.getLanguageVersionUrl(language) }))))),
313
339
  h("slot", { name: "toprightend" }))),
314
340
  h("div", { class: "siteheader-row" },
315
- h("div", { class: "siteheader-menu" }, (this.gotData && this.menuItems) && (h("pn-mainnav", { market: this.market, language: this.language, onMenuOpenChange: (e) => {
316
- document.body.setAttribute("data-siteheader-menuopen", (e.detail + ''));
341
+ h("div", { class: "siteheader-menu" }, this.gotData && this.menuItems && (h("pn-mainnav", { market: this.market, language: this.language, onMenuOpenChange: e => {
342
+ document.body.setAttribute('data-siteheader-menuopen', e.detail + '');
317
343
  } },
318
344
  h("pn-mainnav-level", null,
319
- h("pn-mainnav-list", null, this.menuItems.map((item) => {
345
+ h("pn-mainnav-list", null, this.menuItems.map(item => {
320
346
  var _a, _b;
321
- return (h("pn-mainnav-link", { name: item.name, href: item.href, itemid: item.id, target: (_a = item.linkTarget) !== null && _a !== void 0 ? _a : "_self", linkid: item.trackingId }, ((item.promotedMenuItems && item.promotedMenuItems.length > 0) || (item.children && item.children.length > 0)) &&
322
- h("pn-mainnav-level", null,
323
- item.children.length > 0 &&
324
- h("pn-mainnav-list", { heading: ((_b = item.navigationHeading) !== null && _b !== void 0 ? _b : "") }, item.children.map((childitem) => {
325
- var _a;
326
- return (h("pn-mainnav-link", { name: childitem.name, href: childitem.href, target: (_a = childitem.linkTarget) !== null && _a !== void 0 ? _a : "_self", linkid: childitem.trackingId }));
327
- })),
328
- (item.promotedMenuItems && item.promotedMenuItems.length > 0) &&
329
- h("pn-mainnav-list", { heading: item.promotedMenuItemsHeader }, item.promotedMenuItems.map((childitem) => (h("pn-mainnav-link", { href: childitem.href, name: childitem.linkText, target: childitem.openInNewWindow ? "_blank" : "_self", linkid: this.promotedItemId(childitem) + item.id })))))));
347
+ return (h("pn-mainnav-link", { name: item.name, href: item.href, itemid: item.id, target: (_a = item.linkTarget) !== null && _a !== void 0 ? _a : '_self', linkid: item.trackingId }, ((item.promotedMenuItems && item.promotedMenuItems.length > 0) || (item.children && item.children.length > 0)) && (h("pn-mainnav-level", null,
348
+ item.children.length > 0 && (h("pn-mainnav-list", { heading: (_b = item.navigationHeading) !== null && _b !== void 0 ? _b : '' }, item.children.map(childitem => {
349
+ var _a;
350
+ return (h("pn-mainnav-link", { name: childitem.name, href: childitem.href, target: (_a = childitem.linkTarget) !== null && _a !== void 0 ? _a : '_self', linkid: childitem.trackingId }));
351
+ }))),
352
+ item.promotedMenuItems && item.promotedMenuItems.length > 0 && (h("pn-mainnav-list", { heading: item.promotedMenuItemsHeader }, item.promotedMenuItems.map(childitem => (h("pn-mainnav-link", { href: childitem.href, name: childitem.linkText, target: childitem.openInNewWindow ? '_blank' : '_self', linkid: this.promotedItemId(childitem) + item.id })))))))));
330
353
  })),
331
354
  h("div", { slot: "footer", class: "siteheader-menu-footer" },
332
- (this.gotData && this.loginDialog && !this.hideLogin) && (h("pn-marketweb-siteheader-login", { emitEvents: false, loginDialog: this.loginDialog, endpoint: this.endpoint, fullname: this.userFullname, loggedin: this.userLoggedin, i18n: this.i18n, showProfileSelection: this.showProfileSelection })),
333
- (this.gotData && this.languageOptions && this.languageOptions.length) && !this.hideLanguageSelector &&
334
- h("pn-language-selector", { value: this.language }, this.languageOptions.map(language => h("pn-language-selector-option", { name: language.nativeName, code: language.twoLetterISOLanguageName, selected: language.isCurrent, url: this.getLanguageVersionUrl(language) }))),
335
- !this.hideSiteSelector &&
336
- h("pn-site-selector", { language: this.language },
337
- (this.gotData && ((_e = this.siteSelector) === null || _e === void 0 ? void 0 : _e.currentSiteTitle)) &&
338
- h("pn-site-selector-item", { heading: this.siteSelector.currentSiteTitle, description: this.siteSelector.currentSiteDescription }),
339
- (this.gotData && ((_f = this.siteSelector) === null || _f === void 0 ? void 0 : _f.siteSelections)) && this.siteSelector.siteSelections.map((site) => h("pn-site-selector-item", { heading: site.linkText, description: site.linkDescription, url: site.pageLink, newwindow: site.openInNewWindow })))),
355
+ h("slot", { name: "menu-footer-cta" }),
356
+ this.gotData && this.loginDialog && !this.hideLogin && (h("pn-marketweb-siteheader-login", { emitEvents: false, loginDialog: this.loginDialog, endpoint: this.endpoint, fullname: this.userFullname, loggedin: this.userLoggedin, i18n: this.i18n, showProfileSelection: this.showProfileSelection })),
357
+ this.gotData && this.languageOptions && this.languageOptions.length && !this.hideLanguageSelector && (h("pn-language-selector", { value: this.language }, this.languageOptions.map(language => (h("pn-language-selector-option", { name: language.nativeName, code: language.twoLetterISOLanguageName, selected: language.isCurrent, url: this.getLanguageVersionUrl(language) }))))),
358
+ !this.hideSiteSelector && (h("pn-site-selector", { language: this.language },
359
+ this.gotData && ((_e = this.siteSelector) === null || _e === void 0 ? void 0 : _e.currentSiteTitle) && (h("pn-site-selector-item", { heading: this.siteSelector.currentSiteTitle, description: this.siteSelector.currentSiteDescription })),
360
+ this.gotData &&
361
+ ((_f = this.siteSelector) === null || _f === void 0 ? void 0 : _f.siteSelections) &&
362
+ this.siteSelector.siteSelections.map(site => (h("pn-site-selector-item", { heading: site.linkText, description: site.linkDescription, url: site.pageLink, newwindow: site.openInNewWindow })))))),
340
363
  h("div", { slot: "top", class: "siteheader-menu-top" },
341
364
  h("pn-marketweb-siteheader-search", { language: this.language, siteid: this.siteid, search: this.search, "hide-search": this.hideSearch, i18n: this.i18n })))))),
342
365
  h("pn-marketweb-siteheader-search", { language: this.language, siteid: this.siteid, primary: true, search: this.search, "hide-search": this.hideSearch, "show-only-link": this.minimizeSearch, i18n: this.i18n })))));
@@ -437,7 +460,7 @@ export class PnMarketwebSiteheader {
437
460
  },
438
461
  "attribute": "user-token",
439
462
  "reflect": false,
440
- "defaultValue": "\"\""
463
+ "defaultValue": "''"
441
464
  },
442
465
  "userFullname": {
443
466
  "type": "string",
@@ -455,7 +478,7 @@ export class PnMarketwebSiteheader {
455
478
  },
456
479
  "attribute": "user-fullname",
457
480
  "reflect": false,
458
- "defaultValue": "\"\""
481
+ "defaultValue": "''"
459
482
  },
460
483
  "userLoggedin": {
461
484
  "type": "boolean",
@@ -617,7 +640,7 @@ export class PnMarketwebSiteheader {
617
640
  },
618
641
  "attribute": "autocomplete-endpoint",
619
642
  "reflect": false,
620
- "defaultValue": "\"\""
643
+ "defaultValue": "''"
621
644
  },
622
645
  "sessionForward": {
623
646
  "type": "boolean",
@@ -1,44 +1,44 @@
1
- import readme from "./readme.md";
1
+ import readme from './readme.md';
2
2
 
3
3
  const usertoken = '80956fbe5c1f7bbf70e31226809ccf77829cffb65feb8ed0d9f5434';
4
4
 
5
5
  export default {
6
- title: "Web Components/Market web site Header",
6
+ title: 'Web Components/Market web site Header',
7
7
  parameters: {
8
8
  notes: readme,
9
- layout: 'fullscreen'
9
+ layout: 'fullscreen',
10
10
  },
11
11
  argTypes: {
12
- market : {
12
+ market: {
13
13
  values: [
14
- { name:'Sweden', value: 'se'},
15
- { name:'Denmark', value:'dk'},
16
- { name:'Finland', value:'fi'},
17
- { name:'Norway', value:'no'},
18
- { name:'Corporate', value:'com'},
19
- { name:'TPL', value:'tpl'},
20
- ]
14
+ { name: 'Sweden', value: 'se' },
15
+ { name: 'Denmark', value: 'dk' },
16
+ { name: 'Finland', value: 'fi' },
17
+ { name: 'Norway', value: 'no' },
18
+ { name: 'Corporate', value: 'com' },
19
+ { name: 'TPL', value: 'tpl' },
20
+ ],
21
21
  },
22
- language : {
22
+ language: {
23
23
  values: [
24
- { name:'English', value:'en'},
25
- { name:'Swedish', value: 'sv'},
26
- { name:'Danish', value: 'da'},
27
- { name:'Finnish', value: 'fi'},
28
- { name:'Norwegian', value: 'no'},
29
- ]
24
+ { name: 'English', value: 'en' },
25
+ { name: 'Swedish', value: 'sv' },
26
+ { name: 'Danish', value: 'da' },
27
+ { name: 'Finnish', value: 'fi' },
28
+ { name: 'Norwegian', value: 'no' },
29
+ ],
30
30
  },
31
- endpoint : {
31
+ endpoint: {
32
32
  values: [
33
- { name:'Localhost', value: 'http://localhost:51444'},
34
- { name:'local.postnord.com', value: 'https://local.postnord.com'},
35
- { name:'Integration', value: 'https://com-integration.postnord.com'},
36
- { name:'Preproduction', value: 'https://com-preproduction.postnord.com'},
37
- { name:'Production', value: 'https://com-production.postnord.com'},
38
- { name:'Live', value: 'https://www.postnord.com'},
39
- ]
33
+ { name: 'Localhost', value: 'http://localhost:51444' },
34
+ { name: 'local.postnord.com', value: 'https://local.postnord.com' },
35
+ { name: 'Integration', value: 'https://com-integration.postnord.com' },
36
+ { name: 'Preproduction', value: 'https://com-preproduction.postnord.com' },
37
+ { name: 'Production', value: 'https://com-production.postnord.com' },
38
+ { name: 'Live', value: 'https://www.postnord.com' },
39
+ ],
40
40
  },
41
- }
41
+ },
42
42
  };
43
43
 
44
44
  const PrimaryTemplate = ({ ...args }) => {
@@ -204,9 +204,9 @@ pn-mainnav>nav {
204
204
 
205
205
  <div style="background:#ddd;min-height:100vh;">
206
206
  <pn-marketweb-siteheader
207
- market="${ args.market }"
208
- language="${ args.language }"
209
- endpoint="${ args.endpoint }"
207
+ market="${args.market}"
208
+ language="${args.language}"
209
+ endpoint="${args.endpoint}"
210
210
  site-domain-in-urls="true"
211
211
  hide-site-selector="false"
212
212
  hide-language-selector="false"
@@ -232,21 +232,21 @@ Content that is higher than 100% viewport height
232
232
  -->
233
233
  `;
234
234
  };
235
- //
235
+ //
236
236
  export const Primary = PrimaryTemplate.bind({});
237
237
  Primary.args = {
238
- market : "se",
238
+ market: 'se',
239
239
  language: 'sv',
240
- endpoint: 'http://localhost:51444'
241
- }
240
+ endpoint: 'http://localhost:51444',
241
+ };
242
242
 
243
243
  const OldLoginDropdownTemplate = ({ ...args }) => {
244
244
  return `
245
245
  <div style="background:#ddd;min-height:100vh;">
246
246
  <pn-marketweb-siteheader
247
- market="${ args.market }"
248
- language="${ args.language }"
249
- endpoint="${ args.endpoint }"
247
+ market="${args.market}"
248
+ language="${args.language}"
249
+ endpoint="${args.endpoint}"
250
250
  hide-site-selector="false"
251
251
  hide-language-selector="false"
252
252
  hide-search="false"
@@ -271,14 +271,13 @@ Content that is higher than 100% viewport height
271
271
  -->
272
272
  `;
273
273
  };
274
- //
274
+ //
275
275
  export const OldLoginDropdown = OldLoginDropdownTemplate.bind({});
276
276
  OldLoginDropdown.args = {
277
- market : "se",
277
+ market: 'se',
278
278
  language: 'sv',
279
- endpoint: 'http://localhost:51444'
280
- }
281
-
279
+ endpoint: 'http://localhost:51444',
280
+ };
282
281
 
283
282
  const MinimalOptionsTemplate = ({ ...args }) => {
284
283
  return `
@@ -310,7 +309,6 @@ const CustomLogoTemplate = ({ ...args }) => {
310
309
 
311
310
  export const CustomLogo = CustomLogoTemplate.bind({});
312
311
 
313
-
314
312
  const EnvironmentOptionsTemplate = ({ ...args }) => {
315
313
  return `
316
314
  <div style="background:#ddd;min-height:100vh;">
@@ -321,8 +319,7 @@ const EnvironmentOptionsTemplate = ({ ...args }) => {
321
319
  };
322
320
 
323
321
  export const EnvironmentOptions = EnvironmentOptionsTemplate.bind({});
324
- MinimalOptionsTemplate.args = {
325
- };
322
+ MinimalOptionsTemplate.args = {};
326
323
 
327
324
  const SPAModeOptionsTemplate = ({ ...args }) => {
328
325
  return `
@@ -347,23 +344,21 @@ const SPAModeOptionsTemplate = ({ ...args }) => {
347
344
  `;
348
345
  };
349
346
 
350
-
351
-
352
347
  export const SPAModeOptions = SPAModeOptionsTemplate.bind({});
353
348
  SPAModeOptions.args = {
354
- market : "",
349
+ market: '',
355
350
  language: '',
356
- endpoint: ''
351
+ endpoint: '',
357
352
  };
358
353
 
359
354
  const LocalhostTemplate = ({ ...args }) => {
360
355
  return `
361
356
  <div style="background:#ddd;min-height:100vh;">
362
357
  <pn-marketweb-siteheader
363
- market="${ args.market }"
364
- language="${ args.language }"
365
- endpoint="${ args.endpoint }"
366
- environment="${ args.environment }"
358
+ market="${args.market}"
359
+ language="${args.language}"
360
+ endpoint="${args.endpoint}"
361
+ environment="${args.environment}"
367
362
  >
368
363
  </pn-marketweb-siteheader>
369
364
  </div>
@@ -372,7 +367,7 @@ const LocalhostTemplate = ({ ...args }) => {
372
367
 
373
368
  export const LocalhostOptions = LocalhostTemplate.bind({});
374
369
  LocalhostOptions.args = {
375
- market : "se",
370
+ market: 'se',
376
371
  language: 'sv',
377
372
  endpoint: 'http://localhost:51444/',
378
373
  };
@@ -381,10 +376,10 @@ const LoggedInTemplate = ({ ...args }) => {
381
376
  return `
382
377
  <div style="background:#ddd;min-height:100vh;">
383
378
  <pn-marketweb-siteheader
384
- market="${ args.market }"
385
- language="${ args.language }"
386
- endpoint="${ args.endpoint }"
387
- user-token="${ args.token }"
379
+ market="${args.market}"
380
+ language="${args.language}"
381
+ endpoint="${args.endpoint}"
382
+ user-token="${args.token}"
388
383
  >
389
384
  </pn-marketweb-siteheader>
390
385
  </div>
@@ -393,7 +388,7 @@ const LoggedInTemplate = ({ ...args }) => {
393
388
 
394
389
  export const LoggedIn = LoggedInTemplate.bind({});
395
390
  LoggedIn.args = {
396
- market : "se",
391
+ market: 'se',
397
392
  language: 'sv',
398
393
  // endpoint: 'https://com-integration.postnord.com',
399
394
  endpoint: 'http://localhost:51444',
@@ -404,10 +399,10 @@ const LoggedInProfileSelectionTemplate = ({ ...args }) => {
404
399
  return `
405
400
  <div style="background:#ddd;min-height:100vh;">
406
401
  <pn-marketweb-siteheader
407
- market="${ args.market }"
408
- language="${ args.language }"
409
- endpoint="${ args.endpoint }"
410
- user-token="${ args.token }"
402
+ market="${args.market}"
403
+ language="${args.language}"
404
+ endpoint="${args.endpoint}"
405
+ user-token="${args.token}"
411
406
  show-profile-selection="true"
412
407
  >
413
408
  </pn-marketweb-siteheader>
@@ -417,7 +412,7 @@ const LoggedInProfileSelectionTemplate = ({ ...args }) => {
417
412
 
418
413
  export const LoggedInProfileSelection = LoggedInProfileSelectionTemplate.bind({});
419
414
  LoggedInProfileSelection.args = {
420
- market : "se",
415
+ market: 'se',
421
416
  language: 'sv',
422
417
  // endpoint: 'https://com-integration.postnord.com',
423
418
  endpoint: 'http://localhost:51444/',
@@ -428,11 +423,11 @@ const BusinessUserLoggedInTemplate = ({ ...args }) => {
428
423
  return `
429
424
  <div style="background:#ddd;min-height:100vh;">
430
425
  <pn-marketweb-siteheader
431
- market="${ args.market }"
432
- language="${ args.language }"
433
- endpoint="${ args.endpoint }"
434
- user-fullname="${ args.name }"
435
- user-loggedin="${ args.loggedin }"
426
+ market="${args.market}"
427
+ language="${args.language}"
428
+ endpoint="${args.endpoint}"
429
+ user-fullname="${args.name}"
430
+ user-loggedin="${args.loggedin}"
436
431
  >
437
432
  </pn-marketweb-siteheader>
438
433
  </div>
@@ -441,9 +436,34 @@ const BusinessUserLoggedInTemplate = ({ ...args }) => {
441
436
 
442
437
  export const BusinessUserLoggedIn = BusinessUserLoggedInTemplate.bind({});
443
438
  BusinessUserLoggedIn.args = {
444
- market : "se",
439
+ market: 'se',
445
440
  language: 'sv',
446
441
  endpoint: 'https://com-integration.postnord.com',
447
442
  name: 'custom user name',
448
- loggedin: true
443
+ loggedin: true,
444
+ };
445
+
446
+ const DotComSiteHeaderTemplate = ({ ...args }) => {
447
+ return `
448
+ <header data-header-theme="dotcom">
449
+ <pn-marketweb-siteheader
450
+ market="${args.market}"
451
+ language="${args.language}"
452
+ endpoint="${args.endpoint}"
453
+ user-fullname="${args.name}"
454
+ user-loggedin="${args.loggedin}"
455
+ >
456
+ <pn-button slot="toprightend" small="true">Get started</pn-button>
457
+ <pn-button slot="menu-footer-cta" small="true">Get started</pn-button>
458
+ </pn-marketweb-siteheader>
459
+ </header>`;
460
+ };
461
+
462
+ export const DotComSiteHeader = DotComSiteHeaderTemplate.bind({});
463
+ DotComSiteHeader.args = {
464
+ market: 'se',
465
+ language: 'sv',
466
+ endpoint: 'https://com-integration.postnord.com',
467
+ name: 'DotCom User',
468
+ loggedin: false,
449
469
  };