@spectrum-web-components/slider 1.3.0-beta.6 → 1.3.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/README.md +253 -106
- package/package.json +8 -9
- package/LICENSE +0 -201
- package/stories/slider-sizes.stories.js +0 -36
- package/stories/slider-sizes.stories.js.map +0 -7
- package/stories/slider.stories.js +0 -1191
- package/stories/slider.stories.js.map +0 -7
- package/test/benchmark/test-basic.js +0 -15
- package/test/benchmark/test-basic.js.map +0 -7
- package/test/index.js +0 -286
- package/test/index.js.map +0 -7
- package/test/slider-editable-sync.test.js +0 -5
- package/test/slider-editable-sync.test.js.map +0 -7
- package/test/slider-editable.test.js +0 -5
- package/test/slider-editable.test.js.map +0 -7
- package/test/slider-handle-upgrade.test.js +0 -28
- package/test/slider-handle-upgrade.test.js.map +0 -7
- package/test/slider-memory.test.js +0 -8
- package/test/slider-memory.test.js.map +0 -7
- package/test/slider-sizes.test-vrt.js +0 -5
- package/test/slider-sizes.test-vrt.js.map +0 -7
- package/test/slider.test-vrt.js +0 -5
- package/test/slider.test-vrt.js.map +0 -7
- package/test/slider.test.js +0 -1557
- package/test/slider.test.js.map +0 -7
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
##
|
|
1
|
+
## Overview
|
|
2
2
|
|
|
3
3
|
`<sp-slider>` allows users to quickly select a value within a range. They should be used when the upper and lower bounds of the range are invariable.
|
|
4
4
|
|
|
@@ -30,7 +30,87 @@ When looking to leverage the `Slider` base class as a type and/or for extension
|
|
|
30
30
|
import { Slider } from '@spectrum-web-components/slider';
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
### Anatomy
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<sp-slider label="Slider Label"></sp-slider>
|
|
37
|
+
<sp-slider label="Slider Label - Disabled" disabled></sp-slider>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
#### Label visibility
|
|
41
|
+
|
|
42
|
+
By default, an `<sp-slider>` element has both a "text" label and a "value" label. The "value" label is output by the element itself based on its state, but the "text" label must be supplied by the consuming developer in order for the `<sp-slider>` to be delivered in an accessible manner.
|
|
43
|
+
|
|
44
|
+
Either or both of these can be suppressed visually as needed by your application UI, while still fulfilling their role in delivering a quality accessibility tree to the browser. This delivery is controlled by the `label-visibility` attribute (or `labelVisibility` property) which accepts `text`, `value`, or `none` as values.
|
|
45
|
+
|
|
46
|
+
Use `label-visibility="text"` to suppress the "value" label, use `label-visibility="value"` to suppress the "text" label, or use `label-visibility="none"` to suppress the "text" label. In each case outlined above the content for both labels will be made available to screen readers, so be sure to manage the content delivered to visitors in that context.
|
|
47
|
+
|
|
48
|
+
<sp-tabs selected="text" auto label="Label Visibility Attribute Options">
|
|
49
|
+
<sp-tab value="text">Text</sp-tab>
|
|
50
|
+
<sp-tab-panel value="text">
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<sp-slider
|
|
54
|
+
label="No visible value label"
|
|
55
|
+
label-visibility="text"
|
|
56
|
+
value="50"
|
|
57
|
+
></sp-slider>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
</sp-tab-panel>
|
|
61
|
+
<sp-tab value="value">Value</sp-tab>
|
|
62
|
+
<sp-tab-panel value="value">
|
|
63
|
+
|
|
64
|
+
```html
|
|
65
|
+
<sp-slider label="No visible text label" label-visibility="value"></sp-slider>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
</sp-tab-panel>
|
|
69
|
+
<sp-tab value="none">None</sp-tab>
|
|
70
|
+
<sp-tab-panel value="none">
|
|
71
|
+
|
|
72
|
+
```html
|
|
73
|
+
<sp-slider label="No visible labels" label-visibility="none"></sp-slider>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
</sp-tab-panel>
|
|
77
|
+
</sp-tabs>
|
|
78
|
+
|
|
79
|
+
#### Handle slot
|
|
80
|
+
|
|
81
|
+
The slider also optionally accepts two or more `<sp-slider-handle>` elements with `slot="handle"`:
|
|
82
|
+
|
|
83
|
+
```html
|
|
84
|
+
<sp-slider step="1" min="0" max="255">
|
|
85
|
+
Output Levels
|
|
86
|
+
<sp-slider-handle
|
|
87
|
+
slot="handle"
|
|
88
|
+
name="low"
|
|
89
|
+
label="Low"
|
|
90
|
+
value="5"
|
|
91
|
+
max="next"
|
|
92
|
+
></sp-slider-handle>
|
|
93
|
+
<sp-slider-handle
|
|
94
|
+
slot="handle"
|
|
95
|
+
name="mid"
|
|
96
|
+
label="Mid"
|
|
97
|
+
value="100"
|
|
98
|
+
min="previous"
|
|
99
|
+
max="next"
|
|
100
|
+
></sp-slider-handle>
|
|
101
|
+
<sp-slider-handle
|
|
102
|
+
slot="handle"
|
|
103
|
+
name="high"
|
|
104
|
+
label="High"
|
|
105
|
+
value="250"
|
|
106
|
+
min="previous"
|
|
107
|
+
></sp-slider-handle>
|
|
108
|
+
</sp-slider>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Options
|
|
112
|
+
|
|
113
|
+
#### Sizes
|
|
34
114
|
|
|
35
115
|
<sp-tabs selected="m" auto label="Size Attribute Options">
|
|
36
116
|
<sp-tab value="s">Small</sp-tab>
|
|
@@ -71,16 +151,66 @@ import { Slider } from '@spectrum-web-components/slider';
|
|
|
71
151
|
</sp-tab-panel>
|
|
72
152
|
</sp-tabs>
|
|
73
153
|
|
|
74
|
-
|
|
154
|
+
#### Editable
|
|
155
|
+
|
|
156
|
+
An `<sp-slider>` element can be paired with an `<sp-number-field>` element via the `editable` attribute. The `<sp-number-field>` will be passed all of the standard options from the `<sp-slider>` element (e.g. `min`, `max`, `formatOptions`, etc.) and will also accept the `hide-stepper` attribute in order to prevent the display of its stepper UI.
|
|
157
|
+
|
|
158
|
+
The `quiet` attribute applies Quiet styling to the number field when a slider is `editable`.
|
|
75
159
|
|
|
76
|
-
|
|
160
|
+
<sp-tabs selected="editable" auto label="Editable Attribute Options">
|
|
161
|
+
<sp-tab value="editable">Editable</sp-tab>
|
|
162
|
+
<sp-tab-panel value="editable">
|
|
77
163
|
|
|
78
164
|
```html
|
|
79
|
-
<sp-slider
|
|
80
|
-
|
|
165
|
+
<sp-slider
|
|
166
|
+
label="Hours of the day (editable)"
|
|
167
|
+
editable
|
|
168
|
+
max="24"
|
|
169
|
+
min="0"
|
|
170
|
+
value="7.25"
|
|
171
|
+
step="0.25"
|
|
172
|
+
style="--spectrum-slider-editable-number-field-width: 100px;"
|
|
173
|
+
format-options='{
|
|
174
|
+
"style": "unit",
|
|
175
|
+
"unit": "hour"
|
|
176
|
+
}'
|
|
177
|
+
></sp-slider>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
</sp-tab-panel>
|
|
181
|
+
<sp-tab value="hide-stepper">Editable, hide-stepper</sp-tab>
|
|
182
|
+
<sp-tab-panel value="hide-stepper">
|
|
183
|
+
|
|
184
|
+
```html
|
|
185
|
+
<sp-slider
|
|
186
|
+
label="Angle (editable)"
|
|
187
|
+
editable
|
|
188
|
+
hide-stepper
|
|
189
|
+
min="0"
|
|
190
|
+
max="360"
|
|
191
|
+
format-options='{
|
|
192
|
+
"style": "unit",
|
|
193
|
+
"unit": "degree",
|
|
194
|
+
"unitDisplay": "narrow"
|
|
195
|
+
}'
|
|
196
|
+
></sp-slider>
|
|
81
197
|
```
|
|
82
198
|
|
|
83
|
-
|
|
199
|
+
</sp-tab-panel>
|
|
200
|
+
<sp-tab value="quiet">Editable, quiet</sp-tab>
|
|
201
|
+
<sp-tab-panel value="quiet">
|
|
202
|
+
|
|
203
|
+
```html
|
|
204
|
+
<sp-slider quiet editable value="50"></sp-slider>
|
|
205
|
+
<sp-slider quiet editable hide-stepper value="50"></sp-slider>
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
</sp-tab-panel>
|
|
209
|
+
</sp-tabs>
|
|
210
|
+
|
|
211
|
+
#### Filled
|
|
212
|
+
|
|
213
|
+
Use `variant="filled"` to add a filled style to the slider from a starting point to the current value. By default the starting point is the `min` value.
|
|
84
214
|
|
|
85
215
|
```html
|
|
86
216
|
<sp-slider
|
|
@@ -102,9 +232,15 @@ import { Slider } from '@spectrum-web-components/slider';
|
|
|
102
232
|
></sp-slider>
|
|
103
233
|
```
|
|
104
234
|
|
|
105
|
-
|
|
235
|
+
##### fill-start
|
|
236
|
+
|
|
237
|
+
When both `fill-start` and `variant="filled"` are used in `<sp-slider>`, the `fill-start` property defines the starting point. If fill start does not have a number associated with it, the starting point will be the `value`.
|
|
238
|
+
|
|
239
|
+
Any number (including `0`) can be used as a fill-start value. If a [custom normalization](#advanced-normalization) function is provided, it will also normalize all fill-related params.
|
|
106
240
|
|
|
107
|
-
|
|
241
|
+
<sp-tabs selected="start" auto label="fill-start Attribute Options">
|
|
242
|
+
<sp-tab value="start">fill-start</sp-tab>
|
|
243
|
+
<sp-tab-panel value="start">
|
|
108
244
|
|
|
109
245
|
```html
|
|
110
246
|
<sp-slider
|
|
@@ -122,22 +258,20 @@ When both `fill-start` and `variant="filled"` are used in `<sp-slider>`, the `fi
|
|
|
122
258
|
fill-start
|
|
123
259
|
variant="filled"
|
|
124
260
|
min="0"
|
|
125
|
-
value=".
|
|
261
|
+
value=".8"
|
|
126
262
|
step="0.01"
|
|
127
263
|
disabled
|
|
128
264
|
></sp-slider>
|
|
129
265
|
```
|
|
130
266
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
#### Fill Start greater than value
|
|
267
|
+
</sp-tab-panel>
|
|
268
|
+
<sp-tab value="greater">fill-start > value</sp-tab>
|
|
269
|
+
<sp-tab-panel value="greater">
|
|
136
270
|
|
|
137
271
|
```html
|
|
138
272
|
<sp-slider
|
|
139
273
|
id="fill-start-slider"
|
|
140
|
-
label="
|
|
274
|
+
label="fill-start greater than value"
|
|
141
275
|
max="1"
|
|
142
276
|
min="0"
|
|
143
277
|
value=".3"
|
|
@@ -147,7 +281,9 @@ Any number (including `0`) can be used as a fill-start value. If a [custom norma
|
|
|
147
281
|
></sp-slider>
|
|
148
282
|
```
|
|
149
283
|
|
|
150
|
-
|
|
284
|
+
</sp-tab-panel>
|
|
285
|
+
<sp-tab value="less">fill-start < value</sp-tab>
|
|
286
|
+
<sp-tab-panel value="less">
|
|
151
287
|
|
|
152
288
|
```html
|
|
153
289
|
<sp-slider
|
|
@@ -162,11 +298,13 @@ Any number (including `0`) can be used as a fill-start value. If a [custom norma
|
|
|
162
298
|
></sp-slider>
|
|
163
299
|
```
|
|
164
300
|
|
|
165
|
-
|
|
301
|
+
</sp-tab-panel>
|
|
302
|
+
<sp-tab value="zero">fill-start="0" and negative min</sp-tab>
|
|
303
|
+
<sp-tab-panel value="zero">
|
|
166
304
|
|
|
167
305
|
```html
|
|
168
306
|
<sp-slider
|
|
169
|
-
label="
|
|
307
|
+
label="fill-start set to 0"
|
|
170
308
|
max="1"
|
|
171
309
|
min="-1"
|
|
172
310
|
value=".7"
|
|
@@ -176,7 +314,16 @@ Any number (including `0`) can be used as a fill-start value. If a [custom norma
|
|
|
176
314
|
></sp-slider>
|
|
177
315
|
```
|
|
178
316
|
|
|
179
|
-
|
|
317
|
+
</sp-tab-panel>
|
|
318
|
+
</sp-tabs>
|
|
319
|
+
|
|
320
|
+
#### Tick
|
|
321
|
+
|
|
322
|
+
With `variant="tick"`, ticks are applied at intervals defined with the `tick-step` attribute. The `tick-labels` attribute will apply labels to the ticks.
|
|
323
|
+
|
|
324
|
+
<sp-tabs selected="no-labels" auto label="Tick Variant Options">
|
|
325
|
+
<sp-tab value="no-labels">Tick with No Labels</sp-tab>
|
|
326
|
+
<sp-tab-panel value="no-labels">
|
|
180
327
|
|
|
181
328
|
```html
|
|
182
329
|
<sp-slider label="Slider Label" variant="tick" tick-step="5"></sp-slider>
|
|
@@ -188,7 +335,9 @@ Any number (including `0`) can be used as a fill-start value. If a [custom norma
|
|
|
188
335
|
></sp-slider>
|
|
189
336
|
```
|
|
190
337
|
|
|
191
|
-
|
|
338
|
+
</sp-tab-panel>
|
|
339
|
+
<sp-tab value="labels">Tick with Labels</sp-tab>
|
|
340
|
+
<sp-tab-panel value="labels">
|
|
192
341
|
|
|
193
342
|
```html
|
|
194
343
|
<sp-slider
|
|
@@ -206,84 +355,41 @@ Any number (including `0`) can be used as a fill-start value. If a [custom norma
|
|
|
206
355
|
></sp-slider>
|
|
207
356
|
```
|
|
208
357
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
```html
|
|
212
|
-
<sp-slider label="Slider Label" variant="ramp"></sp-slider>
|
|
213
|
-
<sp-slider label="Slider Label - Disabled" variant="ramp" disabled></sp-slider>
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### Editable
|
|
217
|
-
|
|
218
|
-
An `<sp-slider>` element can be paired with an `<sp-number-field>` element via the `editable` attribute. The `<sp-number-field>` will be passed all of the standard options from the `<sp-slider>` element (e.g. `min`, `max`, `formatOptions`, etc.) and will also accept the `hide-stepper` attribute in order to prevent the display of its stepper UI.
|
|
219
|
-
|
|
220
|
-
```html
|
|
221
|
-
<sp-slider
|
|
222
|
-
label="Angle (editable)"
|
|
223
|
-
editable
|
|
224
|
-
hide-stepper
|
|
225
|
-
min="0"
|
|
226
|
-
max="360"
|
|
227
|
-
format-options='{
|
|
228
|
-
"style": "unit",
|
|
229
|
-
"unit": "degree",
|
|
230
|
-
"unitDisplay": "narrow"
|
|
231
|
-
}'
|
|
232
|
-
></sp-slider>
|
|
233
|
-
<sp-slider
|
|
234
|
-
label="Hours of the day (editable)"
|
|
235
|
-
editable
|
|
236
|
-
max="24"
|
|
237
|
-
min="0"
|
|
238
|
-
value="7.25"
|
|
239
|
-
step="0.25"
|
|
240
|
-
style="--spectrum-slider-editable-number-field-width: 100px;"
|
|
241
|
-
format-options='{
|
|
242
|
-
"style": "unit",
|
|
243
|
-
"unit": "hour"
|
|
244
|
-
}'
|
|
245
|
-
></sp-slider>
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
#### Quiet
|
|
249
|
-
|
|
250
|
-
```html
|
|
251
|
-
<sp-slider quiet editable value="50"></sp-slider>
|
|
252
|
-
<sp-slider quiet disabled editable value="50"></sp-slider>
|
|
253
|
-
```
|
|
358
|
+
</sp-tab-panel>
|
|
359
|
+
</sp-tabs>
|
|
254
360
|
|
|
255
|
-
####
|
|
361
|
+
#### Ramp
|
|
256
362
|
|
|
257
|
-
|
|
363
|
+
With `variant="ramp"`, the slider with increases as it approaches the `max` position.
|
|
258
364
|
|
|
259
365
|
```html
|
|
260
|
-
<sp-slider
|
|
366
|
+
<sp-slider label="Slider Label" variant="ramp"></sp-slider>
|
|
367
|
+
<sp-slider label="Slider Label - Disabled" variant="ramp" disabled></sp-slider>
|
|
261
368
|
```
|
|
262
369
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
- If the slider value is different from the default value then the slider value will be reset to the default value and the modal will not be closed.
|
|
266
|
-
- If the slider value is equal to the default value then the modal will be closed.
|
|
267
|
-
|
|
268
|
-
#### Indeterminate
|
|
370
|
+
### Range
|
|
269
371
|
|
|
270
|
-
The
|
|
372
|
+
The `"range"` variant along with two handles to create a range slider. (See [slider handle](../slider-handle).)
|
|
271
373
|
|
|
272
374
|
```html
|
|
273
|
-
<sp-slider
|
|
274
|
-
|
|
375
|
+
<sp-slider variant="range" step="1" min="0" max="255">
|
|
376
|
+
Output Levels
|
|
377
|
+
<sp-slider-handle
|
|
378
|
+
slot="handle"
|
|
379
|
+
name="min"
|
|
380
|
+
label="Minimum"
|
|
381
|
+
value="5"
|
|
382
|
+
></sp-slider-handle>
|
|
383
|
+
<sp-slider-handle
|
|
384
|
+
slot="handle"
|
|
385
|
+
name="max"
|
|
386
|
+
label="Maximum"
|
|
387
|
+
value="250"
|
|
388
|
+
></sp-slider-handle>
|
|
389
|
+
</sp-slider>
|
|
275
390
|
```
|
|
276
391
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
By default, `sp-slider` assumes a linear scale between the `min` and `max` values.
|
|
280
|
-
For advanced applications, it is sometimes necessary to specify a custom
|
|
281
|
-
"normalization."
|
|
282
|
-
|
|
283
|
-
Normalization is the process of converting a slider to a value between 0 and 1 where
|
|
284
|
-
0 represents the minimum and 1 represents the maximum. See the <a href="../../storybook/index.html?path=/story/slider--three-handles-complex" target="_blank">"Three Handles Complex" example in the playground</a>.
|
|
285
|
-
|
|
286
|
-
## Labels and Formatting
|
|
392
|
+
#### Format options for labels
|
|
287
393
|
|
|
288
394
|
An `<sp-slider>` or `<sp-slider-handle>` element will process its numeric value with `new Intl.NumberFormat(this.resolvedLanguage, this.formatOptions).format(this.value)` in order to prepare it for visual delivery in the input. In order to customize this processing supply your own `Intl.NumberFormatOptions` via the `formatOptions` property, or `format-options` attribute as seen below.
|
|
289
395
|
|
|
@@ -308,7 +414,7 @@ for a multi-handle slider, you can format the combined value label for all
|
|
|
308
414
|
handles by passing a formatting function to the `getAriaValueText` property
|
|
309
415
|
on the parent `sp-slider`.
|
|
310
416
|
|
|
311
|
-
|
|
417
|
+
##### Units not included in `Intl.NumberFormatOptions`
|
|
312
418
|
|
|
313
419
|
While `Intl.NumberFormatOptions` does support a [wide range of units](https://tc39.es/proposal-unified-intl-numberformat/section6/locales-currencies-tz_proposed_out.html#sec-issanctionedsimpleunitidentifier), it is possible to encounter units (e.g. the graphics units of `pixel`, `pixels`, `points`, etc.) that are not supported therein. When this occurs, an `<sp-slider>` element will attempt to polyfill support for this unit. See the following example delivering `{ style: "unit", unit: "px" }` below:
|
|
314
420
|
|
|
@@ -327,37 +433,57 @@ While `Intl.NumberFormatOptions` does support a [wide range of units](https://tc
|
|
|
327
433
|
|
|
328
434
|
Note: the polyfilling done here is very simplistic and is triggered by supplying options that would otherwise cause the `Intl.NumberFormat()` call to throw an error. Once the unsupporting unit of `px` causes the construction of the object to throw, a backup formatter/parser pair will be created without the supplied unit data. When the `style` is set to `unit`, the `unit` value will be adopted as the _static_ unit display. This means that neither pluralization nor translation will be handled within the `<sp-number-field>` element itself. If pluralization or translation is important to the delivered interface, please be sure to handle passing those strings into to element via the `formatOptions` property reactively to the value of the element or locale of that page in question.
|
|
329
435
|
|
|
330
|
-
###
|
|
331
|
-
|
|
332
|
-
By default, an `<sp-slider>` element has both a "text" label and a "value" label. The "value" label is output by the element itself based on its state, but the "text" label must be supplied by the consuming developer in order for the `<sp-slider>` to be delivered in an accessible manner.
|
|
436
|
+
### Behavior
|
|
333
437
|
|
|
334
|
-
|
|
438
|
+
#### Default value
|
|
335
439
|
|
|
336
|
-
|
|
440
|
+
Slider will reset to its `default-value` when the user double clicks on the slider handle or if the user presses the `escape` key when the slider handle is focused.
|
|
337
441
|
|
|
338
442
|
```html
|
|
339
|
-
<sp-slider
|
|
340
|
-
label="No visible value label"
|
|
341
|
-
label-visibility="text"
|
|
342
|
-
value="50"
|
|
343
|
-
></sp-slider>
|
|
443
|
+
<sp-slider value="50" default-value="20"></sp-slider>
|
|
344
444
|
```
|
|
345
445
|
|
|
346
|
-
|
|
446
|
+
Note: If a slider with `default-value` attribute is contained in a modal and the slider handle is focused then the following interaction will occur on pressing the `escape` key:
|
|
447
|
+
|
|
448
|
+
- If the slider value is different from the default value then the slider value will be reset to the default value and the modal will not be closed.
|
|
449
|
+
- If the slider value is equal to the default value then the modal will be closed.
|
|
450
|
+
|
|
451
|
+
#### Advanced normalization
|
|
452
|
+
|
|
453
|
+
By default, `sp-slider` assumes a linear scale between the `min` and `max` values.
|
|
454
|
+
For advanced applications, it is sometimes necessary to specify a custom
|
|
455
|
+
"normalization."
|
|
456
|
+
|
|
457
|
+
Normalization is the process of converting a slider to a value between 0 and 1 where
|
|
458
|
+
0 represents the minimum and 1 represents the maximum. See the <a href="../../storybook/index.html?path=/story/slider--three-handles-complex" target="_blank">"Three Handles Complex" example in the playground</a>.
|
|
459
|
+
|
|
460
|
+
### States
|
|
461
|
+
|
|
462
|
+
#### Disabled
|
|
347
463
|
|
|
348
464
|
```html
|
|
349
|
-
<sp-slider
|
|
465
|
+
<sp-slider disabled value="50"></sp-slider>
|
|
466
|
+
<sp-slider disabled quiet value="50"></sp-slider>
|
|
467
|
+
<sp-slider disabled editable value="50"></sp-slider>
|
|
468
|
+
<sp-slider disabled variant="filled" value="50"></sp-slider>
|
|
469
|
+
<sp-slider disabled variant="ticks" value="50"></sp-slider>
|
|
470
|
+
<sp-slider disabled variant="ramp" value="50"></sp-slider>
|
|
350
471
|
```
|
|
351
472
|
|
|
352
|
-
|
|
473
|
+
#### Indeterminate
|
|
474
|
+
|
|
475
|
+
The indeterminate attribute will be passed to the internal `<sp-number-field>` element and alter its visual delivery until a change has been made to the `<sp-slider>` element at which point the `change` event that is dispatched can be understood as always removing the indeterminate attribute from the `<sp-slider>`.
|
|
353
476
|
|
|
354
477
|
```html
|
|
355
|
-
<sp-slider
|
|
478
|
+
<sp-slider indeterminate value="50"></sp-slider>
|
|
479
|
+
<sp-slider indeterminate quiet value="50"></sp-slider>
|
|
480
|
+
<sp-slider indeterminate editable value="50"></sp-slider>
|
|
481
|
+
<sp-slider indeterminate variant="filled" value="50"></sp-slider>
|
|
482
|
+
<sp-slider indeterminate variant="ticks" value="50"></sp-slider>
|
|
483
|
+
<sp-slider indeterminate variant="ramp" value="50"></sp-slider>
|
|
356
484
|
```
|
|
357
485
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
## Events
|
|
486
|
+
### Events
|
|
361
487
|
|
|
362
488
|
Like the `<input type="range">` element after which the `<sp-slider>` is fashioned, it will dispatch `input` events in a stream culminating with a `change` event (representing the final commit of the `value` to the element) once the user has finished interacting with the element. Both other these events can access the `value` of their dispatching target via `event.target.value`. In this way, a steaming listener pattern similar to the following can prove useful:
|
|
363
489
|
|
|
@@ -384,3 +510,24 @@ const startListener = ({ target }) => {
|
|
|
384
510
|
|
|
385
511
|
slider.addEventListener('input', startListener);
|
|
386
512
|
```
|
|
513
|
+
|
|
514
|
+
### Accessibility
|
|
515
|
+
|
|
516
|
+
#### Include labels
|
|
517
|
+
|
|
518
|
+
Every slider should have a label. A slider without a label is ambiguous and not accessible. Write the label in sentence case.
|
|
519
|
+
|
|
520
|
+
In rare cases where context is sufficient and a label doesn't require visibility, make sure to have the design reviewed and approved by an accessibility expert. Use [`label-visibility`](#label-visibility) to set which labels should remain visible, and non-visible labels will still be read by assistive technology.
|
|
521
|
+
|
|
522
|
+
#### Keyboard navigation
|
|
523
|
+
|
|
524
|
+
The <kbd>Tab</kbd> and <kbd>Shift+Tab</kbd> keys are used to navigate to and set focus on the slider control. The <kbd>Arrow Up (↑)</kbd> and <kbd>Arrow Down (↓)</kbd> keys are used to increment the slider value, respectively.
|
|
525
|
+
|
|
526
|
+
Because multiple sliders are often used on the same page, the number field in the `editable` slider is designed to not be keyboard focusable via <kbd>Tab</kbd> or <kbd>Shift+Tab</kbd> keys. (See [WAI ARIA APG's Keyboard Navigation Inside Components](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#keyboardnavigationinsidecomponents).) Since the slider itself can already be incremented via the arrow keys, a [roving tabindex controller](https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_roving_tabindex) cannot be used within the slider; therefore, the number field will not be keyboard navigable.
|
|
527
|
+
|
|
528
|
+
<!--
|
|
529
|
+
TODO when an option is created to focus on the number field via tab:
|
|
530
|
+
When a slider is `editable`, the <kbd>Arrow Left (←)</kbd> and <kbd>Arrow Right (→)</kbd> keys are used to move the cursor within the number input field. Since the slider itself can already be incremented via the arrow keys, the number field stepper buttons are not available via keyboard.
|
|
531
|
+
-->
|
|
532
|
+
|
|
533
|
+
Review the accessibility guidelines for the [slider handle](../slider-handle).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/slider",
|
|
3
|
-
"version": "1.3.0
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -76,12 +76,12 @@
|
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@internationalized/number": "^3.6.0",
|
|
78
78
|
"@lit-labs/observers": "^2.0.2",
|
|
79
|
-
"@spectrum-web-components/base": "
|
|
80
|
-
"@spectrum-web-components/field-label": "
|
|
81
|
-
"@spectrum-web-components/number-field": "
|
|
82
|
-
"@spectrum-web-components/reactive-controllers": "
|
|
83
|
-
"@spectrum-web-components/shared": "
|
|
84
|
-
"@spectrum-web-components/theme": "
|
|
79
|
+
"@spectrum-web-components/base": "1.3.0",
|
|
80
|
+
"@spectrum-web-components/field-label": "1.3.0",
|
|
81
|
+
"@spectrum-web-components/number-field": "1.3.0",
|
|
82
|
+
"@spectrum-web-components/reactive-controllers": "1.3.0",
|
|
83
|
+
"@spectrum-web-components/shared": "1.3.0",
|
|
84
|
+
"@spectrum-web-components/theme": "1.3.0"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@spectrum-css/slider": "6.0.1"
|
|
@@ -92,6 +92,5 @@
|
|
|
92
92
|
"./sp-*.js",
|
|
93
93
|
"./**/*.dev.js",
|
|
94
94
|
"./sync/sp-*.js"
|
|
95
|
-
]
|
|
96
|
-
"gitHead": "7a244ef2b2cad9f06962483af6fdff89828d9a83"
|
|
95
|
+
]
|
|
97
96
|
}
|