@postnord/pn-marketweb-components 2.1.8 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/cjs/loader.cjs.js +1 -1
  2. package/cjs/pn-market-web-components.cjs.js +1 -1
  3. package/cjs/pn-marketweb-siteheader-login-button_5.cjs.entry.js +68 -58
  4. package/cjs/pn-share-item.cjs.entry.js +22 -0
  5. package/cjs/pn-share.cjs.entry.js +64 -0
  6. package/collection/collection-manifest.json +2 -0
  7. package/collection/components/cta/pn-share/pn-share-item.css +42 -0
  8. package/collection/components/cta/pn-share/pn-share-item.js +61 -0
  9. package/collection/components/cta/pn-share/pn-share.css +23 -0
  10. package/collection/components/cta/pn-share/pn-share.js +91 -0
  11. package/collection/components/cta/pn-share/pn-share.stories.js +22 -0
  12. package/collection/components/cta/pn-share/translations.js +17 -0
  13. package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-login-profileselection.js +78 -68
  14. package/custom-elements/index.d.ts +12 -0
  15. package/custom-elements/index.js +188 -100
  16. package/esm/loader.js +1 -1
  17. package/esm/pn-market-web-components.js +1 -1
  18. package/esm/pn-marketweb-siteheader-login-button_5.entry.js +68 -58
  19. package/esm/pn-share-item.entry.js +18 -0
  20. package/esm/pn-share.entry.js +60 -0
  21. package/esm-es5/loader.js +1 -1
  22. package/esm-es5/pn-market-web-components.js +1 -1
  23. package/esm-es5/pn-marketweb-siteheader-login-button_5.entry.js +1 -1
  24. package/esm-es5/pn-share-item.entry.js +1 -0
  25. package/esm-es5/pn-share.entry.js +1 -0
  26. package/package.json +1 -1
  27. package/pn-market-web-components/p-086a72ca.system.entry.js +1 -0
  28. package/pn-market-web-components/p-138b1e76.entry.js +1 -0
  29. package/pn-market-web-components/{p-eb4eed7f.entry.js → p-381c034b.entry.js} +1 -1
  30. package/pn-market-web-components/p-67887512.system.js +1 -1
  31. package/pn-market-web-components/{p-aba46e52.system.entry.js → p-a5171cb9.system.entry.js} +1 -1
  32. package/pn-market-web-components/p-ecf712bb.system.entry.js +1 -0
  33. package/pn-market-web-components/p-ee589138.entry.js +1 -0
  34. package/pn-market-web-components/pn-market-web-components.esm.js +1 -1
  35. package/types/components/cta/pn-share/pn-share-item.d.ts +6 -0
  36. package/types/components/cta/pn-share/pn-share.d.ts +10 -0
  37. package/types/components/cta/pn-share/translations.d.ts +17 -0
  38. package/types/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-login-profileselection.d.ts +3 -2
  39. package/types/components.d.ts +34 -0
  40. package/umd/pn-marketweb-init.js +1 -1
  41. package/umd/pn-marketweb-salesforce.js +2 -2
