@spectrum-web-components/picker 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.
Files changed (43) hide show
  1. package/README.md +355 -183
  2. package/package.json +17 -18
  3. package/src/picker.css.dev.js +1 -1
  4. package/src/picker.css.dev.js.map +1 -1
  5. package/src/picker.css.js +1 -1
  6. package/src/picker.css.js.map +1 -1
  7. package/src/spectrum-picker.css.dev.js +1 -1
  8. package/src/spectrum-picker.css.dev.js.map +1 -1
  9. package/src/spectrum-picker.css.js +1 -1
  10. package/src/spectrum-picker.css.js.map +1 -1
  11. package/LICENSE +0 -201
  12. package/stories/args.js +0 -56
  13. package/stories/args.js.map +0 -7
  14. package/stories/picker-pending.stories.js +0 -16
  15. package/stories/picker-pending.stories.js.map +0 -7
  16. package/stories/picker-sizes.stories.js +0 -75
  17. package/stories/picker-sizes.stories.js.map +0 -7
  18. package/stories/picker.stories.js +0 -755
  19. package/stories/picker.stories.js.map +0 -7
  20. package/stories/states.js +0 -228
  21. package/stories/states.js.map +0 -7
  22. package/stories/template.js +0 -32
  23. package/stories/template.js.map +0 -7
  24. package/test/benchmark/basic-test.js +0 -269
  25. package/test/benchmark/basic-test.js.map +0 -7
  26. package/test/index.js +0 -1745
  27. package/test/index.js.map +0 -7
  28. package/test/picker-memory.test.js +0 -5
  29. package/test/picker-memory.test.js.map +0 -7
  30. package/test/picker-pending.test-vrt.js +0 -5
  31. package/test/picker-pending.test-vrt.js.map +0 -7
  32. package/test/picker-reparenting.test.js +0 -101
  33. package/test/picker-reparenting.test.js.map +0 -7
  34. package/test/picker-responsive.test.js +0 -125
  35. package/test/picker-responsive.test.js.map +0 -7
  36. package/test/picker-sizes.test-vrt.js +0 -5
  37. package/test/picker-sizes.test-vrt.js.map +0 -7
  38. package/test/picker-sync.test.js +0 -7
  39. package/test/picker-sync.test.js.map +0 -7
  40. package/test/picker.test-vrt.js +0 -5
  41. package/test/picker.test-vrt.js.map +0 -7
  42. package/test/picker.test.js +0 -7
  43. package/test/picker.test.js.map +0 -7
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- ## Description
1
+ ## Overview
2
2
 
3
- An `<sp-picker>` is an alternative to HTML's `<select>` element. Use `<sp-menu-item>` elements to outline the options that will be made available to the user when interacting with the `<sp-picker>` element.
3
+ An `<sp-picker>` is an alternative to HTML's `<select>` element. Use [`<sp-menu-item>`](../menu-item) elements to outline the options that will be made available to the user when interacting with the `<sp-picker>` element.
4
4
 
5
5
  ### Usage
6
6
 
@@ -30,154 +30,68 @@ When looking to leverage the `Picker` base class as a type and/or for extension
30
30
  import { Picker } from '@spectrum-web-components/picker';
31
31
  ```
32
32
 
33
- ## Sizes
33
+ ### Anatomy
34
34
 
35
- <sp-tabs selected="m" auto label="Size Attribute Options">
36
- <sp-tab value="s">Small</sp-tab>
37
- <sp-tab-panel value="s">
35
+ #### Labels
38
36
 
39
- ```html demo
40
- <sp-field-group>
41
- <div>
42
- <sp-field-label for="picker-s" size="s">Selection type:</sp-field-label>
43
- <sp-picker id="picker-s" size="s" label="Selection type">
44
- <sp-menu-item>Deselect</sp-menu-item>
45
- <sp-menu-item>Select inverse</sp-menu-item>
46
- <sp-menu-item>Feather...</sp-menu-item>
47
- <sp-menu-item>Select and mask...</sp-menu-item>
48
- <sp-menu-divider></sp-menu-divider>
49
- <sp-menu-item>Save selection</sp-menu-item>
50
- <sp-menu-item disabled>Make work path</sp-menu-item>
51
- </sp-picker>
52
- </div>
53
- <div>
54
- <sp-field-label for="picker-s-quiet" size="s">
55
- Selection type:
56
- </sp-field-label>
57
- <sp-picker id="picker-s-quiet" quiet size="s" label="Selection type">
58
- <sp-menu-item>Deselect</sp-menu-item>
59
- <sp-menu-item>Select inverse</sp-menu-item>
60
- <sp-menu-item>Feather...</sp-menu-item>
61
- <sp-menu-item>Select and mask...</sp-menu-item>
62
- <sp-menu-divider></sp-menu-divider>
63
- <sp-menu-item>Save selection</sp-menu-item>
64
- <sp-menu-item disabled>Make work path</sp-menu-item>
65
- </sp-picker>
66
- </div>
67
- </sp-field-group>
68
- ```
37
+ To render accessibly, an `<sp-picker>` element should be paired with an `<sp-field-label>` element that has the `for` attribute referencing the `id` of the `<sp-picker>` element.
69
38
 
70
- </sp-tab-panel>
71
- <sp-tab value="m">Medium</sp-tab>
72
- <sp-tab-panel value="m">
39
+ For an accessible label that renders within the bounds of the picker itself, but still fulfills the accessibility contract, use the `label` attribute or a `<span slot="label">` as a child element of `<sp-picker>`.
40
+
41
+ <sp-tabs selected="sp-field-label" auto label="Label options">
42
+ <sp-tab value="sp-field-label">Uses &lt;sp-field-label&gt;</sp-tab>
43
+ <sp-tab-panel value="sp-field-label">
73
44
 
74
45
  ```html demo
