@rogieking/figui3 6.7.4 → 6.8.0
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/base.css +3 -0
- package/components.css +17 -14
- package/dist/base.css +1 -1
- package/dist/components.css +1 -1
- package/dist/fig.css +1 -1
- package/dist/fig.js +18 -18
- package/fig.js +34 -10
- package/package.json +1 -1
package/fig.js
CHANGED
|
@@ -6606,9 +6606,11 @@ class FigField extends HTMLElement {
|
|
|
6606
6606
|
#boundFocus = null;
|
|
6607
6607
|
#boundLabelEnter = null;
|
|
6608
6608
|
#boundLabelLeave = null;
|
|
6609
|
+
#childrenObserver = null;
|
|
6609
6610
|
|
|
6610
6611
|
constructor() {
|
|
6611
6612
|
super();
|
|
6613
|
+
this.#boundToggle = this.#toggle.bind(this);
|
|
6612
6614
|
this.#boundFocus = this.focus.bind(this);
|
|
6613
6615
|
this.#boundLabelEnter = this.#onLabelEnter.bind(this);
|
|
6614
6616
|
this.#boundLabelLeave = this.#onLabelLeave.bind(this);
|
|
@@ -6620,14 +6622,34 @@ class FigField extends HTMLElement {
|
|
|
6620
6622
|
|
|
6621
6623
|
connectedCallback() {
|
|
6622
6624
|
queueMicrotask(() => {
|
|
6623
|
-
if (this.isConnected)
|
|
6625
|
+
if (!this.isConnected) return;
|
|
6626
|
+
this.#setup();
|
|
6627
|
+
this.#observeChildren();
|
|
6628
|
+
});
|
|
6629
|
+
}
|
|
6630
|
+
|
|
6631
|
+
#observeChildren() {
|
|
6632
|
+
if (this.#childrenObserver || typeof MutationObserver === "undefined") return;
|
|
6633
|
+
this.#childrenObserver = new MutationObserver(() => {
|
|
6634
|
+
this.#setup();
|
|
6624
6635
|
});
|
|
6636
|
+
this.#childrenObserver.observe(this, { childList: true });
|
|
6625
6637
|
}
|
|
6626
6638
|
|
|
6627
6639
|
#setup() {
|
|
6640
|
+
const previousLabel = this.label;
|
|
6641
|
+
const previousChevron = this.#chevron;
|
|
6642
|
+
previousLabel?.removeEventListener("click", this.#boundToggle);
|
|
6643
|
+
previousLabel?.removeEventListener("click", this.#boundFocus);
|
|
6644
|
+
previousLabel?.removeEventListener("pointerenter", this.#boundLabelEnter);
|
|
6645
|
+
previousLabel?.removeEventListener("pointerleave", this.#boundLabelLeave);
|
|
6646
|
+
previousChevron?.removeEventListener("click", this.#boundToggle);
|
|
6647
|
+
|
|
6628
6648
|
this.label = this.querySelector(":scope>label");
|
|
6629
6649
|
this.input = Array.from(this.childNodes).find((node) =>
|
|
6630
|
-
node.
|
|
6650
|
+
node.nodeType === Node.ELEMENT_NODE &&
|
|
6651
|
+
node.nodeName.toLowerCase().startsWith("fig-") &&
|
|
6652
|
+
!(node instanceof Element && node.classList.contains("fig-field-chevron")),
|
|
6631
6653
|
);
|
|
6632
6654
|
|
|
6633
6655
|
this.#toggleable = !!(this.input && "open" in this.input);
|
|
@@ -6641,17 +6663,9 @@ class FigField extends HTMLElement {
|
|
|
6641
6663
|
this.insertBefore(this.#chevron, this.label);
|
|
6642
6664
|
}
|
|
6643
6665
|
|
|
6644
|
-
this.#boundToggle = (e) => {
|
|
6645
|
-
e.preventDefault();
|
|
6646
|
-
e.stopPropagation();
|
|
6647
|
-
if (this.input && typeof this.input.open !== "undefined") {
|
|
6648
|
-
this.input.open = !this.input.open;
|
|
6649
|
-
}
|
|
6650
|
-
};
|
|
6651
6666
|
this.#chevron.addEventListener("click", this.#boundToggle);
|
|
6652
6667
|
this.label.addEventListener("click", this.#boundToggle);
|
|
6653
6668
|
} else if (this.input && this.label) {
|
|
6654
|
-
this.label.removeEventListener("click", this.#boundFocus);
|
|
6655
6669
|
this.label.addEventListener("click", this.#boundFocus);
|
|
6656
6670
|
}
|
|
6657
6671
|
|
|
@@ -6668,6 +6682,8 @@ class FigField extends HTMLElement {
|
|
|
6668
6682
|
}
|
|
6669
6683
|
|
|
6670
6684
|
disconnectedCallback() {
|
|
6685
|
+
this.#childrenObserver?.disconnect();
|
|
6686
|
+
this.#childrenObserver = null;
|
|
6671
6687
|
if (this.label) FigTooltip.hide(this.label);
|
|
6672
6688
|
if (this.label && this.#boundToggle) {
|
|
6673
6689
|
this.label.removeEventListener("click", this.#boundToggle);
|
|
@@ -6686,6 +6702,14 @@ class FigField extends HTMLElement {
|
|
|
6686
6702
|
}
|
|
6687
6703
|
}
|
|
6688
6704
|
|
|
6705
|
+
#toggle(e) {
|
|
6706
|
+
e.preventDefault();
|
|
6707
|
+
e.stopPropagation();
|
|
6708
|
+
if (this.input && typeof this.input.open !== "undefined") {
|
|
6709
|
+
this.input.open = !this.input.open;
|
|
6710
|
+
}
|
|
6711
|
+
}
|
|
6712
|
+
|
|
6689
6713
|
#onLabelEnter() {
|
|
6690
6714
|
if (!this.label || this.label.scrollWidth <= this.label.clientWidth) return;
|
|
6691
6715
|
FigTooltip.show(this.label, this.label.textContent.trim());
|
package/package.json
CHANGED