@selfcommunity/react-ui
Version:
React UI Components to integrate a Community created with SelfCommunity Platform.
51 lines (50 loc) • 4.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = tslib_1.__importDefault(require("react"));
const material_1 = require("@mui/material");
const classnames_1 = tslib_1.__importDefault(require("classnames"));
const system_1 = require("@mui/system");
const ScrollContainer_1 = tslib_1.__importDefault(require("../../shared/ScrollContainer"));
const DefaultDrawerContent_1 = tslib_1.__importDefault(require("./DefaultDrawerContent"));
const DefaultHeaderContent_1 = tslib_1.__importDefault(require("./DefaultHeaderContent"));
const CreateLiveStreamButton_1 = tslib_1.__importDefault(require("../CreateLiveStreamButton"));
const PREFIX = 'SCNavigationMenuDrawer';
const classes = {
root: `${PREFIX}-root`,
logo: `${PREFIX}-logo`,
drawerRoot: `${PREFIX}-drawer-root`,
drawerHeader: `${PREFIX}-drawer-header`,
drawerHeaderAction: `${PREFIX}-drawer-header-action`,
drawerContent: `${PREFIX}-drawer-content`,
drawerFooter: `${PREFIX}-drawer-footer`,
drawerFooterLiveStream: `${PREFIX}-drawer-footer-live`,
drawerFooterLiveStreamButton: `${PREFIX}-drawer-footer-live-button`
};
const Root = (0, material_1.styled)(material_1.Drawer, {
name: PREFIX,
slot: 'Root',
overridesResolver: (props, styles) => styles.root
})(({ theme }) => ({}));
function NavigationMenuDrawer(inProps) {
// PROPS
const props = (0, system_1.useThemeProps)({
props: inProps,
name: PREFIX
});
const { className = null, showDrawerHeader = true, drawerHeaderContent = (0, jsx_runtime_1.jsx)(DefaultHeaderContent_1.default, {}), drawerContent = (0, jsx_runtime_1.jsx)(DefaultDrawerContent_1.default, {}), showDrawerFooterContent = true, drawerFooterContent = null, ScrollContainerProps = { hideTracksWhenNotNeeded: true }, CreateLiveStreamButtonComponentProps = {}, open, onClose } = props, rest = tslib_1.__rest(props, ["className", "showDrawerHeader", "drawerHeaderContent", "drawerContent", "showDrawerFooterContent", "drawerFooterContent", "ScrollContainerProps", "CreateLiveStreamButtonComponentProps", "open", "onClose"]);
const footerContent = (() => {
if (typeof drawerFooterContent === 'function') {
return drawerFooterContent({ handleCloseMenuDrawer: onClose });
}
if (react_1.default.isValidElement(drawerFooterContent)) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
return react_1.default.cloneElement(drawerFooterContent, { handleCloseMenuDrawer: onClose });
}
return drawerFooterContent;
})();
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ anchor: "left", className: (0, classnames_1.default)(classes.root, className), open: open, onClose: onClose }, rest, { children: [showDrawerHeader && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.drawerHeader }, { children: [drawerHeaderContent, (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ className: classes.drawerHeaderAction, onClick: onClose }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "close" }) }))] })), (0, jsx_runtime_1.jsx)(material_1.Divider, {})] })), (0, jsx_runtime_1.jsx)(ScrollContainer_1.default, Object.assign({}, ScrollContainerProps, { children: (0, jsx_runtime_1.jsx)(material_1.List, Object.assign({ className: classes.drawerContent, onClick: onClose }, { children: drawerContent })) })), showDrawerFooterContent && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ component: "div", className: classes.drawerFooter }, { children: footerContent || ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.drawerFooterLiveStream }, { children: (0, jsx_runtime_1.jsx)(CreateLiveStreamButton_1.default, Object.assign({ color: "primary", className: classes.drawerFooterLiveStreamButton, fullWidth: true }, CreateLiveStreamButtonComponentProps)) }))) })) }))] })));
}
exports.default = NavigationMenuDrawer;