@spectrum-web-components/color-area 0.4.12-devmode.0 → 0.5.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/color-area",
3
- "version": "0.4.12-devmode.0+1a8b29491",
3
+ "version": "0.5.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -62,8 +62,8 @@
62
62
  ],
63
63
  "dependencies": {
64
64
  "@ctrl/tinycolor": "^3.3.3",
65
- "@spectrum-web-components/base": "^0.6.1-devmode.0+1a8b29491",
66
- "@spectrum-web-components/color-handle": "^0.3.12-devmode.0+1a8b29491",
65
+ "@spectrum-web-components/base": "^0.7.0",
66
+ "@spectrum-web-components/color-handle": "^0.4.0",
67
67
  "tslib": "^2.0.0"
68
68
  },
69
69
  "devDependencies": {
@@ -75,5 +75,5 @@
75
75
  "./sp-*.js",
76
76
  "./**/*.dev.js"
77
77
  ],
78
- "gitHead": "1a8b294911ab377fa4f07e16eb016f1e3bf7b517"
78
+ "gitHead": "05c81318844160db3f8156144106e643507fef97"
79
79
  }
package/sp-color-area.js CHANGED
@@ -1,3 +1,2 @@
1
- import { ColorArea } from "./src/ColorArea.js";
2
- customElements.define("sp-color-area", ColorArea);
1
+ import{ColorArea as e}from"./src/ColorArea.js";customElements.define("sp-color-area",e);
3
2
  //# sourceMappingURL=sp-color-area.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["sp-color-area.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 { ColorArea } from './src/ColorArea.js';\n\ncustomElements.define('sp-color-area', ColorArea);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'sp-color-area': ColorArea;\n }\n}\n"],
5
- "mappings": "AAYA;AAEA,eAAe,OAAO,iBAAiB,SAAS;",
5
+ "mappings": "AAYA,+CAEA,eAAe,OAAO,gBAAiB,CAAS",
6
6
  "names": []
7
7
  }
