@rogieking/figui3 2.12.1 → 2.12.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
@@ -1523,7 +1523,7 @@ details {
1523
1523
  display: flex;
1524
1524
  align-items: center;
1525
1525
  padding: 0 1rem 0 0;
1526
- height: var(--spacer-6);
1526
+ height: var(--spacer-5);
1527
1527
  user-select: none;
1528
1528
  color: var(--figma-color-text-secondary);
1529
1529
 
package/fig.js CHANGED
@@ -719,12 +719,15 @@ customElements.define("fig-popover", FigPopover);
719
719
  */
720
720
  class FigDialog extends HTMLDialogElement {
721
721
  #isDragging = false;
722
+ #dragPending = false;
723
+ #dragStartPos = { x: 0, y: 0 };
722
724
  #dragOffset = { x: 0, y: 0 };
723
725
  #boundPointerDown;
724
726
  #boundPointerMove;
725
727
  #boundPointerUp;
726
728
  #offset = 16; // 1rem in pixels
727
729
  #positionInitialized = false;
730
+ #dragThreshold = 3; // pixels before drag starts
728
731
 
729
732
  constructor() {
730
733
  super();
@@ -886,7 +889,7 @@ class FigDialog extends HTMLDialogElement {
886
889
  }
887
890
 
888
891
  #handlePointerDown(e) {
889
- if (!this.drag || this.#isInteractiveElement(e.target)) {
892
+ if (!this.drag) {
890
893
  return;
891
894
  }
892
895
 
@@ -901,31 +904,48 @@ class FigDialog extends HTMLDialogElement {
901
904
  }
902
905
  // No handle specified = drag from anywhere (original behavior)
903
906
 
904
- this.#isDragging = true;
905
- this.setPointerCapture(e.pointerId);
907
+ // Don't prevent default yet - just set up pending drag
908
+ // This allows clicks on interactive elements like <details> to work
909
+ this.#dragPending = true;
910
+ this.#dragStartPos.x = e.clientX;
911
+ this.#dragStartPos.y = e.clientY;
906
912
 
907
913
  // Get current position from computed style
908
914
  const rect = this.getBoundingClientRect();
909
915
 
910
- // Convert to pixel-based top/left positioning for dragging
911
- // (clears margin: auto centering)
912
- this.style.top = `${rect.top}px`;
913
- this.style.left = `${rect.left}px`;
914
- this.style.bottom = "auto";
915
- this.style.right = "auto";
916
- this.style.margin = "0";
917
-
918
916
  // Store offset from pointer to dialog top-left corner
919
917
  this.#dragOffset.x = e.clientX - rect.left;
920
918
  this.#dragOffset.y = e.clientY - rect.top;
921
919
 
922
920
  document.addEventListener("pointermove", this.#boundPointerMove);
923
921
  document.addEventListener("pointerup", this.#boundPointerUp);
924
-
925
- e.preventDefault();
926
922
  }
927
923
 
928
924
  #handlePointerMove(e) {
925
+ // Check if we should start dragging (threshold exceeded)
926
+ if (this.#dragPending && !this.#isDragging) {
927
+ const dx = Math.abs(e.clientX - this.#dragStartPos.x);
928
+ const dy = Math.abs(e.clientY - this.#dragStartPos.y);
929
+
930
+ if (dx > this.#dragThreshold || dy > this.#dragThreshold) {
931
+ // Start actual drag
932
+ this.#isDragging = true;
933
+ this.#dragPending = false;
934
+ this.setPointerCapture(e.pointerId);
935
+
936
+ // Get current position from computed style
937
+ const rect = this.getBoundingClientRect();
938
+
939
+ // Convert to pixel-based top/left positioning for dragging
940
+ // (clears margin: auto centering)
941
+ this.style.top = `${rect.top}px`;
942
+ this.style.left = `${rect.left}px`;
943
+ this.style.bottom = "auto";
944
+ this.style.right = "auto";
945
+ this.style.margin = "0";
946
+ }
947
+ }
948
+
929
949
  if (!this.#isDragging) return;
930
950
 
931
951
  // Calculate new position based on pointer position minus offset
@@ -940,10 +960,13 @@ class FigDialog extends HTMLDialogElement {
940
960
  }
941
961
 
942
962
  #handlePointerUp(e) {
943
- if (!this.#isDragging) return;
963
+ // Clean up pending or active drag
964
+ if (this.#isDragging) {
965
+ this.releasePointerCapture(e.pointerId);
966
+ }
944
967
 
945
968
  this.#isDragging = false;
946
- this.releasePointerCapture(e.pointerId);
969
+ this.#dragPending = false;
947
970
 
948
971
  document.removeEventListener("pointermove", this.#boundPointerMove);
949
972
  document.removeEventListener("pointerup", this.#boundPointerUp);
package/index.html CHANGED
@@ -686,6 +686,13 @@
686
686
  <label>Example Field</label>
687
687
  <fig-input-text placeholder="Enter text"></fig-input-text>
688
688
  </fig-field>
689
+ <details>
690
+ <summary>More options</summary>
691
+ <fig-field direction="horizontal">
692
+ <label>Advanced</label>
693
+ <fig-input-text placeholder="Advanced setting"></fig-input-text>
694
+ </fig-field>
695
+ </details>
689
696
  </fig-content>
690
697
  <footer>
691
698
  <fig-button variant="secondary"
@@ -771,6 +778,13 @@
771
778
  <li>✗ This content area (won't drag)</li>
772
779
  <li>✗ The footer below (won't drag)</li>
773
780
  </ul>
781
+ <details>
782
+ <summary>More options</summary>
783
+ <fig-field direction="horizontal">
784
+ <label>Advanced</label>
785
+ <fig-input-text placeholder="Advanced setting"></fig-input-text>
786
+ </fig-field>
787
+ </details>
774
788
  </fig-content>
775
789
  <footer>
776
790
  <fig-button close-dialog>Close</fig-button>
@@ -3351,48 +3365,45 @@ button.addEventListener('click', () => {
3351
3365
  <p class="description">A disclosure widget for expandable/collapsible content.</p>
3352
3366
 
3353
3367
  <h3>Default (Closed)</h3>
3354
- <details style="font-size: 13px; color: var(--figma-color-text);">
3355
- <summary style="cursor: pointer; padding: 8px 0;">Click to expand</summary>
3356
- <p style="padding: 8px 0 8px 16px; margin: 0; color: var(--figma-color-text-secondary);">
3368
+ <details>
3369
+ <summary>Click to expand</summary>
3370
+ <p>
3357
3371
  This is the hidden content that appears when the details element is expanded.
3358
3372
  </p>
3359
3373
  </details>
3360
3374
 
3361
3375
  <h3>Default Open</h3>
3362
- <details open
3363
- style="font-size: 13px; color: var(--figma-color-text);">
3376
+ <details open>
3364
3377
  <summary style="cursor: pointer; padding: 8px 0;">Already expanded</summary>
3365
- <p style="padding: 8px 0 8px 16px; margin: 0; color: var(--figma-color-text-secondary);">
3378
+ <p>
3366
3379
  This content is visible by default because of the <code>open</code> attribute.
3367
3380
  </p>
3368
3381
  </details>
3369
3382
 
3370
3383
  <h3>Multiple Sections</h3>
3371
3384
  <vstack style="gap: 0;">
3372
- <details
3373
- style="font-size: 13px; color: var(--figma-color-text); border-bottom: 1px solid var(--figma-color-border);">
3385
+ <details>
3374
3386
  <summary style="cursor: pointer; padding: 8px 0;">Section One</summary>
3375
- <p style="padding: 8px 0 8px 16px; margin: 0; color: var(--figma-color-text-secondary);">
3387
+ <p>
3376
3388
  Content for section one.
3377
3389
  </p>
3378
3390
  </details>
3379
- <details
3380
- style="font-size: 13px; color: var(--figma-color-text); border-bottom: 1px solid var(--figma-color-border);">
3391
+ <details>
3381
3392
  <summary style="cursor: pointer; padding: 8px 0;">Section Two</summary>
3382
- <p style="padding: 8px 0 8px 16px; margin: 0; color: var(--figma-color-text-secondary);">
3393
+ <p>
3383
3394
  Content for section two.
3384
3395
  </p>
3385
3396
  </details>
3386
- <details style="font-size: 13px; color: var(--figma-color-text);">
3397
+ <details>
3387
3398
  <summary style="cursor: pointer; padding: 8px 0;">Section Three</summary>
3388
- <p style="padding: 8px 0 8px 16px; margin: 0; color: var(--figma-color-text-secondary);">
3399
+ <p>
3389
3400
  Content for section three.
3390
3401
  </p>
3391
3402
  </details>
3392
3403
  </vstack>
3393
3404
 
3394
3405
  <h3>With Rich Content</h3>
3395
- <details style="font-size: 13px; color: var(--figma-color-text);">
3406
+ <details>
3396
3407
  <summary style="cursor: pointer; padding: 8px 0;">Advanced Settings</summary>
3397
3408
  <vstack style="padding: 8px 0 8px 16px;">
3398
3409
  <fig-field direction="horizontal"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rogieking/figui3",
3
- "version": "2.12.1",
3
+ "version": "2.12.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",