@progressive-development/pd-forms 0.6.5 → 0.6.7

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.
Files changed (64) hide show
  1. package/dist/generated/locales/be.d.ts +6 -1
  2. package/dist/generated/locales/be.d.ts.map +1 -1
  3. package/dist/generated/locales/de.d.ts +7 -2
  4. package/dist/generated/locales/de.d.ts.map +1 -1
  5. package/dist/generated/locales/en.d.ts +6 -1
  6. package/dist/generated/locales/en.d.ts.map +1 -1
  7. package/dist/index.d.ts +2 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +3 -1
  10. package/dist/locales/be.js +8 -2
  11. package/dist/locales/de.js +9 -3
  12. package/dist/locales/en.js +8 -2
  13. package/dist/pd-base-input-element.d.ts +4 -1
  14. package/dist/pd-base-input-element.d.ts.map +1 -1
  15. package/dist/pd-base-input-element.js +31 -5
  16. package/dist/pd-base-ui-input.d.ts +31 -7
  17. package/dist/pd-base-ui-input.d.ts.map +1 -1
  18. package/dist/pd-base-ui-input.js +226 -50
  19. package/dist/pd-checkbox.d.ts +4 -3
  20. package/dist/pd-checkbox.d.ts.map +1 -1
  21. package/dist/pd-checkbox.js +91 -62
  22. package/dist/pd-form-container.d.ts +12 -8
  23. package/dist/pd-form-container.d.ts.map +1 -1
  24. package/dist/pd-form-container.js +121 -88
  25. package/dist/pd-icon-panel-button.d.ts.map +1 -1
  26. package/dist/pd-icon-panel-button.js +3 -1
  27. package/dist/pd-input-area.d.ts +3 -1
  28. package/dist/pd-input-area.d.ts.map +1 -1
  29. package/dist/pd-input-area.js +28 -1
  30. package/dist/pd-input-file.d.ts +3 -2
  31. package/dist/pd-input-file.d.ts.map +1 -1
  32. package/dist/pd-input-file.js +21 -16
  33. package/dist/pd-input-time.d.ts +2 -1
  34. package/dist/pd-input-time.d.ts.map +1 -1
  35. package/dist/pd-input-time.js +19 -6
  36. package/dist/pd-input.d.ts +3 -1
  37. package/dist/pd-input.d.ts.map +1 -1
  38. package/dist/pd-input.js +32 -5
  39. package/dist/pd-radio-group.d.ts +4 -1
  40. package/dist/pd-radio-group.d.ts.map +1 -1
  41. package/dist/pd-radio-group.js +54 -34
  42. package/dist/pd-range.d.ts +8 -2
  43. package/dist/pd-range.d.ts.map +1 -1
  44. package/dist/pd-range.js +59 -5
  45. package/dist/pd-select.d.ts +6 -2
  46. package/dist/pd-select.d.ts.map +1 -1
  47. package/dist/pd-select.js +27 -3
  48. package/dist/stories/checkbox.stories.d.ts +1 -0
  49. package/dist/stories/checkbox.stories.d.ts.map +1 -1
  50. package/dist/stories/form-container2.stories.d.ts +8 -0
  51. package/dist/stories/form-container2.stories.d.ts.map +1 -0
  52. package/dist/stories/form-container3.stories.d.ts +8 -0
  53. package/dist/stories/form-container3.stories.d.ts.map +1 -0
  54. package/dist/stories/pd-hover-box.stories.d.ts +8 -0
  55. package/dist/stories/pd-hover-box.stories.d.ts.map +1 -0
  56. package/dist/styles/shared-input-field-styles.d.ts.map +1 -1
  57. package/dist/styles/shared-input-field-styles.js +21 -9
  58. package/dist/types.d.ts +15 -0
  59. package/dist/types.d.ts.map +1 -1
  60. package/dist/types.js +4 -0
  61. package/dist/validators.d.ts +10 -0
  62. package/dist/validators.d.ts.map +1 -0
  63. package/dist/validators.js +41 -0
  64. package/package.json +2 -2
@@ -1,8 +1,10 @@
1
1
  import { css, html } from "lit";
2
2
  import { property, state } from "lit/decorators.js";
