@nethru/ui 1.0.52 → 1.0.53

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.
@@ -24,7 +24,7 @@ export default function MenuTree({
24
24
  backgroundColor: 'transparent'
25
25
  }
26
26
  };
27
- const naviate = useNavigate();
27
+ const navigate = useNavigate();
28
28
  const {
29
29
  states,
30
30
  dispatch
@@ -40,7 +40,7 @@ export default function MenuTree({
40
40
  hasChildren: hasChildren(event.target)
41
41
  });
42
42
  const node = getNode(ids);
43
- if (node && node.href) naviate(node.href);
43
+ if (node && node.href) navigate(node.href instanceof Array ? node.href[0] : node.href);
44
44
  };
45
45
  const handleToggle = (event, ids) => {
46
46
  dispatch({
@@ -91,7 +91,7 @@ function updateActiveItems(draft, menu, href) {
91
91
  function updateActiveSection(sections) {
92
92
  if (!sections) return;
93
93
  for (let section of sections) {
94
- if (href.indexOf(section.href) === 0) {
94
+ if (startsWith(section.href)) {
95
95
  draft.activeSecondaryItem = section.id;
96
96
  return true;
97
97
  }
@@ -104,7 +104,7 @@ function updateActiveItems(draft, menu, href) {
104
104
  function updateActiveSubmenuItems(id, submenu) {
105
105
  if (!submenu) return;
106
106
  for (let item of submenu) {
107
- if (href.indexOf(item.href) === 0) {
107
+ if (startsWith(item.href)) {
108
108
  if (!(id in draft.menuTrees)) draft.menuTrees[id] = emptyState();
109
109
  draft.activeSecondaryItem = item.id;
110
110
  return true;
@@ -115,4 +115,8 @@ function updateActiveItems(draft, menu, href) {
115
115
  }
116
116
  }
117
117
  }
118
+ function startsWith(hrefs) {
119
+ const menuHrefs = hrefs instanceof Array ? hrefs : [hrefs];
120
+ return menuHrefs.some(menuHref => href.startsWith(menuHref));
121
+ }
118
122
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nethru/ui",
3
- "version": "1.0.52",
3
+ "version": "1.0.53",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "/dist"