@luzmo/lucero 1.0.1-alpha.14 → 1.0.1-alpha.16
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/accordion/index.cjs +183 -6
- package/components/accordion/index.js +136 -88
- package/components/action-bar/index.cjs +85 -4
- package/components/action-bar/index.js +72 -50
- package/components/action-button/index.cjs +205 -3
- package/components/action-button/index.js +167 -93
- package/components/action-group/index.cjs +7 -1
- package/components/action-group/index.js +12 -8
- package/components/action-group-DHp8RHDf.js +392 -0
- package/components/action-group-MPf19RPV.cjs +391 -0
- package/components/action-menu/index.cjs +91 -11
- package/components/action-menu/index.js +66 -47
- package/components/avatar/index.cjs +63 -3
- package/components/avatar/index.js +54 -42
- package/components/base-COw9n7UR.cjs +119 -0
- package/components/base-DmeVy0cq.js +120 -0
- package/components/button/index.cjs +134 -2
- package/components/button/index.js +106 -72
- package/components/button-base-7Ak55xFd.cjs +206 -0
- package/components/button-base-C3kf6BTK.js +207 -0
- package/components/button-group/index.cjs +45 -1
- package/components/button-group/index.js +37 -25
- package/components/calendar/index.cjs +632 -1
- package/components/calendar/index.js +637 -7
- package/components/checkbox/index.cjs +111 -4
- package/components/checkbox/index.js +98 -53
- package/components/checkbox-mixin-8cL-vfDy.js +84 -0
- package/components/checkbox-mixin-CE7dJj3J.cjs +83 -0
- package/components/clear-button-Co6oKSgl.js +59 -0
- package/components/clear-button-X_HDY2eH.cjs +58 -0
- package/components/close-button-DPBK6Kpu.cjs +59 -0
- package/components/close-button-Miw9ZjoJ.js +60 -0
- package/components/color-area/index.cjs +440 -13
- package/components/color-area/index.js +322 -187
- package/components/color-controller-BjDZaxhX.js +491 -0
- package/components/color-controller-C3c_vb2P.cjs +490 -0
- package/components/color-field/index.cjs +95 -2
- package/components/color-field/index.js +77 -41
- package/components/color-handle/index.cjs +64 -3
- package/components/color-handle/index.js +58 -37
- package/components/color-loupe/index.cjs +7 -1
- package/components/color-loupe/index.js +12 -8
- package/components/color-loupe-BQqNR8YD.cjs +88 -0
- package/components/color-loupe-B_DDFv8l.js +89 -0
- package/components/color-menu/index.cjs +217 -12
- package/components/color-menu/index.js +187 -93
- package/components/color-palette/index.cjs +89 -1
- package/components/color-palette/index.js +78 -51
- package/components/color-palette-group/index.cjs +259 -3
- package/components/color-palette-group/index.js +193 -105
- package/components/color-picker/index.cjs +114 -6
- package/components/color-picker/index.js +92 -72
- package/components/color-slider/index.cjs +585 -1
- package/components/color-slider/index.js +590 -7
- package/components/{directive-oAbCiebi.js → condition-attribute-with-id-Cn815e9W.js} +22 -22
- package/components/condition-attribute-with-id-DEc2Yjne.cjs +43 -0
- package/components/date-time-picker/index.cjs +1357 -31
- package/components/date-time-picker/index.js +951 -637
- package/components/dependency-manger-CcIE1uvQ.cjs +63 -0
- package/components/{dependency-manger-CEXvGQUV.js → dependency-manger-XHpQjFgK.js} +24 -14
- package/components/divider/index.cjs +54 -1
- package/components/divider/index.js +49 -30
- package/components/divider.module-Cm5LcDRV.cjs +20 -0
- package/components/divider.module-DauH6k2_.js +21 -0
- package/components/element-resolution-DCsrhGZO.cjs +112 -0
- package/components/element-resolution-nMlmW4Jy.js +113 -0
- package/components/field-group/index.cjs +7 -1
- package/components/field-group/index.js +12 -8
- package/components/field-group-DNmY8W9v.cjs +86 -0
- package/components/field-group-DVdAWCQF.js +87 -0
- package/components/field-label/index.cjs +7 -1
- package/components/field-label/index.js +12 -8
- package/components/field-label-CKH9EXpR.cjs +156 -0
- package/components/field-label-Dpsecoc6.js +157 -0
- package/components/focus-group-BqDAk9Is.js +337 -0
- package/components/focus-group-DFzOlalL.cjs +336 -0
- package/components/focus-visible-B-B8-P9R.cjs +104 -0
- package/components/focus-visible-BUPRWlsh.js +105 -0
- package/components/focusable-BPrTcZPd.cjs +262 -0
- package/components/focusable-ChCLg1k4.js +263 -0
- package/components/{directive-C7oCP5Bh.cjs → focusable-selectors-D0t_5P7C.cjs} +16 -5
- package/components/{focusable-selectors-B4YgbghQ.js → focusable-selectors-IltOAOd9.js} +7 -4
- package/components/icon/index.cjs +90 -1
- package/components/icon/index.js +74 -46
- package/components/index.cjs +174 -1
- package/components/index.js +174 -172
- package/components/infield-button/index.cjs +46 -2
- package/components/infield-button/index.js +41 -30
- package/components/label/index.cjs +37 -1
- package/components/label/index.js +36 -24
- package/components/{language-resolution-8yZa5r_P.js → language-resolution-BSGJAWiQ.js} +21 -16
- package/components/language-resolution-iN9EImbb.cjs +57 -0
- package/components/like-anchor-D62faRNG.cjs +79 -0
- package/components/like-anchor-v3cJ9RWM.js +80 -0
- package/components/manage-help-text-BYx84zZR.cjs +125 -0
- package/components/manage-help-text-DOuMTGht.js +126 -0
- package/components/menu/index.cjs +1297 -29
- package/components/menu/index.js +954 -499
- package/components/multi-language-field/index.cjs +132 -2
- package/components/multi-language-field/index.js +118 -88
- package/components/number-field/index.cjs +613 -10
- package/components/number-field/index.js +442 -243
- package/components/observe-slot-presence-9AwLGUQ_.cjs +78 -0
- package/components/observe-slot-presence-DcMdoumP.js +79 -0
- package/components/observe-slot-text-CSofZeeF.cjs +104 -0
- package/components/observe-slot-text-CjnkkBPn.js +105 -0
- package/components/options/index.cjs +693 -60
- package/components/options/index.js +519 -953
- package/components/overlay/index.cjs +367 -21
- package/components/overlay/index.js +273 -189
- package/components/overlay-CN8ISP1F.js +2485 -0
- package/components/overlay-LViy9VWM.cjs +2484 -0
- package/components/{pending-state-DTX7ggyF.js → pending-state-CXbe-Xul.js} +28 -13
- package/components/pending-state-e4RbXe9u.cjs +75 -0
- package/components/picker/index.cjs +9 -1
- package/components/picker/index.js +15 -11
- package/components/picker-DNde3awt.cjs +672 -0
- package/components/picker-PfUAF05y.js +673 -0
- package/components/picker-button/index.cjs +56 -4
- package/components/picker-button/index.js +45 -34
- package/components/platform-CxDar3Dn.cjs +68 -0
- package/components/platform-Cxn0WbyT.js +69 -0
- package/components/popover/index.cjs +7 -1
- package/components/popover/index.js +12 -8
- package/components/popover-BkbYhl3i.js +74 -0
- package/components/popover-BkgUf0kL.cjs +74 -0
- package/components/progress-circle/index.cjs +7 -1
- package/components/progress-circle/index.js +12 -8
- package/components/progress-circle-Hu_ivPHf.js +133 -0
- package/components/progress-circle-_Etqsj9f.cjs +132 -0
- package/components/radio/index.cjs +244 -2
- package/components/radio/index.js +192 -110
- package/components/{when-CDK1Tt5Y.js → random-id-BE6HA503.cjs} +7 -10
- package/components/{random-id-ByCz1xaq.js → random-id-BEc6QIUL.js} +3 -3
- package/components/roving-tabindex-AsmAh2In.cjs +95 -0
- package/components/roving-tabindex-DPF9NmrH.js +96 -0
- package/components/search/index.cjs +115 -8
- package/components/search/index.js +96 -66
- package/components/select/index.cjs +720 -51
- package/components/select/index.js +563 -347
- package/components/sized-mixin-DmkrNdWB.js +80 -0
- package/components/sized-mixin-UaTVa-AE.cjs +79 -0
- package/components/slider/index.cjs +119 -1
- package/components/slider/index.js +100 -1113
- package/components/{condition-attribute-with-id-Dv4lSRbe.js → slottable-request-event-CANixJnR.cjs} +15 -13
- package/components/{slottable-request-event-DggLA4Rx.js → slottable-request-event-D9WzrdWv.js} +12 -9
- package/components/strategies-DlMlaSJR.cjs +317 -0
- package/components/strategies-DlPQoTFE.js +318 -0
- package/components/streaming-listener-D4sHaMub.cjs +145 -0
- package/components/streaming-listener-cAz5zJyk.js +146 -0
- package/components/swatch/index.cjs +436 -7
- package/components/swatch/index.js +350 -205
- package/components/switch/index.cjs +61 -2
- package/components/switch/index.js +51 -34
- package/components/tabs/index.cjs +693 -26
- package/components/tabs/index.js +521 -388
- package/components/tags/index.cjs +201 -4
- package/components/tags/index.js +152 -87
- package/components/text-field/index.cjs +49 -3
- package/components/text-field/index.js +44 -30
- package/components/text-field-11tcnftU.cjs +338 -0
- package/components/text-field-Chi9J2Cz.js +339 -0
- package/components/text-field.module-CMBS0jSL.js +21 -0
- package/components/text-field.module-DIJdV_sA.cjs +20 -0
- package/components/toast/index.cjs +177 -12
- package/components/toast/index.js +145 -73
- package/components/tooltip/index.cjs +221 -6
- package/components/tooltip/index.js +156 -109
- package/components/unit-input/index.cjs +232 -8
- package/components/unit-input/index.js +201 -108
- package/components/utils.cjs +25 -1
- package/components/utils.js +22 -22
- package/package.json +1 -1
- package/components/NumberFormatter-DewVDY5w.cjs +0 -18
- package/components/NumberFormatter-DgOUVrge.js +0 -136
- package/components/NumberParser-Dik4a0h-.cjs +0 -18
- package/components/NumberParser-ci9J5EKv.js +0 -173
- package/components/action-group-DBImibFn.js +0 -258
- package/components/action-group-DJGMcRHb.cjs +0 -20
- package/components/async-directive-BX1T1e1_.cjs +0 -22
- package/components/async-directive-BfcqVjDp.js +0 -82
- package/components/base-BjTwmyRF.cjs +0 -22
- package/components/base-CBCg3yyw.cjs +0 -40
- package/components/base-D76d76ww.js +0 -26
- package/components/base-WsynuqaS.js +0 -677
- package/components/button-base-DbkDzb71.js +0 -144
- package/components/button-base-XgPLmwP-.cjs +0 -25
- package/components/checkbox-mixin-BDN0dBtS.cjs +0 -27
- package/components/checkbox-mixin-Do7EgtpQ.js +0 -70
- package/components/class-map-Di1D_rCm.cjs +0 -22
- package/components/class-map-NbVXqBU0.js +0 -51
- package/components/clear-button-DQcRdcUa.js +0 -53
- package/components/clear-button-OFUFFe7G.cjs +0 -18
- package/components/close-button-Cbnb7XXj.cjs +0 -18
- package/components/close-button-CqHYZhum.js +0 -51
- package/components/color-controller-B0uX6Zso.js +0 -3230
- package/components/color-controller-CoUL5f9K.cjs +0 -18
- package/components/color-loupe-CaA_Lfkk.cjs +0 -56
- package/components/color-loupe-CmMsXbjT.js +0 -81
- package/components/condition-attribute-with-id-DrQYZzFS.cjs +0 -18
- package/components/dependency-manger-C5HCkMMB.cjs +0 -18
- package/components/directive-helpers-Cm6gitnu.js +0 -62
- package/components/directive-helpers-DyIRTWwA.cjs +0 -22
- package/components/divider.module-DDvBo9zo.cjs +0 -18
- package/components/divider.module-DoQWQEIJ.js +0 -21
- package/components/element-resolution-BvRLGqIU.cjs +0 -18
- package/components/element-resolution-FCUT-wql.js +0 -91
- package/components/field-group-DXfBWrkO.js +0 -66
- package/components/field-group-DkGst3r5.cjs +0 -23
- package/components/field-label-CZ2zzChK.js +0 -106
- package/components/field-label-mO1AkUgR.cjs +0 -25
- package/components/flow-D-0MTYCm.js +0 -527
- package/components/flow-DM3dNAKs.cjs +0 -30
- package/components/focus-group-DHeTq18L.js +0 -218
- package/components/focus-group-DnxZUBhQ.cjs +0 -18
- package/components/focus-visible-B0P9aY_G.cjs +0 -18
- package/components/focus-visible-DBlJGoEW.js +0 -74
- package/components/focusable-BxtpnzWp.js +0 -153
- package/components/focusable-EbipgXRh.cjs +0 -18
- package/components/focusable-selectors-BgFlyFcY.cjs +0 -18
- package/components/if-defined-C9YGdo33.cjs +0 -22
- package/components/if-defined-DOaE2coe.js +0 -27
- package/components/index-BwxgAdzi.cjs +0 -57
- package/components/index-Cl54m8Yh.js +0 -1490
- package/components/index-HjQa8tew.js +0 -1174
- package/components/index-Wq3qZJGh.cjs +0 -113
- package/components/language-resolution-DJzmyzZq.cjs +0 -18
- package/components/like-anchor-Bvn_vLQ8.js +0 -69
- package/components/like-anchor-sod1C1fR.cjs +0 -32
- package/components/luzmo-icons-4nDFv1Lq.js +0 -229
- package/components/luzmo-icons-D4IvHgVd.cjs +0 -29
- package/components/manage-help-text-DhgARkZX.cjs +0 -30
- package/components/manage-help-text-syYnjKGL.js +0 -92
- package/components/mutation-controller-DH7YOCyj.js +0 -52
- package/components/mutation-controller-DkOMCW-c.cjs +0 -22
- package/components/observe-slot-presence-CmVi0zTc.js +0 -68
- package/components/observe-slot-presence-bc9chhsi.cjs +0 -18
- package/components/observe-slot-text-BPfIQQtz.js +0 -87
- package/components/observe-slot-text-Ceb7SvYT.cjs +0 -18
- package/components/overlay-Cig9r6uU.js +0 -2747
- package/components/overlay-KSKMzzkh.cjs +0 -47
- package/components/pending-state-CaH1si5b.cjs +0 -26
- package/components/picker-BfBP7XJN.js +0 -461
- package/components/picker-xIphqE6d.cjs +0 -123
- package/components/platform-BM-uMWpX.js +0 -69
- package/components/platform-BiXhwqk3.cjs +0 -18
- package/components/popover-DjX0aAnY.js +0 -67
- package/components/popover-KFfO0IYL.cjs +0 -30
- package/components/progress-circle-BvRJNuNo.cjs +0 -33
- package/components/progress-circle-DXH9z8-6.js +0 -97
- package/components/query-BL-TJj7K.cjs +0 -22
- package/components/query-D_KR_GUc.js +0 -51
- package/components/query-assigned-elements-DjfhL1cl.js +0 -36
- package/components/query-assigned-elements-DsKsfk7G.cjs +0 -22
- package/components/query-assigned-nodes-BcKWmGzy.cjs +0 -22
- package/components/query-assigned-nodes-C76XVPWY.js +0 -36
- package/components/random-id-CqvckpWe.cjs +0 -18
- package/components/roving-tabindex-By_fCy_e.cjs +0 -18
- package/components/roving-tabindex-DOg4z6ZU.js +0 -66
- package/components/sized-mixin-CPxE5C96.cjs +0 -18
- package/components/sized-mixin-D4ACoVUr.js +0 -63
- package/components/slottable-request-event-BfUUt1Mh.cjs +0 -18
- package/components/state-D8JEtYqe.cjs +0 -22
- package/components/state-Deh-vKYE.js +0 -29
- package/components/strategies-9indNIEb.js +0 -195
- package/components/strategies-BACP6MhR.cjs +0 -18
- package/components/streaming-listener-B00MvALi.cjs +0 -18
- package/components/streaming-listener-CP-JE6Fa.js +0 -91
- package/components/style-map-CeilmSgs.cjs +0 -22
- package/components/style-map-IgqIKvlE.js +0 -53
- package/components/text-field-CeG75PPO.cjs +0 -85
- package/components/text-field-DCl-AFM-.js +0 -314
- package/components/text-field.module-C2KVUJcX.js +0 -21
- package/components/text-field.module-DXhFA9G-.cjs +0 -18
- package/components/when-CDZyJPvd.cjs +0 -22
|
@@ -15,39 +15,351 @@
|
|
|
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";
|
|
18
|
+
"use strict";
|
|
19
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
20
|
+
const lit = require("lit");
|
|
21
|
+
const decorators_js = require("lit/decorators.js");
|
|
22
|
+
const ifDefined_js = require("lit/directives/if-defined.js");
|
|
23
|
+
require("../color-handle/index.cjs");
|
|
24
|
+
const base = require("../base-COw9n7UR.cjs");
|
|
25
|
+
const platform = require("../platform-CxDar3Dn.cjs");
|
|
26
|
+
const colorController = require("../color-controller-C3c_vb2P.cjs");
|
|
27
|
+
const languageResolution = require("../language-resolution-iN9EImbb.cjs");
|
|
28
|
+
const streamingListener = require("../streaming-listener-D4sHaMub.cjs");
|
|
29
|
+
const styles = "@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}";
|
|
30
|
+
var __defProp = Object.defineProperty;
|
|
31
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
32
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
33
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
34
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
35
|
+
if (decorator = decorators[i])
|
|
36
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
37
|
+
if (kind && result) __defProp(target, key, result);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
class LuzmoColorArea extends base.LuzmoElement {
|
|
41
|
+
constructor() {
|
|
42
|
+
super(...arguments);
|
|
43
|
+
this.disabled = false;
|
|
44
|
+
this.focused = false;
|
|
45
|
+
this.labelX = "saturation";
|
|
46
|
+
this.labelY = "luminosity";
|
|
47
|
+
this.isLTR = true;
|
|
48
|
+
this.languageResolver = new languageResolution.LanguageResolutionController(this);
|
|
49
|
+
this.colorController = new colorController.ColorController(this, { manageAs: "hsv" });
|
|
50
|
+
this.activeAxis = "x";
|
|
51
|
+
this.step = 0.01;
|
|
52
|
+
this.altered = 0;
|
|
53
|
+
this.activeKeys = /* @__PURE__ */ new Set();
|
|
54
|
+
this._valueChanged = false;
|
|
55
|
+
this._pointerDown = false;
|
|
56
|
+
}
|
|
57
|
+
static get styles() {
|
|
58
|
+
return [lit.unsafeCSS(styles)];
|
|
59
|
+
}
|
|
60
|
+
get hue() {
|
|
61
|
+
return this.colorController.hue;
|
|
62
|
+
}
|
|
63
|
+
set hue(value) {
|
|
64
|
+
this.colorController.hue = value;
|
|
65
|
+
}
|
|
66
|
+
get value() {
|
|
67
|
+
return this.colorController.colorValue;
|
|
68
|
+
}
|
|
69
|
+
get color() {
|
|
70
|
+
return this.colorController.colorValue;
|
|
71
|
+
}
|
|
72
|
+
set color(color) {
|
|
73
|
+
this.colorController.color = color;
|
|
74
|
+
}
|
|
75
|
+
get x() {
|
|
76
|
+
return this.colorController.color.hsv.s / 100;
|
|
77
|
+
}
|
|
78
|
+
set x(x) {
|
|
79
|
+
if (x === this.x) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const oldValue = this.x;
|
|
83
|
+
if (this.inputX) {
|
|
84
|
+
this.inputX.value = x.toString();
|
|
85
|
+
this.colorController.color.set("s", this.inputX.valueAsNumber * 100);
|
|
86
|
+
} else {
|
|
87
|
+
this.colorController.color.set("s", x * 100);
|
|
88
|
+
}
|
|
89
|
+
this.requestUpdate("x", oldValue);
|
|
90
|
+
}
|
|
91
|
+
get y() {
|
|
92
|
+
return this.colorController.color.hsv.v / 100;
|
|
93
|
+
}
|
|
94
|
+
set y(y) {
|
|
95
|
+
if (y === this.y) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const oldValue = this.y;
|
|
99
|
+
if (this.inputY) {
|
|
100
|
+
this.inputY.value = y.toString();
|
|
101
|
+
this.colorController.color.set("v", this.inputY.valueAsNumber * 100);
|
|
102
|
+
}
|
|
103
|
+
this.requestUpdate("y", oldValue);
|
|
104
|
+
}
|
|
105
|
+
focus(focusOptions = {}) {
|
|
106
|
+
super.focus(focusOptions);
|
|
107
|
+
this.forwardFocus();
|
|
108
|
+
}
|
|
109
|
+
forwardFocus() {
|
|
110
|
+
if (this.activeAxis === "x") {
|
|
111
|
+
this.inputX.focus();
|
|
112
|
+
} else {
|
|
113
|
+
this.inputY.focus();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
handleFocus() {
|
|
117
|
+
this.focused = true;
|
|
118
|
+
this._valueChanged = false;
|
|
119
|
+
}
|
|
120
|
+
handleBlur() {
|
|
121
|
+
if (this._pointerDown) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
this.altered = 0;
|
|
125
|
+
this.focused = false;
|
|
126
|
+
this._valueChanged = false;
|
|
127
|
+
}
|
|
128
|
+
handleKeydown(event) {
|
|
129
|
+
const { code } = event;
|
|
130
|
+
this.focused = true;
|
|
131
|
+
this.altered = [event.shiftKey, event.ctrlKey, event.altKey].filter(
|
|
132
|
+
(key) => !!key
|
|
133
|
+
).length;
|
|
134
|
+
const isArrowKey = code.search("Arrow") === 0 || code.search("Page") === 0 || code.search("Home") === 0 || code.search("End") === 0;
|
|
135
|
+
if (isArrowKey) {
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
this.activeKeys.add(code);
|
|
138
|
+
this.handleKeypress();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
handleKeypress() {
|
|
142
|
+
let deltaX = 0;
|
|
143
|
+
let deltaY = 0;
|
|
144
|
+
const step = Math.max(this.step, this.altered * 5 * this.step);
|
|
145
|
+
this.activeKeys.forEach((code) => {
|
|
146
|
+
switch (code) {
|
|
147
|
+
case "ArrowUp": {
|
|
148
|
+
deltaY = step;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
case "ArrowDown": {
|
|
152
|
+
deltaY = step * -1;
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
case "ArrowLeft": {
|
|
156
|
+
deltaX = this.step * (this.isLTR ? -1 : 1);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
case "ArrowRight": {
|
|
160
|
+
deltaX = this.step * (this.isLTR ? 1 : -1);
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
case "PageUp": {
|
|
164
|
+
deltaY = step * 10;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
case "PageDown": {
|
|
168
|
+
deltaY = step * -10;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
case "Home": {
|
|
172
|
+
deltaX = step * (this.isLTR ? -10 : 10);
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
case "End": {
|
|
176
|
+
deltaX = step * (this.isLTR ? 10 : -10);
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
if (deltaX !== 0) {
|
|
182
|
+
this.activeAxis = "x";
|
|
183
|
+
this.inputX.focus();
|
|
184
|
+
} else if (deltaY !== 0) {
|
|
185
|
+
this.activeAxis = "y";
|
|
186
|
+
this.inputY.focus();
|
|
187
|
+
}
|
|
188
|
+
this.x = Math.min(1, Math.max(this.x + deltaX, 0));
|
|
189
|
+
this.y = Math.min(1, Math.max(this.y + deltaY, 0));
|
|
190
|
+
this.colorController.savePreviousColor();
|
|
191
|
+
if (deltaX !== 0 || deltaY !== 0) {
|
|
192
|
+
this._valueChanged = true;
|
|
193
|
+
this.dispatchEvent(
|
|
194
|
+
new Event("input", {
|
|
195
|
+
bubbles: true,
|
|
196
|
+
composed: true
|
|
197
|
+
})
|
|
198
|
+
);
|
|
199
|
+
const applyDefault = this.dispatchEvent(
|
|
200
|
+
new Event("change", {
|
|
201
|
+
bubbles: true,
|
|
202
|
+
composed: true,
|
|
203
|
+
cancelable: true
|
|
204
|
+
})
|
|
205
|
+
);
|
|
206
|
+
if (!applyDefault) {
|
|
207
|
+
this.colorController.restorePreviousColor();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
handleKeyup(event) {
|
|
212
|
+
event.preventDefault();
|
|
213
|
+
const { code } = event;
|
|
214
|
+
this.activeKeys.delete(code);
|
|
215
|
+
}
|
|
216
|
+
handleInput(event) {
|
|
217
|
+
const { valueAsNumber, name } = event.target;
|
|
218
|
+
this[name] = valueAsNumber;
|
|
219
|
+
}
|
|
220
|
+
handleChange(event) {
|
|
221
|
+
this.handleInput(event);
|
|
222
|
+
this.dispatchEvent(
|
|
223
|
+
new Event("change", {
|
|
224
|
+
bubbles: true,
|
|
225
|
+
composed: true,
|
|
226
|
+
cancelable: true
|
|
227
|
+
})
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
handlePointerdown(event) {
|
|
231
|
+
if (event.button !== 0) {
|
|
232
|
+
event.preventDefault();
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
this._pointerDown = true;
|
|
236
|
+
this.colorController.savePreviousColor();
|
|
237
|
+
this.boundingClientRect = this.getBoundingClientRect();
|
|
238
|
+
event.target.setPointerCapture(event.pointerId);
|
|
239
|
+
if (event.pointerType === "mouse") {
|
|
240
|
+
this.focused = true;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
handlePointermove(event) {
|
|
244
|
+
const [x, y] = this.calculateHandlePosition(event);
|
|
245
|
+
this._valueChanged = false;
|
|
246
|
+
this.x = x;
|
|
247
|
+
this.y = y;
|
|
248
|
+
this.dispatchEvent(
|
|
249
|
+
new Event("input", {
|
|
250
|
+
bubbles: true,
|
|
251
|
+
composed: true,
|
|
252
|
+
cancelable: true
|
|
253
|
+
})
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
handlePointerup(event) {
|
|
257
|
+
event.preventDefault();
|
|
258
|
+
this._pointerDown = false;
|
|
259
|
+
event.target.releasePointerCapture(event.pointerId);
|
|
260
|
+
const applyDefault = this.dispatchEvent(
|
|
261
|
+
new Event("change", {
|
|
262
|
+
bubbles: true,
|
|
263
|
+
composed: true,
|
|
264
|
+
cancelable: true
|
|
265
|
+
})
|
|
266
|
+
);
|
|
267
|
+
this.inputX.focus();
|
|
268
|
+
if (event.pointerType === "mouse") {
|
|
269
|
+
this.focused = false;
|
|
270
|
+
}
|
|
271
|
+
if (!applyDefault) {
|
|
272
|
+
this.colorController.restorePreviousColor();
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Returns the value under the cursor
|
|
277
|
+
* @param: PointerEvent on slider
|
|
278
|
+
* @return: Slider value that correlates to the position under the pointer
|
|
279
|
+
*/
|
|
280
|
+
calculateHandlePosition(event) {
|
|
281
|
+
if (!this.boundingClientRect) {
|
|
282
|
+
return [this.x, this.y];
|
|
283
|
+
}
|
|
284
|
+
const rect = this.boundingClientRect;
|
|
285
|
+
const minOffsetX = rect.left;
|
|
286
|
+
const minOffsetY = rect.top;
|
|
287
|
+
const offsetX = event.clientX;
|
|
288
|
+
const offsetY = event.clientY;
|
|
289
|
+
const width = rect.width;
|
|
290
|
+
const height = rect.height;
|
|
291
|
+
const percentX = Math.max(0, Math.min(1, (offsetX - minOffsetX) / width));
|
|
292
|
+
const percentY = Math.max(0, Math.min(1, (offsetY - minOffsetY) / height));
|
|
293
|
+
return [this.isLTR ? percentX : 1 - percentX, 1 - percentY];
|
|
294
|
+
}
|
|
295
|
+
handleAreaPointerdown(event) {
|
|
296
|
+
if (event.button !== 0) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
event.stopPropagation();
|
|
300
|
+
event.preventDefault();
|
|
301
|
+
this.handle.dispatchEvent(new PointerEvent("pointerdown", event));
|
|
302
|
+
this.handlePointermove(event);
|
|
303
|
+
}
|
|
304
|
+
render() {
|
|
305
|
+
const { width = 0, height = 0 } = this.boundingClientRect || {};
|
|
306
|
+
const isMobile = platform.isAndroid() || platform.isIOS();
|
|
307
|
+
const defaultAriaLabel = "Color Picker";
|
|
308
|
+
const ariaLabel = defaultAriaLabel;
|
|
309
|
+
const ariaRoleDescription = ifDefined_js.ifDefined(isMobile ? void 0 : "2d slider");
|
|
310
|
+
const ariaLabelX = this.labelX;
|
|
311
|
+
const ariaLabelY = this.labelY;
|
|
312
|
+
const ariaValueX = new Intl.NumberFormat(this.languageResolver.language, {
|
|
313
|
+
style: "percent",
|
|
314
|
+
unitDisplay: "narrow"
|
|
315
|
+
}).format(this.x);
|
|
316
|
+
const ariaValueY = new Intl.NumberFormat(this.languageResolver.language, {
|
|
317
|
+
style: "percent",
|
|
318
|
+
unitDisplay: "narrow"
|
|
319
|
+
}).format(this.y);
|
|
320
|
+
const style = {
|
|
321
|
+
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%);`
|
|
322
|
+
};
|
|
323
|
+
return lit.html`
|
|
19
324
|
<div
|
|
20
325
|
@pointerdown=${this.handleAreaPointerdown}
|
|
21
326
|
class="gradient"
|
|
22
|
-
style="background: ${
|
|
327
|
+
style="background: ${style.background}"
|
|
23
328
|
>
|
|
24
329
|
<slot name="gradient"></slot>
|
|
25
330
|
</div>
|
|
26
331
|
|
|
27
332
|
<luzmo-color-handle
|
|
28
|
-
tabindex=${
|
|
333
|
+
tabindex=${ifDefined_js.ifDefined(this.focused ? void 0 : "0")}
|
|
29
334
|
@focus=${this.forwardFocus}
|
|
30
335
|
?focused=${this.focused}
|
|
31
336
|
class="handle"
|
|
32
337
|
color=${this.colorController.getHslString()}
|
|
33
338
|
?disabled=${this.disabled}
|
|
34
|
-
style=${`transform: translate(${(this.isLTR?this.x:1-this.x)*
|
|
35
|
-
${
|
|
339
|
+
style=${`transform: translate(${(this.isLTR ? this.x : 1 - this.x) * width}px, ${height - this.y * height}px);`}
|
|
340
|
+
${streamingListener.streamingListener({
|
|
341
|
+
start: ["pointerdown", this.handlePointerdown],
|
|
342
|
+
streamInside: ["pointermove", this.handlePointermove],
|
|
343
|
+
end: [
|
|
344
|
+
["pointerup", "pointercancel", "pointerleave"],
|
|
345
|
+
this.handlePointerup
|
|
346
|
+
]
|
|
347
|
+
})}
|
|
36
348
|
></luzmo-color-handle>
|
|
37
349
|
|
|
38
350
|
<fieldset
|
|
39
351
|
class="fieldset"
|
|
40
|
-
aria-label=${
|
|
352
|
+
aria-label=${ifDefined_js.ifDefined(isMobile ? ariaLabel : void 0)}
|
|
41
353
|
>
|
|
42
354
|
<div role="presentation">
|
|
43
355
|
<input
|
|
44
356
|
type="range"
|
|
45
357
|
class="slider"
|
|
46
358
|
name="x"
|
|
47
|
-
aria-label=${
|
|
48
|
-
aria-roledescription=${
|
|
359
|
+
aria-label=${isMobile ? ariaLabelX : `${ariaLabelX} ${ariaLabel}`}
|
|
360
|
+
aria-roledescription=${ariaRoleDescription}
|
|
49
361
|
aria-orientation="horizontal"
|
|
50
|
-
aria-valuetext=${
|
|
362
|
+
aria-valuetext=${isMobile ? ariaValueX : `${ariaValueX}, ${ariaLabelX}${this._valueChanged ? "" : `, ${ariaValueY}, ${ariaLabelY}`}`}
|
|
51
363
|
min="0"
|
|
52
364
|
max="1"
|
|
53
365
|
step=${this.step}
|
|
@@ -62,10 +374,10 @@
|
|
|
62
374
|
type="range"
|
|
63
375
|
class="slider"
|
|
64
376
|
name="y"
|
|
65
|
-
aria-label=${
|
|
66
|
-
aria-roledescription=${
|
|
377
|
+
aria-label=${isMobile ? ariaLabelY : `${ariaLabelY} ${ariaLabel}`}
|
|
378
|
+
aria-roledescription=${ariaRoleDescription}
|
|
67
379
|
aria-orientation="vertical"
|
|
68
|
-
aria-valuetext=${
|
|
380
|
+
aria-valuetext=${isMobile ? ariaValueY : `${ariaValueY}, ${ariaLabelY}${this._valueChanged ? "" : `, ${ariaValueX}, ${ariaLabelX}`}`}
|
|
69
381
|
orient="vertical"
|
|
70
382
|
min="0"
|
|
71
383
|
max="1"
|
|
@@ -77,4 +389,119 @@
|
|
|
77
389
|
/>
|
|
78
390
|
</div>
|
|
79
391
|
</fieldset>
|
|
80
|
-
|
|
392
|
+
`;
|
|
393
|
+
}
|
|
394
|
+
firstUpdated(changed) {
|
|
395
|
+
super.firstUpdated(changed);
|
|
396
|
+
this.boundingClientRect = this.getBoundingClientRect();
|
|
397
|
+
this.addEventListener("focus", this.handleFocus);
|
|
398
|
+
this.addEventListener("blur", this.handleBlur);
|
|
399
|
+
this.addEventListener("keyup", this.handleKeyup);
|
|
400
|
+
this.addEventListener("keydown", this.handleKeydown);
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Overrides the `updated` method to handle changes in property values.
|
|
404
|
+
*
|
|
405
|
+
* @param changed - A map of changed properties with their previous values.
|
|
406
|
+
*
|
|
407
|
+
* This method performs the following actions:
|
|
408
|
+
* - Updates the saturation (`s`) of the color if `x` has changed.
|
|
409
|
+
* - Updates the value (`v`) of the color if `y` has changed.
|
|
410
|
+
* - If the `focused` property has changed and is now true, it lazily binds
|
|
411
|
+
* the `input[type="range"]` elements in shadow roots to prevent multiple
|
|
412
|
+
* tab stops within the Color Area for certain browser settings (e.g., Webkit).
|
|
413
|
+
*/
|
|
414
|
+
updated(changed) {
|
|
415
|
+
super.updated(changed);
|
|
416
|
+
if (this.x !== this.inputX.valueAsNumber) {
|
|
417
|
+
this.colorController.color.set("s", this.inputX.valueAsNumber * 100);
|
|
418
|
+
}
|
|
419
|
+
if (this.y !== this.inputY.valueAsNumber) {
|
|
420
|
+
this.colorController.color.set(
|
|
421
|
+
"v",
|
|
422
|
+
(1 - this.inputY.valueAsNumber) * 100
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
if (changed.has("focused") && this.focused) {
|
|
426
|
+
const parentX = this.inputX.parentElement;
|
|
427
|
+
const parentY = this.inputY.parentElement;
|
|
428
|
+
if (!parentX.shadowRoot && !parentY.shadowRoot) {
|
|
429
|
+
parentX.attachShadow({ mode: "open" });
|
|
430
|
+
parentY.attachShadow({ mode: "open" });
|
|
431
|
+
const slot = '<div tabindex="-1"><slot></slot></div>';
|
|
432
|
+
parentX.shadowRoot.innerHTML = slot;
|
|
433
|
+
parentY.shadowRoot.innerHTML = slot;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
connectedCallback() {
|
|
438
|
+
var _a;
|
|
439
|
+
super.connectedCallback();
|
|
440
|
+
if (!this.observer && window.ResizeObserver) {
|
|
441
|
+
this.observer = new window.ResizeObserver((entries) => {
|
|
442
|
+
for (const entry of entries) {
|
|
443
|
+
this.boundingClientRect = entry.contentRect;
|
|
444
|
+
}
|
|
445
|
+
this.requestUpdate();
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
(_a = this.observer) == null ? void 0 : _a.observe(this);
|
|
449
|
+
}
|
|
450
|
+
disconnectedCallback() {
|
|
451
|
+
var _a;
|
|
452
|
+
(_a = this.observer) == null ? void 0 : _a.unobserve(this);
|
|
453
|
+
super.disconnectedCallback();
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
__decorateClass([
|
|
457
|
+
decorators_js.property({ type: String, reflect: true })
|
|
458
|
+
], LuzmoColorArea.prototype, "dir", 2);
|
|
459
|
+
__decorateClass([
|
|
460
|
+
decorators_js.property({ type: Boolean, reflect: true })
|
|
461
|
+
], LuzmoColorArea.prototype, "disabled", 2);
|
|
462
|
+
__decorateClass([
|
|
463
|
+
decorators_js.property({ type: Boolean, reflect: true })
|
|
464
|
+
], LuzmoColorArea.prototype, "focused", 2);
|
|
465
|
+
__decorateClass([
|
|
466
|
+
decorators_js.property({ type: String, attribute: "label-x" })
|
|
467
|
+
], LuzmoColorArea.prototype, "labelX", 2);
|
|
468
|
+
__decorateClass([
|
|
469
|
+
decorators_js.property({ type: String, attribute: "label-y" })
|
|
470
|
+
], LuzmoColorArea.prototype, "labelY", 2);
|
|
471
|
+
__decorateClass([
|
|
472
|
+
decorators_js.property({ type: Boolean, attribute: "is-ltr" })
|
|
473
|
+
], LuzmoColorArea.prototype, "isLTR", 2);
|
|
474
|
+
__decorateClass([
|
|
475
|
+
decorators_js.query(".handle")
|
|
476
|
+
], LuzmoColorArea.prototype, "handle", 2);
|
|
477
|
+
__decorateClass([
|
|
478
|
+
decorators_js.property({ type: Number })
|
|
479
|
+
], LuzmoColorArea.prototype, "hue", 1);
|
|
480
|
+
__decorateClass([
|
|
481
|
+
decorators_js.property({ type: String })
|
|
482
|
+
], LuzmoColorArea.prototype, "value", 1);
|
|
483
|
+
__decorateClass([
|
|
484
|
+
decorators_js.property({ type: String })
|
|
485
|
+
], LuzmoColorArea.prototype, "color", 1);
|
|
486
|
+
__decorateClass([
|
|
487
|
+
decorators_js.property({ attribute: false })
|
|
488
|
+
], LuzmoColorArea.prototype, "activeAxis", 2);
|
|
489
|
+
__decorateClass([
|
|
490
|
+
decorators_js.property({ type: Number })
|
|
491
|
+
], LuzmoColorArea.prototype, "x", 1);
|
|
492
|
+
__decorateClass([
|
|
493
|
+
decorators_js.property({ type: Number })
|
|
494
|
+
], LuzmoColorArea.prototype, "y", 1);
|
|
495
|
+
__decorateClass([
|
|
496
|
+
decorators_js.property({ type: Number })
|
|
497
|
+
], LuzmoColorArea.prototype, "step", 2);
|
|
498
|
+
__decorateClass([
|
|
499
|
+
decorators_js.query('[name="x"]')
|
|
500
|
+
], LuzmoColorArea.prototype, "inputX", 2);
|
|
501
|
+
__decorateClass([
|
|
502
|
+
decorators_js.query('[name="y"]')
|
|
503
|
+
], LuzmoColorArea.prototype, "inputY", 2);
|
|
504
|
+
if (!customElements.get("luzmo-color-area")) {
|
|
505
|
+
customElements.define("luzmo-color-area", LuzmoColorArea);
|
|
506
|
+
}
|
|
507
|
+
exports.LuzmoColorArea = LuzmoColorArea;
|