DataTable() — ui Function Reference
Architecture documentation for the DataTable() function in data-table.tsx from the ui codebase.
Entity Profile
Dependency Diagram
graph TD 94ace49c_6ca1_caf0_b7b6_a5e11b1c1b71["DataTable()"] 35e180e2_eb50_375e_4a19_e8096d02a705["data-table.tsx"] 94ace49c_6ca1_caf0_b7b6_a5e11b1c1b71 -->|defined in| 35e180e2_eb50_375e_4a19_e8096d02a705 style 94ace49c_6ca1_caf0_b7b6_a5e11b1c1b71 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
apps/v4/registry/bases/base/blocks/dashboard-01/components/data-table.tsx lines 356–700
export function DataTable({
data: initialData,
}: {
data: z.infer<typeof schema>[]
}) {
const [data, setData] = React.useState(() => initialData)
const [rowSelection, setRowSelection] = React.useState({})
const [columnVisibility, setColumnVisibility] =
React.useState<VisibilityState>({})
const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(
[]
)
const [sorting, setSorting] = React.useState<SortingState>([])
const [pagination, setPagination] = React.useState({
pageIndex: 0,
pageSize: 10,
})
const sortableId = React.useId()
const sensors = useSensors(
useSensor(MouseSensor, {}),
useSensor(TouchSensor, {}),
useSensor(KeyboardSensor, {})
)
const dataIds = React.useMemo<UniqueIdentifier[]>(
() => data?.map(({ id }) => id) || [],
[data]
)
const table = useReactTable({
data,
columns,
state: {
sorting,
columnVisibility,
rowSelection,
columnFilters,
pagination,
},
getRowId: (row) => row.id.toString(),
enableRowSelection: true,
onRowSelectionChange: setRowSelection,
onSortingChange: setSorting,
onColumnFiltersChange: setColumnFilters,
onColumnVisibilityChange: setColumnVisibility,
onPaginationChange: setPagination,
getCoreRowModel: getCoreRowModel(),
getFilteredRowModel: getFilteredRowModel(),
getPaginationRowModel: getPaginationRowModel(),
getSortedRowModel: getSortedRowModel(),
getFacetedRowModel: getFacetedRowModel(),
getFacetedUniqueValues: getFacetedUniqueValues(),
})
function handleDragEnd(event: DragEndEvent) {
const { active, over } = event
if (active && over && active.id !== over.id) {
setData((data) => {
const oldIndex = dataIds.indexOf(active.id)
const newIndex = dataIds.indexOf(over.id)
return arrayMove(data, oldIndex, newIndex)
})
}
}
return (
<Tabs
defaultValue="outline"
className="w-full flex-col justify-start gap-6"
>
<div className="flex items-center justify-between px-4 lg:px-6">
<Label htmlFor="view-selector" className="sr-only">
View
</Label>
<Select
defaultValue="outline"
items={[
{ label: "Outline", value: "outline" },
{ label: "Past Performance", value: "past-performance" },
{ label: "Key Personnel", value: "key-personnel" },
{ label: "Focus Documents", value: "focus-documents" },
]}
>
<SelectTrigger
className="flex w-fit @4xl/main:hidden"
Domain
Subdomains
Source
Frequently Asked Questions
What does DataTable() do?
DataTable() is a function in the ui codebase, defined in apps/v4/registry/bases/base/blocks/dashboard-01/components/data-table.tsx.
Where is DataTable() defined?
DataTable() is defined in apps/v4/registry/bases/base/blocks/dashboard-01/components/data-table.tsx at line 356.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free