aleman 1.1.40 → 1.1.42

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,13 @@
1
+ 2025.08.30, v1.1.42
2
+
3
+ feature:
4
+ - 5fcb0ae aleman: menu: data-menu-path
5
+
6
+ 2025.08.30, v1.1.41
7
+
8
+ fix:
9
+ - 48a8b59 menu: stopPropagation
10
+
1
11
  2025.08.30, v1.1.40
2
12
 
3
13
  feature:
@@ -66,12 +66,10 @@ const createListener = ({options, addon, readState, writeState}) => (event) => {
66
66
  key,
67
67
  listener,
68
68
  preventDefault,
69
+ stopPropagation,
69
70
  filter,
70
71
  } = addon;
71
72
 
72
- if (preventDefault)
73
- event.preventDefault();
74
-
75
73
  if (key && event.key !== key)
76
74
  return;
77
75
 
@@ -86,6 +84,12 @@ const createListener = ({options, addon, readState, writeState}) => (event) => {
86
84
  if (filter && !is)
87
85
  return false;
88
86
 
87
+ if (preventDefault)
88
+ event.preventDefault();
89
+
90
+ if (stopPropagation)
91
+ event.stopPropagation();
92
+
89
93
  const newState = listener({
90
94
  event,
91
95
  state,
@@ -3,8 +3,7 @@ export const events = ['click'];
3
3
  export const filter = ({state}) => state.command === 'show';
4
4
 
5
5
  export const listener = ({options, state}) => {
6
- options.beforeClick?.(state);
7
- options.beforeClose?.(state);
6
+ options.beforeHide?.(state);
8
7
 
9
8
  return {
10
9
  command: 'hide',
@@ -4,12 +4,15 @@ export const key = 'Enter';
4
4
 
5
5
  export const filter = ({state}) => state.command === 'show';
6
6
 
7
+ export const stopPropagation = true;
8
+
7
9
  export const listener = ({options, state}) => {
8
10
  const {index} = state;
9
11
  const {menu} = options;
10
12
 
11
13
  const fn = values(menu)[index];
12
14
  setTimeout(fn);
15
+ options.beforeHide?.(state);
13
16
 
14
17
  return {
15
18
  command: 'hide',
@@ -1,7 +1,7 @@
1
1
  export const key = 'Escape';
2
2
 
3
- export const listener = ({options}) => {
4
- options.beforeHide?.();
3
+ export const listener = ({state, options}) => {
4
+ options.beforeHide?.(state);
5
5
  return {
6
6
  command: 'hide',
7
7
  index: -1,
@@ -11,7 +11,7 @@ const listener = ({event, options}) => {
11
11
  const fn = menu[name];
12
12
 
13
13
  setTimeout(fn);
14
- options.beforeClose?.();
14
+ options.beforeHide?.();
15
15
 
16
16
  return {
17
17
  index: -1,
@@ -1 +1 @@
1
- <ul data-name="menu" class="menu menu-hidden"><li data-name='menu-item' className='menu-item'><label>hello</label></li><li data-name='menu-item' className='menu-item'><label>world</label></li></ul>;
1
+ <ul data-name="menu" class="menu menu-hidden"><li data-name='menu-item' className='menu-item'><label data-menu-path='hello'>hello</label></li><li data-name='menu-item' className='menu-item'><label data-menu-path='world'>world</label></li></ul>;
@@ -1 +1 @@
1
- <ul data-name="menu" class="menu menu-hidden"><li data-name='menu-item' className="menu-item icon icon-hello"><label>hello</label></li><li data-name='menu-item' className="menu-item icon icon-world"><label>world</label></li></ul>;
1
+ <ul data-name="menu" class="menu menu-hidden"><li data-name='menu-item' className="menu-item icon icon-hello"><label data-menu-path='hello'>hello</label></li><li data-name='menu-item' className="menu-item icon icon-world"><label data-menu-path='world'>world</label></li></ul>;
@@ -1 +1 @@
1
- <ul data-name="menu" class="menu menu-hidden"><li data-name='menu-item' className="menu-item icon icon-hello"><label>hello</label><ul data-name='menu' className='menu menu-hidden'><li data-name='menu-item' className="menu-item icon icon-world"><label>world</label></li></ul></li></ul>;
1
+ <ul data-name="menu" class="menu menu-hidden"><li data-name='menu-item' className='menu-item icon icon-hello menu-submenu'><label data-menu-path='hello'>hello</label><ul data-name='menu' className='menu menu-hidden'><li data-name='menu-item' className="menu-item icon icon-world"><label data-menu-path='hello.world'>world</label></li></ul></li></ul>;
@@ -10,7 +10,7 @@ const isObject = (a) => a && typeof a === 'object';
10
10
  export const report = () => `Build menu`;
11
11
 
12
12
  const createMenuItem = template(`
13
- <li data-name="menu-item" className="menu-item"><label>NAME</label></li>
13
+ <li data-name="menu-item" className="menu-item"><label data-menu-path="">NAME</label></li>
14
14
  `);
15
15
 
16
16
  const createMenu = template(`
@@ -22,7 +22,7 @@ const DefaultMenu = {
22
22
  world: noop,
23
23
  };
24
24
 
25
- export const fix = ({path, menu, icon}) => {
25
+ export const fix = ({path, menu, icon, name = ''}) => {
26
26
  const {children} = path.parentPath.node;
27
27
 
28
28
  for (const [key, value] of entries(menu)) {
@@ -33,6 +33,8 @@ export const fix = ({path, menu, icon}) => {
33
33
  if (icon)
34
34
  setIcon(key, menuItem);
35
35
 
36
+ setDataMenuPath(key, name, menuItem);
37
+
36
38
  children.push(menuItem);
37
39
 
38
40
  if (isObject(value)) {
@@ -48,6 +50,7 @@ export const fix = ({path, menu, icon}) => {
48
50
  path: openingElement,
49
51
  icon,
50
52
  menu: value,
53
+ name: key,
51
54
  });
52
55
  }
53
56
  }
@@ -86,6 +89,18 @@ function setSubmenu(menuItem) {
86
89
  }
87
90
  }
88
91
 
92
+ function setDataMenuPath(key, name, menuItem) {
93
+ const {attributes} = menuItem.children[0].openingElement;
94
+ const dataMenuPath = name ? `${name}.${key}` : key;
95
+
96
+ for (const attr of attributes) {
97
+ if (attr.name.name === 'data-menu-path') {
98
+ setLiteralValue(attr.value, dataMenuPath);
99
+ break;
100
+ }
101
+ }
102
+ }
103
+
89
104
  function setIcon(name, menuItem) {
90
105
  const {attributes} = menuItem.openingElement;
91
106
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aleman",
3
- "version": "1.1.40",
3
+ "version": "1.1.42",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout-based framework for web",