import type { InputHTMLAttributes, ReactNode } from 'react';
import classnames from 'classnames';
import { HStack, VStack } from './Stacks';
import Editor from './Editor/Editor';
interface Props extends Omit, 'size' | 'onChange'> {
name: string;
label: string;
hideLabel?: boolean;
labelClassName?: string;
containerClassName?: string;
onChange?: (value: string) => void;
onSubmit?: () => void;
useTemplating?: boolean;
useEditor?: boolean;
leftSlot?: ReactNode;
rightSlot?: ReactNode;
size?: 'sm' | 'md';
}
export function Input({
label,
hideLabel,
className,
containerClassName,
labelClassName,
onSubmit,
useTemplating,
size = 'md',
useEditor,
onChange,
name,
leftSlot,
rightSlot,
defaultValue,
...props
}: Props) {
const id = `input-${name}`;
return (
{leftSlot}
{useEditor ? (
) : (
onChange?.(e.target.value)}
className={classnames(
className,
'bg-transparent min-w-0 pl-3 pr-2 h-full w-full focus:outline-none',
leftSlot && '!pl-1',
rightSlot && '!pr-1',
)}
{...props}
/>
)}
{rightSlot}
);
}