@progressive-development/pd-contact 0.1.54 → 0.1.55

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 +23 -13
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.54",
6
+ "version": "0.1.55",
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.2.7",
20
+ "@progressive-development/pd-forms": "^0.2.8",
21
21
  "@progressive-development/pd-shared-styles": "^0.1.1",
22
22
  "lit": "^2.2.0"
23
23
  },
package/src/PdContact.js CHANGED
@@ -60,16 +60,21 @@
60
60
 
61
61
  static get properties() {
62
62
  return {
63
+
63
64
  addressTitle: { type: String },
64
65
  addressRef: { type: String },
65
66
  /**
66
- * address type, business (true) or private (false)
67
+ * address type, business (true) or private (false), refactor, ist state internal? => _business, state:true
67
68
  */
68
69
  business: { type: Boolean },
69
70
  /**
70
71
  * summary (true) or view (false) contact data
71
72
  */
72
73
  summary: { type: Boolean },
74
+ /**
75
+ * List with required contact fields, if not set use default (previous existing values to be consitent during update)
76
+ */
77
+ requiredFields: { type: Array },
73
78
  contact: { type: Object },
74
79
  match: { type: Object },
75
80
  _errorMap: { type: Object },
@@ -78,7 +83,8 @@
78
83
 
79
84
  constructor() {
80
85
  super();
81
- this.addressTitle = 'Adres';
86
+ this.addressTitle = 'Adres';
87
+ this.requiredFields = [];
82
88
  this.summary = false;
83
89
  this.business = false;
84
90
  this.match = {};
@@ -148,7 +154,7 @@
148
154
  id="compNameId"
149
155
  class="quarter2"
150
156
  label="Naam onderneming"
151
- required
157
+ ?required="${this._isRequired("companyName")}"
152
158
  valueName="companyName"
153
159
  autoCompleteName="organization"
154
160
  ></pd-input>
@@ -156,7 +162,7 @@
156
162
  id="vatId"
157
163
  class="quarter2"
158
164
  label="Ondernemingsnr"
159
- required
165
+ ?required="${this._isRequired("vatNr")}"
160
166
  field-type="vat"
161
167
  valueName="vatNr"
162
168
  autoCompleteName="vat"
@@ -172,7 +178,7 @@
172
178
  valueName="firstName"
173
179
  value="${this.contact ? this.contact.firstName : ""}"
174
180
  autoCompleteName="given-name"
175
- required
181
+ ?required="${this._isRequired("firstName")}"
176
182
  ></pd-input>
177
183
  <pd-input
178
184
  id="lastNameId"
@@ -181,7 +187,7 @@
181
187
  valueName="lastName"
182
188
  value="${this.contact ? this.contact.lastName : ""}"
183
189
  autoCompleteName="family-name"
184
- required
190
+ ?required="${this._isRequired("lastName")}"
185
191
  ></pd-input>
186
192
  </pd-form-row>
187
193
  `}
@@ -193,7 +199,7 @@
193
199
  valueName="street"
194
200
  value="${this.contact ? this.contact.street : ""}"
195
201
  autoCompleteName="street-address"
196
- required
202
+ ?required="${this._isRequired("street")}"
197
203
  ></pd-input>
198
204
  <pd-input
199
205
  id="streetNrId"
@@ -201,7 +207,7 @@
201
207
  label="Nr"
202
208
  valueName="streetNr"
203
209
  value="${this.contact ? this.contact.streetNr : ""}"
204
- required
210
+ ?required="${this._isRequired("streetNr")}"
205
211
  ></pd-input>
206
212
  </pd-form-row>
207
213
  <pd-form-row class="contact-form">
@@ -222,7 +228,6 @@
222
228
  label="Postcode"
223
229
  valueName="zip"
224
230
  value="${this.match ? this.match.zip || '' : ''}"
225
- required
226
231
  ></pd-input>
227
232
  `
228
233
  : html`
@@ -234,7 +239,7 @@
234
239
  valueName="zip"
235
240
  value="${this.contact ? this.contact.zip : ""}"
236
241
  autoCompleteName="postal-code"
237
- required
242
+ ?required="${this._isRequired("zip")}"
238
243
  ></pd-input>
239
244
  `}
240
245
  <pd-input
@@ -244,7 +249,7 @@
244
249
  valueName="city"
245
250
  value="${this.contact ? this.contact.city : ""}"
246
251
  autoCompleteName="locality"
247
- required
252
+ ?required="${this._isRequired("city")}"
248
253
  ></pd-input>
249
254
  </pd-form-row>
250
255
  <pd-form-row class="contact-form">
@@ -257,7 +262,7 @@
257
262
  value="${this.contact ? this.contact.phone1 : ""}"
258
263
  field-type="phone"
259
264
  autoCompleteName="tel"
260
- required
265
+ ?required="${this._isRequired("phone1")}"
261
266
  ></pd-input>
262
267
  <pd-input
263
268
  id="mailId"
@@ -267,7 +272,7 @@
267
272
  valueName="email"
268
273
  value="${this.contact ? this.contact.email : ""}"
269
274
  autoCompleteName="email"
270
- required
275
+ ?required="${this._isRequired("email")}"
271
276
  ></pd-input>
272
277
  </pd-form-row>
273
278
  </pd-form-container>
@@ -317,6 +322,11 @@
317
322
  this.business = e.detail.name === 'business';
318
323
  }
319
324
 
325
+ _isRequired(field) {
326
+ return this.requiredFields && this.requiredFields.length > 0 ?
327
+ this.requiredFields.includes(field) : false;
328
+ }
329
+
320
330
  /*
321
331
  validateInput() {
322
332
  const matchForValidate = this.match || {};