import { jsx as _jsx } from "react/jsx-runtime";
import { useMemo } from "react";
import { cn } from "../utils/css";
import { withFixedStyle } from "./colHOC";
export const ColItem = (props)=>{
    const { col, record, index, style } = props;
    const { align } = col;
    const content = useMemo(()=>{
        const { col } = props;
        const { dataIndex, formatter, render } = col;
        let value = props.record[dataIndex];
        if (formatter) {
            value = formatter(value, props.record, props.index);
        }
        if (render) {
            return render(value, props.record, props.index);
        }
        return value;
    }, [
        col,
        record
    ]);
    return /*#__PURE__*/ _jsx("td", {
        className: cn("orderly-ui-table-td orderly-py-[2px] orderly-px-1 whitespace-nowrap group-hover:!orderly-bg-base-800", props.justified && "first:orderly-pl-0 last:orderly-pr-0", col.className, align === "right" && "orderly-text-right", col.fixed && "orderly-sticky orderly-z-10"),
        style: {
            backgroundColor: col.fixed ? "var(--table-background-color)" : "transparent",
            ...style
        },
        children: content
    });
};
export const Col = withFixedStyle(ColItem);

//# sourceMappingURL=col.js.map