@progressive-development/pd-page 0.0.40 → 0.0.42

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 +4 -4
  2. package/src/PdContactUs.js +22 -55
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Progressive development page helper, teaser, menu, footer.",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "author": "PD Progressive Development",
6
- "version": "0.0.40",
6
+ "version": "0.0.42",
7
7
  "main": "index.js",
8
8
  "module": "index.js",
9
9
  "scripts": {
@@ -17,9 +17,9 @@
17
17
  "storybook:build": "npm run analyze -- --exclude dist && build-storybook"
18
18
  },
19
19
  "dependencies": {
20
- "@progressive-development/pd-contact": "0.0.15",
21
- "@progressive-development/pd-dialog": "0.0.26",
22
- "@progressive-development/pd-forms": "0.0.43",
20
+ "@progressive-development/pd-contact": "0.0.16",
21
+ "@progressive-development/pd-dialog": "0.0.28",
22
+ "@progressive-development/pd-forms": "0.0.44",
23
23
  "@progressive-development/pd-icon": "^0.0.9",
24
24
  "lit": "^2.0.2"
25
25
  },
@@ -117,22 +117,12 @@ export class PdContactUs extends LitElement {
117
117
  static get properties() {
118
118
  return {
119
119
  contact: { type: Object },
120
- _errorMap: { type: Object },
121
120
  };
122
121
  }
123
122
 
124
123
  constructor() {
125
124
  super();
126
-
127
- this.contact = {};
128
- this._errorMap = new Map();
129
- }
130
-
131
- firstUpdated() {
132
- this.addEventListener('key-pressed', e => {
133
- this._errorMap.set(e.detail.name, '');
134
- super.requestUpdate();
135
- });
125
+ this.contact = {};
136
126
  }
137
127
 
138
128
  render() {
@@ -150,14 +140,14 @@ export class PdContactUs extends LitElement {
150
140
  </div>
151
141
 
152
142
  <div class="right-content">
153
- <pd-form-container>
143
+ <pd-form-container id="contactFormId">
154
144
  <pd-form-row>
155
145
  <pd-input
156
146
  id="nameInputId"
157
147
  class="quarter3"
158
148
  placeHolder="Naam"
159
149
  valueName="name"
160
- errorMsg="${this._getErrorMsg('name')}"
150
+ required
161
151
  ></pd-input>
162
152
  </pd-form-row>
163
153
 
@@ -167,7 +157,8 @@ export class PdContactUs extends LitElement {
167
157
  class="quarter3"
168
158
  placeHolder="Email"
169
159
  valueName="mail"
170
- errorMsg="${this._getErrorMsg('mail')}"
160
+ field-type="mail"
161
+ required
171
162
  ></pd-input>
172
163
  </pd-form-row>
173
164
 
@@ -177,7 +168,8 @@ export class PdContactUs extends LitElement {
177
168
  class="quarter3"
178
169
  placeHolder="Telefoon Nummer"
179
170
  valueName="phone"
180
- errorMsg="${this._getErrorMsg('phone')}"
171
+ field-type="phone"
172
+ required
181
173
  ></pd-input>
182
174
  </pd-form-row>
183
175
 
@@ -187,8 +179,8 @@ export class PdContactUs extends LitElement {
187
179
  class="quarter3-area"
188
180
  placeHolder="Type uw bericht hier"
189
181
  rows="15"
182
+ required
190
183
  valueName="msg"
191
- errorMsg="${this._getErrorMsg('msg')}"
192
184
  ></pd-input-area>
193
185
  </pd-form-row>
194
186
  </pd-form-container>
@@ -207,33 +199,22 @@ export class PdContactUs extends LitElement {
207
199
  this.shadowRoot.getElementById('msgInputId').clear();
208
200
  }
209
201
 
210
- _sendMail() {
211
- // get inpus
212
- const name = this.shadowRoot.getElementById('nameInputId').value;
213
- const email = this.shadowRoot.getElementById('mailInputId').value;
214
- const phone = this.shadowRoot.getElementById('phoneInputId').value;
215
- const msg = this.shadowRoot.getElementById('msgInputId').value;
202
+ _sendMail() {
216
203
 
217
- const newErrorMap = new Map();
218
- if (!name || name === '') {
219
- newErrorMap.set('name', 'Verplicht veld');
220
- }
221
- if (!email || email === '') {
222
- newErrorMap.set('mail', 'Verplicht veld');
223
- } else if (!PdContactUs._mailIsValid(email)) {
224
- newErrorMap.set('mail', 'Invalid address');
225
- }
226
- if (!phone || phone === '') {
227
- newErrorMap.set('phone', 'Verplicht veld');
228
- } else if (!PdContactUs._phoneIsValid(phone)) {
229
- newErrorMap.set('phone', 'Invalid phone number');
230
- }
231
- if (!msg || msg === '') {
232
- newErrorMap.set('msg', 'Verplicht veld');
233
- }
204
+ const detail = {
205
+ errorMap: new Map()
206
+ };
234
207
 
235
- this._errorMap = newErrorMap;
236
- if (newErrorMap.size === 0) {
208
+ // current wizard element
209
+ const curentStepEl = this.shadowRoot.getElementById("contactFormId");
210
+ curentStepEl.dispatchEvent(new CustomEvent('validate-form', { detail }));
211
+
212
+ if (detail.errorMap.size === 0) {
213
+
214
+ const name = this.shadowRoot.getElementById('nameInputId').value;
215
+ const email = this.shadowRoot.getElementById('mailInputId').value;
216
+ const phone = this.shadowRoot.getElementById('phoneInputId').value;
217
+ const msg = this.shadowRoot.getElementById('msgInputId').value;
237
218
  this.dispatchEvent(
238
219
  new CustomEvent('send-contact-request', {
239
220
  detail: {
@@ -244,18 +225,4 @@ export class PdContactUs extends LitElement {
244
225
  }
245
226
  }
246
227
 
247
- _getErrorMsg(itemId) {
248
- return this._errorMap.get(itemId) || '';
249
- }
250
-
251
- static _mailIsValid(email) {
252
- const mValid = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
253
- return mValid;
254
- }
255
-
256
- static _phoneIsValid(phone) {
257
- // Valid +49 830 9001 | 49 221 123 | 08912379
258
- const mValid = /^\+?[0-9 ]{7,15}$/.test(phone);
259
- return mValid;
260
- }
261
228
  }