@zywave/zui-slider 4.0.9-pre.1 → 4.0.10-pre.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.
- package/CHANGELOG.md +8 -0
- package/dist/custom-elements.json +54 -21
- package/dist/zui-slider.d.ts +18 -17
- package/dist/zui-slider.js +20 -19
- package/dist/zui-slider.js.map +1 -1
- package/docs/customelement-manifest-element.html +28 -0
- package/{demo/index.html → docs/demo.html} +0 -0
- package/package.json +5 -4
- package/src/zui-slider.ts +19 -18
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.0.9](https://gitlab.com/zywave/devkit/zui/zui/compare/@zywave/zui-slider@4.0.9-pre.2...@zywave/zui-slider@4.0.9) (2022-02-25)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @zywave/zui-slider
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [4.0.8](https://gitlab.com/zywave/devkit/zui/zui/compare/@zywave/zui-slider@4.0.8-pre.3...@zywave/zui-slider@4.0.8) (2022-01-26)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @zywave/zui-slider
|
|
@@ -8,8 +8,15 @@
|
|
|
8
8
|
"declarations": [
|
|
9
9
|
{
|
|
10
10
|
"kind": "class",
|
|
11
|
-
"description": "",
|
|
11
|
+
"description": "A range form control for choosing values along a slider.",
|
|
12
12
|
"name": "ZuiSlider",
|
|
13
|
+
"cssProperties": [
|
|
14
|
+
{
|
|
15
|
+
"description": "Point of contact to grab and slide to change value",
|
|
16
|
+
"name": "--zui-slider-thumb-size",
|
|
17
|
+
"default": "1.875rem (30px)"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
13
20
|
"members": [
|
|
14
21
|
{
|
|
15
22
|
"kind": "field",
|
|
@@ -41,13 +48,21 @@
|
|
|
41
48
|
{
|
|
42
49
|
"kind": "field",
|
|
43
50
|
"name": "value",
|
|
51
|
+
"type": {
|
|
52
|
+
"text": "string"
|
|
53
|
+
},
|
|
44
54
|
"description": "Represents the value of the input. Can be set to a default value, and will reflect the value provided by the user when interactive with the control",
|
|
55
|
+
"default": "'50'",
|
|
45
56
|
"attribute": "value"
|
|
46
57
|
},
|
|
47
58
|
{
|
|
48
59
|
"kind": "field",
|
|
49
60
|
"name": "valueAsNumber",
|
|
50
|
-
"
|
|
61
|
+
"type": {
|
|
62
|
+
"text": "number"
|
|
63
|
+
},
|
|
64
|
+
"description": "Returns the value of the element, interpreted as one of the following, in order: A number, NaN if conversion is impossible",
|
|
65
|
+
"default": "50"
|
|
51
66
|
},
|
|
52
67
|
{
|
|
53
68
|
"kind": "field",
|
|
@@ -56,18 +71,18 @@
|
|
|
56
71
|
"text": "number"
|
|
57
72
|
},
|
|
58
73
|
"default": "0",
|
|
59
|
-
"description": "Represents the
|
|
74
|
+
"description": "Represents the maximum permitted value",
|
|
60
75
|
"attribute": "min"
|
|
61
76
|
},
|
|
62
77
|
{
|
|
63
78
|
"kind": "field",
|
|
64
79
|
"name": "max",
|
|
65
|
-
"default": "100",
|
|
66
|
-
"description": "Represents the maximum permitted value",
|
|
67
|
-
"attribute": "max",
|
|
68
80
|
"type": {
|
|
69
81
|
"text": "number"
|
|
70
|
-
}
|
|
82
|
+
},
|
|
83
|
+
"default": "100",
|
|
84
|
+
"description": "Represents the maximum permitted value",
|
|
85
|
+
"attribute": "max"
|
|
71
86
|
},
|
|
72
87
|
{
|
|
73
88
|
"kind": "field",
|
|
@@ -91,7 +106,12 @@
|
|
|
91
106
|
},
|
|
92
107
|
{
|
|
93
108
|
"kind": "field",
|
|
94
|
-
"name": "progress"
|
|
109
|
+
"name": "progress",
|
|
110
|
+
"type": {
|
|
111
|
+
"text": "number"
|
|
112
|
+
},
|
|
113
|
+
"description": "Determines visual placement of the slider thumb along the line",
|
|
114
|
+
"default": "50"
|
|
95
115
|
},
|
|
96
116
|
{
|
|
97
117
|
"kind": "method",
|
|
@@ -145,10 +165,11 @@
|
|
|
145
165
|
},
|
|
146
166
|
{
|
|
147
167
|
"type": {
|
|
148
|
-
"text": "string"
|
|
168
|
+
"text": "string | null"
|
|
149
169
|
},
|
|
150
170
|
"description": "The name of this element that is associated with form submission",
|
|
151
171
|
"name": "name",
|
|
172
|
+
"default": "null",
|
|
152
173
|
"kind": "field"
|
|
153
174
|
},
|
|
154
175
|
{
|
|
@@ -157,6 +178,7 @@
|
|
|
157
178
|
},
|
|
158
179
|
"description": "Represents whether a user can make changes to this element; if true, the value of this element will be excluded from the form submission",
|
|
159
180
|
"name": "disabled",
|
|
181
|
+
"default": "false",
|
|
160
182
|
"kind": "field"
|
|
161
183
|
},
|
|
162
184
|
{
|
|
@@ -165,6 +187,7 @@
|
|
|
165
187
|
},
|
|
166
188
|
"description": "Represents whether a user can make changes to this element; the value of this element will still be included in the form submission",
|
|
167
189
|
"name": "readOnly",
|
|
190
|
+
"default": "false",
|
|
168
191
|
"kind": "field"
|
|
169
192
|
},
|
|
170
193
|
{
|
|
@@ -173,6 +196,7 @@
|
|
|
173
196
|
},
|
|
174
197
|
"description": "If true, this element will be focused when connected to the document",
|
|
175
198
|
"name": "autofocus",
|
|
199
|
+
"default": "false",
|
|
176
200
|
"kind": "field"
|
|
177
201
|
}
|
|
178
202
|
],
|
|
@@ -181,41 +205,50 @@
|
|
|
181
205
|
"name": "change",
|
|
182
206
|
"type": {
|
|
183
207
|
"text": "CustomEvent"
|
|
184
|
-
}
|
|
208
|
+
},
|
|
209
|
+
"description": "Fires when value changes, details contain `value`"
|
|
185
210
|
}
|
|
186
211
|
],
|
|
187
212
|
"attributes": [
|
|
188
213
|
{
|
|
189
214
|
"type": {
|
|
190
|
-
"text": "string"
|
|
215
|
+
"text": "string | null"
|
|
191
216
|
},
|
|
192
217
|
"description": "The name of this element that is associated with form submission",
|
|
193
|
-
"name": "name"
|
|
218
|
+
"name": "name",
|
|
219
|
+
"default": "null"
|
|
194
220
|
},
|
|
195
221
|
{
|
|
196
222
|
"type": {
|
|
197
223
|
"text": "boolean"
|
|
198
224
|
},
|
|
199
225
|
"description": "Represents whether a user can make changes to this element; if true, the value of this element will be excluded from the form submission",
|
|
200
|
-
"name": "disabled"
|
|
226
|
+
"name": "disabled",
|
|
227
|
+
"default": "false"
|
|
201
228
|
},
|
|
202
229
|
{
|
|
203
230
|
"type": {
|
|
204
231
|
"text": "boolean"
|
|
205
232
|
},
|
|
206
233
|
"description": "Represents whether a user can make changes to this element; the value of this element will still be included in the form submission",
|
|
207
|
-
"name": "readonly"
|
|
234
|
+
"name": "readonly",
|
|
235
|
+
"default": "false"
|
|
208
236
|
},
|
|
209
237
|
{
|
|
210
238
|
"type": {
|
|
211
239
|
"text": "boolean"
|
|
212
240
|
},
|
|
213
241
|
"description": "If true, this element will be focused when connected to the document",
|
|
214
|
-
"name": "autofocus"
|
|
242
|
+
"name": "autofocus",
|
|
243
|
+
"default": "false"
|
|
215
244
|
},
|
|
216
245
|
{
|
|
217
|
-
"
|
|
246
|
+
"type": {
|
|
247
|
+
"text": "string"
|
|
248
|
+
},
|
|
218
249
|
"description": "Represents the value of the input. Can be set to a default value, and will reflect the value provided by the user when interactive with the control",
|
|
250
|
+
"name": "value",
|
|
251
|
+
"default": "'50'",
|
|
219
252
|
"fieldName": "value"
|
|
220
253
|
},
|
|
221
254
|
{
|
|
@@ -224,16 +257,16 @@
|
|
|
224
257
|
"text": "number"
|
|
225
258
|
},
|
|
226
259
|
"default": "0",
|
|
227
|
-
"description": "Represents the
|
|
260
|
+
"description": "Represents the maximum permitted value",
|
|
228
261
|
"fieldName": "min"
|
|
229
262
|
},
|
|
230
263
|
{
|
|
231
264
|
"name": "max",
|
|
232
|
-
"
|
|
233
|
-
|
|
234
|
-
"resolveInitializer": {
|
|
235
|
-
"module": "src/zui-slider.ts"
|
|
265
|
+
"type": {
|
|
266
|
+
"text": "number"
|
|
236
267
|
},
|
|
268
|
+
"default": "100",
|
|
269
|
+
"description": "Represents the maximum permitted value",
|
|
237
270
|
"fieldName": "max"
|
|
238
271
|
},
|
|
239
272
|
{
|
package/dist/zui-slider.d.ts
CHANGED
|
@@ -1,35 +1,36 @@
|
|
|
1
1
|
import { ZuiFormAssociatedElement } from '@zywave/zui-base';
|
|
2
2
|
/**
|
|
3
|
+
* A range form control for choosing values along a slider.
|
|
3
4
|
* @element zui-slider
|
|
4
5
|
*
|
|
5
|
-
* @attr {string} name - The name of this element that is associated with form submission
|
|
6
|
-
* @attr {boolean} disabled - Represents whether a user can make changes to this element; if true, the value of this element will be excluded from the form submission
|
|
7
|
-
* @attr {boolean} readonly - Represents whether a user can make changes to this element; the value of this element will still be included in the form submission
|
|
8
|
-
* @attr {boolean} autofocus - If true, this element will be focused when connected to the document
|
|
6
|
+
* @attr {string | null} [name=null] - The name of this element that is associated with form submission
|
|
7
|
+
* @attr {boolean} [disabled=false] - Represents whether a user can make changes to this element; if true, the value of this element will be excluded from the form submission
|
|
8
|
+
* @attr {boolean} [readonly=false] - Represents whether a user can make changes to this element; the value of this element will still be included in the form submission
|
|
9
|
+
* @attr {boolean} [autofocus=false] - If true, this element will be focused when connected to the document
|
|
10
|
+
* @attr {number} [value=50] - Represents the value of the input. Can be set to a default value, and will reflect the value provided by the user when interactive with the control
|
|
9
11
|
*
|
|
10
|
-
* @prop {string} name - The name of this element that is associated with form submission
|
|
11
|
-
* @prop {boolean} disabled - Represents whether a user can make changes to this element; if true, the value of this element will be excluded from the form submission
|
|
12
|
-
* @prop {boolean} readOnly - Represents whether a user can make changes to this element; the value of this element will still be included in the form submission
|
|
13
|
-
* @prop {boolean} autofocus - If true, this element will be focused when connected to the document
|
|
12
|
+
* @prop {string | null} [name=null] - The name of this element that is associated with form submission
|
|
13
|
+
* @prop {boolean} [disabled=false] - Represents whether a user can make changes to this element; if true, the value of this element will be excluded from the form submission
|
|
14
|
+
* @prop {boolean} [readOnly=false] - Represents whether a user can make changes to this element; the value of this element will still be included in the form submission
|
|
15
|
+
* @prop {boolean} [autofocus=false] - If true, this element will be focused when connected to the document
|
|
16
|
+
* @prop {number} [valueAsNumber=50] - Returns the value of the element, interpreted as one of the following, in order: A number, NaN if conversion is impossible
|
|
17
|
+
* @prop {string} [value='50'] - Represents the value of the input. Can be set to a default value, and will reflect the value provided by the user when interactive with the control
|
|
18
|
+
* @prop {number} [progress=50] - Determines visual placement of the slider thumb along the line
|
|
19
|
+
*
|
|
20
|
+
* @cssprop [--zui-slider-thumb-size=1.875rem (30px)] - Point of contact to grab and slide to change value
|
|
21
|
+
*
|
|
22
|
+
* @event {CustomEvent} change - Fires when value changes, details contain `value`
|
|
14
23
|
*/
|
|
15
24
|
export declare class ZuiSlider extends ZuiFormAssociatedElement {
|
|
16
25
|
#private;
|
|
17
26
|
protected get _formControlSelector(): string;
|
|
18
27
|
protected get _formValue(): string;
|
|
19
28
|
protected formResetCallback(): void;
|
|
20
|
-
/**
|
|
21
|
-
* Represents the value of the input. Can be set to a default value, and will reflect the value provided by the user when interactive with the control
|
|
22
|
-
*/
|
|
23
29
|
get value(): string;
|
|
24
30
|
set value(val: string);
|
|
25
|
-
/**
|
|
26
|
-
* Returns the value of the element, interpreted as one of the following, in order:
|
|
27
|
-
A number
|
|
28
|
-
NaN if conversion is impossible
|
|
29
|
-
*/
|
|
30
31
|
get valueAsNumber(): number;
|
|
31
32
|
/**
|
|
32
|
-
* Represents the
|
|
33
|
+
* Represents the maximum permitted value
|
|
33
34
|
*/
|
|
34
35
|
min: number;
|
|
35
36
|
/**
|
package/dist/zui-slider.js
CHANGED
|
@@ -23,17 +23,26 @@ import { styleMap } from 'lit/directives/style-map.js';
|
|
|
23
23
|
import { style } from './zui-slider-css.js';
|
|
24
24
|
const DEFAULT_MAX = 100;
|
|
25
25
|
/**
|
|
26
|
+
* A range form control for choosing values along a slider.
|
|
26
27
|
* @element zui-slider
|
|
27
28
|
*
|
|
28
|
-
* @attr {string} name - The name of this element that is associated with form submission
|
|
29
|
-
* @attr {boolean} disabled - Represents whether a user can make changes to this element; if true, the value of this element will be excluded from the form submission
|
|
30
|
-
* @attr {boolean} readonly - Represents whether a user can make changes to this element; the value of this element will still be included in the form submission
|
|
31
|
-
* @attr {boolean} autofocus - If true, this element will be focused when connected to the document
|
|
29
|
+
* @attr {string | null} [name=null] - The name of this element that is associated with form submission
|
|
30
|
+
* @attr {boolean} [disabled=false] - Represents whether a user can make changes to this element; if true, the value of this element will be excluded from the form submission
|
|
31
|
+
* @attr {boolean} [readonly=false] - Represents whether a user can make changes to this element; the value of this element will still be included in the form submission
|
|
32
|
+
* @attr {boolean} [autofocus=false] - If true, this element will be focused when connected to the document
|
|
33
|
+
* @attr {number} [value=50] - Represents the value of the input. Can be set to a default value, and will reflect the value provided by the user when interactive with the control
|
|
32
34
|
*
|
|
33
|
-
* @prop {string} name - The name of this element that is associated with form submission
|
|
34
|
-
* @prop {boolean} disabled - Represents whether a user can make changes to this element; if true, the value of this element will be excluded from the form submission
|
|
35
|
-
* @prop {boolean} readOnly - Represents whether a user can make changes to this element; the value of this element will still be included in the form submission
|
|
36
|
-
* @prop {boolean} autofocus - If true, this element will be focused when connected to the document
|
|
35
|
+
* @prop {string | null} [name=null] - The name of this element that is associated with form submission
|
|
36
|
+
* @prop {boolean} [disabled=false] - Represents whether a user can make changes to this element; if true, the value of this element will be excluded from the form submission
|
|
37
|
+
* @prop {boolean} [readOnly=false] - Represents whether a user can make changes to this element; the value of this element will still be included in the form submission
|
|
38
|
+
* @prop {boolean} [autofocus=false] - If true, this element will be focused when connected to the document
|
|
39
|
+
* @prop {number} [valueAsNumber=50] - Returns the value of the element, interpreted as one of the following, in order: A number, NaN if conversion is impossible
|
|
40
|
+
* @prop {string} [value='50'] - Represents the value of the input. Can be set to a default value, and will reflect the value provided by the user when interactive with the control
|
|
41
|
+
* @prop {number} [progress=50] - Determines visual placement of the slider thumb along the line
|
|
42
|
+
*
|
|
43
|
+
* @cssprop [--zui-slider-thumb-size=1.875rem (30px)] - Point of contact to grab and slide to change value
|
|
44
|
+
*
|
|
45
|
+
* @event {CustomEvent} change - Fires when value changes, details contain `value`
|
|
37
46
|
*/
|
|
38
47
|
export class ZuiSlider extends ZuiFormAssociatedElement {
|
|
39
48
|
constructor() {
|
|
@@ -41,13 +50,13 @@ export class ZuiSlider extends ZuiFormAssociatedElement {
|
|
|
41
50
|
_ZuiSlider_defaultValue.set(this, `${DEFAULT_MAX / 2}`);
|
|
42
51
|
_ZuiSlider_value.set(this, `${DEFAULT_MAX / 2}`);
|
|
43
52
|
/**
|
|
44
|
-
* Represents the
|
|
53
|
+
* Represents the maximum permitted value
|
|
45
54
|
*/
|
|
46
55
|
this.min = 0;
|
|
47
56
|
/**
|
|
48
57
|
* Represents the maximum permitted value
|
|
49
58
|
*/
|
|
50
|
-
this.max =
|
|
59
|
+
this.max = 100;
|
|
51
60
|
/**
|
|
52
61
|
* Represents the stepping interval, used both for user interface and validation purposes
|
|
53
62
|
*/
|
|
@@ -66,9 +75,6 @@ export class ZuiSlider extends ZuiFormAssociatedElement {
|
|
|
66
75
|
formResetCallback() {
|
|
67
76
|
this.value = __classPrivateFieldGet(this, _ZuiSlider_defaultValue, "f");
|
|
68
77
|
}
|
|
69
|
-
/**
|
|
70
|
-
* Represents the value of the input. Can be set to a default value, and will reflect the value provided by the user when interactive with the control
|
|
71
|
-
*/
|
|
72
78
|
get value() {
|
|
73
79
|
return __classPrivateFieldGet(this, _ZuiSlider_value, "f");
|
|
74
80
|
}
|
|
@@ -79,11 +85,6 @@ export class ZuiSlider extends ZuiFormAssociatedElement {
|
|
|
79
85
|
this._setFormValue(__classPrivateFieldGet(this, _ZuiSlider_value, "f"));
|
|
80
86
|
this.requestUpdate('value', oldVal);
|
|
81
87
|
}
|
|
82
|
-
/**
|
|
83
|
-
* Returns the value of the element, interpreted as one of the following, in order:
|
|
84
|
-
A number
|
|
85
|
-
NaN if conversion is impossible
|
|
86
|
-
*/
|
|
87
88
|
get valueAsNumber() {
|
|
88
89
|
return parseFloat(__classPrivateFieldGet(this, _ZuiSlider_value, "f"));
|
|
89
90
|
}
|
|
@@ -169,7 +170,7 @@ __decorate([
|
|
|
169
170
|
property({ type: Number })
|
|
170
171
|
], ZuiSlider.prototype, "min", void 0);
|
|
171
172
|
__decorate([
|
|
172
|
-
property({ type: Number })
|
|
173
|
+
property({ type: Number, attribute: 'max' })
|
|
173
174
|
], ZuiSlider.prototype, "max", void 0);
|
|
174
175
|
__decorate([
|
|
175
176
|
property({ type: Number })
|
package/dist/zui-slider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zui-slider.js","sourceRoot":"","sources":["../src/zui-slider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,SAAU,SAAQ,wBAAwB;IAAvD;;QAaE,kCAAgB,GAAG,WAAW,GAAG,CAAC,EAAE,EAAC;QAErC,2BAAS,GAAG,WAAW,GAAG,CAAC,EAAE,EAAC;QA2B9B;;WAEG;QACyB,QAAG,GAAG,CAAC,CAAC;QAEpC;;WAEG;QACyB,QAAG,GAAG,WAAW,CAAC;QAE9C;;WAEG;QACyB,SAAI,GAAG,CAAC,CAAC;QAErC;;WAEG;QACgD,WAAM,GAAG,KAAK,CAAC;IAsFpE,CAAC;IAjJC,IAAc,oBAAoB;QAChC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,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CAAU;AAKc;IAAlD,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;yCAAgB;AAwFpE,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import { ZuiFormAssociatedElement } from '@zywave/zui-base';\nimport { html } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { style } from './zui-slider-css.js';\n\nconst DEFAULT_MAX = 100;\n\n/**\n * @element zui-slider\n *\n * @attr {string} name - The name of this element that is associated with form submission\n * @attr {boolean} disabled - Represents whether a user can make changes to this element; if true, the value of this element will be excluded from the form submission\n * @attr {boolean} readonly - Represents whether a user can make changes to this element; the value of this element will still be included in the form submission\n * @attr {boolean} autofocus - If true, this element will be focused when connected to the document\n *\n * @prop {string} name - The name of this element that is associated with form submission\n * @prop {boolean} disabled - Represents whether a user can make changes to this element; if true, the value of this element will be excluded from the form submission\n * @prop {boolean} readOnly - Represents whether a user can make changes to this element; the value of this element will still be included in the form submission\n * @prop {boolean} autofocus - If true, this element will be focused when connected to the document\n */\nexport class ZuiSlider extends ZuiFormAssociatedElement {\n protected get _formControlSelector() {\n return 'input';\n }\n\n protected get _formValue() {\n return this.value;\n }\n\n protected formResetCallback() {\n this.value = this.#defaultValue;\n }\n\n #defaultValue = `${DEFAULT_MAX / 2}`;\n\n #value = `${DEFAULT_MAX / 2}`;\n\n /**\n * Represents the value of the input. Can be set to a default value, and will reflect the value provided by the user when interactive with the control\n */\n @property()\n get value() {\n return this.#value;\n }\n\n set value(val) {\n const oldVal = this.#value;\n val = this._ensureValidValue(val);\n this.#value = val;\n this._setFormValue(this.#value);\n this.requestUpdate('value', oldVal);\n }\n\n /**\n * Returns the value of the element, interpreted as one of the following, in order:\n A number\n NaN if conversion is impossible\n */\n get valueAsNumber() {\n return parseFloat(this.#value);\n }\n\n /**\n * Represents the minimum permitted value\n */\n @property({ type: Number }) min = 0;\n\n /**\n * Represents the maximum permitted value\n */\n @property({ type: Number }) max = DEFAULT_MAX;\n\n /**\n * Represents the stepping interval, used both for user interface and validation purposes\n */\n @property({ type: Number }) step = 0;\n\n /**\n * Represents that this control must be filled in for form submission\n */\n @property({ type: Boolean, attribute: 'no-text' }) noText = false;\n\n get progress() {\n return ((this.valueAsNumber - this.min) / (this.max - this.min)) * 100;\n }\n\n static get styles() {\n return [super.styles, style];\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n // we want to go a little faster than LitElement and behave more like native HTML Form Associated Elements\n let value = this.getAttribute('value') ?? this.value;\n const max = this.getAttribute('max') ?? this.max;\n const min = this.getAttribute('min') ?? this.min;\n\n value = this._ensureValidValue(value, min, max);\n\n this.#defaultValue = value;\n this._setFormValue(value.toString());\n }\n\n render() {\n const progressColor = this.disabled ? 'var(--zui-gray)' : 'var(--zui-blue)';\n const styles = {\n background: `linear-gradient(to right, ${progressColor} 0%, ${progressColor} ${this.progress}%, var(--zui-gray-200) ${this.progress}%, var(--zui-gray-200) 100%)`,\n };\n return html`<input\n style=${styleMap(styles)}\n type=\"range\"\n .value=\"${this.value}\"\n .min=\"${this.min}\"\n .max=\"${this.max}\"\n .step=\"${this.step}\"\n ?disabled=\"${this.disabled}\"\n @input=\"${this._onInput}\"\n @change=\"${this._onChange}\"\n />${this._renderText()}`;\n }\n\n private _renderText() {\n if (this.noText) {\n return html``;\n }\n const thumbOffset = `var(--zui-slider-thumb-size) * ${this.progress / 100}`;\n const styles = {\n left: `calc(${this.progress}% - ${thumbOffset} + 0.125rem)`,\n };\n return html`<span style=${styleMap(styles)}>${this.value}</span>`;\n }\n\n private _onInput(e: Event) {\n this.value = (e.target as HTMLInputElement).value;\n }\n\n private _onChange() {\n this.dispatchEvent(new CustomEvent('change', { detail: this.value, bubbles: true }));\n }\n\n private _ensureValidValue(value: string | number, min?: number | string | null, max?: number | string | null) {\n if (value === '') {\n return value;\n }\n min = min ?? this.min;\n max = max ?? this.max;\n\n if (typeof value === 'string') {\n value = parseFloat(value);\n }\n if (typeof min === 'string') {\n min = parseFloat(min);\n }\n if (typeof max === 'string') {\n max = parseFloat(max);\n }\n\n if (value < min) {\n value = min;\n } else if (value > max) {\n value = max;\n }\n\n return value.toString();\n }\n}\n\nwindow.customElements.define('zui-slider', ZuiSlider);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'zui-slider': ZuiSlider;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"zui-slider.js","sourceRoot":"","sources":["../src/zui-slider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,SAAU,SAAQ,wBAAwB;IAAvD;;QAaE,kCAAgB,GAAG,WAAW,GAAG,CAAC,EAAE,EAAC;QAErC,2BAAS,GAAG,WAAW,GAAG,CAAC,EAAE,EAAC;QAmB9B;;WAEG;QACyB,QAAG,GAAG,CAAC,CAAC;QAEpC;;WAEG;QAC2C,QAAG,GAAG,GAAG,CAAC;QAExD;;WAEG;QACyB,SAAI,GAAG,CAAC,CAAC;QAErC;;WAEG;QACgD,WAAM,GAAG,KAAK,CAAC;IAsFpE,CAAC;IAzIC,IAAc,oBAAoB;QAChC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,IAAc,UAAU;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAES,iBAAiB;QACzB,IAAI,CAAC,KAAK,GAAG,uBAAA,IAAI,+BAAc,C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AC,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import { ZuiFormAssociatedElement } from '@zywave/zui-base';\nimport { html } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport { style } from './zui-slider-css.js';\n\nconst DEFAULT_MAX = 100;\n\n/**\n * A range form control for choosing values along a slider.\n * @element zui-slider\n *\n * @attr {string | null} [name=null] - The name of this element that is associated with form submission\n * @attr {boolean} [disabled=false] - Represents whether a user can make changes to this element; if true, the value of this element will be excluded from the form submission\n * @attr {boolean} [readonly=false] - Represents whether a user can make changes to this element; the value of this element will still be included in the form submission\n * @attr {boolean} [autofocus=false] - If true, this element will be focused when connected to the document\n * @attr {number} [value=50] - Represents the value of the input. Can be set to a default value, and will reflect the value provided by the user when interactive with the control\n *\n * @prop {string | null} [name=null] - The name of this element that is associated with form submission\n * @prop {boolean} [disabled=false] - Represents whether a user can make changes to this element; if true, the value of this element will be excluded from the form submission\n * @prop {boolean} [readOnly=false] - Represents whether a user can make changes to this element; the value of this element will still be included in the form submission\n * @prop {boolean} [autofocus=false] - If true, this element will be focused when connected to the document\n * @prop {number} [valueAsNumber=50] - Returns the value of the element, interpreted as one of the following, in order: A number, NaN if conversion is impossible\n * @prop {string} [value='50'] - Represents the value of the input. Can be set to a default value, and will reflect the value provided by the user when interactive with the control\n * @prop {number} [progress=50] - Determines visual placement of the slider thumb along the line\n *\n * @cssprop [--zui-slider-thumb-size=1.875rem (30px)] - Point of contact to grab and slide to change value\n *\n * @event {CustomEvent} change - Fires when value changes, details contain `value`\n */\nexport class ZuiSlider extends ZuiFormAssociatedElement {\n protected get _formControlSelector() {\n return 'input';\n }\n\n protected get _formValue() {\n return this.value;\n }\n\n protected formResetCallback() {\n this.value = this.#defaultValue;\n }\n\n #defaultValue = `${DEFAULT_MAX / 2}`;\n\n #value = `${DEFAULT_MAX / 2}`;\n\n @property()\n get value() {\n return this.#value;\n }\n\n set value(val) {\n const oldVal = this.#value;\n val = this._ensureValidValue(val);\n this.#value = val;\n this._setFormValue(this.#value);\n this.requestUpdate('value', oldVal);\n }\n\n get valueAsNumber() {\n return parseFloat(this.#value);\n }\n\n /**\n * Represents the maximum permitted value\n */\n @property({ type: Number }) min = 0;\n\n /**\n * Represents the maximum permitted value\n */\n @property({ type: Number, attribute: 'max' }) max = 100;\n\n /**\n * Represents the stepping interval, used both for user interface and validation purposes\n */\n @property({ type: Number }) step = 0;\n\n /**\n * Represents that this control must be filled in for form submission\n */\n @property({ type: Boolean, attribute: 'no-text' }) noText = false;\n\n get progress() {\n return ((this.valueAsNumber - this.min) / (this.max - this.min)) * 100;\n }\n\n static get styles() {\n return [super.styles, style];\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n // we want to go a little faster than LitElement and behave more like native HTML Form Associated Elements\n let value = this.getAttribute('value') ?? this.value;\n const max = this.getAttribute('max') ?? this.max;\n const min = this.getAttribute('min') ?? this.min;\n\n value = this._ensureValidValue(value, min, max);\n\n this.#defaultValue = value;\n this._setFormValue(value.toString());\n }\n\n render() {\n const progressColor = this.disabled ? 'var(--zui-gray)' : 'var(--zui-blue)';\n const styles = {\n background: `linear-gradient(to right, ${progressColor} 0%, ${progressColor} ${this.progress}%, var(--zui-gray-200) ${this.progress}%, var(--zui-gray-200) 100%)`,\n };\n return html`<input\n style=${styleMap(styles)}\n type=\"range\"\n .value=\"${this.value}\"\n .min=\"${this.min}\"\n .max=\"${this.max}\"\n .step=\"${this.step}\"\n ?disabled=\"${this.disabled}\"\n @input=\"${this._onInput}\"\n @change=\"${this._onChange}\"\n />${this._renderText()}`;\n }\n\n private _renderText() {\n if (this.noText) {\n return html``;\n }\n const thumbOffset = `var(--zui-slider-thumb-size) * ${this.progress / 100}`;\n const styles = {\n left: `calc(${this.progress}% - ${thumbOffset} + 0.125rem)`,\n };\n return html`<span style=${styleMap(styles)}>${this.value}</span>`;\n }\n\n private _onInput(e: Event) {\n this.value = (e.target as HTMLInputElement).value;\n }\n\n private _onChange() {\n this.dispatchEvent(new CustomEvent('change', { detail: this.value, bubbles: true }));\n }\n\n private _ensureValidValue(value: string | number, min?: number | string | null, max?: number | string | null) {\n if (value === '') {\n return value;\n }\n min = min ?? this.min;\n max = max ?? this.max;\n\n if (typeof value === 'string') {\n value = parseFloat(value);\n }\n if (typeof min === 'string') {\n min = parseFloat(min);\n }\n if (typeof max === 'string') {\n max = parseFloat(max);\n }\n\n if (value < min) {\n value = min;\n } else if (value > max) {\n value = max;\n }\n\n return value.toString();\n }\n}\n\nwindow.customElements.define('zui-slider', ZuiSlider);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'zui-slider': ZuiSlider;\n }\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
+
<meta name="description" content="ZUI Web Component Skeleton" />
|
|
8
|
+
<title>zui-slider CEM Demo</title>
|
|
9
|
+
<script src="https://cdn.zywave.com/@zywave/customelement-manifest-element@latest/index.bundle.js" type="module"></script>
|
|
10
|
+
<link rel="stylesheet" href="../../../../node_modules/@zywave/zui-base-styles/dist/zui-base-styles.css" />
|
|
11
|
+
<style>
|
|
12
|
+
body {
|
|
13
|
+
margin: 2rem;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@media (min-width: 56.25rem){
|
|
17
|
+
/* 900px */
|
|
18
|
+
body {
|
|
19
|
+
margin: 2rem auto;
|
|
20
|
+
width: 52%; /* approx width to CEM in Booster API tab */
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
</style>
|
|
24
|
+
</head>
|
|
25
|
+
<body>
|
|
26
|
+
<customelement-manifest-element src="../dist/custom-elements.json" initialelementname="zui-slider"></customelement-manifest-element>
|
|
27
|
+
</body>
|
|
28
|
+
</html>
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zywave/zui-slider",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.10-pre.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"build:clean": "node ../../../scripts/node/remove-build-files.mjs && yarn run build",
|
|
10
10
|
"build:scss": "node ../../../scripts/node/sass.mjs",
|
|
11
11
|
"build:ts": "tsc -p tsconfig.build.json",
|
|
12
|
-
"launch-server:
|
|
12
|
+
"launch-server:cem": "es-dev-server --root-dir ../../../ --app-index packages/components/zui-slider/docs/customelement-manifest-element.html --open --node-resolve --watch",
|
|
13
|
+
"launch-server:demo": "es-dev-server --root-dir ../../../ --app-index packages/components/zui-slider/docs/demo.html --open --node-resolve --watch",
|
|
13
14
|
"launch-server:lab": "es-dev-server --root-dir ../../../ --app-index packages/components/zui-slider/lab.html --open --node-resolve --watch",
|
|
14
15
|
"demo": "npm-run-all build --parallel watcher:start launch-server:demo",
|
|
15
16
|
"watch": "npm-run-all build --parallel watcher:start launch-server:lab",
|
|
@@ -20,8 +21,8 @@
|
|
|
20
21
|
"access": "public"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@zywave/zui-base": "^4.1.
|
|
24
|
+
"@zywave/zui-base": "^4.1.21-pre.0"
|
|
24
25
|
},
|
|
25
26
|
"customElements": "dist/custom-elements.json",
|
|
26
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "2f7b09102f2c162ca30aa9fbfa58f6f90328ae3f"
|
|
27
28
|
}
|
package/src/zui-slider.ts
CHANGED
|
@@ -7,17 +7,26 @@ import { style } from './zui-slider-css.js';
|
|
|
7
7
|
const DEFAULT_MAX = 100;
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
+
* A range form control for choosing values along a slider.
|
|
10
11
|
* @element zui-slider
|
|
11
12
|
*
|
|
12
|
-
* @attr {string} name - The name of this element that is associated with form submission
|
|
13
|
-
* @attr {boolean} disabled - Represents whether a user can make changes to this element; if true, the value of this element will be excluded from the form submission
|
|
14
|
-
* @attr {boolean} readonly - Represents whether a user can make changes to this element; the value of this element will still be included in the form submission
|
|
15
|
-
* @attr {boolean} autofocus - If true, this element will be focused when connected to the document
|
|
13
|
+
* @attr {string | null} [name=null] - The name of this element that is associated with form submission
|
|
14
|
+
* @attr {boolean} [disabled=false] - Represents whether a user can make changes to this element; if true, the value of this element will be excluded from the form submission
|
|
15
|
+
* @attr {boolean} [readonly=false] - Represents whether a user can make changes to this element; the value of this element will still be included in the form submission
|
|
16
|
+
* @attr {boolean} [autofocus=false] - If true, this element will be focused when connected to the document
|
|
17
|
+
* @attr {number} [value=50] - Represents the value of the input. Can be set to a default value, and will reflect the value provided by the user when interactive with the control
|
|
16
18
|
*
|
|
17
|
-
* @prop {string} name - The name of this element that is associated with form submission
|
|
18
|
-
* @prop {boolean} disabled - Represents whether a user can make changes to this element; if true, the value of this element will be excluded from the form submission
|
|
19
|
-
* @prop {boolean} readOnly - Represents whether a user can make changes to this element; the value of this element will still be included in the form submission
|
|
20
|
-
* @prop {boolean} autofocus - If true, this element will be focused when connected to the document
|
|
19
|
+
* @prop {string | null} [name=null] - The name of this element that is associated with form submission
|
|
20
|
+
* @prop {boolean} [disabled=false] - Represents whether a user can make changes to this element; if true, the value of this element will be excluded from the form submission
|
|
21
|
+
* @prop {boolean} [readOnly=false] - Represents whether a user can make changes to this element; the value of this element will still be included in the form submission
|
|
22
|
+
* @prop {boolean} [autofocus=false] - If true, this element will be focused when connected to the document
|
|
23
|
+
* @prop {number} [valueAsNumber=50] - Returns the value of the element, interpreted as one of the following, in order: A number, NaN if conversion is impossible
|
|
24
|
+
* @prop {string} [value='50'] - Represents the value of the input. Can be set to a default value, and will reflect the value provided by the user when interactive with the control
|
|
25
|
+
* @prop {number} [progress=50] - Determines visual placement of the slider thumb along the line
|
|
26
|
+
*
|
|
27
|
+
* @cssprop [--zui-slider-thumb-size=1.875rem (30px)] - Point of contact to grab and slide to change value
|
|
28
|
+
*
|
|
29
|
+
* @event {CustomEvent} change - Fires when value changes, details contain `value`
|
|
21
30
|
*/
|
|
22
31
|
export class ZuiSlider extends ZuiFormAssociatedElement {
|
|
23
32
|
protected get _formControlSelector() {
|
|
@@ -36,9 +45,6 @@ export class ZuiSlider extends ZuiFormAssociatedElement {
|
|
|
36
45
|
|
|
37
46
|
#value = `${DEFAULT_MAX / 2}`;
|
|
38
47
|
|
|
39
|
-
/**
|
|
40
|
-
* Represents the value of the input. Can be set to a default value, and will reflect the value provided by the user when interactive with the control
|
|
41
|
-
*/
|
|
42
48
|
@property()
|
|
43
49
|
get value() {
|
|
44
50
|
return this.#value;
|
|
@@ -52,24 +58,19 @@ export class ZuiSlider extends ZuiFormAssociatedElement {
|
|
|
52
58
|
this.requestUpdate('value', oldVal);
|
|
53
59
|
}
|
|
54
60
|
|
|
55
|
-
/**
|
|
56
|
-
* Returns the value of the element, interpreted as one of the following, in order:
|
|
57
|
-
A number
|
|
58
|
-
NaN if conversion is impossible
|
|
59
|
-
*/
|
|
60
61
|
get valueAsNumber() {
|
|
61
62
|
return parseFloat(this.#value);
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
/**
|
|
65
|
-
* Represents the
|
|
66
|
+
* Represents the maximum permitted value
|
|
66
67
|
*/
|
|
67
68
|
@property({ type: Number }) min = 0;
|
|
68
69
|
|
|
69
70
|
/**
|
|
70
71
|
* Represents the maximum permitted value
|
|
71
72
|
*/
|
|
72
|
-
@property({ type: Number }) max =
|
|
73
|
+
@property({ type: Number, attribute: 'max' }) max = 100;
|
|
73
74
|
|
|
74
75
|
/**
|
|
75
76
|
* Represents the stepping interval, used both for user interface and validation purposes
|