@progressive-development/pd-contact 0.1.27 → 0.1.29

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 (2) hide show
  1. package/package.json +2 -2
  2. package/src/PdContact.js +31 -36
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.1.27",
6
+ "version": "0.1.29",
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.1.32",
20
+ "@progressive-development/pd-forms": "^0.1.34",
21
21
  "@progressive-development/pd-shared-styles": "^0.1.1",
22
22
  "lit": "^2.2.0"
23
23
  },
package/src/PdContact.js CHANGED
@@ -12,57 +12,52 @@
12
12
  import '@progressive-development/pd-forms/pd-form-row.js';
13
13
  import '@progressive-development/pd-forms/pd-input.js';
14
14
  import '@progressive-development/pd-forms/pd-radio-group.js';
15
+
15
16
 
16
- /**
17
- * An example element.
18
- *
19
- * @slot - This element has a slot
20
- * @csspart button - The button
21
- */
22
17
  export class PdContact extends LitElement {
23
18
  static get styles() {
24
19
  return [
25
20
  PDFontStyles,
26
21
  css`
27
22
  :host {
28
- display: block;
23
+ display: block;
29
24
  }
30
-
25
+
31
26
  .contact {
32
27
  display: flex;
33
28
  flex-direction: column;
34
29
  }
35
-
30
+
36
31
  address {
37
32
  color: var(--pd-contact-address-col, var(--pd-default-font-content-col));
38
33
  line-height: 1.8;
39
34
  font-style: normal;
40
35
  }
41
-
36
+
42
37
  dl {
43
38
  margin: 0;
44
39
  padding: 0;
45
40
  }
46
-
41
+
47
42
  dt {
48
43
  font-weight: bold;
49
44
  padding-top: 10px;
50
45
  color: var(--pd-contact-address-title-col, var(--pd-default-font-title-col));
51
46
  }
52
-
47
+
53
48
  dd {
54
49
  font-weight: 400;
55
50
  font-size: 1em;
56
51
  margin: 0;
57
52
  padding: 0;
58
53
  }
59
-
54
+
60
55
  .contact-form {
61
56
  --row-padding-top: 10px;
62
57
  }
63
58
  `];
64
59
  }
65
-
60
+
66
61
  static get properties() {
67
62
  return {
68
63
  addressTitle: { type: String },
@@ -80,7 +75,7 @@
80
75
  _errorMap: { type: Object },
81
76
  };
82
77
  }
83
-
78
+
84
79
  constructor() {
85
80
  super();
86
81
  this.addressTitle = 'Adres';
@@ -89,7 +84,7 @@
89
84
  this.match = {};
90
85
  this._errorMap = new Map();
91
86
  }
92
-
87
+
93
88
  firstUpdated() {
94
89
  this.addEventListener('key-pressed', e => {
95
90
  this._errorMap.set(e.detail.name, '');
@@ -97,7 +92,7 @@
97
92
  });
98
93
  this.addEventListener('validate-form', this._validateForm);
99
94
  }
100
-
95
+
101
96
  render() {
102
97
  return html`
103
98
  <div class="contact">
@@ -105,7 +100,7 @@
105
100
  </div>
106
101
  `;
107
102
  }
108
-
103
+
109
104
  _renderEditContact() {
110
105
  return html`
111
106
  <pd-form-container id="contactContainerId" requiredFieldInfo>
@@ -123,7 +118,7 @@
123
118
  <pd-checkbox valueName="business">Onderneming</pd-checkbox>
124
119
  </pd-radio-group>
125
120
  </pd-form-row>
126
-
121
+
127
122
  ${this.business
128
123
  ? html`
129
124
  <pd-form-row class="contact-form">
@@ -197,7 +192,7 @@
197
192
  readonly
198
193
  id="zipId"
199
194
  class="quarter2"
200
- label="Postcode"
195
+ label="Postcode"
201
196
  valueName="zip"
202
197
  value="${this.match ? this.match.zip || '' : ''}"
203
198
  required
@@ -207,7 +202,7 @@
207
202
  <pd-input
208
203
  id="zipId"
209
204
  class="quarter2"
210
- label="Postcode"
205
+ label="Postcode"
211
206
  field-type="number"
212
207
  valueName="zip"
213
208
  autoCompleteName="postal-code"
@@ -218,7 +213,7 @@
218
213
  id="cityId"
219
214
  class="quarter2"
220
215
  label="Plaats"
221
- valueName="city"
216
+ valueName="city"
222
217
  autoCompleteName="locality"
223
218
  required
224
219
  ></pd-input>
@@ -227,7 +222,7 @@
227
222
  <pd-input
228
223
  id="phoneId"
229
224
  class="quarter2"
230
- label="Telefoon"
225
+ label="Telefoon"
231
226
  name="phone"
232
227
  valueName="phone1"
233
228
  field-type="phone"
@@ -247,7 +242,7 @@
247
242
  </pd-form-container>
248
243
  `;
249
244
  }
250
-
245
+
251
246
  _renderViewContact() {
252
247
  return html`
253
248
  <address>
@@ -263,7 +258,7 @@
263
258
  <dd>${this.contact.country}</dd>
264
259
  <dd>${this.contact.phone1}</dd>
265
260
  <dd>${this.contact.email}</dd>
266
-
261
+
267
262
  ${this.contact.btw
268
263
  ? html`<dt>BTW</dt>
269
264
  <dd>${this.contact.btw}</dd>`
@@ -279,15 +274,15 @@
279
274
  </address>
280
275
  `;
281
276
  }
282
-
277
+
283
278
  _switchAddressType(e) {
284
279
  this.business = e.detail.name === 'business';
285
280
  }
286
-
281
+
287
282
  /*
288
283
  validateInput() {
289
284
  const matchForValidate = this.match || {};
290
-
285
+
291
286
  const companyName = this.business
292
287
  ? this.shadowRoot.getElementById('compNameId').value
293
288
  : undefined;
@@ -308,9 +303,9 @@
308
303
  const city = this.shadowRoot.getElementById('cityId').value;
309
304
  const phone1 = this.shadowRoot.getElementById('phoneId').value;
310
305
  const email = this.shadowRoot.getElementById('mailId').value;
311
-
306
+
312
307
  const newErrorMap = new Map();
313
-
308
+
314
309
  const reqFieldFunc = (field, key, type, mustMatch) => {
315
310
  if (!field || field === '') {
316
311
  newErrorMap.set(
@@ -353,7 +348,7 @@
353
348
  }
354
349
  }
355
350
  };
356
-
351
+
357
352
  if (this.business) {
358
353
  reqFieldFunc(companyName, 'companyName');
359
354
  reqFieldFunc(vatNr, 'vatNr', 'vat');
@@ -368,7 +363,7 @@
368
363
  reqFieldFunc(phone1, 'phone1', 'phone');
369
364
  reqFieldFunc(email, 'email', 'mail');
370
365
  this._errorMap = newErrorMap;
371
-
366
+
372
367
  return new Promise((resolve, reject) => {
373
368
  if (newErrorMap.size > 0) {
374
369
  reject();
@@ -447,19 +442,19 @@
447
442
 
448
443
  return {...this.contact};
449
444
  }
450
-
445
+
451
446
  _getFullName() {
452
447
  return PdContact._getFullVal(this.contact.firstName, this.contact.lastName);
453
448
  }
454
-
449
+
455
450
  _getFullStreet() {
456
451
  return PdContact._getFullVal(this.contact.street, this.contact.streetNr);
457
452
  }
458
-
453
+
459
454
  _getFullLocation() {
460
455
  return PdContact._getFullVal(this.contact.zip, this.contact.city);
461
456
  }
462
-
457
+
463
458
  static _getFullVal(val1, val2, elseStr) {
464
459
  let fullVal = '';
465
460
  if (val1) {