75
- <sp-field-group>
76
- <div>
77
- <sp-field-label for="picker-m" size="m">Selection type:</sp-field-label>
78
- <sp-picker id="picker-m" size="m" label="Selection type">
79
- <sp-menu-item>Deselect</sp-menu-item>
80
- <sp-menu-item>Select inverse</sp-menu-item>
81
- <sp-menu-item>Feather...</sp-menu-item>
82
- <sp-menu-item>Select and mask...</sp-menu-item>
83
- <sp-menu-divider></sp-menu-divider>
84
- <sp-menu-item>Save selection</sp-menu-item>
85
- <sp-menu-item disabled>Make work path</sp-menu-item>
86
- </sp-picker>
87
- </div>
88
- <div>
89
- <sp-field-label for="picker-m-quiet" size="m">
90
- Selection type:
91
- </sp-field-label>
92
- <sp-picker id="picker-m-quiet" quiet size="m" label="Selection type">
93
- <sp-menu-item>Deselect</sp-menu-item>
94
- <sp-menu-item>Select inverse</sp-menu-item>
95
- <sp-menu-item>Feather...</sp-menu-item>
96
- <sp-menu-item>Select and mask...</sp-menu-item>
97
- <sp-menu-divider></sp-menu-divider>
98
- <sp-menu-item>Save selection</sp-menu-item>
99
- <sp-menu-item disabled>Make work path</sp-menu-item>
100
- </sp-picker>
101
- </div>
102
- </sp-field-group>
46
+ <sp-field-label for="uses-sp-field-label">Selection type:</sp-field-label>
47
+ <sp-picker id="uses-sp-field-label">
48
+ <sp-menu-item>Deselect</sp-menu-item>
49
+ <sp-menu-item>Select inverse</sp-menu-item>
50
+ <sp-menu-item>Feather...</sp-menu-item>
51
+ <sp-menu-item>Select and mask...</sp-menu-item>
52
+ <sp-menu-divider></sp-menu-divider>
53
+ <sp-menu-item>Save selection</sp-menu-item>
54
+ <sp-menu-item disabled>Make work path</sp-menu-item>
55
+ </sp-picker>
103
56
  ```
104
57
 
105
58
  </sp-tab-panel>
106
- <sp-tab value="l">Large</sp-tab>
107
- <sp-tab-panel value="l">
59
+ <sp-tab value="label-attribute">Uses label attribute</sp-tab>
60
+ <sp-tab-panel value="label-attribute">
108
61
 
109
62
  ```html demo
