import classnames from 'classnames'; import type { HTMLAttributes, ReactNode } from 'react'; import type { EditorProps } from './Editor'; import { Editor } from './Editor'; import { HStack, VStack } from './Stacks'; type Props = Omit, 'onChange' | 'onFocus'> & { name: string; label: string; hideLabel?: boolean; labelClassName?: string; containerClassName?: string; onChange?: (value: string) => void; onFocus?: () => void; useEditor?: Pick; defaultValue?: string; leftSlot?: ReactNode; rightSlot?: ReactNode; size?: 'sm' | 'md'; className?: string; placeholder?: string; autoFocus?: boolean; }; 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-0.5', !!rightSlot && '!pr-0.5', ); return ( {leftSlot} {useEditor ? ( ) : ( onChange?.(e.currentTarget.value)} placeholder={placeholder} defaultValue={defaultValue} className={inputClassName} {...props} /> )} {rightSlot} ); }