@rogieking/figui3 8.9.38 → 8.9.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/fig.js CHANGED
@@ -595,6 +595,7 @@ function figSupportsPopover() {
595
595
  * @attr {string} type - The button type: "button" (default), "toggle", "submit", or "link"
596
596
  * @attr {boolean} selected - Whether the button is in a selected state
597
597
  * @attr {boolean} disabled - Whether the button is disabled
598
+ * @attr {string} align - Content alignment: "start", "center" (default), or "end"
598
599
  * @attr {string} href - URL for link type buttons
599
600
  * @attr {string} target - Target window for link type buttons (e.g., "_blank")
600
601
  */
@@ -637,9 +638,9 @@ class FigButton extends HTMLElement {
637
638
  display: flex;
638
639
  border: 0;
639
640
  flex: 1;
640
- text-align: center;
641
+ text-align: var(--fig-button-text-alignment, center);
641
642
  align-items: stretch;
642
- justify-content: center;
643
+ justify-content: var(--fig-button-content-alignment, center);
643
644
  font: inherit;
644
645
  color: inherit;
645
646
  outline: 0;
@@ -7000,6 +7001,7 @@ figDefineElement("fig-input-text", FigInputText);
7000
7001
  * @attr {number} max - Maximum value
7001
7002
  * @attr {number} step - Step increment
7002
7003
  * @attr {number} transform - A multiplier for displayed number values
7004
+ * @attr {number} precision - Fixed decimal places when set
7003
7005
  * @attr {string} units - Unit string to append/prepend to displayed value (e.g., "%", "°", "$")
7004
7006
  * @attr {string} units-disallow - Comma-separated units to disallow (defaults to "px")
7005
7007
  * @attr {string} unit-position - Position of unit: "suffix" (default) or "prefix"
@@ -7175,7 +7177,7 @@ class FigInputNumber extends HTMLElement {
7175
7177
  this.#setUnitsFromAttributes();
7176
7178
  this.#unitPosition = this.getAttribute("unit-position") || "suffix";
7177
7179
  this.#precision = this.#normalizePrecision(
7178
- this.hasAttribute("precision") ? this.getAttribute("precision") : 2,
7180
+ this.hasAttribute("precision") ? this.getAttribute("precision") : null,
7179
7181
  );
7180
7182
 
7181
7183
  if (this.getAttribute("step")) {
@@ -7565,21 +7567,27 @@ class FigInputNumber extends HTMLElement {
7565
7567
  if (typeof this.max === "number") {
7566
7568
  sanitized = Math.min(this.max, sanitized);
7567
7569
  }
7568
- sanitized = this.#formatNumber(sanitized);
7570
+ sanitized = this.#roundNumber(sanitized);
7569
7571
  return sanitized;
7570
7572
  }
7571
7573
 
7572
7574
  #formatNumber(num) {
7573
7575
  const precision = this.#precision ?? 2;
7574
- const factor = Math.pow(10, precision);
7575
- const rounded = Math.round(num * factor) / factor;
7576
- // Only show decimals if needed and up to precision
7576
+ const rounded = this.#roundNumber(num);
7577
+ if (this.#precision !== null) return rounded.toFixed(precision);
7577
7578
  return Number.isInteger(rounded)
7578
- ? rounded
7579
- : parseFloat(rounded.toFixed(precision));
7579
+ ? String(rounded)
7580
+ : String(parseFloat(rounded.toFixed(precision)));
7581
+ }
7582
+
7583
+ #roundNumber(num) {
7584
+ const precision = this.#precision ?? 2;
7585
+ const factor = Math.pow(10, precision);
7586
+ return Math.round(num * factor) / factor;
7580
7587
  }
7581
7588
 
7582
7589
  #normalizePrecision(value) {
7590
+ if (value === null || value === undefined || value === "") return null;
7583
7591
  const parsed = Number(value);
7584
7592
  if (!Number.isFinite(parsed)) return 2;
7585
7593
  return Math.max(0, Math.min(100, Math.trunc(parsed)));
@@ -7674,7 +7682,7 @@ class FigInputNumber extends HTMLElement {
7674
7682
  }
7675
7683
  case "precision":
7676
7684
  this.#precision = this.#normalizePrecision(
7677
- newValue !== null ? newValue : 2,
7685
+ newValue,
7678
7686
  );
7679
7687
  this.input.value = this.#formatWithUnit(this.value);
7680
7688
  this.#syncSpinbuttonAria();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "8.9.38",
3
+ "version": "8.9.40",
4
4
  "description": "A lightweight web components library for building Figma plugin and widget UIs with native look and feel",
5
5
  "author": "Rogie King",
6
6
  "license": "SEE LICENSE IN LICENSE",