UNPKG

@ozen-ui/kit

Version:

React component library

40 lines (39 loc) 3.43 kB
import { __assign, __rest } from "tslib"; import './components/FormControlCarcassHint/FormControlCarcassHint.css'; import './modules/FormControlCarcassIcon/FormControlCarcassIcon.css'; import './FormControlCarcass.css'; import React from 'react'; import { cn } from '../../utils/classname'; import { polymorphicComponentWithRef } from '../../utils/polymorphicComponentWithRef'; import { renderContent } from '../../utils/renderContent'; import { FormControlCarcassHint } from './components'; import { FORM_CONTROL_CARCASS_DEFAULT_AS, FORM_CONTROL_CARCASS_DEFAULT_DISABLED, FORM_CONTROL_CARCASS_DEFAULT_SIZE, FORM_CONTROL_CARCASS_DEFAULT_VARIANT, } from './constants'; import { FormControlCarcassContext } from './FormControlCarcassContext'; export var cnFormControlCarcass = cn('FormControlCarcass'); export var FormControlCarcass = polymorphicComponentWithRef(function (_a, ref) { var _b = _a.size, size = _b === void 0 ? FORM_CONTROL_CARCASS_DEFAULT_SIZE : _b, _c = _a.as, Tag = _c === void 0 ? FORM_CONTROL_CARCASS_DEFAULT_AS : _c, children = _a.children, controlProps = _a.controlProps, label = _a.label, labelProps = _a.labelProps, align = _a.align, _d = _a.disabled, disabled = _d === void 0 ? FORM_CONTROL_CARCASS_DEFAULT_DISABLED : _d, className = _a.className, renderAfter = _a.renderAfter, renderAfterProps = _a.renderAfterProps, _e = _a.variant, variant = _e === void 0 ? FORM_CONTROL_CARCASS_DEFAULT_VARIANT : _e, contentProps = _a.contentProps, mirrored = _a.mirrored, hint = _a.hint, hintProps = _a.hintProps, other = __rest(_a, ["size", "as", "children", "controlProps", "label", "labelProps", "align", "disabled", "className", "renderAfter", "renderAfterProps", "variant", "contentProps", "mirrored", "hint", "hintProps"]); return (React.createElement(FormControlCarcassContext.Provider, { value: { size: size, disabled: disabled, variant: variant, } }, React.createElement(Tag, __assign({}, other, { className: cnFormControlCarcass({ align: align, disabled: disabled, size: size, variant: variant, mirrored: mirrored, }, [className]), ref: ref }), React.createElement("span", __assign({}, controlProps, { className: cnFormControlCarcass('Control', [controlProps === null || controlProps === void 0 ? void 0 : controlProps.className]) }), children), label !== null && label !== undefined && (React.createElement("span", __assign({}, contentProps, { className: cnFormControlCarcass('Content', [ contentProps === null || contentProps === void 0 ? void 0 : contentProps.className, ]) }), React.createElement("span", __assign({}, labelProps, { className: cnFormControlCarcass('Label', [labelProps === null || labelProps === void 0 ? void 0 : labelProps.className]) }), label), hint && (React.createElement(FormControlCarcassHint, __assign({}, hintProps), hint)))), renderAfter && (React.createElement("span", __assign({}, renderAfterProps, { className: cnFormControlCarcass('After', [ renderAfterProps === null || renderAfterProps === void 0 ? void 0 : renderAfterProps.className, ]) }), renderContent({ content: renderAfter, })))))); }); FormControlCarcass.displayName = 'FormControlCarcass';