'use client' import { useCallback } from 'react' import { motion, AnimatePresence } from 'framer-motion' import { Plus, Trash2, GripVertical } from 'lucide-react' import type { InstallMdTodoItem } from '@/types' import { createEmptyTodoItem } from '@/lib/install-md-generator' interface TodoEditorProps { items: InstallMdTodoItem[] onChange: (items: InstallMdTodoItem[]) => void } export default function TodoEditor({ items, onChange }: TodoEditorProps) { const handleAddItem = useCallback(() => { onChange([...items, createEmptyTodoItem()]) }, [items, onChange]) const handleRemoveItem = useCallback((id: string) => { if (items.length <= 1) return onChange(items.filter(item => item.id !== id)) }, [items, onChange]) const handleUpdateItem = useCallback((id: string, text: string) => { onChange(items.map(item => item.id === id ? { ...item, text } : item )) }, [items, onChange]) const handleToggleCompleted = useCallback((id: string) => { onChange(items.map(item => item.id === id ? { ...item, completed: !item.completed } : item )) }, [items, onChange]) const handleMoveItem = useCallback((fromIndex: number, toIndex: number) => { if (toIndex < 0 || toIndex >= items.length) return const newItems = [...items] const [removed] = newItems.splice(fromIndex, 1) newItems.splice(toIndex, 0, removed) onChange(newItems) }, [items, onChange]) return (
Tip: These appear as checkboxes in the install.md. The LLM will work through them sequentially.