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