@progressive-development/pd-forms 0.0.60 → 0.1.1
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/.storybook/preview-head.html +4 -0
- package/package.json +2 -2
- package/src/PdBaseInputElement.js +94 -0
- package/src/PdBaseUi.js +23 -4
- package/src/PdBaseUiInput.js +137 -8
- package/src/PdButton.js +72 -80
- package/src/PdCheckbox.js +194 -216
- package/src/PdFormContainer.js +42 -35
- package/src/PdFormRow.js +19 -16
- package/src/PdInput.js +41 -137
- package/src/PdInputArea.js +38 -134
- package/src/PdRadioGroup.js +27 -65
- package/src/PdRange.js +0 -2
- package/src/PdSelect.js +36 -190
- package/src/shared-global-styles.js +42 -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 +60 -7
- 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/PdCheckbox.js
CHANGED
|
@@ -1,291 +1,268 @@
|
|
|
1
|
+
/* eslint-disable lit-a11y/click-events-have-key-events */
|
|
1
2
|
/**
|
|
2
3
|
* @license
|
|
3
4
|
* Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// Änderungen an den Klassen aus node_modules übernommen, nicht deployed und verwendet => offen
|
|
8
|
-
|
|
9
6
|
import { html, css } from "lit";
|
|
10
7
|
import { classMap } from 'lit/directives/class-map.js';
|
|
11
8
|
|
|
12
|
-
// import {GestureEventListeners} from '@polymer/polymer/lib/mixins/gesture-event-listeners.js';
|
|
13
|
-
|
|
14
9
|
import '@progressive-development/pd-icon';
|
|
15
|
-
import { PdBaseUIInput, INPUT_TYPE_CHECK } from "./PdBaseUiInput.js";
|
|
16
10
|
|
|
11
|
+
import { PdBaseUIInput, INPUT_TYPE_CHECK } from "./PdBaseUiInput.js";
|
|
17
12
|
|
|
18
|
-
// import { installMediaQueryWatcher } from 'pwa-helpers/media-query.js';
|
|
19
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Lit Checkbox Element.
|
|
16
|
+
* Could displayed as switch (set isSwitch to true) or checkbox implementation.
|
|
17
|
+
*
|
|
18
|
+
* Styling is wrapped inside the checkbox element, which uses the styling properties from
|
|
19
|
+
* pd-icon (detailed).
|
|
20
|
+
*
|
|
21
|
+
### Custom Properties: #######################################
|
|
22
|
+
# Style for checked checkbox: Default values #
|
|
23
|
+
##############################################################
|
|
24
|
+
* --pd-cb-col unset, pd-icon default
|
|
25
|
+
* --pd-cb-col-hover unset, pd-icon default
|
|
26
|
+
* --pd-cb-bg-col unset, pd-icon default
|
|
27
|
+
* --pd-cb-stroke-col unset, pd-icon default
|
|
28
|
+
* --pd-cb-stroke-col-hover unset, pd-icon default
|
|
29
|
+
*
|
|
30
|
+
* Style for unchecked checkbox:
|
|
31
|
+
* --pd-cb-unset-col unset, pd-icon default
|
|
32
|
+
* --pd-cb-unset-col-hover unset, pd-icon default
|
|
33
|
+
* --pd-cb-unset-bg-col unset, pd-icon default
|
|
34
|
+
* --pd-cb-unset-stroke-col unset, pd-icon default
|
|
35
|
+
* --pd-cb-unset-stroke-col-hover unset, pd-icon default
|
|
36
|
+
*
|
|
37
|
+
* --pd-cb-border-col --pd-default-col
|
|
38
|
+
* --pd-cb-border-radius 4px (not border for rounded elements, cb specific)
|
|
39
|
+
* --pd-cb-font-col --pd-default-font-input-col
|
|
40
|
+
* --pd-default-font-input-family
|
|
41
|
+
* --pd-default-font-input-size
|
|
42
|
+
* --pd-cb-txt-col-readonly #4d4d4d
|
|
43
|
+
* --pd-cb-switch-height not set
|
|
44
|
+
* --pd-cb-switch-paddle-col --pd-default-col
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
20
47
|
export class PdCheckbox extends PdBaseUIInput {
|
|
48
|
+
|
|
21
49
|
static get properties() {
|
|
22
|
-
return {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// _panEnd: {type: Boolean},
|
|
26
|
-
isSwitch: { type: Boolean }
|
|
50
|
+
return {
|
|
51
|
+
isSwitch: { type: Boolean },
|
|
52
|
+
_hasInner: { type: Boolean, state: true },
|
|
27
53
|
};
|
|
28
54
|
}
|
|
29
55
|
|
|
30
56
|
constructor() {
|
|
31
57
|
super();
|
|
32
58
|
this._inputType = INPUT_TYPE_CHECK;
|
|
33
|
-
// this._panEnd = false;
|
|
34
|
-
// this._panX = 0;
|
|
35
59
|
}
|
|
36
60
|
|
|
37
61
|
static get styles() {
|
|
38
62
|
return [
|
|
39
|
-
|
|
63
|
+
PdBaseUIInput.styles,
|
|
40
64
|
css`
|
|
41
|
-
:host {
|
|
42
|
-
|
|
43
|
-
/*
|
|
44
|
-
--my-icon-fill: var(--pd-app-light-background, #fefefe);
|
|
45
|
-
--my-icon-active-fill: var(--pd-app-primary-color, #067394);
|
|
46
|
-
--my-icon-inactive-fill: var(--pd-app-primary-color, darkgrey);
|
|
47
|
-
|
|
48
|
-
--my-icon-bg-active-color: var(--app-primary-color, #fefefe);
|
|
49
|
-
|
|
50
|
-
--my-bg-color: var(--squi-bg-color, #177E89);
|
|
51
|
-
--my-txt-color: var(--squi-bg-color, black);
|
|
65
|
+
:host {
|
|
66
|
+
display: inline-block;
|
|
52
67
|
|
|
53
|
-
|
|
68
|
+
/* Style for active checkbox => use defaults from pd-icon if no custom properties set */
|
|
69
|
+
--pd-icon-col-active: var(--pd-cb-col);
|
|
70
|
+
--pd-icon-col-active-hover: var(--pd-cb-col-hover);
|
|
71
|
+
--pd-icon-bg-col-active: var(--pd-cb-bg-col);
|
|
72
|
+
--pd-icon-stroke-col-active: var(--pd-cb-stroke-col);
|
|
73
|
+
--pd-icon-stroke-col-active-hover: var(--pd-cb-stroke-col-hover);
|
|
54
74
|
|
|
55
|
-
|
|
56
|
-
--
|
|
57
|
-
--
|
|
58
|
-
--
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
* TODO vars used in pd-icon *
|
|
63
|
-
--squi-checkbox-checked-color: var(--my-primary);
|
|
64
|
-
--squi-checkbox-unchecked-color: var(--my-ligth);
|
|
65
|
-
--squi-checkbox-bg: var(--my-dark);
|
|
66
|
-
--squi-checkbox-unchecked-bg: var(--my-dark);
|
|
67
|
-
--squi-checkbox-label-color: var(--my-primary);
|
|
68
|
-
|
|
69
|
-
--squi-checkbox-label-disabled-color: var(--app-copy-color, #303030);
|
|
70
|
-
|
|
71
|
-
* Checkbox pd-icon
|
|
72
|
-
--pd-icon-fill: red;
|
|
73
|
-
--pd-icon-bg: red;
|
|
74
|
-
--pd-icon-fill-active: var(--my-icon-bg-active-color);
|
|
75
|
-
--pd-icon-bg-active: var(--my-icon-active-fill);
|
|
76
|
-
*/
|
|
77
|
-
|
|
78
|
-
--pd-icon-fill-active: var(--pd-app-primary-col, #067394);
|
|
79
|
-
--pd-icon-fill: var(--pd-checkbox-inactive-col, darkgrey);
|
|
80
|
-
--pd-icon-bg: var(--pd-checkbox-bg-col, #fefefe);
|
|
81
|
-
|
|
82
|
-
display: inline-block;
|
|
83
|
-
font-size: .8rem;
|
|
75
|
+
/* Style for inactive checkbox */
|
|
76
|
+
--pd-icon-col: var(--pd-cb-unset-col);
|
|
77
|
+
--pd-icon-col-hover: var(--pd-cb-unset-col-hover);
|
|
78
|
+
--pd-icon-bg-col: var(--pd-cb-unset-bg-col);
|
|
79
|
+
--pd-icon-stroke-col: var(--pd-cb-unset-stroke-col);
|
|
80
|
+
--pd-icon-stroke-col-hover: var(--pd-cb-unset-stroke-col-hover);
|
|
84
81
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
--pd-icon-bg: var(--my-icon-bg-color);
|
|
90
|
-
--pd-icon-bg-active: var(--my-icon-bg-active-color);
|
|
82
|
+
|
|
83
|
+
/* Switch pd-icon => Prüfen, bei mir musste ich reflect setzten, wird das verwendet? */
|
|
84
|
+
:host([isSwitch]) {
|
|
85
|
+
/* derzeit keine Angaben */
|
|
91
86
|
}
|
|
92
|
-
|
|
87
|
+
|
|
88
|
+
.div-container {
|
|
93
89
|
display: flex;
|
|
94
90
|
align-items: center;
|
|
95
91
|
cursor: pointer;
|
|
96
92
|
}
|
|
97
|
-
|
|
93
|
+
|
|
94
|
+
.div-container.disabled {
|
|
98
95
|
opacity: 0.5;
|
|
99
96
|
cursor: auto;
|
|
100
97
|
}
|
|
101
|
-
|
|
98
|
+
|
|
99
|
+
.div-container.readonly {
|
|
102
100
|
cursor: auto;
|
|
103
101
|
}
|
|
102
|
+
|
|
103
|
+
/*
|
|
104
|
+
* Class checkbox for icon and a element (checkbox case)
|
|
105
|
+
*/
|
|
104
106
|
.checkbox {
|
|
105
107
|
display: flex;
|
|
106
108
|
border-radius: 4px;
|
|
107
109
|
line-height: 0;
|
|
108
110
|
align-items: center;
|
|
109
111
|
justify-content: center;
|
|
110
|
-
|
|
112
|
+
/*
|
|
113
|
+
Wurde das hier für Border verwendet? Aktuell border in folgendem Element gesetzt
|
|
114
|
+
background-color: var(--pd-cb-border-col, var(--pd-primary-col, #067394));
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
111
119
|
.checkbox pd-icon {
|
|
112
|
-
margin: .
|
|
120
|
+
margin-right: .2rem;
|
|
121
|
+
margin-bottom: .2rem;
|
|
122
|
+
border: 2px solid var(--pd-cb-border-col, var(--pd-default-col));;
|
|
123
|
+
border-radius: var(--pd-cb-border-radius, 3px);
|
|
113
124
|
}
|
|
125
|
+
|
|
114
126
|
.label {
|
|
115
|
-
margin-left: .
|
|
116
|
-
color: var(--
|
|
117
|
-
font-family: var(--pd-input-
|
|
127
|
+
margin-left: 0.1rem;
|
|
128
|
+
color: var(--pd-cb-font-col, var(--pd-default-font-input-col));
|
|
129
|
+
font-family: var(--pd-default-font-input-family);
|
|
118
130
|
text-align: left;
|
|
119
|
-
font-size:
|
|
120
|
-
}
|
|
121
|
-
.disabled .label {
|
|
122
|
-
color: var(--squi-checkbox-label-disabled-color, #6e6c6c);
|
|
131
|
+
font-size: var(--pd-default-font-input-size);
|
|
123
132
|
}
|
|
133
|
+
|
|
124
134
|
.readonly .label {
|
|
125
|
-
color: var(--
|
|
135
|
+
color: var(--pd-cb-font-col-readonly, #4d4d4d);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.readonly .checkbox pd-icon {
|
|
139
|
+
border-color: var(--pd-cb-border-col-readonly, transparent);
|
|
126
140
|
}
|
|
141
|
+
|
|
127
142
|
/* Switch styles */
|
|
128
143
|
.switch {
|
|
129
|
-
height: var(--
|
|
144
|
+
height: var(--pd-cb-switch-height);
|
|
130
145
|
position: relative;
|
|
131
146
|
outline: 0;
|
|
132
147
|
-webkit-user-select: none;
|
|
133
148
|
-moz-user-select: none;
|
|
134
149
|
-ms-user-select: none;
|
|
135
150
|
user-select: none;
|
|
136
|
-
|
|
137
|
-
.switch-paddle {
|
|
138
|
-
display: inline-block;
|
|
139
|
-
vertical-align: baseline;
|
|
140
|
-
margin: 0;
|
|
141
|
-
position: relative;
|
|
142
|
-
min-width: 4rem;
|
|
143
|
-
max-width: 4rem;
|
|
144
|
-
height: 2rem;
|
|
145
|
-
border-radius: 0;
|
|
146
|
-
background: var(--my-bg-color);
|
|
147
|
-
font-weight: inherit;
|
|
148
|
-
color: inherit;
|
|
149
|
-
cursor: pointer;
|
|
150
|
-
}
|
|
151
|
-
.disabled .switch-paddle {
|
|
152
|
-
cursor: auto;
|
|
153
|
-
}
|
|
154
|
-
.readonly .switch-paddle {
|
|
155
|
-
cursor: auto;
|
|
156
|
-
max-width: 2rem;
|
|
157
|
-
min-width: 2rem;
|
|
158
|
-
background: none;
|
|
159
|
-
|
|
160
|
-
/* Prüfen TODO
|
|
161
|
-
--pd-icon-bg: transparent;
|
|
162
|
-
--pd-icon-fill: var(--card-dark-red);
|
|
163
|
-
--pd-icon-fill-hover: var(--pd-icon-fill);
|
|
164
|
-
--pd-icon-fill-active: var(--card-medium-green);
|
|
165
|
-
*/
|
|
166
|
-
}
|
|
167
|
-
.readonly .isChecked.switch-paddle pd-icon {
|
|
168
|
-
transform: translate3d(0, 0, 0);
|
|
169
|
-
left: 0.25rem;
|
|
170
|
-
}
|
|
171
|
-
.switch-paddle pd-icon {
|
|
172
|
-
position: absolute;
|
|
173
|
-
top: 0.25rem;
|
|
174
|
-
left: 0.25rem;
|
|
175
|
-
display: block;
|
|
176
|
-
width: 1.5rem;
|
|
177
|
-
height: 1.5rem;
|
|
178
|
-
-webkit-transform: translate3d(0, 0, 0);
|
|
179
|
-
transform: translate3d(0, 0, 0);
|
|
180
|
-
border-radius: 3px;
|
|
181
|
-
-webkit-transition: all 0.25s ease-out;
|
|
182
|
-
transition: all 0.25s ease-out;
|
|
183
|
-
content: '';
|
|
184
|
-
}
|
|
185
|
-
.isChecked.switch-paddle pd-icon {
|
|
186
|
-
left: 2.25rem;
|
|
187
|
-
}
|
|
151
|
+
}
|
|
188
152
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
color: var(--my-error-color);
|
|
193
|
-
background: var(--my-error-background-color);
|
|
194
|
-
border: 1px solid var(--my-error-color);
|
|
195
|
-
border-radius: var(--my-border-radius);
|
|
196
|
-
}
|
|
153
|
+
.switch .label {
|
|
154
|
+
margin-left: 0.5rem;
|
|
155
|
+
}
|
|
197
156
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
157
|
+
.switch-paddle {
|
|
158
|
+
display: inline-block;
|
|
159
|
+
vertical-align: baseline;
|
|
160
|
+
margin: 0;
|
|
161
|
+
position: relative;
|
|
162
|
+
min-width: 4rem;
|
|
163
|
+
max-width: 4rem;
|
|
164
|
+
height: 2rem;
|
|
165
|
+
border-radius: 0;
|
|
166
|
+
background: var(--pd-cb-switch-paddle-col, var(--pd-default-col));
|
|
167
|
+
font-weight: inherit;
|
|
168
|
+
color: inherit;
|
|
169
|
+
cursor: pointer;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.switch-paddle pd-icon {
|
|
173
|
+
position: absolute;
|
|
174
|
+
top: 0;
|
|
175
|
+
left: 0;
|
|
176
|
+
display: block;
|
|
177
|
+
width: 1.5rem;
|
|
178
|
+
height: 1.5rem;
|
|
179
|
+
-webkit-transform: translate3d(0, 0, 0);
|
|
180
|
+
transform: translate3d(0, 0, 0);
|
|
181
|
+
border: 2px solid var(--pd-cb-border-col, var(--pd-default-col));
|
|
182
|
+
box-shadow: rgba(0, 0, 0, 0.15) 1.95px 1.95px 2.6px;
|
|
183
|
+
border-radius: var(--pd-cb-border-radius, 4px);
|
|
184
|
+
-webkit-transition: all 0.25s ease-out;
|
|
185
|
+
transition: all 0.25s ease-out;
|
|
186
|
+
content: '';
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.disabled .switch-paddle {
|
|
190
|
+
cursor: auto;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.readonly .switch-paddle {
|
|
194
|
+
cursor: auto;
|
|
195
|
+
max-width: 2rem;
|
|
196
|
+
min-width: 2rem;
|
|
197
|
+
background: none;
|
|
198
|
+
|
|
199
|
+
/* Prüfen TODO
|
|
200
|
+
--pd-icon-bg: transparent;
|
|
201
|
+
--pd-icon-fill: var(--card-dark-red);
|
|
202
|
+
--pd-icon-fill-hover: var(--pd-icon-fill);
|
|
203
|
+
--pd-icon-fill-active: var(--card-medium-green);
|
|
204
|
+
*/
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.readonly .switch-paddle pd-icon {
|
|
208
|
+
border-color: var(--pd-cb-border-col-readonly, transparent);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.readonly .isChecked.switch-paddle pd-icon {
|
|
212
|
+
transform: translate3d(0, 0, 0);
|
|
213
|
+
left: 0rem;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.isChecked.switch-paddle pd-icon {
|
|
217
|
+
left: 2.25rem;
|
|
218
|
+
}
|
|
205
219
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
220
|
+
@media (min-width: 580px) {
|
|
221
|
+
:host {
|
|
222
|
+
font-size: 1rem;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
211
225
|
`];
|
|
212
226
|
}
|
|
213
227
|
|
|
214
|
-
firstUpdated() {
|
|
215
|
-
this.hasInner = !!this.innerHTML.trim().length;
|
|
216
|
-
// installMediaQueryWatcher(`(min-width: 780px)`, (matches) => matches ? this : this._updateScale(1.5));
|
|
217
|
-
// const paddle = el.shadowRoot.querySelectorAll('.switch-paddle');
|
|
218
|
-
// this.isSwitch ? Gestures.addListener(this, 'track', this.handleTrack.bind(this)) : '';
|
|
219
|
-
}
|
|
220
|
-
|
|
221
228
|
render() {
|
|
222
|
-
|
|
229
|
+
|
|
230
|
+
// set inner for the first time (avoid upddate cycle in firstupdated (in real avoid log here...))
|
|
231
|
+
if (!this._hasInnerSet) {
|
|
232
|
+
this._hasInnerSet = true;
|
|
233
|
+
this._hasInner = !!this.innerHTML.trim().length;
|
|
234
|
+
}
|
|
223
235
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
236
|
+
const checked = (this.value === 'true');
|
|
237
|
+
const classMapVal = {'disabled': this.disabled, 'switch': this.isSwitch, 'readonly': this.readonly, 'div-container': true};
|
|
238
|
+
const aClassMap = {'switch-paddle': this.isSwitch, 'checkbox': !this.isSwitch, 'isChecked': checked, 'isUnchecked': !checked};
|
|
239
|
+
|
|
240
|
+
return html`
|
|
241
|
+
<div @click="${this.onClick}" class="${classMap(classMapVal)}">
|
|
242
|
+
<a href="#" @click="${this.linkClick}" @keypress="${this.onKeyPress}" class="${classMap(aClassMap)}">
|
|
243
|
+
<pd-icon icon="checkBox" class="small" ?activeIcon="${checked}"></pd-icon>
|
|
229
244
|
</a>
|
|
230
|
-
${this.
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
: ""}
|
|
245
|
+
${this._hasInner ? html`
|
|
246
|
+
<span class="label">
|
|
247
|
+
<slot></slot>
|
|
248
|
+
</span>` : ""}
|
|
235
249
|
</div>
|
|
236
|
-
${this.
|
|
237
|
-
<div class="error-box error">
|
|
238
|
-
<span class="error-msg">${this.errorMsg}</span>
|
|
239
|
-
</div>
|
|
240
|
-
` : ''}
|
|
250
|
+
${this._renderErrorMsg()}
|
|
241
251
|
`;
|
|
242
252
|
}
|
|
243
253
|
|
|
244
|
-
|
|
245
|
-
update(changedProperties) {
|
|
246
|
-
//let { deltaX = 0, isFinal = false } = this._panX;
|
|
247
|
-
let isFinal = this._panEnd;
|
|
248
|
-
let deltaX = this._panX || 0;
|
|
249
|
-
//console.log(this._panData);
|
|
250
|
-
|
|
251
|
-
// Guard against an infinite loop by looking for index.
|
|
252
|
-
if (isFinal) {
|
|
253
|
-
console.log('deltaX', deltaX);
|
|
254
|
-
// TODO 250 half screen size?
|
|
255
|
-
if ( deltaX > 100) {
|
|
256
|
-
this.onClick(true);
|
|
257
|
-
} else if(deltaX < -100){
|
|
258
|
-
this.onClick(false);
|
|
259
|
-
}
|
|
260
|
-
this._panEnd = false;
|
|
261
|
-
}
|
|
262
|
-
// We don't want the latent deltaX when releasing a pan.
|
|
263
|
-
deltaX = (isFinal ? 0 : deltaX);
|
|
264
|
-
|
|
265
|
-
super.update(changedProperties);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
handleTrack(e) {
|
|
269
|
-
switch(e.detail.state) {
|
|
270
|
-
case 'start':
|
|
271
|
-
//this.message = 'Tracking started!';
|
|
272
|
-
break;
|
|
273
|
-
case 'track':
|
|
274
|
-
//this.message = 'Tracking in progress... ' + e.detail.x + ', ' + e.detail.y;
|
|
275
|
-
break;
|
|
276
|
-
case 'end':
|
|
277
|
-
this._panX = e.detail.dx;
|
|
278
|
-
this._panEnd = true;
|
|
279
|
-
break;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
*/
|
|
283
|
-
onClick() {
|
|
254
|
+
onClick(e) {
|
|
284
255
|
if (this.disabled || this.readonly) {
|
|
285
256
|
return;
|
|
286
257
|
}
|
|
287
|
-
const checked = (this.value === 'true');
|
|
288
|
-
|
|
258
|
+
const checked = (this.value === 'true');
|
|
259
|
+
|
|
260
|
+
// set changed value and generate events (key-pressed, enter-pressed, validateForm)
|
|
261
|
+
// if neccessary
|
|
262
|
+
this._handleChangedValue(checked ? 'false' : 'true', e);
|
|
263
|
+
|
|
264
|
+
// TODO: Idee, alle input elemente haben gleichen event!
|
|
265
|
+
/*
|
|
289
266
|
this.dispatchEvent(
|
|
290
267
|
new CustomEvent("checkbox-changed", {
|
|
291
268
|
bubbles: true,
|
|
@@ -293,12 +270,13 @@ export class PdCheckbox extends PdBaseUIInput {
|
|
|
293
270
|
detail: {check: !checked, name: this.valueName},
|
|
294
271
|
})
|
|
295
272
|
);
|
|
273
|
+
*/
|
|
296
274
|
}
|
|
297
275
|
|
|
298
|
-
onKeyPress(e) {
|
|
276
|
+
onKeyPress(e) {
|
|
299
277
|
e.preventDefault();
|
|
300
278
|
if (e.keyCode === 32 || e.code === "Space") {
|
|
301
|
-
this.onClick();
|
|
279
|
+
this.onClick(e);
|
|
302
280
|
}
|
|
303
281
|
}
|
|
304
282
|
|
package/src/PdFormContainer.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Lit element container for pd input elements.
|
|
6
|
+
*
|
|
7
|
+
* Used to:
|
|
8
|
+
* - Automatically validation of form content
|
|
9
|
+
* - Success/NotReady information for form-container
|
|
4
10
|
*/
|
|
5
11
|
|
|
6
12
|
import { html, css } from 'lit';
|
|
@@ -17,42 +23,44 @@ import { PdBaseUI } from './PdBaseUi.js';
|
|
|
17
23
|
export class PdFormContainer extends PdBaseUI {
|
|
18
24
|
|
|
19
25
|
static get styles() {
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
return [
|
|
27
|
+
PdBaseUI.styles,
|
|
28
|
+
css`
|
|
29
|
+
:host {
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
align-items: left;
|
|
25
33
|
gap: 20px;
|
|
26
34
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
font-
|
|
30
|
-
|
|
31
|
-
padding:10px;
|
|
35
|
+
|
|
36
|
+
.validation-info {
|
|
37
|
+
font-family: var(--pd-default-font-content-family);
|
|
38
|
+
font-size: var(--pd-form-info-font-size, 0.8rem);
|
|
39
|
+
padding: 10px;
|
|
32
40
|
color:#58585a;
|
|
33
|
-
border-radius: var(--
|
|
34
|
-
-moz-border-radius: var(--
|
|
35
|
-
width:
|
|
36
|
-
min-width:
|
|
41
|
+
border-radius: var(--pd-border-radius, 0);
|
|
42
|
+
-moz-border-radius: var(--pd-border-radius, 0);
|
|
43
|
+
width:40%;
|
|
44
|
+
min-width:250px;
|
|
37
45
|
}
|
|
38
46
|
|
|
39
|
-
.filled {
|
|
40
|
-
border-left:4px solid
|
|
41
|
-
border-right:4px solid
|
|
42
|
-
border-top:1px solid
|
|
43
|
-
border-bottom:1px solid
|
|
44
|
-
background-color
|
|
47
|
+
.filled {
|
|
48
|
+
border-left: 4px solid var(--pd-default-success-col);
|
|
49
|
+
border-right: 4px solid var(--pd-default-success-col);
|
|
50
|
+
border-top: 1px solid var(--pd-default-success-col);
|
|
51
|
+
border-bottom: 1px solid var(--pd-default-success-col);
|
|
52
|
+
background-color: var(--pd-default-success-light-col);
|
|
45
53
|
}
|
|
46
54
|
|
|
47
|
-
.unfilled {
|
|
48
|
-
border-left:4px solid
|
|
49
|
-
border-right:4px solid
|
|
50
|
-
border-top:1px solid
|
|
51
|
-
border-bottom:1px solid
|
|
52
|
-
background-color
|
|
55
|
+
.unfilled {
|
|
56
|
+
border-left: 4px solid var(--pd-default-error-col);
|
|
57
|
+
border-right: 4px solid var(--pd-default-error-col);
|
|
58
|
+
border-top: 1px solid var(--pd-default-error-col);
|
|
59
|
+
border-bottom: 1px solid var(--pd-default-error-col);
|
|
60
|
+
background-color: var(--pd-default-error-light-col);
|
|
53
61
|
}
|
|
54
62
|
|
|
55
|
-
|
|
63
|
+
`];
|
|
56
64
|
}
|
|
57
65
|
|
|
58
66
|
static get properties() {
|
|
@@ -72,33 +80,32 @@ export class PdFormContainer extends PdBaseUI {
|
|
|
72
80
|
<form>
|
|
73
81
|
<slot></slot>
|
|
74
82
|
${this.requiredFieldInfo ? html`
|
|
75
|
-
<p class="
|
|
83
|
+
<p class="validation-info ${this._requiredFieldsValid ? 'filled' : 'unfilled'}">
|
|
76
84
|
${msg('* Pflichtfeld',{desc: '#pd.form.required.info#'})}
|
|
77
85
|
</p>` : ''}
|
|
78
86
|
<br />
|
|
79
|
-
</form>
|
|
87
|
+
</form>
|
|
80
88
|
`;
|
|
81
89
|
}
|
|
82
90
|
|
|
83
|
-
_validateForm(e) {
|
|
91
|
+
_validateForm(e) {
|
|
84
92
|
|
|
85
93
|
const reqEl = this.querySelectorAll("[required]");
|
|
86
94
|
|
|
87
95
|
// validate required fields TODO: Auf PdInputxxx beschränken
|
|
88
96
|
reqEl.forEach(el => {
|
|
89
97
|
const tmpEl = el;
|
|
90
|
-
|
|
98
|
+
|
|
99
|
+
if (!el.value || el.value === "" || el.value === "false") {
|
|
91
100
|
const erMsg = el.requiredMsg || msg('Eingabe erforderlich',{desc: '#pd.form.field.required#'});
|
|
92
101
|
if (!e.detail.singleElement || e.detail.singleElement === el) {
|
|
93
102
|
tmpEl.errorMsg = erMsg;
|
|
94
103
|
}
|
|
95
104
|
e.detail.errorMap.set(el.id, erMsg);
|
|
96
|
-
} else {
|
|
97
|
-
if (!e.detail.singleElement || e.detail.singleElement === el) {
|
|
105
|
+
} else if (!e.detail.singleElement || e.detail.singleElement === el) {
|
|
98
106
|
tmpEl.errorMsg = "";
|
|
99
|
-
}
|
|
100
107
|
}
|
|
101
|
-
})
|
|
108
|
+
});
|
|
102
109
|
|
|
103
110
|
this._requiredFieldsValid = e.detail.errorMap.size === 0;
|
|
104
111
|
|