UNPKG

@talend/react-components

Version:
155 lines 5.65 kB
import { useTranslation } from 'react-i18next'; import PropTypes from 'prop-types'; import AppSwitcher from '../AppSwitcher'; import I18N_DOMAIN_COMPONENTS from '../constants'; import Inject from '../Inject'; import { getTheme } from '../theme'; import { AppNotification } from './primitives/AppNotification.component'; import { CallToAction } from './primitives/CallToAction.component'; import { Environment } from './primitives/Environment.component'; import { GenericAction } from './primitives/GenericAction.component'; import { Help } from './primitives/Help.component'; import { Information } from './primitives/Information.component'; import { Intercom } from './primitives/Intercom.component'; import { Logo } from './primitives/Logo.component'; import { Search } from './primitives/Search.component'; import { User } from './primitives/User.component'; import headerBarCssModule from './HeaderBar.module.scss'; import { omit } from "lodash"; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; const theme = getTheme(headerBarCssModule); function HeaderBar(props) { const { t } = useTranslation(I18N_DOMAIN_COMPONENTS); const Components = Inject.getAll(props.getComponent, { Logo, Environment, CallToAction, GenericAction, Search, User, Information, Help, AppNotification, Intercom }); const AppSwitcherComponent = props.AppSwitcher || Inject.get(props.getComponent, 'AppSwitcher', AppSwitcher); let notificationCenter; const { NotificationCenter } = props; if (NotificationCenter) { notificationCenter = /*#__PURE__*/_jsx(NotificationCenter, {}); } else if (props.notification) { // Deprecated: use @talend ee notificationCenter = /*#__PURE__*/_jsx(Components.AppNotification, { getComponent: props.getComponent, ...props.notification, t: t }); } let intercom; const { Intercom: CustomIntercom } = props; if (CustomIntercom) { intercom = /*#__PURE__*/_jsx(CustomIntercom, {}); } else if (props.intercom) { // Deprecated use @talend ee intercom = /*#__PURE__*/_jsx(Components.Intercom, { getComponent: props.getComponent, ...props.intercom }); } return /*#__PURE__*/_jsxs("nav", { className: theme('tc-header-bar', 'navbar', 'navbar-inverse'), children: [/*#__PURE__*/_jsxs("ul", { className: theme('tc-header-bar-actions', 'navbar-nav'), children: [props.logo && /*#__PURE__*/_jsx(Components.Logo, { getComponent: props.getComponent, ...props.logo, t: t }), /*#__PURE__*/_jsx(AppSwitcherComponent, { ...props.brand, ...props.products, isSeparated: !!props.env }), props.env && /*#__PURE__*/_jsx(Components.Environment, { getComponent: props.getComponent, ...props.env })] }), /*#__PURE__*/_jsxs("ul", { className: theme('tc-header-bar-actions', 'navbar-nav', 'right'), children: [props.genericAction && /*#__PURE__*/_jsx(Components.GenericAction, { getComponent: props.getComponent, ...props.genericAction }), props.callToAction && /*#__PURE__*/_jsx(Components.CallToAction, { getComponent: props.getComponent, ...props.callToAction }), props.search && /*#__PURE__*/_jsx(Components.Search, { getComponent: props.getComponent, ...props.search }), notificationCenter && /*#__PURE__*/_jsx("li", { role: "presentation", className: theme('tc-header-bar-notification-center', 'tc-header-bar-action', 'separated'), children: notificationCenter }), intercom && /*#__PURE__*/_jsx("li", { role: "presentation", className: theme('tc-header-bar-intercom', 'tc-header-bar-action', 'separated'), children: intercom }), props.help && /*#__PURE__*/_jsx(Components.Help, { getComponent: props.getComponent, ...props.help, t: t }), !props.user && props.information && /*#__PURE__*/_jsx(Components.Information, { getComponent: props.getComponent, ...props.information, t: t }), props.user && /*#__PURE__*/_jsx(Components.User, { getComponent: props.getComponent, ...props.user, t: t })] })] }); } HeaderBar.Logo = Logo; HeaderBar.Environment = Environment; HeaderBar.CallToAction = CallToAction; HeaderBar.Search = Search; HeaderBar.GenericAction = GenericAction; HeaderBar.Help = Help; HeaderBar.Information = Information; HeaderBar.User = User; HeaderBar.displayName = 'HeaderBar'; HeaderBar.propTypes = { AppSwitcher: PropTypes.func, Intercom: PropTypes.func, NotificationCenter: PropTypes.func, logo: PropTypes.shape(omit(Logo.propTypes, 't')), brand: PropTypes.shape({ isSeparated: PropTypes.bool, renderers: PropTypes.shape({ Action: PropTypes.func }), icon: PropTypes.string, iconUrl: PropTypes.string }), env: PropTypes.shape(Environment.propTypes), callToAction: PropTypes.shape(CallToAction.propTypes), genericAction: PropTypes.shape(GenericAction.propTypes), search: PropTypes.shape(Search.propTypes), help: PropTypes.shape(omit(Help.propTypes, 't')), information: PropTypes.shape(omit(Information.propTypes, 't')), intercom: PropTypes.shape(Intercom.propTypes), user: PropTypes.shape(User.propTypes), notification: PropTypes.shape(omit(AppNotification.propTypes, 't')), products: PropTypes.shape({ items: PropTypes.array, onSelect: PropTypes.func }), getComponent: PropTypes.func, t: PropTypes.func }; export default HeaderBar; //# sourceMappingURL=HeaderBar.component.js.map