import React, { useMemo } from 'react'; import { css } from '@rocket.chat/css-in-js'; import { Box, Icon, ActionButton } from '@rocket.chat/fuselage'; import { useTranslation } from '../contexts/TranslationContext'; import { useRoutePath } from '../contexts/RouterContext'; import ScrollableContentWrapper from './ScrollableContentWrapper'; const Sidebar = ({ children, ...props }) => {children} ; const Content = ({ children, ...props }) => {children} ; const Header = ({ title, onClose, children = undefined, ...props }) => {(title || onClose) && {title && {title}} {onClose && } } {children} ; const GenericItem = ({ href, active, children, ...props }) => {children} ; const NavigationItem = ({ permissionGranted, pathGroup, pathSection, icon, label, currentPath }) => { const params = useMemo(() => ({ group: pathGroup }), [pathGroup]); const path = useRoutePath(pathSection, params); const isActive = path === currentPath || false; if (permissionGranted && !permissionGranted()) { return null; } return {icon && } {label} ; }; const ItemsAssembler = ({ items, currentPath }) => { const t = useTranslation(); return items.map(({ href, pathSection, i18nLabel, name, icon, permissionGranted, pathGroup, }) => ); }; Sidebar.Content = Content; Sidebar.Header = Header; Sidebar.GenericItem = React.memo(GenericItem); Sidebar.NavigationItem = React.memo(NavigationItem); Sidebar.ItemsAssembler = React.memo(ItemsAssembler); export default Sidebar;