@postnord/pn-marketweb-components 2.0.23-beta3 → 2.0.23-beta6

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 (110) hide show
  1. package/cjs/loader.cjs.js +1 -1
  2. package/cjs/pn-customernumber-selector-option.cjs.entry.js +2 -2
  3. package/cjs/pn-customernumber-selector.cjs.entry.js +3 -3
  4. package/cjs/pn-find-price-result.cjs.entry.js +5 -5
  5. package/cjs/pn-find-price.cjs.entry.js +7 -5
  6. package/cjs/pn-language-selector_9.cjs.entry.js +51 -59
  7. package/cjs/pn-market-web-components.cjs.js +1 -1
  8. package/cjs/pn-marketweb-siteheader-login-linklist.cjs.entry.js +72 -0
  9. package/cjs/pn-marketweb-siteheader-login-links_2.cjs.entry.js +186 -0
  10. package/cjs/pn-marketweb-siteheader.cjs.entry.js +26 -7
  11. package/cjs/pn-product-card_4.cjs.entry.js +1 -1
  12. package/cjs/pn-profile-selector-option.cjs.entry.js +2 -2
  13. package/collection/collection-manifest.json +3 -1
  14. package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-login-linklist.css +22 -0
  15. package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-login-linklist.js +149 -0
  16. package/collection/components/layout-components/pn-marketweb-siteheader/{pn-marketweb-siteheader-profileselection.css → pn-marketweb-siteheader-login-links.css} +0 -0
  17. package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-login-links.js +199 -0
  18. package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-login-profileselection.css +93 -0
  19. package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-login-profileselection.js +269 -0
  20. package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-login.css +0 -17
  21. package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-login.js +79 -72
  22. package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader.js +24 -2
  23. package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader.stories.js +69 -2
  24. package/collection/components/layout-components/pn-marketweb-siteheader/translations.js +20 -5
  25. package/collection/components/profile/pn-customernumber-selector/pn-customernumber-selector-option.js +4 -4
  26. package/collection/components/profile/pn-customernumber-selector/pn-customernumber-selector.js +7 -7
  27. package/collection/components/profile/pn-customernumber-selector/pn-customernumber-selector.stories.js +3 -3
  28. package/collection/components/profile/pn-profile-selector/pn-profile-selector-option.js +4 -4
  29. package/collection/components/widgets/pn-find-price/pn-find-price-result.js +5 -5
  30. package/collection/components/widgets/pn-find-price/pn-find-price.js +7 -5
  31. package/collection/components/widgets/pn-product-card/pn-product-card.css +1 -0
  32. package/custom-elements/index.d.ts +16 -4
  33. package/custom-elements/index.js +294 -185
  34. package/esm/loader.js +1 -1
  35. package/esm/pn-customernumber-selector-option.entry.js +2 -2
  36. package/esm/pn-customernumber-selector.entry.js +3 -3
  37. package/esm/pn-find-price-result.entry.js +5 -5
  38. package/esm/pn-find-price.entry.js +7 -5
  39. package/esm/pn-language-selector_9.entry.js +51 -59
  40. package/esm/pn-market-web-components.js +1 -1
  41. package/esm/pn-marketweb-siteheader-login-linklist.entry.js +68 -0
  42. package/esm/pn-marketweb-siteheader-login-links_2.entry.js +181 -0
  43. package/esm/pn-marketweb-siteheader.entry.js +26 -7
  44. package/esm/pn-product-card_4.entry.js +1 -1
  45. package/esm/pn-profile-selector-option.entry.js +2 -2
  46. package/esm-es5/loader.js +1 -1
  47. package/esm-es5/pn-customernumber-selector-option.entry.js +1 -1
  48. package/esm-es5/pn-customernumber-selector.entry.js +1 -1
  49. package/esm-es5/pn-find-price-result.entry.js +1 -1
  50. package/esm-es5/pn-find-price.entry.js +1 -1
  51. package/esm-es5/pn-language-selector_9.entry.js +1 -1
  52. package/esm-es5/pn-market-web-components.js +1 -1
  53. package/esm-es5/pn-marketweb-siteheader-login-linklist.entry.js +1 -0
  54. package/esm-es5/pn-marketweb-siteheader-login-links_2.entry.js +1 -0
  55. package/esm-es5/pn-marketweb-siteheader.entry.js +1 -1
  56. package/esm-es5/pn-product-card_4.entry.js +1 -1
  57. package/esm-es5/pn-profile-selector-option.entry.js +1 -1
  58. package/package.json +1 -1
  59. package/pn-market-web-components/p-04240175.entry.js +1 -0
  60. package/pn-market-web-components/p-08411f5e.entry.js +1 -0
  61. package/pn-market-web-components/{p-77887623.system.entry.js → p-1924152a.system.entry.js} +1 -1
  62. package/pn-market-web-components/p-1f2d9304.entry.js +1 -0
  63. package/pn-market-web-components/p-2ac481d7.entry.js +1 -0
  64. package/pn-market-web-components/{p-4cea6bf3.system.entry.js → p-2afc5570.system.entry.js} +1 -1
  65. package/pn-market-web-components/p-5cc29b6e.entry.js +1 -0
  66. package/pn-market-web-components/p-67887512.system.js +1 -1
  67. package/pn-market-web-components/p-6ce5a56d.system.entry.js +1 -0
  68. package/pn-market-web-components/p-77c9b601.entry.js +1 -0
  69. package/pn-market-web-components/p-8a763bfd.system.entry.js +1 -0
  70. package/pn-market-web-components/{p-2a7e6d3a.system.entry.js → p-93cecc43.system.entry.js} +1 -1
  71. package/pn-market-web-components/p-a7bb94a0.entry.js +1 -0
  72. package/pn-market-web-components/p-ba41a7c0.system.entry.js +1 -0
  73. package/pn-market-web-components/p-c5a97974.entry.js +1 -0
  74. package/pn-market-web-components/{p-7f5bee11.entry.js → p-dc1827a6.entry.js} +1 -1
  75. package/pn-market-web-components/p-e32dc098.entry.js +1 -0
  76. package/pn-market-web-components/p-e66a8bb8.system.entry.js +1 -0
  77. package/pn-market-web-components/{p-ddbd131f.system.entry.js → p-e6fa11ad.system.entry.js} +1 -1
  78. package/pn-market-web-components/p-ec96434c.system.entry.js +1 -0
  79. package/pn-market-web-components/{p-e23a18f4.system.entry.js → p-f7d1c0a0.system.entry.js} +1 -1
  80. package/pn-market-web-components/pn-market-web-components.esm.js +1 -1
  81. package/types/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-login-linklist.d.ts +13 -0
  82. package/types/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-login-links.d.ts +14 -0
  83. package/types/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-login-profileselection.d.ts +20 -0
  84. package/types/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-login.d.ts +6 -4
  85. package/types/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-types.d.ts +21 -0
  86. package/types/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader.d.ts +4 -2
  87. package/types/components/layout-components/pn-marketweb-siteheader/translations.d.ts +15 -0
  88. package/types/components/profile/pn-customernumber-selector/pn-customernumber-selector-option.d.ts +1 -1
  89. package/types/components/profile/pn-customernumber-selector/pn-customernumber-selector.d.ts +1 -1
  90. package/types/components/profile/pn-profile-selector/pn-profile-selector-option.d.ts +1 -1
  91. package/types/components/widgets/pn-find-price/pn-find-price-types.d.ts +1 -1
  92. package/types/components.d.ts +89 -45
  93. package/umd/pn-marketweb-salesforce.js +1 -1
  94. package/cjs/pn-marketweb-siteheader-profileselection.cjs.entry.js +0 -161
  95. package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-profileselection.js +0 -319
  96. package/esm/pn-marketweb-siteheader-profileselection.entry.js +0 -157
  97. package/esm-es5/pn-marketweb-siteheader-profileselection.entry.js +0 -1
  98. package/pn-market-web-components/p-39c42017.entry.js +0 -1
  99. package/pn-market-web-components/p-3a4b70d1.system.entry.js +0 -1
  100. package/pn-market-web-components/p-47cf8713.system.entry.js +0 -1
  101. package/pn-market-web-components/p-63a2ba1c.entry.js +0 -1
  102. package/pn-market-web-components/p-7e294268.entry.js +0 -1
  103. package/pn-market-web-components/p-a26e5490.system.entry.js +0 -1
  104. package/pn-market-web-components/p-a94593a9.system.entry.js +0 -1
  105. package/pn-market-web-components/p-ac8285b4.entry.js +0 -1
  106. package/pn-market-web-components/p-b1685197.entry.js +0 -1
  107. package/pn-market-web-components/p-e08a29ff.entry.js +0 -1
  108. package/pn-market-web-components/p-ea39d576.entry.js +0 -1
  109. package/pn-market-web-components/p-fcea21cb.entry.js +0 -1
  110. package/types/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-profileselection.d.ts +0 -28
