@spectrum-web-components/picker 0.41.1 → 0.42.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 +67 -1
- package/custom-elements.json +158 -0
- package/package.json +17 -15
- package/src/Picker.d.ts +12 -2
- package/src/Picker.dev.js +65 -23
- package/src/Picker.dev.js.map +2 -2
- package/src/Picker.js +33 -24
- package/src/Picker.js.map +3 -3
- package/src/picker.css.dev.js +1 -512
- package/src/picker.css.dev.js.map +2 -2
- package/src/picker.css.js +1 -512
- package/src/picker.css.js.map +2 -2
- package/src/spectrum-config.js +22 -0
- package/src/spectrum-picker.css.dev.js +1 -506
- package/src/spectrum-picker.css.dev.js.map +2 -2
- package/src/spectrum-picker.css.js +1 -506
- package/src/spectrum-picker.css.js.map +2 -2
- package/stories/args.js +2 -1
- package/stories/args.js.map +2 -2
- package/stories/picker-pending.stories.js +16 -0
- package/stories/picker-pending.stories.js.map +7 -0
- package/stories/picker-sizes.stories.js +28 -2
- package/stories/picker-sizes.stories.js.map +2 -2
- package/stories/picker.stories.js +186 -15
- package/stories/picker.stories.js.map +2 -2
- package/stories/template.js +7 -2
- package/stories/template.js.map +2 -2
- package/test/index.js +88 -8
- package/test/index.js.map +3 -3
- package/test/picker-pending.test-vrt.js +5 -0
- package/test/picker-pending.test-vrt.js.map +7 -0
package/README.md
CHANGED
|
@@ -357,6 +357,44 @@ When the `value` of an `<sp-picker>` matches the `value` attribute or the trimme
|
|
|
357
357
|
</sp-picker>
|
|
358
358
|
```
|
|
359
359
|
|
|
360
|
+
### Side Label
|
|
361
|
+
|
|
362
|
+
```html
|
|
363
|
+
<sp-field-label side-aligned="start" for="picker-sideLabel">
|
|
364
|
+
Standard:
|
|
365
|
+
</sp-field-label>
|
|
366
|
+
<sp-picker
|
|
367
|
+
label="Select a Country with a very long label, too long in fact"
|
|
368
|
+
id="picker-sideLabel"
|
|
369
|
+
>
|
|
370
|
+
<sp-menu-item>Deselect</sp-menu-item>
|
|
371
|
+
<sp-menu-item>Select inverse</sp-menu-item>
|
|
372
|
+
<sp-menu-item>Feather...</sp-menu-item>
|
|
373
|
+
<sp-menu-item>Select and mask...</sp-menu-item>
|
|
374
|
+
<sp-menu-divider></sp-menu-divider>
|
|
375
|
+
<sp-menu-item>Save selection</sp-menu-item>
|
|
376
|
+
<sp-menu-item disabled>Make work path</sp-menu-item>
|
|
377
|
+
</sp-picker>
|
|
378
|
+
<br />
|
|
379
|
+
<br />
|
|
380
|
+
<sp-field-label side-aligned="start" for="picker-sideLabel-quiet">
|
|
381
|
+
Quiet:
|
|
382
|
+
</sp-field-label>
|
|
383
|
+
<sp-picker
|
|
384
|
+
label="Select a Country with a very long label, too long in fact"
|
|
385
|
+
quiet
|
|
386
|
+
id="picker-sideLabel-quiet"
|
|
387
|
+
>
|
|
388
|
+
<sp-menu-item>Deselect</sp-menu-item>
|
|
389
|
+
<sp-menu-item>Select inverse</sp-menu-item>
|
|
390
|
+
<sp-menu-item>Feather...</sp-menu-item>
|
|
391
|
+
<sp-menu-item>Select and mask...</sp-menu-item>
|
|
392
|
+
<sp-menu-divider></sp-menu-divider>
|
|
393
|
+
<sp-menu-item>Save selection</sp-menu-item>
|
|
394
|
+
<sp-menu-item disabled>Make work path</sp-menu-item>
|
|
395
|
+
</sp-picker>
|
|
396
|
+
```
|
|
397
|
+
|
|
360
398
|
### Disabled
|
|
361
399
|
|
|
362
400
|
```html
|
|
@@ -376,7 +414,7 @@ When the `value` of an `<sp-picker>` matches the `value` attribute or the trimme
|
|
|
376
414
|
</sp-picker>
|
|
377
415
|
<br />
|
|
378
416
|
<br />
|
|
379
|
-
<sp-field-label for="picker-disabled">Quiet:</sp-field-label>
|
|
417
|
+
<sp-field-label for="picker-disabled-quiet">Quiet:</sp-field-label>
|
|
380
418
|
<sp-picker
|
|
381
419
|
label="Select a Country with a very long label, too long in fact"
|
|
382
420
|
disabled
|
|
@@ -393,6 +431,34 @@ When the `value` of an `<sp-picker>` matches the `value` attribute or the trimme
|
|
|
393
431
|
</sp-picker>
|
|
394
432
|
```
|
|
395
433
|
|
|
434
|
+
### Pending
|
|
435
|
+
|
|
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.
|
|
437
|
+
|
|
438
|
+
```html
|
|
439
|
+
<sp-field-label for="picker-loading">Standard:</sp-field-label>
|
|
440
|
+
<sp-picker id="picker-loading" label="Loading blending modes..." pending>
|
|
441
|
+
<sp-menu-item>Pass through</sp-menu-item>
|
|
442
|
+
<sp-menu-item>Normal</sp-menu-item>
|
|
443
|
+
<sp-menu-item>Multiply</sp-menu-item>
|
|
444
|
+
<sp-menu-item>Screen</sp-menu-item>
|
|
445
|
+
</sp-picker>
|
|
446
|
+
<br />
|
|
447
|
+
<br />
|
|
448
|
+
<sp-field-label for="picker-loading-quiet">Quiet:</sp-field-label>
|
|
449
|
+
<sp-picker
|
|
450
|
+
id="picker-loading-quiet"
|
|
451
|
+
label="Loading blending modes..."
|
|
452
|
+
pending
|
|
453
|
+
quiet
|
|
454
|
+
>
|
|
455
|
+
<sp-menu-item>Pass through</sp-menu-item>
|
|
456
|
+
<sp-menu-item>Normal</sp-menu-item>
|
|
457
|
+
<sp-menu-item>Multiply</sp-menu-item>
|
|
458
|
+
<sp-menu-item>Screen</sp-menu-item>
|
|
459
|
+
</sp-picker>
|
|
460
|
+
```
|
|
461
|
+
|
|
396
462
|
## Accessibility
|
|
397
463
|
|
|
398
464
|
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>`.
|
package/custom-elements.json
CHANGED
|
@@ -113,6 +113,29 @@
|
|
|
113
113
|
"attribute": "invalid",
|
|
114
114
|
"reflects": true
|
|
115
115
|
},
|
|
116
|
+
{
|
|
117
|
+
"kind": "field",
|
|
118
|
+
"name": "pending",
|
|
119
|
+
"type": {
|
|
120
|
+
"text": "boolean"
|
|
121
|
+
},
|
|
122
|
+
"privacy": "public",
|
|
123
|
+
"default": "false",
|
|
124
|
+
"description": "Whether the items are currently loading.",
|
|
125
|
+
"attribute": "pending",
|
|
126
|
+
"reflects": true
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"kind": "field",
|
|
130
|
+
"name": "pendingLabel",
|
|
131
|
+
"type": {
|
|
132
|
+
"text": "string"
|
|
133
|
+
},
|
|
134
|
+
"privacy": "public",
|
|
135
|
+
"default": "'Pending'",
|
|
136
|
+
"description": "Defines a string value that labels the Picker while it is in pending state.",
|
|
137
|
+
"attribute": "pending-label"
|
|
138
|
+
},
|
|
116
139
|
{
|
|
117
140
|
"kind": "field",
|
|
118
141
|
"name": "label",
|
|
@@ -153,6 +176,14 @@
|
|
|
153
176
|
"privacy": "public",
|
|
154
177
|
"default": "'single'"
|
|
155
178
|
},
|
|
179
|
+
{
|
|
180
|
+
"kind": "field",
|
|
181
|
+
"name": "labelAlignment",
|
|
182
|
+
"type": {
|
|
183
|
+
"text": "'inline' | undefined"
|
|
184
|
+
},
|
|
185
|
+
"privacy": "public"
|
|
186
|
+
},
|
|
156
187
|
{
|
|
157
188
|
"kind": "field",
|
|
158
189
|
"name": "menuItems",
|
|
@@ -534,6 +565,24 @@
|
|
|
534
565
|
}
|
|
535
566
|
]
|
|
536
567
|
},
|
|
568
|
+
{
|
|
569
|
+
"kind": "method",
|
|
570
|
+
"name": "handleBeforetoggle",
|
|
571
|
+
"privacy": "protected",
|
|
572
|
+
"return": {
|
|
573
|
+
"type": {
|
|
574
|
+
"text": "void"
|
|
575
|
+
}
|
|
576
|
+
},
|
|
577
|
+
"parameters": [
|
|
578
|
+
{
|
|
579
|
+
"name": "event",
|
|
580
|
+
"type": {
|
|
581
|
+
"text": "Event & {\n target: Overlay;\n newState: 'open' | 'closed';\n }"
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
]
|
|
585
|
+
},
|
|
537
586
|
{
|
|
538
587
|
"kind": "method",
|
|
539
588
|
"name": "renderLabelContent",
|
|
@@ -834,6 +883,24 @@
|
|
|
834
883
|
"default": "false",
|
|
835
884
|
"fieldName": "invalid"
|
|
836
885
|
},
|
|
886
|
+
{
|
|
887
|
+
"name": "pending",
|
|
888
|
+
"type": {
|
|
889
|
+
"text": "boolean"
|
|
890
|
+
},
|
|
891
|
+
"default": "false",
|
|
892
|
+
"description": "Whether the items are currently loading.",
|
|
893
|
+
"fieldName": "pending"
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
"name": "pending-label",
|
|
897
|
+
"type": {
|
|
898
|
+
"text": "string"
|
|
899
|
+
},
|
|
900
|
+
"default": "'Pending'",
|
|
901
|
+
"description": "Defines a string value that labels the Picker while it is in pending state.",
|
|
902
|
+
"fieldName": "pendingLabel"
|
|
903
|
+
},
|
|
837
904
|
{
|
|
838
905
|
"name": "label",
|
|
839
906
|
"type": {
|
|
@@ -1035,6 +1102,37 @@
|
|
|
1035
1102
|
"module": "src/Picker.js"
|
|
1036
1103
|
}
|
|
1037
1104
|
},
|
|
1105
|
+
{
|
|
1106
|
+
"kind": "field",
|
|
1107
|
+
"name": "pending",
|
|
1108
|
+
"type": {
|
|
1109
|
+
"text": "boolean"
|
|
1110
|
+
},
|
|
1111
|
+
"privacy": "public",
|
|
1112
|
+
"default": "false",
|
|
1113
|
+
"description": "Whether the items are currently loading.",
|
|
1114
|
+
"attribute": "pending",
|
|
1115
|
+
"reflects": true,
|
|
1116
|
+
"inheritedFrom": {
|
|
1117
|
+
"name": "PickerBase",
|
|
1118
|
+
"module": "src/Picker.js"
|
|
1119
|
+
}
|
|
1120
|
+
},
|
|
1121
|
+
{
|
|
1122
|
+
"kind": "field",
|
|
1123
|
+
"name": "pendingLabel",
|
|
1124
|
+
"type": {
|
|
1125
|
+
"text": "string"
|
|
1126
|
+
},
|
|
1127
|
+
"privacy": "public",
|
|
1128
|
+
"default": "'Pending'",
|
|
1129
|
+
"description": "Defines a string value that labels the Picker while it is in pending state.",
|
|
1130
|
+
"attribute": "pending-label",
|
|
1131
|
+
"inheritedFrom": {
|
|
1132
|
+
"name": "PickerBase",
|
|
1133
|
+
"module": "src/Picker.js"
|
|
1134
|
+
}
|
|
1135
|
+
},
|
|
1038
1136
|
{
|
|
1039
1137
|
"kind": "field",
|
|
1040
1138
|
"name": "label",
|
|
@@ -1091,6 +1189,18 @@
|
|
|
1091
1189
|
"module": "src/Picker.js"
|
|
1092
1190
|
}
|
|
1093
1191
|
},
|
|
1192
|
+
{
|
|
1193
|
+
"kind": "field",
|
|
1194
|
+
"name": "labelAlignment",
|
|
1195
|
+
"type": {
|
|
1196
|
+
"text": "'inline' | undefined"
|
|
1197
|
+
},
|
|
1198
|
+
"privacy": "public",
|
|
1199
|
+
"inheritedFrom": {
|
|
1200
|
+
"name": "PickerBase",
|
|
1201
|
+
"module": "src/Picker.js"
|
|
1202
|
+
}
|
|
1203
|
+
},
|
|
1094
1204
|
{
|
|
1095
1205
|
"kind": "field",
|
|
1096
1206
|
"name": "menuItems",
|
|
@@ -1578,6 +1688,28 @@
|
|
|
1578
1688
|
"module": "src/Picker.js"
|
|
1579
1689
|
}
|
|
1580
1690
|
},
|
|
1691
|
+
{
|
|
1692
|
+
"kind": "method",
|
|
1693
|
+
"name": "handleBeforetoggle",
|
|
1694
|
+
"privacy": "protected",
|
|
1695
|
+
"return": {
|
|
1696
|
+
"type": {
|
|
1697
|
+
"text": "void"
|
|
1698
|
+
}
|
|
1699
|
+
},
|
|
1700
|
+
"parameters": [
|
|
1701
|
+
{
|
|
1702
|
+
"name": "event",
|
|
1703
|
+
"type": {
|
|
1704
|
+
"text": "Event & {\n target: Overlay;\n newState: 'open' | 'closed';\n }"
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
],
|
|
1708
|
+
"inheritedFrom": {
|
|
1709
|
+
"name": "PickerBase",
|
|
1710
|
+
"module": "src/Picker.js"
|
|
1711
|
+
}
|
|
1712
|
+
},
|
|
1581
1713
|
{
|
|
1582
1714
|
"kind": "method",
|
|
1583
1715
|
"name": "renderLabelContent",
|
|
@@ -2009,6 +2141,32 @@
|
|
|
2009
2141
|
"module": "src/Picker.ts"
|
|
2010
2142
|
}
|
|
2011
2143
|
},
|
|
2144
|
+
{
|
|
2145
|
+
"name": "pending",
|
|
2146
|
+
"type": {
|
|
2147
|
+
"text": "boolean"
|
|
2148
|
+
},
|
|
2149
|
+
"default": "false",
|
|
2150
|
+
"description": "Whether the items are currently loading.",
|
|
2151
|
+
"fieldName": "pending",
|
|
2152
|
+
"inheritedFrom": {
|
|
2153
|
+
"name": "PickerBase",
|
|
2154
|
+
"module": "src/Picker.ts"
|
|
2155
|
+
}
|
|
2156
|
+
},
|
|
2157
|
+
{
|
|
2158
|
+
"name": "pending-label",
|
|
2159
|
+
"type": {
|
|
2160
|
+
"text": "string"
|
|
2161
|
+
},
|
|
2162
|
+
"default": "'Pending'",
|
|
2163
|
+
"description": "Defines a string value that labels the Picker while it is in pending state.",
|
|
2164
|
+
"fieldName": "pendingLabel",
|
|
2165
|
+
"inheritedFrom": {
|
|
2166
|
+
"name": "PickerBase",
|
|
2167
|
+
"module": "src/Picker.ts"
|
|
2168
|
+
}
|
|
2169
|
+
},
|
|
2012
2170
|
{
|
|
2013
2171
|
"name": "label",
|
|
2014
2172
|
"type": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/picker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -65,21 +65,23 @@
|
|
|
65
65
|
"lit-html"
|
|
66
66
|
],
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@spectrum-web-components/base": "^0.
|
|
69
|
-
"@spectrum-web-components/button": "^0.
|
|
70
|
-
"@spectrum-web-components/
|
|
71
|
-
"@spectrum-web-components/
|
|
72
|
-
"@spectrum-web-components/icons-
|
|
73
|
-
"@spectrum-web-components/
|
|
74
|
-
"@spectrum-web-components/
|
|
75
|
-
"@spectrum-web-components/
|
|
76
|
-
"@spectrum-web-components/
|
|
77
|
-
"@spectrum-web-components/
|
|
78
|
-
"@spectrum-web-components/
|
|
79
|
-
"@spectrum-web-components/
|
|
68
|
+
"@spectrum-web-components/base": "^0.42.0",
|
|
69
|
+
"@spectrum-web-components/button": "^0.42.0",
|
|
70
|
+
"@spectrum-web-components/field-label": "^0.42.0",
|
|
71
|
+
"@spectrum-web-components/icon": "^0.42.0",
|
|
72
|
+
"@spectrum-web-components/icons-ui": "^0.42.0",
|
|
73
|
+
"@spectrum-web-components/icons-workflow": "^0.42.0",
|
|
74
|
+
"@spectrum-web-components/menu": "^0.42.0",
|
|
75
|
+
"@spectrum-web-components/overlay": "^0.42.0",
|
|
76
|
+
"@spectrum-web-components/popover": "^0.42.0",
|
|
77
|
+
"@spectrum-web-components/progress-circle": "^0.42.0",
|
|
78
|
+
"@spectrum-web-components/reactive-controllers": "^0.42.0",
|
|
79
|
+
"@spectrum-web-components/shared": "^0.42.0",
|
|
80
|
+
"@spectrum-web-components/tooltip": "^0.42.0",
|
|
81
|
+
"@spectrum-web-components/tray": "^0.42.0"
|
|
80
82
|
},
|
|
81
83
|
"devDependencies": {
|
|
82
|
-
"@spectrum-css/picker": "^7.2.
|
|
84
|
+
"@spectrum-css/picker": "^7.2.6"
|
|
83
85
|
},
|
|
84
86
|
"types": "./src/index.d.ts",
|
|
85
87
|
"customElements": "custom-elements.json",
|
|
@@ -89,5 +91,5 @@
|
|
|
89
91
|
"./sync/index.js",
|
|
90
92
|
"./sync/sp-*.js"
|
|
91
93
|
],
|
|
92
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "9b3bd55ff8e8f9438817255976e77fd456b19d72"
|
|
93
95
|
}
|
package/src/Picker.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ import '@spectrum-web-components/menu/sp-menu.js';
|
|
|
8
8
|
import type { Menu, MenuItem, MenuItemChildren } from '@spectrum-web-components/menu';
|
|
9
9
|
import { Placement } from '@spectrum-web-components/overlay';
|
|
10
10
|
import { MatchMediaController } from '@spectrum-web-components/reactive-controllers/src/MatchMedia.js';
|
|
11
|
-
import
|
|
11
|
+
import { Overlay } from '@spectrum-web-components/overlay/src/Overlay.js';
|
|
12
|
+
import type { FieldLabel } from '@spectrum-web-components/field-label';
|
|
12
13
|
export declare const DESCRIPTION_ID = "option-picker";
|
|
13
14
|
declare const PickerBase_base: typeof Focusable & {
|
|
14
15
|
new (...args: any[]): import("@spectrum-web-components/base").SizedElementInterface;
|
|
@@ -23,10 +24,15 @@ export declare class PickerBase extends PickerBase_base {
|
|
|
23
24
|
focused: boolean;
|
|
24
25
|
icons?: 'only' | 'none';
|
|
25
26
|
invalid: boolean;
|
|
27
|
+
/** Whether the items are currently loading. */
|
|
28
|
+
pending: boolean;
|
|
29
|
+
/** Defines a string value that labels the Picker while it is in pending state. */
|
|
30
|
+
pendingLabel: string;
|
|
26
31
|
label?: string;
|
|
27
32
|
open: boolean;
|
|
28
33
|
readonly: boolean;
|
|
29
34
|
selects: undefined | 'single';
|
|
35
|
+
labelAlignment?: 'inline';
|
|
30
36
|
protected get menuItems(): MenuItem[];
|
|
31
37
|
protected optionsMenu: Menu;
|
|
32
38
|
protected overlayElement: Overlay;
|
|
@@ -67,9 +73,13 @@ export declare class PickerBase extends PickerBase_base {
|
|
|
67
73
|
protected handleTooltipSlotchange(event: Event & {
|
|
68
74
|
target: HTMLSlotElement;
|
|
69
75
|
}): void;
|
|
76
|
+
protected handleBeforetoggle(event: Event & {
|
|
77
|
+
target: Overlay;
|
|
78
|
+
newState: 'open' | 'closed';
|
|
79
|
+
}): void;
|
|
70
80
|
protected renderLabelContent(content: Node[]): TemplateResult | Node[];
|
|
71
81
|
protected get buttonContent(): TemplateResult[];
|
|
72
|
-
applyFocusElementLabel: (value
|
|
82
|
+
applyFocusElementLabel: (value: string, labelElement: FieldLabel) => void;
|
|
73
83
|
protected renderOverlay(menu: TemplateResult): TemplateResult;
|
|
74
84
|
protected get renderDescriptionSlot(): TemplateResult;
|
|
75
85
|
protected render(): TemplateResult;
|
package/src/Picker.dev.js
CHANGED
|
@@ -18,7 +18,8 @@ import {
|
|
|
18
18
|
import {
|
|
19
19
|
classMap,
|
|
20
20
|
ifDefined,
|
|
21
|
-
styleMap
|
|
21
|
+
styleMap,
|
|
22
|
+
when
|
|
22
23
|
} from "@spectrum-web-components/base/src/directives.js";
|
|
23
24
|
import {
|
|
24
25
|
property,
|
|
@@ -50,6 +51,8 @@ export class PickerBase extends SizedMixin(Focusable, { noDefaultSize: true }) {
|
|
|
50
51
|
this.disabled = false;
|
|
51
52
|
this.focused = false;
|
|
52
53
|
this.invalid = false;
|
|
54
|
+
this.pending = false;
|
|
55
|
+
this.pendingLabel = "Pending";
|
|
53
56
|
this.open = false;
|
|
54
57
|
this.readonly = false;
|
|
55
58
|
this.selects = "single";
|
|
@@ -69,8 +72,9 @@ export class PickerBase extends SizedMixin(Focusable, { noDefaultSize: true }) {
|
|
|
69
72
|
event.preventDefault();
|
|
70
73
|
this.toggle(true);
|
|
71
74
|
};
|
|
72
|
-
this.applyFocusElementLabel = (value) => {
|
|
75
|
+
this.applyFocusElementLabel = (value, labelElement) => {
|
|
73
76
|
this.appliedLabel = value;
|
|
77
|
+
this.labelAlignment = labelElement.sideAligned ? "inline" : void 0;
|
|
74
78
|
};
|
|
75
79
|
this.dependenciesLoaded = false;
|
|
76
80
|
this.dependenciesToLoad = {};
|
|
@@ -141,15 +145,21 @@ export class PickerBase extends SizedMixin(Focusable, { noDefaultSize: true }) {
|
|
|
141
145
|
}
|
|
142
146
|
this.pointerdownState = this.open;
|
|
143
147
|
this.preventNextToggle = "maybe";
|
|
148
|
+
let cleanupAction = 0;
|
|
144
149
|
const cleanup = () => {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
150
|
+
cancelAnimationFrame(cleanupAction);
|
|
151
|
+
cleanupAction = requestAnimationFrame(async () => {
|
|
152
|
+
document.removeEventListener("pointerup", cleanup);
|
|
153
|
+
document.removeEventListener("pointercancel", cleanup);
|
|
154
|
+
this.button.removeEventListener("click", cleanup);
|
|
155
|
+
requestAnimationFrame(() => {
|
|
156
|
+
this.preventNextToggle = "no";
|
|
157
|
+
});
|
|
149
158
|
});
|
|
150
159
|
};
|
|
151
160
|
document.addEventListener("pointerup", cleanup);
|
|
152
161
|
document.addEventListener("pointercancel", cleanup);
|
|
162
|
+
this.button.addEventListener("click", cleanup);
|
|
153
163
|
this.handleActivate();
|
|
154
164
|
}
|
|
155
165
|
handleButtonFocus(event) {
|
|
@@ -180,6 +190,7 @@ export class PickerBase extends SizedMixin(Focusable, { noDefaultSize: true }) {
|
|
|
180
190
|
this.button.focus();
|
|
181
191
|
}
|
|
182
192
|
handleChange(event) {
|
|
193
|
+
this.preventNextToggle = "no";
|
|
183
194
|
const target = event.target;
|
|
184
195
|
const [selected] = target.selectedItems;
|
|
185
196
|
event.stopPropagation();
|
|
@@ -232,7 +243,7 @@ export class PickerBase extends SizedMixin(Focusable, { noDefaultSize: true }) {
|
|
|
232
243
|
item.selected = value;
|
|
233
244
|
}
|
|
234
245
|
toggle(target) {
|
|
235
|
-
if (this.readonly) {
|
|
246
|
+
if (this.readonly || this.pending) {
|
|
236
247
|
return;
|
|
237
248
|
}
|
|
238
249
|
this.open = typeof target !== "undefined" ? target : !this.open;
|
|
@@ -264,6 +275,22 @@ export class PickerBase extends SizedMixin(Focusable, { noDefaultSize: true }) {
|
|
|
264
275
|
handleTooltipSlotchange(event) {
|
|
265
276
|
this.tooltipEl = event.target.assignedElements()[0];
|
|
266
277
|
}
|
|
278
|
+
handleBeforetoggle(event) {
|
|
279
|
+
if (event.composedPath()[0] !== event.target) {
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
if (event.newState === "closed") {
|
|
283
|
+
if (this.preventNextToggle === "no") {
|
|
284
|
+
this.open = false;
|
|
285
|
+
} else if (!this.pointerdownState) {
|
|
286
|
+
this.overlayElement.manuallyKeepOpen();
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
if (!this.open) {
|
|
290
|
+
this.optionsMenu.updateSelectedItemIndex();
|
|
291
|
+
this.optionsMenu.closeDescendentOverlays();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
267
294
|
renderLabelContent(content) {
|
|
268
295
|
if (this.value && this.selectedItem) {
|
|
269
296
|
return content;
|
|
@@ -312,11 +339,23 @@ export class PickerBase extends SizedMixin(Focusable, { noDefaultSize: true }) {
|
|
|
312
339
|
` : html`
|
|
313
340
|
<span hidden id="applied-label">${appliedLabel}</span>
|
|
314
341
|
`}
|
|
315
|
-
${this.invalid ? html`
|
|
342
|
+
${this.invalid && !this.pending ? html`
|
|
316
343
|
<sp-icon-alert
|
|
317
344
|
class="validation-icon"
|
|
318
345
|
></sp-icon-alert>
|
|
319
346
|
` : nothing}
|
|
347
|
+
${when(this.pending, () => {
|
|
348
|
+
import("@spectrum-web-components/progress-circle/sp-progress-circle.js");
|
|
349
|
+
return html`
|
|
350
|
+
<sp-progress-circle
|
|
351
|
+
id="loader"
|
|
352
|
+
size="s"
|
|
353
|
+
indeterminate
|
|
354
|
+
aria-valuetext=${this.pendingLabel}
|
|
355
|
+
class="progress-circle"
|
|
356
|
+
></sp-progress-circle>
|
|
357
|
+
`;
|
|
358
|
+
})}
|
|
320
359
|
<sp-icon-chevron100
|
|
321
360
|
class="picker ${chevronClass[this.size]}"
|
|
322
361
|
></sp-icon-chevron100>
|
|
@@ -342,18 +381,7 @@ export class PickerBase extends SizedMixin(Focusable, { noDefaultSize: true }) {
|
|
|
342
381
|
.type=${this.isMobile.matches ? "modal" : "auto"}
|
|
343
382
|
.receivesFocus=${"true"}
|
|
344
383
|
.willPreventClose=${this.preventNextToggle !== "no" && this.open && this.dependenciesLoaded}
|
|
345
|
-
@beforetoggle=${
|
|
346
|
-
if (event.composedPath()[0] !== event.target) {
|
|
347
|
-
return;
|
|
348
|
-
}
|
|
349
|
-
if (event.newState === "closed") {
|
|
350
|
-
this.open = false;
|
|
351
|
-
}
|
|
352
|
-
if (!this.open) {
|
|
353
|
-
this.optionsMenu.updateSelectedItemIndex();
|
|
354
|
-
this.optionsMenu.closeDescendentOverlays();
|
|
355
|
-
}
|
|
356
|
-
}}
|
|
384
|
+
@beforetoggle=${this.handleBeforetoggle}
|
|
357
385
|
>
|
|
358
386
|
${container}
|
|
359
387
|
</sp-overlay>
|
|
@@ -384,9 +412,11 @@ export class PickerBase extends SizedMixin(Focusable, { noDefaultSize: true }) {
|
|
|
384
412
|
aria-describedby="tooltip"
|
|
385
413
|
aria-expanded=${this.open ? "true" : "false"}
|
|
386
414
|
aria-haspopup="true"
|
|
387
|
-
aria-labelledby="icon label applied-label"
|
|
415
|
+
aria-labelledby="loader icon label applied-label"
|
|
388
416
|
id="button"
|
|
389
|
-
class
|
|
417
|
+
class=${ifDefined(
|
|
418
|
+
this.labelAlignment ? `label-${this.labelAlignment}` : void 0
|
|
419
|
+
)}
|
|
390
420
|
@blur=${this.handleButtonBlur}
|
|
391
421
|
@click=${this.handleActivate}
|
|
392
422
|
@pointerdown=${this.handleButtonPointerdown}
|
|
@@ -411,6 +441,9 @@ export class PickerBase extends SizedMixin(Focusable, { noDefaultSize: true }) {
|
|
|
411
441
|
if (changes.has("disabled") && this.disabled) {
|
|
412
442
|
this.open = false;
|
|
413
443
|
}
|
|
444
|
+
if (changes.has("pending") && this.pending) {
|
|
445
|
+
this.open = false;
|
|
446
|
+
}
|
|
414
447
|
if (changes.has("value")) {
|
|
415
448
|
this.shouldScheduleManageSelection();
|
|
416
449
|
}
|
|
@@ -620,6 +653,12 @@ __decorateClass([
|
|
|
620
653
|
__decorateClass([
|
|
621
654
|
property({ type: Boolean, reflect: true })
|
|
622
655
|
], PickerBase.prototype, "invalid", 2);
|
|
656
|
+
__decorateClass([
|
|
657
|
+
property({ type: Boolean, reflect: true })
|
|
658
|
+
], PickerBase.prototype, "pending", 2);
|
|
659
|
+
__decorateClass([
|
|
660
|
+
property({ type: String, attribute: "pending-label" })
|
|
661
|
+
], PickerBase.prototype, "pendingLabel", 2);
|
|
623
662
|
__decorateClass([
|
|
624
663
|
property()
|
|
625
664
|
], PickerBase.prototype, "label", 2);
|
|
@@ -629,6 +668,9 @@ __decorateClass([
|
|
|
629
668
|
__decorateClass([
|
|
630
669
|
property({ type: Boolean, reflect: true })
|
|
631
670
|
], PickerBase.prototype, "readonly", 2);
|
|
671
|
+
__decorateClass([
|
|
672
|
+
state()
|
|
673
|
+
], PickerBase.prototype, "labelAlignment", 2);
|
|
632
674
|
__decorateClass([
|
|
633
675
|
query("sp-menu")
|
|
634
676
|
], PickerBase.prototype, "optionsMenu", 2);
|
|
@@ -659,7 +701,7 @@ export class Picker extends PickerBase {
|
|
|
659
701
|
this.handleKeydown = (event) => {
|
|
660
702
|
const { code } = event;
|
|
661
703
|
this.focused = true;
|
|
662
|
-
if (!code.startsWith("Arrow") || this.readonly) {
|
|
704
|
+
if (!code.startsWith("Arrow") || this.readonly || this.pending) {
|
|
663
705
|
return;
|
|
664
706
|
}
|
|
665
707
|
if (code === "ArrowUp" || code === "ArrowDown") {
|