@progressive-development/pd-forms 0.0.59 → 0.0.61
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 +2 -2
- package/src/PdBaseInputElement.js +95 -0
- package/src/PdBaseUi.js +23 -4
- package/src/PdBaseUiInput.js +137 -6
- package/src/PdButton.js +78 -75
- package/src/PdCheckbox.js +175 -212
- package/src/PdFormContainer.js +56 -30
- package/src/PdFormRow.js +19 -16
- package/src/PdInput.js +41 -137
- package/src/PdInputArea.js +37 -124
- package/src/PdRadioGroup.js +32 -54
- package/src/PdRange.js +0 -2
- package/src/PdSelect.js +36 -179
- package/src/shared-global-styles.js +38 -0
- package/src/shared-input-field-styles.js +147 -0
- package/src/shared-input-styles.js +28 -191
- package/stories/01_index.stories.js +25 -69
- package/stories/checkbox.stories.js +40 -5
- package/stories/form-container.stories.js +18 -4
- package/stories/input.stories.js +23 -15
- package/stories/radio-group.stories.js +30 -21
- package/stories/select.stories.js +34 -22
- package/pd-button-goup.js +0 -3
- package/pd-label-value.js +0 -3
- package/src/PdButtonGroup.js +0 -54
- package/src/PdLabelValue.js +0 -75
- package/stories/label-value.stories.js +0 -32
package/src/PdInput.js
CHANGED
|
@@ -4,12 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { html, css } from 'lit';
|
|
7
|
-
import
|
|
8
|
-
import { SharedInputStyles } from './shared-input-styles.js';
|
|
7
|
+
import '@progressive-development/pd-icon/pd-icon.js';
|
|
9
8
|
|
|
10
|
-
import {
|
|
9
|
+
import { INPUT_TYPE_TEXT } from './PdBaseUiInput.js';
|
|
10
|
+
import { PdBaseInputElement } from './PdBaseInputElement.js';
|
|
11
11
|
|
|
12
|
-
import '@progressive-development/pd-icon/pd-icon.js';
|
|
13
12
|
|
|
14
13
|
// https://github.com/Victor-Bernabe/lit-input
|
|
15
14
|
// https://levelup.gitconnected.com/build-a-material-like-input-web-component-using-litelement-20e9e0d203b6
|
|
@@ -24,7 +23,7 @@ import '@progressive-development/pd-icon/pd-icon.js';
|
|
|
24
23
|
*
|
|
25
24
|
* Custom property | Description | Default
|
|
26
25
|
* ----------------|-------------|--------
|
|
27
|
-
* `--
|
|
26
|
+
* `--pd-input-field-width` | Width | `250px`
|
|
28
27
|
* `--my-input-height` | Height | `30px`
|
|
29
28
|
* `--squi-input-border` | Border | `1px solid black`
|
|
30
29
|
* `--squi-input-border-focus` | Border when focused | `1px solid #4d90fe`
|
|
@@ -49,30 +48,11 @@ import '@progressive-development/pd-icon/pd-icon.js';
|
|
|
49
48
|
* <pd-input text-right></pd-input>
|
|
50
49
|
* <pd-input text-left></pd-input>
|
|
51
50
|
*/
|
|
52
|
-
export class PdInput extends
|
|
53
|
-
/**
|
|
54
|
-
* Fired when `pd-input` has focus and the user press `Enter` key.
|
|
55
|
-
* @event enter-pressed
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Fired when `pd-input` has focus and the user press any key except `Enter`.
|
|
60
|
-
* @event key-pressed
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Fire when the `pd-input` loses focus.
|
|
65
|
-
* @event focus-lost
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Fire when the icon inside `pd-input` is clicked.
|
|
70
|
-
* @event icon-clicked
|
|
71
|
-
*/
|
|
51
|
+
export class PdInput extends PdBaseInputElement {
|
|
72
52
|
|
|
73
53
|
static get styles() {
|
|
74
54
|
return [
|
|
75
|
-
|
|
55
|
+
PdBaseInputElement.styles,
|
|
76
56
|
css`
|
|
77
57
|
* {
|
|
78
58
|
box-sizing: border-box;
|
|
@@ -82,11 +62,7 @@ export class PdInput extends PdBaseUIInput {
|
|
|
82
62
|
}
|
|
83
63
|
|
|
84
64
|
static get properties() {
|
|
85
|
-
return {
|
|
86
|
-
key: { type: String }, // Test, wird für das setzten der Error Msg benötigt
|
|
87
|
-
|
|
88
|
-
/** Placeholder for `pd-input` initial text. */
|
|
89
|
-
placeHolder: { type: String },
|
|
65
|
+
return {
|
|
90
66
|
/**
|
|
91
67
|
* Icon to be shown inside `pd-input`.
|
|
92
68
|
*/
|
|
@@ -100,128 +76,56 @@ export class PdInput extends PdBaseUIInput {
|
|
|
100
76
|
constructor() {
|
|
101
77
|
super();
|
|
102
78
|
this._inputType = INPUT_TYPE_TEXT;
|
|
103
|
-
this.placeHolder = '';
|
|
104
|
-
this.icon = 'toggleCollapse';
|
|
105
|
-
this.secret = false;
|
|
106
|
-
this.key = '';
|
|
107
79
|
}
|
|
108
80
|
|
|
109
81
|
render() {
|
|
82
|
+
const inputId = `${this.id}Input`;
|
|
110
83
|
return html`
|
|
111
|
-
|
|
112
|
-
<div class="input ${
|
|
113
|
-
<pd-icon
|
|
114
|
-
icon="toggleCollapse"
|
|
115
|
-
@click="${this._onIconClick}"
|
|
116
|
-
></pd-icon>
|
|
84
|
+
${this._renderLabel(inputId)}
|
|
85
|
+
<div class="input ${this.errorMsg.length > 0 ? 'error' : ''}">
|
|
117
86
|
<input
|
|
118
|
-
id="${
|
|
87
|
+
id="${inputId}"
|
|
88
|
+
name="${this.autoCompleteName}"
|
|
89
|
+
autocomplete=${this.autoCompleteName}
|
|
119
90
|
class="input-style ${this.gradient ? 'gradient' : ''}"
|
|
120
91
|
type="${this.secret ? 'password' : 'text'}"
|
|
121
|
-
placeholder="${this.
|
|
122
|
-
.value="${this.value}"
|
|
123
|
-
?readonly="${this.readonly}"
|
|
92
|
+
placeholder="${this.placeHolder}"
|
|
93
|
+
.value="${this.value}"
|
|
124
94
|
minlength="${this.minlength}"
|
|
125
95
|
maxlength="${this.maxlength}"
|
|
96
|
+
?readonly="${this.readonly}"
|
|
126
97
|
?disabled="${this.disabled}"
|
|
127
98
|
@keyup="${this._onKeyUp}"
|
|
128
99
|
@blur="${this._onBlur}"
|
|
100
|
+
|
|
129
101
|
/>
|
|
130
|
-
<!-- Sollte erst Clientseitig im Input validiert werden. Meldung verschwindet erst beim Submit nicht mehr zeitgemäß-->
|
|
131
|
-
${this.errorMsg.length > 0
|
|
132
|
-
? html`<span class="error-msg">${this.errorMsg}</span>`
|
|
133
|
-
: ''}
|
|
134
102
|
</div>
|
|
103
|
+
${this._renderErrorMsg()}
|
|
135
104
|
`;
|
|
136
105
|
}
|
|
137
106
|
|
|
138
|
-
|
|
139
|
-
// Save input reference for performance (bind html element to class property)
|
|
140
|
-
this._input = this.shadowRoot.querySelector('input');
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
_onKeyUp(event) {
|
|
144
|
-
// set value (tbd überdenken)
|
|
145
|
-
this.value = this._input.value;
|
|
146
|
-
|
|
147
|
-
// If Enter key pressed, fire 'enter-pressed'
|
|
148
|
-
const eventKeyCodeNumber = Number(event.keyCode);
|
|
149
|
-
if (eventKeyCodeNumber === 13) {
|
|
150
|
-
this.dispatchEvent(
|
|
151
|
-
new CustomEvent('enter-pressed', {
|
|
152
|
-
detail: {
|
|
153
|
-
value: this._input.value,
|
|
154
|
-
},
|
|
155
|
-
composed: true,
|
|
156
|
-
bubbles: true,
|
|
157
|
-
})
|
|
158
|
-
);
|
|
159
|
-
event.preventDefault();
|
|
160
|
-
} else if (eventKeyCodeNumber !== 9) {
|
|
161
|
-
// If any other key, fire 'key-pressed'
|
|
162
|
-
|
|
163
|
-
// Interessante Stelle, die error msg wird von außen gesetzt
|
|
164
|
-
// wenn die error msg hier gesetzt wird, danach nicht mehr für änderungen von außen für den gleichen typ gültig
|
|
165
|
-
// da der wert außen nicht verändert wurde, und daher nicht neu gesetzt wird...
|
|
166
|
-
// => Die eigentliche NAchricht ist nochgesetzt...
|
|
167
|
-
// Hack bevor das Thema richtig nachgezogen wird (recherche), es wird nicht für felder von bestimmten typ durchgeführt
|
|
168
|
-
// d.h. für zip und mail nicht
|
|
169
|
-
/*
|
|
170
|
-
if (this.key != 'mail' && this.key != 'zip' && this.key != 'phone') {
|
|
171
|
-
this.errorMsg = '';
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
Aufrund der gennanten Problematik auskommentiert, ein evenlistener sorgt nun dafür
|
|
175
|
-
|
|
176
|
-
Nachtrag: Nun auf interne propertie umgestellt, im Test...
|
|
177
|
-
*/
|
|
178
|
-
if (this.errorMsg.length > 0) {
|
|
179
|
-
this.dispatchEvent(
|
|
180
|
-
new CustomEvent('validate-form', {
|
|
181
|
-
detail: {
|
|
182
|
-
singleElement: this,
|
|
183
|
-
errorMap: new Map()
|
|
184
|
-
},
|
|
185
|
-
composed: true,
|
|
186
|
-
bubbles: true,
|
|
187
|
-
})
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
this.dispatchEvent(
|
|
192
|
-
new CustomEvent('key-pressed', {
|
|
193
|
-
detail: {
|
|
194
|
-
value: this._input.value,
|
|
195
|
-
name: this.valueName,
|
|
196
|
-
},
|
|
197
|
-
composed: true,
|
|
198
|
-
bubbles: true,
|
|
199
|
-
})
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
107
|
+
}
|
|
203
108
|
|
|
204
|
-
_onBlur() {
|
|
205
|
-
this.dispatchEvent(
|
|
206
|
-
new CustomEvent('focus-lost', {
|
|
207
|
-
detail: {
|
|
208
|
-
value: this._input.value,
|
|
209
|
-
},
|
|
210
|
-
composed: true,
|
|
211
|
-
bubbles: true,
|
|
212
|
-
})
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
109
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
)
|
|
226
|
-
|
|
227
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Aus Historien Doku noch stehen gelassen... => Dokumentieren und entfernen
|
|
112
|
+
*
|
|
113
|
+
// If any other key, fire 'key-pressed'
|
|
114
|
+
|
|
115
|
+
// Interessante Stelle, die error msg wird von außen gesetzt
|
|
116
|
+
// wenn die error msg hier gesetzt wird, danach nicht mehr für änderungen von außen für den gleichen typ gültig
|
|
117
|
+
// da der wert außen nicht verändert wurde, und daher nicht neu gesetzt wird...
|
|
118
|
+
// => Die eigentliche NAchricht ist nochgesetzt...
|
|
119
|
+
// Hack bevor das Thema richtig nachgezogen wird (recherche), es wird nicht für felder von bestimmten typ durchgeführt
|
|
120
|
+
// d.h. für zip und mail nicht
|
|
121
|
+
/*
|
|
122
|
+
if (this.key != 'mail' && this.key != 'zip' && this.key != 'phone') {
|
|
123
|
+
this.errorMsg = '';
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
Aufrund der gennanten Problematik auskommentiert, ein evenlistener sorgt nun dafür
|
|
127
|
+
|
|
128
|
+
Nachtrag: Nun auf interne propertie umgestellt, im Test...
|
|
129
|
+
*/
|
|
130
|
+
// if (this.errorMsg.length > 0) {
|
|
131
|
+
// }
|
package/src/PdInputArea.js
CHANGED
|
@@ -4,14 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { html, css } from 'lit';
|
|
7
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
8
|
-
import { SharedInputStyles } from './shared-input-styles.js';
|
|
9
|
-
|
|
10
|
-
import { PdBaseUIInput, INPUT_TYPE_AREA } from './PdBaseUiInput.js';
|
|
11
|
-
|
|
12
|
-
|
|
13
7
|
import '@progressive-development/pd-icon/pd-icon.js';
|
|
14
8
|
|
|
9
|
+
import { INPUT_TYPE_AREA } from './PdBaseUiInput.js';
|
|
10
|
+
import { PdBaseInputElement } from './PdBaseInputElement.js';
|
|
11
|
+
|
|
15
12
|
// https://github.com/Victor-Bernabe/lit-input
|
|
16
13
|
// https://levelup.gitconnected.com/build-a-material-like-input-web-component-using-litelement-20e9e0d203b6
|
|
17
14
|
/**
|
|
@@ -25,7 +22,7 @@ import '@progressive-development/pd-icon/pd-icon.js';
|
|
|
25
22
|
*
|
|
26
23
|
* Custom property | Description | Default
|
|
27
24
|
* ----------------|-------------|--------
|
|
28
|
-
* `--
|
|
25
|
+
* `--pd-input-field-width` | Width | `250px`
|
|
29
26
|
* `--my-input-height` | Height | `30px`
|
|
30
27
|
* `--squi-input-border` | Border | `1px solid black`
|
|
31
28
|
* `--squi-input-border-focus` | Border when focused | `1px solid #4d90fe`
|
|
@@ -50,141 +47,57 @@ import '@progressive-development/pd-icon/pd-icon.js';
|
|
|
50
47
|
* <pd-input text-right></pd-input>
|
|
51
48
|
* <pd-input text-left></pd-input>
|
|
52
49
|
*/
|
|
53
|
-
export class PdInputArea extends
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Fired when `pd-input-area` has focus and the user press `Enter` key.
|
|
57
|
-
* @event enter-pressed
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Fired when `pd-input-area` has focus and the user press any key except `Enter`.
|
|
62
|
-
* @event key-pressed
|
|
63
|
-
*/
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Fire when the `pd-input-area` loses focus.
|
|
67
|
-
* @event focus-lost
|
|
68
|
-
*/
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Fire when the icon inside `pd-input-area` is clicked.
|
|
72
|
-
* @event icon-clicked
|
|
73
|
-
*/
|
|
50
|
+
export class PdInputArea extends PdBaseInputElement {
|
|
74
51
|
|
|
75
52
|
static get styles() {
|
|
76
|
-
return [
|
|
77
|
-
|
|
78
|
-
css`
|
|
79
|
-
/*
|
|
53
|
+
return [
|
|
54
|
+
PdBaseInputElement.styles,
|
|
55
|
+
css`
|
|
56
|
+
/* overwrite default (250px), area contains 10px scroll bar */
|
|
80
57
|
.input-style {
|
|
81
|
-
|
|
58
|
+
width: var(--pd-input-field-width, 240px);
|
|
82
59
|
}
|
|
83
|
-
|
|
84
|
-
|
|
60
|
+
`,
|
|
61
|
+
];
|
|
85
62
|
}
|
|
86
63
|
|
|
87
64
|
static get properties() {
|
|
88
65
|
return {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
*/
|
|
94
|
-
icon: { type: String },
|
|
95
|
-
name: { type: String },
|
|
96
|
-
rows: { type: Number },
|
|
97
|
-
cols: { type: Number },
|
|
98
|
-
minlength: { type: String },
|
|
99
|
-
maxlength: { type: String } // max length for field
|
|
66
|
+
rows: { type: Number },
|
|
67
|
+
cols: { type: Number },
|
|
68
|
+
minlength: { type: String },
|
|
69
|
+
maxlength: { type: String }, // max length for field
|
|
100
70
|
};
|
|
101
71
|
}
|
|
102
72
|
|
|
103
73
|
constructor() {
|
|
104
74
|
super();
|
|
105
75
|
this._inputType = INPUT_TYPE_AREA;
|
|
106
|
-
this.
|
|
107
|
-
this.
|
|
108
|
-
|
|
109
|
-
this.maxlength = 500;
|
|
110
|
-
this.name = '';
|
|
111
|
-
this.rows = 2;
|
|
112
|
-
this.value = '';
|
|
76
|
+
this.maxlength = 500;
|
|
77
|
+
this.rows = 2;
|
|
113
78
|
}
|
|
114
79
|
|
|
115
80
|
render() {
|
|
81
|
+
const inputAreaId = `${this.id}InputArea`;
|
|
116
82
|
return html`
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
83
|
+
${this._renderLabel(inputAreaId)}
|
|
84
|
+
<div class="input ${this.errorMsg.length > 0 ? 'error' : ''}">
|
|
85
|
+
<textarea
|
|
86
|
+
id="${inputAreaId}"
|
|
87
|
+
name="${this.autoCompleteName}"
|
|
88
|
+
autocomplete=${this.autoCompleteName}
|
|
89
|
+
class="input-style ${this.gradient ? 'gradient' : ''}"
|
|
90
|
+
rows="${this.rows}"
|
|
91
|
+
cols="${this.cols}"
|
|
92
|
+
placeholder="${this.placeHolder}"
|
|
93
|
+
?disabled="${this.disabled}"
|
|
94
|
+
?readonly="${this.readonly}"
|
|
95
|
+
@keyup="${this._onKeyUp}"
|
|
96
|
+
@blur="${this._onBlur}"
|
|
97
|
+
>${this.value}</textarea>
|
|
98
|
+
</div>
|
|
99
|
+
${this._renderErrorMsg()}
|
|
134
100
|
`;
|
|
135
101
|
}
|
|
136
102
|
|
|
137
|
-
|
|
138
|
-
// Save input reference for performance (bind html element to class property)
|
|
139
|
-
this._input = this.shadowRoot.querySelector('textarea');
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
_onKeyUp(event) {
|
|
143
|
-
|
|
144
|
-
// set value (tbd überdenken)
|
|
145
|
-
this.value = this._input.value;
|
|
146
|
-
|
|
147
|
-
// If Enter key pressed, fire 'enter-pressed'
|
|
148
|
-
if(event.keyCode === 13) {
|
|
149
|
-
this.dispatchEvent(new CustomEvent('enter-pressed', {
|
|
150
|
-
detail: {
|
|
151
|
-
value: this._input.value
|
|
152
|
-
},
|
|
153
|
-
composed: true,
|
|
154
|
-
bubbles: true
|
|
155
|
-
}));
|
|
156
|
-
event.preventDefault();
|
|
157
|
-
} else {
|
|
158
|
-
// If any other key, fire 'key-pressed'
|
|
159
|
-
this.errorMsg = '';
|
|
160
|
-
this.dispatchEvent(new CustomEvent('key-pressed', {
|
|
161
|
-
detail: {
|
|
162
|
-
value: this._input.value,
|
|
163
|
-
name: this.valueName
|
|
164
|
-
},
|
|
165
|
-
composed: true,
|
|
166
|
-
bubbles: true
|
|
167
|
-
}));
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
_onBlur() {
|
|
172
|
-
this.dispatchEvent(new CustomEvent('focus-lost', {
|
|
173
|
-
detail: {
|
|
174
|
-
value: this._input.value
|
|
175
|
-
},
|
|
176
|
-
composed: true,
|
|
177
|
-
bubbles: true
|
|
178
|
-
}));
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
_onIconClick() {
|
|
182
|
-
this.dispatchEvent(new CustomEvent('icon-clicked', {
|
|
183
|
-
detail: {
|
|
184
|
-
value: this._input.value
|
|
185
|
-
},
|
|
186
|
-
composed: true,
|
|
187
|
-
bubbles: true
|
|
188
|
-
}));
|
|
189
|
-
}
|
|
190
|
-
}
|
|
103
|
+
}
|
package/src/PdRadioGroup.js
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
* Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { html, css } from 'lit';
|
|
7
7
|
import { classMap } from 'lit/directives/class-map.js';
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
import { PdBaseUIInput } from './PdBaseUiInput.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* An example element.
|
|
@@ -13,71 +14,52 @@ import { SharedInputStyles } from './shared-input-styles.js';
|
|
|
13
14
|
* @slot - This element has a slot
|
|
14
15
|
* @csspart button - The button
|
|
15
16
|
*/
|
|
16
|
-
export class PdRadioGroup extends
|
|
17
|
+
export class PdRadioGroup extends PdBaseUIInput {
|
|
17
18
|
|
|
18
19
|
static get styles() {
|
|
19
20
|
return [
|
|
20
|
-
|
|
21
|
-
css`
|
|
22
|
-
:host {
|
|
23
|
-
/* define direction of checkboxes*/
|
|
24
|
-
--my-direction: var(--group-direction, row);
|
|
25
|
-
|
|
26
|
-
/* ToDo: Auf die schnelle, anders lösen (vertikal / horizontal als eigenschaft mit entsprechenden klassen)*/
|
|
27
|
-
--my-gap: var(--group-gap, 5px);
|
|
28
|
-
}
|
|
21
|
+
PdBaseUIInput.styles,
|
|
22
|
+
css`
|
|
29
23
|
|
|
30
24
|
.group-style {
|
|
31
25
|
display: flex;
|
|
32
|
-
gap: var(--
|
|
33
|
-
flex-direction: var(--
|
|
26
|
+
gap: var(--pd-cb-group-gap, 20px);
|
|
27
|
+
flex-direction: var(--pd-cb-group-direction, row);
|
|
34
28
|
}
|
|
35
29
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
static get properties() {
|
|
40
|
-
return {
|
|
41
|
-
label: {type: String},
|
|
42
|
-
required: {type: Boolean},
|
|
43
|
-
defaultRequiredChar: { type: String },
|
|
44
|
-
valueName: { type: String },
|
|
45
|
-
errorMsg: {type: String} // errorMsg (could set fronm outside for busines validation, internal validation=> todo)
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
constructor() {
|
|
50
|
-
super();
|
|
51
|
-
this.label = '';
|
|
52
|
-
this.valueName = '';
|
|
53
|
-
this.errorMsg = '';
|
|
54
|
-
|
|
55
|
-
this.defaultRequiredChar = '*';
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
get value() {
|
|
59
|
-
const elColl = this.getElementsByTagName('pd-checkbox');
|
|
60
|
-
let returnVal;
|
|
61
|
-
Object.keys(elColl).forEach(keyValue => {
|
|
62
|
-
if (elColl[keyValue].value === 'true') {
|
|
63
|
-
returnVal = elColl[keyValue];
|
|
30
|
+
/* Overwrite width for radio group */
|
|
31
|
+
.error-box {
|
|
32
|
+
max-width: var(--pd-input-field-width, 500px);
|
|
64
33
|
}
|
|
65
|
-
|
|
66
|
-
|
|
34
|
+
|
|
35
|
+
`];
|
|
67
36
|
}
|
|
68
37
|
|
|
69
38
|
firstUpdated() {
|
|
70
39
|
|
|
71
40
|
// add event listener
|
|
72
|
-
this.addEventListener('
|
|
41
|
+
this.addEventListener('field-change', (e) => {
|
|
73
42
|
const elCollection = this.getElementsByTagName('pd-checkbox');
|
|
74
43
|
Object.keys(elCollection).forEach(keyValue => {
|
|
75
44
|
if (elCollection[keyValue] !== e.target) {
|
|
76
|
-
elCollection[keyValue].value = false;
|
|
45
|
+
elCollection[keyValue].value = "false";
|
|
46
|
+
} else {
|
|
47
|
+
this.value = elCollection[keyValue].valueName;
|
|
77
48
|
}
|
|
78
|
-
elCollection[keyValue].readonly = (elCollection[keyValue].value === 'true');
|
|
79
|
-
this.errorMsg = '';
|
|
49
|
+
elCollection[keyValue].readonly = (elCollection[keyValue].value === 'true');
|
|
80
50
|
});
|
|
51
|
+
|
|
52
|
+
// validate radio-group after change
|
|
53
|
+
this.dispatchEvent(
|
|
54
|
+
new CustomEvent('validate-form', {
|
|
55
|
+
detail: {
|
|
56
|
+
singleElement: this,
|
|
57
|
+
errorMap: new Map()
|
|
58
|
+
},
|
|
59
|
+
composed: true,
|
|
60
|
+
bubbles: true,
|
|
61
|
+
})
|
|
62
|
+
);
|
|
81
63
|
});
|
|
82
64
|
|
|
83
65
|
// set default
|
|
@@ -90,15 +72,11 @@ export class PdRadioGroup extends LitElement {
|
|
|
90
72
|
|
|
91
73
|
render() {
|
|
92
74
|
return html`
|
|
93
|
-
|
|
75
|
+
${this._renderLabel()}
|
|
94
76
|
<div class="group-style input ${classMap({'error': this.errorMsg.length > 0})}">
|
|
95
77
|
<slot></slot>
|
|
96
78
|
</div>
|
|
97
|
-
${this.
|
|
98
|
-
<div class="error-box error">
|
|
99
|
-
<span class="error-msg">${this.errorMsg}</span>
|
|
100
|
-
</div>
|
|
101
|
-
` : ''}
|
|
79
|
+
${this._renderErrorMsg()}
|
|
102
80
|
`;
|
|
103
81
|
}
|
|
104
82
|
|
package/src/PdRange.js
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
import { html, css } from 'lit';
|
|
7
7
|
|
|
8
|
-
import { SharedInputStyles } from './shared-input-styles.js';
|
|
9
8
|
import { PdBaseUIInput, INPUT_TYPE_RANGE } from './PdBaseUiInput.js';
|
|
10
9
|
|
|
11
10
|
|
|
@@ -29,7 +28,6 @@ export class PdRange extends PdBaseUIInput {
|
|
|
29
28
|
|
|
30
29
|
static get styles() {
|
|
31
30
|
return [
|
|
32
|
-
SharedInputStyles,
|
|
33
31
|
css`
|
|
34
32
|
input[type=range] {
|
|
35
33
|
-webkit-appearance: none;
|