import { useState } from 'react'; interface StringArrayEditorProps { value: string[]; onChange: (value: string[]) => void; placeholder?: string; } export function StringArrayEditor({ value, onChange, placeholder }: StringArrayEditorProps) { const [input, setInput] = useState(''); const handleAdd = () => { const trimmed = input.trim(); if (!trimmed) return; onChange([...value, trimmed]); setInput(''); }; const handleRemove = (index: number) => { onChange(value.filter((_, i) => i !== index)); }; return (
setInput(e.target.value)} onKeyDown={e => { if (e.key === 'Enter') { e.preventDefault(); handleAdd(); } }} placeholder={placeholder} className="flex-1 px-3 py-1.5 text-sm border border-slate-300 rounded-lg focus:ring-2 focus:ring-accent-ring focus:border-accent outline-none" />
{value.length > 0 && (
{value.map((item, i) => ( {item} ))}
)}
); }