"use client"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; import { FieldGroup, Field, FieldLabel } from "@/components/ui/field"; import { Input } from "@/components/ui/input"; type AddItemDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; title: string; description: string; fieldLabel: string; fieldId: string; placeholder: string; onAdd: (name: string) => void; }; export function AddItemDialog({ open, onOpenChange, title, description, fieldLabel, fieldId, placeholder, onAdd, }: AddItemDialogProps) { const [name, setName] = useState(""); const handleSubmit = () => { const trimmed = name.trim(); if (!trimmed) return; onAdd(trimmed); setName(""); onOpenChange(false); }; return ( { onOpenChange(v); if (!v) setName(""); }} > {title} {description} {fieldLabel} setName(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter") handleSubmit(); }} placeholder={placeholder} /> キャンセル} /> ); }