@rogieking/figui3 1.0.90 → 1.0.91

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.
Files changed (4) hide show
  1. package/example.html +1 -1
  2. package/fig.css +22 -25
  3. package/fig.js +13 -10
  4. package/package.json +1 -1
package/example.html CHANGED
@@ -40,7 +40,7 @@
40
40
  step="0.1"
41
41
  transform="100"
42
42
  type="number"
43
- style="width: 100px;"
43
+ autoresize="true"
44
44
  value="0.5"
45
45
  text="true">
46
46
  <span slot="append">%</span>
package/fig.css CHANGED
@@ -1983,30 +1983,6 @@ fig-tabs {
1983
1983
  }
1984
1984
  }
1985
1985
 
1986
- /* Text input */
1987
- fig-input-text {
1988
- display: inline-flex;
1989
- user-select: all;
1990
- gap: 0;
1991
-
1992
- &[multiline] {
1993
- display: block;
1994
- }
1995
- &[autoresize] input,
1996
- &[autoresize] textarea {
1997
- field-sizing: content;
1998
- }
1999
- &[resizable] input,
2000
- &[resizable] textarea {
2001
- resize: both;
2002
- }
2003
- &[resizable]:has(textarea[style*="width"]),
2004
- &[resizable]:has(textarea[style*="height"]),
2005
- &[resizable]:has(input[style*="width"]),
2006
- &[resizable]:has(input[style*="height"]) {
2007
- flex: unset;
2008
- }
2009
- }
2010
1986
 
2011
1987
  fig-checkbox,
2012
1988
  fig-radio {
@@ -2069,9 +2045,30 @@ fig-input-text {
2069
2045
  background-color: var(--figma-color-bg-secondary);
2070
2046
  border: 0;
2071
2047
  border-radius: var(--radius-medium);
2072
- display: flex;
2048
+ display: inline-flex;
2073
2049
  flex-wrap: nowrap;
2074
2050
  justify-content: center;
2051
+ user-select: all;
2052
+ gap: 0;
2053
+
2054
+ &[multiline] {
2055
+ display: block;
2056
+ display: flex;
2057
+ }
2058
+ &[autoresize] input,
2059
+ &[autoresize] textarea {
2060
+ field-sizing: content;
2061
+ }
2062
+ &[resizable] input,
2063
+ &[resizable] textarea {
2064
+ resize: both;
2065
+ }
2066
+ &[resizable]:has(textarea[style*="width"]),
2067
+ &[resizable]:has(textarea[style*="height"]),
2068
+ &[resizable]:has(input[style*="width"]),
2069
+ &[resizable]:has(input[style*="height"]) {
2070
+ flex: unset;
2071
+ }
2075
2072
 
2076
2073
  & label,
2077
2074
  & [slot] {
package/fig.js CHANGED
@@ -805,25 +805,28 @@ class FigSlider extends HTMLElement {
805
805
  }
806
806
  handleTextInput() {
807
807
  if (this.figInputText) {
808
- this.input.value = Number(this.figInputText.value);
809
- this.handleInput();
808
+ this.value = this.input.value = this.figInputText.value;
809
+ this.#syncProperties();
810
810
  }
811
811
  }
812
812
  #calculateNormal(value) {
813
813
  let min = Number(this.input.min);
814
814
  let max = Number(this.input.max);
815
- let val = Number(value);
815
+ let val = value;
816
816
  return (val - min) / (max - min);
817
817
  }
818
-
819
- handleInput() {
820
- let val = Number(this.input.value);
821
- this.value = val;
822
- let complete = this.#calculateNormal(val);
818
+ #syncProperties() {
819
+ let complete = this.#calculateNormal(this.value);
823
820
  let defaultValue = this.#calculateNormal(this.default);
824
821
  this.style.setProperty("--slider-complete", complete);
825
822
  this.style.setProperty("--default", defaultValue);
826
823
  this.style.setProperty("--unchanged", complete === defaultValue ? 1 : 0);
824
+ }
825
+
826
+ handleInput() {
827
+ let val = this.input.value;
828
+ this.value = val;
829
+ this.#syncProperties();
827
830
  if (this.figInputText) {
828
831
  this.figInputText.setAttribute("value", val);
829
832
  }
@@ -902,10 +905,10 @@ class FigInputText extends HTMLElement {
902
905
  this.input.focus();
903
906
  }
904
907
  #transformNumber(value) {
905
- return Number(value) * (this.transform || 1);
908
+ return value * (this.transform || 1);
906
909
  }
907
910
  #handleInput(e) {
908
- let value = Number(e.target.value);
911
+ let value = e.target.value;
909
912
  if (this.type === "number") {
910
913
  this.value = value / (this.transform || 1);
911
914
  } else {
package/package.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "1.0.90"
3
+ "version": "1.0.91"
4
4
  }