MCPcopy
hub / github.com/kite-org/kite / ResourceTableView

Function ResourceTableView

ui/src/components/resource-table-view.tsx:46–304  ·  view source on GitHub ↗
({
  table,
  columnCount,
  isLoading,
  data,
  allPageSize,
  maxBodyHeightClassName = 'max-h-[calc(100dvh-210px)]',
  containerClassName = 'flex flex-col gap-3',
  fitViewportHeight = false,
  emptyState,
  hasActiveFilters,
  filteredRowCount,
  totalRowCount,
  searchQuery,
  pagination,
  setPagination,
  shrinkFirstColumn = true,
  showAllPageSize = true,
}: ResourceTableViewProps<T>)

Source from the content-addressed store, hash-verified

44}
45
46export function ResourceTableView<T>({
47 table,
48 columnCount,
49 isLoading,
50 data,
51 allPageSize,
52 maxBodyHeightClassName = 'max-h-[calc(100dvh-210px)]',
53 containerClassName = 'flex flex-col gap-3',
54 fitViewportHeight = false,
55 emptyState,
56 hasActiveFilters,
57 filteredRowCount,
58 totalRowCount,
59 searchQuery,
60 pagination,
61 setPagination,
62 shrinkFirstColumn = true,
63 showAllPageSize = true,
64}: ResourceTableViewProps<T>) {
65 const renderRows = () => {
66 const rows = table.getRowModel().rows
67
68 if (rows.length === 0) {
69 return (
70 <TableRow>
71 <TableCell colSpan={columnCount} className="h-24 text-center">
72 No results.
73 </TableCell>
74 </TableRow>
75 )
76 }
77
78 return rows.map((row) => (
79 <TableRow key={row.id} data-state={row.getIsSelected() && 'selected'}>
80 {row.getVisibleCells().map((cell, index) => (
81 <TableCell
82 key={cell.id}
83 className={`align-middle ${index <= 1 ? 'text-left' : 'text-center'}`}
84 >
85 {cell.column.columnDef.cell
86 ? flexRender(cell.column.columnDef.cell, cell.getContext())
87 : String(cell.getValue() || '-')}
88 </TableCell>
89 ))}
90 </TableRow>
91 ))
92 }
93
94 const dataLength = data?.length ?? 0
95 const resolvedAllPageSize = allPageSize ?? dataLength
96 const rootRef = useRef<HTMLDivElement>(null)
97 const tableShellRef = useRef<HTMLDivElement>(null)
98 const footerRef = useRef<HTMLDivElement>(null)
99 const [tableHeight, setTableHeight] = useState<number | null>(null)
100
101 useLayoutEffect(() => {
102 if (!fitViewportHeight || !tableShellRef.current) {
103 return

Callers

nothing calls this directly

Calls 3

cnFunction · 0.90
scheduleUpdateFunction · 0.85
renderRowsFunction · 0.85

Tested by

no test coverage detected