@spectrum-web-components/action-group 0.10.2-devmode2.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/sp-action-group.dev.js +1 -0
- package/sp-action-group.dev.js.map +1 -1
- package/sp-action-group.js +1 -2
- package/sp-action-group.js.map +2 -2
- package/src/ActionGroup.dev.js +49 -27
- package/src/ActionGroup.dev.js.map +1 -1
- package/src/ActionGroup.js +2 -307
- package/src/ActionGroup.js.map +2 -2
- package/src/action-group.css.dev.js +1 -0
- package/src/action-group.css.dev.js.map +1 -1
- package/src/action-group.css.js +2 -4
- package/src/action-group.css.js.map +2 -2
- package/src/index.dev.js +1 -0
- package/src/index.dev.js.map +1 -1
- package/src/index.js +1 -1
- package/src/index.js.map +1 -1
- package/src/spectrum-action-group.css.dev.js +1 -0
- package/src/spectrum-action-group.css.dev.js.map +1 -1
- package/src/spectrum-action-group.css.js +2 -4
- package/src/spectrum-action-group.css.js.map +2 -2
- package/stories/action-group-tooltip.stories.js +7 -2
- package/stories/action-group-tooltip.stories.js.map +1 -1
- package/stories/action-group.stories.js +13 -4
- package/stories/action-group.stories.js.map +1 -1
- package/test/action-group-tooltip.test-vrt.js +1 -0
- package/test/action-group-tooltip.test-vrt.js.map +1 -1
- package/test/action-group.test-vrt.js +1 -0
- package/test/action-group.test-vrt.js.map +1 -1
- package/test/action-group.test.js +154 -77
- package/test/action-group.test.js.map +1 -1
- package/test/benchmark/basic-test.js +1 -0
- package/test/benchmark/basic-test.js.map +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
import {
|
|
2
3
|
elementUpdated,
|
|
3
4
|
expect,
|
|
@@ -43,7 +44,8 @@ class EmphasizedActionGroup extends LitElement {
|
|
|
43
44
|
}
|
|
44
45
|
customElements.define("emphasized-action-group", EmphasizedActionGroup);
|
|
45
46
|
async function singleSelectedActionGroup(selected) {
|
|
46
|
-
const el = await fixture(
|
|
47
|
+
const el = await fixture(
|
|
48
|
+
html`
|
|
47
49
|
<sp-action-group
|
|
48
50
|
label="Selects User-Chosen Buttons"
|
|
49
51
|
selects="single"
|
|
@@ -56,11 +58,13 @@ async function singleSelectedActionGroup(selected) {
|
|
|
56
58
|
Second
|
|
57
59
|
</sp-action-button>
|
|
58
60
|
</sp-action-group>
|
|
59
|
-
`
|
|
61
|
+
`
|
|
62
|
+
);
|
|
60
63
|
return el;
|
|
61
64
|
}
|
|
62
65
|
async function multipleSelectedActionGroup(selected) {
|
|
63
|
-
const el = await fixture(
|
|
66
|
+
const el = await fixture(
|
|
67
|
+
html`
|
|
64
68
|
<sp-action-group
|
|
65
69
|
label="Selects User-Chosen Buttons"
|
|
66
70
|
selects="multiple"
|
|
@@ -73,32 +77,41 @@ async function multipleSelectedActionGroup(selected) {
|
|
|
73
77
|
Second
|
|
74
78
|
</sp-action-button>
|
|
75
79
|
</sp-action-group>
|
|
76
|
-
`
|
|
80
|
+
`
|
|
81
|
+
);
|
|
77
82
|
return el;
|
|
78
83
|
}
|
|
79
84
|
describe("ActionGroup", () => {
|
|
80
85
|
it("loads empty action-group accessibly", async () => {
|
|
81
|
-
const el = await fixture(
|
|
86
|
+
const el = await fixture(
|
|
87
|
+
html`
|
|
82
88
|
<sp-action-group></sp-action-group>
|
|
83
|
-
`
|
|
89
|
+
`
|
|
90
|
+
);
|
|
84
91
|
await elementUpdated(el);
|
|
85
92
|
await expect(el).to.be.accessible();
|
|
86
93
|
});
|
|
87
|
-
testForLitDevWarnings(
|
|
94
|
+
testForLitDevWarnings(
|
|
95
|
+
async () => await fixture(
|
|
96
|
+
html`
|
|
88
97
|
<sp-action-group aria-label="Default Group">
|
|
89
98
|
<sp-action-button>First</sp-action-button>
|
|
90
99
|
<sp-action-button>Second</sp-action-button>
|
|
91
100
|
<sp-action-button>Third</sp-action-button>
|
|
92
101
|
</sp-action-group>
|
|
93
|
-
`
|
|
102
|
+
`
|
|
103
|
+
)
|
|
104
|
+
);
|
|
94
105
|
it("loads default action-group accessibly", async () => {
|
|
95
|
-
const el = await fixture(
|
|
106
|
+
const el = await fixture(
|
|
107
|
+
html`
|
|
96
108
|
<sp-action-group aria-label="Default Group">
|
|
97
109
|
<sp-action-button>First</sp-action-button>
|
|
98
110
|
<sp-action-button>Second</sp-action-button>
|
|
99
111
|
<sp-action-button>Third</sp-action-button>
|
|
100
112
|
</sp-action-group>
|
|
101
|
-
`
|
|
113
|
+
`
|
|
114
|
+
);
|
|
102
115
|
await elementUpdated(el);
|
|
103
116
|
await expect(el).to.be.accessible();
|
|
104
117
|
expect(el.getAttribute("aria-label")).to.equal("Default Group");
|
|
@@ -106,12 +119,14 @@ describe("ActionGroup", () => {
|
|
|
106
119
|
expect(el.children[0].getAttribute("role")).to.equal("button");
|
|
107
120
|
});
|
|
108
121
|
it("applies `quiet` attribute to its children", async () => {
|
|
109
|
-
const el = await fixture(
|
|
122
|
+
const el = await fixture(
|
|
123
|
+
html`
|
|
110
124
|
<sp-action-group quiet>
|
|
111
125
|
<sp-action-button id="first">First</sp-action-button>
|
|
112
126
|
<sp-action-button id="second">Second</sp-action-button>
|
|
113
127
|
</sp-action-group>
|
|
114
|
-
`
|
|
128
|
+
`
|
|
129
|
+
);
|
|
115
130
|
const firstButton = el.querySelector("#first");
|
|
116
131
|
const secondButton = el.querySelector("#second");
|
|
117
132
|
await elementUpdated(el);
|
|
@@ -121,7 +136,8 @@ describe("ActionGroup", () => {
|
|
|
121
136
|
expect(secondButton.quiet).to.be.true;
|
|
122
137
|
});
|
|
123
138
|
it("applies `quiet` attribute to its slotted children", async () => {
|
|
124
|
-
const el = await fixture(
|
|
139
|
+
const el = await fixture(
|
|
140
|
+
html`
|
|
125
141
|
<quiet-action-group>
|
|
126
142
|
<sp-action-button slot="first" id="first">
|
|
127
143
|
First
|
|
@@ -130,7 +146,8 @@ describe("ActionGroup", () => {
|
|
|
130
146
|
Second
|
|
131
147
|
</sp-action-button>
|
|
132
148
|
</quiet-action-group>
|
|
133
|
-
`
|
|
149
|
+
`
|
|
150
|
+
);
|
|
134
151
|
const firstButton = el.querySelector("#first");
|
|
135
152
|
const secondButton = el.querySelector("#second");
|
|
136
153
|
await elementUpdated(el);
|
|
@@ -140,7 +157,8 @@ describe("ActionGroup", () => {
|
|
|
140
157
|
expect(secondButton.quiet).to.be.true;
|
|
141
158
|
});
|
|
142
159
|
it("applies `emphasized` attribute to its slotted children", async () => {
|
|
143
|
-
const el = await fixture(
|
|
160
|
+
const el = await fixture(
|
|
161
|
+
html`
|
|
144
162
|
<emphasized-action-group>
|
|
145
163
|
<sp-action-button slot="first" id="first">
|
|
146
164
|
First
|
|
@@ -149,7 +167,8 @@ describe("ActionGroup", () => {
|
|
|
149
167
|
Second
|
|
150
168
|
</sp-action-button>
|
|
151
169
|
</emphasized-action-group>
|
|
152
|
-
`
|
|
170
|
+
`
|
|
171
|
+
);
|
|
153
172
|
const firstButton = el.querySelector("#first");
|
|
154
173
|
const secondButton = el.querySelector("#second");
|
|
155
174
|
await elementUpdated(el);
|
|
@@ -159,7 +178,8 @@ describe("ActionGroup", () => {
|
|
|
159
178
|
expect(secondButton.emphasized).to.be.true;
|
|
160
179
|
});
|
|
161
180
|
it("applies `quiet` attribute to slotted children with overlays", async () => {
|
|
162
|
-
const el = await fixture(
|
|
181
|
+
const el = await fixture(
|
|
182
|
+
html`
|
|
163
183
|
<quiet-action-group>
|
|
164
184
|
<overlay-trigger slot="first">
|
|
165
185
|
<sp-action-button slot="trigger" id="first">
|
|
@@ -172,7 +192,8 @@ describe("ActionGroup", () => {
|
|
|
172
192
|
</sp-action-button>
|
|
173
193
|
</overlay-trigger>
|
|
174
194
|
</quiet-action-group>
|
|
175
|
-
`
|
|
195
|
+
`
|
|
196
|
+
);
|
|
176
197
|
const firstButton = el.querySelector("#first");
|
|
177
198
|
const secondButton = el.querySelector("#second");
|
|
178
199
|
await elementUpdated(el);
|
|
@@ -182,7 +203,8 @@ describe("ActionGroup", () => {
|
|
|
182
203
|
expect(secondButton.quiet).to.be.true;
|
|
183
204
|
});
|
|
184
205
|
it("applies `emphasized` attribute to slotted children with overlays", async () => {
|
|
185
|
-
const el = await fixture(
|
|
206
|
+
const el = await fixture(
|
|
207
|
+
html`
|
|
186
208
|
<emphasized-action-group>
|
|
187
209
|
<overlay-trigger slot="first">
|
|
188
210
|
<sp-action-button slot="trigger" id="first">
|
|
@@ -195,7 +217,8 @@ describe("ActionGroup", () => {
|
|
|
195
217
|
</sp-action-button>
|
|
196
218
|
</overlay-trigger>
|
|
197
219
|
</emphasized-action-group>
|
|
198
|
-
`
|
|
220
|
+
`
|
|
221
|
+
);
|
|
199
222
|
const firstButton = el.querySelector("#first");
|
|
200
223
|
const secondButton = el.querySelector("#second");
|
|
201
224
|
await elementUpdated(el);
|
|
@@ -205,13 +228,15 @@ describe("ActionGroup", () => {
|
|
|
205
228
|
expect(secondButton.emphasized).to.be.true;
|
|
206
229
|
});
|
|
207
230
|
it('loads [selects="single"] action-group accessibly', async () => {
|
|
208
|
-
const el = await fixture(
|
|
231
|
+
const el = await fixture(
|
|
232
|
+
html`
|
|
209
233
|
<sp-action-group label="Selects Single Group" selects="single">
|
|
210
234
|
<sp-action-button>First</sp-action-button>
|
|
211
235
|
<sp-action-button>Second</sp-action-button>
|
|
212
236
|
<sp-action-button>Third</sp-action-button>
|
|
213
237
|
</sp-action-group>
|
|
214
|
-
`
|
|
238
|
+
`
|
|
239
|
+
);
|
|
215
240
|
await elementUpdated(el);
|
|
216
241
|
await expect(el).to.be.accessible();
|
|
217
242
|
expect(el.getAttribute("aria-label")).to.equal("Selects Single Group");
|
|
@@ -219,18 +244,21 @@ describe("ActionGroup", () => {
|
|
|
219
244
|
expect(el.children[0].getAttribute("role")).to.equal("radio");
|
|
220
245
|
});
|
|
221
246
|
it('loads [selects="single"] action-group w/ selection accessibly', async () => {
|
|
222
|
-
const el = await fixture(
|
|
247
|
+
const el = await fixture(
|
|
248
|
+
html`
|
|
223
249
|
<sp-action-group label="Selects Single Group" selects="single">
|
|
224
250
|
<sp-action-button>First</sp-action-button>
|
|
225
251
|
<sp-action-button>Second</sp-action-button>
|
|
226
252
|
<sp-action-button selected>Third</sp-action-button>
|
|
227
253
|
</sp-action-group>
|
|
228
|
-
`
|
|
254
|
+
`
|
|
255
|
+
);
|
|
229
256
|
await elementUpdated(el);
|
|
230
257
|
await expect(el).to.be.accessible();
|
|
231
258
|
});
|
|
232
259
|
it('loads [selects="multiple"] action-group accessibly', async () => {
|
|
233
|
-
const el = await fixture(
|
|
260
|
+
const el = await fixture(
|
|
261
|
+
html`
|
|
234
262
|
<sp-action-group
|
|
235
263
|
label="Selects Multiple Group"
|
|
236
264
|
selects="multiple"
|
|
@@ -239,15 +267,19 @@ describe("ActionGroup", () => {
|
|
|
239
267
|
<sp-action-button>Second</sp-action-button>
|
|
240
268
|
<sp-action-button>Third</sp-action-button>
|
|
241
269
|
</sp-action-group>
|
|
242
|
-
`
|
|
270
|
+
`
|
|
271
|
+
);
|
|
243
272
|
await elementUpdated(el);
|
|
244
273
|
await expect(el).to.be.accessible();
|
|
245
|
-
expect(el.getAttribute("aria-label")).to.equal(
|
|
274
|
+
expect(el.getAttribute("aria-label")).to.equal(
|
|
275
|
+
"Selects Multiple Group"
|
|
276
|
+
);
|
|
246
277
|
expect(el.getAttribute("role")).to.equal("group");
|
|
247
278
|
expect(el.children[0].getAttribute("role")).to.equal("checkbox");
|
|
248
279
|
});
|
|
249
280
|
it('loads [selects="multiple"] action-group w/ selection accessibly', async () => {
|
|
250
|
-
const el = await fixture(
|
|
281
|
+
const el = await fixture(
|
|
282
|
+
html`
|
|
251
283
|
<sp-action-group
|
|
252
284
|
label="Selects Multiple Group"
|
|
253
285
|
selects="multiple"
|
|
@@ -256,36 +288,42 @@ describe("ActionGroup", () => {
|
|
|
256
288
|
<sp-action-button selected>Second</sp-action-button>
|
|
257
289
|
<sp-action-button selected>Third</sp-action-button>
|
|
258
290
|
</sp-action-group>
|
|
259
|
-
`
|
|
291
|
+
`
|
|
292
|
+
);
|
|
260
293
|
await elementUpdated(el);
|
|
261
294
|
await expect(el).to.be.accessible();
|
|
262
295
|
});
|
|
263
296
|
it('sets tab stop when [selects="single"] and the initial button is [disabled]', async () => {
|
|
264
|
-
const el = await fixture(
|
|
297
|
+
const el = await fixture(
|
|
298
|
+
html`
|
|
265
299
|
<sp-action-group label="Selects Single Group" selects="single">
|
|
266
300
|
<sp-action-button disabled>First</sp-action-button>
|
|
267
301
|
<sp-action-button class="second">Second</sp-action-button>
|
|
268
302
|
<sp-action-button>Third</sp-action-button>
|
|
269
303
|
</sp-action-group>
|
|
270
|
-
`
|
|
304
|
+
`
|
|
305
|
+
);
|
|
271
306
|
const secondButton = el.querySelector(".second");
|
|
272
307
|
await elementUpdated(el);
|
|
273
308
|
expect(secondButton.hasAttribute("tabindex"));
|
|
274
309
|
expect(secondButton.getAttribute("tabindex")).to.equal("0");
|
|
275
310
|
});
|
|
276
311
|
it('surfaces [selects="single"] selection', async () => {
|
|
277
|
-
const el = await fixture(
|
|
312
|
+
const el = await fixture(
|
|
313
|
+
html`
|
|
278
314
|
<sp-action-group label="Selects Single Group" selects="single">
|
|
279
315
|
<sp-action-button>First</sp-action-button>
|
|
280
316
|
<sp-action-button>Second</sp-action-button>
|
|
281
317
|
<sp-action-button selected>Third</sp-action-button>
|
|
282
318
|
</sp-action-group>
|
|
283
|
-
`
|
|
319
|
+
`
|
|
320
|
+
);
|
|
284
321
|
await elementUpdated(el);
|
|
285
322
|
expect(el.selected, '"Third" selected').to.deep.equal(["Third"]);
|
|
286
323
|
});
|
|
287
324
|
it('surfaces [selects="multiple"] selection', async () => {
|
|
288
|
-
const el = await fixture(
|
|
325
|
+
const el = await fixture(
|
|
326
|
+
html`
|
|
289
327
|
<sp-action-group
|
|
290
328
|
label="Selects Multiple Group"
|
|
291
329
|
selects="multiple"
|
|
@@ -294,7 +332,8 @@ describe("ActionGroup", () => {
|
|
|
294
332
|
<sp-action-button selected>Second</sp-action-button>
|
|
295
333
|
<sp-action-button selected>Third</sp-action-button>
|
|
296
334
|
</sp-action-group>
|
|
297
|
-
`
|
|
335
|
+
`
|
|
336
|
+
);
|
|
298
337
|
await elementUpdated(el);
|
|
299
338
|
expect(el.selected, '"Second" and "Third" selected').to.deep.equal([
|
|
300
339
|
"Second",
|
|
@@ -302,13 +341,15 @@ describe("ActionGroup", () => {
|
|
|
302
341
|
]);
|
|
303
342
|
});
|
|
304
343
|
it("does not select without [selects]", async () => {
|
|
305
|
-
const el = await fixture(
|
|
344
|
+
const el = await fixture(
|
|
345
|
+
html`
|
|
306
346
|
<sp-action-group label="No Selects Group">
|
|
307
347
|
<sp-action-button>First</sp-action-button>
|
|
308
348
|
<sp-action-button selected>Second</sp-action-button>
|
|
309
349
|
<sp-action-button class="third">Third</sp-action-button>
|
|
310
350
|
</sp-action-group>
|
|
311
|
-
`
|
|
351
|
+
`
|
|
352
|
+
);
|
|
312
353
|
const thirdElement = el.querySelector(".third");
|
|
313
354
|
await elementUpdated(el);
|
|
314
355
|
expect(el.selected.length).to.equal(1);
|
|
@@ -317,7 +358,8 @@ describe("ActionGroup", () => {
|
|
|
317
358
|
expect(el.selected.length).to.equal(1);
|
|
318
359
|
});
|
|
319
360
|
it('selects via `click` while [selects="single"]', async () => {
|
|
320
|
-
const el = await fixture(
|
|
361
|
+
const el = await fixture(
|
|
362
|
+
html`
|
|
321
363
|
<sp-action-group label="Selects Single Group" selects="single">
|
|
322
364
|
<sp-action-button value="first">First</sp-action-button>
|
|
323
365
|
<sp-action-button value="second" selected>
|
|
@@ -327,7 +369,8 @@ describe("ActionGroup", () => {
|
|
|
327
369
|
Third
|
|
328
370
|
</sp-action-button>
|
|
329
371
|
</sp-action-group>
|
|
330
|
-
`
|
|
372
|
+
`
|
|
373
|
+
);
|
|
331
374
|
const thirdElement = el.querySelector(".third");
|
|
332
375
|
await elementUpdated(el);
|
|
333
376
|
expect(el.selected.length).to.equal(1);
|
|
@@ -335,10 +378,14 @@ describe("ActionGroup", () => {
|
|
|
335
378
|
thirdElement.click();
|
|
336
379
|
await elementUpdated(el);
|
|
337
380
|
expect(thirdElement.selected, "third child selected").to.be.true;
|
|
338
|
-
await waitUntil(
|
|
381
|
+
await waitUntil(
|
|
382
|
+
() => el.selected.length === 1 && el.selected.includes("third"),
|
|
383
|
+
"Updates value of `selected`"
|
|
384
|
+
);
|
|
339
385
|
});
|
|
340
386
|
it('selects via `click` while [selects="multiple"] selection', async () => {
|
|
341
|
-
const el = await fixture(
|
|
387
|
+
const el = await fixture(
|
|
388
|
+
html`
|
|
342
389
|
<sp-action-group
|
|
343
390
|
label="Selects Multiple Group"
|
|
344
391
|
selects="multiple"
|
|
@@ -349,7 +396,8 @@ describe("ActionGroup", () => {
|
|
|
349
396
|
<sp-action-button class="second">Second</sp-action-button>
|
|
350
397
|
<sp-action-button class="third">Third</sp-action-button>
|
|
351
398
|
</sp-action-group>
|
|
352
|
-
`
|
|
399
|
+
`
|
|
400
|
+
);
|
|
353
401
|
const firstElement = el.querySelector(".first");
|
|
354
402
|
const secondElement = el.querySelector(".second");
|
|
355
403
|
const thirdElement = el.querySelector(".third");
|
|
@@ -362,16 +410,21 @@ describe("ActionGroup", () => {
|
|
|
362
410
|
await elementUpdated(el);
|
|
363
411
|
expect(secondElement.selected, "second child selected").to.be.true;
|
|
364
412
|
expect(thirdElement.selected, "third child selected").to.be.true;
|
|
365
|
-
await waitUntil(
|
|
413
|
+
await waitUntil(
|
|
414
|
+
() => el.selected.length === 2 && el.selected.includes("Second") && el.selected.includes("Third"),
|
|
415
|
+
"Updates value of `selected`"
|
|
416
|
+
);
|
|
366
417
|
});
|
|
367
418
|
it("does not respond to clicks on itself", async () => {
|
|
368
|
-
const el = await fixture(
|
|
419
|
+
const el = await fixture(
|
|
420
|
+
html`
|
|
369
421
|
<sp-action-group label="Selects Single Group" selects="single">
|
|
370
422
|
<sp-action-button>First</sp-action-button>
|
|
371
423
|
<sp-action-button>Second</sp-action-button>
|
|
372
424
|
<sp-action-button class="third">Third</sp-action-button>
|
|
373
425
|
</sp-action-group>
|
|
374
|
-
`
|
|
426
|
+
`
|
|
427
|
+
);
|
|
375
428
|
await elementUpdated(el);
|
|
376
429
|
expect(el.selected.length).to.equal(0);
|
|
377
430
|
el.click();
|
|
@@ -379,19 +432,21 @@ describe("ActionGroup", () => {
|
|
|
379
432
|
expect(el.selected.length).to.equal(0);
|
|
380
433
|
});
|
|
381
434
|
it("selection can be prevented", async () => {
|
|
382
|
-
const el = await fixture(
|
|
435
|
+
const el = await fixture(
|
|
436
|
+
html`
|
|
383
437
|
<sp-action-group
|
|
384
438
|
label="Selects Single Group"
|
|
385
439
|
selects="single"
|
|
386
440
|
@change=${(event) => {
|
|
387
|
-
|
|
388
|
-
|
|
441
|
+
event.preventDefault();
|
|
442
|
+
}}
|
|
389
443
|
>
|
|
390
444
|
<sp-action-button>First</sp-action-button>
|
|
391
445
|
<sp-action-button>Second</sp-action-button>
|
|
392
446
|
<sp-action-button class="third">Third</sp-action-button>
|
|
393
447
|
</sp-action-group>
|
|
394
|
-
`
|
|
448
|
+
`
|
|
449
|
+
);
|
|
395
450
|
const thirdElement = el.querySelector(".third");
|
|
396
451
|
await elementUpdated(el);
|
|
397
452
|
expect(el.selected.length).to.equal(0);
|
|
@@ -429,7 +484,8 @@ describe("ActionGroup", () => {
|
|
|
429
484
|
expect(secondButton.selected, "second button selected").to.be.true;
|
|
430
485
|
});
|
|
431
486
|
it('selects user-passed value while [selects="multiple"]', async () => {
|
|
432
|
-
const el = await fixture(
|
|
487
|
+
const el = await fixture(
|
|
488
|
+
html`
|
|
433
489
|
<sp-action-group
|
|
434
490
|
label="Selects Multiple Group"
|
|
435
491
|
selects="multiple"
|
|
@@ -445,7 +501,8 @@ describe("ActionGroup", () => {
|
|
|
445
501
|
Third
|
|
446
502
|
</sp-action-button>
|
|
447
503
|
</sp-action-group>
|
|
448
|
-
`
|
|
504
|
+
`
|
|
505
|
+
);
|
|
449
506
|
await elementUpdated(el);
|
|
450
507
|
const firstButton = el.querySelector(".first");
|
|
451
508
|
const secondButton = el.querySelector(".second");
|
|
@@ -468,7 +525,8 @@ describe("ActionGroup", () => {
|
|
|
468
525
|
expect(thirdButton.selected, "third button selected").to.be.true;
|
|
469
526
|
});
|
|
470
527
|
it('selects can be updated while [selects="multiple"]', async () => {
|
|
471
|
-
const el = await fixture(
|
|
528
|
+
const el = await fixture(
|
|
529
|
+
html`
|
|
472
530
|
<sp-action-group
|
|
473
531
|
label="Selects Multiple Group"
|
|
474
532
|
selects="multiple"
|
|
@@ -484,7 +542,8 @@ describe("ActionGroup", () => {
|
|
|
484
542
|
Third
|
|
485
543
|
</sp-action-button>
|
|
486
544
|
</sp-action-group>
|
|
487
|
-
`
|
|
545
|
+
`
|
|
546
|
+
);
|
|
488
547
|
await elementUpdated(el);
|
|
489
548
|
const firstButton = el.querySelector(".first");
|
|
490
549
|
const secondButton = el.querySelector(".second");
|
|
@@ -530,7 +589,8 @@ describe("ActionGroup", () => {
|
|
|
530
589
|
expect(firstButton.selected, "first button selected").to.be.false;
|
|
531
590
|
});
|
|
532
591
|
it("selects user-passed values with no .selects value, but does not allow interaction afterwards", async () => {
|
|
533
|
-
const el = await fixture(
|
|
592
|
+
const el = await fixture(
|
|
593
|
+
html`
|
|
534
594
|
<sp-action-group
|
|
535
595
|
label="Selects User-Chosen Buttons"
|
|
536
596
|
.selected=${["first"]}
|
|
@@ -542,7 +602,8 @@ describe("ActionGroup", () => {
|
|
|
542
602
|
Second
|
|
543
603
|
</sp-action-button>
|
|
544
604
|
</sp-action-group>
|
|
545
|
-
`
|
|
605
|
+
`
|
|
606
|
+
);
|
|
546
607
|
await elementUpdated(el);
|
|
547
608
|
expect(el.selected.length).to.equal(1);
|
|
548
609
|
const firstButton = el.querySelector(".first");
|
|
@@ -556,7 +617,8 @@ describe("ActionGroup", () => {
|
|
|
556
617
|
expect(secondButton.selected, "second button selected").to.be.false;
|
|
557
618
|
});
|
|
558
619
|
it("selects multiple buttons if .selected is passed in, but does not allow further interaction afterwards", async () => {
|
|
559
|
-
const el = await fixture(
|
|
620
|
+
const el = await fixture(
|
|
621
|
+
html`
|
|
560
622
|
<sp-action-group
|
|
561
623
|
label="Selects User-Chosen Buttons"
|
|
562
624
|
.selected=${["first", "second"]}
|
|
@@ -568,7 +630,8 @@ describe("ActionGroup", () => {
|
|
|
568
630
|
Second
|
|
569
631
|
</sp-action-button>
|
|
570
632
|
</sp-action-group>
|
|
571
|
-
`
|
|
633
|
+
`
|
|
634
|
+
);
|
|
572
635
|
await elementUpdated(el);
|
|
573
636
|
expect(el.selected.length).to.equal(2);
|
|
574
637
|
const firstButton = el.querySelector(".first");
|
|
@@ -582,14 +645,15 @@ describe("ActionGroup", () => {
|
|
|
582
645
|
expect(secondButton.selected, "second button selected").to.be.true;
|
|
583
646
|
});
|
|
584
647
|
it('will not change .selected state if event is prevented while [selects="multiple"]', async () => {
|
|
585
|
-
const el = await fixture(
|
|
648
|
+
const el = await fixture(
|
|
649
|
+
html`
|
|
586
650
|
<sp-action-group
|
|
587
651
|
label="Selects Multiple Group"
|
|
588
652
|
selects="multiple"
|
|
589
653
|
.selected=${["first", "second"]}
|
|
590
654
|
@change=${(event) => {
|
|
591
|
-
|
|
592
|
-
|
|
655
|
+
event.preventDefault();
|
|
656
|
+
}}
|
|
593
657
|
>
|
|
594
658
|
<sp-action-button class="first" value="first">
|
|
595
659
|
First
|
|
@@ -601,7 +665,8 @@ describe("ActionGroup", () => {
|
|
|
601
665
|
Third
|
|
602
666
|
</sp-action-button>
|
|
603
667
|
</sp-action-group>
|
|
604
|
-
`
|
|
668
|
+
`
|
|
669
|
+
);
|
|
605
670
|
const firstElement = el.querySelector(".first");
|
|
606
671
|
const secondElement = el.querySelector(".second");
|
|
607
672
|
const thirdElement = el.querySelector(".third");
|
|
@@ -618,14 +683,15 @@ describe("ActionGroup", () => {
|
|
|
618
683
|
expect(secondElement.selected, "second element still selected").to.be.true;
|
|
619
684
|
});
|
|
620
685
|
it('will not change .selected state if event is prevented while [selects="single"]', async () => {
|
|
621
|
-
const el = await fixture(
|
|
686
|
+
const el = await fixture(
|
|
687
|
+
html`
|
|
622
688
|
<sp-action-group
|
|
623
689
|
label="Selects Single Group"
|
|
624
690
|
selects="single"
|
|
625
691
|
.selected=${["first"]}
|
|
626
692
|
@change=${(event) => {
|
|
627
|
-
|
|
628
|
-
|
|
693
|
+
event.preventDefault();
|
|
694
|
+
}}
|
|
629
695
|
>
|
|
630
696
|
<sp-action-button class="first" value="first">
|
|
631
697
|
First
|
|
@@ -634,7 +700,8 @@ describe("ActionGroup", () => {
|
|
|
634
700
|
Second
|
|
635
701
|
</sp-action-button>
|
|
636
702
|
</sp-action-group>
|
|
637
|
-
`
|
|
703
|
+
`
|
|
704
|
+
);
|
|
638
705
|
const firstElement = el.querySelector(".first");
|
|
639
706
|
const secondElement = el.querySelector(".second");
|
|
640
707
|
await elementUpdated(el);
|
|
@@ -649,13 +716,14 @@ describe("ActionGroup", () => {
|
|
|
649
716
|
expect(firstElement.selected, "first element still selected").to.be.true;
|
|
650
717
|
});
|
|
651
718
|
it("will not change .selected state if event is prevented while selects is undefined", async () => {
|
|
652
|
-
const el = await fixture(
|
|
719
|
+
const el = await fixture(
|
|
720
|
+
html`
|
|
653
721
|
<sp-action-group
|
|
654
722
|
label="Selects Single Group"
|
|
655
723
|
.selected=${["first"]}
|
|
656
724
|
@change=${(event) => {
|
|
657
|
-
|
|
658
|
-
|
|
725
|
+
event.preventDefault();
|
|
726
|
+
}}
|
|
659
727
|
>
|
|
660
728
|
<sp-action-button class="first" value="first">
|
|
661
729
|
First
|
|
@@ -664,7 +732,8 @@ describe("ActionGroup", () => {
|
|
|
664
732
|
Second
|
|
665
733
|
</sp-action-button>
|
|
666
734
|
</sp-action-group>
|
|
667
|
-
`
|
|
735
|
+
`
|
|
736
|
+
);
|
|
668
737
|
const firstElement = el.querySelector(".first");
|
|
669
738
|
const secondElement = el.querySelector(".second");
|
|
670
739
|
await elementUpdated(el);
|
|
@@ -677,7 +746,8 @@ describe("ActionGroup", () => {
|
|
|
677
746
|
expect(secondElement.selected, "second child not selected").to.be.false;
|
|
678
747
|
});
|
|
679
748
|
it("will accept selected as a JSON string", async () => {
|
|
680
|
-
const el = await fixture(
|
|
749
|
+
const el = await fixture(
|
|
750
|
+
html`
|
|
681
751
|
<sp-action-group
|
|
682
752
|
label="Selects Single Group"
|
|
683
753
|
selects="single"
|
|
@@ -690,7 +760,8 @@ describe("ActionGroup", () => {
|
|
|
690
760
|
Second
|
|
691
761
|
</sp-action-button>
|
|
692
762
|
</sp-action-group>
|
|
693
|
-
`
|
|
763
|
+
`
|
|
764
|
+
);
|
|
694
765
|
await elementUpdated(el);
|
|
695
766
|
const firstElement = el.querySelector(".first");
|
|
696
767
|
const secondElement = el.querySelector(".second");
|
|
@@ -733,17 +804,20 @@ describe("ActionGroup", () => {
|
|
|
733
804
|
expect(el.selected[0]).to.equal("Second");
|
|
734
805
|
};
|
|
735
806
|
it("accepts keybord input", async () => {
|
|
736
|
-
const el = await fixture(
|
|
807
|
+
const el = await fixture(
|
|
808
|
+
html`
|
|
737
809
|
<sp-action-group label="Selects Single Group" selects="single">
|
|
738
810
|
<sp-action-button>First</sp-action-button>
|
|
739
811
|
<sp-action-button selected>Second</sp-action-button>
|
|
740
812
|
<sp-action-button class="third">Third</sp-action-button>
|
|
741
813
|
</sp-action-group>
|
|
742
|
-
`
|
|
814
|
+
`
|
|
815
|
+
);
|
|
743
816
|
await acceptKeyboardInput(el);
|
|
744
817
|
});
|
|
745
818
|
it("accepts keybord input with tooltip", async () => {
|
|
746
|
-
const el = await fixture(
|
|
819
|
+
const el = await fixture(
|
|
820
|
+
html`
|
|
747
821
|
<sp-action-group label="Selects Single Group" selects="single">
|
|
748
822
|
<overlay-trigger>
|
|
749
823
|
<sp-action-button slot="trigger">
|
|
@@ -768,11 +842,13 @@ describe("ActionGroup", () => {
|
|
|
768
842
|
<sp-tooltip slot="hover-content">Select me.</sp-tooltip>
|
|
769
843
|
</overlay-trigger>
|
|
770
844
|
</sp-action-group>
|
|
771
|
-
`
|
|
845
|
+
`
|
|
846
|
+
);
|
|
772
847
|
await acceptKeyboardInput(el);
|
|
773
848
|
});
|
|
774
849
|
it('accepts keybord input when [dir="ltr"]', async () => {
|
|
775
|
-
const el = await fixture(
|
|
850
|
+
const el = await fixture(
|
|
851
|
+
html`
|
|
776
852
|
<sp-action-group
|
|
777
853
|
label="Selects Single Group"
|
|
778
854
|
selects="single"
|
|
@@ -782,7 +858,8 @@ describe("ActionGroup", () => {
|
|
|
782
858
|
<sp-action-button disabled>Second</sp-action-button>
|
|
783
859
|
<sp-action-button class="third">Third</sp-action-button>
|
|
784
860
|
</sp-action-group>
|
|
785
|
-
`
|
|
861
|
+
`
|
|
862
|
+
);
|
|
786
863
|
const thirdElement = el.querySelector(".third");
|
|
787
864
|
await elementUpdated(el);
|
|
788
865
|
expect(el.selected.length).to.equal(0);
|