@progressive-development/pd-forms 0.5.6 → 0.6.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.
Files changed (107) hide show
  1. package/dist/generated/locale-codes.d.ts +14 -0
  2. package/dist/generated/locale-codes.d.ts.map +1 -0
  3. package/dist/generated/locales/be.d.ts +10 -0
  4. package/dist/generated/locales/be.d.ts.map +1 -0
  5. package/dist/generated/locales/de.d.ts +10 -0
  6. package/dist/generated/locales/de.d.ts.map +1 -0
  7. package/dist/generated/locales/en.d.ts +10 -0
  8. package/dist/generated/locales/en.d.ts.map +1 -0
  9. package/dist/index.d.ts +15 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +10 -10
  12. package/dist/locales/be.d.ts +2 -0
  13. package/dist/locales/de.d.ts +2 -0
  14. package/dist/locales/en.d.ts +2 -0
  15. package/dist/pd-base-input-element.d.ts +28 -0
  16. package/dist/pd-base-input-element.d.ts.map +1 -0
  17. package/dist/pd-base-input-element.js +82 -0
  18. package/dist/pd-base-ui-input.d.ts +54 -0
  19. package/dist/pd-base-ui-input.d.ts.map +1 -0
  20. package/dist/pd-base-ui-input.js +208 -0
  21. package/dist/pd-base-ui.d.ts +12 -0
  22. package/dist/pd-base-ui.d.ts.map +1 -0
  23. package/dist/{src/PdBaseUi.js → pd-base-ui.js} +9 -15
  24. package/dist/pd-button.d.ts +16 -0
  25. package/dist/pd-button.d.ts.map +1 -0
  26. package/dist/pd-button.js +154 -4
  27. package/dist/pd-checkbox.d.ts +14 -0
  28. package/dist/pd-checkbox.d.ts.map +1 -0
  29. package/dist/pd-checkbox.js +251 -4
  30. package/dist/pd-form-container.d.ts +25 -0
  31. package/dist/pd-form-container.d.ts.map +1 -0
  32. package/dist/pd-form-container.js +183 -4
  33. package/dist/pd-form-row.d.ts +12 -0
  34. package/dist/pd-form-row.d.ts.map +1 -0
  35. package/dist/pd-form-row.js +108 -4
  36. package/dist/pd-hover-box.d.ts +23 -0
  37. package/dist/pd-hover-box.d.ts.map +1 -0
  38. package/dist/pd-hover-box.js +122 -4
  39. package/dist/pd-icon-panel-button.d.ts +18 -0
  40. package/dist/pd-icon-panel-button.d.ts.map +1 -0
  41. package/dist/pd-input-area.d.ts +18 -0
  42. package/dist/pd-input-area.d.ts.map +1 -0
  43. package/dist/pd-input-area.js +74 -4
  44. package/dist/pd-input-file.d.ts +15 -0
  45. package/dist/pd-input-file.d.ts.map +1 -0
  46. package/dist/pd-input-file.js +91 -4
  47. package/dist/pd-input-time.d.ts +10 -0
  48. package/dist/pd-input-time.d.ts.map +1 -0
  49. package/dist/pd-input-time.js +68 -0
  50. package/dist/pd-input.d.ts +30 -0
  51. package/dist/pd-input.d.ts.map +1 -0
  52. package/dist/pd-input.js +99 -4
  53. package/dist/pd-radio-group.d.ts +9 -0
  54. package/dist/pd-radio-group.d.ts.map +1 -0
  55. package/dist/pd-radio-group.js +89 -4
  56. package/dist/pd-range.d.ts +16 -0
  57. package/dist/pd-range.d.ts.map +1 -0
  58. package/dist/pd-range.js +236 -4
  59. package/dist/pd-select.d.ts +14 -0
  60. package/dist/pd-select.d.ts.map +1 -0
  61. package/dist/pd-select.js +121 -4
  62. package/dist/stories/01_index.stories.d.ts +58 -0
  63. package/dist/stories/01_index.stories.d.ts.map +1 -0
  64. package/dist/stories/button.stories.d.ts +22 -0
  65. package/dist/stories/button.stories.d.ts.map +1 -0
  66. package/dist/stories/checkbox.stories.d.ts +28 -0
  67. package/dist/stories/checkbox.stories.d.ts.map +1 -0
  68. package/dist/stories/form-container.stories.d.ts +28 -0
  69. package/dist/stories/form-container.stories.d.ts.map +1 -0
  70. package/dist/stories/form-row.stories.d.ts +27 -0
  71. package/dist/stories/form-row.stories.d.ts.map +1 -0
  72. package/dist/stories/input-area.stories.d.ts +54 -0
  73. package/dist/stories/input-area.stories.d.ts.map +1 -0
  74. package/dist/stories/input-file.stories.d.ts +49 -0
  75. package/dist/stories/input-file.stories.d.ts.map +1 -0
  76. package/dist/stories/input.stories.d.ts +37 -0
  77. package/dist/stories/input.stories.d.ts.map +1 -0
  78. package/dist/stories/pd-icon-button.stories.d.ts +30 -0
  79. package/dist/stories/pd-icon-button.stories.d.ts.map +1 -0
  80. package/dist/stories/radio-group.stories.d.ts +9 -0
  81. package/dist/stories/radio-group.stories.d.ts.map +1 -0
  82. package/dist/stories/range.stories.d.ts +9 -0
  83. package/dist/stories/range.stories.d.ts.map +1 -0
  84. package/dist/stories/select.stories.d.ts +37 -0
  85. package/dist/stories/select.stories.d.ts.map +1 -0
  86. package/dist/styles/shared-input-field-styles.d.ts +9 -0
  87. package/dist/styles/shared-input-field-styles.d.ts.map +1 -0
  88. package/dist/{src → styles}/shared-input-field-styles.js +37 -25
  89. package/dist/styles/shared-input-styles.d.ts +10 -0
  90. package/dist/styles/shared-input-styles.d.ts.map +1 -0
  91. package/dist/{src → styles}/shared-input-styles.js +7 -6
  92. package/dist/types.d.ts +10 -0
  93. package/dist/types.d.ts.map +1 -0
  94. package/package.json +32 -47
  95. package/dist/src/PdBaseInputElement.js +0 -86
  96. package/dist/src/PdBaseUiInput.js +0 -229
  97. package/dist/src/PdButton.js +0 -194
  98. package/dist/src/PdCheckbox.js +0 -230
  99. package/dist/src/PdFormContainer.js +0 -167
  100. package/dist/src/PdFormRow.js +0 -92
  101. package/dist/src/PdHoverBox.js +0 -108
  102. package/dist/src/PdInput.js +0 -79
  103. package/dist/src/PdInputArea.js +0 -61
  104. package/dist/src/PdInputFile.js +0 -73
  105. package/dist/src/PdRadioGroup.js +0 -72
  106. package/dist/src/PdRange.js +0 -267
  107. package/dist/src/PdSelect.js +0 -125
