import * as React from 'react' import { cn } from '../core/cn' interface CrudField { key: string label: string type: 'text' | 'number' | 'email' | 'select' | 'textarea' required?: boolean options?: Array<{ label: string; value: string }> placeholder?: string } interface CrudPageProps> { title: string subtitle?: string data: T[] fields: CrudField[] columns: Array<{ key: keyof T label: string render?: (value: unknown, row: T) => React.ReactNode }> onAdd?: (item: Partial) => void onEdit?: (item: T) => void onDelete?: (item: T) => void actions?: React.ReactNode className?: string } export function crudPage>({ title, subtitle, data, fields, columns, onAdd, onEdit, onDelete, actions, className, }: CrudPageProps): React.ReactElement { return (
{/* Header */}

{title}

{subtitle &&

{subtitle}

}
{actions} {onAdd && ( )}
{/* Table */}
{columns.map((col) => ( ))} {(onEdit || onDelete) && ( )} {data.length === 0 ? ( ) : ( data.map((row, i) => ( {columns.map((col) => ( ))} {(onEdit || onDelete) && ( )} )) )}
{col.label} Actions
No items yet.
{col.render ? col.render(row[col.key], row) : String(row[col.key] ?? '')}
{onEdit && ( )} {onDelete && ( )}
{/* Form fields definition (for agent use — renders a form preview) */}
) } export type { CrudPageProps, CrudField }