feat: add toolbar support to DataTable component for enhanced functionality
This commit is contained in:
parent
c43713c41c
commit
520696fb67
@ -49,6 +49,7 @@ interface DataTableProps<TData, TValue> {
|
||||
emptyText?: string;
|
||||
onReorder?: (items: TData[]) => void;
|
||||
getRowId?: (item: TData) => string | number;
|
||||
toolbar?: React.ReactNode;
|
||||
}
|
||||
|
||||
const DragHandleContext = React.createContext<{
|
||||
@ -115,6 +116,7 @@ export function DataTable<TData, TValue>({
|
||||
emptyText = 'Tidak ada data.',
|
||||
onReorder,
|
||||
getRowId,
|
||||
toolbar,
|
||||
}: DataTableProps<TData, TValue>) {
|
||||
const [sorting, setSorting] = React.useState<SortingState>([]);
|
||||
const [columnFilters, setColumnFilters] =
|
||||
@ -187,21 +189,26 @@ export function DataTable<TData, TValue>({
|
||||
|
||||
return (
|
||||
<>
|
||||
{searchKey && (
|
||||
<Input
|
||||
placeholder={searchPlaceholder}
|
||||
value={
|
||||
(table
|
||||
.getColumn(searchKey)
|
||||
?.getFilterValue() as string) ?? ''
|
||||
}
|
||||
onChange={(event) =>
|
||||
table
|
||||
.getColumn(searchKey)
|
||||
?.setFilterValue(event.target.value)
|
||||
}
|
||||
className="max-w-sm"
|
||||
/>
|
||||
{(searchKey || toolbar) && (
|
||||
<div className="flex items-center gap-2">
|
||||
{searchKey && (
|
||||
<Input
|
||||
placeholder={searchPlaceholder}
|
||||
value={
|
||||
(table
|
||||
.getColumn(searchKey)
|
||||
?.getFilterValue() as string) ?? ''
|
||||
}
|
||||
onChange={(event) =>
|
||||
table
|
||||
.getColumn(searchKey)
|
||||
?.setFilterValue(event.target.value)
|
||||
}
|
||||
className="max-w-sm"
|
||||
/>
|
||||
)}
|
||||
{toolbar}
|
||||
</div>
|
||||
)}
|
||||
<Card className="bg-sidebar p-0">
|
||||
<CardContent className="p-0">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user