UNPKG

@drivy/cobalt

Version:

Opinionated design system for Drivy's projects.

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