import { jsx as _jsx } from "react/jsx-runtime";
import { useMemo } from "react";
import { cn } from "../utils/css";
export const ExpandRow = (props)=>{
    const { columns, record, index } = props;
    const cols = useMemo(()=>{
        const cols = [];
        let prev;
        for(let i = 0; i < columns.length; i++){
            const col = columns[i];
            if (i === 0) {
                cols.push({
                    colCount: 1,
                    type: col.fixed
                });
                continue;
            } else {
                prev = columns[i - 1];
            }
            if (col.fixed !== prev?.fixed) {
                cols.push({
                    colCount: 1,
                    type: col.fixed
                });
            } else {
                cols[cols.length - 1] = {
                    ...cols[cols.length - 1],
                    colCount: cols[cols.length - 1].colCount + 1
                };
            }
        }
        return cols;
    }, [
        columns
    ]);
    return /*#__PURE__*/ _jsx("tr", {
        className: cn(props.bordered && "orderly-border-b orderly-border-divider last:orderly-border-b-0"),
        children: cols.map((item, index)=>{
            const pos = item.type === undefined ? {} : item.type === "left" ? {
                left: "0px",
                borderBouttom: "1px solid #e5e5e5"
            } : {
                right: "0px",
                borderBouttom: "1px solid #e5e5e5"
            };
            return /*#__PURE__*/ _jsx("td", {
                colSpan: item.colCount,
                style: {
                    ...pos,
                    backgroundColor: item.type !== undefined ? "var(--table-background-color)" : "transparent"
                },
                className: cn(!!item.type && "orderly-sticky"),
                children: !item.type ? /*#__PURE__*/ _jsx("div", {
                    className: "orderly-bg-base-700 orderly-rounded-[4px] orderly-my-1",
                    children: props.expandRowRender?.(record, index)
                }) : null
            }, index);
        })
    });
};

//# sourceMappingURL=expandRow.js.map