native-document 1.0.285 → 1.0.286

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-document",
3
- "version": "1.0.285",
3
+ "version": "1.0.286",
4
4
  "description": "A reactive JavaScript framework that preserves native DOM simplicity without sacrificing modern features",
5
5
  "author": "AfroCodeur <https://github.com/afrocodeur>",
6
6
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  import {Div, ListItem, Span } from '../../../core/elements';
2
2
  import ShortcutManager from '../../../core/utils/shortcut-manager';
3
3
  import { $ } from '../../../core/data/Observable';
4
- import {buildSubmenu, setupInteraction} from './helpers';
4
+ import {applyIsActive, buildSubmenu, setupInteraction} from './helpers';
5
5
 
6
6
  export default function MenuItemRender($desc, instance) {
7
7
  if($desc.render) {
@@ -18,6 +18,8 @@ export default function MenuItemRender($desc, instance) {
18
18
  props.class.add('is-selected', $desc.selected);
19
19
  }
20
20
 
21
+ applyIsActive(instance, $desc, props);
22
+
21
23
  const orientation = instance.$parent?.$description?.orientation || 'horizontal';
22
24
  const interaction = $desc.interaction || instance.$parent?.$description?.interaction || 'hover';
23
25
  const hasSubmenu = $desc.items?.length;
@@ -2,7 +2,7 @@ import {Link, ListItem, Span} from '../../../core/elements';
2
2
  import { Link as RouterLink } from '../../../../router';
3
3
  import ShortcutManager from '../../../core/utils/shortcut-manager';
4
4
  import { $ } from '../../../core/data/Observable';
5
- import {buildSubmenu, setupInteraction} from './helpers';
5
+ import {applyIsActive, buildSubmenu, setupInteraction} from './helpers';
6
6
 
7
7
  export default function MenuLinkRender($desc, instance) {
8
8
  if($desc.render) {
@@ -14,6 +14,9 @@ export default function MenuLinkRender($desc, instance) {
14
14
  props.class.add('menu-item');
15
15
  props.class.add({ 'is-disabled': $desc.disabled, 'is-selected': $desc.selected });
16
16
 
17
+
18
+ applyIsActive(instance, $desc, props);
19
+
17
20
  const orientation = instance.$parent?.$description?.orientation || 'horizontal';
18
21
  const interaction = $desc.interaction || instance.$parent?.$description?.interaction || 'hover';
19
22
  const hasSubmenu = $desc.items?.length;
@@ -56,7 +59,7 @@ export default function MenuLinkRender($desc, instance) {
56
59
  return ListItem(instance.resolveProps(), el);
57
60
  }
58
61
 
59
- const $isOpen = $(false);
62
+ const $isOpen = $(false);
60
63
  const submenuEl = buildSubmenu($desc, orientation, $isOpen, instance);
61
64
  const listItem = ListItem(instance.resolveProps(), [el, submenuEl]);
62
65
 
@@ -23,5 +23,4 @@ export default function MenuRender($desc, instance) {
23
23
  }
24
24
 
25
25
  return nav;
26
-
27
26
  }
@@ -119,4 +119,13 @@ export const setupInteraction = (listItem, el, submenuEl, orientation, interacti
119
119
  $activeItem?.set(null);
120
120
  });
121
121
 
122
- };
122
+ };
123
+
124
+
125
+ export function applyIsActive(instance, $description, props) {
126
+ const root = instance.getRoot();
127
+ if(root && root.$description.active) {
128
+ const isActive = root.active($description);
129
+ props.class.add({ 'is-active': isActive });
130
+ }
131
+ }