@@ -0,0 +1,269 @@
1
+ import { Component, Prop, h, State, Element, Host } from "@stencil/core";
2
+ export class PnMarketwebSiteheaderLoginProfileselection {
3
+ constructor() {
4
+ // Login dialog
5
+ this.loginDialog = null;
6
+ this.loginManager = null;
7
+ this.endpoint = "";
8
+ this.loggedin = false;
9
+ this.idNamespace = "";
10
+ this.heading = "";
11
+ this.i18n = { "searchlabel": "", "searchplaceholder": "", "searchbuttontext": "", "menuHomeButton": "", "menuGoBackButton": "", "mainMenuButton": "", "menuStartButton": "", "profileSelectionFlyoutHeading": "" };
12
+ this.user = null;
13
+ this.logoutLink = null;
14
+ this.profileSelectorDialog = {
15
+ currentProfile: {
16
+ name: 'Hedin',
17
+ customerid: '5560230053'
18
+ },
19
+ profiles: [
20
+ {
21
+ name: 'Bilmetro AB',
22
+ customerid: '5560612789'
23
+ }
24
+ ]
25
+ };
26
+ }
27
+ componentWillLoad() {
28
+ var _a;
29
+ console.log('loginDialog', this.loginDialog);
30
+ console.log('this.loginManager', this.loginManager);
31
+ console.log('### this.loggedin', this.loggedin);
32
+ console.log('this.endpoint', this.endpoint);
33
+ if (!this.heading && ((_a = this.i18n) === null || _a === void 0 ? void 0 : _a.profileSelectionFlyoutHeading)) {
34
+ this.heading = this.i18n.profileSelectionFlyoutHeading;
35
+ }
36
+ this.init();
37
+ }
38
+ init() {
39
+ this.updateUserInfo();
40
+ this.adjustLoginLinks();
41
+ }
42
+ adjustLoginLinks() {
43
+ var _a, _b, _c, _d;
44
+ const adjustLink = (link, i) => {
45
+ link.isLogoutLink = (link.href.indexOf('logout') !== -1);
46
+ if (link.isLogoutLink) {
47
+ link.href = this.loginManager.getLogoutUrl(link.href.replace('logout', '').replace('http://window.location.href/?', '').replace('https://window.location.href/?', ''));
48
+ }
49
+ if (i === 0 && !link.href) {
50
+ link.href = this.loginManager.getLoginUrl();
51
+ link.linkType = 'primary';
52
+ }
53
+ if (link.primaryLinkApperance && !link.linkType) {
54
+ link.linkType = 'primary';
55
+ }
56
+ };
57
+ if ((_a = this.loginDialog) === null || _a === void 0 ? void 0 : _a.loggedInLinks) {
58
+ (_b = this.loginDialog) === null || _b === void 0 ? void 0 : _b.loggedInLinks.forEach(adjustLink);
59
+ }
60
+ this.logoutLink = (_d = (_c = this.loginDialog) === null || _c === void 0 ? void 0 : _c.loggedInLinks.filter(x => x.isLogoutLink)[0]) !== null && _d !== void 0 ? _d : null;
61
+ }
62
+ updateUserInfo() {
63
+ const userInfo = this.loginManager.getUserInfo();
64
+ this.user = userInfo;
65
+ console.log('this.user', this.user);
66
+ }
67
+ render() {
68
+ if (!this.loginDialog || !this.profileSelectorDialog) {
69
+ return;
70
+ }
71
+ let hostElementAttribute = {};
72
+ return (h(Host, Object.assign({}, hostElementAttribute),
73
+ this.heading ? h("strong", { class: "pn-marketweb-siteheader-login-profileselection-heading" }, this.heading) : null,
74
+ h("div", { class: "pn-marketweb-siteheader-login-profileselection-user" },
75
+ h("div", { class: "pn-marketweb-siteheader-login-profileselection-user-name" }, this.user.given_name),
76
+ h("div", { class: "pn-marketweb-siteheader-login-profileselection-user-description" }, this.user.username)),
77
+ h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile" },
78
+ h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile-name" }, this.profileSelectorDialog.currentProfile.name),
79
+ h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile-description" }, this.profileSelectorDialog.currentProfile.customerid)),
80
+ h("pn-marketweb-siteheader-login-linklist", { links: this.loginDialog.loggedInLinks.filter(x => x.isLogoutLink === false), loginManager: this.loginManager, idNamespace: this.idNamespace }),
81
+ h("div", { class: "pn-marketweb-siteheader-login-profileselection-divider" }),
82
+ this.profileSelectorDialog.profiles.map((profile) => {
83
+ return (h("div", { class: "pn-marketweb-siteheader-login-profileselection-profileoption" },
84
+ h("a", { href: `${this.endpoint}?selectprofile=${profile.customerid}}`, class: "pn-marketweb-siteheader-login-profileselection-profileoption-link" },
85
+ h("div", { class: "pn-marketweb-siteheader-login-profileselection-profileoption-content" },
86
+ h("div", { class: "pn-marketweb-siteheader-login-profileselection-profileoption-name" }, profile.name),
87
+ h("div", { class: "pn-marketweb-siteheader-login-profileselection-profileoption-description" }, profile.customerid)),
88
+ h("pn-icon", { symbol: "arrow-right", small: "false", color: "blue700" }))));
89
+ }),
90
+ this.logoutLink ?
91
+ h("div", { class: "pn-marketweb-siteheader-login-profileselection-logout" },
92
+ h("a", { href: this.logoutLink.href, rel: "nofollower noopener", class: "pn-marketweb-siteheader-login-profileselection-logout-link" }, this.logoutLink.linkText))
93
+ : null));
94
+ }
95
+ static get is() { return "pn-marketweb-siteheader-login-profileselection"; }
96
+ static get originalStyleUrls() { return {
97
+ "$": ["pn-marketweb-siteheader-login-profileselection.scss"]
98
+ }; }
99
+ static get styleUrls() { return {
100
+ "$": ["pn-marketweb-siteheader-login-profileselection.css"]
101
+ }; }
102
+ static get properties() { return {
103
+ "loginDialog": {
104
+ "type": "unknown",
105
+ "mutable": true,
106
+ "complexType": {
107
+ "original": "LoginDialog",
108
+ "resolved": "LoginDialog",
109
+ "references": {
110
+ "LoginDialog": {
111
+ "location": "import",
112
+ "path": "./pn-marketweb-siteheader-types"
113
+ }
114
+ }
115
+ },
116
+ "required": false,
117
+ "optional": false,
118
+ "docs": {
119
+ "tags": [],
120
+ "text": ""
121
+ },
122
+ "defaultValue": "null"
123
+ },
124
+ "loginManager": {
125
+ "type": "unknown",
126
+ "mutable": false,
127
+ "complexType": {
128
+ "original": "MarketWebLoginManager",
129
+ "resolved": "MarketWebLoginManager",
130
+ "references": {
131
+ "MarketWebLoginManager": {
132
+ "location": "import",
133
+ "path": "../../../globals/MarketWebLoginManager"
134
+ }
135
+ }
136
+ },
137
+ "required": false,
138
+ "optional": false,
139
+ "docs": {
140
+ "tags": [],
141
+ "text": ""
142
+ },
143
+ "defaultValue": "null"
144
+ },
145
+ "endpoint": {
146
+ "type": "string",
147
+ "mutable": false,
148
+ "complexType": {
149
+ "original": "string",
150
+ "resolved": "string",
151
+ "references": {}
152
+ },
153
+ "required": false,
154
+ "optional": false,
155
+ "docs": {
156
+ "tags": [],
157
+ "text": ""
158
+ },
159
+ "attribute": "endpoint",
160
+ "reflect": false,
161
+ "defaultValue": "\"\""
162
+ },
163
+ "loggedin": {
164
+ "type": "boolean",
165
+ "mutable": false,
166
+ "complexType": {
167
+ "original": "boolean",
168
+ "resolved": "boolean",
169
+ "references": {}
170
+ },
171
+ "required": false,
172
+ "optional": false,
173
+ "docs": {
174
+ "tags": [],
175
+ "text": ""
176
+ },
177
+ "attribute": "loggedin",
178
+ "reflect": false,
179
+ "defaultValue": "false"
180
+ },
181
+ "idNamespace": {
182
+ "type": "string",
183
+ "mutable": false,
184
+ "complexType": {
185
+ "original": "string",
186
+ "resolved": "string",
187
+ "references": {}
188
+ },
189
+ "required": false,
190
+ "optional": false,
191
+ "docs": {
192
+ "tags": [],
193
+ "text": ""
194
+ },
195
+ "attribute": "id-namespace",
196
+ "reflect": false,
197
+ "defaultValue": "\"\""
198
+ },
199
+ "heading": {
200
+ "type": "string",
201
+ "mutable": false,
202
+ "complexType": {
203
+ "original": "string",
204
+ "resolved": "string",
205
+ "references": {}
206
+ },
207
+ "required": false,
208
+ "optional": false,
209
+ "docs": {
210
+ "tags": [],
211
+ "text": ""
212
+ },
213
+ "attribute": "heading",
214
+ "reflect": false,
215
+ "defaultValue": "\"\""
216
+ },
217
+ "i18n": {
218
+ "type": "unknown",
219
+ "mutable": false,
220
+ "complexType": {
221
+ "original": "SiteHeaderI18N",
222
+ "resolved": "SiteHeaderI18N",
223
+ "references": {
224
+ "SiteHeaderI18N": {
225
+ "location": "import",
226
+ "path": "./pn-marketweb-siteheader-types"
227
+ }
228
+ }
229
+ },
230
+ "required": false,
231
+ "optional": false,
232
+ "docs": {
233
+ "tags": [],
234
+ "text": ""
235
+ },
236
+ "defaultValue": "{ \"searchlabel\":\"\", \"searchplaceholder\":\"\", \"searchbuttontext\":\"\", \"menuHomeButton\": \"\", \"menuGoBackButton\": \"\", \"mainMenuButton\": \"\", \"menuStartButton\": \"\", \"profileSelectionFlyoutHeading\": \"\" } as SiteHeaderI18N"
237
+ },
238
+ "profileSelectorDialog": {
239
+ "type": "unknown",
240
+ "mutable": false,
241
+ "complexType": {
242
+ "original": "ProfileSelectorDialog",
243
+ "resolved": "ProfileSelectorDialog",
244
+ "references": {
245
+ "ProfileSelectorDialog": {
246
+ "location": "import",
247
+ "path": "./pn-marketweb-siteheader-types"
248
+ },
249
+ "ProfileSelectorCustomer": {
250
+ "location": "import",
251
+ "path": "./pn-marketweb-siteheader-types"
252
+ }
253
+ }
254
+ },
255
+ "required": false,
256
+ "optional": false,
257
+ "docs": {
258
+ "tags": [],
259
+ "text": ""
260
+ },
261
+ "defaultValue": "{\n currentProfile: {\n name: 'Hedin',\n customerid: '5560230053'\n } as ProfileSelectorCustomer,\n profiles: [\n {\n name: 'Bilmetro AB',\n customerid: '5560612789'\n } as ProfileSelectorCustomer\n ]\n}"
262
+ }
263
+ }; }
264
+ static get states() { return {
265
+ "user": {},
266
+ "logoutLink": {}
267
+ }; }
268
+ static get elementRef() { return "hostElement"; }
269
+ }
@@ -3,23 +3,6 @@ pn-marketweb-siteheader-login {
3
3
  max-height: 5.2rem;
4
4
  position: relative;
5
5
  }
