@spectrum-web-components/swatch 0.41.2 → 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/custom-elements.json +30 -15
- package/package.json +10 -10
- package/src/SwatchGroup.d.ts +5 -2
- package/src/SwatchGroup.dev.js +53 -21
- package/src/SwatchGroup.dev.js.map +2 -2
- package/src/SwatchGroup.js +2 -2
- package/src/SwatchGroup.js.map +3 -3
- package/stories/swatch-group.stories.js +18 -18
- package/stories/swatch-group.stories.js.map +2 -2
- package/test/swatch-group.test.js +44 -2
- package/test/swatch-group.test.js.map +2 -2
package/custom-elements.json
CHANGED
|
@@ -390,6 +390,16 @@
|
|
|
390
390
|
"attribute": "border",
|
|
391
391
|
"reflects": true
|
|
392
392
|
},
|
|
393
|
+
{
|
|
394
|
+
"kind": "field",
|
|
395
|
+
"name": "density",
|
|
396
|
+
"type": {
|
|
397
|
+
"text": "'compact' | 'spacious' | undefined"
|
|
398
|
+
},
|
|
399
|
+
"privacy": "public",
|
|
400
|
+
"attribute": "density",
|
|
401
|
+
"reflects": true
|
|
402
|
+
},
|
|
393
403
|
{
|
|
394
404
|
"kind": "field",
|
|
395
405
|
"name": "rounding",
|
|
@@ -407,9 +417,17 @@
|
|
|
407
417
|
"text": "string[]"
|
|
408
418
|
},
|
|
409
419
|
"privacy": "public",
|
|
410
|
-
"default": "[]",
|
|
411
420
|
"attribute": "selected"
|
|
412
421
|
},
|
|
422
|
+
{
|
|
423
|
+
"kind": "field",
|
|
424
|
+
"name": "_selected",
|
|
425
|
+
"type": {
|
|
426
|
+
"text": "string[]"
|
|
427
|
+
},
|
|
428
|
+
"privacy": "private",
|
|
429
|
+
"default": "[]"
|
|
430
|
+
},
|
|
413
431
|
{
|
|
414
432
|
"kind": "field",
|
|
415
433
|
"name": "selects",
|
|
@@ -437,18 +455,16 @@
|
|
|
437
455
|
},
|
|
438
456
|
{
|
|
439
457
|
"kind": "field",
|
|
440
|
-
"name": "
|
|
458
|
+
"name": "swatches",
|
|
441
459
|
"type": {
|
|
442
|
-
"text": "
|
|
460
|
+
"text": "Swatch[]"
|
|
443
461
|
},
|
|
444
|
-
"privacy": "public"
|
|
445
|
-
"attribute": "density",
|
|
446
|
-
"reflects": true
|
|
462
|
+
"privacy": "public"
|
|
447
463
|
},
|
|
448
464
|
{
|
|
449
465
|
"kind": "field",
|
|
450
466
|
"name": "rovingTabindexController",
|
|
451
|
-
"default": "new RovingTabindexController<Swatch>(this, {\n focusInIndex: (elements: Swatch[]) => {\n let firstEnabledIndex = -1;\n const firstSelectedIndex = elements.findIndex((el, index) => {\n if (!elements[firstEnabledIndex] && !el.disabled) {\n firstEnabledIndex = index;\n }\n return el.selected && !el.disabled;\n });\n return elements[firstSelectedIndex]\n ? firstSelectedIndex\n : firstEnabledIndex;\n },\n elements: () =>
|
|
467
|
+
"default": "new RovingTabindexController<Swatch>(this, {\n focusInIndex: (elements: Swatch[]) => {\n let firstEnabledIndex = -1;\n const firstSelectedIndex = elements.findIndex((el, index) => {\n if (!elements[firstEnabledIndex] && !el.disabled) {\n firstEnabledIndex = index;\n }\n return el.selected && !el.disabled;\n });\n return elements[firstSelectedIndex]\n ? firstSelectedIndex\n : firstEnabledIndex;\n },\n elements: () => this.swatches,\n isFocusableElement: (el: Swatch) => !el.disabled,\n })"
|
|
452
468
|
},
|
|
453
469
|
{
|
|
454
470
|
"kind": "method",
|
|
@@ -545,6 +561,13 @@
|
|
|
545
561
|
},
|
|
546
562
|
"fieldName": "border"
|
|
547
563
|
},
|
|
564
|
+
{
|
|
565
|
+
"name": "density",
|
|
566
|
+
"type": {
|
|
567
|
+
"text": "'compact' | 'spacious' | undefined"
|
|
568
|
+
},
|
|
569
|
+
"fieldName": "density"
|
|
570
|
+
},
|
|
548
571
|
{
|
|
549
572
|
"name": "rounding",
|
|
550
573
|
"type": {
|
|
@@ -557,7 +580,6 @@
|
|
|
557
580
|
"type": {
|
|
558
581
|
"text": "string[]"
|
|
559
582
|
},
|
|
560
|
-
"default": "[]",
|
|
561
583
|
"fieldName": "selected"
|
|
562
584
|
},
|
|
563
585
|
{
|
|
@@ -573,13 +595,6 @@
|
|
|
573
595
|
"text": "SwatchShape"
|
|
574
596
|
},
|
|
575
597
|
"fieldName": "shape"
|
|
576
|
-
},
|
|
577
|
-
{
|
|
578
|
-
"name": "density",
|
|
579
|
-
"type": {
|
|
580
|
-
"text": "'compact' | 'spacious' | undefined"
|
|
581
|
-
},
|
|
582
|
-
"fieldName": "density"
|
|
583
598
|
}
|
|
584
599
|
],
|
|
585
600
|
"mixins": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/swatch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -67,16 +67,16 @@
|
|
|
67
67
|
],
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@lit-labs/observers": "^2.0.0",
|
|
70
|
-
"@spectrum-web-components/base": "^0.
|
|
71
|
-
"@spectrum-web-components/icon": "^0.
|
|
72
|
-
"@spectrum-web-components/icons-ui": "^0.
|
|
73
|
-
"@spectrum-web-components/opacity-checkerboard": "^0.
|
|
74
|
-
"@spectrum-web-components/reactive-controllers": "^0.
|
|
75
|
-
"@spectrum-web-components/shared": "^0.
|
|
70
|
+
"@spectrum-web-components/base": "^0.42.0",
|
|
71
|
+
"@spectrum-web-components/icon": "^0.42.0",
|
|
72
|
+
"@spectrum-web-components/icons-ui": "^0.42.0",
|
|
73
|
+
"@spectrum-web-components/opacity-checkerboard": "^0.42.0",
|
|
74
|
+
"@spectrum-web-components/reactive-controllers": "^0.42.0",
|
|
75
|
+
"@spectrum-web-components/shared": "^0.42.0"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"@spectrum-css/swatch": "^5.1.
|
|
79
|
-
"@spectrum-css/swatchgroup": "^2.1.
|
|
78
|
+
"@spectrum-css/swatch": "^5.1.4",
|
|
79
|
+
"@spectrum-css/swatchgroup": "^2.1.4"
|
|
80
80
|
},
|
|
81
81
|
"types": "./src/index.d.ts",
|
|
82
82
|
"customElements": "custom-elements.json",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"./sp-*.js",
|
|
85
85
|
"./**/*.dev.js"
|
|
86
86
|
],
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "9b3bd55ff8e8f9438817255976e77fd456b19d72"
|
|
88
88
|
}
|
package/src/SwatchGroup.d.ts
CHANGED
|
@@ -15,12 +15,15 @@ declare const SwatchGroup_base: typeof SpectrumElement & {
|
|
|
15
15
|
export declare class SwatchGroup extends SwatchGroup_base {
|
|
16
16
|
static get styles(): CSSResultArray;
|
|
17
17
|
border: SwatchBorder;
|
|
18
|
+
density: 'compact' | 'spacious' | undefined;
|
|
18
19
|
rounding: SwatchRounding;
|
|
19
|
-
selected: string[];
|
|
20
|
+
get selected(): string[];
|
|
21
|
+
set selected(selected: string[]);
|
|
22
|
+
private _selected;
|
|
20
23
|
selects: SwatchSelects;
|
|
21
24
|
private selectedSet;
|
|
22
25
|
shape: SwatchShape;
|
|
23
|
-
|
|
26
|
+
swatches: Swatch[];
|
|
24
27
|
constructor();
|
|
25
28
|
rovingTabindexController: RovingTabindexController<Swatch>;
|
|
26
29
|
focus(options?: FocusOptions): void;
|
package/src/SwatchGroup.dev.js
CHANGED
|
@@ -15,7 +15,10 @@ import {
|
|
|
15
15
|
SizedMixin,
|
|
16
16
|
SpectrumElement
|
|
17
17
|
} from "@spectrum-web-components/base";
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
property,
|
|
20
|
+
queryAssignedElements
|
|
21
|
+
} from "@spectrum-web-components/base/src/decorators.js";
|
|
19
22
|
import { RovingTabindexController } from "@spectrum-web-components/reactive-controllers/src/RovingTabindex.js";
|
|
20
23
|
import { MutationController } from "@lit-labs/observers/mutation-controller.js";
|
|
21
24
|
import styles from "./swatch-group.css.js";
|
|
@@ -25,7 +28,9 @@ export class SwatchGroup extends SizedMixin(SpectrumElement, {
|
|
|
25
28
|
}) {
|
|
26
29
|
constructor() {
|
|
27
30
|
super();
|
|
28
|
-
this
|
|
31
|
+
// Specifically surface `_selected` internally so that change can be made to this value internally
|
|
32
|
+
// without triggering the update lifecycle directly.
|
|
33
|
+
this._selected = [];
|
|
29
34
|
this.selectedSet = /* @__PURE__ */ new Set();
|
|
30
35
|
this.rovingTabindexController = new RovingTabindexController(this, {
|
|
31
36
|
focusInIndex: (elements) => {
|
|
@@ -38,14 +43,14 @@ export class SwatchGroup extends SizedMixin(SpectrumElement, {
|
|
|
38
43
|
});
|
|
39
44
|
return elements[firstSelectedIndex] ? firstSelectedIndex : firstEnabledIndex;
|
|
40
45
|
},
|
|
41
|
-
elements: () =>
|
|
46
|
+
elements: () => this.swatches,
|
|
42
47
|
isFocusableElement: (el) => !el.disabled
|
|
43
48
|
});
|
|
44
|
-
this.manageChange = () => {
|
|
49
|
+
this.manageChange = async () => {
|
|
45
50
|
const presentSet = /* @__PURE__ */ new Set();
|
|
46
51
|
this.selectedSet = new Set(this.selected);
|
|
47
|
-
|
|
48
|
-
swatches.forEach((swatch) => {
|
|
52
|
+
await Promise.all(this.swatches.map((swatch) => swatch.updateComplete));
|
|
53
|
+
this.swatches.forEach((swatch) => {
|
|
49
54
|
presentSet.add(swatch.value);
|
|
50
55
|
if (swatch.selected) {
|
|
51
56
|
this.selectedSet.add(swatch.value);
|
|
@@ -56,7 +61,8 @@ export class SwatchGroup extends SizedMixin(SpectrumElement, {
|
|
|
56
61
|
this.selectedSet.delete(value);
|
|
57
62
|
}
|
|
58
63
|
});
|
|
59
|
-
this.
|
|
64
|
+
this._selected = [...this.selectedSet];
|
|
65
|
+
this.rovingTabindexController.clearElementCache();
|
|
60
66
|
};
|
|
61
67
|
new MutationController(this, {
|
|
62
68
|
config: {
|
|
@@ -72,6 +78,16 @@ export class SwatchGroup extends SizedMixin(SpectrumElement, {
|
|
|
72
78
|
static get styles() {
|
|
73
79
|
return [styles];
|
|
74
80
|
}
|
|
81
|
+
get selected() {
|
|
82
|
+
return this._selected;
|
|
83
|
+
}
|
|
84
|
+
set selected(selected) {
|
|
85
|
+
if (selected === this.selected)
|
|
86
|
+
return;
|
|
87
|
+
const oldSelected = this.selected;
|
|
88
|
+
this._selected = selected;
|
|
89
|
+
this.requestUpdate("selected", oldSelected);
|
|
90
|
+
}
|
|
75
91
|
focus(options) {
|
|
76
92
|
this.rovingTabindexController.focus(options);
|
|
77
93
|
}
|
|
@@ -104,7 +120,7 @@ export class SwatchGroup extends SizedMixin(SpectrumElement, {
|
|
|
104
120
|
this.selectedSet.delete(target.value);
|
|
105
121
|
}
|
|
106
122
|
}
|
|
107
|
-
this.
|
|
123
|
+
this._selected = [...this.selectedSet];
|
|
108
124
|
const applyDefault = this.dispatchEvent(
|
|
109
125
|
new Event("change", {
|
|
110
126
|
cancelable: true,
|
|
@@ -112,7 +128,7 @@ export class SwatchGroup extends SizedMixin(SpectrumElement, {
|
|
|
112
128
|
})
|
|
113
129
|
);
|
|
114
130
|
if (!applyDefault) {
|
|
115
|
-
this.
|
|
131
|
+
this._selected = oldSelected;
|
|
116
132
|
event.preventDefault();
|
|
117
133
|
}
|
|
118
134
|
}
|
|
@@ -195,7 +211,7 @@ export class SwatchGroup extends SizedMixin(SpectrumElement, {
|
|
|
195
211
|
...this.getPassthroughSwatchActions(changes),
|
|
196
212
|
...this.getSelectionSwatchActions(changes)
|
|
197
213
|
];
|
|
198
|
-
|
|
214
|
+
let nextSelected = new Set(this.selected);
|
|
199
215
|
const currentValues = /* @__PURE__ */ new Set();
|
|
200
216
|
if (changes.has("selected")) {
|
|
201
217
|
swatchActions.push((swatch) => {
|
|
@@ -207,28 +223,44 @@ export class SwatchGroup extends SizedMixin(SpectrumElement, {
|
|
|
207
223
|
}
|
|
208
224
|
});
|
|
209
225
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
226
|
+
const doActions = () => {
|
|
227
|
+
nextSelected = new Set(this.selected);
|
|
228
|
+
this.swatches.forEach((swatch) => {
|
|
229
|
+
swatchActions.forEach((action) => {
|
|
230
|
+
action(swatch);
|
|
231
|
+
});
|
|
213
232
|
});
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
233
|
+
if (changes.has("selected")) {
|
|
234
|
+
this._selected = [...nextSelected.values()].filter(
|
|
235
|
+
(selectedValue) => currentValues.has(selectedValue)
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
if (this.hasUpdated) {
|
|
240
|
+
doActions();
|
|
241
|
+
} else {
|
|
242
|
+
this.shadowRoot.addEventListener(
|
|
243
|
+
"slotchange",
|
|
244
|
+
() => {
|
|
245
|
+
requestAnimationFrame(doActions);
|
|
246
|
+
},
|
|
247
|
+
{ once: true }
|
|
218
248
|
);
|
|
219
|
-
this.rovingTabindexController.clearElementCache();
|
|
220
249
|
}
|
|
221
250
|
}
|
|
222
251
|
}
|
|
223
252
|
__decorateClass([
|
|
224
253
|
property({ reflect: true })
|
|
225
254
|
], SwatchGroup.prototype, "border", 2);
|
|
255
|
+
__decorateClass([
|
|
256
|
+
property({ reflect: true })
|
|
257
|
+
], SwatchGroup.prototype, "density", 2);
|
|
226
258
|
__decorateClass([
|
|
227
259
|
property({ reflect: true })
|
|
228
260
|
], SwatchGroup.prototype, "rounding", 2);
|
|
229
261
|
__decorateClass([
|
|
230
262
|
property({ type: Array })
|
|
231
|
-
], SwatchGroup.prototype, "selected",
|
|
263
|
+
], SwatchGroup.prototype, "selected", 1);
|
|
232
264
|
__decorateClass([
|
|
233
265
|
property()
|
|
234
266
|
], SwatchGroup.prototype, "selects", 2);
|
|
@@ -236,6 +268,6 @@ __decorateClass([
|
|
|
236
268
|
property({ reflect: true })
|
|
237
269
|
], SwatchGroup.prototype, "shape", 2);
|
|
238
270
|
__decorateClass([
|
|
239
|
-
|
|
240
|
-
], SwatchGroup.prototype, "
|
|
271
|
+
queryAssignedElements({ flatten: true })
|
|
272
|
+
], SwatchGroup.prototype, "swatches", 2);
|
|
241
273
|
//# sourceMappingURL=SwatchGroup.dev.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["SwatchGroup.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n ElementSize,\n html,\n PropertyValues,\n SizedMixin,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { RovingTabindexController } from '@spectrum-web-components/reactive-controllers/src/RovingTabindex.js';\nimport { MutationController } from '@lit-labs/observers/mutation-controller.js';\n\nimport styles from './swatch-group.css.js';\nimport type {\n Swatch,\n SwatchBorder,\n SwatchRounding,\n SwatchShape,\n} from './Swatch.dev.js'\n\nexport type SwatchGroupSizes = Exclude<ElementSize, 'xxs' | 'xl' | 'xxl'>;\nexport type SwatchSelects = 'single' | 'multiple' | undefined;\n\n/**\n * @element sp-swatch-group\n *\n * @slot - Swatch elements to manage as a group\n */\nexport class SwatchGroup extends SizedMixin(SpectrumElement, {\n validSizes: ['xs', 's', 'm', 'l'],\n noDefaultSize: true,\n}) {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ reflect: true })\n public border: SwatchBorder;\n\n @property({ reflect: true })\n public rounding: SwatchRounding;\n\n @property({ type: Array })\n public selected: string[] = [];\n\n @property()\n public selects: SwatchSelects;\n\n private selectedSet = new Set<string>();\n\n @property({ reflect: true })\n public shape: SwatchShape;\n\n @property({ reflect: true })\n public density: 'compact' | 'spacious' | undefined;\n\n constructor() {\n super();\n\n new MutationController(this, {\n config: {\n attributes: true,\n childList: true,\n subtree: true,\n },\n callback: () => {\n this.manageChange();\n },\n });\n }\n\n rovingTabindexController = new RovingTabindexController<Swatch>(this, {\n focusInIndex: (elements: Swatch[]) => {\n let firstEnabledIndex = -1;\n const firstSelectedIndex = elements.findIndex((el, index) => {\n if (!elements[firstEnabledIndex] && !el.disabled) {\n firstEnabledIndex = index;\n }\n return el.selected && !el.disabled;\n });\n return elements[firstSelectedIndex]\n ? firstSelectedIndex\n : firstEnabledIndex;\n },\n elements: () => [...this.children] as Swatch[],\n isFocusableElement: (el: Swatch) => !el.disabled,\n });\n\n public override focus(options?: FocusOptions): void {\n this.rovingTabindexController.focus(options);\n }\n\n protected handleChange(event: Event & { target: Swatch }): void {\n event.stopPropagation();\n const oldSelected = this.selected;\n if (!this.selects) {\n event.preventDefault();\n return;\n }\n if (this.selects === 'single') {\n const { target } = event;\n target.tabIndex = 0;\n target.selected = true;\n if (this.selectedSet.has(target.value)) {\n return;\n }\n this.selectedSet.clear();\n this.selectedSet.add(target.value);\n this.rovingTabindexController.elements.forEach((child) => {\n if (child === target) return;\n child.selected = false;\n });\n } else if (this.selects === 'multiple') {\n const { target } = event;\n if (target.selected) {\n this.selectedSet.add(target.value);\n } else {\n this.selectedSet.delete(target.value);\n }\n }\n this.selected = [...this.selectedSet];\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n cancelable: true,\n bubbles: true,\n })\n );\n if (!applyDefault) {\n this.selected = oldSelected;\n event.preventDefault();\n }\n }\n\n private manageChange = (): void => {\n const presentSet = new Set();\n this.selectedSet = new Set(this.selected);\n const swatches = [...this.children] as Swatch[];\n swatches.forEach((swatch) => {\n presentSet.add(swatch.value);\n if (swatch.selected) {\n this.selectedSet.add(swatch.value);\n }\n });\n this.selectedSet.forEach((value) => {\n if (!presentSet.has(value)) {\n this.selectedSet.delete(value);\n }\n });\n this.selected = [...this.selectedSet];\n };\n\n private getPassthroughSwatchActions(\n changes: PropertyValues\n ): ((swatch: Swatch) => void)[] {\n const targetValues: {\n border?: SwatchBorder;\n rounding?: SwatchRounding;\n shape?: SwatchShape;\n size?: SwatchGroupSizes;\n selects?: SwatchSelects;\n } = {};\n if (\n changes.has('selects') &&\n (this.selects || typeof changes.get('selects') !== 'undefined')\n ) {\n targetValues.selects = this.selects;\n }\n if (\n changes.has('border') &&\n (this.border || typeof changes.get('border') !== 'undefined')\n ) {\n targetValues.border = this.border;\n }\n if (\n changes.has('rounding') &&\n (this.rounding || typeof changes.get('rounding') !== 'undefined')\n ) {\n targetValues.rounding = this.rounding;\n }\n if (\n changes.has('size') &&\n (this.size !== 'm' || typeof changes.get('size') !== 'undefined')\n ) {\n targetValues.size = this.size as SwatchGroupSizes;\n }\n if (\n changes.has('shape') &&\n (this.shape || typeof changes.get('shape') !== 'undefined')\n ) {\n targetValues.shape = this.shape;\n }\n const passThroughSwatchActions: ((swatch: Swatch) => void)[] = [];\n if (Object.keys(targetValues).length) {\n passThroughSwatchActions.push((swatch) => {\n if (window.__swc.DEBUG) {\n if (\n 'selects' in targetValues &&\n targetValues.selects !== 'multiple' &&\n swatch.mixedValue\n ) {\n window.__swc.warn(\n this,\n `<sp-swatch> elements can only leverage the \"mixed-value\" attribute when their <sp-swatch-group> parent element is also leveraging \"selects=\"multiple\"\"`,\n 'https://opensource.adobe.com/spectrum-web-components/components/swatch-group/#multiple',\n {\n type: 'accessibility',\n }\n );\n }\n }\n if ('border' in targetValues)\n swatch.border = targetValues.border;\n if ('rounding' in targetValues)\n swatch.rounding = targetValues.rounding;\n if ('shape' in targetValues) swatch.shape = targetValues.shape;\n if ('size' in targetValues)\n swatch.size = targetValues.size as SwatchGroupSizes;\n });\n }\n return passThroughSwatchActions;\n }\n\n private getSelectionSwatchActions(\n changes: PropertyValues\n ): ((swatch: Swatch) => void)[] {\n const selectionSwatchActions: ((swatch: Swatch) => void)[] = [];\n if (!changes.has('selects')) return selectionSwatchActions;\n if (this.selects) {\n this.setAttribute(\n 'role',\n this.selects === 'single' ? 'radiogroup' : 'group'\n );\n } else {\n this.removeAttribute('role');\n }\n const swatchRoles = {\n single: 'radio',\n multiple: 'checkbox',\n };\n const swatchRole = this.selects ? swatchRoles[this.selects] : 'button';\n selectionSwatchActions.push((swatch) => {\n swatch.setAttribute('role', swatchRole);\n });\n return selectionSwatchActions;\n }\n\n protected override render(): TemplateResult {\n return html`\n <slot\n @change=${this.handleChange}\n @slotchange=${this.manageChange}\n ></slot>\n `;\n }\n\n protected override willUpdate(changes: PropertyValues<this>): void {\n const swatchActions = [\n ...this.getPassthroughSwatchActions(changes),\n ...this.getSelectionSwatchActions(changes),\n ];\n\n // Create Swatch actions that build state to be applied later.\n const nextSelected = new Set(this.selected);\n const currentValues = new Set();\n if (changes.has('selected')) {\n swatchActions.push((swatch) => {\n currentValues.add(swatch.value);\n if (\n nextSelected.has(swatch.value) ||\n (!this.hasUpdated && swatch.selected)\n ) {\n swatch.selected = true;\n } else {\n swatch.selected = false;\n }\n });\n }\n\n // Do Swatch actions to each Swach in the collection.\n this.rovingTabindexController.elements.forEach((swatch) => {\n swatchActions.forEach((action) => {\n action(swatch);\n });\n });\n\n // Apply state built in actions back to the Swatch Group\n if (changes.has('selected')) {\n this.selected = [...nextSelected].filter((selectedValue) =>\n currentValues.has(selectedValue)\n );\n this.rovingTabindexController.clearElementCache();\n }\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;AAYA;AAAA,EAGI;AAAA,EAEA;AAAA,EACA;AAAA,OAEG;AACP,
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n ElementSize,\n html,\n PropertyValues,\n SizedMixin,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n queryAssignedElements,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { RovingTabindexController } from '@spectrum-web-components/reactive-controllers/src/RovingTabindex.js';\nimport { MutationController } from '@lit-labs/observers/mutation-controller.js';\n\nimport styles from './swatch-group.css.js';\nimport type {\n Swatch,\n SwatchBorder,\n SwatchRounding,\n SwatchShape,\n} from './Swatch.dev.js'\n\nexport type SwatchGroupSizes = Exclude<ElementSize, 'xxs' | 'xl' | 'xxl'>;\nexport type SwatchSelects = 'single' | 'multiple' | undefined;\n\n/**\n * @element sp-swatch-group\n *\n * @slot - Swatch elements to manage as a group\n */\nexport class SwatchGroup extends SizedMixin(SpectrumElement, {\n validSizes: ['xs', 's', 'm', 'l'],\n noDefaultSize: true,\n}) {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ reflect: true })\n public border: SwatchBorder;\n\n @property({ reflect: true })\n public density: 'compact' | 'spacious' | undefined;\n\n @property({ reflect: true })\n public rounding: SwatchRounding;\n\n @property({ type: Array })\n public get selected(): string[] {\n return this._selected;\n }\n\n public set selected(selected: string[]) {\n if (selected === this.selected) return;\n\n const oldSelected = this.selected;\n this._selected = selected;\n this.requestUpdate('selected', oldSelected);\n }\n\n // Specifically surface `_selected` internally so that change can be made to this value internally\n // without triggering the update lifecycle directly.\n private _selected: string[] = [];\n\n @property()\n public selects: SwatchSelects;\n\n private selectedSet = new Set<string>();\n\n @property({ reflect: true })\n public shape: SwatchShape;\n\n @queryAssignedElements({ flatten: true })\n public swatches!: Swatch[];\n\n constructor() {\n super();\n\n new MutationController(this, {\n config: {\n attributes: true,\n childList: true,\n subtree: true,\n },\n callback: () => {\n this.manageChange();\n },\n });\n }\n\n rovingTabindexController = new RovingTabindexController<Swatch>(this, {\n focusInIndex: (elements: Swatch[]) => {\n let firstEnabledIndex = -1;\n const firstSelectedIndex = elements.findIndex((el, index) => {\n if (!elements[firstEnabledIndex] && !el.disabled) {\n firstEnabledIndex = index;\n }\n return el.selected && !el.disabled;\n });\n return elements[firstSelectedIndex]\n ? firstSelectedIndex\n : firstEnabledIndex;\n },\n elements: () => this.swatches,\n isFocusableElement: (el: Swatch) => !el.disabled,\n });\n\n public override focus(options?: FocusOptions): void {\n this.rovingTabindexController.focus(options);\n }\n\n protected handleChange(event: Event & { target: Swatch }): void {\n event.stopPropagation();\n const oldSelected = this.selected;\n if (!this.selects) {\n event.preventDefault();\n return;\n }\n if (this.selects === 'single') {\n const { target } = event;\n target.tabIndex = 0;\n target.selected = true;\n if (this.selectedSet.has(target.value)) {\n return;\n }\n this.selectedSet.clear();\n this.selectedSet.add(target.value);\n this.rovingTabindexController.elements.forEach((child) => {\n if (child === target) return;\n child.selected = false;\n });\n } else if (this.selects === 'multiple') {\n const { target } = event;\n if (target.selected) {\n this.selectedSet.add(target.value);\n } else {\n this.selectedSet.delete(target.value);\n }\n }\n this._selected = [...this.selectedSet];\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n cancelable: true,\n bubbles: true,\n })\n );\n if (!applyDefault) {\n this._selected = oldSelected;\n event.preventDefault();\n }\n }\n\n private manageChange = async (): Promise<void> => {\n const presentSet = new Set();\n this.selectedSet = new Set(this.selected);\n await Promise.all(this.swatches.map((swatch) => swatch.updateComplete));\n this.swatches.forEach((swatch) => {\n presentSet.add(swatch.value);\n if (swatch.selected) {\n this.selectedSet.add(swatch.value);\n }\n });\n this.selectedSet.forEach((value) => {\n if (!presentSet.has(value)) {\n this.selectedSet.delete(value);\n }\n });\n this._selected = [...this.selectedSet];\n this.rovingTabindexController.clearElementCache();\n };\n\n private getPassthroughSwatchActions(\n changes: PropertyValues\n ): ((swatch: Swatch) => void)[] {\n const targetValues: {\n border?: SwatchBorder;\n rounding?: SwatchRounding;\n shape?: SwatchShape;\n size?: SwatchGroupSizes;\n selects?: SwatchSelects;\n } = {};\n if (\n changes.has('selects') &&\n (this.selects || typeof changes.get('selects') !== 'undefined')\n ) {\n targetValues.selects = this.selects;\n }\n if (\n changes.has('border') &&\n (this.border || typeof changes.get('border') !== 'undefined')\n ) {\n targetValues.border = this.border;\n }\n if (\n changes.has('rounding') &&\n (this.rounding || typeof changes.get('rounding') !== 'undefined')\n ) {\n targetValues.rounding = this.rounding;\n }\n if (\n changes.has('size') &&\n (this.size !== 'm' || typeof changes.get('size') !== 'undefined')\n ) {\n targetValues.size = this.size as SwatchGroupSizes;\n }\n if (\n changes.has('shape') &&\n (this.shape || typeof changes.get('shape') !== 'undefined')\n ) {\n targetValues.shape = this.shape;\n }\n const passThroughSwatchActions: ((swatch: Swatch) => void)[] = [];\n if (Object.keys(targetValues).length) {\n passThroughSwatchActions.push((swatch) => {\n if (window.__swc.DEBUG) {\n if (\n 'selects' in targetValues &&\n targetValues.selects !== 'multiple' &&\n swatch.mixedValue\n ) {\n window.__swc.warn(\n this,\n `<sp-swatch> elements can only leverage the \"mixed-value\" attribute when their <sp-swatch-group> parent element is also leveraging \"selects=\"multiple\"\"`,\n 'https://opensource.adobe.com/spectrum-web-components/components/swatch-group/#multiple',\n {\n type: 'accessibility',\n }\n );\n }\n }\n if ('border' in targetValues)\n swatch.border = targetValues.border;\n if ('rounding' in targetValues)\n swatch.rounding = targetValues.rounding;\n if ('shape' in targetValues) swatch.shape = targetValues.shape;\n if ('size' in targetValues)\n swatch.size = targetValues.size as SwatchGroupSizes;\n });\n }\n return passThroughSwatchActions;\n }\n\n private getSelectionSwatchActions(\n changes: PropertyValues\n ): ((swatch: Swatch) => void)[] {\n const selectionSwatchActions: ((swatch: Swatch) => void)[] = [];\n if (!changes.has('selects')) return selectionSwatchActions;\n if (this.selects) {\n this.setAttribute(\n 'role',\n this.selects === 'single' ? 'radiogroup' : 'group'\n );\n } else {\n this.removeAttribute('role');\n }\n const swatchRoles = {\n single: 'radio',\n multiple: 'checkbox',\n };\n const swatchRole = this.selects ? swatchRoles[this.selects] : 'button';\n selectionSwatchActions.push((swatch) => {\n swatch.setAttribute('role', swatchRole);\n });\n return selectionSwatchActions;\n }\n\n protected override render(): TemplateResult {\n return html`\n <slot\n @change=${this.handleChange}\n @slotchange=${this.manageChange}\n ></slot>\n `;\n }\n\n protected override willUpdate(changes: PropertyValues<this>): void {\n const swatchActions = [\n ...this.getPassthroughSwatchActions(changes),\n ...this.getSelectionSwatchActions(changes),\n ];\n\n // Create Swatch actions that build state to be applied later.\n let nextSelected = new Set(this.selected);\n const currentValues = new Set();\n if (changes.has('selected')) {\n swatchActions.push((swatch) => {\n currentValues.add(swatch.value);\n if (\n nextSelected.has(swatch.value) ||\n (!this.hasUpdated && swatch.selected)\n ) {\n swatch.selected = true;\n } else {\n swatch.selected = false;\n }\n });\n }\n\n const doActions = (): void => {\n nextSelected = new Set(this.selected);\n\n // Do Swatch actions to each Swatch in the collection.\n this.swatches.forEach((swatch) => {\n swatchActions.forEach((action) => {\n action(swatch);\n });\n });\n\n // Apply state built in actions back to the Swatch Group\n if (changes.has('selected')) {\n this._selected = [...nextSelected.values()].filter(\n (selectedValue) => currentValues.has(selectedValue)\n );\n }\n };\n\n if (this.hasUpdated) {\n // Do actions immediately when the element has already updated.\n doActions();\n } else {\n // On first update wait for a `slotchange` event, which is not currently managed\n // by the element lifecycle before allowing Swatch actions to be commited.\n this.shadowRoot.addEventListener(\n 'slotchange',\n () => {\n requestAnimationFrame(doActions);\n },\n { once: true }\n );\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAYA;AAAA,EAGI;AAAA,EAEA;AAAA,EACA;AAAA,OAEG;AACP;AAAA,EACI;AAAA,EACA;AAAA,OACG;AACP,SAAS,gCAAgC;AACzC,SAAS,0BAA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AAA,IACL;AAEA,UAAM,YAAY,MAAY;AAC1B,qBAAe,IAAI,IAAI,KAAK,QAAQ;AAGpC,WAAK,SAAS,QAAQ,CAAC,WAAW;AAC9B,sBAAc,QAAQ,CAAC,WAAW;AAC9B,iBAAO,MAAM;AAAA,QACjB,CAAC;AAAA,MACL,CAAC;AAGD,UAAI,QAAQ,IAAI,UAAU,GAAG;AACzB,aAAK,YAAY,CAAC,GAAG,aAAa,OAAO,CAAC,EAAE;AAAA,UACxC,CAAC,kBAAkB,cAAc,IAAI,aAAa;AAAA,QACtD;AAAA,MACJ;AAAA,IACJ;AAEA,QAAI,KAAK,YAAY;AAEjB,gBAAU;AAAA,IACd,OAAO;AAGH,WAAK,WAAW;AAAA,QACZ;AAAA,QACA,MAAM;AACF,gCAAsB,SAAS;AAAA,QACnC;AAAA,QACA,EAAE,MAAM,KAAK;AAAA,MACjB;AAAA,IACJ;AAAA,EACJ;AACJ;AApSW;AAAA,EADN,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,GARlB,YASF;AAGA;AAAA,EADN,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,GAXlB,YAYF;AAGA;AAAA,EADN,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,GAdlB,YAeF;AAGI;AAAA,EADV,SAAS,EAAE,MAAM,MAAM,CAAC;AAAA,GAjBhB,YAkBE;AAiBJ;AAAA,EADN,SAAS;AAAA,GAlCD,YAmCF;AAKA;AAAA,EADN,SAAS,EAAE,SAAS,KAAK,CAAC;AAAA,GAvClB,YAwCF;AAGA;AAAA,EADN,sBAAsB,EAAE,SAAS,KAAK,CAAC;AAAA,GA1C/B,YA2CF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/SwatchGroup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var h=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var a=(n,o,t,e)=>{for(var i=e>1?void 0:e?u(o,t):o,s=n.length-1,r;s>=0;s--)(r=n[s])&&(i=(e?r(o,t,i):r(i))||i);return e&&i&&h(o,t,i),i};import{html as p,SizedMixin as f,SpectrumElement as S}from"@spectrum-web-components/base";import{property as c,queryAssignedElements as g}from"@spectrum-web-components/base/src/decorators.js";import{RovingTabindexController as w}from"@spectrum-web-components/reactive-controllers/src/RovingTabindex.js";import{MutationController as m}from"@lit-labs/observers/mutation-controller.js";import b from"./swatch-group.css.js";export class SwatchGroup extends f(S,{validSizes:["xs","s","m","l"],noDefaultSize:!0}){constructor(){super();this._selected=[];this.selectedSet=new Set;this.rovingTabindexController=new w(this,{focusInIndex:t=>{let e=-1;const i=t.findIndex((s,r)=>(!t[e]&&!s.disabled&&(e=r),s.selected&&!s.disabled));return t[i]?i:e},elements:()=>this.swatches,isFocusableElement:t=>!t.disabled});this.manageChange=async()=>{const t=new Set;this.selectedSet=new Set(this.selected),await Promise.all(this.swatches.map(e=>e.updateComplete)),this.swatches.forEach(e=>{t.add(e.value),e.selected&&this.selectedSet.add(e.value)}),this.selectedSet.forEach(e=>{t.has(e)||this.selectedSet.delete(e)}),this._selected=[...this.selectedSet],this.rovingTabindexController.clearElementCache()};new m(this,{config:{attributes:!0,childList:!0,subtree:!0},callback:()=>{this.manageChange()}})}static get styles(){return[b]}get selected(){return this._selected}set selected(t){if(t===this.selected)return;const e=this.selected;this._selected=t,this.requestUpdate("selected",e)}focus(t){this.rovingTabindexController.focus(t)}handleChange(t){t.stopPropagation();const e=this.selected;if(!this.selects){t.preventDefault();return}if(this.selects==="single"){const{target:s}=t;if(s.tabIndex=0,s.selected=!0,this.selectedSet.has(s.value))return;this.selectedSet.clear(),this.selectedSet.add(s.value),this.rovingTabindexController.elements.forEach(r=>{r!==s&&(r.selected=!1)})}else if(this.selects==="multiple"){const{target:s}=t;s.selected?this.selectedSet.add(s.value):this.selectedSet.delete(s.value)}this._selected=[...this.selectedSet],this.dispatchEvent(new Event("change",{cancelable:!0,bubbles:!0}))||(this._selected=e,t.preventDefault())}getPassthroughSwatchActions(t){const e={};t.has("selects")&&(this.selects||typeof t.get("selects")!="undefined")&&(e.selects=this.selects),t.has("border")&&(this.border||typeof t.get("border")!="undefined")&&(e.border=this.border),t.has("rounding")&&(this.rounding||typeof t.get("rounding")!="undefined")&&(e.rounding=this.rounding),t.has("size")&&(this.size!=="m"||typeof t.get("size")!="undefined")&&(e.size=this.size),t.has("shape")&&(this.shape||typeof t.get("shape")!="undefined")&&(e.shape=this.shape);const i=[];return Object.keys(e).length&&i.push(s=>{"border"in e&&(s.border=e.border),"rounding"in e&&(s.rounding=e.rounding),"shape"in e&&(s.shape=e.shape),"size"in e&&(s.size=e.size)}),i}getSelectionSwatchActions(t){const e=[];if(!t.has("selects"))return e;this.selects?this.setAttribute("role",this.selects==="single"?"radiogroup":"group"):this.removeAttribute("role");const i={single:"radio",multiple:"checkbox"},s=this.selects?i[this.selects]:"button";return e.push(r=>{r.setAttribute("role",s)}),e}render(){return p`
|
|
2
2
|
<slot
|
|
3
3
|
@change=${this.handleChange}
|
|
4
4
|
@slotchange=${this.manageChange}
|
|
5
5
|
></slot>
|
|
6
|
-
`}willUpdate(
|
|
6
|
+
`}willUpdate(t){const e=[...this.getPassthroughSwatchActions(t),...this.getSelectionSwatchActions(t)];let i=new Set(this.selected);const s=new Set;t.has("selected")&&e.push(l=>{s.add(l.value),i.has(l.value)||!this.hasUpdated&&l.selected?l.selected=!0:l.selected=!1});const r=()=>{i=new Set(this.selected),this.swatches.forEach(l=>{e.forEach(d=>{d(l)})}),t.has("selected")&&(this._selected=[...i.values()].filter(l=>s.has(l)))};this.hasUpdated?r():this.shadowRoot.addEventListener("slotchange",()=>{requestAnimationFrame(r)},{once:!0})}}a([c({reflect:!0})],SwatchGroup.prototype,"border",2),a([c({reflect:!0})],SwatchGroup.prototype,"density",2),a([c({reflect:!0})],SwatchGroup.prototype,"rounding",2),a([c({type:Array})],SwatchGroup.prototype,"selected",1),a([c()],SwatchGroup.prototype,"selects",2),a([c({reflect:!0})],SwatchGroup.prototype,"shape",2),a([g({flatten:!0})],SwatchGroup.prototype,"swatches",2);
|
|
7
7
|
//# sourceMappingURL=SwatchGroup.js.map
|
package/src/SwatchGroup.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["SwatchGroup.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n ElementSize,\n html,\n PropertyValues,\n SizedMixin,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\nimport { RovingTabindexController } from '@spectrum-web-components/reactive-controllers/src/RovingTabindex.js';\nimport { MutationController } from '@lit-labs/observers/mutation-controller.js';\n\nimport styles from './swatch-group.css.js';\nimport type {\n Swatch,\n SwatchBorder,\n SwatchRounding,\n SwatchShape,\n} from './Swatch.js';\n\nexport type SwatchGroupSizes = Exclude<ElementSize, 'xxs' | 'xl' | 'xxl'>;\nexport type SwatchSelects = 'single' | 'multiple' | undefined;\n\n/**\n * @element sp-swatch-group\n *\n * @slot - Swatch elements to manage as a group\n */\nexport class SwatchGroup extends SizedMixin(SpectrumElement, {\n validSizes: ['xs', 's', 'm', 'l'],\n noDefaultSize: true,\n}) {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ reflect: true })\n public border: SwatchBorder;\n\n @property({ reflect: true })\n public rounding: SwatchRounding;\n\n @property({ type: Array })\n public selected: string[] = [];\n\n @property()\n public selects: SwatchSelects;\n\n private selectedSet = new Set<string>();\n\n @property({ reflect: true })\n public shape: SwatchShape;\n\n @property({ reflect: true })\n public density: 'compact' | 'spacious' | undefined;\n\n constructor() {\n super();\n\n new MutationController(this, {\n config: {\n attributes: true,\n childList: true,\n subtree: true,\n },\n callback: () => {\n this.manageChange();\n },\n });\n }\n\n rovingTabindexController = new RovingTabindexController<Swatch>(this, {\n focusInIndex: (elements: Swatch[]) => {\n let firstEnabledIndex = -1;\n const firstSelectedIndex = elements.findIndex((el, index) => {\n if (!elements[firstEnabledIndex] && !el.disabled) {\n firstEnabledIndex = index;\n }\n return el.selected && !el.disabled;\n });\n return elements[firstSelectedIndex]\n ? firstSelectedIndex\n : firstEnabledIndex;\n },\n elements: () => [...this.children] as Swatch[],\n isFocusableElement: (el: Swatch) => !el.disabled,\n });\n\n public override focus(options?: FocusOptions): void {\n this.rovingTabindexController.focus(options);\n }\n\n protected handleChange(event: Event & { target: Swatch }): void {\n event.stopPropagation();\n const oldSelected = this.selected;\n if (!this.selects) {\n event.preventDefault();\n return;\n }\n if (this.selects === 'single') {\n const { target } = event;\n target.tabIndex = 0;\n target.selected = true;\n if (this.selectedSet.has(target.value)) {\n return;\n }\n this.selectedSet.clear();\n this.selectedSet.add(target.value);\n this.rovingTabindexController.elements.forEach((child) => {\n if (child === target) return;\n child.selected = false;\n });\n } else if (this.selects === 'multiple') {\n const { target } = event;\n if (target.selected) {\n this.selectedSet.add(target.value);\n } else {\n this.selectedSet.delete(target.value);\n }\n }\n this.selected = [...this.selectedSet];\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n cancelable: true,\n bubbles: true,\n })\n );\n if (!applyDefault) {\n this.selected = oldSelected;\n event.preventDefault();\n }\n }\n\n private manageChange = (): void => {\n const presentSet = new Set();\n this.selectedSet = new Set(this.selected);\n const swatches = [...this.children] as Swatch[];\n swatches.forEach((swatch) => {\n presentSet.add(swatch.value);\n if (swatch.selected) {\n this.selectedSet.add(swatch.value);\n }\n });\n this.selectedSet.forEach((value) => {\n if (!presentSet.has(value)) {\n this.selectedSet.delete(value);\n }\n });\n this.selected = [...this.selectedSet];\n };\n\n private getPassthroughSwatchActions(\n changes: PropertyValues\n ): ((swatch: Swatch) => void)[] {\n const targetValues: {\n border?: SwatchBorder;\n rounding?: SwatchRounding;\n shape?: SwatchShape;\n size?: SwatchGroupSizes;\n selects?: SwatchSelects;\n } = {};\n if (\n changes.has('selects') &&\n (this.selects || typeof changes.get('selects') !== 'undefined')\n ) {\n targetValues.selects = this.selects;\n }\n if (\n changes.has('border') &&\n (this.border || typeof changes.get('border') !== 'undefined')\n ) {\n targetValues.border = this.border;\n }\n if (\n changes.has('rounding') &&\n (this.rounding || typeof changes.get('rounding') !== 'undefined')\n ) {\n targetValues.rounding = this.rounding;\n }\n if (\n changes.has('size') &&\n (this.size !== 'm' || typeof changes.get('size') !== 'undefined')\n ) {\n targetValues.size = this.size as SwatchGroupSizes;\n }\n if (\n changes.has('shape') &&\n (this.shape || typeof changes.get('shape') !== 'undefined')\n ) {\n targetValues.shape = this.shape;\n }\n const passThroughSwatchActions: ((swatch: Swatch) => void)[] = [];\n if (Object.keys(targetValues).length) {\n passThroughSwatchActions.push((swatch) => {\n if (window.__swc.DEBUG) {\n if (\n 'selects' in targetValues &&\n targetValues.selects !== 'multiple' &&\n swatch.mixedValue\n ) {\n window.__swc.warn(\n this,\n `<sp-swatch> elements can only leverage the \"mixed-value\" attribute when their <sp-swatch-group> parent element is also leveraging \"selects=\"multiple\"\"`,\n 'https://opensource.adobe.com/spectrum-web-components/components/swatch-group/#multiple',\n {\n type: 'accessibility',\n }\n );\n }\n }\n if ('border' in targetValues)\n swatch.border = targetValues.border;\n if ('rounding' in targetValues)\n swatch.rounding = targetValues.rounding;\n if ('shape' in targetValues) swatch.shape = targetValues.shape;\n if ('size' in targetValues)\n swatch.size = targetValues.size as SwatchGroupSizes;\n });\n }\n return passThroughSwatchActions;\n }\n\n private getSelectionSwatchActions(\n changes: PropertyValues\n ): ((swatch: Swatch) => void)[] {\n const selectionSwatchActions: ((swatch: Swatch) => void)[] = [];\n if (!changes.has('selects')) return selectionSwatchActions;\n if (this.selects) {\n this.setAttribute(\n 'role',\n this.selects === 'single' ? 'radiogroup' : 'group'\n );\n } else {\n this.removeAttribute('role');\n }\n const swatchRoles = {\n single: 'radio',\n multiple: 'checkbox',\n };\n const swatchRole = this.selects ? swatchRoles[this.selects] : 'button';\n selectionSwatchActions.push((swatch) => {\n swatch.setAttribute('role', swatchRole);\n });\n return selectionSwatchActions;\n }\n\n protected override render(): TemplateResult {\n return html`\n <slot\n @change=${this.handleChange}\n @slotchange=${this.manageChange}\n ></slot>\n `;\n }\n\n protected override willUpdate(changes: PropertyValues<this>): void {\n const swatchActions = [\n ...this.getPassthroughSwatchActions(changes),\n ...this.getSelectionSwatchActions(changes),\n ];\n\n // Create Swatch actions that build state to be applied later.\n const nextSelected = new Set(this.selected);\n const currentValues = new Set();\n if (changes.has('selected')) {\n swatchActions.push((swatch) => {\n currentValues.add(swatch.value);\n if (\n nextSelected.has(swatch.value) ||\n (!this.hasUpdated && swatch.selected)\n ) {\n swatch.selected = true;\n } else {\n swatch.selected = false;\n }\n });\n }\n\n // Do Swatch actions to each Swach in the collection.\n this.rovingTabindexController.elements.forEach((swatch) => {\n swatchActions.forEach((action) => {\n action(swatch);\n });\n });\n\n // Apply state built in actions back to the Swatch Group\n if (changes.has('selected')) {\n this.selected = [...nextSelected].filter((selectedValue) =>\n currentValues.has(selectedValue)\n );\n this.rovingTabindexController.clearElementCache();\n }\n }\n}\n"],
|
|
5
|
-
"mappings": "qNAYA,OAGI,QAAAA,EAEA,cAAAC,EACA,mBAAAC,MAEG,gCACP,
|
|
6
|
-
"names": ["html", "SizedMixin", "SpectrumElement", "property", "RovingTabindexController", "MutationController", "styles", "elements", "firstEnabledIndex", "firstSelectedIndex", "el", "index", "presentSet", "swatch", "value", "
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n CSSResultArray,\n ElementSize,\n html,\n PropertyValues,\n SizedMixin,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n property,\n queryAssignedElements,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { RovingTabindexController } from '@spectrum-web-components/reactive-controllers/src/RovingTabindex.js';\nimport { MutationController } from '@lit-labs/observers/mutation-controller.js';\n\nimport styles from './swatch-group.css.js';\nimport type {\n Swatch,\n SwatchBorder,\n SwatchRounding,\n SwatchShape,\n} from './Swatch.js';\n\nexport type SwatchGroupSizes = Exclude<ElementSize, 'xxs' | 'xl' | 'xxl'>;\nexport type SwatchSelects = 'single' | 'multiple' | undefined;\n\n/**\n * @element sp-swatch-group\n *\n * @slot - Swatch elements to manage as a group\n */\nexport class SwatchGroup extends SizedMixin(SpectrumElement, {\n validSizes: ['xs', 's', 'm', 'l'],\n noDefaultSize: true,\n}) {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ reflect: true })\n public border: SwatchBorder;\n\n @property({ reflect: true })\n public density: 'compact' | 'spacious' | undefined;\n\n @property({ reflect: true })\n public rounding: SwatchRounding;\n\n @property({ type: Array })\n public get selected(): string[] {\n return this._selected;\n }\n\n public set selected(selected: string[]) {\n if (selected === this.selected) return;\n\n const oldSelected = this.selected;\n this._selected = selected;\n this.requestUpdate('selected', oldSelected);\n }\n\n // Specifically surface `_selected` internally so that change can be made to this value internally\n // without triggering the update lifecycle directly.\n private _selected: string[] = [];\n\n @property()\n public selects: SwatchSelects;\n\n private selectedSet = new Set<string>();\n\n @property({ reflect: true })\n public shape: SwatchShape;\n\n @queryAssignedElements({ flatten: true })\n public swatches!: Swatch[];\n\n constructor() {\n super();\n\n new MutationController(this, {\n config: {\n attributes: true,\n childList: true,\n subtree: true,\n },\n callback: () => {\n this.manageChange();\n },\n });\n }\n\n rovingTabindexController = new RovingTabindexController<Swatch>(this, {\n focusInIndex: (elements: Swatch[]) => {\n let firstEnabledIndex = -1;\n const firstSelectedIndex = elements.findIndex((el, index) => {\n if (!elements[firstEnabledIndex] && !el.disabled) {\n firstEnabledIndex = index;\n }\n return el.selected && !el.disabled;\n });\n return elements[firstSelectedIndex]\n ? firstSelectedIndex\n : firstEnabledIndex;\n },\n elements: () => this.swatches,\n isFocusableElement: (el: Swatch) => !el.disabled,\n });\n\n public override focus(options?: FocusOptions): void {\n this.rovingTabindexController.focus(options);\n }\n\n protected handleChange(event: Event & { target: Swatch }): void {\n event.stopPropagation();\n const oldSelected = this.selected;\n if (!this.selects) {\n event.preventDefault();\n return;\n }\n if (this.selects === 'single') {\n const { target } = event;\n target.tabIndex = 0;\n target.selected = true;\n if (this.selectedSet.has(target.value)) {\n return;\n }\n this.selectedSet.clear();\n this.selectedSet.add(target.value);\n this.rovingTabindexController.elements.forEach((child) => {\n if (child === target) return;\n child.selected = false;\n });\n } else if (this.selects === 'multiple') {\n const { target } = event;\n if (target.selected) {\n this.selectedSet.add(target.value);\n } else {\n this.selectedSet.delete(target.value);\n }\n }\n this._selected = [...this.selectedSet];\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n cancelable: true,\n bubbles: true,\n })\n );\n if (!applyDefault) {\n this._selected = oldSelected;\n event.preventDefault();\n }\n }\n\n private manageChange = async (): Promise<void> => {\n const presentSet = new Set();\n this.selectedSet = new Set(this.selected);\n await Promise.all(this.swatches.map((swatch) => swatch.updateComplete));\n this.swatches.forEach((swatch) => {\n presentSet.add(swatch.value);\n if (swatch.selected) {\n this.selectedSet.add(swatch.value);\n }\n });\n this.selectedSet.forEach((value) => {\n if (!presentSet.has(value)) {\n this.selectedSet.delete(value);\n }\n });\n this._selected = [...this.selectedSet];\n this.rovingTabindexController.clearElementCache();\n };\n\n private getPassthroughSwatchActions(\n changes: PropertyValues\n ): ((swatch: Swatch) => void)[] {\n const targetValues: {\n border?: SwatchBorder;\n rounding?: SwatchRounding;\n shape?: SwatchShape;\n size?: SwatchGroupSizes;\n selects?: SwatchSelects;\n } = {};\n if (\n changes.has('selects') &&\n (this.selects || typeof changes.get('selects') !== 'undefined')\n ) {\n targetValues.selects = this.selects;\n }\n if (\n changes.has('border') &&\n (this.border || typeof changes.get('border') !== 'undefined')\n ) {\n targetValues.border = this.border;\n }\n if (\n changes.has('rounding') &&\n (this.rounding || typeof changes.get('rounding') !== 'undefined')\n ) {\n targetValues.rounding = this.rounding;\n }\n if (\n changes.has('size') &&\n (this.size !== 'm' || typeof changes.get('size') !== 'undefined')\n ) {\n targetValues.size = this.size as SwatchGroupSizes;\n }\n if (\n changes.has('shape') &&\n (this.shape || typeof changes.get('shape') !== 'undefined')\n ) {\n targetValues.shape = this.shape;\n }\n const passThroughSwatchActions: ((swatch: Swatch) => void)[] = [];\n if (Object.keys(targetValues).length) {\n passThroughSwatchActions.push((swatch) => {\n if (window.__swc.DEBUG) {\n if (\n 'selects' in targetValues &&\n targetValues.selects !== 'multiple' &&\n swatch.mixedValue\n ) {\n window.__swc.warn(\n this,\n `<sp-swatch> elements can only leverage the \"mixed-value\" attribute when their <sp-swatch-group> parent element is also leveraging \"selects=\"multiple\"\"`,\n 'https://opensource.adobe.com/spectrum-web-components/components/swatch-group/#multiple',\n {\n type: 'accessibility',\n }\n );\n }\n }\n if ('border' in targetValues)\n swatch.border = targetValues.border;\n if ('rounding' in targetValues)\n swatch.rounding = targetValues.rounding;\n if ('shape' in targetValues) swatch.shape = targetValues.shape;\n if ('size' in targetValues)\n swatch.size = targetValues.size as SwatchGroupSizes;\n });\n }\n return passThroughSwatchActions;\n }\n\n private getSelectionSwatchActions(\n changes: PropertyValues\n ): ((swatch: Swatch) => void)[] {\n const selectionSwatchActions: ((swatch: Swatch) => void)[] = [];\n if (!changes.has('selects')) return selectionSwatchActions;\n if (this.selects) {\n this.setAttribute(\n 'role',\n this.selects === 'single' ? 'radiogroup' : 'group'\n );\n } else {\n this.removeAttribute('role');\n }\n const swatchRoles = {\n single: 'radio',\n multiple: 'checkbox',\n };\n const swatchRole = this.selects ? swatchRoles[this.selects] : 'button';\n selectionSwatchActions.push((swatch) => {\n swatch.setAttribute('role', swatchRole);\n });\n return selectionSwatchActions;\n }\n\n protected override render(): TemplateResult {\n return html`\n <slot\n @change=${this.handleChange}\n @slotchange=${this.manageChange}\n ></slot>\n `;\n }\n\n protected override willUpdate(changes: PropertyValues<this>): void {\n const swatchActions = [\n ...this.getPassthroughSwatchActions(changes),\n ...this.getSelectionSwatchActions(changes),\n ];\n\n // Create Swatch actions that build state to be applied later.\n let nextSelected = new Set(this.selected);\n const currentValues = new Set();\n if (changes.has('selected')) {\n swatchActions.push((swatch) => {\n currentValues.add(swatch.value);\n if (\n nextSelected.has(swatch.value) ||\n (!this.hasUpdated && swatch.selected)\n ) {\n swatch.selected = true;\n } else {\n swatch.selected = false;\n }\n });\n }\n\n const doActions = (): void => {\n nextSelected = new Set(this.selected);\n\n // Do Swatch actions to each Swatch in the collection.\n this.swatches.forEach((swatch) => {\n swatchActions.forEach((action) => {\n action(swatch);\n });\n });\n\n // Apply state built in actions back to the Swatch Group\n if (changes.has('selected')) {\n this._selected = [...nextSelected.values()].filter(\n (selectedValue) => currentValues.has(selectedValue)\n );\n }\n };\n\n if (this.hasUpdated) {\n // Do actions immediately when the element has already updated.\n doActions();\n } else {\n // On first update wait for a `slotchange` event, which is not currently managed\n // by the element lifecycle before allowing Swatch actions to be commited.\n this.shadowRoot.addEventListener(\n 'slotchange',\n () => {\n requestAnimationFrame(doActions);\n },\n { once: true }\n );\n }\n }\n}\n"],
|
|
5
|
+
"mappings": "qNAYA,OAGI,QAAAA,EAEA,cAAAC,EACA,mBAAAC,MAEG,gCAC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["html", "SizedMixin", "SpectrumElement", "property", "queryAssignedElements", "RovingTabindexController", "MutationController", "styles", "elements", "firstEnabledIndex", "firstSelectedIndex", "el", "index", "presentSet", "swatch", "value", "selected", "oldSelected", "options", "event", "target", "child", "changes", "targetValues", "passThroughSwatchActions", "selectionSwatchActions", "swatchRoles", "swatchRole", "swatchActions", "nextSelected", "currentValues", "doActions", "action", "selectedValue", "__decorateClass"]
|
|
7
7
|
}
|
|
@@ -91,19 +91,19 @@ export default {
|
|
|
91
91
|
]
|
|
92
92
|
};
|
|
93
93
|
const colors = [
|
|
94
|
-
"--spectrum-
|
|
95
|
-
"--spectrum-
|
|
96
|
-
"--spectrum-
|
|
97
|
-
"--spectrum-
|
|
98
|
-
"--spectrum-
|
|
99
|
-
"--spectrum-
|
|
100
|
-
"--spectrum-
|
|
101
|
-
"--spectrum-
|
|
102
|
-
"--spectrum-
|
|
103
|
-
"--spectrum-
|
|
104
|
-
"--spectrum-
|
|
105
|
-
"--spectrum-
|
|
106
|
-
"--spectrum-
|
|
94
|
+
"--spectrum-gray-700",
|
|
95
|
+
"--spectrum-red-700",
|
|
96
|
+
"--spectrum-orange-700",
|
|
97
|
+
"--spectrum-yellow-700",
|
|
98
|
+
"--spectrum-chartreuse-700",
|
|
99
|
+
"--spectrum-celery-700",
|
|
100
|
+
"--spectrum-green-700",
|
|
101
|
+
"--spectrum-seafoam-700",
|
|
102
|
+
"--spectrum-blue-700",
|
|
103
|
+
"--spectrum-indigo-700",
|
|
104
|
+
"--spectrum-purple-700",
|
|
105
|
+
"--spectrum-fuchsia-700",
|
|
106
|
+
"--spectrum-magenta-700"
|
|
107
107
|
];
|
|
108
108
|
const template = ({
|
|
109
109
|
border,
|
|
@@ -149,16 +149,16 @@ densitySpacious.args = {
|
|
|
149
149
|
export const selectsSingle = (args) => template(args);
|
|
150
150
|
selectsSingle.args = {
|
|
151
151
|
selects: "single",
|
|
152
|
-
selected: ["--spectrum-
|
|
152
|
+
selected: ["--spectrum-yellow-500"]
|
|
153
153
|
};
|
|
154
154
|
export const selectsMultiple = (args) => template(args);
|
|
155
155
|
selectsMultiple.args = {
|
|
156
156
|
selects: "multiple",
|
|
157
157
|
selected: [
|
|
158
|
-
"--spectrum-
|
|
159
|
-
"--spectrum-
|
|
160
|
-
"--spectrum-
|
|
161
|
-
"--spectrum-
|
|
158
|
+
"--spectrum-celery-500",
|
|
159
|
+
"--spectrum-red-500",
|
|
160
|
+
"--spectrum-purple-500",
|
|
161
|
+
"--spectrum-blue-500"
|
|
162
162
|
]
|
|
163
163
|
};
|
|
164
164
|
export const borderLight = (args) => template(args);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["swatch-group.stories.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { html, TemplateResult } from '@spectrum-web-components/base';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\n\nimport '@spectrum-web-components/swatch/sp-swatch-group.js';\nimport '@spectrum-web-components/swatch/sp-swatch.js';\nimport type {\n SwatchBorder,\n SwatchRounding,\n SwatchShape,\n} from '../src/Swatch.js';\nimport { SwatchGroup } from '../src/SwatchGroup.js';\n\ntype Properties = {\n border: SwatchBorder | 'normal';\n density?: 'normal' | 'spacious' | 'compact';\n rounding?: SwatchRounding | 'normal';\n selected?: string[];\n selects?: 'none' | 'single' | 'multiple';\n shape?: SwatchShape | 'normal';\n};\n\nexport default {\n title: 'Swatch group',\n component: 'sp-swatch-group',\n args: {},\n argTypes: {\n border: {\n name: 'border',\n type: { name: 'string', required: false },\n description: 'The border to apply to the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'light', 'none'],\n },\n },\n density: {\n name: 'density',\n type: { name: 'string', required: false },\n description: 'The density at which to display the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'compact', 'spacious'],\n },\n },\n rounding: {\n name: 'rounding',\n type: { name: 'string', required: false },\n description: 'The rounding to apply to the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'none', 'full'],\n },\n },\n selects: {\n name: 'selects',\n type: { name: 'string', required: false },\n description:\n 'Whether the Swatch Group manages a selection, and whether it is a sinlge or multiple selection.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['none', 'single', 'multiple'],\n },\n },\n shape: {\n name: 'shape',\n type: { name: 'string', required: false },\n description: 'The shape to apply to the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'rectangle'],\n },\n },\n },\n decorators: [\n (\n story: () => TemplateResult,\n {\n args: { selected = [] },\n }: {\n args: {\n selected: string[];\n };\n }\n ): TemplateResult => html`\n <div\n @change=${async (event: Event & { target: SwatchGroup }) => {\n await 0;\n if (event.defaultPrevented) return;\n const next = event.target\n .nextElementSibling as HTMLDivElement;\n next.textContent = `Selected: ${JSON.stringify(\n event.target.selected\n )}`;\n }}\n >\n ${story()}\n <div>Selected: ${JSON.stringify(selected)}</div>\n </div>\n `,\n ],\n};\n\nconst colors = [\n '--spectrum-
|
|
5
|
-
"mappings": ";AAWA,SAAS,YAA4B;AACrC,SAAS,iBAAiB;AAE1B,OAAO;AACP,OAAO;AAiBP,eAAe;AAAA,EACX,OAAO;AAAA,EACP,WAAW;AAAA,EACX,MAAM,CAAC;AAAA,EACP,UAAU;AAAA,IACN,QAAQ;AAAA,MACJ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GzB,CAAC;AAAA;AAAA;AAGb;AAEO,aAAM,UAAU,CAAC,SAAqC,SAAS,IAAI;AAC1E,QAAQ,OAAO,CAAC;AACT,aAAM,iBAAiB,CAAC,SAC3B,SAAS,IAAI;AACjB,eAAe,OAAO;AAAA,EAClB,SAAS;AACb;AACO,aAAM,kBAAkB,CAAC,SAC5B,SAAS,IAAI;AACjB,gBAAgB,OAAO;AAAA,EACnB,SAAS;AACb;AACO,aAAM,gBAAgB,CAAC,SAC1B,SAAS,IAAI;AACjB,cAAc,OAAO;AAAA,EACjB,SAAS;AAAA,EACT,UAAU,CAAC,
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { html, TemplateResult } from '@spectrum-web-components/base';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\n\nimport '@spectrum-web-components/swatch/sp-swatch-group.js';\nimport '@spectrum-web-components/swatch/sp-swatch.js';\nimport type {\n SwatchBorder,\n SwatchRounding,\n SwatchShape,\n} from '../src/Swatch.js';\nimport { SwatchGroup } from '../src/SwatchGroup.js';\n\ntype Properties = {\n border: SwatchBorder | 'normal';\n density?: 'normal' | 'spacious' | 'compact';\n rounding?: SwatchRounding | 'normal';\n selected?: string[];\n selects?: 'none' | 'single' | 'multiple';\n shape?: SwatchShape | 'normal';\n};\n\nexport default {\n title: 'Swatch group',\n component: 'sp-swatch-group',\n args: {},\n argTypes: {\n border: {\n name: 'border',\n type: { name: 'string', required: false },\n description: 'The border to apply to the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'light', 'none'],\n },\n },\n density: {\n name: 'density',\n type: { name: 'string', required: false },\n description: 'The density at which to display the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'compact', 'spacious'],\n },\n },\n rounding: {\n name: 'rounding',\n type: { name: 'string', required: false },\n description: 'The rounding to apply to the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'none', 'full'],\n },\n },\n selects: {\n name: 'selects',\n type: { name: 'string', required: false },\n description:\n 'Whether the Swatch Group manages a selection, and whether it is a sinlge or multiple selection.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['none', 'single', 'multiple'],\n },\n },\n shape: {\n name: 'shape',\n type: { name: 'string', required: false },\n description: 'The shape to apply to the Swatch children.',\n table: {\n defaultValue: { summary: '' },\n },\n control: {\n type: 'inline-radio',\n options: ['normal', 'rectangle'],\n },\n },\n },\n decorators: [\n (\n story: () => TemplateResult,\n {\n args: { selected = [] },\n }: {\n args: {\n selected: string[];\n };\n }\n ): TemplateResult => html`\n <div\n @change=${async (event: Event & { target: SwatchGroup }) => {\n await 0;\n if (event.defaultPrevented) return;\n const next = event.target\n .nextElementSibling as HTMLDivElement;\n next.textContent = `Selected: ${JSON.stringify(\n event.target.selected\n )}`;\n }}\n >\n ${story()}\n <div>Selected: ${JSON.stringify(selected)}</div>\n </div>\n `,\n ],\n};\n\nconst colors = [\n '--spectrum-gray-700',\n '--spectrum-red-700',\n '--spectrum-orange-700',\n '--spectrum-yellow-700',\n '--spectrum-chartreuse-700',\n '--spectrum-celery-700',\n '--spectrum-green-700',\n '--spectrum-seafoam-700',\n '--spectrum-blue-700',\n '--spectrum-indigo-700',\n '--spectrum-purple-700',\n '--spectrum-fuchsia-700',\n '--spectrum-magenta-700',\n];\n\nconst template = ({\n border,\n density,\n rounding,\n selects,\n selected = [],\n shape,\n}: Properties): TemplateResult => {\n const groupLabel = !!selects\n ? selects === 'single'\n ? 'Select a color'\n : 'Selects color(s)'\n : undefined;\n return html`\n <sp-swatch-group\n border=${ifDefined(border === 'normal' ? undefined : border)}\n density=${ifDefined(density === 'normal' ? undefined : density)}\n rounding=${ifDefined(rounding === 'normal' ? undefined : rounding)}\n selects=${ifDefined(selects === 'none' ? undefined : selects)}\n .selected=${selected}\n shape=${ifDefined(shape === 'normal' ? undefined : shape)}\n aria-label=${ifDefined(groupLabel)}\n >\n ${colors.map(\n (color) => html`\n <sp-swatch\n color=\"var(${color})\"\n label=${color}\n value=${color}\n ></sp-swatch>\n `\n )}\n </sp-swatch-group>\n `;\n};\n\nexport const Default = (args: Properties): TemplateResult => template(args);\nDefault.args = {} as Properties;\nexport const densityCompact = (args: Properties): TemplateResult =>\n template(args);\ndensityCompact.args = {\n density: 'compact',\n} as Properties;\nexport const densitySpacious = (args: Properties): TemplateResult =>\n template(args);\ndensitySpacious.args = {\n density: 'spacious',\n} as Properties;\nexport const selectsSingle = (args: Properties): TemplateResult =>\n template(args);\nselectsSingle.args = {\n selects: 'single',\n selected: ['--spectrum-yellow-500'],\n} as Properties;\nexport const selectsMultiple = (args: Properties): TemplateResult =>\n template(args);\nselectsMultiple.args = {\n selects: 'multiple',\n selected: [\n '--spectrum-celery-500',\n '--spectrum-red-500',\n '--spectrum-purple-500',\n '--spectrum-blue-500',\n ],\n} as Properties;\nexport const borderLight = (args: Properties): TemplateResult => template(args);\nborderLight.args = {\n border: 'light',\n} as Properties;\nexport const borderNone = (args: Properties): TemplateResult => template(args);\nborderNone.args = {\n border: 'none',\n} as Properties;\nexport const roundingNone = (args: Properties): TemplateResult =>\n template(args);\nroundingNone.args = {\n rounding: 'none',\n} as Properties;\nexport const roundingFull = (args: Properties): TemplateResult =>\n template(args);\nroundingFull.args = {\n rounding: 'full',\n} as Properties;\nexport const shapeRectangle = (args: Properties): TemplateResult =>\n template(args);\nshapeRectangle.args = {\n shape: 'rectangle',\n} as Properties;\n"],
|
|
5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Group", () => {
|
|
|
204
204
|
el.selected = [selectedChild.value];
|
|
205
205
|
await elementUpdated(el);
|
|
206
206
|
await nextFrame();
|
|
207
|
+
await nextFrame();
|
|
207
208
|
expect(selectedChild.selected).to.be.true;
|
|
208
209
|
expect(document.activeElement === selectedChild).to.be.false;
|
|
209
210
|
await sendKeys({
|
|
@@ -260,6 +261,8 @@ describe("Swatch Group - DOM selected", () => {
|
|
|
260
261
|
`
|
|
261
262
|
);
|
|
262
263
|
await elementUpdated(el);
|
|
264
|
+
await nextFrame();
|
|
265
|
+
await nextFrame();
|
|
263
266
|
expect(consoleWarnStub.called).to.be.true;
|
|
264
267
|
const spyCall = consoleWarnStub.getCall(0);
|
|
265
268
|
expect(
|
|
@@ -289,7 +292,7 @@ describe("Swatch Group - DOM selected", () => {
|
|
|
289
292
|
await elementUpdated(el);
|
|
290
293
|
expect(el.selected).to.deep.equal(["color-1", "color-3"]);
|
|
291
294
|
});
|
|
292
|
-
it("merges `selected` and selection from DOM", async ()
|
|
295
|
+
it("merges `selected` and selection from DOM", async function() {
|
|
293
296
|
const el = await fixture(html`
|
|
294
297
|
<sp-swatch-group selects="multiple" .selected=${["color-1"]}>
|
|
295
298
|
<sp-swatch value="color-0" color="red"></sp-swatch>
|
|
@@ -299,9 +302,11 @@ describe("Swatch Group - DOM selected", () => {
|
|
|
299
302
|
</sp-swatch-group>
|
|
300
303
|
`);
|
|
301
304
|
await elementUpdated(el);
|
|
305
|
+
await nextFrame();
|
|
306
|
+
await nextFrame();
|
|
302
307
|
expect(el.selected).to.deep.equal(["color-1", "color-3"]);
|
|
303
308
|
});
|
|
304
|
-
it("lazily accepts selection from DOM", async ()
|
|
309
|
+
it("lazily accepts selection from DOM", async function() {
|
|
305
310
|
const el = await fixture(html`
|
|
306
311
|
<sp-swatch-group selects="multiple">
|
|
307
312
|
<sp-swatch value="color-0" color="red"></sp-swatch>
|
|
@@ -311,10 +316,14 @@ describe("Swatch Group - DOM selected", () => {
|
|
|
311
316
|
</sp-swatch-group>
|
|
312
317
|
`);
|
|
313
318
|
await elementUpdated(el);
|
|
319
|
+
await nextFrame();
|
|
320
|
+
await nextFrame();
|
|
314
321
|
const color1 = el.querySelector('[value="color-1"]');
|
|
315
322
|
expect(el.selected).to.deep.equal(["color-3"]);
|
|
316
323
|
color1.selected = true;
|
|
317
324
|
await elementUpdated(el);
|
|
325
|
+
await nextFrame();
|
|
326
|
+
await nextFrame();
|
|
318
327
|
expect(el.selected).to.deep.equal(["color-3", "color-1"]);
|
|
319
328
|
});
|
|
320
329
|
it("clears previously selected children when updating `selected`", async () => {
|
|
@@ -332,4 +341,37 @@ describe("Swatch Group - DOM selected", () => {
|
|
|
332
341
|
expect(el.selected).to.deep.equal(["color-2"]);
|
|
333
342
|
});
|
|
334
343
|
});
|
|
344
|
+
describe("Swatch Group - slotted", () => {
|
|
345
|
+
it('manages [selects="single"] selection through multiple slots', async () => {
|
|
346
|
+
const test = await fixture(
|
|
347
|
+
html`
|
|
348
|
+
<div>
|
|
349
|
+
<sp-swatch value="First">First</sp-swatch>
|
|
350
|
+
<sp-swatch value="Second">Second</sp-swatch>
|
|
351
|
+
<sp-swatch value="Third" selected>Third</sp-swatch>
|
|
352
|
+
</div>
|
|
353
|
+
`
|
|
354
|
+
);
|
|
355
|
+
const firstItem = test.querySelector("sp-swatch");
|
|
356
|
+
const thirdItem = test.querySelector("sp-swatch[selected]");
|
|
357
|
+
const shadowRoot = test.attachShadow({ mode: "open" });
|
|
358
|
+
shadowRoot.innerHTML = `
|
|
359
|
+
<sp-swatch-group label="Selects Single Group" selects="single">
|
|
360
|
+
<slot></slot>
|
|
361
|
+
</sp-swatch-group>
|
|
362
|
+
`;
|
|
363
|
+
const el = shadowRoot.querySelector("sp-swatch-group");
|
|
364
|
+
await elementUpdated(el);
|
|
365
|
+
await nextFrame();
|
|
366
|
+
await nextFrame();
|
|
367
|
+
expect(el.selected, '"Third" selected').to.deep.equal(["Third"]);
|
|
368
|
+
expect(firstItem.selected).to.be.false;
|
|
369
|
+
expect(thirdItem.selected).to.be.true;
|
|
370
|
+
firstItem.click();
|
|
371
|
+
await elementUpdated(el);
|
|
372
|
+
expect(el.selected, '"First" selected').to.deep.equal(["First"]);
|
|
373
|
+
expect(firstItem.selected).to.be.true;
|
|
374
|
+
expect(thirdItem.selected).to.be.false;
|
|
375
|
+
});
|
|
376
|
+
});
|
|
335
377
|
//# sourceMappingURL=swatch-group.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["swatch-group.test.ts"],
|
|
4
|
-
"sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { elementUpdated, expect, fixture, nextFrame } from '@open-wc/testing';\nimport { sendKeys } from '@web/test-runner-commands';\n\nimport '@spectrum-web-components/swatch/sp-swatch.js';\nimport { Swatch, SwatchGroup } from '../';\nimport { Default } from '../stories/swatch-group.stories.js';\nimport { spy, stub } from 'sinon';\nimport { html } from '@spectrum-web-components/base';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\n\ndescribe('Swatch Group', () => {\n let el: SwatchGroup;\n beforeEach(async () => {\n el = await fixture<SwatchGroup>(Default(Default.args));\n\n await elementUpdated(el);\n });\n testForLitDevWarnings(\n async () => await fixture<SwatchGroup>(Default(Default.args))\n );\n it('loads default swatch accessibly', async () => {\n await expect(el).to.be.accessible();\n });\n it('forwards `border` to children', async () => {\n el.border = 'light';\n await elementUpdated(el);\n\n ([...el.children] as Swatch[]).forEach((child) => {\n expect(child.border).to.equal('light');\n });\n });\n it('forwards `rounding` to children', async () => {\n el.rounding = 'full';\n await elementUpdated(el);\n\n ([...el.children] as Swatch[]).forEach((child) => {\n expect(child.rounding).to.equal('full');\n });\n });\n it('forwards `size` to children', async () => {\n el.size = 'xs';\n await elementUpdated(el);\n\n ([...el.children] as Swatch[]).forEach((child) => {\n expect(child.size).to.equal('xs');\n });\n });\n it('forwards `shape` to children', async () => {\n el.shape = 'rectangle';\n await elementUpdated(el);\n\n ([...el.children] as Swatch[]).forEach((child) => {\n expect(child.shape).to.equal('rectangle');\n });\n });\n it('unsets forwarding', async () => {\n el.border = 'light';\n el.rounding = 'full';\n el.size = 'xs';\n el.shape = 'rectangle';\n await elementUpdated(el);\n\n ([...el.children] as Swatch[]).forEach((child) => {\n expect(child.border).to.not.be.undefined;\n expect(child.rounding).to.not.be.undefined;\n expect(child.size).to.not.equal('m');\n expect(child.shape).to.not.be.undefined;\n });\n\n el.border = undefined;\n el.rounding = undefined;\n el.removeAttribute('size');\n el.shape = undefined;\n await elementUpdated(el);\n\n ([...el.children] as Swatch[]).forEach((child) => {\n expect(child.border).to.equal(undefined);\n expect(child.rounding).to.equal(undefined);\n expect(child.size).to.equal('m');\n expect(child.shape).to.equal(undefined);\n });\n });\n it('does not dispatch `change` events without `selects` attribute', async () => {\n const selectedChild = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n\n const changeSpy = spy();\n\n el.addEventListener('change', () => changeSpy());\n\n expect(el.selected).to.deep.equal([]);\n\n selectedChild.click();\n\n expect(changeSpy.called).to.be.false;\n expect(el.selected).to.deep.equal([]);\n });\n it('dispatches `change` events as [selects=\"single\"]', async () => {\n el.selects = 'single';\n const selectedChild = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n\n const changeSpy = spy();\n\n el.addEventListener('change', () => changeSpy());\n\n expect(el.selected).to.deep.equal([]);\n expect(selectedChild.selected).to.be.false;\n\n selectedChild.click();\n\n expect(changeSpy.calledOnce).to.be.true;\n expect(el.selected).to.deep.equal([selectedChild.value]);\n expect(selectedChild.selected).to.be.true;\n\n selectedChild.click();\n\n expect(changeSpy.calledOnce).to.be.true;\n expect(el.selected).to.deep.equal([selectedChild.value]);\n expect(selectedChild.selected).to.be.true;\n });\n it('can have `change` events prevented', async () => {\n el.selects = 'single';\n const selectedChild = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n\n el.addEventListener('change', (event: Event) => event.preventDefault());\n\n expect(el.selected).to.deep.equal([]);\n expect(selectedChild.selected).to.be.false;\n\n selectedChild.click();\n\n expect(el.selected).to.deep.equal([]);\n expect(selectedChild.selected).to.be.false;\n });\n it('dispatches `change` events as [selects=\"multiple\"]', async () => {\n el.selects = 'multiple';\n const selectedChild0 = el.querySelector(\n ':scope > sp-swatch:nth-child(1)'\n ) as Swatch;\n const selectedChild1 = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n const selectedChild2 = el.querySelector(\n ':scope > sp-swatch:nth-child(6)'\n ) as Swatch;\n\n await elementUpdated(selectedChild0);\n\n const changeSpy = spy();\n\n el.addEventListener('change', () => changeSpy());\n\n expect(el.selected).to.deep.equal([]);\n\n selectedChild0.click();\n selectedChild1.click();\n selectedChild2.click();\n\n expect(changeSpy.callCount).to.equal(3);\n expect(el.selected).to.deep.equal([\n selectedChild0.value,\n selectedChild1.value,\n selectedChild2.value,\n ]);\n });\n it('filters `selected` when a selected Swatch is removed from the DOM', async () => {\n el.selects = 'multiple';\n const selectedChild0 = el.querySelector(\n ':scope > sp-swatch:nth-child(1)'\n ) as Swatch;\n const selectedChild1 = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n const selectedChild2 = el.querySelector(\n ':scope > sp-swatch:nth-child(6)'\n ) as Swatch;\n\n await elementUpdated(selectedChild0);\n\n expect(el.selected).to.deep.equal([]);\n\n selectedChild0.click();\n selectedChild1.click();\n selectedChild2.click();\n\n expect(el.selected).to.deep.equal([\n selectedChild0.value,\n selectedChild1.value,\n selectedChild2.value,\n ]);\n\n selectedChild0.remove();\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal([\n selectedChild1.value,\n selectedChild2.value,\n ]);\n\n selectedChild2.remove();\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal([selectedChild1.value]);\n\n selectedChild1.remove();\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal([]);\n });\n it('maintains a single tab stop', async () => {\n const inputBefore = document.createElement('input');\n const inputAfter = document.createElement('input');\n el.insertAdjacentElement('beforebegin', inputBefore);\n el.insertAdjacentElement('afterend', inputAfter);\n inputBefore.focus();\n expect(document.activeElement === el.children[0]).to.be.false;\n await sendKeys({\n press: 'Tab',\n });\n expect(document.activeElement === el.children[0]).to.be.true;\n await sendKeys({\n press: 'Tab',\n });\n expect(document.activeElement === el.children[0]).to.be.false;\n await sendKeys({\n press: 'Shift+Tab',\n });\n expect(document.activeElement === el.children[0]).to.be.true;\n });\n it('makes the first selected child the single tab stop', async () => {\n const selectedChild = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n expect(selectedChild.selected).to.be.false;\n\n const inputBefore = document.createElement('input');\n const inputAfter = document.createElement('input');\n el.insertAdjacentElement('beforebegin', inputBefore);\n el.insertAdjacentElement('afterend', inputAfter);\n inputBefore.focus();\n el.selects = 'single';\n el.selected = [selectedChild.value];\n await elementUpdated(el);\n await nextFrame();\n\n expect(selectedChild.selected).to.be.true;\n\n expect(document.activeElement === selectedChild).to.be.false;\n await sendKeys({\n press: 'Tab',\n });\n expect(document.activeElement === selectedChild).to.be.true;\n await sendKeys({\n press: 'Tab',\n });\n expect(document.activeElement === selectedChild).to.be.false;\n await sendKeys({\n press: 'Shift+Tab',\n });\n expect(document.activeElement === selectedChild).to.be.true;\n });\n it('focus()es to the first Swatch', async () => {\n el.focus();\n expect(document.activeElement === el.children[0]).to.be.true;\n });\n it('focus()es to the first selected Swatch', async () => {\n const selectedChild = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n expect(selectedChild.selected).to.be.false;\n el.selects = 'single';\n el.selected = [selectedChild.value];\n await elementUpdated(el);\n await nextFrame();\n\n expect(selectedChild.selected).to.be.true;\n el.focus();\n expect(document.activeElement === selectedChild).to.be.true;\n });\n});\n\ndescribe('Swatch Group - DOM selected', () => {\n describe('dev mode', () => {\n let consoleWarnStub!: ReturnType<typeof stub>;\n before(() => {\n window.__swc.verbose = true;\n consoleWarnStub = stub(console, 'warn');\n });\n afterEach(() => {\n consoleWarnStub.resetHistory();\n });\n after(() => {\n window.__swc.verbose = false;\n consoleWarnStub.restore();\n });\n\n it('warns in Dev Mode when mixed-value attribute is added in sp-swatch when parent sp-swatch-group is not having selects=\"multiple\"', async () => {\n const el = await fixture<SwatchGroup>(\n html`\n <sp-swatch-group selects=\"single\">\n <sp-swatch mixed-value></sp-swatch>\n </sp-swatch-group>\n `\n );\n\n await elementUpdated(el);\n\n expect(consoleWarnStub.called).to.be.true;\n const spyCall = consoleWarnStub.getCall(0);\n\n expect(\n (spyCall.args.at(0) as string).includes(\n '<sp-swatch> elements can only leverage the \"mixed-value\" attribute when their <sp-swatch-group> parent element is also leveraging \"selects=\"multiple\"'\n ),\n 'confirm warning message'\n ).to.be.true;\n\n expect(spyCall.args.at(-1), 'confirm `data` shape').to.deep.equal({\n data: {\n localName: 'sp-swatch-group',\n type: 'accessibility',\n level: 'default',\n },\n });\n });\n });\n it('accepts selection from DOM', async () => {\n const el = await fixture<SwatchGroup>(html`\n <sp-swatch-group selects=\"multiple\">\n <sp-swatch value=\"color-0\" color=\"red\"></sp-swatch>\n <sp-swatch value=\"color-1\" color=\"green\" selected></sp-swatch>\n <sp-swatch value=\"color-2\" color=\"blue\"></sp-swatch>\n <sp-swatch value=\"color-3\" color=\"yellow\" selected></sp-swatch>\n </sp-swatch-group>\n `);\n\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal(['color-1', 'color-3']);\n });\n it('merges `selected` and selection from DOM', async () => {\n const el = await fixture<SwatchGroup>(html`\n <sp-swatch-group selects=\"multiple\" .selected=${['color-1']}>\n <sp-swatch value=\"color-0\" color=\"red\"></sp-swatch>\n <sp-swatch value=\"color-1\" color=\"green\"></sp-swatch>\n <sp-swatch value=\"color-2\" color=\"blue\"></sp-swatch>\n <sp-swatch value=\"color-3\" color=\"yellow\" selected></sp-swatch>\n </sp-swatch-group>\n `);\n\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal(['color-1', 'color-3']);\n });\n it('lazily accepts selection from DOM', async () => {\n const el = await fixture<SwatchGroup>(html`\n <sp-swatch-group selects=\"multiple\">\n <sp-swatch value=\"color-0\" color=\"red\"></sp-swatch>\n <sp-swatch value=\"color-1\" color=\"green\"></sp-swatch>\n <sp-swatch value=\"color-2\" color=\"blue\"></sp-swatch>\n <sp-swatch value=\"color-3\" color=\"yellow\" selected></sp-swatch>\n </sp-swatch-group>\n `);\n\n await elementUpdated(el);\n const color1 = el.querySelector('[value=\"color-1\"]') as Swatch;\n\n expect(el.selected).to.deep.equal(['color-3']);\n\n color1.selected = true;\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal(['color-3', 'color-1']);\n });\n it('clears previously selected children when updating `selected`', async () => {\n const el = await fixture<SwatchGroup>(html`\n <sp-swatch-group selects=\"single\" .selected=${['color-1']}>\n <sp-swatch value=\"color-0\" color=\"red\"></sp-swatch>\n <sp-swatch value=\"color-1\" color=\"green\"></sp-swatch>\n <sp-swatch value=\"color-2\" color=\"blue\"></sp-swatch>\n </sp-swatch-group>\n `);\n await elementUpdated(el);\n expect(el.selected).to.deep.equal(['color-1']);\n el.selected = ['color-2'];\n await elementUpdated(el);\n expect(el.selected).to.deep.equal(['color-2']);\n });\n});\n"],
|
|
5
|
-
"mappings": ";AAWA,SAAS,gBAAgB,QAAQ,SAAS,iBAAiB;AAC3D,SAAS,gBAAgB;AAEzB,OAAO;AAEP,SAAS,eAAe;AACxB,SAAS,KAAK,YAAY;AAC1B,SAAS,YAAY;AACrB,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,MACX,OAAO;AAAA,IACX,CAAC;AACD,WAAO,SAAS,kBAAkB,aAAa,EAAE,GAAG,GAAG;AAAA,EAC3D,CAAC;AACD,KAAG,iCAAiC,YAAY;AAC5C,OAAG,MAAM;AACT,WAAO,SAAS,kBAAkB,GAAG,SAAS,CAAC,CAAC,EAAE,GAAG,GAAG;AAAA,EAC5D,CAAC;AACD,KAAG,0CAA0C,YAAY;AACrD,UAAM,gBAAgB,GAAG;AAAA,MACrB;AAAA,IACJ;AACA,WAAO,cAAc,QAAQ,EAAE,GAAG,GAAG;AACrC,OAAG,UAAU;AACb,OAAG,WAAW,CAAC,cAAc,KAAK;AAClC,UAAM,eAAe,EAAE;AACvB,UAAM,UAAU;AAEhB,WAAO,cAAc,QAAQ,EAAE,GAAG,GAAG;AACrC,OAAG,MAAM;AACT,WAAO,SAAS,kBAAkB,aAAa,EAAE,GAAG,GAAG;AAAA,EAC3D,CAAC;AACL,CAAC;AAED,SAAS,+BAA+B,MAAM;AAC1C,WAAS,YAAY,MAAM;AACvB,QAAI;AACJ,WAAO,MAAM;AACT,aAAO,MAAM,UAAU;AACvB,wBAAkB,KAAK,SAAS,MAAM;AAAA,IAC1C,CAAC;AACD,cAAU,MAAM;AACZ,sBAAgB,aAAa;AAAA,IACjC,CAAC;AACD,UAAM,MAAM;AACR,aAAO,MAAM,UAAU;AACvB,sBAAgB,QAAQ;AAAA,IAC5B,CAAC;AAED,OAAG,mIAAmI,YAAY;AAC9I,YAAM,KAAK,MAAM;AAAA,QACb;AAAA;AAAA;AAAA;AAAA;AAAA,MAKJ;AAEA,YAAM,eAAe,EAAE;
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { elementUpdated, expect, fixture, nextFrame } from '@open-wc/testing';\nimport { sendKeys } from '@web/test-runner-commands';\n\nimport '@spectrum-web-components/swatch/sp-swatch.js';\nimport { Swatch, SwatchGroup } from '../';\nimport { Default } from '../stories/swatch-group.stories.js';\nimport { spy, stub } from 'sinon';\nimport { html } from '@spectrum-web-components/base';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\n\ndescribe('Swatch Group', () => {\n let el: SwatchGroup;\n beforeEach(async () => {\n el = await fixture<SwatchGroup>(Default(Default.args));\n\n await elementUpdated(el);\n });\n testForLitDevWarnings(\n async () => await fixture<SwatchGroup>(Default(Default.args))\n );\n it('loads default swatch accessibly', async () => {\n await expect(el).to.be.accessible();\n });\n it('forwards `border` to children', async () => {\n el.border = 'light';\n await elementUpdated(el);\n\n ([...el.children] as Swatch[]).forEach((child) => {\n expect(child.border).to.equal('light');\n });\n });\n it('forwards `rounding` to children', async () => {\n el.rounding = 'full';\n await elementUpdated(el);\n\n ([...el.children] as Swatch[]).forEach((child) => {\n expect(child.rounding).to.equal('full');\n });\n });\n it('forwards `size` to children', async () => {\n el.size = 'xs';\n await elementUpdated(el);\n\n ([...el.children] as Swatch[]).forEach((child) => {\n expect(child.size).to.equal('xs');\n });\n });\n it('forwards `shape` to children', async () => {\n el.shape = 'rectangle';\n await elementUpdated(el);\n\n ([...el.children] as Swatch[]).forEach((child) => {\n expect(child.shape).to.equal('rectangle');\n });\n });\n it('unsets forwarding', async () => {\n el.border = 'light';\n el.rounding = 'full';\n el.size = 'xs';\n el.shape = 'rectangle';\n await elementUpdated(el);\n\n ([...el.children] as Swatch[]).forEach((child) => {\n expect(child.border).to.not.be.undefined;\n expect(child.rounding).to.not.be.undefined;\n expect(child.size).to.not.equal('m');\n expect(child.shape).to.not.be.undefined;\n });\n\n el.border = undefined;\n el.rounding = undefined;\n el.removeAttribute('size');\n el.shape = undefined;\n await elementUpdated(el);\n\n ([...el.children] as Swatch[]).forEach((child) => {\n expect(child.border).to.equal(undefined);\n expect(child.rounding).to.equal(undefined);\n expect(child.size).to.equal('m');\n expect(child.shape).to.equal(undefined);\n });\n });\n it('does not dispatch `change` events without `selects` attribute', async () => {\n const selectedChild = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n\n const changeSpy = spy();\n\n el.addEventListener('change', () => changeSpy());\n\n expect(el.selected).to.deep.equal([]);\n\n selectedChild.click();\n\n expect(changeSpy.called).to.be.false;\n expect(el.selected).to.deep.equal([]);\n });\n it('dispatches `change` events as [selects=\"single\"]', async () => {\n el.selects = 'single';\n const selectedChild = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n\n const changeSpy = spy();\n\n el.addEventListener('change', () => changeSpy());\n\n expect(el.selected).to.deep.equal([]);\n expect(selectedChild.selected).to.be.false;\n\n selectedChild.click();\n\n expect(changeSpy.calledOnce).to.be.true;\n expect(el.selected).to.deep.equal([selectedChild.value]);\n expect(selectedChild.selected).to.be.true;\n\n selectedChild.click();\n\n expect(changeSpy.calledOnce).to.be.true;\n expect(el.selected).to.deep.equal([selectedChild.value]);\n expect(selectedChild.selected).to.be.true;\n });\n it('can have `change` events prevented', async () => {\n el.selects = 'single';\n const selectedChild = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n\n el.addEventListener('change', (event: Event) => event.preventDefault());\n\n expect(el.selected).to.deep.equal([]);\n expect(selectedChild.selected).to.be.false;\n\n selectedChild.click();\n\n expect(el.selected).to.deep.equal([]);\n expect(selectedChild.selected).to.be.false;\n });\n it('dispatches `change` events as [selects=\"multiple\"]', async () => {\n el.selects = 'multiple';\n const selectedChild0 = el.querySelector(\n ':scope > sp-swatch:nth-child(1)'\n ) as Swatch;\n const selectedChild1 = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n const selectedChild2 = el.querySelector(\n ':scope > sp-swatch:nth-child(6)'\n ) as Swatch;\n\n await elementUpdated(selectedChild0);\n\n const changeSpy = spy();\n\n el.addEventListener('change', () => changeSpy());\n\n expect(el.selected).to.deep.equal([]);\n\n selectedChild0.click();\n selectedChild1.click();\n selectedChild2.click();\n\n expect(changeSpy.callCount).to.equal(3);\n expect(el.selected).to.deep.equal([\n selectedChild0.value,\n selectedChild1.value,\n selectedChild2.value,\n ]);\n });\n it('filters `selected` when a selected Swatch is removed from the DOM', async () => {\n el.selects = 'multiple';\n const selectedChild0 = el.querySelector(\n ':scope > sp-swatch:nth-child(1)'\n ) as Swatch;\n const selectedChild1 = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n const selectedChild2 = el.querySelector(\n ':scope > sp-swatch:nth-child(6)'\n ) as Swatch;\n\n await elementUpdated(selectedChild0);\n\n expect(el.selected).to.deep.equal([]);\n\n selectedChild0.click();\n selectedChild1.click();\n selectedChild2.click();\n\n expect(el.selected).to.deep.equal([\n selectedChild0.value,\n selectedChild1.value,\n selectedChild2.value,\n ]);\n\n selectedChild0.remove();\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal([\n selectedChild1.value,\n selectedChild2.value,\n ]);\n\n selectedChild2.remove();\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal([selectedChild1.value]);\n\n selectedChild1.remove();\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal([]);\n });\n it('maintains a single tab stop', async () => {\n const inputBefore = document.createElement('input');\n const inputAfter = document.createElement('input');\n el.insertAdjacentElement('beforebegin', inputBefore);\n el.insertAdjacentElement('afterend', inputAfter);\n inputBefore.focus();\n expect(document.activeElement === el.children[0]).to.be.false;\n await sendKeys({\n press: 'Tab',\n });\n expect(document.activeElement === el.children[0]).to.be.true;\n await sendKeys({\n press: 'Tab',\n });\n expect(document.activeElement === el.children[0]).to.be.false;\n await sendKeys({\n press: 'Shift+Tab',\n });\n expect(document.activeElement === el.children[0]).to.be.true;\n });\n it('makes the first selected child the single tab stop', async () => {\n const selectedChild = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n expect(selectedChild.selected).to.be.false;\n\n const inputBefore = document.createElement('input');\n const inputAfter = document.createElement('input');\n el.insertAdjacentElement('beforebegin', inputBefore);\n el.insertAdjacentElement('afterend', inputAfter);\n inputBefore.focus();\n el.selects = 'single';\n el.selected = [selectedChild.value];\n await elementUpdated(el);\n await nextFrame();\n await nextFrame();\n\n expect(selectedChild.selected).to.be.true;\n\n expect(document.activeElement === selectedChild).to.be.false;\n await sendKeys({\n press: 'Tab',\n });\n expect(document.activeElement === selectedChild).to.be.true;\n await sendKeys({\n press: 'Tab',\n });\n expect(document.activeElement === selectedChild).to.be.false;\n await sendKeys({\n press: 'Shift+Tab',\n });\n expect(document.activeElement === selectedChild).to.be.true;\n });\n it('focus()es to the first Swatch', async () => {\n el.focus();\n expect(document.activeElement === el.children[0]).to.be.true;\n });\n it('focus()es to the first selected Swatch', async () => {\n const selectedChild = el.querySelector(\n ':scope > sp-swatch:nth-child(4)'\n ) as Swatch;\n expect(selectedChild.selected).to.be.false;\n el.selects = 'single';\n el.selected = [selectedChild.value];\n await elementUpdated(el);\n await nextFrame();\n\n expect(selectedChild.selected).to.be.true;\n el.focus();\n expect(document.activeElement === selectedChild).to.be.true;\n });\n});\n\ndescribe('Swatch Group - DOM selected', () => {\n describe('dev mode', () => {\n let consoleWarnStub!: ReturnType<typeof stub>;\n before(() => {\n window.__swc.verbose = true;\n consoleWarnStub = stub(console, 'warn');\n });\n afterEach(() => {\n consoleWarnStub.resetHistory();\n });\n after(() => {\n window.__swc.verbose = false;\n consoleWarnStub.restore();\n });\n\n it('warns in Dev Mode when mixed-value attribute is added in sp-swatch when parent sp-swatch-group is not having selects=\"multiple\"', async () => {\n const el = await fixture<SwatchGroup>(\n html`\n <sp-swatch-group selects=\"single\">\n <sp-swatch mixed-value></sp-swatch>\n </sp-swatch-group>\n `\n );\n\n await elementUpdated(el);\n await nextFrame();\n await nextFrame();\n\n expect(consoleWarnStub.called).to.be.true;\n const spyCall = consoleWarnStub.getCall(0);\n\n expect(\n (spyCall.args.at(0) as string).includes(\n '<sp-swatch> elements can only leverage the \"mixed-value\" attribute when their <sp-swatch-group> parent element is also leveraging \"selects=\"multiple\"'\n ),\n 'confirm warning message'\n ).to.be.true;\n\n expect(spyCall.args.at(-1), 'confirm `data` shape').to.deep.equal({\n data: {\n localName: 'sp-swatch-group',\n type: 'accessibility',\n level: 'default',\n },\n });\n });\n });\n it('accepts selection from DOM', async () => {\n const el = await fixture<SwatchGroup>(html`\n <sp-swatch-group selects=\"multiple\">\n <sp-swatch value=\"color-0\" color=\"red\"></sp-swatch>\n <sp-swatch value=\"color-1\" color=\"green\" selected></sp-swatch>\n <sp-swatch value=\"color-2\" color=\"blue\"></sp-swatch>\n <sp-swatch value=\"color-3\" color=\"yellow\" selected></sp-swatch>\n </sp-swatch-group>\n `);\n\n await elementUpdated(el);\n\n expect(el.selected).to.deep.equal(['color-1', 'color-3']);\n });\n it('merges `selected` and selection from DOM', async function () {\n const el = await fixture<SwatchGroup>(html`\n <sp-swatch-group selects=\"multiple\" .selected=${['color-1']}>\n <sp-swatch value=\"color-0\" color=\"red\"></sp-swatch>\n <sp-swatch value=\"color-1\" color=\"green\"></sp-swatch>\n <sp-swatch value=\"color-2\" color=\"blue\"></sp-swatch>\n <sp-swatch value=\"color-3\" color=\"yellow\" selected></sp-swatch>\n </sp-swatch-group>\n `);\n\n await elementUpdated(el);\n await nextFrame();\n await nextFrame();\n\n expect(el.selected).to.deep.equal(['color-1', 'color-3']);\n });\n it('lazily accepts selection from DOM', async function () {\n const el = await fixture<SwatchGroup>(html`\n <sp-swatch-group selects=\"multiple\">\n <sp-swatch value=\"color-0\" color=\"red\"></sp-swatch>\n <sp-swatch value=\"color-1\" color=\"green\"></sp-swatch>\n <sp-swatch value=\"color-2\" color=\"blue\"></sp-swatch>\n <sp-swatch value=\"color-3\" color=\"yellow\" selected></sp-swatch>\n </sp-swatch-group>\n `);\n\n await elementUpdated(el);\n await nextFrame();\n await nextFrame();\n const color1 = el.querySelector('[value=\"color-1\"]') as Swatch;\n\n expect(el.selected).to.deep.equal(['color-3']);\n\n color1.selected = true;\n await elementUpdated(el);\n await nextFrame();\n await nextFrame();\n\n expect(el.selected).to.deep.equal(['color-3', 'color-1']);\n });\n it('clears previously selected children when updating `selected`', async () => {\n const el = await fixture<SwatchGroup>(html`\n <sp-swatch-group selects=\"single\" .selected=${['color-1']}>\n <sp-swatch value=\"color-0\" color=\"red\"></sp-swatch>\n <sp-swatch value=\"color-1\" color=\"green\"></sp-swatch>\n <sp-swatch value=\"color-2\" color=\"blue\"></sp-swatch>\n </sp-swatch-group>\n `);\n await elementUpdated(el);\n expect(el.selected).to.deep.equal(['color-1']);\n el.selected = ['color-2'];\n await elementUpdated(el);\n expect(el.selected).to.deep.equal(['color-2']);\n });\n});\n\ndescribe('Swatch Group - slotted', () => {\n it('manages [selects=\"single\"] selection through multiple slots', async () => {\n const test = await fixture<HTMLDivElement>(\n html`\n <div>\n <sp-swatch value=\"First\">First</sp-swatch>\n <sp-swatch value=\"Second\">Second</sp-swatch>\n <sp-swatch value=\"Third\" selected>Third</sp-swatch>\n </div>\n `\n );\n\n const firstItem = test.querySelector('sp-swatch') as Swatch;\n const thirdItem = test.querySelector('sp-swatch[selected]') as Swatch;\n\n const shadowRoot = test.attachShadow({ mode: 'open' });\n shadowRoot.innerHTML = `\n <sp-swatch-group label=\"Selects Single Group\" selects=\"single\">\n <slot></slot>\n </sp-swatch-group>\n `;\n\n const el = shadowRoot.querySelector('sp-swatch-group') as SwatchGroup;\n await elementUpdated(el);\n // Await test slot change time.\n await nextFrame();\n await nextFrame();\n\n expect(el.selected, '\"Third\" selected').to.deep.equal(['Third']);\n expect(firstItem.selected).to.be.false;\n expect(thirdItem.selected).to.be.true;\n\n firstItem.click();\n await elementUpdated(el);\n\n expect(el.selected, '\"First\" selected').to.deep.equal(['First']);\n expect(firstItem.sel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