"use client"; import { cn } from "@/utils/cn"; import { type InputProps, InputState, useInput } from "@/utils/input"; import Link from "next/link"; import { TailSpin } from "react-loading-icons"; import { Badge } from "../ui/badge"; import { Input } from "../ui/input"; import { Textarea } from "../ui/textarea"; interface Props { link?: string; badge?: string; max?: number; placeholder?: string; multiline?: boolean; resetState?: string; } export function InputText({ className, label, link, badge, description, disabled, max = 256, placeholder, multiline, resetState, endpoint, k, defaultState, transform, onSave }: InputProps & Props) { const { value, state, error, update, reset } = useInput({ endpoint, k, defaultState, transform, onSave, debounceMs: 1_000 }); const showCharCount = max - 64 < (value?.length || 0); const nearLimit = max - 8 < (value?.length || 0); return (
{label} {badge && ( {badge} )} {state === InputState.Loading && ( )} {resetState !== undefined && resetState !== value && ( )} {showCharCount && ( {value?.length || 0}/{max} )}
{multiline || max > 300 ? (