import clsx from 'clsx' import type { ComponentProps, ReactNode, Ref } from 'react' import { match } from 'ts-pattern' import styles from './Input.module.css' type Props = Omit, 'size'> & { align?: 'left' | 'right' size?: 'md' | 'sm' | 'xs' leftIcon?: ReactNode rightIcon?: ReactNode wrapperClassName?: string error?: boolean | undefined ref?: Ref } export const Input = ({ type = 'text', align = 'left', size = 'md', className, wrapperClassName, leftIcon, rightIcon, disabled, readOnly, error, ref, ...rest }: Props) => { const sizeClassName = match(size) .with('md', () => styles.md) .with('sm', () => styles.sm) .with('xs', () => styles.xs) .exhaustive() return (
{leftIcon &&
{leftIcon}
} {rightIcon &&
{rightIcon}
}
) }