@postnord/pn-marketweb-components 1.0.17 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/MarketWebContextService-420668a7.js +166 -0
- package/cjs/loader.cjs.js +1 -1
- package/cjs/pn-filter-checkbox.cjs.entry.js +67 -0
- package/cjs/pn-language-selector_9.cjs.entry.js +34 -11
- package/cjs/pn-mainnav-link.cjs.entry.js +1 -1
- package/cjs/{pn-mainnav-store-661b0b11.js → pn-mainnav-store-87a95686.js} +1 -0
- package/cjs/pn-market-web-components.cjs.js +1 -1
- package/cjs/pn-marketweb-sitefooter.cjs.entry.js +48 -6
- package/cjs/pn-marketweb-siteheader.cjs.entry.js +62 -9
- package/collection/collection-manifest.json +1 -0
- package/collection/components/input/pn-filter-checkbox/checkbox.stories.js +34 -0
- package/collection/components/input/pn-filter-checkbox/pn-filter-checkbox.css +73 -0
- package/collection/components/input/pn-filter-checkbox/pn-filter-checkbox.js +183 -0
- package/collection/components/layout-components/pn-marketweb-sitefooter/pn-marketweb-sitefooter.js +75 -12
- package/collection/components/layout-components/pn-marketweb-sitefooter/pn-marketweb-sitefooter.stories.js +16 -0
- package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-login.js +8 -1
- package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader.js +172 -68
- package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader.stories.js +23 -12
- package/collection/components/navigation/pn-language-selector/pn-language-selector.js +28 -7
- package/collection/components/navigation/pn-mainnav/pn-mainnav-level.css +3 -0
- package/collection/components/navigation/pn-mainnav/pn-mainnav-level.js +5 -1
- package/collection/components/navigation/pn-mainnav/pn-mainnav-store.js +1 -0
- package/collection/components/navigation/pn-mainnav/pn-mainnav.js +1 -1
- package/collection/components/navigation/pn-site-selector/pn-site-selector.js +6 -6
- package/collection/globals/MarketWebContextService.js +163 -0
- package/custom-elements/index.d.ts +6 -0
- package/custom-elements/index.js +376 -32
- package/esm/MarketWebContextService-9a201388.js +164 -0
- package/esm/loader.js +1 -1
- package/esm/pn-filter-checkbox.entry.js +63 -0
- package/esm/pn-language-selector_9.entry.js +34 -11
- package/esm/pn-mainnav-link.entry.js +1 -1
- package/esm/{pn-mainnav-store-4b030e31.js → pn-mainnav-store-8e518460.js} +1 -0
- package/esm/pn-market-web-components.js +1 -1
- package/esm/pn-marketweb-sitefooter.entry.js +48 -6
- package/esm/pn-marketweb-siteheader.entry.js +63 -10
- package/esm-es5/MarketWebContextService-9a201388.js +1 -0
- package/esm-es5/loader.js +1 -1
- package/esm-es5/pn-filter-checkbox.entry.js +1 -0
- package/esm-es5/pn-language-selector_9.entry.js +1 -1
- package/esm-es5/pn-mainnav-link.entry.js +1 -1
- package/esm-es5/pn-mainnav-store-8e518460.js +1 -0
- package/esm-es5/pn-market-web-components.js +1 -1
- package/esm-es5/pn-marketweb-sitefooter.entry.js +1 -1
- package/esm-es5/pn-marketweb-siteheader.entry.js +1 -1
- package/package.json +2 -2
- package/pn-market-web-components/p-02eed66e.system.entry.js +1 -0
- package/pn-market-web-components/{p-facf4ecb.system.entry.js → p-251d44f2.system.entry.js} +1 -1
- package/pn-market-web-components/p-25bdf3f8.system.js +1 -1
- package/pn-market-web-components/p-2da203c9.system.entry.js +1 -0
- package/pn-market-web-components/p-363a27ff.entry.js +1 -0
- package/pn-market-web-components/p-582dbd9c.entry.js +1 -0
- package/pn-market-web-components/p-64dc840d.js +1 -0
- package/pn-market-web-components/p-86a9f853.system.js +1 -0
- package/pn-market-web-components/p-8c072330.entry.js +1 -0
- package/pn-market-web-components/p-8d62c46f.system.entry.js +1 -0
- package/pn-market-web-components/p-8dad5ed9.js +1 -0
- package/pn-market-web-components/p-a320fe58.system.js +1 -0
- package/pn-market-web-components/p-ae0e5fd8.entry.js +1 -0
- package/pn-market-web-components/{p-f7d60229.entry.js → p-e220ea83.entry.js} +1 -1
- package/pn-market-web-components/p-ecfabe25.system.entry.js +1 -0
- package/pn-market-web-components/pn-market-web-components.esm.js +1 -1
- package/types/components/input/pn-filter-checkbox/pn-filter-checkbox.d.ts +22 -0
- package/types/components/layout-components/pn-marketweb-sitefooter/pn-marketweb-sitefooter.d.ts +5 -0
- package/types/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader.d.ts +8 -0
- package/types/components/navigation/pn-language-selector/pn-language-selector.d.ts +2 -0
- package/types/components/navigation/pn-mainnav/pn-mainnav-store.d.ts +2 -0
- package/types/components.d.ts +61 -0
- package/types/globals/MarketWebContextService.d.ts +51 -0
- package/esm-es5/pn-mainnav-store-4b030e31.js +0 -1
- package/pn-market-web-components/p-6b735c44.system.js +0 -1
- package/pn-market-web-components/p-a74e5481.js +0 -1
- package/pn-market-web-components/p-b80600a3.system.entry.js +0 -1
- package/pn-market-web-components/p-cc6e3bcb.entry.js +0 -1
- package/pn-market-web-components/p-d2da364d.system.entry.js +0 -1
- package/pn-market-web-components/p-ed135751.entry.js +0 -1
- package/pn-market-web-components/p-f55ad3f8.system.entry.js +0 -1
- package/pn-market-web-components/p-f5dddd2d.entry.js +0 -1
package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import { Component, Prop, h, State, Element, Listen } from "@stencil/core";
|
|
1
|
+
import { Component, Prop, h, State, Element, Listen, Watch, Host, Event } from "@stencil/core";
|
|
2
2
|
import { translations } from "./translations";
|
|
3
|
+
import { MarketWebContextService } from "../../../globals/MarketWebContextService";
|
|
3
4
|
export class PnMarketwebSiteheader {
|
|
4
5
|
constructor() {
|
|
5
6
|
this.endpointPath = "/api/navigation/header";
|
|
7
|
+
// allowedLanguages = ["sv","da","fi","no","en"];
|
|
8
|
+
// allowedMarkets = ["se","dk","fi","no","com"];
|
|
6
9
|
/** Specifies which market we want to show (se,dk,fi,no,com) */
|
|
7
|
-
this.market =
|
|
10
|
+
this.market = null; //se
|
|
8
11
|
/** Specifies which language we want to show (sv,da,fi,no,en) */
|
|
9
|
-
this.language =
|
|
12
|
+
this.language = null; //sv
|
|
13
|
+
/** Specifies which environment we're fetching data from. (production, preproduction, integration, localhost) */
|
|
14
|
+
this.environment = null; //sv
|
|
10
15
|
/** Specifies which endpoint domain we should load from */
|
|
11
|
-
this.endpoint =
|
|
16
|
+
this.endpoint = null;
|
|
12
17
|
/** Hides the site selector if set to true*/
|
|
13
18
|
this.hideSiteSelector = false;
|
|
14
19
|
/** Hides the language selector if set to true*/
|
|
@@ -32,22 +37,64 @@ export class PnMarketwebSiteheader {
|
|
|
32
37
|
this.minimizeSearch = false;
|
|
33
38
|
}
|
|
34
39
|
componentWillLoad() {
|
|
35
|
-
this.
|
|
36
|
-
|
|
40
|
+
this.setInitialValues().then(() => {
|
|
41
|
+
this.init();
|
|
42
|
+
});
|
|
37
43
|
}
|
|
44
|
+
async setInitialValues(href = window.location.href) {
|
|
45
|
+
var _a;
|
|
46
|
+
const marketWebContextService = new MarketWebContextService(href);
|
|
47
|
+
if (this.market === null) {
|
|
48
|
+
const resolvedMarket = await marketWebContextService.getMarket();
|
|
49
|
+
this.market = resolvedMarket;
|
|
50
|
+
}
|
|
51
|
+
if (this.language === null) {
|
|
52
|
+
const resolvedMarket = await marketWebContextService.getLanguage();
|
|
53
|
+
this.language = resolvedMarket;
|
|
54
|
+
}
|
|
55
|
+
if (this.environment === null) {
|
|
56
|
+
this.environment = await marketWebContextService.getEnvironmentName();
|
|
57
|
+
}
|
|
58
|
+
if (this.endpoint === null && ((_a = this.environment) === null || _a === void 0 ? void 0 : _a.indexOf('local')) === -1) {
|
|
59
|
+
this.endpoint = await marketWebContextService.getEndpoint(this.environment);
|
|
60
|
+
}
|
|
61
|
+
if (this.endpoint === null) {
|
|
62
|
+
this.endpoint = "";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// TODO
|
|
66
|
+
//* Expose market and language attributes when changed internally
|
|
67
|
+
//* Business logic to select market and language depending on domains / html tag.
|
|
68
|
+
//* Property to stop language change from changeing url, throw an event instead.
|
|
69
|
+
//* Fetch new data when langauge or market is changed
|
|
38
70
|
async init() {
|
|
71
|
+
this.setTranslations();
|
|
39
72
|
await this.fetchData();
|
|
40
73
|
window.setTimeout(() => { this.checkMenuOverflow(); }, 50);
|
|
41
74
|
}
|
|
42
75
|
setTranslations() {
|
|
43
|
-
if (translations[this.language]) {
|
|
76
|
+
if (this.language && translations[this.language]) {
|
|
44
77
|
this.i18n = translations[this.language];
|
|
45
78
|
}
|
|
46
79
|
}
|
|
80
|
+
onLanguageChange() {
|
|
81
|
+
this.setTranslations();
|
|
82
|
+
this.changeLanguage.emit(this.language);
|
|
83
|
+
this.fetchData();
|
|
84
|
+
}
|
|
85
|
+
onMarketChange() {
|
|
86
|
+
this.changeMarket.emit(this.market);
|
|
87
|
+
this.fetchData();
|
|
88
|
+
}
|
|
47
89
|
async fetchData() {
|
|
90
|
+
if (this.endpoint === null || !this.market || !this.language) {
|
|
91
|
+
// console.warn(`One or more values where not specified.\nEndpoint: ${this.endpoint}\nMarket: ${this.market}\nLanguage: ${this.language}`)
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
48
94
|
this.fetchingData = true;
|
|
49
95
|
const endpointBase = (this.endpoint.lastIndexOf("/") === this.endpoint.length - 1) ? this.endpoint.substring(0, this.endpoint.length - 1) : this.endpoint;
|
|
50
|
-
const
|
|
96
|
+
const fetchUrl = `${endpointBase}${this.endpointPath}?market=${this.market}&language=${this.language}`;
|
|
97
|
+
const response = await fetch(fetchUrl);
|
|
51
98
|
const data = await response.json();
|
|
52
99
|
this.setStateFromData(data);
|
|
53
100
|
}
|
|
@@ -118,55 +165,56 @@ export class PnMarketwebSiteheader {
|
|
|
118
165
|
}
|
|
119
166
|
render() {
|
|
120
167
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
121
|
-
return (h(
|
|
122
|
-
h("
|
|
123
|
-
h("div", { class: "siteheader-
|
|
124
|
-
h("
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
(this.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
h("
|
|
132
|
-
h("
|
|
133
|
-
h("
|
|
134
|
-
|
|
135
|
-
h("
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
h("div", { class: "siteheader-
|
|
142
|
-
h("
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
h("pn-mainnav-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
h("pn-mainnav-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
h("
|
|
169
|
-
|
|
168
|
+
return (h(Host, { language: this.language, market: this.market, environment: this.environment },
|
|
169
|
+
h("header", null,
|
|
170
|
+
h("div", { class: "siteheader-row" },
|
|
171
|
+
h("div", { class: "siteheader-topleft" },
|
|
172
|
+
h("slot", { name: "topleft" }),
|
|
173
|
+
!this.hideSiteSelector &&
|
|
174
|
+
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' },
|
|
175
|
+
(this.gotData && ((_c = this.siteSelector) === null || _c === void 0 ? void 0 : _c.currentSiteTitle)) &&
|
|
176
|
+
h("pn-site-selector-item", { heading: this.siteSelector.currentSiteTitle, description: this.siteSelector.currentSiteDescription }),
|
|
177
|
+
(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: site.href, newwindow: site.openInNewWindow })))),
|
|
178
|
+
h("div", { class: "siteheader-logocontainer" },
|
|
179
|
+
h("a", { href: (_f = (_e = this.siteDefinition) === null || _e === void 0 ? void 0 : _e.url) !== null && _f !== void 0 ? _f : document.location.hostname, title: "Home", class: "siteheader-logolink" },
|
|
180
|
+
h("svg", { class: "siteheader-logo", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 141.73 26.65" },
|
|
181
|
+
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)" })))),
|
|
182
|
+
h("div", { class: "siteheader-topright" },
|
|
183
|
+
h("slot", { name: "toprightstart" }),
|
|
184
|
+
(this.gotData && this.loginDialog && !this.hideLogin) && (h("pn-marketweb-siteheader-login", { loginDialog: this.loginDialog, endpoint: this.endpoint, i18n: this.i18n })),
|
|
185
|
+
(this.gotData && ((_g = this.languageSelector) === null || _g === void 0 ? void 0 : _g.languages)) && !this.hideLanguageSelector &&
|
|
186
|
+
h("pn-language-selector", { value: this.language }, this.languageSelector.languages.map(language => h("pn-language-selector-option", { name: language.nativeName, code: language.twoLetterISOLanguageName, selected: language.isCurrent, url: this.getLanguageVersionUrl(language) }))),
|
|
187
|
+
h("slot", { name: "toprightend" }))),
|
|
188
|
+
h("div", { class: "siteheader-row" },
|
|
189
|
+
h("div", { class: "siteheader-menu" },
|
|
190
|
+
h("pn-mainnav", { market: this.market, language: this.language, onMenuOpenChange: (e) => {
|
|
191
|
+
document.body.setAttribute("data-siteheader-menuopen", (e.detail + ''));
|
|
192
|
+
} },
|
|
193
|
+
h("pn-mainnav-level", null,
|
|
194
|
+
h("pn-mainnav-list", null, this.menuItems.map((item) => {
|
|
195
|
+
var _a, _b;
|
|
196
|
+
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)) &&
|
|
197
|
+
h("pn-mainnav-level", null,
|
|
198
|
+
item.children.length > 0 &&
|
|
199
|
+
h("pn-mainnav-list", { heading: ((_b = item.navigationHeading) !== null && _b !== void 0 ? _b : "") }, item.children.map((childitem) => {
|
|
200
|
+
var _a;
|
|
201
|
+
return (h("pn-mainnav-link", { name: childitem.name, href: childitem.href, target: (_a = childitem.linkTarget) !== null && _a !== void 0 ? _a : "_self", linkid: childitem.trackingId }));
|
|
202
|
+
})),
|
|
203
|
+
(item.promotedMenuItems && item.promotedMenuItems.length > 0) &&
|
|
204
|
+
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) })))))));
|
|
205
|
+
})),
|
|
206
|
+
h("div", { slot: "footer", class: "siteheader-menu-footer" },
|
|
207
|
+
(this.gotData && this.loginDialog && !this.hideLogin) && (h("pn-marketweb-siteheader-login", { loginDialog: this.loginDialog, endpoint: this.endpoint, i18n: this.i18n })),
|
|
208
|
+
(this.gotData && ((_h = this.languageSelector) === null || _h === void 0 ? void 0 : _h.languages)) && !this.hideLanguageSelector &&
|
|
209
|
+
h("pn-language-selector", { value: this.language }, this.languageSelector.languages.map(language => h("pn-language-selector-option", { name: language.nativeName, code: language.twoLetterISOLanguageName, selected: language.isCurrent, url: this.getLanguageVersionUrl(language) }))),
|
|
210
|
+
!this.hideSiteSelector &&
|
|
211
|
+
h("pn-site-selector", { language: this.language },
|
|
212
|
+
(this.gotData && ((_j = this.siteSelector) === null || _j === void 0 ? void 0 : _j.currentSiteTitle)) &&
|
|
213
|
+
h("pn-site-selector-item", { heading: this.siteSelector.currentSiteTitle, description: this.siteSelector.currentSiteDescription }),
|
|
214
|
+
(this.gotData && ((_k = this.siteSelector) === null || _k === void 0 ? void 0 : _k.siteSelections)) && this.siteSelector.siteSelections.map((site) => h("pn-site-selector-item", { heading: site.linkText, description: site.linkDescription, url: site.pageLink, newwindow: site.openInNewWindow })))),
|
|
215
|
+
h("div", { slot: "top", class: "siteheader-menu-top" },
|
|
216
|
+
h("pn-marketweb-siteheader-search", { search: this.search, "hide-search": this.hideSearch, i18n: this.i18n }))))),
|
|
217
|
+
h("pn-marketweb-siteheader-search", { search: this.search, "hide-search": this.hideSearch, "show-only-link": this.minimizeSearch, i18n: this.i18n })))));
|
|
170
218
|
}
|
|
171
219
|
static get is() { return "pn-marketweb-siteheader"; }
|
|
172
220
|
static get originalStyleUrls() { return {
|
|
@@ -178,7 +226,7 @@ export class PnMarketwebSiteheader {
|
|
|
178
226
|
static get properties() { return {
|
|
179
227
|
"market": {
|
|
180
228
|
"type": "string",
|
|
181
|
-
"mutable":
|
|
229
|
+
"mutable": true,
|
|
182
230
|
"complexType": {
|
|
183
231
|
"original": "string",
|
|
184
232
|
"resolved": "string",
|
|
@@ -191,12 +239,12 @@ export class PnMarketwebSiteheader {
|
|
|
191
239
|
"text": "Specifies which market we want to show (se,dk,fi,no,com)"
|
|
192
240
|
},
|
|
193
241
|
"attribute": "market",
|
|
194
|
-
"reflect":
|
|
195
|
-
"defaultValue": "
|
|
242
|
+
"reflect": true,
|
|
243
|
+
"defaultValue": "null"
|
|
196
244
|
},
|
|
197
245
|
"language": {
|
|
198
246
|
"type": "string",
|
|
199
|
-
"mutable":
|
|
247
|
+
"mutable": true,
|
|
200
248
|
"complexType": {
|
|
201
249
|
"original": "string",
|
|
202
250
|
"resolved": "string",
|
|
@@ -209,8 +257,26 @@ export class PnMarketwebSiteheader {
|
|
|
209
257
|
"text": "Specifies which language we want to show (sv,da,fi,no,en)"
|
|
210
258
|
},
|
|
211
259
|
"attribute": "language",
|
|
212
|
-
"reflect":
|
|
213
|
-
"defaultValue": "
|
|
260
|
+
"reflect": true,
|
|
261
|
+
"defaultValue": "null"
|
|
262
|
+
},
|
|
263
|
+
"environment": {
|
|
264
|
+
"type": "string",
|
|
265
|
+
"mutable": true,
|
|
266
|
+
"complexType": {
|
|
267
|
+
"original": "string",
|
|
268
|
+
"resolved": "string",
|
|
269
|
+
"references": {}
|
|
270
|
+
},
|
|
271
|
+
"required": false,
|
|
272
|
+
"optional": false,
|
|
273
|
+
"docs": {
|
|
274
|
+
"tags": [],
|
|
275
|
+
"text": "Specifies which environment we're fetching data from. (production, preproduction, integration, localhost)"
|
|
276
|
+
},
|
|
277
|
+
"attribute": "environment",
|
|
278
|
+
"reflect": true,
|
|
279
|
+
"defaultValue": "null"
|
|
214
280
|
},
|
|
215
281
|
"endpoint": {
|
|
216
282
|
"type": "string",
|
|
@@ -228,7 +294,7 @@ export class PnMarketwebSiteheader {
|
|
|
228
294
|
},
|
|
229
295
|
"attribute": "endpoint",
|
|
230
296
|
"reflect": false,
|
|
231
|
-
"defaultValue": "
|
|
297
|
+
"defaultValue": "null"
|
|
232
298
|
},
|
|
233
299
|
"hideSiteSelector": {
|
|
234
300
|
"type": "boolean",
|
|
@@ -245,7 +311,7 @@ export class PnMarketwebSiteheader {
|
|
|
245
311
|
"text": "Hides the site selector if set to true"
|
|
246
312
|
},
|
|
247
313
|
"attribute": "hide-site-selector",
|
|
248
|
-
"reflect":
|
|
314
|
+
"reflect": true,
|
|
249
315
|
"defaultValue": "false"
|
|
250
316
|
},
|
|
251
317
|
"hideLanguageSelector": {
|
|
@@ -263,7 +329,7 @@ export class PnMarketwebSiteheader {
|
|
|
263
329
|
"text": "Hides the language selector if set to true"
|
|
264
330
|
},
|
|
265
331
|
"attribute": "hide-language-selector",
|
|
266
|
-
"reflect":
|
|
332
|
+
"reflect": true,
|
|
267
333
|
"defaultValue": "false"
|
|
268
334
|
},
|
|
269
335
|
"hideSearch": {
|
|
@@ -281,7 +347,7 @@ export class PnMarketwebSiteheader {
|
|
|
281
347
|
"text": "Hides the search form if set to true"
|
|
282
348
|
},
|
|
283
349
|
"attribute": "hide-search",
|
|
284
|
-
"reflect":
|
|
350
|
+
"reflect": true,
|
|
285
351
|
"defaultValue": "false"
|
|
286
352
|
},
|
|
287
353
|
"hideLogin": {
|
|
@@ -299,7 +365,7 @@ export class PnMarketwebSiteheader {
|
|
|
299
365
|
"text": "Hides the login if set to true"
|
|
300
366
|
},
|
|
301
367
|
"attribute": "hide-login",
|
|
302
|
-
"reflect":
|
|
368
|
+
"reflect": true,
|
|
303
369
|
"defaultValue": "false"
|
|
304
370
|
}
|
|
305
371
|
}; }
|
|
@@ -315,7 +381,45 @@ export class PnMarketwebSiteheader {
|
|
|
315
381
|
"loginDialog": {},
|
|
316
382
|
"minimizeSearch": {}
|
|
317
383
|
}; }
|
|
384
|
+
static get events() { return [{
|
|
385
|
+
"method": "changeLanguage",
|
|
386
|
+
"name": "changeLanguage",
|
|
387
|
+
"bubbles": true,
|
|
388
|
+
"cancelable": true,
|
|
389
|
+
"composed": true,
|
|
390
|
+
"docs": {
|
|
391
|
+
"tags": [],
|
|
392
|
+
"text": ""
|
|
393
|
+
},
|
|
394
|
+
"complexType": {
|
|
395
|
+
"original": "any",
|
|
396
|
+
"resolved": "any",
|
|
397
|
+
"references": {}
|
|
398
|
+
}
|
|
399
|
+
}, {
|
|
400
|
+
"method": "changeMarket",
|
|
401
|
+
"name": "changeMarket",
|
|
402
|
+
"bubbles": true,
|
|
403
|
+
"cancelable": true,
|
|
404
|
+
"composed": true,
|
|
405
|
+
"docs": {
|
|
406
|
+
"tags": [],
|
|
407
|
+
"text": ""
|
|
408
|
+
},
|
|
409
|
+
"complexType": {
|
|
410
|
+
"original": "any",
|
|
411
|
+
"resolved": "any",
|
|
412
|
+
"references": {}
|
|
413
|
+
}
|
|
414
|
+
}]; }
|
|
318
415
|
static get elementRef() { return "hostElement"; }
|
|
416
|
+
static get watchers() { return [{
|
|
417
|
+
"propName": "language",
|
|
418
|
+
"methodName": "onLanguageChange"
|
|
419
|
+
}, {
|
|
420
|
+
"propName": "market",
|
|
421
|
+
"methodName": "onMarketChange"
|
|
422
|
+
}]; }
|
|
319
423
|
static get listeners() { return [{
|
|
320
424
|
"name": "resize",
|
|
321
425
|
"method": "handleResize",
|
|
@@ -38,7 +38,7 @@ export default {
|
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
const
|
|
41
|
+
const PrimaryTemplate = ({ ...args }) => {
|
|
42
42
|
return `
|
|
43
43
|
<div style="background:#ddd;min-height:100vh;">
|
|
44
44
|
<pn-marketweb-siteheader
|
|
@@ -50,24 +50,35 @@ const Template = ({ ...args }) => {
|
|
|
50
50
|
hide-search="false"
|
|
51
51
|
hide-login="false">
|
|
52
52
|
</pn-marketweb-siteheader>
|
|
53
|
-
<div>
|
|
54
|
-
|
|
55
|
-
Lorem ipsum dolor sit amet<br/><br/><br/><br/>
|
|
56
|
-
Lorem ipsum dolor sit amet<br/><br/><br/><br/>
|
|
57
|
-
Lorem ipsum dolor sit amet<br/><br/><br/><br/>
|
|
58
|
-
Lorem ipsum dolor sit amet<br/><br/><br/><br/>
|
|
59
|
-
Lorem ipsum dolor sit amet<br/><br/><br/><br/>
|
|
60
|
-
Lorem ipsum dolor sit amet<br/><br/><br/><br/>
|
|
61
|
-
Lorem ipsum dolor sit amet<br/><br/><br/><br/>
|
|
62
|
-
Lorem ipsum dolor sit amet<br/><br/><br/><br/>
|
|
53
|
+
<div style="height:120vh; margin:2em; max-width:calc(100vw - 1em);background:#ccc;border:1px solid #333;">
|
|
54
|
+
Content that is higher than 100% viewport height
|
|
63
55
|
</div>
|
|
64
56
|
</div>
|
|
65
57
|
`;
|
|
66
58
|
};
|
|
67
59
|
|
|
68
|
-
export const Primary =
|
|
60
|
+
export const Primary = PrimaryTemplate.bind({});
|
|
69
61
|
Primary.args = {
|
|
70
62
|
market : "se",
|
|
71
63
|
language: 'sv',
|
|
72
64
|
endpoint: 'https://com-preproduction.postnord.com'
|
|
73
65
|
};
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
const MinimalOptionsTemplate = ({ ...args }) => {
|
|
69
|
+
return `
|
|
70
|
+
<div style="background:#ddd;min-height:100vh;">
|
|
71
|
+
<pn-marketweb-siteheader language="sv">
|
|
72
|
+
</pn-marketweb-siteheader>
|
|
73
|
+
</div>
|
|
74
|
+
`;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
export const MinimalOptions = MinimalOptionsTemplate.bind({});
|
|
80
|
+
MinimalOptionsTemplate.args = {
|
|
81
|
+
market : "",
|
|
82
|
+
language: '',
|
|
83
|
+
endpoint: ''
|
|
84
|
+
};
|
|
@@ -14,18 +14,30 @@ export class PnlanguageSelector {
|
|
|
14
14
|
this.initialize();
|
|
15
15
|
}
|
|
16
16
|
initialize() {
|
|
17
|
+
this.setSelectedLanguageName();
|
|
18
|
+
this.addEventBindingsToOptions();
|
|
19
|
+
}
|
|
20
|
+
addEventBindingsToOptions() {
|
|
17
21
|
const options = [].slice.apply(this.hostElement.querySelectorAll("pn-language-selector-option"));
|
|
18
22
|
options.map((option) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
+
option.removeEventListener("setCurrentLanguage", (event) => {
|
|
24
|
+
this.onSetCurrentLanguage(event.detail);
|
|
25
|
+
});
|
|
23
26
|
// Bind event listener for when a user change language
|
|
24
27
|
option.addEventListener("setCurrentLanguage", (event) => {
|
|
25
28
|
this.onSetCurrentLanguage(event.detail);
|
|
26
29
|
});
|
|
27
30
|
});
|
|
28
31
|
}
|
|
32
|
+
setSelectedLanguageName() {
|
|
33
|
+
const options = [].slice.apply(this.hostElement.querySelectorAll("pn-language-selector-option"));
|
|
34
|
+
options.map((option) => {
|
|
35
|
+
// Set current label of language selector
|
|
36
|
+
if (option.getAttribute("code") == this.value) { // || option.getAttribute("selected") == "true"
|
|
37
|
+
this.selectedLanguageName = option.getAttribute("name");
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
29
41
|
onSetCurrentLanguage(option) {
|
|
30
42
|
this.value = option.code;
|
|
31
43
|
this.selectedLanguageName = option.name;
|
|
@@ -41,11 +53,14 @@ export class PnlanguageSelector {
|
|
|
41
53
|
components.forEach((component) => {
|
|
42
54
|
// Pass values as props into slotted components
|
|
43
55
|
// component.setAttribute("current-language", this.value);
|
|
44
|
-
|
|
56
|
+
const isSelected = (component.getAttribute("code") === this.value) + '';
|
|
57
|
+
if ((component.getAttribute('selected') + '') !== isSelected) {
|
|
58
|
+
component.setAttribute("selected", isSelected);
|
|
59
|
+
}
|
|
45
60
|
});
|
|
46
61
|
}
|
|
47
62
|
render() {
|
|
48
|
-
return (h(Host,
|
|
63
|
+
return (h(Host, { value: this.value },
|
|
49
64
|
h("pn-nav-dropdown", { label: this.selectedLanguageName, icon: "globe" },
|
|
50
65
|
h("nav", { class: "languageselector-nav", "aria-label": this.i18n.heading },
|
|
51
66
|
h("strong", { class: "languageselector-title" }, this.i18n.heading),
|
|
@@ -62,7 +77,7 @@ export class PnlanguageSelector {
|
|
|
62
77
|
static get properties() { return {
|
|
63
78
|
"value": {
|
|
64
79
|
"type": "string",
|
|
65
|
-
"mutable":
|
|
80
|
+
"mutable": false,
|
|
66
81
|
"complexType": {
|
|
67
82
|
"original": "string",
|
|
68
83
|
"resolved": "string",
|
|
@@ -86,6 +101,12 @@ export class PnlanguageSelector {
|
|
|
86
101
|
}; }
|
|
87
102
|
static get elementRef() { return "hostElement"; }
|
|
88
103
|
static get watchers() { return [{
|
|
104
|
+
"propName": "value",
|
|
105
|
+
"methodName": "setSelectedLanguageName"
|
|
106
|
+
}, {
|
|
107
|
+
"propName": "value",
|
|
108
|
+
"methodName": "setTranslations"
|
|
109
|
+
}, {
|
|
89
110
|
"propName": "value",
|
|
90
111
|
"methodName": "onValueChange"
|
|
91
112
|
}]; }
|
|
@@ -56,12 +56,16 @@ export class PnMainnavLevel {
|
|
|
56
56
|
}
|
|
57
57
|
onChangeOpenLevel() {
|
|
58
58
|
this.isOpen = state.openLevel === this.levelId;
|
|
59
|
+
state.currentLevel = this.level;
|
|
59
60
|
}
|
|
60
61
|
render() {
|
|
61
62
|
return (h(Host, Object.assign({ role: "navigation" }, ((this.level > 1 && this.levelId) ? { 'aria-hidden': (!this.isOpen) + '' } : {}), { "data-level-listcount": this.listCount + '', "data-level-alignment": this.alignment, "data-level": this.level + '' }, (this.levelId ? { id: this.levelId } : {})),
|
|
62
63
|
(this.level > 1) ? (h("div", { class: "mainnav-level-header" },
|
|
63
64
|
h("label", { htmlFor: this.levelId }, state.i18n.menuGoBackButton),
|
|
64
|
-
h("button", { class: "secondlevel-backbtn", onClick: () =>
|
|
65
|
+
h("button", { class: "secondlevel-backbtn", onClick: () => {
|
|
66
|
+
state.openLevel = '';
|
|
67
|
+
state.currentLevel = 1;
|
|
68
|
+
}, "aria-expanded": (state.openLevel === this.levelId) + '' },
|
|
65
69
|
h("pn-icon", { symbol: "arrow-left", color: "blue700" }),
|
|
66
70
|
state.i18n.menuStartButton),
|
|
67
71
|
(this.parentHref && this.parentName) ? h("pn-mainnav-link", { href: this.parentHref, name: this.parentName, linkid: this.parentLinkId }) : null)) : null,
|
|
@@ -56,7 +56,7 @@ export class PnMainnav {
|
|
|
56
56
|
h("button", { "aria-controls": this.navigationId, "aria-expanded": state.openMenu + '', onClick: this.setMenuOpenState.bind(this) },
|
|
57
57
|
state.i18n.mainMenuButton,
|
|
58
58
|
h("pn-icon", { symbol: state.openMenu ? "close" : "bars", color: "white" }))),
|
|
59
|
-
h("nav", { class: "mainnav", "aria-label": this.navLabel, "data-menu-open": state.openMenu + '', id: this.navigationId },
|
|
59
|
+
h("nav", { class: "mainnav", "aria-label": this.navLabel, "data-menu-open": state.openMenu + '', "data-menu-currentlevel": state.currentLevel, id: this.navigationId },
|
|
60
60
|
h("slot", null))));
|
|
61
61
|
}
|
|
62
62
|
static get is() { return "pn-mainnav"; }
|
|
@@ -36,7 +36,7 @@ export class PnSiteSelector {
|
|
|
36
36
|
static get properties() { return {
|
|
37
37
|
"buttontext": {
|
|
38
38
|
"type": "string",
|
|
39
|
-
"mutable":
|
|
39
|
+
"mutable": true,
|
|
40
40
|
"complexType": {
|
|
41
41
|
"original": "string",
|
|
42
42
|
"resolved": "string",
|
|
@@ -49,12 +49,12 @@ export class PnSiteSelector {
|
|
|
49
49
|
"text": ""
|
|
50
50
|
},
|
|
51
51
|
"attribute": "buttontext",
|
|
52
|
-
"reflect":
|
|
52
|
+
"reflect": true,
|
|
53
53
|
"defaultValue": "\"postnord\""
|
|
54
54
|
},
|
|
55
55
|
"heading": {
|
|
56
56
|
"type": "string",
|
|
57
|
-
"mutable":
|
|
57
|
+
"mutable": true,
|
|
58
58
|
"complexType": {
|
|
59
59
|
"original": "string",
|
|
60
60
|
"resolved": "string",
|
|
@@ -67,12 +67,12 @@ export class PnSiteSelector {
|
|
|
67
67
|
"text": ""
|
|
68
68
|
},
|
|
69
69
|
"attribute": "heading",
|
|
70
|
-
"reflect":
|
|
70
|
+
"reflect": true,
|
|
71
71
|
"defaultValue": "\"PostNord\""
|
|
72
72
|
},
|
|
73
73
|
"language": {
|
|
74
74
|
"type": "string",
|
|
75
|
-
"mutable":
|
|
75
|
+
"mutable": true,
|
|
76
76
|
"complexType": {
|
|
77
77
|
"original": "string",
|
|
78
78
|
"resolved": "string",
|
|
@@ -85,7 +85,7 @@ export class PnSiteSelector {
|
|
|
85
85
|
"text": "Specifies which language we want to show navigation in (sv,da,fi,no,en)"
|
|
86
86
|
},
|
|
87
87
|
"attribute": "language",
|
|
88
|
-
"reflect":
|
|
88
|
+
"reflect": true,
|
|
89
89
|
"defaultValue": "\"sv\""
|
|
90
90
|
}
|
|
91
91
|
}; }
|