aleman 1.2.0 → 1.2.2

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,16 @@
1
+ 2025.09.02, v1.2.2
2
+
3
+ fix:
4
+ - 388bb33 menu: afterIf
5
+
6
+ 2025.09.02, v1.2.1
7
+
8
+ fix:
9
+ - b2e892b package: repository url
10
+
11
+ feature:
12
+ - cfea6cc aleman: menu: after, afterCondition
13
+
1
14
  2025.09.02, v1.2.0
2
15
 
3
16
  feature:
@@ -68,6 +68,8 @@ const createListener = ({options, addon, readState, writeState}) => (event) => {
68
68
  preventDefault,
69
69
  stopPropagation,
70
70
  filter,
71
+ after,
72
+ afterIf,
71
73
  } = addon;
72
74
 
73
75
  if (key && event.key !== key)
@@ -98,4 +100,18 @@ const createListener = ({options, addon, readState, writeState}) => (event) => {
98
100
  });
99
101
 
100
102
  writeState(newState);
103
+
104
+ const isAfterIf = !afterIf || afterIf({
105
+ state: newState,
106
+ options,
107
+ });
108
+
109
+ if (after && isAfterIf)
110
+ requestAnimationFrame(() => {
111
+ writeState(after({
112
+ event,
113
+ state: newState,
114
+ options,
115
+ }));
116
+ });
101
117
  };
package/aleman/index.js CHANGED
@@ -53,9 +53,9 @@ export const hydrate = (element, config) => {
53
53
  });
54
54
 
55
55
  return {
56
- run: (event, fn = id) => {
56
+ run: (event, addon) => {
57
57
  const state = readState();
58
- const newState = fn({
58
+ const newState = addon.listener({
59
59
  state,
60
60
  event,
61
61
  options,
@@ -66,6 +66,15 @@ export const hydrate = (element, config) => {
66
66
  ...state,
67
67
  ...newState,
68
68
  });
69
+
70
+ if (addon.afterIf?.({state: newState, options}))
71
+ requestAnimationFrame(() => {
72
+ writeState(addon.after({
73
+ event,
74
+ options,
75
+ state: newState,
76
+ }));
77
+ });
69
78
  },
70
79
  };
71
80
  };
@@ -5,6 +5,8 @@ export const createContextMenu = (name) => {
5
5
  name,
6
6
  events,
7
7
  preventDefault,
8
+ after,
9
+ afterIf,
8
10
  listener,
9
11
  };
10
12
  };
@@ -16,7 +18,7 @@ const events = [
16
18
  const preventDefault = true;
17
19
 
18
20
  const listener = ({event, state, options, writeState}) => {
19
- const {name, beforeShow} = options;
21
+ const {beforeShow} = options;
20
22
  const {x, y} = {
21
23
  x: event.clientX,
22
24
  y: event.clientY,
@@ -30,11 +32,6 @@ const listener = ({event, state, options, writeState}) => {
30
32
  },
31
33
  });
32
34
 
33
- if (is)
34
- requestAnimationFrame(() => {
35
- writeState(setPosition(name, event));
36
- }, 0);
37
-
38
35
  const command = is ? 'show' : 'hide';
39
36
 
40
37
  return {
@@ -45,3 +42,12 @@ const listener = ({event, state, options, writeState}) => {
45
42
  },
46
43
  };
47
44
  };
45
+
46
+ const after = ({event, options}) => {
47
+ const {name} = options;
48
+ return setPosition(name, event);
49
+ };
50
+
51
+ const afterIf = ({state}) => {
52
+ return state.command === 'show';
53
+ };
@@ -3,7 +3,7 @@ export const setPosition = (name, event) => {
3
3
  const {x, y} = calculate(element, event);
4
4
 
5
5
  element.style.left = `${x}px`;
6
- element.style.top = `${y - 14}px`;
6
+ element.style.top = `${y}px`;
7
7
 
8
8
  return {
9
9
  position: {
@@ -39,8 +39,8 @@ export const hydrateMenu = (elementName, {hydrateElement, options, menu}) => {
39
39
  clientY,
40
40
  };
41
41
 
42
- run(event, contextMenu.listener, options.beforeShow);
42
+ run(event, contextMenu);
43
43
  },
44
- hide: () => run({}, click.listener, 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.0",
3
+ "version": "1.2.2",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout-based framework for web",