3
+ import { pdIcons } from "@progressive-development/pd-icon";
3
4
  import "@progressive-development/pd-icon/pd-icon";
4
5
  import { PdBaseUI } from "./pd-base-ui.js";
5
6
  import { SharedInputStyles } from "./styles/shared-input-styles.js";
7
+ import { requiredValidator, requiredSelectValidator, requiredRangeValidator, requiredCheckedValidator, emailValidator, numberValidator, phoneValidator, vatValidator } from "./validators.js";
6
8
  import "./pd-hover-box.js";
7
9
  var __defProp = Object.defineProperty;
8
10
  var __decorateClass = (decorators, target, key, kind) => {
@@ -22,8 +24,6 @@ const INPUT_TYPE_DATE = 7;
22
24
  const INPUT_TYPE_FILE = 8;
23
25
  const INPUT_TYPE_TIME = 9;
24
26
  const KEY_RETURN = "Enter";
25
- let delayTimer;
26
- const DELAY_WAIT_TIME_MS = 400;
27
27
  const _PdBaseUIInput = class _PdBaseUIInput extends PdBaseUI {
28
28
  constructor() {
29
29
  super(...arguments);
@@ -35,11 +35,30 @@ const _PdBaseUIInput = class _PdBaseUIInput extends PdBaseUI {
35
35
  this.helperTxt = "";
36
36
  this.valueName = "";
37
37
  this.defaultRequiredChar = "*";
38
- this.defaultValue = "";
39
38
  this.label = "";
40
- this.value = "";
39
+ this.fieldType = "text";
40
+ this.initValue = "";
41
+ this._valid = false;
42
+ this._invalid = false;
43
+ this._dirty = false;
44
+ this._pristine = true;
45
+ this._touched = false;
46
+ this._focused = false;
41
47
  this._errorMsg = "";
48
+ this._value = "";
42
49
  this._inputType = -1;
50
+ this._validators = [];
51
+ }
52
+ update(changedProps) {
53
+ if (changedProps.has("initValue") && this.initValue) {
54
+ this._value = this.initValue;
55
+ }
56
+ super.update(changedProps);
57
+ }
58
+ firstUpdated() {
59
+ this.runValidators(true).then((result) => {
60
+ this._registerAtContainer(result);
61
+ });
43
62
  }
44
63
  get errorMsg() {
45
64
  return this._errorMsg;
@@ -47,66 +66,156 @@ const _PdBaseUIInput = class _PdBaseUIInput extends PdBaseUI {
47
66
  set errorMsg(msg) {
48
67
  this._errorMsg = msg;
49
68
  }
50
- clear() {
51
- this.value = "";
52
- this._errorMsg = "";
69
+ get value() {
70
+ return this._value;
71
+ }
72
+ set value(val) {
73
+ this._handleChangedValue(val, void 0, true);
53
74
  }
54
75
  reset() {
55
- this.value = this.defaultValue || "";
56
- this._errorMsg = "";
76
+ this._value = this._getInitialValue(true);
77
+ this.runValidators(true).then((result) => {
78
+ this._errorMsg = "";
79
+ this._valid = false;
80
+ this._invalid = false;
81
+ this._pristine = true;
82
+ this._dirty = false;
83
+ this._touched = false;
84
+ this._focused = false;
85
+ this.dispatchEvent(
86
+ new CustomEvent("pd-form-element-change", {
87
+ detail: {
88
+ value: this._value,
89
+ name: this.valueName || this.id || "field",
90
+ state: {
91
+ pristine: this._pristine,
92
+ dirty: this._dirty,
93
+ touched: this._touched,
94
+ focused: this._focused,
95
+ valid: result,
96
+ invalid: !result
97
+ }
98
+ },
99
+ bubbles: true,
100
+ composed: true
101
+ })
102
+ );
103
+ });
104
+ }
105
+ clear() {
106
+ this.reset();
107
+ this._value = "";
57
108
  }
58
- _generateValidateEvent() {
109
+ _registerAtContainer(valid) {
59
110
  this.dispatchEvent(
60
- new CustomEvent("validate-form", {
111
+ new CustomEvent("pd-form-element-register", {
61
112
  detail: {
62
- singleElement: this,
63
- errorMap: /* @__PURE__ */ new Map()
113
+ name: this.valueName || this.id || "field",
114
+ value: this._getInitialValue(),
115
+ state: {
116
+ pristine: this._pristine,
117
+ dirty: this._dirty,
118
+ touched: this._touched,
119
+ focused: this._focused,
120
+ valid,
121
+ invalid: !valid
122
+ }
64
123
  },
65
- composed: true,
66
- bubbles: true
124
+ bubbles: true,
125
+ composed: true
67
126
  })
68
127
  );
69
128
  }
70
- _handleChangedValue(newValue, event, checkReturn = false, showValidateMsg = false) {
71
- const changed = this.value !== newValue;
129
+ _collectValidators() {
130
+ const validators = [];
131
+ if (this.required) {
132
+ validators.push(requiredValidator);
133
+ if (this._inputType === INPUT_TYPE_SELECT) {
134
+ validators.push(requiredSelectValidator);
135
+ }
136
+ if (this._inputType === INPUT_TYPE_RANGE) {
137
+ validators.push(requiredRangeValidator);
138
+ }
139
+ if (this._inputType === INPUT_TYPE_CHECK) {
140
+ validators.push(requiredCheckedValidator);
141
+ }
142
+ }
143
+ if (this.fieldType === "mail") {
144
+ validators.push(emailValidator);
145
+ }
146
+ if (this.fieldType === "number") {
147
+ validators.push(numberValidator);
148
+ }
149
+ if (this.fieldType === "phone") {
150
+ validators.push(phoneValidator);
151
+ }
152
+ if (this.fieldType === "vat") {
153
+ validators.push(vatValidator);
154
+ }
155
+ return [...validators, ...this._validators];
156
+ }
157
+ _handleChangedValue(newValue, event, dispatchEvent = false, checkReturn = false) {
158
+ const changed = this._value !== newValue;
72
159
  let keyCode = "-1";
73
- if (event instanceof KeyboardEvent) {
160
+ if (event && event instanceof KeyboardEvent) {
74
161
  keyCode = event.key;
75
162
  }
76
- this.value = newValue;
77
- const eventDetail = {
78
- value: newValue,
79
- name: this.valueName,
80
- keyCode,
81
- changed
82
- };
83
163
  if (checkReturn && keyCode === KEY_RETURN) {
84
164
  this.dispatchEvent(
85
165
  new CustomEvent("enter-pressed", {
86
- detail: eventDetail,
87
- composed: true,
88
- bubbles: true
166
+ detail: {
167
+ value: newValue,
168
+ name: this.valueName || this.id || "field",
169
+ keyCode,
170
+ changed
171
+ },
172
+ bubbles: true,
173
+ composed: true
89
174
  })
90
175
  );
91
- event.preventDefault();
176
+ event == null ? void 0 : event.preventDefault();
92
177
  }
93
178
  if (changed) {
94
- this.dispatchEvent(
95
- new CustomEvent("field-change", {
96
- detail: eventDetail,
97
- composed: true,
98
- bubbles: true
99
- })
100
- );
101
- }
102
- if (showValidateMsg) {
103
- clearTimeout(delayTimer);
104
- delayTimer = window.setTimeout(
105
- () => this._generateValidateEvent(),
106
- DELAY_WAIT_TIME_MS
107
- );
179
+ this._value = newValue;
180
+ this._pristine = false;
181
+ this._dirty = true;
182
+ this.runValidators().then((result) => {
183
+ if (dispatchEvent) {
184
+ this._dispatchChange(newValue);
185
+ }
186
+ });
108
187
  }
109
188
  }
189
+ _dispatchChange(value, eventName) {
190
+ this.dispatchEvent(
191
+ new CustomEvent(eventName || "pd-form-element-change", {
192
+ detail: {
193
+ value,
194
+ name: this.valueName || this.id || "field",
195
+ state: {
196
+ pristine: this._pristine,
197
+ dirty: this._dirty,
198
+ touched: this._touched,
199
+ focused: this._focused,
200
+ valid: this._valid,
201
+ invalid: this._invalid
202
+ }
203
+ },
204
+ bubbles: true,
205
+ composed: true
206
+ })
207
+ );
208
+ }
209
+ getClassmap(specific = {}) {
210
+ return {
211
+ ...specific,
212
+ error: this._invalid,
213
+ valid: this._valid && this._value,
214
+ focus: this._focused,
215
+ prestine: this._pristine,
216
+ dirty: this._dirty
217
+ };
218
+ }
110
219
  _renderErrorMsg() {
111
220
  return this._errorMsg ? html`
112
221
  <div class="error-box error">
@@ -125,8 +234,9 @@ const _PdBaseUIInput = class _PdBaseUIInput extends PdBaseUI {
125
234
  <pd-hover-box>
126
235
  <pd-icon
127
236
  slot="normal-view"
128
- icon="helpIcon"
237
+ icon="${pdIcons.ICON_HELP}"
129
238
  activeIcon
239
+ class="help-icon"
130
240
  ></pd-icon>
131
241
  <p slot="info-view">${this.helperTxt}</p>
132
242
  </pd-hover-box>
@@ -134,6 +244,52 @@ const _PdBaseUIInput = class _PdBaseUIInput extends PdBaseUI {
134
244
  </div>
135
245
  `;
136
246
  }
247
+ runValidators(dryRun) {
248
+ if (!dryRun) {
249
+ this._errorMsg = "";
250
+ this._valid = true;
251
+ this._invalid = false;
252
+ }
253
+ const validators = this._collectValidators();
254
+ const asyncChecks = [];
255
+ for (const validator of validators) {
256
+ const result = validator(this._value);
257
+ if (result instanceof Promise) {
258
+ asyncChecks.push(result);
259
+ } else if (result) {
260
+ if (!dryRun) {
261
+ this._errorMsg = result;
262
+ this._valid = false;
263
+ this._invalid = true;
264
+ }
265
+ return Promise.resolve(false);
266
+ }
267
+ }
268
+ if (asyncChecks.length > 0) {
269
+ return Promise.all(asyncChecks).then((results) => {
270
+ const firstError = results.find((r) => r !== null);
271
+ if (firstError) {
272
+ if (!dryRun) {
273
+ this._errorMsg = firstError;
274
+ this._valid = false;
275
+ this._invalid = true;
276
+ }
277
+ return Promise.resolve(false);
278
+ } else {
279
+ if (!dryRun) {
280
+ this._errorMsg = "";
281
+ this._valid = true;
282
+ this._invalid = false;
283
+ }
284
+ }
285
+ return Promise.resolve(true);
286
+ });
287
+ }
288
+ return Promise.resolve(true);
289
+ }
290
+ _getInitialValue(reset) {
291
+ return reset ? this.initValue || "" : this.initValue || this._value || "";
292
+ }
137
293
  };
138
294
  _PdBaseUIInput.styles = [
139
295
  PdBaseUI.styles,
@@ -145,12 +301,11 @@ _PdBaseUIInput.styles = [
145
301
  justify-content: space-between;
146
302
  }
147
303
 
148
- .label-header pd-icon {
149
- --pd-icon-size: 1.25rem;
304
+ .help-icon {
305
+ --pd-icon-size: 20px;
150
306
  --pd-icon-col-active: var(--pd-default-col);
151
307
  --pd-icon-col-active-hover: var(--pd-default-hover-col);
152
308
  --pd-icon-stroke-width: 0;
153
- padding-right: 5px;
154
309
  cursor: help;
155
310
  }
156
311
  `
@@ -182,16 +337,37 @@ __decorateClass([
182
337
  ], PdBaseUIInput.prototype, "defaultRequiredChar");
183
338
  __decorateClass([
184
339
  property({ type: String })
185
- ], PdBaseUIInput.prototype, "defaultValue");
340
+ ], PdBaseUIInput.prototype, "label");
186
341
  __decorateClass([
187
342
  property({ type: String })
188
- ], PdBaseUIInput.prototype, "label");
343
+ ], PdBaseUIInput.prototype, "fieldType");
189
344
  __decorateClass([
190
345
  property({ type: String })
191
- ], PdBaseUIInput.prototype, "value");
346
+ ], PdBaseUIInput.prototype, "initValue");
347
+ __decorateClass([
348
+ state()
349
+ ], PdBaseUIInput.prototype, "_valid");
350
+ __decorateClass([
351
+ state()
352
+ ], PdBaseUIInput.prototype, "_invalid");
353
+ __decorateClass([
354
+ state()
355
+ ], PdBaseUIInput.prototype, "_dirty");
356
+ __decorateClass([
357
+ state()
358
+ ], PdBaseUIInput.prototype, "_pristine");
359
+ __decorateClass([
360
+ state()
361
+ ], PdBaseUIInput.prototype, "_touched");
362
+ __decorateClass([
363
+ state()
364
+ ], PdBaseUIInput.prototype, "_focused");
192
365
  __decorateClass([
193
366
  state()
194
367
  ], PdBaseUIInput.prototype, "_errorMsg");
368
+ __decorateClass([
369
+ state()
370
+ ], PdBaseUIInput.prototype, "_value");
195
371
  __decorateClass([
196
372
  state()
197
373
  ], PdBaseUIInput.prototype, "_inputType");
@@ -1,14 +1,15 @@
1
1
  import { CSSResultGroup } from 'lit';
2
2
  import { PdBaseUIInput } from './pd-base-ui-input';
3
3
  export declare class PdCheckbox extends PdBaseUIInput {
4
- isSwitch: boolean;
5
- private _hasInner;
4
+ checkType: "CHECK" | "RADIO" | "SWITCH";
6
5
  static styles: CSSResultGroup;
7
6
  constructor();
8
- firstUpdated(): void;
7
+ setCheckedState(newValue: "true" | "false"): void;
9
8
  render(): import('lit-html').TemplateResult<1>;
10
9
  private _onClick;
11
10
  private _onKeyPress;
12
11
  private _onLinkClick;
12
+ protected _getInitialValue(reset?: boolean): string;
13
+ clear(): void;
13
14
  }
14
15
  //# sourceMappingURL=pd-checkbox.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pd-checkbox.d.ts","sourceRoot":"","sources":["../src/pd-checkbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAa,cAAc,EAAE,MAAM,KAAK,CAAC;AAIhD,OAAO,0CAA0C,CAAC;AAElD,OAAO,EAAE,aAAa,EAAoB,MAAM,oBAAoB,CAAC;AAErE,qBACa,UAAW,SAAQ,aAAa;IAE3C,QAAQ,UAAS;IAGjB,OAAO,CAAC,SAAS,CAAS;IAE1B,OAAgB,MAAM,EAAE,cAAc,CAmKpC;;IAOO,YAAY;IAIZ,MAAM;IAuCf,OAAO,CAAC,QAAQ;IAOhB,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,YAAY;CAGrB"}
1
+ {"version":3,"file":"pd-checkbox.d.ts","sourceRoot":"","sources":["../src/pd-checkbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAa,cAAc,EAAE,MAAM,KAAK,CAAC;AAIhD,OAAO,0CAA0C,CAAC;AAElD,OAAO,EAAE,aAAa,EAAoB,MAAM,oBAAoB,CAAC;AAGrE,qBACa,UAAW,SAAQ,aAAa;IAE3C,SAAS,EAAE,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAW;IAElD,OAAgB,MAAM,EAAE,cAAc,CAgMpC;;IAOK,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI;IAI/C,MAAM;IAuCf,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,YAAY;IAIpB,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM;IAM5C,KAAK,IAAI,IAAI;CAGrB"}
@@ -1,8 +1,9 @@
1
1
  import { css, html } from "lit";
2
- import { property, state, customElement } from "lit/decorators.js";
2
+ import { property, customElement } from "lit/decorators.js";
3
3
  import { classMap } from "lit/directives/class-map.js";
4
4
  import "@progressive-development/pd-icon/pd-icon";
5
5
  import { PdBaseUIInput, INPUT_TYPE_CHECK } from "./pd-base-ui-input.js";
6
+ import { pdIcons } from "@progressive-development/pd-icon";
6
7
  var __defProp = Object.defineProperty;
7
8
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8
9
  var __decorateClass = (decorators, target, key, kind) => {
@@ -16,52 +17,48 @@ var __decorateClass = (decorators, target, key, kind) => {
16
17
  let PdCheckbox = class extends PdBaseUIInput {
17
18
  constructor() {
18
19
  super();
19
- this.isSwitch = false;
20
- this._hasInner = false;
20
+ this.checkType = "CHECK";
21
21
  this._inputType = INPUT_TYPE_CHECK;
22
22
  }
23
- firstUpdated() {
24
- this._hasInner = this.innerHTML.trim().length > 0;
23
+ setCheckedState(newValue) {
24
+ this._value = newValue;
25
25
  }
26
26
  render() {
27
- const checked = this.value === "true";
27
+ const checked = this._value === "true";
28
28
  const inputId = `${this.id}Check`;
29
29
  const classMapVal = {
30
30
  disabled: this.disabled,
31
- switch: this.isSwitch,
31
+ switch: this.checkType === "SWITCH",
32
+ "radio-outer": this.checkType === "RADIO",
32
33
  readonly: this.readonly,
33
34
  "div-container": true
34
35
  };
35
36
  const aClassMap = {
36
- "switch-paddle": this.isSwitch,
37
- checkbox: !this.isSwitch,
37
+ "switch-paddle": this.checkType === "SWITCH",
38
+ checkbox: this.checkType === "CHECK",
39
+ radio: this.checkType === "RADIO",
38
40
  isChecked: checked,
39
41
  isUnchecked: !checked
40
42
  };
41
43
  return html`
42
44
  ${this._renderLabel(inputId)}
43
45
  <div @click=${this._onClick} class=${classMap(classMapVal)}>
44
- <a
45
- href="#"
46
- @click=${this._onLinkClick}
47
- @keypress=${this._onKeyPress}
48
- class=${classMap(aClassMap)}
49
- >
46
+ <div class=${classMap(aClassMap)}>
50
47
  <pd-icon
51
- icon=${this.isSwitch ? "checkBox" : "checkBoxOnlyCheck"}
52
- class="small"
48
+ icon=${this.checkType === "SWITCH" ? pdIcons.ICON_CHECKBOX : this.checkType === "RADIO" ? pdIcons.ICON_CIRCLE : pdIcons.ICON_CHECKBOX_ONLY_CHECK}
49
+ class="${this.checkType === "RADIO" ? "round" : ""}"
53
50
  ?activeIcon=${checked}
54
51
  ></pd-icon>
55
- </a>
56
- ${this._hasInner ? html`<span class="label"><slot></slot></span>` : null}
52
+ </div>
53
+ <span class="label"><slot></slot></span>
57
54
  </div>
58
55
  ${this._renderErrorMsg()}
59
56
  `;
60
57
  }
61
58
  _onClick(event) {
62
59
  if (this.disabled || this.readonly) return;
63
- const checked = this.value === "true";
64
- this._handleChangedValue(!checked ? "true" : "false", event);
60
+ const checked = this._value === "true";
61
+ this._handleChangedValue(!checked ? "true" : "false", event, true);
65
62
  }
66
63
  _onKeyPress(event) {
67
64
  event.preventDefault();
@@ -72,6 +69,12 @@ let PdCheckbox = class extends PdBaseUIInput {
72
69
  _onLinkClick(event) {
73
70
  event.preventDefault();
74
71
  }
72
+ _getInitialValue(reset) {
73
+ return reset ? this.initValue || "false" : this.initValue || this._value || "false";
74
+ }
75
+ clear() {
76
+ this.reset();
77
+ }
75
78
  };
76
79
  PdCheckbox.styles = [
77
80
  PdBaseUIInput.styles,
@@ -79,23 +82,29 @@ PdCheckbox.styles = [
79
82
  :host {
80
83
  display: inline-block;
81
84
 
82
- /* Style for active checkbox => use defaults from pd-icon if no custom properties set */
83
- --pd-icon-col-active: var(--pd-cb-col);
84
- --pd-icon-col-active-hover: var(--pd-cb-col-hover);
85
- --pd-icon-bg-col-active: var(--pd-cb-bg-col);
86
- --pd-icon-stroke-col-active: var(--pd-cb-stroke-col);
87
- --pd-icon-stroke-col-active-hover: var(--pd-cb-stroke-col-hover);
85
+ /* active checkbox */
86
+ --pd-icon-bg-col-active: var(
87
+ --pd-cb-bg-col,
88
+ var(--pd-default-light-col)
89
+ );
90
+ --pd-icon-col-active: var(--pd-cb-col, var(--pd-default-hover-col));
91
+ --pd-icon-stroke-col-active: var(
92
+ --pd-cb-stroke-col,
93
+ var(--pd-default-col)
94
+ );
95
+
96
+ /* inactive checkbox */
97
+ --pd-icon-bg-col: var(
98
+ --pd-cb-unset-bg-col,
99
+ var(--pd-default-light-col)
100
+ );
101
+ --pd-icon-col: var(--pd-cb-col, var(--pd-default-bg-dark-col));
102
+ --pd-icon-stroke-col: var(--pd-cb-stroke-col, var(--pd-default-col));
88
103
 
89
- /* Style for inactive checkbox */
90
- --pd-icon-col: var(--pd-cb-unset-col);
91
- --pd-icon-col-hover: var(--pd-cb-unset-col-hover);
92
- --pd-icon-bg-col: var(--pd-cb-unset-bg-col);
93
- --pd-icon-stroke-col: var(--pd-cb-unset-stroke-col);
94
- --pd-icon-stroke-col-hover: var(--pd-cb-unset-stroke-col-hover);
104
+ --pd-icon-bg-col-hover: var(--pd-cb-bg-col, var(--pd-default-bg-col));
95
105
  }
96
106
 
97
- /* Switch pd-icon => Prüfen, bei mir musste ich reflect setzten, wird das verwendet? */
98
- :host([isSwitch]) {
107
+ :host([checkType="SWITCH"]) {
99
108
  /* derzeit keine Angaben */
100
109
  }
101
110
 
@@ -106,7 +115,7 @@ PdCheckbox.styles = [
106
115
  }
107
116
 
108
117
  .div-container.disabled {
109
- opacity: 0.5;
118
+ opacity: 0.7;
110
119
  cursor: auto;
111
120
  }
112
121
 
@@ -114,6 +123,22 @@ PdCheckbox.styles = [
114
123
  cursor: auto;
115
124
  }
116
125
 
126
+ .label {
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);
130
+ text-align: left;
131
+ font-size: var(--pd-default-font-input-size);
132
+ }
133
+
134
+ .readonly .label {
135
+ color: var(--pd-cb-font-col-readonly, #4d4d4d);
136
+ }
137
+
138
+ .disabled .label {
139
+ color: var(--pd-cb-font-col-disabled, #4d4d4d);
140
+ }
141
+
117
142
  /*
118
143
  * Class checkbox for icon and a element (checkbox case)
119
144
  */
@@ -123,33 +148,43 @@ PdCheckbox.styles = [
123
148
  line-height: 0;
124
149
  align-items: center;
125
150
  justify-content: center;
126
- /*
127
- Wurde das hier für Border verwendet? Aktuell border in folgendem Element gesetzt
128
- background-color: var(--pd-cb-border-col, var(--pd-primary-col, #067394));
129
- */
130
151
  }
131
152
 
132
153
  .checkbox pd-icon {
154
+ --pd-icon-size: 1.3rem;
133
155
  margin-right: 0.2rem;
134
156
  margin-bottom: 0.2rem;
135
157
  border: 2px solid var(--pd-cb-border-col, var(--pd-default-col));
136
158
  border-radius: var(--pd-cb-border-radius, 3px);
137
159
  }
138
160
 
139
- .label {
140
- margin-left: 0.1rem;
141
- color: var(--pd-cb-font-col, var(--pd-default-font-input-col));
142
- font-family: var(--pd-default-font-input-family);
143
- text-align: left;
144
- font-size: var(--pd-default-font-input-size);
161
+ .readonly .checkbox pd-icon,
162
+ .disabled .checkbox pd-icon {
163
+ border-color: var(--pd-cb-border-col-readonly, darkgrey);
145
164
  }
146
165
 
147
- .readonly .label {
148
- color: var(--pd-cb-font-col-readonly, #4d4d4d);
166
+ /*
167
+ * Class Radio for icon and a element (radio group case)
168
+ */
169
+ .radio-outer .label {
170
+ margin-left: 0.7rem;
149
171
  }
150
172
 
151
- .readonly .checkbox pd-icon {
152
- border-color: var(--pd-cb-border-col-readonly, transparent);
173
+ .radio {
174
+ display: flex;
175
+ align-items: center;
176
+ justify-content: center;
177
+ }
178
+
179
+ .radio pd-icon {
180
+ --pd-icon-size: 1.5rem;
181
+ --pd-icon-round-padding: 0.1rem;
182
+ border: 2px solid var(--pd-cb-border-col, var(--pd-default-col));
183
+ }
184
+
185
+ .readonly .radio pd-icon,
186
+ .disabled .radio pd-icon {
187
+ border-color: var(--pd-cb-border-col-readonly, darkgrey);
153
188
  }
154
189
 
155
190
  /* Switch styles */
@@ -172,23 +207,20 @@ PdCheckbox.styles = [
172
207
  vertical-align: baseline;
173
208
  margin: 0;
174
209
  position: relative;
175
- min-width: 4rem;
176
- max-width: 4rem;
177
- height: 2rem;
210
+ min-width: 4.1rem;
211
+ max-width: 4.1rem;
212
+ height: 1.9rem;
178
213
  border-radius: 0;
179
214
  background: var(--pd-cb-switch-paddle-col, var(--pd-default-col));
180
- font-weight: inherit;
181
- color: inherit;
182
215
  cursor: pointer;
183
216
  }
184
217
 
185
218
  .switch-paddle pd-icon {
219
+ --pd-icon-size: 1.25rem;
186
220
  position: absolute;
187
221
  top: 0;
188
222
  left: 0;
189
223
  display: block;
190
- width: 1.5rem;
191
- height: 1.5rem;
192
224
  -webkit-transform: translate3d(0, 0, 0);
193
225
  transform: translate3d(0, 0, 0);
194
226
  border: 2px solid var(--pd-cb-border-col, var(--pd-default-col));
@@ -238,11 +270,8 @@ PdCheckbox.styles = [
238
270
  `
239
271
  ];
240
272
  __decorateClass([
241
- property({ type: Boolean })
242
- ], PdCheckbox.prototype, "isSwitch", 2);
243
- __decorateClass([
244
- state()
245
- ], PdCheckbox.prototype, "_hasInner", 2);
273
+ property({ type: String, reflect: true })
274
+ ], PdCheckbox.prototype, "checkType", 2);
246
275
  PdCheckbox = __decorateClass([
247
276
  customElement("pd-checkbox")
248
277
  ], PdCheckbox);
@@ -1,5 +1,6 @@
1
1
  import { CSSResultGroup, TemplateResult } from 'lit';
2
2
  import { PdBaseUI } from './pd-base-ui.js';
3
+ import { PdFormElementStatus } from './types.js';
3
4
  export declare class PdFormContainer extends PdBaseUI {
4
5
  /**
5
6
  * If true, display info about required fields
@@ -9,17 +10,20 @@ export declare class PdFormContainer extends PdBaseUI {
9
10
  * Optional general error message
10
11
  */
11
12
  commonError: string;
12
- /**
13
- * Internal: whether all required fields are valid
14
- */
15
- private _requiredFieldsValid;
13
+ private _fields;
16
14
  static styles: CSSResultGroup;
17
15
  connectedCallback(): void;
18
16
  disconnectedCallback(): void;
19
17
  render(): TemplateResult;
20
- private _validateForm;
21
- private static _mailIsValid;
22
- private static _vatIsValid;
23
- private static _phoneIsValid;
18
+ private _renderValidationInfo;
19
+ private _onRegister;
20
+ private _onChange;
21
+ private _onBlur;
22
+ private _onFocus;
23
+ private _getOverallValidity;
24
+ triggerValidate(): Promise<void>;
25
+ getValues(): Record<string, any>;
26
+ reset(): void;
27
+ getStatus(): Map<string, PdFormElementStatus>;
24
28
  }
25
29
  //# sourceMappingURL=pd-form-container.d.ts.map