110
- <sp-field-group>
111
- <div>
112
- <sp-field-label for="picker-l" size="l">Selection type:</sp-field-label>
113
- <sp-picker id="picker-l" size="l" label="Selection type">
114
- <sp-menu-item>Deselect</sp-menu-item>
115
- <sp-menu-item>Select inverse</sp-menu-item>
116
- <sp-menu-item>Feather...</sp-menu-item>
117
- <sp-menu-item>Select and mask...</sp-menu-item>
118
- <sp-menu-divider></sp-menu-divider>
119
- <sp-menu-item>Save selection</sp-menu-item>
120
- <sp-menu-item disabled>Make work path</sp-menu-item>
121
- </sp-picker>
122
- </div>
123
- <div>
124
- <sp-field-label for="picker-l-quiet" size="l">
125
- Selection type:
126
- </sp-field-label>
127
- <sp-picker id="picker-l-quiet" quiet size="l" label="Selection type">
128
- <sp-menu-item>Deselect</sp-menu-item>
129
- <sp-menu-item>Select inverse</sp-menu-item>
130
- <sp-menu-item>Feather...</sp-menu-item>
131
- <sp-menu-item>Select and mask...</sp-menu-item>
132
- <sp-menu-divider></sp-menu-divider>
133
- <sp-menu-item>Save selection</sp-menu-item>
134
- <sp-menu-item disabled>Make work path</sp-menu-item>
135
- </sp-picker>
136
- </div>
137
- </sp-field-group>
63
+ <sp-picker label="Selection type" id="uses-label-attribute">
64
+ <sp-menu-item>Deselect</sp-menu-item>
65
+ <sp-menu-item>Select inverse</sp-menu-item>
66
+ <sp-menu-item>Feather...</sp-menu-item>
67
+ <sp-menu-item>Select and mask...</sp-menu-item>
68
+ <sp-menu-divider></sp-menu-divider>
69
+ <sp-menu-item>Save selection</sp-menu-item>
70
+ <sp-menu-item disabled>Make work path</sp-menu-item>
71
+ </sp-picker>
138
72
  ```
139
73
 
140
74
  </sp-tab-panel>
141
- <sp-tab value="xl">Extra Large</sp-tab>
142
- <sp-tab-panel value="xl">
75
+ <sp-tab value="label-slot">Uses label slot</sp-tab>
76
+ <sp-tab-panel value="label-slot">
143
77
 
144
78
  ```html demo
145
- <sp-field-group>
146
- <div>
147
- <sp-field-label for="picker-xl" size="xl">
148
- Selection type:
149
- </sp-field-label>
150
- <sp-picker id="picker-xl" size="xl" label="Selection type">
151
- <sp-menu-item>Deselect</sp-menu-item>
152
- <sp-menu-item>Select inverse</sp-menu-item>
153
- <sp-menu-item>Feather...</sp-menu-item>
154
- <sp-menu-item>Select and mask...</sp-menu-item>
155
- <sp-menu-divider></sp-menu-divider>
156
- <sp-menu-item>Save selection</sp-menu-item>
157
- <sp-menu-item disabled>Make work path</sp-menu-item>
158
- </sp-picker>
159
- </div>
160
- <div>
161
- <sp-field-label for="picker-xl-quiet" size="xl">
162
- Selection type:
163
- </sp-field-label>
164
- <sp-picker id="picker-xl-quiet" quiet size="xl" label="Selection type">
165
- <sp-menu-item>Deselect</sp-menu-item>
166
- <sp-menu-item>Select inverse</sp-menu-item>
167
- <sp-menu-item>Feather...</sp-menu-item>
168
- <sp-menu-item>Select and mask...</sp-menu-item>
169
- <sp-menu-divider></sp-menu-divider>
170
- <sp-menu-item>Save selection</sp-menu-item>
171
- <sp-menu-item disabled>Make work path</sp-menu-item>
172
- </sp-picker>
173
- </div>
174
- </sp-field-group>
79
+ <sp-picker id="uses-label-slot">
80
+ <span slot="label">Selection type:</span>
81
+ <sp-menu-item>Deselect</sp-menu-item>
82
+ <sp-menu-item>Select inverse</sp-menu-item>
83
+ <sp-menu-item>Feather...</sp-menu-item>
84
+ <sp-menu-item>Select and mask...</sp-menu-item>
85
+ <sp-menu-divider></sp-menu-divider>
86
+ <sp-menu-item>Save selection</sp-menu-item>
87
+ <sp-menu-item disabled>Make work path</sp-menu-item>
88
+ </sp-picker>
175
89
  ```
176
90
 
177
91
  </sp-tab-panel>
178
92
  </sp-tabs>
179
93
 
180
- ## Icons
94
+ #### Icons
181
95
 
182
96
  `<sp-menu-item>`s in an `<sp-picker>` that are provided content addressed to their `icon` slot will be passed to the `<sp-picker>` element when that item is chosen.
183
97
 
@@ -199,7 +113,7 @@ import { Picker } from '@spectrum-web-components/picker';
199
113
  </sp-picker>
200
114
  ```
201
115
 
202
- When you choose to leverage `<sp-menu-item>` elements without text content, you will need to be sure to leverage the `value` attribute so that the `<sp-picker>` element can differentiate between the available options. Further, it is important that you apply accessible labeling to the `[slot="icon"]` content as follows:
116
+ When using `<sp-menu-item>` elements without text content, be sure to use the `value` attribute so that the `<sp-picker>` element can differentiate between the available options. Furthermore, it is important to apply accessible labeling to the `[slot="icon"]` content as follows:
203
117
 
204
118
  ```html
205
119
  <sp-field-label for="picker-icons-only">Choose an action...</sp-field-label>
@@ -223,67 +137,78 @@ When you choose to leverage `<sp-menu-item>` elements without text content, you
223
137
  </sp-picker>
224
138
  ```
225
139
 
