@progressive-development/pd-forms 0.0.43 → 0.0.44
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 +1 -1
- package/src/PdBaseUiInput.js +77 -68
- package/src/PdInput.js +1 -1
- package/src/PdInputArea.js +2 -2
- package/src/PdRadioGroup.js +1 -1
- package/src/PdSelect.js +2 -2
package/package.json
CHANGED
package/src/PdBaseUiInput.js
CHANGED
|
@@ -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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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"
|
package/src/PdInputArea.js
CHANGED
|
@@ -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>
|
package/src/PdRadioGroup.js
CHANGED
|
@@ -91,7 +91,7 @@ export class PdRadioGroup extends LitElement {
|
|
|
91
91
|
|
|
92
92
|
render() {
|
|
93
93
|
return html`
|
|
94
|
-
<label>${this.label}${this.required ? this.defaultRequiredChar : ''}</label>
|
|
94
|
+
<label>${this.label}${this.required && this.label ? this.defaultRequiredChar : ''}</label>
|
|
95
95
|
<div class="group-style input ${classMap({'error': this.errorMsg.length > 0})}">
|
|
96
96
|
<slot></slot>
|
|
97
97
|
</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"
|