bisalsaha's picture
Upload 8831 files
a7060a0 verified
Raw History Blame Contribute Delete
798 Bytes
import { forwardRef, useMemo } from "react";
import { cn } from "../../utils/bem";
import Label from "../Label/Label";
import "./Input.prefix.css";
const Input = forwardRef(({ label, className, required, labelProps, ghost, waiting, ...props }, ref) => {
const rootClass = cn("input");
const classList = [rootClass.mod({ ghost }), className].join(" ").trim();
const input = useMemo(() => {
return waiting ? (
<div className={rootClass.elem("spinner").toClassName()} />
) : (
<input {...props} ref={ref} className={classList} />
);
}, [props, ref, classList, waiting]);
return label ? (
<Label {...(labelProps ?? {})} text={label} required={required}>
{input}
</Label>
) : (
input
);
});
Input.displayName = "Input";
export default Input;