@rogieking/figui3 2.0.0 → 2.0.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/fig.js +39 -22
- package/package.json +1 -1
package/fig.js
CHANGED
|
@@ -653,14 +653,14 @@ class FigDialog extends HTMLDialogElement {
|
|
|
653
653
|
|
|
654
654
|
// Apply common styles
|
|
655
655
|
this.style.position = "fixed";
|
|
656
|
-
this.style.
|
|
656
|
+
this.style.transform = "none";
|
|
657
657
|
|
|
658
658
|
// Reset position properties
|
|
659
659
|
this.style.top = "auto";
|
|
660
660
|
this.style.bottom = "auto";
|
|
661
661
|
this.style.left = "auto";
|
|
662
662
|
this.style.right = "auto";
|
|
663
|
-
this.style.
|
|
663
|
+
this.style.margin = "0";
|
|
664
664
|
|
|
665
665
|
// Parse position attribute
|
|
666
666
|
const hasTop = position.includes("top");
|
|
@@ -676,7 +676,8 @@ class FigDialog extends HTMLDialogElement {
|
|
|
676
676
|
} else if (hasBottom) {
|
|
677
677
|
this.style.bottom = `${this.#offset}px`;
|
|
678
678
|
} else if (hasVCenter) {
|
|
679
|
-
this.style.top = "
|
|
679
|
+
this.style.top = "0";
|
|
680
|
+
this.style.bottom = "0";
|
|
680
681
|
}
|
|
681
682
|
|
|
682
683
|
// Horizontal positioning
|
|
@@ -685,16 +686,19 @@ class FigDialog extends HTMLDialogElement {
|
|
|
685
686
|
} else if (hasRight) {
|
|
686
687
|
this.style.right = `${this.#offset}px`;
|
|
687
688
|
} else if (hasHCenter) {
|
|
688
|
-
this.style.left = "
|
|
689
|
+
this.style.left = "0";
|
|
690
|
+
this.style.right = "0";
|
|
689
691
|
}
|
|
690
692
|
|
|
691
|
-
// Apply
|
|
693
|
+
// Apply margin auto for centering (works without knowing dimensions)
|
|
692
694
|
if (hasVCenter && hasHCenter) {
|
|
693
|
-
this.style.
|
|
695
|
+
this.style.margin = "auto";
|
|
694
696
|
} else if (hasVCenter) {
|
|
695
|
-
this.style.
|
|
697
|
+
this.style.marginTop = "auto";
|
|
698
|
+
this.style.marginBottom = "auto";
|
|
696
699
|
} else if (hasHCenter) {
|
|
697
|
-
this.style.
|
|
700
|
+
this.style.marginLeft = "auto";
|
|
701
|
+
this.style.marginRight = "auto";
|
|
698
702
|
}
|
|
699
703
|
|
|
700
704
|
this.#positionInitialized = true;
|
|
@@ -718,7 +722,7 @@ class FigDialog extends HTMLDialogElement {
|
|
|
718
722
|
}
|
|
719
723
|
|
|
720
724
|
#isInteractiveElement(element) {
|
|
721
|
-
//
|
|
725
|
+
// Standard HTML interactive elements
|
|
722
726
|
const interactiveSelectors = [
|
|
723
727
|
"input",
|
|
724
728
|
"button",
|
|
@@ -728,26 +732,30 @@ class FigDialog extends HTMLDialogElement {
|
|
|
728
732
|
"label",
|
|
729
733
|
'[contenteditable="true"]',
|
|
730
734
|
"[tabindex]",
|
|
731
|
-
"fig-button",
|
|
732
|
-
"fig-input-text",
|
|
733
|
-
"fig-input-number",
|
|
734
|
-
"fig-slider",
|
|
735
|
-
"fig-checkbox",
|
|
736
|
-
"fig-radio",
|
|
737
|
-
"fig-tab",
|
|
738
|
-
"fig-dropdown",
|
|
739
|
-
"fig-chit",
|
|
740
735
|
];
|
|
741
736
|
|
|
737
|
+
// Non-interactive fig-* container elements (should allow dragging)
|
|
738
|
+
const nonInteractiveFigElements = [
|
|
739
|
+
"FIG-HEADER",
|
|
740
|
+
"FIG-DIALOG",
|
|
741
|
+
"FIG-FIELD",
|
|
742
|
+
"FIG-TOOLTIP",
|
|
743
|
+
];
|
|
744
|
+
|
|
745
|
+
const isInteractive = (el) =>
|
|
746
|
+
interactiveSelectors.some((selector) => el.matches?.(selector)) ||
|
|
747
|
+
(el.tagName?.startsWith("FIG-") &&
|
|
748
|
+
!nonInteractiveFigElements.includes(el.tagName));
|
|
749
|
+
|
|
742
750
|
// Check if the element itself is interactive
|
|
743
|
-
if (
|
|
751
|
+
if (isInteractive(element)) {
|
|
744
752
|
return true;
|
|
745
753
|
}
|
|
746
754
|
|
|
747
755
|
// Check if any parent element up to the dialog is interactive
|
|
748
756
|
let parent = element.parentElement;
|
|
749
757
|
while (parent && parent !== this) {
|
|
750
|
-
if (
|
|
758
|
+
if (isInteractive(parent)) {
|
|
751
759
|
return true;
|
|
752
760
|
}
|
|
753
761
|
parent = parent.parentElement;
|
|
@@ -767,11 +775,13 @@ class FigDialog extends HTMLDialogElement {
|
|
|
767
775
|
// Get current position from computed style
|
|
768
776
|
const rect = this.getBoundingClientRect();
|
|
769
777
|
|
|
770
|
-
//
|
|
778
|
+
// Convert to pixel-based top/left positioning for dragging
|
|
779
|
+
// (clears margin: auto centering)
|
|
771
780
|
this.style.top = `${rect.top}px`;
|
|
772
781
|
this.style.left = `${rect.left}px`;
|
|
773
782
|
this.style.bottom = "auto";
|
|
774
783
|
this.style.right = "auto";
|
|
784
|
+
this.style.margin = "0";
|
|
775
785
|
|
|
776
786
|
// Store offset from pointer to dialog top-left corner
|
|
777
787
|
this.#dragOffset.x = e.clientX - rect.left;
|
|
@@ -2338,7 +2348,14 @@ class FigCheckbox extends HTMLElement {
|
|
|
2338
2348
|
if (!this.labelElement) {
|
|
2339
2349
|
this.labelElement = document.createElement("label");
|
|
2340
2350
|
this.labelElement.setAttribute("for", this.input.id);
|
|
2341
|
-
|
|
2351
|
+
}
|
|
2352
|
+
// Add to DOM if not already there and input is in the DOM
|
|
2353
|
+
if (
|
|
2354
|
+
this.labelElement &&
|
|
2355
|
+
!this.labelElement.parentNode &&
|
|
2356
|
+
this.input.parentNode
|
|
2357
|
+
) {
|
|
2358
|
+
this.input.after(this.labelElement);
|
|
2342
2359
|
}
|
|
2343
2360
|
}
|
|
2344
2361
|
|