226
- ### Advanced icon management
140
+ ##### Advanced icon management
227
141
 
228
- The `icons` attribute allows you to manage whether to `only` display the icon in the `<sp-picker>` element or to display `none` of the icons in the `<sp-picker>`.
142
+ The `icons` attribute manages how the selected item will appear. Set `icons="only"` to display only the selected item's icon in the `<sp-picker>` element, or `icons="none"` to display the selected item text without the icon `<sp-picker>`.
229
143
 
230
- When using `icons="only"` and your `<sp-menu-item>` elements still have text content, that content will be applied to `<sp-picker>` element in a non-visible way.
144
+ When using `icons="only"` on `<sp-menu-item>` elements that have text content, that text will be applied to `<sp-picker>` element in a non-visible way.
231
145
 
232
- ```html
146
+ <sp-tabs selected="only" auto label="Icons Attribute Options">
147
+ <sp-tab value="only">Only</sp-tab>
148
+ <sp-tab-panel value="only">
149
+
150
+ ```html demo
233
151
  <sp-field-label for="picker-icons-value">Choose an action...</sp-field-label>
234
152
  <sp-picker
235
153
  label="What would you like to do?"
236
- value="item-2"
154
+ value="save"
237
155
  id="picker-icons-value"
238
156
  icons="only"
239
157
  >
240
- <sp-menu-item>
158
+ <sp-menu-item value="save">
241
159
  <sp-icon-save-floppy slot="icon"></sp-icon-save-floppy>
242
160
  Save
243
161
  </sp-menu-item>
244
- <sp-menu-item>
162
+ <sp-menu-item value="finish">
245
163
  <sp-icon-stopwatch slot="icon"></sp-icon-stopwatch>
246
164
  Finish
247
165
  </sp-menu-item>
248
- <sp-menu-item>
166
+ <sp-menu-item value="review">
249
167
  <sp-icon-user-activity slot="icon"></sp-icon-user-activity>
250
168
  Review
251
169
  </sp-menu-item>
252
170
  </sp-picker>
253
171
  ```
254
172
 
255
- When using `icons="none"`, the icons will only be available in the overlaid menu.
173
+ </sp-tab-panel>
174
+ <sp-tab value="none">None</sp-tab>
175
+ <sp-tab-panel value="none">
256
176
 
257
- ```html
177
+ ```html demo
258
178
  <sp-field-label for="picker-icons-none">Choose an action...</sp-field-label>
259
179
  <sp-picker
260
180
  label="What would you like to do?"
261
- value="item-2"
181
+ value="save"
262
182
  id="picker-icons-none"
263
183
  icons="none"
264
184
  >
265
- <sp-menu-item>
185
+ <sp-menu-item value="save">
266
186
  <sp-icon-save-floppy slot="icon"></sp-icon-save-floppy>
267
187
  Save
268
188
  </sp-menu-item>
269
- <sp-menu-item>
189
+ <sp-menu-item value="finish">
270
190
  <sp-icon-stopwatch slot="icon"></sp-icon-stopwatch>
271
191
  Finish
272
192
  </sp-menu-item>
273
- <sp-menu-item>
193
+ <sp-menu-item value="review">
274
194
  <sp-icon-user-activity slot="icon"></sp-icon-user-activity>
275
195
  Review
276
196
  </sp-menu-item>
277
197
  </sp-picker>
278
198
  ```
279
199
 
280
- ## Value
200
+ </sp-tab-panel>
201
+ </sp-tabs>
202
+
203
+ #### Value
281
204
 
282
- When the `value` of an `<sp-picker>` matches the `value` attribute or the trimmed `textContent` (or `itemText`) of a descendent `<sp-menu-item>` element, it will make that element as `selected`.
205
+ When the `value` of an `<sp-picker>` matches either the `value` attribute or the trimmed `textContent` (or `itemText`) of a descendent `<sp-menu-item>`, it will mark that element as `selected`.
283
206
 
284
- ### Matching `value`
207
+ <sp-tabs selected="matching-value" auto label="Selected">
208
+ <sp-tab value="matching-value">Matching value</sp-tab>
209
+ <sp-tab-panel value="matching-value">
285
210
 
286
- ```html
211
+ ```html demo
287
212
  <sp-field-label for="picker-value">Selection type:</sp-field-label>
288
213
  <sp-picker
289
214
  label="Select a Country with a very long label, too long in fact"
@@ -300,9 +225,11 @@ When the `value` of an `<sp-picker>` matches the `value` attribute or the trimme
300
225
  </sp-picker>