@@ -0,0 +1,23 @@
1
+ pn-share .pn-share__container {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 0.8rem;
5
+ }
6
+ pn-share .pn-share__heading {
7
+ font-size: 1.6rem;
8
+ font-weight: 500;
9
+ }
10
+ pn-share .pn-share__heading:after {
11
+ content: "";
12
+ display: block;
13
+ height: 0.2rem;
14
+ background-color: #F3F2F2;
15
+ margin-top: 0.4rem;
16
+ margin-bottom: 0.8rem;
17
+ }
18
+ pn-share .pn-share__items {
19
+ display: flex;
20
+ flex-direction: row;
21
+ gap: 0.8rem;
22
+ align-items: center;
23
+ }
@@ -0,0 +1,91 @@
1
+ import { Component, Element, h, Host, Prop, State, Watch } from '@stencil/core';
2
+ import { translations } from './translations';
3
+ const SHARE_URLS = [
4
+ { platform: 'linkedin', url: 'https://www.linkedin.com/sharing/share-offsite/?url=', text: 'LinkedIn' },
5
+ { platform: 'twitter', url: 'https://twitter.com/intent/tweet?url=', text: 'Twitter' },
6
+ { platform: 'facebook', url: 'https://www.facebook.com/sharer/sharer.php?u=', text: 'Facebook' },
7
+ ];
8
+ export class PnShare {
9
+ constructor() {
10
+ this.link = null;
11
+ this.language = 'sv';
12
+ }
13
+ componentWillLoad() {
14
+ this.setTranslations();
15
+ }
16
+ setTranslations() {
17
+ if (this.language === 'nb') {
18
+ this.language = 'no';
19
+ }
20
+ if (this.language && translations[this.language]) {
21
+ this.i18n = translations[this.language];
22
+ }
23
+ }
24
+ onLanguageChange() {
25
+ this.setTranslations();
26
+ }
27
+ render() {
28
+ return (h(Host, null,
29
+ h("div", { class: "pn-share__container" },
30
+ h("h3", { class: "pn-share__heading" },
31
+ this.i18n.sharelabel,
32
+ ":"),
33
+ h("div", { class: "pn-share__items" }, SHARE_URLS.map(platform => {
34
+ return (h("pn-share-item", { link: `${platform.url}${this.link}`, text: platform.text },
35
+ h("pn-icon", { slot: "icon", symbol: platform.platform })));
36
+ })))));
37
+ }
38
+ static get is() { return "pn-share"; }
39
+ static get originalStyleUrls() { return {
40
+ "$": ["pn-share.scss"]
41
+ }; }
42
+ static get styleUrls() { return {
43
+ "$": ["pn-share.css"]
44
+ }; }
45
+ static get properties() { return {
46
+ "link": {
47
+ "type": "string",
48
+ "mutable": false,
49
+ "complexType": {
50
+ "original": "string",
51
+ "resolved": "string",
52
+ "references": {}
53
+ },
54
+ "required": false,
55
+ "optional": false,
56
+ "docs": {
57
+ "tags": [],
58
+ "text": ""
59
+ },
60
+ "attribute": "link",
61
+ "reflect": false,
62
+ "defaultValue": "null"
63
+ },
64
+ "language": {
65
+ "type": "string",
66
+ "mutable": true,
67
+ "complexType": {
68
+ "original": "string",
69
+ "resolved": "string",
70
+ "references": {}
71
+ },
72
+ "required": false,
73
+ "optional": false,
74
+ "docs": {
75
+ "tags": [],
76
+ "text": ""
77
+ },
78
+ "attribute": "language",
79
+ "reflect": true,
80
+ "defaultValue": "'sv'"
81
+ }
82
+ }; }
83
+ static get states() { return {
84
+ "i18n": {}
85
+ }; }
86
+ static get elementRef() { return "hostElement"; }
87
+ static get watchers() { return [{
88
+ "propName": "language",
89
+ "methodName": "onLanguageChange"
90
+ }]; }
91
+ }
@@ -0,0 +1,22 @@
1
+ import readme from './readme.md';
2
+
3
+ export default {
4
+ title: 'CTA/Share',
5
+ parameters: {
6
+ notes: readme,
7
+ layout: 'centered',
8
+ },
9
+ };
10
+
11
+ const Template = ({ ...args }) => {
12
+ return `
13
+ <div style="width:200%; margin:0 auto">
14
+ <pn-share link=${args.link}></pn-share>
15
+ </div>
16
+ `;
17
+ };
18
+
19
+ export const Share = Template.bind({});
20
+ Share.args = {
21
+ link: 'www.google.se',
22
+ };
@@ -0,0 +1,17 @@
1
+ export const translations = {
2
+ sv: {
3
+ sharelabel: 'Dela med',
4
+ },
5
+ en: {
6
+ sharelabel: 'Share to',
7
+ },
8
+ da: {
9
+ sharelabel: 'Del med',
10
+ },
11
+ no: {
12
+ sharelabel: 'Dele med',
13
+ },
14
+ fi: {
15
+ sharelabel: 'Jakaa',
16
+ },
17
+ };
@@ -1,18 +1,27 @@
1
- import { Component, Prop, h, State, Element, Host } from "@stencil/core";
2
- import { state as headerState } from "./pn-marketweb-siteheader-store";
1
+ import { Component, Element, h, Host, Prop, State } from '@stencil/core';
2
+ import { state as headerState } from './pn-marketweb-siteheader-store';
3
3
  export class PnMarketwebSiteheaderLoginProfileselection {
4
4
  constructor() {
5
5
  // Login dialog
6
6
  this.loginDialog = null;
7
- this.endpoint = "";
7
+ this.endpoint = '';
8
8
  this.loggedin = false;
9
- this.idNamespace = "";
9
+ this.idNamespace = '';
10
10
  this.heading = null;
11
- this.i18n = { "searchlabel": "", "searchplaceholder": "", "searchbuttontext": "", "menuHomeButton": "", "menuGoBackButton": "", "mainMenuButton": "", "menuStartButton": "", "profileSelectionFlyoutHeading": "" };
11
+ this.i18n = {
12
+ searchlabel: '',
13
+ searchplaceholder: '',
14
+ searchbuttontext: '',
15
+ menuHomeButton: '',
16
+ menuGoBackButton: '',
17
+ mainMenuButton: '',
18
+ menuStartButton: '',
19
+ profileSelectionFlyoutHeading: '',
20
+ };
12
21
  this.user = null;
13
22
  this.logoutLink = null;
14
23
  this.userName = null;
15
- this.userEmail = "";
24
+ this.userEmail = '';
16
25
  this.currentProfile = null;
17
26
  this.profileoptions = [];
18
27
  }
@@ -32,84 +41,84 @@ export class PnMarketwebSiteheaderLoginProfileselection {
32
41
  if (!this.loggedin || this.profileoptions.length > 0) {
33
42
  return;
34
43
  }
35
- let apiUrl = `${this.endpoint}${(this.endpoint.lastIndexOf('/') > -1 && this.endpoint.lastIndexOf('/') === this.endpoint.length - 1) ? '' : '/'}api/user/parentorganizations`;
44
+ let apiUrl = `${this.endpoint}${this.endpoint.lastIndexOf('/') > -1 && this.endpoint.lastIndexOf('/') === this.endpoint.length - 1 ? '' : '/'}api/user/parentorganizations`;
36
45
  const req = await fetch(apiUrl);
37
46
  const reqdata = await req.json();
38
47
  const fallbackData = {
39
48
  loggedin: true,
40
49
  organizations: [
41
50
  {
42
- name: "Forsheda Livs AB",
43
- customerNumber: "5564513603",
44
- id: "dbba867d-1dff-3dbb-b420-c57b4b828b73",
51
+ name: 'Forsheda Livs AB',
52
+ customerNumber: '5564513603',
53
+ id: 'dbba867d-1dff-3dbb-b420-c57b4b828b73',
45
54
  selected: true,
46
55
  profiles: [
47
56
  {
48
- name: "Forsheda Livs AB",
49
- customerNumber: "20685482",
50
- id: "f757ba28-9a73-15a2-f128-4b394d970f3f",
51
- ssid: "",
57
+ name: 'Forsheda Livs AB',
58
+ customerNumber: '20685482',
59
+ id: 'f757ba28-9a73-15a2-f128-4b394d970f3f',
60
+ ssid: '',
52
61
  selected: false,
53
- customerGroup: "Business"
62
+ customerGroup: 'Business',
54
63
  },
55
64
  {
56
- name: "ICA MAXI KUNGSBACKA",
57
- customerNumber: "20831191",
58
- id: "5aea41df-32b0-3f7e-2946-78598360177d",
59
- ssid: "259686",
65
+ name: 'ICA MAXI KUNGSBACKA',
66
+ customerNumber: '20831191',
67
+ id: '5aea41df-32b0-3f7e-2946-78598360177d',
68
+ ssid: '259686',
60
69
  selected: true,
61
- customerGroup: "Agent"
62
- }
63
- ]
70
+ customerGroup: 'Agent',
71
+ },
72
+ ],
64
73
  },
65
74
  {
66
- name: "Hem Livs i Kungsbacka AB",
67
- customerNumber: "5565271250",
68
- id: "97ca363c-40ef-cca9-7a3c-9e7f025567c2",
75
+ name: 'Hem Livs i Kungsbacka AB',
76
+ customerNumber: '5565271250',
77
+ id: '97ca363c-40ef-cca9-7a3c-9e7f025567c2',
69
78
  selected: false,
70
79
  profiles: [
71
80
  {
72
- name: "ICA KVANTUM KUNGSBACKA",
73
- customerNumber: "20831193",
74
- id: "fbd61ffd-41c6-2206-b88e-cfef91e1dc39",
75
- ssid: "259691",
81
+ name: 'ICA KVANTUM KUNGSBACKA',
82
+ customerNumber: '20831193',
83
+ id: 'fbd61ffd-41c6-2206-b88e-cfef91e1dc39',
84
+ ssid: '259691',
76
85
  selected: false,
77
- customerGroup: "Agent"
78
- }
79
- ]
86
+ customerGroup: 'Agent',
87
+ },
88
+ ],
80
89
  },
