@hypericon/mico 0.5.7 → 0.5.9
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.
|
@@ -70,6 +70,21 @@ class MenuManager {
|
|
|
70
70
|
yield new Promise((resolve, reject) => {
|
|
71
71
|
setTimeout(() => resolve(), 0);
|
|
72
72
|
});
|
|
73
|
+
// If the target is a menu button, and if the menu button was a child and not in the body container,
|
|
74
|
+
// then ignore the open and just re-hide.
|
|
75
|
+
// This is not ideal, but as the "open menu" action is being triggered by the button,
|
|
76
|
+
// for now, just ignore the "new" menu.
|
|
77
|
+
// This is a workaround for the issue where the menu is opened from a button that is a child of the menu,
|
|
78
|
+
// re-opening itself.
|
|
79
|
+
if ((ev === null || ev === void 0 ? void 0 : ev.target) instanceof HTMLElement && ev.target.closest(".mico-menu-button")) {
|
|
80
|
+
const parentEl = ev.target.parentElement;
|
|
81
|
+
// If there is *not* an ancestor with the "menu-container" class, then ignore the open
|
|
82
|
+
if (parentEl && !parentEl.closest(".menu-container")) {
|
|
83
|
+
menu_settings_1.MENU_SETTINGS.DEBUG_MENU && console.log("Ignoring menu open from button, as it is not in the menu container");
|
|
84
|
+
console.log("Ignoring new menu (current menu attached as child)");
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
73
88
|
let y = menu_settings_1.MENU_SETTINGS.ANCHOR === "page" ? ev === null || ev === void 0 ? void 0 : ev.pageY : ev === null || ev === void 0 ? void 0 : ev.clientY;
|
|
74
89
|
// When the event is raised from within a dialog element,
|
|
75
90
|
// automatically set the menu to be a dialog as well.
|
|
@@ -104,7 +119,26 @@ class MenuManager {
|
|
|
104
119
|
const asChild = (_b = options === null || options === void 0 ? void 0 : options.asChild) !== null && _b !== void 0 ? _b : menu_settings_1.MENU_SETTINGS.AS_CHILD;
|
|
105
120
|
if (asChild && (ev === null || ev === void 0 ? void 0 : ev.target) && ev.target instanceof HTMLElement) {
|
|
106
121
|
menu_settings_1.MENU_SETTINGS.DEBUG_MENU && console.log("Adding menu as child, event:", ev);
|
|
107
|
-
|
|
122
|
+
// If the target is an <i> with one of the classes "fas", "far", "fal", "fab", or "fa-*" then
|
|
123
|
+
// we want to add the menu as a child of the parent element, not the icon
|
|
124
|
+
const isIcon = ev.target.tagName === "I" && (ev.target.classList.contains("fas") ||
|
|
125
|
+
ev.target.classList.contains("far") ||
|
|
126
|
+
ev.target.classList.contains("fal") ||
|
|
127
|
+
ev.target.classList.contains("fab") ||
|
|
128
|
+
ev.target.classList.contains("fa"));
|
|
129
|
+
if (isIcon) {
|
|
130
|
+
const parentEl = ev.target.parentElement;
|
|
131
|
+
if (parentEl) {
|
|
132
|
+
this.directParentEl = parentEl;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
this.directParentEl = ev.target;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
this.directParentEl = ev.target;
|
|
140
|
+
}
|
|
141
|
+
// this.directParentEl = ev.target;
|
|
108
142
|
this.directParentWrapperEl = document.createElement("div");
|
|
109
143
|
this.directParentEl.append(this.directParentWrapperEl);
|
|
110
144
|
mithril_1.default.render(this.directParentWrapperEl, menuVnode);
|
|
@@ -70,6 +70,21 @@ class MenuManager {
|
|
|
70
70
|
yield new Promise((resolve, reject) => {
|
|
71
71
|
setTimeout(() => resolve(), 0);
|
|
72
72
|
});
|
|
73
|
+
// If the target is a menu button, and if the menu button was a child and not in the body container,
|
|
74
|
+
// then ignore the open and just re-hide.
|
|
75
|
+
// This is not ideal, but as the "open menu" action is being triggered by the button,
|
|
76
|
+
// for now, just ignore the "new" menu.
|
|
77
|
+
// This is a workaround for the issue where the menu is opened from a button that is a child of the menu,
|
|
78
|
+
// re-opening itself.
|
|
79
|
+
if ((ev === null || ev === void 0 ? void 0 : ev.target) instanceof HTMLElement && ev.target.closest(".mico-menu-button")) {
|
|
80
|
+
const parentEl = ev.target.parentElement;
|
|
81
|
+
// If there is *not* an ancestor with the "menu-container" class, then ignore the open
|
|
82
|
+
if (parentEl && !parentEl.closest(".menu-container")) {
|
|
83
|
+
menu_settings_1.MENU_SETTINGS.DEBUG_MENU && console.log("Ignoring menu open from button, as it is not in the menu container");
|
|
84
|
+
console.log("Ignoring new menu (current menu attached as child)");
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
73
88
|
let y = menu_settings_1.MENU_SETTINGS.ANCHOR === "page" ? ev === null || ev === void 0 ? void 0 : ev.pageY : ev === null || ev === void 0 ? void 0 : ev.clientY;
|
|
74
89
|
// When the event is raised from within a dialog element,
|
|
75
90
|
// automatically set the menu to be a dialog as well.
|
|
@@ -104,7 +119,26 @@ class MenuManager {
|
|
|
104
119
|
const asChild = (_b = options === null || options === void 0 ? void 0 : options.asChild) !== null && _b !== void 0 ? _b : menu_settings_1.MENU_SETTINGS.AS_CHILD;
|
|
105
120
|
if (asChild && (ev === null || ev === void 0 ? void 0 : ev.target) && ev.target instanceof HTMLElement) {
|
|
106
121
|
menu_settings_1.MENU_SETTINGS.DEBUG_MENU && console.log("Adding menu as child, event:", ev);
|
|
107
|
-
|
|
122
|
+
// If the target is an <i> with one of the classes "fas", "far", "fal", "fab", or "fa-*" then
|
|
123
|
+
// we want to add the menu as a child of the parent element, not the icon
|
|
124
|
+
const isIcon = ev.target.tagName === "I" && (ev.target.classList.contains("fas") ||
|
|
125
|
+
ev.target.classList.contains("far") ||
|
|
126
|
+
ev.target.classList.contains("fal") ||
|
|
127
|
+
ev.target.classList.contains("fab") ||
|
|
128
|
+
ev.target.classList.contains("fa"));
|
|
129
|
+
if (isIcon) {
|
|
130
|
+
const parentEl = ev.target.parentElement;
|
|
131
|
+
if (parentEl) {
|
|
132
|
+
this.directParentEl = parentEl;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
this.directParentEl = ev.target;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
this.directParentEl = ev.target;
|
|
140
|
+
}
|
|
141
|
+
// this.directParentEl = ev.target;
|
|
108
142
|
this.directParentWrapperEl = document.createElement("div");
|
|
109
143
|
this.directParentEl.append(this.directParentWrapperEl);
|
|
110
144
|
mithril_1.default.render(this.directParentWrapperEl, menuVnode);
|