@rogieking/figui3 2.18.0 → 2.18.2

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
@@ -2486,6 +2486,11 @@ fig-input-number {
2486
2486
  }
2487
2487
  }
2488
2488
 
2489
+ fig-input-number > [slot],
2490
+ fig-input-text[type="number"] > [slot] {
2491
+ cursor: ew-resize !important;
2492
+ }
2493
+
2489
2494
  fig-input-color,
2490
2495
  fig-input-fill {
2491
2496
  & > .input-combo > fig-chit:not(:only-child),
package/fig.js CHANGED
@@ -2497,30 +2497,27 @@ class FigInputText extends HTMLElement {
2497
2497
  }
2498
2498
  #handleMouseMove(e) {
2499
2499
  if (this.type !== "number") return;
2500
- if (e.altKey) {
2501
- let step = (this.step || 1) * e.movementX;
2502
- let value = Number(this.input.value);
2503
- value = value / (this.transform || 1) + step;
2504
- value = this.#sanitizeInput(value, false);
2505
- let valueTransformed = value * (this.transform || 1);
2506
- value = this.#formatNumber(value);
2507
- valueTransformed = this.#formatNumber(valueTransformed);
2508
- this.value = value;
2509
- this.input.value = valueTransformed;
2510
- this.dispatchEvent(new CustomEvent("input", { bubbles: true }));
2511
- this.dispatchEvent(new CustomEvent("change", { bubbles: true }));
2512
- }
2500
+ let step = (this.step || 1) * e.movementX;
2501
+ let value = Number(this.input.value);
2502
+ value = value / (this.transform || 1) + step;
2503
+ value = this.#sanitizeInput(value, false);
2504
+ let valueTransformed = value * (this.transform || 1);
2505
+ value = this.#formatNumber(value);
2506
+ valueTransformed = this.#formatNumber(valueTransformed);
2507
+ this.value = value;
2508
+ this.input.value = valueTransformed;
2509
+ this.dispatchEvent(new CustomEvent("input", { bubbles: true }));
2510
+ this.dispatchEvent(new CustomEvent("change", { bubbles: true }));
2513
2511
  }
2514
2512
  #handleMouseDown(e) {
2515
2513
  if (this.type !== "number") return;
