@progressive-development/pd-order 0.1.129 → 0.5.0
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 +12 -0
- package/dist/locales/be.js +10 -0
- package/dist/locales/de.js +14 -4
- package/dist/locales/en.js +10 -0
- package/dist/pd-order-contacts.js +3 -1
- package/dist/pd-order-summary.js +3 -1
- package/dist/src/PdOrderContacts.js +155 -33
- package/dist/src/PdOrderSummary.js +8 -8
- package/package.json +21 -19
- package/dist/node_modules/@progressive-development/pd-contact/pd-contact.js +0 -2
- package/dist/node_modules/@progressive-development/pd-contact/src/PdContact.js +0 -566
- package/dist/node_modules/@progressive-development/pd-content/pd-collapse.js +0 -2
- package/dist/node_modules/@progressive-development/pd-content/pd-edit-content.js +0 -2
- package/dist/node_modules/@progressive-development/pd-content/src/PdCollapse.js +0 -135
- package/dist/node_modules/@progressive-development/pd-content/src/PdEditContent.js +0 -223
- package/dist/node_modules/@progressive-development/pd-dialog/pd-popup.js +0 -2
- package/dist/node_modules/@progressive-development/pd-dialog/src/PdPopup.js +0 -112
- package/dist/node_modules/@progressive-development/pd-forms/pd-checkbox.js +0 -2
- package/dist/node_modules/@progressive-development/pd-forms/pd-form-container.js +0 -2
- package/dist/node_modules/@progressive-development/pd-forms/pd-form-row.js +0 -2
- package/dist/node_modules/@progressive-development/pd-forms/pd-hover-box.js +0 -2
- package/dist/node_modules/@progressive-development/pd-forms/pd-input.js +0 -2
- package/dist/node_modules/@progressive-development/pd-forms/pd-radio-group.js +0 -2
- package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseInputElement.js +0 -86
- package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseUi.js +0 -33
- package/dist/node_modules/@progressive-development/pd-forms/src/PdBaseUiInput.js +0 -229
- package/dist/node_modules/@progressive-development/pd-forms/src/PdCheckbox.js +0 -230
- package/dist/node_modules/@progressive-development/pd-forms/src/PdFormContainer.js +0 -167
- package/dist/node_modules/@progressive-development/pd-forms/src/PdFormRow.js +0 -92
- package/dist/node_modules/@progressive-development/pd-forms/src/PdHoverBox.js +0 -108
- package/dist/node_modules/@progressive-development/pd-forms/src/PdInput.js +0 -79
- package/dist/node_modules/@progressive-development/pd-forms/src/PdRadioGroup.js +0 -72
- package/dist/node_modules/@progressive-development/pd-forms/src/shared-input-field-styles.js +0 -152
- package/dist/node_modules/@progressive-development/pd-forms/src/shared-input-styles.js +0 -64
- package/dist/node_modules/@progressive-development/pd-icon/pd-icon.js +0 -4
- package/dist/node_modules/@progressive-development/pd-icon/src/PdIcon.js +0 -595
- package/dist/node_modules/@progressive-development/pd-price/pd-pricetable.js +0 -2
- package/dist/node_modules/@progressive-development/pd-price/src/PdPricetable.js +0 -149
- package/dist/node_modules/fecha/lib/fecha.js +0 -200
- package/dist/node_modules/lit/node_modules/lit-html/directive.js +0 -27
- package/dist/node_modules/lit/node_modules/lit-html/directives/class-map.js +0 -36
- package/dist/node_modules/lit/node_modules/lit-html/lit-html.js +0 -242
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import { css, html } from "lit";
|
|
2
|
-
import "../../pd-icon/pd-icon.js";
|
|
3
|
-
import { PdBaseUI } from "./PdBaseUi.js";
|
|
4
|
-
import { SharedInputStyles } from "./shared-input-styles.js";
|
|
5
|
-
import "../pd-hover-box.js";
|
|
6
|
-
/**
|
|
7
|
-
* @license
|
|
8
|
-
* Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
|
|
9
|
-
*
|
|
10
|
-
* Abstract base lit class for pd-input elements.
|
|
11
|
-
*
|
|
12
|
-
* Used from:
|
|
13
|
-
* - pd-checkbox
|
|
14
|
-
* - pd-input
|
|
15
|
-
* - pd-input-area
|
|
16
|
-
* - pd-radio-group
|
|
17
|
-
* - pd-range
|
|
18
|
-
* - pd-select
|
|
19
|
-
*
|
|
20
|
-
* Used to:
|
|
21
|
-
* - define css (import additional shared-input-styles.js)
|
|
22
|
-
* - define common properties (detailieren, aktuell zu viele bzw. nicht für alle sub-elemente gültig)
|
|
23
|
-
* - handle error msg (getter/setter)
|
|
24
|
-
* - helpers for validation event after change and render label/error elements.
|
|
25
|
-
*
|
|
26
|
-
* Events:
|
|
27
|
-
* - validate-form => fired when input element changed its value.
|
|
28
|
-
* - enter-pressed => fired when enter pressed.
|
|
29
|
-
* - field-change => fired when input element changed its value.
|
|
30
|
-
*
|
|
31
|
-
* Custom Properties (shared-input-styles):
|
|
32
|
-
* ... TODO
|
|
33
|
-
*
|
|
34
|
-
*/
|
|
35
|
-
const INPUT_TYPE_TEXT = 1;
|
|
36
|
-
const INPUT_TYPE_SELECT = 2;
|
|
37
|
-
const INPUT_TYPE_CHECK = 3;
|
|
38
|
-
const INPUT_TYPE_RANGE = 4;
|
|
39
|
-
const INPUT_TYPE_AREA = 5;
|
|
40
|
-
const INPUT_TYPE_DATE = 7;
|
|
41
|
-
const INPUT_TYPE_FILE = 8;
|
|
42
|
-
const KEY_RETURN = 13;
|
|
43
|
-
let delayTimer = 0;
|
|
44
|
-
const DELAY_WAIT_TIME_MS = 400;
|
|
45
|
-
class PdBaseUIInput extends PdBaseUI {
|
|
46
|
-
/**
|
|
47
|
-
* Fired when an input element change its values.
|
|
48
|
-
* @event validate-form
|
|
49
|
-
*/
|
|
50
|
-
/**
|
|
51
|
-
* Fired when enter was pressend during focus on input element.
|
|
52
|
-
* @event enter-pressed
|
|
53
|
-
*/
|
|
54
|
-
/**
|
|
55
|
-
* Fired when field-value changed.
|
|
56
|
-
* @event field-change
|
|
57
|
-
*/
|
|
58
|
-
static get styles() {
|
|
59
|
-
return [
|
|
60
|
-
PdBaseUI.styles,
|
|
61
|
-
SharedInputStyles,
|
|
62
|
-
css`
|
|
63
|
-
.label-header {
|
|
64
|
-
display: flex;
|
|
65
|
-
align-items: end;
|
|
66
|
-
justify-content: space-between;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.label-header pd-icon {
|
|
70
|
-
--pd-icon-size: 1.25rem;
|
|
71
|
-
--pd-icon-col-active: var(--pd-default-col);
|
|
72
|
-
--pd-icon-col-active-hover: var(--pd-default-hover-col);
|
|
73
|
-
--pd-icon-stroke-width: 0;
|
|
74
|
-
padding-right: 5px;
|
|
75
|
-
cursor: help;
|
|
76
|
-
}
|
|
77
|
-
`
|
|
78
|
-
];
|
|
79
|
-
}
|
|
80
|
-
static get properties() {
|
|
81
|
-
return {
|
|
82
|
-
gradient: { type: Boolean },
|
|
83
|
-
// true for gradient background
|
|
84
|
-
disabled: { type: Boolean },
|
|
85
|
-
// disabled flag for element
|
|
86
|
-
readonly: { type: Boolean },
|
|
87
|
-
// readonly flag for element
|
|
88
|
-
required: { type: Boolean },
|
|
89
|
-
// required flag for element
|
|
90
|
-
requiredMsg: { type: String },
|
|
91
|
-
// specific error msg for required field
|
|
92
|
-
helperTxt: { type: String },
|
|
93
|
-
// helper text
|
|
94
|
-
valueName: { type: String },
|
|
95
|
-
defaultRequiredChar: { type: String },
|
|
96
|
-
defaultValue: { type: String },
|
|
97
|
-
// default value for input element (used for reset) TODO: Das hier ggf. automatisch mit erstem gesetzten Wert füllen?
|
|
98
|
-
label: { type: String },
|
|
99
|
-
// label text for input
|
|
100
|
-
value: { type: String },
|
|
101
|
-
// current value (set from outside) TODO: Typ (Object, Number, Txt, Bool...)
|
|
102
|
-
_errorMsg: { type: String, state: true },
|
|
103
|
-
// errorMsg (could set fronm outside for busines validation, internal validation=> todo)
|
|
104
|
-
_inputType: { type: Number, state: true }
|
|
105
|
-
// number value for type (text, select, range....), set constructor of sub-class
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
constructor() {
|
|
109
|
-
super();
|
|
110
|
-
this.gradient = false;
|
|
111
|
-
this.disabled = false;
|
|
112
|
-
this.readonly = false;
|
|
113
|
-
this.defaultValue = "";
|
|
114
|
-
this.label = "";
|
|
115
|
-
this.value = "";
|
|
116
|
-
this._errorMsg = "";
|
|
117
|
-
this._inputType = -1;
|
|
118
|
-
this.valueName = "";
|
|
119
|
-
this.defaultRequiredChar = "*";
|
|
120
|
-
}
|
|
121
|
-
// Test: Clear input with value => Dann in BasisKlasse und alle leiten von Basis UI Element ab
|
|
122
|
-
clear() {
|
|
123
|
-
this.value = "";
|
|
124
|
-
}
|
|
125
|
-
// Test: Reset input with value
|
|
126
|
-
reset() {
|
|
127
|
-
this.value = this.defaultValue || "";
|
|
128
|
-
}
|
|
129
|
-
get errorMsg() {
|
|
130
|
-
return this._errorMsg;
|
|
131
|
-
}
|
|
132
|
-
set errorMsg(msg) {
|
|
133
|
-
this._errorMsg = msg;
|
|
134
|
-
}
|
|
135
|
-
/*
|
|
136
|
-
get value() {
|
|
137
|
-
return this._value;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
set value(newValue) {
|
|
141
|
-
console.info("Meine Werte vor Set _value, input.value, newValue: ", this._value, this._input.value, newValue);
|
|
142
|
-
this._value = newValue;
|
|
143
|
-
this._input.value = newValue;
|
|
144
|
-
console.info("Meine Werte nach Set: ", this._value, this._input.value, newValue);
|
|
145
|
-
}
|
|
146
|
-
*/
|
|
147
|
-
_generateValidateEvent() {
|
|
148
|
-
this.dispatchEvent(
|
|
149
|
-
new CustomEvent("validate-form", {
|
|
150
|
-
detail: {
|
|
151
|
-
singleElement: this,
|
|
152
|
-
errorMap: /* @__PURE__ */ new Map()
|
|
153
|
-
},
|
|
154
|
-
composed: true,
|
|
155
|
-
bubbles: true
|
|
156
|
-
})
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
_handleChangedValue(newValue, event, checkReturn, showValidateMsg) {
|
|
160
|
-
const changed = this.value !== newValue;
|
|
161
|
-
this.value = newValue;
|
|
162
|
-
const keyCode = event.keyCode ? Number(event.keyCode) : -1;
|
|
163
|
-
const eventDetail = {
|
|
164
|
-
value: newValue,
|
|
165
|
-
name: this.valueName,
|
|
166
|
-
keyCode,
|
|
167
|
-
changed
|
|
168
|
-
};
|
|
169
|
-
const handleReturn = checkReturn && keyCode === KEY_RETURN;
|
|
170
|
-
if (handleReturn) {
|
|
171
|
-
this.dispatchEvent(
|
|
172
|
-
new CustomEvent("enter-pressed", {
|
|
173
|
-
detail: eventDetail,
|
|
174
|
-
composed: true,
|
|
175
|
-
bubbles: true
|
|
176
|
-
})
|
|
177
|
-
);
|
|
178
|
-
event.preventDefault();
|
|
179
|
-
}
|
|
180
|
-
if (changed) {
|
|
181
|
-
this.dispatchEvent(
|
|
182
|
-
new CustomEvent("field-change", {
|
|
183
|
-
detail: eventDetail,
|
|
184
|
-
composed: true,
|
|
185
|
-
bubbles: true
|
|
186
|
-
})
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
if (showValidateMsg) {
|
|
190
|
-
clearTimeout(delayTimer);
|
|
191
|
-
delayTimer = setTimeout(
|
|
192
|
-
this._generateValidateEvent.bind(this),
|
|
193
|
-
DELAY_WAIT_TIME_MS
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
_renderErrorMsg() {
|
|
198
|
-
return this.errorMsg && this.errorMsg.length > 0 ? html`
|
|
199
|
-
<div class="error-box error">
|
|
200
|
-
<p class="error-msg">${this.errorMsg}</p>
|
|
201
|
-
</div>
|
|
202
|
-
` : "";
|
|
203
|
-
}
|
|
204
|
-
_renderLabel(forParam, additionalValue) {
|
|
205
|
-
return html`
|
|
206
|
-
<div class="label-header">
|
|
207
|
-
<label for="${forParam}">${this.label}${this.required && this.label ? this.defaultRequiredChar : ""}${additionalValue ? html` - <b>${additionalValue}</b>` : ""}</label>
|
|
208
|
-
${this.helperTxt ? html`
|
|
209
|
-
|
|
210
|
-
<pd-hover-box>
|
|
211
|
-
<pd-icon slot="normal-view" icon="helpIcon" activeIcon></pd-icon>
|
|
212
|
-
<p slot="info-view">${this.helperTxt}</p>
|
|
213
|
-
</pd-hover-box>
|
|
214
|
-
|
|
215
|
-
` : ""}
|
|
216
|
-
</div>
|
|
217
|
-
`;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
export {
|
|
221
|
-
INPUT_TYPE_AREA,
|
|
222
|
-
INPUT_TYPE_CHECK,
|
|
223
|
-
INPUT_TYPE_DATE,
|
|
224
|
-
INPUT_TYPE_FILE,
|
|
225
|
-
INPUT_TYPE_RANGE,
|
|
226
|
-
INPUT_TYPE_SELECT,
|
|
227
|
-
INPUT_TYPE_TEXT,
|
|
228
|
-
PdBaseUIInput
|
|
229
|
-
};
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
import { css, html } from "lit";
|
|
2
|
-
import { classMap as o } from "../../../lit/node_modules/lit-html/directives/class-map.js";
|
|
3
|
-
import "../../pd-icon/pd-icon.js";
|
|
4
|
-
import { PdBaseUIInput, INPUT_TYPE_CHECK } from "./PdBaseUiInput.js";
|
|
5
|
-
/**
|
|
6
|
-
* @license
|
|
7
|
-
* Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
|
|
8
|
-
*/
|
|
9
|
-
class PdCheckbox extends PdBaseUIInput {
|
|
10
|
-
static get properties() {
|
|
11
|
-
return {
|
|
12
|
-
isSwitch: { type: Boolean },
|
|
13
|
-
_hasInner: { type: Boolean, state: true }
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
constructor() {
|
|
17
|
-
super();
|
|
18
|
-
this._inputType = INPUT_TYPE_CHECK;
|
|
19
|
-
}
|
|
20
|
-
static get styles() {
|
|
21
|
-
return [
|
|
22
|
-
PdBaseUIInput.styles,
|
|
23
|
-
css`
|
|
24
|
-
:host {
|
|
25
|
-
display: inline-block;
|
|
26
|
-
|
|
27
|
-
/* Style for active checkbox => use defaults from pd-icon if no custom properties set */
|
|
28
|
-
--pd-icon-col-active: var(--pd-cb-col);
|
|
29
|
-
--pd-icon-col-active-hover: var(--pd-cb-col-hover);
|
|
30
|
-
--pd-icon-bg-col-active: var(--pd-cb-bg-col);
|
|
31
|
-
--pd-icon-stroke-col-active: var(--pd-cb-stroke-col);
|
|
32
|
-
--pd-icon-stroke-col-active-hover: var(--pd-cb-stroke-col-hover);
|
|
33
|
-
|
|
34
|
-
/* Style for inactive checkbox */
|
|
35
|
-
--pd-icon-col: var(--pd-cb-unset-col);
|
|
36
|
-
--pd-icon-col-hover: var(--pd-cb-unset-col-hover);
|
|
37
|
-
--pd-icon-bg-col: var(--pd-cb-unset-bg-col);
|
|
38
|
-
--pd-icon-stroke-col: var(--pd-cb-unset-stroke-col);
|
|
39
|
-
--pd-icon-stroke-col-hover: var(--pd-cb-unset-stroke-col-hover);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/* Switch pd-icon => Prüfen, bei mir musste ich reflect setzten, wird das verwendet? */
|
|
43
|
-
:host([isSwitch]) {
|
|
44
|
-
/* derzeit keine Angaben */
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.div-container {
|
|
48
|
-
display: flex;
|
|
49
|
-
align-items: center;
|
|
50
|
-
cursor: pointer;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.div-container.disabled {
|
|
54
|
-
opacity: 0.5;
|
|
55
|
-
cursor: auto;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.div-container.readonly {
|
|
59
|
-
cursor: auto;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/*
|
|
63
|
-
* Class checkbox for icon and a element (checkbox case)
|
|
64
|
-
*/
|
|
65
|
-
.checkbox {
|
|
66
|
-
display: flex;
|
|
67
|
-
border-radius: 4px;
|
|
68
|
-
line-height: 0;
|
|
69
|
-
align-items: center;
|
|
70
|
-
justify-content: center;
|
|
71
|
-
/*
|
|
72
|
-
Wurde das hier für Border verwendet? Aktuell border in folgendem Element gesetzt
|
|
73
|
-
background-color: var(--pd-cb-border-col, var(--pd-primary-col, #067394));
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.checkbox pd-icon {
|
|
79
|
-
margin-right: .2rem;
|
|
80
|
-
margin-bottom: .2rem;
|
|
81
|
-
border: 2px solid var(--pd-cb-border-col, var(--pd-default-col));
|
|
82
|
-
border-radius: var(--pd-cb-border-radius, 3px);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.label {
|
|
86
|
-
margin-left: 0.1rem;
|
|
87
|
-
color: var(--pd-cb-font-col, var(--pd-default-font-input-col));
|
|
88
|
-
font-family: var(--pd-default-font-input-family);
|
|
89
|
-
text-align: left;
|
|
90
|
-
font-size: var(--pd-default-font-input-size);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.readonly .label {
|
|
94
|
-
color: var(--pd-cb-font-col-readonly, #4d4d4d);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.readonly .checkbox pd-icon {
|
|
98
|
-
border-color: var(--pd-cb-border-col-readonly, transparent);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/* Switch styles */
|
|
102
|
-
.switch {
|
|
103
|
-
height: var(--pd-cb-switch-height);
|
|
104
|
-
position: relative;
|
|
105
|
-
outline: 0;
|
|
106
|
-
-webkit-user-select: none;
|
|
107
|
-
-moz-user-select: none;
|
|
108
|
-
-ms-user-select: none;
|
|
109
|
-
user-select: none;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.switch .label {
|
|
113
|
-
margin-left: 0.5rem;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
.switch-paddle {
|
|
117
|
-
display: inline-block;
|
|
118
|
-
vertical-align: baseline;
|
|
119
|
-
margin: 0;
|
|
120
|
-
position: relative;
|
|
121
|
-
min-width: 4rem;
|
|
122
|
-
max-width: 4rem;
|
|
123
|
-
height: 2rem;
|
|
124
|
-
border-radius: 0;
|
|
125
|
-
background: var(--pd-cb-switch-paddle-col, var(--pd-default-col));
|
|
126
|
-
font-weight: inherit;
|
|
127
|
-
color: inherit;
|
|
128
|
-
cursor: pointer;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
.switch-paddle pd-icon {
|
|
132
|
-
position: absolute;
|
|
133
|
-
top: 0;
|
|
134
|
-
left: 0;
|
|
135
|
-
display: block;
|
|
136
|
-
width: 1.5rem;
|
|
137
|
-
height: 1.5rem;
|
|
138
|
-
-webkit-transform: translate3d(0, 0, 0);
|
|
139
|
-
transform: translate3d(0, 0, 0);
|
|
140
|
-
border: 2px solid var(--pd-cb-border-col, var(--pd-default-col));
|
|
141
|
-
box-shadow: rgba(0, 0, 0, 0.15) 1.95px 1.95px 2.6px;
|
|
142
|
-
border-radius: var(--pd-cb-border-radius, 4px);
|
|
143
|
-
-webkit-transition: all 0.25s ease-out;
|
|
144
|
-
transition: all 0.25s ease-out;
|
|
145
|
-
content: '';
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
.disabled .switch-paddle {
|
|
149
|
-
cursor: auto;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
.readonly .switch-paddle {
|
|
153
|
-
cursor: auto;
|
|
154
|
-
max-width: 2rem;
|
|
155
|
-
min-width: 2rem;
|
|
156
|
-
background: none;
|
|
157
|
-
|
|
158
|
-
/* Prüfen TODO
|
|
159
|
-
--pd-icon-bg: transparent;
|
|
160
|
-
--pd-icon-fill: var(--card-dark-red);
|
|
161
|
-
--pd-icon-fill-hover: var(--pd-icon-fill);
|
|
162
|
-
--pd-icon-fill-active: var(--card-medium-green);
|
|
163
|
-
*/
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
.readonly .switch-paddle pd-icon {
|
|
167
|
-
border-color: var(--pd-cb-border-col-readonly, transparent);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
.readonly .isChecked.switch-paddle pd-icon {
|
|
171
|
-
transform: translate3d(0, 0, 0);
|
|
172
|
-
left: 0rem;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
.isChecked.switch-paddle pd-icon {
|
|
176
|
-
left: 2.25rem;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
@media (min-width: 580px) {
|
|
180
|
-
:host {
|
|
181
|
-
font-size: 1rem;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
`
|
|
185
|
-
];
|
|
186
|
-
}
|
|
187
|
-
render() {
|
|
188
|
-
if (!this._hasInnerSet) {
|
|
189
|
-
this._hasInnerSet = true;
|
|
190
|
-
this._hasInner = !!this.innerHTML.trim().length;
|
|
191
|
-
}
|
|
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 };
|
|
195
|
-
const inputId = `${this.id}Check`;
|
|
196
|
-
return html`
|
|
197
|
-
${this._renderLabel(inputId)}
|
|
198
|
-
<div @click="${this.onClick}" class="${o(classMapVal)}">
|
|
199
|
-
<a href="#" @click="${this.linkClick}" @keypress="${this.onKeyPress}" class="${o(aClassMap)}">
|
|
200
|
-
<pd-icon icon="${this.isSwitch ? "checkBox" : "checkBoxOnlyCheck"}" class="small" ?activeIcon="${checked}"></pd-icon>
|
|
201
|
-
</a>
|
|
202
|
-
${this._hasInner ? html`
|
|
203
|
-
<span class="label">
|
|
204
|
-
<slot></slot>
|
|
205
|
-
</span>` : ""}
|
|
206
|
-
</div>
|
|
207
|
-
${this._renderErrorMsg()}
|
|
208
|
-
`;
|
|
209
|
-
}
|
|
210
|
-
onClick(e) {
|
|
211
|
-
if (this.disabled || this.readonly) {
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
const checked = this.value === "true";
|
|
215
|
-
this._handleChangedValue(checked ? "false" : "true", e);
|
|
216
|
-
}
|
|
217
|
-
onKeyPress(e) {
|
|
218
|
-
e.preventDefault();
|
|
219
|
-
if (e.keyCode === 32 || e.code === "Space") {
|
|
220
|
-
this.onClick(e);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
// eslint-disable-next-line class-methods-use-this
|
|
224
|
-
linkClick(e) {
|
|
225
|
-
e.preventDefault();
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
export {
|
|
229
|
-
PdCheckbox
|
|
230
|
-
};
|
|
@@ -1,167 +0,0 @@
|
|
|
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";
|
|
5
|
-
/**
|
|
6
|
-
* @license
|
|
7
|
-
* Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
|
|
8
|
-
*
|
|
9
|
-
* Lit element container for pd input elements.
|
|
10
|
-
*
|
|
11
|
-
* Used to:
|
|
12
|
-
* - Automatically validation of form content
|
|
13
|
-
* - Success/NotReady information for form-container
|
|
14
|
-
*/
|
|
15
|
-
class PdFormContainer extends PdBaseUI {
|
|
16
|
-
static get styles() {
|
|
17
|
-
return [
|
|
18
|
-
PdBaseUI.styles,
|
|
19
|
-
css`
|
|
20
|
-
:host {
|
|
21
|
-
display: flex;
|
|
22
|
-
flex-direction: column;
|
|
23
|
-
align-items: left;
|
|
24
|
-
gap: 20px;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.validation-info-container {
|
|
28
|
-
padding-top: var(--pd-form-row-padding-top, 10px);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.validation-info {
|
|
32
|
-
font-family: var(--pd-default-font-content-family);
|
|
33
|
-
font-size: var(--pd-form-info-font-size, 0.8em);
|
|
34
|
-
padding: 0.5em;
|
|
35
|
-
color:#58585a;
|
|
36
|
-
border-radius: var(--pd-border-radius, 0);
|
|
37
|
-
-moz-border-radius: var(--pd-border-radius, 0);
|
|
38
|
-
width:70%;
|
|
39
|
-
max-width:780px;
|
|
40
|
-
min-width:200px;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.filled {
|
|
44
|
-
border-left: 4px solid var(--pd-default-success-col);
|
|
45
|
-
border-right: 4px solid var(--pd-default-success-col);
|
|
46
|
-
border-top: 1px solid var(--pd-default-success-col);
|
|
47
|
-
border-bottom: 1px solid var(--pd-default-success-col);
|
|
48
|
-
background-color: var(--pd-default-success-light-col);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.unfilled {
|
|
52
|
-
border-left: 4px solid var(--pd-default-error-col);
|
|
53
|
-
border-right: 4px solid var(--pd-default-error-col);
|
|
54
|
-
border-top: 1px solid var(--pd-default-error-col);
|
|
55
|
-
border-bottom: 1px solid var(--pd-default-error-col);
|
|
56
|
-
background-color: var(--pd-default-error-light-col);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
`
|
|
60
|
-
];
|
|
61
|
-
}
|
|
62
|
-
static get properties() {
|
|
63
|
-
return {
|
|
64
|
-
requiredFieldInfo: { type: Boolean },
|
|
65
|
-
commonError: { type: String },
|
|
66
|
-
_requiredFieldsValid: { type: Boolean, state: true }
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
connectedCallback() {
|
|
70
|
-
super.connectedCallback();
|
|
71
|
-
this.addEventListener("validate-form", this._validateForm);
|
|
72
|
-
}
|
|
73
|
-
disconnectedCallback() {
|
|
74
|
-
super.connectedCallback();
|
|
75
|
-
this.removeEventListener("validate-form", this._validateForm);
|
|
76
|
-
}
|
|
77
|
-
render() {
|
|
78
|
-
return html`
|
|
79
|
-
<form>
|
|
80
|
-
<slot></slot>
|
|
81
|
-
${this.requiredFieldInfo || this.commonError ? html`
|
|
82
|
-
<div class="validation-info-container">
|
|
83
|
-
<p class="validation-info ${this._requiredFieldsValid && (!this.commonError || this.commonError === "") ? "filled" : "unfilled"}">
|
|
84
|
-
${this.commonError || (this._requiredFieldsValid ? msg("* Pflichtfelder ausgefüllt", { desc: "#pd.form.required.valid#" }) : msg("* Pflichtfeld", { desc: "#pd.form.required.info#" }))}
|
|
85
|
-
</p>
|
|
86
|
-
</div>` : ""}
|
|
87
|
-
</form>
|
|
88
|
-
`;
|
|
89
|
-
}
|
|
90
|
-
_validateForm(e) {
|
|
91
|
-
const reqEl = this.querySelectorAll("[required]");
|
|
92
|
-
reqEl.forEach((el) => {
|
|
93
|
-
const tmpEl = el;
|
|
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", { desc: "#pd.form.field.required#" });
|
|
96
|
-
if (!e.detail.singleElement || e.detail.singleElement === el) {
|
|
97
|
-
tmpEl.errorMsg = erMsg;
|
|
98
|
-
}
|
|
99
|
-
e.detail.errorMap.set(el.id, erMsg);
|
|
100
|
-
} else if (el.validate && typeof el.validate === "function" && el.validate(e)) {
|
|
101
|
-
const errMsg = el.validate(e);
|
|
102
|
-
if (!e.detail.singleElement || e.detail.singleElement === el) {
|
|
103
|
-
tmpEl.errorMsg = errMsg;
|
|
104
|
-
}
|
|
105
|
-
e.detail.errorMap.set(el.id, errMsg);
|
|
106
|
-
} else if (!e.detail.singleElement || e.detail.singleElement === el) {
|
|
107
|
-
tmpEl.errorMsg = "";
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
this._requiredFieldsValid = e.detail.errorMap.size === 0;
|
|
111
|
-
const validateByType = (fieldType, validFunc, invalidMsgTxt) => {
|
|
112
|
-
if (e.detail.singleElement && e.detail.singleElement.getAttribute("field-type") !== fieldType) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const reqSpecEl = e.detail.singleElement ? [e.detail.singleElement] : this.querySelectorAll(`[field-type=${fieldType}]`);
|
|
116
|
-
reqSpecEl.forEach((el) => {
|
|
117
|
-
const tmpEl = el;
|
|
118
|
-
if (!e.detail.errorMap.has(el.id) && el.value && el.value.length > 0) {
|
|
119
|
-
if (validFunc(el.value)) {
|
|
120
|
-
tmpEl.errorMsg = "";
|
|
121
|
-
} else {
|
|
122
|
-
tmpEl.errorMsg = invalidMsgTxt || `Invalid format for ${fieldType}`;
|
|
123
|
-
e.detail.errorMap.set(el.id, tmpEl.errorMsg);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
|
-
validateByType(
|
|
129
|
-
"mail",
|
|
130
|
-
PdFormContainer._mailIsValid,
|
|
131
|
-
msg("Format mail@test.de verwenden", { desc: "#pd.form.field.invalid.mail#" })
|
|
132
|
-
);
|
|
133
|
-
validateByType(
|
|
134
|
-
"phone",
|
|
135
|
-
PdFormContainer._phoneIsValid,
|
|
136
|
-
msg("Format +49123 123456 verwenden", { desc: "#pd.form.field.invalid.phone#" })
|
|
137
|
-
);
|
|
138
|
-
validateByType(
|
|
139
|
-
"vat",
|
|
140
|
-
PdFormContainer._vatIsValid,
|
|
141
|
-
msg("Format DE0123456789 verwenden", { desc: "#pd.form.field.invalid.vat#" })
|
|
142
|
-
);
|
|
143
|
-
validateByType(
|
|
144
|
-
"number",
|
|
145
|
-
(val) => !isNaN(val),
|
|
146
|
-
msg("Nur Zahlen erlaubt", { desc: "#pd.form.field.invalid.number#" })
|
|
147
|
-
);
|
|
148
|
-
if (e.detail.singleElement) {
|
|
149
|
-
e.stopPropagation();
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
static _mailIsValid(email) {
|
|
153
|
-
const mValid = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
|
154
|
-
return mValid;
|
|
155
|
-
}
|
|
156
|
-
static _vatIsValid(vat) {
|
|
157
|
-
const mValid = /^[A-Z]{2}[0-9]{8,12}$/.test(vat);
|
|
158
|
-
return mValid;
|
|
159
|
-
}
|
|
160
|
-
static _phoneIsValid(nr) {
|
|
161
|
-
const mValid = /^\+?[0-9 ]{7,15}$/.test(nr);
|
|
162
|
-
return mValid;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
export {
|
|
166
|
-
PdFormContainer
|
|
167
|
-
};
|