@progressive-development/pd-forms 0.1.30 → 0.1.32

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Webcomponent pd-forms following open-wc recommendations",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "author": "PD Progressive Development",
6
- "version": "0.1.30",
6
+ "version": "0.1.32",
7
7
  "main": "index.js",
8
8
  "module": "index.js",
9
9
  "scripts": {
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * @license
3
3
  * Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
4
- *
4
+ *
5
5
  * Abstract base lit class for pd-input elements.
6
- *
6
+ *
7
7
  * Used from:
8
8
  * - pd-checkbox
9
9
  * - pd-input
@@ -11,31 +11,33 @@
11
11
  * - pd-radio-group
12
12
  * - pd-range
13
13
  * - pd-select
14
- *
14
+ *
15
15
  * Used to:
16
16
  * - define css (import additional shared-input-styles.js)
17
17
  * - define common properties (detailieren, aktuell zu viele bzw. nicht für alle sub-elemente gültig)
18
18
  * - handle error msg (getter/setter)
19
19
  * - helpers for validation event after change and render label/error elements.
20
- *
20
+ *
21
21
  * Events:
22
22
  * - validate-form => fired when input element changed its value.
23
23
  * - enter-pressed => fired when enter pressed.
24
24
  * - field-change => fired when input element changed its value.
25
- *
25
+ *
26
26
  * Custom Properties (shared-input-styles):
27
- * ... TODO
28
- *
27
+ * ... TODO
28
+ *
29
29
  */
30
- import { html } from 'lit';
31
- import { PdBaseUI } from './PdBaseUi.js';
30
+ import {css, html} from 'lit';
31
+ import '@progressive-development/pd-icon/pd-icon.js';
32
+
33
+ import { PdBaseUI } from './PdBaseUi.js';
32
34
 
33
35
  import { SharedInputStyles } from './shared-input-styles.js';
34
36
 
35
37
  /**
36
38
  * Available input types.
37
39
  * Each input elemt set it's own type during constructor call.
38
- *
40
+ *
39
41
  * Comment: Not really needed/used at the moment.
40
42
  */
41
43
  export const INPUT_TYPE_TEXT = 1;
@@ -45,7 +47,7 @@ import { SharedInputStyles } from './shared-input-styles.js';
45
47
  export const INPUT_TYPE_AREA = 5;
46
48
  export const INPUT_TYPE_CHECK_GROUP = 6;
47
49
  export const INPUT_TYPE_DATE = 7;
48
-
50
+
49
51
  /**
50
52
  * Specific key codes for input events.
51
53
  */
@@ -59,7 +61,7 @@ import { SharedInputStyles } from './shared-input-styles.js';
59
61
 
60
62
  /**
61
63
  * Fired when an input element change its values.
62
- * @event validate-form
64
+ * @event validate-form
63
65
  */
64
66
 
65
67
  /**
@@ -75,19 +77,33 @@ import { SharedInputStyles } from './shared-input-styles.js';
75
77
  static get styles() {
76
78
  return [
77
79
  PdBaseUI.styles,
78
- SharedInputStyles
80
+ SharedInputStyles,
81
+ css`
82
+ .label-header {
83
+ display: flex;
84
+ align-items: end;
85
+ justify-content: space-between;
86
+ }
87
+
88
+ .label-header pd-icon {
89
+ --pd-icon-size: 1rem;
90
+ padding-right: 5px;
91
+ cursor: help;
92
+ }
93
+ `
79
94
  ];
80
95
  }
81
96
 
82
97
  static get properties() {
83
- return {
98
+ return {
84
99
  gradient: { type: Boolean }, // true for gradient background
85
100
  disabled: { type: Boolean }, // disabled flag for element
86
101
  readonly: { type: Boolean }, // readonly flag for element
87
102
  required: { type: Boolean }, // required flag for element
88
103
  requiredMsg: { type: String }, // specific error msg for required field
89
- valueName: { type: String },
90
- defaultRequiredChar: { type: String },
104
+ helperTxt: { type: String }, // helper text
105
+ valueName: { type: String },
106
+ defaultRequiredChar: { type: String },
91
107
  defaultValue: { type: String }, // default value for input element (used for reset) TODO: Das hier ggf. automatisch mit erstem gesetzten Wert füllen?
92
108
  label: { type: String }, // label text for input
93
109
  value: {type: String}, // current value (set from outside) TODO: Typ (Object, Number, Txt, Bool...)
@@ -95,51 +111,51 @@ import { SharedInputStyles } from './shared-input-styles.js';
95
111
  _inputType: {type: Number, state: true}, // number value for type (text, select, range....), set constructor of sub-class
96
112
  };
97
113
  }
98
-
114
+
99
115
  constructor() {
100
- super();
116
+ super();
101
117
  this.gradient = false;
102
118
  this.disabled = false;
103
119
  this.readonly = false;
104
120
  this.defaultValue = '';
105
121
  this.label = '';
106
122
  this.value = '';
107
- this._errorMsg = '';
123
+ this._errorMsg = '';
108
124
  this._inputType = -1;
109
125
  this.valueName = '';
110
-
126
+
111
127
  this.defaultRequiredChar = '*';
112
- }
113
-
128
+ }
129
+
114
130
  // Test: Clear input with value => Dann in BasisKlasse und alle leiten von Basis UI Element ab
115
131
  clear() {
116
132
  this.value = '';
117
133
  // this._input.value = this.value;
118
134
  }
119
-
135
+
120
136
  // Test: Reset input with value
121
- reset() {
137
+ reset() {
122
138
  this.value = this.defaultValue || '';
123
139
  // this._input.value = this.value;
124
140
  }
125
-
141
+
126
142
  get errorMsg() {
127
143
  return this._errorMsg;
128
144
  }
129
-
145
+
130
146
  set errorMsg(msg) {
131
147
  this._errorMsg = msg;
132
148
  }
133
-
149
+
134
150
  /*
135
151
  get value() {
136
152
  return this._value;
137
153
  }
138
-
154
+
139
155
  set value(newValue) {
140
156
  console.info("Meine Werte vor Set _value, input.value, newValue: ", this._value, this._input.value, newValue);
141
157
  this._value = newValue;
142
- this._input.value = newValue;
158
+ this._input.value = newValue;
143
159
  console.info("Meine Werte nach Set: ", this._value, this._input.value, newValue);
144
160
  }
145
161
  */
@@ -148,7 +164,7 @@ import { SharedInputStyles } from './shared-input-styles.js';
148
164
  this.dispatchEvent(
149
165
  new CustomEvent('validate-form', {
150
166
  detail: {
151
- singleElement: this,
167
+ singleElement: this,
152
168
  errorMap: new Map()
153
169
  },
154
170
  composed: true,
@@ -167,7 +183,7 @@ import { SharedInputStyles } from './shared-input-styles.js';
167
183
  name: this.valueName,
168
184
  keyCode, changed
169
185
  }
170
- const handleReturn = checkReturn && keyCode === KEY_RETURN;
186
+ const handleReturn = checkReturn && keyCode === KEY_RETURN;
171
187
  if (handleReturn) {
172
188
  this.dispatchEvent(
173
189
  new CustomEvent('enter-pressed', {
@@ -178,7 +194,7 @@ import { SharedInputStyles } from './shared-input-styles.js';
178
194
  );
179
195
  event.preventDefault();
180
196
 
181
- }
197
+ }
182
198
 
183
199
  if (changed) {
184
200
  // generate changed event
@@ -188,7 +204,7 @@ import { SharedInputStyles } from './shared-input-styles.js';
188
204
  composed: true,
189
205
  bubbles: true,
190
206
  })
191
- );
207
+ );
192
208
  }
