@spectrum-web-components/reactive-controllers 1.9.0 → 1.9.1-nightly.20251028214328
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/CHANGELOG.md +391 -0
- package/package.json +94 -94
- package/src/PendingState.dev.js.map +1 -1
- package/src/PendingState.js.map +1 -1
- package/test/color-controller.test.js +208 -0
- package/test/color-controller.test.js.map +7 -0
- package/test/dependency-manager.test.js +24 -0
- package/test/dependency-manager.test.js.map +7 -0
- package/test/element-resolution.test.js +38 -0
- package/test/element-resolution.test.js.map +7 -0
- package/test/helpers.js +23 -0
- package/test/helpers.js.map +7 -0
- package/test/match-media.test.js +27 -0
- package/test/match-media.test.js.map +7 -0
- package/test/pending-state.test.js +130 -0
- package/test/pending-state.test.js.map +7 -0
- package/test/roving-tabindex-integration.test.js +215 -0
- package/test/roving-tabindex-integration.test.js.map +7 -0
- package/test/roving-tabindex.test.js +19 -0
- package/test/roving-tabindex.test.js.map +7 -0
package/src/PendingState.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["PendingState.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport '@spectrum-web-components/progress-circle/sp-progress-circle.js';\nimport { html, LitElement, ReactiveController, TemplateResult } from 'lit';\n\n/**\n * Renders a pending state visual element and manages the aria-label of the host element.\n
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport '@spectrum-web-components/progress-circle/sp-progress-circle.js';\nimport { html, LitElement, ReactiveController, TemplateResult } from 'lit';\n\n/**\n * Renders a pending state visual element and manages the aria-label of the host element.\n *\n * Currently this is used by Button only since the host element is the interactive element that needs pending state. This pattern does not work for components where the interactive element that needs pending state is in the shadow DOM. i.e. Combobox and Picker.\n *\n * @TODO consider deprecating this controller since it is not used by any other component.\n */\nexport interface HostWithPendingState extends LitElement {\n pendingLabel?: string;\n pending: boolean;\n disabled: boolean;\n pendingStateController: PendingStateController<HostWithPendingState>;\n}\n\n/**\n * Represents a controller for managing the pending state of a reactive element.\n *\n * @template T - The type of the reactive element.\n */\nexport class PendingStateController<T extends HostWithPendingState>\n implements ReactiveController\n{\n /**\n * The host element that this controller is attached to.\n */\n public host: T;\n\n /**\n * Creates an instance of PendingStateController.\n * @param host - The host element that this controller is attached to.\n */\n constructor(host: T) {\n this.host = host;\n this.host.addController(this);\n }\n\n public cachedAriaLabel: string | null = null;\n /**\n * Renders the pending state UI.\n * @returns A TemplateResult representing the pending state UI.\n *\n * @TODO [SWC-1119, SWC-1255, SWC-459] Confirm the accessibility warning and a11y dom tree are accurate for the pending state in button, combobox, and picker components.\n */\n public renderPendingState(): TemplateResult {\n return this.host.pending\n ? html`\n <sp-progress-circle\n id=\"loader\"\n size=\"s\"\n indeterminate\n class=\"progress-circle\"\n role=\"presentation\"\n ></sp-progress-circle>\n `\n : html``;\n }\n\n /**\n * Updates the ARIA label of the host element based on the pending state.\n * Manages Cached Aria Label\n */\n private updateAriaLabel(): void {\n const { pending, disabled, pendingLabel } = this.host;\n const currentAriaLabel = this.host.getAttribute('aria-label');\n\n function shouldCacheAriaLabel(\n cached: string | null,\n current: string | null,\n pending: string | undefined\n ): boolean {\n return (\n (!cached && current !== pending) ||\n (cached !== current && current !== pending)\n );\n }\n\n // If the current `aria-label` is different from the pending label, cache it\n // or if the cached `aria-label` is different from the current `aria-label`, cache it\n if (\n shouldCacheAriaLabel(\n this.cachedAriaLabel,\n currentAriaLabel,\n pendingLabel\n )\n ) {\n this.cachedAriaLabel = currentAriaLabel;\n }\n\n if (pending && !disabled) {\n // Since it is pending, we set the aria-label to `pendingLabel` or \"Pending\"\n this.host.setAttribute('aria-label', pendingLabel || 'Pending');\n } else {\n // Restore the cached `aria-label` if it exists\n if (this.cachedAriaLabel) {\n this.host.setAttribute('aria-label', this.cachedAriaLabel);\n } else {\n this.host.removeAttribute('aria-label');\n }\n }\n }\n\n hostConnected(): void {\n if (!this.cachedAriaLabel)\n this.cachedAriaLabel = this.host.getAttribute('aria-label');\n this.updateAriaLabel();\n }\n\n hostUpdated(): void {\n this.updateAriaLabel();\n }\n}\n"],
|
|
5
5
|
"mappings": "aAYA,MAAO,iEACP,OAAS,QAAAA,MAA4D,MAqB9D,aAAM,sBAEb,CAUI,YAAYC,EAAS,CAKrB,KAAO,gBAAiC,KAJpC,KAAK,KAAOA,EACZ,KAAK,KAAK,cAAc,IAAI,CAChC,CASO,oBAAqC,CACxC,OAAO,KAAK,KAAK,QACXD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBASAA,GACV,CAMQ,iBAAwB,CAC5B,KAAM,CAAE,QAAAE,EAAS,SAAAC,EAAU,aAAAC,CAAa,EAAI,KAAK,KAC3CC,EAAmB,KAAK,KAAK,aAAa,YAAY,EAE5D,SAASC,EACLC,EACAC,EACAN,EACO,CACP,MACK,CAACK,GAAUC,IAAYN,GACvBK,IAAWC,GAAWA,IAAYN,CAE3C,CAKII,EACI,KAAK,gBACLD,EACAD,CACJ,IAEA,KAAK,gBAAkBC,GAGvBH,GAAW,CAACC,EAEZ,KAAK,KAAK,aAAa,aAAcC,GAAgB,SAAS,EAG1D,KAAK,gBACL,KAAK,KAAK,aAAa,aAAc,KAAK,eAAe,EAEzD,KAAK,KAAK,gBAAgB,YAAY,CAGlD,CAEA,eAAsB,CACb,KAAK,kBACN,KAAK,gBAAkB,KAAK,KAAK,aAAa,YAAY,GAC9D,KAAK,gBAAgB,CACzB,CAEA,aAAoB,CAChB,KAAK,gBAAgB,CACzB,CACJ",
|
|
6
6
|
"names": ["html", "host", "pending", "disabled", "pendingLabel", "currentAriaLabel", "shouldCacheAriaLabel", "cached", "current"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { expect } from "@open-wc/testing";
|
|
3
|
+
import Color from "colorjs.io";
|
|
4
|
+
import {
|
|
5
|
+
ColorController
|
|
6
|
+
} from "@spectrum-web-components/reactive-controllers/src/ColorController.js";
|
|
7
|
+
describe("ColorController", () => {
|
|
8
|
+
let host;
|
|
9
|
+
let colorController;
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
host = {};
|
|
12
|
+
host.requestUpdate = () => {
|
|
13
|
+
};
|
|
14
|
+
colorController = new ColorController(host);
|
|
15
|
+
});
|
|
16
|
+
it("should initialize correctly", () => {
|
|
17
|
+
expect(colorController).to.exist;
|
|
18
|
+
expect(colorController.color).to.be.instanceOf(Color);
|
|
19
|
+
});
|
|
20
|
+
it("should validate color strings correctly", () => {
|
|
21
|
+
const validRgba = "rgba(255, 0, 0, 1)";
|
|
22
|
+
const validHsla = "hsla(120, 100%, 50%, 0.5)";
|
|
23
|
+
const validHsva = "hsva(240, 100%, 100%, 0.75)";
|
|
24
|
+
const invalidColor = "invalidColor";
|
|
25
|
+
expect(colorController.validateColorString(validRgba).isValid).to.be.true;
|
|
26
|
+
expect(colorController.validateColorString(validHsla).isValid).to.be.true;
|
|
27
|
+
expect(colorController.validateColorString(validHsva).isValid).to.be.true;
|
|
28
|
+
expect(colorController.validateColorString(invalidColor).isValid).to.be.false;
|
|
29
|
+
});
|
|
30
|
+
it("should process RGB values in percentage correctly", () => {
|
|
31
|
+
const colorString = "rgb(50%, 25%, 75%)";
|
|
32
|
+
const result = colorController.validateColorString(colorString);
|
|
33
|
+
expect(result.isValid).to.be.true;
|
|
34
|
+
expect(result.coords).to.deep.equal([0.5, 0.25, 0.75]);
|
|
35
|
+
expect(result.spaceId).to.equal("srgb");
|
|
36
|
+
});
|
|
37
|
+
it("should default alpha to 1 when alpha is undefined in RGBA", () => {
|
|
38
|
+
const colorString = "rgb(255, 0, 0)";
|
|
39
|
+
const result = colorController.validateColorString(colorString);
|
|
40
|
+
expect(result.alpha).to.equal(1);
|
|
41
|
+
expect(result.isValid).to.be.true;
|
|
42
|
+
expect(result.coords).to.deep.equal([1, 0, 0]);
|
|
43
|
+
expect(result.spaceId).to.equal("srgb");
|
|
44
|
+
});
|
|
45
|
+
it("should handle invalid color strings by trying to create a new Color object with a prefixed #", () => {
|
|
46
|
+
const invalidColorString = "invalidColor";
|
|
47
|
+
const validHexColorString = "ff0000";
|
|
48
|
+
colorController.color = invalidColorString;
|
|
49
|
+
expect(colorController.color.toString()).to.equal(
|
|
50
|
+
new Color("hsv", [0, 100, 100], 1).toString()
|
|
51
|
+
);
|
|
52
|
+
colorController.color = validHexColorString;
|
|
53
|
+
expect(colorController.color.toString()).to.equal(
|
|
54
|
+
new Color(`#${validHexColorString}`).toString()
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
it("should set color correctly with string input", () => {
|
|
58
|
+
const colorString = "rgba(255, 0, 0, 1)";
|
|
59
|
+
colorController.color = colorString;
|
|
60
|
+
expect(colorController.color.toString()).to.equal(
|
|
61
|
+
new Color(colorString).toString()
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
it("should set color correctly with object input", () => {
|
|
65
|
+
const colorObject = { r: 255, g: 0, b: 0, a: 1 };
|
|
66
|
+
colorController.color = colorObject;
|
|
67
|
+
});
|
|
68
|
+
it("should get color value correctly", () => {
|
|
69
|
+
let colorString = "rgba(255, 0, 0, 0.7)";
|
|
70
|
+
colorController.color = colorString;
|
|
71
|
+
expect(colorController.colorValue).to.equal(colorString);
|
|
72
|
+
colorString = "hsla(120, 100%, 50%, 0.5)";
|
|
73
|
+
colorController.color = colorString;
|
|
74
|
+
expect(colorController.colorValue).to.equal(colorString);
|
|
75
|
+
});
|
|
76
|
+
it("should get and set hue correctly", () => {
|
|
77
|
+
colorController.hue = 180;
|
|
78
|
+
expect(colorController.hue).to.equal(180);
|
|
79
|
+
});
|
|
80
|
+
it("should convert color correctly", () => {
|
|
81
|
+
const colorString = "rgba(255, 0, 0, 1)";
|
|
82
|
+
colorController.color = colorString;
|
|
83
|
+
expect(colorController.getColor("hsl")).to.be.an("object");
|
|
84
|
+
});
|
|
85
|
+
it("should get HSL string correctly", () => {
|
|
86
|
+
const colorString = "rgba(255, 0, 0, 1)";
|
|
87
|
+
colorController.color = colorString;
|
|
88
|
+
expect(colorController.getHslString()).to.equal(
|
|
89
|
+
new Color(colorString).to("hsl").toString()
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
it("should process hex color values correctly when alpha is defined", () => {
|
|
93
|
+
const colorString = "#ff573380";
|
|
94
|
+
colorController.color = colorString;
|
|
95
|
+
expect(colorController.color.toString()).to.equal(
|
|
96
|
+
new Color(colorString).toString()
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
it("should process hex color values correctly when alpha is not defined", () => {
|
|
100
|
+
const colorString = "#ff5733";
|
|
101
|
+
colorController.color = colorString;
|
|
102
|
+
expect(colorController.color.toString()).to.equal(
|
|
103
|
+
new Color(colorString).toString()
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
it("should save and restore previous color correctly", () => {
|
|
107
|
+
const colorString = "rgba(255, 0, 0, 1)";
|
|
108
|
+
colorController.color = colorString;
|
|
109
|
+
colorController.savePreviousColor();
|
|
110
|
+
colorController.color = "rgba(0, 255, 0, 1)";
|
|
111
|
+
colorController.restorePreviousColor();
|
|
112
|
+
expect(colorController.color.toString()).to.equal(
|
|
113
|
+
new Color(colorString).toString()
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
it("should return correct color value for hsv spaceId", () => {
|
|
117
|
+
colorController.color = "hsv(120, 100%, 50%)";
|
|
118
|
+
const result = colorController.colorValue;
|
|
119
|
+
expect(result).to.equal("hsv(120, 100%, 50%)");
|
|
120
|
+
});
|
|
121
|
+
it("should return correct color value for hsva spaceId", () => {
|
|
122
|
+
colorController.color = "hsva(120, 100%, 50%, 0.5)";
|
|
123
|
+
const result = colorController.colorValue;
|
|
124
|
+
expect(result).to.equal("hsva(120, 100%, 50%, 0.5)");
|
|
125
|
+
});
|
|
126
|
+
it("should return correct color value for hsl spaceId", () => {
|
|
127
|
+
colorController.color = "hsl(120, 100%, 50%)";
|
|
128
|
+
const result = colorController.colorValue;
|
|
129
|
+
expect(result).to.equal("hsl(120, 100%, 50%)");
|
|
130
|
+
});
|
|
131
|
+
it("should return correct color value for hsla spaceId", () => {
|
|
132
|
+
colorController.color = "hsla(120, 100%, 50%, 0.5)";
|
|
133
|
+
const result = colorController.colorValue;
|
|
134
|
+
expect(result).to.equal("hsla(120, 100%, 50%, 0.5)");
|
|
135
|
+
});
|
|
136
|
+
it("should return correct color value for hex string spaceId", () => {
|
|
137
|
+
colorController.color = "#ff5733";
|
|
138
|
+
const result = colorController.colorValue;
|
|
139
|
+
expect(result).to.equal("#ff5733");
|
|
140
|
+
});
|
|
141
|
+
it("should return correct color value for hex string spaceId with alpha", () => {
|
|
142
|
+
colorController.color = "#ff573380";
|
|
143
|
+
const result = colorController.colorValue;
|
|
144
|
+
expect(result).to.equal("#ff573380");
|
|
145
|
+
});
|
|
146
|
+
it("should return correct color value for default spaceId with hex origin", () => {
|
|
147
|
+
colorController.color = "#ff5733";
|
|
148
|
+
const result = colorController.colorValue;
|
|
149
|
+
expect(result).to.equal("#ff5733");
|
|
150
|
+
});
|
|
151
|
+
it("should return correct color value for default spaceId with hex origin and alpha", () => {
|
|
152
|
+
colorController.color = "#ff573380";
|
|
153
|
+
const result = colorController.colorValue;
|
|
154
|
+
expect(result).to.equal("#ff573380");
|
|
155
|
+
});
|
|
156
|
+
it("should return correct color value for default spaceId with percentage origin", () => {
|
|
157
|
+
colorController.color = "rgb(50%, 25%, 75%)";
|
|
158
|
+
const result = colorController.colorValue;
|
|
159
|
+
expect(result).to.equal("rgb(50%, 25%, 75%)");
|
|
160
|
+
});
|
|
161
|
+
it("should return correct color value for default spaceId with rgba origin", () => {
|
|
162
|
+
colorController.color = "rgba(255, 87, 51, 0.5)";
|
|
163
|
+
const result = colorController.colorValue;
|
|
164
|
+
expect(result).to.equal("rgba(255, 87, 51, 0.5)");
|
|
165
|
+
});
|
|
166
|
+
it("should return correct color values for hsv spaceId", () => {
|
|
167
|
+
colorController.color = new Color("hsv", [120, 100, 50]);
|
|
168
|
+
const result = colorController.colorValue;
|
|
169
|
+
expect(result).to.deep.equal({
|
|
170
|
+
h: 120,
|
|
171
|
+
s: 1,
|
|
172
|
+
v: 0.5,
|
|
173
|
+
a: 1
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
it("should return correct color values for hsl spaceId", () => {
|
|
177
|
+
colorController.color = new Color("hsl", [120, 100, 50]);
|
|
178
|
+
const result = colorController.colorValue;
|
|
179
|
+
expect(result).to.deep.equal({
|
|
180
|
+
h: 120,
|
|
181
|
+
s: 1,
|
|
182
|
+
l: 0.5,
|
|
183
|
+
a: 1
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
it("should return correct color values for srgb spaceId", () => {
|
|
187
|
+
colorController.color = new Color("srgb", [0.5, 0.25, 0.75]);
|
|
188
|
+
const result = colorController.colorValue;
|
|
189
|
+
expect(result).to.deep.equal({
|
|
190
|
+
r: 128,
|
|
191
|
+
g: 64,
|
|
192
|
+
b: 191,
|
|
193
|
+
a: 1
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
it("should return correct color values for srgb spaceId with percentage origin", () => {
|
|
197
|
+
colorController.color = new Color("srgb", [0.5, 0.25, 0.75]);
|
|
198
|
+
colorController.colorOrigin = { r: "50%", g: "25%", b: "75%" };
|
|
199
|
+
const result = colorController.colorValue;
|
|
200
|
+
expect(result).to.deep.equal({
|
|
201
|
+
r: "128%",
|
|
202
|
+
g: "64%",
|
|
203
|
+
b: "191%",
|
|
204
|
+
a: 1
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
//# sourceMappingURL=color-controller.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["color-controller.test.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { expect } from '@open-wc/testing';\nimport { ReactiveElement } from 'lit';\nimport Color from 'colorjs.io';\nimport {\n ColorController,\n ColorTypes,\n} from '@spectrum-web-components/reactive-controllers/src/ColorController.js';\n\ndescribe('ColorController', () => {\n let host: ReactiveElement;\n let colorController: ColorController;\n\n beforeEach(() => {\n host = {} as ReactiveElement;\n host.requestUpdate = () => {};\n colorController = new ColorController(host);\n });\n\n it('should initialize correctly', () => {\n expect(colorController).to.exist;\n expect(colorController.color).to.be.instanceOf(Color);\n });\n\n it('should validate color strings correctly', () => {\n const validRgba = 'rgba(255, 0, 0, 1)';\n const validHsla = 'hsla(120, 100%, 50%, 0.5)';\n const validHsva = 'hsva(240, 100%, 100%, 0.75)';\n const invalidColor = 'invalidColor';\n\n expect(colorController.validateColorString(validRgba).isValid).to.be\n .true;\n expect(colorController.validateColorString(validHsla).isValid).to.be\n .true;\n expect(colorController.validateColorString(validHsva).isValid).to.be\n .true;\n expect(colorController.validateColorString(invalidColor).isValid).to.be\n .false;\n });\n\n it('should process RGB values in percentage correctly', () => {\n const colorString = 'rgb(50%, 25%, 75%)';\n const result = colorController.validateColorString(colorString);\n expect(result.isValid).to.be.true;\n expect(result.coords).to.deep.equal([0.5, 0.25, 0.75]);\n expect(result.spaceId).to.equal('srgb');\n });\n\n it('should default alpha to 1 when alpha is undefined in RGBA', () => {\n const colorString = 'rgb(255, 0, 0)';\n const result = colorController.validateColorString(colorString);\n\n expect(result.alpha).to.equal(1);\n expect(result.isValid).to.be.true;\n expect(result.coords).to.deep.equal([1, 0, 0]);\n expect(result.spaceId).to.equal('srgb');\n });\n\n it('should handle invalid color strings by trying to create a new Color object with a prefixed #', () => {\n const invalidColorString = 'invalidColor';\n const validHexColorString = 'ff0000'; // Equivalent to #ff0000\n\n // Set the invalid color string\n colorController.color = invalidColorString;\n\n // Expect the color to be unchanged (default color)\n expect(colorController.color.toString()).to.equal(\n new Color('hsv', [0, 100, 100], 1).toString()\n );\n\n // Set the valid hex color string without #\n colorController.color = validHexColorString;\n\n // Expect the color to be set correctly\n expect(colorController.color.toString()).to.equal(\n new Color(`#${validHexColorString}`).toString()\n );\n });\n\n it('should set color correctly with string input', () => {\n const colorString = 'rgba(255, 0, 0, 1)';\n colorController.color = colorString;\n expect(colorController.color.toString()).to.equal(\n new Color(colorString).toString()\n );\n });\n\n it('should set color correctly with object input', () => {\n const colorObject: ColorTypes = { r: 255, g: 0, b: 0, a: 1 };\n colorController.color = colorObject;\n //expect(colorController.color.toString()).to.equal(new Color(colorObject).toString());\n });\n\n it('should get color value correctly', () => {\n let colorString = 'rgba(255, 0, 0, 0.7)';\n colorController.color = colorString;\n expect(colorController.colorValue).to.equal(colorString);\n colorString = 'hsla(120, 100%, 50%, 0.5)';\n colorController.color = colorString;\n expect(colorController.colorValue).to.equal(colorString);\n });\n\n it('should get and set hue correctly', () => {\n colorController.hue = 180;\n expect(colorController.hue).to.equal(180);\n });\n\n it('should convert color correctly', () => {\n const colorString = 'rgba(255, 0, 0, 1)';\n colorController.color = colorString;\n expect(colorController.getColor('hsl')).to.be.an('object');\n });\n\n it('should get HSL string correctly', () => {\n const colorString = 'rgba(255, 0, 0, 1)';\n colorController.color = colorString;\n expect(colorController.getHslString()).to.equal(\n new Color(colorString).to('hsl').toString()\n );\n });\n\n it('should process hex color values correctly when alpha is defined', () => {\n const colorString = '#ff573380'; // Equivalent to rgba(255, 87, 51, 0.5)\n colorController.color = colorString;\n expect(colorController.color.toString()).to.equal(\n new Color(colorString).toString()\n );\n });\n\n it('should process hex color values correctly when alpha is not defined', () => {\n const colorString = '#ff5733'; // Equivalent to rgba(255, 87, 51, 1)\n colorController.color = colorString;\n expect(colorController.color.toString()).to.equal(\n new Color(colorString).toString()\n );\n });\n\n it('should save and restore previous color correctly', () => {\n const colorString = 'rgba(255, 0, 0, 1)';\n colorController.color = colorString;\n colorController.savePreviousColor();\n colorController.color = 'rgba(0, 255, 0, 1)';\n colorController.restorePreviousColor();\n expect(colorController.color.toString()).to.equal(\n new Color(colorString).toString()\n );\n });\n it('should return correct color value for hsv spaceId', () => {\n colorController.color = 'hsv(120, 100%, 50%)';\n const result = colorController.colorValue;\n expect(result).to.equal('hsv(120, 100%, 50%)');\n });\n\n it('should return correct color value for hsva spaceId', () => {\n colorController.color = 'hsva(120, 100%, 50%, 0.5)';\n const result = colorController.colorValue;\n expect(result).to.equal('hsva(120, 100%, 50%, 0.5)');\n });\n\n it('should return correct color value for hsl spaceId', () => {\n colorController.color = 'hsl(120, 100%, 50%)';\n const result = colorController.colorValue;\n expect(result).to.equal('hsl(120, 100%, 50%)');\n });\n\n it('should return correct color value for hsla spaceId', () => {\n colorController.color = 'hsla(120, 100%, 50%, 0.5)';\n const result = colorController.colorValue;\n expect(result).to.equal('hsla(120, 100%, 50%, 0.5)');\n });\n\n it('should return correct color value for hex string spaceId', () => {\n colorController.color = '#ff5733';\n const result = colorController.colorValue;\n expect(result).to.equal('#ff5733');\n });\n\n it('should return correct color value for hex string spaceId with alpha', () => {\n colorController.color = '#ff573380'; // Equivalent to rgba(255, 87, 51, 0.5)\n const result = colorController.colorValue;\n expect(result).to.equal('#ff573380');\n });\n\n it('should return correct color value for default spaceId with hex origin', () => {\n colorController.color = '#ff5733';\n const result = colorController.colorValue;\n expect(result).to.equal('#ff5733');\n });\n\n it('should return correct color value for default spaceId with hex origin and alpha', () => {\n colorController.color = '#ff573380'; // Equivalent to rgba(255, 87, 51, 0.5)\n const result = colorController.colorValue;\n expect(result).to.equal('#ff573380');\n });\n\n it('should return correct color value for default spaceId with percentage origin', () => {\n colorController.color = 'rgb(50%, 25%, 75%)';\n const result = colorController.colorValue;\n expect(result).to.equal('rgb(50%, 25%, 75%)');\n });\n\n it('should return correct color value for default spaceId with rgba origin', () => {\n colorController.color = 'rgba(255, 87, 51, 0.5)';\n const result = colorController.colorValue;\n expect(result).to.equal('rgba(255, 87, 51, 0.5)');\n });\n\n it('should return correct color values for hsv spaceId', () => {\n colorController.color = new Color('hsv', [120, 100, 50]);\n const result = colorController.colorValue;\n expect(result).to.deep.equal({\n h: 120,\n s: 1,\n v: 0.5,\n a: 1,\n });\n });\n\n it('should return correct color values for hsl spaceId', () => {\n colorController.color = new Color('hsl', [120, 100, 50]);\n const result = colorController.colorValue;\n expect(result).to.deep.equal({\n h: 120,\n s: 1,\n l: 0.5,\n a: 1,\n });\n });\n\n it('should return correct color values for srgb spaceId', () => {\n colorController.color = new Color('srgb', [0.5, 0.25, 0.75]);\n const result = colorController.colorValue;\n expect(result).to.deep.equal({\n r: 128,\n g: 64,\n b: 191,\n a: 1,\n });\n });\n\n it('should return correct color values for srgb spaceId with percentage origin', () => {\n colorController.color = new Color('srgb', [0.5, 0.25, 0.75]);\n colorController.colorOrigin = { r: '50%', g: '25%', b: '75%' };\n const result = colorController.colorValue;\n expect(result).to.deep.equal({\n r: '128%',\n g: '64%',\n b: '191%',\n a: 1,\n });\n });\n});\n"],
|
|
5
|
+
"mappings": ";AAYA,SAAS,cAAc;AAEvB,OAAO,WAAW;AAClB;AAAA,EACI;AAAA,OAEG;AAEP,SAAS,mBAAmB,MAAM;AAC9B,MAAI;AACJ,MAAI;AAEJ,aAAW,MAAM;AACb,WAAO,CAAC;AACR,SAAK,gBAAgB,MAAM;AAAA,IAAC;AAC5B,sBAAkB,IAAI,gBAAgB,IAAI;AAAA,EAC9C,CAAC;AAED,KAAG,+BAA+B,MAAM;AACpC,WAAO,eAAe,EAAE,GAAG;AAC3B,WAAO,gBAAgB,KAAK,EAAE,GAAG,GAAG,WAAW,KAAK;AAAA,EACxD,CAAC;AAED,KAAG,2CAA2C,MAAM;AAChD,UAAM,YAAY;AAClB,UAAM,YAAY;AAClB,UAAM,YAAY;AAClB,UAAM,eAAe;AAErB,WAAO,gBAAgB,oBAAoB,SAAS,EAAE,OAAO,EAAE,GAAG,GAC7D;AACL,WAAO,gBAAgB,oBAAoB,SAAS,EAAE,OAAO,EAAE,GAAG,GAC7D;AACL,WAAO,gBAAgB,oBAAoB,SAAS,EAAE,OAAO,EAAE,GAAG,GAC7D;AACL,WAAO,gBAAgB,oBAAoB,YAAY,EAAE,OAAO,EAAE,GAAG,GAChE;AAAA,EACT,CAAC;AAED,KAAG,qDAAqD,MAAM;AAC1D,UAAM,cAAc;AACpB,UAAM,SAAS,gBAAgB,oBAAoB,WAAW;AAC9D,WAAO,OAAO,OAAO,EAAE,GAAG,GAAG;AAC7B,WAAO,OAAO,MAAM,EAAE,GAAG,KAAK,MAAM,CAAC,KAAK,MAAM,IAAI,CAAC;AACrD,WAAO,OAAO,OAAO,EAAE,GAAG,MAAM,MAAM;AAAA,EAC1C,CAAC;AAED,KAAG,6DAA6D,MAAM;AAClE,UAAM,cAAc;AACpB,UAAM,SAAS,gBAAgB,oBAAoB,WAAW;AAE9D,WAAO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ependencyManagerController } from "@spectrum-web-components/reactive-controllers/src/DependencyManger.js";
|
|
4
|
+
import { spy } from "sinon";
|
|
5
|
+
describe("Dependency Manager", () => {
|
|
6
|
+
it("manages dependencies", async function() {
|
|
7
|
+
this.retries(0);
|
|
8
|
+
const tagName = "some-heavy-element";
|
|
9
|
+
const requestUpdateSpy = spy();
|
|
10
|
+
const manager = new DependencyManagerController({
|
|
11
|
+
requestUpdate: () => requestUpdateSpy()
|
|
12
|
+
});
|
|
13
|
+
expect(manager.loaded).to.be.false;
|
|
14
|
+
manager.add(tagName);
|
|
15
|
+
expect(manager.loaded).to.be.false;
|
|
16
|
+
expect(requestUpdateSpy.notCalled).to.be.true;
|
|
17
|
+
customElements.define(tagName, class extends HTMLElement {
|
|
18
|
+
});
|
|
19
|
+
await nextFrame();
|
|
20
|
+
expect(manager.loaded).to.be.true;
|
|
21
|
+
expect(requestUpdateSpy.notCalled).to.be.false;
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=dependency-manager.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["dependency-manager.test.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { ReactiveElement } from 'lit';\nimport { expect, nextFrame } from '@open-wc/testing';\nimport { DependencyManagerController } from '@spectrum-web-components/reactive-controllers/src/DependencyManger.js';\nimport { spy } from 'sinon';\n\ndescribe('Dependency Manager', () => {\n it('manages dependencies', async function () {\n this.retries(0);\n const tagName = 'some-heavy-element';\n const requestUpdateSpy = spy();\n const manager = new DependencyManagerController({\n requestUpdate: () => requestUpdateSpy(),\n } as unknown as ReactiveElement);\n expect(manager.loaded).to.be.false;\n manager.add(tagName);\n expect(manager.loaded).to.be.false;\n expect(requestUpdateSpy.notCalled).to.be.true;\n customElements.define(tagName, class extends HTMLElement {});\n // Allow time for the registration to propagate.\n await nextFrame();\n expect(manager.loaded).to.be.true;\n expect(requestUpdateSpy.notCalled).to.be.false;\n });\n});\n"],
|
|
5
|
+
"mappings": ";AAaA,SAAS,QAAQ,iBAAiB;AAClC,SAAS,mCAAmC;AAC5C,SAAS,WAAW;AAEpB,SAAS,sBAAsB,MAAM;AACjC,KAAG,wBAAwB,iBAAkB;AACzC,SAAK,QAAQ,CAAC;AACd,UAAM,UAAU;AAChB,UAAM,mBAAmB,IAAI;AAC7B,UAAM,UAAU,IAAI,4BAA4B;AAAA,MAC5C,eAAe,MAAM,iBAAiB;AAAA,IAC1C,CAA+B;AAC/B,WAAO,QAAQ,MAAM,EAAE,GAAG,GAAG;AAC7B,YAAQ,IAAI,OAAO;AACnB,WAAO,QAAQ,MAAM,EAAE,GAAG,GAAG;AAC7B,WAAO,iBAAiB,SAAS,EAAE,GAAG,GAAG;AACzC,mBAAe,OAAO,SAAS,cAAc,YAAY;AAAA,IAAC,CAAC;AAE3D,UAAM,UAAU;AAChB,WAAO,QAAQ,MAAM,EAAE,GAAG,GAAG;AAC7B,WAAO,iBAAiB,SAAS,EAAE,GAAG,GAAG;AAAA,EAC7C,CAAC;AACL,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { html, LitElement } from "lit";
|
|
3
|
+
import { elementUpdated, expect, fixture } from "@open-wc/testing";
|
|
4
|
+
import { ElementResolutionController } from "@spectrum-web-components/reactive-controllers/src/ElementResolution.js";
|
|
5
|
+
describe("Element Resolution", () => {
|
|
6
|
+
it("responds to DOM changes", async () => {
|
|
7
|
+
class TestEl extends LitElement {
|
|
8
|
+
}
|
|
9
|
+
if (!customElements.get("test-element-resolution-el")) {
|
|
10
|
+
customElements.define("test-element-resolution-el", TestEl);
|
|
11
|
+
}
|
|
12
|
+
const test = await fixture(html`
|
|
13
|
+
<div>
|
|
14
|
+
<test-element-resolution-el></test-element-resolution-el>
|
|
15
|
+
<div class="target" id="one"></div>
|
|
16
|
+
<div class="target" id="two"></div>
|
|
17
|
+
</div>
|
|
18
|
+
`);
|
|
19
|
+
const el = test.querySelector("test-element-resolution-el");
|
|
20
|
+
const target1 = test.querySelector("#one");
|
|
21
|
+
const target2 = test.querySelector("#two");
|
|
22
|
+
const controller = new ElementResolutionController(el);
|
|
23
|
+
expect(controller.element).to.be.null;
|
|
24
|
+
controller.selector = ".target";
|
|
25
|
+
await elementUpdated(el);
|
|
26
|
+
expect(controller.element === target1).to.be.true;
|
|
27
|
+
test.insertAdjacentElement("afterbegin", target2);
|
|
28
|
+
await elementUpdated(el);
|
|
29
|
+
expect(controller.element === target2).to.be.true;
|
|
30
|
+
target2.setAttribute("class", "not-target");
|
|
31
|
+
await elementUpdated(el);
|
|
32
|
+
expect(controller.element === target1).to.be.true;
|
|
33
|
+
target2.setAttribute("class", "target");
|
|
34
|
+
await elementUpdated(el);
|
|
35
|
+
expect(controller.element === target2).to.be.true;
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=element-resolution.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["element-resolution.test.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { html, LitElement } from 'lit';\nimport { elementUpdated, expect, fixture } from '@open-wc/testing';\nimport { ElementResolutionController } from '@spectrum-web-components/reactive-controllers/src/ElementResolution.js';\n\ndescribe('Element Resolution', () => {\n it('responds to DOM changes', async () => {\n class TestEl extends LitElement {}\n if (!customElements.get('test-element-resolution-el')) {\n customElements.define('test-element-resolution-el', TestEl);\n }\n const test = await fixture(html`\n <div>\n <test-element-resolution-el></test-element-resolution-el>\n <div class=\"target\" id=\"one\"></div>\n <div class=\"target\" id=\"two\"></div>\n </div>\n `);\n const el = test.querySelector('test-element-resolution-el') as TestEl;\n const target1 = test.querySelector('#one') as HTMLDivElement;\n const target2 = test.querySelector('#two') as HTMLDivElement;\n const controller = new ElementResolutionController(el as LitElement);\n expect(controller.element).to.be.null;\n controller.selector = '.target';\n await elementUpdated(el);\n expect(controller.element === target1).to.be.true;\n test.insertAdjacentElement('afterbegin', target2);\n await elementUpdated(el);\n expect(controller.element === target2).to.be.true;\n target2.setAttribute('class', 'not-target');\n await elementUpdated(el);\n expect(controller.element === target1).to.be.true;\n target2.setAttribute('class', 'target');\n await elementUpdated(el);\n expect(controller.element === target2).to.be.true;\n });\n});\n"],
|
|
5
|
+
"mappings": ";AAYA,SAAS,MAAM,kBAAkB;AACjC,SAAS,gBAAgB,QAAQ,eAAe;AAChD,SAAS,mCAAmC;AAE5C,SAAS,sBAAsB,MAAM;AACjC,KAAG,2BAA2B,YAAY;AAAA,IACtC,MAAM,eAAe,WAAW;AAAA,IAAC;AACjC,QAAI,CAAC,eAAe,IAAI,4BAA4B,GAAG;AACnD,qBAAe,OAAO,8BAA8B,MAAM;AAAA,IAC9D;AACA,UAAM,OAAO,MAAM,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAM1B;AACD,UAAM,KAAK,KAAK,cAAc,4BAA4B;AAC1D,UAAM,UAAU,KAAK,cAAc,MAAM;AACzC,UAAM,UAAU,KAAK,cAAc,MAAM;AACzC,UAAM,aAAa,IAAI,4BAA4B,EAAgB;AACnE,WAAO,WAAW,OAAO,EAAE,GAAG,GAAG;AACjC,eAAW,WAAW;AACtB,UAAM,eAAe,EAAE;AACvB,WAAO,WAAW,YAAY,OAAO,EAAE,GAAG,GAAG;AAC7C,SAAK,sBAAsB,cAAc,OAAO;AAChD,UAAM,eAAe,EAAE;AACvB,WAAO,WAAW,YAAY,OAAO,EAAE,GAAG,GAAG;AAC7C,YAAQ,aAAa,SAAS,YAAY;AAC1C,UAAM,eAAe,EAAE;AACvB,WAAO,WAAW,YAAY,OAAO,EAAE,GAAG,GAAG;AAC7C,YAAQ,aAAa,SAAS,QAAQ;AACtC,UAAM,eAAe,EAAE;AACvB,WAAO,WAAW,YAAY,OAAO,EAAE,GAAG,GAAG;AAAA,EACjD,CAAC;AACL,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/test/helpers.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
export const createLanguageContext = (lang) => {
|
|
3
|
+
let language = lang;
|
|
4
|
+
const updateLanguage = (lang2) => {
|
|
5
|
+
language = lang2;
|
|
6
|
+
resolveLanguage();
|
|
7
|
+
};
|
|
8
|
+
const langResolvers = [];
|
|
9
|
+
const createLangResolver = (event) => {
|
|
10
|
+
langResolvers.push([
|
|
11
|
+
event.detail.callback,
|
|
12
|
+
() => langResolvers.splice(langResolvers.length, 1)
|
|
13
|
+
]);
|
|
14
|
+
resolveLanguage();
|
|
15
|
+
};
|
|
16
|
+
const resolveLanguage = () => {
|
|
17
|
+
langResolvers.forEach(
|
|
18
|
+
([resolver, unsubscribe]) => resolver(language, unsubscribe)
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
return [createLangResolver, updateLanguage];
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["helpers.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { ProvideLang } from '@spectrum-web-components/theme';\n\nexport const createLanguageContext = (\n lang: string\n): [(event: CustomEvent<ProvideLang>) => void, (lang: string) => void] => {\n let language = lang;\n const updateLanguage = (lang: string): void => {\n language = lang;\n resolveLanguage();\n };\n const langResolvers: [ProvideLang['callback'], () => void][] = [];\n const createLangResolver = (event: CustomEvent<ProvideLang>): void => {\n langResolvers.push([\n event.detail.callback,\n () => langResolvers.splice(langResolvers.length, 1),\n ]);\n resolveLanguage();\n };\n const resolveLanguage = (): void => {\n langResolvers.forEach(([resolver, unsubscribe]) =>\n resolver(language, unsubscribe)\n );\n };\n return [createLangResolver, updateLanguage];\n};\n"],
|
|
5
|
+
"mappings": ";AAcO,aAAM,wBAAwB,CACjC,SACsE;AACtE,MAAI,WAAW;AACf,QAAM,iBAAiB,CAACA,UAAuB;AAC3C,eAAWA;AACX,oBAAgB;AAAA,EACpB;AACA,QAAM,gBAAyD,CAAC;AAChE,QAAM,qBAAqB,CAAC,UAA0C;AAClE,kBAAc,KAAK;AAAA,MACf,MAAM,OAAO;AAAA,MACb,MAAM,cAAc,OAAO,cAAc,QAAQ,CAAC;AAAA,IACtD,CAAC;AACD,oBAAgB;AAAA,EACpB;AACA,QAAM,kBAAkB,MAAY;AAChC,kBAAc;AAAA,MAAQ,CAAC,CAAC,UAAU,WAAW,MACzC,SAAS,UAAU,WAAW;AAAA,IAClC;AAAA,EACJ;AACA,SAAO,CAAC,oBAAoB,cAAc;AAC9C;",
|
|
6
|
+
"names": ["lang"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { html, LitElement } from "lit";
|
|
3
|
+
import { expect, fixture, nextFrame } from "@open-wc/testing";
|
|
4
|
+
import { setViewport } from "@web/test-runner-commands";
|
|
5
|
+
import { MatchMediaController } from "@spectrum-web-components/reactive-controllers/src/MatchMedia.js";
|
|
6
|
+
class TestEl extends LitElement {
|
|
7
|
+
}
|
|
8
|
+
customElements.define("test-match-media-el", TestEl);
|
|
9
|
+
describe("Match Media", () => {
|
|
10
|
+
it("responds to media changes", async () => {
|
|
11
|
+
const el = await fixture(html`
|
|
12
|
+
<test-match-media-el></test-match-media-el>
|
|
13
|
+
`);
|
|
14
|
+
const controller = new MatchMediaController(
|
|
15
|
+
el,
|
|
16
|
+
"(min-width: 500px)"
|
|
17
|
+
);
|
|
18
|
+
await nextFrame();
|
|
19
|
+
await nextFrame();
|
|
20
|
+
expect(controller.matches).to.be.true;
|
|
21
|
+
await setViewport({ width: 360, height: 640 });
|
|
22
|
+
await nextFrame();
|
|
23
|
+
await nextFrame();
|
|
24
|
+
expect(controller.matches).to.be.false;
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=match-media.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["match-media.test.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { html, LitElement } from 'lit';\nimport { expect, fixture, nextFrame } from '@open-wc/testing';\nimport { setViewport } from '@web/test-runner-commands';\nimport { MatchMediaController } from '@spectrum-web-components/reactive-controllers/src/MatchMedia.js';\n\nclass TestEl extends LitElement {}\ncustomElements.define('test-match-media-el', TestEl);\n\ndescribe('Match Media', () => {\n it('responds to media changes', async () => {\n const el = await fixture(html`\n <test-match-media-el></test-match-media-el>\n `);\n const controller = new MatchMediaController(\n el as LitElement & { shadowRoot: ShadowRoot },\n '(min-width: 500px)'\n );\n // Allow Controller to initialize\n await nextFrame();\n await nextFrame();\n expect(controller.matches).to.be.true;\n\n await setViewport({ width: 360, height: 640 });\n // Allow viewport update to propagate.\n await nextFrame();\n await nextFrame();\n expect(controller.matches).to.be.false;\n });\n});\n"],
|
|
5
|
+
"mappings": ";AAYA,SAAS,MAAM,kBAAkB;AACjC,SAAS,QAAQ,SAAS,iBAAiB;AAC3C,SAAS,mBAAmB;AAC5B,SAAS,4BAA4B;AAErC,MAAM,eAAe,WAAW;AAAC;AACjC,eAAe,OAAO,uBAAuB,MAAM;AAEnD,SAAS,eAAe,MAAM;AAC1B,KAAG,6BAA6B,YAAY;AACxC,UAAM,KAAK,MAAM,QAAQ;AAAA;AAAA,SAExB;AACD,UAAM,aAAa,IAAI;AAAA,MACnB;AAAA,MACA;AAAA,IACJ;AAEA,UAAM,UAAU;AAChB,UAAM,UAAU;AAChB,WAAO,WAAW,OAAO,EAAE,GAAG,GAAG;AAEjC,UAAM,YAAY,EAAE,OAAO,KAAK,QAAQ,IAAI,CAAC;AAE7C,UAAM,UAAU;AAChB,UAAM,UAAU;AAChB,WAAO,WAAW,OAAO,EAAE,GAAG,GAAG;AAAA,EACrC,CAAC;AACL,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import { expect, fixture, html } from "@open-wc/testing";
|
|
3
|
+
import "@spectrum-web-components/button/sp-button.js";
|
|
4
|
+
import "@spectrum-web-components/progress-circle/sp-progress-circle.js";
|
|
5
|
+
describe("PendingStateController", () => {
|
|
6
|
+
let host;
|
|
7
|
+
let controller;
|
|
8
|
+
beforeEach(async () => {
|
|
9
|
+
host = await fixture(html`
|
|
10
|
+
<sp-button aria-label="clickable" pending>Click me</sp-button>
|
|
11
|
+
`);
|
|
12
|
+
controller = host.pendingStateController;
|
|
13
|
+
});
|
|
14
|
+
describe("renderPendingState", () => {
|
|
15
|
+
it("should change aria-label of host when pending and when not pending", async () => {
|
|
16
|
+
host = await fixture(html`
|
|
17
|
+
<sp-button>Click me</sp-button>
|
|
18
|
+
`);
|
|
19
|
+
controller = host.pendingStateController;
|
|
20
|
+
host.setAttribute("pending", "true");
|
|
21
|
+
await host.updateComplete;
|
|
22
|
+
let ariaLabel = host.getAttribute("aria-label");
|
|
23
|
+
expect(ariaLabel).to.equal("Pending");
|
|
24
|
+
host.removeAttribute("pending");
|
|
25
|
+
await host.updateComplete;
|
|
26
|
+
ariaLabel = host.getAttribute("aria-label");
|
|
27
|
+
expect(ariaLabel).to.equal(null);
|
|
28
|
+
host.setAttribute("aria-label", "clickable");
|
|
29
|
+
await host.updateComplete;
|
|
30
|
+
ariaLabel = host.getAttribute("aria-label");
|
|
31
|
+
expect(ariaLabel).to.equal("clickable");
|
|
32
|
+
host.setAttribute("pending", "true");
|
|
33
|
+
await host.updateComplete;
|
|
34
|
+
ariaLabel = host.getAttribute("aria-label");
|
|
35
|
+
expect(ariaLabel).to.equal("Pending");
|
|
36
|
+
host.removeAttribute("pending");
|
|
37
|
+
await host.updateComplete;
|
|
38
|
+
ariaLabel = host.getAttribute("aria-label");
|
|
39
|
+
expect(ariaLabel).to.equal("clickable");
|
|
40
|
+
host.setAttribute("pending", "true");
|
|
41
|
+
await host.updateComplete;
|
|
42
|
+
ariaLabel = host.getAttribute("aria-label");
|
|
43
|
+
expect(ariaLabel).to.equal("Pending");
|
|
44
|
+
});
|
|
45
|
+
it("should render the pending state UI", async () => {
|
|
46
|
+
const pendingLabel = "Custom Pending Label";
|
|
47
|
+
host.pendingLabel = pendingLabel;
|
|
48
|
+
const templateResult = controller.renderPendingState();
|
|
49
|
+
const renderedElement = await fixture(html`
|
|
50
|
+
${templateResult}
|
|
51
|
+
`);
|
|
52
|
+
const expectedElement = await fixture(html`
|
|
53
|
+
<sp-progress-circle
|
|
54
|
+
id="loader"
|
|
55
|
+
size="s"
|
|
56
|
+
indeterminate
|
|
57
|
+
class="progress-circle"
|
|
58
|
+
role="presentation"
|
|
59
|
+
></sp-progress-circle>
|
|
60
|
+
`);
|
|
61
|
+
expect(renderedElement.outerHTML === expectedElement.outerHTML).to.be.true;
|
|
62
|
+
});
|
|
63
|
+
it("should render the default pending state UI if no label is provided", async () => {
|
|
64
|
+
host.pendingLabel = void 0;
|
|
65
|
+
const templateResult = controller.renderPendingState();
|
|
66
|
+
const renderedElement = await fixture(html`
|
|
67
|
+
${templateResult}
|
|
68
|
+
`);
|
|
69
|
+
const expectedElement = await fixture(html`
|
|
70
|
+
<sp-progress-circle
|
|
71
|
+
id="loader"
|
|
72
|
+
size="s"
|
|
73
|
+
indeterminate
|
|
74
|
+
role="presentation"
|
|
75
|
+
class="progress-circle"
|
|
76
|
+
></sp-progress-circle>
|
|
77
|
+
`);
|
|
78
|
+
const renderedAttributes = renderedElement.attributes;
|
|
79
|
+
const expectedAttributes = expectedElement.attributes;
|
|
80
|
+
expect(renderedAttributes.length).to.equal(
|
|
81
|
+
expectedAttributes.length
|
|
82
|
+
);
|
|
83
|
+
for (let i = 0; i < renderedAttributes.length; i++) {
|
|
84
|
+
const renderedAttr = renderedAttributes[i];
|
|
85
|
+
const expectedAttr = expectedAttributes.getNamedItem(
|
|
86
|
+
renderedAttr.name
|
|
87
|
+
);
|
|
88
|
+
expect(renderedAttr.value === (expectedAttr == null ? void 0 : expectedAttr.value)).to.be.true;
|
|
89
|
+
}
|
|
90
|
+
expect(host.pending).to.be.true;
|
|
91
|
+
});
|
|
92
|
+
it("should toggle the pending state on and off and preserve the component state correctly", async () => {
|
|
93
|
+
var _a, _b, _c;
|
|
94
|
+
host.setAttribute("pending", "true");
|
|
95
|
+
await host.updateComplete;
|
|
96
|
+
let progressCircle = (_a = host.shadowRoot) == null ? void 0 : _a.querySelector("sp-progress-circle");
|
|
97
|
+
expect(progressCircle).to.not.be.null;
|
|
98
|
+
host.removeAttribute("pending");
|
|
99
|
+
await host.updateComplete;
|
|
100
|
+
progressCircle = (_b = host.shadowRoot) == null ? void 0 : _b.querySelector("sp-progress-circle");
|
|
101
|
+
expect(progressCircle).to.be.null;
|
|
102
|
+
host.setAttribute("pending", "true");
|
|
103
|
+
await host.updateComplete;
|
|
104
|
+
progressCircle = (_c = host.shadowRoot) == null ? void 0 : _c.querySelector("sp-progress-circle");
|
|
105
|
+
expect(progressCircle).to.not.be.null;
|
|
106
|
+
const expectedElement = await fixture(html`
|
|
107
|
+
<sp-progress-circle
|
|
108
|
+
id="loader"
|
|
109
|
+
size="s"
|
|
110
|
+
indeterminate
|
|
111
|
+
role="presentation"
|
|
112
|
+
class="progress-circle"
|
|
113
|
+
></sp-progress-circle>
|
|
114
|
+
`);
|
|
115
|
+
const renderedAttributes = progressCircle == null ? void 0 : progressCircle.attributes;
|
|
116
|
+
const expectedAttributes = expectedElement.attributes;
|
|
117
|
+
expect((renderedAttributes == null ? void 0 : renderedAttributes.length) === expectedAttributes.length).to.be.true;
|
|
118
|
+
if (renderedAttributes) {
|
|
119
|
+
for (let i = 0; i < renderedAttributes.length; i++) {
|
|
120
|
+
const renderedAttr = renderedAttributes[i];
|
|
121
|
+
const expectedAttr = expectedAttributes.getNamedItem(
|
|
122
|
+
renderedAttr.name
|
|
123
|
+
);
|
|
124
|
+
expect(renderedAttr.value === (expectedAttr == null ? void 0 : expectedAttr.value)).to.be.true;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
//# sourceMappingURL=pending-state.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["pending-state.test.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { expect, fixture, html } from '@open-wc/testing';\nimport {\n HostWithPendingState,\n PendingStateController,\n} from '@spectrum-web-components/reactive-controllers/src/PendingState.js';\n\nimport '@spectrum-web-components/button/sp-button.js';\nimport '@spectrum-web-components/progress-circle/sp-progress-circle.js';\n\ndescribe('PendingStateController', () => {\n let host: HostWithPendingState;\n let controller: PendingStateController<HostWithPendingState>;\n\n beforeEach(async () => {\n host = await fixture<HostWithPendingState>(html`\n <sp-button aria-label=\"clickable\" pending>Click me</sp-button>\n `);\n controller = host.pendingStateController;\n });\n\n describe('renderPendingState', () => {\n it('should change aria-label of host when pending and when not pending', async () => {\n host = await fixture<HostWithPendingState>(html`\n <sp-button>Click me</sp-button>\n `);\n controller = host.pendingStateController;\n\n host.setAttribute('pending', 'true');\n await host.updateComplete;\n\n let ariaLabel = host.getAttribute('aria-label');\n expect(ariaLabel).to.equal('Pending');\n\n host.removeAttribute('pending');\n await host.updateComplete;\n\n ariaLabel = host.getAttribute('aria-label');\n expect(ariaLabel).to.equal(null);\n\n host.setAttribute('aria-label', 'clickable');\n await host.updateComplete;\n ariaLabel = host.getAttribute('aria-label');\n expect(ariaLabel).to.equal('clickable');\n host.setAttribute('pending', 'true');\n\n await host.updateComplete;\n ariaLabel = host.getAttribute('aria-label');\n expect(ariaLabel).to.equal('Pending');\n\n host.removeAttribute('pending');\n await host.updateComplete;\n ariaLabel = host.getAttribute('aria-label');\n expect(ariaLabel).to.equal('clickable');\n\n host.setAttribute('pending', 'true');\n await host.updateComplete;\n ariaLabel = host.getAttribute('aria-label');\n expect(ariaLabel).to.equal('Pending');\n });\n\n it('should render the pending state UI', async () => {\n const pendingLabel = 'Custom Pending Label';\n host.pendingLabel = pendingLabel;\n const templateResult = controller.renderPendingState();\n\n const renderedElement = await fixture(html`\n ${templateResult}\n `);\n const expectedElement = await fixture(html`\n <sp-progress-circle\n id=\"loader\"\n size=\"s\"\n indeterminate\n class=\"progress-circle\"\n role=\"presentation\"\n ></sp-progress-circle>\n `);\n\n expect(renderedElement.outerHTML === expectedElement.outerHTML).to\n .be.true;\n });\n\n it('should render the default pending state UI if no label is provided', async () => {\n host.pendingLabel = undefined;\n const templateResult = controller.renderPendingState();\n const renderedElement = await fixture(html`\n ${templateResult}\n `);\n const expectedElement = await fixture(html`\n <sp-progress-circle\n id=\"loader\"\n size=\"s\"\n indeterminate\n role=\"presentation\"\n class=\"progress-circle\"\n ></sp-progress-circle>\n `);\n\n const renderedAttributes = renderedElement.attributes;\n const expectedAttributes = expectedElement.attributes;\n\n expect(renderedAttributes.length).to.equal(\n expectedAttributes.length\n );\n\n for (let i = 0; i < renderedAttributes.length; i++) {\n const renderedAttr = renderedAttributes[i];\n const expectedAttr = expectedAttributes.getNamedItem(\n renderedAttr.name\n );\n\n expect(renderedAttr.value === expectedAttr?.value).to.be.true;\n }\n expect(host.pending).to.be.true;\n });\n\n it('should toggle the pending state on and off and preserve the component state correctly', async () => {\n // Set initial pending state to true\n host.setAttribute('pending', 'true');\n await host.updateComplete;\n let progressCircle =\n host.shadowRoot?.querySelector('sp-progress-circle');\n expect(progressCircle).to.not.be.null;\n host.removeAttribute('pending');\n await host.updateComplete;\n progressCircle =\n host.shadowRoot?.querySelector('sp-progress-circle');\n expect(progressCircle).to.be.null;\n host.setAttribute('pending', 'true');\n await host.updateComplete;\n progressCircle =\n host.shadowRoot?.querySelector('sp-progress-circle');\n expect(progressCircle).to.not.be.null;\n const expectedElement = await fixture(html`\n <sp-progress-circle\n id=\"loader\"\n size=\"s\"\n indeterminate\n role=\"presentation\"\n class=\"progress-circle\"\n ></sp-progress-circle>\n `);\n\n const renderedAttributes = progressCircle?.attributes;\n const expectedAttributes = expectedElement.attributes;\n expect(renderedAttributes?.length === expectedAttributes.length).to\n .be.true;\n if (renderedAttributes) {\n for (let i = 0; i < renderedAttributes.length; i++) {\n const renderedAttr = renderedAttributes[i];\n const expectedAttr = expectedAttributes.getNamedItem(\n renderedAttr.name\n );\n\n expect(renderedAttr.value === expectedAttr?.value).to.be\n .true;\n }\n }\n });\n });\n});\n"],
|
|
5
|
+
"mappings": ";AAYA,SAAS,QAAQ,SAAS,YAAY;AAMtC,OAAO;AACP,OAAO;AAEP,SAAS,0BAA0B,MAAM;AACrC,MAAI;AACJ,MAAI;AAEJ,aAAW,YAAY;AACnB,WAAO,MAAM,QAA8B;AAAA;AAAA,SAE1C;AACD,iBAAa,KAAK;AAAA,EACtB,CAAC;AAED,WAAS,sBAAsB,MAAM;AACjC,OAAG,sEAAsE,YAAY;AACjF,aAAO,MAAM,QAA8B;AAAA;AAAA,aAE1C;AACD,mBAAa,KAAK;AAElB,WAAK,aAAa,WAAW,MAAM;AACnC,YAAM,KAAK;AAEX,UAAI,YAAY,KAAK,aAAa,YAAY;AAC9C,aAAO,SAAS,EAAE,GAAG,MAAM,SAAS;AAEpC,WAAK,gBAAgB,SAAS;AAC9B,YAAM,KAAK;AAEX,kBAAY,KAAK,aAAa,YAAY;AAC1C,aAAO,SAAS,EAAE,GAAG,MAAM,IAAI;AAE/B,WAAK,aAAa,cAAc,WAAW;AAC3C,YAAM,KAAK;AACX,kBAAY,KAAK,aAAa,YAAY;AAC1C,aAAO,SAAS,EAAE,GAAG,MAAM,WAAW;AACtC,WAAK,aAAa,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