aleman 1.2.0 → 1.2.1

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,11 @@
1
+ 2025.09.02, v1.2.1
2
+
3
+ fix:
4
+ - b2e892b package: repository url
5
+
6
+ feature:
7
+ - cfea6cc aleman: menu: after, afterCondition
8
+
1
9
  2025.09.02, v1.2.0
2
10
 
3
11
  feature:
@@ -68,6 +68,8 @@ const createListener = ({options, addon, readState, writeState}) => (event) => {
68
68
  preventDefault,
69
69
  stopPropagation,
70
70
  filter,
71
+ after,
72
+ conditionAfter,
71
73
  } = addon;
72
74
 
73
75
  if (key && event.key !== key)
@@ -98,4 +100,13 @@ const createListener = ({options, addon, readState, writeState}) => (event) => {
98
100
  });
99
101
 
100
102
  writeState(newState);
103
+
104
+ if (after && conditionAfter?.({state: newState, options}))
105
+ requestAnimationFrame(() => {
106
+ writeState(after({
107
+ event,
108
+ state: newState,
109
+ options,
110
+ }));
111
+ });
101
112
  };
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.conditionAfter?.({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,7 +5,9 @@ export const createContextMenu = (name) => {
5
5
  name,
6
6
  events,
7
7
  preventDefault,
8
+ after,
8
9
  listener,
10
+ conditionAfter,
9
11
  };
10
12
  };
11
13
 
@@ -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 conditionAfter = ({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, options.beforeShow);
43
43
  },
44
- hide: () => run({}, click.listener, options.beforeHide),
44
+ hide: () => run({}, click, options.beforeHide),
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.1",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout-based framework for web",