// * Packages import { Eye, EyeOff } from "lucide-react"; import { useState } from "react"; import { usePage } from "@inertiajs/react"; // * Components shadcn import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Button } from "@/components/ui/button"; // * Other import InputError from "@/back/Components/InputError"; import WordCounter from "@/back/Components/WordCounter"; import { cn } from "@/lib/utils"; import useTrans from "@/hooks/use-translations"; type SimpleInputProps = { className?: string; name: string; label: string; value?: string; id?: string; type?: string; placeholder?: string; wordCounter?: boolean; required?: boolean; disabled?: boolean; checkVisibility?: boolean; // eslint-disable-next-line no-unused-vars setData: (name: string, value: string) => void; }; export default function SimpleInput({ className, value = "", name, label, id = name as string, type = "text", placeholder = "back.enter_text_here", wordCounter = true, required = true, disabled = false, checkVisibility = false, setData, }: SimpleInputProps) { const [isVisible, setIsVisible] = useState(checkVisibility); const { errors } = usePage().props; return (
{wordCounter && }
{ setData(name, e.target.value); }} required={required} disabled={disabled} className={`${ type === "password" || checkVisibility ? "w-[calc(100%-40px-0.25rem)]" : "w-full" } ${errors[name] ? "border-destructive/50" : ""}`} /> {(type === "password" || checkVisibility) && ( )}
); }