@spectrum-web-components/color-wheel 0.3.11 → 0.3.13-devmode.7
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 +27 -10
- package/sp-color-wheel.dev.js +3 -0
- package/sp-color-wheel.dev.js.map +7 -0
- package/sp-color-wheel.js +3 -14
- package/sp-color-wheel.js.map +7 -1
- package/src/ColorWheel.dev.js +363 -0
- package/src/ColorWheel.dev.js.map +7 -0
- package/src/ColorWheel.js +313 -333
- package/src/ColorWheel.js.map +7 -1
- package/src/color-wheel.css.dev.js +48 -0
- package/src/color-wheel.css.dev.js.map +7 -0
- package/src/color-wheel.css.js +3 -14
- package/src/color-wheel.css.js.map +7 -1
- package/src/index.dev.js +2 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +2 -13
- package/src/index.js.map +7 -1
- package/src/spectrum-color-wheel.css.dev.js +42 -0
- package/src/spectrum-color-wheel.css.dev.js.map +7 -0
- package/src/spectrum-color-wheel.css.js +3 -14
- package/src/spectrum-color-wheel.css.js.map +7 -1
- package/src/types.dev.js +1 -0
- package/src/types.dev.js.map +7 -0
- package/src/types.js +1 -13
- package/src/types.js.map +7 -1
- package/stories/color-wheel.stories.js +51 -62
- package/stories/color-wheel.stories.js.map +7 -1
- package/test/benchmark/basic-test.js +5 -16
- package/test/benchmark/basic-test.js.map +7 -1
- package/test/color-wheel.test-vrt.js +4 -15
- package/test/color-wheel.test-vrt.js.map +7 -1
- package/test/color-wheel.test.js +347 -358
- package/test/color-wheel.test.js.map +7 -1
package/test/color-wheel.test.js
CHANGED
|
@@ -1,399 +1,388 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
it('loads default color-wheel accessibly', async () => {
|
|
20
|
-
const el = await fixture(html `
|
|
1
|
+
import { elementUpdated, expect, fixture, html } from "@open-wc/testing";
|
|
2
|
+
import {
|
|
3
|
+
arrowDownEvent,
|
|
4
|
+
arrowDownKeyupEvent,
|
|
5
|
+
arrowLeftEvent,
|
|
6
|
+
arrowLeftKeyupEvent,
|
|
7
|
+
arrowRightEvent,
|
|
8
|
+
arrowRightKeyupEvent,
|
|
9
|
+
arrowUpEvent,
|
|
10
|
+
arrowUpKeyupEvent
|
|
11
|
+
} from "../../../test/testing-helpers.js";
|
|
12
|
+
import "@spectrum-web-components/color-wheel/sp-color-wheel.js";
|
|
13
|
+
import { TinyColor } from "@ctrl/tinycolor";
|
|
14
|
+
import { sendKeys } from "@web/test-runner-commands";
|
|
15
|
+
import { spy } from "sinon";
|
|
16
|
+
describe("ColorWheel", () => {
|
|
17
|
+
it("loads default color-wheel accessibly", async () => {
|
|
18
|
+
const el = await fixture(html`
|
|
21
19
|
<sp-color-wheel></sp-color-wheel>
|
|
22
20
|
`);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
await elementUpdated(el);
|
|
22
|
+
await expect(el).to.be.accessible();
|
|
23
|
+
});
|
|
24
|
+
it("manages a single tab stop", async () => {
|
|
25
|
+
const test = await fixture(html`
|
|
28
26
|
<div>
|
|
29
27
|
<input type="text" id="test-input-1" />
|
|
30
28
|
<sp-color-wheel></sp-color-wheel>
|
|
31
29
|
<input type="text" id="test-input-2" />
|
|
32
30
|
</div>
|
|
33
31
|
`);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
});
|
|
65
|
-
expect(document.activeElement).to.equal(input1);
|
|
32
|
+
const el = test.querySelector("sp-color-wheel");
|
|
33
|
+
const input1 = test.querySelector("input:nth-of-type(1)");
|
|
34
|
+
const input2 = test.querySelector("input:nth-of-type(2)");
|
|
35
|
+
await elementUpdated(el);
|
|
36
|
+
input1.focus();
|
|
37
|
+
expect(document.activeElement).to.equal(input1);
|
|
38
|
+
await sendKeys({
|
|
39
|
+
press: "Tab"
|
|
40
|
+
});
|
|
41
|
+
expect(document.activeElement).to.equal(el);
|
|
42
|
+
let value = el.value;
|
|
43
|
+
await sendKeys({
|
|
44
|
+
press: "ArrowRight"
|
|
45
|
+
});
|
|
46
|
+
expect(el.value).to.not.equal(value);
|
|
47
|
+
await sendKeys({
|
|
48
|
+
press: "Tab"
|
|
49
|
+
});
|
|
50
|
+
expect(document.activeElement).to.equal(input2);
|
|
51
|
+
await sendKeys({
|
|
52
|
+
press: "Shift+Tab"
|
|
53
|
+
});
|
|
54
|
+
expect(document.activeElement).to.equal(el);
|
|
55
|
+
value = el.value;
|
|
56
|
+
await sendKeys({
|
|
57
|
+
press: "ArrowDown"
|
|
58
|
+
});
|
|
59
|
+
expect(el.value).to.not.equal(value);
|
|
60
|
+
await sendKeys({
|
|
61
|
+
press: "Shift+Tab"
|
|
66
62
|
});
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
expect(document.activeElement).to.equal(input1);
|
|
64
|
+
});
|
|
65
|
+
it("manages [focused]", async () => {
|
|
66
|
+
const el = await fixture(html`
|
|
69
67
|
<sp-color-wheel></sp-color-wheel>
|
|
70
68
|
`);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
69
|
+
await elementUpdated(el);
|
|
70
|
+
el.dispatchEvent(new FocusEvent("focusin"));
|
|
71
|
+
await elementUpdated(el);
|
|
72
|
+
expect(el.focused).to.be.true;
|
|
73
|
+
el.dispatchEvent(new FocusEvent("focusout"));
|
|
74
|
+
await elementUpdated(el);
|
|
75
|
+
expect(el.focused).to.be.false;
|
|
76
|
+
});
|
|
77
|
+
it('dispatches input and change events in response to "Arrow*" keypresses', async () => {
|
|
78
|
+
const inputSpy = spy();
|
|
79
|
+
const changeSpy = spy();
|
|
80
|
+
const el = await fixture(html`
|
|
83
81
|
<sp-color-wheel
|
|
84
82
|
@change=${() => changeSpy()}
|
|
85
83
|
@input=${() => inputSpy()}
|
|
86
84
|
></sp-color-wheel>
|
|
87
85
|
`);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const el = await fixture(html `
|
|
86
|
+
await elementUpdated(el);
|
|
87
|
+
el.focus();
|
|
88
|
+
await sendKeys({ press: "ArrowRight" });
|
|
89
|
+
expect(inputSpy.callCount).to.equal(1);
|
|
90
|
+
expect(changeSpy.callCount).to.equal(1);
|
|
91
|
+
await sendKeys({ press: "ArrowLeft" });
|
|
92
|
+
expect(inputSpy.callCount).to.equal(2);
|
|
93
|
+
expect(changeSpy.callCount).to.equal(2);
|
|
94
|
+
await sendKeys({ press: "ArrowUp" });
|
|
95
|
+
expect(inputSpy.callCount).to.equal(3);
|
|
96
|
+
expect(changeSpy.callCount).to.equal(3);
|
|
97
|
+
await sendKeys({ press: "ArrowDown" });
|
|
98
|
+
expect(inputSpy.callCount).to.equal(4);
|
|
99
|
+
expect(changeSpy.callCount).to.equal(4);
|
|
100
|
+
});
|
|
101
|
+
it("responds to events on the internal input element", async () => {
|
|
102
|
+
const inputSpy = spy();
|
|
103
|
+
const changeSpy = spy();
|
|
104
|
+
const el = await fixture(html`
|
|
108
105
|
<sp-color-wheel
|
|
109
106
|
@change=${() => changeSpy()}
|
|
110
107
|
@input=${() => inputSpy()}
|
|
111
108
|
></sp-color-wheel>
|
|
112
109
|
`);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
110
|
+
await elementUpdated(el);
|
|
111
|
+
const input = el.focusElement;
|
|
112
|
+
el.focus();
|
|
113
|
+
input.dispatchEvent(new Event("input", {
|
|
114
|
+
bubbles: true,
|
|
115
|
+
composed: true
|
|
116
|
+
}));
|
|
117
|
+
input.dispatchEvent(new Event("change", {
|
|
118
|
+
bubbles: true,
|
|
119
|
+
composed: false
|
|
120
|
+
}));
|
|
121
|
+
expect(inputSpy.callCount).to.equal(1);
|
|
122
|
+
expect(changeSpy.callCount).to.equal(1);
|
|
123
|
+
});
|
|
124
|
+
it('accepts "Arrow*" keypresses', async () => {
|
|
125
|
+
const el = await fixture(html`
|
|
129
126
|
<sp-color-wheel></sp-color-wheel>
|
|
130
127
|
`);
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
128
|
+
await elementUpdated(el);
|
|
129
|
+
expect(el.value).to.equal(0);
|
|
130
|
+
const input = el.focusElement;
|
|
131
|
+
input.dispatchEvent(arrowUpEvent());
|
|
132
|
+
input.dispatchEvent(arrowUpKeyupEvent());
|
|
133
|
+
input.dispatchEvent(arrowUpEvent());
|
|
134
|
+
input.dispatchEvent(arrowUpKeyupEvent());
|
|
135
|
+
await elementUpdated(el);
|
|
136
|
+
expect(el.value).to.equal(2);
|
|
137
|
+
input.dispatchEvent(arrowRightEvent());
|
|
138
|
+
input.dispatchEvent(arrowRightKeyupEvent());
|
|
139
|
+
input.dispatchEvent(arrowRightEvent());
|
|
140
|
+
input.dispatchEvent(arrowRightKeyupEvent());
|
|
141
|
+
await elementUpdated(el);
|
|
142
|
+
expect(el.value).to.equal(4);
|
|
143
|
+
input.dispatchEvent(arrowDownEvent());
|
|
144
|
+
input.dispatchEvent(arrowDownKeyupEvent());
|
|
145
|
+
input.dispatchEvent(arrowDownEvent());
|
|
146
|
+
input.dispatchEvent(arrowDownKeyupEvent());
|
|
147
|
+
await elementUpdated(el);
|
|
148
|
+
expect(el.value).to.equal(2);
|
|
149
|
+
input.dispatchEvent(arrowLeftEvent());
|
|
150
|
+
input.dispatchEvent(arrowLeftKeyupEvent());
|
|
151
|
+
input.dispatchEvent(arrowLeftEvent());
|
|
152
|
+
input.dispatchEvent(arrowLeftKeyupEvent());
|
|
153
|
+
await elementUpdated(el);
|
|
154
|
+
expect(el.value).to.equal(0);
|
|
155
|
+
});
|
|
156
|
+
it('accepts "Arrow*" keypresses in dir="rtl"', async () => {
|
|
157
|
+
const el = await fixture(html`
|
|
161
158
|
<sp-color-wheel dir="rtl"></sp-color-wheel>
|
|
162
159
|
`);
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
160
|
+
await elementUpdated(el);
|
|
161
|
+
expect(el.value).to.equal(0);
|
|
162
|
+
const input = el.focusElement;
|
|
163
|
+
input.dispatchEvent(arrowUpEvent());
|
|
164
|
+
input.dispatchEvent(arrowUpKeyupEvent());
|
|
165
|
+
input.dispatchEvent(arrowUpEvent());
|
|
166
|
+
input.dispatchEvent(arrowUpKeyupEvent());
|
|
167
|
+
await elementUpdated(el);
|
|
168
|
+
expect(el.value).to.equal(2);
|
|
169
|
+
input.dispatchEvent(arrowRightEvent());
|
|
170
|
+
input.dispatchEvent(arrowRightKeyupEvent());
|
|
171
|
+
input.dispatchEvent(arrowRightEvent());
|
|
172
|
+
input.dispatchEvent(arrowRightKeyupEvent());
|
|
173
|
+
await elementUpdated(el);
|
|
174
|
+
expect(el.value).to.equal(0);
|
|
175
|
+
input.dispatchEvent(arrowLeftEvent());
|
|
176
|
+
input.dispatchEvent(arrowLeftKeyupEvent());
|
|
177
|
+
input.dispatchEvent(arrowLeftEvent());
|
|
178
|
+
input.dispatchEvent(arrowLeftKeyupEvent());
|
|
179
|
+
await elementUpdated(el);
|
|
180
|
+
expect(el.value).to.equal(2);
|
|
181
|
+
input.dispatchEvent(arrowDownEvent());
|
|
182
|
+
input.dispatchEvent(arrowDownKeyupEvent());
|
|
183
|
+
input.dispatchEvent(arrowDownEvent());
|
|
184
|
+
input.dispatchEvent(arrowDownKeyupEvent());
|
|
185
|
+
await elementUpdated(el);
|
|
186
|
+
expect(el.value).to.equal(0);
|
|
187
|
+
});
|
|
188
|
+
it('accepts "Arrow*" keypresses with alteration', async () => {
|
|
189
|
+
const el = await fixture(html`
|
|
193
190
|
<sp-color-wheel></sp-color-wheel>
|
|
194
191
|
`);
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
});
|
|
204
|
-
await sendKeys({
|
|
205
|
-
press: 'ArrowUp',
|
|
206
|
-
});
|
|
207
|
-
await elementUpdated(el);
|
|
208
|
-
expect(el.value).to.equal(20);
|
|
209
|
-
await sendKeys({
|
|
210
|
-
press: 'ArrowRight',
|
|
211
|
-
});
|
|
212
|
-
await sendKeys({
|
|
213
|
-
press: 'ArrowRight',
|
|
214
|
-
});
|
|
215
|
-
await elementUpdated(el);
|
|
216
|
-
expect(el.value).to.equal(40);
|
|
217
|
-
await sendKeys({
|
|
218
|
-
press: 'ArrowDown',
|
|
219
|
-
});
|
|
220
|
-
await sendKeys({
|
|
221
|
-
press: 'ArrowDown',
|
|
222
|
-
});
|
|
223
|
-
await elementUpdated(el);
|
|
224
|
-
expect(el.value).to.equal(20);
|
|
225
|
-
await sendKeys({
|
|
226
|
-
press: 'ArrowLeft',
|
|
227
|
-
});
|
|
228
|
-
await sendKeys({
|
|
229
|
-
press: 'ArrowLeft',
|
|
230
|
-
});
|
|
231
|
-
await sendKeys({
|
|
232
|
-
up: 'Shift',
|
|
233
|
-
});
|
|
234
|
-
await elementUpdated(el);
|
|
235
|
-
expect(el.value).to.equal(0);
|
|
192
|
+
await elementUpdated(el);
|
|
193
|
+
el.focus();
|
|
194
|
+
expect(el.value).to.equal(0);
|
|
195
|
+
await sendKeys({
|
|
196
|
+
down: "Shift"
|
|
197
|
+
});
|
|
198
|
+
await sendKeys({
|
|
199
|
+
press: "ArrowUp"
|
|
236
200
|
});
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
201
|
+
await sendKeys({
|
|
202
|
+
press: "ArrowUp"
|
|
203
|
+
});
|
|
204
|
+
await elementUpdated(el);
|
|
205
|
+
expect(el.value).to.equal(20);
|
|
206
|
+
await sendKeys({
|
|
207
|
+
press: "ArrowRight"
|
|
208
|
+
});
|
|
209
|
+
await sendKeys({
|
|
210
|
+
press: "ArrowRight"
|
|
211
|
+
});
|
|
212
|
+
await elementUpdated(el);
|
|
213
|
+
expect(el.value).to.equal(40);
|
|
214
|
+
await sendKeys({
|
|
215
|
+
press: "ArrowDown"
|
|
216
|
+
});
|
|
217
|
+
await sendKeys({
|
|
218
|
+
press: "ArrowDown"
|
|
219
|
+
});
|
|
220
|
+
await elementUpdated(el);
|
|
221
|
+
expect(el.value).to.equal(20);
|
|
222
|
+
await sendKeys({
|
|
223
|
+
press: "ArrowLeft"
|
|
224
|
+
});
|
|
225
|
+
await sendKeys({
|
|
226
|
+
press: "ArrowLeft"
|
|
227
|
+
});
|
|
228
|
+
await sendKeys({
|
|
229
|
+
up: "Shift"
|
|
230
|
+
});
|
|
231
|
+
await elementUpdated(el);
|
|
232
|
+
expect(el.value).to.equal(0);
|
|
233
|
+
});
|
|
234
|
+
it("accepts pointer events", async () => {
|
|
235
|
+
const color = new TinyColor({ h: "0", s: "20%", l: "70%" });
|
|
236
|
+
const el = await fixture(html`
|
|
240
237
|
<sp-color-wheel
|
|
241
238
|
.color=${color}
|
|
242
239
|
style="--spectrum-global-dimension-size-125: 10px;"
|
|
243
240
|
></sp-color-wheel>
|
|
244
241
|
`);
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
// hsv
|
|
336
|
-
{ name: 'HSV String', color: 'hsv(300, 75%, 100%)' },
|
|
337
|
-
{ name: 'HSV', color: { h: 300, s: 0.75, v: 1, a: 1 } },
|
|
338
|
-
];
|
|
339
|
-
colorFormats.map((format) => {
|
|
340
|
-
it(`maintains \`color\` format as ${format.name}`, async () => {
|
|
341
|
-
const el = await fixture(html `
|
|
242
|
+
await elementUpdated(el);
|
|
243
|
+
const { handle } = el;
|
|
244
|
+
handle.setPointerCapture = () => {
|
|
245
|
+
return;
|
|
246
|
+
};
|
|
247
|
+
handle.releasePointerCapture = () => {
|
|
248
|
+
return;
|
|
249
|
+
};
|
|
250
|
+
expect(el.value).to.equal(0);
|
|
251
|
+
expect(el.color.s).to.be.within(0.19, 0.21);
|
|
252
|
+
expect(el.color.l).to.be.within(0.69, 0.71);
|
|
253
|
+
handle.dispatchEvent(new PointerEvent("pointerdown", {
|
|
254
|
+
button: 1,
|
|
255
|
+
pointerId: 1,
|
|
256
|
+
clientX: 80,
|
|
257
|
+
clientY: 15,
|
|
258
|
+
bubbles: true,
|
|
259
|
+
composed: true,
|
|
260
|
+
cancelable: true
|
|
261
|
+
}));
|
|
262
|
+
await elementUpdated(el);
|
|
263
|
+
expect(el.value).to.equal(0);
|
|
264
|
+
expect(el.color.s).to.be.within(0.19, 0.21);
|
|
265
|
+
expect(el.color.l).to.be.within(0.69, 0.71);
|
|
266
|
+
const root = el.shadowRoot ? el.shadowRoot : el;
|
|
267
|
+
const gradient = root.querySelector('[name="gradient"]');
|
|
268
|
+
gradient.dispatchEvent(new PointerEvent("pointerdown", {
|
|
269
|
+
button: 1,
|
|
270
|
+
pointerId: 1,
|
|
271
|
+
clientX: 80,
|
|
272
|
+
clientY: 15,
|
|
273
|
+
bubbles: true,
|
|
274
|
+
composed: true,
|
|
275
|
+
cancelable: true
|
|
276
|
+
}));
|
|
277
|
+
await elementUpdated(el);
|
|
278
|
+
expect(el.value).to.equal(0);
|
|
279
|
+
expect(el.color.s).to.be.within(0.19, 0.21);
|
|
280
|
+
expect(el.color.l).to.be.within(0.69, 0.71);
|
|
281
|
+
gradient.dispatchEvent(new PointerEvent("pointerdown", {
|
|
282
|
+
pointerId: 1,
|
|
283
|
+
clientX: 80,
|
|
284
|
+
clientY: 15,
|
|
285
|
+
bubbles: true,
|
|
286
|
+
composed: true,
|
|
287
|
+
cancelable: true
|
|
288
|
+
}));
|
|
289
|
+
await elementUpdated(el);
|
|
290
|
+
expect(el.value).to.equal(263.74596725608353);
|
|
291
|
+
expect(el.color.s).to.be.within(0.19, 0.21);
|
|
292
|
+
expect(el.color.l).to.be.within(0.69, 0.71);
|
|
293
|
+
handle.dispatchEvent(new PointerEvent("pointermove", {
|
|
294
|
+
pointerId: 1,
|
|
295
|
+
clientX: 80,
|
|
296
|
+
clientY: 160,
|
|
297
|
+
bubbles: true,
|
|
298
|
+
composed: true,
|
|
299
|
+
cancelable: true
|
|
300
|
+
}));
|
|
301
|
+
handle.dispatchEvent(new PointerEvent("pointerup", {
|
|
302
|
+
pointerId: 1,
|
|
303
|
+
clientX: 80,
|
|
304
|
+
clientY: 160,
|
|
305
|
+
bubbles: true,
|
|
306
|
+
composed: true,
|
|
307
|
+
cancelable: true
|
|
308
|
+
}));
|
|
309
|
+
await elementUpdated(el);
|
|
310
|
+
expect(el.value).to.equal(96.34019174590992);
|
|
311
|
+
expect(el.color.s).to.be.within(0.19, 0.21);
|
|
312
|
+
expect(el.color.l).to.be.within(0.69, 0.71);
|
|
313
|
+
});
|
|
314
|
+
const colorFormats = [
|
|
315
|
+
{ name: "RGB String", color: "rgb(204, 51, 204)" },
|
|
316
|
+
{ name: "RGB", color: { r: 204, g: 51, b: 204, a: 1 } },
|
|
317
|
+
{ name: "PRGB String", color: "rgb(80%, 20%, 80%)" },
|
|
318
|
+
{ name: "PRGB", color: { r: "80%", g: "20%", b: "80%", a: 1 } },
|
|
319
|
+
{ name: "Hex", color: "cc33cc" },
|
|
320
|
+
{ name: "Hex String", color: "#cc33cc" },
|
|
321
|
+
{ name: "Hex8", color: "cc33ccff" },
|
|
322
|
+
{ name: "Hex8 String", color: "#cc33ccff" },
|
|
323
|
+
{ name: "string", color: "red" },
|
|
324
|
+
{ name: "HSL String", color: "hsl(300, 60%, 50%)" },
|
|
325
|
+
{ name: "HSL", color: { h: 300, s: 0.6000000000000001, l: 0.5, a: 1 } },
|
|
326
|
+
{ name: "HSV String", color: "hsv(300, 75%, 100%)" },
|
|
327
|
+
{ name: "HSV", color: { h: 300, s: 0.75, v: 1, a: 1 } }
|
|
328
|
+
];
|
|
329
|
+
colorFormats.map((format) => {
|
|
330
|
+
it(`maintains \`color\` format as ${format.name}`, async () => {
|
|
331
|
+
const el = await fixture(html`
|
|
342
332
|
<sp-color-wheel></sp-color-wheel>
|
|
343
333
|
`);
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
expect(el.color).to.deep.equal(format.color);
|
|
350
|
-
});
|
|
334
|
+
el.color = format.color;
|
|
335
|
+
if (format.name.startsWith("Hex")) {
|
|
336
|
+
expect(el.color).to.equal(format.color);
|
|
337
|
+
} else
|
|
338
|
+
expect(el.color).to.deep.equal(format.color);
|
|
351
339
|
});
|
|
352
|
-
|
|
353
|
-
|
|
340
|
+
});
|
|
341
|
+
it(`maintains \`color\` format as TinyColor`, async () => {
|
|
342
|
+
const el = await fixture(html`
|
|
354
343
|
<sp-color-wheel></sp-color-wheel>
|
|
355
344
|
`);
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
345
|
+
const color = new TinyColor("rgb(204, 51, 204)");
|
|
346
|
+
el.color = color;
|
|
347
|
+
expect(color.equals(el.color));
|
|
348
|
+
});
|
|
349
|
+
it(`maintains hue value`, async () => {
|
|
350
|
+
const el = await fixture(html`
|
|
362
351
|
<sp-color-wheel></sp-color-wheel>
|
|
363
352
|
`);
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
353
|
+
const hue = 300;
|
|
354
|
+
const hsl = `hsl(${hue}, 60%, 100%)`;
|
|
355
|
+
el.color = hsl;
|
|
356
|
+
expect(el.value).to.equal(hue);
|
|
357
|
+
expect(el.color).to.equal(hsl);
|
|
358
|
+
const hsla = `hsla(${hue}, 60%, 100%, 0.9)`;
|
|
359
|
+
el.color = hsla;
|
|
360
|
+
expect(el.value).to.equal(hue);
|
|
361
|
+
expect(el.color).to.equal(hsla);
|
|
362
|
+
const hsv = `hsv(${hue}, 60%, 100%)`;
|
|
363
|
+
el.color = hsv;
|
|
364
|
+
expect(el.value).to.equal(hue);
|
|
365
|
+
expect(el.color).to.equal(hsv);
|
|
366
|
+
const hsva = `hsva(${hue}, 60%, 100%, 0.9)`;
|
|
367
|
+
el.color = hsva;
|
|
368
|
+
expect(el.value).to.equal(hue);
|
|
369
|
+
expect(el.color).to.equal(hsva);
|
|
370
|
+
const tinyHSV = new TinyColor({ h: hue, s: 60, v: 100 });
|
|
371
|
+
el.color = tinyHSV;
|
|
372
|
+
expect(el.value).to.equal(hue);
|
|
373
|
+
expect(tinyHSV.equals(el.color)).to.be.true;
|
|
374
|
+
const tinyHSVA = new TinyColor({ h: hue, s: 60, v: 100, a: 1 });
|
|
375
|
+
el.color = tinyHSVA;
|
|
376
|
+
expect(el.value).to.equal(hue);
|
|
377
|
+
expect(tinyHSVA.equals(el.color)).to.be.true;
|
|
378
|
+
const tinyHSL = new TinyColor({ h: hue, s: 60, l: 100 });
|
|
379
|
+
el.color = tinyHSL;
|
|
380
|
+
expect(el.value).to.equal(hue);
|
|
381
|
+
expect(tinyHSL.equals(el.color)).to.be.true;
|
|
382
|
+
const tinyHSLA = new TinyColor({ h: hue, s: 60, l: 100, a: 1 });
|
|
383
|
+
el.color = tinyHSLA;
|
|
384
|
+
expect(el.value).to.equal(hue);
|
|
385
|
+
expect(tinyHSLA.equals(el.color)).to.be.true;
|
|
386
|
+
});
|
|
398
387
|
});
|
|
399
|
-
//# sourceMappingURL=color-wheel.test.js.map
|
|
388
|
+
//# sourceMappingURL=color-wheel.test.js.map
|