@luzmo/lucero 0.0.39 → 0.0.40
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/components/color-area/color-area.d.ts +44 -6
- package/components/color-area/index.cjs +5 -5
- package/components/color-area/index.js +70 -62
- package/components/color-controller-DTp1juRz.js +3198 -0
- package/components/color-controller-_ZwyhvaU.cjs +18 -0
- package/components/color-field/color-field.d.ts +3 -3
- package/components/color-field/index.cjs +5 -5
- package/components/color-field/index.js +25 -28
- package/components/color-menu/index.cjs +1 -1
- package/components/color-menu/index.js +1 -2
- package/components/color-slider/index.cjs +1 -40
- package/components/color-slider/index.js +6 -296
- package/components/index-BwxgAdzi.cjs +57 -0
- package/components/index-HjQa8tew.js +1174 -0
- package/components/index.cjs +1 -1
- package/components/index.js +2 -2
- package/components/menu/index.cjs +1 -1
- package/components/menu/index.js +1 -1
- package/components/overlay/index.cjs +1 -1
- package/components/overlay/index.js +2 -2
- package/components/{overlay-DaOKAKMl.js → overlay-BtZCJ2M0.js} +1 -2
- package/components/{overlay-lzq2PziH.cjs → overlay-DTCm3y_-.cjs} +1 -1
- package/custom-elements.json +1 -1
- package/package.json +1 -1
- package/utils/reactive-controllers/color-controller.d.ts +224 -0
- package/components/color-Bg3tYsAQ.js +0 -178
- package/components/color-DphK4hwx.cjs +0 -18
- package/components/index-C1chwzNp.js +0 -727
- package/components/index-DCKCHDTt.cjs +0 -18
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CSSResultArray, PropertyValues, TemplateResult } from 'lit';
|
|
2
2
|
import './../color-handle';
|
|
3
3
|
import { LuzmoElement } from '../../utils/base';
|
|
4
|
-
import {
|
|
4
|
+
import { ColorTypes } from '../../utils/reactive-controllers/color-controller';
|
|
5
5
|
/**
|
|
6
6
|
* @element luzmo-color-area
|
|
7
7
|
* @slot gradient - a custom gradient visually outlining the available color values
|
|
@@ -18,19 +18,45 @@ export declare class LuzmoColorArea extends LuzmoElement {
|
|
|
18
18
|
isLTR: boolean;
|
|
19
19
|
private handle;
|
|
20
20
|
private languageResolver;
|
|
21
|
+
/**
|
|
22
|
+
* A controller for managing color interactions within the ColorArea component.
|
|
23
|
+
*
|
|
24
|
+
* The `ColorController` is instantiated with the `manageAs` option set to `hsv`
|
|
25
|
+
* because the ColorArea component is designed to manipulate the saturation (`s`)
|
|
26
|
+
* and value (`v`) components of the HSV color model along the x and y axes,
|
|
27
|
+
* respectively. In the HSV color model:
|
|
28
|
+
*
|
|
29
|
+
* - The `hue` (h) represents the color type and is typically controlled by a separate input.
|
|
30
|
+
* - The `saturation` (s) represents the intensity of the color, ranging from 0% (gray) to 100% (full color).
|
|
31
|
+
* - The `value` (v) represents the brightness of the color, ranging from 0% (black) to 100% (full brightness).
|
|
32
|
+
*
|
|
33
|
+
* In the ColorArea component:
|
|
34
|
+
*
|
|
35
|
+
* - The x-axis controls the saturation (`s`), allowing users to adjust the intensity of the color.
|
|
36
|
+
* - The y-axis controls the value (`v`), allowing users to adjust the brightness of the color.
|
|
37
|
+
*Add commentMore actions
|
|
38
|
+
* By managing the color as `hsv`, the ColorController can efficiently handle the changes in saturation and value
|
|
39
|
+
* as the user interacts with the ColorArea component.
|
|
40
|
+
*
|
|
41
|
+
* @private
|
|
42
|
+
* @type {ColorController}
|
|
43
|
+
* @memberof ColorArea
|
|
44
|
+
*
|
|
45
|
+
* @property {ColorArea} this - The instance of the ColorArea component.
|
|
46
|
+
* @property {Object} options - Configuration options for the ColorController.
|
|
47
|
+
* @property {string} options.manageAs - Specifies the color model to manage, in this case 'hsv'.
|
|
48
|
+
*/
|
|
21
49
|
private colorController;
|
|
22
50
|
get hue(): number;
|
|
23
51
|
set hue(value: number);
|
|
24
|
-
get value():
|
|
25
|
-
get color():
|
|
26
|
-
set color(color:
|
|
52
|
+
get value(): ColorTypes;
|
|
53
|
+
get color(): ColorTypes;
|
|
54
|
+
set color(color: ColorTypes);
|
|
27
55
|
private activeAxis;
|
|
28
56
|
get x(): number;
|
|
29
57
|
set x(x: number);
|
|
30
|
-
private _x;
|
|
31
58
|
get y(): number;
|
|
32
59
|
set y(y: number);
|
|
33
|
-
private _y;
|
|
34
60
|
step: number;
|
|
35
61
|
inputX: HTMLInputElement;
|
|
36
62
|
inputY: HTMLInputElement;
|
|
@@ -60,6 +86,18 @@ export declare class LuzmoColorArea extends LuzmoElement {
|
|
|
60
86
|
private handleAreaPointerdown;
|
|
61
87
|
protected render(): TemplateResult;
|
|
62
88
|
protected firstUpdated(changed: PropertyValues): void;
|
|
89
|
+
/**
|
|
90
|
+
* Overrides the `updated` method to handle changes in property values.
|
|
91
|
+
*
|
|
92
|
+
* @param changed - A map of changed properties with their previous values.
|
|
93
|
+
*
|
|
94
|
+
* This method performs the following actions:
|
|
95
|
+
* - Updates the saturation (`s`) of the color if `x` has changed.
|
|
96
|
+
* - Updates the value (`v`) of the color if `y` has changed.
|
|
97
|
+
* - If the `focused` property has changed and is now true, it lazily binds
|
|
98
|
+
* the `input[type="range"]` elements in shadow roots to prevent multiple
|
|
99
|
+
* tab stops within the Color Area for certain browser settings (e.g., Webkit).
|
|
100
|
+
*/
|
|
63
101
|
protected updated(changed: PropertyValues): void;
|
|
64
102
|
private observer?;
|
|
65
103
|
connectedCallback(): void;
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
16
16
|
* SOFTWARE.
|
|
17
17
|
* */
|
|
18
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../base-CBCg3yyw.cjs"),f=require("../query-BL-TJj7K.cjs"),b=require("../if-defined-C9YGdo33.cjs");require("../color-handle/index.cjs");const
|
|
18
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../base-CBCg3yyw.cjs"),f=require("../query-BL-TJj7K.cjs"),b=require("../if-defined-C9YGdo33.cjs");require("../color-handle/index.cjs");const v=require("../platform-BiXhwqk3.cjs"),g=require("../color-controller-_ZwyhvaU.cjs"),y=require("../language-resolution-DJzmyzZq.cjs"),w=require("../streaming-listener-B00MvALi.cjs"),C="@media (forced-colors: active){:host{--highcontrast-color-area-border-color-disabled: GrayText;--highcontrast-color-area-border-color: Canvas;--highcontrast-color-area-fill-color-disabled: Canvas}.gradient,:host([disabled]){forced-color-adjust:none}}:host{cursor:default;-webkit-user-select:none;user-select:none;min-inline-size:var(--luzmo-color-area-min-width, 64px);min-block-size:var(--luzmo-color-area-min-height, 64px);inline-size:var(--luzmo-color-area-width, 192px);block-size:var(--luzmo-color-area-height, 192px);box-sizing:border-box;border-radius:var(--luzmo-color-area-border-radius, var(--luzmo-border-radius-s));border:var(--luzmo-color-area-border-width, var(--luzmo-border-width)) solid var(--highcontrast-color-area-border-color, var(--luzmo-color-area-border-color, var(--luzmo-border-color)));display:inline-block;position:relative}:host([focused]){z-index:1}:host([disabled]){pointer-events:none;background:var(--highcontrast-color-area-fill-color-disabled, var(--luzmo-color-area-disabled-background-color, var(--luzmo-dimmed-color)));border:var(--luzmo-color-area-border-width, var(--luzmo-border-width)) solid var(--highcontrast-color-area-border-color-disabled)}:host([disabled]) .gradient{display:none}.handle{transform:translate(calc(var(--luzmo-color-area-width, 192px) - var(--luzmo-border-width)));inset-block-start:0}.handle:dir(rtl),:host([dir=rtl]) .handle{inset-inline-end:0}.gradient{inline-size:100%;block-size:100%;border-radius:var(--luzmo-color-area-border-radius, var(--luzmo-border-radius-s))}.slider{opacity:0;inline-size:100%;block-size:100%;z-index:0;pointer-events:none;margin:0;position:absolute;inset-block-start:0;inset-inline-start:0}:host{touch-action:none}:host:before{pointer-events:none}.gradient{overflow:hidden}.handle{transform:translate(var(--luzmo-color-area-default-width))}::slotted(*){width:100%;height:100%}:host([dir=rtl]) .gradient{transform:scaleX(-1)}.slider[orient=vertical]{-webkit-appearance:slider-vertical;-moz-appearance:slider-vertical;appearance:slider-vertical}.slider:focus{z-index:1}.fieldset{border:0;margin:0;padding:0}";var x=Object.defineProperty,$=Object.getOwnPropertyDescriptor,a=(p,e,t,r)=>{for(var o=r>1?void 0:r?$(e,t):e,n=p.length-1,l;n>=0;n--)(l=p[n])&&(o=(r?l(e,t,o):l(o))||o);return r&&o&&x(e,t,o),o};class i extends s.LuzmoElement{constructor(){super(...arguments),this.disabled=!1,this.focused=!1,this.labelX="saturation",this.labelY="luminosity",this.isLTR=!0,this.languageResolver=new y.LanguageResolutionController(this),this.colorController=new g.ColorController(this,{manageAs:"hsv"}),this.activeAxis="x",this.step=.01,this.altered=0,this.activeKeys=new Set,this._valueChanged=!1,this._pointerDown=!1}static get styles(){return[s.r(C)]}get hue(){return this.colorController.hue}set hue(e){this.colorController.hue=e}get value(){return this.colorController.colorValue}get color(){return this.colorController.colorValue}set color(e){this.colorController.color=e}get x(){return this.colorController.color.hsv.s/100}set x(e){if(e===this.x)return;const t=this.x;this.inputX?(this.inputX.value=e.toString(),this.colorController.color.set("s",this.inputX.valueAsNumber*100)):this.colorController.color.set("s",e*100),this.requestUpdate("x",t)}get y(){return this.colorController.color.hsv.v/100}set y(e){if(e===this.y)return;const t=this.y;this.inputY&&(this.inputY.value=e.toString(),this.colorController.color.set("v",this.inputY.valueAsNumber*100)),this.requestUpdate("y",t)}focus(e={}){super.focus(e),this.forwardFocus()}forwardFocus(){this.activeAxis==="x"?this.inputX.focus():this.inputY.focus()}handleFocus(){this.focused=!0,this._valueChanged=!1}handleBlur(){this._pointerDown||(this.altered=0,this.focused=!1,this._valueChanged=!1)}handleKeydown(e){const{code:t}=e;this.focused=!0,this.altered=[e.shiftKey,e.ctrlKey,e.altKey].filter(o=>!!o).length,(t.search("Arrow")===0||t.search("Page")===0||t.search("Home")===0||t.search("End")===0)&&(e.preventDefault(),this.activeKeys.add(t),this.handleKeypress())}handleKeypress(){let e=0,t=0;const r=Math.max(this.step,this.altered*5*this.step);this.activeKeys.forEach(o=>{switch(o){case"ArrowUp":{t=r;break}case"ArrowDown":{t=r*-1;break}case"ArrowLeft":{e=this.step*(this.isLTR?-1:1);break}case"ArrowRight":{e=this.step*(this.isLTR?1:-1);break}case"PageUp":{t=r*10;break}case"PageDown":{t=r*-10;break}case"Home":{e=r*(this.isLTR?-10:10);break}case"End":{e=r*(this.isLTR?10:-10);break}}}),e!==0?(this.activeAxis="x",this.inputX.focus()):t!==0&&(this.activeAxis="y",this.inputY.focus()),this.x=Math.min(1,Math.max(this.x+e,0)),this.y=Math.min(1,Math.max(this.y+t,0)),this.colorController.savePreviousColor(),(e!==0||t!==0)&&(this._valueChanged=!0,this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0,cancelable:!0}))||this.colorController.restorePreviousColor())}handleKeyup(e){e.preventDefault();const{code:t}=e;this.activeKeys.delete(t)}handleInput(e){const{valueAsNumber:t,name:r}=e.target;this[r]=t}handleChange(e){this.handleInput(e),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0,cancelable:!0}))}handlePointerdown(e){if(e.button!==0){e.preventDefault();return}this._pointerDown=!0,this.colorController.savePreviousColor(),this.boundingClientRect=this.getBoundingClientRect(),e.target.setPointerCapture(e.pointerId),e.pointerType==="mouse"&&(this.focused=!0)}handlePointermove(e){const[t,r]=this.calculateHandlePosition(e);this._valueChanged=!1,this.x=t,this.y=r,this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0,cancelable:!0}))}handlePointerup(e){e.preventDefault(),this._pointerDown=!1,e.target.releasePointerCapture(e.pointerId);const t=this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0,cancelable:!0}));this.inputX.focus(),e.pointerType==="mouse"&&(this.focused=!1),t||this.colorController.restorePreviousColor()}calculateHandlePosition(e){if(!this.boundingClientRect)return[this.x,this.y];const t=this.boundingClientRect,r=t.left,o=t.top,n=e.clientX,l=e.clientY,h=t.width,d=t.height,c=Math.max(0,Math.min(1,(n-r)/h)),u=Math.max(0,Math.min(1,(l-o)/d));return[this.isLTR?c:1-c,1-u]}handleAreaPointerdown(e){e.button===0&&(e.stopPropagation(),e.preventDefault(),this.handle.dispatchEvent(new PointerEvent("pointerdown",e)),this.handlePointermove(e))}render(){const{width:e=0,height:t=0}=this.boundingClientRect||{},r=v.isAndroid()||v.isIOS(),n="Color Picker",l=b.o(r?void 0:"2d slider"),h=this.labelX,d=this.labelY,c=new Intl.NumberFormat(this.languageResolver.language,{style:"percent",unitDisplay:"narrow"}).format(this.x),u=new Intl.NumberFormat(this.languageResolver.language,{style:"percent",unitDisplay:"narrow"}).format(this.y),m={background:`linear-gradient(to top, black 0%, hsla(${this.hue}, 100%, 0.01%, 0) 100%),linear-gradient(to right, white 0%, hsla(${this.hue}, 100%, 0.01%, 0) 100%), hsl(${this.hue}, 100%, 50%);`};return s.x`
|
|
19
19
|
<div
|
|
20
20
|
@pointerdown=${this.handleAreaPointerdown}
|
|
21
21
|
class="gradient"
|
|
22
|
-
style="background: ${
|
|
22
|
+
style="background: ${m.background}"
|
|
23
23
|
>
|
|
24
24
|
<slot name="gradient"></slot>
|
|
25
25
|
</div>
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
aria-label=${r?h:`${h} ${n}`}
|
|
48
48
|
aria-roledescription=${l}
|
|
49
49
|
aria-orientation="horizontal"
|
|
50
|
-
aria-valuetext=${r?
|
|
50
|
+
aria-valuetext=${r?c:`${c}, ${h}${this._valueChanged?"":`, ${u}, ${d}`}`}
|
|
51
51
|
min="0"
|
|
52
52
|
max="1"
|
|
53
53
|
step=${this.step}
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
aria-label=${r?d:`${d} ${n}`}
|
|
66
66
|
aria-roledescription=${l}
|
|
67
67
|
aria-orientation="vertical"
|
|
68
|
-
aria-valuetext=${r?
|
|
68
|
+
aria-valuetext=${r?u:`${u}, ${d}${this._valueChanged?"":`, ${c}, ${h}`}`}
|
|
69
69
|
orient="vertical"
|
|
70
70
|
min="0"
|
|
71
71
|
max="1"
|
|
@@ -77,4 +77,4 @@
|
|
|
77
77
|
/>
|
|
78
78
|
</div>
|
|
79
79
|
</fieldset>
|
|
80
|
-
`}firstUpdated(e){super.firstUpdated(e),this.boundingClientRect=this.getBoundingClientRect(),this.addEventListener("focus",this.handleFocus),this.addEventListener("blur",this.handleBlur),this.addEventListener("keyup",this.handleKeyup),this.addEventListener("keydown",this.handleKeydown)}updated(e){if(super.updated(e),this.x!==this.inputX.valueAsNumber&&
|
|
80
|
+
`}firstUpdated(e){super.firstUpdated(e),this.boundingClientRect=this.getBoundingClientRect(),this.addEventListener("focus",this.handleFocus),this.addEventListener("blur",this.handleBlur),this.addEventListener("keyup",this.handleKeyup),this.addEventListener("keydown",this.handleKeydown)}updated(e){if(super.updated(e),this.x!==this.inputX.valueAsNumber&&this.colorController.color.set("s",this.inputX.valueAsNumber*100),this.y!==this.inputY.valueAsNumber&&this.colorController.color.set("v",(1-this.inputY.valueAsNumber)*100),e.has("focused")&&this.focused){const t=this.inputX.parentElement,r=this.inputY.parentElement;if(!t.shadowRoot&&!r.shadowRoot){t.attachShadow({mode:"open"}),r.attachShadow({mode:"open"});const o='<div tabindex="-1"><slot></slot></div>';t.shadowRoot.innerHTML=o,r.shadowRoot.innerHTML=o}}}connectedCallback(){var e;super.connectedCallback(),!this.observer&&window.ResizeObserver&&(this.observer=new window.ResizeObserver(t=>{for(const r of t)this.boundingClientRect=r.contentRect;this.requestUpdate()})),(e=this.observer)==null||e.observe(this)}disconnectedCallback(){var e;(e=this.observer)==null||e.unobserve(this),super.disconnectedCallback()}}a([s.n({type:String,reflect:!0})],i.prototype,"dir",2);a([s.n({type:Boolean,reflect:!0})],i.prototype,"disabled",2);a([s.n({type:Boolean,reflect:!0})],i.prototype,"focused",2);a([s.n({type:String,attribute:"label-x"})],i.prototype,"labelX",2);a([s.n({type:String,attribute:"label-y"})],i.prototype,"labelY",2);a([s.n({type:Boolean,attribute:"is-ltr"})],i.prototype,"isLTR",2);a([f.e(".handle")],i.prototype,"handle",2);a([s.n({type:Number})],i.prototype,"hue",1);a([s.n({type:String})],i.prototype,"value",1);a([s.n({type:String})],i.prototype,"color",1);a([s.n({attribute:!1})],i.prototype,"activeAxis",2);a([s.n({type:Number})],i.prototype,"x",1);a([s.n({type:Number})],i.prototype,"y",1);a([s.n({type:Number})],i.prototype,"step",2);a([f.e('[name="x"]')],i.prototype,"inputX",2);a([f.e('[name="y"]')],i.prototype,"inputY",2);customElements.get("luzmo-color-area")||customElements.define("luzmo-color-area",i);exports.LuzmoColorArea=i;
|
|
@@ -20,7 +20,7 @@ import { e as b } from "../query-D_KR_GUc.js";
|
|
|
20
20
|
import { o as m } from "../if-defined-DOaE2coe.js";
|
|
21
21
|
import "../color-handle/index.js";
|
|
22
22
|
import { j as x, c as w } from "../platform-BM-uMWpX.js";
|
|
23
|
-
import { C } from "../color-
|
|
23
|
+
import { C } from "../color-controller-DTp1juRz.js";
|
|
24
24
|
import { L as $ } from "../language-resolution-8yZa5r_P.js";
|
|
25
25
|
import { s as k } from "../streaming-listener-CP-JE6Fa.js";
|
|
26
26
|
const g = () => {
|
|
@@ -31,23 +31,14 @@ const g = () => {
|
|
|
31
31
|
};
|
|
32
32
|
g();
|
|
33
33
|
const R = "@media (forced-colors: active){:host{--highcontrast-color-area-border-color-disabled: GrayText;--highcontrast-color-area-border-color: Canvas;--highcontrast-color-area-fill-color-disabled: Canvas}.gradient,:host([disabled]){forced-color-adjust:none}}:host{cursor:default;-webkit-user-select:none;user-select:none;min-inline-size:var(--luzmo-color-area-min-width, 64px);min-block-size:var(--luzmo-color-area-min-height, 64px);inline-size:var(--luzmo-color-area-width, 192px);block-size:var(--luzmo-color-area-height, 192px);box-sizing:border-box;border-radius:var(--luzmo-color-area-border-radius, var(--luzmo-border-radius-s));border:var(--luzmo-color-area-border-width, var(--luzmo-border-width)) solid var(--highcontrast-color-area-border-color, var(--luzmo-color-area-border-color, var(--luzmo-border-color)));display:inline-block;position:relative}:host([focused]){z-index:1}:host([disabled]){pointer-events:none;background:var(--highcontrast-color-area-fill-color-disabled, var(--luzmo-color-area-disabled-background-color, var(--luzmo-dimmed-color)));border:var(--luzmo-color-area-border-width, var(--luzmo-border-width)) solid var(--highcontrast-color-area-border-color-disabled)}:host([disabled]) .gradient{display:none}.handle{transform:translate(calc(var(--luzmo-color-area-width, 192px) - var(--luzmo-border-width)));inset-block-start:0}.handle:dir(rtl),:host([dir=rtl]) .handle{inset-inline-end:0}.gradient{inline-size:100%;block-size:100%;border-radius:var(--luzmo-color-area-border-radius, var(--luzmo-border-radius-s))}.slider{opacity:0;inline-size:100%;block-size:100%;z-index:0;pointer-events:none;margin:0;position:absolute;inset-block-start:0;inset-inline-start:0}:host{touch-action:none}:host:before{pointer-events:none}.gradient{overflow:hidden}.handle{transform:translate(var(--luzmo-color-area-default-width))}::slotted(*){width:100%;height:100%}:host([dir=rtl]) .gradient{transform:scaleX(-1)}.slider[orient=vertical]{-webkit-appearance:slider-vertical;-moz-appearance:slider-vertical;appearance:slider-vertical}.slider:focus{z-index:1}.fieldset{border:0;margin:0;padding:0}";
|
|
34
|
-
var
|
|
35
|
-
for (var r = t > 1 ? void 0 : t ?
|
|
34
|
+
var A = Object.defineProperty, P = Object.getOwnPropertyDescriptor, i = (u, e, o, t) => {
|
|
35
|
+
for (var r = t > 1 ? void 0 : t ? P(e, o) : e, a = u.length - 1, n; a >= 0; a--)
|
|
36
36
|
(n = u[a]) && (r = (t ? n(e, o, r) : n(r)) || r);
|
|
37
|
-
return t && r &&
|
|
37
|
+
return t && r && A(e, o, r), r;
|
|
38
38
|
};
|
|
39
|
-
class
|
|
39
|
+
class l extends z {
|
|
40
40
|
constructor() {
|
|
41
|
-
super(...arguments), this.disabled = !1, this.focused = !1, this.labelX = "saturation", this.labelY = "luminosity", this.isLTR = !0, this.languageResolver = new $(this), this.colorController = new C(this, {
|
|
42
|
-
extractColorFromState: () => ({
|
|
43
|
-
h: this.hue,
|
|
44
|
-
s: this.x,
|
|
45
|
-
v: this.y
|
|
46
|
-
}),
|
|
47
|
-
applyColorToState: ({ s: e, v: o }) => {
|
|
48
|
-
this._x = e, this._y = o, this.requestUpdate();
|
|
49
|
-
}
|
|
50
|
-
}), this.activeAxis = "x", this._x = 1, this._y = 1, this.step = 0.01, this.altered = 0, this.activeKeys = /* @__PURE__ */ new Set(), this._valueChanged = !1, this._pointerDown = !1;
|
|
41
|
+
super(...arguments), this.disabled = !1, this.focused = !1, this.labelX = "saturation", this.labelY = "luminosity", this.isLTR = !0, this.languageResolver = new $(this), this.colorController = new C(this, { manageAs: "hsv" }), this.activeAxis = "x", this.step = 0.01, this.altered = 0, this.activeKeys = /* @__PURE__ */ new Set(), this._valueChanged = !1, this._pointerDown = !1;
|
|
51
42
|
}
|
|
52
43
|
static get styles() {
|
|
53
44
|
return [v(R)];
|
|
@@ -59,31 +50,31 @@ class i extends z {
|
|
|
59
50
|
this.colorController.hue = e;
|
|
60
51
|
}
|
|
61
52
|
get value() {
|
|
62
|
-
return this.colorController.
|
|
53
|
+
return this.colorController.colorValue;
|
|
63
54
|
}
|
|
64
55
|
get color() {
|
|
65
|
-
return this.colorController.
|
|
56
|
+
return this.colorController.colorValue;
|
|
66
57
|
}
|
|
67
58
|
set color(e) {
|
|
68
59
|
this.colorController.color = e;
|
|
69
60
|
}
|
|
70
61
|
get x() {
|
|
71
|
-
return this.
|
|
62
|
+
return this.colorController.color.hsv.s / 100;
|
|
72
63
|
}
|
|
73
64
|
set x(e) {
|
|
74
65
|
if (e === this.x)
|
|
75
66
|
return;
|
|
76
67
|
const o = this.x;
|
|
77
|
-
this.
|
|
68
|
+
this.inputX ? (this.inputX.value = e.toString(), this.colorController.color.set("s", this.inputX.valueAsNumber * 100)) : this.colorController.color.set("s", e * 100), this.requestUpdate("x", o);
|
|
78
69
|
}
|
|
79
70
|
get y() {
|
|
80
|
-
return this.
|
|
71
|
+
return this.colorController.color.hsv.v / 100;
|
|
81
72
|
}
|
|
82
73
|
set y(e) {
|
|
83
74
|
if (e === this.y)
|
|
84
75
|
return;
|
|
85
76
|
const o = this.y;
|
|
86
|
-
this.
|
|
77
|
+
this.inputY && (this.inputY.value = e.toString(), this.colorController.color.set("v", this.inputY.valueAsNumber * 100)), this.requestUpdate("y", o);
|
|
87
78
|
}
|
|
88
79
|
focus(e = {}) {
|
|
89
80
|
super.focus(e), this.forwardFocus();
|
|
@@ -141,7 +132,7 @@ class i extends z {
|
|
|
141
132
|
break;
|
|
142
133
|
}
|
|
143
134
|
}
|
|
144
|
-
}), e !== 0 ? (this.activeAxis = "x", this.inputX.focus()) : o !== 0 && (this.activeAxis = "y", this.inputY.focus()), this.x = Math.min(1, Math.max(this.x + e, 0)), this.y = Math.min(1, Math.max(this.y + o, 0)), this.colorController.savePreviousColor(),
|
|
135
|
+
}), e !== 0 ? (this.activeAxis = "x", this.inputX.focus()) : o !== 0 && (this.activeAxis = "y", this.inputY.focus()), this.x = Math.min(1, Math.max(this.x + e, 0)), this.y = Math.min(1, Math.max(this.y + o, 0)), this.colorController.savePreviousColor(), (e !== 0 || o !== 0) && (this._valueChanged = !0, this.dispatchEvent(
|
|
145
136
|
new Event("input", {
|
|
146
137
|
bubbles: !0,
|
|
147
138
|
composed: !0
|
|
@@ -161,7 +152,7 @@ class i extends z {
|
|
|
161
152
|
}
|
|
162
153
|
handleInput(e) {
|
|
163
154
|
const { valueAsNumber: o, name: t } = e.target;
|
|
164
|
-
this[t] = o
|
|
155
|
+
this[t] = o;
|
|
165
156
|
}
|
|
166
157
|
handleChange(e) {
|
|
167
158
|
this.handleInput(e), this.dispatchEvent(
|
|
@@ -181,7 +172,7 @@ class i extends z {
|
|
|
181
172
|
}
|
|
182
173
|
handlePointermove(e) {
|
|
183
174
|
const [o, t] = this.calculateHandlePosition(e);
|
|
184
|
-
this._valueChanged = !1, this.x = o, this.y =
|
|
175
|
+
this._valueChanged = !1, this.x = o, this.y = t, this.dispatchEvent(
|
|
185
176
|
new Event("input", {
|
|
186
177
|
bubbles: !0,
|
|
187
178
|
composed: !0,
|
|
@@ -209,7 +200,7 @@ class i extends z {
|
|
|
209
200
|
if (!this.boundingClientRect)
|
|
210
201
|
return [this.x, this.y];
|
|
211
202
|
const o = this.boundingClientRect, t = o.left, r = o.top, a = e.clientX, n = e.clientY, c = o.width, d = o.height, h = Math.max(0, Math.min(1, (a - t) / c)), p = Math.max(0, Math.min(1, (n - r) / d));
|
|
212
|
-
return [this.isLTR ? h : 1 - h, p];
|
|
203
|
+
return [this.isLTR ? h : 1 - h, 1 - p];
|
|
213
204
|
}
|
|
214
205
|
handleAreaPointerdown(e) {
|
|
215
206
|
e.button === 0 && (e.stopPropagation(), e.preventDefault(), this.handle.dispatchEvent(new PointerEvent("pointerdown", e)), this.handlePointermove(e));
|
|
@@ -221,12 +212,14 @@ class i extends z {
|
|
|
221
212
|
}).format(this.x), p = new Intl.NumberFormat(this.languageResolver.language, {
|
|
222
213
|
style: "percent",
|
|
223
214
|
unitDisplay: "narrow"
|
|
224
|
-
}).format(this.y), f =
|
|
215
|
+
}).format(this.y), f = {
|
|
216
|
+
background: `linear-gradient(to top, black 0%, hsla(${this.hue}, 100%, 0.01%, 0) 100%),linear-gradient(to right, white 0%, hsla(${this.hue}, 100%, 0.01%, 0) 100%), hsl(${this.hue}, 100%, 50%);`
|
|
217
|
+
};
|
|
225
218
|
return y`
|
|
226
219
|
<div
|
|
227
220
|
@pointerdown=${this.handleAreaPointerdown}
|
|
228
221
|
class="gradient"
|
|
229
|
-
style="background: ${f}"
|
|
222
|
+
style="background: ${f.background}"
|
|
230
223
|
>
|
|
231
224
|
<slot name="gradient"></slot>
|
|
232
225
|
</div>
|
|
@@ -296,8 +289,23 @@ class i extends z {
|
|
|
296
289
|
firstUpdated(e) {
|
|
297
290
|
super.firstUpdated(e), this.boundingClientRect = this.getBoundingClientRect(), this.addEventListener("focus", this.handleFocus), this.addEventListener("blur", this.handleBlur), this.addEventListener("keyup", this.handleKeyup), this.addEventListener("keydown", this.handleKeydown);
|
|
298
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* Overrides the `updated` method to handle changes in property values.
|
|
294
|
+
*
|
|
295
|
+
* @param changed - A map of changed properties with their previous values.
|
|
296
|
+
*
|
|
297
|
+
* This method performs the following actions:
|
|
298
|
+
* - Updates the saturation (`s`) of the color if `x` has changed.
|
|
299
|
+
* - Updates the value (`v`) of the color if `y` has changed.
|
|
300
|
+
* - If the `focused` property has changed and is now true, it lazily binds
|
|
301
|
+
* the `input[type="range"]` elements in shadow roots to prevent multiple
|
|
302
|
+
* tab stops within the Color Area for certain browser settings (e.g., Webkit).
|
|
303
|
+
*/
|
|
299
304
|
updated(e) {
|
|
300
|
-
if (super.updated(e), this.x !== this.inputX.valueAsNumber &&
|
|
305
|
+
if (super.updated(e), this.x !== this.inputX.valueAsNumber && this.colorController.color.set("s", this.inputX.valueAsNumber * 100), this.y !== this.inputY.valueAsNumber && this.colorController.color.set(
|
|
306
|
+
"v",
|
|
307
|
+
(1 - this.inputY.valueAsNumber) * 100
|
|
308
|
+
), e.has("focused") && this.focused) {
|
|
301
309
|
const o = this.inputX.parentElement, t = this.inputY.parentElement;
|
|
302
310
|
if (!o.shadowRoot && !t.shadowRoot) {
|
|
303
311
|
o.attachShadow({ mode: "open" }), t.attachShadow({ mode: "open" });
|
|
@@ -319,55 +327,55 @@ class i extends z {
|
|
|
319
327
|
(e = this.observer) == null || e.unobserve(this), super.disconnectedCallback();
|
|
320
328
|
}
|
|
321
329
|
}
|
|
322
|
-
|
|
330
|
+
i([
|
|
323
331
|
s({ type: String, reflect: !0 })
|
|
324
|
-
],
|
|
325
|
-
|
|
332
|
+
], l.prototype, "dir", 2);
|
|
333
|
+
i([
|
|
326
334
|
s({ type: Boolean, reflect: !0 })
|
|
327
|
-
],
|
|
328
|
-
|
|
335
|
+
], l.prototype, "disabled", 2);
|
|
336
|
+
i([
|
|
329
337
|
s({ type: Boolean, reflect: !0 })
|
|
330
|
-
],
|
|
331
|
-
|
|
338
|
+
], l.prototype, "focused", 2);
|
|
339
|
+
i([
|
|
332
340
|
s({ type: String, attribute: "label-x" })
|
|
333
|
-
],
|
|
334
|
-
|
|
341
|
+
], l.prototype, "labelX", 2);
|
|
342
|
+
i([
|
|
335
343
|
s({ type: String, attribute: "label-y" })
|
|
336
|
-
],
|
|
337
|
-
|
|
344
|
+
], l.prototype, "labelY", 2);
|
|
345
|
+
i([
|
|
338
346
|
s({ type: Boolean, attribute: "is-ltr" })
|
|
339
|
-
],
|
|
340
|
-
|
|
347
|
+
], l.prototype, "isLTR", 2);
|
|
348
|
+
i([
|
|
341
349
|
b(".handle")
|
|
342
|
-
],
|
|
343
|
-
|
|
350
|
+
], l.prototype, "handle", 2);
|
|
351
|
+
i([
|
|
344
352
|
s({ type: Number })
|
|
345
|
-
],
|
|
346
|
-
|
|
353
|
+
], l.prototype, "hue", 1);
|
|
354
|
+
i([
|
|
347
355
|
s({ type: String })
|
|
348
|
-
],
|
|
349
|
-
|
|
356
|
+
], l.prototype, "value", 1);
|
|
357
|
+
i([
|
|
350
358
|
s({ type: String })
|
|
351
|
-
],
|
|
352
|
-
|
|
359
|
+
], l.prototype, "color", 1);
|
|
360
|
+
i([
|
|
353
361
|
s({ attribute: !1 })
|
|
354
|
-
],
|
|
355
|
-
|
|
362
|
+
], l.prototype, "activeAxis", 2);
|
|
363
|
+
i([
|
|
356
364
|
s({ type: Number })
|
|
357
|
-
],
|
|
358
|
-
|
|
365
|
+
], l.prototype, "x", 1);
|
|
366
|
+
i([
|
|
359
367
|
s({ type: Number })
|
|
360
|
-
],
|
|
361
|
-
|
|
368
|
+
], l.prototype, "y", 1);
|
|
369
|
+
i([
|
|
362
370
|
s({ type: Number })
|
|
363
|
-
],
|
|
364
|
-
|
|
371
|
+
], l.prototype, "step", 2);
|
|
372
|
+
i([
|
|
365
373
|
b('[name="x"]')
|
|
366
|
-
],
|
|
367
|
-
|
|
374
|
+
], l.prototype, "inputX", 2);
|
|
375
|
+
i([
|
|
368
376
|
b('[name="y"]')
|
|
369
|
-
],
|
|
370
|
-
customElements.get("luzmo-color-area") || customElements.define("luzmo-color-area",
|
|
377
|
+
], l.prototype, "inputY", 2);
|
|
378
|
+
customElements.get("luzmo-color-area") || customElements.define("luzmo-color-area", l);
|
|
371
379
|
export {
|
|
372
|
-
|
|
380
|
+
l as LuzmoColorArea
|
|
373
381
|
};
|