@postnord/pn-marketweb-components 2.4.21 → 2.4.23
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/index-4199ff85.js +8 -4
- package/cjs/loader.cjs.js +1 -1
- package/cjs/pn-address-autofill.cjs.entry.js +322 -0
- package/cjs/pn-market-web-components.cjs.js +1 -1
- package/cjs/pn-marketweb-input.cjs.entry.js +36 -25
- package/cjs/pn-marketweb-sitefooter.cjs.entry.js +6 -6
- package/cjs/pn-marketweb-siteheader.cjs.entry.js +3 -3
- package/cjs/pn-proxio-findprice.cjs.entry.js +3 -3
- package/cjs/pn-proxio-pricegroup.cjs.entry.js +3 -3
- package/collection/collection-manifest.json +2 -1
- package/collection/components/input/pn-address-autofill/pn-address-autofill.css +45 -0
- package/collection/components/input/pn-address-autofill/pn-address-autofill.js +537 -0
- package/collection/components/input/pn-address-autofill/pn-address-autofill.stories.js +40 -0
- package/collection/components/input/pn-marketweb-input/pn-marketweb-input.js +50 -39
- package/collection/components/input/pn-multi-formfield/types.js +1 -0
- package/collection/components/layout-components/pn-marketweb-sitefooter/socialMediaIcons.js +3 -3
- package/components/index.d.ts +2 -1
- package/components/index.js +1 -0
- package/components/index2.js +63 -52
- package/components/index3.js +52 -63
- package/components/pn-address-autofill.d.ts +11 -0
- package/components/pn-address-autofill.js +359 -0
- package/components/pn-animated-tile.js +1 -1
- package/components/pn-dropdown-choice-adds-row.js +1 -1
- package/components/pn-marketweb-input2.js +36 -25
- package/components/pn-marketweb-sitefooter.js +4 -4
- package/components/pn-marketweb-siteheader.js +1 -1
- package/components/pn-multi-formfield.js +1 -1
- package/components/pn-proxio-findprice.js +1 -1
- package/components/pn-proxio-pricegroup.js +1 -1
- package/components/pn-spotlight.js +1 -1
- package/esm/index-ee44c065.js +8 -4
- package/esm/loader.js +1 -1
- package/esm/pn-address-autofill.entry.js +318 -0
- package/esm/pn-market-web-components.js +1 -1
- package/esm/pn-marketweb-input.entry.js +36 -25
- package/esm/pn-marketweb-sitefooter.entry.js +4 -4
- package/esm/pn-marketweb-siteheader.entry.js +1 -1
- package/esm/pn-proxio-findprice.entry.js +1 -1
- package/esm/pn-proxio-pricegroup.entry.js +1 -1
- package/esm-es5/FetchHelper-62dc55bf.js +1 -0
- package/esm-es5/index-ee44c065.js +1 -1
- package/esm-es5/loader.js +1 -1
- package/esm-es5/pn-address-autofill.entry.js +1 -0
- package/esm-es5/pn-market-web-components.js +1 -1
- package/esm-es5/pn-marketweb-input.entry.js +1 -1
- package/esm-es5/pn-marketweb-sitefooter.entry.js +1 -1
- package/esm-es5/pn-marketweb-siteheader.entry.js +1 -1
- package/esm-es5/pn-proxio-findprice.entry.js +1 -1
- package/esm-es5/pn-proxio-pricegroup.entry.js +1 -1
- package/package.json +1 -1
- package/pn-market-web-components/{p-7e99f631.system.entry.js → p-18aca162.system.entry.js} +1 -1
- package/pn-market-web-components/{p-6e11edfe.entry.js → p-1b282c2b.entry.js} +1 -1
- package/pn-market-web-components/{p-3c38a67e.system.entry.js → p-256ba011.system.entry.js} +1 -1
- package/pn-market-web-components/{p-21bf0e64.system.entry.js → p-356a937e.system.entry.js} +1 -1
- package/pn-market-web-components/{p-1a8d7eb8.entry.js → p-372b4cad.entry.js} +1 -1
- package/{esm-es5/MarketWebContextService-f6a33f17.js → pn-market-web-components/p-439d5d73.system.js} +1 -1
- package/pn-market-web-components/p-4afba818.entry.js +1 -0
- package/pn-market-web-components/p-592b66fc.system.entry.js +1 -0
- package/pn-market-web-components/p-7a4a7a83.system.entry.js +1 -0
- package/pn-market-web-components/{p-5427a6ba.entry.js → p-90d2fb46.entry.js} +1 -1
- package/pn-market-web-components/p-9ad0ceb0.js +1 -0
- package/pn-market-web-components/p-b1527c0c.entry.js +1 -0
- package/pn-market-web-components/{p-0ae0b140.system.entry.js → p-c06e3588.system.entry.js} +1 -1
- package/pn-market-web-components/{p-9ae49b8a.entry.js → p-f8a13e03.entry.js} +1 -1
- package/pn-market-web-components/p-fcdb7381.system.js +1 -1
- package/pn-market-web-components/pn-market-web-components.esm.js +1 -1
- package/types/components/input/pn-address-autofill/pn-address-autofill.d.ts +56 -0
- package/types/components/input/pn-address-autofill/types.d.ts +40 -0
- package/types/components.d.ts +50 -1
- package/pn-market-web-components/p-1e5756b9.system.entry.js +0 -1
- package/pn-market-web-components/p-33322417.system.js +0 -1
- package/pn-market-web-components/p-5d21372b.js +0 -1
- package/pn-market-web-components/p-f0078106.entry.js +0 -1
- package/cjs/{MarketWebContextService-17053565.js → FetchHelper-2130dacf.js} +84 -84
- package/collection/components/{layout-components/pn-multi-formfield → input/pn-address-autofill}/types.js +0 -0
- package/collection/components/{layout-components → input}/pn-multi-formfield/multi-formfield.stories.js +0 -0
- package/collection/components/{layout-components → input}/pn-multi-formfield/pn-multi-formfield.css +0 -0
- package/collection/components/{layout-components → input}/pn-multi-formfield/pn-multi-formfield.js +0 -0
- package/components/{MarketWebContextService.js → FetchHelper.js} +84 -84
- package/esm/{MarketWebContextService-f6a33f17.js → FetchHelper-62dc55bf.js} +84 -84
- /package/types/components/{layout-components → input}/pn-multi-formfield/pn-multi-formfield.d.ts +0 -0
- /package/types/components/{layout-components → input}/pn-multi-formfield/types.d.ts +0 -0
|
@@ -1,89 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
class FetchHelper {
|
|
4
|
-
constructor(namespace = "") {
|
|
5
|
-
this.storagePrefix = "";
|
|
6
|
-
this.store = {
|
|
7
|
-
get: (key, permanentStorageFirst = false) => {
|
|
8
|
-
const firstProfider = permanentStorageFirst ? window.localStorage : window.sessionStorage;
|
|
9
|
-
const secondProvider = permanentStorageFirst ? window.sessionStorage : window.localStorage;
|
|
10
|
-
let value = firstProfider.getItem(`${this.storagePrefix}-${key}`);
|
|
11
|
-
if (!value) {
|
|
12
|
-
value = secondProvider.getItem(`${this.storagePrefix}-${key}`);
|
|
13
|
-
}
|
|
14
|
-
if (!value) {
|
|
15
|
-
return value;
|
|
16
|
-
}
|
|
17
|
-
if (value.indexOf('{') === 0) {
|
|
18
|
-
try {
|
|
19
|
-
return JSON.parse(value);
|
|
20
|
-
}
|
|
21
|
-
catch (e) {
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
if (value.indexOf(',') !== -1) {
|
|
25
|
-
return value.split(',');
|
|
26
|
-
}
|
|
27
|
-
return value;
|
|
28
|
-
},
|
|
29
|
-
set: (key, value, permanent = false) => {
|
|
30
|
-
const provider = permanent ? window.localStorage : window.sessionStorage;
|
|
31
|
-
if (typeof value === "object" && typeof value.length === "undefined") {
|
|
32
|
-
provider.setItem(`${this.storagePrefix}-${key}`, JSON.stringify(value));
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
provider.setItem(`${this.storagePrefix}-${key}`, value);
|
|
36
|
-
},
|
|
37
|
-
remove: (key) => {
|
|
38
|
-
window.sessionStorage.removeItem(`${this.storagePrefix}-${key}`);
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
this.storagePrefix = namespace;
|
|
42
|
-
}
|
|
43
|
-
async fetchJson(input, init = {}, useCache = false, onCacheUpdated = null) {
|
|
44
|
-
const requestPromise = new Promise(async (resolve) => {
|
|
45
|
-
let doFetchRequest = true;
|
|
46
|
-
const url = (typeof input === "string") ? input : input.url;
|
|
47
|
-
const cacheKey = url;
|
|
48
|
-
let jsonData = null;
|
|
49
|
-
let cachedData = null;
|
|
50
|
-
if (useCache) {
|
|
51
|
-
cachedData = this.store.get(cacheKey);
|
|
52
|
-
// If the data was stored in session storage, then we don't need to do a full request
|
|
53
|
-
if (cachedData && !cachedData.permanent) {
|
|
54
|
-
doFetchRequest = false;
|
|
55
|
-
}
|
|
56
|
-
if (cachedData && cachedData.data) {
|
|
57
|
-
jsonData = cachedData.data;
|
|
58
|
-
resolve(jsonData);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
if (doFetchRequest) {
|
|
62
|
-
const response = await window.fetch(input, init);
|
|
63
|
-
jsonData = await response.json();
|
|
64
|
-
resolve(jsonData);
|
|
65
|
-
if (useCache) {
|
|
66
|
-
if (typeof onCacheUpdated === "function" && cachedData != null) {
|
|
67
|
-
onCacheUpdated(jsonData);
|
|
68
|
-
}
|
|
69
|
-
this.store.set(cacheKey, this.wrapJson(jsonData, true), true);
|
|
70
|
-
this.store.set(cacheKey, this.wrapJson(jsonData, false), false);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
return requestPromise;
|
|
75
|
-
}
|
|
76
|
-
wrapJson(data, permanent = false) {
|
|
77
|
-
const now = new Date();
|
|
78
|
-
return {
|
|
79
|
-
timestamp: now.getTime(),
|
|
80
|
-
time: now.toISOString(),
|
|
81
|
-
data: data,
|
|
82
|
-
permanent: permanent
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
3
|
class MarketWebContextService {
|
|
88
4
|
constructor(href = window.location.href) {
|
|
89
5
|
this.href = '';
|
|
@@ -317,5 +233,89 @@ class MarketWebContextService {
|
|
|
317
233
|
}
|
|
318
234
|
}
|
|
319
235
|
|
|
236
|
+
class FetchHelper {
|
|
237
|
+
constructor(namespace = "") {
|
|
238
|
+
this.storagePrefix = "";
|
|
239
|
+
this.store = {
|
|
240
|
+
get: (key, permanentStorageFirst = false) => {
|
|
241
|
+
const firstProfider = permanentStorageFirst ? window.localStorage : window.sessionStorage;
|
|
242
|
+
const secondProvider = permanentStorageFirst ? window.sessionStorage : window.localStorage;
|
|
243
|
+
let value = firstProfider.getItem(`${this.storagePrefix}-${key}`);
|
|
244
|
+
if (!value) {
|
|
245
|
+
value = secondProvider.getItem(`${this.storagePrefix}-${key}`);
|
|
246
|
+
}
|
|
247
|
+
if (!value) {
|
|
248
|
+
return value;
|
|
249
|
+
}
|
|
250
|
+
if (value.indexOf('{') === 0) {
|
|
251
|
+
try {
|
|
252
|
+
return JSON.parse(value);
|
|
253
|
+
}
|
|
254
|
+
catch (e) {
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (value.indexOf(',') !== -1) {
|
|
258
|
+
return value.split(',');
|
|
259
|
+
}
|
|
260
|
+
return value;
|
|
261
|
+
},
|
|
262
|
+
set: (key, value, permanent = false) => {
|
|
263
|
+
const provider = permanent ? window.localStorage : window.sessionStorage;
|
|
264
|
+
if (typeof value === "object" && typeof value.length === "undefined") {
|
|
265
|
+
provider.setItem(`${this.storagePrefix}-${key}`, JSON.stringify(value));
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
provider.setItem(`${this.storagePrefix}-${key}`, value);
|
|
269
|
+
},
|
|
270
|
+
remove: (key) => {
|
|
271
|
+
window.sessionStorage.removeItem(`${this.storagePrefix}-${key}`);
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
this.storagePrefix = namespace;
|
|
275
|
+
}
|
|
276
|
+
async fetchJson(input, init = {}, useCache = false, onCacheUpdated = null) {
|
|
277
|
+
const requestPromise = new Promise(async (resolve) => {
|
|
278
|
+
let doFetchRequest = true;
|
|
279
|
+
const url = (typeof input === "string") ? input : input.url;
|
|
280
|
+
const cacheKey = url;
|
|
281
|
+
let jsonData = null;
|
|
282
|
+
let cachedData = null;
|
|
283
|
+
if (useCache) {
|
|
284
|
+
cachedData = this.store.get(cacheKey);
|
|
285
|
+
// If the data was stored in session storage, then we don't need to do a full request
|
|
286
|
+
if (cachedData && !cachedData.permanent) {
|
|
287
|
+
doFetchRequest = false;
|
|
288
|
+
}
|
|
289
|
+
if (cachedData && cachedData.data) {
|
|
290
|
+
jsonData = cachedData.data;
|
|
291
|
+
resolve(jsonData);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (doFetchRequest) {
|
|
295
|
+
const response = await window.fetch(input, init);
|
|
296
|
+
jsonData = await response.json();
|
|
297
|
+
resolve(jsonData);
|
|
298
|
+
if (useCache) {
|
|
299
|
+
if (typeof onCacheUpdated === "function" && cachedData != null) {
|
|
300
|
+
onCacheUpdated(jsonData);
|
|
301
|
+
}
|
|
302
|
+
this.store.set(cacheKey, this.wrapJson(jsonData, true), true);
|
|
303
|
+
this.store.set(cacheKey, this.wrapJson(jsonData, false), false);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
return requestPromise;
|
|
308
|
+
}
|
|
309
|
+
wrapJson(data, permanent = false) {
|
|
310
|
+
const now = new Date();
|
|
311
|
+
return {
|
|
312
|
+
timestamp: now.getTime(),
|
|
313
|
+
time: now.toISOString(),
|
|
314
|
+
data: data,
|
|
315
|
+
permanent: permanent
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
320
|
exports.FetchHelper = FetchHelper;
|
|
321
321
|
exports.MarketWebContextService = MarketWebContextService;
|
|
File without changes
|
|
File without changes
|
package/collection/components/{layout-components → input}/pn-multi-formfield/pn-multi-formfield.css
RENAMED
|
File without changes
|
package/collection/components/{layout-components → input}/pn-multi-formfield/pn-multi-formfield.js
RENAMED
|
File without changes
|
|
@@ -1,87 +1,3 @@
|
|
|
1
|
-
class FetchHelper {
|
|
2
|
-
constructor(namespace = "") {
|
|
3
|
-
this.storagePrefix = "";
|
|
4
|
-
this.store = {
|
|
5
|
-
get: (key, permanentStorageFirst = false) => {
|
|
6
|
-
const firstProfider = permanentStorageFirst ? window.localStorage : window.sessionStorage;
|
|
7
|
-
const secondProvider = permanentStorageFirst ? window.sessionStorage : window.localStorage;
|
|
8
|
-
let value = firstProfider.getItem(`${this.storagePrefix}-${key}`);
|
|
9
|
-
if (!value) {
|
|
10
|
-
value = secondProvider.getItem(`${this.storagePrefix}-${key}`);
|
|
11
|
-
}
|
|
12
|
-
if (!value) {
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
if (value.indexOf('{') === 0) {
|
|
16
|
-
try {
|
|
17
|
-
return JSON.parse(value);
|
|
18
|
-
}
|
|
19
|
-
catch (e) {
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
if (value.indexOf(',') !== -1) {
|
|
23
|
-
return value.split(',');
|
|
24
|
-
}
|
|
25
|
-
return value;
|
|
26
|
-
},
|
|
27
|
-
set: (key, value, permanent = false) => {
|
|
28
|
-
const provider = permanent ? window.localStorage : window.sessionStorage;
|
|
29
|
-
if (typeof value === "object" && typeof value.length === "undefined") {
|
|
30
|
-
provider.setItem(`${this.storagePrefix}-${key}`, JSON.stringify(value));
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
provider.setItem(`${this.storagePrefix}-${key}`, value);
|
|
34
|
-
},
|
|
35
|
-
remove: (key) => {
|
|
36
|
-
window.sessionStorage.removeItem(`${this.storagePrefix}-${key}`);
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
this.storagePrefix = namespace;
|
|
40
|
-
}
|
|
41
|
-
async fetchJson(input, init = {}, useCache = false, onCacheUpdated = null) {
|
|
42
|
-
const requestPromise = new Promise(async (resolve) => {
|
|
43
|
-
let doFetchRequest = true;
|
|
44
|
-
const url = (typeof input === "string") ? input : input.url;
|
|
45
|
-
const cacheKey = url;
|
|
46
|
-
let jsonData = null;
|
|
47
|
-
let cachedData = null;
|
|
48
|
-
if (useCache) {
|
|
49
|
-
cachedData = this.store.get(cacheKey);
|
|
50
|
-
// If the data was stored in session storage, then we don't need to do a full request
|
|
51
|
-
if (cachedData && !cachedData.permanent) {
|
|
52
|
-
doFetchRequest = false;
|
|
53
|
-
}
|
|
54
|
-
if (cachedData && cachedData.data) {
|
|
55
|
-
jsonData = cachedData.data;
|
|
56
|
-
resolve(jsonData);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (doFetchRequest) {
|
|
60
|
-
const response = await window.fetch(input, init);
|
|
61
|
-
jsonData = await response.json();
|
|
62
|
-
resolve(jsonData);
|
|
63
|
-
if (useCache) {
|
|
64
|
-
if (typeof onCacheUpdated === "function" && cachedData != null) {
|
|
65
|
-
onCacheUpdated(jsonData);
|
|
66
|
-
}
|
|
67
|
-
this.store.set(cacheKey, this.wrapJson(jsonData, true), true);
|
|
68
|
-
this.store.set(cacheKey, this.wrapJson(jsonData, false), false);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
return requestPromise;
|
|
73
|
-
}
|
|
74
|
-
wrapJson(data, permanent = false) {
|
|
75
|
-
const now = new Date();
|
|
76
|
-
return {
|
|
77
|
-
timestamp: now.getTime(),
|
|
78
|
-
time: now.toISOString(),
|
|
79
|
-
data: data,
|
|
80
|
-
permanent: permanent
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
1
|
class MarketWebContextService {
|
|
86
2
|
constructor(href = window.location.href) {
|
|
87
3
|
this.href = '';
|
|
@@ -315,4 +231,88 @@ class MarketWebContextService {
|
|
|
315
231
|
}
|
|
316
232
|
}
|
|
317
233
|
|
|
234
|
+
class FetchHelper {
|
|
235
|
+
constructor(namespace = "") {
|
|
236
|
+
this.storagePrefix = "";
|
|
237
|
+
this.store = {
|
|
238
|
+
get: (key, permanentStorageFirst = false) => {
|
|
239
|
+
const firstProfider = permanentStorageFirst ? window.localStorage : window.sessionStorage;
|
|
240
|
+
const secondProvider = permanentStorageFirst ? window.sessionStorage : window.localStorage;
|
|
241
|
+
let value = firstProfider.getItem(`${this.storagePrefix}-${key}`);
|
|
242
|
+
if (!value) {
|
|
243
|
+
value = secondProvider.getItem(`${this.storagePrefix}-${key}`);
|
|
244
|
+
}
|
|
245
|
+
if (!value) {
|
|
246
|
+
return value;
|
|
247
|
+
}
|
|
248
|
+
if (value.indexOf('{') === 0) {
|
|
249
|
+
try {
|
|
250
|
+
return JSON.parse(value);
|
|
251
|
+
}
|
|
252
|
+
catch (e) {
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (value.indexOf(',') !== -1) {
|
|
256
|
+
return value.split(',');
|
|
257
|
+
}
|
|
258
|
+
return value;
|
|
259
|
+
},
|
|
260
|
+
set: (key, value, permanent = false) => {
|
|
261
|
+
const provider = permanent ? window.localStorage : window.sessionStorage;
|
|
262
|
+
if (typeof value === "object" && typeof value.length === "undefined") {
|
|
263
|
+
provider.setItem(`${this.storagePrefix}-${key}`, JSON.stringify(value));
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
provider.setItem(`${this.storagePrefix}-${key}`, value);
|
|
267
|
+
},
|
|
268
|
+
remove: (key) => {
|
|
269
|
+
window.sessionStorage.removeItem(`${this.storagePrefix}-${key}`);
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
this.storagePrefix = namespace;
|
|
273
|
+
}
|
|
274
|
+
async fetchJson(input, init = {}, useCache = false, onCacheUpdated = null) {
|
|
275
|
+
const requestPromise = new Promise(async (resolve) => {
|
|
276
|
+
let doFetchRequest = true;
|
|
277
|
+
const url = (typeof input === "string") ? input : input.url;
|
|
278
|
+
const cacheKey = url;
|
|
279
|
+
let jsonData = null;
|
|
280
|
+
let cachedData = null;
|
|
281
|
+
if (useCache) {
|
|
282
|
+
cachedData = this.store.get(cacheKey);
|
|
283
|
+
// If the data was stored in session storage, then we don't need to do a full request
|
|
284
|
+
if (cachedData && !cachedData.permanent) {
|
|
285
|
+
doFetchRequest = false;
|
|
286
|
+
}
|
|
287
|
+
if (cachedData && cachedData.data) {
|
|
288
|
+
jsonData = cachedData.data;
|
|
289
|
+
resolve(jsonData);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
if (doFetchRequest) {
|
|
293
|
+
const response = await window.fetch(input, init);
|
|
294
|
+
jsonData = await response.json();
|
|
295
|
+
resolve(jsonData);
|
|
296
|
+
if (useCache) {
|
|
297
|
+
if (typeof onCacheUpdated === "function" && cachedData != null) {
|
|
298
|
+
onCacheUpdated(jsonData);
|
|
299
|
+
}
|
|
300
|
+
this.store.set(cacheKey, this.wrapJson(jsonData, true), true);
|
|
301
|
+
this.store.set(cacheKey, this.wrapJson(jsonData, false), false);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
return requestPromise;
|
|
306
|
+
}
|
|
307
|
+
wrapJson(data, permanent = false) {
|
|
308
|
+
const now = new Date();
|
|
309
|
+
return {
|
|
310
|
+
timestamp: now.getTime(),
|
|
311
|
+
time: now.toISOString(),
|
|
312
|
+
data: data,
|
|
313
|
+
permanent: permanent
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
318
|
export { FetchHelper as F, MarketWebContextService as M };
|
|
@@ -1,87 +1,3 @@
|
|
|
1
|
-
class FetchHelper {
|
|
2
|
-
constructor(namespace = "") {
|
|
3
|
-
this.storagePrefix = "";
|
|
4
|
-
this.store = {
|
|
5
|
-
get: (key, permanentStorageFirst = false) => {
|
|
6
|
-
const firstProfider = permanentStorageFirst ? window.localStorage : window.sessionStorage;
|
|
7
|
-
const secondProvider = permanentStorageFirst ? window.sessionStorage : window.localStorage;
|
|
8
|
-
let value = firstProfider.getItem(`${this.storagePrefix}-${key}`);
|
|
9
|
-
if (!value) {
|
|
10
|
-
value = secondProvider.getItem(`${this.storagePrefix}-${key}`);
|
|
11
|
-
}
|
|
12
|
-
if (!value) {
|
|
13
|
-
return value;
|
|
14
|
-
}
|
|
15
|
-
if (value.indexOf('{') === 0) {
|
|
16
|
-
try {
|
|
17
|
-
return JSON.parse(value);
|
|
18
|
-
}
|
|
19
|
-
catch (e) {
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
if (value.indexOf(',') !== -1) {
|
|
23
|
-
return value.split(',');
|
|
24
|
-
}
|
|
25
|
-
return value;
|
|
26
|
-
},
|
|
27
|
-
set: (key, value, permanent = false) => {
|
|
28
|
-
const provider = permanent ? window.localStorage : window.sessionStorage;
|
|
29
|
-
if (typeof value === "object" && typeof value.length === "undefined") {
|
|
30
|
-
provider.setItem(`${this.storagePrefix}-${key}`, JSON.stringify(value));
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
provider.setItem(`${this.storagePrefix}-${key}`, value);
|
|
34
|
-
},
|
|
35
|
-
remove: (key) => {
|
|
36
|
-
window.sessionStorage.removeItem(`${this.storagePrefix}-${key}`);
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
this.storagePrefix = namespace;
|
|
40
|
-
}
|
|
41
|
-
async fetchJson(input, init = {}, useCache = false, onCacheUpdated = null) {
|
|
42
|
-
const requestPromise = new Promise(async (resolve) => {
|
|
43
|
-
let doFetchRequest = true;
|
|
44
|
-
const url = (typeof input === "string") ? input : input.url;
|
|
45
|
-
const cacheKey = url;
|
|
46
|
-
let jsonData = null;
|
|
47
|
-
let cachedData = null;
|
|
48
|
-
if (useCache) {
|
|
49
|
-
cachedData = this.store.get(cacheKey);
|
|
50
|
-
// If the data was stored in session storage, then we don't need to do a full request
|
|
51
|
-
if (cachedData && !cachedData.permanent) {
|
|
52
|
-
doFetchRequest = false;
|
|
53
|
-
}
|
|
54
|
-
if (cachedData && cachedData.data) {
|
|
55
|
-
jsonData = cachedData.data;
|
|
56
|
-
resolve(jsonData);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (doFetchRequest) {
|
|
60
|
-
const response = await window.fetch(input, init);
|
|
61
|
-
jsonData = await response.json();
|
|
62
|
-
resolve(jsonData);
|
|
63
|
-
if (useCache) {
|
|
64
|
-
if (typeof onCacheUpdated === "function" && cachedData != null) {
|
|
65
|
-
onCacheUpdated(jsonData);
|
|
66
|
-
}
|
|
67
|
-
this.store.set(cacheKey, this.wrapJson(jsonData, true), true);
|
|
68
|
-
this.store.set(cacheKey, this.wrapJson(jsonData, false), false);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
return requestPromise;
|
|
73
|
-
}
|
|
74
|
-
wrapJson(data, permanent = false) {
|
|
75
|
-
const now = new Date();
|
|
76
|
-
return {
|
|
77
|
-
timestamp: now.getTime(),
|
|
78
|
-
time: now.toISOString(),
|
|
79
|
-
data: data,
|
|
80
|
-
permanent: permanent
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
1
|
class MarketWebContextService {
|
|
86
2
|
constructor(href = window.location.href) {
|
|
87
3
|
this.href = '';
|
|
@@ -315,4 +231,88 @@ class MarketWebContextService {
|
|
|
315
231
|
}
|
|
316
232
|
}
|
|
317
233
|
|
|
234
|
+
class FetchHelper {
|
|
235
|
+
constructor(namespace = "") {
|
|
236
|
+
this.storagePrefix = "";
|
|
237
|
+
this.store = {
|
|
238
|
+
get: (key, permanentStorageFirst = false) => {
|
|
239
|
+
const firstProfider = permanentStorageFirst ? window.localStorage : window.sessionStorage;
|
|
240
|
+
const secondProvider = permanentStorageFirst ? window.sessionStorage : window.localStorage;
|
|
241
|
+
let value = firstProfider.getItem(`${this.storagePrefix}-${key}`);
|
|
242
|
+
if (!value) {
|
|
243
|
+
value = secondProvider.getItem(`${this.storagePrefix}-${key}`);
|
|
244
|
+
}
|
|
245
|
+
if (!value) {
|
|
246
|
+
return value;
|
|
247
|
+
}
|
|
248
|
+
if (value.indexOf('{') === 0) {
|
|
249
|
+
try {
|
|
250
|
+
return JSON.parse(value);
|
|
251
|
+
}
|
|
252
|
+
catch (e) {
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (value.indexOf(',') !== -1) {
|
|
256
|
+
return value.split(',');
|
|
257
|
+
}
|
|
258
|
+
return value;
|
|
259
|
+
},
|
|
260
|
+
set: (key, value, permanent = false) => {
|
|
261
|
+
const provider = permanent ? window.localStorage : window.sessionStorage;
|
|
262
|
+
if (typeof value === "object" && typeof value.length === "undefined") {
|
|
263
|
+
provider.setItem(`${this.storagePrefix}-${key}`, JSON.stringify(value));
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
provider.setItem(`${this.storagePrefix}-${key}`, value);
|
|
267
|
+
},
|
|
268
|
+
remove: (key) => {
|
|
269
|
+
window.sessionStorage.removeItem(`${this.storagePrefix}-${key}`);
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
this.storagePrefix = namespace;
|
|
273
|
+
}
|
|
274
|
+
async fetchJson(input, init = {}, useCache = false, onCacheUpdated = null) {
|
|
275
|
+
const requestPromise = new Promise(async (resolve) => {
|
|
276
|
+
let doFetchRequest = true;
|
|
277
|
+
const url = (typeof input === "string") ? input : input.url;
|
|
278
|
+
const cacheKey = url;
|
|
279
|
+
let jsonData = null;
|
|
280
|
+
let cachedData = null;
|
|
281
|
+
if (useCache) {
|
|
282
|
+
cachedData = this.store.get(cacheKey);
|
|
283
|
+
// If the data was stored in session storage, then we don't need to do a full request
|
|
284
|
+
if (cachedData && !cachedData.permanent) {
|
|
285
|
+
doFetchRequest = false;
|
|
286
|
+
}
|
|
287
|
+
if (cachedData && cachedData.data) {
|
|
288
|
+
jsonData = cachedData.data;
|
|
289
|
+
resolve(jsonData);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
if (doFetchRequest) {
|
|
293
|
+
const response = await window.fetch(input, init);
|
|
294
|
+
jsonData = await response.json();
|
|
295
|
+
resolve(jsonData);
|
|
296
|
+
if (useCache) {
|
|
297
|
+
if (typeof onCacheUpdated === "function" && cachedData != null) {
|
|
298
|
+
onCacheUpdated(jsonData);
|
|
299
|
+
}
|
|
300
|
+
this.store.set(cacheKey, this.wrapJson(jsonData, true), true);
|
|
301
|
+
this.store.set(cacheKey, this.wrapJson(jsonData, false), false);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
return requestPromise;
|
|
306
|
+
}
|
|
307
|
+
wrapJson(data, permanent = false) {
|
|
308
|
+
const now = new Date();
|
|
309
|
+
return {
|
|
310
|
+
timestamp: now.getTime(),
|
|
311
|
+
time: now.toISOString(),
|
|
312
|
+
data: data,
|
|
313
|
+
permanent: permanent
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
318
|
export { FetchHelper as F, MarketWebContextService as M };
|
/package/types/components/{layout-components → input}/pn-multi-formfield/pn-multi-formfield.d.ts
RENAMED
|
File without changes
|
|
File without changes
|