aleman 1.2.1 → 1.2.3

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.09.03, v1.2.3
2
+
3
+ feature:
4
+ - ae911f9 aleman: menu: key -> keys
5
+
6
+ 2025.09.02, v1.2.2
7
+
8
+ fix:
9
+ - 388bb33 menu: afterIf
10
+
1
11
  2025.09.02, v1.2.1
2
12
 
3
13
  fix:
@@ -63,16 +63,16 @@ export const addGlobalListeners = ({globalAddons, options, readState, writeState
63
63
 
64
64
  const createListener = ({options, addon, readState, writeState}) => (event) => {
65
65
  const {
66
- key,
66
+ keys,
67
67
  listener,
68
68
  preventDefault,
69
69
  stopPropagation,
70
70
  filter,
71
71
  after,
72
- conditionAfter,
72
+ afterIf,
73
73
  } = addon;
74
74
 
75
- if (key && event.key !== key)
75
+ if (keys && !keys.includes(event.key))
76
76
  return;
77
77
 
78
78
  const state = readState();
@@ -101,7 +101,12 @@ const createListener = ({options, addon, readState, writeState}) => (event) => {
101
101
 
102
102
  writeState(newState);
103
103
 
104
- if (after && conditionAfter?.({state: newState, options}))
104
+ const isAfterIf = !afterIf || afterIf({
105
+ state: newState,
106
+ options,
107
+ });
108
+
109
+ if (after && isAfterIf)
105
110
  requestAnimationFrame(() => {
106
111
  writeState(after({
107
112
  event,
package/aleman/index.js CHANGED
@@ -67,7 +67,7 @@ export const hydrate = (element, config) => {
67
67
  ...newState,
68
68
  });
69
69
 
70
- if (addon.conditionAfter?.({state: newState, options}))
70
+ if (addon.afterIf?.({state: newState, options}))
71
71
  requestAnimationFrame(() => {
72
72
  writeState(addon.after({
73
73
  event,
@@ -6,8 +6,8 @@ export const createContextMenu = (name) => {
6
6
  events,
7
7
  preventDefault,
8
8
  after,
9
+ afterIf,
9
10
  listener,
10
- conditionAfter,
11
11
  };
12
12
  };
13
13
 
@@ -48,6 +48,6 @@ const after = ({event, options}) => {
48
48
  return setPosition(name, event);
49
49
  };
50
50
 
51
- const conditionAfter = ({state}) => {
51
+ const afterIf = ({state}) => {
52
52
  return state.command === 'show';
53
53
  };
@@ -1,12 +1,13 @@
1
- const {keys} = Object;
2
-
3
- export const key = 'ArrowDown';
1
+ export const keys = [
2
+ 'ArrowDown',
3
+ 'j',
4
+ ];
4
5
  export const preventDefault = true;
5
6
 
6
7
  export const listener = ({state, options}) => {
7
8
  let {index} = state;
8
9
  const {menu} = options;
9
- const n = keys(menu).length - 1;
10
+ const n = Object.keys(menu).length - 1;
10
11
 
11
12
  if (index < n)
12
13
  ++index;
@@ -1,6 +1,6 @@
1
1
  const {values} = Object;
2
2
 
3
- export const key = 'Enter';
3
+ export const keys = ['Enter'];
4
4
 
5
5
  export const filter = ({state}) => state.command === 'show';
6
6
 
@@ -1,4 +1,4 @@
1
- export const key = 'Escape';
1
+ export const keys = ['Escape'];
2
2
 
3
3
  export const listener = ({state, options}) => {
4
4
  options.beforeHide?.(state);
package/menu/addons/up.js CHANGED
@@ -1,4 +1,7 @@
1
- export const key = 'ArrowUp';
1
+ export const keys = [
2
+ 'ArrowUp',
3
+ 'k',
4
+ ];
2
5
 
3
6
  export const preventDefault = true;
4
7
 
@@ -39,8 +39,8 @@ export const hydrateMenu = (elementName, {hydrateElement, options, menu}) => {
39
39
  clientY,
40
40
  };
41
41
 
42
- run(event, contextMenu, options.beforeShow);
42
+ run(event, contextMenu);
43
43
  },
44
- hide: () => run({}, click, options.beforeHide),
44
+ hide: () => run({}, click),
45
45
  };
46
46
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aleman",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout-based framework for web",