aleman 1.3.0 → 1.3.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,8 @@
1
+ 2025.09.04, v1.3.1
2
+
3
+ feature:
4
+ - 314e4f9 aleman: menu: hide-submenu
5
+
1
6
  2025.09.04, v1.3.0
2
7
 
3
8
  feature:
package/aleman/state.js CHANGED
@@ -39,6 +39,7 @@ export const createState = (state, {options, listener, stateName = 'aleman-state
39
39
 
40
40
  history[str] = true;
41
41
  stateElement.textContent = str;
42
+ window.alemanSync = fn;
42
43
 
43
44
  document.addEventListener('keydown', ({key}) => {
44
45
  if (key === '`')
package/menu/README.md CHANGED
@@ -8,6 +8,7 @@
8
8
  - ✅[`build-menu`](https://putout.cloudcmd.io/#/gist/329dccd5fdc7f8b220be79af405dc9bb/b56df53f52bbe2a300ede38a96d1d2242e60679f);
9
9
  - ✅[`set-position`](https://putout.cloudcmd.io/#/gist/215bb4654a27f15235f3e380a3035138/7f4af88aaa4863be4f1b8a90b9f0f4b1cf4744a0);
10
10
  - ✅[`submenu`](https://putout.cloudcmd.io/#/gist/b0a3b64d14f3497869a345e7e438d66e/feb671c4a59a555ff408af92fab602bae3a94e2f);
11
+ - ✅[`hide-submenu`](https://putout.cloudcmd.io/#/gist/fdf6cf60a7fdfa2bae64279eda2ab023/ce0d5e24dc5e0b3436b7e87585c62e8a5132a9ab);
11
12
 
12
13
  ## License
13
14
 
@@ -9,5 +9,6 @@ export const listener = ({options, state}) => {
9
9
  command: 'hide',
10
10
  index: -1,
11
11
  showSubmenu: false,
12
+ insideSubmenu: false,
12
13
  };
13
14
  };
@@ -3,5 +3,8 @@ export const createMouseEnter = (name) => ({
3
3
  events: ['mouseenter'],
4
4
  listener: () => ({
5
5
  index: -1,
6
+ showSubmenu: false,
7
+ insideSubmenu: false,
8
+ submenuIndex: 0,
6
9
  }),
7
10
  });
@@ -0,0 +1,17 @@
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>;
@@ -0,0 +1,18 @@
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
+
@@ -0,0 +1,53 @@
1
+ import {operator} from 'putout';
2
+
3
+ const {setLiteralValue} = operator;
4
+
5
+ export const report = () => `Hide submenu`;
6
+
7
+ export const fix = (path) => {
8
+ const {value} = path.node;
9
+ const newValue = value.value;
10
+
11
+ setLiteralValue(value, newValue
12
+ .replace('menu-submenu-show', '')
13
+ .trim());
14
+ };
15
+
16
+ export const traverse = ({push, options}) => ({
17
+ JSXOpeningElement(path) {
18
+ const {name, showSubmenu} = options;
19
+
20
+ if (path.node.name.name !== 'li')
21
+ return;
22
+
23
+ if (showSubmenu)
24
+ return;
25
+
26
+ const attributes = path.get('attributes');
27
+ const openingElementPath = path.parentPath.parentPath.get('openingElement');
28
+
29
+ if (!checkDataName(openingElementPath, name))
30
+ return false;
31
+
32
+ for (const attr of attributes) {
33
+ const {name, value} = attr.node;
34
+
35
+ if (name.name !== 'className')
36
+ continue;
37
+
38
+ if (value.value.includes('menu-submenu-show'))
39
+ push(attr);
40
+ }
41
+ },
42
+ });
43
+
44
+ function checkDataName(path, dataName = 'menu') {
45
+ const {attributes} = path.node;
46
+
47
+ for (const {name, value} of attributes) {
48
+ if (name.name === 'data-name')
49
+ return value.value === dataName;
50
+ }
51
+
52
+ return false;
53
+ }
@@ -1,3 +1,4 @@
1
+ import * as hideSubmenu from './hide-submenu/index.js';
1
2
  import * as submenu from './submenu/index.js';
2
3
  import * as setPosition from './set-position/index.js';
3
4
  import * as buildMenu from './build-menu/index.js';
@@ -12,4 +13,5 @@ export const rules = {
12
13
  'select': select,
13
14
  'unselect-all': unselectAll,
14
15
  'submenu': submenu,
16
+ 'hide-submenu': hideSubmenu,
15
17
  };
@@ -0,0 +1,17 @@
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-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>;
@@ -0,0 +1,18 @@
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 menu-item-selected">
13
+ <label data-menu-path="New.Directory">Directory</label>
14
+ </li>
15
+ </ul>
16
+ </li>
17
+ </ul>;
18
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aleman",
3
- "version": "1.3.0",
3
+ "version": "1.3.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",