@postnord/pn-marketweb-components 2.4.21 → 2.4.22

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 (81) hide show
  1. package/cjs/index-4199ff85.js +8 -4
  2. package/cjs/loader.cjs.js +1 -1
  3. package/cjs/pn-address-autofill.cjs.entry.js +322 -0
  4. package/cjs/pn-market-web-components.cjs.js +1 -1
  5. package/cjs/pn-marketweb-input.cjs.entry.js +36 -25
  6. package/cjs/pn-marketweb-sitefooter.cjs.entry.js +3 -3
  7. package/cjs/pn-marketweb-siteheader.cjs.entry.js +3 -3
  8. package/cjs/pn-proxio-findprice.cjs.entry.js +3 -3
  9. package/cjs/pn-proxio-pricegroup.cjs.entry.js +3 -3
  10. package/collection/collection-manifest.json +2 -1
  11. package/collection/components/input/pn-address-autofill/pn-address-autofill.css +45 -0
  12. package/collection/components/input/pn-address-autofill/pn-address-autofill.js +537 -0
  13. package/collection/components/input/pn-address-autofill/pn-address-autofill.stories.js +40 -0
  14. package/collection/components/input/pn-marketweb-input/pn-marketweb-input.js +50 -39
  15. package/collection/components/input/pn-multi-formfield/types.js +1 -0
  16. package/components/index.d.ts +2 -1
  17. package/components/index.js +1 -0
  18. package/components/index2.js +63 -52
  19. package/components/index3.js +52 -63
  20. package/components/pn-address-autofill.d.ts +11 -0
  21. package/components/pn-address-autofill.js +359 -0
  22. package/components/pn-animated-tile.js +1 -1
  23. package/components/pn-dropdown-choice-adds-row.js +1 -1
  24. package/components/pn-marketweb-input2.js +36 -25
  25. package/components/pn-marketweb-sitefooter.js +1 -1
  26. package/components/pn-marketweb-siteheader.js +1 -1
  27. package/components/pn-multi-formfield.js +1 -1
  28. package/components/pn-proxio-findprice.js +1 -1
  29. package/components/pn-proxio-pricegroup.js +1 -1
  30. package/components/pn-spotlight.js +1 -1
  31. package/esm/index-ee44c065.js +8 -4
  32. package/esm/loader.js +1 -1
  33. package/esm/pn-address-autofill.entry.js +318 -0
  34. package/esm/pn-market-web-components.js +1 -1
  35. package/esm/pn-marketweb-input.entry.js +36 -25
  36. package/esm/pn-marketweb-sitefooter.entry.js +1 -1
  37. package/esm/pn-marketweb-siteheader.entry.js +1 -1
  38. package/esm/pn-proxio-findprice.entry.js +1 -1
  39. package/esm/pn-proxio-pricegroup.entry.js +1 -1
  40. package/esm-es5/FetchHelper-62dc55bf.js +1 -0
  41. package/esm-es5/index-ee44c065.js +1 -1
  42. package/esm-es5/loader.js +1 -1
  43. package/esm-es5/pn-address-autofill.entry.js +1 -0
  44. package/esm-es5/pn-market-web-components.js +1 -1
  45. package/esm-es5/pn-marketweb-input.entry.js +1 -1
  46. package/esm-es5/pn-marketweb-sitefooter.entry.js +1 -1
  47. package/esm-es5/pn-marketweb-siteheader.entry.js +1 -1
  48. package/esm-es5/pn-proxio-findprice.entry.js +1 -1
  49. package/esm-es5/pn-proxio-pricegroup.entry.js +1 -1
  50. package/package.json +1 -1
  51. package/pn-market-web-components/{p-7e99f631.system.entry.js → p-18aca162.system.entry.js} +1 -1
  52. package/pn-market-web-components/{p-6e11edfe.entry.js → p-1b282c2b.entry.js} +1 -1
  53. package/pn-market-web-components/{p-3c38a67e.system.entry.js → p-256ba011.system.entry.js} +1 -1
  54. package/pn-market-web-components/{p-21bf0e64.system.entry.js → p-356a937e.system.entry.js} +1 -1
  55. package/pn-market-web-components/{p-1a8d7eb8.entry.js → p-372b4cad.entry.js} +1 -1
  56. package/{esm-es5/MarketWebContextService-f6a33f17.js → pn-market-web-components/p-439d5d73.system.js} +1 -1
  57. package/pn-market-web-components/p-4afba818.entry.js +1 -0
  58. package/pn-market-web-components/p-592b66fc.system.entry.js +1 -0
  59. package/pn-market-web-components/{p-1e5756b9.system.entry.js → p-89fcb948.system.entry.js} +1 -1
  60. package/pn-market-web-components/{p-5427a6ba.entry.js → p-90d2fb46.entry.js} +1 -1
  61. package/pn-market-web-components/p-9ad0ceb0.js +1 -0
  62. package/pn-market-web-components/p-b1527c0c.entry.js +1 -0
  63. package/pn-market-web-components/{p-0ae0b140.system.entry.js → p-c06e3588.system.entry.js} +1 -1
  64. package/pn-market-web-components/{p-9ae49b8a.entry.js → p-da9e05c0.entry.js} +1 -1
  65. package/pn-market-web-components/p-fcdb7381.system.js +1 -1
  66. package/pn-market-web-components/pn-market-web-components.esm.js +1 -1
  67. package/types/components/input/pn-address-autofill/pn-address-autofill.d.ts +56 -0
  68. package/types/components/input/pn-address-autofill/types.d.ts +40 -0
  69. package/types/components.d.ts +50 -1
  70. package/pn-market-web-components/p-33322417.system.js +0 -1
  71. package/pn-market-web-components/p-5d21372b.js +0 -1
  72. package/pn-market-web-components/p-f0078106.entry.js +0 -1
  73. package/cjs/{MarketWebContextService-17053565.js → FetchHelper-2130dacf.js} +84 -84
  74. package/collection/components/{layout-components/pn-multi-formfield → input/pn-address-autofill}/types.js +0 -0
  75. package/collection/components/{layout-components → input}/pn-multi-formfield/multi-formfield.stories.js +0 -0
  76. package/collection/components/{layout-components → input}/pn-multi-formfield/pn-multi-formfield.css +0 -0
  77. package/collection/components/{layout-components → input}/pn-multi-formfield/pn-multi-formfield.js +0 -0
  78. package/components/{MarketWebContextService.js → FetchHelper.js} +84 -84
  79. package/esm/{MarketWebContextService-f6a33f17.js → FetchHelper-62dc55bf.js} +84 -84
  80. /package/types/components/{layout-components → input}/pn-multi-formfield/pn-multi-formfield.d.ts +0 -0
  81. /package/types/components/{layout-components → input}/pn-multi-formfield/types.d.ts +0 -0
