-
{
- const childs = getChilds(item) || [];
- if (local.open.includes(item)) {
- local.open = local.open.filter(
- (e: any) => e !== item && !childs.includes(e)
- );
- } else {
- local.open.push(item);
- }
- local.active = item;
- local.render();
- }}
- >
-
- {pm.child}
-
-
-
- {Array.isArray(menu.value) && expand ? (
- <>
-
- >
- ) : (
- <>>
- )}
-
-
- );
+ // const find_child = findChild(item, (e: any) => local.open.includes(e));
+ // let expand = find_child;
+ // if (find_child && !local.open.includes(item)) local.open.push(item);
+ // return (
+ //
+ //
{
+ // const childs = getChilds(item) || [];
+ // if (local.open.includes(item)) {
+ // local.open = local.open.filter(
+ // (e: any) => e !== item && !childs.includes(e)
+ // );
+ // } else {
+ // local.open.push(item);
+ // }
+ // local.active = item;
+ // local.render();
+ // }}
+ // >
+ //
+ // {pm.child}
+ //
+ //
+ //
+ // {Array.isArray(menu.value) && expand ? (
+ // <>
+ //
+ // >
+ // ) : (
+ // <>>
+ // )}
+ //
+ //
+ // );
})}
);
- return (
-
- {data.map((e) => {
- const label: string = e[0];
- const child: any = e[2];
- const hasChildren = Array.isArray(child);
- const predicate = (item: MenuActive) => {
- if (hasChildren) {
- return item.label === e[0] && item.path === "";
- } else {
- return item.label === e[0] && item.path === child;
- }
- };
- const found_local = local.open.find(predicate);
- let expand = get(found_local, "expand") ? true : false;
- const selected = found(e, (menu: any) =>
- local.open.some(
- (item: MenuActive) =>
- item.label === menu[0] || item.path === menu[2]
- )
- );
- if (selected && !found_local) {
- local.open.push({
- label: e[0],
- path: hasChildren ? "" : e[2],
- expand: hasChildren,
- });
- expand = true;
- }
+ // return (
+ //
+ // {data.map((e) => {
+ // const label: string = e[0];
+ // const child: any = e[2];
+ // const hasChildren = Array.isArray(child);
+ // const predicate = (item: MenuActive) => {
+ // if (hasChildren) {
+ // return item.label === e[0] && item.path === "";
+ // } else {
+ // return item.label === e[0] && item.path === child;
+ // }
+ // };
+ // const found_local = local.open.find(predicate);
+ // let expand = get(found_local, "expand") ? true : false;
+ // const selected = found(e, (menu: any) =>
+ // local.open.some(
+ // (item: MenuActive) =>
+ // item.label === menu[0] || item.path === menu[2]
+ // )
+ // );
+ // if (selected && !found_local) {
+ // local.open.push({
+ // label: e[0],
+ // path: hasChildren ? "" : e[2],
+ // expand: hasChildren,
+ // });
+ // expand = true;
+ // }
- return (
-
-
{
- const found_local = local.open.find(predicate);
- console.log(found_local);
- if (found_local) {
- found_local.expand = !found_local.expand;
- // local.open = local.open.filter((item: MenuActive) => {
- // if (hasChildren) {
- // return item.label !== e[0] && item.path === "";
- // } else {
- // return item.label !== e[0] && item.path !== child;
- // }
- // });
- local.render();
- } else {
- local.open = [
- {
- label: e[0],
- path: hasChildren ? "" : e[2],
- expand: hasChildren,
- },
- ];
- }
- local.render();
- console.log(local.open);
- }}
- >
-
- {pm.child}
-
-
- {hasChildren && selected && expand ? (
-
-
-
- ) : (
- <>>
- )}
-
- );
- })}
-
- );
+ // return (
+ //
+ //
{
+ // const found_local = local.open.find(predicate);
+ // console.log(found_local);
+ // if (found_local) {
+ // found_local.expand = !found_local.expand;
+ // // local.open = local.open.filter((item: MenuActive) => {
+ // // if (hasChildren) {
+ // // return item.label !== e[0] && item.path === "";
+ // // } else {
+ // // return item.label !== e[0] && item.path !== child;
+ // // }
+ // // });
+ // local.render();
+ // } else {
+ // local.open = [
+ // {
+ // label: e[0],
+ // path: hasChildren ? "" : e[2],
+ // expand: hasChildren,
+ // },
+ // ];
+ // }
+ // local.render();
+ // console.log(local.open);
+ // }}
+ // >
+ //
+ // {pm.child}
+ //
+ //
+ // {hasChildren && selected && expand ? (
+ //
+ //
+ //
+ // ) : (
+ // <>>
+ // )}
+ //
+ // );
+ // })}
+ //
+ // );
};
const getChilds = (data: Array