@buerokratt-ria/menu 0.1.16 → 0.2.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/.eslintrc.json +18 -18
- package/CHANGELOG.md +73 -70
- package/MAKING_CHANGES.md +8 -8
- package/README.md +49 -49
- package/buerokratt-ria-menu-0.2.1.tgz +0 -0
- package/index.ts +2 -2
- package/package.json +42 -42
- package/project.json +52 -52
- package/src/index.ts +2 -2
- package/src/menu/components/icons/icon/icon.tsx +33 -33
- package/src/menu/components/icons/icon.scss +22 -22
- package/src/menu/components/menuTree/index.tsx +77 -64
- package/src/menu/components/menuTree/isSameRoot.ts +10 -10
- package/src/menu/components/menuTree/menuData.tsx +42 -42
- package/src/menu/data/menu-structure.json +364 -357
- package/src/menu/hooks/useFilteredMenuItems.tsx +39 -33
- package/src/menu/hooks/useMenuItems.tsx +77 -63
- package/src/menu/index.tsx +53 -48
- package/src/menu/main-navigation.scss +129 -129
- package/src/menu/types/countConf.ts +3 -0
- package/src/menu/types/menuItem.ts +14 -13
- package/tsconfig.base.json +21 -21
- package/tsconfig.json +14 -14
- package/tsconfig.spec.json +19 -19
- package/vite.config.ts +67 -67
- package/buerokratt-ria-menu-0.1.16.tgz +0 -0
|
@@ -1,64 +1,77 @@
|
|
|
1
|
-
import React, { FC, MouseEvent } from "react";
|
|
2
|
-
import { NavLink } from 'react-router-dom';
|
|
3
|
-
import { MdKeyboardArrowDown } from 'react-icons/md';
|
|
4
|
-
import { MenuItem } from "../../types/menuItem";
|
|
5
|
-
import { useTranslation } from "react-i18next";
|
|
6
|
-
import { menuData } from './menuData';
|
|
7
|
-
import Icon from "../icons/icon/icon";
|
|
8
|
-
import { isSameRoot } from "./isSameRoot";
|
|
9
|
-
import clsx from 'clsx';
|
|
10
|
-
import '../../main-navigation.scss';
|
|
11
|
-
|
|
12
|
-
interface MenuTreeProps {
|
|
13
|
-
menuItems: MenuItem[];
|
|
14
|
-
serviceId: string[];
|
|
15
|
-
handleNavToggle: (event: MouseEvent) => void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
{
|
|
54
|
-
</
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
1
|
+
import React, { FC, MouseEvent } from "react";
|
|
2
|
+
import { NavLink } from 'react-router-dom';
|
|
3
|
+
import { MdKeyboardArrowDown } from 'react-icons/md';
|
|
4
|
+
import { MenuItem } from "../../types/menuItem";
|
|
5
|
+
import { useTranslation } from "react-i18next";
|
|
6
|
+
import { menuData } from './menuData';
|
|
7
|
+
import Icon from "../icons/icon/icon";
|
|
8
|
+
import { isSameRoot } from "./isSameRoot";
|
|
9
|
+
import clsx from 'clsx';
|
|
10
|
+
import '../../main-navigation.scss';
|
|
11
|
+
|
|
12
|
+
interface MenuTreeProps {
|
|
13
|
+
menuItems: MenuItem[];
|
|
14
|
+
serviceId: string[];
|
|
15
|
+
handleNavToggle: (event: MouseEvent) => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface MenuItemLabelProps {
|
|
19
|
+
menuItem: MenuItem
|
|
20
|
+
currentlySelectedLanguage: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const MenuItemLabel: React.FC<MenuItemLabelProps> = ({ menuItem, currentlySelectedLanguage }) => {
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
{menuItem.label[currentlySelectedLanguage]} {menuItem.count != null ? `(${menuItem.count})` : ''}
|
|
27
|
+
</>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const MenuTree: FC<MenuTreeProps> = ({
|
|
32
|
+
menuItems,
|
|
33
|
+
serviceId,
|
|
34
|
+
handleNavToggle,
|
|
35
|
+
}) => {
|
|
36
|
+
const currentlySelectedLanguage = useTranslation().i18n.language;
|
|
37
|
+
|
|
38
|
+
return menuItems
|
|
39
|
+
.filter(x => !x.hidden)
|
|
40
|
+
.map((menuItem) => (
|
|
41
|
+
<li key={menuItem.label[currentlySelectedLanguage]}>
|
|
42
|
+
{!!menuItem.children ? (
|
|
43
|
+
<>
|
|
44
|
+
<button
|
|
45
|
+
className={clsx('nav__toggle', { 'nav__toggle--icon': !!menuItem.id })}
|
|
46
|
+
aria-expanded={menuItem.path && (isSameRoot(menuItem, serviceId)) ? 'true' : 'false'}
|
|
47
|
+
onClick={handleNavToggle}
|
|
48
|
+
>
|
|
49
|
+
{menuItem.id && (
|
|
50
|
+
<Icon icon={menuData.find(dataItem => dataItem.id === menuItem.id)?.icon} size='large' />
|
|
51
|
+
)}
|
|
52
|
+
<span className='menu-item-title'>{menuItem.label[currentlySelectedLanguage]}</span>
|
|
53
|
+
<Icon icon={<MdKeyboardArrowDown />} className='menu-item-arrow' />
|
|
54
|
+
</button>
|
|
55
|
+
<ul className='nav__submenu'>
|
|
56
|
+
<MenuTree
|
|
57
|
+
menuItems={menuItem.children.map((item) => ({id: menuItem.id, ...item}))}
|
|
58
|
+
serviceId={serviceId}
|
|
59
|
+
handleNavToggle={handleNavToggle}
|
|
60
|
+
/>
|
|
61
|
+
</ul>
|
|
62
|
+
</>
|
|
63
|
+
) : (
|
|
64
|
+
serviceId.includes(menuItem.id!)
|
|
65
|
+
? <NavLink to={menuItem.path || '#'}>
|
|
66
|
+
<MenuItemLabel menuItem={menuItem} currentlySelectedLanguage={currentlySelectedLanguage} />
|
|
67
|
+
</NavLink>
|
|
68
|
+
: <a href={(menuData.find(dataItem => dataItem.id === menuItem.id)?.url ?? '') + menuItem.path}>
|
|
69
|
+
<MenuItemLabel menuItem={menuItem} currentlySelectedLanguage={currentlySelectedLanguage} />
|
|
70
|
+
</a>
|
|
71
|
+
)}
|
|
72
|
+
</li>
|
|
73
|
+
),
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export default MenuTree;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { MenuItem } from "../../types/menuItem";
|
|
2
|
-
|
|
3
|
-
export const isSameRoot = (menuItem, serviceId) => {
|
|
4
|
-
const base = window.location.pathname.split("/")[1];
|
|
5
|
-
const currentService = base === 'chat' ? serviceId : [base];
|
|
6
|
-
if(currentService.includes(menuItem.id)) {
|
|
7
|
-
return menuItem.children.some((item: MenuItem) => item.path?.includes("/" + window.location.pathname.split("/")[2]));
|
|
8
|
-
}
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
1
|
+
import { MenuItem } from "../../types/menuItem";
|
|
2
|
+
|
|
3
|
+
export const isSameRoot = (menuItem, serviceId) => {
|
|
4
|
+
const base = window.location.pathname.split("/")[1];
|
|
5
|
+
const currentService = base === 'chat' ? serviceId : [base];
|
|
6
|
+
if(currentService.includes(menuItem.id)) {
|
|
7
|
+
return menuItem.children.some((item: MenuItem) => item.path?.includes("/" + window.location.pathname.split("/")[2]));
|
|
8
|
+
}
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
MdOutlineForum,
|
|
4
|
-
MdOutlineAdb,
|
|
5
|
-
MdOutlineEqualizer,
|
|
6
|
-
MdMiscellaneousServices,
|
|
7
|
-
MdSettings,
|
|
8
|
-
MdOutlineMonitorWeight,
|
|
9
|
-
} from 'react-icons/md';
|
|
10
|
-
|
|
11
|
-
export const menuData = [
|
|
12
|
-
{
|
|
13
|
-
id: 'conversations',
|
|
14
|
-
icon: <MdOutlineForum className='menu-item-icon' />,
|
|
15
|
-
url: import.meta.env.REACT_APP_CONVERSATIONS_BASE_URL,
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
id: 'training',
|
|
19
|
-
icon: <MdOutlineAdb className='menu-item-icon' />,
|
|
20
|
-
url: import.meta.env.REACT_APP_TRAINING_BASE_URL,
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
id: 'analytics',
|
|
24
|
-
icon: <MdOutlineEqualizer className='menu-item-icon' />,
|
|
25
|
-
url: import.meta.env.REACT_APP_ANALYTICS_BASE_URL,
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
id: "services",
|
|
29
|
-
icon: <MdMiscellaneousServices className='menu-item-icon' />,
|
|
30
|
-
url: import.meta.env.REACT_APP_SERVICES_BASE_URL,
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
id: 'settings',
|
|
34
|
-
icon: <MdSettings className='menu-item-icon' />,
|
|
35
|
-
url: import.meta.env.REACT_APP_SETTINGS_BASE_URL,
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
id: 'monitoring',
|
|
39
|
-
icon: <MdOutlineMonitorWeight className='menu-item-icon' />,
|
|
40
|
-
url: import.meta.env.REACT_APP_MONITORING_BASE_URL,
|
|
41
|
-
},
|
|
42
|
-
];
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
MdOutlineForum,
|
|
4
|
+
MdOutlineAdb,
|
|
5
|
+
MdOutlineEqualizer,
|
|
6
|
+
MdMiscellaneousServices,
|
|
7
|
+
MdSettings,
|
|
8
|
+
MdOutlineMonitorWeight,
|
|
9
|
+
} from 'react-icons/md';
|
|
10
|
+
|
|
11
|
+
export const menuData = [
|
|
12
|
+
{
|
|
13
|
+
id: 'conversations',
|
|
14
|
+
icon: <MdOutlineForum className='menu-item-icon' />,
|
|
15
|
+
url: import.meta.env.REACT_APP_CONVERSATIONS_BASE_URL,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: 'training',
|
|
19
|
+
icon: <MdOutlineAdb className='menu-item-icon' />,
|
|
20
|
+
url: import.meta.env.REACT_APP_TRAINING_BASE_URL,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 'analytics',
|
|
24
|
+
icon: <MdOutlineEqualizer className='menu-item-icon' />,
|
|
25
|
+
url: import.meta.env.REACT_APP_ANALYTICS_BASE_URL,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
id: "services",
|
|
29
|
+
icon: <MdMiscellaneousServices className='menu-item-icon' />,
|
|
30
|
+
url: import.meta.env.REACT_APP_SERVICES_BASE_URL,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: 'settings',
|
|
34
|
+
icon: <MdSettings className='menu-item-icon' />,
|
|
35
|
+
url: import.meta.env.REACT_APP_SETTINGS_BASE_URL,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: 'monitoring',
|
|
39
|
+
icon: <MdOutlineMonitorWeight className='menu-item-icon' />,
|
|
40
|
+
url: import.meta.env.REACT_APP_MONITORING_BASE_URL,
|
|
41
|
+
},
|
|
42
|
+
];
|