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