UNPKG

@trail-ui/react

Version:
56 lines (53 loc) 2.31 kB
import { EditableTableCell } from "./chunk-SVDQBOZE.mjs"; import { _Spinner } from "./chunk-P3AIC7XZ.mjs"; // src/editable-table/editable-table-body.tsx import { jsx, jsxs } from "react/jsx-runtime"; function EditableTableBody({ isLoading, columns, table, checkBoxSelectedName, isCellDisabled }) { var _a; return /* @__PURE__ */ jsx("tbody", { children: isLoading ? /* @__PURE__ */ jsx("tr", { className: "h-[300px]", children: /* @__PURE__ */ jsx("td", { colSpan: columns.length, children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-1", children: [ /* @__PURE__ */ jsx(_Spinner, { className: "h-8 w-8 animate-spin" }), /* @__PURE__ */ jsx("p", { className: "pt-1 text-neutral-700", children: "Loading..." }) ] }) }) }) : ((_a = table.getRowModel().rows) == null ? void 0 : _a.length) ? ( // Normal rows table.getRowModel().rows.map((row, rowIndex) => /* @__PURE__ */ jsx("tr", { children: row.getVisibleCells().map((cell) => { const Element = cell.column.id === "id" ? "th" : "td"; return /* @__PURE__ */ jsx( Element, { style: { minWidth: cell.column.columnDef.size === 100 ? "auto" : cell.column.columnDef.size, maxWidth: cell.column.columnDef.size === 100 ? "auto" : cell.column.columnDef.size }, scope: "row", className: `${cell.row.getIsSelected() ? "bg-purple-50" : "bg-neutral-50"} border-b border-r border-neutral-200 px-2 py-2 text-left text-sm font-normal text-neutral-900 last:border-r-0`, children: /* @__PURE__ */ jsx( EditableTableCell, { rowHeaderId: `checkbox-${rowIndex}`, checkBoxSelectedName, cell, isCellDisabled } ) }, cell.id ); }) }, row.id)) ) : ( // Empty state /* @__PURE__ */ jsx("tr", { className: "h-[300px]", children: /* @__PURE__ */ jsx("td", { colSpan: columns.length, children: /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center gap-1", children: /* @__PURE__ */ jsx("p", { role: "alert", "aria-live": "polite", className: "text-neutral-700", children: "No data" }) }) }) }) ) }); } export { EditableTableBody };