material-react-table 0.40.8 → 0.40.11
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/README.md +6 -14
- package/dist/cjs/MaterialReactTable.d.ts +5 -3
- package/dist/cjs/index.js +59 -28
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/MaterialReactTable.d.ts +5 -3
- package/dist/esm/material-react-table.esm.js +59 -28
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/package.json +4 -4
- package/src/MaterialReactTable.tsx +6 -2
- package/src/buttons/MRT_CopyButton.tsx +7 -1
- package/src/buttons/MRT_ExpandAllButton.tsx +2 -1
- package/src/buttons/MRT_ExpandButton.tsx +2 -1
- package/src/buttons/MRT_FullScreenToggleButton.tsx +2 -1
- package/src/buttons/MRT_GrabHandleButton.tsx +2 -1
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +2 -1
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +2 -1
- package/src/buttons/MRT_ToggleFiltersButton.tsx +2 -1
- package/src/buttons/MRT_ToggleGlobalFilterButton.tsx +2 -2
- package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +2 -1
- package/src/inputs/MRT_FilterTextField.tsx +18 -3
- package/src/inputs/MRT_SelectCheckbox.tsx +5 -1
- package/src/table/MRT_TableRoot.tsx +7 -2
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Material React Table
|
|
2
2
|
|
|
3
|
+
__Built with [Material UI <sup>V5</sup>](https://mui.com) and [TanStack Table <sup>V8</sup>](https://tanstack.com/table/v8)__
|
|
4
|
+
|
|
5
|
+
_Quickly Create React Data Tables with Material Design_
|
|
6
|
+
|
|
3
7
|
<a href="https://npmjs.com/package/material-react-table" target="_blank">
|
|
4
8
|
<img alt="" src="https://badgen.net/npm/v/material-react-table?color=blue" />
|
|
5
9
|
</a>
|
|
@@ -19,8 +23,6 @@
|
|
|
19
23
|
<img alt="" src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square" />
|
|
20
24
|
</a>
|
|
21
25
|
|
|
22
|
-
---
|
|
23
|
-
|
|
24
26
|
## About
|
|
25
27
|
|
|
26
28
|
> This project is still in alpha, but is expected to enter beta by August 2022, and a stable 1.0 release shortly thereafter.
|
|
@@ -36,12 +38,10 @@ View the [Docs Website](https://www.material-react-table.com/)
|
|
|
36
38
|
|
|
37
39
|
See all [Props and Options](https://www.material-react-table.com/docs/api)
|
|
38
40
|
|
|
39
|
-
---
|
|
40
|
-
|
|
41
41
|
## Quick Examples
|
|
42
42
|
|
|
43
43
|
- [Basic Table](https://www.material-react-table.com/docs/examples/basic/) (See Default Features)
|
|
44
|
-
- [Minimal Table](https://www.material-react-table.com/docs/examples/minimal/) (Turn off Features)
|
|
44
|
+
- [Minimal Table](https://www.material-react-table.com/docs/examples/minimal/) (Turn off Features like Pagination, Sorting, Filtering, and Toolbars)
|
|
45
45
|
- [Advanced Table](https://www.material-react-table.com/docs/examples/advanced/) (See some of the Advanced Features)
|
|
46
46
|
- [Aggregation/Grouping](https://www.material-react-table.com/docs/examples/aggregation-and-grouping/) (Aggregation features such as Sum, Average, Count, etc.)
|
|
47
47
|
- [Data Export Table](https://www.material-react-table.com/docs/examples/data-export/) (Export to CSV, Excel, etc.)
|
|
@@ -53,8 +53,6 @@ See all [Props and Options](https://www.material-react-table.com/docs/api)
|
|
|
53
53
|
|
|
54
54
|
View additional [storybook examples](https://www.material-react-table.dev/)
|
|
55
55
|
|
|
56
|
-
---
|
|
57
|
-
|
|
58
56
|
## Features (All Features work and are MVP, but are still being polished)
|
|
59
57
|
|
|
60
58
|
_All features can easily be enabled/disabled_
|
|
@@ -91,8 +89,6 @@ _All features can easily be enabled/disabled_
|
|
|
91
89
|
- [x] Tree Data / Expanding Sub-rows
|
|
92
90
|
- [x] Virtualization (react-virtual)
|
|
93
91
|
|
|
94
|
-
---
|
|
95
|
-
|
|
96
92
|
## Getting Started
|
|
97
93
|
|
|
98
94
|
### Installation
|
|
@@ -113,13 +109,11 @@ npm install material-react-table
|
|
|
113
109
|
|
|
114
110
|
> _`@tanstack/react-table`, `@tanstack/react-virtual`, and `@tanstack/match-sorter-utils`_ are internal dependencies, so you don't need to install them yourself.
|
|
115
111
|
|
|
116
|
-
---
|
|
117
|
-
|
|
118
112
|
### Usage
|
|
119
113
|
|
|
120
114
|
> Read the full usage docs [here](https://www.material-react-table.com/docs/getting-started/usage/)
|
|
121
115
|
|
|
122
|
-
```
|
|
116
|
+
```jsx
|
|
123
117
|
import React, { useMemo, useState, useEffect } from 'react';
|
|
124
118
|
import MaterialReactTable from 'material-react-table';
|
|
125
119
|
|
|
@@ -178,8 +172,6 @@ export default function App() {
|
|
|
178
172
|
|
|
179
173
|
_Open in [Code Sandbox](https://codesandbox.io/s/simple-material-react-table-example-t5c3ji)_
|
|
180
174
|
|
|
181
|
-
---
|
|
182
|
-
|
|
183
175
|
## Contributors
|
|
184
176
|
|
|
185
177
|
<a href="https://github.com/kevinvandy/material-react-table/graphs/contributors">
|
|
@@ -160,7 +160,7 @@ export declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit
|
|
|
160
160
|
filterFn?: MRT_FilterFn<TData>;
|
|
161
161
|
filterSelectOptions?: (string | {
|
|
162
162
|
text: string;
|
|
163
|
-
value:
|
|
163
|
+
value: any;
|
|
164
164
|
})[];
|
|
165
165
|
filterVariant?: 'text' | 'select' | 'multi-select' | 'range';
|
|
166
166
|
/**
|
|
@@ -181,9 +181,11 @@ export declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit
|
|
|
181
181
|
* @default gets set to the same value as `accessorKey` by default
|
|
182
182
|
*/
|
|
183
183
|
id?: LiteralUnion<string & keyof TData>;
|
|
184
|
-
muiTableBodyCellCopyButtonProps?: ButtonProps | (({ cell, table, }: {
|
|
185
|
-
table: MRT_TableInstance<TData>;
|
|
184
|
+
muiTableBodyCellCopyButtonProps?: ButtonProps | (({ cell, column, row, table, }: {
|
|
186
185
|
cell: MRT_Cell<TData>;
|
|
186
|
+
column: MRT_Column<TData>;
|
|
187
|
+
row: MRT_Row<TData>;
|
|
188
|
+
table: MRT_TableInstance<TData>;
|
|
187
189
|
}) => ButtonProps);
|
|
188
190
|
muiTableBodyCellEditTextFieldProps?: TextFieldProps | (({ cell, column, row, table, }: {
|
|
189
191
|
cell: MRT_Cell<TData>;
|
package/dist/cjs/index.js
CHANGED
|
@@ -256,16 +256,17 @@ const rankGlobalFuzzy = (rowA, rowB) => Math.max(...Object.values(rowB.columnFil
|
|
|
256
256
|
Math.max(...Object.values(rowA.columnFiltersMeta).map((v) => v.rank));
|
|
257
257
|
|
|
258
258
|
const MRT_ExpandAllButton = ({ table }) => {
|
|
259
|
+
var _a;
|
|
259
260
|
const { getIsAllRowsExpanded, getIsSomeRowsExpanded, getCanSomeRowsExpand, getState, options: { icons: { KeyboardDoubleArrowDownIcon }, localization, muiExpandAllButtonProps, renderDetailPanel, }, toggleAllRowsExpanded, } = table;
|
|
260
261
|
const { density } = getState();
|
|
261
262
|
const iconButtonProps = muiExpandAllButtonProps instanceof Function
|
|
262
263
|
? muiExpandAllButtonProps({ table })
|
|
263
264
|
: muiExpandAllButtonProps;
|
|
264
|
-
return (React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.expandAll },
|
|
265
|
+
return (React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : localization.expandAll },
|
|
265
266
|
React__default["default"].createElement("span", null,
|
|
266
267
|
React__default["default"].createElement(material.IconButton, Object.assign({ "aria-label": localization.expandAll, disabled: !getCanSomeRowsExpand() && !renderDetailPanel, onClick: () => toggleAllRowsExpanded(!getIsAllRowsExpanded()) }, iconButtonProps, { sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', width: density === 'compact' ? '1.75rem' : '2.25rem', mt: density !== 'compact' ? '-0.25rem' : undefined }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
|
|
267
268
|
? iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx(theme)
|
|
268
|
-
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))) }),
|
|
269
|
+
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined }),
|
|
269
270
|
React__default["default"].createElement(KeyboardDoubleArrowDownIcon, { style: {
|
|
270
271
|
transform: `rotate(${getIsAllRowsExpanded()
|
|
271
272
|
? -180
|
|
@@ -277,6 +278,7 @@ const MRT_ExpandAllButton = ({ table }) => {
|
|
|
277
278
|
};
|
|
278
279
|
|
|
279
280
|
const MRT_ExpandButton = ({ row, table }) => {
|
|
281
|
+
var _a;
|
|
280
282
|
const { getState, options: { icons: { ExpandMoreIcon }, localization, muiExpandButtonProps, renderDetailPanel, }, } = table;
|
|
281
283
|
const { density } = getState();
|
|
282
284
|
const iconButtonProps = muiExpandButtonProps instanceof Function
|
|
@@ -288,11 +290,11 @@ const MRT_ExpandButton = ({ row, table }) => {
|
|
|
288
290
|
row.toggleExpanded();
|
|
289
291
|
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
290
292
|
};
|
|
291
|
-
return (React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.expand },
|
|
293
|
+
return (React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : localization.expand },
|
|
292
294
|
React__default["default"].createElement("span", null,
|
|
293
295
|
React__default["default"].createElement(material.IconButton, Object.assign({ "aria-label": localization.expand, disabled: !row.getCanExpand() && !renderDetailPanel }, iconButtonProps, { onClick: handleToggleExpand, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', width: density === 'compact' ? '1.75rem' : '2.25rem' }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
|
|
294
296
|
? iconButtonProps.sx(theme)
|
|
295
|
-
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))) }),
|
|
297
|
+
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined }),
|
|
296
298
|
React__default["default"].createElement(ExpandMoreIcon, { style: {
|
|
297
299
|
transform: `rotate(${!row.getCanExpand() && !renderDetailPanel
|
|
298
300
|
? -90
|
|
@@ -472,8 +474,9 @@ const MRT_ColumnPinningButtons = ({ column, table, }) => {
|
|
|
472
474
|
};
|
|
473
475
|
|
|
474
476
|
const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table, }) => {
|
|
477
|
+
var _a;
|
|
475
478
|
const { options: { icons: { DragHandleIcon }, localization, }, } = table;
|
|
476
|
-
return (React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: localization.move },
|
|
479
|
+
return (React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : localization.move },
|
|
477
480
|
React__default["default"].createElement(material.IconButton, Object.assign({ disableRipple: true, draggable: "true", onDragStart: onDragStart, onDragEnd: onDragEnd, size: "small" }, iconButtonProps, { onClick: (e) => {
|
|
478
481
|
var _a;
|
|
479
482
|
e.stopPropagation();
|
|
@@ -485,7 +488,7 @@ const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table,
|
|
|
485
488
|
cursor: 'grabbing',
|
|
486
489
|
} }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
|
|
487
490
|
? iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx(theme)
|
|
488
|
-
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))) }),
|
|
491
|
+
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined }),
|
|
489
492
|
React__default["default"].createElement(DragHandleIcon, null))));
|
|
490
493
|
};
|
|
491
494
|
|
|
@@ -981,6 +984,7 @@ const MRT_ToggleRowActionMenuButton = ({ cell, row, table, }) => {
|
|
|
981
984
|
};
|
|
982
985
|
|
|
983
986
|
const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
987
|
+
var _a;
|
|
984
988
|
const { getState, options: { localization, muiSelectCheckboxProps, muiSelectAllCheckboxProps, selectAllMode, }, } = table;
|
|
985
989
|
const { density } = getState();
|
|
986
990
|
const checkboxProps = !row
|
|
@@ -990,7 +994,9 @@ const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
|
990
994
|
: muiSelectCheckboxProps instanceof Function
|
|
991
995
|
? muiSelectCheckboxProps({ row, table })
|
|
992
996
|
: muiSelectCheckboxProps;
|
|
993
|
-
return (React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title:
|
|
997
|
+
return (React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: (_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _a !== void 0 ? _a : (selectAll
|
|
998
|
+
? localization.toggleSelectAll
|
|
999
|
+
: localization.toggleSelectRow) },
|
|
994
1000
|
React__default["default"].createElement(material.Checkbox, Object.assign({ checked: selectAll ? table.getIsAllRowsSelected() : row === null || row === void 0 ? void 0 : row.getIsSelected(), indeterminate: selectAll ? table.getIsSomeRowsSelected() : row === null || row === void 0 ? void 0 : row.getIsSomeSelected(), inputProps: {
|
|
995
1001
|
'aria-label': selectAll
|
|
996
1002
|
? localization.toggleSelectAll
|
|
@@ -1005,7 +1011,7 @@ const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
|
1005
1011
|
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
|
|
1006
1012
|
}, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.5rem', width: density === 'compact' ? '1.75rem' : '2.5rem', m: density !== 'compact' ? '-0.4rem' : undefined }, ((checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx) instanceof Function
|
|
1007
1013
|
? checkboxProps.sx(theme)
|
|
1008
|
-
: checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx))) }))));
|
|
1014
|
+
: checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx))), title: undefined }))));
|
|
1009
1015
|
};
|
|
1010
1016
|
|
|
1011
1017
|
const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
@@ -1123,17 +1129,19 @@ const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
|
|
|
1123
1129
|
};
|
|
1124
1130
|
|
|
1125
1131
|
const MRT_FullScreenToggleButton = (_a) => {
|
|
1132
|
+
var _b;
|
|
1126
1133
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
1127
1134
|
const { getState, options: { icons: { FullscreenExitIcon, FullscreenIcon }, localization, }, setIsFullScreen, } = table;
|
|
1128
1135
|
const { isFullScreen } = getState();
|
|
1129
1136
|
const handleToggleFullScreen = () => {
|
|
1130
1137
|
setIsFullScreen(!isFullScreen);
|
|
1131
1138
|
};
|
|
1132
|
-
return (React__default["default"].createElement(material.Tooltip, { arrow: true, title: localization.toggleFullScreen },
|
|
1133
|
-
React__default["default"].createElement(material.IconButton, Object.assign({ "aria-label": localization.showHideFilters, onClick: handleToggleFullScreen }, rest), isFullScreen ? React__default["default"].createElement(FullscreenExitIcon, null) : React__default["default"].createElement(FullscreenIcon, null))));
|
|
1139
|
+
return (React__default["default"].createElement(material.Tooltip, { arrow: true, title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.toggleFullScreen },
|
|
1140
|
+
React__default["default"].createElement(material.IconButton, Object.assign({ "aria-label": localization.showHideFilters, onClick: handleToggleFullScreen }, rest, { title: undefined }), isFullScreen ? React__default["default"].createElement(FullscreenExitIcon, null) : React__default["default"].createElement(FullscreenIcon, null))));
|
|
1134
1141
|
};
|
|
1135
1142
|
|
|
1136
1143
|
const MRT_ShowHideColumnsButton = (_a) => {
|
|
1144
|
+
var _b;
|
|
1137
1145
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
1138
1146
|
const { options: { icons: { ViewColumnIcon }, localization, }, } = table;
|
|
1139
1147
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
@@ -1141,13 +1149,14 @@ const MRT_ShowHideColumnsButton = (_a) => {
|
|
|
1141
1149
|
setAnchorEl(event.currentTarget);
|
|
1142
1150
|
};
|
|
1143
1151
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
1144
|
-
React__default["default"].createElement(material.Tooltip, { arrow: true, title: localization.showHideColumns },
|
|
1145
|
-
React__default["default"].createElement(material.IconButton, Object.assign({ "aria-label": localization.showHideColumns, onClick: handleClick }, rest),
|
|
1152
|
+
React__default["default"].createElement(material.Tooltip, { arrow: true, title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideColumns },
|
|
1153
|
+
React__default["default"].createElement(material.IconButton, Object.assign({ "aria-label": localization.showHideColumns, onClick: handleClick }, rest, { title: undefined }),
|
|
1146
1154
|
React__default["default"].createElement(ViewColumnIcon, null))),
|
|
1147
1155
|
React__default["default"].createElement(MRT_ShowHideColumnsMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table })));
|
|
1148
1156
|
};
|
|
1149
1157
|
|
|
1150
1158
|
const MRT_ToggleDensePaddingButton = (_a) => {
|
|
1159
|
+
var _b;
|
|
1151
1160
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
1152
1161
|
const { getState, options: { icons: { DensityLargeIcon, DensityMediumIcon, DensitySmallIcon }, localization, }, setDensity, } = table;
|
|
1153
1162
|
const { density } = getState();
|
|
@@ -1159,22 +1168,24 @@ const MRT_ToggleDensePaddingButton = (_a) => {
|
|
|
1159
1168
|
: 'comfortable';
|
|
1160
1169
|
setDensity(nextDensity);
|
|
1161
1170
|
};
|
|
1162
|
-
return (React__default["default"].createElement(material.Tooltip, { arrow: true, title: localization.toggleDensity },
|
|
1163
|
-
React__default["default"].createElement(material.IconButton, Object.assign({ "aria-label": localization.toggleDensity, onClick: handleToggleDensePadding }, rest), density === 'compact' ? (React__default["default"].createElement(DensitySmallIcon, null)) : density === 'comfortable' ? (React__default["default"].createElement(DensityMediumIcon, null)) : (React__default["default"].createElement(DensityLargeIcon, null)))));
|
|
1171
|
+
return (React__default["default"].createElement(material.Tooltip, { arrow: true, title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.toggleDensity },
|
|
1172
|
+
React__default["default"].createElement(material.IconButton, Object.assign({ "aria-label": localization.toggleDensity, onClick: handleToggleDensePadding }, rest, { title: undefined }), density === 'compact' ? (React__default["default"].createElement(DensitySmallIcon, null)) : density === 'comfortable' ? (React__default["default"].createElement(DensityMediumIcon, null)) : (React__default["default"].createElement(DensityLargeIcon, null)))));
|
|
1164
1173
|
};
|
|
1165
1174
|
|
|
1166
1175
|
const MRT_ToggleFiltersButton = (_a) => {
|
|
1176
|
+
var _b;
|
|
1167
1177
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
1168
1178
|
const { getState, options: { icons: { FilterListIcon, FilterListOffIcon }, localization, }, setShowFilters, } = table;
|
|
1169
1179
|
const { showColumnFilters } = getState();
|
|
1170
1180
|
const handleToggleShowFilters = () => {
|
|
1171
1181
|
setShowFilters(!showColumnFilters);
|
|
1172
1182
|
};
|
|
1173
|
-
return (React__default["default"].createElement(material.Tooltip, { arrow: true, title: localization.showHideFilters },
|
|
1174
|
-
React__default["default"].createElement(material.IconButton, Object.assign({ "aria-label": localization.showHideFilters, onClick: handleToggleShowFilters }, rest), showColumnFilters ? React__default["default"].createElement(FilterListOffIcon, null) : React__default["default"].createElement(FilterListIcon, null))));
|
|
1183
|
+
return (React__default["default"].createElement(material.Tooltip, { arrow: true, title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideFilters },
|
|
1184
|
+
React__default["default"].createElement(material.IconButton, Object.assign({ "aria-label": localization.showHideFilters, onClick: handleToggleShowFilters }, rest, { title: undefined }), showColumnFilters ? React__default["default"].createElement(FilterListOffIcon, null) : React__default["default"].createElement(FilterListIcon, null))));
|
|
1175
1185
|
};
|
|
1176
1186
|
|
|
1177
1187
|
const MRT_ToggleGlobalFilterButton = (_a) => {
|
|
1188
|
+
var _b;
|
|
1178
1189
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
1179
1190
|
const { getState, options: { icons: { SearchIcon, SearchOffIcon }, localization, }, refs: { searchInputRef }, setShowGlobalFilter, } = table;
|
|
1180
1191
|
const { showGlobalFilter } = getState();
|
|
@@ -1182,8 +1193,8 @@ const MRT_ToggleGlobalFilterButton = (_a) => {
|
|
|
1182
1193
|
setShowGlobalFilter(!showGlobalFilter);
|
|
1183
1194
|
queueMicrotask(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
|
|
1184
1195
|
};
|
|
1185
|
-
return (React__default["default"].createElement(material.Tooltip, { arrow: true, title: localization.showHideSearch },
|
|
1186
|
-
React__default["default"].createElement(material.IconButton, Object.assign({ onClick: handleToggleSearch }, rest), showGlobalFilter ? React__default["default"].createElement(SearchOffIcon, null) : React__default["default"].createElement(SearchIcon, null))));
|
|
1196
|
+
return (React__default["default"].createElement(material.Tooltip, { arrow: true, title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideSearch },
|
|
1197
|
+
React__default["default"].createElement(material.IconButton, Object.assign({ onClick: handleToggleSearch }, rest, { title: undefined }), showGlobalFilter ? React__default["default"].createElement(SearchOffIcon, null) : React__default["default"].createElement(SearchIcon, null))));
|
|
1187
1198
|
};
|
|
1188
1199
|
|
|
1189
1200
|
const MRT_ToolbarInternalButtons = ({ table }) => {
|
|
@@ -1315,6 +1326,7 @@ const MRT_BottomToolbar = ({ table }) => {
|
|
|
1315
1326
|
};
|
|
1316
1327
|
|
|
1317
1328
|
const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
|
|
1329
|
+
var _a;
|
|
1318
1330
|
const { options: { icons: { MoreVertIcon }, localization, muiTableHeadCellColumnActionsButtonProps, }, } = table;
|
|
1319
1331
|
const { column } = header;
|
|
1320
1332
|
const { columnDef } = column;
|
|
@@ -1335,12 +1347,12 @@ const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
|
|
|
1335
1347
|
: columnDef.muiTableHeadCellColumnActionsButtonProps;
|
|
1336
1348
|
const iconButtonProps = Object.assign(Object.assign({}, mTableHeadCellColumnActionsButtonProps), mcTableHeadCellColumnActionsButtonProps);
|
|
1337
1349
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
1338
|
-
React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: localization.columnActions },
|
|
1350
|
+
React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : localization.columnActions },
|
|
1339
1351
|
React__default["default"].createElement(material.IconButton, Object.assign({ "aria-label": localization.columnActions, onClick: handleClick, size: "small" }, iconButtonProps, { sx: (theme) => (Object.assign({ height: '2rem', mt: '-0.2rem', opacity: 0.5, transition: 'opacity 0.2s', width: '2rem', '&:hover': {
|
|
1340
1352
|
opacity: 1,
|
|
1341
1353
|
} }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
|
|
1342
1354
|
? iconButtonProps.sx(theme)
|
|
1343
|
-
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))) }),
|
|
1355
|
+
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))), title: undefined }),
|
|
1344
1356
|
React__default["default"].createElement(MoreVertIcon, null))),
|
|
1345
1357
|
React__default["default"].createElement(MRT_ColumnActionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table })));
|
|
1346
1358
|
};
|
|
@@ -1484,7 +1496,15 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1484
1496
|
displayEmpty: true,
|
|
1485
1497
|
multiple: isMultiSelectFilter,
|
|
1486
1498
|
renderValue: isMultiSelectFilter
|
|
1487
|
-
? (selected) => !(selected === null || selected === void 0 ? void 0 : selected.length) ? (React__default["default"].createElement(material.Box, { sx: { opacity: 0.5 } }, filterPlaceholder)) : (React__default["default"].createElement(material.Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' } }, selected === null || selected === void 0 ? void 0 : selected.map((value) =>
|
|
1499
|
+
? (selected) => !(selected === null || selected === void 0 ? void 0 : selected.length) ? (React__default["default"].createElement(material.Box, { sx: { opacity: 0.5 } }, filterPlaceholder)) : (React__default["default"].createElement(material.Box, { sx: { display: 'flex', flexWrap: 'wrap', gap: '2px' } }, selected === null || selected === void 0 ? void 0 : selected.map((value) => {
|
|
1500
|
+
var _a;
|
|
1501
|
+
const selectedValue = (_a = columnDef.filterSelectOptions) === null || _a === void 0 ? void 0 : _a.find((option) => option instanceof Object
|
|
1502
|
+
? option.value === value
|
|
1503
|
+
: option === value);
|
|
1504
|
+
return (React__default["default"].createElement(material.Chip, { key: value, label: selectedValue instanceof Object
|
|
1505
|
+
? selectedValue.text
|
|
1506
|
+
: selectedValue }));
|
|
1507
|
+
})))
|
|
1488
1508
|
: undefined,
|
|
1489
1509
|
} }, textFieldProps, { inputRef: (inputRef) => {
|
|
1490
1510
|
filterInputRefs.current[`${column.id}-${rangeFilterIndex !== null && rangeFilterIndex !== void 0 ? rangeFilterIndex : 0}`] =
|
|
@@ -1875,6 +1895,7 @@ const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
|
|
|
1875
1895
|
};
|
|
1876
1896
|
|
|
1877
1897
|
const MRT_CopyButton = ({ cell, children, table, }) => {
|
|
1898
|
+
var _a;
|
|
1878
1899
|
const { options: { localization, muiTableBodyCellCopyButtonProps }, } = table;
|
|
1879
1900
|
const { column, row } = cell;
|
|
1880
1901
|
const { columnDef } = column;
|
|
@@ -1891,14 +1912,16 @@ const MRT_CopyButton = ({ cell, children, table, }) => {
|
|
|
1891
1912
|
const mcTableBodyCellCopyButtonProps = columnDef.muiTableBodyCellCopyButtonProps instanceof Function
|
|
1892
1913
|
? columnDef.muiTableBodyCellCopyButtonProps({
|
|
1893
1914
|
cell,
|
|
1915
|
+
column,
|
|
1916
|
+
row,
|
|
1894
1917
|
table,
|
|
1895
1918
|
})
|
|
1896
1919
|
: columnDef.muiTableBodyCellCopyButtonProps;
|
|
1897
1920
|
const buttonProps = Object.assign(Object.assign({}, mTableBodyCellCopyButtonProps), mcTableBodyCellCopyButtonProps);
|
|
1898
|
-
return (React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: copied ? localization.copiedToClipboard : localization.clickToCopy },
|
|
1921
|
+
return (React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: (_a = buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.title) !== null && _a !== void 0 ? _a : (copied ? localization.copiedToClipboard : localization.clickToCopy) },
|
|
1899
1922
|
React__default["default"].createElement(material.Button, Object.assign({ onClick: (e) => handleCopy(e, cell.getValue()), size: "small", type: "button", variant: "text" }, buttonProps, { sx: (theme) => (Object.assign({ backgroundColor: 'transparent', border: 'none', color: 'inherit', cursor: 'copy', fontFamily: 'inherit', fontSize: 'inherit', letterSpacing: 'inherit', m: '-0.25rem', minWidth: 'unset', textAlign: 'inherit', textTransform: 'inherit' }, ((buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx) instanceof Function
|
|
1900
1923
|
? buttonProps.sx(theme)
|
|
1901
|
-
: buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx))) }), children)));
|
|
1924
|
+
: buttonProps === null || buttonProps === void 0 ? void 0 : buttonProps.sx))), title: undefined }), children)));
|
|
1902
1925
|
};
|
|
1903
1926
|
|
|
1904
1927
|
const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
|
|
@@ -2378,7 +2401,7 @@ const MRT_EditRowModal = ({ open, row, table, }) => {
|
|
|
2378
2401
|
};
|
|
2379
2402
|
|
|
2380
2403
|
const MRT_TableRoot = (props) => {
|
|
2381
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8;
|
|
2404
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;
|
|
2382
2405
|
const bottomToolbarRef = React.useRef(null);
|
|
2383
2406
|
const editInputRefs = React.useRef({});
|
|
2384
2407
|
const filterInputRefs = React.useRef({});
|
|
@@ -2450,7 +2473,15 @@ const MRT_TableRoot = (props) => {
|
|
|
2450
2473
|
props.positionActionsColumn,
|
|
2451
2474
|
props.renderDetailPanel,
|
|
2452
2475
|
]);
|
|
2453
|
-
const columnDefs = React.useMemo(() =>
|
|
2476
|
+
const columnDefs = React.useMemo(() => {
|
|
2477
|
+
var _a, _b;
|
|
2478
|
+
return prepareColumns([...displayColumns, ...props.columns], (_b = (_a = props.state) === null || _a === void 0 ? void 0 : _a.columnFilterFns) !== null && _b !== void 0 ? _b : columnFilterFns, props.filterFns, props.sortingFns);
|
|
2479
|
+
}, [
|
|
2480
|
+
columnFilterFns,
|
|
2481
|
+
displayColumns,
|
|
2482
|
+
props.columns,
|
|
2483
|
+
(_r = props.state) === null || _r === void 0 ? void 0 : _r.columnFilterFns,
|
|
2484
|
+
]);
|
|
2454
2485
|
const data = React.useMemo(() => {
|
|
2455
2486
|
var _a, _b, _c, _d, _e;
|
|
2456
2487
|
return (((_a = props.state) === null || _a === void 0 ? void 0 : _a.isLoading) || ((_b = props.state) === null || _b === void 0 ? void 0 : _b.showSkeletons)) &&
|
|
@@ -2466,11 +2497,11 @@ const MRT_TableRoot = (props) => {
|
|
|
2466
2497
|
});
|
|
2467
2498
|
})))
|
|
2468
2499
|
: props.data;
|
|
2469
|
-
}, [props.data, (
|
|
2500
|
+
}, [props.data, (_s = props.state) === null || _s === void 0 ? void 0 : _s.isLoading, (_t = props.state) === null || _t === void 0 ? void 0 : _t.showSkeletons]);
|
|
2470
2501
|
//@ts-ignore
|
|
2471
2502
|
const table = Object.assign(Object.assign({}, reactTable.useReactTable(Object.assign(Object.assign({ getCoreRowModel: reactTable.getCoreRowModel(), getExpandedRowModel: reactTable.getExpandedRowModel(), getFacetedRowModel: reactTable.getFacetedRowModel(), getFilteredRowModel: reactTable.getFilteredRowModel(), getGroupedRowModel: reactTable.getGroupedRowModel(), getPaginationRowModel: reactTable.getPaginationRowModel(), getSortedRowModel: reactTable.getSortedRowModel(), onColumnOrderChange: setColumnOrder, onGroupingChange: setGrouping, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows }, props), {
|
|
2472
2503
|
//@ts-ignore
|
|
2473
|
-
columns: columnDefs, data, globalFilterFn: (
|
|
2504
|
+
columns: columnDefs, data, globalFilterFn: (_v = (_u = props.filterFns) === null || _u === void 0 ? void 0 : _u[globalFilterFn]) !== null && _v !== void 0 ? _v : (_w = props.filterFns) === null || _w === void 0 ? void 0 : _w.fuzzy, initialState, state: Object.assign({ columnFilterFns,
|
|
2474
2505
|
columnOrder,
|
|
2475
2506
|
density,
|
|
2476
2507
|
draggingColumn,
|
|
@@ -2491,7 +2522,7 @@ const MRT_TableRoot = (props) => {
|
|
|
2491
2522
|
searchInputRef,
|
|
2492
2523
|
tableContainerRef,
|
|
2493
2524
|
topToolbarRef,
|
|
2494
|
-
}, setColumnFilterFns: (
|
|
2525
|
+
}, setColumnFilterFns: (_x = props.onFilterFnsChange) !== null && _x !== void 0 ? _x : setColumnFilterFns, setDensity: (_y = props.onDensityChange) !== null && _y !== void 0 ? _y : setDensity, setDraggingColumn: (_z = props.onDraggingColumnChange) !== null && _z !== void 0 ? _z : setDraggingColumn, setDraggingRow: (_0 = props.onDraggingRowChange) !== null && _0 !== void 0 ? _0 : setDraggingRow, setEditingCell: (_1 = props.onEditingCellChange) !== null && _1 !== void 0 ? _1 : setEditingCell, setEditingRow: (_2 = props.onEditingRowChange) !== null && _2 !== void 0 ? _2 : setEditingRow, setGlobalFilterFn: (_3 = props.onGlobalFilterFnChange) !== null && _3 !== void 0 ? _3 : setGlobalFilterFn, setHoveredColumn: (_4 = props.onHoveredColumnChange) !== null && _4 !== void 0 ? _4 : setHoveredColumn, setHoveredRow: (_5 = props.onHoveredRowChange) !== null && _5 !== void 0 ? _5 : setHoveredRow, setIsFullScreen: (_6 = props.onIsFullScreenChange) !== null && _6 !== void 0 ? _6 : setIsFullScreen, setShowAlertBanner: (_7 = props.onShowAlertBannerChange) !== null && _7 !== void 0 ? _7 : setShowAlertBanner, setShowFilters: (_8 = props.onShowFiltersChange) !== null && _8 !== void 0 ? _8 : setShowFilters, setShowGlobalFilter: (_9 = props.onShowGlobalFilterChange) !== null && _9 !== void 0 ? _9 : setShowGlobalFilter });
|
|
2495
2526
|
if (props.tableInstanceRef) {
|
|
2496
2527
|
props.tableInstanceRef.current = table;
|
|
2497
2528
|
}
|