@progressive-development/pd-forms 0.6.5 → 0.6.8

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 (66) 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/01_index.stories.d.ts.map +1 -1
  49. package/dist/stories/checkbox.stories.d.ts +1 -0
  50. package/dist/stories/checkbox.stories.d.ts.map +1 -1
  51. package/dist/stories/form-container2.stories.d.ts +8 -0
  52. package/dist/stories/form-container2.stories.d.ts.map +1 -0
  53. package/dist/stories/form-container3.stories.d.ts +8 -0
  54. package/dist/stories/form-container3.stories.d.ts.map +1 -0
  55. package/dist/stories/input.stories.d.ts.map +1 -1
  56. package/dist/stories/pd-hover-box.stories.d.ts +8 -0
  57. package/dist/stories/pd-hover-box.stories.d.ts.map +1 -0
  58. package/dist/styles/shared-input-field-styles.d.ts.map +1 -1
  59. package/dist/styles/shared-input-field-styles.js +21 -9
  60. package/dist/types.d.ts +15 -0
  61. package/dist/types.d.ts.map +1 -1
  62. package/dist/types.js +4 -0
  63. package/dist/validators.d.ts +10 -0
  64. package/dist/validators.d.ts.map +1 -0
  65. package/dist/validators.js +41 -0
  66. package/package.json +2 -2
@@ -12,26 +12,11 @@ var __decorateClass = (decorators, target, key, kind) => {
12
12
  };
13
13
  let PdRadioGroup = class extends PdBaseUIInput {
14
14
  firstUpdated() {
15
- this.addEventListener("field-change", (e) => {
16
- const target = e.target;
17
- const checkboxes2 = this.querySelectorAll("pd-checkbox");
18
- checkboxes2.forEach((el) => {
19
- const isActive = el === target;
20
- el.value = isActive ? "true" : "false";
21
- el.readonly = isActive;
22
- if (isActive) {
23
- this.value = el.valueName;
24
- }
25
- });
26
- this._dispatchValidation();
27
- });
28
- const checkboxes = this.querySelectorAll("pd-checkbox");
29
- checkboxes.forEach((el) => {
30
- if (el.value === "true") {
31
- el.readonly = true;
32
- this.value = el.valueName;
33
- }
34
- });
15
+ this.addEventListener("pd-form-element-register", this._onInternalRegister);
16
+ this.addEventListener("pd-form-element-change", this._onInternalChange);
17
+ this.addEventListener("pd-form-element-focus", this._onInternalFocus);
18
+ this.addEventListener("pd-form-element-blur", this._onInternalBlur);
19
+ super.firstUpdated();
35
20
  }
36
21
  render() {
37
22
  const radioInputId = `${this.id}RadioGroup`;
@@ -39,27 +24,62 @@ let PdRadioGroup = class extends PdBaseUIInput {
39
24
  ${this._renderLabel(radioInputId)}
40
25
  <div
41
26
  id=${radioInputId}
42
- class="group-style input ${classMap({
43
- error: this.errorMsg.length > 0
44
- })}"
27
+ class="${classMap(
28
+ this.getClassmap({
29
+ "group-style": true,
30
+ input: true
31
+ })
32
+ )}"
45
33
  >
46
34
  <slot></slot>
47
35
  </div>
48
36
  ${this._renderErrorMsg()}
