chore: update eslint and prettier configuration
This commit is contained in:
@@ -67,12 +67,15 @@ export function DataTable<TData, TValue>({
|
||||
onSortingChange,
|
||||
}: DataTableProps<TData, TValue>) {
|
||||
const [rowSelection, setRowSelection] = React.useState({});
|
||||
const [internalSorting, setInternalSorting] = React.useState<SortingState>([]);
|
||||
const [internalSorting, setInternalSorting] = React.useState<SortingState>(
|
||||
[],
|
||||
);
|
||||
const sorting = controlledSorting ?? internalSorting;
|
||||
const isManualSorting = Boolean(onSortingChange);
|
||||
const handleSortingChange = React.useCallback(
|
||||
(updater: SortingState | ((old: SortingState) => SortingState)) => {
|
||||
const nextSorting = typeof updater === 'function' ? updater(sorting) : updater;
|
||||
const nextSorting =
|
||||
typeof updater === 'function' ? updater(sorting) : updater;
|
||||
if (onSortingChange) {
|
||||
onSortingChange(nextSorting);
|
||||
return;
|
||||
@@ -95,7 +98,9 @@ export function DataTable<TData, TValue>({
|
||||
<div className="flex justify-end gap-2">
|
||||
{actions.map((action) => {
|
||||
const label =
|
||||
typeof action.label === 'function' ? action.label(item) : action.label;
|
||||
typeof action.label === 'function'
|
||||
? action.label(item)
|
||||
: action.label;
|
||||
|
||||
return (
|
||||
<TableActionButton
|
||||
@@ -131,7 +136,9 @@ export function DataTable<TData, TValue>({
|
||||
getPaginationRowModel: getPaginationRowModel(),
|
||||
manualPagination: !!pagination,
|
||||
manualSorting: isManualSorting,
|
||||
pageCount: pagination?.totalItems ? Math.ceil(pagination.totalItems / pagination.limit) : -1,
|
||||
pageCount: pagination?.totalItems
|
||||
? Math.ceil(pagination.totalItems / pagination.limit)
|
||||
: -1,
|
||||
state: {
|
||||
rowSelection,
|
||||
sorting,
|
||||
@@ -191,17 +198,26 @@ export function DataTable<TData, TValue>({
|
||||
))
|
||||
) : table.getRowModel().rows?.length ? (
|
||||
table.getRowModel().rows.map((row) => (
|
||||
<TableRow key={row.id} data-state={row.getIsSelected() && 'selected'}>
|
||||
<TableRow
|
||||
key={row.id}
|
||||
data-state={row.getIsSelected() && 'selected'}
|
||||
>
|
||||
{row.getVisibleCells().map((cell) => (
|
||||
<TableCell key={cell.id}>
|
||||
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
||||
{flexRender(
|
||||
cell.column.columnDef.cell,
|
||||
cell.getContext(),
|
||||
)}
|
||||
</TableCell>
|
||||
))}
|
||||
</TableRow>
|
||||
))
|
||||
) : (
|
||||
<TableRow>
|
||||
<TableCell colSpan={columns.length} className="h-28 text-center">
|
||||
<TableCell
|
||||
colSpan={columns.length}
|
||||
className="h-28 text-center"
|
||||
>
|
||||
<div className="flex flex-col items-center justify-center text-muted-foreground gap-1">
|
||||
<p className="text-sm font-medium">{emptyTitle}</p>
|
||||
<p className="text-xs">{emptyDescription}</p>
|
||||
|
||||
Reference in New Issue
Block a user