@hypericon/mico 0.5.3 → 0.5.5
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/dist/cjs/components/menu/menu-manager.js +10 -6
- package/dist/cjs/components/menu/menu-settings.d.ts +2 -0
- package/dist/cjs/components/menu/menu-settings.js +2 -0
- package/dist/esm/components/menu/menu-manager.js +10 -6
- package/dist/esm/components/menu/menu-settings.d.ts +2 -0
- package/dist/esm/components/menu/menu-settings.js +2 -0
- package/package.json +1 -1
|
@@ -74,10 +74,14 @@ class MenuManager {
|
|
|
74
74
|
// When the event is raised from within a dialog element,
|
|
75
75
|
// automatically set the menu to be a dialog as well.
|
|
76
76
|
// This makes menus that are opened from within a dialog automatically function correctly.
|
|
77
|
-
if (menu_settings_1.MENU_SETTINGS.DETECT_MENU_IN_DIALOG
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
if (menu_settings_1.MENU_SETTINGS.DETECT_MENU_IN_DIALOG) {
|
|
78
|
+
if ((ev === null || ev === void 0 ? void 0 : ev.target) instanceof HTMLElement && ev.target.closest("dialog")) {
|
|
79
|
+
menu_settings_1.MENU_SETTINGS.DEBUG_MENU && console.log("Menu opened from within a dialog");
|
|
80
|
+
options = options || {};
|
|
81
|
+
options.isWithinDialog = true;
|
|
82
|
+
options.asChild = true;
|
|
83
|
+
y = (_a = ev === null || ev === void 0 ? void 0 : ev.clientY) !== null && _a !== void 0 ? _a : 0; // Use clientY to position the menu within the dialog
|
|
84
|
+
}
|
|
81
85
|
}
|
|
82
86
|
const menuVnode = (0, mithril_1.default)(Menu_1.Menu, {
|
|
83
87
|
x: ev === null || ev === void 0 ? void 0 : ev.clientX,
|
|
@@ -107,7 +111,7 @@ class MenuManager {
|
|
|
107
111
|
else {
|
|
108
112
|
mithril_1.default.render(this.containerEl, menuVnode);
|
|
109
113
|
}
|
|
110
|
-
|
|
114
|
+
menu_settings_1.MENU_SETTINGS.DEBUG_MENU && console.log("Added menu");
|
|
111
115
|
});
|
|
112
116
|
}
|
|
113
117
|
hide() {
|
|
@@ -119,7 +123,7 @@ class MenuManager {
|
|
|
119
123
|
this.directParentEl = undefined;
|
|
120
124
|
(_b = this.dialogEl) === null || _b === void 0 ? void 0 : _b.close();
|
|
121
125
|
mithril_1.default.render(this.dialogEl, []);
|
|
122
|
-
|
|
126
|
+
menu_settings_1.MENU_SETTINGS.DEBUG_MENU && console.log("Closed menu");
|
|
123
127
|
}
|
|
124
128
|
/**
|
|
125
129
|
* Set the default behavior for whether menus are added as children of the element that raised the event.
|
|
@@ -12,4 +12,6 @@ exports.MENU_SETTINGS = {
|
|
|
12
12
|
AS_CHILD: false, // Default to not adding the menu as a child of the element that raised the event
|
|
13
13
|
/** Automatically display menus differently when opened from within a dialog */
|
|
14
14
|
DETECT_MENU_IN_DIALOG: true,
|
|
15
|
+
/** Enable debug logging */
|
|
16
|
+
DEBUG_MENU: false,
|
|
15
17
|
};
|
|
@@ -74,10 +74,14 @@ class MenuManager {
|
|
|
74
74
|
// When the event is raised from within a dialog element,
|
|
75
75
|
// automatically set the menu to be a dialog as well.
|
|
76
76
|
// This makes menus that are opened from within a dialog automatically function correctly.
|
|
77
|
-
if (menu_settings_1.MENU_SETTINGS.DETECT_MENU_IN_DIALOG
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
if (menu_settings_1.MENU_SETTINGS.DETECT_MENU_IN_DIALOG) {
|
|
78
|
+
if ((ev === null || ev === void 0 ? void 0 : ev.target) instanceof HTMLElement && ev.target.closest("dialog")) {
|
|
79
|
+
menu_settings_1.MENU_SETTINGS.DEBUG_MENU && console.log("Menu opened from within a dialog");
|
|
80
|
+
options = options || {};
|
|
81
|
+
options.isWithinDialog = true;
|
|
82
|
+
options.asChild = true;
|
|
83
|
+
y = (_a = ev === null || ev === void 0 ? void 0 : ev.clientY) !== null && _a !== void 0 ? _a : 0; // Use clientY to position the menu within the dialog
|
|
84
|
+
}
|
|
81
85
|
}
|
|
82
86
|
const menuVnode = (0, mithril_1.default)(Menu_1.Menu, {
|
|
83
87
|
x: ev === null || ev === void 0 ? void 0 : ev.clientX,
|
|
@@ -107,7 +111,7 @@ class MenuManager {
|
|
|
107
111
|
else {
|
|
108
112
|
mithril_1.default.render(this.containerEl, menuVnode);
|
|
109
113
|
}
|
|
110
|
-
|
|
114
|
+
menu_settings_1.MENU_SETTINGS.DEBUG_MENU && console.log("Added menu");
|
|
111
115
|
});
|
|
112
116
|
}
|
|
113
117
|
hide() {
|
|
@@ -119,7 +123,7 @@ class MenuManager {
|
|
|
119
123
|
this.directParentEl = undefined;
|
|
120
124
|
(_b = this.dialogEl) === null || _b === void 0 ? void 0 : _b.close();
|
|
121
125
|
mithril_1.default.render(this.dialogEl, []);
|
|
122
|
-
|
|
126
|
+
menu_settings_1.MENU_SETTINGS.DEBUG_MENU && console.log("Closed menu");
|
|
123
127
|
}
|
|
124
128
|
/**
|
|
125
129
|
* Set the default behavior for whether menus are added as children of the element that raised the event.
|
|
@@ -12,4 +12,6 @@ exports.MENU_SETTINGS = {
|
|
|
12
12
|
AS_CHILD: false, // Default to not adding the menu as a child of the element that raised the event
|
|
13
13
|
/** Automatically display menus differently when opened from within a dialog */
|
|
14
14
|
DETECT_MENU_IN_DIALOG: true,
|
|
15
|
+
/** Enable debug logging */
|
|
16
|
+
DEBUG_MENU: false,
|
|
15
17
|
};
|