@rogieking/figui3 3.9.1 → 3.9.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/README.md +6 -2
- package/components.css +30 -4
- package/dist/fig.js +24 -24
- package/fig.js +50 -12
- package/package.json +1 -1
package/fig.js
CHANGED
|
@@ -8620,9 +8620,10 @@ customElements.define("fig-joystick", FigInputJoystick);
|
|
|
8620
8620
|
* @attr {number} value - The current angle of the handle in degrees.
|
|
8621
8621
|
* @attr {number} precision - The number of decimal places for the output.
|
|
8622
8622
|
* @attr {boolean} text - Whether to display a text input for the angle value.
|
|
8623
|
+
* @attr {boolean} dial - Whether to display the circular dial control. Defaults to true.
|
|
8623
8624
|
* @attr {number} adjacent - The adjacent value of the angle.
|
|
8624
8625
|
* @attr {number} opposite - The opposite value of the angle.
|
|
8625
|
-
* @attr {boolean}
|
|
8626
|
+
* @attr {boolean} rotations - Whether to display a rotation count (×N) when rotations > 1. Defaults to false.
|
|
8626
8627
|
*/
|
|
8627
8628
|
class FigInputAngle extends HTMLElement {
|
|
8628
8629
|
// Private fields
|
|
@@ -8645,6 +8646,7 @@ class FigInputAngle extends HTMLElement {
|
|
|
8645
8646
|
this.units = "°";
|
|
8646
8647
|
this.min = null;
|
|
8647
8648
|
this.max = null;
|
|
8649
|
+
this.dial = true;
|
|
8648
8650
|
this.showRotations = false;
|
|
8649
8651
|
this.rotationSpan = null;
|
|
8650
8652
|
|
|
@@ -8667,7 +8669,8 @@ class FigInputAngle extends HTMLElement {
|
|
|
8667
8669
|
this.max = this.hasAttribute("max")
|
|
8668
8670
|
? Number(this.getAttribute("max"))
|
|
8669
8671
|
: null;
|
|
8670
|
-
this.
|
|
8672
|
+
this.dial = this.#readBooleanAttribute("dial", true);
|
|
8673
|
+
this.showRotations = this.#readRotationsEnabled();
|
|
8671
8674
|
|
|
8672
8675
|
this.#render();
|
|
8673
8676
|
this.#setupListeners();
|
|
@@ -8690,14 +8693,38 @@ class FigInputAngle extends HTMLElement {
|
|
|
8690
8693
|
this.innerHTML = this.#getInnerHTML();
|
|
8691
8694
|
}
|
|
8692
8695
|
|
|
8696
|
+
#readBooleanAttribute(name, defaultValue = false) {
|
|
8697
|
+
const value = this.getAttribute(name);
|
|
8698
|
+
if (value === null) return defaultValue;
|
|
8699
|
+
const normalized = value.trim().toLowerCase();
|
|
8700
|
+
if (normalized === "" || normalized === "true") return true;
|
|
8701
|
+
if (normalized === "false") return false;
|
|
8702
|
+
return true;
|
|
8703
|
+
}
|
|
8704
|
+
|
|
8705
|
+
#readRotationsEnabled() {
|
|
8706
|
+
if (this.hasAttribute("rotations")) {
|
|
8707
|
+
return this.#readBooleanAttribute("rotations", false);
|
|
8708
|
+
}
|
|
8709
|
+
// Backward-compat alias
|
|
8710
|
+
if (this.hasAttribute("show-rotations")) {
|
|
8711
|
+
return this.#readBooleanAttribute("show-rotations", false);
|
|
8712
|
+
}
|
|
8713
|
+
return false;
|
|
8714
|
+
}
|
|
8715
|
+
|
|
8693
8716
|
#getInnerHTML() {
|
|
8694
8717
|
const step = this.#getStepForUnit();
|
|
8695
8718
|
const minAttr = this.min !== null ? `min="${this.min}"` : "";
|
|
8696
8719
|
const maxAttr = this.max !== null ? `max="${this.max}"` : "";
|
|
8697
8720
|
return `
|
|
8698
|
-
|
|
8721
|
+
${
|
|
8722
|
+
this.dial
|
|
8723
|
+
? `<div class="fig-input-angle-plane" tabindex="0">
|
|
8699
8724
|
<div class="fig-input-angle-handle"></div>
|
|
8700
|
-
</div
|
|
8725
|
+
</div>`
|
|
8726
|
+
: ""
|
|
8727
|
+
}
|
|
8701
8728
|
${
|
|
8702
8729
|
this.text
|
|
8703
8730
|
? `<fig-input-number
|
|
@@ -8798,8 +8825,8 @@ class FigInputAngle extends HTMLElement {
|
|
|
8798
8825
|
this.angleInput = this.querySelector("fig-input-number[name='angle']");
|
|
8799
8826
|
this.rotationSpan = this.querySelector(".fig-input-angle-rotations");
|
|
8800
8827
|
this.#updateRotationDisplay();
|
|
8801
|
-
this.plane
|
|
8802
|
-
this.plane
|
|
8828
|
+
this.plane?.addEventListener("mousedown", this.#handleMouseDown.bind(this));
|
|
8829
|
+
this.plane?.addEventListener(
|
|
8803
8830
|
"touchstart",
|
|
8804
8831
|
this.#handleTouchStart.bind(this),
|
|
8805
8832
|
);
|
|
@@ -9025,6 +9052,8 @@ class FigInputAngle extends HTMLElement {
|
|
|
9025
9052
|
"min",
|
|
9026
9053
|
"max",
|
|
9027
9054
|
"units",
|
|
9055
|
+
"dial",
|
|
9056
|
+
"rotations",
|
|
9028
9057
|
"show-rotations",
|
|
9029
9058
|
];
|
|
9030
9059
|
}
|
|
@@ -9067,18 +9096,26 @@ class FigInputAngle extends HTMLElement {
|
|
|
9067
9096
|
case "text":
|
|
9068
9097
|
if (newValue !== oldValue) {
|
|
9069
9098
|
this.text = newValue?.toLowerCase() === "true";
|
|
9070
|
-
if (this.
|
|
9099
|
+
if (this.isConnected) {
|
|
9071
9100
|
this.#render();
|
|
9072
9101
|
this.#setupListeners();
|
|
9073
9102
|
this.#syncHandlePosition();
|
|
9074
9103
|
}
|
|
9075
9104
|
}
|
|
9076
9105
|
break;
|
|
9106
|
+
case "dial":
|
|
9107
|
+
this.dial = this.#readBooleanAttribute("dial", true);
|
|
9108
|
+
if (this.isConnected) {
|
|
9109
|
+
this.#render();
|
|
9110
|
+
this.#setupListeners();
|
|
9111
|
+
this.#syncHandlePosition();
|
|
9112
|
+
}
|
|
9113
|
+
break;
|
|
9077
9114
|
case "units": {
|
|
9078
9115
|
let units = newValue || "°";
|
|
9079
9116
|
if (units === "deg") units = "°";
|
|
9080
9117
|
this.units = units;
|
|
9081
|
-
if (this.
|
|
9118
|
+
if (this.isConnected) {
|
|
9082
9119
|
this.#render();
|
|
9083
9120
|
this.#setupListeners();
|
|
9084
9121
|
this.#syncHandlePosition();
|
|
@@ -9087,7 +9124,7 @@ class FigInputAngle extends HTMLElement {
|
|
|
9087
9124
|
}
|
|
9088
9125
|
case "min":
|
|
9089
9126
|
this.min = newValue !== null ? Number(newValue) : null;
|
|
9090
|
-
if (this.
|
|
9127
|
+
if (this.isConnected) {
|
|
9091
9128
|
this.#render();
|
|
9092
9129
|
this.#setupListeners();
|
|
9093
9130
|
this.#syncHandlePosition();
|
|
@@ -9095,15 +9132,16 @@ class FigInputAngle extends HTMLElement {
|
|
|
9095
9132
|
break;
|
|
9096
9133
|
case "max":
|
|
9097
9134
|
this.max = newValue !== null ? Number(newValue) : null;
|
|
9098
|
-
if (this.
|
|
9135
|
+
if (this.isConnected) {
|
|
9099
9136
|
this.#render();
|
|
9100
9137
|
this.#setupListeners();
|
|
9101
9138
|
this.#syncHandlePosition();
|
|
9102
9139
|
}
|
|
9103
9140
|
break;
|
|
9141
|
+
case "rotations":
|
|
9104
9142
|
case "show-rotations":
|
|
9105
|
-
this.showRotations =
|
|
9106
|
-
if (this.
|
|
9143
|
+
this.showRotations = this.#readRotationsEnabled();
|
|
9144
|
+
if (this.isConnected) {
|
|
9107
9145
|
this.#render();
|
|
9108
9146
|
this.#setupListeners();
|
|
9109
9147
|
this.#syncHandlePosition();
|
package/package.json
CHANGED