@progressive-development/pd-order 0.1.126 → 0.1.128

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 (42) hide show
  1. package/dist/locales/be.js +15 -0
  2. package/dist/locales/de.js +15 -0
  3. package/dist/locales/en.js +15 -0
  4. package/dist/node_modules/@progressive-development/pd-contact/pd-contact.js +2 -0
  5. package/dist/node_modules/@progressive-development/pd-contact/src/PdContact.js +566 -0
  6. package/dist/node_modules/@progressive-development/pd-content/pd-collapse.js +2 -0
  7. package/dist/node_modules/@progressive-development/pd-content/pd-edit-content.js +2 -0
  8. package/dist/node_modules/@progressive-development/pd-content/src/PdCollapse.js +135 -0
  9. package/dist/node_modules/@progressive-development/pd-content/src/PdEditContent.js +223 -0
  10. package/dist/node_modules/@progressive-development/pd-dialog/pd-popup.js +2 -0
  11. package/dist/node_modules/@progressive-development/pd-dialog/src/PdPopup.js +112 -0
  12. package/dist/node_modules/@progressive-development/pd-forms/pd-checkbox.js +2 -0
  13. package/dist/node_modules/@progressive-development/pd-forms/pd-form-container.js +2 -0
  14. package/dist/node_modules/@progressive-development/pd-forms/pd-form-row.js +2 -0
  15. package/dist/node_modules/@progressive-development/pd-forms/pd-hover-box.js +2 -0
  16. package/dist/node_modules/@progressive-development/pd-forms/pd-input.js +2 -0
  17. package/dist/node_modules/@progressive-development/pd-forms/pd-radio-group.js +2 -0
  18. package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseInputElement.js +86 -0
  19. package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseUi.js +33 -0
  20. package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseUiInput.js +229 -0
  21. package/dist/node_modules/@progressive-development/pd-forms/src/PdCheckbox.js +230 -0
  22. package/dist/node_modules/@progressive-development/pd-forms/src/PdFormContainer.js +167 -0
  23. package/dist/node_modules/@progressive-development/pd-forms/src/PdFormRow.js +92 -0
  24. package/dist/node_modules/@progressive-development/pd-forms/src/PdHoverBox.js +108 -0
  25. package/dist/node_modules/@progressive-development/pd-forms/src/PdInput.js +79 -0
  26. package/dist/node_modules/@progressive-development/pd-forms/src/PdRadioGroup.js +72 -0
  27. package/dist/node_modules/@progressive-development/pd-forms/src/shared-input-field-styles.js +152 -0
  28. package/dist/node_modules/@progressive-development/pd-forms/src/shared-input-styles.js +64 -0
  29. package/dist/node_modules/@progressive-development/pd-icon/pd-icon.js +4 -0
  30. package/dist/node_modules/@progressive-development/pd-icon/src/PdIcon.js +595 -0
  31. package/dist/node_modules/@progressive-development/pd-price/pd-pricetable.js +2 -0
  32. package/dist/node_modules/@progressive-development/pd-price/src/PdPricetable.js +149 -0
  33. package/dist/node_modules/fecha/lib/fecha.js +200 -0
  34. package/dist/node_modules/lit/node_modules/lit-html/directive.js +27 -0
  35. package/dist/node_modules/lit/node_modules/lit-html/directives/class-map.js +36 -0
  36. package/dist/node_modules/lit/node_modules/lit-html/lit-html.js +242 -0
  37. package/dist/pd-order-contacts.js +2 -1
  38. package/dist/pd-order-summary.js +1 -703
  39. package/dist/src/PdOrderContacts.js +191 -0
  40. package/dist/src/PdOrderSummary.js +242 -0
  41. package/package.json +13 -5
  42. package/dist/pd-order-contacts-chunk.js +0 -3060
