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

28 lines 1.84 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.PillControlled = 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 pillStandAlone_1 = require("./pillStandAlone"); const PillControlledComponent = react_1.default.forwardRef((props, ref) => { const sizeStyles = (0, useStyles_1.useStyles)(stylesName_1.STYLES_NAME.PILL, props.size, props.ctv); const variantStyles = sizeStyles ? sizeStyles[props.variant] : {}; const handleOnChange = event => { props.onPillChange?.(event.target.checked, props.value || ''); }; return ((0, jsx_runtime_1.jsx)(pillStandAlone_1.PillStandAlone, { ...props, ref: ref, styles: variantStyles, onPillChange: handleOnChange, children: props.children })); }); PillControlledComponent.displayName = 'PillControlledComponent'; const PillBoundary = (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)(pillStandAlone_1.PillStandAlone, { ...props, ref: ref }) }), children: (0, jsx_runtime_1.jsx)(PillControlledComponent, { ...props, ref: ref }) })); /** * @deprecated Try the new PillV2 component */ exports.PillControlled = react_1.default.forwardRef(PillBoundary); //# sourceMappingURL=pillControlled.js.map