@rogieking/figui3 8.9.37 → 8.9.39
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 +1 -0
- package/dist/fig-lab.js +1 -1
- package/dist/fig.js +3 -3
- package/fig-lab.js +1 -1
- package/fig.js +15 -8
- package/package.json +1 -1
package/fig-lab.js
CHANGED
|
@@ -6753,7 +6753,7 @@ class PropskitWheel extends HTMLElement {
|
|
|
6753
6753
|
this.#elasticMaxPx = this.#readCssLength(
|
|
6754
6754
|
"--propskit-wheel-elastic-distance",
|
|
6755
6755
|
);
|
|
6756
|
-
const rangeRect = this
|
|
6756
|
+
const rangeRect = this.getBoundingClientRect();
|
|
6757
6757
|
if (rangeRect) {
|
|
6758
6758
|
this.#elasticRangeRect = {
|
|
6759
6759
|
left: rangeRect.left,
|
package/fig.js
CHANGED
|
@@ -7000,6 +7000,7 @@ figDefineElement("fig-input-text", FigInputText);
|
|
|
7000
7000
|
* @attr {number} max - Maximum value
|
|
7001
7001
|
* @attr {number} step - Step increment
|
|
7002
7002
|
* @attr {number} transform - A multiplier for displayed number values
|
|
7003
|
+
* @attr {number} precision - Fixed decimal places when set
|
|
7003
7004
|
* @attr {string} units - Unit string to append/prepend to displayed value (e.g., "%", "°", "$")
|
|
7004
7005
|
* @attr {string} units-disallow - Comma-separated units to disallow (defaults to "px")
|
|
7005
7006
|
* @attr {string} unit-position - Position of unit: "suffix" (default) or "prefix"
|
|
@@ -7175,7 +7176,7 @@ class FigInputNumber extends HTMLElement {
|
|
|
7175
7176
|
this.#setUnitsFromAttributes();
|
|
7176
7177
|
this.#unitPosition = this.getAttribute("unit-position") || "suffix";
|
|
7177
7178
|
this.#precision = this.#normalizePrecision(
|
|
7178
|
-
this.hasAttribute("precision") ? this.getAttribute("precision") :
|
|
7179
|
+
this.hasAttribute("precision") ? this.getAttribute("precision") : null,
|
|
7179
7180
|
);
|
|
7180
7181
|
|
|
7181
7182
|
if (this.getAttribute("step")) {
|
|
@@ -7565,21 +7566,27 @@ class FigInputNumber extends HTMLElement {
|
|
|
7565
7566
|
if (typeof this.max === "number") {
|
|
7566
7567
|
sanitized = Math.min(this.max, sanitized);
|
|
7567
7568
|
}
|
|
7568
|
-
sanitized = this.#
|
|
7569
|
+
sanitized = this.#roundNumber(sanitized);
|
|
7569
7570
|
return sanitized;
|
|
7570
7571
|
}
|
|
7571
7572
|
|
|
7572
7573
|
#formatNumber(num) {
|
|
7573
7574
|
const precision = this.#precision ?? 2;
|
|
7574
|
-
const
|
|
7575
|
-
|
|
7576
|
-
// Only show decimals if needed and up to precision
|
|
7575
|
+
const rounded = this.#roundNumber(num);
|
|
7576
|
+
if (this.#precision !== null) return rounded.toFixed(precision);
|
|
7577
7577
|
return Number.isInteger(rounded)
|
|
7578
|
-
? rounded
|
|
7579
|
-
: parseFloat(rounded.toFixed(precision));
|
|
7578
|
+
? String(rounded)
|
|
7579
|
+
: String(parseFloat(rounded.toFixed(precision)));
|
|
7580
|
+
}
|
|
7581
|
+
|
|
7582
|
+
#roundNumber(num) {
|
|
7583
|
+
const precision = this.#precision ?? 2;
|
|
7584
|
+
const factor = Math.pow(10, precision);
|
|
7585
|
+
return Math.round(num * factor) / factor;
|
|
7580
7586
|
}
|
|
7581
7587
|
|
|
7582
7588
|
#normalizePrecision(value) {
|
|
7589
|
+
if (value === null || value === undefined || value === "") return null;
|
|
7583
7590
|
const parsed = Number(value);
|
|
7584
7591
|
if (!Number.isFinite(parsed)) return 2;
|
|
7585
7592
|
return Math.max(0, Math.min(100, Math.trunc(parsed)));
|
|
@@ -7674,7 +7681,7 @@ class FigInputNumber extends HTMLElement {
|
|
|
7674
7681
|
}
|
|
7675
7682
|
case "precision":
|
|
7676
7683
|
this.#precision = this.#normalizePrecision(
|
|
7677
|
-
newValue
|
|
7684
|
+
newValue,
|
|
7678
7685
|
);
|
|
7679
7686
|
this.input.value = this.#formatWithUnit(this.value);
|
|
7680
7687
|
this.#syncSpinbuttonAria();
|
package/package.json
CHANGED