@hypericon/mico 0.5.4 → 0.5.6

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.
@@ -76,6 +76,7 @@ class MenuManager {
76
76
  // This makes menus that are opened from within a dialog automatically function correctly.
77
77
  if (menu_settings_1.MENU_SETTINGS.DETECT_MENU_IN_DIALOG) {
78
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");
79
80
  options = options || {};
80
81
  options.isWithinDialog = true;
81
82
  options.asChild = true;
@@ -101,8 +102,8 @@ class MenuManager {
101
102
  }
102
103
  // m.render(this.containerEl, menuVnode);
103
104
  const asChild = (_b = options === null || options === void 0 ? void 0 : options.asChild) !== null && _b !== void 0 ? _b : menu_settings_1.MENU_SETTINGS.AS_CHILD;
104
- if (asChild && (ev === null || ev === void 0 ? void 0 : ev.target) && ev.target instanceof HTMLElement) {
105
- this.directParentEl = ev.target;
105
+ if (asChild && (ev === null || ev === void 0 ? void 0 : ev.target) && ev.currentTarget instanceof HTMLElement) {
106
+ this.directParentEl = ev.currentTarget;
106
107
  this.directParentWrapperEl = document.createElement("div");
107
108
  this.directParentEl.append(this.directParentWrapperEl);
108
109
  mithril_1.default.render(this.directParentWrapperEl, menuVnode);
@@ -110,7 +111,7 @@ class MenuManager {
110
111
  else {
111
112
  mithril_1.default.render(this.containerEl, menuVnode);
112
113
  }
113
- // console.log("Added menu");
114
+ menu_settings_1.MENU_SETTINGS.DEBUG_MENU && console.log("Added menu");
114
115
  });
115
116
  }
116
117
  hide() {
@@ -122,7 +123,7 @@ class MenuManager {
122
123
  this.directParentEl = undefined;
123
124
  (_b = this.dialogEl) === null || _b === void 0 ? void 0 : _b.close();
124
125
  mithril_1.default.render(this.dialogEl, []);
125
- // console.log("Closed menu");
126
+ menu_settings_1.MENU_SETTINGS.DEBUG_MENU && console.log("Closed menu");
126
127
  }
127
128
  /**
128
129
  * Set the default behavior for whether menus are added as children of the element that raised the event.
@@ -9,4 +9,6 @@ export declare const MENU_SETTINGS: {
9
9
  AS_CHILD: boolean;
10
10
  /** Automatically display menus differently when opened from within a dialog */
11
11
  DETECT_MENU_IN_DIALOG: boolean;
12
+ /** Enable debug logging */
13
+ DEBUG_MENU: boolean;
12
14
  };
@@ -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
  };
@@ -76,6 +76,7 @@ class MenuManager {
76
76
  // This makes menus that are opened from within a dialog automatically function correctly.
77
77
  if (menu_settings_1.MENU_SETTINGS.DETECT_MENU_IN_DIALOG) {
78
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");
79
80
  options = options || {};
80
81
  options.isWithinDialog = true;
81
82
  options.asChild = true;
@@ -101,8 +102,8 @@ class MenuManager {
101
102
  }
102
103
  // m.render(this.containerEl, menuVnode);
103
104
  const asChild = (_b = options === null || options === void 0 ? void 0 : options.asChild) !== null && _b !== void 0 ? _b : menu_settings_1.MENU_SETTINGS.AS_CHILD;
104
- if (asChild && (ev === null || ev === void 0 ? void 0 : ev.target) && ev.target instanceof HTMLElement) {
105
- this.directParentEl = ev.target;
105
+ if (asChild && (ev === null || ev === void 0 ? void 0 : ev.target) && ev.currentTarget instanceof HTMLElement) {
106
+ this.directParentEl = ev.currentTarget;
106
107
  this.directParentWrapperEl = document.createElement("div");
107
108
  this.directParentEl.append(this.directParentWrapperEl);
108
109
  mithril_1.default.render(this.directParentWrapperEl, menuVnode);
@@ -110,7 +111,7 @@ class MenuManager {
110
111
  else {
111
112
  mithril_1.default.render(this.containerEl, menuVnode);
112
113
  }
113
- // console.log("Added menu");
114
+ menu_settings_1.MENU_SETTINGS.DEBUG_MENU && console.log("Added menu");
114
115
  });
115
116
  }
116
117
  hide() {
@@ -122,7 +123,7 @@ class MenuManager {
122
123
  this.directParentEl = undefined;
123
124
  (_b = this.dialogEl) === null || _b === void 0 ? void 0 : _b.close();
124
125
  mithril_1.default.render(this.dialogEl, []);
125
- // console.log("Closed menu");
126
+ menu_settings_1.MENU_SETTINGS.DEBUG_MENU && console.log("Closed menu");
126
127
  }
127
128
  /**
128
129
  * Set the default behavior for whether menus are added as children of the element that raised the event.
@@ -9,4 +9,6 @@ export declare const MENU_SETTINGS: {
9
9
  AS_CHILD: boolean;
10
10
  /** Automatically display menus differently when opened from within a dialog */
11
11
  DETECT_MENU_IN_DIALOG: boolean;
12
+ /** Enable debug logging */
13
+ DEBUG_MENU: boolean;
12
14
  };
@@ -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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypericon/mico",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "description": "UI components and utilities with Mithril",
5
5
  "author": "Ed Johnson, Hypericon Ltd",
6
6
  "license": "MIT",