@bsol-oss/react-datatable5 1.0.22 → 1.0.24
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 +15 -2
- package/dist/index.js +47 -5
- package/dist/index.mjs +47 -6
- package/dist/types/components/DataTable.d.ts +10 -1
- package/dist/types/components/DataTableContext.d.ts +2 -0
- package/dist/types/components/GlobalFilter.d.ts +1 -0
- package/dist/types/components/useDataTable.d.ts +2 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
-
import { ColumnDef } from '@tanstack/react-table';
|
|
3
|
+
import { FilterFn, ColumnDef } from '@tanstack/react-table';
|
|
4
|
+
import { RankingInfo } from '@tanstack/match-sorter-utils';
|
|
4
5
|
import { ReactNode } from 'react';
|
|
5
6
|
import * as _tanstack_table_core from '@tanstack/table-core';
|
|
6
7
|
|
|
8
|
+
declare module '@tanstack/react-table' {
|
|
9
|
+
interface FilterFns {
|
|
10
|
+
fuzzy: FilterFn<unknown>;
|
|
11
|
+
}
|
|
12
|
+
interface FilterMeta {
|
|
13
|
+
itemRank: RankingInfo;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
7
16
|
interface DataTableProps<T> {
|
|
8
17
|
children: JSX.Element | JSX.Element[];
|
|
9
18
|
data: T[];
|
|
@@ -40,6 +49,8 @@ declare const EditSortingButton: () => react_jsx_runtime.JSX.Element;
|
|
|
40
49
|
|
|
41
50
|
declare const EditViewButton: () => react_jsx_runtime.JSX.Element;
|
|
42
51
|
|
|
52
|
+
declare const GlobalFilter: () => react_jsx_runtime.JSX.Element;
|
|
53
|
+
|
|
43
54
|
interface PageSizeControlProps {
|
|
44
55
|
pageSizes?: number[];
|
|
45
56
|
}
|
|
@@ -108,6 +119,8 @@ declare const useDataFromUrl: <T>({ url, params, defaultData, }: useDataFromUrlP
|
|
|
108
119
|
declare const useDataTable: () => {
|
|
109
120
|
table: _tanstack_table_core.Table<any>;
|
|
110
121
|
refreshData: () => void;
|
|
122
|
+
globalFilter: string;
|
|
123
|
+
setGlobalFilter: (filter: string) => void;
|
|
111
124
|
};
|
|
112
125
|
|
|
113
|
-
export { type DataResponse, DataTable, type DataTableProps, DataTableServer, type DataTableServerProps, EditFilterButton, EditOrderButton, EditSortingButton, EditViewButton, PageSizeControl, type PageSizeControlProps, type PaginationProps, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, type Result, Table, TableBody, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableFilter, TableFooter, TableHeader, type TableHeaderProps, TableOrderer, TablePagination, type TableProps, TableSelector, TableSorter, TextCell, type TextCellProps, useDataFromUrl, type useDataFromUrlProps, type useDataFromUrlReturn, useDataTable };
|
|
126
|
+
export { type DataResponse, DataTable, type DataTableProps, DataTableServer, type DataTableServerProps, EditFilterButton, EditOrderButton, EditSortingButton, EditViewButton, GlobalFilter, PageSizeControl, type PageSizeControlProps, type PaginationProps, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, type Result, Table, TableBody, TableCardContainer, type TableCardContainerProps, TableCards, type TableCardsProps, TableFilter, TableFooter, TableHeader, type TableHeaderProps, TableOrderer, TablePagination, type TableProps, TableSelector, TableSorter, TextCell, type TextCellProps, useDataFromUrl, type useDataFromUrlProps, type useDataFromUrlReturn, useDataTable };
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var reactTable = require('@tanstack/react-table');
|
|
5
5
|
var react = require('react');
|
|
6
|
+
var matchSorterUtils = require('@tanstack/match-sorter-utils');
|
|
6
7
|
var axios = require('axios');
|
|
7
8
|
var react$1 = require('@chakra-ui/react');
|
|
8
9
|
var md = require('react-icons/md');
|
|
@@ -13,10 +14,24 @@ var table = require('@chakra-ui/table');
|
|
|
13
14
|
const TableContext = react.createContext({
|
|
14
15
|
table: {},
|
|
15
16
|
refreshData: () => { },
|
|
17
|
+
globalFilter: "",
|
|
18
|
+
setGlobalFilter: () => { },
|
|
16
19
|
});
|
|
17
20
|
|
|
21
|
+
// Define a custom fuzzy filter function that will apply ranking info to rows (using match-sorter utils)
|
|
22
|
+
const fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
23
|
+
// Rank the item
|
|
24
|
+
const itemRank = matchSorterUtils.rankItem(row.getValue(columnId), value);
|
|
25
|
+
// Store the itemRank info
|
|
26
|
+
addMeta({
|
|
27
|
+
itemRank,
|
|
28
|
+
});
|
|
29
|
+
// Return if the item should be filtered in/out
|
|
30
|
+
return itemRank.passed;
|
|
31
|
+
};
|
|
18
32
|
const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, children, }) => {
|
|
19
33
|
const [columnOrder, setColumnOrder] = react.useState([]);
|
|
34
|
+
const [globalFilter, setGlobalFilter] = react.useState('');
|
|
20
35
|
const table = reactTable.useReactTable({
|
|
21
36
|
data: data,
|
|
22
37
|
columns: columns,
|
|
@@ -31,6 +46,7 @@ const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
31
46
|
},
|
|
32
47
|
state: {
|
|
33
48
|
columnOrder,
|
|
49
|
+
globalFilter,
|
|
34
50
|
},
|
|
35
51
|
onColumnOrderChange: (state) => {
|
|
36
52
|
setColumnOrder(state);
|
|
@@ -39,6 +55,11 @@ const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
39
55
|
enableMultiRowSelection: enableMultiRowSelection,
|
|
40
56
|
enableSubRowSelection: enableSubRowSelection,
|
|
41
57
|
columnResizeMode: "onChange",
|
|
58
|
+
filterFns: {
|
|
59
|
+
fuzzy: fuzzyFilter, //define as a filter function that can be used in column definitions
|
|
60
|
+
},
|
|
61
|
+
onGlobalFilterChange: setGlobalFilter,
|
|
62
|
+
globalFilterFn: 'fuzzy', //apply fuzzy filter to the global filter (most common use case for fuzzy filter)
|
|
42
63
|
});
|
|
43
64
|
react.useEffect(() => {
|
|
44
65
|
setColumnOrder(table.getAllLeafColumns().map((column) => column.id));
|
|
@@ -48,6 +69,8 @@ const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
48
69
|
refreshData: () => {
|
|
49
70
|
throw new Error("not implemented");
|
|
50
71
|
},
|
|
72
|
+
globalFilter: globalFilter,
|
|
73
|
+
setGlobalFilter: setGlobalFilter,
|
|
51
74
|
}, children: children }));
|
|
52
75
|
};
|
|
53
76
|
|
|
@@ -89,6 +112,7 @@ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiR
|
|
|
89
112
|
});
|
|
90
113
|
const [rowSelection, setRowSelection] = react.useState({});
|
|
91
114
|
const [columnOrder, setColumnOrder] = react.useState([]);
|
|
115
|
+
const [globalFilter, setGlobalFilter] = react.useState("");
|
|
92
116
|
const { data, loading, hasError, refreshData } = useDataFromUrl({
|
|
93
117
|
url: url,
|
|
94
118
|
defaultData: {
|
|
@@ -110,6 +134,7 @@ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiR
|
|
|
110
134
|
obj[filter.id] = filter.value;
|
|
111
135
|
return { ...accumulator, ...obj };
|
|
112
136
|
}, {})),
|
|
137
|
+
searching: globalFilter,
|
|
113
138
|
},
|
|
114
139
|
});
|
|
115
140
|
const table = reactTable.useReactTable({
|
|
@@ -129,6 +154,7 @@ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiR
|
|
|
129
154
|
columnFilters,
|
|
130
155
|
rowSelection,
|
|
131
156
|
columnOrder,
|
|
157
|
+
globalFilter,
|
|
132
158
|
},
|
|
133
159
|
defaultColumn: {
|
|
134
160
|
size: 150, //starting column size
|
|
@@ -141,15 +167,23 @@ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiR
|
|
|
141
167
|
onColumnOrderChange: (state) => {
|
|
142
168
|
setColumnOrder(state);
|
|
143
169
|
},
|
|
170
|
+
onGlobalFilterChange: (state) => {
|
|
171
|
+
setGlobalFilter(state);
|
|
172
|
+
},
|
|
144
173
|
rowCount: data.filterCount,
|
|
145
174
|
});
|
|
146
175
|
react.useEffect(() => {
|
|
147
176
|
refreshData();
|
|
148
|
-
}, [pagination, sorting, columnFilters]);
|
|
177
|
+
}, [pagination, sorting, columnFilters, globalFilter]);
|
|
149
178
|
react.useEffect(() => {
|
|
150
179
|
setColumnOrder(table.getAllLeafColumns().map((column) => column.id));
|
|
151
180
|
}, []);
|
|
152
|
-
return (jsxRuntime.jsx(TableContext.Provider, { value: {
|
|
181
|
+
return (jsxRuntime.jsx(TableContext.Provider, { value: {
|
|
182
|
+
table: { ...table },
|
|
183
|
+
refreshData: refreshData,
|
|
184
|
+
globalFilter,
|
|
185
|
+
setGlobalFilter,
|
|
186
|
+
}, children: children }));
|
|
153
187
|
};
|
|
154
188
|
|
|
155
189
|
const ResetFilteringButton = () => {
|
|
@@ -160,8 +194,8 @@ const ResetFilteringButton = () => {
|
|
|
160
194
|
};
|
|
161
195
|
|
|
162
196
|
const useDataTable = () => {
|
|
163
|
-
const { table, refreshData } = react.useContext(TableContext);
|
|
164
|
-
return { table, refreshData };
|
|
197
|
+
const { table, refreshData, globalFilter, setGlobalFilter } = react.useContext(TableContext);
|
|
198
|
+
return { table, refreshData, globalFilter, setGlobalFilter };
|
|
165
199
|
};
|
|
166
200
|
|
|
167
201
|
const TableFilter = () => {
|
|
@@ -261,9 +295,16 @@ const EditViewButton = () => {
|
|
|
261
295
|
}) }) })] })] }));
|
|
262
296
|
};
|
|
263
297
|
|
|
298
|
+
const GlobalFilter = () => {
|
|
299
|
+
const { globalFilter, setGlobalFilter } = useDataTable();
|
|
300
|
+
return (jsxRuntime.jsx(react$1.Input, { value: globalFilter, onChange: (e) => {
|
|
301
|
+
setGlobalFilter(e.target.value);
|
|
302
|
+
} }));
|
|
303
|
+
};
|
|
304
|
+
|
|
264
305
|
const PageSizeControl = ({ pageSizes = [10, 20, 30, 40, 50], }) => {
|
|
265
306
|
const { table } = react.useContext(TableContext);
|
|
266
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(react$1.Menu, { children: [jsxRuntime.jsx(react$1.MenuButton, { as: react$1.Button, variant: "ghost", rightIcon: jsxRuntime.jsx(icons.ChevronDownIcon, {}), children: table.getState().pagination.pageSize }), jsxRuntime.jsx(react$1.MenuList, { children: pageSizes.map((pageSize) => (jsxRuntime.jsx(react$1.MenuItem, { onClick: () => {
|
|
307
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs(react$1.Menu, { children: [jsxRuntime.jsx(react$1.MenuButton, { as: react$1.Button, variant: "ghost", rightIcon: jsxRuntime.jsx(icons.ChevronDownIcon, {}), gap: "0.5rem", children: table.getState().pagination.pageSize }), jsxRuntime.jsx(react$1.MenuList, { children: pageSizes.map((pageSize) => (jsxRuntime.jsx(react$1.MenuItem, { onClick: () => {
|
|
267
308
|
table.setPageSize(Number(pageSize));
|
|
268
309
|
}, children: pageSize }))) })] }) }));
|
|
269
310
|
};
|
|
@@ -444,6 +485,7 @@ exports.EditFilterButton = EditFilterButton;
|
|
|
444
485
|
exports.EditOrderButton = EditOrderButton;
|
|
445
486
|
exports.EditSortingButton = EditSortingButton;
|
|
446
487
|
exports.EditViewButton = EditViewButton;
|
|
488
|
+
exports.GlobalFilter = GlobalFilter;
|
|
447
489
|
exports.PageSizeControl = PageSizeControl;
|
|
448
490
|
exports.ResetFilteringButton = ResetFilteringButton;
|
|
449
491
|
exports.ResetSelectionButton = ResetSelectionButton;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { useReactTable, getCoreRowModel, getFilteredRowModel, getSortedRowModel, getPaginationRowModel, flexRender } from '@tanstack/react-table';
|
|
3
3
|
import { createContext, useState, useEffect, useContext } from 'react';
|
|
4
|
+
import { rankItem } from '@tanstack/match-sorter-utils';
|
|
4
5
|
import axios from 'axios';
|
|
5
6
|
import { Button, Box, Text, Input, Popover, Tooltip, PopoverTrigger, IconButton, PopoverContent, PopoverArrow, PopoverBody, Flex, FormControl, Checkbox, Menu, MenuButton, MenuList, MenuItem, Container, Table as Table$1, Grid, Card, CardBody, Tfoot, Tr as Tr$1, Th, Thead, Portal, ButtonGroup, Icon } from '@chakra-ui/react';
|
|
6
7
|
import { MdFilterAlt, MdArrowUpward, MdArrowDownward, MdOutlineMoveDown, MdOutlineSort, MdPushPin, MdCancel, MdSort, MdFilterListAlt, MdFirstPage, MdArrowBack, MdArrowForward, MdLastPage, MdClear, MdOutlineChecklist } from 'react-icons/md';
|
|
@@ -11,10 +12,24 @@ import { Tbody, Tr, Td } from '@chakra-ui/table';
|
|
|
11
12
|
const TableContext = createContext({
|
|
12
13
|
table: {},
|
|
13
14
|
refreshData: () => { },
|
|
15
|
+
globalFilter: "",
|
|
16
|
+
setGlobalFilter: () => { },
|
|
14
17
|
});
|
|
15
18
|
|
|
19
|
+
// Define a custom fuzzy filter function that will apply ranking info to rows (using match-sorter utils)
|
|
20
|
+
const fuzzyFilter = (row, columnId, value, addMeta) => {
|
|
21
|
+
// Rank the item
|
|
22
|
+
const itemRank = rankItem(row.getValue(columnId), value);
|
|
23
|
+
// Store the itemRank info
|
|
24
|
+
addMeta({
|
|
25
|
+
itemRank,
|
|
26
|
+
});
|
|
27
|
+
// Return if the item should be filtered in/out
|
|
28
|
+
return itemRank.passed;
|
|
29
|
+
};
|
|
16
30
|
const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSelection = true, enableSubRowSelection = true, children, }) => {
|
|
17
31
|
const [columnOrder, setColumnOrder] = useState([]);
|
|
32
|
+
const [globalFilter, setGlobalFilter] = useState('');
|
|
18
33
|
const table = useReactTable({
|
|
19
34
|
data: data,
|
|
20
35
|
columns: columns,
|
|
@@ -29,6 +44,7 @@ const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
29
44
|
},
|
|
30
45
|
state: {
|
|
31
46
|
columnOrder,
|
|
47
|
+
globalFilter,
|
|
32
48
|
},
|
|
33
49
|
onColumnOrderChange: (state) => {
|
|
34
50
|
setColumnOrder(state);
|
|
@@ -37,6 +53,11 @@ const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
37
53
|
enableMultiRowSelection: enableMultiRowSelection,
|
|
38
54
|
enableSubRowSelection: enableSubRowSelection,
|
|
39
55
|
columnResizeMode: "onChange",
|
|
56
|
+
filterFns: {
|
|
57
|
+
fuzzy: fuzzyFilter, //define as a filter function that can be used in column definitions
|
|
58
|
+
},
|
|
59
|
+
onGlobalFilterChange: setGlobalFilter,
|
|
60
|
+
globalFilterFn: 'fuzzy', //apply fuzzy filter to the global filter (most common use case for fuzzy filter)
|
|
40
61
|
});
|
|
41
62
|
useEffect(() => {
|
|
42
63
|
setColumnOrder(table.getAllLeafColumns().map((column) => column.id));
|
|
@@ -46,6 +67,8 @@ const DataTable = ({ columns, data, enableRowSelection = true, enableMultiRowSel
|
|
|
46
67
|
refreshData: () => {
|
|
47
68
|
throw new Error("not implemented");
|
|
48
69
|
},
|
|
70
|
+
globalFilter: globalFilter,
|
|
71
|
+
setGlobalFilter: setGlobalFilter,
|
|
49
72
|
}, children: children }));
|
|
50
73
|
};
|
|
51
74
|
|
|
@@ -87,6 +110,7 @@ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiR
|
|
|
87
110
|
});
|
|
88
111
|
const [rowSelection, setRowSelection] = useState({});
|
|
89
112
|
const [columnOrder, setColumnOrder] = useState([]);
|
|
113
|
+
const [globalFilter, setGlobalFilter] = useState("");
|
|
90
114
|
const { data, loading, hasError, refreshData } = useDataFromUrl({
|
|
91
115
|
url: url,
|
|
92
116
|
defaultData: {
|
|
@@ -108,6 +132,7 @@ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiR
|
|
|
108
132
|
obj[filter.id] = filter.value;
|
|
109
133
|
return { ...accumulator, ...obj };
|
|
110
134
|
}, {})),
|
|
135
|
+
searching: globalFilter,
|
|
111
136
|
},
|
|
112
137
|
});
|
|
113
138
|
const table = useReactTable({
|
|
@@ -127,6 +152,7 @@ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiR
|
|
|
127
152
|
columnFilters,
|
|
128
153
|
rowSelection,
|
|
129
154
|
columnOrder,
|
|
155
|
+
globalFilter,
|
|
130
156
|
},
|
|
131
157
|
defaultColumn: {
|
|
132
158
|
size: 150, //starting column size
|
|
@@ -139,15 +165,23 @@ const DataTableServer = ({ columns, url, enableRowSelection = true, enableMultiR
|
|
|
139
165
|
onColumnOrderChange: (state) => {
|
|
140
166
|
setColumnOrder(state);
|
|
141
167
|
},
|
|
168
|
+
onGlobalFilterChange: (state) => {
|
|
169
|
+
setGlobalFilter(state);
|
|
170
|
+
},
|
|
142
171
|
rowCount: data.filterCount,
|
|
143
172
|
});
|
|
144
173
|
useEffect(() => {
|
|
145
174
|
refreshData();
|
|
146
|
-
}, [pagination, sorting, columnFilters]);
|
|
175
|
+
}, [pagination, sorting, columnFilters, globalFilter]);
|
|
147
176
|
useEffect(() => {
|
|
148
177
|
setColumnOrder(table.getAllLeafColumns().map((column) => column.id));
|
|
149
178
|
}, []);
|
|
150
|
-
return (jsx(TableContext.Provider, { value: {
|
|
179
|
+
return (jsx(TableContext.Provider, { value: {
|
|
180
|
+
table: { ...table },
|
|
181
|
+
refreshData: refreshData,
|
|
182
|
+
globalFilter,
|
|
183
|
+
setGlobalFilter,
|
|
184
|
+
}, children: children }));
|
|
151
185
|
};
|
|
152
186
|
|
|
153
187
|
const ResetFilteringButton = () => {
|
|
@@ -158,8 +192,8 @@ const ResetFilteringButton = () => {
|
|
|
158
192
|
};
|
|
159
193
|
|
|
160
194
|
const useDataTable = () => {
|
|
161
|
-
const { table, refreshData } = useContext(TableContext);
|
|
162
|
-
return { table, refreshData };
|
|
195
|
+
const { table, refreshData, globalFilter, setGlobalFilter } = useContext(TableContext);
|
|
196
|
+
return { table, refreshData, globalFilter, setGlobalFilter };
|
|
163
197
|
};
|
|
164
198
|
|
|
165
199
|
const TableFilter = () => {
|
|
@@ -259,9 +293,16 @@ const EditViewButton = () => {
|
|
|
259
293
|
}) }) })] })] }));
|
|
260
294
|
};
|
|
261
295
|
|
|
296
|
+
const GlobalFilter = () => {
|
|
297
|
+
const { globalFilter, setGlobalFilter } = useDataTable();
|
|
298
|
+
return (jsx(Input, { value: globalFilter, onChange: (e) => {
|
|
299
|
+
setGlobalFilter(e.target.value);
|
|
300
|
+
} }));
|
|
301
|
+
};
|
|
302
|
+
|
|
262
303
|
const PageSizeControl = ({ pageSizes = [10, 20, 30, 40, 50], }) => {
|
|
263
304
|
const { table } = useContext(TableContext);
|
|
264
|
-
return (jsx(Fragment, { children: jsxs(Menu, { children: [jsx(MenuButton, { as: Button, variant: "ghost", rightIcon: jsx(ChevronDownIcon, {}), children: table.getState().pagination.pageSize }), jsx(MenuList, { children: pageSizes.map((pageSize) => (jsx(MenuItem, { onClick: () => {
|
|
305
|
+
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: () => {
|
|
265
306
|
table.setPageSize(Number(pageSize));
|
|
266
307
|
}, children: pageSize }))) })] }) }));
|
|
267
308
|
};
|
|
@@ -436,4 +477,4 @@ const TextCell = ({ label, children }) => {
|
|
|
436
477
|
return (jsx(Text, { as: "span", overflow: "hidden", textOverflow: "ellipsis", noOfLines: [1, 2, 3], children: children }));
|
|
437
478
|
};
|
|
438
479
|
|
|
439
|
-
export { DataTable, DataTableServer, EditFilterButton, EditOrderButton, EditSortingButton, EditViewButton, PageSizeControl, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, Table, TableBody, TableCardContainer, TableCards, TableFilter, TableFooter, TableHeader, TableOrderer, TablePagination, TableSelector, TableSorter, TextCell, useDataFromUrl, useDataTable };
|
|
480
|
+
export { DataTable, DataTableServer, EditFilterButton, EditOrderButton, EditSortingButton, EditViewButton, GlobalFilter, PageSizeControl, ResetFilteringButton, ResetSelectionButton, ResetSortingButton, Table, TableBody, TableCardContainer, TableCards, TableFilter, TableFooter, TableHeader, TableOrderer, TablePagination, TableSelector, TableSorter, TextCell, useDataFromUrl, useDataTable };
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
import { ColumnDef, FilterFn } from "@tanstack/react-table";
|
|
3
|
+
import { RankingInfo } from '@tanstack/match-sorter-utils';
|
|
4
|
+
declare module '@tanstack/react-table' {
|
|
5
|
+
interface FilterFns {
|
|
6
|
+
fuzzy: FilterFn<unknown>;
|
|
7
|
+
}
|
|
8
|
+
interface FilterMeta {
|
|
9
|
+
itemRank: RankingInfo;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
3
12
|
export interface DataTableProps<T> {
|
|
4
13
|
children: JSX.Element | JSX.Element[];
|
|
5
14
|
data: T[];
|
|
@@ -3,5 +3,7 @@ import { Table } from "@tanstack/react-table";
|
|
|
3
3
|
export interface DataTableContext<T> {
|
|
4
4
|
table: Table<T>;
|
|
5
5
|
refreshData: () => void;
|
|
6
|
+
globalFilter: string;
|
|
7
|
+
setGlobalFilter: (filter: string) => void;
|
|
6
8
|
}
|
|
7
9
|
export declare const TableContext: import("react").Context<DataTableContext<any>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GlobalFilter: () => import("react/jsx-runtime").JSX.Element;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./components/EditFilterButton";
|
|
|
4
4
|
export * from "./components/EditOrderButton";
|
|
5
5
|
export * from "./components/EditSortingButton";
|
|
6
6
|
export * from "./components/EditViewButton";
|
|
7
|
+
export * from "./components/GlobalFilter";
|
|
7
8
|
export * from "./components/PageSizeControl";
|
|
8
9
|
export * from "./components/ResetFilteringButton";
|
|
9
10
|
export * from "./components/ResetSelectionButton";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bsol-oss/react-datatable5",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"@chakra-ui/react": "^2.8.2",
|
|
40
40
|
"@emotion/react": "^11.11.4",
|
|
41
41
|
"@emotion/styled": "^11.11.0",
|
|
42
|
+
"@tanstack/match-sorter-utils": "^8.15.1",
|
|
42
43
|
"@tanstack/react-table": "^8.16.0",
|
|
43
44
|
"axios": "^1.6.8",
|
|
44
45
|
"framer-motion": "^11.0.22",
|