@hypericon/mico 0.5.1 → 0.5.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/dist/cjs/components/menu/menu-manager.d.ts +5 -0
- package/dist/cjs/components/menu/menu-manager.js +10 -5
- package/dist/cjs/components/menu/menu-settings.d.ts +1 -0
- package/dist/cjs/components/menu/menu-settings.js +1 -0
- package/dist/esm/components/menu/menu-manager.d.ts +5 -0
- package/dist/esm/components/menu/menu-manager.js +10 -5
- package/dist/esm/components/menu/menu-settings.d.ts +1 -0
- package/dist/esm/components/menu/menu-settings.js +1 -0
- package/package.json +1 -1
|
@@ -20,5 +20,10 @@ export declare class MenuManager {
|
|
|
20
20
|
*/
|
|
21
21
|
show(ev: MouseEvent | undefined, menuContents: m.ChildArrayOrPrimitive, options?: MenuOptions): Promise<void>;
|
|
22
22
|
hide(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Set the default behavior for whether menus are added as children of the element that raised the event.
|
|
25
|
+
* @param asChild
|
|
26
|
+
*/
|
|
27
|
+
setDefaultAsChild(asChild: boolean): void;
|
|
23
28
|
}
|
|
24
29
|
export declare const menuMgr: MenuManager;
|
|
@@ -50,6 +50,7 @@ class MenuManager {
|
|
|
50
50
|
* @param menuContents
|
|
51
51
|
*/
|
|
52
52
|
show(ev, menuContents, options) {
|
|
53
|
+
var _a;
|
|
53
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
55
|
ev === null || ev === void 0 ? void 0 : ev.stopPropagation();
|
|
55
56
|
if (this.isOpen) {
|
|
@@ -67,10 +68,9 @@ class MenuManager {
|
|
|
67
68
|
]);
|
|
68
69
|
this._menuVnode.next(menuVnode);
|
|
69
70
|
// m.render(this.containerEl, menuVnode);
|
|
70
|
-
|
|
71
|
+
const asChild = (_a = options === null || options === void 0 ? void 0 : options.asChild) !== null && _a !== void 0 ? _a : menu_settings_1.MENU_SETTINGS.AS_CHILD;
|
|
72
|
+
if (asChild && (ev === null || ev === void 0 ? void 0 : ev.target) && ev.target instanceof HTMLElement) {
|
|
71
73
|
this.directParentEl = ev.target;
|
|
72
|
-
// m.render(ev.target, menuVnode);
|
|
73
|
-
// this.containerEl = ev.target;
|
|
74
74
|
this.directParentWrapperEl = document.createElement("div");
|
|
75
75
|
this.directParentEl.append(this.directParentWrapperEl);
|
|
76
76
|
mithril_1.default.render(this.directParentWrapperEl, menuVnode);
|
|
@@ -78,8 +78,6 @@ class MenuManager {
|
|
|
78
78
|
else {
|
|
79
79
|
mithril_1.default.render(this.containerEl, menuVnode);
|
|
80
80
|
}
|
|
81
|
-
// m.render(this.containerEl, menuVnode);
|
|
82
|
-
// console.log("Added menu");
|
|
83
81
|
});
|
|
84
82
|
}
|
|
85
83
|
hide() {
|
|
@@ -91,6 +89,13 @@ class MenuManager {
|
|
|
91
89
|
this.directParentEl = undefined;
|
|
92
90
|
// console.log("Closed menu");
|
|
93
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Set the default behavior for whether menus are added as children of the element that raised the event.
|
|
94
|
+
* @param asChild
|
|
95
|
+
*/
|
|
96
|
+
setDefaultAsChild(asChild) {
|
|
97
|
+
menu_settings_1.MENU_SETTINGS.AS_CHILD = asChild;
|
|
98
|
+
}
|
|
94
99
|
}
|
|
95
100
|
exports.MenuManager = MenuManager;
|
|
96
101
|
exports.menuMgr = new MenuManager();
|
|
@@ -20,5 +20,10 @@ export declare class MenuManager {
|
|
|
20
20
|
*/
|
|
21
21
|
show(ev: MouseEvent | undefined, menuContents: m.ChildArrayOrPrimitive, options?: MenuOptions): Promise<void>;
|
|
22
22
|
hide(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Set the default behavior for whether menus are added as children of the element that raised the event.
|
|
25
|
+
* @param asChild
|
|
26
|
+
*/
|
|
27
|
+
setDefaultAsChild(asChild: boolean): void;
|
|
23
28
|
}
|
|
24
29
|
export declare const menuMgr: MenuManager;
|
|
@@ -50,6 +50,7 @@ class MenuManager {
|
|
|
50
50
|
* @param menuContents
|
|
51
51
|
*/
|
|
52
52
|
show(ev, menuContents, options) {
|
|
53
|
+
var _a;
|
|
53
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
55
|
ev === null || ev === void 0 ? void 0 : ev.stopPropagation();
|
|
55
56
|
if (this.isOpen) {
|
|
@@ -67,10 +68,9 @@ class MenuManager {
|
|
|
67
68
|
]);
|
|
68
69
|
this._menuVnode.next(menuVnode);
|
|
69
70
|
// m.render(this.containerEl, menuVnode);
|
|
70
|
-
|
|
71
|
+
const asChild = (_a = options === null || options === void 0 ? void 0 : options.asChild) !== null && _a !== void 0 ? _a : menu_settings_1.MENU_SETTINGS.AS_CHILD;
|
|
72
|
+
if (asChild && (ev === null || ev === void 0 ? void 0 : ev.target) && ev.target instanceof HTMLElement) {
|
|
71
73
|
this.directParentEl = ev.target;
|
|
72
|
-
// m.render(ev.target, menuVnode);
|
|
73
|
-
// this.containerEl = ev.target;
|
|
74
74
|
this.directParentWrapperEl = document.createElement("div");
|
|
75
75
|
this.directParentEl.append(this.directParentWrapperEl);
|
|
76
76
|
mithril_1.default.render(this.directParentWrapperEl, menuVnode);
|
|
@@ -78,8 +78,6 @@ class MenuManager {
|
|
|
78
78
|
else {
|
|
79
79
|
mithril_1.default.render(this.containerEl, menuVnode);
|
|
80
80
|
}
|
|
81
|
-
// m.render(this.containerEl, menuVnode);
|
|
82
|
-
// console.log("Added menu");
|
|
83
81
|
});
|
|
84
82
|
}
|
|
85
83
|
hide() {
|
|
@@ -91,6 +89,13 @@ class MenuManager {
|
|
|
91
89
|
this.directParentEl = undefined;
|
|
92
90
|
// console.log("Closed menu");
|
|
93
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Set the default behavior for whether menus are added as children of the element that raised the event.
|
|
94
|
+
* @param asChild
|
|
95
|
+
*/
|
|
96
|
+
setDefaultAsChild(asChild) {
|
|
97
|
+
menu_settings_1.MENU_SETTINGS.AS_CHILD = asChild;
|
|
98
|
+
}
|
|
94
99
|
}
|
|
95
100
|
exports.MenuManager = MenuManager;
|
|
96
101
|
exports.menuMgr = new MenuManager();
|