UNPKG

@kubit-ui-web/react-components

Version:

Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience

48 lines 2.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DecorativeElement = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const avatar_1 = require("../../components/avatar/avatar"); const elementOrIllustration_1 = require("../../components/elementOrIllustration/elementOrIllustration"); const iconHighlighted_1 = require("../../components/iconHighlighted/iconHighlighted"); const errorBoundary_1 = require("../../provider/errorBoundary/errorBoundary"); const elementOrIcon_1 = require("../elementOrIcon/elementOrIcon"); const image_1 = require("../image/image"); const decorativeElement_1 = require("./types/decorativeElement"); /** * @description * DecorativeElementStandAlone component is a wrapper component that can be used to wrap other components. * * @param {IDecorativeElementStandAlone} props * @returns {JSX.Element | null} * @constructor * @example * <DecorativeElementStandAlone * element={{ * [DecorativeType.ICON]: { * variant: 'icon', * iconName: 'iconName', * }, * additionalProps={{ * variant: 'icon', * iconName: 'iconName', * }} * /> * */ const DecorativeElementStandAlone = ({ element, additionalProps = {}, dataTestId = 'decorative-element', }) => { const elementKey = Object.keys(element)[0]; const elementProps = element[elementKey]; const elementsAvailable = { [decorativeElement_1.DecorativeType.ICON]: elementOrIcon_1.ElementOrIcon, [decorativeElement_1.DecorativeType.ICON_HIGHLIGHTED]: iconHighlighted_1.IconHighlighted, [decorativeElement_1.DecorativeType.ILLUSTRATION]: elementOrIllustration_1.ElementOrIllustration, [decorativeElement_1.DecorativeType.IMAGE]: image_1.Image, [decorativeElement_1.DecorativeType.AVATAR]: avatar_1.Avatar, }; const Element = elementsAvailable[elementKey]; return (0, jsx_runtime_1.jsx)(Element, { dataTestId: dataTestId, ...elementProps, ...additionalProps }); }; const DecorativeElement = (props) => ((0, jsx_runtime_1.jsx)(errorBoundary_1.ErrorBoundary, { fallBackComponent: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), children: (0, jsx_runtime_1.jsx)(DecorativeElementStandAlone, { ...props }) })); exports.DecorativeElement = DecorativeElement; //# sourceMappingURL=decorativeElementStandAlone.js.map