@progressive-development/pd-contact 0.0.12 → 0.0.14
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/package.json +2 -2
- package/src/PdContact.js +88 -40
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Progressive Development Contact component",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"author": "PD Progressive Development",
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.14",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"module": "index.js",
|
|
9
9
|
"scripts": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"storybook:build": "npm run analyze -- --exclude dist && build-storybook"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@progressive-development/pd-forms": "0.0.
|
|
20
|
+
"@progressive-development/pd-forms": "0.0.42",
|
|
21
21
|
"lit": "^2.0.2"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
package/src/PdContact.js
CHANGED
|
@@ -94,6 +94,7 @@
|
|
|
94
94
|
this._errorMap.set(e.detail.name, '');
|
|
95
95
|
super.requestUpdate();
|
|
96
96
|
});
|
|
97
|
+
this.addEventListener('validate-form', this._validateForm);
|
|
97
98
|
}
|
|
98
99
|
|
|
99
100
|
render() {
|
|
@@ -106,11 +107,12 @@
|
|
|
106
107
|
|
|
107
108
|
_renderEditContact() {
|
|
108
109
|
return html`
|
|
109
|
-
<pd-form-container>
|
|
110
|
+
<pd-form-container id="contactContainerId">
|
|
110
111
|
<pd-form-row id="testFormId">
|
|
111
112
|
<pd-radio-group
|
|
112
113
|
class="quarter4"
|
|
113
|
-
label="Type
|
|
114
|
+
label="Type"
|
|
115
|
+
required
|
|
114
116
|
@checkbox-changed="${this._switchAddressType}"
|
|
115
117
|
style="--group-gap: 20px;"
|
|
116
118
|
>
|
|
@@ -127,16 +129,17 @@
|
|
|
127
129
|
<pd-input
|
|
128
130
|
id="compNameId"
|
|
129
131
|
class="quarter2"
|
|
130
|
-
label="Naam onderneming
|
|
132
|
+
label="Naam onderneming"
|
|
133
|
+
required
|
|
131
134
|
valueName="companyName"
|
|
132
|
-
errorMsg="${this._getErrorMsg('companyName')}"
|
|
133
135
|
></pd-input>
|
|
134
136
|
<pd-input
|
|
135
137
|
id="vatId"
|
|
136
138
|
class="quarter2"
|
|
137
|
-
label="Ondernemingsnr
|
|
139
|
+
label="Ondernemingsnr"
|
|
140
|
+
required
|
|
141
|
+
field-type="vat"
|
|
138
142
|
valueName="vatNr"
|
|
139
|
-
errorMsg="${this._getErrorMsg('vatNr')}"
|
|
140
143
|
></pd-input>
|
|
141
144
|
</pd-form-row>
|
|
142
145
|
`
|
|
@@ -145,16 +148,16 @@
|
|
|
145
148
|
<pd-input
|
|
146
149
|
id="firstNameId"
|
|
147
150
|
class="quarter2"
|
|
148
|
-
label="Voornaam
|
|
151
|
+
label="Voornaam"
|
|
149
152
|
valueName="firstName"
|
|
150
|
-
|
|
153
|
+
required
|
|
151
154
|
></pd-input>
|
|
152
155
|
<pd-input
|
|
153
156
|
id="lastNameId"
|
|
154
157
|
class="quarter2"
|
|
155
|
-
label="Naam
|
|
158
|
+
label="Naam"
|
|
156
159
|
valueName="lastName"
|
|
157
|
-
|
|
160
|
+
required
|
|
158
161
|
></pd-input>
|
|
159
162
|
</pd-form-row>
|
|
160
163
|
`}
|
|
@@ -162,16 +165,16 @@
|
|
|
162
165
|
<pd-input
|
|
163
166
|
id="streetId"
|
|
164
167
|
class="quarter3"
|
|
165
|
-
label="Straat
|
|
168
|
+
label="Straat"
|
|
166
169
|
valueName="street"
|
|
167
|
-
|
|
170
|
+
required
|
|
168
171
|
></pd-input>
|
|
169
172
|
<pd-input
|
|
170
173
|
id="streetNrId"
|
|
171
174
|
class="quarter1"
|
|
172
|
-
label="Nr
|
|
175
|
+
label="Nr"
|
|
173
176
|
valueName="streetNr"
|
|
174
|
-
|
|
177
|
+
required
|
|
175
178
|
></pd-input>
|
|
176
179
|
</pd-form-row>
|
|
177
180
|
<pd-form-row class="contact-form">
|
|
@@ -188,47 +191,50 @@
|
|
|
188
191
|
readonly
|
|
189
192
|
id="zipId"
|
|
190
193
|
class="quarter2"
|
|
191
|
-
label="Postcode
|
|
194
|
+
label="Postcode"
|
|
192
195
|
key="zip"
|
|
193
196
|
valueName="zip"
|
|
194
197
|
value="${this.match ? this.match.zip || '' : ''}"
|
|
195
|
-
|
|
198
|
+
required
|
|
196
199
|
></pd-input>
|
|
197
200
|
`
|
|
198
201
|
: html`
|
|
199
202
|
<pd-input
|
|
200
203
|
id="zipId"
|
|
201
204
|
class="quarter2"
|
|
202
|
-
label="Postcode
|
|
205
|
+
label="Postcode"
|
|
203
206
|
key="zip"
|
|
207
|
+
field-type="number"
|
|
204
208
|
valueName="zip"
|
|
205
|
-
|
|
209
|
+
required
|
|
206
210
|
></pd-input>
|
|
207
211
|
`}
|
|
208
212
|
<pd-input
|
|
209
213
|
id="cityId"
|
|
210
214
|
class="quarter2"
|
|
211
|
-
label="Plaats
|
|
212
|
-
valueName="city"
|
|
213
|
-
|
|
215
|
+
label="Plaats"
|
|
216
|
+
valueName="city"
|
|
217
|
+
required
|
|
214
218
|
></pd-input>
|
|
215
219
|
</pd-form-row>
|
|
216
220
|
<pd-form-row class="contact-form">
|
|
217
221
|
<pd-input
|
|
218
222
|
id="phoneId"
|
|
219
223
|
class="quarter2"
|
|
220
|
-
label="Telefoon
|
|
224
|
+
label="Telefoon"
|
|
221
225
|
key="phone"
|
|
222
226
|
valueName="phone1"
|
|
223
|
-
|
|
227
|
+
field-type="phone"
|
|
228
|
+
required
|
|
224
229
|
></pd-input>
|
|
225
230
|
<pd-input
|
|
226
231
|
id="mailId"
|
|
227
232
|
class="quarter2"
|
|
228
|
-
label="E-mail
|
|
233
|
+
label="E-mail"
|
|
229
234
|
key="mail"
|
|
235
|
+
field-type="mail"
|
|
230
236
|
valueName="email"
|
|
231
|
-
|
|
237
|
+
required
|
|
232
238
|
></pd-input>
|
|
233
239
|
</pd-form-row>
|
|
234
240
|
</pd-form-container>
|
|
@@ -271,6 +277,7 @@
|
|
|
271
277
|
this.business = e.detail.name === 'business';
|
|
272
278
|
}
|
|
273
279
|
|
|
280
|
+
/*
|
|
274
281
|
validateInput() {
|
|
275
282
|
const matchForValidate = this.match || {};
|
|
276
283
|
|
|
@@ -377,27 +384,68 @@
|
|
|
377
384
|
}
|
|
378
385
|
});
|
|
379
386
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
387
|
+
*/
|
|
388
|
+
|
|
389
|
+
_validateForm(e) {
|
|
390
|
+
if (e.detail) {
|
|
391
|
+
this.shadowRoot.getElementById("contactContainerId").dispatchEvent(
|
|
392
|
+
new CustomEvent("validate-form", {
|
|
393
|
+
detail: e.detail
|
|
394
|
+
})
|
|
395
|
+
);
|
|
396
|
+
|
|
397
|
+
// set prepared form, if no validation error occured
|
|
398
|
+
if (e.detail.errorMap.size === 0) {
|
|
399
|
+
e.detail.formData[this.id] = this._setFormData();
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
_setFormData() {
|
|
405
|
+
const companyName = this.business
|
|
406
|
+
? this.shadowRoot.getElementById('compNameId').value
|
|
407
|
+
: undefined;
|
|
408
|
+
const vatNr = this.business
|
|
409
|
+
? this.shadowRoot.getElementById('vatId').value
|
|
410
|
+
: undefined;
|
|
411
|
+
const firstName = this.business
|
|
412
|
+
? undefined
|
|
413
|
+
: this.shadowRoot.getElementById('firstNameId').value;
|
|
414
|
+
const lastName = this.business
|
|
415
|
+
? undefined
|
|
416
|
+
: this.shadowRoot.getElementById('lastNameId').value;
|
|
417
|
+
const street = this.shadowRoot.getElementById('streetId').value;
|
|
418
|
+
const streetNr = this.shadowRoot.getElementById('streetNrId').value;
|
|
419
|
+
const additionalHint =
|
|
420
|
+
this.shadowRoot.getElementById('additionalHintId').value;
|
|
421
|
+
const zip = this.shadowRoot.getElementById('zipId').value;
|
|
422
|
+
const city = this.shadowRoot.getElementById('cityId').value;
|
|
423
|
+
const phone1 = this.shadowRoot.getElementById('phoneId').value;
|
|
424
|
+
const email = this.shadowRoot.getElementById('mailId').value;
|
|
425
|
+
|
|
426
|
+
this.contact = {
|
|
427
|
+
business: this.business,
|
|
428
|
+
companyName,
|
|
429
|
+
vatNr,
|
|
430
|
+
firstName,
|
|
431
|
+
lastName,
|
|
432
|
+
street,
|
|
433
|
+
streetNr,
|
|
434
|
+
additionalHint,
|
|
435
|
+
zip,
|
|
436
|
+
city,
|
|
437
|
+
phone1,
|
|
438
|
+
email,
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
return {...this.contact};
|
|
442
|
+
}
|
|
385
443
|
|
|
386
444
|
static _vatIsValid(vat) {
|
|
387
445
|
const mValid = /^BE[0-9]{10}/.test(vat);
|
|
388
446
|
return mValid;
|
|
389
447
|
}
|
|
390
448
|
|
|
391
|
-
static _phoneIsValid(nr) {
|
|
392
|
-
// Valid +49 830 9001 | 49 221 123 | 08912379
|
|
393
|
-
const mValid = /^\+?[0-9 ]{7,15}$/.test(nr);
|
|
394
|
-
return mValid;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
_getErrorMsg(itemId) {
|
|
398
|
-
return this._errorMap.get(itemId) || '';
|
|
399
|
-
}
|
|
400
|
-
|
|
401
449
|
_getFullName() {
|
|
402
450
|
return PdContact._getFullVal(this.contact.firstName, this.contact.lastName);
|
|
403
451
|
}
|