aleman 1.1.36 → 1.1.38
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 +9 -0
- package/aleman/index.js +1 -2
- package/menu/addons/click.js +2 -4
- package/menu/addons/context-menu.js +1 -0
- package/menu/addons/enter.js +1 -3
- package/menu/addons/f9.js +3 -5
- package/menu/hydrate-menu.js +1 -0
- package/menu/importmap.json +5 -5
- package/menu/menu.js +1 -0
- package/menu/rules/build-menu/fixture/icon-fix.js +1 -1
- package/menu/rules/build-menu/fixture/nested-fix.js +1 -0
- package/menu/rules/build-menu/fixture/nested.js +1 -0
- package/menu/rules/build-menu/index.js +40 -19
- package/menu/rules/check-data-name.js +2 -4
- package/menu/rules/menu/index.js +3 -1
- package/menu/rules/select/index.js +3 -1
- package/menu/rules/set-position/index.js +3 -1
- package/menu/rules/unselect-all/index.js +3 -1
- package/package.json +1 -1
package/ChangeLog
ADDED
package/aleman/index.js
CHANGED
|
@@ -45,7 +45,7 @@ export const hydrate = (element, {addons, options, state, rules, stateName = 'al
|
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
return {
|
|
48
|
-
run: (event, fn = id
|
|
48
|
+
run: (event, fn = id) => {
|
|
49
49
|
const state = readState();
|
|
50
50
|
const newState = fn({
|
|
51
51
|
state,
|
|
@@ -60,4 +60,3 @@ export const hydrate = (element, {addons, options, state, rules, stateName = 'al
|
|
|
60
60
|
},
|
|
61
61
|
};
|
|
62
62
|
};
|
|
63
|
-
|
package/menu/addons/click.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
export const events = ['click'];
|
|
2
2
|
|
|
3
|
-
export const filter = ({state}) =>
|
|
4
|
-
return state.command === 'show';
|
|
5
|
-
};
|
|
3
|
+
export const filter = ({state}) => state.command === 'show';
|
|
6
4
|
|
|
7
5
|
export const listener = ({options, state}) => {
|
|
8
6
|
options.beforeClick?.(state);
|
|
9
|
-
options.
|
|
7
|
+
options.beforeClose?.(state);
|
|
10
8
|
|
|
11
9
|
return {
|
|
12
10
|
command: 'hide',
|
package/menu/addons/enter.js
CHANGED
|
@@ -2,9 +2,7 @@ const {values} = Object;
|
|
|
2
2
|
|
|
3
3
|
export const key = 'Enter';
|
|
4
4
|
|
|
5
|
-
export const filter = ({state}) =>
|
|
6
|
-
return state.command === 'show';
|
|
7
|
-
};
|
|
5
|
+
export const filter = ({state}) => state.command === 'show';
|
|
8
6
|
|
|
9
7
|
export const listener = ({options, state}) => {
|
|
10
8
|
const {index} = state;
|
package/menu/addons/f9.js
CHANGED
package/menu/hydrate-menu.js
CHANGED
package/menu/importmap.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"imports": {
|
|
3
|
+
"putout": "https://esm.sh/@putout/bundle",
|
|
4
|
+
"@putout/processor-html": "https://esm.sh/@putout/processor-html",
|
|
5
|
+
"fullstore": "https://esm.sh/fullstore"
|
|
6
|
+
}
|
|
7
7
|
}
|
package/menu/menu.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<ul data-name="menu" class="menu menu-hidden"><li data-name='menu-item' className=
|
|
1
|
+
<ul data-name="menu" class="menu menu-hidden"><li data-name='menu-item' className="menu-item icon icon-hello"><label>hello</label></li><li data-name='menu-item' className="menu-item icon icon-world"><label>world</label></li></ul>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<ul data-name="menu" class="menu menu-hidden"><li data-name='menu-item' className="menu-item icon icon-hello"><label>hello</label><ul data-name='menu' className='menu menu-hidden'><li data-name='menu-item' className="menu-item icon icon-world"><label>world</label></li></ul></li></ul>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<ul data-name="menu" class="menu menu-hidden"></ul>;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {template, operator} from 'putout';
|
|
2
|
+
import {checkDataName} from '../check-data-name.js';
|
|
3
|
+
|
|
4
|
+
const {setLiteralValue} = operator;
|
|
5
|
+
|
|
6
|
+
const isObject = (a) => a && typeof a === 'object';
|
|
7
|
+
|
|
8
|
+
const {entries} = Object;
|
|
2
9
|
|
|
3
|
-
const {entries, keys} = Object;
|
|
4
10
|
const noop = () => {};
|
|
5
|
-
const {jsxText} = types;
|
|
6
11
|
|
|
7
12
|
export const report = () => `Build menu`;
|
|
8
13
|
|
|
@@ -10,8 +15,9 @@ const createMenuItem = template(`
|
|
|
10
15
|
<li data-name="menu-item" className="menu-item"><label>NAME</label></li>
|
|
11
16
|
`);
|
|
12
17
|
|
|
13
|
-
const
|
|
14
|
-
|
|
18
|
+
const createMenu = template(`
|
|
19
|
+
<ul data-name="menu" className="menu menu-hidden"></ul>
|
|
20
|
+
`);
|
|
15
21
|
|
|
16
22
|
const DefaultMenu = {
|
|
17
23
|
hello: noop,
|
|
@@ -19,9 +25,9 @@ const DefaultMenu = {
|
|
|
19
25
|
};
|
|
20
26
|
|
|
21
27
|
export const fix = ({path, menu, icon}) => {
|
|
22
|
-
const
|
|
28
|
+
const {children} = path.parentPath.node;
|
|
23
29
|
|
|
24
|
-
for (const key of
|
|
30
|
+
for (const [key, value] of entries(menu)) {
|
|
25
31
|
const menuItem = createMenuItem();
|
|
26
32
|
|
|
27
33
|
menuItem.children[0].children[0].value = key;
|
|
@@ -29,10 +35,24 @@ export const fix = ({path, menu, icon}) => {
|
|
|
29
35
|
if (icon)
|
|
30
36
|
setIcon(key, menuItem);
|
|
31
37
|
|
|
32
|
-
|
|
38
|
+
children.push(menuItem);
|
|
39
|
+
|
|
40
|
+
if (isObject(value)) {
|
|
41
|
+
setSubmenu(menuItem);
|
|
42
|
+
menuItem.children.push(createMenu());
|
|
43
|
+
|
|
44
|
+
const openingElement = path.parentPath
|
|
45
|
+
.get('children')
|
|
46
|
+
.at(-1)
|
|
47
|
+
.get('children.1.openingElement');
|
|
48
|
+
|
|
49
|
+
fix({
|
|
50
|
+
path: openingElement,
|
|
51
|
+
icon,
|
|
52
|
+
menu: value,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
33
55
|
}
|
|
34
|
-
|
|
35
|
-
path.parentPath.node.children = items;
|
|
36
56
|
};
|
|
37
57
|
|
|
38
58
|
export const traverse = ({options, push}) => ({
|
|
@@ -57,15 +77,15 @@ export const traverse = ({options, push}) => ({
|
|
|
57
77
|
},
|
|
58
78
|
});
|
|
59
79
|
|
|
60
|
-
function
|
|
61
|
-
const {attributes} =
|
|
80
|
+
function setSubmenu(menuItem) {
|
|
81
|
+
const {attributes} = menuItem.openingElement;
|
|
62
82
|
|
|
63
|
-
for (const
|
|
64
|
-
if (name.name === '
|
|
65
|
-
|
|
83
|
+
for (const attr of attributes) {
|
|
84
|
+
if (attr.name.name === 'className') {
|
|
85
|
+
setLiteralValue(attr.value, `${attr.value.value} menu-submenu`);
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
66
88
|
}
|
|
67
|
-
|
|
68
|
-
return false;
|
|
69
89
|
}
|
|
70
90
|
|
|
71
91
|
function setIcon(name, menuItem) {
|
|
@@ -73,8 +93,8 @@ function setIcon(name, menuItem) {
|
|
|
73
93
|
|
|
74
94
|
for (const attr of attributes) {
|
|
75
95
|
if (attr.name.name === 'className') {
|
|
76
|
-
attr.value.value
|
|
77
|
-
|
|
96
|
+
setLiteralValue(attr.value, `${attr.value.value} icon ${getIconName(name)}`);
|
|
97
|
+
break;
|
|
78
98
|
}
|
|
79
99
|
}
|
|
80
100
|
}
|
|
@@ -85,3 +105,4 @@ function getIconName(name) {
|
|
|
85
105
|
.replace(/\s/g, '-')
|
|
86
106
|
.toLowerCase();
|
|
87
107
|
}
|
|
108
|
+
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
export function checkDataName(path, dataName = 'menu') {
|
|
2
|
-
const attributes = path.
|
|
2
|
+
const {attributes} = path.node;
|
|
3
3
|
|
|
4
|
-
for (const
|
|
5
|
-
const {name, value} = attr.node;
|
|
6
|
-
|
|
4
|
+
for (const {name, value} of attributes) {
|
|
7
5
|
if (name.name === 'data-name')
|
|
8
6
|
return value.value === dataName;
|
|
9
7
|
}
|
package/menu/rules/menu/index.js
CHANGED
|
@@ -26,7 +26,9 @@ export const traverse = ({push, options}) => ({
|
|
|
26
26
|
const {name, command} = options;
|
|
27
27
|
const attributes = path.get('attributes');
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
const opengineElementPath = path.parentPath.get('openingElement');
|
|
30
|
+
|
|
31
|
+
if (!checkDataName(opengineElementPath, name))
|
|
30
32
|
return false;
|
|
31
33
|
|
|
32
34
|
for (const attr of attributes) {
|
|
@@ -24,7 +24,9 @@ export const traverse = ({options, push}) => ({
|
|
|
24
24
|
if (!isJSXElement(path.parentPath.parentPath))
|
|
25
25
|
return;
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
const openingElementPath = path.parentPath.parentPath.get('openingElement');
|
|
28
|
+
|
|
29
|
+
if (!checkDataName(openingElementPath, name))
|
|
28
30
|
return;
|
|
29
31
|
|
|
30
32
|
const children = path.parentPath
|
|
@@ -32,7 +32,9 @@ export const traverse = ({options, push}) => ({
|
|
|
32
32
|
const {name = 'menu', position = {}} = options;
|
|
33
33
|
const {x = 0, y = 20} = position;
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
const openingElementPath = path.parentPath.get('openingElement');
|
|
36
|
+
|
|
37
|
+
if (!checkDataName(openingElementPath, name))
|
|
36
38
|
return;
|
|
37
39
|
|
|
38
40
|
for (const attr of path.node.attributes) {
|
|
@@ -26,7 +26,9 @@ export const traverse = ({push, options}) => ({
|
|
|
26
26
|
if (!isJSXElement(path.parentPath.parentPath))
|
|
27
27
|
return;
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
const openingElementPath = path.parentPath.parentPath.get('openingElement');
|
|
30
|
+
|
|
31
|
+
if (!checkDataName(openingElementPath, name))
|
|
30
32
|
return;
|
|
31
33
|
|
|
32
34
|
const children = path.parentPath
|