quivr/frontend/lib/components/ui/Field.tsx
Mamadou DICKO 36fd146fed
feat: improve app ux (#1281)
* style: make FeedItemIcon the same size

* feat: update feed component brain selector label position

* style: change purple to 600

* feat: improve already dropped file message ux

* feat: autoclose feedinput on chatId change

* style: change chat colors

* feat: prevent linebreak in knowledge to upload row

* feat(textFIeld): avoid textfield content going under icon

* feat(knowledgeToUpload): add tooltip on urls and files name

* feat(feedBrain): auto scroll on messages when feed modal get opened

* style: update colors

* refactor: rename uploadCard to FeedCard
2023-09-29 10:24:31 +02:00

67 lines
1.5 KiB
TypeScript

import {
DetailedHTMLProps,
forwardRef,
InputHTMLAttributes,
RefObject,
} from "react";
import { cn } from "@/lib/utils";
interface FieldProps
extends DetailedHTMLProps<
InputHTMLAttributes<HTMLInputElement>,
HTMLInputElement
> {
label?: string;
name: string;
icon?: React.ReactNode;
inputClassName?: string;
}
const Field = forwardRef(
(
{
label,
className,
name,
inputClassName,
required = false,
icon,
...props
}: FieldProps,
forwardedRef
) => {
return (
<fieldset className={cn("flex flex-col w-full", className)} name={name}>
{label !== undefined && (
<label htmlFor={name} className="text-sm">
{label}
{required && <span>*</span>}
</label>
)}
<div className="relative">
<input
ref={forwardedRef as RefObject<HTMLInputElement>}
className={cn(
`w-full bg-gray-50 dark:bg-gray-900 px-4 py-2 border rounded-md border-black/10 dark:border-white/25`,
icon !== undefined ? "pr-12" : "",
inputClassName
)}
name={name}
id={name}
{...props}
/>
{icon !== undefined && (
<div className="absolute inset-y-0 right-0 pr-3 flex items-center">
{icon}
</div>
)}
</div>
</fieldset>
);
}
);
Field.displayName = "Field";
export default Field;