@rogieking/figui3 8.9.6 → 8.9.8
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 +14 -1
- package/dist/components.css +1 -1
- package/dist/fig.css +1 -1
- package/dist/fig.js +3 -3
- package/fig.js +42 -4
- package/package.json +1 -1
package/fig.js
CHANGED
|
@@ -18796,6 +18796,7 @@ class FigMenu extends HTMLElement {
|
|
|
18796
18796
|
#boundPopupClick;
|
|
18797
18797
|
#boundMenuKeydown;
|
|
18798
18798
|
#boundPopupClose;
|
|
18799
|
+
#boundPopupToggle;
|
|
18799
18800
|
#boundSyncOverflow = this.#syncOverflow.bind(this);
|
|
18800
18801
|
#focusedIndex = -1;
|
|
18801
18802
|
|
|
@@ -18810,6 +18811,7 @@ class FigMenu extends HTMLElement {
|
|
|
18810
18811
|
this.#boundPopupClick = this.#handlePopupClick.bind(this);
|
|
18811
18812
|
this.#boundMenuKeydown = this.#handleMenuKeydown.bind(this);
|
|
18812
18813
|
this.#boundPopupClose = this.#handlePopupClose.bind(this);
|
|
18814
|
+
this.#boundPopupToggle = this.#handlePopupToggle.bind(this);
|
|
18813
18815
|
}
|
|
18814
18816
|
|
|
18815
18817
|
get value() {
|
|
@@ -18857,10 +18859,12 @@ class FigMenu extends HTMLElement {
|
|
|
18857
18859
|
}
|
|
18858
18860
|
if (this.#popup) {
|
|
18859
18861
|
this.#popup.removeEventListener("close", this.#boundPopupClose);
|
|
18862
|
+
this.#popup.removeEventListener("toggle", this.#boundPopupToggle);
|
|
18863
|
+
this.#popup.open = false;
|
|
18860
18864
|
const items = Array.from(
|
|
18861
18865
|
this.#panel?.querySelectorAll(FIG_MENU_CHILD_SELECTOR) ?? [],
|
|
18862
18866
|
);
|
|
18863
|
-
for (const item of items) this.
|
|
18867
|
+
for (const item of items) this.append(item);
|
|
18864
18868
|
this.#popup.remove();
|
|
18865
18869
|
this.#popup = null;
|
|
18866
18870
|
this.#panel = null;
|
|
@@ -18911,12 +18915,16 @@ class FigMenu extends HTMLElement {
|
|
|
18911
18915
|
}
|
|
18912
18916
|
|
|
18913
18917
|
#createPopup() {
|
|
18918
|
+
const supportsPopover =
|
|
18919
|
+
typeof HTMLElement !== "undefined" &&
|
|
18920
|
+
"popover" in HTMLElement.prototype;
|
|
18914
18921
|
this.#popup = document.createElement("dialog", { is: "fig-popup" });
|
|
18915
18922
|
this.#popup.setAttribute("is", "fig-popup");
|
|
18916
18923
|
this.#popup.classList.add("fig-menu-popup");
|
|
18917
18924
|
this.#popup.setAttribute("theme", "menu");
|
|
18918
18925
|
this.#popup.setAttribute("role", "menu");
|
|
18919
18926
|
this.#popup.setAttribute("id", this.#popup.getAttribute("id") || figUniqueId());
|
|
18927
|
+
if (supportsPopover) this.#popup.setAttribute("popover", "manual");
|
|
18920
18928
|
|
|
18921
18929
|
const position = this.getAttribute("position") || "bottom left";
|
|
18922
18930
|
this.#popup.setAttribute("position", position);
|
|
@@ -18936,7 +18944,26 @@ class FigMenu extends HTMLElement {
|
|
|
18936
18944
|
this.#panel.setAttribute("role", "presentation");
|
|
18937
18945
|
this.#popup.appendChild(this.#panel);
|
|
18938
18946
|
this.#popup.addEventListener("close", this.#boundPopupClose);
|
|
18939
|
-
this.
|
|
18947
|
+
this.#popup.addEventListener("toggle", this.#boundPopupToggle);
|
|
18948
|
+
|
|
18949
|
+
if (supportsPopover) {
|
|
18950
|
+
(figGetOverlayRoot() ?? document.body).append(this.#popup);
|
|
18951
|
+
return;
|
|
18952
|
+
}
|
|
18953
|
+
|
|
18954
|
+
const openDialogs = [];
|
|
18955
|
+
let ancestor = this.parentElement;
|
|
18956
|
+
while (ancestor) {
|
|
18957
|
+
if (ancestor instanceof HTMLDialogElement && ancestor.open) {
|
|
18958
|
+
openDialogs.push(ancestor);
|
|
18959
|
+
}
|
|
18960
|
+
ancestor = ancestor.parentElement;
|
|
18961
|
+
}
|
|
18962
|
+
if (openDialogs.length === 1) {
|
|
18963
|
+
openDialogs[0].append(this.#popup);
|
|
18964
|
+
} else {
|
|
18965
|
+
(figGetOverlayRoot() ?? document.body).append(this.#popup);
|
|
18966
|
+
}
|
|
18940
18967
|
}
|
|
18941
18968
|
|
|
18942
18969
|
#moveItemsToPopup() {
|
|
@@ -19115,7 +19142,7 @@ class FigMenu extends HTMLElement {
|
|
|
19115
19142
|
if (this.#usesContextMenuTrigger()) return;
|
|
19116
19143
|
if (this.#isDisabled()) return;
|
|
19117
19144
|
e.stopPropagation();
|
|
19118
|
-
const popupShowing = this.#
|
|
19145
|
+
const popupShowing = this.#isPopupShowing();
|
|
19119
19146
|
if (this.open && !popupShowing) {
|
|
19120
19147
|
this.removeAttribute("open");
|
|
19121
19148
|
}
|
|
@@ -19178,7 +19205,7 @@ class FigMenu extends HTMLElement {
|
|
|
19178
19205
|
if (this.#isDisabled()) return;
|
|
19179
19206
|
if (e.currentTarget === document && e.key !== "Escape") return;
|
|
19180
19207
|
if (e.currentTarget === this && this.#popup?.contains(e.target)) return;
|
|
19181
|
-
if (!this.open || !this.#
|
|
19208
|
+
if (!this.open || !this.#isPopupShowing()) {
|
|
19182
19209
|
if (
|
|
19183
19210
|
this.#trigger?.contains(e.target) &&
|
|
19184
19211
|
(e.key === "ArrowDown" || e.key === "Enter" || e.key === " ")
|
|
@@ -19248,6 +19275,17 @@ class FigMenu extends HTMLElement {
|
|
|
19248
19275
|
this.#focusedIndex = -1;
|
|
19249
19276
|
}
|
|
19250
19277
|
|
|
19278
|
+
#handlePopupToggle(event) {
|
|
19279
|
+
if (event.newState === "closed") this.#handlePopupClose();
|
|
19280
|
+
}
|
|
19281
|
+
|
|
19282
|
+
#isPopupShowing() {
|
|
19283
|
+
return Boolean(
|
|
19284
|
+
this.#popup?.matches?.(":open") ||
|
|
19285
|
+
this.#popup?.matches?.(":popover-open"),
|
|
19286
|
+
);
|
|
19287
|
+
}
|
|
19288
|
+
|
|
19251
19289
|
#selectItem(item) {
|
|
19252
19290
|
const value = item.getAttribute("value") || item.textContent.trim();
|
|
19253
19291
|
this.setAttribute("value", value);
|
package/package.json
CHANGED