@spectrum-web-components/color-slider 0.3.14-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-slider.js +1 -2
- package/sp-color-slider.js.map +1 -1
- package/src/ColorSlider.js +5 -324
- package/src/ColorSlider.js.map +1 -1
- package/src/color-slider.css.js +2 -4
- package/src/color-slider.css.js.map +1 -1
- package/src/index.js +1 -1
- package/src/index.js.map +1 -1
- package/src/spectrum-color-slider.css.js +2 -4
- package/src/spectrum-color-slider.css.js.map +1 -1
- package/stories/color-slider.stories.js +8 -74
- package/stories/color-slider.stories.js.map +1 -1
- package/stories/images.js +1 -1
- package/stories/images.js.map +1 -1
- package/test/benchmark/basic-test.js +1 -4
- package/test/benchmark/basic-test.js.map +1 -1
- package/test/color-slider.test-vrt.js +1 -3
- package/test/color-slider.test-vrt.js.map +1 -1
- package/test/color-slider.test.js +23 -472
- package/test/color-slider.test.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/color-slider",
|
|
3
|
-
"version": "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.
|
|
67
|
-
"@spectrum-web-components/shared": "^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-slider.js
CHANGED
package/sp-color-slider.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["sp-color-slider.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 { ColorSlider } from './src/ColorSlider.js';\n\ncustomElements.define('sp-color-slider', ColorSlider);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-color-slider': ColorSlider;\n }\n}\n"],
|
|
5
|
-
"mappings": "AAYA
|
|
5
|
+
"mappings": "AAYA,mDAEA,eAAe,OAAO,kBAAmB,CAAW",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/ColorSlider.js
CHANGED
|
@@ -1,281 +1,4 @@
|
|
|
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-slider.css.js";
|
|
24
|
-
import {
|
|
25
|
-
extractHueAndSaturationRegExp,
|
|
26
|
-
replaceHueAndSaturationRegExp
|
|
27
|
-
} from "@spectrum-web-components/color-handle";
|
|
28
|
-
import { TinyColor } from "@ctrl/tinycolor";
|
|
29
|
-
export class ColorSlider extends Focusable {
|
|
30
|
-
constructor() {
|
|
31
|
-
super(...arguments);
|
|
32
|
-
this.disabled = false;
|
|
33
|
-
this.focused = false;
|
|
34
|
-
this.label = "hue";
|
|
35
|
-
this.vertical = false;
|
|
36
|
-
this._value = 0;
|
|
37
|
-
this.sliderHandlePosition = 0;
|
|
38
|
-
this._color = new TinyColor({ h: 0, s: 1, v: 1 });
|
|
39
|
-
this._previousColor = new TinyColor({ h: 0, s: 1, v: 1 });
|
|
40
|
-
this._format = {
|
|
41
|
-
format: "",
|
|
42
|
-
isString: false
|
|
43
|
-
};
|
|
44
|
-
this.step = 1;
|
|
45
|
-
this._altered = 0;
|
|
46
|
-
this._pointerDown = false;
|
|
47
|
-
}
|
|
48
|
-
static get styles() {
|
|
49
|
-
return [styles];
|
|
50
|
-
}
|
|
51
|
-
get value() {
|
|
52
|
-
return this._value;
|
|
53
|
-
}
|
|
54
|
-
set value(hue) {
|
|
55
|
-
const value = Math.min(360, Math.max(0, hue));
|
|
56
|
-
if (value === this.value) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const oldValue = this.value;
|
|
60
|
-
const { s, v } = this._color.toHsv();
|
|
61
|
-
this._color = new TinyColor({ h: value, s, v });
|
|
62
|
-
this._value = value;
|
|
63
|
-
if (value !== this.sliderHandlePosition) {
|
|
64
|
-
this.sliderHandlePosition = 100 * (value / 360);
|
|
65
|
-
}
|
|
66
|
-
this.requestUpdate("value", oldValue);
|
|
67
|
-
}
|
|
68
|
-
get color() {
|
|
69
|
-
switch (this._format.format) {
|
|
70
|
-
case "rgb":
|
|
71
|
-
return this._format.isString ? this._color.toRgbString() : this._color.toRgb();
|
|
72
|
-
case "prgb":
|
|
73
|
-
return this._format.isString ? this._color.toPercentageRgbString() : this._color.toPercentageRgb();
|
|
74
|
-
case "hex":
|
|
75
|
-
case "hex3":
|
|
76
|
-
case "hex4":
|
|
77
|
-
case "hex6":
|
|
78
|
-
return this._format.isString ? this._color.toHexString() : this._color.toHex();
|
|
79
|
-
case "hex8":
|
|
80
|
-
return this._format.isString ? this._color.toHex8String() : this._color.toHex8();
|
|
81
|
-
case "name":
|
|
82
|
-
return this._color.toName() || this._color.toRgbString();
|
|
83
|
-
case "hsl":
|
|
84
|
-
if (this._format.isString) {
|
|
85
|
-
const hslString = this._color.toHslString();
|
|
86
|
-
return hslString.replace(replaceHueAndSaturationRegExp, `$1${this.value}$2${this._saturation}`);
|
|
87
|
-
} else {
|
|
88
|
-
const { s, l, a } = this._color.toHsl();
|
|
89
|
-
return { h: this.value, s, l, a };
|
|
90
|
-
}
|
|
91
|
-
case "hsv":
|
|
92
|
-
if (this._format.isString) {
|
|
93
|
-
const hsvString = this._color.toHsvString();
|
|
94
|
-
return hsvString.replace(replaceHueAndSaturationRegExp, `$1${this.value}$2${this._saturation}`);
|
|
95
|
-
} else {
|
|
96
|
-
const { s, v, a } = this._color.toHsv();
|
|
97
|
-
return { h: this.value, s, v, a };
|
|
98
|
-
}
|
|
99
|
-
default:
|
|
100
|
-
return "No color format applied.";
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
set color(color) {
|
|
104
|
-
if (color === this.color) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
const oldValue = this._color;
|
|
108
|
-
this._color = new TinyColor(color);
|
|
109
|
-
const format = this._color.format;
|
|
110
|
-
let isString = typeof color === "string" || color instanceof String;
|
|
111
|
-
if (format.startsWith("hex")) {
|
|
112
|
-
isString = color.startsWith("#");
|
|
113
|
-
}
|
|
114
|
-
this._format = {
|
|
115
|
-
format,
|
|
116
|
-
isString
|
|
117
|
-
};
|
|
118
|
-
if (isString && format.startsWith("hs")) {
|
|
119
|
-
const values = extractHueAndSaturationRegExp.exec(color);
|
|
120
|
-
if (values !== null) {
|
|
121
|
-
const [, h, s] = values;
|
|
122
|
-
this.value = Number(h);
|
|
123
|
-
this._saturation = Number(s);
|
|
124
|
-
}
|
|
125
|
-
} else if (!isString && format.startsWith("hs")) {
|
|
126
|
-
const colorInput = this._color.originalInput;
|
|
127
|
-
const colorValues = Object.values(colorInput);
|
|
128
|
-
this.value = colorValues[0];
|
|
129
|
-
this._saturation = colorValues[1];
|
|
130
|
-
} else {
|
|
131
|
-
const { h } = this._color.toHsv();
|
|
132
|
-
this.value = h;
|
|
133
|
-
}
|
|
134
|
-
this._previousColor = oldValue;
|
|
135
|
-
this.requestUpdate("color", oldValue);
|
|
136
|
-
}
|
|
137
|
-
get altered() {
|
|
138
|
-
return this._altered;
|
|
139
|
-
}
|
|
140
|
-
set altered(altered) {
|
|
141
|
-
this._altered = altered;
|
|
142
|
-
this.step = Math.max(1, this.altered * 10);
|
|
143
|
-
}
|
|
144
|
-
get focusElement() {
|
|
145
|
-
return this.input;
|
|
146
|
-
}
|
|
147
|
-
handleKeydown(event) {
|
|
148
|
-
const { key } = event;
|
|
149
|
-
this.focused = true;
|
|
150
|
-
this.altered = [event.shiftKey, event.ctrlKey, event.altKey].filter((key2) => !!key2).length;
|
|
151
|
-
let delta = 0;
|
|
152
|
-
switch (key) {
|
|
153
|
-
case "ArrowUp":
|
|
154
|
-
delta = this.step;
|
|
155
|
-
break;
|
|
156
|
-
case "ArrowDown":
|
|
157
|
-
delta = -this.step;
|
|
158
|
-
break;
|
|
159
|
-
case "ArrowLeft":
|
|
160
|
-
delta = this.step * (this.isLTR ? -1 : 1);
|
|
161
|
-
break;
|
|
162
|
-
case "ArrowRight":
|
|
163
|
-
delta = this.step * (this.isLTR ? 1 : -1);
|
|
164
|
-
break;
|
|
165
|
-
default:
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
event.preventDefault();
|
|
169
|
-
this.sliderHandlePosition = Math.min(100, Math.max(0, this.sliderHandlePosition + delta));
|
|
170
|
-
this.value = 360 * (this.sliderHandlePosition / 100);
|
|
171
|
-
this._color = new TinyColor({ ...this._color.toHsl(), h: this.value });
|
|
172
|
-
if (delta != 0) {
|
|
173
|
-
this.dispatchEvent(new Event("input", {
|
|
174
|
-
bubbles: true,
|
|
175
|
-
composed: true
|
|
176
|
-
}));
|
|
177
|
-
this.dispatchEvent(new Event("change", {
|
|
178
|
-
bubbles: true,
|
|
179
|
-
composed: true
|
|
180
|
-
}));
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
handleInput(event) {
|
|
184
|
-
const { valueAsNumber } = event.target;
|
|
185
|
-
this.value = valueAsNumber;
|
|
186
|
-
this.sliderHandlePosition = 100 * (this.value / 360);
|
|
187
|
-
this._color = new TinyColor({ ...this._color.toHsl(), h: this.value });
|
|
188
|
-
}
|
|
189
|
-
handleChange(event) {
|
|
190
|
-
this.handleInput(event);
|
|
191
|
-
this.dispatchEvent(new Event("change", {
|
|
192
|
-
bubbles: true,
|
|
193
|
-
composed: true
|
|
194
|
-
}));
|
|
195
|
-
}
|
|
196
|
-
focus(focusOptions = {}) {
|
|
197
|
-
super.focus(focusOptions);
|
|
198
|
-
this.forwardFocus();
|
|
199
|
-
}
|
|
200
|
-
forwardFocus() {
|
|
201
|
-
this.focused = this.hasVisibleFocusInTree();
|
|
202
|
-
this.input.focus();
|
|
203
|
-
}
|
|
204
|
-
handleFocusin() {
|
|
205
|
-
this.focused = true;
|
|
206
|
-
}
|
|
207
|
-
handleFocusout() {
|
|
208
|
-
if (this._pointerDown) {
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
this.altered = 0;
|
|
212
|
-
this.focused = false;
|
|
213
|
-
}
|
|
214
|
-
handlePointerdown(event) {
|
|
215
|
-
if (event.button !== 0) {
|
|
216
|
-
event.preventDefault();
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
this._pointerDown = true;
|
|
220
|
-
this._previousColor = this._color.clone();
|
|
221
|
-
this.boundingClientRect = this.getBoundingClientRect();
|
|
222
|
-
event.target.setPointerCapture(event.pointerId);
|
|
223
|
-
if (event.pointerType === "mouse") {
|
|
224
|
-
this.focused = true;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
handlePointermove(event) {
|
|
228
|
-
this.sliderHandlePosition = this.calculateHandlePosition(event);
|
|
229
|
-
this.value = 360 * (this.sliderHandlePosition / 100);
|
|
230
|
-
this._color = new TinyColor({ ...this._color.toHsl(), h: this.value });
|
|
231
|
-
this.dispatchEvent(new Event("input", {
|
|
232
|
-
bubbles: true,
|
|
233
|
-
composed: true,
|
|
234
|
-
cancelable: true
|
|
235
|
-
}));
|
|
236
|
-
}
|
|
237
|
-
handlePointerup(event) {
|
|
238
|
-
this._pointerDown = false;
|
|
239
|
-
event.target.releasePointerCapture(event.pointerId);
|
|
240
|
-
const applyDefault = this.dispatchEvent(new Event("change", {
|
|
241
|
-
bubbles: true,
|
|
242
|
-
composed: true,
|
|
243
|
-
cancelable: true
|
|
244
|
-
}));
|
|
245
|
-
if (!applyDefault) {
|
|
246
|
-
this._color = this._previousColor;
|
|
247
|
-
}
|
|
248
|
-
this.focus();
|
|
249
|
-
if (event.pointerType === "mouse") {
|
|
250
|
-
this.focused = false;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
calculateHandlePosition(event) {
|
|
254
|
-
if (!this.boundingClientRect) {
|
|
255
|
-
return this.sliderHandlePosition;
|
|
256
|
-
}
|
|
257
|
-
const rect = this.boundingClientRect;
|
|
258
|
-
const minOffset = this.vertical ? rect.top : rect.left;
|
|
259
|
-
const offset = this.vertical ? event.clientY : event.clientX;
|
|
260
|
-
const size = this.vertical ? rect.height : rect.width;
|
|
261
|
-
const percent = Math.max(0, Math.min(1, (offset - minOffset) / size));
|
|
262
|
-
const sliderHandlePosition = 100 * percent;
|
|
263
|
-
return sliderHandlePosition;
|
|
264
|
-
}
|
|
265
|
-
handleGradientPointerdown(event) {
|
|
266
|
-
if (event.button !== 0) {
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
event.stopPropagation();
|
|
270
|
-
event.preventDefault();
|
|
271
|
-
this.handle.dispatchEvent(new PointerEvent("pointerdown", event));
|
|
272
|
-
this.handlePointermove(event);
|
|
273
|
-
}
|
|
274
|
-
get handlePositionStyles() {
|
|
275
|
-
return `${this.vertical ? "top" : "left"}: ${this.sliderHandlePosition}%`;
|
|
276
|
-
}
|
|
277
|
-
render() {
|
|
278
|
-
return html`
|
|
1
|
+
var p=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var o=(h,t,e,i)=>{for(var s=i>1?void 0:i?v(t,e):t,r=h.length-1,n;r>=0;r--)(n=h[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&p(t,e,s),s};import{html as f}from"@spectrum-web-components/base";import{ifDefined as m}from"@spectrum-web-components/base/src/directives.js";import{property as a,query as c}from"@spectrum-web-components/base/src/decorators.js";import{streamingListener as g}from"@spectrum-web-components/base/src/streaming-listener.js";import{Focusable as b}from"@spectrum-web-components/shared/src/focusable.js";import"@spectrum-web-components/color-handle/sp-color-handle.js";import _ from"./color-slider.css.js";import{extractHueAndSaturationRegExp as P,replaceHueAndSaturationRegExp as d}from"@spectrum-web-components/color-handle";import{TinyColor as l}from"@ctrl/tinycolor";export class ColorSlider extends b{constructor(){super(...arguments);this.disabled=!1;this.focused=!1;this.label="hue";this.vertical=!1;this._value=0;this.sliderHandlePosition=0;this._color=new l({h:0,s:1,v:1});this._previousColor=new l({h:0,s:1,v:1});this._format={format:"",isString:!1};this.step=1;this._altered=0;this._pointerDown=!1}static get styles(){return[_]}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 l({h:e,s,v:r}),this._value=e,e!==this.sliderHandlePosition&&(this.sliderHandlePosition=100*(e/360)),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(d,`$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(d,`$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 l(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=P.exec(t);if(r!==null){const[,n,u]=r;this.value=Number(n),this._saturation=Number(u)}}else if(!s&&i.startsWith("hs")){const r=this._color.originalInput,n=Object.values(r);this.value=n[0],this._saturation=n[1]}else{const{h:r}=this._color.toHsv();this.value=r}this._previousColor=e,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(s=>!!s).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.sliderHandlePosition=Math.min(100,Math.max(0,this.sliderHandlePosition+i)),this.value=360*(this.sliderHandlePosition/100),this._color=new l({...this._color.toHsl(),h:this.value}),i!=0&&(this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}handleInput(t){const{valueAsNumber:e}=t.target;this.value=e,this.sliderHandlePosition=100*(this.value/360),this._color=new l({...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.sliderHandlePosition=this.calculateHandlePosition(t),this.value=360*(this.sliderHandlePosition/100),this._color=new l({...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.sliderHandlePosition;const e=this.boundingClientRect,i=this.vertical?e.top:e.left,s=this.vertical?t.clientY:t.clientX,r=this.vertical?e.height:e.width,n=Math.max(0,Math.min(1,(s-i)/r));return 100*n}handleGradientPointerdown(t){t.button===0&&(t.stopPropagation(),t.preventDefault(),this.handle.dispatchEvent(new PointerEvent("pointerdown",t)),this.handlePointermove(t))}get handlePositionStyles(){return`${this.vertical?"top":"left"}: ${this.sliderHandlePosition}%`}render(){return f`
|
|
279
2
|
<div
|
|
280
3
|
class="checkerboard"
|
|
281
4
|
role="presentation"
|
|
@@ -284,24 +7,20 @@ export class ColorSlider extends Focusable {
|
|
|
284
7
|
<div
|
|
285
8
|
class="gradient"
|
|
286
9
|
role="presentation"
|
|
287
|
-
style="background: linear-gradient(to ${this.vertical
|
|
10
|
+
style="background: linear-gradient(to ${this.vertical?"bottom":"right"}, var(--sp-color-slider-gradient, var(--sp-color-slider-gradient-fallback)));"
|
|
288
11
|
>
|
|
289
12
|
<slot name="gradient"></slot>
|
|
290
13
|
</div>
|
|
291
14
|
</div>
|
|
292
15
|
<sp-color-handle
|
|
293
|
-
tabindex=${
|
|
16
|
+
tabindex=${m(this.focused?void 0:"0")}
|
|
294
17
|
@focus=${this.forwardFocus}
|
|
295
18
|
?focused=${this.focused}
|
|
296
19
|
class="handle"
|
|
297
20
|
color="hsl(${this.value}, 100%, 50%)"
|
|
298
21
|
?disabled=${this.disabled}
|
|
299
22
|
style=${this.handlePositionStyles}
|
|
300
|
-
${
|
|
301
|
-
start: ["pointerdown", this.handlePointerdown],
|
|
302
|
-
streamInside: ["pointermove", this.handlePointermove],
|
|
303
|
-
end: [["pointerup", "pointercancel"], this.handlePointerup]
|
|
304
|
-
})}
|
|
23
|
+
${g({start:["pointerdown",this.handlePointerdown],streamInside:["pointermove",this.handlePointermove],end:[["pointerup","pointercancel"],this.handlePointerup]})}
|
|
305
24
|
></sp-color-handle>
|
|
306
25
|
<input
|
|
307
26
|
type="range"
|
|
@@ -315,43 +34,5 @@ export class ColorSlider extends Focusable {
|
|
|
315
34
|
@change=${this.handleChange}
|
|
316
35
|
@keydown=${this.handleKeydown}
|
|
317
36
|
/>
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
firstUpdated(changed) {
|
|
321
|
-
super.firstUpdated(changed);
|
|
322
|
-
this.boundingClientRect = this.getBoundingClientRect();
|
|
323
|
-
this.addEventListener("focusin", this.handleFocusin);
|
|
324
|
-
this.addEventListener("focusout", this.handleFocusout);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
__decorateClass([
|
|
328
|
-
property({ type: Boolean, reflect: true })
|
|
329
|
-
], ColorSlider.prototype, "disabled", 2);
|
|
330
|
-
__decorateClass([
|
|
331
|
-
property({ type: Boolean, reflect: true })
|
|
332
|
-
], ColorSlider.prototype, "focused", 2);
|
|
333
|
-
__decorateClass([
|
|
334
|
-
query(".handle")
|
|
335
|
-
], ColorSlider.prototype, "handle", 2);
|
|
336
|
-
__decorateClass([
|
|
337
|
-
property({ type: String })
|
|
338
|
-
], ColorSlider.prototype, "label", 2);
|
|
339
|
-
__decorateClass([
|
|
340
|
-
property({ type: Boolean, reflect: true })
|
|
341
|
-
], ColorSlider.prototype, "vertical", 2);
|
|
342
|
-
__decorateClass([
|
|
343
|
-
property({ type: Number })
|
|
344
|
-
], ColorSlider.prototype, "value", 1);
|
|
345
|
-
__decorateClass([
|
|
346
|
-
property({ type: Number, reflect: true })
|
|
347
|
-
], ColorSlider.prototype, "sliderHandlePosition", 2);
|
|
348
|
-
__decorateClass([
|
|
349
|
-
property({ type: String })
|
|
350
|
-
], ColorSlider.prototype, "color", 1);
|
|
351
|
-
__decorateClass([
|
|
352
|
-
property({ type: Number })
|
|
353
|
-
], ColorSlider.prototype, "step", 2);
|
|
354
|
-
__decorateClass([
|
|
355
|
-
query("input")
|
|
356
|
-
], ColorSlider.prototype, "input", 2);
|
|
37
|
+
`}firstUpdated(t){super.firstUpdated(t),this.boundingClientRect=this.getBoundingClientRect(),this.addEventListener("focusin",this.handleFocusin),this.addEventListener("focusout",this.handleFocusout)}}o([a({type:Boolean,reflect:!0})],ColorSlider.prototype,"disabled",2),o([a({type:Boolean,reflect:!0})],ColorSlider.prototype,"focused",2),o([c(".handle")],ColorSlider.prototype,"handle",2),o([a({type:String})],ColorSlider.prototype,"label",2),o([a({type:Boolean,reflect:!0})],ColorSlider.prototype,"vertical",2),o([a({type:Number})],ColorSlider.prototype,"value",1),o([a({type:Number,reflect:!0})],ColorSlider.prototype,"sliderHandlePosition",2),o([a({type:String})],ColorSlider.prototype,"color",1),o([a({type:Number})],ColorSlider.prototype,"step",2),o([c("input")],ColorSlider.prototype,"input",2);
|
|
357
38
|
//# sourceMappingURL=ColorSlider.js.map
|
package/src/ColorSlider.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["ColorSlider.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 { Focusable } from '@spectrum-web-components/shared/src/focusable.js';\nimport '@spectrum-web-components/color-handle/sp-color-handle.js';\nimport styles from './color-slider.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-slider\n * @slot gradient - a custom gradient visually outlining the available color values\n * @fires input - The value of the Color Slider has changed.\n * @fires change - An alteration to the value of the Color Slider has been committed by the user.\n */\nexport class ColorSlider 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: Boolean, reflect: true })\n public vertical = false;\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\n if (value !== this.sliderHandlePosition) {\n this.sliderHandlePosition = 100 * (value / 360);\n }\n\n this.requestUpdate('value', oldValue);\n }\n\n private _value = 0;\n\n @property({ type: Number, reflect: true })\n public sliderHandlePosition = 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 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._previousColor = oldValue;\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\n @property({ type: Number })\n public step = 1;\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\n this.sliderHandlePosition = Math.min(\n 100,\n Math.max(0, this.sliderHandlePosition + delta)\n );\n this.value = 360 * (this.sliderHandlePosition / 100);\n this._color = new TinyColor({ ...this._color.toHsl(), h: this.value });\n\n if (delta != 0) {\n this.dispatchEvent(\n new Event('input', {\n bubbles: true,\n composed: true,\n })\n );\n this.dispatchEvent(\n new Event('change', {\n bubbles: true,\n composed: true,\n })\n );\n }\n }\n\n private handleInput(event: Event & { target: HTMLInputElement }): void {\n const { valueAsNumber } = event.target;\n\n this.value = valueAsNumber;\n this.sliderHandlePosition = 100 * (this.value / 360);\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.sliderHandlePosition = this.calculateHandlePosition(event);\n this.value = 360 * (this.sliderHandlePosition / 100);\n\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.sliderHandlePosition;\n }\n const rect = this.boundingClientRect;\n const minOffset = this.vertical ? rect.top : rect.left;\n const offset = this.vertical ? event.clientY : event.clientX;\n const size = this.vertical ? rect.height : rect.width;\n\n const percent = Math.max(0, Math.min(1, (offset - minOffset) / size));\n const sliderHandlePosition = 100 * percent;\n\n return sliderHandlePosition;\n }\n\n private handleGradientPointerdown(event: PointerEvent): void {\n if (event.button !== 0) {\n return;\n }\n event.stopPropagation();\n event.preventDefault();\n this.handle.dispatchEvent(new PointerEvent('pointerdown', event));\n this.handlePointermove(event);\n }\n\n private get handlePositionStyles(): string {\n return `${this.vertical ? 'top' : 'left'}: ${\n this.sliderHandlePosition\n }%`;\n }\n\n protected override render(): TemplateResult {\n return html`\n <div\n class=\"checkerboard\"\n role=\"presentation\"\n @pointerdown=${this.handleGradientPointerdown}\n >\n <div\n class=\"gradient\"\n role=\"presentation\"\n style=\"background: linear-gradient(to ${this.vertical\n ? 'bottom'\n : 'right'}, var(--sp-color-slider-gradient, var(--sp-color-slider-gradient-fallback)));\"\n >\n <slot name=\"gradient\"></slot>\n </div>\n </div>\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=${this.handlePositionStyles}\n ${streamingListener({\n start: ['pointerdown', this.handlePointerdown],\n streamInside: ['pointermove', this.handlePointermove],\n end: [['pointerup', 'pointercancel'], this.handlePointerup],\n })}\n ></sp-color-handle>\n <input\n type=\"range\"\n class=\"slider\"\n min=\"0\"\n max=\"360\"\n step=${this.step}\n aria-label=${this.label}\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"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": "wMAYA,qDAMA,4EACA,sFAIA,4FACA,6EACA,iEACA,qCACA,yHAMA,4CAQO,aAAM,mBAAoB,EAAU,CAApC,kCAMa,cAAW,GAGpB,aAAU,GAMV,WAAQ,MAGR,cAAW,GAwBV,YAAS,EAGV,0BAAuB,EA2FtB,YAAS,GAAI,GAAU,CAAE,EAAG,EAAG,EAAG,EAAG,EAAG,CAAE,CAAC,EAE3C,oBAAiB,GAAI,GAAU,CAAE,EAAG,EAAG,EAAG,EAAG,EAAG,CAAE,CAAC,EAInD,aAAiD,CACrD,OAAQ,GACR,SAAU,EACd,EAGO,UAAO,EAWN,cAAW,EAkGX,kBAAe,aAhQI,SAAyB,CAChD,MAAO,CAAC,CAAM,CAClB,IAkBW,QAAgB,CACvB,MAAO,MAAK,MAChB,IAEW,OAAM,EAAa,CAC1B,KAAM,GAAQ,KAAK,IAAI,IAAK,KAAK,IAAI,EAAG,CAAG,CAAC,EAC5C,GAAI,IAAU,KAAK,MACf,OAEJ,KAAM,GAAW,KAAK,MAChB,CAAE,EAAG,KAAM,KAAK,OAAO,MAAM,EACnC,KAAK,OAAS,GAAI,GAAU,CAAE,EAAG,EAAO,EAAG,GAAE,CAAC,EAC9C,KAAK,OAAS,EAEV,IAAU,KAAK,sBACf,MAAK,qBAAuB,IAAO,GAAQ,MAG/C,KAAK,cAAc,QAAS,CAAQ,CACxC,IAQW,QAA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1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
const styles = css`
|
|
1
|
+
import{css as r}from"@spectrum-web-components/base";const e=r`
|
|
3
2
|
:host{--spectrum-colorslider-handle-hitarea-border-radius:0%;--spectrum-colorslider-handle-hitarea-width:var(
|
|
4
3
|
--spectrum-global-dimension-size-300
|
|
5
4
|
);--spectrum-colorslider-handle-hitarea-height:var(
|
|
@@ -53,6 +52,5 @@ var(--spectrum-global-dimension-size-200)
|
|
|
53
52
|
) var(
|
|
54
53
|
--spectrum-colorslider-border-color-disabled,var(--spectrum-alias-track-color-disabled)
|
|
55
54
|
)}:host([disabled]) .gradient{display:none}@media (forced-colors:active){:host{--spectrum-colorslider-border-color-disabled:GrayText;--spectrum-colorslider-fill-color-disabled:Canvas}:host{forced-color-adjust:none}}:host{--sp-color-slider-gradient-fallback:red 0%,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%;touch-action:none}:host(:focus){outline:none}.gradient{overflow:hidden}::slotted(*){height:100%;width:100%}
|
|
56
|
-
`;
|
|
57
|
-
export default styles;
|
|
55
|
+
`;export default e;
|
|
58
56
|
//# sourceMappingURL=color-slider.css.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["color-slider.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-colorslider-handle-hitarea-border-radius:0%;--spectrum-colorslider-handle-hitarea-width:var(\n--spectrum-global-dimension-size-300\n);--spectrum-colorslider-handle-hitarea-height:var(\n--spectrum-global-dimension-size-300\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{cursor:default;display:block;height:var(\n--spectrum-colorslider-height,var(--spectrum-global-dimension-size-300)\n);position:relative;-webkit-user-select:none;user-select:none;width:var(\n--spectrum-colorslider-default-length,var(--spectrum-global-dimension-size-2400)\n)}:host([focused]){z-index:2}:host([disabled]){pointer-events:none}:host([vertical]){display:inline-block;height:var(\n--spectrum-colorslider-vertical-default-length,var(--spectrum-global-dimension-size-2400)\n);width:var(\n--spectrum-colorslider-vertical-width,var(--spectrum-global-dimension-size-300)\n)}:host([vertical]) .handle{left:50%;top:0}.handle{left:0;top:50%}.handle:after{border-radius:var(\n--spectrum-colorslider-handle-hitarea-border-radius\n);height:var(--spectrum-colorslider-handle-hitarea-height);width:var(--spectrum-colorslider-handle-hitarea-width)}.checkerboard{background-position:0 0,0 var(--spectrum-global-dimension-static-size-100,8px),var(--spectrum-global-dimension-static-size-100,8px) calc(var(--spectrum-global-dimension-static-size-100, 8px)*-1),calc(var(--spectrum-global-dimension-static-size-100, 8px)*-1) 0;background-size:var(--spectrum-global-dimension-static-size-200,16px) var(--spectrum-global-dimension-static-size-200,16px)}.checkerboard:before{border-radius:var(\n--spectrum-colorslider-border-radius,var(--spectrum-alias-border-radius-regular)\n);bottom:0;content:\"\";left:0;position:absolute;right:0;top:0;z-index:1}.checkerboard,.gradient{border-radius:var(\n--spectrum-colorslider-border-radius,var(--spectrum-alias-border-radius-regular)\n);height:100%;width:100%}:host{--spectrum-colorslider-border-color:var(\n--spectrum-colorarea-border-color,var(--spectrum-alias-border-color-translucent)\n)}.checkerboard{background-color:var(\n--spectrum-colorcontrol-checkerboard-light-color,var(--spectrum-global-color-static-white)\n);background-image:linear-gradient(-45deg,transparent 75.5%,var(\n--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)\n) 75.5%),linear-gradient(45deg,transparent 75.5%,var(\n--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)\n) 75.5%),linear-gradient(-45deg,var(\n--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)\n) 25.5%,transparent 25.5%),linear-gradient(45deg,var(\n--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)\n) 25.5%,transparent 25.5%)}.checkerboard:before{box-shadow:inset 0 0 0 var(\n--spectrum-colorslider-border-size,var(--spectrum-alias-border-size-thin)\n) var(\n--spectrum-colorslider-border-color,var(--spectrum-alias-border-color-translucent)\n)}:host([disabled]) .checkerboard{background:var(\n--spectrum-colorslider-fill-color-disabled,var(--spectrum-alias-track-color-disabled)\n)}:host([disabled]) .checkerboard:before{box-shadow:0 0 0 var(\n--spectrum-colorslider-border-size,var(--spectrum-alias-border-size-thin)\n) var(\n--spectrum-colorslider-border-color-disabled,var(--spectrum-alias-track-color-disabled)\n)}:host([disabled]) .gradient{display:none}@media (forced-colors:active){:host{--spectrum-colorslider-border-color-disabled:GrayText;--spectrum-colorslider-fill-color-disabled:Canvas}:host{forced-color-adjust:none}}:host{--sp-color-slider-gradient-fallback:red 0%,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red 100%;touch-action:none}:host(:focus){outline:none}.gradient{overflow:hidden}::slotted(*){height:100%;width:100%}\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuDf,cAAe",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export*from"./ColorSlider.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 './ColorSlider.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 r}from"@spectrum-web-components/base";const e=r`
|
|
3
2
|
:host{--spectrum-colorslider-handle-hitarea-border-radius:0%;--spectrum-colorslider-handle-hitarea-width:var(
|
|
4
3
|
--spectrum-global-dimension-size-300
|
|
5
4
|
);--spectrum-colorslider-handle-hitarea-height:var(
|
|
@@ -53,6 +52,5 @@ var(--spectrum-global-dimension-size-200)
|
|
|
53
52
|
) var(
|
|
54
53
|
--spectrum-colorslider-border-color-disabled,var(--spectrum-alias-track-color-disabled)
|
|
55
54
|
)}:host([disabled]) .gradient{display:none}@media (forced-colors:active){:host{--spectrum-colorslider-border-color-disabled:GrayText;--spectrum-colorslider-fill-color-disabled:Canvas}:host{forced-color-adjust:none}}
|
|
56
|
-
`;
|
|
57
|
-
export default styles;
|
|
55
|
+
`;export default e;
|
|
58
56
|
//# sourceMappingURL=spectrum-color-slider.css.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["spectrum-color-slider.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-colorslider-handle-hitarea-border-radius:0%;--spectrum-colorslider-handle-hitarea-width:var(\n--spectrum-global-dimension-size-300\n);--spectrum-colorslider-handle-hitarea-height:var(\n--spectrum-global-dimension-size-300\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{cursor:default;display:block;height:var(\n--spectrum-colorslider-height,var(--spectrum-global-dimension-size-300)\n);position:relative;-webkit-user-select:none;user-select:none;width:var(\n--spectrum-colorslider-default-length,var(--spectrum-global-dimension-size-2400)\n)}:host([focused]){z-index:2}:host([disabled]){pointer-events:none}:host([vertical]){display:inline-block;height:var(\n--spectrum-colorslider-vertical-default-length,var(--spectrum-global-dimension-size-2400)\n);width:var(\n--spectrum-colorslider-vertical-width,var(--spectrum-global-dimension-size-300)\n)}:host([vertical]) .handle{left:50%;top:0}.handle{left:0;top:50%}.handle:after{border-radius:var(\n--spectrum-colorslider-handle-hitarea-border-radius\n);height:var(--spectrum-colorslider-handle-hitarea-height);width:var(--spectrum-colorslider-handle-hitarea-width)}.checkerboard{background-position:0 0,0 var(--spectrum-global-dimension-static-size-100,8px),var(--spectrum-global-dimension-static-size-100,8px) calc(var(--spectrum-global-dimension-static-size-100, 8px)*-1),calc(var(--spectrum-global-dimension-static-size-100, 8px)*-1) 0;background-size:var(--spectrum-global-dimension-static-size-200,16px) var(--spectrum-global-dimension-static-size-200,16px)}.checkerboard:before{border-radius:var(\n--spectrum-colorslider-border-radius,var(--spectrum-alias-border-radius-regular)\n);bottom:0;content:\"\";left:0;position:absolute;right:0;top:0;z-index:1}.checkerboard,.gradient{border-radius:var(\n--spectrum-colorslider-border-radius,var(--spectrum-alias-border-radius-regular)\n);height:100%;width:100%}:host{--spectrum-colorslider-border-color:var(\n--spectrum-colorarea-border-color,var(--spectrum-alias-border-color-translucent)\n)}.checkerboard{background-color:var(\n--spectrum-colorcontrol-checkerboard-light-color,var(--spectrum-global-color-static-white)\n);background-image:linear-gradient(-45deg,transparent 75.5%,var(\n--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)\n) 75.5%),linear-gradient(45deg,transparent 75.5%,var(\n--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)\n) 75.5%),linear-gradient(-45deg,var(\n--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)\n) 25.5%,transparent 25.5%),linear-gradient(45deg,var(\n--spectrum-colorcontrol-checkerboard-dark-color,var(--spectrum-global-color-static-gray-300)\n) 25.5%,transparent 25.5%)}.checkerboard:before{box-shadow:inset 0 0 0 var(\n--spectrum-colorslider-border-size,var(--spectrum-alias-border-size-thin)\n) var(\n--spectrum-colorslider-border-color,var(--spectrum-alias-border-color-translucent)\n)}:host([disabled]) .checkerboard{background:var(\n--spectrum-colorslider-fill-color-disabled,var(--spectrum-alias-track-color-disabled)\n)}:host([disabled]) .checkerboard:before{box-shadow:0 0 0 var(\n--spectrum-colorslider-border-size,var(--spectrum-alias-border-size-thin)\n) var(\n--spectrum-colorslider-border-color-disabled,var(--spectrum-alias-track-color-disabled)\n)}:host([disabled]) .gradient{display:none}@media (forced-colors:active){:host{--spectrum-colorslider-border-color-disabled:GrayText;--spectrum-colorslider-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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAuDf,cAAe",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|