@rogieking/figui3 3.20.1 → 3.20.3
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/fig.js +47 -23
- package/package.json +1 -1
package/fig.js
CHANGED
|
@@ -3533,8 +3533,8 @@ class FigInputText extends HTMLElement {
|
|
|
3533
3533
|
valueTransformed = this.#formatNumber(valueTransformed);
|
|
3534
3534
|
this.value = value;
|
|
3535
3535
|
this.input.value = valueTransformed;
|
|
3536
|
-
this.dispatchEvent(new CustomEvent("input", { bubbles: true }));
|
|
3537
|
-
this.dispatchEvent(new CustomEvent("change", { bubbles: true }));
|
|
3536
|
+
this.dispatchEvent(new CustomEvent("input", { detail: this.value, bubbles: true }));
|
|
3537
|
+
this.dispatchEvent(new CustomEvent("change", { detail: this.value, bubbles: true }));
|
|
3538
3538
|
}
|
|
3539
3539
|
#handleMouseDown(e) {
|
|
3540
3540
|
if (this.type !== "number") return;
|
|
@@ -4023,8 +4023,8 @@ class FigInputNumber extends HTMLElement {
|
|
|
4023
4023
|
value = this.#sanitizeInput(value, false);
|
|
4024
4024
|
this.value = value;
|
|
4025
4025
|
this.input.value = this.#formatWithUnit(this.value);
|
|
4026
|
-
this.dispatchEvent(new CustomEvent("input", { bubbles: true }));
|
|
4027
|
-
this.dispatchEvent(new CustomEvent("change", { bubbles: true }));
|
|
4026
|
+
this.dispatchEvent(new CustomEvent("input", { detail: this.value, bubbles: true }));
|
|
4027
|
+
this.dispatchEvent(new CustomEvent("change", { detail: this.value, bubbles: true }));
|
|
4028
4028
|
}
|
|
4029
4029
|
|
|
4030
4030
|
#handleMouseDown(e) {
|
|
@@ -4801,18 +4801,18 @@ class FigInputColor extends HTMLElement {
|
|
|
4801
4801
|
}
|
|
4802
4802
|
|
|
4803
4803
|
#emitInputEvent() {
|
|
4804
|
-
|
|
4804
|
+
this.dispatchEvent(new CustomEvent("input", {
|
|
4805
4805
|
bubbles: true,
|
|
4806
4806
|
cancelable: true,
|
|
4807
|
-
|
|
4808
|
-
|
|
4807
|
+
detail: { value: this.value, hex: this.hex, rgba: this.rgba },
|
|
4808
|
+
}));
|
|
4809
4809
|
}
|
|
4810
4810
|
#emitChangeEvent() {
|
|
4811
|
-
|
|
4811
|
+
this.dispatchEvent(new CustomEvent("change", {
|
|
4812
4812
|
bubbles: true,
|
|
4813
4813
|
cancelable: true,
|
|
4814
|
-
|
|
4815
|
-
|
|
4814
|
+
detail: { value: this.value, hex: this.hex, rgba: this.rgba },
|
|
4815
|
+
}));
|
|
4816
4816
|
}
|
|
4817
4817
|
|
|
4818
4818
|
static get observedAttributes() {
|
|
@@ -6260,12 +6260,13 @@ class FigInputGradient extends HTMLElement {
|
|
|
6260
6260
|
return this.#gradient.stops
|
|
6261
6261
|
.map(
|
|
6262
6262
|
(stop, i) =>
|
|
6263
|
-
`<fig-tooltip action="manual" text="${Math.round(stop.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color" color="${stop.color}" value="${stop.position}% 50%" data-stop-index="${i}"${disabled ? " disabled" : ""}></fig-handle></fig-tooltip>`,
|
|
6263
|
+
`<fig-tooltip action="manual" text="${Math.round(stop.position)}%"><fig-handle drag drag-axes="x" drag-surface=".fig-input-gradient-track" type="color" color="${stop.color}" value="${stop.position}% 50%" hit-area="4" data-stop-index="${i}"${disabled ? " disabled" : ""}></fig-handle></fig-tooltip>`,
|
|
6264
6264
|
)
|
|
6265
6265
|
.join("");
|
|
6266
6266
|
}
|
|
6267
6267
|
|
|
6268
6268
|
#ghostHandle = null;
|
|
6269
|
+
#addedOnPointerDown = false;
|
|
6269
6270
|
|
|
6270
6271
|
#render() {
|
|
6271
6272
|
const disabled = this.hasAttribute("disabled");
|
|
@@ -6301,22 +6302,14 @@ class FigInputGradient extends HTMLElement {
|
|
|
6301
6302
|
|
|
6302
6303
|
const ghost = document.createElement("fig-handle");
|
|
6303
6304
|
ghost.classList.add("fig-input-gradient-ghost");
|
|
6305
|
+
ghost.setAttribute("type", "color");
|
|
6306
|
+
ghost.setAttribute("control", "add");
|
|
6304
6307
|
ghost.style.position = "absolute";
|
|
6305
6308
|
ghost.style.top = "50%";
|
|
6306
6309
|
ghost.style.transform = "translate(-50%, -50%)";
|
|
6307
6310
|
ghost.style.pointerEvents = "none";
|
|
6308
6311
|
ghost.style.opacity = "0";
|
|
6309
6312
|
ghost.style.transition = "opacity 0.15s";
|
|
6310
|
-
ghost.style.overflow = "visible";
|
|
6311
|
-
|
|
6312
|
-
const tip = document.createElement("fig-color-tip");
|
|
6313
|
-
tip.setAttribute("control", "add");
|
|
6314
|
-
tip.style.position = "absolute";
|
|
6315
|
-
tip.style.bottom = "calc(100% + 6px)";
|
|
6316
|
-
tip.style.left = "50%";
|
|
6317
|
-
tip.style.transform = "translateX(-50%)";
|
|
6318
|
-
tip.style.zIndex = "10";
|
|
6319
|
-
ghost.appendChild(tip);
|
|
6320
6313
|
|
|
6321
6314
|
this.#track.appendChild(ghost);
|
|
6322
6315
|
this.#ghostHandle = ghost;
|
|
@@ -6392,6 +6385,10 @@ class FigInputGradient extends HTMLElement {
|
|
|
6392
6385
|
#onTrackClick = (e) => {
|
|
6393
6386
|
if (!this.#track) return;
|
|
6394
6387
|
if (this.#handleDragging) return;
|
|
6388
|
+
if (this.#addedOnPointerDown) {
|
|
6389
|
+
this.#addedOnPointerDown = false;
|
|
6390
|
+
return;
|
|
6391
|
+
}
|
|
6395
6392
|
if (e.target.closest("fig-handle:not(.fig-input-gradient-ghost)")) {
|
|
6396
6393
|
if (e.shiftKey) {
|
|
6397
6394
|
const clickedHandle = e.target.closest("fig-handle");
|
|
@@ -6524,6 +6521,7 @@ class FigInputGradient extends HTMLElement {
|
|
|
6524
6521
|
if (e.target.closest("fig-handle:not(.fig-input-gradient-ghost)")) return;
|
|
6525
6522
|
if (e.button !== 0) return;
|
|
6526
6523
|
e.preventDefault();
|
|
6524
|
+
e.stopPropagation();
|
|
6527
6525
|
|
|
6528
6526
|
const trackRect = this.#track.getBoundingClientRect();
|
|
6529
6527
|
const pct = Math.max(0, Math.min(1, (e.clientX - trackRect.left) / trackRect.width));
|
|
@@ -6534,6 +6532,7 @@ class FigInputGradient extends HTMLElement {
|
|
|
6534
6532
|
const newIndex = this.#gradient.stops.findIndex(
|
|
6535
6533
|
(s) => s.position === position && s.color === color,
|
|
6536
6534
|
);
|
|
6535
|
+
this.#addedOnPointerDown = true;
|
|
6537
6536
|
this.#syncHandles();
|
|
6538
6537
|
this.#syncChit();
|
|
6539
6538
|
this.#emitInput();
|
|
@@ -6544,6 +6543,9 @@ class FigInputGradient extends HTMLElement {
|
|
|
6544
6543
|
);
|
|
6545
6544
|
const newHandle = handles[newIndex];
|
|
6546
6545
|
if (newHandle) {
|
|
6546
|
+
this.#track.querySelectorAll("fig-handle:not(.fig-input-gradient-ghost)").forEach((h) => {
|
|
6547
|
+
if (h !== newHandle) h.deselect();
|
|
6548
|
+
});
|
|
6547
6549
|
newHandle.select();
|
|
6548
6550
|
newHandle.dispatchEvent(new PointerEvent("pointerdown", {
|
|
6549
6551
|
bubbles: true,
|
|
@@ -6561,6 +6563,15 @@ class FigInputGradient extends HTMLElement {
|
|
|
6561
6563
|
const handle = e.target.closest("fig-handle");
|
|
6562
6564
|
if (!handle) return;
|
|
6563
6565
|
e.stopPropagation();
|
|
6566
|
+
if (e.detail?.color) {
|
|
6567
|
+
const idx = parseInt(handle.dataset.stopIndex, 10);
|
|
6568
|
+
if (!isNaN(idx) && this.#gradient.stops[idx]) {
|
|
6569
|
+
this.#gradient.stops[idx].color = e.detail.color;
|
|
6570
|
+
this.#syncChit();
|
|
6571
|
+
this.#emitInput();
|
|
6572
|
+
}
|
|
6573
|
+
return;
|
|
6574
|
+
}
|
|
6564
6575
|
if (!this.#handleDragging) handle.style.zIndex = "5";
|
|
6565
6576
|
this.#handleDragging = true;
|
|
6566
6577
|
const idx = parseInt(handle.dataset.stopIndex, 10);
|
|
@@ -6603,6 +6614,15 @@ class FigInputGradient extends HTMLElement {
|
|
|
6603
6614
|
const handle = e.target.closest("fig-handle");
|
|
6604
6615
|
if (!handle) return;
|
|
6605
6616
|
e.stopPropagation();
|
|
6617
|
+
if (e.detail?.color) {
|
|
6618
|
+
const idx = parseInt(handle.dataset.stopIndex, 10);
|
|
6619
|
+
if (!isNaN(idx) && this.#gradient.stops[idx]) {
|
|
6620
|
+
this.#gradient.stops[idx].color = e.detail.color;
|
|
6621
|
+
this.#syncChit();
|
|
6622
|
+
this.#emitChange();
|
|
6623
|
+
}
|
|
6624
|
+
return;
|
|
6625
|
+
}
|
|
6606
6626
|
handle.style.zIndex = "";
|
|
6607
6627
|
const tooltip = handle.closest("fig-tooltip");
|
|
6608
6628
|
if (tooltip) tooltip.removeAttribute("show");
|
|
@@ -9615,6 +9635,7 @@ class FigInputJoystick extends HTMLElement {
|
|
|
9615
9635
|
new CustomEvent("input", {
|
|
9616
9636
|
bubbles: true,
|
|
9617
9637
|
cancelable: true,
|
|
9638
|
+
detail: { value: this.value, x: this.position.x, y: this.position.y },
|
|
9618
9639
|
}),
|
|
9619
9640
|
);
|
|
9620
9641
|
}
|
|
@@ -9624,6 +9645,7 @@ class FigInputJoystick extends HTMLElement {
|
|
|
9624
9645
|
new CustomEvent("change", {
|
|
9625
9646
|
bubbles: true,
|
|
9626
9647
|
cancelable: true,
|
|
9648
|
+
detail: { value: this.value, x: this.position.x, y: this.position.y },
|
|
9627
9649
|
}),
|
|
9628
9650
|
);
|
|
9629
9651
|
}
|
|
@@ -10086,6 +10108,7 @@ class FigInputAngle extends HTMLElement {
|
|
|
10086
10108
|
new CustomEvent("input", {
|
|
10087
10109
|
bubbles: true,
|
|
10088
10110
|
cancelable: true,
|
|
10111
|
+
detail: { value: this.value, angle: this.angle },
|
|
10089
10112
|
}),
|
|
10090
10113
|
);
|
|
10091
10114
|
}
|
|
@@ -10095,6 +10118,7 @@ class FigInputAngle extends HTMLElement {
|
|
|
10095
10118
|
new CustomEvent("change", {
|
|
10096
10119
|
bubbles: true,
|
|
10097
10120
|
cancelable: true,
|
|
10121
|
+
detail: { value: this.value, angle: this.angle },
|
|
10098
10122
|
}),
|
|
10099
10123
|
);
|
|
10100
10124
|
}
|
|
@@ -14476,7 +14500,7 @@ class FigHandle extends HTMLElement {
|
|
|
14476
14500
|
document.addEventListener("keydown", this.#handleKeyDown);
|
|
14477
14501
|
const initial = this.getAttribute("value");
|
|
14478
14502
|
if (initial) this.#applyValue(initial);
|
|
14479
|
-
if (this.#hasControlMode
|
|
14503
|
+
if (this.#hasControlMode) this.#showColorTip();
|
|
14480
14504
|
}
|
|
14481
14505
|
|
|
14482
14506
|
disconnectedCallback() {
|
|
@@ -14540,7 +14564,7 @@ class FigHandle extends HTMLElement {
|
|
|
14540
14564
|
if (name === "value" && !this.#applyingValue && !this.#isDragging) {
|
|
14541
14565
|
this.#applyValue(value);
|
|
14542
14566
|
}
|
|
14543
|
-
if (name === "control"
|
|
14567
|
+
if (name === "control") {
|
|
14544
14568
|
if (this.#hasControlMode) {
|
|
14545
14569
|
this.#hideColorTip();
|
|
14546
14570
|
this.#showColorTip();
|
package/package.json
CHANGED