301
226
  ```
302
227
 
303
- ### Matching `itemText`
228
+ </sp-tab-panel>
229
+ <sp-tab value="matching-item-text">Matching itemText</sp-tab>
230
+ <sp-tab-panel value="matching-item-text">
304
231
 
305
- ```html
232
+ ```html demo
306
233
  <sp-field-label for="picker-item-text">Selection type:</sp-field-label>
307
234
  <sp-picker
308
235
  label="Select a Country with a very long label, too long in fact"
@@ -319,17 +246,20 @@ When the `value` of an `<sp-picker>` matches the `value` attribute or the trimme
319
246
  </sp-picker>
320
247
  ```
321
248
 
322
- ## States
249
+ </sp-tab-panel>
250
+ </sp-tabs>
323
251
 
324
- ### Invalid
252
+ ### Options
325
253
 
326
- ```html
327
- <sp-field-label for="picker-invalid">Standard:</sp-field-label>
328
- <sp-picker
329
- label="Select a Country with a very long label, too long in fact"
330
- invalid
331
- id="picker-invalid"
332
- >
254
+ #### Sizes
255
+
256
+ <sp-tabs selected="m" auto label="Size attribute options">
257
+ <sp-tab value="s">Small</sp-tab>
258
+ <sp-tab-panel value="s">
259
+
260
+ ```html demo
261
+ <sp-field-label for="picker-s" size="s">Selection type:</sp-field-label>
262
+ <sp-picker id="picker-s" size="s" label="Selection type">
333
263
  <sp-menu-item>Deselect</sp-menu-item>
334
264
  <sp-menu-item>Select inverse</sp-menu-item>
335
265
  <sp-menu-item>Feather...</sp-menu-item>
@@ -340,13 +270,65 @@ When the `value` of an `<sp-picker>` matches the `value` attribute or the trimme
340
270
  </sp-picker>
341
271
  <br />
342
272
  <br />
343
- <sp-field-label for="picker-invalid-quiet">Quiet:</sp-field-label>
344
- <sp-picker
345
- label="Select a Country with a very long label, too long in fact"
346
- invalid
347
- quiet
348
- id="picker-invalid-quiet"
349
- >
273
+ <sp-field-label for="picker-s-quiet" size="s">Selection type:</sp-field-label>
274
+ <sp-picker id="picker-s-quiet" quiet size="s" label="Selection type">
275
+ <sp-menu-item>Deselect</sp-menu-item>
276
+ <sp-menu-item>Select inverse</sp-menu-item>
277
+ <sp-menu-item>Feather...</sp-menu-item>
278
+ <sp-menu-item>Select and mask...</sp-menu-item>
279
+ <sp-menu-divider></sp-menu-divider>
280
+ <sp-menu-item>Save selection</sp-menu-item>
281
+ <sp-menu-item disabled>Make work path</sp-menu-item>
282
+ </sp-picker>
283
+ ```
284
+
285
+ </sp-tab-panel>
286
+ <sp-tab value="m">Medium</sp-tab>
287
+ <sp-tab-panel value="m">
288
+
289
+ ```html demo
290
+ <sp-field-label for="picker-m" size="m">Selection type:</sp-field-label>
291
+ <sp-picker id="picker-m" size="m" label="Selection type">
292
+ <sp-menu-item>Deselect</sp-menu-item>
293
+ <sp-menu-item>Select inverse</sp-menu-item>
294
+ <sp-menu-item>Feather...</sp-menu-item>
295
+ <sp-menu-item>Select and mask...</sp-menu-item>
296
+ <sp-menu-divider></sp-menu-divider>
297
+ <sp-menu-item>Save selection</sp-menu-item>
298
+ <sp-menu-item disabled>Make work path</sp-menu-item>
299
+ </sp-picker>
300
+ <br />
301
+ <br />
302
+ <sp-field-label for="picker-m-quiet" size="m">Selection type:</sp-field-label>
303
+ <sp-picker id="picker-m-quiet" quiet size="m" label="Selection type">
304
+ <sp-menu-item>Deselect</sp-menu-item>
305
+ <sp-menu-item>Select inverse</sp-menu-item>
306
+ <sp-menu-item>Feather...</sp-menu-item>
307
+ <sp-menu-item>Select and mask...</sp-menu-item>
308
+ <sp-menu-divider></sp-menu-divider>
309
+ <sp-menu-item>Save selection</sp-menu-item>
310
+ <sp-menu-item disabled>Make work path</sp-menu-item>
311
+ </sp-picker>
312
+ ```
313
+
314
+ </sp-tab-panel>
315
+ <sp-tab value="l">Large</sp-tab>
316
+ <sp-tab-panel value="l">
317
+
318
+ ```html demo
319
+ <sp-picker id="picker-l" size="l" label="Selection type">
320
+ <sp-menu-item>Deselect</sp-menu-item>
321
+ <sp-menu-item>Select inverse</sp-menu-item>
322
+ <sp-menu-item>Feather...</sp-menu-item>
323
+ <sp-menu-item>Select and mask...</sp-menu-item>
324
+ <sp-menu-divider></sp-menu-divider>
325
+ <sp-menu-item>Save selection</sp-menu-item>
326
+ <sp-menu-item disabled>Make work path</sp-menu-item>
327
+ </sp-picker>
328
+ <br />
329
+ <br />
330
+ <sp-field-label for="picker-l-quiet" size="l">Selection type:</sp-field-label>
331
+ <sp-picker id="picker-l-quiet" quiet size="l" label="Selection type">
350
332
  <sp-menu-item>Deselect</sp-menu-item>