49
37
  `;
50
38
  }
51
- _dispatchValidation() {
52
- this.dispatchEvent(
53
- new CustomEvent("validate-form", {
54
- detail: {
55
- singleElement: this,
56
- errorMap: /* @__PURE__ */ new Map()
57
- },
58
- composed: true,
59
- bubbles: true
60
- })
61
- );
39
+ _onInternalBlur(e) {
40
+ e.stopPropagation();
41
+ }
42
+ _onInternalFocus(e) {
43
+ e.stopPropagation();
62
44
  }
45
+ _onInternalChange(e) {
46
+ if (e.target !== this) {
47
+ e.stopPropagation();
48
+ const target = e.target;
49
+ const checkboxes = this.querySelectorAll("pd-checkbox");
50
+ let newValue;
51
+ checkboxes.forEach((el) => {
52
+ const isActive = el === target;
53
+ el.readonly = isActive;
54
+ el.setCheckedState(isActive ? "true" : "false");
55
+ if (isActive) {
56
+ newValue = el.valueName;
57
+ }
58
+ });
59
+ this.value = newValue || "";
60
+ }
61
+ }
62
+ _onInternalRegister(e) {
63
+ if (e.target !== this) {
64
+ e.stopPropagation();
65
+ if (e.detail.value === "true") {
66
+ this.value = e.detail.name;
67
+ }
68
+ }
69
+ }
70
+ /*
71
+ public reset(): void {
72
+ const checkboxes = this.querySelectorAll("pd-checkbox");
73
+ checkboxes.forEach((el) => {
74
+ (el as any).reset();
75
+ });
76
+ super.reset();
77
+ }
78
+
79
+ public clear(): void {
80
+ this.reset();
81
+ }
82
+ */
63
83
  };
64
84
  PdRadioGroup.styles = [
65
85
  PdBaseUIInput.styles,
@@ -1,4 +1,4 @@
1
- import { CSSResultGroup } from 'lit';
1
+ import { CSSResultGroup, PropertyValues } from 'lit';
2
2
  import { PdBaseUIInput } from './pd-base-ui-input.js';
3
3
  export declare class PdRange extends PdBaseUIInput {
4
4
  min: number;
@@ -9,8 +9,14 @@ export declare class PdRange extends PdBaseUIInput {
9
9
  protected _input: HTMLInputElement | null | undefined;
10
10
  static styles: CSSResultGroup;
11
11
  constructor();
12
- protected firstUpdated(): void;
12
+ update(changedProps: PropertyValues<this>): void;
13
+ firstUpdated(): void;
13
14
  protected _onChange(e: Event): void;
15
+ protected _onBlur(event: Event): void;
16
+ protected _onFocus(event: Event): void;
17
+ focus(): void;
14
18
  render(): import('lit-html').TemplateResult<1>;
19
+ _getInitialValue(): string;
20
+ clear(): void;
15
21
  }
16
22
  //# sourceMappingURL=pd-range.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pd-range.d.ts","sourceRoot":"","sources":["../src/pd-range.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAa,cAAc,EAAE,MAAM,KAAK,CAAC;AAIhD,OAAO,EAAE,aAAa,EAAoB,MAAM,uBAAuB,CAAC;AAExE,qBACa,OAAQ,SAAQ,aAAa;IAExC,GAAG,EAAE,MAAM,CAAK;IAGhB,GAAG,EAAE,MAAM,CAAM;IAGjB,IAAI,SAAK;IAGT,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IAG/C,IAAI,SAAM;IAEV,SAAS,CAAC,MAAM,EAAG,gBAAgB,GAAG,IAAI,GAAG,SAAS,CAAC;IAEvD,OAAgB,MAAM,EAAE,cAAc,CAqJpC;;cAOiB,YAAY,IAAI,IAAI;IAIvC,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI;IAI1B,MAAM;CA8BhB"}
1
+ {"version":3,"file":"pd-range.d.ts","sourceRoot":"","sources":["../src/pd-range.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAa,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAIhE,OAAO,EAAE,aAAa,EAAoB,MAAM,uBAAuB,CAAC;AAExE,qBACa,OAAQ,SAAQ,aAAa;IAExC,GAAG,EAAE,MAAM,CAAK;IAGhB,GAAG,EAAE,MAAM,CAAM;IAGjB,IAAI,SAAK;IAGT,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IAG/C,IAAI,SAAM;IAEV,SAAS,CAAC,MAAM,EAAG,gBAAgB,GAAG,IAAI,GAAG,SAAS,CAAC;IAEvD,OAAgB,MAAM,EAAE,cAAc,CAqJpC;;IAOO,MAAM,CAAC,YAAY,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAOhD,YAAY,IAAI,IAAI;IAK7B,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI;IAInC,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAgBrC,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IActC,KAAK,IAAI,IAAI;IAIJ,MAAM;IAuCN,gBAAgB,IAAI,MAAM;IAI5B,KAAK,IAAI,IAAI;CAGrB"}
package/dist/pd-range.js CHANGED
@@ -22,26 +22,72 @@ let PdRange = class extends PdBaseUIInput {
22
22
  this.name = "";
23
23
  this._inputType = INPUT_TYPE_RANGE;
24
24
  }
25
+ update(changedProps) {
26
+ if (changedProps.has("optionValueMapper") && !this.initValue) {
27
+ this._value = Object.keys(this.optionValueMapper)[0];
28
+ }
29
+ super.update(changedProps);
30
+ }
25
31
  firstUpdated() {
26
32
  var _a;
27
33
  this._input = (_a = this.shadowRoot) == null ? void 0 : _a.querySelector("input");
34
+ super.firstUpdated();
28
35
  }
29
36
  _onChange(e) {
30
37
  var _a;
31
- this._handleChangedValue(((_a = this._input) == null ? void 0 : _a.value) ?? "", e, false);
38
+ this._handleChangedValue(((_a = this._input) == null ? void 0 : _a.value) ?? "", e, true);
39
+ }
40
+ _onBlur(event) {
41
+ var _a;
42
+ this._focused = false;
43
+ this._touched = true;
44
+ this.dispatchEvent(
45
+ new CustomEvent("pd-form-element-blur", {
46
+ detail: {
47
+ name: this.valueName || this.id || "field",
48
+ value: (_a = this._input) == null ? void 0 : _a.value
49
+ },
50
+ bubbles: true,
51
+ composed: true
52
+ })
53
+ );
54
+ }
55
+ _onFocus(event) {
56
+ var _a;
57
+ this._focused = true;
58
+ this.dispatchEvent(
59
+ new CustomEvent("pd-form-element-focus", {
60
+ detail: {
61
+ name: this.valueName || this.id || "field",
62
+ value: (_a = this._input) == null ? void 0 : _a.value
63
+ },
64
+ bubbles: true,
65
+ composed: true
66
+ })
67
+ );
68
+ }
69
+ focus() {
70
+ var _a;
71
+ (_a = this._input) == null ? void 0 : _a.focus();
32
72
  }
33
73
  render() {
34
74
  const inputId = `${this.id}Range`;
35
- const labelDetail = this.optionValueMapper[this.value] || this.value;
75
+ const labelDetail = this.optionValueMapper[this._value] || this._value;
36
76
  return html`
