UNPKG

@drivy/cobalt

Version:

Opinionated design system for Drivy's projects.

22 lines (19 loc) 1.12 kB
import { jsx, jsxs } from 'react/jsx-runtime'; import cx from 'classnames'; import { Icon } from '../Icon/index.js'; import { withFieldLabelAndHint } from './field.js'; const TextInputWrapper = ({ icon, status, render, }) => { return (jsxs("div", { className: cx("cobalt-TextField", { "cobalt-TextField--withIcon": icon, "cobalt-TextField--success": status === "success", "cobalt-TextField--error": status === "error", }), children: [render("cobalt-TextField__Input"), icon && jsx(Icon, { source: icon, className: "cobalt-TextField__Icon" })] })); }; const TextInput = ({ icon, status, type = "text", forwardedRef, ...inputProps }) => (jsx(TextInputWrapper, { icon: icon, status: status, render: (className) => { return (jsx("input", { type: type, ...inputProps, className: className, ref: forwardedRef })); } })); TextInput.displayName = "TextInputRaw"; const wrappedComponent = withFieldLabelAndHint(TextInput); wrappedComponent.displayName = "TextInput"; export { wrappedComponent as TextInput, TextInputWrapper }; //# sourceMappingURL=TextInput.js.map