351
333
  <sp-menu-item>Select inverse</sp-menu-item>
352
334
  <sp-menu-item>Feather...</sp-menu-item>
@@ -357,7 +339,43 @@ When the `value` of an `<sp-picker>` matches the `value` attribute or the trimme
357
339
  </sp-picker>
358
340
  ```
359
341
 
360
- ### Side Label
342
+ </sp-tab-panel>
343
+ <sp-tab value="xl">Extra Large</sp-tab>
344
+ <sp-tab-panel value="xl">
345
+
346
+ ```html demo
347
+ <sp-field-label for="picker-xl" size="xl">Selection type:</sp-field-label>
348
+ <sp-picker id="picker-xl" size="xl" label="Selection type">
349
+ <sp-menu-item>Deselect</sp-menu-item>
350
+ <sp-menu-item>Select inverse</sp-menu-item>
351
+ <sp-menu-item>Feather...</sp-menu-item>
352
+ <sp-menu-item>Select and mask...</sp-menu-item>
353
+ <sp-menu-divider></sp-menu-divider>
354
+ <sp-menu-item>Save selection</sp-menu-item>
355
+ <sp-menu-item disabled>Make work path</sp-menu-item>
356
+ </sp-picker>
357
+ <br />
358
+ <br />
359
+ <sp-field-label for="picker-xl-quiet" size="xl">Selection type:</sp-field-label>
360
+ <sp-picker id="picker-xl-quiet" quiet size="xl" label="Selection type">
361
+ <sp-menu-item>Deselect</sp-menu-item>
362
+ <sp-menu-item>Select inverse</sp-menu-item>
363
+ <sp-menu-item>Feather...</sp-menu-item>
364
+ <sp-menu-item>Select and mask...</sp-menu-item>
365
+ <sp-menu-divider></sp-menu-divider>
366
+ <sp-menu-item>Save selection</sp-menu-item>
367
+ <sp-menu-item disabled>Make work path</sp-menu-item>
368
+ </sp-picker>
369
+ ```
370
+
371
+ </sp-tab-panel>
372
+ </sp-tabs>
373
+
374
+ #### Side Label
375
+
376
+ <sp-tabs selected="standard-side-label" auto label="Side-aligned option">
377
+ <sp-tab value="standard-side-label">Side label, standard</sp-tab>
378
+ <sp-tab-panel value="standard-side-label">
361
379
 
362
380
  ```html
363
381
  <sp-field-label side-aligned="start" for="picker-sideLabel">
@@ -375,8 +393,13 @@ When the `value` of an `<sp-picker>` matches the `value` attribute or the trimme
375
393
  <sp-menu-item>Save selection</sp-menu-item>
376
394
  <sp-menu-item disabled>Make work path</sp-menu-item>
377
395
  </sp-picker>
378
- <br />
379
- <br />
396
+ ```
397
+
398
+ </sp-tab-panel>
399
+ <sp-tab value="quiet-side-label">Side label, quiet</sp-tab>
400
+ <sp-tab-panel value="quiet-side-label">
401
+
402
+ ```html demo
380
403
  <sp-field-label side-aligned="start" for="picker-sideLabel-quiet">
381
404
  Quiet:
382
405
  </sp-field-label>
@@ -395,9 +418,66 @@ When the `value` of an `<sp-picker>` matches the `value` attribute or the trimme
395
418
  </sp-picker>
