-
-
Notifications
You must be signed in to change notification settings - Fork 130
Expand file tree
/
Copy pathSortedTableInHtmlTable.tsx
More file actions
73 lines (72 loc) · 1.98 KB
/
Copy pathSortedTableInHtmlTable.tsx
File metadata and controls
73 lines (72 loc) · 1.98 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
68
69
70
71
72
73
/* @jsxImportSource solid-js */
import type {JSXElement} from 'solid-js';
import type {
HtmlTableProps,
SortedTableInHtmlTable as SortedTableInHtmlTableDecl,
SortedTableInHtmlTableProps,
} from '../@types/ui-solid-dom/index.d.ts';
import {CellView} from '../ui-solid/index.ts';
import {
useRowCount,
useSortedRowIds,
useTableCellIds,
} from '../ui-solid/primitives.ts';
import {HtmlTable} from './common/components.tsx';
import {
getParams,
getStoreCellComponentProps,
useCells,
} from './common/hooks.tsx';
import {EditableCellView} from './EditableCellView.tsx';
import {useSortingAndPagination} from './SortedTablePaginator.tsx';
export const SortedTableInHtmlTable: typeof SortedTableInHtmlTableDecl = (
props: SortedTableInHtmlTableProps & HtmlTableProps,
): JSXElement => {
const [sortAndOffset, handleSort, paginatorComponent] =
useSortingAndPagination(
() => props.cellId,
() => props.descending,
() => props.sortOnClick,
() => props.offset,
() => props.limit,
useRowCount(
() => props.tableId,
() => props.store,
),
() => props.paginator ?? false,
() => props.onChange,
);
return (
<HtmlTable
{...props}
params={getParams(
useCells(
useTableCellIds(
() => props.tableId,
() => props.store,
),
() => props.customCells,
() => (props.editable === true ? EditableCellView : CellView),
),
getStoreCellComponentProps(
() => props.store,
() => props.tableId,
),
useSortedRowIds(
() => props.tableId,
() => sortAndOffset()[0],
() => sortAndOffset()[1],
() => sortAndOffset()[2],
() => props.limit,
undefined,
() => props.store,
),
() => props.extraCellsBefore,
() => props.extraCellsAfter,
sortAndOffset,
handleSort,
paginatorComponent,
)}
/>
);
};