@progressive-development/pd-order 0.1.130 → 0.5.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.
- package/dist/index.js +12 -0
- package/dist/locales/be.js +10 -0
- package/dist/locales/de.js +14 -4
- package/dist/locales/en.js +10 -0
- package/dist/pd-order-contacts.js +3 -1
- package/dist/pd-order-summary.js +3 -1
- package/dist/src/PdOrderContacts.js +155 -33
- package/dist/src/PdOrderSummary.js +8 -8
- package/package.json +18 -16
- package/dist/node_modules/@progressive-development/pd-contact/pd-contact.js +0 -2
- package/dist/node_modules/@progressive-development/pd-contact/src/PdContact.js +0 -566
- package/dist/node_modules/@progressive-development/pd-content/pd-collapse.js +0 -2
- package/dist/node_modules/@progressive-development/pd-content/pd-edit-content.js +0 -2
- package/dist/node_modules/@progressive-development/pd-content/src/PdCollapse.js +0 -135
- package/dist/node_modules/@progressive-development/pd-content/src/PdEditContent.js +0 -223
- package/dist/node_modules/@progressive-development/pd-dialog/pd-popup.js +0 -2
- package/dist/node_modules/@progressive-development/pd-dialog/src/PdPopup.js +0 -112
- package/dist/node_modules/@progressive-development/pd-forms/pd-checkbox.js +0 -2
- package/dist/node_modules/@progressive-development/pd-forms/pd-form-container.js +0 -2
- package/dist/node_modules/@progressive-development/pd-forms/pd-form-row.js +0 -2
- package/dist/node_modules/@progressive-development/pd-forms/pd-hover-box.js +0 -2
- package/dist/node_modules/@progressive-development/pd-forms/pd-input.js +0 -2
- package/dist/node_modules/@progressive-development/pd-forms/pd-radio-group.js +0 -2
- package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseInputElement.js +0 -86
- package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseUi.js +0 -33
- package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseUiInput.js +0 -229
- package/dist/node_modules/@progressive-development/pd-forms/src/PdCheckbox.js +0 -230
- package/dist/node_modules/@progressive-development/pd-forms/src/PdFormContainer.js +0 -167
- package/dist/node_modules/@progressive-development/pd-forms/src/PdFormRow.js +0 -92
- package/dist/node_modules/@progressive-development/pd-forms/src/PdHoverBox.js +0 -108
- package/dist/node_modules/@progressive-development/pd-forms/src/PdInput.js +0 -79
- package/dist/node_modules/@progressive-development/pd-forms/src/PdRadioGroup.js +0 -72
- package/dist/node_modules/@progressive-development/pd-forms/src/shared-input-field-styles.js +0 -152
- package/dist/node_modules/@progressive-development/pd-forms/src/shared-input-styles.js +0 -64
- package/dist/node_modules/@progressive-development/pd-icon/pd-icon.js +0 -4
- package/dist/node_modules/@progressive-development/pd-icon/src/PdIcon.js +0 -595
- package/dist/node_modules/@progressive-development/pd-price/pd-pricetable.js +0 -2
- package/dist/node_modules/@progressive-development/pd-price/src/PdPricetable.js +0 -149
- package/dist/node_modules/fecha/lib/fecha.js +0 -200
- package/dist/node_modules/lit/node_modules/lit-html/directive.js +0 -27
- package/dist/node_modules/lit/node_modules/lit-html/directives/class-map.js +0 -36
- package/dist/node_modules/lit/node_modules/lit-html/lit-html.js +0 -242
|
@@ -1,566 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { LitElement, css, html } from "lit";
|
|
2
|
-
import { ICON_TOGGLE_COLLAPSE } from "../../pd-icon/src/PdIcon.js";
|
|
3
|
-
import "../../pd-icon/pd-icon.js";
|
|
4
|
-
import { PDColorStyles, PDFontStyles } from "@progressive-development/pd-shared-styles";
|
|
5
|
-
/**
|
|
6
|
-
* @license
|
|
7
|
-
* Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
|
|
8
|
-
*/
|
|
9
|
-
class PdCollapse extends LitElement {
|
|
10
|
-
static get properties() {
|
|
11
|
-
return {
|
|
12
|
-
active: { type: Boolean },
|
|
13
|
-
icon: { type: String }
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
constructor() {
|
|
17
|
-
super();
|
|
18
|
-
this.active = false;
|
|
19
|
-
}
|
|
20
|
-
static get styles() {
|
|
21
|
-
return [
|
|
22
|
-
PDColorStyles,
|
|
23
|
-
PDFontStyles,
|
|
24
|
-
css`
|
|
25
|
-
:host {
|
|
26
|
-
display: block;
|
|
27
|
-
width: 100%;
|
|
28
|
-
position: relative;
|
|
29
|
-
overflow: visible;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
:host .content.open {
|
|
33
|
-
border: 2px solid var(--pd-default-light-col);
|
|
34
|
-
background: var(--pd-collapse-content-bg-col, var(--pd-default-bg-col));
|
|
35
|
-
margin-bottom: 1rem;
|
|
36
|
-
position: relative;
|
|
37
|
-
overflow: visible;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
pd-icon {
|
|
41
|
-
--pd-icon-stroke-col-active: var(--pd-default-bg-col);
|
|
42
|
-
--pd-icon-col-active: var(--pd-default-dark-col);
|
|
43
|
-
--pd-icon-col-hover: var(--pd-default-dark-col);
|
|
44
|
-
--pd-icon-stroke-col-hover: var(--pd-default-hover-col);
|
|
45
|
-
--pd-icon-col-active-hover: var(--pd-default-dark-col);
|
|
46
|
-
--pd-icon-stroke-col-active-hover: var(--pd-default-hover-col);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.trigger {
|
|
50
|
-
background: var(--pd-collapse-bg-col, var(--pd-default-col));
|
|
51
|
-
font-family: var(--pd-default-font-title-family);
|
|
52
|
-
font-weight: bold;
|
|
53
|
-
color: var(--pd-collapse-font-col, var(--pd-default-bg-col));
|
|
54
|
-
transition-property: box-shadow, background;
|
|
55
|
-
transition: 0.2s ease-in;
|
|
56
|
-
cursor: pointer;
|
|
57
|
-
font-size: var(--pd-collapse-header-font-size, 1rem);
|
|
58
|
-
padding: 0.5rem;
|
|
59
|
-
display: flex;
|
|
60
|
-
justify-content: space-between;
|
|
61
|
-
box-sizing: border-box;
|
|
62
|
-
position: relative;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
::slotted(.header) {
|
|
66
|
-
display: flex;
|
|
67
|
-
align-items: center;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.trigger:hover {
|
|
71
|
-
background: var(--pd-collapse-hover-col, var(--pd-default-dark-col));
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.trigger.closed {
|
|
75
|
-
margin-bottom: 1rem;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.content {
|
|
79
|
-
will-change: transform;
|
|
80
|
-
height: 0;
|
|
81
|
-
overflow: hidden;
|
|
82
|
-
transition-property: visibility, transform;
|
|
83
|
-
transition-duration: 0.2s;
|
|
84
|
-
visibility: hidden;
|
|
85
|
-
transform: translate3d(0, -100%, 0);
|
|
86
|
-
box-sizing: border-box;
|
|
87
|
-
|
|
88
|
-
padding: 0.5em;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.content.open {
|
|
92
|
-
visibility: visible;
|
|
93
|
-
height: auto;
|
|
94
|
-
transform: translate3d(0, 0, 0);
|
|
95
|
-
overflow-y: auto;
|
|
96
|
-
}
|
|
97
|
-
`
|
|
98
|
-
];
|
|
99
|
-
}
|
|
100
|
-
open() {
|
|
101
|
-
this.active = true;
|
|
102
|
-
}
|
|
103
|
-
close() {
|
|
104
|
-
this.active = false;
|
|
105
|
-
}
|
|
106
|
-
onClick() {
|
|
107
|
-
this.active = !this.active;
|
|
108
|
-
this.dispatchEvent(
|
|
109
|
-
new CustomEvent("toggle-accordion", {
|
|
110
|
-
bubbles: true,
|
|
111
|
-
composed: true,
|
|
112
|
-
detail: this.active
|
|
113
|
-
})
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
render() {
|
|
117
|
-
return html`<div
|
|
118
|
-
class="trigger ${this.active ? "open" : "closed"}"
|
|
119
|
-
@click="${this.onClick}"
|
|
120
|
-
>
|
|
121
|
-
<slot name="header"></slot>
|
|
122
|
-
<pd-icon
|
|
123
|
-
icon="${ICON_TOGGLE_COLLAPSE}"
|
|
124
|
-
?activeIcon="${this.active}"
|
|
125
|
-
class="small primary"
|
|
126
|
-
></pd-icon>
|
|
127
|
-
</div>
|
|
128
|
-
<div class="content ${this.active ? "open" : "closed"}">
|
|
129
|
-
<slot name="content"></slot>
|
|
130
|
-
</div> `;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
export {
|
|
134
|
-
PdCollapse
|
|
135
|
-
};
|