import { Checkbox as BaseCheckbox } from "@base-ui/react/checkbox"; import { Radio as BaseRadio } from "@base-ui/react/radio"; import { RadioGroup } from "@base-ui/react/radio-group"; import { Select as BaseSelect } from "@base-ui/react/select"; import { CaretUpDownIcon, CheckIcon } from "../icons"; import { useId, type ComponentProps, type ReactNode } from "react"; import { cn } from "./cn"; const FIELD = "w-full rounded-control bg-field text-ink shadow-[inset_0_0_0_1px_var(--line)] placeholder:text-faint transition-[box-shadow,background-color] duration-150 hover:shadow-[inset_0_0_0_1px_color-mix(in_oklab,var(--ink)_26%,transparent)] focus:outline-none focus-visible:outline-none focus:shadow-[inset_0_0_0_1px_var(--accent-hover),0_0_0_3px_var(--accent-tint)] disabled:opacity-50 aria-invalid:shadow-[inset_0_0_0_1px_var(--danger)] aria-invalid:focus:shadow-[inset_0_0_0_1px_var(--danger),0_0_0_3px_var(--danger-tint)]"; interface FieldText { label?: ReactNode; description?: ReactNode; error?: ReactNode; } function Frame({ id, label, description, error, children, className }: FieldText & { id: string; children: ReactNode; className?: string }) { return (
{label && ( )} {children} {error ? (

{error}

) : ( description && (

{description}

) )}
); } export type InputProps = FieldText & Omit, "size"> & { size?: "base" | "lg" }; /** A single-line text field with its label, help text and error. */ export function Input({ label, description, error, size = "base", className, id, ...props }: InputProps) { const generated = useId(); const field = id ?? generated; return ( ); } export type InputAreaProps = FieldText & ComponentProps<"textarea"> & { onValueChange?: (value: string) => void }; /** A multi-line text field. `onValueChange` receives the text on every edit. */ export function InputArea({ label, description, error, className, id, onValueChange, onChange, rows = 4, ...props }: InputAreaProps) { const generated = useId(); const field = id ?? generated; return (