aleman 1.1.20 → 1.1.22

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.
@@ -13,8 +13,8 @@ export const listener = ({event, state, options}) => {
13
13
  return {
14
14
  command: 'show',
15
15
  position: {
16
- left: event.clientX,
17
- top: event.clientY - 14,
16
+ x: event.clientX,
17
+ y: event.clientY - 14,
18
18
  },
19
19
  };
20
20
  };
@@ -5,8 +5,6 @@ import * as down from './down.js';
5
5
  import * as up from './up.js';
6
6
  import * as f9 from './f9.js';
7
7
  import * as enter from './enter.js';
8
- import * as mouseEnter from './mouse-enter.js';
9
- import * as itemClick from './item-click.js';
10
8
 
11
9
  export const addons = [
12
10
  contextMenu,
@@ -16,6 +14,4 @@ export const addons = [
16
14
  up,
17
15
  f9,
18
16
  enter,
19
- mouseEnter,
20
- itemClick,
21
17
  ];
@@ -1,7 +1,10 @@
1
- export const name = 'menu';
2
- export const events = ['click'];
1
+ export const createItemClick = (name) => ({
2
+ name,
3
+ events: ['click'],
4
+ listener,
5
+ });
3
6
 
4
- export const listener = ({event, options}) => {
7
+ const listener = ({event, options}) => {
5
8
  const menuItemElement = document.elementFromPoint(event.clientX, event.clientY);
6
9
  const name = menuItemElement.textContent.trim();
7
10
  const {menu} = options;
@@ -1,5 +1,7 @@
1
- export const name = 'menu';
2
- export const events = ['mouseenter'];
3
- export const listener = () => ({
4
- index: -1,
1
+ export const createMouseEnter = (name) => ({
2
+ name,
3
+ events: ['mouseenter'],
4
+ listener: () => ({
5
+ index: -1,
6
+ }),
5
7
  });
@@ -2,6 +2,8 @@ import {rules} from './rules/index.js';
2
2
  import {hydrate} from '../aleman/index.js';
3
3
  import {initState} from './state.js';
4
4
  import {addons} from './addons/index.js';
5
+ import {createMouseEnter} from './addons/mouse-enter.js';
6
+ import {createItemClick} from './addons/item-click.js';
5
7
 
6
8
  const {assign} = Object;
7
9
 
@@ -14,7 +16,11 @@ export const hydrateMenu = (element, options, menu) => {
14
16
  const {run} = hydrate(element, {
15
17
  options,
16
18
  state,
17
- addons,
19
+ addons: [
20
+ createMouseEnter(options.name),
21
+ createItemClick(options.name),
22
+ ...addons,
23
+ ],
18
24
  rules,
19
25
  stateName: `aleman-state-${options.name}`,
20
26
  });
@@ -1,8 +1,6 @@
1
- import {operator, types} from 'putout';
1
+ import {operator} from 'putout';
2
2
  import {checkDataName} from '../check-data-name.js';
3
3
 
4
- const {isJSXElement} = types;
5
-
6
4
  const {setLiteralValue} = operator;
7
5
 
8
6
  export const report = ({command}) => {
@@ -51,4 +49,3 @@ export const traverse = ({push, options}) => ({
51
49
  }
52
50
  },
53
51
  });
54
-
@@ -71,4 +71,3 @@ function unselect(path) {
71
71
  setLiteralValue(value, value.value.replace(' menu-item-selected', ''));
72
72
  }
73
73
  }
74
-
@@ -11,8 +11,8 @@ const {setLiteralValue} = operator;
11
11
 
12
12
  export const report = () => `Set position`;
13
13
 
14
- export const fix = ({path, attr, left, top}) => {
15
- const style = `left: ${left}px; top: ${top}px;`;
14
+ export const fix = ({path, attr, x, y}) => {
15
+ const style = `left: ${x}px; top: ${y}px;`;
16
16
 
17
17
  if (attr) {
18
18
  setLiteralValue(attr.value, style);
@@ -30,7 +30,7 @@ export const fix = ({path, attr, left, top}) => {
30
30
  export const traverse = ({options, push}) => ({
31
31
  JSXOpeningElement(path) {
32
32
  const {name = 'menu', position = {}} = options;
33
- const {left = 0, top = 20} = position;
33
+ const {x = 0, y = 20} = position;
34
34
 
35
35
  if (!checkDataName(path.parentPath, name))
36
36
  return;
@@ -39,24 +39,24 @@ export const traverse = ({options, push}) => ({
39
39
  if (attr.name.name !== 'style')
40
40
  continue;
41
41
 
42
- const [x, y] = parsePosition(attr.value.value);
42
+ const [x1, y1] = parsePosition(attr.value.value);
43
43
 
44
- if (x === left && y === top)
44
+ if (x === x1 && y === y1)
45
45
  return;
46
46
 
47
47
  push({
48
48
  path,
49
49
  attr,
50
- left,
51
- top,
50
+ x,
51
+ y,
52
52
  });
53
53
  return;
54
54
  }
55
55
 
56
56
  push({
57
57
  path,
58
- left,
59
- top,
58
+ x,
59
+ y,
60
60
  });
61
61
  },
62
62
  });
@@ -15,7 +15,7 @@ export const fix = ({path}) => {
15
15
 
16
16
  export const traverse = ({push, options}) => ({
17
17
  JSXOpeningElement(path) {
18
- const {index} = options;
18
+ const {index, name} = options;
19
19
 
20
20
  if (index !== -1)
21
21
  return;
package/menu/state.js CHANGED
@@ -9,8 +9,8 @@ export const initState = ({menu, name = 'menu'}) => {
9
9
  index: -1,
10
10
  count,
11
11
  position: {
12
- left: 0,
13
- top: 20,
12
+ x: 0,
13
+ y: 20,
14
14
  },
15
15
  };
16
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aleman",
3
- "version": "1.1.20",
3
+ "version": "1.1.22",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout-based framework for web",