-
-
Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy pathSortedTableInHtmlTable.tsx
More file actions
67 lines (66 loc) · 1.58 KB
/
Copy pathSortedTableInHtmlTable.tsx
File metadata and controls
67 lines (66 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import type {
HtmlTableProps,
SortedTableInHtmlTable as SortedTableInHtmlTableDecl,
SortedTableInHtmlTableProps,
} from '../@types/ui-react-dom/index.d.ts';
import {
useRowCount,
useSortedRowIds,
useTableCellIds,
} from '../ui-react/hooks.ts';
import {CellView} from '../ui-react/index.ts';
import {HtmlTable} from './common/components.tsx';
import {
useCells,
useParams,
useStoreCellComponentProps,
} from './common/hooks.tsx';
import {EditableCellView} from './EditableCellView.tsx';
import {useSortingAndPagination} from './SortedTablePaginator.tsx';
export const SortedTableInHtmlTable: typeof SortedTableInHtmlTableDecl = ({
tableId,
cellId,
descending,
offset,
limit,
store,
editable,
sortOnClick,
paginator = false,
onChange,
customCells,
extraCellsBefore,
extraCellsAfter,
...props
}: SortedTableInHtmlTableProps & HtmlTableProps): any => {
const [sortAndOffset, handleSort, paginatorComponent] =
useSortingAndPagination(
cellId,
descending,
sortOnClick,
offset,
limit,
useRowCount(tableId, store),
paginator,
onChange,
);
return (
<HtmlTable
{...props}
params={useParams(
useCells(
useTableCellIds(tableId, store),
customCells,
editable ? EditableCellView : CellView,
),
useStoreCellComponentProps(store, tableId),
useSortedRowIds(tableId, ...sortAndOffset, limit, store),
extraCellsBefore,
extraCellsAfter,
sortAndOffset,
handleSort,
paginatorComponent,
)}
/>
);
};