@bsol-oss/react-datatable5 1.0.64 → 2.0.0
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/index.d.ts +40 -31
- package/dist/index.js +77 -104
- package/dist/index.mjs +78 -105
- package/dist/types/components/Controls/SelectAllRowsToggle.d.ts +4 -4
- package/dist/types/components/DataTable/DataTable.d.ts +18 -13
- package/dist/types/components/DataTable/DataTableContext.d.ts +3 -3
- package/dist/types/components/DataTable/DataTableServer.d.ts +18 -14
- package/dist/types/components/DataTable/useDataTable.d.ts +33 -8
- package/dist/types/components/DataTable/useDataTableContext.d.ts +8 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/types/components/DataTable.d.ts +0 -33
- package/dist/types/components/DataTableContext.d.ts +0 -10
- package/dist/types/components/DataTableServer.d.ts +0 -38
- package/dist/types/components/DefaultTable.d.ts +0 -5
- package/dist/types/components/DensityFeature.d.ts +0 -23
- package/dist/types/components/DensityToggle.d.ts +0 -1
- package/dist/types/components/DensityToggleButton.d.ts +0 -6
- package/dist/types/components/EditFilterButton.d.ts +0 -9
- package/dist/types/components/EditOrderButton.d.ts +0 -7
- package/dist/types/components/EditSortingButton.d.ts +0 -7
- package/dist/types/components/EditViewButton.d.ts +0 -7
- package/dist/types/components/FilterOptions.d.ts +0 -4
- package/dist/types/components/GlobalFilter.d.ts +0 -3
- package/dist/types/components/PageSizeControl.d.ts +0 -4
- package/dist/types/components/ResetFilteringButton.d.ts +0 -4
- package/dist/types/components/ResetSelectionButton.d.ts +0 -4
- package/dist/types/components/ResetSortingButton.d.ts +0 -4
- package/dist/types/components/RowCountText.d.ts +0 -1
- package/dist/types/components/SelectAllRowsToggle.d.ts +0 -8
- package/dist/types/components/Table.d.ts +0 -8
- package/dist/types/components/TableBody.d.ts +0 -17
- package/dist/types/components/TableCardContainer.d.ts +0 -6
- package/dist/types/components/TableCards.d.ts +0 -4
- package/dist/types/components/TableComponent.d.ts +0 -6
- package/dist/types/components/TableComponentRenderer.d.ts +0 -6
- package/dist/types/components/TableControls.d.ts +0 -13
- package/dist/types/components/TableFilter.d.ts +0 -8
- package/dist/types/components/TableFilterTags.d.ts +0 -1
- package/dist/types/components/TableFooter.d.ts +0 -7
- package/dist/types/components/TableHeader.d.ts +0 -8
- package/dist/types/components/TableLoadingComponent.d.ts +0 -5
- package/dist/types/components/TableOrderer.d.ts +0 -1
- package/dist/types/components/TablePagination.d.ts +0 -3
- package/dist/types/components/TableReloadButton.d.ts +0 -4
- package/dist/types/components/TableSelector.d.ts +0 -1
- package/dist/types/components/TableSorter.d.ts +0 -1
- package/dist/types/components/TableViewer.d.ts +0 -1
- package/dist/types/components/TextCell.d.ts +0 -10
- package/dist/types/components/useDataFromUrl.d.ts +0 -14
- package/dist/types/components/useDataTable.d.ts +0 -7
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { IconButton, Button, useDisclosure, Modal, ModalOverlay, ModalContent, M
|
|
|
3
3
|
import { AiOutlineColumnWidth } from 'react-icons/ai';
|
|
4
4
|
import { MdFilterAlt, MdOutlineMoveDown, MdOutlineSort, MdOutlineViewColumn, MdFilterListAlt, MdPushPin, MdCancel, MdClear, MdArrowUpward, MdArrowDownward, MdFirstPage, MdArrowBack, MdArrowForward, MdLastPage, MdOutlineChecklist, MdClose, MdSearch } from 'react-icons/md';
|
|
5
5
|
import { UpDownIcon, ChevronDownIcon, ChevronUpIcon, CloseIcon } from '@chakra-ui/icons';
|
|
6
|
-
import { createContext, useContext,
|
|
6
|
+
import { createContext, useContext, useEffect, useState } from 'react';
|
|
7
7
|
import { IoMdEye, IoMdCheckbox } from 'react-icons/io';
|
|
8
8
|
import { makeStateUpdater, functionalUpdate, useReactTable, getCoreRowModel, getFilteredRowModel, getSortedRowModel, getPaginationRowModel, flexRender } from '@tanstack/react-table';
|
|
9
9
|
import { rankItem } from '@tanstack/match-sorter-utils';
|
|
@@ -16,7 +16,7 @@ import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
|
|
|
16
16
|
import { FaGripLinesVertical } from 'react-icons/fa';
|
|
17
17
|
|
|
18
18
|
const DensityToggleButton = ({ text, icon = jsx(AiOutlineColumnWidth, {}), }) => {
|
|
19
|
-
const { table } =
|
|
19
|
+
const { table } = useDataTableContext();
|
|
20
20
|
return (jsxs(Fragment, { children: [!!text === false && (jsx(IconButton, { variant: "ghost", "aria-label": "Toggle Density", icon: icon, onClick: () => {
|
|
21
21
|
table.toggleDensity();
|
|
22
22
|
} })), !!text !== false && (jsx(Button, { leftIcon: icon, variant: "ghost", "aria-label": "Toggle Density", onClick: () => {
|
|
@@ -37,13 +37,13 @@ const EditOrderButton = ({ text, icon = jsx(MdOutlineMoveDown, {}), title = "Cha
|
|
|
37
37
|
const TableContext = createContext({
|
|
38
38
|
table: {},
|
|
39
39
|
refreshData: () => { },
|
|
40
|
-
globalFilter: "",
|
|
40
|
+
globalFilter: { globalFilter: "" },
|
|
41
41
|
setGlobalFilter: () => { },
|
|
42
42
|
loading: false,
|
|
43
43
|
hasError: false,
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
const
|
|
46
|
+
const useDataTableContext = () => {
|
|
47
47
|
const { table, refreshData, globalFilter, setGlobalFilter, loading, hasError, } = useContext(TableContext);
|
|
48
48
|
return {
|
|
49
49
|
table,
|
|
@@ -56,20 +56,14 @@ const useDataTable = () => {
|
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
const TableSorter = () => {
|
|
59
|
-
const { table } =
|
|
59
|
+
const { table } = useDataTableContext();
|
|
60
60
|
return (jsx(Fragment, { children: table.getHeaderGroups().map((headerGroup) => (jsx(Fragment, { children: headerGroup.headers.map((header) => {
|
|
61
61
|
const displayName = header.column.columnDef.meta === undefined
|
|
62
62
|
? header.column.id
|
|
63
63
|
: header.column.columnDef.meta.displayName;
|
|
64
|
-
return (jsx(Fragment, { children: header.column.getCanSort() && (jsxs(Flex, { alignItems: "center", gap: "0.5rem", padding: "0.5rem", children: [jsx(Text, { children: displayName }), jsxs(Button, { variant: "ghost", onClick: (
|
|
64
|
+
return (jsx(Fragment, { children: header.column.getCanSort() && (jsxs(Flex, { alignItems: "center", gap: "0.5rem", padding: "0.5rem", children: [jsx(Text, { children: displayName }), jsxs(Button, { variant: "ghost", onClick: () => {
|
|
65
65
|
header.column.toggleSorting();
|
|
66
|
-
}, children: [header.column.getIsSorted() === false && (
|
|
67
|
-
// <Text>To No sort</Text>
|
|
68
|
-
jsx(UpDownIcon, {})), header.column.getIsSorted() === "asc" && (
|
|
69
|
-
// <Text>To asc</Text>
|
|
70
|
-
jsx(ChevronDownIcon, {})), header.column.getIsSorted() === "desc" && (
|
|
71
|
-
// <Text>To desc</Text>
|
|
72
|
-
jsx(ChevronUpIcon, {}))] }), header.column.getIsSorted() && (jsx(Button, { onClick: (e) => {
|
|
66
|
+
}, children: [header.column.getIsSorted() === false && jsx(UpDownIcon, {}), header.column.getIsSorted() === "asc" && (jsx(ChevronDownIcon, {})), header.column.getIsSorted() === "desc" && (jsx(ChevronUpIcon, {}))] }), header.column.getIsSorted() && (jsx(Button, { onClick: () => {
|
|
73
67
|
header.column.clearSorting();
|
|
74
68
|
}, children: jsx(CloseIcon, {}) }))] })) }));
|
|
75
69
|
}) }))) }));
|
|
@@ -86,35 +80,35 @@ const EditViewButton = ({ text, icon = jsx(IoMdEye, {}), title = "Edit View", })
|
|
|
86
80
|
};
|
|
87
81
|
|
|
88
82
|
const PageSizeControl = ({ pageSizes = [10, 20, 30, 40, 50], }) => {
|
|
89
|
-
const { table } =
|
|
83
|
+
const { table } = useDataTableContext();
|
|
90
84
|
return (jsx(Fragment, { children: jsxs(Menu, { children: [jsx(MenuButton, { as: Button, variant: "ghost", rightIcon: jsx(ChevronDownIcon, {}), gap: "0.5rem", children: table.getState().pagination.pageSize }), jsx(MenuList, { children: pageSizes.map((pageSize) => (jsx(MenuItem, { onClick: () => {
|
|
91
85
|
table.setPageSize(Number(pageSize));
|
|
92
86
|
}, children: pageSize }, crypto.randomUUID()))) })] }) }));
|
|
93
87
|
};
|
|
94
88
|
|
|
95
89
|
const ResetFilteringButton = ({ text = "Reset Filtering", }) => {
|
|
96
|
-
const { table } =
|
|
90
|
+
const { table } = useDataTableContext();
|
|
97
91
|
return (jsx(Button, { onClick: () => {
|
|
98
92
|
table.resetColumnFilters();
|
|
99
93
|
}, children: text }));
|
|
100
94
|
};
|
|
101
95
|
|
|
102
96
|
const ResetSelectionButton = ({ text = "Reset Selection", }) => {
|
|
103
|
-
const { table } =
|
|
97
|
+
const { table } = useDataTableContext();
|
|
104
98
|
return (jsx(Button, { onClick: () => {
|
|
105
99
|
table.resetRowSelection();
|
|
106
100
|
}, children: text }));
|
|
107
101
|
};
|
|
108
102
|
|
|
109
103
|
const ResetSortingButton = ({ text = "Reset Sorting", }) => {
|
|
110
|
-
const { table } =
|
|
104
|
+
const { table } = useDataTableContext();
|
|
111
105
|
return (jsx(Button, { onClick: () => {
|
|
112
106
|
table.resetSorting();
|
|
113
107
|
}, children: text }));
|
|
114
108
|
};
|
|
115
109
|
|
|
116
110
|
const RowCountText = () => {
|
|
117
|
-
const { table } =
|
|
111
|
+
const { table } = useDataTableContext();
|
|
118
112
|
return jsx(Text, { children: table.getRowCount() });
|
|
119
113
|
};
|
|
120
114
|
|
|
@@ -202,15 +196,7 @@ const fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
|
202
196
|
// Return if the item should be filtered in/out
|
|
203
197
|
return itemRank.passed;
|
|
204
198
|
};
|
|
205
|
-
const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, onRowSelect = () => { }, columnOrder
|
|
206
|
-
pageIndex: 0, //initial page index
|
|
207
|
-
pageSize: 10, //default page size
|
|
208
|
-
}, sorting: defaultSorting = [], rowSelection: defaultRowSelection = {}, columnVisibility: defaultColumnVisibility = {}, children, }) => {
|
|
209
|
-
const [columnOrder, setColumnOrder] = useState(defaultColumnOrder);
|
|
210
|
-
const [globalFilter, setGlobalFilter] = useState(defaultGlobalFilter);
|
|
211
|
-
const [densityState, setDensity] = useState(density);
|
|
212
|
-
const [rowSelection, setRowSelection] = useState(defaultRowSelection);
|
|
213
|
-
const [columnVisibility, setColumnVisibility] = useState(defaultColumnVisibility);
|
|
199
|
+
const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, onRowSelect = () => { }, columnOrder, columnFilters, columnVisibility, density, globalFilter, pagination, sorting, rowSelection, setPagination, setSorting, setColumnFilters, setRowSelection, setGlobalFilter, setColumnOrder, setDensity, setColumnVisibility, children, }) => {
|
|
214
200
|
const table = useReactTable({
|
|
215
201
|
_features: [DensityFeature],
|
|
216
202
|
data: data,
|
|
@@ -224,16 +210,6 @@ const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
224
210
|
minSize: 10, //enforced during column resizing
|
|
225
211
|
maxSize: 10000, //enforced during column resizing
|
|
226
212
|
},
|
|
227
|
-
state: {
|
|
228
|
-
columnOrder,
|
|
229
|
-
globalFilter,
|
|
230
|
-
density: densityState,
|
|
231
|
-
rowSelection,
|
|
232
|
-
columnVisibility,
|
|
233
|
-
},
|
|
234
|
-
onColumnOrderChange: (state) => {
|
|
235
|
-
setColumnOrder(state);
|
|
236
|
-
},
|
|
237
213
|
enableRowSelection: enableRowSelection,
|
|
238
214
|
enableMultiRowSelection: enableMultiRowSelection,
|
|
239
215
|
enableSubRowSelection: enableSubRowSelection,
|
|
@@ -242,17 +218,29 @@ const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
242
218
|
filterFns: {
|
|
243
219
|
fuzzy: fuzzyFilter,
|
|
244
220
|
},
|
|
245
|
-
onGlobalFilterChange: setGlobalFilter,
|
|
246
221
|
globalFilterFn: "fuzzy",
|
|
247
|
-
|
|
248
|
-
|
|
222
|
+
state: {
|
|
223
|
+
pagination,
|
|
224
|
+
sorting,
|
|
225
|
+
columnFilters,
|
|
226
|
+
rowSelection,
|
|
227
|
+
columnOrder,
|
|
228
|
+
globalFilter,
|
|
229
|
+
density,
|
|
230
|
+
columnVisibility,
|
|
231
|
+
},
|
|
232
|
+
onPaginationChange: setPagination,
|
|
233
|
+
onSortingChange: setSorting,
|
|
234
|
+
onColumnFiltersChange: setColumnFilters,
|
|
249
235
|
onRowSelectionChange: setRowSelection,
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
236
|
+
onColumnOrderChange: (state) => {
|
|
237
|
+
setColumnOrder(state);
|
|
238
|
+
},
|
|
239
|
+
onGlobalFilterChange: (state) => {
|
|
240
|
+
setGlobalFilter(state);
|
|
255
241
|
},
|
|
242
|
+
onDensityChange: setDensity,
|
|
243
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
256
244
|
});
|
|
257
245
|
useEffect(() => {
|
|
258
246
|
setColumnOrder(table.getAllLeafColumns().map((column) => column.id));
|
|
@@ -306,18 +294,7 @@ const useDataFromUrl = ({ url, params = {}, disableFirstFetch = false, onFetchSu
|
|
|
306
294
|
return { data, loading, hasError, refreshData };
|
|
307
295
|
};
|
|
308
296
|
|
|
309
|
-
const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, onRowSelect = () => { }, columnOrder
|
|
310
|
-
pageIndex: 0, //initial page index
|
|
311
|
-
pageSize: 10, //default page size
|
|
312
|
-
}, sorting: defaultSorting = [], rowSelection: defaultRowSelection = {}, columnVisibility: defaultColumnVisibility = {}, children, }) => {
|
|
313
|
-
const [sorting, setSorting] = useState(defaultSorting);
|
|
314
|
-
const [columnFilters, setColumnFilters] = useState(defaultColumnFilter); // can set initial column filter state here
|
|
315
|
-
const [pagination, setPagination] = useState(defaultPagination);
|
|
316
|
-
const [rowSelection, setRowSelection] = useState(defaultRowSelection);
|
|
317
|
-
const [columnOrder, setColumnOrder] = useState(defaultColumnOrder);
|
|
318
|
-
const [globalFilter, setGlobalFilter] = useState(defaultGlobalFilter);
|
|
319
|
-
const [densityState, setDensity] = useState(density);
|
|
320
|
-
const [columnVisibility, setColumnVisibility] = useState(defaultColumnVisibility);
|
|
297
|
+
const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, onRowSelect = () => { }, columnOrder, columnFilters, columnVisibility, density, globalFilter, pagination, sorting, rowSelection, setPagination, setSorting, setColumnFilters, setRowSelection, setGlobalFilter, setColumnOrder, setDensity, setColumnVisibility, children, }) => {
|
|
321
298
|
const { data, loading, hasError, refreshData } = useDataFromUrl({
|
|
322
299
|
url: url,
|
|
323
300
|
defaultData: {
|
|
@@ -339,7 +316,7 @@ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiR
|
|
|
339
316
|
obj[filter.id] = filter.value;
|
|
340
317
|
return { ...accumulator, ...obj };
|
|
341
318
|
}, {})),
|
|
342
|
-
searching: globalFilter,
|
|
319
|
+
searching: globalFilter.globalFilter,
|
|
343
320
|
},
|
|
344
321
|
disableFirstFetch: true,
|
|
345
322
|
});
|
|
@@ -350,11 +327,15 @@ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiR
|
|
|
350
327
|
getCoreRowModel: getCoreRowModel(),
|
|
351
328
|
manualPagination: true,
|
|
352
329
|
manualSorting: true,
|
|
353
|
-
onPaginationChange: setPagination,
|
|
354
|
-
onSortingChange: setSorting,
|
|
355
|
-
onColumnFiltersChange: setColumnFilters,
|
|
356
330
|
columnResizeMode: "onChange",
|
|
357
|
-
|
|
331
|
+
defaultColumn: {
|
|
332
|
+
size: 150, //starting column size
|
|
333
|
+
minSize: 10, //enforced during column resizing
|
|
334
|
+
maxSize: 10000, //enforced during column resizing
|
|
335
|
+
},
|
|
336
|
+
enableRowSelection: enableRowSelection,
|
|
337
|
+
enableMultiRowSelection: enableMultiRowSelection,
|
|
338
|
+
enableSubRowSelection: enableSubRowSelection,
|
|
358
339
|
state: {
|
|
359
340
|
pagination,
|
|
360
341
|
sorting,
|
|
@@ -362,23 +343,21 @@ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiR
|
|
|
362
343
|
rowSelection,
|
|
363
344
|
columnOrder,
|
|
364
345
|
globalFilter,
|
|
365
|
-
density
|
|
346
|
+
density,
|
|
366
347
|
columnVisibility,
|
|
367
348
|
},
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
},
|
|
373
|
-
enableRowSelection: enableRowSelection,
|
|
374
|
-
enableMultiRowSelection: enableMultiRowSelection,
|
|
375
|
-
enableSubRowSelection: enableSubRowSelection,
|
|
349
|
+
onPaginationChange: setPagination,
|
|
350
|
+
onSortingChange: setSorting,
|
|
351
|
+
onColumnFiltersChange: setColumnFilters,
|
|
352
|
+
onRowSelectionChange: setRowSelection,
|
|
376
353
|
onColumnOrderChange: (state) => {
|
|
377
354
|
setColumnOrder(state);
|
|
378
355
|
},
|
|
379
356
|
onGlobalFilterChange: (state) => {
|
|
380
357
|
setGlobalFilter(state);
|
|
381
358
|
},
|
|
359
|
+
onDensityChange: setDensity,
|
|
360
|
+
onColumnVisibilityChange: setColumnVisibility,
|
|
382
361
|
rowCount: data.count,
|
|
383
362
|
// for tanstack-table ts bug start
|
|
384
363
|
filterFns: {
|
|
@@ -387,8 +366,6 @@ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiR
|
|
|
387
366
|
},
|
|
388
367
|
},
|
|
389
368
|
// for tanstack-table ts bug end
|
|
390
|
-
onDensityChange: setDensity,
|
|
391
|
-
onColumnVisibilityChange: setColumnVisibility,
|
|
392
369
|
});
|
|
393
370
|
useEffect(() => {
|
|
394
371
|
refreshData();
|
|
@@ -459,14 +436,14 @@ const TableRowSelector = ({ index, row, hoveredRow, pinnedBgColor = { light: "gr
|
|
|
459
436
|
};
|
|
460
437
|
|
|
461
438
|
const TableControls = ({ totalText = "Total:", showFilter = false, fitTableWidth = false, fitTableHeight = false, isMobile = false, children = jsx(Fragment, {}), showFilterName = false, showFilterTags = false, filterOptions = [], }) => {
|
|
462
|
-
const { loading, hasError } =
|
|
439
|
+
const { loading, hasError } = useDataTableContext();
|
|
463
440
|
return (jsxs(Grid, { templateRows: "auto auto auto 1fr auto", templateColumns: "1fr 1fr", width: fitTableWidth ? "fit-content" : "100%", height: fitTableHeight ? "fit-content" : "100%", justifySelf: "center", alignSelf: "center", gap: "0.5rem", children: [jsxs(Flex, { justifyContent: "space-between", gridColumn: "1 / span 2", children: [jsx(Box, { children: jsx(EditViewButton, { text: isMobile ? undefined : "View", icon: jsx(MdOutlineViewColumn, {}) }) }), jsxs(Flex, { gap: "1rem", alignItems: "center", justifySelf: "end", children: [loading && jsx(Spinner, { size: "sm" }), hasError && (jsx(Tooltip, { label: "An error occurred while fetching data", children: jsx(Box, { children: jsx(Icon, { as: BsExclamationCircleFill, color: "red.400" }) }) })), showFilter && (jsxs(Fragment, { children: [jsx(GlobalFilter, {}), jsx(EditFilterButton, { text: isMobile ? undefined : "Advanced Filter" })] }))] })] }), jsx(Flex, { gridColumn: "1 / span 2", flexFlow: "column", gap: "0.5rem", children: filterOptions.map((column) => {
|
|
464
441
|
return (jsxs(Flex, { alignItems: "center", flexFlow: "wrap", gap: "0.5rem", children: [showFilterName && jsxs(Text, { children: [column, ":"] }), jsx(FilterOptions, { column: column })] }));
|
|
465
442
|
}) }), jsx(Flex, { gridColumn: "1 / span 2", children: showFilterTags && jsx(TableFilterTags, {}) }), jsx(Box, { overflow: "auto", gridColumn: "1 / span 2", width: "100%", height: "100%", children: children }), jsxs(Flex, { gap: "1rem", alignItems: "center", children: [jsx(PageSizeControl, {}), jsxs(Flex, { children: [jsx(Text, { paddingRight: "0.5rem", children: totalText }), jsx(RowCountText, {})] })] }), jsx(Box, { justifySelf: "end", children: jsx(TablePagination, {}) })] }));
|
|
466
443
|
};
|
|
467
444
|
|
|
468
445
|
const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, }) => {
|
|
469
|
-
const table =
|
|
446
|
+
const table = useDataTableContext().table;
|
|
470
447
|
const SELECTION_BOX_WIDTH = 20;
|
|
471
448
|
const [hoveredCheckBox, setHoveredCheckBox] = useState(false);
|
|
472
449
|
const handleRowHover = (isHovered) => {
|
|
@@ -515,7 +492,7 @@ const TableFooter = ({ pinnedBgColor = { light: "gray.50", dark: "gray.700" }, }
|
|
|
515
492
|
};
|
|
516
493
|
|
|
517
494
|
const TableHeader = ({ canResize, pinnedBgColor = { light: "gray.50", dark: "gray.700" }, }) => {
|
|
518
|
-
const { table } =
|
|
495
|
+
const { table } = useDataTableContext();
|
|
519
496
|
const SELECTION_BOX_WIDTH = 20;
|
|
520
497
|
const [hoveredCheckBox, setHoveredCheckBox] = useState(false);
|
|
521
498
|
const handleRowHover = (isHovered) => {
|
|
@@ -600,7 +577,7 @@ const DefaultTable = ({ totalText = "Total:", showFilter = false, showFooter = f
|
|
|
600
577
|
};
|
|
601
578
|
|
|
602
579
|
const Table = ({ children, showLoading = false, loadingComponent = jsx(Fragment, { children: "Loading..." }), ...props }) => {
|
|
603
|
-
const { table, loading } =
|
|
580
|
+
const { table, loading } = useDataTableContext();
|
|
604
581
|
if (showLoading) {
|
|
605
582
|
return (jsxs(Fragment, { children: [loading && loadingComponent, !loading && (jsx(Table$1, { width: table.getCenterTotalSize(), overflow: "auto", ...props, children: children }))] }));
|
|
606
583
|
}
|
|
@@ -626,7 +603,7 @@ const TableCards = ({ isSelectable = false }) => {
|
|
|
626
603
|
const TableComponent = ({ render = () => {
|
|
627
604
|
throw Error("Not Implemented");
|
|
628
605
|
}, }) => {
|
|
629
|
-
const { table } =
|
|
606
|
+
const { table } = useDataTableContext();
|
|
630
607
|
return render(table);
|
|
631
608
|
};
|
|
632
609
|
|
|
@@ -730,32 +707,32 @@ function Filter({ column }) {
|
|
|
730
707
|
} })] }, column.id));
|
|
731
708
|
}
|
|
732
709
|
const TableFilter = () => {
|
|
733
|
-
const { table } =
|
|
710
|
+
const { table } = useDataTableContext();
|
|
734
711
|
return (jsx(Fragment, { children: table.getAllColumns().map((column) => {
|
|
735
712
|
return jsx(Filter, { column: column }, column.id);
|
|
736
713
|
}) }));
|
|
737
714
|
};
|
|
738
715
|
|
|
739
716
|
const TableFilterTags = () => {
|
|
740
|
-
const { table } =
|
|
741
|
-
return (jsx(Flex, { gap: "0.5rem", flexFlow: "wrap", children: table.getState().columnFilters.map(({ id, value }
|
|
717
|
+
const { table } = useDataTableContext();
|
|
718
|
+
return (jsx(Flex, { gap: "0.5rem", flexFlow: "wrap", children: table.getState().columnFilters.map(({ id, value }) => {
|
|
742
719
|
return (jsxs(Tag, { display: "flex", gap: "0.5rem", alignItems: "center", children: [jsx(Text, { children: `${id}: ${value}` }), jsx(IconButton, { size: "xs", variant: "ghost", icon: jsx(CloseIcon, {}), onClick: () => {
|
|
743
|
-
table.setColumnFilters(table.getState().columnFilters.filter((
|
|
744
|
-
return
|
|
720
|
+
table.setColumnFilters(table.getState().columnFilters.filter((filter) => {
|
|
721
|
+
return filter.value != value;
|
|
745
722
|
}));
|
|
746
723
|
}, "aria-label": "remove filter" })] }, `${id}-${value}`));
|
|
747
724
|
}) }));
|
|
748
725
|
};
|
|
749
726
|
|
|
750
727
|
const TableLoadingComponent = ({ render, }) => {
|
|
751
|
-
const { loading } =
|
|
728
|
+
const { loading } = useDataTableContext();
|
|
752
729
|
return jsx(Fragment, { children: render(loading) });
|
|
753
730
|
};
|
|
754
731
|
|
|
755
732
|
const ColumnOrderChanger = ({ columns }) => {
|
|
756
733
|
const [order, setOrder] = useState([]);
|
|
757
734
|
const [originalOrder, setOriginalOrder] = useState([]);
|
|
758
|
-
const { table } =
|
|
735
|
+
const { table } = useDataTableContext();
|
|
759
736
|
const handleChangeOrder = (startIndex, endIndex) => {
|
|
760
737
|
const newOrder = Array.from(order);
|
|
761
738
|
const [removed] = newOrder.splice(startIndex, 1);
|
|
@@ -801,24 +778,24 @@ const ColumnOrderChanger = ({ columns }) => {
|
|
|
801
778
|
}, children: "Reset" })] })] }));
|
|
802
779
|
};
|
|
803
780
|
const TableOrderer = () => {
|
|
804
|
-
const { table } =
|
|
781
|
+
const { table } = useDataTableContext();
|
|
805
782
|
return (jsx(Fragment, { children: jsx(ColumnOrderChanger, { columns: table.getState().columnOrder }) }));
|
|
806
783
|
};
|
|
807
784
|
|
|
808
785
|
const TablePagination = ({}) => {
|
|
809
|
-
const { firstPage, getCanPreviousPage, previousPage, getState, nextPage, getCanNextPage, lastPage, } =
|
|
786
|
+
const { firstPage, getCanPreviousPage, previousPage, getState, nextPage, getCanNextPage, lastPage, } = useDataTableContext().table;
|
|
810
787
|
return (jsxs(ButtonGroup, { isAttached: true, children: [jsx(IconButton, { icon: jsx(MdFirstPage, {}), onClick: () => firstPage(), isDisabled: !getCanPreviousPage(), "aria-label": "first-page", variant: "ghost" }), jsx(IconButton, { icon: jsx(MdArrowBack, {}), onClick: () => previousPage(), isDisabled: !getCanPreviousPage(), "aria-label": "previous-page", variant: "ghost" }), jsx(Button, { variant: "ghost", onClick: () => { }, disabled: !getCanPreviousPage(), children: getState().pagination.pageIndex + 1 }), jsx(IconButton, { onClick: () => nextPage(), isDisabled: !getCanNextPage(), "aria-label": "next-page", variant: "ghost", children: jsx(MdArrowForward, {}) }), jsx(IconButton, { onClick: () => lastPage(), isDisabled: !getCanNextPage(), "aria-label": "last-page", variant: "ghost", children: jsx(MdLastPage, {}) })] }));
|
|
811
788
|
};
|
|
812
789
|
|
|
813
790
|
const ReloadButton = ({ text = "Reload" }) => {
|
|
814
|
-
const { refreshData } =
|
|
791
|
+
const { refreshData } = useDataTableContext();
|
|
815
792
|
return (jsx(Button, { leftIcon: jsx(IoReload, {}), onClick: () => {
|
|
816
793
|
refreshData();
|
|
817
794
|
}, children: text }));
|
|
818
795
|
};
|
|
819
796
|
|
|
820
|
-
const SelectAllRowsToggle = ({ selectAllIcon = jsx(MdOutlineChecklist, {}), clearAllIcon = jsx(MdClear, {}), selectAllText, clearAllText, }) => {
|
|
821
|
-
const { table } =
|
|
797
|
+
const SelectAllRowsToggle = ({ selectAllIcon = jsx(MdOutlineChecklist, {}), clearAllIcon = jsx(MdClear, {}), selectAllText = "", clearAllText = "", }) => {
|
|
798
|
+
const { table } = useDataTableContext();
|
|
822
799
|
return (jsxs(Fragment, { children: [!!selectAllText === false && (jsx(IconButton, { icon: table.getIsAllRowsSelected() ? clearAllIcon : selectAllIcon, variant: "ghost", "aria-label": table.getIsAllRowsSelected() ? clearAllText : selectAllText, onClick: (event) => {
|
|
823
800
|
table.getToggleAllRowsSelectedHandler()(event);
|
|
824
801
|
} })), !!selectAllText !== false && (jsx(Button, { leftIcon: table.getIsAllRowsSelected() ? clearAllIcon : selectAllIcon, variant: "ghost", onClick: (event) => {
|
|
@@ -834,11 +811,9 @@ const TableSelector = () => {
|
|
|
834
811
|
};
|
|
835
812
|
|
|
836
813
|
const TableViewer = () => {
|
|
837
|
-
const { table } =
|
|
814
|
+
const { table } = useDataTableContext();
|
|
838
815
|
const columns = table.getAllLeafColumns();
|
|
839
|
-
const [columnOrder, setColumnOrder] = useState(columns.map(
|
|
840
|
-
return column.id;
|
|
841
|
-
}));
|
|
816
|
+
const [columnOrder, setColumnOrder] = useState(columns.map(column => column.id));
|
|
842
817
|
const handleDragEnd = (result) => {
|
|
843
818
|
if (!result.destination)
|
|
844
819
|
return;
|
|
@@ -848,12 +823,10 @@ const TableViewer = () => {
|
|
|
848
823
|
setColumnOrder(newColumnOrder);
|
|
849
824
|
table.setColumnOrder(newColumnOrder);
|
|
850
825
|
};
|
|
851
|
-
return (jsx(
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
return (jsx(Draggable, { draggableId: column.id, index: i, children: (provided) => (jsxs(Grid, { ref: provided.innerRef, ...provided.draggableProps, templateColumns: "auto 1fr", gap: "0.5rem", alignItems: "center", children: [jsx(Flex, { ...provided.dragHandleProps, alignItems: "center", padding: "auto 0 auto 0", children: jsx(Icon, { as: FaGripLinesVertical, color: "gray.400" }) }), jsxs(Flex, { justifyContent: "space-between", alignItems: "center", children: [jsxs(Box, { children: [" ", displayName] }), jsx(Switch, { isChecked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler() })] })] }, column.id)) }, column.id));
|
|
856
|
-
}), provided.placeholder] })) }) }) }));
|
|
826
|
+
return (jsx(DragDropContext, { onDragEnd: handleDragEnd, children: jsx(Droppable, { droppableId: "columns", children: (provided) => (jsxs(Flex, { flexFlow: "column", gap: "0.5rem", ref: provided.innerRef, ...provided.droppableProps, children: [columns.map((column, index) => {
|
|
827
|
+
const displayName = column.columnDef.meta?.displayName || column.id;
|
|
828
|
+
return (jsx(Draggable, { draggableId: column.id, index: index, children: (provided) => (jsxs(Grid, { ref: provided.innerRef, ...provided.draggableProps, templateColumns: "auto 1fr", gap: "0.5rem", alignItems: "center", children: [jsx(Flex, { ...provided.dragHandleProps, alignItems: "center", padding: "0", children: jsx(Icon, { as: FaGripLinesVertical, color: "gray.400" }) }), jsxs(Flex, { justifyContent: "space-between", alignItems: "center", children: [jsx(Box, { children: displayName }), jsx(Switch, { isChecked: column.getIsVisible(), onChange: column.getToggleVisibilityHandler() })] })] })) }, column.id));
|
|
829
|
+
}), provided.placeholder] })) }) }));
|
|
857
830
|
};
|
|
858
831
|
|
|
859
832
|
const TextCell = ({ label, noOfLines = [1], padding = "0rem", children, tooltipProps, ...props }) => {
|
|
@@ -864,7 +837,7 @@ const TextCell = ({ label, noOfLines = [1], padding = "0rem", children, tooltipP
|
|
|
864
837
|
};
|
|
865
838
|
|
|
866
839
|
const FilterOptions = ({ column }) => {
|
|
867
|
-
const { table } =
|
|
840
|
+
const { table } = useDataTableContext();
|
|
868
841
|
const tableColumn = table.getColumn(column);
|
|
869
842
|
const options = tableColumn?.columnDef.meta?.filterOptions ?? [];
|
|
870
843
|
return (jsx(Fragment, { children: options.map((option) => {
|
|
@@ -884,10 +857,10 @@ const FilterOptions = ({ column }) => {
|
|
|
884
857
|
};
|
|
885
858
|
|
|
886
859
|
const GlobalFilter = ({ icon = MdSearch }) => {
|
|
887
|
-
const {
|
|
888
|
-
return (jsx(Fragment, { children: jsx(Box, { children: jsxs(InputGroup, { children: [jsx(InputLeftElement, { pointerEvents: "none", children: jsx(Icon, { as: icon, color: "gray.300" }) }), jsx(Input, { value: globalFilter, onChange: (e) => {
|
|
889
|
-
setGlobalFilter(e.target.value);
|
|
860
|
+
const { table } = useDataTableContext();
|
|
861
|
+
return (jsx(Fragment, { children: jsx(Box, { children: jsxs(InputGroup, { children: [jsx(InputLeftElement, { pointerEvents: "none", children: jsx(Icon, { as: icon, color: "gray.300" }) }), jsx(Input, { value: table.getState().globalFilter.globalFilter, onChange: (e) => {
|
|
862
|
+
table.setGlobalFilter(e.target.value);
|
|
890
863
|
} })] }) }) }));
|
|
891
864
|
};
|
|
892
865
|
|
|
893
|
-
export { DataTable, DataTableServer, DefaultTable, DensityToggleButton, EditFilterButton, EditOrderButton, EditSortingButton, EditViewButton, FilterOptions, GlobalFilter, PageSizeControl, ReloadButton, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, RowCountText, Table, TableBody, TableCardContainer, TableCards, TableComponent, TableControls, TableFilter, TableFilterTags, TableFooter, TableHeader, TableLoadingComponent, TableOrderer, TablePagination, TableSelector, TableSorter, TableViewer, TextCell, useDataFromUrl,
|
|
866
|
+
export { DataTable, DataTableServer, DefaultTable, DensityToggleButton, EditFilterButton, EditOrderButton, EditSortingButton, EditViewButton, FilterOptions, GlobalFilter, PageSizeControl, ReloadButton, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, RowCountText, Table, TableBody, TableCardContainer, TableCards, TableComponent, TableControls, TableFilter, TableFilterTags, TableFooter, TableHeader, TableLoadingComponent, TableOrderer, TablePagination, TableSelector, TableSorter, TableViewer, TextCell, useDataFromUrl, useDataTableContext };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export interface SelectAllRowsToggleProps {
|
|
3
|
-
selectAllIcon
|
|
4
|
-
clearAllIcon
|
|
5
|
-
selectAllText
|
|
6
|
-
clearAllText
|
|
3
|
+
selectAllIcon?: React.ReactElement;
|
|
4
|
+
clearAllIcon?: React.ReactElement;
|
|
5
|
+
selectAllText?: string;
|
|
6
|
+
clearAllText?: string;
|
|
7
7
|
}
|
|
8
8
|
export declare const SelectAllRowsToggle: ({ selectAllIcon, clearAllIcon, selectAllText, clearAllText, }: SelectAllRowsToggleProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ColumnDef, ColumnFiltersState, FilterFn, RowSelectionState, SortingState, VisibilityState } from "@tanstack/react-table";
|
|
2
|
+
import { ColumnDef, ColumnFiltersState, ColumnOrderState, FilterFn, GlobalFilterTableState, OnChangeFn, PaginationState, RowSelectionState, SortingState, VisibilityState } from "@tanstack/react-table";
|
|
3
3
|
import { RankingInfo } from "@tanstack/match-sorter-utils";
|
|
4
4
|
import { DensityState } from "../Controls/DensityFeature";
|
|
5
5
|
declare module "@tanstack/react-table" {
|
|
@@ -18,16 +18,21 @@ export interface DataTableProps<TData> {
|
|
|
18
18
|
enableMultiRowSelection?: boolean;
|
|
19
19
|
enableSubRowSelection?: boolean;
|
|
20
20
|
onRowSelect?: (rowSelectionState: RowSelectionState, data: TData[]) => void;
|
|
21
|
-
columnOrder
|
|
22
|
-
columnFilters
|
|
23
|
-
globalFilter
|
|
24
|
-
density
|
|
25
|
-
pagination
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
21
|
+
columnOrder: ColumnOrderState;
|
|
22
|
+
columnFilters: ColumnFiltersState;
|
|
23
|
+
globalFilter: GlobalFilterTableState;
|
|
24
|
+
density: DensityState;
|
|
25
|
+
pagination: PaginationState;
|
|
26
|
+
sorting: SortingState;
|
|
27
|
+
rowSelection: RowSelectionState;
|
|
28
|
+
columnVisibility: VisibilityState;
|
|
29
|
+
setPagination: OnChangeFn<PaginationState>;
|
|
30
|
+
setSorting: OnChangeFn<SortingState>;
|
|
31
|
+
setColumnFilters: OnChangeFn<ColumnFiltersState>;
|
|
32
|
+
setRowSelection: OnChangeFn<RowSelectionState>;
|
|
33
|
+
setGlobalFilter: OnChangeFn<GlobalFilterTableState>;
|
|
34
|
+
setColumnOrder: OnChangeFn<ColumnOrderState>;
|
|
35
|
+
setDensity: OnChangeFn<DensityState>;
|
|
36
|
+
setColumnVisibility: OnChangeFn<VisibilityState>;
|
|
32
37
|
}
|
|
33
|
-
export declare const DataTable: <TData>({ columns, data, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, onRowSelect, columnOrder
|
|
38
|
+
export declare const DataTable: <TData>({ columns, data, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, onRowSelect, columnOrder, columnFilters, columnVisibility, density, globalFilter, pagination, sorting, rowSelection, setPagination, setSorting, setColumnFilters, setRowSelection, setGlobalFilter, setColumnOrder, setDensity, setColumnVisibility, children, }: DataTableProps<TData>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Table } from "@tanstack/react-table";
|
|
2
|
+
import { GlobalFilterTableState, OnChangeFn, Table } from "@tanstack/react-table";
|
|
3
3
|
export interface DataTableContext<TData> {
|
|
4
4
|
table: Table<TData>;
|
|
5
5
|
refreshData: () => void;
|
|
6
|
-
globalFilter:
|
|
7
|
-
setGlobalFilter:
|
|
6
|
+
globalFilter: GlobalFilterTableState;
|
|
7
|
+
setGlobalFilter: OnChangeFn<GlobalFilterTableState>;
|
|
8
8
|
loading: boolean;
|
|
9
9
|
hasError: boolean;
|
|
10
10
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ColumnDef, ColumnFiltersState, RowSelectionState, SortingState, VisibilityState } from "@tanstack/react-table";
|
|
2
|
+
import { ColumnDef, ColumnFiltersState, ColumnOrderState, GlobalFilterTableState, OnChangeFn, PaginationState, RowSelectionState, SortingState, VisibilityState } from "@tanstack/react-table";
|
|
3
3
|
import { DensityState } from "../Controls/DensityFeature";
|
|
4
4
|
export interface DataTableServerProps<TData> {
|
|
5
5
|
children: JSX.Element | JSX.Element[];
|
|
@@ -9,18 +9,22 @@ export interface DataTableServerProps<TData> {
|
|
|
9
9
|
enableMultiRowSelection?: boolean;
|
|
10
10
|
enableSubRowSelection?: boolean;
|
|
11
11
|
onRowSelect?: (rowSelectionState: RowSelectionState, data: TData[]) => void;
|
|
12
|
-
columnOrder
|
|
13
|
-
columnFilters
|
|
14
|
-
globalFilter
|
|
15
|
-
density
|
|
16
|
-
pagination
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
columnOrder: ColumnOrderState;
|
|
13
|
+
columnFilters: ColumnFiltersState;
|
|
14
|
+
globalFilter: GlobalFilterTableState;
|
|
15
|
+
density: DensityState;
|
|
16
|
+
pagination: PaginationState;
|
|
17
|
+
sorting: SortingState;
|
|
18
|
+
rowSelection: RowSelectionState;
|
|
19
|
+
columnVisibility: VisibilityState;
|
|
20
|
+
setPagination: OnChangeFn<PaginationState>;
|
|
21
|
+
setSorting: OnChangeFn<SortingState>;
|
|
22
|
+
setColumnFilters: OnChangeFn<ColumnFiltersState>;
|
|
23
|
+
setRowSelection: OnChangeFn<RowSelectionState>;
|
|
24
|
+
setGlobalFilter: OnChangeFn<GlobalFilterTableState>;
|
|
25
|
+
setColumnOrder: OnChangeFn<ColumnOrderState>;
|
|
26
|
+
setDensity: OnChangeFn<DensityState>;
|
|
27
|
+
setColumnVisibility: OnChangeFn<VisibilityState>;
|
|
24
28
|
}
|
|
25
29
|
export interface Result<T> {
|
|
26
30
|
results: T[];
|
|
@@ -30,4 +34,4 @@ export interface DataResponse<T> extends Result<T> {
|
|
|
30
34
|
count: number;
|
|
31
35
|
filterCount: number;
|
|
32
36
|
}
|
|
33
|
-
export declare const DataTableServer: <TData>({ columns, url, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, onRowSelect, columnOrder
|
|
37
|
+
export declare const DataTableServer: <TData>({ columns, url, enableRowSelection, enableMultiRowSelection, enableSubRowSelection, onRowSelect, columnOrder, columnFilters, columnVisibility, density, globalFilter, pagination, sorting, rowSelection, setPagination, setSorting, setColumnFilters, setRowSelection, setGlobalFilter, setColumnOrder, setDensity, setColumnVisibility, children, }: DataTableServerProps<TData>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { ColumnFiltersState, ColumnOrderState, GlobalFilterTableState, OnChangeFn, PaginationState, RowSelectionState, SortingState, VisibilityState } from "@tanstack/react-table";
|
|
2
|
+
import { DensityState } from "../Controls/DensityFeature";
|
|
3
|
+
export interface UseDataTableProps {
|
|
4
|
+
default: {
|
|
5
|
+
sorting?: SortingState;
|
|
6
|
+
columnFilters?: ColumnFiltersState;
|
|
7
|
+
pagination?: PaginationState;
|
|
8
|
+
rowSelection?: RowSelectionState;
|
|
9
|
+
columnOrder?: ColumnOrderState;
|
|
10
|
+
globalFilter?: GlobalFilterTableState;
|
|
11
|
+
columnVisibility?: VisibilityState;
|
|
12
|
+
density?: DensityState;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface UseDataTableReturn {
|
|
16
|
+
sorting: SortingState;
|
|
17
|
+
columnFilters: ColumnFiltersState;
|
|
18
|
+
pagination: PaginationState;
|
|
19
|
+
rowSelection: RowSelectionState;
|
|
20
|
+
columnOrder: ColumnOrderState;
|
|
21
|
+
globalFilter: GlobalFilterTableState;
|
|
22
|
+
columnVisibility: VisibilityState;
|
|
23
|
+
density: DensityState;
|
|
24
|
+
setPagination: OnChangeFn<PaginationState>;
|
|
25
|
+
setSorting: OnChangeFn<SortingState>;
|
|
26
|
+
setColumnFilters: OnChangeFn<ColumnFiltersState>;
|
|
27
|
+
setRowSelection: OnChangeFn<RowSelectionState>;
|
|
28
|
+
setGlobalFilter: OnChangeFn<GlobalFilterTableState>;
|
|
29
|
+
setColumnOrder: OnChangeFn<ColumnOrderState>;
|
|
30
|
+
setDensity: OnChangeFn<DensityState>;
|
|
31
|
+
setColumnVisibility: OnChangeFn<VisibilityState>;
|
|
32
|
+
}
|
|
33
|
+
export declare const useDataTable: ({ default: { sorting: defaultSorting, pagination: defaultPagination, rowSelection: defaultRowSelection, columnFilters: defaultColumnFilters, columnOrder: defaultColumnOrder, columnVisibility: defaultColumnVisibility, globalFilter: defaultGlobalFilter, density: defaultDensity, }, }?: UseDataTableProps) => UseDataTableReturn;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const useDataTableContext: () => {
|
|
2
|
+
table: import("@tanstack/table-core").Table<any>;
|
|
3
|
+
refreshData: () => void;
|
|
4
|
+
globalFilter: import("@tanstack/table-core").GlobalFilterTableState;
|
|
5
|
+
setGlobalFilter: import("@tanstack/table-core").OnChangeFn<import("@tanstack/table-core").GlobalFilterTableState>;
|
|
6
|
+
loading: boolean;
|
|
7
|
+
hasError: boolean;
|
|
8
|
+
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -83,6 +83,6 @@ export * from "./components/DataTable/TableSorter";
|
|
|
83
83
|
export * from "./components/DataTable/TableViewer";
|
|
84
84
|
export * from "./components/DataTable/TextCell";
|
|
85
85
|
export * from "./components/DataTable/useDataFromUrl";
|
|
86
|
-
export * from "./components/DataTable/
|
|
86
|
+
export * from "./components/DataTable/useDataTableContext";
|
|
87
87
|
export * from "./components/Filter/FilterOptions";
|
|
88
88
|
export * from "./components/Filter/GlobalFilter";
|