UNPKG

@sap-ux/ui-components

Version:

SAP UI Components Library

28 lines 1.24 kB
import React from 'react'; import { ErrorMessageType, MESSAGE_TYPES_CLASSNAME_MAP } from './utils.js'; import { UiIcons } from '../../components/Icons.js'; import { UIIcon } from '../../components/UIIcon/index.js'; import './MessageWrapper.scss'; export const MESSAGE_ICONS_MAP = new Map([ [undefined, UiIcons.Error], [ErrorMessageType.Error, UiIcons.Error], [ErrorMessageType.Warning, UiIcons.Warning], [ErrorMessageType.Info, UiIcons.Info] ]); /** * Method return MessageWrapper react element. * * @param props * @returns {React.ReactElement} */ export function MessageWrapper(props) { const { children, message } = props; const errorSuffix = message.message ? MESSAGE_TYPES_CLASSNAME_MAP.get(message.type) : undefined; const icon = MESSAGE_ICONS_MAP.get(message.type); return (React.createElement("div", { className: `ts-message-wrapper ts-message-wrapper--${errorSuffix}` }, React.createElement("div", { className: "ts-message-target" }, children), React.createElement("div", { className: "ts-message-body" }, React.createElement(UIIcon, { iconName: icon }), React.createElement("span", null, message.message)))); } //# sourceMappingURL=MessageWrapper.js.map