'use client';
import { forwardRef, TableHTMLAttributes } from 'react';
import styles from './data-grid.module.css';
export interface DataGridColumn {
key: keyof T;
header: string;
width?: string;
}
export interface DataGridProps> extends Omit, 'children'> {
/** Column definitions */
columns: DataGridColumn[];
/** Data rows */
data: T[];
/** Color variant */
variant?: 'cyan' | 'green' | 'amber';
/** Striped rows */
striped?: boolean;
/** Hoverable rows */
hoverable?: boolean;
}
function DataGridInner>(
{
columns,
data,
variant = 'cyan',
striped = true,
hoverable = true,
className,
...props
}: DataGridProps,
ref: React.ForwardedRef
) {
return (
{columns.map((col) => (
|
{col.header}
|
))}
{data.map((row, i) => (
{columns.map((col) => (
|
{String(row[col.key])}
|
))}
))}
);
}
export const DataGrid = forwardRef(DataGridInner) as >(
props: DataGridProps & { ref?: React.ForwardedRef }
) => JSX.Element;
export default DataGrid;