import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { useMemo } from "react";
import { Col } from "./col";
import { cn } from "../utils/css";
import { ExpandRow } from "./expandRow";
export const Row = (props)=>{
    const { columns, record, index, bordered } = props;
    const cols = useMemo(()=>{
        return columns.map((column, index)=>{
            return /*#__PURE__*/ _jsx(Col, {
                col: column,
                index: index,
                record: record,
                justified: props.justified
            }, column.dataIndex);
        });
    }, [
        columns,
        record
    ]);
    const rowAttrs = useMemo(()=>{
        if (typeof props.onRow === "function") {
            return props.onRow(record, index);
        }
        return {};
    }, [
        record,
        index
    ]);
    const { className, ...rest } = rowAttrs;
    return /*#__PURE__*/ _jsxs(_Fragment, {
        children: [
            /*#__PURE__*/ _jsx("tr", {
                className: cn("orderly-ui-table-tr hover:orderly-bg-base-800 orderly-group", props.bordered && "orderly-border-b orderly-border-divider last:orderly-border-b-0", props.canExpand && "orderly-cursor-pointer", className),
                onClick: (event)=>{
                    if (!props.canExpand) return;
                    props.onToggleExpand(props.rowKey);
                    event.preventDefault();
                    event.stopPropagation();
                },
                ...rest,
                children: cols
            }),
            props.expanded && /*#__PURE__*/ _jsx(ExpandRow, {
                columns: columns,
                expandRowRender: props.expandRowRender,
                record: record,
                index: index,
                bordered: bordered
            })
        ]
    });
};

//# sourceMappingURL=row.js.map