@rogieking/figui3 1.9.4 → 1.9.5

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.css CHANGED
@@ -2389,7 +2389,6 @@ fig-input-color {
2389
2389
  & fig-input-text:not([type]),
2390
2390
  & fig-input-text[type="text"],
2391
2391
  & fig-input-number {
2392
- flex-basis: 6em;
2393
2392
  display: inline-flex;
2394
2393
  flex-direction: column;
2395
2394
  align-items: stretch;
@@ -2402,9 +2401,15 @@ fig-input-color {
2402
2401
 
2403
2402
  & fig-input-text[type="number"],
2404
2403
  & fig-input-number {
2405
- width: 3.5rem;
2404
+ width: 3rem;
2406
2405
  display: inline-flex;
2407
2406
  }
2407
+ & > * {
2408
+ flex: 1;
2409
+ fig-input-text {
2410
+ flex: 1;
2411
+ }
2412
+ }
2408
2413
  }
2409
2414
 
2410
2415
  fig-slider {
@@ -2416,7 +2421,7 @@ fig-slider {
2416
2421
 
2417
2422
  & fig-input-text[type="number"],
2418
2423
  & fig-input-number {
2419
- width: 3.5rem;
2424
+ width: 3rem;
2420
2425
  }
2421
2426
  }
2422
2427
 
package/example.html CHANGED
@@ -30,6 +30,8 @@
30
30
  <br /><br /><br /><br /><br /><br /><br /><br />
31
31
 
32
32
 
33
+
34
+
33
35
  <fig-field direction="horizontal">
34
36
  <label>Position</label>
35
37
  <fig-dropdown value="outside"
@@ -39,16 +41,30 @@
39
41
  <option value="outside">Outside</option>
40
42
  </fig-dropdown>
41
43
  </fig-field>
42
-
43
- <fig-field direction="horizontal">
44
- <label>Position</label>
45
- <fig-dropdown value="outside">
46
- <option value="inside">Inside</option>
47
- <option value="center">Center</option>
48
- <option value="outside">Outside</option>
49
- </fig-dropdown>
44
+ <fig-field direction="horizontal"
45
+ style="width: 320px;">
46
+ <label>Color</label>
47
+ <fig-input-color alpha="true"
48
+ full
49
+ text="true"
50
+ value="#000000"></fig-input-color>
51
+ </fig-field>
52
+ <fig-field direction="horizontal"
53
+ style="width: 320px;">
54
+ <label>Opacity</label>
55
+ <fig-slider alpha="true"
56
+ text="true"
57
+ value="50"
58
+ full
59
+ variant="neue"
60
+ min="0"
61
+ max="100"
62
+ step="1"
63
+ units="%"></fig-slider>
50
64
  </fig-field>
51
65
 
66
+ <br /><br /><br /><br /><br /><br /><br /><br />
67
+
52
68
 
53
69
 
54
70
 
package/fig.js CHANGED
@@ -1814,14 +1814,13 @@ class FigInputColor extends HTMLElement {
1814
1814
  </fig-input-text>`;
1815
1815
  if (this.getAttribute("alpha") === "true") {
1816
1816
  label += `<fig-tooltip text="Opacity">
1817
- <fig-input-text
1817
+ <fig-input-number
1818
1818
  placeholder="##"
1819
- type="number"
1820
1819
  min="0"
1821
1820
  max="100"
1822
- value="${this.alpha}">
1823
- <span slot="append">%</slot>
1824
- </fig-input-text>
1821
+ value="${this.alpha}"
1822
+ units="%">
1823
+ </fig-input-number>
1825
1824
  </fig-tooltip>`;
1826
1825
  }
1827
1826
  html = `<div class="input-combo">
@@ -1836,7 +1835,7 @@ class FigInputColor extends HTMLElement {
1836
1835
  requestAnimationFrame(() => {
1837
1836
  this.#swatch = this.querySelector("fig-chit[type=color]");
1838
1837
  this.#textInput = this.querySelector("fig-input-text:not([type=number])");
1839
- this.#alphaInput = this.querySelector("fig-input-text[type=number]");
1838
+ this.#alphaInput = this.querySelector("fig-input-number");
1840
1839
 
1841
1840
  this.#swatch.disabled = this.hasAttribute("disabled");
1842
1841
  this.#swatch.addEventListener("input", this.#handleInput.bind(this));
@@ -1898,7 +1897,9 @@ class FigInputColor extends HTMLElement {
1898
1897
  #handleAlphaInput(event) {
1899
1898
  //do not propagate to onInput handler for web component
1900
1899
  event.stopPropagation();
1901
- const alpha = Math.round((event.target.value / 100) * 255);
1900
+ // fig-input-number stores numeric value internally, ensure it's a number
1901
+ const alphaValue = Number(event.target.value) || 0;
1902
+ const alpha = Math.round((alphaValue / 100) * 255);
1902
1903
  const alphaHex = alpha.toString(16).padStart(2, "0");
1903
1904
  this.#setValues(this.hexOpaque + alphaHex);
1904
1905
  this.#emitInputEvent();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "1.9.4",
3
+ "version": "1.9.5",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "devDependencies": {