@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
33 lines • 2.13 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BadgeControlled = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = __importDefault(require("react"));
const stylesName_1 = require("../../constants/stylesName/stylesName");
const useStyles_1 = require("../../hooks/useStyles/useStyles");
const errorBoundary_1 = require("../../provider/errorBoundary/errorBoundary");
const fallbackComponent_1 = require("../../provider/errorBoundary/fallbackComponent");
const badgeStandAlone_1 = require("./badgeStandAlone");
const status_1 = require("./types/status");
const BadgeControlledComponent = react_1.default.forwardRef(({ ctv, cts, ...props }, ref) => {
const styles = (0, useStyles_1.useStyles)(stylesName_1.STYLES_NAME.BADGE, props.variant, ctv);
const iconStyles = styles[props.open ? status_1.BadgeStatus.OPEN : status_1.BadgeStatus.CLOSE];
const sizeStyles = (0, useStyles_1.useStyles)(stylesName_1.STYLES_NAME.BADGE, props.size, cts);
return ((0, jsx_runtime_1.jsx)(badgeStandAlone_1.BadgeStandAlone, { ...props, ref: ref, iconStyles: iconStyles, sizeStyles: sizeStyles, styles: styles }));
});
BadgeControlledComponent.displayName = 'BadgeControlledComponent';
const BagdeBoundary = (props, ref) => ((0, jsx_runtime_1.jsx)(errorBoundary_1.ErrorBoundary, { fallBackComponent: (0, jsx_runtime_1.jsx)(fallbackComponent_1.FallbackComponent, { children: (0, jsx_runtime_1.jsx)(badgeStandAlone_1.BadgeStandAlone, { ...props, ref: ref }) }), children: (0, jsx_runtime_1.jsx)(BadgeControlledComponent, { ...props, ref: ref }) }));
/**
* @deprecated Try the new BadgeV2 component
*
* @description
* Badge component is a component that shows a badge with a number or a dot.
* @param {React.PropsWithChildren<IBadgeControlled<V>>} props
* @returns {JSX.Element}
*/
const BadgeControlled = react_1.default.forwardRef(BagdeBoundary);
exports.BadgeControlled = BadgeControlled;
//# sourceMappingURL=badgeControlled.js.map