2516
- if (e.altKey) {
2514
+ if (e.altKey || e.target.closest("[slot]")) {
2517
2515
  this.#isInteracting = true;
2518
2516
  this.input.style.cursor =
2519
2517
  this.style.cursor =
2520
2518
  document.body.style.cursor =
2521
2519
  "ew-resize";
2522
2520
  this.style.userSelect = "none";
2523
- // Use the pre-bound handlers
2524
2521
  window.addEventListener("pointermove", this.#boundMouseMove);
2525
2522
  window.addEventListener("pointerup", this.#boundMouseUp);
2526
2523
  }
@@ -2533,7 +2530,6 @@ class FigInputText extends HTMLElement {
2533
2530
  document.body.style.cursor =
2534
2531
  "";
2535
2532
  this.style.userSelect = "all";
2536
- // Remove the pre-bound handlers
2537
2533
  window.removeEventListener("pointermove", this.#boundMouseMove);
2538
2534
  window.removeEventListener("pointerup", this.#boundMouseUp);
2539
2535
  }
@@ -2937,28 +2933,25 @@ class FigInputNumber extends HTMLElement {
2937
2933
 
2938
2934
  #handleMouseMove(e) {
2939
2935
  if (this.disabled) return;
2940
- if (e.altKey) {
2941
- let step = (this.step || 1) * e.movementX;
2942
- let numericValue = this.#getNumericValue(this.input.value);
2943
- let value = Number(numericValue) / (this.transform || 1) + step;
2944
- value = this.#sanitizeInput(value, false);
2945
- this.value = value;
2946
- this.input.value = this.#formatWithUnit(this.value);
2947
- this.dispatchEvent(new CustomEvent("input", { bubbles: true }));
2948
- this.dispatchEvent(new CustomEvent("change", { bubbles: true }));
2949
- }
2936
+ let step = (this.step || 1) * e.movementX;
2937
+ let numericValue = this.#getNumericValue(this.input.value);
2938
+ let value = Number(numericValue) / (this.transform || 1) + step;
2939
+ value = this.#sanitizeInput(value, false);
2940
+ this.value = value;
2941
+ this.input.value = this.#formatWithUnit(this.value);
2942
+ this.dispatchEvent(new CustomEvent("input", { bubbles: true }));
2943
+ this.dispatchEvent(new CustomEvent("change", { bubbles: true }));
2950
2944
  }
2951
2945
 
2952
2946
  #handleMouseDown(e) {
2953
2947
  if (this.disabled) return;
2954
- if (e.altKey) {
2948
+ if (e.altKey || e.target.closest("[slot]")) {
2955
2949
  this.#isInteracting = true;
2956
2950
  this.input.style.cursor =
2957
2951
  this.style.cursor =
2958
2952
  document.body.style.cursor =
2959
2953
  "ew-resize";
2960
2954
  this.style.userSelect = "none";
2961
- // Use the pre-bound handlers
2962
2955
  window.addEventListener("pointermove", this.#boundMouseMove);
2963
2956
  window.addEventListener("pointerup", this.#boundMouseUp);
2964
2957
  }
@@ -2971,7 +2964,6 @@ class FigInputNumber extends HTMLElement {
2971
2964
  document.body.style.cursor =
2972
2965
  "";
2973
2966
  this.style.userSelect = "all";
2974
- // Remove the pre-bound handlers
2975
2967
  window.removeEventListener("pointermove", this.#boundMouseMove);
2976
2968
  window.removeEventListener("pointerup", this.#boundMouseUp);
2977
2969
  }
@@ -3690,7 +3682,7 @@ class FigInputFill extends HTMLElement {
3690
3682
  placeholder="##"
3691
3683
  min="0"
3692
3684
  max="100"
3693
- value="${this.#gradient.stops[0]?.opacity || 100}"
3685
+ value="${this.#gradient.stops[0]?.opacity ?? 100}"
3694
3686
  units="%"
3695
3687
  ${disabled ? "disabled" : ""}>
3696
3688
  </fig-input-number>
@@ -3895,7 +3887,7 @@ class FigInputFill extends HTMLElement {
3895
3887
  if (this.#opacityInput) {
3896
3888
  this.#opacityInput.setAttribute(
3897
3889
  "value",
3898
- this.#gradient.stops[0]?.opacity || 100
3890
+ this.#gradient.stops[0]?.opacity ?? 100
3899
3891
  );
3900
3892
  }
3901
3893
  break;
@@ -3978,7 +3970,7 @@ class FigInputFill extends HTMLElement {
3978
3970
  placeholder="##"
3979
3971
  min="0"
3980
3972
  max="100"
3981
- value="${this.#gradient.stops[0]?.opacity || 100}"
3973
+ value="${this.#gradient.stops[0]?.opacity ?? 100}"
3982
3974
  units="%"
3983
3975
  ${disabled ? "disabled" : ""}>
3984
3976
  </fig-input-number>
@@ -6477,6 +6469,7 @@ class FigFillPicker extends HTMLElement {
6477
6469
  this.#hueSlider.addEventListener("input", (e) => {
6478
6470
  this.#color.h = parseFloat(e.target.value);
6479
6471
  this.#drawColorArea();
6472
+ this.#updateHandlePosition();
6480
6473
  this.#updateColorInputs();
6481
6474
  this.#emitInput();
6482
6475
  });
@@ -6876,8 +6869,9 @@ class FigFillPicker extends HTMLElement {
6876
6869
  .addEventListener("input", (e) => {
6877
6870
  this.#gradient.stops[index].color =
6878
6871
  e.target.hexOpaque || e.target.value;
6872
+ const parsedAlpha = parseFloat(e.target.alpha);
6879
6873
  this.#gradient.stops[index].opacity =
6880
- parseFloat(e.target.alpha) || 100;
6874
+ isNaN(parsedAlpha) ? 100 : parsedAlpha;
6881
6875
  this.#updateGradientPreview();
6882
6876
  this.#emitInput();
6883
6877
  });
package/index.html CHANGED
@@ -1268,15 +1268,18 @@
1268
1268
 
1269
1269
  <h3>Horizontal Fields with Different Inputs</h3>
1270
1270
  <p class="description">Drag the right edge to test at different widths.</p>
1271
- <div class="resize-test" style="width: 240px;">
1271
+ <div class="resize-test"
1272
+ style="width: 240px;">
1272
1273
  <fig-field direction="horizontal">
1273
1274
  <label>Text Input</label>
1274
- <fig-input-text placeholder="Enter text" full></fig-input-text>
1275
+ <fig-input-text placeholder="Enter text"
1276
+ full></fig-input-text>
1275
1277
  </fig-field>
1276
1278
  <fig-field direction="horizontal">
1277
1279
  <label>Number Input</label>
1278
1280
  <fig-input-number value="100"
1279
- units="px" full></fig-input-number>
1281
+ units="px"
1282
+ full></fig-input-number>
1280
1283
  </fig-field>
1281
1284
  <fig-field direction="horizontal">
1282
1285
  <label>Dropdown</label>
@@ -1289,22 +1292,26 @@
1289
1292
  <fig-field direction="horizontal">
1290
1293
  <label>Slider</label>
1291
1294
  <fig-slider value="50"
1292
- text="true" full></fig-slider>
1295
+ text="true"
1296
+ full></fig-slider>
1293
1297
  </fig-field>
1294
1298
  <fig-field direction="horizontal">
1295
1299
  <label>Color</label>
1296
1300
  <fig-input-color value="#0D99FF"
1297
- text="true" full></fig-input-color>
1301
+ text="true"
1302
+ full></fig-input-color>
1298
1303
  </fig-field>
1299
1304
  <fig-field direction="horizontal">
1300
1305
  <label>Angle</label>
1301
1306
  <fig-input-angle value="45"
1302
- text="true" full></fig-input-angle>
1307
+ text="true"
1308
+ full></fig-input-angle>
1303
1309
  </fig-field>
1304
1310
  <fig-field direction="horizontal">
1305
1311
  <label>Joystick</label>
1306
1312
  <fig-input-joystick text="true"
1307
- value="50,50" full></fig-input-joystick>
1313
+ value="50,50"
1314
+ full></fig-input-joystick>
1308
1315
  </fig-field>
1309
1316
  <fig-field direction="horizontal">
1310
1317
  <label>Switch</label>
@@ -1401,6 +1408,18 @@
1401
1408
  document.getElementById('fill-picker-output').textContent = 'Change: ' + JSON.stringify(e.detail);
1402
1409
  });
1403
1410
  </script>
1411
+
1412
+ <h3>Experimental</h3>
1413
+ <p class="description">Use the <code>experimental</code> attribute to pass through experimental features to
1414
+ internal <code>fig-dropdown</code> elements.</p>
1415
+
1416
+ <h4>fig-fill-picker</h4>
1417
+ <fig-fill-picker experimental="modern"
1418
+ value='{"type":"gradient","gradient":{"type":"linear","angle":135,"stops":[{"position":0,"color":"#f093fb","opacity":100},{"position":100,"color":"#f5576c","opacity":100}]}}'></fig-fill-picker>
1419
+
1420
+ <h4>fig-input-fill</h4>
1421
+ <fig-input-fill experimental="modern"
1422
+ value='{"type":"gradient","gradient":{"type":"radial","centerX":50,"centerY":50,"stops":[{"position":0,"color":"#4facfe","opacity":100},{"position":100,"color":"#00f2fe","opacity":100}]}}'></fig-input-fill>
1404
1423
  </section>
1405
1424
  <hr>
1406
1425
 
@@ -2882,7 +2901,8 @@
2882
2901
 
2883
2902
  <h3>Single-Value Position Shorthand</h3>
2884
2903
  <p class="description">Single values are supported for directional shorthand (for example:
2885
- <code>top</code>, <code>right</code>).</p>
2904
+ <code>top</code>, <code>right</code>).
2905
+ </p>
2886
2906
 
2887
2907
  <h4>Top (left edges aligned)</h4>
2888
2908
  <hstack>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "2.18.0",
3
+ "version": "2.18.2",
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": "MIT",