tsx import React, { useCallback } from 'react' import { useAppStore } from '@/store/useAppStore' import { CHARACTER_LIMITS } from '@/utils/constants' import { getCharacterWarnings } from '@/utils/validation' import { AlertTriangle, Info } from 'lucide-react' /** * Component for prompt input with character counting and validation */ export function PromptInput() { const { prompt, characterCount, setPrompt, validation } = useAppStore() const validationResult = validation() const characterWarnings = getCharacterWarnings(characterCount) /** * Handle input change with debouncing */ const handleChange = useCallback((e: React.ChangeEvent) => { setPrompt(e.target.value) }, [setPrompt]) /** * Get character count color based on limits */ const getCharacterCountColor = () => { if (characterCount > CHARACTER_LIMITS.WARNING) { return 'text-yellow-600 dark:text-yellow-400' } if (characterCount > CHARACTER_LIMITS.INPUT * 0.9) { return 'text-red-600 dark:text-red-400' } return 'text-gray-600 dark:text-gray-400' } /** * Get character count background color */ const getCharacterCountBg = () => { if (characterCount > CHARACTER_LIMITS.WARNING) { return 'bg-yellow-100 dark:bg-yellow-900' } if (characterCount > CHARACTER_LIMITS.INPUT * 0.9) { return 'bg-red-100 dark:bg-red-900' } return 'bg-gray-100 dark:bg-gray-700' } return (
{/* Character Counter */}
{characterCount.toLocaleString()} / {CHARACTER_LIMITS.INPUT.toLocaleString()} Zeichen
{characterCount > CHARACTER_LIMITS.WARNING && (
Langer Prompt
)}
{/* Main Textarea */}