"use client"; import React from "react"; import { Button } from "../Button/"; import { Icon } from "../Icon/"; import { Cell } from "./Cell"; import TableContext from "./TableContext"; import type { TableRow } from "./types"; interface RowProps { row: TableRow; } const Row = ({ row }: RowProps) => { const { headers, expandableRows, isResponsive } = React.useContext(TableContext); return headers.map(({ key, label, cellProps }, index, array) => { const cell = row[key]; const isObject = typeof cell === "object" && cell !== null; const value = isObject && "value" in cell ? cell.value : cell; const props = isObject && "value" in cell ? Object.entries(cell) .filter(([k]) => k !== "value" && k !== "rawValue") .reduce((acc, [k, v]) => ({ ...acc, [k]: v }), {}) : {}; const rl = row?.expand?.length || 0; return ( {value ? (value as React.ReactNode) : ""} {index === array.length - 1 && expandableRows?.hasExpandableRows && (row?.expand ? ( ) : ( {expandableRows?.expandableRowsCaptions?.emptyRow} ))} ); }); }; Row.displayName = "TableRow"; export { Row };