@drivy/cobalt
Version:
Opinionated design system for Drivy's projects.
24 lines (21 loc) • 1.17 kB
JavaScript
import React from 'react';
import cx from 'classnames';
import { Icon } from '../Icon/index.js';
import { withFieldLabelAndHint } from './field.js';
const TextInputWrapper = ({ icon, status, render, }) => {
return (React.createElement("div", { className: cx("cobalt-TextField", {
"cobalt-TextField--withIcon": icon,
"cobalt-TextField--success": status === "success",
"cobalt-TextField--error": status === "error",
}) },
render("cobalt-TextField__Input"),
icon && React.createElement(Icon, { source: icon, className: "cobalt-TextField__Icon" })));
};
const TextInput = ({ icon, status, type = "text", forwardedRef, ...inputProps }) => (React.createElement(TextInputWrapper, { icon: icon, status: status, render: (className) => {
return (React.createElement("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