@@ -0,0 +1,15 @@
1
+ import { html } from "lit";
2
+ const templates = {
3
+ "pd.order.contacts.billingContact.inputHeader": `Facturatieadres`,
4
+ "pd.order.contacts.billingContact.otherBillingLink": `Gebruik een ander facturatieadres`,
5
+ "pd.order.contacts.billingContact.sameBillingLink": `Gebruik hetzelfde facturatieadres`,
6
+ "pd.order.contacts.billingContact.sameBillingText": `Het adres wordt ook gebruikt als facturatieadres.`,
7
+ "pd.order.contacts.orderContact.inputHeader": `Adres`,
8
+ "pd.order.summary.agree.link": html`Ga akkoord met onze <a @click="${0}" @keypress="${1}">algemene voorwaarden</a>.`,
9
+ "pd.order.summary.agree.required": `Ga akkoord met de algemene voorwaarden om verder te gaan.`,
10
+ "pd.order.summary.billing": `Factuur`,
11
+ "pd.order.summary.title": `Overzicht`
12
+ };
13
+ export {
14
+ templates
15
+ };
@@ -0,0 +1,15 @@
1
+ import { html } from "lit";
2
+ const templates = {
3
+ "pd.order.contacts.orderContact.inputHeader": `Adresse`,
4
+ "pd.order.contacts.billingContact.inputHeader": `Rechnungsadresse`,
5
+ "pd.order.contacts.billingContact.sameBillingLink": `Gleiche Rechnungsadresse`,
6
+ "pd.order.contacts.billingContact.sameBillingText": `Die Adresse, wird auch als Rechnungsadresse verwendet.`,
7
+ "pd.order.contacts.billingContact.otherBillingLink": `Andere Rechnungsadresse verwenden`,
8
+ "pd.order.summary.title": `Übersicht`,
9
+ "pd.order.summary.billing": `Rechnung`,
10
+ "pd.order.summary.agree.required": `Bitte stimmen Sie den Allgemeinen Geschäftsbedingungen zu, um fortzufahren.`,
11
+ "pd.order.summary.agree.link": html`Stimmen Sie unseren <a @click="${0}" @keypress="${1}">Allgemeinen Geschäftsbedingungen</a> zu`
12
+ };
13
+ export {
14
+ templates
15
+ };
@@ -0,0 +1,15 @@
1
+ import { html } from "lit";
2
+ const templates = {
3
+ "pd.order.contacts.billingContact.inputHeader": `Billing Address`,
4
+ "pd.order.contacts.billingContact.otherBillingLink": `Use a different billing address`,
5
+ "pd.order.contacts.billingContact.sameBillingLink": `Use the same billing address`,
6
+ "pd.order.contacts.billingContact.sameBillingText": `The address will also be used as the billing address.`,
7
+ "pd.order.contacts.orderContact.inputHeader": `Address`,
8
+ "pd.order.summary.agree.link": html`Agree to our <a @click="${0}" @keypress="${1}">terms and conditions</a>.`,
9
+ "pd.order.summary.agree.required": `Please agree to the terms and conditions to proceed.`,
10
+ "pd.order.summary.billing": `Invoice`,
11
+ "pd.order.summary.title": `Overview`
12
+ };
13
+ export {
14
+ templates
15
+ };
@@ -0,0 +1,2 @@
1
+ import { PdContact } from "./src/PdContact.js";
2
+ window.customElements.define("pd-contact", PdContact);
@@ -0,0 +1,566 @@
1
+ import { LitElement, css, html } from "lit";
2
+ import { PDFontStyles } from "@progressive-development/pd-shared-styles";
3
+ import "../../pd-icon/pd-icon.js";
4
+ import "../../pd-forms/pd-checkbox.js";
5
+ import "../../pd-forms/pd-form-container.js";
6
+ import "../../pd-forms/pd-form-row.js";
7
+ import "../../pd-forms/pd-input.js";
8
+ import "../../pd-forms/pd-radio-group.js";
9
+ /**
10
+ * @license
11
+ * Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
12
+ */
13
+ const countryPrefixes = {
14
+ de: "+49",
15
+ // Deutschland
16
+ be: "+32",
17
+ // Belgien
18
+ nl: "+31",
19
+ // Niederland
20
+ fr: "+33",
21
+ // Frankreich
22
+ es: "+34"
23
+ // Spanien
24
+ };
25
+ function transformPhone(phone, country) {
26
+ if (!phone || typeof phone !== "string") {
27
+ return "";
28
+ }
29
+ const countryPrefix = countryPrefixes[country];
30
+ if (!countryPrefix) {
31
+ throw new Error(`Unbekanntes Land: ${country}`);
32
+ }
33
+ const cleanedPhone = phone.replace(/\s+/g, "").replace(/[^0-9+]/g, "");
34
+ if (cleanedPhone.startsWith("+")) {
35
+ return cleanedPhone;
36
+ }
37
+ if (cleanedPhone.startsWith("0")) {
38
+ return countryPrefix + cleanedPhone.slice(1);
39
+ }
40
+ return "";
41
+ }
42
+ class PdContact extends LitElement {
43
+ static get styles() {
44
+ return [
45
+ PDFontStyles,
46
+ css`
47
+ :host {
48
+ display: block;
49
+ }
50
+
51
+ .contact {
52
+ display: flex;
53
+ flex-direction: column;
54
+ }
55
+
56
+ address {
57
+ color: var(--pd-contact-address-col, var(--pd-default-font-content-col));
58
+ line-height: 1.8;
59
+ font-style: normal;
60
+ }
61
+
62
+ dl {
63
+ margin: 0;
64
+ padding: 0;
65
+ }
66
+
67
+ dt {
68
+ font-weight: bold;
69
+ padding-top: 10px;
70
+ color: var(--pd-contact-address-title-col, var(--pd-default-font-title-col));
71
+ }
72
+
73
+ dd {
74
+ font-weight: 400;
75
+ font-size: 1em;
76
+ margin: 0;
77
+ padding: 0;
78
+ }
79
+
80
+ dd.larger {
81
+ padding-top: 3px;
82
+ padding-bottom: 5px;
83
+ }
84
+
85
+ .contact-form {
86
+ --row-padding-top: 10px;
87
+ }
88
+
89
+ .link-icon {
90
+ --pd-icon-bg-col-active: #859900;
91
+ --pd-icon-bg-col-hover: #859900;
92
+ --pd-icon-size: 14px;
93
+ --pd-icon-stroke-col-active: white;
94
+ --pd-icon-col-active: white;
95
+ }
96
+
97
+ .link-item {
98
+ display: flex;
99
+ align-items: center;
100
+ text-decoration: none;
101
+ color: var(--pd-default-font-link-col, inherit);
102
+ }
103
+
104
+ .link-item:hover {
105
+ color: var(--pd-default-font-link-col-hover, #451A46) ;
106
+ }
107
+
108
+ `
109
+ ];
110
+ }
111
+ static get properties() {
112
+ return {
113
+ addressTitle: { type: String },
114
+ addressRef: { type: String },
115
+ /**
116
+ * show (true) or not (false) tel number as link
117
+ */
118
+ phoneMailLink: { type: Boolean },
119
+ /**
120
+ * summary (true) or view (false) contact data
121
+ */
122
+ summary: { type: Boolean },
123
+ /**
124
+ * List with required contact fields, if not set use default (previous existing values to be consitent during update)
125
+ */
126
+ requiredFields: { type: Array },
127
+ contact: { type: Object },
128
+ match: { type: Object },
129
+ /**
130
+ * address type, business (true) or private (false), refactor, ist state internal? => _business, state:true
131
+ */
132
+ _business: { type: Boolean, state: true },
133
+ _errorMap: { type: Object }
134
+ };
135
+ }
136
+ constructor() {
137
+ super();
138
+ this.addressTitle = "Adres";
139
+ this.requiredFields = [];
140
+ this.summary = false;
141
+ this.match = {};
142
+ this._business = false;
143
+ this._errorMap = /* @__PURE__ */ new Map();
144
+ }
145
+ update(changedProperties) {
146
+ if (changedProperties.has("contact") && this.contact) {
147
+ this._business = this.contact.business;
148
+ }
149
+ super.update(changedProperties);
150
+ }
151
+ connectedCallback() {
152
+ super.connectedCallback();
153
+ this.addEventListener("validate-form", this._validateForm);
154
+ }
155
+ disconnectedCallback() {
156
+ super.connectedCallback();
157
+ this.removeEventListener("validate-form", this._validateForm);
158
+ }
159
+ firstUpdated() {
160
+ var _a, _b;
161
+ this.addEventListener("key-pressed", (e) => {
162
+ this._errorMap.set(e.detail.name, "");
163
+ super.requestUpdate();
164
+ });
165
+ if (this.contact) {
166
+ const detail = {
167
+ errorMap: /* @__PURE__ */ new Map()
168
+ };
169
+ (_b = (_a = this.shadowRoot) == null ? void 0 : _a.getElementById("contactContainerId")) == null ? void 0 : _b.dispatchEvent(
170
+ new CustomEvent("validate-form", { detail })
171
+ );
172
+ }
173
+ }
174
+ render() {
175
+ return html`
176
+ <div class="contact">
177
+ ${this.summary ? this._renderViewContact() : this._renderEditContact()}
178
+ </div>
179
+ `;
180
+ }
181
+ _renderEditContact() {
182
+ return html`
183
+ <pd-form-container id="contactContainerId" requiredFieldInfo>
184
+ <pd-form-row id="testFormId">
185
+ <pd-radio-group
186
+ class="quarter3"
187
+ label="Type"
188
+ required
189
+ value="${this._getRadioValue()}"
190
+ @field-change="${this._switchAddressType}"
191
+ style="--group-gap: 20px;"
192
+ >
193
+ <pd-checkbox value="${this.contact ? !this.contact.business : true}" valueName="private"
194
+ >Particulier</pd-checkbox
195
+ >
196
+ <pd-checkbox valueName="business" value="${this.contact ? this.contact.business : false}">Onderneming</pd-checkbox>
197
+ </pd-radio-group>
198
+ </pd-form-row>
199
+
200
+ ${this._business ? html`
201
+ <pd-form-row class="contact-form">
202
+ <pd-input
203
+ id="compNameId"
204
+ class="quarter3"
205
+ label="Naam onderneming"
206
+ ?required="${this._isRequired("companyName")}"
207
+ value="${this.contact ? this.contact.companyName : ""}"
208
+ valueName="companyName"
209
+ autoCompleteName="organization"
210
+ ></pd-input>
211
+ </pd-form-row>
212
+ <pd-form-row class="contact-form">
213
+ <pd-input
214
+ id="vatId"
215
+ class="quarter3"
216
+ label="Ondernemingsnr"
217
+ ?required="${this._isRequired("vatNr")}"
218
+ field-type="vat"
219
+ valueName="vatNr"
220
+ value="${this.contact ? this.contact.vatNr : ""}"
221
+ autoCompleteName="vat"
222
+ ></pd-input>
223
+ </pd-form-row>
224
+ ` : html`
225
+ <pd-form-row class="contact-form">
226
+ <pd-input
227
+ id="firstNameId"
228
+ class="quarter3"
229
+ label="Voornaam"
230
+ valueName="firstName"
231
+ value="${this.contact ? this.contact.firstName : ""}"
232
+ autoCompleteName="given-name"
233
+ ?required="${this._isRequired("firstName")}"
234
+ ></pd-input>
235
+ </pd-form-row>
236
+ <pd-form-row class="contact-form">
237
+ <pd-input
238
+ id="lastNameId"
239
+ class="quarter3"
240
+ label="Naam"
241
+ valueName="lastName"
242
+ value="${this.contact ? this.contact.lastName : ""}"
243
+ autoCompleteName="family-name"
244
+ ?required="${this._isRequired("lastName")}"
245
+ ></pd-input>
246
+ </pd-form-row>
247
+ `}
248
+ <pd-form-row class="contact-form">
249
+ <pd-input
250
+ id="streetId"
251
+ class="quarter2"
252
+ label="Straat"
253
+ valueName="street"
254
+ value="${this.contact ? this.contact.street : ""}"
255
+ autoCompleteName="street-address"
256
+ ?required="${this._isRequired("street")}"
257
+ ></pd-input>
258
+ <pd-input
259
+ id="streetNrId"
260
+ class="quarter1"
261
+ label="Nr"
262
+ valueName="streetNr"
263
+ value="${this.contact ? this.contact.streetNr : ""}"
264
+ ?required="${this._isRequired("streetNr")}"
265
+ ></pd-input>
266
+ </pd-form-row>
267
+ <pd-form-row class="contact-form">
268
+ ${this.match && this.match.zip ? html`
269
+ <pd-input
270
+ readonly
271
+ id="zipId"
272
+ class="quarter1"
273
+ label="Postcode"
274
+ valueName="zip"
275
+ value="${this.match ? this.match.zip || "" : ""}"
276
+ ></pd-input>
277
+ ` : html`
278
+ <pd-input
279
+ id="zipId"
280
+ class="quarter1"
281
+ label="Postcode"
282
+ field-type="number"
283
+ valueName="zip"
284
+ value="${this.contact ? this.contact.zip : ""}"
285
+ autoCompleteName="postal-code"
286
+ ?required="${this._isRequired("zip")}"
287
+ ></pd-input>
288
+ `}
289
+ <pd-input
290
+ id="cityId"
291
+ class="quarter2"
292
+ label="Plaats"
293
+ valueName="city"
294
+ value="${this.contact ? this.contact.city : ""}"
295
+ autoCompleteName="locality"
296
+ ?required="${this._isRequired("city")}"
297
+ ></pd-input>
298
+ </pd-form-row>
299
+ <pd-form-row class="contact-form">
300
+ <pd-input
301
+ class="quarter3"
302
+ id="additionalHintId"
303
+ label="Extra informatie"
304
+ value="${this.contact ? this.contact.additionalHint : ""}"
305
+ ></pd-input>
306
+ </pd-form-row>
307
+ <pd-form-row class="contact-form">
308
+ <pd-input
309
+ id="phoneId"
310
+ class="quarter3"
311
+ label="Telefoon"
312
+ name="phone"
313
+ valueName="phone1"
314
+ value="${this.contact ? this.contact.phone1 : ""}"
315
+ field-type="phone"
316
+ autoCompleteName="tel"
317
+ ?required="${this._isRequired("phone1")}"
318
+ ></pd-input>
319
+ </pd-form-row>
320
+ <pd-form-row class="contact-form">
321
+ <pd-input
322
+ id="mailId"
323
+ class="quarter3"
324
+ label="E-mail"
325
+ field-type="mail"
326
+ valueName="email"
327
+ value="${this.contact ? this.contact.email : ""}"
328
+ autoCompleteName="email"
329
+ ?required="${this._isRequired("email")}"
330
+ ></pd-input>
331
+ </pd-form-row>
332
+ </pd-form-container>
333
+ `;
334
+ }
335
+ _getRadioValue() {
336
+ if (this.contact) {
337
+ return this.contact.business ? "business" : "private";
338
+ }
339
+ return "private";
340
+ }
341
+ _renderViewContact() {
342
+ if (!this.contact) {
343
+ return html`<p>Contact undefined</p>`;
344
+ }
345
+ const trPhoneNr = transformPhone(this.contact.phone1, this.contact.country || "be");
346
+ return html`
347
+ <address>
348
+ <dl>
349
+ <dt>${this.addressTitle}</dt>
350
+ ${this.contact ? html`
351
+ <dd>${this.contact.companyName}</dd>
352
+ <dd>${this.contact.vatNr}</dd>
353
+ <dd>${this._getFullName()}</dd>
354
+ <dd>${this._getFullStreet()}</dd>
355
+ <dd>${this._getFullLocation()}</dd>
356
+ ${this.contact.additionalHint ? html`<dd>${this.contact.additionalHint}</dd>` : ""}
357
+ <dd>${this.contact.country}</dd>
358
+
359
+ ${this.contact.phone1 ? html`
360
+ <dd class="larger">${this.phoneMailLink && trPhoneNr ? html`
361
+ <a href="${`tel:${trPhoneNr}`}"
362
+ aria-label="${`Phone call: ${this.contact.phone1}`}"
363
+ class="link-item">
364
+ <span style="margin-right: 8px;">${this.contact.phone1}</span>
365
+ <pd-icon activeIcon icon="phoneIcon" class="round link-icon"></pd-icon>
366
+ </a>
367
+ ` : this.contact.phone1}</dd>
368
+ ` : ""}
369
+
370
+ ${this.contact.email ? html`
371
+ <dd class="larger">${this.phoneMailLink ? html`
372
+ <a href="${`mailto:${this.contact.email}`}"
373
+ aria-label="${`Send mail: ${this.contact.email}`}"
374
+ class="link-item">
375
+ <span style="margin-right: 8px;">${this.contact.email}</span>
376
+ <pd-icon activeIcon icon="mailIcon" class="round link-icon"></pd-icon>
377
+ </a>
378
+ ` : this.contact.email}</dd>
379
+ ` : ""}
380
+
381
+ ${this.contact.btw ? html`<dt>BTW</dt>
382
+ <dd>${this.contact.btw}</dd>` : ""}
383
+ ${this.contact.kbc ? html`<dt>Bankgegevens</dt>
384
+ <dd>${this.contact.kbc}</dd>
385
+ <dd>${this.contact.bank}</dd>` : ""}
386
+ ` : html`${this.addressRef || "--"}`}
387
+ </dl>
388
+ </address>
389
+ `;
390
+ }
391
+ _switchAddressType(e) {
392
+ this._business = e.detail.name === "business";
393
+ }
394
+ _isRequired(field) {
395
+ return this.requiredFields && this.requiredFields.length > 0 ? this.requiredFields.includes(field) : false;
396
+ }
397
+ /*
398
+ validateInput() {
399
+ const matchForValidate = this.match || {};
400
+
401
+ const companyName = this.business
402
+ ? this.shadowRoot.getElementById('compNameId').value
403
+ : undefined;
404
+ const vatNr = this.business
405
+ ? this.shadowRoot.getElementById('vatId').value
406
+ : undefined;
407
+ const firstName = this.business
408
+ ? undefined
409
+ : this.shadowRoot.getElementById('firstNameId').value;
410
+ const lastName = this.business
411
+ ? undefined
412
+ : this.shadowRoot.getElementById('lastNameId').value;
413
+ const street = this.shadowRoot.getElementById('streetId').value;
414
+ const streetNr = this.shadowRoot.getElementById('streetNrId').value;
415
+ const additionalHint =
416
+ this.shadowRoot.getElementById('additionalHintId').value;
417
+ const zip = this.shadowRoot.getElementById('zipId').value;
418
+ const city = this.shadowRoot.getElementById('cityId').value;
419
+ const phone1 = this.shadowRoot.getElementById('phoneId').value;
420
+ const email = this.shadowRoot.getElementById('mailId').value;
421
+
422
+ const newErrorMap = new Map();
423
+
424
+ const reqFieldFunc = (field, key, type, mustMatch) => {
425
+ if (!field || field === '') {
426
+ newErrorMap.set(
427
+ key,
428
+ type !== 'phone'
429
+ ? 'Vul dit veld in.'
430
+ : 'Vul dit veld in. Gebruik +32 494 667085.'
431
+ );
432
+ } else if (mustMatch && field !== mustMatch) {
433
+ newErrorMap.set(key, `Not match ${mustMatch}`);
434
+ } else {
435
+ switch (type) {
436
+ case 'vat':
437
+ // eslint-disable-next-line no-restricted-globals
438
+ if (!newErrorMap.has(key) && !PdContact._vatIsValid(field)) {
439
+ newErrorMap.set(key, 'Formaat BE0123456789 vereist');
440
+ }
441
+ break;
442
+ case 'number':
443
+ // eslint-disable-next-line no-restricted-globals
444
+ if (!newErrorMap.has(key) && isNaN(field)) {
445
+ newErrorMap.set(key, 'Alleen nummers toegestaan');
446
+ }
447
+ break;
448
+ case 'mail':
449
+ if (!newErrorMap.has(key) && !PdContact._mailIsValid(field)) {
450
+ newErrorMap.set(key, 'Ongeldig e-mailadres');
451
+ }
452
+ break;
453
+ case 'phone':
454
+ if (!newErrorMap.has(key) && !PdContact._phoneIsValid(field)) {
455
+ newErrorMap.set(
456
+ key,
457
+ 'Ongeldig telefoonnummer, gebruik +32 494 667085.'
458
+ );
459
+ }
460
+ break;
461
+ default:
462
+ console.warn('Undefined field: ', type);
463
+ }
464
+ }
465
+ };
466
+
467
+ if (this.business) {
468
+ reqFieldFunc(companyName, 'companyName');
469
+ reqFieldFunc(vatNr, 'vatNr', 'vat');
470
+ } else {
471
+ reqFieldFunc(firstName, 'firstName');
472
+ reqFieldFunc(lastName, 'lastName');
473
+ }
474
+ reqFieldFunc(street, 'street');
475
+ reqFieldFunc(streetNr, 'streetNr');
476
+ reqFieldFunc(zip, 'zip', 'number', matchForValidate.zip);
477
+ reqFieldFunc(city, 'city');
478
+ reqFieldFunc(phone1, 'phone1', 'phone');
479
+ reqFieldFunc(email, 'email', 'mail');
480
+ this._errorMap = newErrorMap;
481
+
482
+ return new Promise((resolve, reject) => {
483
+ if (newErrorMap.size > 0) {
484
+ reject();
485
+ } else {
486
+ this.contact = {
487
+ business: this.business,
488
+ companyName,
489
+ vatNr,
490
+ firstName,
491
+ lastName,
492
+ street,
493
+ streetNr,
494
+ additionalHint,
495
+ zip,
496
+ city,
497
+ phone1,
498
+ email,
499
+ };
500
+ resolve(this.contact);
501
+ }
502
+ });
503
+ }
504
+ */
505
+ _validateForm(e) {
506
+ if (e.detail && !e.detail.singleElement) {
507
+ this.shadowRoot.getElementById("contactContainerId").dispatchEvent(
508
+ new CustomEvent("validate-form", {
509
+ detail: e.detail
510
+ })
511
+ );
512
+ if (e.detail.errorMap.size === 0 && e.detail.formData) {
513
+ e.detail.formData[this.id] = this._setFormData();
514
+ }
515
+ }
516
+ }
517
+ _setFormData() {
518
+ const companyName = this._business ? this.shadowRoot.getElementById("compNameId").value : void 0;
519
+ const vatNr = this._business ? this.shadowRoot.getElementById("vatId").value : void 0;
520
+ const firstName = this._business ? void 0 : this.shadowRoot.getElementById("firstNameId").value;
521
+ const lastName = this._business ? void 0 : this.shadowRoot.getElementById("lastNameId").value;
522
+ const street = this.shadowRoot.getElementById("streetId").value;
523
+ const streetNr = this.shadowRoot.getElementById("streetNrId").value;
524
+ const additionalHint = this.shadowRoot.getElementById("additionalHintId").value;
525
+ const zip = this.shadowRoot.getElementById("zipId").value;
526
+ const city = this.shadowRoot.getElementById("cityId").value;
527
+ const phone1 = this.shadowRoot.getElementById("phoneId").value;
528
+ const email = this.shadowRoot.getElementById("mailId").value;
529
+ return {
530
+ business: this._business,
531
+ companyName,
532
+ vatNr,
533
+ firstName,
534
+ lastName,
535
+ street,
536
+ streetNr,
537
+ additionalHint,
538
+ zip,
539
+ city,
540
+ phone1,
541
+ email
542
+ };
543
+ }
544
+ _getFullName() {
545
+ return PdContact._getFullVal(this.contact.firstName, this.contact.lastName);
546
+ }
547
+ _getFullStreet() {
548
+ return PdContact._getFullVal(this.contact.street, this.contact.streetNr);
549
+ }
550
+ _getFullLocation() {
551
+ return PdContact._getFullVal(this.contact.zip, this.contact.city);
552
+ }
553
+ static _getFullVal(val1, val2, elseStr) {
554
+ let fullVal = "";
555
+ if (val1) {
556
+ fullVal += val1;
557
+ }
558
+ if (val2) {
559
+ fullVal += ` ${val2}`;
560
+ }
561
+ return fullVal.length === 0 ? elseStr : fullVal;
562
+ }
563
+ }
564
+ export {
565
+ PdContact
566
+ };
@@ -0,0 +1,2 @@
1
+ import { PdCollapse } from "./src/PdCollapse.js";
2
+ window.customElements.define("pd-collapse", PdCollapse);
@@ -0,0 +1,2 @@
1
+ import { PdEditContent } from "./src/PdEditContent.js";
2
+ window.customElements.define("pd-edit-content", PdEditContent);