396
419
  ```
397
420
 
398
- ### Disabled
421
+ </sp-tab-panel>
422
+ </sp-tabs>
423
+
424
+ ### States
399
425
 
400
- ```html
426
+ #### Invalid
427
+
428
+ <sp-tabs selected="standard-invalid" auto label="Invalid states">
429
+ <sp-tab value="standard-invalid">Invalid, standard</sp-tab>
430
+ <sp-tab-panel value="standard-invalid">
431
+
432
+ ```html demo
433
+ <sp-field-label for="picker-invalid">Standard:</sp-field-label>
434
+ <sp-picker
435
+ label="Select a Country with a very long label, too long in fact"
436
+ invalid
437
+ id="picker-invalid"
438
+ >
439
+ <sp-menu-item>Deselect</sp-menu-item>
440
+ <sp-menu-item>Select inverse</sp-menu-item>
441
+ <sp-menu-item>Feather...</sp-menu-item>
442
+ <sp-menu-item>Select and mask...</sp-menu-item>
443
+ <sp-menu-divider></sp-menu-divider>
444
+ <sp-menu-item>Save selection</sp-menu-item>
445
+ <sp-menu-item disabled>Make work path</sp-menu-item>
446
+ </sp-picker>
447
+ ```
448
+
449
+ </sp-tab-panel>
450
+ <sp-tab value="quiet-invalid">Invalid, quiet</sp-tab>
451
+ <sp-tab-panel value="quiet-invalid">
452
+
453
+ ```html demo
454
+ <sp-field-label for="picker-invalid-quiet">Quiet:</sp-field-label>
455
+ <sp-picker
456
+ label="Select a Country with a very long label, too long in fact"
457
+ invalid
458
+ quiet
459
+ id="picker-invalid-quiet"
460
+ >
461
+ <sp-menu-item>Deselect</sp-menu-item>
462
+ <sp-menu-item>Select inverse</sp-menu-item>
463
+ <sp-menu-item>Feather...</sp-menu-item>
464
+ <sp-menu-item>Select and mask...</sp-menu-item>
465
+ <sp-menu-divider></sp-menu-divider>
466
+ <sp-menu-item>Save selection</sp-menu-item>
467
+ <sp-menu-item disabled>Make work path</sp-menu-item>
468
+ </sp-picker>
469
+ ```
470
+
471
+ </sp-tab-panel>
472
+ </sp-tabs>
473
+
474
+ #### Disabled
475
+
476
+ <sp-tabs selected="standard-disabled" auto label="Disabled states">
477
+ <sp-tab value="standard-disabled">Disabled, standard</sp-tab>
478
+ <sp-tab-panel value="standard-disabled">
479
+
480
+ ```html demo
401
481
  <sp-field-label for="picker-disabled">Standard:</sp-field-label>
402
482
  <sp-picker
403
483
  label="Select a Country with a very long label, too long in fact"
@@ -412,8 +492,13 @@ When the `value` of an `<sp-picker>` matches the `value` attribute or the trimme
412
492
  <sp-menu-item>Save selection</sp-menu-item>
413
493
  <sp-menu-item disabled>Make work path</sp-menu-item>
414
494
  </sp-picker>
415
- <br />
416
- <br />
495
+ ```
496
+
497
+ </sp-tab-panel>
498
+ <sp-tab value="quiet-disabled">Disabled, quiet</sp-tab>
499
+ <sp-tab-panel value="quiet-disabled">
500
+
501
+ ```html demo
417
502
  <sp-field-label for="picker-disabled-quiet">Quiet:</sp-field-label>
418
503
  <sp-picker
419
504
  label="Select a Country with a very long label, too long in fact"
@@ -431,20 +516,37 @@ When the `value` of an `<sp-picker>` matches the `value` attribute or the trimme
431
516
  </sp-picker>
432
517
  ```
433
518
 
434
- ### Pending
519
+ </sp-tab-panel>
520
+ </sp-tabs>
435
521
 
436
- When in pending state, `<sp-picker>` elements will not respond to click events and will be delivered with a `<sp-progress-circle>` to visually outline that it is pending. It will not toggle open or display its `<sp-menu-item>` descendants until the attribute is removed.
522
+ #### Pending
437
523
 
438
- ```html
524
+ While in pending state, `<sp-picker>` elements will not respond to click events and will be delivered with `<sp-progress-circle>` to visually denote that it is pending. It will not toggle open or display its `<sp-menu-item>` descendants until the attribute is removed. Use the `pending-label` attribute to customize the pending text for assoistive technology, which is set to `Pending` by default.
525
+
526
+ <sp-tabs selected="standard-pending" auto label="Pending states">
527
+ <sp-tab value="standard-pending">Pending, standard</sp-tab>
528
+ <sp-tab-panel value="standard-pending">
529
+
530
+ ```html demo
439
531
  <sp-field-label for="picker-loading">Standard:</sp-field-label>
440
- <sp-picker id="picker-loading" label="Loading blending modes..." pending>
532
+ <sp-picker
533
+ id="picker-loading"
534
+ label="Loading blending modes..."
535
+ pending
536
+ pending-label="loading options"
537
+ >
441
538
  <sp-menu-item>Pass through</sp-menu-item>
442
539
  <sp-menu-item>Normal</sp-menu-item>
443
540
  <sp-menu-item>Multiply</sp-menu-item>
444
541
  <sp-menu-item>Screen</sp-menu-item>
445
542
  </sp-picker>