6
- pn-marketweb-siteheader-login strong {
7
- padding: 0.8rem 1.6rem;
8
- display: flex;
9
- align-items: center;
10
- }
11
- pn-marketweb-siteheader-login ul, pn-marketweb-siteheader-login li {
12
- list-style: none;
13
- margin: 0;
14
- padding: 0;
15
- }
16
- pn-marketweb-siteheader-login li {
17
- padding: 0.8rem 1.6rem;
18
- }
19
- pn-marketweb-siteheader-login li pn-button {
20
- display: block;
21
- width: 100%;
22
- }
23
6
  pn-marketweb-siteheader-login pn-nav-dropdown {
24
7
  display: none;
25
8
  }
@@ -6,12 +6,15 @@ export class PnMarketwebSiteheaderLogin {
6
6
  this.endpoint = "";
7
7
  /** Access token passed from backend */
8
8
  this.token = "";
9
+ this.i18n = { "searchlabel": "", "searchplaceholder": "", "searchbuttontext": "", "menuHomeButton": "", "menuGoBackButton": "", "mainMenuButton": "", "menuStartButton": "", "profileSelectionFlyoutHeading": "" };
9
10
  this.emitEvents = true;
10
11
  // Login dialog
11
12
  this.loginDialog = null;
12
13
  /** User Fullname */
13
14
  this.fullname = "";
14
15
  this.loggedin = false;
16
+ /** If this is selected we will show the new profile selection dropdown instead of the login version */
17
+ this.showProfileSelection = false;
15
18
  this.loginManager = null;
16
19
  this.toggleButtonText = "";
17
20
  this.username = this.fullname;
@@ -35,6 +38,47 @@ export class PnMarketwebSiteheaderLogin {
35
38
  this.toggleButtonText = this.loginDialog.loginMenuLinkText;
36
39
  this.loginManager.init(this.emitEvents);
37
40
  this.setToggleButtonText();
41
+ this.adjustLoginLinks();
42
+ }
43
+ adjustLoginLinks() {
44
+ var _a, _b, _c;
45
+ if (!((_a = this.loginDialog) === null || _a === void 0 ? void 0 : _a.loginMenuLinks)) {
46
+ return;
47
+ }
48
+ const adjustLink = (link, i) => {
49
+ link.isLogoutLink = (link.href.indexOf('logout') !== -1);
50
+ if (link.isLogoutLink) {
51
+ link.href = this.loginManager.getLogoutUrl(link.href.replace('logout', '').replace('http://window.location.href/?', '').replace('https://window.location.href/?', ''));
52
+ }
53
+ if (i === 0 && !link.href) {
54
+ link.href = this.loginManager.getLoginUrl();
55
+ link.linkType = 'primary';
56
+ }
57
+ if (link.primaryLinkApperance && !link.linkType) {
58
+ link.linkType = 'primary';
59
+ }
60
+ };
61
+ (_b = this.loginDialog) === null || _b === void 0 ? void 0 : _b.loginMenuLinks.forEach(adjustLink);
62
+ (_c = this.loginDialog) === null || _c === void 0 ? void 0 : _c.loggedInLinks.forEach(adjustLink);
63
+ this.loginDialog.legacyLoginLinks = [
64
+ {
65
+ href: this.loginManager.getLoginUrl(this.loginDialog.loginUrl),
66
+ linkText: this.loginDialog.loginLinkText,
67
+ openInNewWindow: false,
68
+ isLogoutLink: false,
69
+ pageLink: null,
70
+ linkType: 'primary',
71
+ primaryLinkApperance: true
72
+ },
73
+ {
74
+ href: this.loginManager.getLoginUrl(this.loginDialog.registerUrl),
75
+ linkText: this.loginDialog.createLoginLinkText,
76
+ openInNewWindow: false,
77
+ isLogoutLink: false,
78
+ pageLink: null,
79
+ primaryLinkApperance: false
80
+ }
81
+ ];
38
82
  }
39
83
  setUserName() {
40
84
  const userInfo = this.loginManager.getUserInfo();
@@ -72,83 +116,23 @@ export class PnMarketwebSiteheaderLogin {
72
116
  this.setToggleButtonText();
73
117
  }
74
118
  }
75
- uniqueId(text) {
76
- return "loginlink-" + text.replace(/[^A-Za-z0-9.\\\/]/igm, "") + "-" + (this.emitEvents ? "1" : "2");
77
- }
78
- linkAppearanceAttributes(link) {
79
- let attributes = {};
80
- if (link.linkType) {
81
- switch (link.linkType) {
82
- case 'primary':
83
- attributes = {
84
- appearance: '',
85
- variant: ''
86
- };
87
- break;
88
- case 'secondary':
89
- attributes = {
90
- appearance: 'light',
91
- variant: 'outlined'
92
- };
93
- break;
94
- case 'regularlink':
95
- default:
96
- attributes = {
97
- appearance: 'light',
98
- variant: 'borderless',
99
- icon: 'arrow-right'
100
- };
101
- break;
102
- }
103
- return attributes;
104
- }
105
- if (!link.linkType) {
106
- attributes = {
107
- appearance: link.primaryLinkApperance ? "dark" : "light"
108
- };
109
- }
110
- return attributes;
111
- }
112
119
  render() {
113
- var _a, _b, _c;
114
120
  if (!this.loginDialog) {
115
121
  return;
116
122
  }
117
123
  let hostElementAttribute = {
118
- username: null
124
+ username: null,
125
+ loggedin: 'false',
119
126
  };
120
127
  if (this.username) {
121
128
  hostElementAttribute.username = this.username;
129
+ hostElementAttribute.loggedin = this.loggedin + '';
122
130
  }
123
131
  return (h(Host, Object.assign({}, hostElementAttribute),
124
- h("pn-nav-dropdown", { label: this.toggleButtonText, icon: "user", class: "siteheader-logindialog" }, (!this.loginDialog.overrideLoginMenu) ?
125
- h("div", { "data-loggedin": this.loggedin + '' }, (!this.loggedin) ?
126
- h("div", null, (_a = this.loginDialog.loginTitle) !== null && _a !== void 0 ? _a : h("strong", null, this.loginDialog.loginTitle),
127
- ((_b = this.loginDialog.loginMenuLinks) === null || _b === void 0 ? void 0 : _b.length) > 0 ?
128
- h("ul", null, this.loginDialog.loginMenuLinks.map((link, i) => {
129
- const href = (i === 0 && !link.href) ? this.loginManager.getLoginUrl() : link.href;
130
- return (h("li", null,
131
- h("pn-button", Object.assign({ href: href, id: this.uniqueId(link.linkText) }, this.linkAppearanceAttributes(link), (link.openInNewWindow && { target: '_blank' })), link.linkText)));
132
- }))
133
- : (h("ul", null,
134
- h("li", null,
135
- h("pn-button", { href: this.loginManager.getLoginUrl(this.loginDialog.loginUrl), target: "_top" }, this.loginDialog.loginLinkText)),
136
- h("li", null,
137
- h("pn-button", { href: this.loginDialog.registerUrl, target: "_top", appearance: "light", variant: "outlined" }, this.loginDialog.createLoginLinkText)))))
138
- :
139
- h("div", null,
140
- h("ul", null, this.loginDialog.loggedInLinks.map((link) => {
141
- const isLogoutLink = link.href.indexOf('logout') !== -1;
142
- const href = (isLogoutLink) ? this.loginManager.getLogoutUrl(link.href.replace('logout', '').replace('http://window.location.href/?', '').replace('https://window.location.href/?', '')) : link.href;
143
- return (h("li", null,
144
- h("pn-button", Object.assign({ href: href, id: this.uniqueId(link.linkText) }, (link.openInNewWindow && { target: '_blank' }), this.linkAppearanceAttributes(link), { onClick: () => { if (isLogoutLink) {
145
- this.loginManager.clearUserData();
146
- } } }), link.linkText)));
147
- }))))
132
+ h("pn-nav-dropdown", { label: this.toggleButtonText, icon: "user", class: "siteheader-logindialog" }, this.loggedin && this.showProfileSelection ?
133
+ h("pn-marketweb-siteheader-login-profileselection", { loginDialog: this.loginDialog, loginManager: this.loginManager, loggedin: this.loggedin, i18n: this.i18n, idNamespace: this.emitEvents ? '1' : '2', endpoint: this.endpoint })
148
134
  :
149
- h("div", null,
150
- h("ul", null, (_c = this.loginDialog.loginMenuLinks) === null || _c === void 0 ? void 0 : _c.map(link => h("li", null,
151
- h("a", { href: link.href, target: link.openInNewWindow ? "_blank" : "_self", class: "btn btn-link" }, link.linkText))))))));
135
+ h("pn-marketweb-siteheader-login-links", { loginDialog: this.loginDialog, loginManager: this.loginManager, loggedin: this.loggedin, idNamespace: this.emitEvents ? '1' : '2', username: this.username }))));
152
136
  }