193
209
 
194
210
  if (showValidateMsg) {
@@ -209,7 +225,10 @@ import { SharedInputStyles } from './shared-input-styles.js';
209
225
 
210
226
  _renderLabel(forParam, additionalValue) {
211
227
  return html`
228
+ <div class="label-header">
212
229
  <label for="${forParam}">${this.label}${this.required && this.label ? this.defaultRequiredChar : ''}${additionalValue ? html` - <b>${additionalValue}</b>` : ''}</label>
230
+ ${this.helperTxt ? html`<pd-icon title="${this.helperTxt}" icon="userIcon" class="" activeIcon></pd-icon>` : ""}
231
+ </div>
213
232
  `;
214
233
  }
215
234
 
package/src/PdCheckbox.js CHANGED
@@ -14,26 +14,26 @@ import { PdBaseUIInput, INPUT_TYPE_CHECK } from "./PdBaseUiInput.js";
14
14
  /**
15
15
  * Lit Checkbox Element.
16
16
  * Could displayed as switch (set isSwitch to true) or checkbox implementation.
17
- *
18
- * Styling is wrapped inside the checkbox element, which uses the styling properties from
17
+ *
18
+ * Styling is wrapped inside the checkbox element, which uses the styling properties from
19
19
  * pd-icon (detailed).
20
- *
20
+ *
21
21
  ### Custom Properties: #######################################
22
22
  # Style for checked checkbox: Default values #
23
- ##############################################################
23
+ ##############################################################
24
24
  * --pd-cb-col unset, pd-icon default
25
25
  * --pd-cb-col-hover unset, pd-icon default
26
26
  * --pd-cb-bg-col unset, pd-icon default
27
27
  * --pd-cb-stroke-col unset, pd-icon default
28
28
  * --pd-cb-stroke-col-hover unset, pd-icon default
29
- *
30
- * Style for unchecked checkbox:
29
+ *
30
+ * Style for unchecked checkbox:
31
31
  * --pd-cb-unset-col unset, pd-icon default
32
32
  * --pd-cb-unset-col-hover unset, pd-icon default
33
33
  * --pd-cb-unset-bg-col unset, pd-icon default
34
34
  * --pd-cb-unset-stroke-col unset, pd-icon default
35
35
  * --pd-cb-unset-stroke-col-hover unset, pd-icon default
36
- *
36
+ *
37
37
  * --pd-cb-border-col --pd-default-col
38
38
  * --pd-cb-border-radius 4px (not border for rounded elements, cb specific)
39
39
  * --pd-cb-font-col --pd-default-font-input-col
@@ -42,12 +42,12 @@ import { PdBaseUIInput, INPUT_TYPE_CHECK } from "./PdBaseUiInput.js";
42
42
  * --pd-cb-txt-col-readonly #4d4d4d
43
43
  * --pd-cb-switch-height not set
44
44
  * --pd-cb-switch-paddle-col --pd-default-col
45
- *
45
+ *
46
46
  */
47
47
  export class PdCheckbox extends PdBaseUIInput {
48
-
48
+
49
49
  static get properties() {
50
- return {
50
+ return {
51
51
  isSwitch: { type: Boolean },
52
52
  _hasInner: { type: Boolean, state: true },
53
53
  };
@@ -55,7 +55,7 @@ export class PdCheckbox extends PdBaseUIInput {
55
55
 
56
56
  constructor() {
57
57
  super();
58
- this._inputType = INPUT_TYPE_CHECK;
58
+ this._inputType = INPUT_TYPE_CHECK;
59
59
  }
60
60
 
61
61
  static get styles() {
@@ -63,14 +63,14 @@ export class PdCheckbox extends PdBaseUIInput {
63
63
  PdBaseUIInput.styles,
64
64
  css`
65
65
  :host {
66
- display: inline-block;
66
+ display: inline-block;
67
67
 
68
68
  /* Style for active checkbox => use defaults from pd-icon if no custom properties set */
69
69
  --pd-icon-col-active: var(--pd-cb-col);
70
70
  --pd-icon-col-active-hover: var(--pd-cb-col-hover);
71
71
  --pd-icon-bg-col-active: var(--pd-cb-bg-col);
72
72
  --pd-icon-stroke-col-active: var(--pd-cb-stroke-col);
73
- --pd-icon-stroke-col-active-hover: var(--pd-cb-stroke-col-hover);
73
+ --pd-icon-stroke-col-active-hover: var(--pd-cb-stroke-col-hover);
74
74
 
75
75
  /* Style for inactive checkbox */
76
76
  --pd-icon-col: var(--pd-cb-unset-col);
@@ -81,7 +81,7 @@ export class PdCheckbox extends PdBaseUIInput {
81
81
  }
82
82
 
83
83
  /* Switch pd-icon => Prüfen, bei mir musste ich reflect setzten, wird das verwendet? */
84
- :host([isSwitch]) {
84
+ :host([isSwitch]) {
85
85
  /* derzeit keine Angaben */
86
86
  }
87
87
 
@@ -100,8 +100,8 @@ export class PdCheckbox extends PdBaseUIInput {
100
100
  cursor: auto;
101
101
  }
102
102
 
103
- /*
104
- * Class checkbox for icon and a element (checkbox case)
103
+ /*
104
+ * Class checkbox for icon and a element (checkbox case)
105
105
  */
106
106
  .checkbox {
107
107
  display: flex;
@@ -109,12 +109,12 @@ export class PdCheckbox extends PdBaseUIInput {
109
109
  line-height: 0;
110
110
  align-items: center;
111
111
  justify-content: center;
112
- /*
112
+ /*
113
113
  Wurde das hier für Border verwendet? Aktuell border in folgendem Element gesetzt
114
- background-color: var(--pd-cb-border-col, var(--pd-primary-col, #067394));
115
- */
114
+ background-color: var(--pd-cb-border-col, var(--pd-primary-col, #067394));
115
+ */
116
116
 
117
- }
117
+ }
118
118
 
119
119
  .checkbox pd-icon {
120
120
  margin-right: .2rem;
@@ -125,7 +125,7 @@ export class PdCheckbox extends PdBaseUIInput {
125
125
 
126
126
  .label {
127
127
  margin-left: 0.1rem;
128
- color: var(--pd-cb-font-col, var(--pd-default-font-input-col));
128
+ color: var(--pd-cb-font-col, var(--pd-default-font-input-col));
129
129
  font-family: var(--pd-default-font-input-family);
130
130
  text-align: left;
131
131
  font-size: var(--pd-default-font-input-size);
@@ -180,11 +180,11 @@ export class PdCheckbox extends PdBaseUIInput {
180
180
  transform: translate3d(0, 0, 0);
181
181
  border: 2px solid var(--pd-cb-border-col, var(--pd-default-col));
182
182
  box-shadow: rgba(0, 0, 0, 0.15) 1.95px 1.95px 2.6px;
183
- border-radius: var(--pd-cb-border-radius, 4px);
183
+ border-radius: var(--pd-cb-border-radius, 4px);
184
184
  -webkit-transition: all 0.25s ease-out;
185
185
  transition: all 0.25s ease-out;
186
186
  content: '';
187
- }
187
+ }
188
188
 
189
189
  .disabled .switch-paddle {
190
190
  cursor: auto;
@@ -204,7 +204,7 @@ export class PdCheckbox extends PdBaseUIInput {
204
204
  */
205
205
  }
206
206
 
207
- .readonly .switch-paddle pd-icon {
207
+ .readonly .switch-paddle pd-icon {
208
208
  border-color: var(--pd-cb-border-col-readonly, transparent);
209
209
  }
210
210
 
@@ -212,11 +212,11 @@ export class PdCheckbox extends PdBaseUIInput {
212
212
  transform: translate3d(0, 0, 0);
213
213
  left: 0rem;
214
214
  }
215
-
215
+
216
216
  .isChecked.switch-paddle pd-icon {
217
217
  left: 2.25rem;
218
218
  }
219
-
219
+
220
220
  @media (min-width: 580px) {
221
221
  :host {
222
222
  font-size: 1rem;
@@ -232,10 +232,10 @@ export class PdCheckbox extends PdBaseUIInput {
232
232
  this._hasInnerSet = true;
233
233
  this._hasInner = !!this.innerHTML.trim().length;
234
234
  }
235
-
235
+
236
236
  const checked = (this.value === 'true');
237
237
  const classMapVal = {'disabled': this.disabled, 'switch': this.isSwitch, 'readonly': this.readonly, 'div-container': true};
238
- const aClassMap = {'switch-paddle': this.isSwitch, 'checkbox': !this.isSwitch, 'isChecked': checked, 'isUnchecked': !checked};
238
+ const aClassMap = {'switch-paddle': this.isSwitch, 'checkbox': !this.isSwitch, 'isChecked': checked, 'isUnchecked': !checked};
239
239
  const inputId = `${this.id}Check`;
240
240
 
241
241
  return html`
@@ -257,9 +257,9 @@ export class PdCheckbox extends PdBaseUIInput {
257
257
  if (this.disabled || this.readonly) {
258
258
  return;
259
259
  }
260
- const checked = (this.value === 'true');
261
-
262
- // set changed value and generate events (key-pressed, enter-pressed, validateForm)
260
+ const checked = (this.value === 'true');
261
+
262
+ // set changed value and generate events (key-pressed, enter-pressed, validateForm)
263
263
  // if neccessary
264
264
  this._handleChangedValue(checked ? 'false' : 'true', e);
265
265
 
@@ -275,15 +275,15 @@ export class PdCheckbox extends PdBaseUIInput {
275
275
  */
276
276
  }
277
277
 
278
- onKeyPress(e) {
278
+ onKeyPress(e) {
279
279
  e.preventDefault();
280
280
  if (e.keyCode === 32 || e.code === "Space") {
281
281
  this.onClick(e);
282
282
  }
283
283
  }
284
-
284
+
285
285
  // eslint-disable-next-line class-methods-use-this
286
286
  linkClick(e) {
287
287
  e.preventDefault();
288
288
  }
289
- }
289
+ }
package/src/PdRange.js CHANGED
@@ -215,14 +215,20 @@ export class PdRange extends PdBaseUIInput {
215
215
  font-weight: bolder;
216
216
  }
217
217
 
218
- .tick .disabled {
218
+ .ticks.disabled {
219
219
  color: grey;
220
220
  }
221
221
 
222
- .tick .enabled {
222
+ .ticks.enabled {
223
223
  color: var(--pd-default-col);
224
224
  }
225
225
 
226
+ @media (max-width: 650px) {
227
+ label {
228
+ font-size: 12px;
229
+ }
230
+ }
231
+
226
232
  `
227
233
  ];
228
234
  }
@@ -43,22 +43,22 @@ function Template() {
43
43
  <pd-input class="quarter1" id="test10Id" label="Label 6"></pd-input>
44
44
  </pd-form-row>
45
45
  <pd-form-row>
46
- <pd-input-area class="quarter3-area" id="test19Id" label="Label Area" required></pd-input-area>
46
+ <pd-input-area class="quarter3-area" id="test19Id" label="Label Area" required></pd-input-area>
47
47
  <pd-input-area class="quarter1-area" id="test20Id" label="Label Area" required
48
48
  requiredMsg="Das ist eine richtig lange Fehlermeldung. Diese kann per Parameter für spezielle Felder wie die AGB Checkbox gesetzt werden.">
49
- </pd-input-area>
49
+ </pd-input-area>
50
50
  </pd-form-row>
51
51
  <pd-form-row>
52
52
  <pd-input class="quarter1" id="test11Id" label="Label 5"></pd-input>
53
53
  <pd-input class="quarter3" id="test12Id" label="Label 6"></pd-input>
54
- </pd-form-row>
54
+ </pd-form-row>
55
55
  <pd-form-row>
56
56
  <pd-input class="quarter1" id="test13Id" label="Label 5"></pd-input>
57
57
  <pd-input class="quarter1" id="test14Id" label="Label 5"></pd-input>
58
58
  <pd-input class="quarter2" id="test15Id" label="Label 6"></pd-input>
59
59
  </pd-form-row>
60
60
  <pd-form-row>
61
- <pd-input-area class="quarter4-area" id="test16Id" label="Label Area" required></pd-input-area>
61
+ <pd-input-area class="quarter4-area" id="test16Id" label="Label Area" required></pd-input-area>
62
62
  </pd-form-row>
63
63
  <pd-form-row>
64
64
  <pd-input-area class="quarter2-area" id="test17Id" label="Label Area" required></pd-input-area>
@@ -67,11 +67,19 @@ function Template() {
67
67
  </pd-form-row>
68
68
  <pd-form-row>
69
69
  <pd-range id="testRangeId"
70
- label="Range Label"
70
+ label="Range Label"
71
71
  max="12"
72
72
  value="0" .optionValueMapper="${OPTIONS_GENRE}" required>
73
73
  </pd-range>
74
74
  </pd-form-row>
75
+ <pd-form-row>
76
+ <pd-range id="testRangeId"
77
+ label="Mit Helper"
78
+ max="12"
79
+ helperTxt="Hier kommt dann kluges hin"
80
+ value="0" .optionValueMapper="${OPTIONS_GENRE}" required>
81
+ </pd-range>
82
+ </pd-form-row>
75
83
  </pd-form-container>
76
84
 
77
85
  <h2>Test Validation</h2>