81
90
  {
82
- name: "ICA SUPERMARKET TORGET",
83
- customerNumber: "5568902679",
84
- id: "7cb76a94-e1a5-5f57-58fd-bc563851b28e",
91
+ name: 'ICA SUPERMARKET TORGET',
92
+ customerNumber: '5568902679',
93
+ id: '7cb76a94-e1a5-5f57-58fd-bc563851b28e',
85
94
  selected: false,
86
95
  profiles: [
87
96
  {
88
- name: "ICA SUPERMARKET TORGET",
89
- customerNumber: "20831212",
90
- id: "3a2db017-b68f-6fa0-fe70-542c08cd97ce",
91
- ssid: "",
97
+ name: 'ICA SUPERMARKET TORGET',
98
+ customerNumber: '20831212',
99
+ id: '3a2db017-b68f-6fa0-fe70-542c08cd97ce',
100
+ ssid: '',
92
101
  selected: false,
93
- customerGroup: "Agent"
94
- }
95
- ]
96
- }
97
- ]
102
+ customerGroup: 'Agent',
103
+ },
104
+ ],
105
+ },
106
+ ],
98
107
  };
99
- const data = (window.location.href.indexOf('localhost:6008') !== -1) ? fallbackData : reqdata;
108
+ const data = window.location.href.indexOf('localhost:6008') !== -1 ? fallbackData : reqdata;
100
109
  if (!data || !data.organizations || !data.organizations.length) {
101
110
  return;
102
111
  }
