@progressive-development/pd-forms 0.0.59 → 0.0.60

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Webcomponent pd-forms following open-wc recommendations",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "author": "PD Progressive Development",
6
- "version": "0.0.59",
6
+ "version": "0.0.60",
7
7
  "main": "index.js",
8
8
  "module": "index.js",
9
9
  "scripts": {
@@ -25,26 +25,40 @@ export class PdFormContainer extends PdBaseUI {
25
25
  gap: 20px;
26
26
  }
27
27
  .hinweis {
28
- font-family: 'Poppins', serif;
28
+ font-family: var(--pd-font-content);
29
29
  font-size:0.95rem;
30
+
31
+ padding:10px;
32
+ color:#58585a;
33
+ border-radius: var(--squi-border-radius, 0);
34
+ -moz-border-radius: var(--squi-border-radius, 0);
35
+ width:50%;
36
+ min-width:300px;
37
+ }
38
+
39
+ .filled {
40
+ border-left:4px solid #42a01c;
41
+ border-right:4px solid #42a01c;
42
+ border-top:1px solid #42a01c;
43
+ border-bottom:1px solid #42a01c;
44
+ background-color:#f5ffe8;
45
+ }
46
+
47
+ .unfilled {
30
48
  border-left:4px solid #cc2029;
31
49
  border-right:4px solid #cc2029;
32
50
  border-top:1px solid #cc2029;
33
51
  border-bottom:1px solid #cc2029;
34
52
  background-color:#ffe8e8;
35
- padding:10px;
36
- color:#58585a;
37
- border-radius: 0.5rem;
38
- -moz-border-radius: 0.5rem;
39
- width:50%;
40
- min-width:300px;
41
53
  }
54
+
42
55
  `;
43
56
  }
44
57
 
45
58
  static get properties() {
46
59
  return {
47
60
  requiredFieldInfo: { type: Boolean},
61
+ _requiredFieldsValid: { type: Boolean, state: true},
48
62
  };
49
63
  }
50
64
 
@@ -58,7 +72,7 @@ export class PdFormContainer extends PdBaseUI {
58
72
  <form>
59
73
  <slot></slot>
60
74
  ${this.requiredFieldInfo ? html`
61
- <p class="hinweis">
75
+ <p class="hinweis ${this._requiredFieldsValid ? 'filled' : 'unfilled'}">
62
76
  ${msg('* Pflichtfeld',{desc: '#pd.form.required.info#'})}
63
77
  </p>` : ''}
64
78
  <br />
@@ -68,21 +82,26 @@ export class PdFormContainer extends PdBaseUI {
68
82
 
69
83
  _validateForm(e) {
70
84
 
71
- const reqEl = e.detail.singleElement ? [e.detail.singleElement] :
72
- this.querySelectorAll("[required]");
85
+ const reqEl = this.querySelectorAll("[required]");
73
86
 
74
87
  // validate required fields TODO: Auf PdInputxxx beschränken
75
88
  reqEl.forEach(el => {
76
89
  const tmpEl = el;
77
- if (!el.value || el.value === "") {
78
- tmpEl.errorMsg = el.requiredMsg ||
79
- msg('Eingabe erforderlich',{desc: '#pd.form.field.required#'});
80
- e.detail.errorMap.set(el.id, tmpEl.errorMsg);
90
+ if (!el.value || el.value === "") {
91
+ const erMsg = el.requiredMsg || msg('Eingabe erforderlich',{desc: '#pd.form.field.required#'});
92
+ if (!e.detail.singleElement || e.detail.singleElement === el) {
93
+ tmpEl.errorMsg = erMsg;
94
+ }
95
+ e.detail.errorMap.set(el.id, erMsg);
81
96
  } else {
82
- tmpEl.errorMsg = "";
97
+ if (!e.detail.singleElement || e.detail.singleElement === el) {
98
+ tmpEl.errorMsg = "";
99
+ }
83
100
  }
84
101
  })
85
102
 
103
+ this._requiredFieldsValid = e.detail.errorMap.size === 0;
104
+
86
105
  // general validate method
87
106
  const validateByType = (fieldType, validFunc, invalidMsgTxt) => {
88
107
 
package/src/PdInput.js CHANGED
@@ -175,7 +175,7 @@ export class PdInput extends PdBaseUIInput {
175
175
 
176
176
  Nachtrag: Nun auf interne propertie umgestellt, im Test...
177
177
  */
178
- if (this.errorMsg.length > 0) {
178
+ // if (this.errorMsg.length > 0) {
179
179
  this.dispatchEvent(
180
180
  new CustomEvent('validate-form', {
181
181
  detail: {
@@ -186,7 +186,7 @@ export class PdInput extends PdBaseUIInput {
186
186
  bubbles: true,
187
187
  })
188
188
  );
189
- }
189
+ // }
190
190
 
191
191
  this.dispatchEvent(
192
192
  new CustomEvent('key-pressed', {
@@ -156,7 +156,17 @@ export class PdInputArea extends PdBaseUIInput {
156
156
  event.preventDefault();
157
157
  } else {
158
158
  // If any other key, fire 'key-pressed'
159
- this.errorMsg = '';
159
+ this.dispatchEvent(
160
+ new CustomEvent('validate-form', {
161
+ detail: {
162
+ singleElement: this,
163
+ errorMap: new Map()
164
+ },
165
+ composed: true,
166
+ bubbles: true,
167
+ })
168
+ );
169
+
160
170
  this.dispatchEvent(new CustomEvent('key-pressed', {
161
171
  detail: {
162
172
  value: this._input.value,
@@ -76,7 +76,18 @@ export class PdRadioGroup extends LitElement {
76
76
  elCollection[keyValue].value = false;
77
77
  }
78
78
  elCollection[keyValue].readonly = (elCollection[keyValue].value === 'true');
79
- this.errorMsg = '';
79
+
80
+ this.dispatchEvent(
81
+ new CustomEvent('validate-form', {
82
+ detail: {
83
+ singleElement: this,
84
+ errorMap: new Map()
85
+ },
86
+ composed: true,
87
+ bubbles: true,
88
+ })
89
+ );
90
+
80
91
  });
81
92
  });
82
93
 
package/src/PdSelect.js CHANGED
@@ -278,7 +278,18 @@ export class PdSelect extends PdBaseUIInput {
278
278
 
279
279
  _onChange() {
280
280
  this.value = this._input.value;
281
- this.errorMsg = '';
281
+
282
+ this.dispatchEvent(
283
+ new CustomEvent('validate-form', {
284
+ detail: {
285
+ singleElement: this,
286
+ errorMap: new Map()
287
+ },
288
+ composed: true,
289
+ bubbles: true,
290
+ })
291
+ );
292
+
282
293
  this.dispatchEvent(
283
294
  new CustomEvent('change-value', {
284
295
  detail: {