"use client"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { ArrowLeft, Search } from "lucide-react"; import { motion } from "motion/react"; import { useState, useEffect } from "react"; interface InputWithBackProps { isExpanded: boolean; setIsExpanded: (isExpanded: boolean) => void; placeholder?: string; value?: string; onChange?: (value: string) => void; } export function InputWithBack({ isExpanded, setIsExpanded, placeholder = "Search anything", value, onChange, }: InputWithBackProps) { const [containerRef, setContainerRef] = useState(null); const [buttonOffset, setButtonOffset] = useState(-60); const smoothTransition = { duration: 0.35, ease: [0.25, 0.1, 0.25, 1] as const, }; useEffect(() => { if (containerRef) { const rect = containerRef.getBoundingClientRect(); setButtonOffset(-rect.left - 48); } }, [containerRef]); return (
setIsExpanded(!isExpanded)} >
onChange?.(e.target.value)} />
); }