@progressive-development/pd-forms 0.0.43 → 0.0.45

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.43",
6
+ "version": "0.0.45",
7
7
  "main": "index.js",
8
8
  "module": "index.js",
9
9
  "scripts": {
@@ -3,72 +3,81 @@
3
3
  * Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
4
4
  */
5
5
 
6
- import { PdBaseUI } from './PdBaseUi.js';
6
+ import { PdBaseUI } from './PdBaseUi.js';
7
7
 
8
- export const INPUT_TYPE_TEXT = 1;
9
- export const INPUT_TYPE_SELECT = 2;
10
- export const INPUT_TYPE_CHECK = 3;
11
- export const INPUT_TYPE_RANGE = 4;
12
- export const INPUT_TYPE_AREA = 5;
13
-
14
- export class PdBaseUIInput extends PdBaseUI {
15
-
16
- static get properties() {
17
- return {
18
- gradient: { type: Boolean }, // true for gradient background
19
- disabled: { type: Boolean }, // disabled flag for element
20
- readonly: { type: Boolean }, // readonly flag for element
21
- required: { type: Boolean }, // required flag for element
22
- requiredMsg: { type: String }, // specific error msg for required field
23
- valueName: { type: String },
24
- defaultRequiredChar: { type: String },
25
- defaultValue: { type: String }, // default value for input element (used for reset) TODO: Das hier ggf. automatisch mit erstem gesetzten Wert füllen?
26
- label: { type: String }, // label text for input
27
- value: {type: String}, // current value (set from outside) TODO: Typ (Object, Number, Txt, Bool...)
28
- errorMsg: {type: String}, // errorMsg (could set fronm outside for busines validation, internal validation=> todo)
29
- _inputType: {type: Number}, // number value for type (text, select, range....), set constructor of sub-class
30
- _input: { type: Object } // reference for input html element
31
- };
32
- }
33
-
34
- constructor() {
35
- super();
36
- this.gradient = false;
37
- this.disabled = false;
38
- this.readonly = false;
39
- this.defaultValue = '';
40
- this.label = '';
41
- this.value = '';
42
- this.errorMsg = '';
43
- this._inputType = -1;
44
- this._input = {};
45
- this.valueName = '';
46
-
47
- this.defaultRequiredChar = '*';
48
- }
49
-
50
- // Test: Clear input with value => Dann in BasisKlasse und alle leiten von Basis UI Element ab
51
- clear() {
52
- this.value = '';
53
- this._input.value = this.value;
54
- }
55
-
56
- // Test: Reset input with value
57
- reset() {
58
- this.value = this.defaultValue || '';
59
- this._input.value = this.value;
60
- }
61
-
62
- /*
63
- get value() {
64
- return this._value;
65
- }
66
-
67
- set value(newValue) {
68
- console.info("Meine Werte vor Set _value, input.value, newValue: ", this._value, this._input.value, newValue);
69
- this._value = newValue;
70
- this._input.value = newValue;
71
- console.info("Meine Werte nach Set: ", this._value, this._input.value, newValue);
72
- }
73
- */
74
- }
8
+ export const INPUT_TYPE_TEXT = 1;
9
+ export const INPUT_TYPE_SELECT = 2;
10
+ export const INPUT_TYPE_CHECK = 3;
11
+ export const INPUT_TYPE_RANGE = 4;
12
+ export const INPUT_TYPE_AREA = 5;
13
+
14
+ export class PdBaseUIInput extends PdBaseUI {
15
+
16
+ static get properties() {
17
+ return {
18
+ gradient: { type: Boolean }, // true for gradient background
19
+ disabled: { type: Boolean }, // disabled flag for element
20
+ readonly: { type: Boolean }, // readonly flag for element
21
+ required: { type: Boolean }, // required flag for element
22
+ requiredMsg: { type: String }, // specific error msg for required field
23
+ valueName: { type: String },
24
+ defaultRequiredChar: { type: String },
25
+ defaultValue: { type: String }, // default value for input element (used for reset) TODO: Das hier ggf. automatisch mit erstem gesetzten Wert füllen?
26
+ label: { type: String }, // label text for input
27
+ value: {type: String}, // current value (set from outside) TODO: Typ (Object, Number, Txt, Bool...)
28
+ _errorMsg: {type: String, state: true}, // errorMsg (could set fronm outside for busines validation, internal validation=> todo)
29
+ _inputType: {type: Number}, // number value for type (text, select, range....), set constructor of sub-class
30
+ _input: { type: Object } // reference for input html element
31
+ };
32
+ }
33
+
34
+ constructor() {
35
+ super();
36
+ this.gradient = false;
37
+ this.disabled = false;
38
+ this.readonly = false;
39
+ this.defaultValue = '';
40
+ this.label = '';
41
+ this.value = '';
42
+ this._errorMsg = '';
43
+ this._inputType = -1;
44
+ this._input = {};
45
+ this.valueName = '';
46
+
47
+ this.defaultRequiredChar = '*';
48
+ }
49
+
50
+ // Test: Clear input with value => Dann in BasisKlasse und alle leiten von Basis UI Element ab
51
+ clear() {
52
+ this.value = '';
53
+ this._input.value = this.value;
54
+ }
55
+
56
+ // Test: Reset input with value
57
+ reset() {
58
+ this.value = this.defaultValue || '';
59
+ this._input.value = this.value;
60
+ }
61
+
62
+ get errorMsg() {
63
+ return this._errorMsg;
64
+ }
65
+
66
+ set errorMsg(msg) {
67
+ this._errorMsg = msg;
68
+ }
69
+
70
+ /*
71
+ get value() {
72
+ return this._value;
73
+ }
74
+
75
+ set value(newValue) {
76
+ console.info("Meine Werte vor Set _value, input.value, newValue: ", this._value, this._input.value, newValue);
77
+ this._value = newValue;
78
+ this._input.value = newValue;
79
+ console.info("Meine Werte nach Set: ", this._value, this._input.value, newValue);
80
+ }
81
+ */
82
+ }
83
+
package/src/PdInput.js CHANGED
@@ -108,7 +108,7 @@ export class PdInput extends PdBaseUIInput {
108
108
 
109
109
  render() {
110
110
  return html`
111
- <label for="${this.id}Input">${this.label}${this.required ? this.defaultRequiredChar : ''}</label>
111
+ <label for="${this.id}Input">${this.label}${this.required && this.label ? this.defaultRequiredChar : ''}</label>
112
112
  <div class="input ${classMap({ error: this.errorMsg.length > 0 })}">
113
113
  <pd-icon
114
114
  icon="toggleCollapse"
@@ -171,7 +171,11 @@ export class PdInput extends PdBaseUIInput {
171
171
  }
172
172
 
173
173
  Aufrund der gennanten Problematik auskommentiert, ein evenlistener sorgt nun dafür
174
+
175
+ Nachtrag: Nun auf interne propertie umgestellt, im Test...
174
176
  */
177
+ this._errorMsg = '';
178
+
175
179
  this.dispatchEvent(
176
180
  new CustomEvent('key-pressed', {
177
181
  detail: {
@@ -111,10 +111,10 @@ export class PdInputArea extends PdBaseUIInput {
111
111
  this.rows = 2;
112
112
  this.value = '';
113
113
  }
114
-
114
+
115
115
  render() {
116
116
  return html`
117
- <label for="${this.id}InputArea">${this.label}</label>
117
+ <label for="${this.id}InputArea">${this.label}${this.required && this.label ? this.defaultRequiredChar : ''}</label>
118
118
  <div class="input ${classMap({'error': this.errorMsg.length > 0})}">
119
119
  <pd-icon icon="toggleCollapse"
120
120
  @click="${this._onIconClick}"></pd-icon>
@@ -156,7 +156,7 @@ export class PdInputArea extends PdBaseUIInput {
156
156
  event.preventDefault();
157
157
  } else {
158
158
  // If any other key, fire 'key-pressed'
159
- // this.errorMsg = ''; change with handler now...
159
+ this._errorMsg = '';
160
160
  this.dispatchEvent(new CustomEvent('key-pressed', {
161
161
  detail: {
162
162
  value: this._input.value,
@@ -75,9 +75,8 @@ export class PdRadioGroup extends LitElement {
75
75
  if (elCollection[keyValue] !== e.target) {
76
76
  elCollection[keyValue].value = false;
77
77
  }
78
- elCollection[keyValue].readonly = (elCollection[keyValue].value === 'true');
79
- // do with event handler, change from outside...
80
- // this.errorMsg = '';
78
+ elCollection[keyValue].readonly = (elCollection[keyValue].value === 'true');
79
+ this._errorMsg = '';
81
80
  });
82
81
  });
83
82
 
@@ -91,7 +90,7 @@ export class PdRadioGroup extends LitElement {
91
90
 
92
91
  render() {
93
92
  return html`
94
- <label>${this.label}${this.required ? this.defaultRequiredChar : ''}</label>
93
+ <label>${this.label}${this.required && this.label ? this.defaultRequiredChar : ''}</label>
95
94
  <div class="group-style input ${classMap({'error': this.errorMsg.length > 0})}">
96
95
  <slot></slot>
97
96
  </div>
package/src/PdSelect.js CHANGED
@@ -199,8 +199,8 @@ export class PdSelect extends PdBaseUIInput {
199
199
  }
200
200
 
201
201
  render() {
202
- return html`
203
- <label for="${this.id}Select">${this.label}${this.required ? this.defaultRequiredChar : ''}</label>
202
+ return html`
203
+ <label for="${this.id}Select">${this.label}${this.required && this.label ? this.defaultRequiredChar : ''}</label>
204
204
  <div class="input ${classMap({ error: this.errorMsg.length > 0 })}">
205
205
  <pd-icon
206
206
  icon="toggleCollapse"
@@ -274,7 +274,7 @@ export class PdSelect extends PdBaseUIInput {
274
274
 
275
275
  _onChange() {
276
276
  this.value = this._input.value;
277
- // this.errorMsg = ''; do not change public attribute inside component => progress, handle with event handler at the moment
277
+ this._errorMsg = '';
278
278
  this.dispatchEvent(
279
279
  new CustomEvent('change-value', {
280
280
  detail: {