import { useId } from 'react' import type { InputHTMLAttributes, ReactNode } from 'react' import type { LucideIcon } from 'lucide-react' import { cn } from '../../lib/cn.ts' export const FIELD_BASE = 'w-full rounded-lg border bg-surface-2 text-fg placeholder:text-fg-subtle transition-colors focus:outline-none focus-visible:border-accent disabled:opacity-60' export function FieldFrame({ id, label, hint, error, children, }: { id: string label?: ReactNode hint?: ReactNode error?: ReactNode children: ReactNode }) { return (
{label !== undefined && ( )} {children} {error !== undefined && error !== null && error !== '' ? ( ) : hint !== undefined ? (

{hint}

) : null}
) } export interface InputProps extends InputHTMLAttributes { label?: ReactNode hint?: ReactNode error?: ReactNode icon?: LucideIcon className?: string } export function Input({ label, hint, error, icon: Icon, className, id, ...props }: InputProps) { const autoId = useId() const inputId = id ?? autoId const describedBy = error ? `${inputId}-error` : hint !== undefined ? `${inputId}-hint` : undefined const input = (
{Icon && (
) if (label === undefined && hint === undefined && error === undefined) return input return ( {input} ) }