material-react-table 0.37.0 → 0.37.1
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 -3
- package/dist/cjs/column.utils.d.ts +2 -1
- package/dist/cjs/index.js +22 -18
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/column.utils.d.ts +2 -1
- package/dist/esm/material-react-table.esm.js +22 -18
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/package.json +4 -4
- package/src/column.utils.ts +13 -7
- package/src/table/MRT_TableRoot.tsx +24 -14
package/README.md
CHANGED
|
@@ -4,13 +4,16 @@
|
|
|
4
4
|
<img alt="" src="https://badgen.net/npm/v/material-react-table?color=blue" />
|
|
5
5
|
</a>
|
|
6
6
|
<a href="https://npmjs.com/package/material-react-table" target="_blank">
|
|
7
|
-
<img alt="" src="https://
|
|
7
|
+
<img alt="" src="https://badgen.net/npm/dt/material-react-table?label=installs&icon=npm&color=blue" />
|
|
8
8
|
</a>
|
|
9
9
|
<a href="https://bundlephobia.com/result?p=material-react-table" target="_blank">
|
|
10
10
|
<img alt="" src="https://badgen.net/bundlephobia/minzip/material-react-table@latest?color=blue" />
|
|
11
11
|
</a>
|
|
12
12
|
<a href="https://github.com/KevinVandy/material-react-table" target="_blank">
|
|
13
|
-
<img alt="" src="https://
|
|
13
|
+
<img alt="" src="https://badgen.net/github/stars/KevinVandy/material-react-table?color=blue" />
|
|
14
|
+
</a>
|
|
15
|
+
<a href="https://github.com/KevinVandy/material-react-table/blob/main/LICENSE" target="_blank">
|
|
16
|
+
<img alt="" src="https://badgen.net/github/license/KevinVandy/material-react-table?color=blue" />
|
|
14
17
|
</a>
|
|
15
18
|
<a href="http://makeapullrequest.com" target="_blank">
|
|
16
19
|
<img alt="" src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square" />
|
|
@@ -29,7 +32,7 @@
|
|
|
29
32
|
|
|
30
33
|
Join the [Discord](https://discord.gg/5wqyRx6fnm) server to join in on the development discussion or ask questions
|
|
31
34
|
|
|
32
|
-
View the [Docs
|
|
35
|
+
View the [Docs Website](https://www.material-react-table.com/)
|
|
33
36
|
|
|
34
37
|
See all [Props and Options](https://www.material-react-table.com/docs/api)
|
|
35
38
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnOrderState } from '@tanstack/react-table';
|
|
1
|
+
import { ColumnOrderState, GroupingState } from '@tanstack/react-table';
|
|
2
2
|
import { MaterialReactTableProps, MRT_Column, MRT_ColumnDef, MRT_DefinedColumnDef, MRT_DisplayColumnIds, MRT_FilterOption } from '.';
|
|
3
3
|
import { MRT_FilterFns } from './filterFns';
|
|
4
4
|
import { MRT_SortingFns } from './sortingFns';
|
|
@@ -81,6 +81,7 @@ export declare const prepareColumns: <TData extends Record<string, any> = {}>(co
|
|
|
81
81
|
basic: import("@tanstack/table-core").SortingFn<any>;
|
|
82
82
|
} & Record<string, import("@tanstack/table-core").SortingFn<any>>) => MRT_DefinedColumnDef<TData>[];
|
|
83
83
|
export declare const reorderColumn: <TData extends Record<string, any> = {}>(draggedColumn: MRT_Column<TData>, targetColumn: MRT_Column<TData>, columnOrder: ColumnOrderState) => ColumnOrderState;
|
|
84
|
+
export declare const showExpandColumn: <TData extends Record<string, any> = {}>(props: MaterialReactTableProps<TData>, grouping?: GroupingState) => boolean;
|
|
84
85
|
export declare const getLeadingDisplayColumnIds: <TData extends Record<string, any> = {}>(props: MaterialReactTableProps<TData>) => MRT_DisplayColumnIds[];
|
|
85
86
|
export declare const getTrailingDisplayColumnIds: <TData extends Record<string, any> = {}>(props: MaterialReactTableProps<TData>) => (string | false | undefined)[];
|
|
86
87
|
export declare const getDefaultColumnOrderIds: <TData extends Record<string, any> = {}>(props: MaterialReactTableProps<TData>) => string[];
|
package/dist/cjs/index.js
CHANGED
|
@@ -529,6 +529,9 @@ const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
|
|
|
529
529
|
columnOrder.splice(columnOrder.indexOf(targetColumn.id), 0, columnOrder.splice(columnOrder.indexOf(draggedColumn.id), 1)[0]);
|
|
530
530
|
return [...columnOrder];
|
|
531
531
|
};
|
|
532
|
+
const showExpandColumn = (props, grouping) => !!(props.enableExpanding ||
|
|
533
|
+
(props.enableGrouping && (grouping === undefined || (grouping === null || grouping === void 0 ? void 0 : grouping.length))) ||
|
|
534
|
+
props.renderDetailPanel);
|
|
532
535
|
const getLeadingDisplayColumnIds = (props) => {
|
|
533
536
|
var _a;
|
|
534
537
|
return [
|
|
@@ -538,9 +541,7 @@ const getLeadingDisplayColumnIds = (props) => {
|
|
|
538
541
|
['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
|
|
539
542
|
'mrt-row-actions',
|
|
540
543
|
props.positionExpandColumn === 'first' &&
|
|
541
|
-
(props
|
|
542
|
-
props.enableGrouping ||
|
|
543
|
-
props.renderDetailPanel) &&
|
|
544
|
+
showExpandColumn(props) &&
|
|
544
545
|
'mrt-row-expand',
|
|
545
546
|
props.enableRowSelection && 'mrt-row-select',
|
|
546
547
|
props.enableRowNumbers && 'mrt-row-numbers',
|
|
@@ -554,9 +555,7 @@ const getTrailingDisplayColumnIds = (props) => {
|
|
|
554
555
|
['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
|
|
555
556
|
'mrt-row-actions',
|
|
556
557
|
props.positionExpandColumn === 'last' &&
|
|
557
|
-
(props
|
|
558
|
-
props.enableGrouping ||
|
|
559
|
-
props.renderDetailPanel) &&
|
|
558
|
+
showExpandColumn(props) &&
|
|
560
559
|
'mrt-row-expand',
|
|
561
560
|
];
|
|
562
561
|
};
|
|
@@ -2271,7 +2270,7 @@ const MRT_EditRowModal = ({ open, row, table, }) => {
|
|
|
2271
2270
|
};
|
|
2272
2271
|
|
|
2273
2272
|
const MRT_TableRoot = (props) => {
|
|
2274
|
-
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;
|
|
2273
|
+
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;
|
|
2275
2274
|
const bottomToolbarRef = React.useRef(null);
|
|
2276
2275
|
const editInputRefs = React.useRef({});
|
|
2277
2276
|
const filterInputRefs = React.useRef({});
|
|
@@ -2304,23 +2303,26 @@ const MRT_TableRoot = (props) => {
|
|
|
2304
2303
|
const [editingCell, setEditingCell] = React.useState((_e = initialState.editingCell) !== null && _e !== void 0 ? _e : null);
|
|
2305
2304
|
const [editingRow, setEditingRow] = React.useState((_f = initialState.editingRow) !== null && _f !== void 0 ? _f : null);
|
|
2306
2305
|
const [globalFilterFn, setGlobalFilterFn] = React.useState((_g = initialState.globalFilterFn) !== null && _g !== void 0 ? _g : 'fuzzy');
|
|
2307
|
-
const [
|
|
2308
|
-
const [
|
|
2309
|
-
const [
|
|
2310
|
-
const [
|
|
2311
|
-
const [
|
|
2312
|
-
const [
|
|
2306
|
+
const [grouping, setGrouping] = React.useState((_h = initialState.grouping) !== null && _h !== void 0 ? _h : []);
|
|
2307
|
+
const [hoveredColumn, setHoveredColumn] = React.useState((_j = initialState.hoveredColumn) !== null && _j !== void 0 ? _j : null);
|
|
2308
|
+
const [hoveredRow, setHoveredRow] = React.useState((_k = initialState.hoveredRow) !== null && _k !== void 0 ? _k : null);
|
|
2309
|
+
const [isFullScreen, setIsFullScreen] = React.useState((_l = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _l !== void 0 ? _l : false);
|
|
2310
|
+
const [showAlertBanner, setShowAlertBanner] = React.useState((_o = (_m = props.initialState) === null || _m === void 0 ? void 0 : _m.showAlertBanner) !== null && _o !== void 0 ? _o : false);
|
|
2311
|
+
const [showColumnFilters, setShowFilters] = React.useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _p !== void 0 ? _p : false);
|
|
2312
|
+
const [showGlobalFilter, setShowGlobalFilter] = React.useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _q !== void 0 ? _q : false);
|
|
2313
2313
|
const displayColumns = React.useMemo(() => {
|
|
2314
2314
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2315
2315
|
return [
|
|
2316
2316
|
columnOrder.includes('mrt-row-drag') && Object.assign(Object.assign(Object.assign({ header: (_a = props.localization) === null || _a === void 0 ? void 0 : _a.move, size: 60 }, defaultDisplayColumnDefOptions), (_b = props.displayColumnDefOptions) === null || _b === void 0 ? void 0 : _b['mrt-row-drag']), { id: 'mrt-row-drag' }),
|
|
2317
2317
|
columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React__default["default"].createElement(MRT_ToggleRowActionMenuButton, { row: row, table: table })), header: (_c = props.localization) === null || _c === void 0 ? void 0 : _c.actions, size: 70 }, defaultDisplayColumnDefOptions), (_d = props.displayColumnDefOptions) === null || _d === void 0 ? void 0 : _d['mrt-row-actions']), { id: 'mrt-row-actions' }),
|
|
2318
|
-
columnOrder.includes('mrt-row-expand') &&
|
|
2318
|
+
columnOrder.includes('mrt-row-expand') &&
|
|
2319
|
+
showExpandColumn(props, grouping) && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React__default["default"].createElement(MRT_ExpandButton, { row: row, table: table })), Header: () => props.enableExpandAll ? (React__default["default"].createElement(MRT_ExpandAllButton, { table: table })) : null, header: (_e = props.localization) === null || _e === void 0 ? void 0 : _e.expand, size: 60 }, defaultDisplayColumnDefOptions), (_f = props.displayColumnDefOptions) === null || _f === void 0 ? void 0 : _f['mrt-row-expand']), { id: 'mrt-row-expand' }),
|
|
2319
2320
|
columnOrder.includes('mrt-row-select') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => (React__default["default"].createElement(MRT_SelectCheckbox, { row: row, table: table })), Header: () => props.enableSelectAll ? (React__default["default"].createElement(MRT_SelectCheckbox, { selectAll: true, table: table })) : null, header: (_g = props.localization) === null || _g === void 0 ? void 0 : _g.select, size: 60 }, defaultDisplayColumnDefOptions), (_h = props.displayColumnDefOptions) === null || _h === void 0 ? void 0 : _h['mrt-row-select']), { id: 'mrt-row-select' }),
|
|
2320
2321
|
columnOrder.includes('mrt-row-numbers') && Object.assign(Object.assign(Object.assign({ Cell: ({ row }) => row.index + 1, Header: () => { var _a; return (_a = props.localization) === null || _a === void 0 ? void 0 : _a.rowNumber; }, header: (_j = props.localization) === null || _j === void 0 ? void 0 : _j.rowNumbers, size: 60 }, defaultDisplayColumnDefOptions), (_k = props.displayColumnDefOptions) === null || _k === void 0 ? void 0 : _k['mrt-row-numbers']), { id: 'mrt-row-numbers' }),
|
|
2321
2322
|
].filter(Boolean);
|
|
2322
2323
|
}, [
|
|
2323
2324
|
columnOrder,
|
|
2325
|
+
grouping,
|
|
2324
2326
|
props.displayColumnDefOptions,
|
|
2325
2327
|
props.editingMode,
|
|
2326
2328
|
props.enableColumnDragging,
|
|
@@ -2337,6 +2339,7 @@ const MRT_TableRoot = (props) => {
|
|
|
2337
2339
|
props.enableSelectAll,
|
|
2338
2340
|
props.localization,
|
|
2339
2341
|
props.positionActionsColumn,
|
|
2342
|
+
props.renderDetailPanel,
|
|
2340
2343
|
]);
|
|
2341
2344
|
const columnDefs = React.useMemo(() => prepareColumns([...displayColumns, ...props.columns], columnFilterFns, props.filterFns, props.sortingFns), [columnFilterFns, displayColumns, props.columns]);
|
|
2342
2345
|
const data = React.useMemo(() => {
|
|
@@ -2354,11 +2357,11 @@ const MRT_TableRoot = (props) => {
|
|
|
2354
2357
|
});
|
|
2355
2358
|
})))
|
|
2356
2359
|
: props.data;
|
|
2357
|
-
}, [props.data, (
|
|
2360
|
+
}, [props.data, (_r = props.state) === null || _r === void 0 ? void 0 : _r.isLoading, (_s = props.state) === null || _s === void 0 ? void 0 : _s.showSkeletons]);
|
|
2358
2361
|
//@ts-ignore
|
|
2359
|
-
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, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows }, props), {
|
|
2362
|
+
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), {
|
|
2360
2363
|
//@ts-ignore
|
|
2361
|
-
columns: columnDefs, data, globalFilterFn: (
|
|
2364
|
+
columns: columnDefs, data, globalFilterFn: (_u = (_t = props.filterFns) === null || _t === void 0 ? void 0 : _t[globalFilterFn]) !== null && _u !== void 0 ? _u : (_v = props.filterFns) === null || _v === void 0 ? void 0 : _v.fuzzy, initialState, state: Object.assign({ columnFilterFns,
|
|
2362
2365
|
columnOrder,
|
|
2363
2366
|
density,
|
|
2364
2367
|
draggingColumn,
|
|
@@ -2366,6 +2369,7 @@ const MRT_TableRoot = (props) => {
|
|
|
2366
2369
|
editingCell,
|
|
2367
2370
|
editingRow,
|
|
2368
2371
|
globalFilterFn,
|
|
2372
|
+
grouping,
|
|
2369
2373
|
hoveredColumn,
|
|
2370
2374
|
hoveredRow,
|
|
2371
2375
|
isFullScreen,
|
|
@@ -2378,7 +2382,7 @@ const MRT_TableRoot = (props) => {
|
|
|
2378
2382
|
searchInputRef,
|
|
2379
2383
|
tableContainerRef,
|
|
2380
2384
|
topToolbarRef,
|
|
2381
|
-
}, setColumnFilterFns: (
|
|
2385
|
+
}, setColumnFilterFns: (_w = props.onFilterFnsChange) !== null && _w !== void 0 ? _w : setColumnFilterFns, setDensity: (_x = props.onDensityChange) !== null && _x !== void 0 ? _x : setDensity, setDraggingColumn: (_y = props.onDraggingColumnChange) !== null && _y !== void 0 ? _y : setDraggingColumn, setDraggingRow: (_z = props.onDraggingRowChange) !== null && _z !== void 0 ? _z : setDraggingRow, setEditingCell: (_0 = props.onEditingCellChange) !== null && _0 !== void 0 ? _0 : setEditingCell, setEditingRow: (_1 = props.onEditingRowChange) !== null && _1 !== void 0 ? _1 : setEditingRow, setGlobalFilterFn: (_2 = props.onGlobalFilterFnChange) !== null && _2 !== void 0 ? _2 : setGlobalFilterFn, setHoveredColumn: (_3 = props.onHoveredColumnChange) !== null && _3 !== void 0 ? _3 : setHoveredColumn, setHoveredRow: (_4 = props.onHoveredRowChange) !== null && _4 !== void 0 ? _4 : setHoveredRow, setIsFullScreen: (_5 = props.onIsFullScreenChange) !== null && _5 !== void 0 ? _5 : setIsFullScreen, setShowAlertBanner: (_6 = props.onShowAlertBannerChange) !== null && _6 !== void 0 ? _6 : setShowAlertBanner, setShowFilters: (_7 = props.onShowFiltersChange) !== null && _7 !== void 0 ? _7 : setShowFilters, setShowGlobalFilter: (_8 = props.onShowGlobalFilterChange) !== null && _8 !== void 0 ? _8 : setShowGlobalFilter });
|
|
2382
2386
|
return (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2383
2387
|
React__default["default"].createElement(material.Dialog, { PaperComponent: material.Box, TransitionComponent: material.Grow, disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => setIsFullScreen(false), open: isFullScreen, transitionDuration: 400 },
|
|
2384
2388
|
React__default["default"].createElement(MRT_TablePaper, { table: table })),
|