153
137
  static get is() { return "pn-marketweb-siteheader-login"; }
154
138
  static get originalStyleUrls() { return {
@@ -195,12 +179,17 @@ export class PnMarketwebSiteheaderLogin {
195
179
  "defaultValue": "\"\""
196
180
  },
197
181
  "i18n": {
198
- "type": "any",
182
+ "type": "unknown",
199
183
  "mutable": false,
200
184
  "complexType": {
201
- "original": "any",
202
- "resolved": "any",
203
- "references": {}
185
+ "original": "SiteHeaderI18N",
186
+ "resolved": "SiteHeaderI18N",
187
+ "references": {
188
+ "SiteHeaderI18N": {
189
+ "location": "import",
190
+ "path": "./pn-marketweb-siteheader-types"
191
+ }
192
+ }
204
193
  },
205
194
  "required": false,
206
195
  "optional": false,
@@ -208,8 +197,7 @@ export class PnMarketwebSiteheaderLogin {
208
197
  "tags": [],
209
198
  "text": ""
210
199
  },
211
- "attribute": "i-1-8n",
212
- "reflect": false
200
+ "defaultValue": "{ \"searchlabel\":\"\", \"searchplaceholder\":\"\", \"searchbuttontext\":\"\", \"menuHomeButton\": \"\", \"menuGoBackButton\": \"\", \"mainMenuButton\": \"\", \"menuStartButton\": \"\", \"profileSelectionFlyoutHeading\": \"\" } as SiteHeaderI18N"
213
201
  },
214
202
  "emitEvents": {
215
203
  "type": "boolean",
@@ -285,10 +273,29 @@ export class PnMarketwebSiteheaderLogin {
285
273
  "attribute": "loggedin",
286
274
  "reflect": false,
287
275
  "defaultValue": "false"
276
+ },
277
+ "showProfileSelection": {
278
+ "type": "boolean",
279
+ "mutable": true,
280
+ "complexType": {
281
+ "original": "boolean",
282
+ "resolved": "boolean",
283
+ "references": {}
284
+ },
285
+ "required": false,
286
+ "optional": false,
287
+ "docs": {
288
+ "tags": [],
289
+ "text": "If this is selected we will show the new profile selection dropdown instead of the login version"
290
+ },
291
+ "attribute": "show-profile-selection",
292
+ "reflect": false,
293
+ "defaultValue": "false"
288
294
  }
289
295
  }; }
290
296
  static get states() { return {
291
297
  "loginManager": {},
298
+ "loginLinks": {},
292
299
  "toggleButtonText": {},
293
300
  "username": {}
294
301
  }; }
@@ -30,6 +30,8 @@ export class PnMarketwebSiteheader {
30
30
  this.hideSearch = false;
31
31
  /** Hides the login if set to true*/
32
32
  this.hideLogin = false;
33
+ /** If this is selected we will show the new profile selection dropdown instead of the login version */
34
+ this.showProfileSelection = false;
33
35
  /** Autocomplete endpoint */
34
36
  this.AutocompleteEndpoint = "";
35
37
  /** Forward session to backend */
@@ -38,6 +40,7 @@ export class PnMarketwebSiteheader {
38
40
  this.cache = false;
39
41
  /** Event based only language switch */
40
42
  this.spaMode = false;
43
+ this.i18n = { "searchlabel": "", "searchplaceholder": "", "searchbuttontext": "", "menuHomeButton": "", "menuGoBackButton": "", "mainMenuButton": "", "menuStartButton": "", "profileSelectionFlyoutHeading": "" };
41
44
  this.gotData = false;
42
45
  this.fetchingData = false;
43
46
  this.homePageLink = "/";
@@ -200,6 +203,7 @@ export class PnMarketwebSiteheader {
200
203
  }
201
204
  onLoginStateChange(e) {
202
205
  var _a, _b, _c;
206
+ console.log('onLoginStateChange(e', e);
203
207
  if (((_a = e.detail) === null || _a === void 0 ? void 0 : _a.loggedIn) && ((_b = e.detail) === null || _b === void 0 ? void 0 : _b.token)) {
204
208
  this.loggedIn = ((_c = e.detail) === null || _c === void 0 ? void 0 : _c.loggedIn) === true;
205
209
  if (this.sessionForward) {
@@ -268,7 +272,7 @@ export class PnMarketwebSiteheader {
268
272
  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)" }))))),
269
273
  h("div", { class: "siteheader-topright" },
270
274
  h("slot", { name: "toprightstart" }),
271
- (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 })),
275
+ (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 })),
272
276
  (this.gotData && this.languageOptions && this.languageOptions.length) && !this.hideLanguageSelector &&
273
277
  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) }))),
