@spectrum-web-components/swatch 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/sp-swatch-group.d.ts +6 -0
- package/sp-swatch-group.dev.js +5 -0
- package/sp-swatch-group.dev.js.map +7 -0
- package/sp-swatch-group.js +2 -0
- package/sp-swatch-group.js.map +7 -0
- package/sp-swatch.d.ts +6 -0
- package/sp-swatch.dev.js +5 -0
- package/sp-swatch.dev.js.map +7 -0
- package/sp-swatch.js +2 -0
- package/sp-swatch.js.map +7 -0
- package/src/Swatch.d.ts +43 -0
- package/src/Swatch.dev.js +243 -0
- package/src/Swatch.dev.js.map +7 -0
- package/src/Swatch.js +48 -0
- package/src/Swatch.js.map +7 -0
- package/src/SwatchGroup.d.ts +39 -0
- package/src/SwatchGroup.dev.js +268 -0
- package/src/SwatchGroup.dev.js.map +7 -0
- package/src/SwatchGroup.js +7 -0
- package/src/SwatchGroup.js.map +7 -0
- package/src/index.d.ts +2 -0
- package/src/index.dev.js +4 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +2 -0
- package/src/index.js.map +7 -0
- package/src/spectrum-swatch-group.css.d.ts +2 -0
- package/src/spectrum-swatch-group.css.dev.js +7 -0
- package/src/spectrum-swatch-group.css.dev.js.map +7 -0
- package/src/spectrum-swatch-group.css.js +4 -0
- package/src/spectrum-swatch-group.css.js.map +7 -0
- package/src/spectrum-swatch.css.d.ts +2 -0
- package/src/spectrum-swatch.css.dev.js +7 -0
- package/src/spectrum-swatch.css.dev.js.map +7 -0
- package/src/spectrum-swatch.css.js +4 -0
- package/src/spectrum-swatch.css.js.map +7 -0
- package/src/swatch-group-overrides.css.d.ts +2 -0
- package/src/swatch-group-overrides.css.dev.js +7 -0
- package/src/swatch-group-overrides.css.dev.js.map +7 -0
- package/src/swatch-group-overrides.css.js +4 -0
- package/src/swatch-group-overrides.css.js.map +7 -0
- package/src/swatch-group.css.d.ts +2 -0
- package/src/swatch-group.css.dev.js +7 -0
- package/src/swatch-group.css.dev.js.map +7 -0
- package/src/swatch-group.css.js +4 -0
- package/src/swatch-group.css.js.map +7 -0
- package/src/swatch-overrides.css.d.ts +2 -0
- package/src/swatch-overrides.css.dev.js +7 -0
- package/src/swatch-overrides.css.dev.js.map +7 -0
- package/src/swatch-overrides.css.js +4 -0
- package/src/swatch-overrides.css.js.map +7 -0
- package/src/swatch.css.d.ts +2 -0
- package/src/swatch.css.dev.js +7 -0
- package/src/swatch.css.dev.js.map +7 -0
- package/src/swatch.css.js +4 -0
- package/src/swatch.css.js.map +7 -0
- package/stories/swatch-group.stories.js +183 -0
- package/stories/swatch-group.stories.js.map +7 -0
- package/stories/swatch-sizes.stories.js +40 -0
- package/stories/swatch-sizes.stories.js.map +7 -0
- package/stories/swatch.stories.js +109 -0
- package/stories/swatch.stories.js.map +7 -0
- package/test/benchmark/basic-test.js +8 -0
- package/test/benchmark/basic-test.js.map +7 -0
- package/test/swatch-group.test-vrt.js +5 -0
- package/test/swatch-group.test-vrt.js.map +7 -0
- package/test/swatch-group.test.js +377 -0
- package/test/swatch-group.test.js.map +7 -0
- package/test/swatch-memory.test.js +8 -0
- package/test/swatch-memory.test.js.map +7 -0
- package/test/swatch-sizes.test-vrt.js +5 -0
- package/test/swatch-sizes.test-vrt.js.map +7 -0
- package/test/swatch.test-vrt.js +5 -0
- package/test/swatch.test-vrt.js.map +7 -0
- package/test/swatch.test.js +155 -0
- package/test/swatch.test.js.map +7 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
5
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
6
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
7
|
+
if (decorator = decorators[i])
|
|
8
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
9
|
+
if (kind && result) __defProp(target, key, result);
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
import {
|
|
13
|
+
html,
|
|
14
|
+
SizedMixin,
|
|
15
|
+
SpectrumElement
|
|
16
|
+
} from "@spectrum-web-components/base";
|
|
17
|
+
import {
|
|
18
|
+
property,
|
|
19
|
+
queryAssignedElements
|
|
20
|
+
} from "@spectrum-web-components/base/src/decorators.js";
|
|
21
|
+
import { RovingTabindexController } from "@spectrum-web-components/reactive-controllers/src/RovingTabindex.js";
|
|
22
|
+
import { MutationController } from "@lit-labs/observers/mutation-controller.js";
|
|
23
|
+
import styles from "./swatch-group.css.js";
|
|
24
|
+
export class SwatchGroup extends SizedMixin(SpectrumElement, {
|
|
25
|
+
validSizes: ["xs", "s", "m", "l"],
|
|
26
|
+
noDefaultSize: true
|
|
27
|
+
}) {
|
|
28
|
+
constructor() {
|
|
29
|
+
super();
|
|
30
|
+
// Specifically surface `_selected` internally so that change can be made to this value internally
|
|
31
|
+
// without triggering the update lifecycle directly.
|
|
32
|
+
this._selected = [];
|
|
33
|
+
this.selectedSet = /* @__PURE__ */ new Set();
|
|
34
|
+
this.rovingTabindexController = new RovingTabindexController(this, {
|
|
35
|
+
focusInIndex: (elements) => {
|
|
36
|
+
let firstEnabledIndex = -1;
|
|
37
|
+
const firstSelectedIndex = elements.findIndex((el, index) => {
|
|
38
|
+
if (!elements[firstEnabledIndex] && !el.disabled) {
|
|
39
|
+
firstEnabledIndex = index;
|
|
40
|
+
}
|
|
41
|
+
return el.selected && !el.disabled;
|
|
42
|
+
});
|
|
43
|
+
return elements[firstSelectedIndex] ? firstSelectedIndex : firstEnabledIndex;
|
|
44
|
+
},
|
|
45
|
+
elements: () => this.swatches,
|
|
46
|
+
isFocusableElement: (el) => !el.disabled
|
|
47
|
+
});
|
|
48
|
+
this.manageChange = async () => {
|
|
49
|
+
const presentSet = /* @__PURE__ */ new Set();
|
|
50
|
+
this.selectedSet = new Set(this.selected);
|
|
51
|
+
await Promise.all(this.swatches.map((swatch) => swatch.updateComplete));
|
|
52
|
+
this.swatches.forEach((swatch) => {
|
|
53
|
+
presentSet.add(swatch.value);
|
|
54
|
+
if (swatch.selected) {
|
|
55
|
+
this.selectedSet.add(swatch.value);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
this.selectedSet.forEach((value) => {
|
|
59
|
+
if (!presentSet.has(value)) {
|
|
60
|
+
this.selectedSet.delete(value);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
this._selected = [...this.selectedSet];
|
|
64
|
+
this.rovingTabindexController.clearElementCache();
|
|
65
|
+
};
|
|
66
|
+
new MutationController(this, {
|
|
67
|
+
config: {
|
|
68
|
+
attributes: true,
|
|
69
|
+
childList: true,
|
|
70
|
+
subtree: true
|
|
71
|
+
},
|
|
72
|
+
callback: () => {
|
|
73
|
+
this.manageChange();
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
static get styles() {
|
|
78
|
+
return [styles];
|
|
79
|
+
}
|
|
80
|
+
get selected() {
|
|
81
|
+
return this._selected;
|
|
82
|
+
}
|
|
83
|
+
set selected(selected) {
|
|
84
|
+
if (selected === this.selected) return;
|
|
85
|
+
const oldSelected = this.selected;
|
|
86
|
+
this._selected = selected;
|
|
87
|
+
this.requestUpdate("selected", oldSelected);
|
|
88
|
+
}
|
|
89
|
+
focus(options) {
|
|
90
|
+
this.rovingTabindexController.focus(options);
|
|
91
|
+
}
|
|
92
|
+
handleChange(event) {
|
|
93
|
+
event.stopPropagation();
|
|
94
|
+
const oldSelected = this.selected;
|
|
95
|
+
if (!this.selects) {
|
|
96
|
+
event.preventDefault();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (this.selects === "single") {
|
|
100
|
+
const { target } = event;
|
|
101
|
+
target.tabIndex = 0;
|
|
102
|
+
target.selected = true;
|
|
103
|
+
if (this.selectedSet.has(target.value)) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
this.selectedSet.clear();
|
|
107
|
+
this.selectedSet.add(target.value);
|
|
108
|
+
this.rovingTabindexController.elements.forEach((child) => {
|
|
109
|
+
if (child === target) return;
|
|
110
|
+
child.selected = false;
|
|
111
|
+
});
|
|
112
|
+
} else if (this.selects === "multiple") {
|
|
113
|
+
const { target } = event;
|
|
114
|
+
if (target.selected) {
|
|
115
|
+
this.selectedSet.add(target.value);
|
|
116
|
+
} else {
|
|
117
|
+
this.selectedSet.delete(target.value);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
this._selected = [...this.selectedSet];
|
|
121
|
+
const applyDefault = this.dispatchEvent(
|
|
122
|
+
new Event("change", {
|
|
123
|
+
cancelable: true,
|
|
124
|
+
bubbles: true
|
|
125
|
+
})
|
|
126
|
+
);
|
|
127
|
+
if (!applyDefault) {
|
|
128
|
+
this._selected = oldSelected;
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
getPassthroughSwatchActions(changes) {
|
|
133
|
+
const targetValues = {};
|
|
134
|
+
if (changes.has("selects") && (this.selects || typeof changes.get("selects") !== "undefined")) {
|
|
135
|
+
targetValues.selects = this.selects;
|
|
136
|
+
}
|
|
137
|
+
if (changes.has("border") && (this.border || typeof changes.get("border") !== "undefined")) {
|
|
138
|
+
targetValues.border = this.border;
|
|
139
|
+
}
|
|
140
|
+
if (changes.has("rounding") && (this.rounding || typeof changes.get("rounding") !== "undefined")) {
|
|
141
|
+
targetValues.rounding = this.rounding;
|
|
142
|
+
}
|
|
143
|
+
if (changes.has("size") && (this.size !== "m" || typeof changes.get("size") !== "undefined")) {
|
|
144
|
+
targetValues.size = this.size;
|
|
145
|
+
}
|
|
146
|
+
if (changes.has("shape") && (this.shape || typeof changes.get("shape") !== "undefined")) {
|
|
147
|
+
targetValues.shape = this.shape;
|
|
148
|
+
}
|
|
149
|
+
const passThroughSwatchActions = [];
|
|
150
|
+
if (Object.keys(targetValues).length) {
|
|
151
|
+
passThroughSwatchActions.push((swatch) => {
|
|
152
|
+
if (true) {
|
|
153
|
+
if ("selects" in targetValues && targetValues.selects !== "multiple" && swatch.mixedValue) {
|
|
154
|
+
window.__swc.warn(
|
|
155
|
+
this,
|
|
156
|
+
`<sp-swatch> elements can only leverage the "mixed-value" attribute when their <sp-swatch-group> parent element is also leveraging "selects="multiple""`,
|
|
157
|
+
"https://opensource.adobe.com/spectrum-web-components/components/swatch-group/#multiple",
|
|
158
|
+
{
|
|
159
|
+
type: "accessibility"
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if ("border" in targetValues)
|
|
165
|
+
swatch.border = targetValues.border;
|
|
166
|
+
if ("rounding" in targetValues)
|
|
167
|
+
swatch.rounding = targetValues.rounding;
|
|
168
|
+
if ("shape" in targetValues) swatch.shape = targetValues.shape;
|
|
169
|
+
if ("size" in targetValues)
|
|
170
|
+
swatch.size = targetValues.size;
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
return passThroughSwatchActions;
|
|
174
|
+
}
|
|
175
|
+
getSelectionSwatchActions(changes) {
|
|
176
|
+
const selectionSwatchActions = [];
|
|
177
|
+
if (!changes.has("selects")) return selectionSwatchActions;
|
|
178
|
+
if (this.selects) {
|
|
179
|
+
this.setAttribute(
|
|
180
|
+
"role",
|
|
181
|
+
this.selects === "single" ? "radiogroup" : "group"
|
|
182
|
+
);
|
|
183
|
+
} else {
|
|
184
|
+
this.removeAttribute("role");
|
|
185
|
+
}
|
|
186
|
+
const swatchRoles = {
|
|
187
|
+
single: "radio",
|
|
188
|
+
multiple: "checkbox"
|
|
189
|
+
};
|
|
190
|
+
const swatchRole = this.selects ? swatchRoles[this.selects] : "button";
|
|
191
|
+
selectionSwatchActions.push((swatch) => {
|
|
192
|
+
swatch.setAttribute("role", swatchRole);
|
|
193
|
+
});
|
|
194
|
+
return selectionSwatchActions;
|
|
195
|
+
}
|
|
196
|
+
render() {
|
|
197
|
+
return html`
|
|
198
|
+
<slot
|
|
199
|
+
@change=${this.handleChange}
|
|
200
|
+
@slotchange=${this.manageChange}
|
|
201
|
+
></slot>
|
|
202
|
+
`;
|
|
203
|
+
}
|
|
204
|
+
willUpdate(changes) {
|
|
205
|
+
const swatchActions = [
|
|
206
|
+
...this.getPassthroughSwatchActions(changes),
|
|
207
|
+
...this.getSelectionSwatchActions(changes)
|
|
208
|
+
];
|
|
209
|
+
let nextSelected = new Set(this.selected);
|
|
210
|
+
const currentValues = /* @__PURE__ */ new Set();
|
|
211
|
+
if (changes.has("selected")) {
|
|
212
|
+
swatchActions.push((swatch) => {
|
|
213
|
+
currentValues.add(swatch.value);
|
|
214
|
+
if (nextSelected.has(swatch.value) || !this.hasUpdated && swatch.selected) {
|
|
215
|
+
swatch.selected = true;
|
|
216
|
+
} else {
|
|
217
|
+
swatch.selected = false;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
const doActions = () => {
|
|
222
|
+
nextSelected = new Set(this.selected);
|
|
223
|
+
this.swatches.forEach((swatch) => {
|
|
224
|
+
swatchActions.forEach((action) => {
|
|
225
|
+
action(swatch);
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
if (changes.has("selected")) {
|
|
229
|
+
this._selected = [...nextSelected.values()].filter(
|
|
230
|
+
(selectedValue) => currentValues.has(selectedValue)
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
if (this.hasUpdated) {
|
|
235
|
+
doActions();
|
|
236
|
+
} else {
|
|
237
|
+
this.shadowRoot.addEventListener(
|
|
238
|
+
"slotchange",
|
|
239
|
+
() => {
|
|
240
|
+
requestAnimationFrame(doActions);
|
|
241
|
+
},
|
|
242
|
+
{ once: true }
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
__decorateClass([
|
|
248
|
+
property({ reflect: true })
|
|
249
|
+
], SwatchGroup.prototype, "border", 2);
|
|
250
|
+
__decorateClass([
|
|
251
|
+
property({ reflect: true })
|
|
252
|
+
], SwatchGroup.prototype, "density", 2);
|
|
253
|
+
__decorateClass([
|
|
254
|
+
property({ reflect: true })
|
|
255
|
+
], SwatchGroup.prototype, "rounding", 2);
|
|
256
|
+
__decorateClass([
|
|
257
|
+
property({ type: Array })
|
|
258
|
+
], SwatchGroup.prototype, "selected", 1);
|
|
259
|
+
__decorateClass([
|
|
260
|
+
property()
|
|
261
|
+
], SwatchGroup.prototype, "selects", 2);
|
|
262
|
+
__decorateClass([
|
|
263
|
+
property({ reflect: true })
|
|
264
|
+
], SwatchGroup.prototype, "shape", 2);
|
|
265
|
+
__decorateClass([
|
|
266
|
+
queryAssignedElements({ flatten: true })
|
|
267
|
+
], SwatchGroup.prototype, "swatches", 2);
|
|
268
|
+
//# sourceMappingURL=SwatchGroup.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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 {\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,0BAA0B;AAEnC,OAAO,YAAY;AAgBZ,aAAM,oBAAoB,WAAW,iBAAiB;AAAA,EACzD,YAAY,CAAC,MAAM,KAAK,KAAK,GAAG;AAAA,EAChC,eAAe;AACnB,CAAC,EAAE;AAAA,EA0CC,cAAc;AACV,UAAM;AAdV;AAAA;AAAA,SAAQ,YAAsB,CAAC;AAK/B,SAAQ,cAAc,oBAAI,IAAY;AAuBtC,oCAA2B,IAAI,yBAAiC,MAAM;AAAA,MAClE,cAAc,CAAC,aAAuB;AAClC,YAAI,oBAAoB;AACxB,cAAM,qBAAqB,SAAS,UAAU,CAAC,IAAI,UAAU;AACzD,cAAI,CAAC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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
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
<slot
|
|
3
|
+
@change=${this.handleChange}
|
|
4
|
+
@slotchange=${this.manageChange}
|
|
5
|
+
></slot>
|
|
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
|
+
//# sourceMappingURL=SwatchGroup.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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 {\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,gCACP,OACI,YAAAC,EACA,yBAAAC,MACG,kDACP,OAAS,4BAAAC,MAAgC,sEACzC,OAAS,sBAAAC,MAA0B,6CAEnC,OAAOC,MAAY,wBAgBZ,aAAM,oBAAoBN,EAAWC,EAAiB,CACzD,WAAY,CAAC,KAAM,IAAK,IAAK,GAAG,EAChC,cAAe,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AAIhB,EAAO,KAAK,EAE1Be,EAAa,IAAIf,EAAO,KAAK,GAC5B,CAAC,KAAK,YAAcA,EAAO,SAE5BA,EAAO,SAAW,GAElBA,EAAO,SAAW,EAE1B,CAAC,EAGL,MAAMiB,EAAY,IAAY,CAC1BF,EAAe,IAAI,IAAI,KAAK,QAAQ,EAGpC,KAAK,SAAS,QAASf,GAAW,CAC9Bc,EAAc,QAASI,GAAW,CAC9BA,EAAOlB,CAAM,CACjB,CAAC,CACL,CAAC,EAGGQ,EAAQ,IAAI,UAAU,IACtB,KAAK,UAAY,CAAC,GAAGO,EAAa,OAAO,CAAC,EAAE,OACvCI,GAAkBH,EAAc,IAAIG,CAAa,CACtD,EAER,EAEI,KAAK,WAELF,EAAU,EAIV,KAAK,WAAW,iBACZ,aACA,IAAM,CACF,sBAAsBA,CAAS,CACnC,EACA,CAAE,KAAM,EAAK,CACjB,CAER,CACJ,CApSWG,EAAA,CADN/B,EAAS,CAAE,QAAS,EAAK,CAAC,GARlB,YASF,sBAGA+B,EAAA,CADN/B,EAAS,CAAE,QAAS,EAAK,CAAC,GAXlB,YAYF,uBAGA+B,EAAA,CADN/B,EAAS,CAAE,QAAS,EAAK,CAAC,GAdlB,YAeF,wBAGI+B,EAAA,CADV/B,EAAS,CAAE,KAAM,KAAM,CAAC,GAjBhB,YAkBE,wBAiBJ+B,EAAA,CADN/B,EAAS,GAlCD,YAmCF,uBAKA+B,EAAA,CADN/B,EAAS,CAAE,QAAS,EAAK,CAAC,GAvClB,YAwCF,qBAGA+B,EAAA,CADN9B,EAAsB,CAAE,QAAS,EAAK,CAAC,GA1C/B,YA2CF",
|
|
6
|
+
"names": ["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
|
+
}
|
package/src/index.d.ts
ADDED
package/src/index.dev.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["index.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*/\nexport * from './Swatch.dev.js'\nexport * from './SwatchGroup.dev.js'\n"],
|
|
5
|
+
"mappings": ";AAWA,cAAc;AACd,cAAc;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/src/index.js
ADDED
package/src/index.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["index.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*/\nexport * from './Swatch.js';\nexport * from './SwatchGroup.js';\n"],
|
|
5
|
+
"mappings": "aAWA,WAAc,cACd,WAAc",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { css } from "@spectrum-web-components/base";
|
|
3
|
+
const styles = css`
|
|
4
|
+
:host{justify-content:flex-start;align-items:flex-start;gap:var(--mod-swatchgroup-spacing-regular,var(--spectrum-swatchgroup-spacing-regular));flex-flow:wrap;display:inline-flex}:host([density=compact]){gap:var(--mod-swatchgroup-spacing-compact,var(--spectrum-swatchgroup-spacing-compact))}:host([density=spacious]){gap:var(--mod-swatchgroup-spacing-spacious,var(--spectrum-swatchgroup-spacing-spacious))}
|
|
5
|
+
`;
|
|
6
|
+
export default styles;
|
|
7
|
+
//# sourceMappingURL=spectrum-swatch-group.css.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["spectrum-swatch-group.css.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2025 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 { css } from '@spectrum-web-components/base';\nconst styles = css`\n :host{justify-content:flex-start;align-items:flex-start;gap:var(--mod-swatchgroup-spacing-regular,var(--spectrum-swatchgroup-spacing-regular));flex-flow:wrap;display:inline-flex}:host([density=compact]){gap:var(--mod-swatchgroup-spacing-compact,var(--spectrum-swatchgroup-spacing-compact))}:host([density=spacious]){gap:var(--mod-swatchgroup-spacing-spacious,var(--spectrum-swatchgroup-spacing-spacious))}\n`;\nexport default styles;"],
|
|
5
|
+
"mappings": ";AAWA,SAAS,WAAW;AACpB,MAAM,SAAS;AAAA;AAAA;AAGf,eAAe;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";import{css as s}from"@spectrum-web-components/base";const a=s`
|
|
2
|
+
:host{justify-content:flex-start;align-items:flex-start;gap:var(--mod-swatchgroup-spacing-regular,var(--spectrum-swatchgroup-spacing-regular));flex-flow:wrap;display:inline-flex}:host([density=compact]){gap:var(--mod-swatchgroup-spacing-compact,var(--spectrum-swatchgroup-spacing-compact))}:host([density=spacious]){gap:var(--mod-swatchgroup-spacing-spacious,var(--spectrum-swatchgroup-spacing-spacious))}
|
|
3
|
+
`;export default a;
|
|
4
|
+
//# sourceMappingURL=spectrum-swatch-group.css.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["spectrum-swatch-group.css.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2025 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 { css } from '@spectrum-web-components/base';\nconst styles = css`\n :host{justify-content:flex-start;align-items:flex-start;gap:var(--mod-swatchgroup-spacing-regular,var(--spectrum-swatchgroup-spacing-regular));flex-flow:wrap;display:inline-flex}:host([density=compact]){gap:var(--mod-swatchgroup-spacing-compact,var(--spectrum-swatchgroup-spacing-compact))}:host([density=spacious]){gap:var(--mod-swatchgroup-spacing-spacious,var(--spectrum-swatchgroup-spacing-spacious))}\n`;\nexport default styles;"],
|
|
5
|
+
"mappings": "aAWA,OAAS,OAAAA,MAAW,gCACpB,MAAMC,EAASD;AAAA;AAAA,EAGf,eAAeC",
|
|
6
|
+
"names": ["css", "styles"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { css } from "@spectrum-web-components/base";
|
|
3
|
+
const styles = css`
|
|
4
|
+
@media (forced-colors:active){:host{--highcontrast-swatch-disabled-icon-color:GrayText;--highcontrast-swatch-focus-indicator-color:ButtonText;--highcontrast-swatch-background-color-selected:Background;--highcontrast-swatch-border-color-selected:Highlight;--highcontrast-swatch-border-color:ButtonText;--highcontrast-swatch-fill-foreground-color:ButtonText}.fill{forced-color-adjust:none}:host([disabled]),:host([disabled]){--highcontrast-swatch-border-color:GrayText}}:host{inline-size:var(--mod-swatch-size,var(--spectrum-swatch-size));block-size:var(--mod-swatch-size,var(--spectrum-swatch-size));-webkit-user-select:none;user-select:none;outline:none;justify-content:center;align-items:center;display:flex;position:relative}.disabledIcon{inline-size:var(--mod-swatch-disabled-icon-size,var(--spectrum-swatch-disabled-icon-size));block-size:var(--mod-swatch-disabled-icon-size,var(--spectrum-swatch-disabled-icon-size))}:host,:host:before{border-radius:var(--mod-swatch-border-radius,var(--spectrum-swatch-border-radius))}:host([selected]){background-color:var(--highcontrast-swatch-background-color-selected,var(--mod-swatch-inner-border-color-selected,var(--spectrum-swatch-inner-border-color-selected)))}:host([selected]) .fill{clip-path:polygon(calc(var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2)calc(var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2),calc(100% - var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2)calc(var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2),calc(100% - var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2)calc(100% - var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2),calc(var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2)calc(100% - var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2));border-radius:0}:host([selected]) .fill:before{box-shadow:none;border-radius:0}:host([selected]):before{opacity:1}:host .is-image .fill:before{background-color:initial}:host([mixed-value]) .fill{background:0 0;background:var(--spectrum-picked-color,transparent)}:host([mixed-value]) .mixedValueIcon{color:var(--spectrum-swatch-dash-icon-color);display:block}:host([nothing]) .fill{background-color:initial;background-color:var(--spectrum-picked-color,transparent);background-image:none}:host([nothing]) .fill:after{inline-size:var(--mod-swatch-slash-thickness,var(--spectrum-swatch-slash-thickness));content:"";block-size:200%;background:var(--highcontrast-swatch-fill-foreground-color,var(--mod-swatch-slash-icon-color,var(--spectrum-swatch-slash-icon-color)));position:absolute;transform:rotate(-45deg)}:host([nothing][shape=rectangle]) .fill:after{transform:rotate(-25deg)}:host([disabled]) .disabledIcon,:host([disabled]) .disabledIcon{display:block}:host:before{content:"";border-width:var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected));border-style:solid;border-color:var(--highcontrast-swatch-border-color-selected,var(--mod-swatch-border-color-selected,var(--spectrum-swatch-border-color-selected)));opacity:0;pointer-events:none;position:absolute;inset:0}:host:after{content:"";inset:calc(var(--mod-swatch-focus-indicator-gap,var(--spectrum-swatch-focus-indicator-gap))*-2);opacity:0;border-width:var(--mod-swatch-focus-indicator-thickness,var(--spectrum-swatch-focus-indicator-thickness));border-style:solid;border-color:var(--highcontrast-swatch-focus-indicator-color,var(--mod-swatch-focus-indicator-color,var(--spectrum-swatch-focus-indicator-color)));border-radius:var(--mod-swatch-focus-indicator-border-radius,var(--spectrum-swatch-focus-indicator-border-radius));transition:opacity var(--mod-animation-duration-100,var(--spectrum-animation-duration-100))ease-in-out;position:absolute}:host(:focus-visible):after{opacity:1}.fill{inline-size:100%;block-size:100%;box-sizing:border-box;border-radius:var(--mod-swatch-border-radius,var(--spectrum-swatch-border-radius));justify-content:center;align-items:center;display:flex;position:relative;overflow:hidden}.fill:before{content:"";z-index:0;box-shadow:inset 0 0 0 var(--mod-swatch-border-thickness,var(--spectrum-swatch-border-thickness))var(--highcontrast-swatch-border-color,var(--mod-swatch-border-color,var(--spectrum-swatch-border-color)));border-radius:var(--mod-swatch-border-radius,var(--spectrum-swatch-border-radius));position:absolute;inset:0}:host([border=none]) .fill:before,.fill:before{background-color:initial;background-color:var(--spectrum-picked-color,transparent)}:host([border=none]) .fill:before{box-shadow:none}:host([border=light]) .fill:before{box-shadow:inset 0 0 0 var(--mod-swatch-border-thickness,var(--spectrum-swatch-border-thickness))var(--highcontrast-swatch-border-color-light,var(--mod-swatch-border-color-light,var(--spectrum-swatch-border-color-light)))}.mixedValueIcon{pointer-events:none;color:#0000;color:var(--spectrum-picked-color,transparent);display:none}.disabledIcon{z-index:1;pointer-events:none;color:var(--highcontrast-swatch-disabled-icon-color,var(--mod-swatch-disabled-icon-color,var(--spectrum-swatch-disabled-icon-color)));stroke:var(--highcontrast-swatch-disabled-icon-color,var(--mod-swatch-disabled-icon-color,var(--spectrum-swatch-disabled-icon-color)));display:none;position:relative}.disabledIcon path:first-child{fill:var(--highcontrast-swatch-disabled-icon-color,var(--mod-swatch-disabled-icon-color,var(--spectrum-swatch-disabled-icon-color)))}.disabledIcon path:last-child{fill:var(--mod-swatch-icon-border-color,var(--spectrum-swatch-icon-border-color))}:host([shape=rectangle]){inline-size:calc(var(--mod-swatch-size,var(--spectrum-swatch-size))*2)}:host([rounding=none]),:host([rounding=none]) .fill,:host([rounding=none]) .fill:before,:host([rounding=none][selected]) .fill,:host([rounding=none][selected]) .fill:before,:host([rounding=none]):after,:host([rounding=none]):before{border-radius:0}:host([rounding=full][selected]:not([shape=rectangle])) .fill,:host([rounding=full][selected]:not([shape=rectangle])) .fill:before,:host([rounding=full]:not([shape=rectangle])),:host([rounding=full]:not([shape=rectangle])) .fill,:host([rounding=full]:not([shape=rectangle])) .fill:before,:host([rounding=full]:not([shape=rectangle])):after,:host([rounding=full]:not([shape=rectangle])):before{border-radius:100%}:host([rounding=full][selected]:not([shape=rectangle])) .fill{clip-path:circle(calc(50% - var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2)at 50% 50%)}::slotted([slot=image]){object-fit:contain;inline-size:100%;block-size:100%;transition:width var(--mod-animation-duration-100,var(--spectrum-animation-duration-100))ease-in-out,height var(--mod-animation-duration-100,var(--spectrum-animation-duration-100))ease-in-out}
|
|
5
|
+
`;
|
|
6
|
+
export default styles;
|
|
7
|
+
//# sourceMappingURL=spectrum-swatch.css.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["spectrum-swatch.css.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2025 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 { css } from '@spectrum-web-components/base';\nconst styles = css`\n @media (forced-colors:active){:host{--highcontrast-swatch-disabled-icon-color:GrayText;--highcontrast-swatch-focus-indicator-color:ButtonText;--highcontrast-swatch-background-color-selected:Background;--highcontrast-swatch-border-color-selected:Highlight;--highcontrast-swatch-border-color:ButtonText;--highcontrast-swatch-fill-foreground-color:ButtonText}.fill{forced-color-adjust:none}:host([disabled]),:host([disabled]){--highcontrast-swatch-border-color:GrayText}}:host{inline-size:var(--mod-swatch-size,var(--spectrum-swatch-size));block-size:var(--mod-swatch-size,var(--spectrum-swatch-size));-webkit-user-select:none;user-select:none;outline:none;justify-content:center;align-items:center;display:flex;position:relative}.disabledIcon{inline-size:var(--mod-swatch-disabled-icon-size,var(--spectrum-swatch-disabled-icon-size));block-size:var(--mod-swatch-disabled-icon-size,var(--spectrum-swatch-disabled-icon-size))}:host,:host:before{border-radius:var(--mod-swatch-border-radius,var(--spectrum-swatch-border-radius))}:host([selected]){background-color:var(--highcontrast-swatch-background-color-selected,var(--mod-swatch-inner-border-color-selected,var(--spectrum-swatch-inner-border-color-selected)))}:host([selected]) .fill{clip-path:polygon(calc(var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2)calc(var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2),calc(100% - var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2)calc(var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2),calc(100% - var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2)calc(100% - var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2),calc(var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2)calc(100% - var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2));border-radius:0}:host([selected]) .fill:before{box-shadow:none;border-radius:0}:host([selected]):before{opacity:1}:host .is-image .fill:before{background-color:initial}:host([mixed-value]) .fill{background:0 0;background:var(--spectrum-picked-color,transparent)}:host([mixed-value]) .mixedValueIcon{color:var(--spectrum-swatch-dash-icon-color);display:block}:host([nothing]) .fill{background-color:initial;background-color:var(--spectrum-picked-color,transparent);background-image:none}:host([nothing]) .fill:after{inline-size:var(--mod-swatch-slash-thickness,var(--spectrum-swatch-slash-thickness));content:\"\";block-size:200%;background:var(--highcontrast-swatch-fill-foreground-color,var(--mod-swatch-slash-icon-color,var(--spectrum-swatch-slash-icon-color)));position:absolute;transform:rotate(-45deg)}:host([nothing][shape=rectangle]) .fill:after{transform:rotate(-25deg)}:host([disabled]) .disabledIcon,:host([disabled]) .disabledIcon{display:block}:host:before{content:\"\";border-width:var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected));border-style:solid;border-color:var(--highcontrast-swatch-border-color-selected,var(--mod-swatch-border-color-selected,var(--spectrum-swatch-border-color-selected)));opacity:0;pointer-events:none;position:absolute;inset:0}:host:after{content:\"\";inset:calc(var(--mod-swatch-focus-indicator-gap,var(--spectrum-swatch-focus-indicator-gap))*-2);opacity:0;border-width:var(--mod-swatch-focus-indicator-thickness,var(--spectrum-swatch-focus-indicator-thickness));border-style:solid;border-color:var(--highcontrast-swatch-focus-indicator-color,var(--mod-swatch-focus-indicator-color,var(--spectrum-swatch-focus-indicator-color)));border-radius:var(--mod-swatch-focus-indicator-border-radius,var(--spectrum-swatch-focus-indicator-border-radius));transition:opacity var(--mod-animation-duration-100,var(--spectrum-animation-duration-100))ease-in-out;position:absolute}:host(:focus-visible):after{opacity:1}.fill{inline-size:100%;block-size:100%;box-sizing:border-box;border-radius:var(--mod-swatch-border-radius,var(--spectrum-swatch-border-radius));justify-content:center;align-items:center;display:flex;position:relative;overflow:hidden}.fill:before{content:\"\";z-index:0;box-shadow:inset 0 0 0 var(--mod-swatch-border-thickness,var(--spectrum-swatch-border-thickness))var(--highcontrast-swatch-border-color,var(--mod-swatch-border-color,var(--spectrum-swatch-border-color)));border-radius:var(--mod-swatch-border-radius,var(--spectrum-swatch-border-radius));position:absolute;inset:0}:host([border=none]) .fill:before,.fill:before{background-color:initial;background-color:var(--spectrum-picked-color,transparent)}:host([border=none]) .fill:before{box-shadow:none}:host([border=light]) .fill:before{box-shadow:inset 0 0 0 var(--mod-swatch-border-thickness,var(--spectrum-swatch-border-thickness))var(--highcontrast-swatch-border-color-light,var(--mod-swatch-border-color-light,var(--spectrum-swatch-border-color-light)))}.mixedValueIcon{pointer-events:none;color:#0000;color:var(--spectrum-picked-color,transparent);display:none}.disabledIcon{z-index:1;pointer-events:none;color:var(--highcontrast-swatch-disabled-icon-color,var(--mod-swatch-disabled-icon-color,var(--spectrum-swatch-disabled-icon-color)));stroke:var(--highcontrast-swatch-disabled-icon-color,var(--mod-swatch-disabled-icon-color,var(--spectrum-swatch-disabled-icon-color)));display:none;position:relative}.disabledIcon path:first-child{fill:var(--highcontrast-swatch-disabled-icon-color,var(--mod-swatch-disabled-icon-color,var(--spectrum-swatch-disabled-icon-color)))}.disabledIcon path:last-child{fill:var(--mod-swatch-icon-border-color,var(--spectrum-swatch-icon-border-color))}:host([shape=rectangle]){inline-size:calc(var(--mod-swatch-size,var(--spectrum-swatch-size))*2)}:host([rounding=none]),:host([rounding=none]) .fill,:host([rounding=none]) .fill:before,:host([rounding=none][selected]) .fill,:host([rounding=none][selected]) .fill:before,:host([rounding=none]):after,:host([rounding=none]):before{border-radius:0}:host([rounding=full][selected]:not([shape=rectangle])) .fill,:host([rounding=full][selected]:not([shape=rectangle])) .fill:before,:host([rounding=full]:not([shape=rectangle])),:host([rounding=full]:not([shape=rectangle])) .fill,:host([rounding=full]:not([shape=rectangle])) .fill:before,:host([rounding=full]:not([shape=rectangle])):after,:host([rounding=full]:not([shape=rectangle])):before{border-radius:100%}:host([rounding=full][selected]:not([shape=rectangle])) .fill{clip-path:circle(calc(50% - var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2)at 50% 50%)}::slotted([slot=image]){object-fit:contain;inline-size:100%;block-size:100%;transition:width var(--mod-animation-duration-100,var(--spectrum-animation-duration-100))ease-in-out,height var(--mod-animation-duration-100,var(--spectrum-animation-duration-100))ease-in-out}\n`;\nexport default styles;"],
|
|
5
|
+
"mappings": ";AAWA,SAAS,WAAW;AACpB,MAAM,SAAS;AAAA;AAAA;AAGf,eAAe;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";import{css as e}from"@spectrum-web-components/base";const o=e`
|
|
2
|
+
@media (forced-colors:active){:host{--highcontrast-swatch-disabled-icon-color:GrayText;--highcontrast-swatch-focus-indicator-color:ButtonText;--highcontrast-swatch-background-color-selected:Background;--highcontrast-swatch-border-color-selected:Highlight;--highcontrast-swatch-border-color:ButtonText;--highcontrast-swatch-fill-foreground-color:ButtonText}.fill{forced-color-adjust:none}:host([disabled]),:host([disabled]){--highcontrast-swatch-border-color:GrayText}}:host{inline-size:var(--mod-swatch-size,var(--spectrum-swatch-size));block-size:var(--mod-swatch-size,var(--spectrum-swatch-size));-webkit-user-select:none;user-select:none;outline:none;justify-content:center;align-items:center;display:flex;position:relative}.disabledIcon{inline-size:var(--mod-swatch-disabled-icon-size,var(--spectrum-swatch-disabled-icon-size));block-size:var(--mod-swatch-disabled-icon-size,var(--spectrum-swatch-disabled-icon-size))}:host,:host:before{border-radius:var(--mod-swatch-border-radius,var(--spectrum-swatch-border-radius))}:host([selected]){background-color:var(--highcontrast-swatch-background-color-selected,var(--mod-swatch-inner-border-color-selected,var(--spectrum-swatch-inner-border-color-selected)))}:host([selected]) .fill{clip-path:polygon(calc(var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2)calc(var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2),calc(100% - var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2)calc(var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2),calc(100% - var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2)calc(100% - var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2),calc(var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2)calc(100% - var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2));border-radius:0}:host([selected]) .fill:before{box-shadow:none;border-radius:0}:host([selected]):before{opacity:1}:host .is-image .fill:before{background-color:initial}:host([mixed-value]) .fill{background:0 0;background:var(--spectrum-picked-color,transparent)}:host([mixed-value]) .mixedValueIcon{color:var(--spectrum-swatch-dash-icon-color);display:block}:host([nothing]) .fill{background-color:initial;background-color:var(--spectrum-picked-color,transparent);background-image:none}:host([nothing]) .fill:after{inline-size:var(--mod-swatch-slash-thickness,var(--spectrum-swatch-slash-thickness));content:"";block-size:200%;background:var(--highcontrast-swatch-fill-foreground-color,var(--mod-swatch-slash-icon-color,var(--spectrum-swatch-slash-icon-color)));position:absolute;transform:rotate(-45deg)}:host([nothing][shape=rectangle]) .fill:after{transform:rotate(-25deg)}:host([disabled]) .disabledIcon,:host([disabled]) .disabledIcon{display:block}:host:before{content:"";border-width:var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected));border-style:solid;border-color:var(--highcontrast-swatch-border-color-selected,var(--mod-swatch-border-color-selected,var(--spectrum-swatch-border-color-selected)));opacity:0;pointer-events:none;position:absolute;inset:0}:host:after{content:"";inset:calc(var(--mod-swatch-focus-indicator-gap,var(--spectrum-swatch-focus-indicator-gap))*-2);opacity:0;border-width:var(--mod-swatch-focus-indicator-thickness,var(--spectrum-swatch-focus-indicator-thickness));border-style:solid;border-color:var(--highcontrast-swatch-focus-indicator-color,var(--mod-swatch-focus-indicator-color,var(--spectrum-swatch-focus-indicator-color)));border-radius:var(--mod-swatch-focus-indicator-border-radius,var(--spectrum-swatch-focus-indicator-border-radius));transition:opacity var(--mod-animation-duration-100,var(--spectrum-animation-duration-100))ease-in-out;position:absolute}:host(:focus-visible):after{opacity:1}.fill{inline-size:100%;block-size:100%;box-sizing:border-box;border-radius:var(--mod-swatch-border-radius,var(--spectrum-swatch-border-radius));justify-content:center;align-items:center;display:flex;position:relative;overflow:hidden}.fill:before{content:"";z-index:0;box-shadow:inset 0 0 0 var(--mod-swatch-border-thickness,var(--spectrum-swatch-border-thickness))var(--highcontrast-swatch-border-color,var(--mod-swatch-border-color,var(--spectrum-swatch-border-color)));border-radius:var(--mod-swatch-border-radius,var(--spectrum-swatch-border-radius));position:absolute;inset:0}:host([border=none]) .fill:before,.fill:before{background-color:initial;background-color:var(--spectrum-picked-color,transparent)}:host([border=none]) .fill:before{box-shadow:none}:host([border=light]) .fill:before{box-shadow:inset 0 0 0 var(--mod-swatch-border-thickness,var(--spectrum-swatch-border-thickness))var(--highcontrast-swatch-border-color-light,var(--mod-swatch-border-color-light,var(--spectrum-swatch-border-color-light)))}.mixedValueIcon{pointer-events:none;color:#0000;color:var(--spectrum-picked-color,transparent);display:none}.disabledIcon{z-index:1;pointer-events:none;color:var(--highcontrast-swatch-disabled-icon-color,var(--mod-swatch-disabled-icon-color,var(--spectrum-swatch-disabled-icon-color)));stroke:var(--highcontrast-swatch-disabled-icon-color,var(--mod-swatch-disabled-icon-color,var(--spectrum-swatch-disabled-icon-color)));display:none;position:relative}.disabledIcon path:first-child{fill:var(--highcontrast-swatch-disabled-icon-color,var(--mod-swatch-disabled-icon-color,var(--spectrum-swatch-disabled-icon-color)))}.disabledIcon path:last-child{fill:var(--mod-swatch-icon-border-color,var(--spectrum-swatch-icon-border-color))}:host([shape=rectangle]){inline-size:calc(var(--mod-swatch-size,var(--spectrum-swatch-size))*2)}:host([rounding=none]),:host([rounding=none]) .fill,:host([rounding=none]) .fill:before,:host([rounding=none][selected]) .fill,:host([rounding=none][selected]) .fill:before,:host([rounding=none]):after,:host([rounding=none]):before{border-radius:0}:host([rounding=full][selected]:not([shape=rectangle])) .fill,:host([rounding=full][selected]:not([shape=rectangle])) .fill:before,:host([rounding=full]:not([shape=rectangle])),:host([rounding=full]:not([shape=rectangle])) .fill,:host([rounding=full]:not([shape=rectangle])) .fill:before,:host([rounding=full]:not([shape=rectangle])):after,:host([rounding=full]:not([shape=rectangle])):before{border-radius:100%}:host([rounding=full][selected]:not([shape=rectangle])) .fill{clip-path:circle(calc(50% - var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2)at 50% 50%)}::slotted([slot=image]){object-fit:contain;inline-size:100%;block-size:100%;transition:width var(--mod-animation-duration-100,var(--spectrum-animation-duration-100))ease-in-out,height var(--mod-animation-duration-100,var(--spectrum-animation-duration-100))ease-in-out}
|
|
3
|
+
`;export default o;
|
|
4
|
+
//# sourceMappingURL=spectrum-swatch.css.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["spectrum-swatch.css.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2025 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 { css } from '@spectrum-web-components/base';\nconst styles = css`\n @media (forced-colors:active){:host{--highcontrast-swatch-disabled-icon-color:GrayText;--highcontrast-swatch-focus-indicator-color:ButtonText;--highcontrast-swatch-background-color-selected:Background;--highcontrast-swatch-border-color-selected:Highlight;--highcontrast-swatch-border-color:ButtonText;--highcontrast-swatch-fill-foreground-color:ButtonText}.fill{forced-color-adjust:none}:host([disabled]),:host([disabled]){--highcontrast-swatch-border-color:GrayText}}:host{inline-size:var(--mod-swatch-size,var(--spectrum-swatch-size));block-size:var(--mod-swatch-size,var(--spectrum-swatch-size));-webkit-user-select:none;user-select:none;outline:none;justify-content:center;align-items:center;display:flex;position:relative}.disabledIcon{inline-size:var(--mod-swatch-disabled-icon-size,var(--spectrum-swatch-disabled-icon-size));block-size:var(--mod-swatch-disabled-icon-size,var(--spectrum-swatch-disabled-icon-size))}:host,:host:before{border-radius:var(--mod-swatch-border-radius,var(--spectrum-swatch-border-radius))}:host([selected]){background-color:var(--highcontrast-swatch-background-color-selected,var(--mod-swatch-inner-border-color-selected,var(--spectrum-swatch-inner-border-color-selected)))}:host([selected]) .fill{clip-path:polygon(calc(var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2)calc(var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2),calc(100% - var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2)calc(var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2),calc(100% - var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2)calc(100% - var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2),calc(var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2)calc(100% - var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2));border-radius:0}:host([selected]) .fill:before{box-shadow:none;border-radius:0}:host([selected]):before{opacity:1}:host .is-image .fill:before{background-color:initial}:host([mixed-value]) .fill{background:0 0;background:var(--spectrum-picked-color,transparent)}:host([mixed-value]) .mixedValueIcon{color:var(--spectrum-swatch-dash-icon-color);display:block}:host([nothing]) .fill{background-color:initial;background-color:var(--spectrum-picked-color,transparent);background-image:none}:host([nothing]) .fill:after{inline-size:var(--mod-swatch-slash-thickness,var(--spectrum-swatch-slash-thickness));content:\"\";block-size:200%;background:var(--highcontrast-swatch-fill-foreground-color,var(--mod-swatch-slash-icon-color,var(--spectrum-swatch-slash-icon-color)));position:absolute;transform:rotate(-45deg)}:host([nothing][shape=rectangle]) .fill:after{transform:rotate(-25deg)}:host([disabled]) .disabledIcon,:host([disabled]) .disabledIcon{display:block}:host:before{content:\"\";border-width:var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected));border-style:solid;border-color:var(--highcontrast-swatch-border-color-selected,var(--mod-swatch-border-color-selected,var(--spectrum-swatch-border-color-selected)));opacity:0;pointer-events:none;position:absolute;inset:0}:host:after{content:\"\";inset:calc(var(--mod-swatch-focus-indicator-gap,var(--spectrum-swatch-focus-indicator-gap))*-2);opacity:0;border-width:var(--mod-swatch-focus-indicator-thickness,var(--spectrum-swatch-focus-indicator-thickness));border-style:solid;border-color:var(--highcontrast-swatch-focus-indicator-color,var(--mod-swatch-focus-indicator-color,var(--spectrum-swatch-focus-indicator-color)));border-radius:var(--mod-swatch-focus-indicator-border-radius,var(--spectrum-swatch-focus-indicator-border-radius));transition:opacity var(--mod-animation-duration-100,var(--spectrum-animation-duration-100))ease-in-out;position:absolute}:host(:focus-visible):after{opacity:1}.fill{inline-size:100%;block-size:100%;box-sizing:border-box;border-radius:var(--mod-swatch-border-radius,var(--spectrum-swatch-border-radius));justify-content:center;align-items:center;display:flex;position:relative;overflow:hidden}.fill:before{content:\"\";z-index:0;box-shadow:inset 0 0 0 var(--mod-swatch-border-thickness,var(--spectrum-swatch-border-thickness))var(--highcontrast-swatch-border-color,var(--mod-swatch-border-color,var(--spectrum-swatch-border-color)));border-radius:var(--mod-swatch-border-radius,var(--spectrum-swatch-border-radius));position:absolute;inset:0}:host([border=none]) .fill:before,.fill:before{background-color:initial;background-color:var(--spectrum-picked-color,transparent)}:host([border=none]) .fill:before{box-shadow:none}:host([border=light]) .fill:before{box-shadow:inset 0 0 0 var(--mod-swatch-border-thickness,var(--spectrum-swatch-border-thickness))var(--highcontrast-swatch-border-color-light,var(--mod-swatch-border-color-light,var(--spectrum-swatch-border-color-light)))}.mixedValueIcon{pointer-events:none;color:#0000;color:var(--spectrum-picked-color,transparent);display:none}.disabledIcon{z-index:1;pointer-events:none;color:var(--highcontrast-swatch-disabled-icon-color,var(--mod-swatch-disabled-icon-color,var(--spectrum-swatch-disabled-icon-color)));stroke:var(--highcontrast-swatch-disabled-icon-color,var(--mod-swatch-disabled-icon-color,var(--spectrum-swatch-disabled-icon-color)));display:none;position:relative}.disabledIcon path:first-child{fill:var(--highcontrast-swatch-disabled-icon-color,var(--mod-swatch-disabled-icon-color,var(--spectrum-swatch-disabled-icon-color)))}.disabledIcon path:last-child{fill:var(--mod-swatch-icon-border-color,var(--spectrum-swatch-icon-border-color))}:host([shape=rectangle]){inline-size:calc(var(--mod-swatch-size,var(--spectrum-swatch-size))*2)}:host([rounding=none]),:host([rounding=none]) .fill,:host([rounding=none]) .fill:before,:host([rounding=none][selected]) .fill,:host([rounding=none][selected]) .fill:before,:host([rounding=none]):after,:host([rounding=none]):before{border-radius:0}:host([rounding=full][selected]:not([shape=rectangle])) .fill,:host([rounding=full][selected]:not([shape=rectangle])) .fill:before,:host([rounding=full]:not([shape=rectangle])),:host([rounding=full]:not([shape=rectangle])) .fill,:host([rounding=full]:not([shape=rectangle])) .fill:before,:host([rounding=full]:not([shape=rectangle])):after,:host([rounding=full]:not([shape=rectangle])):before{border-radius:100%}:host([rounding=full][selected]:not([shape=rectangle])) .fill{clip-path:circle(calc(50% - var(--mod-swatch-border-thickness-selected,var(--spectrum-swatch-border-thickness-selected))*2)at 50% 50%)}::slotted([slot=image]){object-fit:contain;inline-size:100%;block-size:100%;transition:width var(--mod-animation-duration-100,var(--spectrum-animation-duration-100))ease-in-out,height var(--mod-animation-duration-100,var(--spectrum-animation-duration-100))ease-in-out}\n`;\nexport default styles;"],
|
|
5
|
+
"mappings": "aAWA,OAAS,OAAAA,MAAW,gCACpB,MAAMC,EAASD;AAAA;AAAA,EAGf,eAAeC",
|
|
6
|
+
"names": ["css", "styles"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { css } from "@spectrum-web-components/base";
|
|
3
|
+
const styles = css`
|
|
4
|
+
:host{--spectrum-swatchgroup-spacing-compact:var(--system-swatch-group-spacing-compact);--spectrum-swatchgroup-spacing-regular:var(--system-swatch-group-spacing-regular);--spectrum-swatchgroup-spacing-spacious:var(--system-swatch-group-spacing-spacious)}
|
|
5
|
+
`;
|
|
6
|
+
export default styles;
|
|
7
|
+
//# sourceMappingURL=swatch-group-overrides.css.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["swatch-group-overrides.css.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2025 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 { css } from '@spectrum-web-components/base';\nconst styles = css`\n :host{--spectrum-swatchgroup-spacing-compact:var(--system-swatch-group-spacing-compact);--spectrum-swatchgroup-spacing-regular:var(--system-swatch-group-spacing-regular);--spectrum-swatchgroup-spacing-spacious:var(--system-swatch-group-spacing-spacious)}\n`;\nexport default styles;"],
|
|
5
|
+
"mappings": ";AAWA,SAAS,WAAW;AACpB,MAAM,SAAS;AAAA;AAAA;AAGf,eAAe;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";import{css as s}from"@spectrum-web-components/base";const c=s`
|
|
2
|
+
:host{--spectrum-swatchgroup-spacing-compact:var(--system-swatch-group-spacing-compact);--spectrum-swatchgroup-spacing-regular:var(--system-swatch-group-spacing-regular);--spectrum-swatchgroup-spacing-spacious:var(--system-swatch-group-spacing-spacious)}
|
|
3
|
+
`;export default c;
|
|
4
|
+
//# sourceMappingURL=swatch-group-overrides.css.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["swatch-group-overrides.css.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2025 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 { css } from '@spectrum-web-components/base';\nconst styles = css`\n :host{--spectrum-swatchgroup-spacing-compact:var(--system-swatch-group-spacing-compact);--spectrum-swatchgroup-spacing-regular:var(--system-swatch-group-spacing-regular);--spectrum-swatchgroup-spacing-spacious:var(--system-swatch-group-spacing-spacious)}\n`;\nexport default styles;"],
|
|
5
|
+
"mappings": "aAWA,OAAS,OAAAA,MAAW,gCACpB,MAAMC,EAASD;AAAA;AAAA,EAGf,eAAeC",
|
|
6
|
+
"names": ["css", "styles"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { css } from "@spectrum-web-components/base";
|
|
3
|
+
const styles = css`
|
|
4
|
+
:host{justify-content:flex-start;align-items:flex-start;gap:var(--mod-swatchgroup-spacing-regular,var(--spectrum-swatchgroup-spacing-regular));flex-flow:wrap;display:inline-flex}:host([density=compact]){gap:var(--mod-swatchgroup-spacing-compact,var(--spectrum-swatchgroup-spacing-compact))}:host([density=spacious]){gap:var(--mod-swatchgroup-spacing-spacious,var(--spectrum-swatchgroup-spacing-spacious))}:host{--spectrum-swatchgroup-spacing-compact:var(--system-swatch-group-spacing-compact);--spectrum-swatchgroup-spacing-regular:var(--system-swatch-group-spacing-regular);--spectrum-swatchgroup-spacing-spacious:var(--system-swatch-group-spacing-spacious)}
|
|
5
|
+
`;
|
|
6
|
+
export default styles;
|
|
7
|
+
//# sourceMappingURL=swatch-group.css.dev.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["swatch-group.css.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2025 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 { css } from '@spectrum-web-components/base';\nconst styles = css`\n :host{justify-content:flex-start;align-items:flex-start;gap:var(--mod-swatchgroup-spacing-regular,var(--spectrum-swatchgroup-spacing-regular));flex-flow:wrap;display:inline-flex}:host([density=compact]){gap:var(--mod-swatchgroup-spacing-compact,var(--spectrum-swatchgroup-spacing-compact))}:host([density=spacious]){gap:var(--mod-swatchgroup-spacing-spacious,var(--spectrum-swatchgroup-spacing-spacious))}:host{--spectrum-swatchgroup-spacing-compact:var(--system-swatch-group-spacing-compact);--spectrum-swatchgroup-spacing-regular:var(--system-swatch-group-spacing-regular);--spectrum-swatchgroup-spacing-spacious:var(--system-swatch-group-spacing-spacious)}\n`;\nexport default styles;"],
|
|
5
|
+
"mappings": ";AAWA,SAAS,WAAW;AACpB,MAAM,SAAS;AAAA;AAAA;AAGf,eAAe;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|