package/src/ColorArea.js CHANGED
@@ -1,339 +1,4 @@
1
- var __defProp = Object.defineProperty;
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
- SpectrumElement
15
- } from "@spectrum-web-components/base";
16
- import { ifDefined } from "@spectrum-web-components/base/src/directives.js";
17
- import {
18
- property,
19
- query
20
- } from "@spectrum-web-components/base/src/decorators.js";
21
- import { streamingListener } from "@spectrum-web-components/base/src/streaming-listener.js";
22
- import {
23
- extractHueAndSaturationRegExp,
24
- replaceHueRegExp
25
- } from "@spectrum-web-components/color-handle";
26
- import "@spectrum-web-components/color-handle/sp-color-handle.js";
27
- import { TinyColor } from "@ctrl/tinycolor";
28
- import styles from "./color-area.css.js";
29
- export class ColorArea extends SpectrumElement {
30
- constructor() {
31
- super(...arguments);
32
- this.disabled = false;
33
- this.focused = false;
34
- this.labelX = "saturation";
35
- this.labelY = "luminosity";
36
- this._hue = 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.activeAxis = "x";
44
- this._x = 1;
45
- this._y = 0;
46
- this.step = 0.01;
47
- this.altered = 0;
48
- this.activeKeys = /* @__PURE__ */ new Set();
49
- this._pointerDown = false;
50
- }
51
- static get styles() {
52
- return [styles];
53
- }
54
- get hue() {
55
- return this._hue;
56
- }
57
- set hue(value) {
58
- const hue = Math.min(360, Math.max(0, value));
59
- if (hue === this.hue) {
60
- return;
61
- }
62
- const oldValue = this.hue;
63
- const { s, v } = this._color.toHsv();
64
- this._color = new TinyColor({ h: hue, s, v });
65
- this._hue = hue;
66
- this.requestUpdate("hue", oldValue);
67
- }
68
- get value() {
69
- return this.color;
70
- }
71
- get color() {
72
- switch (this._format.format) {
73
- case "rgb":
74
- return this._format.isString ? this._color.toRgbString() : this._color.toRgb();
75
- case "prgb":
76
- return this._format.isString ? this._color.toPercentageRgbString() : this._color.toPercentageRgb();
77
- case "hex8":
78
- return this._format.isString ? this._color.toHex8String() : this._color.toHex8();
79
- case "name":
80
- return this._color.toName() || this._color.toRgbString();
81
- case "hsl":
82
- if (this._format.isString) {
83
- const hslString = this._color.toHslString();
84
- return hslString.replace(replaceHueRegExp, `$1${this.hue}`);
85
- } else {
86
- const { s, l, a } = this._color.toHsl();
87
- return { h: this.hue, s, l, a };
88
- }
89
- case "hsv":
90
- if (this._format.isString) {
91
- const hsvString = this._color.toHsvString();
92
- return hsvString.replace(replaceHueRegExp, `$1${this.hue}`);
93
- } else {
94
- const { s, v, a } = this._color.toHsv();
95
- return { h: this.hue, s, v, a };
96
- }
97
- case "hex":
98
- case "hex3":
99
- case "hex4":
100
- case "hex6":
101
- default:
102
- return this._format.isString ? this._color.toHexString() : this._color.toHex();
103
- }
104
- }
105
- set color(color) {
106
- if (color === this.color) {
107
- return;
108
- }
109
- const oldValue = this._color;
110
- this._color = new TinyColor(color);
111
- const format = this._color.format;
112
- let isString = typeof color === "string" || color instanceof String;
113
- if (format.startsWith("hex")) {
114
- isString = color.startsWith("#");
115
- }
116
- this._format = {
117
- format,
118
- isString
119
- };
120
- const { h, s, v } = this._color.toHsv();
121
- let originalHue = void 0;
122
- if (isString && format.startsWith("hs")) {
123
- const values = extractHueAndSaturationRegExp.exec(color);
124
- if (values !== null) {
125
- const [, h2] = values;
126
- originalHue = Number(h2);
127
- }
128
- } else if (!isString && format.startsWith("hs")) {
129
- const colorInput = this._color.originalInput;
130
- const colorValues = Object.values(colorInput);
131
- originalHue = colorValues[0];
132
- }
133
- this.hue = originalHue || h;
134
- this.x = s;
135
- this.y = 1 - v;
136
- this.requestUpdate("color", oldValue);
137
- }
138
- get x() {
139
- return this._x;
140
- }
141
- set x(x) {
142
- if (x === this.x) {
143
- return;
144
- }
145
- const oldValue = this.x;
146
- if (this.inputX) {
147
- this.inputX.value = x.toString();
148
- this._x = this.inputX.valueAsNumber;
149
- } else {
150
- this._x = x;
151
- }
152
- this.requestUpdate("x", oldValue);
153
- }
154
- get y() {
155
- return this._y;
156
- }
157
- set y(y) {
158
- if (y === this.y) {
159
- return;
160
- }
161
- const oldValue = this.y;
162
- if (this.inputY) {
163
- this.inputY.value = y.toString();
164
- this._y = this.inputY.valueAsNumber;
165
- } else {
166
- this._y = y;
167
- }
168
- this.requestUpdate("y", oldValue);
169
- }
170
- focus(focusOptions = {}) {
171
- super.focus(focusOptions);
172
- this.forwardFocus();
173
- }
174
- forwardFocus() {
175
- this.focused = this.hasVisibleFocusInTree();
176
- if (this.activeAxis === "x") {
177
- this.inputX.focus();
178
- } else {
179
- this.inputY.focus();
180
- }
181
- }
182
- handleFocusin() {
183
- this.focused = true;
184
- }
185
- handleFocusout() {
186
- if (this._pointerDown) {
187
- return;
188
- }
189
- this.focused = false;
190
- }
191
- handleKeydown(event) {
192
- const { code } = event;
193
- this.focused = true;
194
- this.altered = [event.shiftKey, event.ctrlKey, event.altKey].filter((key) => !!key).length;
195
- const isArrowKey = code.search("Arrow") === 0;
196
- if (isArrowKey) {
197
- event.preventDefault();
198
- this.activeKeys.add(code);
199
- this.handleKeypress();
200
- }
201
- }
202
- handleKeypress() {
203
- let deltaX = 0;
204
- let deltaY = 0;
205
- const step = Math.max(this.step, this.altered * 5 * this.step);
206
- this.activeKeys.forEach((code) => {
207
- switch (code) {
208
- case "ArrowUp":
209
- deltaY = step * -1;
210
- break;
211
- case "ArrowDown":
212
- deltaY = step * 1;
213
- break;
214
- case "ArrowLeft":
215
- deltaX = step * -1;
216
- break;
217
- case "ArrowRight":
218
- deltaX = step * 1;
219
- break;
220
- default:
221
- break;
222
- }
223
- });
224
- if (deltaX != 0) {
225
- this.activeAxis = "x";
226
- this.inputX.focus();
227
- } else if (deltaY != 0) {
228
- this.activeAxis = "y";
229
- this.inputY.focus();
230
- }
231
- this.x = Math.min(1, Math.max(this.x + deltaX, 0));
232
- this.y = Math.min(1, Math.max(this.y + deltaY, 0));
233
- this._previousColor = this._color.clone();
234
- this._color = new TinyColor({ h: this.hue, s: this.x, v: 1 - this.y });
235
- if (deltaX != 0 || deltaY != 0) {
236
- this.dispatchEvent(new Event("input", {
237
- bubbles: true,
238
- composed: true
239
- }));
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
- }
249
- }
250
- handleKeyup(event) {
251
- event.preventDefault();
252
- const { code } = event;
253
- this.activeKeys.delete(code);
254
- }
255
- handleInput(event) {
256
- const { valueAsNumber, name } = event.target;
257
- this[name] = valueAsNumber;
258
- this._color = new TinyColor({ h: this.hue, s: this.x, v: 1 - this.y });
259
- }
260
- handleChange(event) {
261
- this.handleInput(event);
262
- this.dispatchEvent(new Event("change", {
263
- bubbles: true,
264
- composed: true,
265
- cancelable: true
266
- }));
267
- }
268
- handlePointerdown(event) {
269
- if (event.button !== 0) {
270
- event.preventDefault();
271
- return;
272
- }
273
- this._pointerDown = true;
274
- this._previousColor = this._color.clone();
275
- this.boundingClientRect = this.getBoundingClientRect();
276
- event.target.setPointerCapture(event.pointerId);
277
- if (event.pointerType === "mouse") {
278
- this.focused = true;
279
- }
280
- }
281
- handlePointermove(event) {
282
- const [x, y] = this.calculateHandlePosition(event);
283
- this._color = new TinyColor({ h: this.hue, s: x, v: 1 - y });
284
- this.x = x;
285
- this.y = y;
286
- this.dispatchEvent(new Event("input", {
287
- bubbles: true,
288
- composed: true,
289
- cancelable: true
290
- }));
291
- }
292
- handlePointerup(event) {
293
- event.preventDefault();
294
- this._pointerDown = false;
295
- event.target.releasePointerCapture(event.pointerId);
296
- const applyDefault = this.dispatchEvent(new Event("change", {
297
- bubbles: true,
298
- composed: true,
299
- cancelable: true
300
- }));
301
- this.inputX.focus();
302
- if (event.pointerType === "mouse") {
303
- this.focused = false;
304
- }
305
- if (!applyDefault) {
306
- this._color = this._previousColor;
307
- }
308
- }
309
- calculateHandlePosition(event) {
310
- if (!this.boundingClientRect) {
311
- return [this.x, this.y];
312
- }
313
- const rect = this.boundingClientRect;
314
- const minOffsetX = rect.left;
315
- const minOffsetY = rect.top;
316
- const offsetX = event.clientX;
317
- const offsetY = event.clientY;
318
- const width = rect.width;
319
- const height = rect.height;
320
- const percentX = Math.max(0, Math.min(1, (offsetX - minOffsetX) / width));
321
- const percentY = Math.max(0, Math.min(1, (offsetY - minOffsetY) / height));
322
- return [percentX, percentY];
323
- }
324
- handleAreaPointerdown(event) {
325
- if (event.button !== 0) {
326
- return;
327
- }
328
- event.stopPropagation();
329
- event.preventDefault();
330
- this.handle.dispatchEvent(new PointerEvent("pointerdown", event));
331
- this.handlePointermove(event);
332
- }
333
- render() {
334
- var _a, _b;
335
- const { width = 0, height = 0 } = this.boundingClientRect || {};
336
- return html`
1
+ var f=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var r=(p,t,e,i)=>{for(var s=i>1?void 0:i?m(t,e):t,o=p.length-1,a;o>=0;o--)(a=p[o])&&(s=(i?a(t,e,s):a(s))||s);return i&&s&&f(t,e,s),s};import{html as g,SpectrumElement as y}from"@spectrum-web-components/base";import{ifDefined as w}from"@spectrum-web-components/base/src/directives.js";import{property as n,query as v}from"@spectrum-web-components/base/src/decorators.js";import{streamingListener as _}from"@spectrum-web-components/base/src/streaming-listener.js";import{extractHueAndSaturationRegExp as x,replaceHueRegExp as b}from"@spectrum-web-components/color-handle";import"@spectrum-web-components/color-handle/sp-color-handle.js";import{TinyColor as h}from"@ctrl/tinycolor";import S from"./color-area.css.js";export class ColorArea extends y{constructor(){super(...arguments);this.disabled=!1;this.focused=!1;this.labelX="saturation";this.labelY="luminosity";this._hue=0;this._color=new h({h:0,s:1,v:1});this._previousColor=new h({h:0,s:1,v:1});this._format={format:"",isString:!1};this.activeAxis="x";this._x=1;this._y=0;this.step=.01;this.altered=0;this.activeKeys=new Set;this._pointerDown=!1}static get styles(){return[S]}get hue(){return this._hue}set hue(t){const e=Math.min(360,Math.max(0,t));if(e===this.hue)return;const i=this.hue,{s,v:o}=this._color.toHsv();this._color=new h({h:e,s,v:o}),this._hue=e,this.requestUpdate("hue",i)}get value(){return this.color}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"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(b,`$1${this.hue}`);{const{s:t,l:e,a:i}=this._color.toHsl();return{h:this.hue,s:t,l:e,a:i}}case"hsv":if(this._format.isString)return this._color.toHsvString().replace(b,`$1${this.hue}`);{const{s:t,v:e,a:i}=this._color.toHsv();return{h:this.hue,s:t,v:e,a:i}}case"hex":case"hex3":case"hex4":case"hex6":default:return this._format.isString?this._color.toHexString():this._color.toHex()}}set color(t){if(t===this.color)return;const e=this._color;this._color=new h(t);const i=this._color.format;let s=typeof t=="string"||t instanceof String;i.startsWith("hex")&&(s=t.startsWith("#")),this._format={format:i,isString:s};const{h:o,s:a,v:d}=this._color.toHsv();let u;if(s&&i.startsWith("hs")){const l=x.exec(t);if(l!==null){const[,c]=l;u=Number(c)}}else if(!s&&i.startsWith("hs")){const l=this._color.originalInput;u=Object.values(l)[0]}this.hue=u||o,this.x=a,this.y=1-d,this.requestUpdate("color",e)}get x(){return this._x}set x(t){if(t===this.x)return;const e=this.x;this.inputX?(this.inputX.value=t.toString(),this._x=this.inputX.valueAsNumber):this._x=t,this.requestUpdate("x",e)}get y(){return this._y}set y(t){if(t===this.y)return;const e=this.y;this.inputY?(this.inputY.value=t.toString(),this._y=this.inputY.valueAsNumber):this._y=t,this.requestUpdate("y",e)}focus(t={}){super.focus(t),this.forwardFocus()}forwardFocus(){this.focused=this.hasVisibleFocusInTree(),this.activeAxis==="x"?this.inputX.focus():this.inputY.focus()}handleFocusin(){this.focused=!0}handleFocusout(){this._pointerDown||(this.focused=!1)}handleKeydown(t){const{code:e}=t;this.focused=!0,this.altered=[t.shiftKey,t.ctrlKey,t.altKey].filter(s=>!!s).length,e.search("Arrow")===0&&(t.preventDefault(),this.activeKeys.add(e),this.handleKeypress())}handleKeypress(){let t=0,e=0;const i=Math.max(this.step,this.altered*5*this.step);this.activeKeys.forEach(s=>{switch(s){case"ArrowUp":e=i*-1;break;case"ArrowDown":e=i*1;break;case"ArrowLeft":t=i*-1;break;case"ArrowRight":t=i*1;break;default:break}}),t!=0?(this.activeAxis="x",this.inputX.focus()):e!=0&&(this.activeAxis="y",this.inputY.focus()),this.x=Math.min(1,Math.max(this.x+t,0)),this.y=Math.min(1,Math.max(this.y+e,0)),this._previousColor=this._color.clone(),this._color=new h({h:this.hue,s:this.x,v:1-this.y}),(t!=0||e!=0)&&(this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0,cancelable:!0}))||(this._color=this._previousColor))}handleKeyup(t){t.preventDefault();const{code:e}=t;this.activeKeys.delete(e)}handleInput(t){const{valueAsNumber:e,name:i}=t.target;this[i]=e,this._color=new h({h:this.hue,s:this.x,v:1-this.y})}handleChange(t){this.handleInput(t),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0,cancelable:!0}))}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){const[e,i]=this.calculateHandlePosition(t);this._color=new h({h:this.hue,s:e,v:1-i}),this.x=e,this.y=i,this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0,cancelable:!0}))}handlePointerup(t){t.preventDefault(),this._pointerDown=!1,t.target.releasePointerCapture(t.pointerId);const e=this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0,cancelable:!0}));this.inputX.focus(),t.pointerType==="mouse"&&(this.focused=!1),e||(this._color=this._previousColor)}calculateHandlePosition(t){if(!this.boundingClientRect)return[this.x,this.y];const e=this.boundingClientRect,i=e.left,s=e.top,o=t.clientX,a=t.clientY,d=e.width,u=e.height,l=Math.max(0,Math.min(1,(o-i)/d)),c=Math.max(0,Math.min(1,(a-s)/u));return[l,c]}handleAreaPointerdown(t){t.button===0&&(t.stopPropagation(),t.preventDefault(),this.handle.dispatchEvent(new PointerEvent("pointerdown",t)),this.handlePointermove(t))}render(){var i,s;const{width:t=0,height:e=0}=this.boundingClientRect||{};return g`
337
2
  <div
338
3
  @pointerdown=${this.handleAreaPointerdown}
339
4
  class="gradient"
@@ -345,18 +10,14 @@ export class ColorArea extends SpectrumElement {
345
10
  </div>
346
11
 
347
12
  <sp-color-handle
348
- tabindex=${ifDefined(this.focused ? void 0 : "0")}
13
+ tabindex=${w(this.focused?void 0:"0")}
349
14
  @focus=${this.forwardFocus}
350
15
  ?focused=${this.focused}
351
16
  class="handle"
352
17
  color=${this._color.toHslString()}
353
18
  ?disabled=${this.disabled}
354
- style="transform: translate(${this.x * width}px, ${this.y * height}px);"
355
- ${streamingListener({
356
- start: ["pointerdown", this.handlePointerdown],
357
- streamInside: ["pointermove", this.handlePointermove],
358
- end: [["pointerup", "pointercancel"], this.handlePointerup]
359
- })}
19
+ style="transform: translate(${this.x*t}px, ${this.y*e}px);"
20
+ ${_({start:["pointerdown",this.handlePointerdown],streamInside:["pointermove",this.handlePointermove],end:[["pointerup","pointercancel"],this.handlePointerup]})}
360
21
  ></sp-color-handle>
361
22
 
362
23
  <div>
@@ -364,7 +25,7 @@ export class ColorArea extends SpectrumElement {
364
25
  type="range"
365
26
  class="slider"
366
27
  name="x"
367
- aria-label=${(_a = this.label) != null ? _a : this.labelX}
28
+ aria-label=${(i=this.label)!=null?i:this.labelX}
368
29
  min="0"
369
30
  max="1"
370
31
  step=${this.step}
@@ -379,7 +40,7 @@ export class ColorArea extends SpectrumElement {
379
40
  type="range"
380
41
  class="slider"
381
42
  name="y"
382
- aria-label=${(_b = this.label) != null ? _b : this.labelY}
43
+ aria-label=${(s=this.label)!=null?s:this.labelY}
383
44
  min="0"
384
45
  max="1"
385
46
  step=${this.step}
@@ -389,98 +50,5 @@ export class ColorArea extends SpectrumElement {
389
50
  @change=${this.handleChange}
390
51
  />
391
52
  </div>
392
- `;
393
- }
394
- firstUpdated(changed) {
395
- super.firstUpdated(changed);
396
- this.boundingClientRect = this.getBoundingClientRect();
397
- this.addEventListener("focusin", this.handleFocusin);
398
- this.addEventListener("focusout", this.handleFocusout);
399
- this.addEventListener("keyup", this.handleKeyup);
400
- this.addEventListener("keydown", this.handleKeydown);
401
- }
402
- updated(changed) {
403
- super.updated(changed);
404
- if (this.x !== this.inputX.valueAsNumber) {
405
- this._x = this.inputX.valueAsNumber;
406
- }
407
- if (this.y !== this.inputY.valueAsNumber) {
408
- this._y = this.inputY.valueAsNumber;
409
- }
410
- if (changed.has("focused") && this.focused) {
411
- const parentX = this.inputX.parentElement;
412
- const parentY = this.inputY.parentElement;
413
- if (!parentX.shadowRoot && !parentY.shadowRoot) {
414
- parentX.attachShadow({ mode: "open" });
415
- parentY.attachShadow({ mode: "open" });
416
- const slot = '<div tabindex="-1"><slot></slot></div>';
417
- parentX.shadowRoot.innerHTML = slot;
418
- parentY.shadowRoot.innerHTML = slot;
419
- }
420
- }
421
- }
422
- connectedCallback() {
423
- var _a;
424
- super.connectedCallback();
425
- if (!this.observer && window.ResizeObserver) {
426
- this.observer = new window.ResizeObserver((entries) => {
427
- for (const entry of entries) {
428
- this.boundingClientRect = entry.contentRect;
429
- }
430
- this.requestUpdate();
431
- });
432
- }
433
- (_a = this.observer) == null ? void 0 : _a.observe(this);
434
- }
435
- disconnectedCallback() {
436
- var _a;
437
- (_a = this.observer) == null ? void 0 : _a.unobserve(this);
438
- super.disconnectedCallback();
439
- }
440
- }
441
- __decorateClass([
442
- property({ type: Boolean, reflect: true })
443
- ], ColorArea.prototype, "disabled", 2);
444
- __decorateClass([
445
- property({ type: Boolean, reflect: true })
446
- ], ColorArea.prototype, "focused", 2);
447
- __decorateClass([
448
- property({ type: String })
449
- ], ColorArea.prototype, "label", 2);
450
- __decorateClass([
451
- property({ type: String, attribute: "label-x" })
452
- ], ColorArea.prototype, "labelX", 2);
453
- __decorateClass([
454
- property({ type: String, attribute: "label-y" })
455
- ], ColorArea.prototype, "labelY", 2);
456
- __decorateClass([
457
- query(".handle")
458
- ], ColorArea.prototype, "handle", 2);
459
- __decorateClass([
460
- property({ type: Number })
461
- ], ColorArea.prototype, "hue", 1);
462
- __decorateClass([
463
- property({ type: String })
464
- ], ColorArea.prototype, "value", 1);
465
- __decorateClass([
466
- property({ type: String })
467
- ], ColorArea.prototype, "color", 1);
468
- __decorateClass([
469
- property({ attribute: false })
470
- ], ColorArea.prototype, "activeAxis", 2);
471
- __decorateClass([
472
- property({ type: Number })
473
- ], ColorArea.prototype, "x", 1);
474
- __decorateClass([
475
- property({ type: Number })
476
- ], ColorArea.prototype, "y", 1);
477
- __decorateClass([
478
- property({ type: Number })
479
- ], ColorArea.prototype, "step", 2);
480
- __decorateClass([
481
- query('[name="x"]')
482
- ], ColorArea.prototype, "inputX", 2);
483
- __decorateClass([
484
- query('[name="y"]')
485
- ], ColorArea.prototype, "inputY", 2);
53
+ `}firstUpdated(t){super.firstUpdated(t),this.boundingClientRect=this.getBoundingClientRect(),this.addEventListener("focusin",this.handleFocusin),this.addEventListener("focusout",this.handleFocusout),this.addEventListener("keyup",this.handleKeyup),this.addEventListener("keydown",this.handleKeydown)}updated(t){if(super.updated(t),this.x!==this.inputX.valueAsNumber&&(this._x=this.inputX.valueAsNumber),this.y!==this.inputY.valueAsNumber&&(this._y=this.inputY.valueAsNumber),t.has("focused")&&this.focused){const e=this.inputX.parentElement,i=this.inputY.parentElement;if(!e.shadowRoot&&!i.shadowRoot){e.attachShadow({mode:"open"}),i.attachShadow({mode:"open"});const s='<div tabindex="-1"><slot></slot></div>';e.shadowRoot.innerHTML=s,i.shadowRoot.innerHTML=s}}}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()}}r([n({type:Boolean,reflect:!0})],ColorArea.prototype,"disabled",2),r([n({type:Boolean,reflect:!0})],ColorArea.prototype,"focused",2),r([n({type:String})],ColorArea.prototype,"label",2),r([n({type:String,attribute:"label-x"})],ColorArea.prototype,"labelX",2),r([n({type:String,attribute:"label-y"})],ColorArea.prototype,"labelY",2),r([v(".handle")],ColorArea.prototype,"handle",2),r([n({type:Number})],ColorArea.prototype,"hue",1),r([n({type:String})],ColorArea.prototype,"value",1),r([n({type:String})],ColorArea.prototype,"color",1),r([n({attribute:!1})],ColorArea.prototype,"activeAxis",2),r([n({type:Number})],ColorArea.prototype,"x",1),r([n({type:Number})],ColorArea.prototype,"y",1),r([n({type:Number})],ColorArea.prototype,"step",2),r([v('[name="x"]')],ColorArea.prototype,"inputX",2),r([v('[name="y"]')],ColorArea.prototype,"inputY",2);
486
54
  //# sourceMappingURL=ColorArea.js.map