274
278
  h("slot", { name: "toprightend" }))),
@@ -290,7 +294,7 @@ export class PnMarketwebSiteheader {
290
294
  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 })))))));
291
295
  })),
292
296
  h("div", { slot: "footer", class: "siteheader-menu-footer" },
293
- (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 })),
297
+ (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 })),
294
298
  (this.gotData && this.languageOptions && this.languageOptions.length) && !this.hideLanguageSelector &&
295
299
  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) }))),
296
300
  !this.hideSiteSelector &&
@@ -508,6 +512,24 @@ export class PnMarketwebSiteheader {
508
512
  "reflect": true,
509
513
  "defaultValue": "false"
510
514
  },
515
+ "showProfileSelection": {
516
+ "type": "boolean",
517
+ "mutable": true,
518
+ "complexType": {
519
+ "original": "boolean",
520
+ "resolved": "boolean",
521
+ "references": {}
522
+ },
523
+ "required": false,
524
+ "optional": false,
525
+ "docs": {
526
+ "tags": [],
527
+ "text": "If this is selected we will show the new profile selection dropdown instead of the login version"
528
+ },
529
+ "attribute": "show-profile-selection",
530
+ "reflect": true,
531
+ "defaultValue": "false"
532
+ },
511
533
  "AutocompleteEndpoint": {
512
534
  "type": "string",
513
535
  "mutable": false,
@@ -1,5 +1,7 @@
1
1
  import readme from "./readme.md";
2
2
 
3
+ const usertoken = '5e5357915ea021150aa24fe6bd889bdacee14da41632a6c305e13ee';
4
+
3
5
  export default {
4
6
  title: "Web Components/Market web site Header",
5
7
  parameters: {
@@ -51,6 +53,7 @@ const PrimaryTemplate = ({ ...args }) => {
51
53
  hide-search="false"
52
54
  hide-login="false"
53
55
  cache="false"
56
+ show-profile-selection="true"
54
57
  autocomplete-endpoint="http://localhost:51444/find_v2/_autocomplete"
55
58
  session-forward="true">
56
59
  <a href="" class="header-cart" slot="toprightend" style="align-self:center;position:relative;text-decoration:none;">
@@ -77,6 +80,45 @@ Primary.args = {
77
80
  endpoint: 'http://localhost:51444'
78
81
  }
79
82
 
83
+ const OldLoginDropdownTemplate = ({ ...args }) => {
84
+ return `
85
+ <div style="background:#ddd;min-height:100vh;">
86
+ <pn-marketweb-siteheader
87
+ market="${ args.market }"
88
+ language="${ args.language }"
89
+ endpoint="${ args.endpoint }"
90
+ hide-site-selector="false"
91
+ hide-language-selector="false"
92
+ hide-search="false"
93
+ hide-login="false"
94
+ show-profile-selection="false"
95
+ cache="false"
96
+ autocomplete-endpoint="http://localhost:51444/find_v2/_autocomplete"
97
+ session-forward="true">
98
+ <a href="" class="header-cart" slot="toprightend" style="align-self:center;position:relative;text-decoration:none;">
99
+ <span>Varukorg</span>
100
+ <pn-icon symbol="shop" color="blue700" class="pn-icon"></pn-icon>
101
+ </a>
102
+ </pn-marketweb-siteheader>
103
+ <div style="height:120vh; margin:2em; max-width:calc(100vw - 1em);background:#ccc;border:1px solid #333;">
104
+ Content that is higher than 100% viewport height
105
+ </div>
106
+ </div>
107
+
108
+ <!--
109
+ <link rel="alternate" href="https://www.postnord.se/en/business-solutions" hreflang="en" />
110
+ <link rel="alternate" href="https://www.postnord.se/foretagslosningar" hreflang="sv" />
111
+ -->
112
+ `;
113
+ };
114
+ //
115
+ export const OldLoginDropdown = OldLoginDropdownTemplate.bind({});
116
+ OldLoginDropdown.args = {
117
+ market : "se",
118
+ language: 'sv',
119
+ endpoint: 'http://localhost:51444'
120
+ }
121
+
80
122
 
81
123
  const MinimalOptionsTemplate = ({ ...args }) => {
82
124
  return `
@@ -191,8 +233,33 @@ export const LoggedIn = LoggedInTemplate.bind({});
191
233
  LoggedIn.args = {
192
234
  market : "se",
193
235
  language: 'sv',
194
- endpoint: 'https://com-integration.postnord.com',
195
- token: '26be29f67598bb2ee0530ac63c938727d703262646e521b67fe9751',
236
+ // endpoint: 'https://com-integration.postnord.com',
237
+ endpoint: 'http://localhost:51444/',
238
+ token: usertoken,
239
+ };
240
+
241
+ const LoggedInProfileSelectionTemplate = ({ ...args }) => {
242
+ return `
243
+ <div style="background:#ddd;min-height:100vh;">
244
+ <pn-marketweb-siteheader
245
+ market="${ args.market }"
246
+ language="${ args.language }"
247
+ endpoint="${ args.endpoint }"
248
+ user-token="${ args.token }"
249
+ show-profile-selection="true"
250
+ >
251
+ </pn-marketweb-siteheader>
252
+ </div>
253
+ `;
254
+ };
255
+
256
+ export const LoggedInProfileSelection = LoggedInProfileSelectionTemplate.bind({});
257
+ LoggedInProfileSelection.args = {
258
+ market : "se",
259
+ language: 'sv',
260
+ // endpoint: 'https://com-integration.postnord.com',
261
+ endpoint: 'http://localhost:51444/',
262
+ token: usertoken,
196
263
  };
197
264
 
198
265
  const BusinessUserLoggedInTemplate = ({ ...args }) => {