@@ -0,0 +1,537 @@
1
+ import { h, Host } from '@stencil/core';
2
+ import { MarketWebContextService } from '../../../globals/MarketWebContextService';
3
+ import { FetchHelper } from '../../../globals/FetchHelper';
4
+ import { debounce } from 'debounce';
5
+ export class PnAddressAutofill {
6
+ constructor() {
7
+ this.pnInputPostalCode = null;
8
+ this.pnInputCity = null;
9
+ this.pnInputStreetAddress = null;
10
+ this.pnInputStreetNumber = null;
11
+ this.postalCodeInputField = null;
12
+ this.streetAddressInputField = null;
13
+ this.streetNumberInputField = null;
14
+ this.pnInputHiddenValue = null;
15
+ this.endpointPath = '/api/location/get-by-location';
16
+ this._postalCodeProps = null;
17
+ this._cityProps = null;
18
+ this._streetAddressProps = null;
19
+ this._streetNumberProps = null;
20
+ this.fetchHelper = new FetchHelper('PostalCodeCityAutofill');
21
+ this.filterStreetNames = (data) => {
22
+ const addresses = [];
23
+ this.streetAdressArr = null;
24
+ data.addresses.forEach(item => {
25
+ if (item.postalCode.postalCity === this.city && !addresses.includes(item.street)) {
26
+ addresses.push(item.street);
27
+ }
28
+ });
29
+ this.streetAdressArr = addresses;
30
+ };
31
+ this.filterStreetNumbers = (data) => {
32
+ const streetNumbersResult = [];
33
+ data.addresses.forEach(item => {
34
+ if (item.postalCode.postalCode === this.postalCode) {
35
+ const { numberFrom, numberTo } = item;
36
+ const from = parseInt(numberFrom);
37
+ const to = parseInt(numberTo);
38
+ for (let i = from; i <= to; i++) {
39
+ const nrString = i.toString();
40
+ if (!streetNumbersResult.includes(nrString)) {
41
+ streetNumbersResult.push(i.toString());
42
+ }
43
+ }
44
+ }
45
+ });
46
+ this.streetNumberArr = streetNumbersResult;
47
+ };
48
+ this.market = null;
49
+ this.environment = null;
50
+ this.endpoint = null;
51
+ this.cache = true;
52
+ this.countryCode = null;
53
+ this.postalCodeProps = null;
54
+ this.cityProps = null;
55
+ this.streetAddressProps = null;
56
+ this.streetNumberProps = null;
57
+ this.streetAdressArr = null;
58
+ this.streetNumberArr = null;
59
+ this.city = null;
60
+ this.postalCode = null;
61
+ this.streetAddress = null;
62
+ this.streetNumber = null;
63
+ this.fullAddress = null;
64
+ }
65
+ componentWillLoad() {
66
+ this.setInitialValues();
67
+ this._postalCodeProps = this.setProps(this.postalCodeProps);
68
+ this._cityProps = this.setProps(this.cityProps);
69
+ this._streetAddressProps = this.setProps(this.streetAddressProps);
70
+ this._streetNumberProps = this.setProps(this.streetNumberProps);
71
+ }
72
+ setProps(props) {
73
+ if (typeof props === 'string') {
74
+ return JSON.parse(props);
75
+ }
76
+ else {
77
+ return props;
78
+ }
79
+ }
80
+ componentDidLoad() {
81
+ this.postalCodeInputField = this.pnInputPostalCode.querySelector('input');
82
+ this.streetAddressInputField = this.pnInputStreetAddress.querySelector('input');
83
+ this.streetNumberInputField = this.pnInputStreetNumber.querySelector('input');
84
+ this.addEventHandlers();
85
+ }
86
+ async setInitialValues(href = window.location.href) {
87
+ var _a;
88
+ const marketWebContextService = new MarketWebContextService(href);
89
+ if (!this.environment) {
90
+ this.environment = await marketWebContextService.getEnvironmentName();
91
+ }
92
+ if (!this.endpoint && ((_a = this.environment) === null || _a === void 0 ? void 0 : _a.indexOf('local')) === -1) {
93
+ this.endpoint = await marketWebContextService.getEndpoint(this.environment, this.market);
94
+ }
95
+ if (!this.endpoint) {
96
+ this.endpoint = '';
97
+ }
98
+ }
99
+ addEventHandlers() {
100
+ const postalCodeSearch = debounce(this.fetchData.bind(this, this.postalCodeInputField), 1000);
101
+ this.postalCodeInputField.addEventListener('keyup', postalCodeSearch);
102
+ this.streetAddressInputField.addEventListener('keyup', this.handleStreetAddressDropdown.bind(this));
103
+ this.streetNumberInputField.addEventListener('focus', this.handleStreetNumberDropdown.bind(this));
104
+ this.addFormFieldEvent();
105
+ }
106
+ addFormFieldEvent() {
107
+ const allInputs = this.hostElement.querySelectorAll('input');
108
+ allInputs.forEach(element => {
109
+ ['keyup', 'change'].forEach(eventName => {
110
+ const debounceUpdate = debounce(this.updateHiddenValue.bind(this), 1000);
111
+ element.addEventListener(eventName, debounceUpdate);
112
+ });
113
+ });
114
+ }
115
+ updateHiddenValue(e) {
116
+ if (e.target === this.streetNumberInputField) {
117
+ this.streetNumber = this.streetNumberInputField.value;
118
+ }
119
+ if (this.postalCode && this.city && this.streetAddress && this.streetNumber) {
120
+ this.fullAddress = `${this.streetAddress} ${this.streetNumber}, ${this.city} ${this.postalCode}`;
121
+ }
122
+ else {
123
+ this.fullAddress = '';
124
+ }
125
+ this.addresscomplete.emit(this.fullAddress);
126
+ }
127
+ async fetchData(field, e) {
128
+ var _a;
129
+ if (e) {
130
+ e.preventDefault();
131
+ if (e.key === 'Tab') {
132
+ if (this.city) {
133
+ return;
134
+ }
135
+ }
136
+ }
137
+ let query = '';
138
+ const isPostalCodeSearch = e && e.target === this.postalCodeInputField;
139
+ const isStreetAddressSearch = field === this.streetAddressInputField && this.city && this.city.length;
140
+ const isStreetNumberSearch = field === this.streetNumberInputField && this.city && this.city.length && this.streetAddress && this.streetAddress.length;
141
+ if (isPostalCodeSearch) {
142
+ query = this.postalCodeInputField.value;
143
+ this.streetAdressArr = null;
144
+ this.streetAddressInputField.value = '';
145
+ this.streetNumberArr = null;
146
+ this.streetNumberInputField.value = '';
147
+ this.city = null;
148
+ this.streetAddress = null;
149
+ this.streetNumber = null;
150
+ }
151
+ if (isStreetAddressSearch) {
152
+ query = `${this.streetAddressInputField.value}, ${this.city}`;
153
+ this.streetNumberArr = null;
154
+ this.streetNumberInputField.value = '';
155
+ this.streetNumber = null;
156
+ }
157
+ if (isStreetNumberSearch) {
158
+ this.streetAdressArr = null;
159
+ query = `${this.streetAddress}, ${this.city}`;
160
+ }
161
+ if (query.length > 0) {
162
+ const endpointBase = this.endpoint.lastIndexOf('/') === this.endpoint.length - 1 ? this.endpoint.substring(0, this.endpoint.length - 1) : this.endpoint;
163
+ const fetchUrl = `${endpointBase}${this.endpointPath}?countryCode=${this.countryCode}&query=${query}`;
164
+ const data = (await this.fetchHelper.fetchJson(fetchUrl, {
165
+ mode: 'cors',
166
+ }, this.cache));
167
+ if (data) {
168
+ if (isPostalCodeSearch) {
169
+ this.city = data.postalCodes ? (_a = data.postalCodes[0]) === null || _a === void 0 ? void 0 : _a.postalCity : null;
170
+ }
171
+ if (isStreetAddressSearch && data.addresses) {
172
+ this.postalCode = this.postalCodeInputField.value;
173
+ this.filterStreetNames(data);
174
+ }
175
+ if (isStreetNumberSearch && data.addresses) {
176
+ this.filterStreetNumbers(data);
177
+ }
178
+ }
179
+ }
180
+ }
181
+ async handleStreetAddressDropdown(e) {
182
+ const target = e.target;
183
+ if (target === this.streetAddressInputField && target.value.length) {
184
+ if (!this.streetAdressArr || !this.streetAdressArr.length) {
185
+ await this.fetchData(this.streetAddressInputField, null);
186
+ }
187
+ }
188
+ if (!target.value || !target.value.length) {
189
+ this.streetAdressArr = null;
190
+ }
191
+ if (this.streetAdressArr && this.streetAdressArr.length) {
192
+ this.autoComplete(e, this.streetAdressArr);
193
+ }
194
+ }
195
+ async handleStreetNumberDropdown(e) {
196
+ e.preventDefault();
197
+ const target = e.target;
198
+ if (target === this.streetNumberInputField) {
199
+ if (!this.streetNumberArr || !this.streetNumberArr.length) {
200
+ await this.fetchData(this.streetNumberInputField, null);
201
+ }
202
+ if (this.streetNumberArr) {
203
+ this.autoComplete(e, this.streetNumberArr);
204
+ }
205
+ }
206
+ }
207
+ autoComplete(e, arr) {
208
+ const inputField = e.target;
209
+ if (arr.length < 1) {
210
+ return;
211
+ }
212
+ let currentFocus = 0;
213
+ inputField.addEventListener('input', () => {
214
+ const val = inputField.value;
215
+ this.closeAllLists(inputField);
216
+ if (!val) {
217
+ return;
218
+ }
219
+ currentFocus = -1;
220
+ let list = document.createElement('div');
221
+ list.setAttribute('id', 'autocomplete-list' + inputField.name);
222
+ list.setAttribute('class', 'autocomplete-items');
223
+ inputField.parentElement.appendChild(list);
224
+ for (let i = 0; i < arr.length; i++) {
225
+ if (arr[i].substring(0, val.length).toUpperCase() == val.toUpperCase()) {
226
+ let option = document.createElement('div');
227
+ option.innerHTML = '<strong>' + arr[i].substring(0, val.length) + '</strong>';
228
+ option.innerHTML += arr[i].substring(val.length);
229
+ option.innerHTML += "<input type='hidden' value='" + arr[i] + "'>";
230
+ option.addEventListener('click', clickEvent => {
231
+ const inputParrent = inputField.closest('pn-marketweb-input');
232
+ let eventTarget = clickEvent.target;
233
+ if (eventTarget.nodeName === 'STRONG') {
234
+ eventTarget = eventTarget.parentElement;
235
+ }
236
+ inputParrent.value = eventTarget.getElementsByTagName('input')[0].value;
237
+ if (inputField === this.streetNumberInputField) {
238
+ this.streetNumber = inputParrent.value;
239
+ }
240
+ if (inputField === this.streetAddressInputField) {
241
+ this.streetAddress = inputParrent.value;
242
+ }
243
+ this.closeAllLists(clickEvent.target);
244
+ inputField.focus();
245
+ });
246
+ list.appendChild(option);
247
+ }
248
+ }
249
+ });
250
+ inputField.addEventListener('keydown', keydownEvent => {
251
+ const listElement = document.getElementById('autocomplete-list' + inputField.name);
252
+ let element;
253
+ if (listElement) {
254
+ element = listElement.getElementsByTagName('div');
255
+ }
256
+ else {
257
+ element = listElement;
258
+ }
259
+ //If arrow DOWN key is pressed
260
+ if (keydownEvent.keyCode == 40) {
261
+ currentFocus++;
262
+ this.addActive(element, currentFocus);
263
+ }
264
+ //If the arrow UP key is pressed
265
+ if (keydownEvent.keyCode == 38) {
266
+ currentFocus--;
267
+ this.addActive(element, currentFocus);
268
+ }
269
+ //If the ENTER key is pressed
270
+ if (keydownEvent.keyCode == 13) {
271
+ keydownEvent.preventDefault();
272
+ if (currentFocus > -1) {
273
+ if (element) {
274
+ element[currentFocus].click();
275
+ }
276
+ }
277
+ }
278
+ });
279
+ }
280
+ //close all autocomplete lists in the document, except the one passed as an argument:
281
+ closeAllLists(elmnt) {
282
+ const lists = document.getElementsByClassName('autocomplete-items');
283
+ for (let i = 0; i < lists.length; i++) {
284
+ if (elmnt != lists[i]) {
285
+ lists[i].parentNode.removeChild(lists[i]);
286
+ }
287
+ }
288
+ }
289
+ //a function to classify an item as "active":
290
+ addActive(elmnt, currentFocus) {
291
+ if (!elmnt)
292
+ return;
293
+ this.removeActive(elmnt);
294
+ if (currentFocus >= elmnt.length)
295
+ currentFocus = 0;
296
+ if (currentFocus < 0)
297
+ currentFocus = elmnt.length - 1;
298
+ elmnt[currentFocus].classList.add('autocomplete-active');
299
+ }
300
+ //a function to remove the "active" class from all autocomplete items:
301
+ removeActive(elmnt) {
302
+ for (let i = 0; i < elmnt.length; i++) {
303
+ elmnt[i].classList.remove('autocomplete-active');
304
+ }
305
+ }
306
+ render() {
307
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
308
+ return (h(Host, { class: "pn-address-autofill" }, ((_a = this._postalCodeProps) === null || _a === void 0 ? void 0 : _a.postalCodeCityLabel) ? (h("div", { class: "label-container" }, h("label", null, `${this._postalCodeProps.postalCodeCityLabel}`))) : null, h("div", { class: "input-container-row" }, h("pn-marketweb-input", { type: "text", name: (_b = this._postalCodeProps) === null || _b === void 0 ? void 0 : _b.postalCodeInputName, required: (_c = this._postalCodeProps) === null || _c === void 0 ? void 0 : _c.postalCodeInputRequired, placeholder: (_d = this._postalCodeProps) === null || _d === void 0 ? void 0 : _d.postalCodeInputPlaceholder, ref: el => (this.pnInputPostalCode = el), autocomplete: "off", helpertext: (_e = this._postalCodeProps) === null || _e === void 0 ? void 0 : _e.postalCodeInputHelpertext }), h("pn-marketweb-input", { type: "text", name: (_f = this._cityProps) === null || _f === void 0 ? void 0 : _f.cityInputName, disabled: true, value: this.city, placeholder: (_g = this._cityProps) === null || _g === void 0 ? void 0 : _g.cityInputPlaceholder, autocomplete: "off", helpertext: (_h = this._cityProps) === null || _h === void 0 ? void 0 : _h.cityInputHelpertext })), ((_j = this._streetAddressProps) === null || _j === void 0 ? void 0 : _j.streetAddressNumberLabel) ? (h("div", { class: "label-container" }, h("label", null, `${this._streetAddressProps.streetAddressNumberLabel}`))) : null, h("div", { class: "input-container-row" }, h("pn-marketweb-input", { type: "text", name: (_k = this._streetAddressProps) === null || _k === void 0 ? void 0 : _k.streetAddressInputName, required: (_l = this._streetAddressProps) === null || _l === void 0 ? void 0 : _l.streetAddressInputRequired, value: this.streetAddress, placeholder: (_m = this._streetAddressProps) === null || _m === void 0 ? void 0 : _m.streetAddressInputPlaceholder, ref: el => (this.pnInputStreetAddress = el), autocomplete: "off", helpertext: (_o = this._streetAddressProps) === null || _o === void 0 ? void 0 : _o.streetAddressInputHelpertext }), h("pn-marketweb-input", { type: "text", name: (_p = this._streetNumberProps) === null || _p === void 0 ? void 0 : _p.streetNumberInputName, required: (_q = this._streetNumberProps) === null || _q === void 0 ? void 0 : _q.streetNumberInputRequired, value: this.streetNumber, placeholder: (_r = this._streetNumberProps) === null || _r === void 0 ? void 0 : _r.streetNumberInputPlaceholder, ref: el => (this.pnInputStreetNumber = el), autocomplete: "off", helpertext: (_s = this._streetNumberProps) === null || _s === void 0 ? void 0 : _s.streetNumberInputHelpertext }))));
309
+ }
310
+ static get is() { return "pn-address-autofill"; }
311
+ static get originalStyleUrls() {
312
+ return {
313
+ "$": ["pn-address-autofill.scss"]
314
+ };
315
+ }
316
+ static get styleUrls() {
317
+ return {
318
+ "$": ["pn-address-autofill.css"]
319
+ };
320
+ }
321
+ static get properties() {
322
+ return {
323
+ "market": {
324
+ "type": "string",
325
+ "mutable": true,
326
+ "complexType": {
327
+ "original": "string",
328
+ "resolved": "string",
329
+ "references": {}
330
+ },
331
+ "required": false,
332
+ "optional": false,
333
+ "docs": {
334
+ "tags": [],
335
+ "text": "Specifies which market we want to show (se,dk,fi,no,com)"
336
+ },
337
+ "attribute": "market",
338
+ "reflect": true,
339
+ "defaultValue": "null"
340
+ },
341
+ "environment": {
342
+ "type": "string",
343
+ "mutable": true,
344
+ "complexType": {
345
+ "original": "string",
346
+ "resolved": "string",
347
+ "references": {}
348
+ },
349
+ "required": false,
350
+ "optional": false,
351
+ "docs": {
352
+ "tags": [],
353
+ "text": "Specifies which environment we're fetching data from. (production, preproduction, integration, localhost)"
354
+ },
355
+ "attribute": "environment",
356
+ "reflect": true,
357
+ "defaultValue": "null"
358
+ },
359
+ "endpoint": {
360
+ "type": "string",
361
+ "mutable": false,
362
+ "complexType": {
363
+ "original": "string",
364
+ "resolved": "string",
365
+ "references": {}
366
+ },
367
+ "required": false,
368
+ "optional": false,
369
+ "docs": {
370
+ "tags": [],
371
+ "text": ""
372
+ },
373
+ "attribute": "endpoint",
374
+ "reflect": false,
375
+ "defaultValue": "null"
376
+ },
377
+ "cache": {
378
+ "type": "boolean",
379
+ "mutable": false,
380
+ "complexType": {
381
+ "original": "boolean",
382
+ "resolved": "boolean",
383
+ "references": {}
384
+ },
385
+ "required": false,
386
+ "optional": false,
387
+ "docs": {
388
+ "tags": [],
389
+ "text": ""
390
+ },
391
+ "attribute": "cache",
392
+ "reflect": false,
393
+ "defaultValue": "true"
394
+ },
395
+ "countryCode": {
396
+ "type": "string",
397
+ "mutable": false,
398
+ "complexType": {
399
+ "original": "string",
400
+ "resolved": "string",
401
+ "references": {}
402
+ },
403
+ "required": false,
404
+ "optional": false,
405
+ "docs": {
406
+ "tags": [],
407
+ "text": ""
408
+ },
409
+ "attribute": "country-code",
410
+ "reflect": false,
411
+ "defaultValue": "null"
412
+ },
413
+ "postalCodeProps": {
414
+ "type": "string",
415
+ "mutable": false,
416
+ "complexType": {
417
+ "original": "string | PostalCodeProps",
418
+ "resolved": "PostalCodeProps | string",
419
+ "references": {
420
+ "PostalCodeProps": {
421
+ "location": "import",
422
+ "path": "./types"
423
+ }
424
+ }
425
+ },
426
+ "required": false,
427
+ "optional": false,
428
+ "docs": {
429
+ "tags": [],
430
+ "text": ""
431
+ },
432
+ "attribute": "postal-code-props",
433
+ "reflect": false,
434
+ "defaultValue": "null"
435
+ },
436
+ "cityProps": {
437
+ "type": "string",
438
+ "mutable": false,
439
+ "complexType": {
440
+ "original": "string | CityProps",
441
+ "resolved": "CityProps | string",
442
+ "references": {
443
+ "CityProps": {
444
+ "location": "import",
445
+ "path": "./types"
446
+ }
447
+ }
448
+ },
449
+ "required": false,
450
+ "optional": false,
451
+ "docs": {
452
+ "tags": [],
453
+ "text": ""
454
+ },
455
+ "attribute": "city-props",
456
+ "reflect": false,
457
+ "defaultValue": "null"
458
+ },
459
+ "streetAddressProps": {
460
+ "type": "string",
461
+ "mutable": false,
462
+ "complexType": {
463
+ "original": "string | StreetAddressProps",
464
+ "resolved": "StreetAddressProps | string",
465
+ "references": {
466
+ "StreetAddressProps": {
467
+ "location": "import",
468
+ "path": "./types"
469
+ }
470
+ }
471
+ },
472
+ "required": false,
473
+ "optional": false,
474
+ "docs": {
475
+ "tags": [],
476
+ "text": ""
477
+ },
478
+ "attribute": "street-address-props",
479
+ "reflect": false,
480
+ "defaultValue": "null"
481
+ },
482
+ "streetNumberProps": {
483
+ "type": "string",
484
+ "mutable": false,
485
+ "complexType": {
486
+ "original": "string | StreetNumberProps",
487
+ "resolved": "StreetNumberProps | string",
488
+ "references": {
489
+ "StreetNumberProps": {
490
+ "location": "import",
491
+ "path": "./types"
492
+ }
493
+ }
494
+ },
495
+ "required": false,
496
+ "optional": false,
497
+ "docs": {
498
+ "tags": [],
499
+ "text": ""
500
+ },
501
+ "attribute": "street-number-props",
502
+ "reflect": false,
503
+ "defaultValue": "null"
504
+ }
505
+ };
506
+ }
507
+ static get states() {
508
+ return {
509
+ "streetAdressArr": {},
510
+ "streetNumberArr": {},
511
+ "city": {},
512
+ "postalCode": {},
513
+ "streetAddress": {},
514
+ "streetNumber": {},
515
+ "fullAddress": {}
516
+ };
517
+ }
518
+ static get events() {
519
+ return [{
520
+ "method": "addresscomplete",
521
+ "name": "addresscomplete",
522
+ "bubbles": true,
523
+ "cancelable": true,
524
+ "composed": true,
525
+ "docs": {
526
+ "tags": [],
527
+ "text": ""
528
+ },
529
+ "complexType": {
530
+ "original": "string",
531
+ "resolved": "string",
532
+ "references": {}
533
+ }
534
+ }];
535
+ }
536
+ static get elementRef() { return "hostElement"; }
537
+ }
@@ -0,0 +1,40 @@
1
+ import readme from './readme.md';
2
+
3
+ export default {
4
+ title: 'input/Address Autofill',
5
+ parameters: {
6
+ notes: readme,
7
+ layout: 'centered',
8
+ },
9
+ };
10
+
11
+ const Template = ({ ...args }) => {
12
+ return `
13
+ <pn-address-autofill
14
+ environment="${args.environment}"
15
+ market="${args.market}"
16
+ cache="${args.cache}"
17
+ country-code="${args.countryCode}"
18
+ postal-code-props='${args.postalCodeProps}'
19
+ city-props='${args.cityProps}'
20
+ street-address-props='${args.streetAddressProps}'
21
+ street-number-props='${args.streetNumberProps}'
22
+ >
23
+ </pn-address-autofill>`;
24
+ };
25
+
26
+ export const Primary = Template.bind({});
27
+ Primary.args = {
28
+ environment: 'localhost',
29
+ market: 'se',
30
+ endpoint: 'https://localhost:51547/',
31
+ cache: true,
32
+ countryCode: 'se',
33
+ postalCodeProps:
34
+ '{"postalCodeCityLabel":"Postal Code and city labe","postalCodeInputName":"__postalcode","postalCodeInputPlaceholder":"Postal Code","postalCodeInputRequired":"true","postalCodeInputHelpertext":"Postal Code Helpertext"}',
35
+ cityProps: '{"cityInputName":"__city","cityInputPlaceholder":"City","cityInputHelpertext":"City Helpertext"}',
36
+ streetAddressProps:
37
+ '{"streetAddressNumberLabel":"Street and number Label","streetAddressInputName":"__streetaddress","streetAddressInputPlaceholder":"Street Address","streetAddressInputRequired":true,"streetAddressInputHelpertext":"Street Address Helpertext"}',
38
+ streetNumberProps:
39
+ '{"streetNumberInputName":"__streetnumber","streetNumberInputPlaceholder":"Street Number","streetNumberInputRequired":true,"streetNumberInputHelpertext":"Street Number Helpertext"}',
40
+ };