@talend/react-components
Version:
Set of react components.
79 lines • 2.43 kB
JavaScript
import { forwardRef } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import Inject from '../../Inject';
import theme from './RichLayout.module.scss';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const TooltipPropTypes = {
id: PropTypes.string.isRequired,
children: PropTypes.oneOfType([PropTypes.node, PropTypes.arrayOf(PropTypes.node)]),
className: PropTypes.string
};
const Header = ({
id,
children,
className
}) => /*#__PURE__*/_jsx("header", {
id: id,
className: classNames(theme.header, 'tc-tooltip-header', className),
children: children
});
Header.propTypes = TooltipPropTypes;
const Body = ({
id,
children,
className
}) => /*#__PURE__*/_jsx("div", {
id: id,
className: classNames(theme.body, 'tc-tooltip-body', className),
children: /*#__PURE__*/_jsx("div", {
id: `${id}-content`,
className: classNames(theme.content, 'tc-tooltip-content'),
children: children
})
});
Body.propTypes = TooltipPropTypes;
const Footer = ({
id,
children,
className
}) => /*#__PURE__*/_jsx("footer", {
id: id,
className: classNames(theme.footer, 'tc-tooltip-footer', className),
children: children
});
Footer.propTypes = TooltipPropTypes;
const RichLayout = /*#__PURE__*/forwardRef((props, ref) => /*#__PURE__*/_jsxs("div", {
id: props.id,
className: theme['rich-layout'],
ref: ref,
tabIndex: "-1",
children: [/*#__PURE__*/_jsx(Header, {
id: `${props.id}-header`,
children: Inject.getReactElement(props.getComponent, props.Header)
}), /*#__PURE__*/_jsxs(Body, {
id: `${props.id}-body`,
className: props.className,
children: [props.text && /*#__PURE__*/_jsx("p", {
children: props.text
}), !props.text && Inject.getReactElement(props.getComponent, props.Content)]
}), /*#__PURE__*/_jsx(Footer, {
id: `${props.id}-footer`,
children: Inject.getReactElement(props.getComponent, props.Footer)
})]
}));
RichLayout.Header = Header;
RichLayout.Body = Body;
RichLayout.Footer = Footer;
RichLayout.displayName = 'RichLayout';
RichLayout.propTypes = {
className: PropTypes.string,
Content: Inject.getReactElement.propTypes,
getComponent: PropTypes.func,
Header: Inject.getReactElement.propTypes,
Footer: Inject.getReactElement.propTypes,
text: PropTypes.string,
id: PropTypes.string.isRequired
};
export default RichLayout;
//# sourceMappingURL=RichLayout.component.js.map