@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.
@@ -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 && (ev === null || ev === void 0 ? void 0 : ev.target) instanceof HTMLElement && ev.target.closest("dialog")) {
78
- options = options || {};
79
- options.isWithinDialog = true;
80
- 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
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
- // console.log("Added menu");
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
- // console.log("Closed menu");
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.
@@ -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
  };
@@ -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 && (ev === null || ev === void 0 ? void 0 : ev.target) instanceof HTMLElement && ev.target.closest("dialog")) {
78
- options = options || {};
79
- options.isWithinDialog = true;
80
- 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
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
- // console.log("Added menu");
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
- // console.log("Closed menu");
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.
@@ -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.3",
3
+ "version": "0.5.5",
4
4
  "description": "UI components and utilities with Mithril",
5
5
  "author": "Ed Johnson, Hypericon Ltd",
6
6
  "license": "MIT",