@progressive-development/pd-forms 0.1.13 → 0.1.15

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.13",
6
+ "version": "0.1.15",
7
7
  "main": "index.js",
8
8
  "module": "index.js",
9
9
  "scripts": {
@@ -203,9 +203,9 @@ import { SharedInputStyles } from './shared-input-styles.js';
203
203
  ` : '';
204
204
  }
205
205
 
206
- _renderLabel(forParam) {
206
+ _renderLabel(forParam, additionalValue) {
207
207
  return html`
208
- <label for="${forParam}">${this.label}${this.required && this.label ? this.defaultRequiredChar : ''}</label>
208
+ <label for="${forParam}">${this.label}${this.required && this.label ? this.defaultRequiredChar : ''}${additionalValue ? html` - <b>${additionalValue}</b>` : ''}</label>
209
209
  `;
210
210
  }
211
211
 
@@ -12,6 +12,8 @@
12
12
  import { html, css } from 'lit';
13
13
  import { msg } from '@lit/localize';
14
14
 
15
+ import { INPUT_TYPE_RANGE } from './PdBaseUiInput.js';
16
+
15
17
  import { PdBaseUI } from './PdBaseUi.js';
16
18
 
17
19
  /**
@@ -102,7 +104,10 @@ export class PdFormContainer extends PdBaseUI {
102
104
  reqEl.forEach(el => {
103
105
  const tmpEl = el;
104
106
 
105
- if (!el.value || el.value === "" || el.value === "false") {
107
+ console.log("Check EL: ", el._inputType, el.value);
108
+
109
+ if (!el.value || el.value === "" || el.value === "false" ||
110
+ (el._inputType === INPUT_TYPE_RANGE && el.value === '0')) {
106
111
  const erMsg = el.requiredMsg || msg('Eingabe erforderlich',{desc: '#pd.form.field.required#'});
107
112
  if (!e.detail.singleElement || e.detail.singleElement === el) {
108
113
  tmpEl.errorMsg = erMsg;
@@ -0,0 +1,197 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 PD Progressive Development UG. All rights reserved.
4
+ */
5
+
6
+ import { html, css } from 'lit';
7
+
8
+ import { PdBaseUIInput, INPUT_TYPE_RANGE } from './PdBaseUiInput.js';
9
+
10
+
11
+ export class PdRange extends PdBaseUIInput {
12
+
13
+ static get properties() {
14
+ return {
15
+ min: { type: String },
16
+ max: { type: String },
17
+ step: { type: Number},
18
+ showLegend: { type: Boolean }
19
+ };
20
+ }
21
+
22
+ constructor() {
23
+ super();
24
+ this._inputType = INPUT_TYPE_RANGE;
25
+ this.step = 0.1;
26
+ this.showLegend = false;
27
+ }
28
+
29
+ static get styles() {
30
+ return [
31
+ css`
32
+ input[type=range] {
33
+ -webkit-appearance: none;
34
+ margin: 0;
35
+ width: 100%;
36
+ background-color: var(--my-background-color);
37
+ padding: var(--squi-input-padding, .5rem);
38
+ height: var(--my-input-height);
39
+ box-sizing: border-box;
40
+ }
41
+ input[type=range]:focus {
42
+ outline: none;
43
+ }
44
+ input[type=range]::-webkit-slider-runnable-track {
45
+ width: 100%;
46
+ cursor: pointer;
47
+ box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
48
+ background: linear-gradient(-90deg, rgba(var(--my-lighter-background-color), .8) 25%, rgba(var(--my-darker-background-color), 1));
49
+ border-radius: 3px;
50
+ border: 0px solid #000101;
51
+ }
52
+ input[type=range]::-webkit-slider-thumb {
53
+ box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
54
+ border: 0px solid #000000;
55
+ height: 20px;
56
+ width: 39px;
57
+ border-radius: 3px;
58
+ background: var(--my-primary-color);
59
+ cursor: pointer;
60
+ -webkit-appearance: none;
61
+ margin-top: -3.6px;
62
+ }
63
+ input[type=range]:focus::-webkit-slider-runnable-track {
64
+ background: linear-gradient(-90deg, rgba(var(--my-lighter-background-color), .8) 25%, rgba(var(--my-darker-background-color), 1));
65
+ }
66
+ input[type=range]::-moz-range-track {
67
+ width: 100%;
68
+ height: 12.8px;
69
+ cursor: pointer;
70
+ animation: 0.2s;
71
+ box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
72
+ background: linear-gradient(-90deg, rgba(var(--my-lighter-background-color), .8) 25%, rgba(var(--my-darker-background-color), 1));
73
+ border-radius: 3px;
74
+ border: 0px solid #000101;
75
+ }
76
+ input[type=range]::-moz-range-thumb {
77
+ box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
78
+ border: 0px solid #000000;
79
+ height: 20px;
80
+ width: 39px;
81
+ border-radius: 3px;
82
+ background: var(--my-primary-color);
83
+ cursor: pointer;
84
+ }
85
+ input[type=range]::-ms-track {
86
+ width: 100%;
87
+ height: 12.8px;
88
+ cursor: pointer;
89
+ animation: 0.2s;
90
+ background: transparent;
91
+ border-color: transparent;
92
+ border-width: 39px 0;
93
+ color: transparent;
94
+ }
95
+ input[type=range]::-ms-fill-lower {
96
+ background: linear-gradient(-90deg, rgba(var(---my-lighter-background-color), .8) 25%, rgba(var(--my-darker-background-color), 1));
97
+ border: 0px solid #000101;
98
+ border-radius: 7px;
99
+ box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
100
+ }
101
+ input[type=range]::-ms-fill-upper {
102
+ background: linear-gradient(-90deg, rgba(var(--my-lighter-background-color), .8) 25%, rgba(var(--my-darker-background-color), 1));
103
+ border: 0px solid #000101;
104
+ border-radius: 7px;
105
+ box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
106
+ }
107
+ input[type=range]::-ms-thumb {
108
+ box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
109
+ border: 0px solid #000000;
110
+ height: 20px;
111
+ width: 39px;
112
+ border-radius: 3px;
113
+ background: var(--my-primary-color);
114
+ cursor: pointer;
115
+ }
116
+ :host label.value {
117
+ flex: 0 1 10%;
118
+ }
119
+ input[type=range]:focus::-ms-fill-lower {
120
+ background: linear-gradient(-90deg, rgba(var(--my-lighter-background-color), .8) 25%, rgba(var(--my-darker-background-color), 1));
121
+ }
122
+ input[type=range]:focus::-ms-fill-upper {
123
+ background: linear-gradient(-90deg, rgba(var(--my-lighter-background-color), .8) 25%, rgba(var(--my-darker-background-color), 1));
124
+ }
125
+ .legend {
126
+ display: flex;
127
+ /*margin: 0 -1rem;*/
128
+ }
129
+ .legend label {
130
+ text-align: center;
131
+ position: relative;
132
+ }
133
+ .legend label::before {
134
+ background-color: rgb(var(--my-lighter-background-color));
135
+ content: "";
136
+ height: .5rem;
137
+ position: absolute;
138
+ left: 50%;
139
+ top: -.5rem;
140
+ width: 1px;
141
+ }
142
+ .range_legend_label--selected {
143
+ color: var(--my-primary-color);
144
+ }
145
+ /* TODO remove to specific */
146
+ .range_legend_label--selected::after{
147
+ content: '';
148
+ position: absolute;
149
+ left: 20%;
150
+ top: 100%;
151
+ width: 0;
152
+ height: 0;
153
+ border-left: 20px solid transparent;
154
+ border-right: 20px solid transparent;
155
+ border-bottom: 20px solid rgb(var(--my-lighter-background-color));
156
+ }
157
+ `
158
+ ];
159
+ }
160
+
161
+ render() {
162
+ // TODO: step kann hier nicht übergeben werden, wird dann initial nicht immer richtig angezeigt (bei komma rundungen)???
163
+ return html`
164
+ <label for="${this.id}Input">${this.label} ${this.showLegend ? '' : html`- ${this.value}`}</label>
165
+ <input ?disabled=${this.disabled} type="range" name="${this.id}Name" @change="${this._onChange}"
166
+ .value="${this.value}" min="${this.min}" max="${this.max}"
167
+ step="${this.step}" id="${this.id}Input">
168
+ ${this.showLegend ? this._addLegend() : ''}
169
+ `;
170
+ }
171
+
172
+ firstUpdated() {
173
+ // Save input reference for performance
174
+ this._input = this.shadowRoot.querySelector('input');
175
+ }
176
+
177
+ _addLegend() {
178
+ const steps = this.max - this.min;
179
+ const labels = [];
180
+ for (let i = 0; i <= steps; i+=1) {
181
+ labels.push(html`<label class="${i + this.step === this.value * 1 ? 'range_legend_label--selected' : ''}">${i + this.step}</label>`);
182
+ }
183
+ return html`<div class="legend">${labels}</div>`
184
+ }
185
+
186
+ _onChange() {
187
+ this.value = this._input.value;
188
+ this.dispatchEvent(new CustomEvent('changed', {
189
+ detail: {
190
+ value: this._input.value
191
+ },
192
+ composed: true,
193
+ bubbles: true
194
+ }));
195
+ }
196
+
197
+ }
package/src/PdRange.js CHANGED
@@ -4,10 +4,10 @@
4
4
  */
5
5
 
6
6
  import { html, css } from 'lit';
7
+ import { classMap } from 'lit/directives/class-map.js';
7
8
 
8
9
  import { PdBaseUIInput, INPUT_TYPE_RANGE } from './PdBaseUiInput.js';
9
10
 
10
-
11
11
  export class PdRange extends PdBaseUIInput {
12
12
 
13
13
  static get properties() {
@@ -15,157 +15,205 @@ export class PdRange extends PdBaseUIInput {
15
15
  min: { type: String },
16
16
  max: { type: String },
17
17
  step: { type: Number},
18
- showLegend: { type: Boolean }
18
+ optionValueMapper: { type: Object },
19
19
  };
20
20
  }
21
21
 
22
22
  constructor() {
23
23
  super();
24
24
  this._inputType = INPUT_TYPE_RANGE;
25
- this.step = 0.1;
26
- this.showLegend = false;
25
+ this.step = 1;
26
+ this.optionValueMapper = {};
27
27
  }
28
28
 
29
29
  static get styles() {
30
- return [
31
- css`
30
+ return [
31
+ PdBaseUIInput.styles,
32
+ css`
33
+
34
+ /* Link:
35
+ * css styling: - https://css-tricks.com/styling-cross-browser-compatible-range-inputs-css/
36
+ * no-empty-default - https://stackoverflow.com/questions/40302515/is-there-a-way-to-set-default-value-of-range-input-to-be-empty
37
+ * => Könnte ich vlt. mit dummy element lösen => Kein Wert => Dummy wird angezeigt => Bei Klick wird Wert gesetzt und PdRange angezeigt. Oder doch Vorschlag aus StackOverflow => -1 als default Wert => Kein gesetzer Wert
38
+ * Style Ticks/Lables: - https://stackoverflow.com/questions/26612700/ticks-for-type-range-html-input
39
+ */
40
+
41
+ /****************************************************
42
+ * Style for SLIDER *
43
+ ****************************************************/
44
+
32
45
  input[type=range] {
33
- -webkit-appearance: none;
34
- margin: 0;
35
- width: 100%;
36
- background-color: var(--my-background-color);
37
- padding: var(--squi-input-padding, .5rem);
38
- height: var(--my-input-height);
46
+ -webkit-appearance: none; /* Hides the slider so that custom slider can be made */
47
+ width: var(--pd-input-field-width, 250px); /* Specific width is required for Firefox. */
48
+ background: transparent; /* Otherwise white in Chrome */
49
+
50
+ background-color: var(--pd-range-bg-col, var(--pd-default-col));
51
+ padding: 0.5rem;
52
+ height: var(--pd-input-field-height, 2.2rem);
39
53
  box-sizing: border-box;
54
+
55
+ border-radius: 0.75rem;
40
56
  }
57
+
41
58
  input[type=range]:focus {
42
- outline: none;
59
+ /* Removes the blue border.
60
+ * You should probably do some kind of focus styling for accessibility reasons though. */
61
+ outline: none;
43
62
  }
44
- input[type=range]::-webkit-slider-runnable-track {
45
- width: 100%;
63
+
64
+ /****************************************************
65
+ * Style for THUMBS specific for different browser *
66
+ * Check: Possible to extract common definitions? *
67
+ * => Note that while we’re repeating code here, *
68
+ * that’s necessary as you can’t comma-separate *
69
+ * these type of selectors. Browsers will drop *
70
+ * the entire selector if it doesn’t understand *
71
+ * a part of it. *
72
+ ****************************************************/
73
+
74
+ /**
75
+ * Standard/Chrome thumb definition.
76
+ */
77
+ input[type=range]::-webkit-slider-thumb {
78
+ /* Hide the standard thumb element */
79
+ -webkit-appearance: none;
80
+ /*margin-top: -14px; /* You need to specify a margin in Chrome, but in Firefox and IE it is automatic */
81
+ margin-top: -6px; /* squi.cards value */
82
+
83
+ /* redundant, check if it is possible to extract common definitions */
46
84
  cursor: pointer;
47
- box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
48
- background: linear-gradient(-90deg, rgba(var(--my-lighter-background-color), .8) 25%, rgba(var(--my-darker-background-color), 1));
85
+ height: 20px;
86
+ width: 39px;
87
+ background: var(--pd-range-thumb-col, var(--pd-default-hover-col));
88
+ border: 1px solid var(--pd-default-dark-col);
49
89
  border-radius: 3px;
50
- border: 0px solid #000101;
90
+ box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
51
91
  }
52
- input[type=range]::-webkit-slider-thumb {
53
- box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
54
- border: 0px solid #000000;
92
+
93
+ /**
94
+ * Firefox thumb definition.
95
+ */
96
+ input[type=range]::-moz-range-thumb {
97
+ /* redundant, check if it is possible to extract common definitions */
98
+ cursor: pointer;
55
99
  height: 20px;
56
100
  width: 39px;
101
+ background: var(--pd-range-thumb-col, var(--pd-default-hover-col));
102
+ border: 1px solid var(--pd-default-dark-col);
57
103
  border-radius: 3px;
58
- background: var(--my-primary-color);
104
+ box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
105
+ }
106
+
107
+ /**
108
+ * IE Thum definiton.
109
+ */
110
+ input[type=range]::-ms-thumb {
111
+ /* redundant, check if it is possible to extract common definitions */
59
112
  cursor: pointer;
60
- -webkit-appearance: none;
61
- margin-top: -3.6px;
113
+ height: 20px;
114
+ width: 39px;
115
+ background: var(--pd-range-thumb-col, var(--pd-default-hover-col));
116
+ border: 1px solid var(--pd-default-dark-col);
117
+ border-radius: 3px;
118
+ box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
62
119
  }
120
+
121
+
122
+ /****************************************************
123
+ * Style for TRACK specific for different browser *
124
+ * (see thumbs styles) *
125
+ ****************************************************/
126
+
127
+ /**
128
+ * Standard/Chrome track definition.
129
+ */
130
+ input[type=range]::-webkit-slider-runnable-track {
131
+ width: 100%;
132
+ height: 8.4px;
133
+ cursor: pointer;
134
+ box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
135
+ background: var(--pd-range-track-col, var(--pd-default-light-col));
136
+ border: 0.2px solid #010101;
137
+
138
+ border-radius: 0.75rem;
139
+ }
140
+
63
141
  input[type=range]:focus::-webkit-slider-runnable-track {
64
- background: linear-gradient(-90deg, rgba(var(--my-lighter-background-color), .8) 25%, rgba(var(--my-darker-background-color), 1));
142
+ background: var(--pd-range-track-hover-col, var(--pd-default-light-col));
143
+ border: 0.2px solid var(--pd-default-hover-col);
65
144
  }
145
+
146
+ /**
147
+ * Firefox track definition.
148
+ */
66
149
  input[type=range]::-moz-range-track {
67
150
  width: 100%;
68
- height: 12.8px;
69
- cursor: pointer;
70
- animation: 0.2s;
71
- box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
72
- background: linear-gradient(-90deg, rgba(var(--my-lighter-background-color), .8) 25%, rgba(var(--my-darker-background-color), 1));
73
- border-radius: 3px;
74
- border: 0px solid #000101;
75
- }
76
- input[type=range]::-moz-range-thumb {
77
- box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
78
- border: 0px solid #000000;
79
- height: 20px;
80
- width: 39px;
81
- border-radius: 3px;
82
- background: var(--my-primary-color);
151
+ height: 8.4px;
83
152
  cursor: pointer;
153
+ box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
154
+ background: var(--pd-range-track-col, var(--pd-default-light-col));
155
+ border-radius: 0.75rem;
156
+ border: 0.2px solid #010101;
84
157
  }
158
+
159
+ /**
160
+ * IE track definition.
161
+ * Check: Why are they different.
162
+ */
85
163
  input[type=range]::-ms-track {
164
+
165
+ height: 8.4px;
86
166
  width: 100%;
87
- height: 12.8px;
88
167
  cursor: pointer;
89
- animation: 0.2s;
90
- background: transparent;
168
+
169
+ /* Hides the slider so custom styles can be added */
170
+ background: transparent;
91
171
  border-color: transparent;
92
- border-width: 39px 0;
93
172
  color: transparent;
173
+
174
+ border-width: 16px 0;
94
175
  }
95
176
  input[type=range]::-ms-fill-lower {
96
- background: linear-gradient(-90deg, rgba(var(---my-lighter-background-color), .8) 25%, rgba(var(--my-darker-background-color), 1));
97
- border: 0px solid #000101;
98
- border-radius: 7px;
99
- box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
100
- }
101
- input[type=range]::-ms-fill-upper {
102
- background: linear-gradient(-90deg, rgba(var(--my-lighter-background-color), .8) 25%, rgba(var(--my-darker-background-color), 1));
103
- border: 0px solid #000101;
104
- border-radius: 7px;
105
- box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
106
- }
107
- input[type=range]::-ms-thumb {
108
- box-shadow: 0px 0px 0px #000000, 0px 0px 0px #0d0d0d;
109
- border: 0px solid #000000;
110
- height: 20px;
111
- width: 39px;
112
- border-radius: 3px;
113
- background: var(--my-primary-color);
114
- cursor: pointer;
115
- }
116
- :host label.value {
117
- flex: 0 1 10%;
177
+ background: var(--pd-range-track-col, var(--pd-default-light-col));
178
+ border: 0.2px solid #010101;
179
+ border-radius: 0.75rem;
180
+ box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
118
181
  }
119
182
  input[type=range]:focus::-ms-fill-lower {
120
- background: linear-gradient(-90deg, rgba(var(--my-lighter-background-color), .8) 25%, rgba(var(--my-darker-background-color), 1));
121
- }
122
- input[type=range]:focus::-ms-fill-upper {
123
- background: linear-gradient(-90deg, rgba(var(--my-lighter-background-color), .8) 25%, rgba(var(--my-darker-background-color), 1));
124
- }
125
- .legend {
126
- display: flex;
127
- /*margin: 0 -1rem;*/
128
- }
129
- .legend label {
130
- text-align: center;
131
- position: relative;
132
- }
133
- .legend label::before {
134
- background-color: rgb(var(--my-lighter-background-color));
135
- content: "";
136
- height: .5rem;
137
- position: absolute;
138
- left: 50%;
139
- top: -.5rem;
140
- width: 1px;
183
+ background: #3071a9;
141
184
  }
142
- .range_legend_label--selected {
143
- color: var(--my-primary-color);
185
+ input[type=range]::-ms-fill-upper {
186
+ background: var(--pd-range-track-col, var(--pd-default-light-col));
187
+ border: 0.2px solid #010101;
188
+ border-radius: 0.75rem;
189
+ box-shadow: 1px 1px 1px #000000, 0px 0px 1px #0d0d0d;
144
190
  }
145
- /* TODO remove to specific */
146
- .range_legend_label--selected::after{
147
- content: '';
148
- position: absolute;
149
- left: 20%;
150
- top: 100%;
151
- width: 0;
152
- height: 0;
153
- border-left: 20px solid transparent;
154
- border-right: 20px solid transparent;
155
- border-bottom: 20px solid rgb(var(--my-lighter-background-color));
191
+ input[type=range]:focus::-ms-fill-upper {
192
+ background: #367ebd;
156
193
  }
157
194
  `
158
195
  ];
159
196
  }