103
- data.organizations.forEach((org) => {
112
+ data.organizations.forEach(org => {
104
113
  if (org.selected === true && org.profiles) {
105
114
  const selectedProfile = org.profiles.filter(x => x.selected === true);
106
- if (selectedProfile && selectedProfile[0] && selectedProfile[0].customerGroup.toLocaleLowerCase() === "agent" && selectedProfile[0].ssid) {
115
+ if (selectedProfile && selectedProfile[0] && selectedProfile[0].customerGroup.toLocaleLowerCase() === 'agent' && selectedProfile[0].ssid) {
107
116
  org.customerNumber = selectedProfile[0].ssid;
108
117
  }
109
118
  }
110
119
  else {
111
- if (org.customerNumber.length === 10 && org.customerNumber.substring(0, 2) === "55") {
112
- org.customerNumber = org.customerNumber.substring(0, 6) + "-" + org.customerNumber.substring(6);
120
+ if (org.customerNumber.length === 10 && org.customerNumber.substring(0, 2) === '55') {
121
+ org.customerNumber = org.customerNumber.substring(0, 6) + '-' + org.customerNumber.substring(6);
113
122
  }
114
123
  this.profileoptions.push(org);
115
124
  }
@@ -119,8 +128,8 @@ export class PnMarketwebSiteheaderLoginProfileselection {
119
128
  name: this.userName,
120
129
  customerNumber: '',
121
130
  id: '',
122
- selected: (!currentProfileObj),
123
- profiles: []
131
+ selected: !currentProfileObj,
132
+ profiles: [],
124
133
  };
125
134
  if (!currentProfileObj) {
126
135
  currentProfileObj = userProfileOption;
@@ -134,7 +143,7 @@ export class PnMarketwebSiteheaderLoginProfileselection {
134
143
  var _a, _b, _c, _d;
135
144
  const adjustLink = (link, i) => {
136
145
  if (!link.isLogoutLink) {
137
- link.isLogoutLink = (link.pageLink.indexOf('location.href') !== -1 && link.pageLink.indexOf('logout') !== -1);
146
+ link.isLogoutLink = link.pageLink.indexOf('location.href') !== -1 && link.pageLink.indexOf('logout') !== -1;
138
147
  }
139
148
  if (link.isLogoutLink) {
140
149
  link.href = headerState.loginManager.getLogoutUrl(link.href);
@@ -162,7 +171,7 @@ export class PnMarketwebSiteheaderLoginProfileselection {
162
171
  this.userEmail = userInfo.email;
163
172
  }
164
173
  if (userInfo && userInfo.given_name) {
165
- this.userName = userInfo.given_name + ((userInfo === null || userInfo === void 0 ? void 0 : userInfo.family_name) ? ` ${userInfo === null || userInfo === void 0 ? void 0 : userInfo.family_name}` : "");
174
+ this.userName = userInfo.given_name + ((userInfo === null || userInfo === void 0 ? void 0 : userInfo.family_name) ? ` ${userInfo === null || userInfo === void 0 ? void 0 : userInfo.family_name}` : '');
166
175
  }
167
176
  if (userInfo && userInfo.given_name) {
168
177
  this.userName = userInfo.given_name;
@@ -177,6 +186,9 @@ export class PnMarketwebSiteheaderLoginProfileselection {
177
186
  return;
178
187
  }
179
188
  }
189
+ filterLogoutLink(loggedInLinks) {
190
+ return loggedInLinks.filter((link) => !link.isLogoutLink);
191
+ }
180
192
  render() {
181
193
  if (!this.loginDialog) {
182
194
  return;
@@ -184,15 +196,15 @@ export class PnMarketwebSiteheaderLoginProfileselection {
184
196
  let hostElementAttribute = {};
185
197
  return (h(Host, Object.assign({}, hostElementAttribute),
186
198
  this.heading ? h("strong", { class: "pn-marketweb-siteheader-login-profileselection-heading" }, this.heading) : null,
187
- this.currentProfile !== null && this.currentProfile.name ?
188
- h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile" },
189
- h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile-name" }, this.currentProfile.name),
190
- h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile-description" }, this.currentProfile.customerNumber ? this.currentProfile.customerNumber : this.userEmail))
191
- : null,
192
- h("pn-marketweb-siteheader-login-linklist", { links: this.loginDialog.loggedInLinks, idNamespace: this.idNamespace }),
199
+ this.currentProfile !== null && this.currentProfile.name ? (h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile" },
200
+ h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile-name" }, this.currentProfile.name),
201
+ h("div", { class: "pn-marketweb-siteheader-login-profileselection-currentprofile-description" }, this.currentProfile.customerNumber ? this.currentProfile.customerNumber : this.userEmail))) : null,
202
+ h("pn-marketweb-siteheader-login-linklist", { links: this.filterLogoutLink(this.loginDialog.loggedInLinks), idNamespace: this.idNamespace }),
193
203
  h("div", { class: "pn-marketweb-siteheader-login-profileselection-divider" }),
194
- this.profileoptions.filter(x => x.selected !== true).map((organization) => {
195
- let customerNumber = (organization.profiles.length > 0) ? organization.profiles[0].customerNumber : organization.customerNumber;
204
+ this.profileoptions
205
+ .filter(x => x.selected !== true)
206
+ .map(organization => {
207
+ let customerNumber = organization.profiles.length > 0 ? organization.profiles[0].customerNumber : organization.customerNumber;
196
208
  return (h("div", { class: "pn-marketweb-siteheader-login-profileselection-profileoption" },
197
209
  h("a", { href: `${this.endpoint}/api/user/setprofile?customernumber=${customerNumber}&returnUrl=${window.location.href}`, class: "pn-marketweb-siteheader-login-profileselection-profileoption-link" },
198
210
  h("div", { class: "pn-marketweb-siteheader-login-profileselection-profileoption-content" },
@@ -200,10 +212,8 @@ export class PnMarketwebSiteheaderLoginProfileselection {
200
212
  h("div", { class: "pn-marketweb-siteheader-login-profileselection-profileoption-description" }, organization.customerNumber ? organization.customerNumber : this.userEmail)),
201
213
  h("pn-icon", { symbol: "arrow-right", small: "false", color: "blue700" }))));
202
214
  }),
203
- this.logoutLink ?
204
- h("div", { class: "pn-marketweb-siteheader-login-profileselection-logout" },
205
- h("a", { href: this.logoutLink.href, rel: "nofollower noopener", id: "pn-marketweb-header-logoutlink", onClick: () => headerState.loginManager.clearUserData(), class: "pn-marketweb-siteheader-login-profileselection-logout-link" }, this.logoutLink.linkText))
206
- : null));
215
+ this.logoutLink ? (h("div", { class: "pn-marketweb-siteheader-login-profileselection-logout" },
216
+ h("a", { href: this.logoutLink.href, rel: "nofollower noopener", id: "pn-marketweb-header-logoutlink", onClick: () => headerState.loginManager.clearUserData(), class: "pn-marketweb-siteheader-login-profileselection-logout-link" }, this.logoutLink.linkText))) : null));
207
217
  }
208
218
  static get is() { return "pn-marketweb-siteheader-login-profileselection"; }
209
219
  static get originalStyleUrls() { return {
@@ -250,7 +260,7 @@ export class PnMarketwebSiteheaderLoginProfileselection {
250
260
  },
251
261
  "attribute": "endpoint",
252
262
  "reflect": false,
253
- "defaultValue": "\"\""
263
+ "defaultValue": "''"
254
264
  },
255
265
  "loggedin": {
256
266
  "type": "boolean",
@@ -286,7 +296,7 @@ export class PnMarketwebSiteheaderLoginProfileselection {
286
296
  },
287
297
  "attribute": "id-namespace",
288
298
  "reflect": false,
289
- "defaultValue": "\"\""
299
+ "defaultValue": "''"
290
300
  },
291
301
  "heading": {
292
302
  "type": "string",
@@ -325,7 +335,7 @@ export class PnMarketwebSiteheaderLoginProfileselection {
325
335
  "tags": [],
326
336
  "text": ""
327
337
  },
328
- "defaultValue": "{ \"searchlabel\":\"\", \"searchplaceholder\":\"\", \"searchbuttontext\":\"\", \"menuHomeButton\": \"\", \"menuGoBackButton\": \"\", \"mainMenuButton\": \"\", \"menuStartButton\": \"\", \"profileSelectionFlyoutHeading\": \"\" } as SiteHeaderI18N"
338
+ "defaultValue": "{\n searchlabel: '',\n searchplaceholder: '',\n searchbuttontext: '',\n menuHomeButton: '',\n menuGoBackButton: '',\n mainMenuButton: '',\n menuStartButton: '',\n profileSelectionFlyoutHeading: '',\n } as SiteHeaderI18N"
329
339
  },
330
340
  "currentProfile": {
331
341
  "type": "unknown",
@@ -344,6 +344,18 @@ export const PnQuoteCard: {
344
344
  new (): PnQuoteCard;
345
345
  };
346
346
 
347
+ interface PnShare extends Components.PnShare, HTMLElement {}
348
+ export const PnShare: {
349
+ prototype: PnShare;
350
+ new (): PnShare;
351
+ };
352
+
353
+ interface PnShareItem extends Components.PnShareItem, HTMLElement {}
354
+ export const PnShareItem: {
355
+ prototype: PnShareItem;
356
+ new (): PnShareItem;
357
+ };
358
+
347
359
  interface PnSidenav extends Components.PnSidenav, HTMLElement {}
348
360
  export const PnSidenav: {
349
361
  prototype: PnSidenav;