import { useId, type InputHTMLAttributes, type ReactNode } from "react";
import { cn } from "../../lib/cn";
import { PrefixFieldShell } from "../inputs/shared";
export type UhuruInputType = InputHTMLAttributes["type"] | "number-with-options";
export type TextFieldProps = Omit, "type"> & {
label?: string;
hint?: string;
error?: string;
options?: { label: string; value: string }[];
prefixIcon?: ReactNode;
suffixIcon?: ReactNode;
suffixInteractive?: boolean;
type?: UhuruInputType;
};
export function TextField({
className,
label,
hint,
error,
id,
options,
prefixIcon,
suffixIcon,
suffixInteractive = false,
type = "text",
...props
}: TextFieldProps) {
const generatedId = useId();
const fieldId = id ?? generatedId;
const hintId = hint ? `${fieldId}-hint` : undefined;
const errorId = error ? `${fieldId}-error` : undefined;
const listId = options?.length ? `${fieldId}-options` : undefined;
const resolvedType = type === "number-with-options" ? "number" : type;
return (
);
}
export const Input = TextField;