"use client"; import { X } from "lucide-react"; import { Input } from "@/components/ui/input"; interface TagInputProps { tags: string[]; onChange: (tags: string[]) => void; } export function TagInput({ tags, onChange }: TagInputProps) { const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Enter" || e.key === ",") { e.preventDefault(); const val = (e.target as HTMLInputElement).value.trim(); if (val && !tags.includes(val)) { onChange([...tags, val]); } (e.target as HTMLInputElement).value = ""; } if (e.key === "Backspace" && (e.target as HTMLInputElement).value === "" && tags.length > 0) { onChange(tags.slice(0, -1)); } }; const removeTag = (tag: string) => { onChange(tags.filter((t) => t !== tag)); }; return (
{tags.map((tag) => ( {tag} ))}
); }