@@ -1,230 +0,0 @@
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";
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="${classMap(classMapVal)}">
199
- <a href="#" @click="${this.linkClick}" @keypress="${this.onKeyPress}" class="${classMap(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", { id: "pd.form.required.valid" }) : msg("* Pflichtfeld", { id: "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", { id: "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", { 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.replaceAll(",", ".")),
146
- msg("Nur Zahlen erlaubt", { id: "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
- };
@@ -1,92 +0,0 @@
1
- import { css, html } from "lit";
2
- import { PdBaseUI } from "./PdBaseUi.js";
3
- /**
4
- * @license
5
- * Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
6
- */
7
- class PdFormRow extends PdBaseUI {
8
- static get styles() {
9
- return css`
10
- :host {
11
-
12
- /* Define size for row, depends on media queries */
13
- --my-row-width: var(--pd-form-row-base-width, 800px);
14
- --my-gap: var(--pd-form-row-gap, 20px);
15
- display: flex;
16
- flex: 1 1 100%;
17
- /*margin: 0 0 .5rem 0;*/
18
- box-sizing: border-box;
19
- width: 100%;
20
- gap: var(--my-gap);
21
- align-items: var(--pd-form-row-align-item, flex-start);
22
- padding-top: var(--pd-form-row-padding-top, 10px);
23
- }
24
-
25
- ::slotted(.full-size) {
26
- --pd-input-field-width: 100%;
27
- }
28
-
29
- ::slotted(.quarter1) {
30
- --pd-input-field-width: calc(var(--my-row-width) * 0.25 - (var(--my-gap) * 0.75));
31
-
32
- }
33
-
34
- ::slotted(.quarter1-area) {
35
- --pd-input-field-width: calc((var(--my-row-width) - 5px) * 0.25 - (var(--my-gap) * 0.75));
36
-
37
- }
38
-
39
- ::slotted(.quarter2) {
40
- --pd-input-field-width: calc((var(--my-row-width) * 0.5) - (var(--my-gap) / 2));
41
-
42
- }
43
-
44
- ::slotted(.quarter2-area) {
45
- --pd-input-field-width: calc(((var(--my-row-width) - 8px) * 0.5) - (var(--my-gap) / 2));
46
- }
47
-
48
- ::slotted(.quarter3) {
49
- --pd-input-field-width: calc(var(--my-row-width) * 0.75 - (var(--my-gap) * 0.25));
50
- }
51
- /* Area is longer? Scrollbar? */
52
- ::slotted(.quarter3-area) {
53
- --pd-input-field-width: calc((var(--my-row-width) - 10px) * 0.75 - (var(--my-gap) * 0.25));
54
- }
55
-
56
- ::slotted(.quarter4) {
57
- --pd-input-field-width: var(--my-row-width);
58
- }
59
- /* Area is longer? Scrollbar? */
60
- ::slotted(.quarter4-area) {
61
- --pd-input-field-width: calc(var(--my-row-width) - 15px);
62
- }
63
-
64
- @media (max-width: 930px) {
65
- :host {
66
- --my-row-width: 600px;
67
- }
68
- }
69
- @media (max-width: 650px) {
70
- :host {
71
- --my-row-width: 400px;
72
- --my-gap: 10px;
73
- }
74
- }
75
- @media (max-width: 450px) {
76
- :host {
77
- --my-row-width: 300px;
78
- --my-gap: 8px;
79
- }
80
- }
81
-
82
- `;
83
- }
84
- render() {
85
- return html`
86
- <slot></slot>
87
- `;
88
- }
89
- }
90
- export {
91
- PdFormRow
92
- };
@@ -1,108 +0,0 @@
1
- import { css, html } from "lit";
2
- import { PdBaseUI } from "./PdBaseUi.js";
3
- /**
4
- * @license
5
- * Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
6
- *
7
- * Lit element container for pd input elements.
8
- *
9
- * Used to:
10
- * - Automatically validation of form content
11
- * - Success/NotReady information for form-container
12
- */
13
- class PdHoverBox extends PdBaseUI {
14
- static get properties() {
15
- return {
16
- _visible: { type: Boolean, state: true },
17
- _toBottom: { type: Boolean }
18
- };
19
- }
20
- static get styles() {
21
- return [
22
- PdBaseUI.styles,
23
- css`
24
-
25
- :host {
26
-
27
- }
28
-
29
- .hover-box {
30
- position: relative;
31
- }
32
-
33
- .info-view {
34
- position: absolute;
35
- z-index: 100;
36
- background-color: var(--pd-hover-box-bg-col, var(--pd-default-dark-col));
37
-
38
- border: 1px solid var(--pd-hover-box-border-col, var(--pd-default-col));
39
-
40
- text-align: center;
41
- padding: 10px;
42
- width: 240px;
43
-
44
- color: var(--pd-hover-box-font-col, white);
45
- font-size: var(--pd-hover-box-font-size, 0.8em);
46
-
47
- transition: opacity 0.2s ease-in;
48
- }
49
-
50
- .visible {
51
- visibility: visible;
52
- opacity: 1;
53
- }
54
-
55
- .hidden {
56
- visibility: hidden;
57
- opacity: 0;
58
- }
59
-
60
- .to-bottom {
61
- right: -3px;
62
- top: -3px;
63
- }
64
-
65
- .to-top {
66
- right: -3px;
67
- bottom: -3px;
68
- }
69
-
70
- @media (max-width: 640px) {
71
- .info-view-visible {
72
- width: 190px;
73
- }
74
- }
75
-
76
- `
77
- ];
78
- }
79
- render() {
80
- return html`
81
- <div class="hover-box">
82
-
83
- <div @click="${this._activateInfo}">
84
- <slot name="normal-view"></slot>
85
- </div>
86
-
87
- <div id="infoViewId" @click="${this._closeInfo}" class="info-view ${this._visible ? "visible" : "hidden"} ${this._toBottom ? "to-bottom" : "to-top"}">
88
- <slot name="info-view"></slot>
89
- </div>
90
-
91
- </div>
92
- `;
93
- }
94
- // eslint-disable-next-line class-methods-use-this
95
- _activateInfo(e) {
96
- const modal = this.shadowRoot.getElementById("infoViewId");
97
- const rect = modal.getBoundingClientRect();
98
- this._toBottom = !(modal.offsetHeight + rect.top + rect.height > window.innerHeight);
99
- this._visible = true;
100
- e.stopPropagation();
101
- }
102
- _closeInfo() {
103
- this._visible = false;
104
- }
105
- }
106
- export {
107
- PdHoverBox
108
- };
@@ -1,79 +0,0 @@
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
- };