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.
- package/menu/addons/context-menu.js +2 -2
- package/menu/addons/index.js +0 -4
- package/menu/addons/item-click.js +6 -3
- package/menu/addons/mouse-enter.js +6 -4
- package/menu/hydrate-menu.js +7 -1
- package/menu/rules/menu/index.js +1 -4
- package/menu/rules/select/index.js +0 -1
- package/menu/rules/set-position/index.js +9 -9
- package/menu/rules/unselect-all/index.js +1 -1
- package/menu/state.js +2 -2
- package/package.json +1 -1
package/menu/addons/index.js
CHANGED
|
@@ -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
|
|
2
|
-
|
|
1
|
+
export const createItemClick = (name) => ({
|
|
2
|
+
name,
|
|
3
|
+
events: ['click'],
|
|
4
|
+
listener,
|
|
5
|
+
});
|
|
3
6
|
|
|
4
|
-
|
|
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;
|
package/menu/hydrate-menu.js
CHANGED
|
@@ -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
|
});
|
package/menu/rules/menu/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {operator
|
|
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
|
-
|
|
@@ -11,8 +11,8 @@ const {setLiteralValue} = operator;
|
|
|
11
11
|
|
|
12
12
|
export const report = () => `Set position`;
|
|
13
13
|
|
|
14
|
-
export const fix = ({path, attr,
|
|
15
|
-
const style = `left: ${
|
|
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 {
|
|
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 [
|
|
42
|
+
const [x1, y1] = parsePosition(attr.value.value);
|
|
43
43
|
|
|
44
|
-
if (x ===
|
|
44
|
+
if (x === x1 && y === y1)
|
|
45
45
|
return;
|
|
46
46
|
|
|
47
47
|
push({
|
|
48
48
|
path,
|
|
49
49
|
attr,
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
x,
|
|
51
|
+
y,
|
|
52
52
|
});
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
push({
|
|
57
57
|
path,
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
x,
|
|
59
|
+
y,
|
|
60
60
|
});
|
|
61
61
|
},
|
|
62
62
|
});
|
package/menu/state.js
CHANGED