@spectrum-web-components/color-wheel 0.4.0-devmode.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/sp-color-wheel.js +1 -2
- package/sp-color-wheel.js.map +1 -1
- package/src/ColorWheel.js +6 -336
- package/src/ColorWheel.js.map +1 -1
- package/src/color-wheel.css.js +2 -4
- package/src/color-wheel.css.js.map +1 -1
- package/src/index.js +1 -1
- package/src/index.js.map +1 -1
- package/src/spectrum-color-wheel.css.js +2 -4
- package/src/spectrum-color-wheel.css.js.map +1 -1
- package/stories/color-wheel.stories.js +7 -72
- package/stories/color-wheel.stories.js.map +1 -1
- package/test/benchmark/basic-test.js +1 -4
- package/test/benchmark/basic-test.js.map +1 -1
- package/test/color-wheel.test-vrt.js +1 -3
- package/test/color-wheel.test-vrt.js.map +1 -1
- package/test/color-wheel.test.js +19 -370
- package/test/color-wheel.test.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/color-wheel",
|
|
3
|
-
"version": "0.4.0
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
],
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@ctrl/tinycolor": "^3.3.3",
|
|
65
|
-
"@spectrum-web-components/base": "^0.
|
|
66
|
-
"@spectrum-web-components/color-handle": "^0.4.0
|
|
67
|
-
"@spectrum-web-components/shared": "^0.15.0
|
|
65
|
+
"@spectrum-web-components/base": "^0.7.0",
|
|
66
|
+
"@spectrum-web-components/color-handle": "^0.4.0",
|
|
67
|
+
"@spectrum-web-components/shared": "^0.15.0",
|
|
68
68
|
"tslib": "^2.0.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"./sp-*.js",
|
|
77
77
|
"./**/*.dev.js"
|
|
78
78
|
],
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "05c81318844160db3f8156144106e643507fef97"
|
|
80
80
|
}
|
package/sp-color-wheel.js
CHANGED
package/sp-color-wheel.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sp-color-wheel.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 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 { ColorWheel } from './src/ColorWheel.js';\n\ncustomElements.define('sp-color-wheel', ColorWheel);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-color-wheel': ColorWheel;\n }\n}\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": "AAYA,iDAEA,eAAe,OAAO,iBAAkB,CAAU",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/ColorWheel.js
CHANGED
|
@@ -1,300 +1,20 @@
|
|
|
1
|
-
var
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
-
if (decorator = decorators[i])
|
|
7
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
-
if (kind && result)
|
|
9
|
-
__defProp(target, key, result);
|
|
10
|
-
return result;
|
|
11
|
-
};
|
|
12
|
-
import {
|
|
13
|
-
html
|
|
14
|
-
} from "@spectrum-web-components/base";
|
|
15
|
-
import { ifDefined } from "@spectrum-web-components/base/src/directives.js";
|
|
16
|
-
import {
|
|
17
|
-
property,
|
|
18
|
-
query
|
|
19
|
-
} from "@spectrum-web-components/base/src/decorators.js";
|
|
20
|
-
import { streamingListener } from "@spectrum-web-components/base/src/streaming-listener.js";
|
|
21
|
-
import { Focusable } from "@spectrum-web-components/shared/src/focusable.js";
|
|
22
|
-
import "@spectrum-web-components/color-handle/sp-color-handle.js";
|
|
23
|
-
import styles from "./color-wheel.css.js";
|
|
24
|
-
import {
|
|
25
|
-
extractHueAndSaturationRegExp,
|
|
26
|
-
replaceHueAndSaturationRegExp
|
|
27
|
-
} from "@spectrum-web-components/color-handle";
|
|
28
|
-
import { TinyColor } from "@ctrl/tinycolor";
|
|
29
|
-
export class ColorWheel extends Focusable {
|
|
30
|
-
constructor() {
|
|
31
|
-
super(...arguments);
|
|
32
|
-
this.disabled = false;
|
|
33
|
-
this.focused = false;
|
|
34
|
-
this.label = "hue";
|
|
35
|
-
this.step = 1;
|
|
36
|
-
this._value = 0;
|
|
37
|
-
this._color = new TinyColor({ h: 0, s: 1, v: 1 });
|
|
38
|
-
this._previousColor = new TinyColor({ h: 0, s: 1, v: 1 });
|
|
39
|
-
this._format = {
|
|
40
|
-
format: "",
|
|
41
|
-
isString: false
|
|
42
|
-
};
|
|
43
|
-
this._altered = 0;
|
|
44
|
-
this._pointerDown = false;
|
|
45
|
-
}
|
|
46
|
-
static get styles() {
|
|
47
|
-
return [styles];
|
|
48
|
-
}
|
|
49
|
-
get value() {
|
|
50
|
-
return this._value;
|
|
51
|
-
}
|
|
52
|
-
set value(hue) {
|
|
53
|
-
const value = Math.min(360, Math.max(0, hue));
|
|
54
|
-
if (value === this.value) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const oldValue = this.value;
|
|
58
|
-
const { s, v } = this._color.toHsv();
|
|
59
|
-
this._color = new TinyColor({ h: value, s, v });
|
|
60
|
-
this._value = value;
|
|
61
|
-
this.requestUpdate("value", oldValue);
|
|
62
|
-
}
|
|
63
|
-
get color() {
|
|
64
|
-
switch (this._format.format) {
|
|
65
|
-
case "rgb":
|
|
66
|
-
return this._format.isString ? this._color.toRgbString() : this._color.toRgb();
|
|
67
|
-
case "prgb":
|
|
68
|
-
return this._format.isString ? this._color.toPercentageRgbString() : this._color.toPercentageRgb();
|
|
69
|
-
case "hex":
|
|
70
|
-
case "hex3":
|
|
71
|
-
case "hex4":
|
|
72
|
-
case "hex6":
|
|
73
|
-
return this._format.isString ? this._color.toHexString() : this._color.toHex();
|
|
74
|
-
case "hex8":
|
|
75
|
-
return this._format.isString ? this._color.toHex8String() : this._color.toHex8();
|
|
76
|
-
case "name":
|
|
77
|
-
return this._color.toName() || this._color.toRgbString();
|
|
78
|
-
case "hsl":
|
|
79
|
-
if (this._format.isString) {
|
|
80
|
-
const hslString = this._color.toHslString();
|
|
81
|
-
return hslString.replace(replaceHueAndSaturationRegExp, `$1${this.value}$2${this._saturation}`);
|
|
82
|
-
} else {
|
|
83
|
-
const { s, l, a } = this._color.toHsl();
|
|
84
|
-
return { h: this.value, s, l, a };
|
|
85
|
-
}
|
|
86
|
-
case "hsv":
|
|
87
|
-
if (this._format.isString) {
|
|
88
|
-
const hsvString = this._color.toHsvString();
|
|
89
|
-
return hsvString.replace(replaceHueAndSaturationRegExp, `$1${this.value}$2${this._saturation}`);
|
|
90
|
-
} else {
|
|
91
|
-
const { s, v, a } = this._color.toHsv();
|
|
92
|
-
return { h: this.value, s, v, a };
|
|
93
|
-
}
|
|
94
|
-
default:
|
|
95
|
-
return "No color format applied.";
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
set color(color) {
|
|
99
|
-
if (color === this.color) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const oldValue = this._color;
|
|
103
|
-
this._color = new TinyColor(color);
|
|
104
|
-
const format = this._color.format;
|
|
105
|
-
let isString = typeof color === "string" || color instanceof String;
|
|
106
|
-
if (format.startsWith("hex")) {
|
|
107
|
-
isString = color.startsWith("#");
|
|
108
|
-
}
|
|
109
|
-
this._format = {
|
|
110
|
-
format,
|
|
111
|
-
isString
|
|
112
|
-
};
|
|
113
|
-
if (isString && format.startsWith("hs")) {
|
|
114
|
-
const values = extractHueAndSaturationRegExp.exec(color);
|
|
115
|
-
if (values !== null) {
|
|
116
|
-
const [, h, s] = values;
|
|
117
|
-
this.value = Number(h);
|
|
118
|
-
this._saturation = Number(s);
|
|
119
|
-
}
|
|
120
|
-
} else if (!isString && format.startsWith("hs")) {
|
|
121
|
-
const colorInput = this._color.originalInput;
|
|
122
|
-
const colorValues = Object.values(colorInput);
|
|
123
|
-
this.value = colorValues[0];
|
|
124
|
-
this._saturation = colorValues[1];
|
|
125
|
-
} else {
|
|
126
|
-
const { h } = this._color.toHsv();
|
|
127
|
-
this.value = h;
|
|
128
|
-
}
|
|
129
|
-
this.requestUpdate("color", oldValue);
|
|
130
|
-
}
|
|
131
|
-
get altered() {
|
|
132
|
-
return this._altered;
|
|
133
|
-
}
|
|
134
|
-
set altered(altered) {
|
|
135
|
-
this._altered = altered;
|
|
136
|
-
this.step = Math.max(1, this.altered * 10);
|
|
137
|
-
}
|
|
138
|
-
get focusElement() {
|
|
139
|
-
return this.input;
|
|
140
|
-
}
|
|
141
|
-
handleKeydown(event) {
|
|
142
|
-
const { key } = event;
|
|
143
|
-
this.focused = true;
|
|
144
|
-
this.altered = [event.shiftKey, event.ctrlKey, event.altKey].filter((key2) => !!key2).length;
|
|
145
|
-
let delta = 0;
|
|
146
|
-
switch (key) {
|
|
147
|
-
case "ArrowUp":
|
|
148
|
-
delta = this.step;
|
|
149
|
-
break;
|
|
150
|
-
case "ArrowDown":
|
|
151
|
-
delta = -this.step;
|
|
152
|
-
break;
|
|
153
|
-
case "ArrowLeft":
|
|
154
|
-
delta = this.step * (this.isLTR ? -1 : 1);
|
|
155
|
-
break;
|
|
156
|
-
case "ArrowRight":
|
|
157
|
-
delta = this.step * (this.isLTR ? 1 : -1);
|
|
158
|
-
break;
|
|
159
|
-
default:
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
event.preventDefault();
|
|
163
|
-
this.value = (360 + this.value + delta) % 360;
|
|
164
|
-
this._previousColor = this._color.clone();
|
|
165
|
-
this._color = new TinyColor({ ...this._color.toHsl(), h: this.value });
|
|
166
|
-
this.dispatchEvent(new Event("input", {
|
|
167
|
-
bubbles: true,
|
|
168
|
-
composed: true
|
|
169
|
-
}));
|
|
170
|
-
const applyDefault = this.dispatchEvent(new Event("change", {
|
|
171
|
-
bubbles: true,
|
|
172
|
-
composed: true,
|
|
173
|
-
cancelable: true
|
|
174
|
-
}));
|
|
175
|
-
if (!applyDefault) {
|
|
176
|
-
this._color = this._previousColor;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
handleInput(event) {
|
|
180
|
-
const { valueAsNumber } = event.target;
|
|
181
|
-
this.value = valueAsNumber;
|
|
182
|
-
this._color = new TinyColor({ ...this._color.toHsl(), h: this.value });
|
|
183
|
-
}
|
|
184
|
-
handleChange(event) {
|
|
185
|
-
this.handleInput(event);
|
|
186
|
-
this.dispatchEvent(new Event("change", {
|
|
187
|
-
bubbles: true,
|
|
188
|
-
composed: true
|
|
189
|
-
}));
|
|
190
|
-
}
|
|
191
|
-
focus(focusOptions = {}) {
|
|
192
|
-
super.focus(focusOptions);
|
|
193
|
-
this.forwardFocus();
|
|
194
|
-
}
|
|
195
|
-
forwardFocus() {
|
|
196
|
-
this.focused = this.hasVisibleFocusInTree();
|
|
197
|
-
this.input.focus();
|
|
198
|
-
}
|
|
199
|
-
handleFocusin() {
|
|
200
|
-
this.focused = true;
|
|
201
|
-
}
|
|
202
|
-
handleFocusout() {
|
|
203
|
-
if (this._pointerDown) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
this.altered = 0;
|
|
207
|
-
this.focused = false;
|
|
208
|
-
}
|
|
209
|
-
handlePointerdown(event) {
|
|
210
|
-
if (event.button !== 0) {
|
|
211
|
-
event.preventDefault();
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
this._pointerDown = true;
|
|
215
|
-
this._previousColor = this._color.clone();
|
|
216
|
-
this.boundingClientRect = this.getBoundingClientRect();
|
|
217
|
-
event.target.setPointerCapture(event.pointerId);
|
|
218
|
-
if (event.pointerType === "mouse") {
|
|
219
|
-
this.focused = true;
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
handlePointermove(event) {
|
|
223
|
-
this.value = this.calculateHandlePosition(event);
|
|
224
|
-
this._color = new TinyColor({ ...this._color.toHsl(), h: this.value });
|
|
225
|
-
this.dispatchEvent(new Event("input", {
|
|
226
|
-
bubbles: true,
|
|
227
|
-
composed: true,
|
|
228
|
-
cancelable: true
|
|
229
|
-
}));
|
|
230
|
-
}
|
|
231
|
-
handlePointerup(event) {
|
|
232
|
-
this._pointerDown = false;
|
|
233
|
-
event.target.releasePointerCapture(event.pointerId);
|
|
234
|
-
const applyDefault = this.dispatchEvent(new Event("change", {
|
|
235
|
-
bubbles: true,
|
|
236
|
-
composed: true,
|
|
237
|
-
cancelable: true
|
|
238
|
-
}));
|
|
239
|
-
if (!applyDefault) {
|
|
240
|
-
this._color = this._previousColor;
|
|
241
|
-
}
|
|
242
|
-
this.focus();
|
|
243
|
-
if (event.pointerType === "mouse") {
|
|
244
|
-
this.focused = false;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
calculateHandlePosition(event) {
|
|
248
|
-
if (!this.boundingClientRect) {
|
|
249
|
-
return this.value;
|
|
250
|
-
}
|
|
251
|
-
const rect = this.boundingClientRect;
|
|
252
|
-
const { width, height, left, top } = rect;
|
|
253
|
-
const centerX = left + width / 2;
|
|
254
|
-
const centerY = top + height / 2;
|
|
255
|
-
const pointX = event.clientX - centerX;
|
|
256
|
-
const pointY = event.clientY - centerY;
|
|
257
|
-
const value = Math.atan2(pointY, pointX) * 180 / Math.PI;
|
|
258
|
-
return (360 + (360 + value)) % 360;
|
|
259
|
-
}
|
|
260
|
-
handleGradientPointerdown(event) {
|
|
261
|
-
if (event.button !== 0 || event.target.classList.contains("innerCircle")) {
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
event.stopPropagation();
|
|
265
|
-
event.preventDefault();
|
|
266
|
-
this.handle.dispatchEvent(new PointerEvent("pointerdown", event));
|
|
267
|
-
this.handlePointermove(event);
|
|
268
|
-
}
|
|
269
|
-
render() {
|
|
270
|
-
const { width: diameter = 160 } = this.boundingClientRect || {};
|
|
271
|
-
const radius = diameter / 2;
|
|
272
|
-
const trackWidth = 24;
|
|
273
|
-
const innerRadius = radius - trackWidth;
|
|
274
|
-
const innerDiameter = innerRadius * 2;
|
|
275
|
-
const clipPath = `path(evenodd, "M ${radius} ${radius} m -${radius} 0 a ${radius} ${radius} 0 1 0 ${diameter} 0 a ${radius} ${radius} 0 1 0 -${diameter} 0 M ${radius} ${radius} m -${innerRadius} 0 a ${innerRadius} ${innerRadius} 0 1 0 ${innerDiameter} 0 a ${innerRadius} ${innerRadius} 0 1 0 -${innerDiameter} 0")`;
|
|
276
|
-
const handleLocationStyles = `transform: translate(${(radius - 12.5) * Math.cos(this.value * Math.PI / 180)}px, ${(radius - 12.5) * Math.sin(this.value * Math.PI / 180)}px);`;
|
|
277
|
-
return html`
|
|
1
|
+
var m=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var n=(u,t,e,i)=>{for(var s=i>1?void 0:i?g(t,e):t,r=u.length-1,o;r>=0;r--)(o=u[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&m(t,e,s),s};import{html as _}from"@spectrum-web-components/base";import{ifDefined as w}from"@spectrum-web-components/base/src/directives.js";import{property as l,query as c}from"@spectrum-web-components/base/src/decorators.js";import{streamingListener as $}from"@spectrum-web-components/base/src/streaming-listener.js";import{Focusable as S}from"@spectrum-web-components/shared/src/focusable.js";import"@spectrum-web-components/color-handle/sp-color-handle.js";import y from"./color-wheel.css.js";import{extractHueAndSaturationRegExp as R,replaceHueAndSaturationRegExp as p}from"@spectrum-web-components/color-handle";import{TinyColor as a}from"@ctrl/tinycolor";export class ColorWheel extends S{constructor(){super(...arguments);this.disabled=!1;this.focused=!1;this.label="hue";this.step=1;this._value=0;this._color=new a({h:0,s:1,v:1});this._previousColor=new a({h:0,s:1,v:1});this._format={format:"",isString:!1};this._altered=0;this._pointerDown=!1}static get styles(){return[y]}get value(){return this._value}set value(t){const e=Math.min(360,Math.max(0,t));if(e===this.value)return;const i=this.value,{s,v:r}=this._color.toHsv();this._color=new a({h:e,s,v:r}),this._value=e,this.requestUpdate("value",i)}get color(){switch(this._format.format){case"rgb":return this._format.isString?this._color.toRgbString():this._color.toRgb();case"prgb":return this._format.isString?this._color.toPercentageRgbString():this._color.toPercentageRgb();case"hex":case"hex3":case"hex4":case"hex6":return this._format.isString?this._color.toHexString():this._color.toHex();case"hex8":return this._format.isString?this._color.toHex8String():this._color.toHex8();case"name":return this._color.toName()||this._color.toRgbString();case"hsl":if(this._format.isString)return this._color.toHslString().replace(p,`$1${this.value}$2${this._saturation}`);{const{s:t,l:e,a:i}=this._color.toHsl();return{h:this.value,s:t,l:e,a:i}}case"hsv":if(this._format.isString)return this._color.toHsvString().replace(p,`$1${this.value}$2${this._saturation}`);{const{s:t,v:e,a:i}=this._color.toHsv();return{h:this.value,s:t,v:e,a:i}}default:return"No color format applied."}}set color(t){if(t===this.color)return;const e=this._color;this._color=new a(t);const i=this._color.format;let s=typeof t=="string"||t instanceof String;if(i.startsWith("hex")&&(s=t.startsWith("#")),this._format={format:i,isString:s},s&&i.startsWith("hs")){const r=R.exec(t);if(r!==null){const[,o,h]=r;this.value=Number(o),this._saturation=Number(h)}}else if(!s&&i.startsWith("hs")){const r=this._color.originalInput,o=Object.values(r);this.value=o[0],this._saturation=o[1]}else{const{h:r}=this._color.toHsv();this.value=r}this.requestUpdate("color",e)}get altered(){return this._altered}set altered(t){this._altered=t,this.step=Math.max(1,this.altered*10)}get focusElement(){return this.input}handleKeydown(t){const{key:e}=t;this.focused=!0,this.altered=[t.shiftKey,t.ctrlKey,t.altKey].filter(r=>!!r).length;let i=0;switch(e){case"ArrowUp":i=this.step;break;case"ArrowDown":i=-this.step;break;case"ArrowLeft":i=this.step*(this.isLTR?-1:1);break;case"ArrowRight":i=this.step*(this.isLTR?1:-1);break;default:return}t.preventDefault(),this.value=(360+this.value+i)%360,this._previousColor=this._color.clone(),this._color=new a({...this._color.toHsl(),h:this.value}),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0,cancelable:!0}))||(this._color=this._previousColor)}handleInput(t){const{valueAsNumber:e}=t.target;this.value=e,this._color=new a({...this._color.toHsl(),h:this.value})}handleChange(t){this.handleInput(t),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))}focus(t={}){super.focus(t),this.forwardFocus()}forwardFocus(){this.focused=this.hasVisibleFocusInTree(),this.input.focus()}handleFocusin(){this.focused=!0}handleFocusout(){this._pointerDown||(this.altered=0,this.focused=!1)}handlePointerdown(t){if(t.button!==0){t.preventDefault();return}this._pointerDown=!0,this._previousColor=this._color.clone(),this.boundingClientRect=this.getBoundingClientRect(),t.target.setPointerCapture(t.pointerId),t.pointerType==="mouse"&&(this.focused=!0)}handlePointermove(t){this.value=this.calculateHandlePosition(t),this._color=new a({...this._color.toHsl(),h:this.value}),this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0,cancelable:!0}))}handlePointerup(t){this._pointerDown=!1,t.target.releasePointerCapture(t.pointerId),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0,cancelable:!0}))||(this._color=this._previousColor),this.focus(),t.pointerType==="mouse"&&(this.focused=!1)}calculateHandlePosition(t){if(!this.boundingClientRect)return this.value;const e=this.boundingClientRect,{width:i,height:s,left:r,top:o}=e,h=r+i/2,d=o+s/2,v=t.clientX-h,b=t.clientY-d,f=Math.atan2(b,v)*180/Math.PI;return(360+(360+f))%360}handleGradientPointerdown(t){t.button!==0||t.target.classList.contains("innerCircle")||(t.stopPropagation(),t.preventDefault(),this.handle.dispatchEvent(new PointerEvent("pointerdown",t)),this.handlePointermove(t))}render(){const{width:t=160}=this.boundingClientRect||{},e=t/2,s=e-24,r=s*2,o=`path(evenodd, "M ${e} ${e} m -${e} 0 a ${e} ${e} 0 1 0 ${t} 0 a ${e} ${e} 0 1 0 -${t} 0 M ${e} ${e} m -${s} 0 a ${s} ${s} 0 1 0 ${r} 0 a ${s} ${s} 0 1 0 -${r} 0")`,h=`transform: translate(${(e-12.5)*Math.cos(this.value*Math.PI/180)}px, ${(e-12.5)*Math.sin(this.value*Math.PI/180)}px);`;return _`
|
|
278
2
|
<slot
|
|
279
3
|
name="gradient"
|
|
280
4
|
@pointerdown=${this.handleGradientPointerdown}
|
|
281
5
|
>
|
|
282
|
-
<div class="wheel" style="clip-path: ${
|
|
6
|
+
<div class="wheel" style="clip-path: ${o}"></div>
|
|
283
7
|
</slot>
|
|
284
8
|
|
|
285
9
|
<sp-color-handle
|
|
286
|
-
tabindex=${
|
|
10
|
+
tabindex=${w(this.focused?void 0:"0")}
|
|
287
11
|
@focus=${this.forwardFocus}
|
|
288
12
|
?focused=${this.focused}
|
|
289
13
|
class="handle"
|
|
290
14
|
color="hsl(${this.value}, 100%, 50%)"
|
|
291
15
|
?disabled=${this.disabled}
|
|
292
|
-
style=${
|
|
293
|
-
${
|
|
294
|
-
start: ["pointerdown", this.handlePointerdown],
|
|
295
|
-
streamInside: ["pointermove", this.handlePointermove],
|
|
296
|
-
end: [["pointerup", "pointercancel"], this.handlePointerup]
|
|
297
|
-
})}
|
|
16
|
+
style=${h}
|
|
17
|
+
${$({start:["pointerdown",this.handlePointerdown],streamInside:["pointermove",this.handlePointermove],end:[["pointerup","pointercancel"],this.handlePointerup]})}
|
|
298
18
|
></sp-color-handle>
|
|
299
19
|
|
|
300
20
|
<input
|
|
@@ -309,55 +29,5 @@ export class ColorWheel extends Focusable {
|
|
|
309
29
|
@change=${this.handleChange}
|
|
310
30
|
@keydown=${this.handleKeydown}
|
|
311
31
|
/>
|
|
312
|
-
|
|
313
|
-
}
|
|
314
|
-
firstUpdated(changed) {
|
|
315
|
-
super.firstUpdated(changed);
|
|
316
|
-
this.boundingClientRect = this.getBoundingClientRect();
|
|
317
|
-
this.addEventListener("focusin", this.handleFocusin);
|
|
318
|
-
this.addEventListener("focusout", this.handleFocusout);
|
|
319
|
-
}
|
|
320
|
-
connectedCallback() {
|
|
321
|
-
var _a;
|
|
322
|
-
super.connectedCallback();
|
|
323
|
-
if (!this.observer && window.ResizeObserver) {
|
|
324
|
-
this.observer = new window.ResizeObserver((entries) => {
|
|
325
|
-
for (const entry of entries) {
|
|
326
|
-
this.boundingClientRect = entry.contentRect;
|
|
327
|
-
}
|
|
328
|
-
this.requestUpdate();
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
(_a = this.observer) == null ? void 0 : _a.observe(this);
|
|
332
|
-
}
|
|
333
|
-
disconnectedCallback() {
|
|
334
|
-
var _a;
|
|
335
|
-
(_a = this.observer) == null ? void 0 : _a.unobserve(this);
|
|
336
|
-
super.disconnectedCallback();
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
__decorateClass([
|
|
340
|
-
property({ type: Boolean, reflect: true })
|
|
341
|
-
], ColorWheel.prototype, "disabled", 2);
|
|
342
|
-
__decorateClass([
|
|
343
|
-
property({ type: Boolean, reflect: true })
|
|
344
|
-
], ColorWheel.prototype, "focused", 2);
|
|
345
|
-
__decorateClass([
|
|
346
|
-
query(".handle")
|
|
347
|
-
], ColorWheel.prototype, "handle", 2);
|
|
348
|
-
__decorateClass([
|
|
349
|
-
property({ type: String })
|
|
350
|
-
], ColorWheel.prototype, "label", 2);
|
|
351
|
-
__decorateClass([
|
|
352
|
-
property({ type: Number })
|
|
353
|
-
], ColorWheel.prototype, "step", 2);
|
|
354
|
-
__decorateClass([
|
|
355
|
-
property({ type: Number })
|
|
356
|
-
], ColorWheel.prototype, "value", 1);
|
|
357
|
-
__decorateClass([
|
|
358
|
-
property({ type: String })
|
|
359
|
-
], ColorWheel.prototype, "color", 1);
|
|
360
|
-
__decorateClass([
|
|
361
|
-
query("input")
|
|
362
|
-
], ColorWheel.prototype, "input", 2);
|
|
32
|
+
`}firstUpdated(t){super.firstUpdated(t),this.boundingClientRect=this.getBoundingClientRect(),this.addEventListener("focusin",this.handleFocusin),this.addEventListener("focusout",this.handleFocusout)}connectedCallback(){var t;super.connectedCallback(),!this.observer&&window.ResizeObserver&&(this.observer=new window.ResizeObserver(e=>{for(const i of e)this.boundingClientRect=i.contentRect;this.requestUpdate()})),(t=this.observer)==null||t.observe(this)}disconnectedCallback(){var t;(t=this.observer)==null||t.unobserve(this),super.disconnectedCallback()}}n([l({type:Boolean,reflect:!0})],ColorWheel.prototype,"disabled",2),n([l({type:Boolean,reflect:!0})],ColorWheel.prototype,"focused",2),n([c(".handle")],ColorWheel.prototype,"handle",2),n([l({type:String})],ColorWheel.prototype,"label",2),n([l({type:Number})],ColorWheel.prototype,"step",2),n([l({type:Number})],ColorWheel.prototype,"value",1),n([l({type:String})],ColorWheel.prototype,"color",1),n([c("input")],ColorWheel.prototype,"input",2);
|
|
363
33
|
//# sourceMappingURL=ColorWheel.js.map
|
package/src/ColorWheel.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["ColorWheel.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 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 html,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport {\n property,\n query,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { streamingListener } from '@spectrum-web-components/base/src/streaming-listener.js';\nimport { SWCResizeObserverEntry, WithSWCResizeObserver } from './types';\nimport { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport '@spectrum-web-components/color-handle/sp-color-handle.js';\nimport styles from './color-wheel.css.js';\nimport {\n ColorHandle,\n ColorValue,\n extractHueAndSaturationRegExp,\n replaceHueAndSaturationRegExp,\n} from '@spectrum-web-components/color-handle';\nimport { TinyColor } from '@ctrl/tinycolor';\n\n/**\n * @element sp-color-wheel\n * @slot gradient - a custom gradient visually outlining the available color values\n * @fires input - The value of the Color Wheel has changed.\n * @fires change - An alteration to the value of the Color Wheel has been committed by the user.\n */\nexport class ColorWheel extends Focusable {\n public static override get styles(): CSSResultArray {\n return [styles];\n }\n\n @property({ type: Boolean, reflect: true })\n public override disabled = false;\n\n @property({ type: Boolean, reflect: true })\n public focused = false;\n\n @query('.handle')\n private handle!: ColorHandle;\n\n @property({ type: String })\n public label = 'hue';\n\n @property({ type: Number })\n public step = 1;\n\n @property({ type: Number })\n public get value(): number {\n return this._value;\n }\n\n public set value(hue: number) {\n const value = Math.min(360, Math.max(0, hue));\n if (value === this.value) {\n return;\n }\n const oldValue = this.value;\n const { s, v } = this._color.toHsv();\n this._color = new TinyColor({ h: value, s, v });\n this._value = value;\n this.requestUpdate('value', oldValue);\n }\n\n private _value = 0;\n\n @property({ type: String })\n public get color(): ColorValue {\n switch (this._format.format) {\n case 'rgb':\n return this._format.isString\n ? this._color.toRgbString()\n : this._color.toRgb();\n case 'prgb':\n return this._format.isString\n ? this._color.toPercentageRgbString()\n : this._color.toPercentageRgb();\n case 'hex':\n case 'hex3':\n case 'hex4':\n case 'hex6':\n return this._format.isString\n ? this._color.toHexString()\n : this._color.toHex();\n case 'hex8':\n return this._format.isString\n ? this._color.toHex8String()\n : this._color.toHex8();\n case 'name':\n return this._color.toName() || this._color.toRgbString();\n case 'hsl':\n if (this._format.isString) {\n const hslString = this._color.toHslString();\n return hslString.replace(\n replaceHueAndSaturationRegExp,\n `$1${this.value}$2${this._saturation}`\n );\n } else {\n const { s, l, a } = this._color.toHsl();\n return { h: this.value, s, l, a };\n }\n case 'hsv':\n if (this._format.isString) {\n const hsvString = this._color.toHsvString();\n return hsvString.replace(\n replaceHueAndSaturationRegExp,\n `$1${this.value}$2${this._saturation}`\n );\n } else {\n const { s, v, a } = this._color.toHsv();\n return { h: this.value, s, v, a };\n }\n default:\n return 'No color format applied.';\n }\n }\n\n public set color(color: ColorValue) {\n if (color === this.color) {\n return;\n }\n const oldValue = this._color;\n this._color = new TinyColor(color);\n const format = this._color.format;\n let isString = typeof color === 'string' || color instanceof String;\n\n if (format.startsWith('hex')) {\n isString = (color as string).startsWith('#');\n }\n\n this._format = {\n format,\n isString,\n };\n\n if (isString && format.startsWith('hs')) {\n const values = extractHueAndSaturationRegExp.exec(color as string);\n\n if (values !== null) {\n const [, h, s] = values;\n this.value = Number(h);\n this._saturation = Number(s);\n }\n } else if (!isString && format.startsWith('hs')) {\n const colorInput = this._color.originalInput;\n const colorValues = Object.values(colorInput);\n this.value = colorValues[0];\n this._saturation = colorValues[1];\n } else {\n const { h } = this._color.toHsv();\n this.value = h;\n }\n this.requestUpdate('color', oldValue);\n }\n\n private _color = new TinyColor({ h: 0, s: 1, v: 1 });\n\n private _previousColor = new TinyColor({ h: 0, s: 1, v: 1 });\n\n private _saturation!: number;\n\n private _format: { format: string; isString: boolean } = {\n format: '',\n isString: false,\n };\n private get altered(): number {\n return this._altered;\n }\n\n private set altered(altered: number) {\n this._altered = altered;\n this.step = Math.max(1, this.altered * 10);\n }\n\n private _altered = 0;\n\n @query('input')\n public input!: HTMLInputElement;\n\n public override get focusElement(): HTMLInputElement {\n return this.input;\n }\n\n private handleKeydown(event: KeyboardEvent): void {\n const { key } = event;\n this.focused = true;\n this.altered = [event.shiftKey, event.ctrlKey, event.altKey].filter(\n (key) => !!key\n ).length;\n let delta = 0;\n switch (key) {\n case 'ArrowUp':\n delta = this.step;\n break;\n case 'ArrowDown':\n delta = -this.step;\n break;\n case 'ArrowLeft':\n delta = this.step * (this.isLTR ? -1 : 1);\n break;\n case 'ArrowRight':\n delta = this.step * (this.isLTR ? 1 : -1);\n break;\n default:\n return;\n }\n event.preventDefault();\n this.value = (360 + this.value + delta) % 360;\n this._previousColor = this._color.clone();\n this._color = new TinyColor({ ...this._color.toHsl(), h: this.value });\n this.dispatchEvent(\n new Event('input', {\n bubbles: true,\n composed: true,\n })\n );\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this._color = this._previousColor;\n }\n }\n\n private handleInput(event: Event & { target: HTMLInputElement }): void {\n const { valueAsNumber } = event.target;\n\n this.value = valueAsNumber;\n this._color = new TinyColor({ ...this._color.toHsl(), h: this.value });\n }\n\n private handleChange(event: Event & { target: HTMLInputElement }): void {\n this.handleInput(event);\n this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n })\n );\n }\n\n public override focus(focusOptions: FocusOptions = {}): void {\n super.focus(focusOptions);\n this.forwardFocus();\n }\n\n private forwardFocus(): void {\n this.focused = this.hasVisibleFocusInTree();\n this.input.focus();\n }\n\n private handleFocusin(): void {\n this.focused = true;\n }\n\n private handleFocusout(): void {\n if (this._pointerDown) {\n return;\n }\n this.altered = 0;\n this.focused = false;\n }\n\n private boundingClientRect!: DOMRect;\n private _pointerDown = false;\n\n private handlePointerdown(event: PointerEvent): void {\n if (event.button !== 0) {\n event.preventDefault();\n return;\n }\n this._pointerDown = true;\n this._previousColor = this._color.clone();\n this.boundingClientRect = this.getBoundingClientRect();\n (event.target as HTMLElement).setPointerCapture(event.pointerId);\n if (event.pointerType === 'mouse') {\n this.focused = true;\n }\n }\n\n private handlePointermove(event: PointerEvent): void {\n this.value = this.calculateHandlePosition(event);\n this._color = new TinyColor({ ...this._color.toHsl(), h: this.value });\n\n this.dispatchEvent(\n new Event('input', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n }\n\n private handlePointerup(event: PointerEvent): void {\n this._pointerDown = false;\n (event.target as HTMLElement).releasePointerCapture(event.pointerId);\n\n const applyDefault = this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n cancelable: true,\n })\n );\n if (!applyDefault) {\n this._color = this._previousColor;\n }\n // Retain focus on input element after mouse up to enable keyboard interactions\n this.focus();\n if (event.pointerType === 'mouse') {\n this.focused = false;\n }\n }\n\n /**\n * Returns the value under the cursor\n * @param: PointerEvent on slider\n * @return: Slider value that correlates to the position under the pointer\n */\n private calculateHandlePosition(event: PointerEvent): number {\n /* c8 ignore next 3 */\n if (!this.boundingClientRect) {\n return this.value;\n }\n const rect = this.boundingClientRect;\n const { width, height, left, top } = rect;\n const centerX = left + width / 2;\n const centerY = top + height / 2;\n const pointX = event.clientX - centerX;\n const pointY = event.clientY - centerY;\n const value = (Math.atan2(pointY, pointX) * 180) / Math.PI;\n\n return (360 + (360 + value)) % 360;\n }\n\n private handleGradientPointerdown(event: PointerEvent): void {\n if (\n event.button !== 0 ||\n (event.target as SVGElement).classList.contains('innerCircle')\n ) {\n return;\n }\n event.stopPropagation();\n event.preventDefault();\n this.handle.dispatchEvent(new PointerEvent('pointerdown', event));\n this.handlePointermove(event);\n }\n\n protected override render(): TemplateResult {\n const { width: diameter = 160 } = this.boundingClientRect || {};\n\n const radius = diameter / 2;\n const trackWidth = 24;\n const innerRadius = radius - trackWidth;\n const innerDiameter = innerRadius * 2;\n const clipPath = `path(evenodd, \"M ${radius} ${radius} m -${radius} 0 a ${radius} ${radius} 0 1 0 ${diameter} 0 a ${radius} ${radius} 0 1 0 -${diameter} 0 M ${radius} ${radius} m -${innerRadius} 0 a ${innerRadius} ${innerRadius} 0 1 0 ${innerDiameter} 0 a ${innerRadius} ${innerRadius} 0 1 0 -${innerDiameter} 0\")`;\n const handleLocationStyles = `transform: translate(${\n (radius - 12.5) * Math.cos((this.value * Math.PI) / 180)\n }px, ${(radius - 12.5) * Math.sin((this.value * Math.PI) / 180)}px);`;\n return html`\n <slot\n name=\"gradient\"\n @pointerdown=${this.handleGradientPointerdown}\n >\n <div class=\"wheel\" style=\"clip-path: ${clipPath}\"></div>\n </slot>\n\n <sp-color-handle\n tabindex=${ifDefined(this.focused ? undefined : '0')}\n @focus=${this.forwardFocus}\n ?focused=${this.focused}\n class=\"handle\"\n color=\"hsl(${this.value}, 100%, 50%)\"\n ?disabled=${this.disabled}\n style=${handleLocationStyles}\n ${streamingListener({\n start: ['pointerdown', this.handlePointerdown],\n streamInside: ['pointermove', this.handlePointermove],\n end: [['pointerup', 'pointercancel'], this.handlePointerup],\n })}\n ></sp-color-handle>\n\n <input\n type=\"range\"\n class=\"slider\"\n aria-label=${this.label}\n min=\"0\"\n max=\"360\"\n step=${this.step}\n .value=${String(this.value)}\n @input=${this.handleInput}\n @change=${this.handleChange}\n @keydown=${this.handleKeydown}\n />\n `;\n }\n\n protected override firstUpdated(changed: PropertyValues): void {\n super.firstUpdated(changed);\n this.boundingClientRect = this.getBoundingClientRect();\n this.addEventListener('focusin', this.handleFocusin);\n this.addEventListener('focusout', this.handleFocusout);\n }\n\n private observer?: WithSWCResizeObserver['ResizeObserver'];\n\n public override connectedCallback(): void {\n super.connectedCallback();\n if (\n !this.observer &&\n (window as unknown as WithSWCResizeObserver).ResizeObserver\n ) {\n this.observer = new (\n window as unknown as WithSWCResizeObserver\n ).ResizeObserver((entries: SWCResizeObserverEntry[]) => {\n for (const entry of entries) {\n this.boundingClientRect = entry.contentRect;\n }\n this.requestUpdate();\n });\n }\n this.observer?.observe(this);\n }\n\n public override disconnectedCallback(): void {\n this.observer?.unobserve(this);\n super.disconnectedCallback();\n }\n}\n"],
|
|
5
|
-
"mappings": "
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um-web-components/base";const r=e`
|
|
3
2
|
:host{--spectrum-colorwheel-border-radius:100%;--spectrum-colorwheel-width:calc(var(--spectrum-global-dimension-size-125)*16);--spectrum-colorwheel-height:var(
|
|
4
3
|
--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)
|
|
5
4
|
)}:host([focused]) .handle{height:calc(var(
|
|
@@ -43,6 +42,5 @@ var(--spectrum-global-dimension-size-200)
|
|
|
43
42
|
)}:host([disabled]) .wheel{background:var(
|
|
44
43
|
--spectrum-colorwheel-fill-color-disabled,var(--spectrum-global-color-gray-300)
|
|
45
44
|
)}
|
|
46
|
-
`;
|
|
47
|
-
export default styles;
|
|
45
|
+
`;export default r;
|
|
48
46
|
//# sourceMappingURL=color-wheel.css.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["color-wheel.css.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{--spectrum-colorwheel-border-radius:100%;--spectrum-colorwheel-width:calc(var(--spectrum-global-dimension-size-125)*16);--spectrum-colorwheel-height:var(\n--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)\n)}:host([focused]) .handle{height:calc(var(\n--spectrum-colorhandle-size,\nvar(--spectrum-global-dimension-size-200)\n)*2);margin-left:calc(var(\n--spectrum-colorhandle-size,\nvar(--spectrum-global-dimension-size-200)\n)*-1);margin-top:calc(var(\n--spectrum-colorhandle-size,\nvar(--spectrum-global-dimension-size-200)\n)*-1);width:calc(var(\n--spectrum-colorhandle-size,\nvar(--spectrum-global-dimension-size-200)\n)*2)}.slider{height:100%;left:0;margin:0;opacity:0;pointer-events:none;position:absolute;top:0;width:100%;z-index:0}:host{border-radius:var(--spectrum-colorwheel-border-radius);cursor:default;display:block;height:var(\n--spectrum-colorwheel-height,var(--spectrum-global-dimension-size-2400)\n);position:relative;-webkit-user-select:none;user-select:none;width:var(\n--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)\n)}:host([focused]){z-index:2}:host([disabled]){pointer-events:none}:host([dragged]){z-index:2}::slotted([slot=gradient]){border-radius:100%;border-style:solid;border-width:var(\n--spectrum-colorwheel-border-size,var(--spectrum-alias-border-size-thin)\n);box-sizing:border-box;height:var(\n--spectrum-colorwheel-height,var(--spectrum-global-dimension-size-2400)\n);position:relative;width:var(\n--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)\n);z-index:0}.wheel{position:relative;z-index:1}.innerCircle,.outerCircle{fill:transparent;stroke-width:var(\n--spectrum-colorwheel-border-size,var(--spectrum-alias-border-size-thin)\n)}.handle{left:50%;top:50%}:host{--spectrum-colorwheel-border-color:var(\n--spectrum-colorarea-border-color,var(--spectrum-alias-border-color-translucent)\n)}:host([disabled]) .innerCircle,:host([disabled]) .outerCircle{stroke:var(\n--spectrum-colorwheel-border-color-disabled,var(--spectrum-alias-track-color-disabled)\n)}:host([disabled]) .outerCircle{fill:var(\n--spectrum-colorwheel-fill-color-disabled,var(--spectrum-alias-track-color-disabled)\n)}:host([disabled]) .segment{display:none}::slotted([slot=gradient]){border-color:var(\n--spectrum-colorwheel-border-color,var(--spectrum-alias-border-color-translucent)\n)}.innerCircle,.outerCircle{stroke:var(\n--spectrum-colorwheel-border-color,var(--spectrum-alias-border-color-translucent)\n)}@media (forced-colors:active){:host{--spectrum-colorwheel-border-color-disabled:GrayText;--spectrum-colorwheel-fill-color-disabled:Canvas}:host{forced-color-adjust:none}}:host{touch-action:none}:host(:focus){outline:none}.wheel{background:conic-gradient(from 90deg,red,#ff8000,#ff0,#80ff00,#0f0,#00ff80,#0ff,#0080ff,#00f,#8000ff,#f0f,#ff0080,red);height:100%;width:100%}.wheel:after,.wheel:before{border:var(\n--spectrum-colorwheel-border-size,var(--spectrum-alias-border-size-thin)\n) solid var(--spectrum-colorwheel-border-color);border-radius:50%;content:\"\";position:absolute}.wheel:after{inset:0}.wheel:before{inset:24px}:host([disabled]) .wheel:after,:host([disabled]) .wheel:before{border-color:var(\n--spectrum-colorwheel-border-color-disabled,var(--spectrum-global-color-gray-300)\n)}:host([disabled]) .wheel{background:var(\n--spectrum-colorwheel-fill-color-disabled,var(--spectrum-global-color-gray-300)\n)}\n`;\nexport default styles;"],
|
|
5
|
-
"mappings": "AAWA
|
|
5
|
+
"mappings": "AAWA,oDACA,KAAM,GAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA6Cf,cAAe",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export*from"./ColorWheel.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["index.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2020 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\nexport * from './ColorWheel.js';\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": "AAYA",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
const styles = css`
|
|
1
|
+
import{css as e}from"@spectrum-web-components/base";const r=e`
|
|
3
2
|
:host{--spectrum-colorwheel-border-radius:100%;--spectrum-colorwheel-width:calc(var(--spectrum-global-dimension-size-125)*16);--spectrum-colorwheel-height:var(
|
|
4
3
|
--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)
|
|
5
4
|
)}:host([focused]) .handle{height:calc(var(
|
|
@@ -37,6 +36,5 @@ var(--spectrum-global-dimension-size-200)
|
|
|
37
36
|
)}.innerCircle,.outerCircle{stroke:var(
|
|
38
37
|
--spectrum-colorwheel-border-color,var(--spectrum-alias-border-color-translucent)
|
|
39
38
|
)}@media (forced-colors:active){:host{--spectrum-colorwheel-border-color-disabled:GrayText;--spectrum-colorwheel-fill-color-disabled:Canvas}:host{forced-color-adjust:none}}
|
|
40
|
-
`;
|
|
41
|
-
export default styles;
|
|
39
|
+
`;export default r;
|
|
42
40
|
//# sourceMappingURL=spectrum-color-wheel.css.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["spectrum-color-wheel.css.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{--spectrum-colorwheel-border-radius:100%;--spectrum-colorwheel-width:calc(var(--spectrum-global-dimension-size-125)*16);--spectrum-colorwheel-height:var(\n--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)\n)}:host([focused]) .handle{height:calc(var(\n--spectrum-colorhandle-size,\nvar(--spectrum-global-dimension-size-200)\n)*2);margin-left:calc(var(\n--spectrum-colorhandle-size,\nvar(--spectrum-global-dimension-size-200)\n)*-1);margin-top:calc(var(\n--spectrum-colorhandle-size,\nvar(--spectrum-global-dimension-size-200)\n)*-1);width:calc(var(\n--spectrum-colorhandle-size,\nvar(--spectrum-global-dimension-size-200)\n)*2)}.slider{height:100%;left:0;margin:0;opacity:0;pointer-events:none;position:absolute;top:0;width:100%;z-index:0}:host{border-radius:var(--spectrum-colorwheel-border-radius);cursor:default;display:block;height:var(\n--spectrum-colorwheel-height,var(--spectrum-global-dimension-size-2400)\n);position:relative;-webkit-user-select:none;user-select:none;width:var(\n--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)\n)}:host([focused]){z-index:2}:host([disabled]){pointer-events:none}:host([dragged]){z-index:2}::slotted([slot=gradient]){border-radius:100%;border-style:solid;border-width:var(\n--spectrum-colorwheel-border-size,var(--spectrum-alias-border-size-thin)\n);box-sizing:border-box;height:var(\n--spectrum-colorwheel-height,var(--spectrum-global-dimension-size-2400)\n);position:relative;width:var(\n--spectrum-colorwheel-width,var(--spectrum-global-dimension-size-2400)\n);z-index:0}.wheel{position:relative;z-index:1}.innerCircle,.outerCircle{fill:transparent;stroke-width:var(\n--spectrum-colorwheel-border-size,var(--spectrum-alias-border-size-thin)\n)}.handle{left:50%;top:50%}:host{--spectrum-colorwheel-border-color:var(\n--spectrum-colorarea-border-color,var(--spectrum-alias-border-color-translucent)\n)}:host([disabled]) .innerCircle,:host([disabled]) .outerCircle{stroke:var(\n--spectrum-colorwheel-border-color-disabled,var(--spectrum-alias-track-color-disabled)\n)}:host([disabled]) .outerCircle{fill:var(\n--spectrum-colorwheel-fill-color-disabled,var(--spectrum-alias-track-color-disabled)\n)}:host([disabled]) .segment{display:none}::slotted([slot=gradient]){border-color:var(\n--spectrum-colorwheel-border-color,var(--spectrum-alias-border-color-translucent)\n)}.innerCircle,.outerCircle{stroke:var(\n--spectrum-colorwheel-border-color,var(--spectrum-alias-border-color-translucent)\n)}@media (forced-colors:active){:host{--spectrum-colorwheel-border-color-disabled:GrayText;--spectrum-colorwheel-fill-color-disabled:Canvas}:host{forced-color-adjust:none}}\n`;\nexport default styles;"],
|
|
5
|
-
"mappings": "AAWA
|
|
5
|
+
"mappings": "AAWA,oDACA,KAAM,GAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuCf,cAAe",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|