'use client'; import { useState, useCallback } from 'react'; import { Type, Link, Mail, Phone, MessageSquare, Wifi, Eye, EyeOff, Sparkles, } from 'lucide-react'; import type { ContentType, WifiData, EmailData, SmsData, SecurityType } from '../lib/types'; import { CONTENT_TYPE_LABELS } from '../lib/types'; import { detectContentType } from '../lib/qr-renderer'; const ICONS: Record = { text: , url: , email: , phone: , sms: , wifi: , }; interface ContentInputProps { contentType: ContentType; onContentTypeChange: (type: ContentType) => void; rawContent: string; onRawContentChange: (content: string) => void; wifiData: WifiData; onWifiDataChange: (data: WifiData) => void; emailData: EmailData; onEmailDataChange: (data: EmailData) => void; smsData: SmsData; onSmsDataChange: (data: SmsData) => void; maxChars: number; currentChars: number; onAutoDetect: (type: ContentType) => void; } export default function ContentInput({ contentType, onContentTypeChange, rawContent, onRawContentChange, wifiData, onWifiDataChange, emailData, onEmailDataChange, smsData, onSmsDataChange, maxChars, currentChars, onAutoDetect, }: ContentInputProps) { const [showPassword, setShowPassword] = useState(false); const [autoDetected, setAutoDetected] = useState(false); const handleTextChange = useCallback( (value: string) => { onRawContentChange(value); if (contentType === 'text' && value.length > 3) { const detected = detectContentType(value); if (detected !== 'text') { setAutoDetected(true); onAutoDetect(detected); setTimeout(() => setAutoDetected(false), 2000); } } }, [contentType, onRawContentChange, onAutoDetect] ); const types: ContentType[] = ['text', 'url', 'email', 'phone', 'sms', 'wifi']; return (
{/* Content Type Selector */}
{types.map((type) => ( ))}
{/* Auto-detect indicator */} {autoDetected && (
Type détecté automatiquement
)} {/* Input Forms */}
{contentType === 'text' && (