"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "Row", {
    enumerable: true,
    get: function() {
        return Row;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _react = require("react");
const _col = require("./col");
const _css = require("../utils/css");
const _expandRow = require("./expandRow");
const Row = (props)=>{
    const { columns, record, index, bordered } = props;
    const cols = (0, _react.useMemo)(()=>{
        return columns.map((column, index)=>{
            return /*#__PURE__*/ (0, _jsxruntime.jsx)(_col.Col, {
                col: column,
                index: index,
                record: record,
                justified: props.justified
            }, column.dataIndex);
        });
    }, [
        columns,
        record
    ]);
    const rowAttrs = (0, _react.useMemo)(()=>{
        if (typeof props.onRow === "function") {
            return props.onRow(record, index);
        }
        return {};
    }, [
        record,
        index
    ]);
    const { className, ...rest } = rowAttrs;
    return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
        children: [
            /*#__PURE__*/ (0, _jsxruntime.jsx)("tr", {
                className: (0, _css.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__*/ (0, _jsxruntime.jsx)(_expandRow.ExpandRow, {
                columns: columns,
                expandRowRender: props.expandRowRender,
                record: record,
                index: index,
                bordered: bordered
            })
        ]
    });
};

//# sourceMappingURL=row.js.map