import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { cn } from "../../lib/utils";
export function SimpleTable({ items, columns, onRowHover, onRowClick, rowClassName, rowTestId, rowKey, "data-testid": dataTestId, }) {
    const getAlignClassName = (align) => {
        switch (align) {
            case "center":
                return "text-center";
            case "right":
                return "text-right";
            default:
                return "text-left";
        }
    };
    return (_jsxs("table", { className: "text-surface min-w-full table-auto text-left text-xs font-light", "data-testid": dataTestId, children: [_jsx("thead", { className: "border-border-default border-b", children: _jsx("tr", { children: columns.map((col, index) => (_jsx("th", { className: cn("px-1.5 py-1.5 align-middle font-medium", getAlignClassName(col.align)), children: col.header }, index))) }) }), _jsx("tbody", { children: items.map((item, index) => (_jsx("tr", { "data-testid": rowTestId?.(item), className: cn("border-border-default border-b", onRowClick ? "hover:bg-neutral-grey-5 cursor-pointer" : "", rowClassName ? rowClassName(item) : ""), onClick: (ev) => {
                        if (onRowClick)
                            onRowClick({ item, event: ev });
                    }, onMouseOver: () => onRowHover?.(item), onMouseLeave: () => onRowHover?.(undefined), children: columns.map((col, index) => (_jsx("td", { className: cn("p-2 align-middle", getAlignClassName(col.align), col.className), children: col.body(item) }, index))) }, rowKey?.(item) ?? index))) })] }));
}
//# sourceMappingURL=SimpleTable.js.map