@rogieking/figui3 1.1.7 → 1.1.9

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 (2) hide show
  1. package/fig.js +16 -6
  2. package/package.json +1 -1
package/fig.js CHANGED
@@ -936,7 +936,11 @@ class FigInputText extends HTMLElement {
936
936
  #handleMouseMove(e) {
937
937
  if (e.altKey) {
938
938
  const step = (this.step || 1) * e.movementX;
939
- const value = this.#sanitizeInput(Number(this.value) + step).toFixed(2);
939
+ const value = this.#sanitizeInput(
940
+ Number(this.value) + step,
941
+ false
942
+ ).toFixed(2);
943
+ console.log("MM:", value, this.max);
940
944
  this.setAttribute("value", value);
941
945
  }
942
946
  }
@@ -962,15 +966,21 @@ class FigInputText extends HTMLElement {
962
966
  window.removeEventListener("pointermove", this.#boundMouseMove);
963
967
  window.removeEventListener("pointerup", this.#boundMouseUp);
964
968
  }
965
- #sanitizeInput(value) {
969
+ #sanitizeInput(value, transform = true) {
966
970
  let sanitized = value;
967
971
  if (this.type === "number") {
968
972
  sanitized = Number(sanitized);
969
973
  if (typeof this.min === "number") {
970
- sanitized = Math.max(this.#transformNumber(this.min), sanitized);
974
+ sanitized = Math.max(
975
+ transform ? this.#transformNumber(this.min) : this.min,
976
+ sanitized
977
+ );
971
978
  }
972
979
  if (typeof this.max === "number") {
973
- sanitized = Math.min(this.#transformNumber(this.max), sanitized);
980
+ sanitized = Math.min(
981
+ transform ? this.#transformNumber(this.max) : this.max,
982
+ sanitized
983
+ );
974
984
  }
975
985
  }
976
986
  return sanitized;
@@ -1246,10 +1256,10 @@ class FigInputColor extends HTMLElement {
1246
1256
  case "value":
1247
1257
  this.#setValues(newValue);
1248
1258
  if (this.#textInput) {
1249
- this.#textInput.setAttribute("value", this.hex);
1259
+ this.#textInput.setAttribute("value", this.value);
1250
1260
  }
1251
1261
  if (this.#swatch) {
1252
- this.#swatch.setAttribute("value", this.hex);
1262
+ this.#swatch.setAttribute("value", this.hexOpaque);
1253
1263
  }
1254
1264
  if (this.#alphaInput) {
1255
1265
  this.#alphaInput.setAttribute("value", this.alpha);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "devDependencies": {