aleman 1.9.1 → 1.10.0

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/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ 2025.09.14, v1.10.0
2
+
3
+ feature:
4
+ - d50edf7 aleman: menu: do not close menu when click on submenu name
5
+
1
6
  2025.09.14, v1.9.1
2
7
 
3
8
  feature:
@@ -1,6 +1,24 @@
1
+ import jessy from 'jessy';
2
+ import {getMenuPath} from './menu/get-menu-path.js';
3
+
4
+ const isFn = (a) => typeof a === 'function';
5
+
1
6
  export const events = ['click'];
2
7
 
3
- export const filter = ({state}) => state.command === 'show';
8
+ export const filter = ({event, state, options}) => {
9
+ const {menu} = options;
10
+ const menuPath = getMenuPath(event);
11
+
12
+ if (!menuPath)
13
+ return true;
14
+
15
+ const fn = jessy(menuPath, menu);
16
+
17
+ if (!isFn(fn))
18
+ return false;
19
+
20
+ return state.command === 'show';
21
+ };
4
22
 
5
23
  export const listener = ({options, state}) => {
6
24
  options.beforeHide?.(state);
@@ -12,3 +30,4 @@ export const listener = ({options, state}) => {
12
30
  insideSubmenu: false,
13
31
  };
14
32
  };
33
+
@@ -1,12 +1,24 @@
1
1
  import jessy from 'jessy';
2
+ import {getMenuPath as _getMenuPath} from './menu/get-menu-path.js';
3
+
4
+ const isFn = (a) => typeof a === 'function';
2
5
 
3
6
  export const createItemClick = (name) => ({
4
7
  name,
5
8
  events: ['click'],
6
9
  listener,
10
+ filter,
7
11
  });
8
12
 
9
- const listener = ({event, options}) => {
13
+ const filter = ({event, options, getMenuPath = _getMenuPath}) => {
14
+ const {menu} = options;
15
+ const menuPath = getMenuPath(event);
16
+ const fn = jessy(menuPath, menu);
17
+
18
+ return isFn(fn);
19
+ };
20
+
21
+ const listener = ({event, options, getMenuPath = _getMenuPath}) => {
10
22
  const {menu} = options;
11
23
  const menuPath = getMenuPath(event);
12
24
  const fn = jessy(menuPath, menu);
@@ -21,12 +33,3 @@ const listener = ({event, options}) => {
21
33
  };
22
34
  };
23
35
 
24
- function getMenuPath(event) {
25
- let menuItemElement = document.elementFromPoint(event.clientX, event.clientY);
26
- const {menuPath} = menuItemElement.dataset;
27
-
28
- if (!menuPath)
29
- menuItemElement = menuItemElement.querySelector('[data-menu-path]');
30
-
31
- return menuItemElement.dataset.menuPath;
32
- }
@@ -0,0 +1,13 @@
1
+ export function getMenuPath(event) {
2
+ let menuItemElement = document.elementFromPoint(event.clientX, event.clientY);
3
+ const {menuPath} = menuItemElement.dataset;
4
+
5
+ if (!menuPath)
6
+ menuItemElement = menuItemElement.querySelector('[data-menu-path]');
7
+
8
+ if (!menuPath)
9
+ return '';
10
+
11
+ return menuItemElement.dataset.menuPath;
12
+ }
13
+
package/menu/menu.js CHANGED
@@ -34,11 +34,10 @@ async function loadStyle() {
34
34
  }
35
35
 
36
36
  function createLink() {
37
- const href = new URL('menu.css', import.meta.url).pathname;
38
37
  const link = document.createElement('link');
39
38
 
40
39
  link.rel = 'stylesheet';
41
- link.href = href;
40
+ link.href = new URL('menu.css', import.meta.url).pathname;
42
41
  document.head.appendChild(link);
43
42
  }
44
43
 
@@ -116,4 +115,3 @@ async function tryToCatch(fn, args) {
116
115
  return [error];
117
116
  }
118
117
  }
119
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aleman",
3
- "version": "1.9.1",
3
+ "version": "1.10.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout-based framework for web",