@dmsi/wedgekit-react 0.0.82 → 0.0.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-6R2HCLEL.js → chunk-37TJJQL3.js} +2 -2
- package/dist/{chunk-B6PDZCU7.js → chunk-5GUW4DUY.js} +1 -1
- package/dist/{chunk-ATOEGP3V.js → chunk-CKSDMI2Q.js} +14 -7
- package/dist/{chunk-2DCVAATK.js → chunk-MQWWNAO3.js} +4 -4
- package/dist/{chunk-FOC6LTSX.js → chunk-UPBBOZM3.js} +1 -1
- package/dist/{chunk-SWA5WVQO.js → chunk-WNQ53SVY.js} +30 -0
- package/dist/components/DataGridCell.cjs +53 -43
- package/dist/components/DataGridCell.js +5 -5
- package/dist/components/Menu.cjs +17 -14
- package/dist/components/Menu.js +3 -3
- package/dist/components/MenuOption.cjs +10 -7
- package/dist/components/MenuOption.js +2 -2
- package/dist/components/Modal.cjs +18 -15
- package/dist/components/Modal.js +3 -3
- package/dist/components/NestedMenu.cjs +12 -9
- package/dist/components/NestedMenu.js +2 -2
- package/dist/components/PDFViewer.cjs +21 -18
- package/dist/components/PDFViewer.js +3 -3
- package/dist/components/ProjectBar.cjs +6 -3
- package/dist/components/ProjectBar.js +1 -1
- package/dist/components/TopBar.cjs +1 -1
- package/dist/components/TopBar.js +1 -1
- package/dist/components/{DataGrid.cjs → index.cjs} +1424 -1335
- package/dist/components/{DataGrid.js → index.js} +948 -883
- package/dist/components/useMenuSystem.cjs +20 -17
- package/dist/components/useMenuSystem.js +2 -2
- package/dist/hooks/index.cjs +34 -3
- package/dist/hooks/index.js +3 -1
- package/package.json +6 -1
- package/src/components/DataGrid/ColumnSelectorHeaderCell/ColumnSelectorMenuOption.tsx +32 -0
- package/src/components/DataGrid/ColumnSelectorHeaderCell/index.tsx +66 -0
- package/src/components/DataGrid/PinnedColumns.tsx +145 -0
- package/src/components/DataGrid/TableBody/LoadingCell.tsx +40 -0
- package/src/components/DataGrid/TableBody/TableBodyRow.tsx +129 -0
- package/src/components/DataGrid/TableBody/index.tsx +159 -0
- package/src/components/{DataGrid.tsx → DataGrid/index.tsx} +42 -678
- package/src/components/DataGrid/types.ts +86 -0
- package/src/components/DataGrid/utils.tsx +15 -0
- package/src/components/DataGridCell.tsx +37 -21
- package/src/components/TopBar.tsx +1 -1
- package/src/components/index.ts +20 -0
- package/src/hooks/index.ts +1 -0
- package/dist/chunk-AWQSSKCK.js +0 -32
- package/dist/components/useInfiniteScroll.cjs +0 -57
- package/dist/components/useInfiniteScroll.js +0 -8
- /package/src/{components → hooks}/useInfiniteScroll.tsx +0 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { HeaderGroup, Row, RowData, Table } from "@tanstack/react-table";
|
|
2
|
+
import { useVirtualizer, Virtualizer } from "@tanstack/react-virtual";
|
|
3
|
+
import { DataGridPagination } from "../types";
|
|
4
|
+
import { DataGridCell, DragAlongCell, Search } from "../..";
|
|
5
|
+
import clsx from "clsx";
|
|
6
|
+
import { TableBodyRow } from "./TableBodyRow";
|
|
7
|
+
import { LoadingCell } from "./LoadingCell";
|
|
8
|
+
|
|
9
|
+
interface TableBodyProps<TData extends RowData> {
|
|
10
|
+
id?: string;
|
|
11
|
+
columnVirtualizer?: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
|
|
12
|
+
table: Table<TData>;
|
|
13
|
+
tableContainerRef: React.RefObject<HTMLDivElement | null>;
|
|
14
|
+
virtualPaddingLeft?: number | undefined;
|
|
15
|
+
virtualPaddingRight?: number | undefined;
|
|
16
|
+
pagination: DataGridPagination | undefined;
|
|
17
|
+
isLoadingMore: boolean;
|
|
18
|
+
hasMore: boolean;
|
|
19
|
+
showFilterRow: boolean;
|
|
20
|
+
enableColumnSelector?: boolean;
|
|
21
|
+
locked?: boolean;
|
|
22
|
+
pinDirection?: "left" | "right";
|
|
23
|
+
}
|
|
24
|
+
export function TableBody<T>({
|
|
25
|
+
id,
|
|
26
|
+
columnVirtualizer,
|
|
27
|
+
table,
|
|
28
|
+
tableContainerRef,
|
|
29
|
+
virtualPaddingLeft,
|
|
30
|
+
virtualPaddingRight,
|
|
31
|
+
pagination,
|
|
32
|
+
isLoadingMore,
|
|
33
|
+
hasMore,
|
|
34
|
+
showFilterRow,
|
|
35
|
+
enableColumnSelector = false,
|
|
36
|
+
locked,
|
|
37
|
+
pinDirection,
|
|
38
|
+
}: TableBodyProps<T>) {
|
|
39
|
+
const { rows } = table.getRowModel();
|
|
40
|
+
|
|
41
|
+
const rowVirtualizer = useVirtualizer<HTMLDivElement, HTMLTableRowElement>({
|
|
42
|
+
count: rows.length,
|
|
43
|
+
estimateSize: () => 40,
|
|
44
|
+
getScrollElement: () => tableContainerRef.current,
|
|
45
|
+
overscan: 8,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const virtualRows = rowVirtualizer.getVirtualItems();
|
|
49
|
+
const CellElement = locked ? DataGridCell : DragAlongCell;
|
|
50
|
+
|
|
51
|
+
let headerGroups: HeaderGroup<T>[];
|
|
52
|
+
if (pinDirection === "left") {
|
|
53
|
+
headerGroups = table.getLeftHeaderGroups();
|
|
54
|
+
} else if (pinDirection === "right") {
|
|
55
|
+
headerGroups = table.getRightHeaderGroups();
|
|
56
|
+
} else {
|
|
57
|
+
headerGroups = table.getCenterHeaderGroups();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<tbody
|
|
62
|
+
className={clsx(locked ? "shadow-16" : "")}
|
|
63
|
+
style={{
|
|
64
|
+
display: "grid",
|
|
65
|
+
height: `${
|
|
66
|
+
showFilterRow
|
|
67
|
+
? rowVirtualizer.getTotalSize() + 40
|
|
68
|
+
: rowVirtualizer.getTotalSize()
|
|
69
|
+
}px`, // tells scrollbar how big the table is
|
|
70
|
+
position: "relative", // needed for absolute positioning of rows
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
{showFilterRow && (
|
|
74
|
+
<tr
|
|
75
|
+
style={{
|
|
76
|
+
display: "flex",
|
|
77
|
+
position: "sticky",
|
|
78
|
+
top: "40px",
|
|
79
|
+
width: "100%",
|
|
80
|
+
height: "40px",
|
|
81
|
+
zIndex: 10,
|
|
82
|
+
}}
|
|
83
|
+
className="even:bg-background-grouped-primary-normal odd:bg-background-grouped-secondary-normal"
|
|
84
|
+
>
|
|
85
|
+
{headerGroups.flatMap((x) =>
|
|
86
|
+
x.headers.map((header) => (
|
|
87
|
+
<CellElement
|
|
88
|
+
id={id ? `${id}-filter-cell-${header.id}` : undefined}
|
|
89
|
+
noPadding
|
|
90
|
+
key={header.id}
|
|
91
|
+
cell={header}
|
|
92
|
+
width={
|
|
93
|
+
header.column.columnDef.meta?.headerWidth ||
|
|
94
|
+
(locked ? `${header.column.getSize()}px` : "")
|
|
95
|
+
}
|
|
96
|
+
>
|
|
97
|
+
{header.column.getCanFilter() &&
|
|
98
|
+
(header.column.columnDef.meta?.filterRowCell?.({
|
|
99
|
+
header,
|
|
100
|
+
table,
|
|
101
|
+
}) ?? (
|
|
102
|
+
<Search
|
|
103
|
+
id={id ? `${id}-filter-search-${header.id}` : undefined}
|
|
104
|
+
removeRoundness
|
|
105
|
+
onChange={(e) =>
|
|
106
|
+
header.column.setFilterValue(e.target.value)
|
|
107
|
+
}
|
|
108
|
+
value={(header.column.getFilterValue() ?? "") as string}
|
|
109
|
+
placeholder=""
|
|
110
|
+
removeSearchIcon
|
|
111
|
+
/>
|
|
112
|
+
))}
|
|
113
|
+
</CellElement>
|
|
114
|
+
)),
|
|
115
|
+
)}
|
|
116
|
+
</tr>
|
|
117
|
+
)}
|
|
118
|
+
|
|
119
|
+
{virtualRows.map((virtualRow) => {
|
|
120
|
+
const row = rows[virtualRow.index] as Row<T>;
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<TableBodyRow
|
|
124
|
+
id={id}
|
|
125
|
+
columnVirtualizer={columnVirtualizer}
|
|
126
|
+
key={row.id}
|
|
127
|
+
row={row}
|
|
128
|
+
rowVirtualizer={rowVirtualizer}
|
|
129
|
+
virtualPaddingLeft={virtualPaddingLeft}
|
|
130
|
+
virtualPaddingRight={virtualPaddingRight}
|
|
131
|
+
virtualRow={virtualRow}
|
|
132
|
+
showFilterRow={showFilterRow}
|
|
133
|
+
enableColumnSelector={enableColumnSelector}
|
|
134
|
+
locked={locked}
|
|
135
|
+
pinDirection={pinDirection}
|
|
136
|
+
/>
|
|
137
|
+
);
|
|
138
|
+
})}
|
|
139
|
+
|
|
140
|
+
{!pagination && isLoadingMore && hasMore && (
|
|
141
|
+
<tr
|
|
142
|
+
style={{
|
|
143
|
+
display: "flex",
|
|
144
|
+
position: "absolute",
|
|
145
|
+
width: "100%",
|
|
146
|
+
transform: `translateY(${
|
|
147
|
+
virtualRows[virtualRows.length - 1].start + 40
|
|
148
|
+
}px)`,
|
|
149
|
+
}}
|
|
150
|
+
className="odd:bg-background-grouped-primary-normal even:bg-background-grouped-secondary-normal"
|
|
151
|
+
>
|
|
152
|
+
{table.getAllLeafColumns().map((column) => (
|
|
153
|
+
<LoadingCell id={id} key={column.id} column={column.columnDef} />
|
|
154
|
+
))}
|
|
155
|
+
</tr>
|
|
156
|
+
)}
|
|
157
|
+
</tbody>
|
|
158
|
+
);
|
|
159
|
+
}
|