@progressive-development/pd-forms 0.2.16 → 0.5.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/dist/index.js +28 -0
- package/dist/locales/be.js +12 -0
- package/dist/locales/de.js +12 -0
- package/dist/locales/en.js +12 -0
- package/dist/pd-button.js +4 -0
- package/dist/pd-checkbox.js +4 -0
- package/dist/pd-form-container.js +4 -0
- package/dist/pd-form-row.js +4 -0
- package/dist/pd-hover-box.js +4 -0
- package/dist/pd-input-area.js +4 -0
- package/dist/pd-input-file.js +4 -0
- package/dist/pd-input.js +4 -0
- package/dist/pd-radio-group.js +4 -0
- package/dist/pd-range.js +4 -0
- package/dist/pd-select.js +4 -0
- package/{src → dist/src}/PdBaseInputElement.js +23 -42
- package/{src → dist/src}/PdBaseUi.js +11 -13
- package/dist/src/PdBaseUiInput.js +229 -0
- package/{src → dist/src}/PdButton.js +42 -48
- package/{src → dist/src}/PdCheckbox.js +16 -75
- package/{src → dist/src}/PdFormContainer.js +51 -79
- package/{src → dist/src}/PdFormRow.js +11 -20
- package/{src → dist/src}/PdHoverBox.js +20 -42
- package/dist/src/PdInput.js +79 -0
- package/dist/src/PdInputArea.js +61 -0
- package/dist/src/PdInputFile.js +73 -0
- package/dist/src/PdRadioGroup.js +72 -0
- package/{src → dist/src}/PdRange.js +38 -47
- package/{src → dist/src}/PdSelect.js +16 -65
- package/{src → dist/src}/shared-input-field-styles.js +6 -8
- package/{src → dist/src}/shared-input-styles.js +5 -8
- package/package.json +50 -27
- package/.editorconfig +0 -29
- package/.storybook/main.js +0 -13
- package/.storybook/preview-head.html +0 -4
- package/.storybook/preview.js +0 -14
- package/demo/index.html +0 -29
- package/index.js +0 -0
- package/lit-localize.json +0 -18
- package/pd-button.js +0 -3
- package/pd-checkbox.js +0 -3
- package/pd-form-container.js +0 -3
- package/pd-form-row.js +0 -3
- package/pd-hover-box.js +0 -3
- package/pd-input-area.js +0 -3
- package/pd-input-file.js +0 -3
- package/pd-input.js +0 -3
- package/pd-radio-group.js +0 -3
- package/pd-range.js +0 -3
- package/pd-select.js +0 -3
- package/src/PdBaseUiInput.js +0 -248
- package/src/PdInput.js +0 -146
- package/src/PdInputArea.js +0 -104
- package/src/PdInputFile.js +0 -121
- package/src/PdRadioGroup.js +0 -88
- package/src/PdRange copy.js +0 -197
- package/src/generated/locale/be.js +0 -19
- package/src/generated/locale/en.js +0 -19
- package/src/generated/locale-codes.js +0 -25
- package/src/stories/01_index.stories.js +0 -268
- package/src/stories/button.stories.js +0 -15
- package/src/stories/checkbox.stories.js +0 -103
- package/src/stories/form-container.stories.js +0 -100
- package/src/stories/form-row.stories.js +0 -23
- package/src/stories/input-area.stories.js +0 -129
- package/src/stories/input-file.stories.js +0 -111
- package/src/stories/input.stories.js +0 -179
- package/src/stories/radio-group.stories.js +0 -54
- package/src/stories/range.stories.js +0 -105
- package/src/stories/select.stories.js +0 -116
- package/test/pd-forms.test.js +0 -32
- package/web-dev-server.config.mjs +0 -27
- package/web-test-runner.config.mjs +0 -41
- package/xliff/be.xlf +0 -37
- package/xliff/en.xlf +0 -31
|
@@ -1,63 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import { css, html } from "lit";
|
|
2
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
3
|
+
import "@progressive-development/pd-icon/pd-icon";
|
|
4
|
+
import { PdBaseUIInput, INPUT_TYPE_CHECK } from "./PdBaseUiInput.js";
|
|
2
5
|
/**
|
|
3
6
|
* @license
|
|
4
7
|
* Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
|
|
5
8
|
*/
|
|
6
|
-
|
|
7
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
8
|
-
|
|
9
|
-
import '@progressive-development/pd-icon/pd-icon.js';
|
|
10
|
-
|
|
11
|
-
import { PdBaseUIInput, INPUT_TYPE_CHECK } from "./PdBaseUiInput.js";
|
|
12
|
-
|
|
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
|
-
*/
|
|
47
|
-
export class PdCheckbox extends PdBaseUIInput {
|
|
48
|
-
|
|
9
|
+
class PdCheckbox extends PdBaseUIInput {
|
|
49
10
|
static get properties() {
|
|
50
11
|
return {
|
|
51
12
|
isSwitch: { type: Boolean },
|
|
52
|
-
_hasInner: { type: Boolean, state: true }
|
|
13
|
+
_hasInner: { type: Boolean, state: true }
|
|
53
14
|
};
|
|
54
15
|
}
|
|
55
|
-
|
|
56
16
|
constructor() {
|
|
57
17
|
super();
|
|
58
18
|
this._inputType = INPUT_TYPE_CHECK;
|
|
59
19
|
}
|
|
60
|
-
|
|
61
20
|
static get styles() {
|
|
62
21
|
return [
|
|
63
22
|
PdBaseUIInput.styles,
|
|
@@ -222,22 +181,18 @@ export class PdCheckbox extends PdBaseUIInput {
|
|
|
222
181
|
font-size: 1rem;
|
|
223
182
|
}
|
|
224
183
|
}
|
|
225
|
-
`
|
|
184
|
+
`
|
|
185
|
+
];
|
|
226
186
|
}
|
|
227
|
-
|
|
228
187
|
render() {
|
|
229
|
-
|
|
230
|
-
// set inner for the first time (avoid upddate cycle in firstupdated (in real avoid log here...))
|
|
231
188
|
if (!this._hasInnerSet) {
|
|
232
189
|
this._hasInnerSet = true;
|
|
233
190
|
this._hasInner = !!this.innerHTML.trim().length;
|
|
234
191
|
}
|
|
235
|
-
|
|
236
|
-
const
|
|
237
|
-
const
|
|
238
|
-
const aClassMap = {'switch-paddle': this.isSwitch, 'checkbox': !this.isSwitch, 'isChecked': checked, 'isUnchecked': !checked};
|
|
192
|
+
const checked = this.value === "true";
|
|
193
|
+
const classMapVal = { "disabled": this.disabled, "switch": this.isSwitch, "readonly": this.readonly, "div-container": true };
|
|
194
|
+
const aClassMap = { "switch-paddle": this.isSwitch, "checkbox": !this.isSwitch, "isChecked": checked, "isUnchecked": !checked };
|
|
239
195
|
const inputId = `${this.id}Check`;
|
|
240
|
-
|
|
241
196
|
return html`
|
|
242
197
|
${this._renderLabel(inputId)}
|
|
243
198
|
<div @click="${this.onClick}" class="${classMap(classMapVal)}">
|
|
@@ -252,38 +207,24 @@ export class PdCheckbox extends PdBaseUIInput {
|
|
|
252
207
|
${this._renderErrorMsg()}
|
|
253
208
|
`;
|
|
254
209
|
}
|
|
255
|
-
|
|
256
210
|
onClick(e) {
|
|
257
211
|
if (this.disabled || this.readonly) {
|
|
258
212
|
return;
|
|
259
213
|
}
|
|
260
|
-
const checked =
|
|
261
|
-
|
|
262
|
-
// set changed value and generate events (key-pressed, enter-pressed, validateForm)
|
|
263
|
-
// if neccessary
|
|
264
|
-
this._handleChangedValue(checked ? 'false' : 'true', e);
|
|
265
|
-
|
|
266
|
-
// TODO: Idee, alle input elemente haben gleichen event!
|
|
267
|
-
/*
|
|
268
|
-
this.dispatchEvent(
|
|
269
|
-
new CustomEvent("checkbox-changed", {
|
|
270
|
-
bubbles: true,
|
|
271
|
-
composed: true,
|
|
272
|
-
detail: {check: !checked, name: this.valueName},
|
|
273
|
-
})
|
|
274
|
-
);
|
|
275
|
-
*/
|
|
214
|
+
const checked = this.value === "true";
|
|
215
|
+
this._handleChangedValue(checked ? "false" : "true", e);
|
|
276
216
|
}
|
|
277
|
-
|
|
278
217
|
onKeyPress(e) {
|
|
279
218
|
e.preventDefault();
|
|
280
219
|
if (e.keyCode === 32 || e.code === "Space") {
|
|
281
220
|
this.onClick(e);
|
|
282
221
|
}
|
|
283
222
|
}
|
|
284
|
-
|
|
285
223
|
// eslint-disable-next-line class-methods-use-this
|
|
286
224
|
linkClick(e) {
|
|
287
225
|
e.preventDefault();
|
|
288
226
|
}
|
|
289
227
|
}
|
|
228
|
+
export {
|
|
229
|
+
PdCheckbox
|
|
230
|
+
};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { css, html } from "lit";
|
|
2
|
+
import { msg } from "@lit/localize";
|
|
3
|
+
import { INPUT_TYPE_RANGE, INPUT_TYPE_SELECT } from "./PdBaseUiInput.js";
|
|
4
|
+
import { PdBaseUI } from "./PdBaseUi.js";
|
|
1
5
|
/**
|
|
2
6
|
* @license
|
|
3
7
|
* Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
|
|
@@ -8,26 +12,11 @@
|
|
|
8
12
|
* - Automatically validation of form content
|
|
9
13
|
* - Success/NotReady information for form-container
|
|
10
14
|
*/
|
|
11
|
-
|
|
12
|
-
import { html, css } from 'lit';
|
|
13
|
-
import { msg } from '@lit/localize';
|
|
14
|
-
|
|
15
|
-
import { INPUT_TYPE_RANGE, INPUT_TYPE_SELECT } from './PdBaseUiInput.js';
|
|
16
|
-
|
|
17
|
-
import { PdBaseUI } from './PdBaseUi.js';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* An example element.
|
|
21
|
-
*
|
|
22
|
-
* @slot - This element has a slot
|
|
23
|
-
* @csspart button - The button
|
|
24
|
-
*/
|
|
25
|
-
export class PdFormContainer extends PdBaseUI {
|
|
26
|
-
|
|
15
|
+
class PdFormContainer extends PdBaseUI {
|
|
27
16
|
static get styles() {
|
|
28
17
|
return [
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
PdBaseUI.styles,
|
|
19
|
+
css`
|
|
31
20
|
:host {
|
|
32
21
|
display: flex;
|
|
33
22
|
flex-direction: column;
|
|
@@ -67,91 +56,68 @@ export class PdFormContainer extends PdBaseUI {
|
|
|
67
56
|
background-color: var(--pd-default-error-light-col);
|
|
68
57
|
}
|
|
69
58
|
|
|
70
|
-
`
|
|
59
|
+
`
|
|
60
|
+
];
|
|
71
61
|
}
|
|
72
|
-
|
|
73
62
|
static get properties() {
|
|
74
63
|
return {
|
|
75
|
-
requiredFieldInfo: { type: Boolean},
|
|
76
|
-
commonError: { type: String},
|
|
77
|
-
_requiredFieldsValid: { type: Boolean, state: true}
|
|
78
|
-
|
|
64
|
+
requiredFieldInfo: { type: Boolean },
|
|
65
|
+
commonError: { type: String },
|
|
66
|
+
_requiredFieldsValid: { type: Boolean, state: true }
|
|
79
67
|
};
|
|
80
68
|
}
|
|
81
|
-
|
|
82
69
|
connectedCallback() {
|
|
83
70
|
super.connectedCallback();
|
|
84
|
-
|
|
85
|
-
this.addEventListener('validate-form', this._validateForm);
|
|
71
|
+
this.addEventListener("validate-form", this._validateForm);
|
|
86
72
|
}
|
|
87
|
-
|
|
88
73
|
disconnectedCallback() {
|
|
89
74
|
super.connectedCallback();
|
|
90
|
-
|
|
91
|
-
this.removeEventListener('validate-form', this._validateForm);
|
|
75
|
+
this.removeEventListener("validate-form", this._validateForm);
|
|
92
76
|
}
|
|
93
|
-
|
|
94
77
|
render() {
|
|
95
78
|
return html`
|
|
96
79
|
<form>
|
|
97
80
|
<slot></slot>
|
|
98
81
|
${this.requiredFieldInfo || this.commonError ? html`
|
|
99
82
|
<div class="validation-info-container">
|
|
100
|
-
<p class="validation-info ${
|
|
101
|
-
${this.commonError || (this._requiredFieldsValid ? msg(
|
|
102
|
-
: msg('* Pflichtfeld',{desc: '#pd.form.required.info#'}))}
|
|
83
|
+
<p class="validation-info ${this._requiredFieldsValid && (!this.commonError || this.commonError === "") ? "filled" : "unfilled"}">
|
|
84
|
+
${this.commonError || (this._requiredFieldsValid ? msg("* Pflichtfelder ausgefüllt", { id: "pd.form.required.valid" }) : msg("* Pflichtfeld", { id: "pd.form.required.info" }))}
|
|
103
85
|
</p>
|
|
104
|
-
</div>` :
|
|
86
|
+
</div>` : ""}
|
|
105
87
|
</form>
|
|
106
88
|
`;
|
|
107
89
|
}
|
|
108
|
-
|
|
109
|
-
_validateForm(e) {
|
|
110
|
-
|
|
90
|
+
_validateForm(e) {
|
|
111
91
|
const reqEl = this.querySelectorAll("[required]");
|
|
112
|
-
|
|
113
|
-
// validate required fields TODO: Auf PdInputxxx beschränken
|
|
114
|
-
reqEl.forEach(el => {
|
|
92
|
+
reqEl.forEach((el) => {
|
|
115
93
|
const tmpEl = el;
|
|
116
|
-
if (!el.value || el.value === "" || el.value === "false" ||
|
|
117
|
-
|
|
118
|
-
const erMsg = el.requiredMsg || msg('Eingabe erforderlich',{desc: '#pd.form.field.required#'});
|
|
94
|
+
if (!el.value || el.value === "" || el.value === "false" || el._inputType === INPUT_TYPE_RANGE && el.value === "0" || el._inputType === INPUT_TYPE_SELECT && el.value === "UNDEF") {
|
|
95
|
+
const erMsg = el.requiredMsg || msg("Eingabe erforderlich", { id: "pd.form.field.required" });
|
|
119
96
|
if (!e.detail.singleElement || e.detail.singleElement === el) {
|
|
120
97
|
tmpEl.errorMsg = erMsg;
|
|
121
98
|
}
|
|
122
99
|
e.detail.errorMap.set(el.id, erMsg);
|
|
123
|
-
|
|
124
100
|
} else if (el.validate && typeof el.validate === "function" && el.validate(e)) {
|
|
125
101
|
const errMsg = el.validate(e);
|
|
126
102
|
if (!e.detail.singleElement || e.detail.singleElement === el) {
|
|
127
103
|
tmpEl.errorMsg = errMsg;
|
|
128
104
|
}
|
|
129
105
|
e.detail.errorMap.set(el.id, errMsg);
|
|
130
|
-
|
|
131
106
|
} else if (!e.detail.singleElement || e.detail.singleElement === el) {
|
|
132
|
-
|
|
107
|
+
tmpEl.errorMsg = "";
|
|
133
108
|
}
|
|
134
109
|
});
|
|
135
|
-
|
|
136
110
|
this._requiredFieldsValid = e.detail.errorMap.size === 0;
|
|
137
|
-
|
|
138
|
-
// general validate method
|
|
139
111
|
const validateByType = (fieldType, validFunc, invalidMsgTxt) => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
e.detail.singleElement.getAttribute("field-type") !== fieldType) {
|
|
143
|
-
return;
|
|
112
|
+
if (e.detail.singleElement && e.detail.singleElement.getAttribute("field-type") !== fieldType) {
|
|
113
|
+
return;
|
|
144
114
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
this.querySelectorAll(`[field-type=${fieldType}]`);
|
|
148
|
-
|
|
149
|
-
reqSpecEl.forEach(el => {
|
|
115
|
+
const reqSpecEl = e.detail.singleElement ? [e.detail.singleElement] : this.querySelectorAll(`[field-type=${fieldType}]`);
|
|
116
|
+
reqSpecEl.forEach((el) => {
|
|
150
117
|
const tmpEl = el;
|
|
151
|
-
// if not already added as required field
|
|
152
118
|
if (!e.detail.errorMap.has(el.id) && el.value && el.value.length > 0) {
|
|
153
119
|
if (validFunc(el.value)) {
|
|
154
|
-
tmpEl.errorMsg =
|
|
120
|
+
tmpEl.errorMsg = "";
|
|
155
121
|
} else {
|
|
156
122
|
tmpEl.errorMsg = invalidMsgTxt || `Invalid format for ${fieldType}`;
|
|
157
123
|
e.detail.errorMap.set(el.id, tmpEl.errorMsg);
|
|
@@ -159,37 +125,43 @@ export class PdFormContainer extends PdBaseUI {
|
|
|
159
125
|
}
|
|
160
126
|
});
|
|
161
127
|
};
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
msg(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
128
|
+
validateByType(
|
|
129
|
+
"mail",
|
|
130
|
+
PdFormContainer._mailIsValid,
|
|
131
|
+
msg("Format mail@test.de verwenden", { id: "pd.form.field.invalid.mail" })
|
|
132
|
+
);
|
|
133
|
+
validateByType(
|
|
134
|
+
"phone",
|
|
135
|
+
PdFormContainer._phoneIsValid,
|
|
136
|
+
msg("Format +49123 123456 verwenden", { id: "pd.form.field.invalid.phone" })
|
|
137
|
+
);
|
|
138
|
+
validateByType(
|
|
139
|
+
"vat",
|
|
140
|
+
PdFormContainer._vatIsValid,
|
|
141
|
+
msg("Format DE0123456789 verwenden", { id: "pd.form.field.invalid.vat" })
|
|
142
|
+
);
|
|
143
|
+
validateByType(
|
|
144
|
+
"number",
|
|
145
|
+
(val) => !isNaN(val),
|
|
146
|
+
msg("Nur Zahlen erlaubt", { id: "pd.form.field.invalid.number" })
|
|
147
|
+
);
|
|
174
148
|
if (e.detail.singleElement) {
|
|
175
149
|
e.stopPropagation();
|
|
176
150
|
}
|
|
177
151
|
}
|
|
178
|
-
|
|
179
152
|
static _mailIsValid(email) {
|
|
180
153
|
const mValid = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
|
181
154
|
return mValid;
|
|
182
155
|
}
|
|
183
|
-
|
|
184
156
|
static _vatIsValid(vat) {
|
|
185
157
|
const mValid = /^[A-Z]{2}[0-9]{8,12}$/.test(vat);
|
|
186
158
|
return mValid;
|
|
187
159
|
}
|
|
188
|
-
|
|
189
160
|
static _phoneIsValid(nr) {
|
|
190
|
-
// Valid +49 830 9001 | 49 221 123 | 08912379
|
|
191
161
|
const mValid = /^\+?[0-9 ]{7,15}$/.test(nr);
|
|
192
162
|
return mValid;
|
|
193
163
|
}
|
|
194
|
-
|
|
195
|
-
|
|
164
|
+
}
|
|
165
|
+
export {
|
|
166
|
+
PdFormContainer
|
|
167
|
+
};
|
|
@@ -1,26 +1,16 @@
|
|
|
1
|
+
import { css, html } from "lit";
|
|
2
|
+
import { PdBaseUI } from "./PdBaseUi.js";
|
|
1
3
|
/**
|
|
2
4
|
* @license
|
|
3
5
|
* Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
|
|
4
6
|
*/
|
|
5
|
-
|
|
6
|
-
import { html, css } from 'lit';
|
|
7
|
-
|
|
8
|
-
import { PdBaseUI } from './PdBaseUi.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* An example element.
|
|
12
|
-
*
|
|
13
|
-
* @slot - This element has a slot
|
|
14
|
-
* @csspart button - The button
|
|
15
|
-
*/
|
|
16
|
-
export class PdFormRow extends PdBaseUI {
|
|
17
|
-
|
|
7
|
+
class PdFormRow extends PdBaseUI {
|
|
18
8
|
static get styles() {
|
|
19
9
|
return css`
|
|
20
10
|
:host {
|
|
21
11
|
|
|
22
12
|
/* Define size for row, depends on media queries */
|
|
23
|
-
--my-row-width: 800px;
|
|
13
|
+
--my-row-width: var(--pd-form-row-base-width, 800px);
|
|
24
14
|
--my-gap: var(--pd-form-row-gap, 20px);
|
|
25
15
|
display: flex;
|
|
26
16
|
flex: 1 1 100%;
|
|
@@ -73,29 +63,30 @@ export class PdFormRow extends PdBaseUI {
|
|
|
73
63
|
|
|
74
64
|
@media (max-width: 930px) {
|
|
75
65
|
:host {
|
|
76
|
-
--my-row-width:
|
|
66
|
+
--my-row-width: calc(var(--my-row-width) * 0.75);
|
|
77
67
|
}
|
|
78
68
|
}
|
|
79
69
|
@media (max-width: 650px) {
|
|
80
70
|
:host {
|
|
81
|
-
--my-row-width:
|
|
71
|
+
--my-row-width: calc(var(--my-row-width) * 0.5);
|
|
82
72
|
--my-gap: 10px;
|
|
83
73
|
}
|
|
84
74
|
}
|
|
85
75
|
@media (max-width: 450px) {
|
|
86
76
|
:host {
|
|
87
|
-
--my-row-width:
|
|
77
|
+
--my-row-width: calc(var(--my-row-width) * 0.25);
|
|
88
78
|
--my-gap: 8px;
|
|
89
79
|
}
|
|
90
80
|
}
|
|
91
81
|
|
|
92
82
|
`;
|
|
93
83
|
}
|
|
94
|
-
|
|
95
84
|
render() {
|
|
96
85
|
return html`
|
|
97
86
|
<slot></slot>
|
|
98
87
|
`;
|
|
99
88
|
}
|
|
100
|
-
|
|
101
|
-
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
PdFormRow
|
|
92
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { css, html } from "lit";
|
|
2
|
+
import { PdBaseUI } from "./PdBaseUi.js";
|
|
2
3
|
/**
|
|
3
4
|
* @license
|
|
4
5
|
* Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
|
|
@@ -9,29 +10,17 @@
|
|
|
9
10
|
* - Automatically validation of form content
|
|
10
11
|
* - Success/NotReady information for form-container
|
|
11
12
|
*/
|
|
12
|
-
|
|
13
|
-
import { html, css } from 'lit';
|
|
14
|
-
import { PdBaseUI } from './PdBaseUi.js';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* An example element.
|
|
18
|
-
*
|
|
19
|
-
* @slot - This element has a slot
|
|
20
|
-
* @csspart button - The button
|
|
21
|
-
*/
|
|
22
|
-
export class PdHoverBox extends PdBaseUI {
|
|
23
|
-
|
|
13
|
+
class PdHoverBox extends PdBaseUI {
|
|
24
14
|
static get properties() {
|
|
25
|
-
return {
|
|
26
|
-
_visible: { type: Boolean, state: true},
|
|
27
|
-
_toBottom: { type: Boolean}
|
|
15
|
+
return {
|
|
16
|
+
_visible: { type: Boolean, state: true },
|
|
17
|
+
_toBottom: { type: Boolean }
|
|
28
18
|
};
|
|
29
19
|
}
|
|
30
|
-
|
|
31
20
|
static get styles() {
|
|
32
|
-
return [
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
return [
|
|
22
|
+
PdBaseUI.styles,
|
|
23
|
+
css`
|
|
35
24
|
|
|
36
25
|
:host {
|
|
37
26
|
|
|
@@ -84,11 +73,10 @@ export class PdHoverBox extends PdBaseUI {
|
|
|
84
73
|
}
|
|
85
74
|
}
|
|
86
75
|
|
|
87
|
-
`
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
render() {
|
|
91
|
-
|
|
76
|
+
`
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
render() {
|
|
92
80
|
return html`
|
|
93
81
|
<div class="hover-box">
|
|
94
82
|
|
|
@@ -103,28 +91,18 @@ export class PdHoverBox extends PdBaseUI {
|
|
|
103
91
|
</div>
|
|
104
92
|
`;
|
|
105
93
|
}
|
|
106
|
-
|
|
107
94
|
// eslint-disable-next-line class-methods-use-this
|
|
108
|
-
_activateInfo(e) {
|
|
109
|
-
|
|
110
|
-
const modal = this.shadowRoot.getElementById('infoViewId');
|
|
95
|
+
_activateInfo(e) {
|
|
96
|
+
const modal = this.shadowRoot.getElementById("infoViewId");
|
|
111
97
|
const rect = modal.getBoundingClientRect();
|
|
112
|
-
|
|
113
|
-
this._toBottom = !((modal.offsetHeight + rect.top + rect.height) > window.innerHeight);
|
|
98
|
+
this._toBottom = !(modal.offsetHeight + rect.top + rect.height > window.innerHeight);
|
|
114
99
|
this._visible = true;
|
|
115
|
-
|
|
116
100
|
e.stopPropagation();
|
|
117
|
-
|
|
118
|
-
// Nachteil: Wird immer bei jedem Click nach erstmaligem aktvieren ausgeführt. Der Code unten
|
|
119
|
-
// aber nur bei KLick auf das Fenster, daher zunächst so belassen.
|
|
120
|
-
// Nachtrag: Allerdings geht es nicht für mehrere Hilfetexte gleichzeitig. Zunächst zurückgenommen.
|
|
121
|
-
/* window.onclick = () => {
|
|
122
|
-
modal.style.display = "none";
|
|
123
|
-
}; */
|
|
124
101
|
}
|
|
125
|
-
|
|
126
102
|
_closeInfo() {
|
|
127
103
|
this._visible = false;
|
|
128
104
|
}
|
|
129
|
-
|
|
130
|
-
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
PdHoverBox
|
|
108
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { css, html } from "lit";
|
|
2
|
+
import "@progressive-development/pd-icon/pd-icon";
|
|
3
|
+
import { INPUT_TYPE_TEXT } from "./PdBaseUiInput.js";
|
|
4
|
+
import { PdBaseInputElement } from "./PdBaseInputElement.js";
|
|
5
|
+
/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
|
|
8
|
+
*/
|
|
9
|
+
const onlyContainsNumbers = (str) => /^\d+$/.test(str);
|
|
10
|
+
class PdInput extends PdBaseInputElement {
|
|
11
|
+
static get styles() {
|
|
12
|
+
return [
|
|
13
|
+
PdBaseInputElement.styles,
|
|
14
|
+
css`
|
|
15
|
+
* {
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
}
|
|
18
|
+
`
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
static get properties() {
|
|
22
|
+
return {
|
|
23
|
+
/**
|
|
24
|
+
* Icon to be shown inside `pd-input`.
|
|
25
|
+
*/
|
|
26
|
+
icon: { type: String },
|
|
27
|
+
secret: { type: Boolean },
|
|
28
|
+
// True for type password
|
|
29
|
+
minlength: { type: String },
|
|
30
|
+
maxlength: { type: String },
|
|
31
|
+
// max length for field,
|
|
32
|
+
onlyNumbers: { type: Boolean }
|
|
33
|
+
// if only numbers allowed => Refactor => dafür war type number vorgesehen, dieses attribut wird entfernt und auf type=number umgestellt
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
constructor() {
|
|
37
|
+
super();
|
|
38
|
+
this._inputType = INPUT_TYPE_TEXT;
|
|
39
|
+
}
|
|
40
|
+
render() {
|
|
41
|
+
const inputId = `${this.id}Input`;
|
|
42
|
+
return html`
|
|
43
|
+
${this._renderLabel(inputId)}
|
|
44
|
+
<div class="input ${this.errorMsg.length > 0 ? "error" : ""}">
|
|
45
|
+
${this.icon ? html`<pd-icon icon="${this.icon}" activeIcon @click="${this._iconClicked}"></pd-icon>` : ""}
|
|
46
|
+
<input
|
|
47
|
+
id="${inputId}"
|
|
48
|
+
name="${this.name || this.valueName || this.autoCompleteName}"
|
|
49
|
+
autocomplete=${this.autoCompleteName}
|
|
50
|
+
class="input-style ${this.gradient ? "gradient" : ""}"
|
|
51
|
+
type="${this.secret ? "password" : "text"}"
|
|
52
|
+
placeholder="${this.placeHolder}"
|
|
53
|
+
.value="${this.value}"
|
|
54
|
+
minlength="${this.minlength}"
|
|
55
|
+
maxlength="${this.maxlength}"
|
|
56
|
+
?readonly="${this.readonly}"
|
|
57
|
+
?disabled="${this.disabled}"
|
|
58
|
+
@keyup="${this._onKeyUp}"
|
|
59
|
+
@blur="${this._onBlur}"
|
|
60
|
+
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
${this._renderErrorMsg()}
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
_onKeyUp(e) {
|
|
67
|
+
if (this.onlyNumbers && !onlyContainsNumbers(this._input.value)) {
|
|
68
|
+
this._input.value = this._input.value.replace(/\D/g, "");
|
|
69
|
+
} else {
|
|
70
|
+
super._onKeyUp(e);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
_iconClicked() {
|
|
74
|
+
this.dispatchEvent(new CustomEvent("input-icon-click"));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
PdInput
|
|
79
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { css, html } from "lit";
|
|
2
|
+
import { INPUT_TYPE_AREA } from "./PdBaseUiInput.js";
|
|
3
|
+
import { PdBaseInputElement } from "./PdBaseInputElement.js";
|
|
4
|
+
/**
|
|
5
|
+
* @license
|
|
6
|
+
* Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
|
|
7
|
+
*/
|
|
8
|
+
class PdInputArea extends PdBaseInputElement {
|
|
9
|
+
static get styles() {
|
|
10
|
+
return [
|
|
11
|
+
PdBaseInputElement.styles,
|
|
12
|
+
css`
|
|
13
|
+
/* overwrite default (250px), area contains 10px scroll bar */
|
|
14
|
+
.input-style {
|
|
15
|
+
width: var(--pd-input-field-width, 240px);
|
|
16
|
+
}
|
|
17
|
+
`
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
static get properties() {
|
|
21
|
+
return {
|
|
22
|
+
rows: { type: Number },
|
|
23
|
+
cols: { type: Number },
|
|
24
|
+
minlength: { type: String },
|
|
25
|
+
maxlength: { type: String }
|
|
26
|
+
// max length for field
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
constructor() {
|
|
30
|
+
super();
|
|
31
|
+
this._inputType = INPUT_TYPE_AREA;
|
|
32
|
+
this.maxlength = 500;
|
|
33
|
+
this.rows = 2;
|
|
34
|
+
}
|
|
35
|
+
render() {
|
|
36
|
+
const inputAreaId = `${this.id}InputArea`;
|
|
37
|
+
return html`
|
|
38
|
+
${this._renderLabel(inputAreaId)}
|
|
39
|
+
<div class="input ${this.errorMsg.length > 0 ? "error" : ""}">
|
|
40
|
+
<textarea
|
|
41
|
+
id="${inputAreaId}"
|
|
42
|
+
name="${this.name || this.valueName || this.autoCompleteName}"
|
|
43
|
+
autocomplete=${this.autoCompleteName}
|
|
44
|
+
class="input-style ${this.gradient ? "gradient" : ""}"
|
|
45
|
+
rows="${this.rows}"
|
|
46
|
+
cols="${this.cols}"
|
|
47
|
+
placeholder="${this.placeHolder}"
|
|
48
|
+
?disabled="${this.disabled}"
|
|
49
|
+
?readonly="${this.readonly}"
|
|
50
|
+
.value="${this.value || ""}"
|
|
51
|
+
@keyup="${this._onKeyUp}"
|
|
52
|
+
@blur="${this._onBlur}"
|
|
53
|
+
></textarea>
|
|
54
|
+
</div>
|
|
55
|
+
${this._renderErrorMsg()}
|
|
56
|
+
`;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
PdInputArea
|
|
61
|
+
};
|