37
77
  ${this._renderLabel(inputId, labelDetail)}
38
- <div class="input-range ${classMap({ error: this.errorMsg.length > 0 })}">
78
+ <div
79
+ class="${classMap(
80
+ this.getClassmap({
81
+ "input-range": true
82
+ })
83
+ )}"
84
+ >
39
85
  <input
40
86
  id=${inputId}
41
87
  name=${this.name || this.valueName || ""}
42
88
  class="input-range-style ${this.gradient ? "gradient" : ""}"
43
89
  type="range"
44
- .value=${this.value}
90
+ .value=${this._value}
45
91
  ?readonly=${this.readonly}
46
92
  ?disabled=${this.disabled}
47
93
  min=${this.min}
@@ -49,9 +95,11 @@ let PdRange = class extends PdBaseUIInput {
49
95
  step=${this.step}
50
96
  @change=${this._onChange}
51
97
  @input=${this._onChange}
98
+ @blur=${this._onBlur}
99
+ @focus=${this._onFocus}
52
100
  />
53
101
  <div class="ticks ${this.disabled ? "disabled" : "enabled"}">
54
- ${Array.from({ length: 5 }).map(
102
+ ${Array.from({ length: this.max - this.min + 1 }).map(
55
103
  () => html`<span class="tick">|</span>`
56
104
  )}
57
105
  </div>
@@ -59,6 +107,12 @@ let PdRange = class extends PdBaseUIInput {
59
107
  ${this._renderErrorMsg()}
60
108
  `;
61
109
  }
110
+ _getInitialValue() {
111
+ return this.initValue || Object.keys(this.optionValueMapper)[0] || "0";
112
+ }
113
+ clear() {
114
+ this.reset();
115
+ }
62
116
  };
63
117
  PdRange.styles = [
64
118
  PdBaseUIInput.styles,
@@ -1,14 +1,18 @@
1
- import { CSSResultGroup } from 'lit';
1
+ import { CSSResultGroup, PropertyValues } from 'lit';
2
2
  import { PdBaseInputElement } from './pd-base-input-element.js';
3
3
  import { PdSelectOption } from './types.js';
4
4
  export declare class PdSelect extends PdBaseInputElement {
5
5
  values: PdSelectOption[];
6
- constructor();
7
6
  static styles: CSSResultGroup;
7
+ constructor();
8
+ update(changedProps: PropertyValues<this>): void;
8
9
  render(): import('lit-html').TemplateResult<1>;
10
+ protected _onSelectChange(event: Event): void;
9
11
  /**
10
12
  * Empty, reserved for possible future enhancements on keyup for select.
11
13
  */
12
14
  protected _onSelectKeyUp(): void;
15
+ _getInitialValue(): string;
16
+ clear(): void;
13
17
  }
14
18
  //# sourceMappingURL=pd-select.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pd-select.d.ts","sourceRoot":"","sources":["../src/pd-select.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAa,cAAc,EAAE,MAAM,KAAK,CAAC;AAIhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,qBACa,QAAS,SAAQ,kBAAkB;IAE9C,MAAM,EAAE,cAAc,EAAE,CAAM;;IAO9B,OAAgB,MAAM,EAAE,cAAc,CA0DpC;IAEO,MAAM;IA6Bf;;OAEG;IACH,SAAS,CAAC,cAAc,IAAI,IAAI;CAGjC"}
1
+ {"version":3,"file":"pd-select.d.ts","sourceRoot":"","sources":["../src/pd-select.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAa,cAAc,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAKhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,qBACa,QAAS,SAAQ,kBAAkB;IAE9C,MAAM,EAAE,cAAc,EAAE,CAAM;IAE9B,OAAgB,MAAM,EAAE,cAAc,CA0DpC;;IAOO,MAAM,CAAC,YAAY,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAOhD,MAAM;IAoCf,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,KAAK;IAItC;;OAEG;IACH,SAAS,CAAC,cAAc,IAAI,IAAI;IAIvB,gBAAgB,IAAI,MAAM;IAI5B,KAAK,IAAI,IAAI;CAGrB"}
package/dist/pd-select.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { css, html } from "lit";
2
2
  import { property, customElement } from "lit/decorators.js";
3
+ import { classMap } from "lit/directives/class-map.js";
3
4
  import { INPUT_TYPE_SELECT } from "./pd-base-ui-input.js";
4
5
  import { PdBaseInputElement } from "./pd-base-input-element.js";
5
6
  var __defProp = Object.defineProperty;
@@ -18,24 +19,37 @@ let PdSelect = class extends PdBaseInputElement {
18
19
  this.values = [];
19
20
  this._inputType = INPUT_TYPE_SELECT;
20
21
  }
22
+ update(changedProps) {
23
+ if (changedProps.has("values") && !this.initValue) {
24
+ this._value = this.values[0].value;
25
+ }
26
+ super.update(changedProps);
27
+ }
21
28
  render() {
22
29
  const selectId = `${this.id}Select`;
23
30
  return html`
24
31
  ${this._renderLabel(selectId)}
25
- <div class="input ${this.errorMsg.length > 0 ? "error" : ""}">
32
+ <div
33
+ class="${classMap(
34
+ this.getClassmap({
35
+ input: true
36
+ })
37
+ )}"
38
+ >
26
39
  <select
27
40
  id=${selectId}
28
41
  class="input-style select-css ${this.gradient ? "gradient" : ""}"
29
42
  ?disabled=${this.disabled}
30
43
  name=${this.name || this.valueName || this.autoCompleteName}
31
44
  autocomplete=${this.autoCompleteName ?? "off"}
32
- @change=${this._onKeyUp}
45
+ @change=${this._onSelectChange}
33
46
  @keyup=${this._onSelectKeyUp}
34
47
  @blur=${this._onBlur}
48
+ @focus=${this._onFocus}
35
49
  >
36
50
  ${this.values.map(
37
51
  (val) => html`
38
- <option value=${val.value} ?selected=${this.value == val.value}>
52
+ <option value=${val.value} ?selected=${this._value == val.value}>
39
53
  ${val.name}
40
54
  </option>
41
55
  `
@@ -45,11 +59,21 @@ let PdSelect = class extends PdBaseInputElement {
45
59
  ${this._renderErrorMsg()}
46
60
  `;
47
61
  }
62
+ _onSelectChange(event) {
63
+ this._handleChangedValue(this._input.value, event, true);
64
+ }
48
65
  /**
49
66
  * Empty, reserved for possible future enhancements on keyup for select.
50
67
  */
51
68
  _onSelectKeyUp() {
52
69
  }
70
+ _getInitialValue() {
71
+ var _a;
72
+ return this.initValue || ((_a = this.values[0]) == null ? void 0 : _a.value) || "";
73
+ }
74
+ clear() {
75
+ this.reset();
76
+ }
53
77
  };
54
78
  PdSelect.styles = [
55
79
  PdBaseInputElement.styles,
@@ -1 +1 @@
1
- {"version":3,"file":"01_index.stories.d.ts","sourceRoot":"","sources":["../../src/stories/01_index.stories.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,iBAAiB,CAAC;AACzB,OAAO,mBAAmB,CAAC;AAC3B,OAAO,gBAAgB,CAAC;AACxB,OAAO,qBAAqB,CAAC;AAC7B,OAAO,qBAAqB,CAAC;AAC7B,OAAO,sBAAsB,CAAC;AAC9B,OAAO,iBAAiB,CAAC;AAGzB,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsBM,CAAC;AAEjB,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC;AAGtB,eAAO,MAAM,YAAY,EAAE,KAgL1B,CAAC"}
1
+ {"version":3,"file":"01_index.stories.d.ts","sourceRoot":"","sources":["../../src/stories/01_index.stories.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,iBAAiB,CAAC;AACzB,OAAO,mBAAmB,CAAC;AAC3B,OAAO,gBAAgB,CAAC;AACxB,OAAO,qBAAqB,CAAC;AAC7B,OAAO,qBAAqB,CAAC;AAC7B,OAAO,sBAAsB,CAAC;AAC9B,OAAO,iBAAiB,CAAC;AAGzB,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsBM,CAAC;AAEjB,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC;AAGtB,eAAO,MAAM,YAAY,EAAE,KA4L1B,CAAC"}
@@ -25,4 +25,5 @@ export default meta;
25
25
  type Story = StoryObj;
26
26
  export declare const Checkbox: Story;
27
27
  export declare const SwitchTemplate: Story;
28
+ export declare const RadioTemplate: Story;
28
29
  //# sourceMappingURL=checkbox.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.stories.d.ts","sourceRoot":"","sources":["../../src/stories/checkbox.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,mBAAmB,CAAC;AAC3B,OAAO,yBAAyB,CAAC;AAGjC,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;CAeM,CAAC;AAEjB,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC;AAEtB,eAAO,MAAM,QAAQ,EAAE,KA8CtB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KA8B5B,CAAC"}
1
+ {"version":3,"file":"checkbox.stories.d.ts","sourceRoot":"","sources":["../../src/stories/checkbox.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,mBAAmB,CAAC;AAC3B,OAAO,yBAAyB,CAAC;AAGjC,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;CAeM,CAAC;AAEjB,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC;AAEtB,eAAO,MAAM,QAAQ,EAAE,KA8CtB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KA8B5B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KA4B3B,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { StoryObj } from '@storybook/web-components';
2
+ declare const meta: {
3
+ title: string;
4
+ };
5
+ export default meta;
6
+ type Story = StoryObj;
7
+ export declare const FormContainerFullTest: Story;
8
+ //# sourceMappingURL=form-container2.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-container2.stories.d.ts","sourceRoot":"","sources":["../../src/stories/form-container2.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAM3D,OAAO,yBAAyB,CAAC;AACjC,OAAO,mBAAmB,CAAC;AAC3B,OAAO,gBAAgB,CAAC;AACxB,OAAO,qBAAqB,CAAC;AAC7B,OAAO,gBAAgB,CAAC;AACxB,OAAO,iBAAiB,CAAC;AACzB,OAAO,sBAAsB,CAAC;AAC9B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,qBAAqB,CAAC;AAC7B,OAAO,qBAAqB,CAAC;AAE7B,QAAA,MAAM,IAAI;;CAEM,CAAC;AAEjB,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC;AAStB,eAAO,MAAM,qBAAqB,EAAE,KA0RnC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { StoryObj } from '@storybook/web-components';
2
+ declare const meta: {
3
+ title: string;
4
+ };
5
+ export default meta;
6
+ type Story = StoryObj;
7
+ export declare const FormContainerValidStory: Story;
8
+ //# sourceMappingURL=form-container3.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-container3.stories.d.ts","sourceRoot":"","sources":["../../src/stories/form-container3.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAM3D,OAAO,yBAAyB,CAAC;AACjC,OAAO,mBAAmB,CAAC;AAC3B,OAAO,gBAAgB,CAAC;AACxB,OAAO,qBAAqB,CAAC;AAC7B,OAAO,gBAAgB,CAAC;AACxB,OAAO,iBAAiB,CAAC;AACzB,OAAO,sBAAsB,CAAC;AAC9B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,qBAAqB,CAAC;AAC7B,OAAO,qBAAqB,CAAC;AAE7B,QAAA,MAAM,IAAI;;CAEM,CAAC;AAEjB,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC;AAStB,eAAO,MAAM,uBAAuB,EAAE,KAqDrC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"input.stories.d.ts","sourceRoot":"","sources":["../../src/stories/input.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAI3D,OAAO,gBAAgB,CAAC;AACxB,OAAO,mBAAmB,CAAC;AAC3B,OAAO,yBAAyB,CAAC;AAGjC,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAaM,CAAC;AAEjB,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC;AAEtB,eAAO,MAAM,KAAK,EAAE,KA8JnB,CAAC"}
1
+ {"version":3,"file":"input.stories.d.ts","sourceRoot":"","sources":["../../src/stories/input.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAI3D,OAAO,gBAAgB,CAAC;AACxB,OAAO,mBAAmB,CAAC;AAC3B,OAAO,yBAAyB,CAAC;AAGjC,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAaM,CAAC;AAEjB,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC;AAEtB,eAAO,MAAM,KAAK,EAAE,KAkKnB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { StoryObj } from '@storybook/web-components';
2
+ declare const meta: {
3
+ title: string;
4
+ };
5
+ export default meta;
6
+ type Story = StoryObj;
7
+ export declare const HoverBoxContainer: Story;
8
+ //# sourceMappingURL=pd-hover-box.stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pd-hover-box.stories.d.ts","sourceRoot":"","sources":["../../src/stories/pd-hover-box.stories.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAI3D,OAAO,yBAAyB,CAAC;AACjC,OAAO,mBAAmB,CAAC;AAC3B,OAAO,gBAAgB,CAAC;AACxB,OAAO,qBAAqB,CAAC;AAC7B,OAAO,gBAAgB,CAAC;AACxB,OAAO,iBAAiB,CAAC;AACzB,OAAO,sBAAsB,CAAC;AAC9B,OAAO,mBAAmB,CAAC;AAC3B,OAAO,qBAAqB,CAAC;AAC7B,OAAO,qBAAqB,CAAC;AAE7B,QAAA,MAAM,IAAI;;CAEM,CAAC;AAEjB,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC;AAStB,eAAO,MAAM,iBAAiB,EAAE,KA4J/B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"shared-input-field-styles.d.ts","sourceRoot":"","sources":["../../src/styles/shared-input-field-styles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,eAAO,MAAM,sBAAsB,yBA2JlC,CAAC"}
1
+ {"version":3,"file":"shared-input-field-styles.d.ts","sourceRoot":"","sources":["../../src/styles/shared-input-field-styles.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,eAAO,MAAM,sBAAsB,yBAuKlC,CAAC"}
@@ -50,7 +50,7 @@ const SharedInputFieldStyles = css`
50
50
  position: relative;
51
51
  }
52
52
 
53
- pd-icon {
53
+ .infield-icon {
54
54
  display: none;
55
55
  position: absolute;
56
56
  --pd-icon-size: var(
@@ -65,7 +65,7 @@ const SharedInputFieldStyles = css`
65
65
  top: 2px;
66
66
  }
67
67
 
68
- pd-icon:hover {
68
+ .infield-icon:hover {
69
69
  cursor: pointer;
70
70
  }
71
71
 
@@ -100,12 +100,6 @@ const SharedInputFieldStyles = css`
100
100
  );
101
101
  }
102
102
 
103
- /* Fokus for input, area => select with own css.? */
104
- .input-style:focus {
105
- border: var(--pd-input-field-border-focus, 2px solid var(--pd-default-col));
106
- outline: 0;
107
- }
108
-
109
103
  /* Höhe soll nicht für Text Area gelten, daher ausgelagert (überschreibt sonst rows) */
110
104
  input.input-style,
111
105
  select.input-style {
@@ -136,6 +130,12 @@ const SharedInputFieldStyles = css`
136
130
  );
137
131
  }
138
132
 
133
+ /* Fokus for input, area => select with own css.? */
134
+ .focus .input-style {
135
+ border: var(--pd-input-field-border-focus, 2px solid var(--pd-default-col));
136
+ outline: 0;
137
+ }
138
+
139
139
  /* error element style for input, area => select has own css.? */
140
140
  .error .input-style {
141
141
  border: 1px solid var(--pd-default-error-col);
@@ -144,10 +144,22 @@ const SharedInputFieldStyles = css`
144
144
  }
145
145
 
146
146
  /* Error Focus for input, area, select */
147
- .error .input-style:focus {
147
+ .focus.error .input-style {
148
148
  border: 2px solid var(--pd-default-error-col);
149
149
  }
150
150
 
151
+ /* valid element style for input, area => select has own css.? */
152
+ .valid .input-style {
153
+ border: 1px solid var(--pd-default-success-col);
154
+ /*color: var(--pd-default-success-col);*/
155
+ background-color: var(--pd-default-success-light-col);
156
+ }
157
+
158
+ /* Error Focus for input, area, select */
159
+ .focus.valid .input-style {
160
+ border: 2px solid var(--pd-default-success-col);
161
+ }
162
+
151
163
  /* Placeholder color for input and input-area */
152
164
  ::placeholder {
153
165
  color: var(--pd-input-placeholder-color, #474747e4);
package/dist/types.d.ts CHANGED
@@ -2,6 +2,21 @@ export interface PdSelectOption {
2
2
  name: string;
3
3
  value: string;
4
4
  }
5
+ export interface PdFormElementStatus {
6
+ name: string;
7
+ value: any;
8
+ valid: boolean;
9
+ invalid: boolean;
10
+ pristine: boolean;
11
+ dirty: boolean;
12
+ touched: boolean;
13
+ focused: boolean;
14
+ errors: Record<string, string>;
15
+ element: HTMLElement;
16
+ }
17
+ export type PdFormValidatorFn = (value: any) => string | null | Promise<string | null>;
18
+ export type PdFieldType = "text" | "number" | "mail" | "vat" | "phone";
19
+ export declare const UNDEF = "UNDEF";
5
20
  /**
6
21
  * MDN-konforme Autocomplete-Werte.
7
22
  * https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB,IAAI,GACJ,KAAK,GACL,MAAM,GACN,kBAAkB,GAClB,YAAY,GACZ,iBAAiB,GACjB,aAAa,GACb,kBAAkB,GAClB,UAAU,GACV,UAAU,GACV,cAAc,GACd,kBAAkB,GAClB,OAAO,GACP,oBAAoB,GACpB,cAAc,GACd,gBAAgB,GAChB,eAAe,GACf,eAAe,GACf,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,GAChB,SAAS,GACT,cAAc,GACd,aAAa,GACb,KAAK,GACL,kBAAkB,GAClB,cAAc,GACd,eAAe,GACf,WAAW,GACX,MAAM,GACN,UAAU,GACV,YAAY,GACZ,WAAW,GACX,KAAK,GACL,KAAK,GACL,OAAO,GACP,SAAS,GACT,eAAe,GACf,oBAAoB,GACpB,gBAAgB,GAChB,WAAW,GACX,QAAQ,GACR,cAAc,GACd,aAAa,GACb,QAAQ,GACR,SAAS,GACT,sBAAsB,GACtB,oBAAoB,GACpB,UAAU,GACV,eAAe,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,MAAM,iBAAiB,GAAG,CAC9B,KAAK,EAAE,GAAG,KACP,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAE5C,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC;AAEvE,eAAO,MAAM,KAAK,UAAU,CAAC;AAE7B;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB,IAAI,GACJ,KAAK,GACL,MAAM,GACN,kBAAkB,GAClB,YAAY,GACZ,iBAAiB,GACjB,aAAa,GACb,kBAAkB,GAClB,UAAU,GACV,UAAU,GACV,cAAc,GACd,kBAAkB,GAClB,OAAO,GACP,oBAAoB,GACpB,cAAc,GACd,gBAAgB,GAChB,eAAe,GACf,eAAe,GACf,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,GAChB,SAAS,GACT,cAAc,GACd,aAAa,GACb,KAAK,GACL,kBAAkB,GAClB,cAAc,GACd,eAAe,GACf,WAAW,GACX,MAAM,GACN,UAAU,GACV,YAAY,GACZ,WAAW,GACX,KAAK,GACL,KAAK,GACL,OAAO,GACP,SAAS,GACT,eAAe,GACf,oBAAoB,GACpB,gBAAgB,GAChB,WAAW,GACX,QAAQ,GACR,cAAc,GACd,aAAa,GACb,QAAQ,GACR,SAAS,GACT,sBAAsB,GACtB,oBAAoB,GACpB,UAAU,GACV,eAAe,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,4 @@
1
+ const UNDEF = "UNDEF";
2
+ export {
3
+ UNDEF
4
+ };
@@ -0,0 +1,10 @@
1
+ import { PdFormValidatorFn } from './types';
2
+ export declare const requiredValidator: PdFormValidatorFn;
3
+ export declare const requiredSelectValidator: PdFormValidatorFn;
4
+ export declare const requiredCheckedValidator: PdFormValidatorFn;
5
+ export declare const requiredRangeValidator: PdFormValidatorFn;
6
+ export declare const emailValidator: PdFormValidatorFn;
7
+ export declare const phoneValidator: PdFormValidatorFn;
8
+ export declare const vatValidator: PdFormValidatorFn;
9
+ export declare const numberValidator: PdFormValidatorFn;
10
+ //# sourceMappingURL=validators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../src/validators.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAS,MAAM,SAAS,CAAC;AAGnD,eAAO,MAAM,iBAAiB,EAAE,iBAI/B,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,iBAIrC,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,iBAItC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,iBAIpC,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,iBAM5B,CAAC;AAGF,eAAO,MAAM,cAAc,EAAE,iBAM5B,CAAC;AAGF,eAAO,MAAM,YAAY,EAAE,iBAI1B,CAAC;AAGF,eAAO,MAAM,eAAe,EAAE,iBAM7B,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { msg } from "@lit/localize";
2
+ import { UNDEF } from "./types.js";
3
+ const requiredValidator = (value) => {
4
+ return value === null || value === void 0 || value === "" ? msg("Eingabe erforderlich", { id: "pd.form.field.required" }) : null;
5
+ };
6
+ const requiredSelectValidator = (value) => {
7
+ return value === UNDEF ? msg("Eingabe erforderlich", { id: "pd.form.field.selectRequired" }) : null;
8
+ };
9
+ const requiredCheckedValidator = (value) => {
10
+ return value === "false" ? msg("Eingabe erforderlich", { id: "pd.form.field.checkRequired" }) : null;
11
+ };
12
+ const requiredRangeValidator = (value) => {
13
+ return value === "0" ? msg("Eingabe erforderlich", { id: "pd.form.field.rangeRequired" }) : null;
14
+ };
15
+ const emailValidator = (value) => {
16
+ return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value) ? null : msg("Format mail@test.de verwenden", {
17
+ id: "pd.form.field.invalid.mail"
18
+ });
19
+ };
20
+ const phoneValidator = (value) => {
21
+ return /^\+?[0-9 ]{7,15}$/.test(value) ? null : msg("Format +49123 123456 verwenden", {
22
+ id: "pd.form.field.invalid.phone"
23
+ });
24
+ };
25
+ const vatValidator = (value) => {
26
+ return /^[A-Z]{2}[0-9]{8,12}$/.test(value) ? null : msg("Format DE0123456789 verwenden", { id: "pd.form.field.invalid.vat" });
27
+ };
28
+ const numberValidator = (value) => {
29
+ const normalized = typeof value === "string" ? value.replaceAll(",", ".") : value;
30
+ return !isNaN(parseFloat(normalized)) && isFinite(normalized) ? null : msg("Nur Zahlen erlaubt", { id: "pd.form.field.invalid.number" });
31
+ };
32
+ export {
33
+ emailValidator,
34
+ numberValidator,
35
+ phoneValidator,
36
+ requiredCheckedValidator,
37
+ requiredRangeValidator,
38
+ requiredSelectValidator,
39
+ requiredValidator,
40
+ vatValidator
41
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@progressive-development/pd-forms",
3
- "version": "0.6.5",
3
+ "version": "0.6.8",
4
4
  "description": "Webcomponent pd-forms for rendering form input elements.",
5
5
  "author": "PD Progressive Development",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -52,7 +52,7 @@
52
52
  "dependencies": {
53
53
  "@lit-labs/motion": "^1.0.8",
54
54
  "@lit/localize": "^0.12.2",
55
- "@progressive-development/pd-icon": "^0.6.2",
55
+ "@progressive-development/pd-icon": "^0.7.1",
56
56
  "@progressive-development/pd-shared-styles": "^0.2.1",
57
57
  "lit": "^3.3.0"
58
58
  },