UNPKG

@pagopa/mui-italia

Version:

[Material-UI](https://mui.com/core/) theme inspired by [Bootstrap Italia](https://italia.github.io/bootstrap-italia/).

26 lines (25 loc) 4.23 kB
"use strict"; "use client"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HeaderAccount = void 0; const tslib_1 = require("tslib"); const jsx_runtime_1 = require("react/jsx-runtime"); const material_1 = require("@mui/material"); const ButtonNaked_1 = require("../ButtonNaked"); const AccountDropdown_1 = require("../AccountDropdown"); /* Icons */ const HelpOutlineRounded_1 = tslib_1.__importDefault(require("@mui/icons-material/HelpOutlineRounded")); const MenuBook_1 = tslib_1.__importDefault(require("@mui/icons-material/MenuBook")); const defaultTranslationsMap = { logIn: "Accedi", logOut: "Esci", assistance: "Assistenza", documentation: "Manuale operativo", }; const HeaderAccount = ({ rootLink, loggedUser, userActions, onAssistanceClick, onDocumentationClick, onLogout, onLogin, enableDropdown = false, enableLogin = true, enableAssistanceButton = true, translationsMap = defaultTranslationsMap, }) => ((0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ component: "div", justifyContent: "center", sx: { borderBottom: 1, borderColor: "divider", backgroundColor: "background.paper", minHeight: "48px", } }, { children: (0, jsx_runtime_1.jsx)(material_1.Container, Object.assign({ maxWidth: false }, { children: (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ spacing: 2, direction: "row", justifyContent: "space-between", alignItems: "center" }, { children: [rootLink && ((0, jsx_runtime_1.jsx)(ButtonNaked_1.ButtonNaked, Object.assign({ component: "a", size: "small", "aria-label": rootLink === null || rootLink === void 0 ? void 0 : rootLink.ariaLabel, href: rootLink === null || rootLink === void 0 ? void 0 : rootLink.href, target: "_blank", rel: "noreferrer", title: rootLink === null || rootLink === void 0 ? void 0 : rootLink.title, sx: { fontWeight: "bold" } }, { children: rootLink === null || rootLink === void 0 ? void 0 : rootLink.label }))), (0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", alignItems: "center", spacing: { xs: 1, sm: 3, md: 4 } }, { children: [onDocumentationClick && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ButtonNaked_1.ButtonNaked, Object.assign({ size: "small", component: "button", onClick: onDocumentationClick, startIcon: (0, jsx_runtime_1.jsx)(MenuBook_1.default, {}), sx: { display: ["none", "flex"] }, weight: "default" }, { children: translationsMap.documentation || defaultTranslationsMap.documentation })), (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "small", "aria-label": "Documentazione", sx: { display: ["flex", "none"], color: "text.primary" }, onClick: onDocumentationClick }, { children: (0, jsx_runtime_1.jsx)(MenuBook_1.default, { fontSize: "inherit" }) }))] })), enableAssistanceButton && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ButtonNaked_1.ButtonNaked, Object.assign({ size: "small", component: "button", onClick: onAssistanceClick, startIcon: (0, jsx_runtime_1.jsx)(HelpOutlineRounded_1.default, {}), sx: { display: ["none", "flex"] }, weight: "default" }, { children: translationsMap.assistance || defaultTranslationsMap.assistance })), (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "small", "aria-label": "Assistenza", sx: { display: ["flex", "none"], color: "text.primary" }, onClick: onAssistanceClick }, { children: (0, jsx_runtime_1.jsx)(HelpOutlineRounded_1.default, { fontSize: "inherit" }) }))] })), enableLogin && loggedUser && enableDropdown && ((0, jsx_runtime_1.jsx)(AccountDropdown_1.AccountDropdown, { user: loggedUser, userActions: userActions })), enableLogin && loggedUser && !enableDropdown && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "text", size: "small", onClick: onLogout, title: "Esci" }, { children: translationsMap.logOut || defaultTranslationsMap.logOut }))), enableLogin && !loggedUser && ((0, jsx_runtime_1.jsx)(material_1.Button, Object.assign({ variant: "contained", size: "small", onClick: onLogin, title: "Accedi" }, { children: translationsMap.logIn || defaultTranslationsMap.logIn })))] }))] })) })) }))); exports.HeaderAccount = HeaderAccount;