aleman 2.0.2 → 2.0.4
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 +27 -0
- package/example/lunes/index.html +3 -0
- package/example/lunes/index.js +22 -0
- package/example/menu/index.html +1 -0
- package/example/menu/index.js +13 -2
- package/lunes/actions/index.js +7 -0
- package/lunes/actions/up.json +5 -0
- package/lunes/compiler/compiler.js +5 -0
- package/lunes/engine/engine.js +16 -0
- package/lunes/engine/listen.js +61 -0
- package/lunes/engine/position/get-position.js +35 -0
- package/lunes/hydrate-menu.js +34 -0
- package/lunes/importmap.js +9 -0
- package/lunes/lunes.js +102 -0
- package/lunes/menu.css +65 -0
- package/lunes/render/render.js +16 -0
- package/lunes/render/rules/README.md +3 -0
- package/lunes/render/rules/build-menu/fixture/build-menu-fix.js +22 -0
- package/lunes/render/rules/build-menu/fixture/build-menu.js +9 -0
- package/lunes/render/rules/build-menu/fixture/no-cursor-fix.js +9 -0
- package/lunes/render/rules/build-menu/fixture/no-cursor.js +9 -0
- package/lunes/render/rules/build-menu/index.js +132 -0
- package/lunes/render/rules/index.js +5 -0
- package/lunes/state/convert-menu-to-state/convert-menu-to-state.js +21 -0
- package/lunes/state/rules/README.md +5 -0
- package/lunes/state/rules/add-cursor/fixture/add-cursor.js +9 -0
- package/lunes/state/rules/add-cursor/fixture/down-fix.js +9 -0
- package/lunes/state/rules/add-cursor/fixture/down.js +9 -0
- package/lunes/state/rules/add-cursor/fixture/up-fix.js +9 -0
- package/lunes/state/rules/add-cursor/fixture/up.js +9 -0
- package/lunes/state/rules/add-cursor/index.js +34 -0
- package/lunes/state/rules/apply-visibility/fixture/apply-visibility-fix.js +9 -0
- package/lunes/state/rules/apply-visibility/fixture/apply-visibility.js +9 -0
- package/lunes/state/rules/apply-visibility/index.js +29 -0
- package/lunes/state/rules/cursor.js +77 -0
- package/lunes/state/rules/move-cursor/fixture/move-cursor-fix.js +9 -0
- package/lunes/state/rules/move-cursor/fixture/move-cursor.js +9 -0
- package/lunes/state/rules/move-cursor/index.js +49 -0
- package/lunes/state/state.js +34 -0
- package/menu/addons/set-position/set-position.js +1 -1
- package/menu/hydrate-menu.js +0 -2
- package/menu/importmap.js +1 -1
- package/nemo/addons/escape/escape.js +3 -9
- package/nemo/hydrate-menu.js +0 -2
- package/nemo/importmap.js +1 -1
- package/nemo/rules/index.js +0 -16
- package/package.json +3 -2
- package/nemo/addons/up.json +0 -5
- package/nemo/rules/hide-submenu/fixture/hide-submenu-fix.js +0 -17
- package/nemo/rules/hide-submenu/fixture/hide-submenu.js +0 -18
- package/nemo/rules/hide-submenu/fixture/no-menu.js +0 -16
- package/nemo/rules/hide-submenu/fixture/show-submenu.js +0 -18
- package/nemo/rules/hide-submenu/index.js +0 -35
- package/nemo/rules/menu/fixture/hide-menu-fix.js +0 -3
- package/nemo/rules/menu/fixture/hide-menu.js +0 -3
- package/nemo/rules/menu/fixture/no-menu.js +0 -3
- package/nemo/rules/menu/fixture/show-menu-fix.js +0 -1
- package/nemo/rules/menu/fixture/show-menu.js +0 -1
- package/nemo/rules/menu/index.js +0 -40
- package/nemo/rules/select/fixture/no-current.js +0 -8
- package/nemo/rules/select/fixture/no-data-name.js +0 -4
- package/nemo/rules/select/fixture/no-index.js +0 -8
- package/nemo/rules/select/fixture/no-next.js +0 -5
- package/nemo/rules/select/fixture/no-parent.js +0 -2
- package/nemo/rules/select/fixture/select-fix.js +0 -8
- package/nemo/rules/select/fixture/select.js +0 -8
- package/nemo/rules/select/fixture/submenu-fix.js +0 -17
- package/nemo/rules/select/fixture/submenu.js +0 -18
- package/nemo/rules/select/fixture/wrong-data-name.js +0 -4
- package/nemo/rules/select/index.js +0 -94
- package/nemo/rules/set-position/fixture/no-style-fix.js +0 -2
- package/nemo/rules/set-position/fixture/no-style.js +0 -2
- package/nemo/rules/set-position/fixture/not-menu.js +0 -2
- package/nemo/rules/set-position/fixture/same-position.js +0 -2
- package/nemo/rules/set-position/fixture/set-position-fix.js +0 -2
- package/nemo/rules/set-position/fixture/set-position.js +0 -2
- package/nemo/rules/set-position/index.js +0 -83
- package/nemo/rules/submenu/fixture/last-selected-fix.js +0 -53
- package/nemo/rules/submenu/fixture/last-selected.js +0 -54
- package/nemo/rules/submenu/fixture/li.js +0 -3
- package/nemo/rules/submenu/fixture/no-submenu-selected.js +0 -17
- package/nemo/rules/submenu/fixture/no-submenu.js +0 -54
- package/nemo/rules/submenu/fixture/not-menu.js +0 -17
- package/nemo/rules/submenu/fixture/submenu-fix.js +0 -53
- package/nemo/rules/submenu/fixture/submenu.js +0 -54
- package/nemo/rules/submenu/index.js +0 -80
- package/nemo/rules/unselect-all/fixture/hide.js +0 -8
- package/nemo/rules/unselect-all/fixture/nested-fix.js +0 -17
- package/nemo/rules/unselect-all/fixture/nested.js +0 -18
- package/nemo/rules/unselect-all/fixture/no-data-name.js +0 -4
- package/nemo/rules/unselect-all/fixture/no-parent.js +0 -2
- package/nemo/rules/unselect-all/fixture/unselect-all-fix.js +0 -8
- package/nemo/rules/unselect-all/fixture/unselect-all.js +0 -8
- package/nemo/rules/unselect-all/index.js +0 -51
- package/nemo/rules/unselect-all-submenu-items/fixture/show-submenu-fix.js +0 -33
- package/nemo/rules/unselect-all-submenu-items/fixture/show-submenu.js +0 -34
- package/nemo/rules/unselect-all-submenu-items/fixture/unselect-all-submenu-items-fix.js +0 -33
- package/nemo/rules/unselect-all-submenu-items/fixture/unselect-all-submenu-items.js +0 -33
- package/nemo/rules/unselect-all-submenu-items/index.js +0 -30
- package/nemo/rules/unselect-wrongly-selected/fixture/hide.js +0 -17
- package/nemo/rules/unselect-wrongly-selected/fixture/unselect-wrongly-selected-fix.js +0 -17
- package/nemo/rules/unselect-wrongly-selected/fixture/unselect-wrongly-selected.js +0 -17
- package/nemo/rules/unselect-wrongly-selected/index.js +0 -39
- /package/{menu/addons/set-position → lunes/engine/position}/calculate.js +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {operator} from 'putout';
|
|
2
|
+
import {
|
|
3
|
+
first,
|
|
4
|
+
last,
|
|
5
|
+
setCursor,
|
|
6
|
+
} from '../cursor.js';
|
|
7
|
+
|
|
8
|
+
const {remove} = operator;
|
|
9
|
+
|
|
10
|
+
const operations = {
|
|
11
|
+
last,
|
|
12
|
+
first,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const report = () => `Add cursor`;
|
|
16
|
+
|
|
17
|
+
export const include = () => [
|
|
18
|
+
'"no-cursor"',
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
export const filter = (path, {options}) => {
|
|
22
|
+
const {operation} = options;
|
|
23
|
+
return operations[operation];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const fix = (path, {options}) => {
|
|
27
|
+
const {operation} = options;
|
|
28
|
+
|
|
29
|
+
const getCursor = operations[operation];
|
|
30
|
+
const cursorPath = getCursor(path);
|
|
31
|
+
|
|
32
|
+
setCursor(cursorPath);
|
|
33
|
+
remove(path);
|
|
34
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {types} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {isExpressionStatement} = types;
|
|
4
|
+
|
|
5
|
+
export const report = () => `Apply visibility`;
|
|
6
|
+
|
|
7
|
+
export const match = ({options}) => {
|
|
8
|
+
const {operation = 'show'} = options;
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
'"off"': (vars, path) => {
|
|
12
|
+
if (operation !== 'show')
|
|
13
|
+
return false;
|
|
14
|
+
|
|
15
|
+
return isExpressionStatement(path.parentPath.parentPath);
|
|
16
|
+
},
|
|
17
|
+
'"on"': (vars, path) => {
|
|
18
|
+
if (operation !== 'hide')
|
|
19
|
+
return false;
|
|
20
|
+
|
|
21
|
+
return isExpressionStatement(path.parentPath.parentPath);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const replace = () => ({
|
|
27
|
+
'"off"': '"on"',
|
|
28
|
+
'"on"': '"off"',
|
|
29
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {types, operator} from 'putout';
|
|
2
|
+
|
|
3
|
+
const {remove} = operator;
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
stringLiteral,
|
|
7
|
+
isArrayExpression,
|
|
8
|
+
isIdentifier,
|
|
9
|
+
identifier,
|
|
10
|
+
isObjectProperty,
|
|
11
|
+
isObjectExpression,
|
|
12
|
+
} = types;
|
|
13
|
+
|
|
14
|
+
export function last(path) {
|
|
15
|
+
return path
|
|
16
|
+
.getNextSibling()
|
|
17
|
+
.get('properties')
|
|
18
|
+
.at(-1);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function first(path) {
|
|
22
|
+
return path
|
|
23
|
+
.getNextSibling()
|
|
24
|
+
.get('properties')
|
|
25
|
+
.at(0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function setCursor(path) {
|
|
29
|
+
const valuePath = path.get('value');
|
|
30
|
+
|
|
31
|
+
if (isIdentifier(valuePath)) {
|
|
32
|
+
path.node.value = stringLiteral('cursor');
|
|
33
|
+
path.node.shorthand = false;
|
|
34
|
+
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (isArrayExpression(valuePath))
|
|
39
|
+
valuePath.node.elements.splice(1, 0, stringLiteral('cursor'));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function prev(path) {
|
|
43
|
+
const nextCursor = path.getNextSibling();
|
|
44
|
+
|
|
45
|
+
if (nextCursor.node)
|
|
46
|
+
return nextCursor;
|
|
47
|
+
|
|
48
|
+
return path.parentPath.get('properties.0');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function next(path) {
|
|
52
|
+
const prevCursor = path.getPrevSibling();
|
|
53
|
+
|
|
54
|
+
if (prevCursor.node)
|
|
55
|
+
return prevCursor;
|
|
56
|
+
|
|
57
|
+
const {parentPath} = path;
|
|
58
|
+
|
|
59
|
+
if (isObjectExpression(parentPath))
|
|
60
|
+
return parentPath.get('properties').at(-1);
|
|
61
|
+
|
|
62
|
+
return parentPath.parentPath
|
|
63
|
+
.get('properties')
|
|
64
|
+
.at(-1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function clearCursor({parentPath}) {
|
|
68
|
+
if (isObjectProperty(parentPath)) {
|
|
69
|
+
parentPath.node.value = identifier(parentPath.node.key.name);
|
|
70
|
+
parentPath.node.shorthand = true;
|
|
71
|
+
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (isArrayExpression(parentPath))
|
|
76
|
+
remove(parentPath.get('elements.0'));
|
|
77
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import {types} from 'putout';
|
|
2
|
+
import {
|
|
3
|
+
next,
|
|
4
|
+
prev,
|
|
5
|
+
setCursor,
|
|
6
|
+
clearCursor,
|
|
7
|
+
} from '../cursor.js';
|
|
8
|
+
|
|
9
|
+
const operations = {
|
|
10
|
+
prev,
|
|
11
|
+
next,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const {isArrayExpression} = types;
|
|
15
|
+
|
|
16
|
+
export const report = () => `Move cursor`;
|
|
17
|
+
|
|
18
|
+
export const include = () => [
|
|
19
|
+
'"cursor"',
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
export const filter = (path, {options}) => {
|
|
23
|
+
const {operation = 'next', cursor} = options;
|
|
24
|
+
const {parentPath} = path;
|
|
25
|
+
|
|
26
|
+
if (!operations[operation])
|
|
27
|
+
return false;
|
|
28
|
+
|
|
29
|
+
if (isArrayExpression(parentPath))
|
|
30
|
+
return parentPath.parentPath.node.key.name === cursor;
|
|
31
|
+
|
|
32
|
+
return parentPath.node.key.name === cursor;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const fix = (path, options) => {
|
|
36
|
+
const {
|
|
37
|
+
operation = 'next',
|
|
38
|
+
count = 1,
|
|
39
|
+
} = options;
|
|
40
|
+
|
|
41
|
+
const getCursor = operations[operation];
|
|
42
|
+
let cursorPath = path.parentPath;
|
|
43
|
+
|
|
44
|
+
for (let i = 0; i < count; i++)
|
|
45
|
+
cursorPath = getCursor(cursorPath);
|
|
46
|
+
|
|
47
|
+
clearCursor(path);
|
|
48
|
+
setCursor(cursorPath);
|
|
49
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {putout} from 'putout';
|
|
2
|
+
import {convertMenuToState} from './convert-menu-to-state/convert-menu-to-state.js';
|
|
3
|
+
import * as addCursor from './rules/add-cursor/index.js';
|
|
4
|
+
import * as moveCursor from './rules/move-cursor/index.js';
|
|
5
|
+
import * as applyVisibility from './rules/apply-visibility/index.js';
|
|
6
|
+
|
|
7
|
+
export const createState = (menu) => {
|
|
8
|
+
const state = convertMenuToState(menu);
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
commit: createCommit(state),
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const createCommit = (state) => (operation) => {
|
|
16
|
+
const options = {
|
|
17
|
+
operation,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const {code} = putout(state, {
|
|
21
|
+
rules: {
|
|
22
|
+
'add-cursor': ['on', options],
|
|
23
|
+
'move-cursor': ['on', options],
|
|
24
|
+
'apply-visibility': ['on', options],
|
|
25
|
+
},
|
|
26
|
+
plugins: [
|
|
27
|
+
['add-cursor', addCursor],
|
|
28
|
+
['move-cursor', moveCursor],
|
|
29
|
+
['apply-visibility', applyVisibility],
|
|
30
|
+
],
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
return code;
|
|
34
|
+
};
|
package/menu/hydrate-menu.js
CHANGED
|
@@ -6,7 +6,6 @@ import {createMouseEnter} from './addons/mouse-leave/index.js';
|
|
|
6
6
|
import {createItemClick} from './addons/item-click/item-click.js';
|
|
7
7
|
import * as click from './addons/click/click.js';
|
|
8
8
|
import {createContextMenu} from './addons/context-menu.js';
|
|
9
|
-
import {setPosition} from './addons/set-position/set-position.js';
|
|
10
9
|
|
|
11
10
|
const {assign} = Object;
|
|
12
11
|
|
|
@@ -29,7 +28,6 @@ export const hydrateMenu = (elementName, {hydrateElement, options, menu}) => {
|
|
|
29
28
|
...addons,
|
|
30
29
|
],
|
|
31
30
|
rules,
|
|
32
|
-
afterHydrate: setPosition,
|
|
33
31
|
stateName: `aleman-state-${name}`,
|
|
34
32
|
});
|
|
35
33
|
|
package/menu/importmap.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const importmap = {
|
|
2
2
|
imports: {
|
|
3
|
-
'putout': 'https://esm.sh/@putout/bundle@5.
|
|
3
|
+
'putout': 'https://esm.sh/@putout/bundle@5.5.0',
|
|
4
4
|
'@putout/processor-html': 'https://esm.sh/@putout/processor-html',
|
|
5
5
|
'fullstore': 'https://esm.sh/fullstore',
|
|
6
6
|
'jessy': 'https://esm.sh/jessy',
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
+
import {updateState} from '../../state/state.js';
|
|
2
|
+
|
|
1
3
|
export const keys = ['Escape'];
|
|
2
4
|
|
|
3
|
-
export const listener = ({state, options}) =>
|
|
4
|
-
options.beforeHide?.(state);
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
command: 'hide',
|
|
8
|
-
showSubmenu: false,
|
|
9
|
-
index: -1,
|
|
10
|
-
};
|
|
11
|
-
};
|
|
5
|
+
export const listener = ({state, options}) => updateState('esc', state, options);
|
package/nemo/hydrate-menu.js
CHANGED
|
@@ -6,7 +6,6 @@ import {createMouseEnter} from './addons/mouse-leave/index.js';
|
|
|
6
6
|
import {createItemClick} from './addons/item-click/item-click.js';
|
|
7
7
|
import * as click from './addons/click/click.js';
|
|
8
8
|
import {createContextMenu} from './addons/context-menu.js';
|
|
9
|
-
import {setPosition} from './addons/set-position/set-position.js';
|
|
10
9
|
|
|
11
10
|
const {assign} = Object;
|
|
12
11
|
|
|
@@ -29,7 +28,6 @@ export const hydrateMenu = (elementName, {hydrateElement, options, menu}) => {
|
|
|
29
28
|
...addons,
|
|
30
29
|
],
|
|
31
30
|
rules,
|
|
32
|
-
afterHydrate: setPosition,
|
|
33
31
|
stateName: `aleman-state-${name}`,
|
|
34
32
|
});
|
|
35
33
|
|
package/nemo/importmap.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const importmap = {
|
|
2
2
|
imports: {
|
|
3
|
-
'putout': 'https://esm.sh/@putout/bundle@5.
|
|
3
|
+
'putout': 'https://esm.sh/@putout/bundle@5.5.1',
|
|
4
4
|
'@putout/processor-html': 'https://esm.sh/@putout/processor-html',
|
|
5
5
|
'fullstore': 'https://esm.sh/fullstore',
|
|
6
6
|
'jessy': 'https://esm.sh/jessy',
|
package/nemo/rules/index.js
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
import * as unselectAllSubmenuItems from './unselect-all-submenu-items/index.js';
|
|
2
|
-
import * as unselectWronglySelected from './unselect-wrongly-selected/index.js';
|
|
3
|
-
import * as hideSubmenu from './hide-submenu/index.js';
|
|
4
|
-
import * as submenu from './submenu/index.js';
|
|
5
|
-
import * as setPosition from './set-position/index.js';
|
|
6
1
|
import * as buildMenu from './build-menu/index.js';
|
|
7
|
-
import * as menu from './menu/index.js';
|
|
8
|
-
import * as select from './select/index.js';
|
|
9
|
-
import * as unselectAll from './unselect-all/index.js';
|
|
10
2
|
|
|
11
3
|
export const rules = {
|
|
12
|
-
'menu': menu,
|
|
13
4
|
'build-menu': buildMenu,
|
|
14
|
-
'set-position': setPosition,
|
|
15
|
-
'select': select,
|
|
16
|
-
'unselect-all': unselectAll,
|
|
17
|
-
'submenu': submenu,
|
|
18
|
-
'hide-submenu': hideSubmenu,
|
|
19
|
-
'unselect-wrongly-selected': unselectWronglySelected,
|
|
20
|
-
'unselect-all-submenu-items': unselectAllSubmenuItems,
|
|
21
5
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aleman",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout-based framework for web",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"report": "madrun report"
|
|
26
26
|
},
|
|
27
27
|
"imports": {
|
|
28
|
-
"#test": "./test/create-test.js"
|
|
28
|
+
"#test": "./test/create-test.js",
|
|
29
|
+
"#aleman": "./aleman/lib/index.js"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
32
|
"@putout/processor-html": "^14.0.2",
|
package/nemo/addons/up.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// second selected
|
|
2
|
-
<ul data-name="menu" className="menu menu-hidden">
|
|
3
|
-
<li data-menu-path="Upload" data-name="menu-item" className="menu-item icon icon-view">
|
|
4
|
-
<label data-menu-path="Upload">Upload</label>
|
|
5
|
-
</li>
|
|
6
|
-
<li data-menu-path="New" data-name="menu-item" className="menu-item icon icon-edit menu-item-selected">
|
|
7
|
-
<label data-menu-path="New">New</label>
|
|
8
|
-
<ul data-name="menu" className="menu menu-hidden">
|
|
9
|
-
<li data-menu-path="New.File" data-name="menu-item" className="menu-item icon icon-view">
|
|
10
|
-
<label data-menu-path="New.File">File</label>
|
|
11
|
-
</li>
|
|
12
|
-
<li data-menu-path="New.Directory" data-name="menu-item" className="menu-item icon icon-edit">
|
|
13
|
-
<label data-menu-path="New.Directory">Directory</label>
|
|
14
|
-
</li>
|
|
15
|
-
</ul>
|
|
16
|
-
</li>
|
|
17
|
-
</ul>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// second selected
|
|
2
|
-
<ul data-name="menu" className="menu menu-hidden">
|
|
3
|
-
<li data-menu-path="Upload" data-name="menu-item" className="menu-item icon icon-view">
|
|
4
|
-
<label data-menu-path="Upload">Upload</label>
|
|
5
|
-
</li>
|
|
6
|
-
<li data-menu-path="New" data-name="menu-item" className="menu-item icon icon-edit menu-item-selected menu-submenu-show">
|
|
7
|
-
<label data-menu-path="New">New</label>
|
|
8
|
-
<ul data-name="menu" className="menu menu-hidden">
|
|
9
|
-
<li data-menu-path="New.File" data-name="menu-item" className="menu-item icon icon-view">
|
|
10
|
-
<label data-menu-path="New.File">File</label>
|
|
11
|
-
</li>
|
|
12
|
-
<li data-menu-path="New.Directory" data-name="menu-item" className="menu-item icon icon-edit">
|
|
13
|
-
<label data-menu-path="New.Directory">Directory</label>
|
|
14
|
-
</li>
|
|
15
|
-
</ul>
|
|
16
|
-
</li>
|
|
17
|
-
</ul>;
|
|
18
|
-
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<ul data-name="hello" className="menu menu-hidden">
|
|
2
|
-
<li data-menu-path="Upload" data-name="menu-item" className="menu-item icon icon-view">
|
|
3
|
-
<label data-menu-path="Upload">Upload</label>
|
|
4
|
-
</li>
|
|
5
|
-
<li data-menu-path="New" data-name="menu-item" className="menu-item icon icon-edit menu-item-selected menu-submenu-show">
|
|
6
|
-
<label data-menu-path="New">New</label>
|
|
7
|
-
<ul data-name="menu" className="menu menu-hidden">
|
|
8
|
-
<li data-menu-path="New.File" data-name="menu-item" className="menu-item icon icon-view">
|
|
9
|
-
<label data-menu-path="New.File">File</label>
|
|
10
|
-
</li>
|
|
11
|
-
<li data-menu-path="New.Directory" data-name="menu-item" className="menu-item icon icon-edit">
|
|
12
|
-
<label data-menu-path="New.Directory">Directory</label>
|
|
13
|
-
</li>
|
|
14
|
-
</ul>
|
|
15
|
-
</li>
|
|
16
|
-
</ul>;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// second selected
|
|
2
|
-
<ul data-name="menu" className="menu menu-hidden">
|
|
3
|
-
<li data-menu-path="Upload" data-name="menu-item" className="menu-item icon icon-view">
|
|
4
|
-
<label data-menu-path="Upload">Upload</label>
|
|
5
|
-
</li>
|
|
6
|
-
<li data-menu-path="New" data-name="menu-item" className="menu-item icon icon-edit menu-item-selected menu-submenu-show">
|
|
7
|
-
<label data-menu-path="New">New</label>
|
|
8
|
-
<ul data-name="menu" className="menu menu-hidden">
|
|
9
|
-
<li data-menu-path="New.File" data-name="menu-item" className="menu-item icon icon-view">
|
|
10
|
-
<label data-menu-path="New.File">File</label>
|
|
11
|
-
</li>
|
|
12
|
-
<li data-menu-path="New.Directory" data-name="menu-item" className="menu-item icon icon-edit">
|
|
13
|
-
<label data-menu-path="New.Directory">Directory</label>
|
|
14
|
-
</li>
|
|
15
|
-
</ul>
|
|
16
|
-
</li>
|
|
17
|
-
</ul>;
|
|
18
|
-
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {operator} from 'putout';
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
hasTagName,
|
|
5
|
-
removeClassName,
|
|
6
|
-
hasDataName,
|
|
7
|
-
containsClassName,
|
|
8
|
-
} = operator;
|
|
9
|
-
|
|
10
|
-
const CLASS = 'menu-submenu-show';
|
|
11
|
-
|
|
12
|
-
export const report = () => `Hide submenu`;
|
|
13
|
-
|
|
14
|
-
export const fix = (path) => {
|
|
15
|
-
removeClassName(path, CLASS);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const traverse = ({push, options}) => ({
|
|
19
|
-
JSXElement(path) {
|
|
20
|
-
const {name = 'menu', showSubmenu} = options;
|
|
21
|
-
const {parentPath} = path;
|
|
22
|
-
|
|
23
|
-
if (showSubmenu)
|
|
24
|
-
return;
|
|
25
|
-
|
|
26
|
-
if (!hasTagName(path, 'li'))
|
|
27
|
-
return;
|
|
28
|
-
|
|
29
|
-
if (!hasDataName(parentPath, name))
|
|
30
|
-
return false;
|
|
31
|
-
|
|
32
|
-
if (containsClassName(path, CLASS))
|
|
33
|
-
push(path);
|
|
34
|
-
},
|
|
35
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<ul data-name="menu" className="menu"><li></li><li></li></ul>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<ul data-name="menu" className="menu menu-hidden"><li></li><li></li></ul>;
|
package/nemo/rules/menu/index.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import {operator} from 'putout';
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
containsClassName,
|
|
5
|
-
hasDataName,
|
|
6
|
-
addClassName,
|
|
7
|
-
removeClassName,
|
|
8
|
-
} = operator;
|
|
9
|
-
|
|
10
|
-
export const report = ({command}) => {
|
|
11
|
-
const [first, ...rest] = command;
|
|
12
|
-
|
|
13
|
-
return `${first.toUpperCase()}${rest.join('')} menu`;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export const fix = ({path, command}) => {
|
|
17
|
-
if (command === 'show') {
|
|
18
|
-
removeClassName(path, 'menu-hidden');
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
addClassName(path, 'menu-hidden');
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const traverse = ({push, options}) => ({
|
|
26
|
-
JSXElement(path) {
|
|
27
|
-
const {name, command} = options;
|
|
28
|
-
|
|
29
|
-
if (!hasDataName(path, name))
|
|
30
|
-
return;
|
|
31
|
-
|
|
32
|
-
const shown = !containsClassName(path, 'menu-hidden');
|
|
33
|
-
|
|
34
|
-
if (command === 'show' && !shown || command === 'hide' && shown)
|
|
35
|
-
push({
|
|
36
|
-
command,
|
|
37
|
-
path,
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<ul data-name="menu" class="menu menu-hidden">
|
|
2
|
-
<li data-name="menu-item" data-menu-index="0" className="menu-item icon icon-view menu-item-selected">
|
|
3
|
-
<label data-menu-path="View">View</label>
|
|
4
|
-
</li>
|
|
5
|
-
<li data-name="menu-item" data-menu-index="1" className="menu-item icon icon-edit">
|
|
6
|
-
<label data-menu-path="Edit">Edit</label>
|
|
7
|
-
</li>
|
|
8
|
-
</ul>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
<ul data-name="menu" class="menu menu-hidden">
|
|
2
|
-
<li data-name="menu-item" data-menu-index="0" className="menu-item icon icon-view menu-item-selected">
|
|
3
|
-
<label data-menu-path="View">View</label>
|
|
4
|
-
</li>
|
|
5
|
-
<li data-name="menu-item" data-menu-index="1" className="menu-item icon icon-edit">
|
|
6
|
-
<label data-menu-path="Edit">Edit</label>
|
|
7
|
-
</li>
|
|
8
|
-
</ul>;
|