160
197
 
161
198
  render() {
162
- // TODO: step kann hier nicht übergeben werden, wird dann initial nicht immer richtig angezeigt (bei komma rundungen)???
163
- return html`
164
- <label for="${this.id}Input">${this.label} ${this.showLegend ? '' : html`- ${this.value}`}</label>
165
- <input ?disabled=${this.disabled} type="range" name="${this.id}Name" @change="${this._onChange}"
166
- .value="${this.value}" min="${this.min}" max="${this.max}"
167
- step="${this.step}" id="${this.id}Input">
168
- ${this.showLegend ? this._addLegend() : ''}
199
+ const inputId = `${this.id}Range`;
200
+ // TODO: step kann hier nicht übergeben werden, wird dann initial nicht immer richtig angezeigt (bei komma rundungen)???
201
+ return html`
202
+ ${this._renderLabel(inputId, this.optionValueMapper[this.value] || this.value)}
203
+ <div class="input-range ${classMap({ error: this.errorMsg.length > 0 })}">
204
+ <input
205
+ id="${inputId}"
206
+ name="${this.name || this.valueName}"
207
+ class="input-range-style ${this.gradient ? 'gradient' : ''}"
208
+ type="range"
209
+ .value="${this.value}"
210
+ ?readonly="${this.readonly}"
211
+ ?disabled="${this.disabled}"
212
+ min="0" max="${this.max}" step="1"
213
+ @change="${this._onChange}"
214
+ />
215
+ </div>
216
+ ${this._renderErrorMsg()}
169
217
  `;
170
218
  }
171
219
 
@@ -174,24 +222,8 @@ export class PdRange extends PdBaseUIInput {
174
222
  this._input = this.shadowRoot.querySelector('input');
175
223
  }
176
224
 
177
- _addLegend() {
178
- const steps = this.max - this.min;
179
- const labels = [];
180
- for (let i = 0; i <= steps; i+=1) {
181
- labels.push(html`<label class="${i + this.step === this.value * 1 ? 'range_legend_label--selected' : ''}">${i + this.step}</label>`);
182
- }
183
- return html`<div class="legend">${labels}</div>`
184
- }
185
-
186
- _onChange() {
187
- this.value = this._input.value;
188
- this.dispatchEvent(new CustomEvent('changed', {
189
- detail: {
190
- value: this._input.value
191
- },
192
- composed: true,
193
- bubbles: true
194
- }));
225
+ _onChange(e) {
226
+ this._handleChangedValue(this._input.value, e, false);
195
227
  }
196
228
 
197
229
  }
@@ -2,6 +2,7 @@ import { html } from 'lit';
2
2
  import '../pd-form-container.js';
3
3
  import '../pd-form-row.js';
4
4
  import '../pd-input.js';
5
+ import '../pd-range.js';
5
6
 
6
7
  export default {
7
8
  title: 'PdForms/Form Container',
@@ -9,6 +10,14 @@ export default {
9
10
  argTypes: {},
10
11
  };
11
12
 
13
+ const OPTIONS_GENRE = {
14
+ 0: "Keine Auswahl",
15
+ 1: "No-Go",
16
+ 2: "Wenig",
17
+ 3: "Mittel",
18
+ 4: "Viel",
19
+ };
20
+
12
21
  function Template() {
13
22
  return html`
14
23
  <h3>Mit Forms</h3>
@@ -55,7 +64,14 @@ function Template() {
55
64
  <pd-input-area class="quarter2-area" id="test17Id" label="Label Area" required></pd-input-area>
56
65
  <pd-input-area class="quarter2-area" id="test18Id" label="Label Area" required
57
66
  requiredMsg="Das ist eine richtig lange Fehlermeldung. Diese kann per Parameter für spezielle Felder wie die AGB Checkbox gesetzt werden."></pd-input-area>
58
- </pd-form-row>
67
+ </pd-form-row>
68
+ <pd-form-row>
69
+ <pd-range id="testRangeId"
70
+ label="Range Label"
71
+ max="12"
72
+ value="0" .optionValueMapper="${OPTIONS_GENRE}" required>
73
+ </pd-range>
74
+ </pd-form-row>
59
75
  </pd-form-container>
60
76
 
61
77
  <h2>Test Validation</h2>
@@ -1,5 +1,7 @@
1
1
  import { html } from 'lit';
2
2
  import '../pd-range.js';
3
+ import '../pd-form-container.js';
4
+ import '../pd-form-row.js';
3
5
 
4
6
  export default {
5
7
  title: 'PdForms/Range',
@@ -17,54 +19,41 @@ export default {
17
19
  },
18
20
  };
19
21
 
20
- function Template({
21
- primaryColor,
22
- secondaryColor,
23
- textColor,
24
- highlightColor,
25
- errorColor,
26
- errorBackgroundColor,
27
- borderRadius,
28
- displayFont,
29
- fontSize,
30
- }) {
31
- let style = '';
32
- if (primaryColor) {
33
- style += `--squi-primary-color:${primaryColor};`;
34
- }
35
- if (secondaryColor) {
36
- style += `--squi-secondary-color:${secondaryColor};`;
37
- }
38
- if (textColor) {
39
- style += `--squi-text-color:${textColor};`;
40
- }
41
- if (highlightColor) {
42
- style += `--squi-highlight-color:${highlightColor};`;
43
- }
44
- if (errorColor) {
45
- style += `--squi-error-color:${errorColor};`;
46
- }
47
- if (errorBackgroundColor) {
48
- style += `--squi-error-background-color:${errorBackgroundColor};`;
49
- }
50
- if (borderRadius) {
51
- style += `--squi-border-radius:${borderRadius};`;
52
- }
53
- if (displayFont) {
54
- style += `--squi-display-font:${displayFont};`;
55
- }
56
- if (fontSize) {
57
- style += `--squi-font-size:${fontSize};`;
58
- }
22
+ const OPTIONS_GENRE = {
23
+ 0: "Keine Auswahl",
24
+ 1: "No-Go",
25
+ 2: "Wenig",
26
+ 3: "Mittel",
27
+ 4: "Viel",
28
+ };
29
+
30
+
31
+ function Template() {
59
32
  return html`
60
33
  <h3>Default Input Range</h3>
61
- <pd-range id="testRangeId"
62
- style="${style}"
63
- label="Range auswählen"
64
- min="1" max="12" step="1"
65
- defaultValue="6"
66
- showLegend>
67
- </pd-range>
34
+ <pd-form-container id="testFormContainerId" requiredFieldInfo>
35
+ <pd-form-row>
36
+ <pd-range id="range5060Id"
37
+ class="quarter4"
38
+ label="50er/60er"
39
+ required
40
+ max="4"
41
+ value="0"
42
+ .optionValueMapper="${OPTIONS_GENRE}">
43
+ </pd-range>
44
+ </pd-form-row>
45
+ </pd-form-container>
46
+
47
+ <h2>Test Validation</h2>
48
+ <button
49
+ @click="${() => {
50
+ document.getElementById('testFormContainerId').dispatchEvent(
51
+ new CustomEvent("validate-form", {detail: {errorMap: new Map()}})
52
+ );
53
+ }}"
54
+ >
55
+ Test Validate
56
+ </button>
68
57
  `;
69
58
  }
70
59