import { useState } from 'react' import { Input } from '@/components/ui/input' import { Copy, Eye, EyeOff } from 'lucide-react' import { cn } from '@/lib/utils' type InputControl = { type?: string placeholder?: string value: string onChange: (value: string) => void inputActions?: string[] className?: string } export function InputControl({ type = 'text', placeholder = '', value = '', onChange, className, inputActions = [], }: InputControl) { const [showPassword, setShowPassword] = useState(false) const hasInputActions = inputActions && inputActions.length > 0 const copyToClipboard = () => { if (value) { navigator.clipboard.writeText(value) } } const inputType = type === 'password' && showPassword ? 'text' : type return (
onChange(e.target.value)} className={cn( type === 'number' ? 'w-16' : 'w-full', hasInputActions && 'pr-16' )} />
{hasInputActions && inputActions.includes('unobscure') && type === 'password' && ( )} {hasInputActions && inputActions.includes('copy') && ( )}
) }