446
- <br />
447
- <br />
543
+ ```
544
+
545
+ </sp-tab-panel>
546
+ <sp-tab value="quiet-pending">Pending, quiet</sp-tab>
547
+ <sp-tab-panel value="quiet-pending">
548
+
549
+ ```html demo
448
550
  <sp-field-label for="picker-loading-quiet">Quiet:</sp-field-label>
449
551
  <sp-picker
450
552
  id="picker-loading-quiet"
@@ -459,7 +561,12 @@ When in pending state, `<sp-picker>` elements will not respond to click events a
459
561
  </sp-picker>
460
562
  ```
461
563
 
462
- ## Force Popover on Mobile Devices
564
+ </sp-tab-panel>
565
+ </sp-tabs>
566
+
567
+ ## Behaviors
568
+
569
+ #### Force Popover on Mobile Devices
463
570
 
464
571
  On mobile, the menu can be exposed in either a `sp-popover` or `sp-tray`. By default, `sp-picker` will render an `sp-tray`. If you would like to render `sp-popover` on mobile, add the attribute `forcePopover` to the `sp-picker`.
465
572
 
@@ -488,6 +595,71 @@ To see this functionality in action, load this page from your mobile device or u
488
595
  </sp-picker>
489
596
  ```
490
597
 
491
- ## Accessibility
598
+ </sp-tab-panel>
599
+ </sp-tabs>
600
+
601
+ ### Accessibility
602
+
603
+ #### Include a visible label
604
+
605
+ Every picker should have a label. A picker without a label is ambiguous and not accessible.
606
+
607
+ #### Use help text to show context
608
+
609
+ A picker’s description in the help text can communicate what to select or how to select an option. This includes information such as:
610
+
611
+ - An overall description of the picker options
612
+ - Hints for what kind of information to choose
613
+ - More context for why a user needs to make a selection
614
+
615
+ The help text’s message should not simply restate the same information in the label in order to prompt someone to interact with a picker. Don’t add help text to maintain layout continuity with other inputs that require help text if it isn’t actually relevant or meaningful to a user.
616
+
617
+ The help text area also displays an error message. When a picker already includes help text and an error is triggered, the help text is replaced with error text. Once the error is resolved, the help text description reappears below the picker.
618
+
619
+ Since one gets replaced by the other, the language of the help text and error text need to work together to convey the same messaging. Help text explains the requirement or adds supplementary context for how to complete the interaction. Error text tells a user how to fix the error by re-stating the selection requirements or describing the necessary interaction. Make sure that the help text and the error text include the same essential information so that it isn’t lost if one replaces the other (e.g., minimum requirements).
620
+
621
+ Use [`<sp-help-text>`](../help-text/) to add help text and error text:
622
+
623
+ <sp-tabs selected="help-text-demo" auto label="Using help text">
624
+ <sp-tab value="help-text-demo">Help text</sp-tab>
625
+ <sp-tab-panel value="help-text-demo">
492
626
 
493
- To render accessibly, an `<sp-picker>` element should be paired with an `<sp-field-label>` element that has a `for` attribute referencing the `id` of the `<sp-picker>` element. For an accessible label that renders within the bounds of the picker itself, but still fulfills the accessibility contract, use the `label` attribute or a `<span slot="label">` as a child element of `<sp-picker>`.
627
+ ```html demo
628
+ <sp-field-label for="text">Preferred contact method:</sp-field-label>
629
+ <sp-picker id="text" label="Select contact method" aria-describedby="help-text">
630
+ <sp-menu-item>Phone</sp-menu-item>
631
+ <sp-menu-item>Text</sp-menu-item>
632
+ <sp-menu-item>Email</sp-menu-item>
633
+ </sp-picker>
634
+ <sp-help-text id="help-text">
635
+ Choose the best way to contact you in case there's an issue with your
636
+ account.
637
+ </sp-help-text>
638
+ ```
639
+
640
+ </sp-tab-panel>
641
+ <sp-tab value="error-text-demo">Error text</sp-tab>
642
+ <sp-tab-panel value="error-text-demo">
643
+
644
+ ```html demo
645
+ <sp-field-label for="error-text" required invalid>
646
+ Preferred contact method:
647
+ </sp-field-label>
648
+ <sp-picker
649
+ id="error-text"
650
+ invalid
651
+ label="Select contact method"
652
+ required
653
+ aria-describedby="error-help-text"
654
+ >
655
+ <sp-menu-item>Phone</sp-menu-item>
656
+ <sp-menu-item>Text</sp-menu-item>
657
+ <sp-menu-item>Email</sp-menu-item>
658
+ </sp-picker>
659
+ <sp-help-text id="error-help-text" variant="negative">
660
+ Select a contact method.
661
+ </sp-help-text>
662
+ ```
663
+
664
+ </sp-tab-panel>
665
+ </sp-tabs>