material-react-table 0.37.1 → 0.38.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 +2 -1
- package/dist/cjs/MaterialReactTable.d.ts +20 -10
- package/dist/cjs/body/MRT_TableBodyCellValue.d.ts +8 -0
- package/dist/cjs/buttons/MRT_CopyButton.d.ts +5 -5
- package/dist/cjs/buttons/MRT_ToggleRowActionMenuButton.d.ts +2 -1
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.js +64 -45
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/MaterialReactTable.d.ts +20 -10
- package/dist/esm/body/MRT_TableBodyCellValue.d.ts +8 -0
- package/dist/esm/buttons/MRT_CopyButton.d.ts +5 -5
- package/dist/esm/buttons/MRT_ToggleRowActionMenuButton.d.ts +2 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/material-react-table.esm.js +64 -46
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/index.d.ts +28 -11
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +25 -8
- package/src/body/MRT_TableBodyCell.tsx +8 -18
- package/src/body/MRT_TableBodyCellValue.tsx +35 -0
- package/src/buttons/MRT_CopyButton.tsx +9 -5
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +9 -4
- package/src/head/MRT_TableHeadCell.tsx +3 -5
- package/src/index.tsx +2 -0
- package/src/inputs/MRT_EditCellTextField.tsx +11 -2
- package/src/inputs/MRT_FilterTextField.tsx +1 -1
- package/src/table/MRT_TableRoot.tsx +6 -2
- package/src/toolbar/MRT_BottomToolbar.tsx +5 -7
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +14 -5
- package/src/toolbar/MRT_TopToolbar.tsx +4 -4
package/README.md
CHANGED
|
@@ -43,6 +43,7 @@ See all [Props and Options](https://www.material-react-table.com/docs/api)
|
|
|
43
43
|
- [Basic Table](https://www.material-react-table.com/docs/examples/basic/) (See Default Features)
|
|
44
44
|
- [Minimal Table](https://www.material-react-table.com/docs/examples/minimal/) (Turn off Features)
|
|
45
45
|
- [Advanced Table](https://www.material-react-table.com/docs/examples/advanced/) (See some of the Advanced Features)
|
|
46
|
+
- [Aggregation/Grouping](https://www.material-react-table.com/docs/examples/aggregation-and-grouping/) (Aggregation features such as Sum, Average, Count, etc.)
|
|
46
47
|
- [Data Export Table](https://www.material-react-table.com/docs/examples/data-export/) (Export to CSV, Excel, etc.)
|
|
47
48
|
- [Editing CRUD Table](https://www.material-react-table.com/docs/examples/editing-crud/) (Create, Edit, and Delete Rows)
|
|
48
49
|
- [Remote Data](https://www.material-react-table.com/docs/examples/remote/) (Server-side Pagination, Sorting, and Filtering)
|
|
@@ -60,9 +61,9 @@ _All features can easily be enabled/disabled_
|
|
|
60
61
|
|
|
61
62
|
- [x] < 37kb gzipped - [Bundlephobia](https://bundlephobia.com/package/material-react-table)
|
|
62
63
|
- [x] Advanced TypeScript Generics Support (TypeScript Optional)
|
|
64
|
+
- [x] Aggregation and Grouping (Sum, Average, Count, etc.)
|
|
63
65
|
- [x] Click To Copy Cell Values
|
|
64
66
|
- [x] Column Action Dropdown Menu
|
|
65
|
-
- [x] Column/Row Grouping (Group By and Aggregates)
|
|
66
67
|
- [x] Column Hiding
|
|
67
68
|
- [x] Column Ordering via Drag'n'Drop
|
|
68
69
|
- [x] Column Pinning (Freeze Columns)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dispatch, DragEvent, MutableRefObject, ReactNode, SetStateAction } from 'react';
|
|
2
|
-
import type { AlertProps, ButtonProps, CheckboxProps, IconButtonProps, LinearProgressProps, PaperProps, SkeletonProps, TableBodyProps, TableCellProps, TableContainerProps, TableFooterProps, TableHeadProps, TablePaginationProps, TableProps, TableRowProps, TextFieldProps, ToolbarProps } from '@mui/material';
|
|
2
|
+
import type { AlertProps, ButtonProps, CheckboxProps, ChipProps, IconButtonProps, LinearProgressProps, PaperProps, SkeletonProps, TableBodyProps, TableCellProps, TableContainerProps, TableFooterProps, TableHeadProps, TablePaginationProps, TableProps, TableRowProps, TextFieldProps, ToolbarProps } from '@mui/material';
|
|
3
3
|
import type { Cell, Column, ColumnDef, DeepKeys, FilterFn, Header, HeaderGroup, OnChangeFn, Row, SortingFn, Table, TableOptions, TableState } from '@tanstack/react-table';
|
|
4
4
|
import type { Options as VirtualizerOptions } from 'react-virtual';
|
|
5
5
|
import { MRT_Icons } from './icons';
|
|
@@ -48,8 +48,8 @@ export declare type MRT_TableInstance<TData extends Record<string, any> = {}> =
|
|
|
48
48
|
setDensity: Dispatch<SetStateAction<'comfortable' | 'compact' | 'spacious'>>;
|
|
49
49
|
setDraggingColumn: Dispatch<SetStateAction<MRT_Column<TData> | null>>;
|
|
50
50
|
setDraggingRow: Dispatch<SetStateAction<MRT_Row<TData> | null>>;
|
|
51
|
-
setEditingCell: Dispatch<SetStateAction<MRT_Cell | null>>;
|
|
52
|
-
setEditingRow: Dispatch<SetStateAction<MRT_Row | null>>;
|
|
51
|
+
setEditingCell: Dispatch<SetStateAction<MRT_Cell<TData> | null>>;
|
|
52
|
+
setEditingRow: Dispatch<SetStateAction<MRT_Row<TData> | null>>;
|
|
53
53
|
setGlobalFilterFn: Dispatch<SetStateAction<MRT_FilterOption>>;
|
|
54
54
|
setHoveredColumn: Dispatch<SetStateAction<MRT_Column<TData> | {
|
|
55
55
|
id: string;
|
|
@@ -113,6 +113,12 @@ export declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit
|
|
|
113
113
|
footer: MRT_Header<TData>;
|
|
114
114
|
table: MRT_TableInstance<TData>;
|
|
115
115
|
}) => ReactNode);
|
|
116
|
+
GroupedCell?: ({ cell, column, row, table, }: {
|
|
117
|
+
cell: MRT_Cell<TData>;
|
|
118
|
+
column: MRT_Column<TData>;
|
|
119
|
+
row: MRT_Row<TData>;
|
|
120
|
+
table: MRT_TableInstance<TData>;
|
|
121
|
+
}) => ReactNode;
|
|
116
122
|
Header?: ReactNode | (({ column, header, table, }: {
|
|
117
123
|
column: MRT_Column<TData>;
|
|
118
124
|
header: MRT_Header<TData>;
|
|
@@ -292,6 +298,9 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
|
292
298
|
icons?: Partial<MRT_Icons>;
|
|
293
299
|
initialState?: Partial<MRT_TableState<TData>>;
|
|
294
300
|
localization?: Partial<MRT_Localization>;
|
|
301
|
+
muiBottomToolbarProps?: ToolbarProps | (({ table }: {
|
|
302
|
+
table: MRT_TableInstance<TData>;
|
|
303
|
+
}) => ToolbarProps);
|
|
295
304
|
muiExpandAllButtonProps?: IconButtonProps | (({ table }: {
|
|
296
305
|
table: MRT_TableInstance<TData>;
|
|
297
306
|
}) => IconButtonProps);
|
|
@@ -346,9 +355,6 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
|
346
355
|
table: MRT_TableInstance<TData>;
|
|
347
356
|
row: MRT_Row<TData>;
|
|
348
357
|
}) => TableRowProps);
|
|
349
|
-
muiTableBottomToolbarProps?: ToolbarProps | (({ table }: {
|
|
350
|
-
table: MRT_TableInstance<TData>;
|
|
351
|
-
}) => ToolbarProps);
|
|
352
358
|
muiTableContainerProps?: TableContainerProps | (({ table, }: {
|
|
353
359
|
table: MRT_TableInstance<TData>;
|
|
354
360
|
}) => TableContainerProps);
|
|
@@ -400,10 +406,13 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
|
400
406
|
muiTableProps?: TableProps | (({ table }: {
|
|
401
407
|
table: MRT_TableInstance<TData>;
|
|
402
408
|
}) => TableProps);
|
|
403
|
-
|
|
409
|
+
muiToolbarAlertBannerChipProps?: ChipProps | (({ table }: {
|
|
410
|
+
table: MRT_TableInstance<TData>;
|
|
411
|
+
}) => ChipProps);
|
|
412
|
+
muiToolbarAlertBannerProps?: AlertProps | (({ table }: {
|
|
404
413
|
table: MRT_TableInstance<TData>;
|
|
405
414
|
}) => AlertProps);
|
|
406
|
-
|
|
415
|
+
muiTopToolbarProps?: ToolbarProps | (({ table }: {
|
|
407
416
|
table: MRT_TableInstance<TData>;
|
|
408
417
|
}) => ToolbarProps);
|
|
409
418
|
onColumnDrop?: ({ event, draggedColumn, targetColumn, }: {
|
|
@@ -416,13 +425,13 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
|
416
425
|
onDensityChange?: OnChangeFn<boolean>;
|
|
417
426
|
onDraggingColumnChange?: OnChangeFn<MRT_Column<TData> | null>;
|
|
418
427
|
onDraggingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
|
|
428
|
+
onEditingCellChange?: OnChangeFn<MRT_Cell<TData> | null>;
|
|
419
429
|
onEditingRowSave?: ({ exitEditingMode, row, table, values, }: {
|
|
420
430
|
exitEditingMode: () => void;
|
|
421
431
|
row: MRT_Row<TData>;
|
|
422
432
|
table: MRT_TableInstance<TData>;
|
|
423
433
|
values: Record<LiteralUnion<string & DeepKeys<TData>>, any>;
|
|
424
434
|
}) => Promise<void> | void;
|
|
425
|
-
onEditingCellChange?: OnChangeFn<MRT_Cell<TData> | null>;
|
|
426
435
|
onEditingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
|
|
427
436
|
onFilterFnsChange?: OnChangeFn<{
|
|
428
437
|
[key: string]: MRT_FilterOption;
|
|
@@ -459,7 +468,8 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
|
459
468
|
row: MRT_Row<TData>;
|
|
460
469
|
table: MRT_TableInstance<TData>;
|
|
461
470
|
}) => ReactNode[];
|
|
462
|
-
renderRowActions?: ({ row, table, }: {
|
|
471
|
+
renderRowActions?: ({ cell, row, table, }: {
|
|
472
|
+
cell: MRT_Cell<TData>;
|
|
463
473
|
row: MRT_Row<TData>;
|
|
464
474
|
table: MRT_TableInstance<TData>;
|
|
465
475
|
}) => ReactNode;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import { MRT_Cell, MRT_TableInstance } from '..';
|
|
3
|
-
interface Props {
|
|
4
|
-
cell: MRT_Cell
|
|
3
|
+
interface Props<TData extends Record<string, any> = {}> {
|
|
4
|
+
cell: MRT_Cell<TData>;
|
|
5
5
|
children: ReactNode;
|
|
6
|
-
table: MRT_TableInstance
|
|
6
|
+
table: MRT_TableInstance<TData>;
|
|
7
7
|
}
|
|
8
|
-
export declare const MRT_CopyButton:
|
|
8
|
+
export declare const MRT_CopyButton: <TData extends Record<string, any> = {}>({ cell, children, table, }: Props<TData>) => JSX.Element;
|
|
9
9
|
export {};
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -4,10 +4,11 @@ export * from './MaterialReactTable';
|
|
|
4
4
|
import type { MRT_Icons } from './icons';
|
|
5
5
|
import type { MRT_Localization } from './localization';
|
|
6
6
|
export type { MRT_Localization, MRT_Icons };
|
|
7
|
+
import { MRT_CopyButton } from './buttons/MRT_CopyButton';
|
|
7
8
|
import { MRT_FullScreenToggleButton } from './buttons/MRT_FullScreenToggleButton';
|
|
8
9
|
import { MRT_GlobalFilterTextField } from './inputs/MRT_GlobalFilterTextField';
|
|
9
10
|
import { MRT_ShowHideColumnsButton } from './buttons/MRT_ShowHideColumnsButton';
|
|
10
11
|
import { MRT_ToggleDensePaddingButton } from './buttons/MRT_ToggleDensePaddingButton';
|
|
11
12
|
import { MRT_ToggleFiltersButton } from './buttons/MRT_ToggleFiltersButton';
|
|
12
13
|
import { MRT_ToggleGlobalFilterButton } from './buttons/MRT_ToggleGlobalFilterButton';
|
|
13
|
-
export { MRT_FullScreenToggleButton, MRT_GlobalFilterTextField, MRT_ShowHideColumnsButton, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton, };
|
|
14
|
+
export { MRT_FullScreenToggleButton, MRT_GlobalFilterTextField, MRT_ShowHideColumnsButton, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton, MRT_CopyButton, };
|
package/dist/cjs/index.js
CHANGED
|
@@ -923,7 +923,7 @@ const commonIconButtonStyles = {
|
|
|
923
923
|
opacity: 1,
|
|
924
924
|
},
|
|
925
925
|
};
|
|
926
|
-
const MRT_ToggleRowActionMenuButton = ({ row, table }) => {
|
|
926
|
+
const MRT_ToggleRowActionMenuButton = ({ cell, row, table }) => {
|
|
927
927
|
const { getState, options: { editingMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
|
|
928
928
|
const { editingRow } = getState();
|
|
929
929
|
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
@@ -936,8 +936,8 @@ const MRT_ToggleRowActionMenuButton = ({ row, table }) => {
|
|
|
936
936
|
setEditingRow(Object.assign({}, row));
|
|
937
937
|
setAnchorEl(null);
|
|
938
938
|
};
|
|
939
|
-
return (React__default["default"].createElement(React__default["default"].Fragment, null, renderRowActions ? (React__default["default"].createElement(React__default["default"].Fragment, null, renderRowActions({ row, table }))) : row.id === (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) && editingMode === 'row' ? (React__default["default"].createElement(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems && enableEditing ? (React__default["default"].createElement(material.Tooltip, { placement: "right", arrow: true, title: localization.edit },
|
|
940
|
-
React__default["default"].createElement(material.IconButton, { sx: commonIconButtonStyles, onClick: handleStartEditMode },
|
|
939
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null, renderRowActions ? (React__default["default"].createElement(React__default["default"].Fragment, null, renderRowActions({ cell, row, table }))) : row.id === (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) && editingMode === 'row' ? (React__default["default"].createElement(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems && enableEditing ? (React__default["default"].createElement(material.Tooltip, { placement: "right", arrow: true, title: localization.edit },
|
|
940
|
+
React__default["default"].createElement(material.IconButton, { "aria-label": localization.edit, sx: commonIconButtonStyles, onClick: handleStartEditMode },
|
|
941
941
|
React__default["default"].createElement(EditIcon, null)))) : renderRowActionMenuItems ? (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
942
942
|
React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.rowActions },
|
|
943
943
|
React__default["default"].createElement(material.IconButton, { "aria-label": localization.rowActions, onClick: handleOpenRowActionMenu, size: "small", sx: commonIconButtonStyles },
|
|
@@ -1053,11 +1053,14 @@ const MRT_TablePagination = ({ table, position }) => {
|
|
|
1053
1053
|
|
|
1054
1054
|
const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
|
|
1055
1055
|
var _a, _b;
|
|
1056
|
-
const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization,
|
|
1056
|
+
const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization, muiToolbarAlertBannerProps, muiToolbarAlertBannerChipProps, }, } = table;
|
|
1057
1057
|
const { grouping, showAlertBanner } = getState();
|
|
1058
|
-
const alertProps =
|
|
1059
|
-
?
|
|
1060
|
-
:
|
|
1058
|
+
const alertProps = muiToolbarAlertBannerProps instanceof Function
|
|
1059
|
+
? muiToolbarAlertBannerProps({ table })
|
|
1060
|
+
: muiToolbarAlertBannerProps;
|
|
1061
|
+
const chipProps = muiToolbarAlertBannerChipProps instanceof Function
|
|
1062
|
+
? muiToolbarAlertBannerChipProps({ table })
|
|
1063
|
+
: muiToolbarAlertBannerChipProps;
|
|
1061
1064
|
const selectMessage = getSelectedRowModel().rows.length > 0
|
|
1062
1065
|
? (_b = (_a = localization.selectedCountOfRowCountRowsSelected) === null || _a === void 0 ? void 0 : _a.replace('{selectedCount}', getSelectedRowModel().rows.length.toString())) === null || _b === void 0 ? void 0 : _b.replace('{rowCount}', getPrePaginationRowModel().rows.length.toString())
|
|
1063
1066
|
: null;
|
|
@@ -1066,7 +1069,7 @@ const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
|
|
|
1066
1069
|
' ',
|
|
1067
1070
|
grouping.map((columnId, index) => (React__default["default"].createElement(React.Fragment, { key: `${index}-${columnId}` },
|
|
1068
1071
|
index > 0 ? localization.thenBy : '',
|
|
1069
|
-
React__default["default"].createElement(material.Chip, {
|
|
1072
|
+
React__default["default"].createElement(material.Chip, Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))))))) : null;
|
|
1070
1073
|
return (React__default["default"].createElement(material.Collapse, { in: showAlertBanner || !!selectMessage || !!groupedByMessage, timeout: stackAlertBanner ? 200 : 0 },
|
|
1071
1074
|
React__default["default"].createElement(material.Alert, Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => (Object.assign({ borderRadius: 0, fontSize: '1rem', left: 0, p: 0, position: 'relative', right: 0, top: 0, width: '100%', zIndex: 2 }, ((alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx) instanceof Function
|
|
1072
1075
|
? alertProps.sx(theme)
|
|
@@ -1197,12 +1200,12 @@ const commonToolbarStyles = ({ theme }) => ({
|
|
|
1197
1200
|
});
|
|
1198
1201
|
const MRT_TopToolbar = ({ table }) => {
|
|
1199
1202
|
var _a;
|
|
1200
|
-
const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions,
|
|
1203
|
+
const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, }, refs: { topToolbarRef }, } = table;
|
|
1201
1204
|
const { isFullScreen, showGlobalFilter } = getState();
|
|
1202
1205
|
const isMobile = material.useMediaQuery('(max-width:720px)');
|
|
1203
|
-
const toolbarProps =
|
|
1204
|
-
?
|
|
1205
|
-
:
|
|
1206
|
+
const toolbarProps = muiTopToolbarProps instanceof Function
|
|
1207
|
+
? muiTopToolbarProps({ table })
|
|
1208
|
+
: muiTopToolbarProps;
|
|
1206
1209
|
const stackAlertBanner = isMobile || !!renderTopToolbarCustomActions || showGlobalFilter;
|
|
1207
1210
|
return (React__default["default"].createElement(material.Toolbar, Object.assign({ variant: "dense" }, toolbarProps, { ref: (ref) => {
|
|
1208
1211
|
topToolbarRef.current = ref;
|
|
@@ -1235,12 +1238,12 @@ const MRT_TopToolbar = ({ table }) => {
|
|
|
1235
1238
|
};
|
|
1236
1239
|
|
|
1237
1240
|
const MRT_BottomToolbar = ({ table }) => {
|
|
1238
|
-
const { getState, options: { enablePagination,
|
|
1241
|
+
const { getState, options: { enablePagination, muiBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions, }, refs: { bottomToolbarRef }, } = table;
|
|
1239
1242
|
const { isFullScreen } = getState();
|
|
1240
1243
|
const isMobile = material.useMediaQuery('(max-width:720px)');
|
|
1241
|
-
const toolbarProps =
|
|
1242
|
-
?
|
|
1243
|
-
:
|
|
1244
|
+
const toolbarProps = muiBottomToolbarProps instanceof Function
|
|
1245
|
+
? muiBottomToolbarProps({ table })
|
|
1246
|
+
: muiBottomToolbarProps;
|
|
1244
1247
|
const stackAlertBanner = isMobile || !!renderBottomToolbarCustomActions;
|
|
1245
1248
|
return (React__default["default"].createElement(material.Toolbar, Object.assign({ variant: "dense" }, toolbarProps, { ref: (ref) => {
|
|
1246
1249
|
bottomToolbarRef.current = ref;
|
|
@@ -1259,7 +1262,7 @@ const MRT_BottomToolbar = ({ table }) => {
|
|
|
1259
1262
|
justifyContent: 'space-between',
|
|
1260
1263
|
width: '100%',
|
|
1261
1264
|
} },
|
|
1262
|
-
renderBottomToolbarCustomActions ? (
|
|
1265
|
+
renderBottomToolbarCustomActions ? (renderBottomToolbarCustomActions({ table })) : (React__default["default"].createElement("span", null)),
|
|
1263
1266
|
React__default["default"].createElement(material.Box, { sx: {
|
|
1264
1267
|
display: 'flex',
|
|
1265
1268
|
justifyContent: 'flex-end',
|
|
@@ -1449,7 +1452,7 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1449
1452
|
if (textFieldProps.inputRef) {
|
|
1450
1453
|
textFieldProps.inputRef = inputRef;
|
|
1451
1454
|
}
|
|
1452
|
-
}, sx: (theme) => (Object.assign({ p: 0, minWidth: !filterChipLabel ? '
|
|
1455
|
+
}, sx: (theme) => (Object.assign({ p: 0, minWidth: !filterChipLabel ? '150px' : 'auto', width: '100%', '& .MuiSelect-icon': {
|
|
1453
1456
|
mr: '1.5rem',
|
|
1454
1457
|
} }, ((textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx) instanceof Function
|
|
1455
1458
|
? textFieldProps.sx(theme)
|
|
@@ -1641,7 +1644,7 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1641
1644
|
if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
|
|
1642
1645
|
setHoveredColumn(null);
|
|
1643
1646
|
}
|
|
1644
|
-
if (enableColumnOrdering && draggingColumn) {
|
|
1647
|
+
if (enableColumnOrdering && draggingColumn && columnDefType !== 'group') {
|
|
1645
1648
|
setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
|
|
1646
1649
|
}
|
|
1647
1650
|
};
|
|
@@ -1691,13 +1694,11 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1691
1694
|
? '0.4rem'
|
|
1692
1695
|
: '0.6rem', position: column.getIsPinned() && columnDefType !== 'group'
|
|
1693
1696
|
? 'sticky'
|
|
1694
|
-
: undefined, pt: columnDefType === 'group'
|
|
1695
|
-
? 0
|
|
1696
|
-
: density === '
|
|
1697
|
-
? '
|
|
1698
|
-
:
|
|
1699
|
-
? '.75rem'
|
|
1700
|
-
: '1.25rem', right: column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined, transition: `all ${enableColumnResizing ? 0 : '0.2s'} ease-in-out`, userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
|
|
1697
|
+
: undefined, pt: columnDefType === 'group' || density === 'compact'
|
|
1698
|
+
? '0.25rem'
|
|
1699
|
+
: density === 'comfortable'
|
|
1700
|
+
? '.75rem'
|
|
1701
|
+
: '1.25rem', right: column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined, transition: `all ${enableColumnResizing ? 0 : '0.2s'} ease-in-out`, userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
|
|
1701
1702
|
? 3
|
|
1702
1703
|
: column.getIsPinned() && columnDefType !== 'group'
|
|
1703
1704
|
? 2
|
|
@@ -1784,6 +1785,9 @@ const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
|
|
|
1784
1785
|
var _a;
|
|
1785
1786
|
(_a = textFieldProps.onChange) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
|
1786
1787
|
setValue(event.target.value);
|
|
1788
|
+
if ((textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.select) && editingRow) {
|
|
1789
|
+
setEditingRow(Object.assign(Object.assign({}, editingRow), { _valuesCache: Object.assign(Object.assign({}, editingRow._valuesCache), { [column.id]: event.target.value }) }));
|
|
1790
|
+
}
|
|
1787
1791
|
};
|
|
1788
1792
|
const handleBlur = (event) => {
|
|
1789
1793
|
var _a;
|
|
@@ -1796,7 +1800,7 @@ const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
|
|
|
1796
1800
|
if (columnDef.Edit) {
|
|
1797
1801
|
return React__default["default"].createElement(React__default["default"].Fragment, null, (_a = columnDef.Edit) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table }));
|
|
1798
1802
|
}
|
|
1799
|
-
return (React__default["default"].createElement(material.TextField, Object.assign({ disabled: columnDef.enableEditing === false, fullWidth: true, label: showLabel ? column.columnDef.header : undefined, margin: "none", name:
|
|
1803
|
+
return (React__default["default"].createElement(material.TextField, Object.assign({ disabled: columnDef.enableEditing === false, fullWidth: true, label: showLabel ? column.columnDef.header : undefined, margin: "none", name: column.id, onClick: (e) => e.stopPropagation(), placeholder: columnDef.header, value: value, variant: "standard" }, textFieldProps, { inputRef: (inputRef) => {
|
|
1800
1804
|
if (inputRef) {
|
|
1801
1805
|
editInputRefs.current[column.id] = inputRef;
|
|
1802
1806
|
if (textFieldProps.inputRef) {
|
|
@@ -1806,7 +1810,7 @@ const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
|
|
|
1806
1810
|
}, onBlur: handleBlur, onChange: handleChange })));
|
|
1807
1811
|
};
|
|
1808
1812
|
|
|
1809
|
-
const MRT_CopyButton = ({ cell, children, table }) => {
|
|
1813
|
+
const MRT_CopyButton = ({ cell, children, table, }) => {
|
|
1810
1814
|
const { options: { localization, muiTableBodyCellCopyButtonProps }, } = table;
|
|
1811
1815
|
const { column, row } = cell;
|
|
1812
1816
|
const { columnDef } = column;
|
|
@@ -1854,8 +1858,31 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
|
|
|
1854
1858
|
return (React__default["default"].createElement(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
|
|
1855
1859
|
};
|
|
1856
1860
|
|
|
1861
|
+
const MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
1862
|
+
var _a, _b, _c, _d;
|
|
1863
|
+
const { column, row } = cell;
|
|
1864
|
+
const { columnDef } = column;
|
|
1865
|
+
return (React__default["default"].createElement(React__default["default"].Fragment, null, cell.getIsAggregated() && column.columnDef.aggregationFn
|
|
1866
|
+
? (_a = columnDef.AggregatedCell) === null || _a === void 0 ? void 0 : _a.call(columnDef, {
|
|
1867
|
+
cell,
|
|
1868
|
+
column,
|
|
1869
|
+
row,
|
|
1870
|
+
table,
|
|
1871
|
+
})
|
|
1872
|
+
: row.getIsGrouped() && !cell.getIsGrouped()
|
|
1873
|
+
? null
|
|
1874
|
+
: (cell.getIsGrouped() &&
|
|
1875
|
+
((_b = columnDef.GroupedCell) === null || _b === void 0 ? void 0 : _b.call(columnDef, {
|
|
1876
|
+
cell,
|
|
1877
|
+
column,
|
|
1878
|
+
row,
|
|
1879
|
+
table,
|
|
1880
|
+
}))) ||
|
|
1881
|
+
((_d = (_c = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Cell) === null || _c === void 0 ? void 0 : _c.call(columnDef, { cell, column, row, table })) !== null && _d !== void 0 ? _d : cell.renderValue())));
|
|
1882
|
+
};
|
|
1883
|
+
|
|
1857
1884
|
const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
1858
|
-
var _a, _b
|
|
1885
|
+
var _a, _b;
|
|
1859
1886
|
const theme = material.useTheme();
|
|
1860
1887
|
const { getState, options: { editingMode, enableClickToCopy, enableColumnOrdering, enableEditing, enableGrouping, enablePagination, enableRowNumbers, muiTableBodyCellProps, muiTableBodyCellSkeletonProps, rowNumberMode, }, refs: { editInputRefs }, setEditingCell, setHoveredColumn, } = table;
|
|
1861
1888
|
const { draggingColumn, editingCell, editingRow, hoveredColumn, density, isLoading, showSkeletons, } = getState();
|
|
@@ -1985,21 +2012,12 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
1985
2012
|
(column.id === 'mrt-row-select' ||
|
|
1986
2013
|
column.id === 'mrt-row-expand' ||
|
|
1987
2014
|
!row.getIsGrouped()) ? ((_a = columnDef.Cell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table })) : isEditing ? (React__default["default"].createElement(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
|
|
1988
|
-
columnDef.enableClickToCopy !== false ? (React__default["default"].createElement(
|
|
1989
|
-
React__default["default"].createElement(
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
" (", (_d = row.subRows) === null || _d === void 0 ? void 0 :
|
|
1995
|
-
_d.length,
|
|
1996
|
-
")"))) : (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
1997
|
-
row.getIsGrouped() && !cell.getIsGrouped()
|
|
1998
|
-
? null
|
|
1999
|
-
: (_g = (_f = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Cell) === null || _f === void 0 ? void 0 : _f.call(columnDef, { cell, column, row, table })) !== null && _g !== void 0 ? _g : cell.renderValue(),
|
|
2000
|
-
cell.getIsGrouped() && React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2001
|
-
" (", (_j = (_h = row.subRows) === null || _h === void 0 ? void 0 : _h.length) !== null && _j !== void 0 ? _j : '',
|
|
2002
|
-
")"))))));
|
|
2015
|
+
columnDef.enableClickToCopy !== false ? (React__default["default"].createElement(MRT_CopyButton, { cell: cell, table: table },
|
|
2016
|
+
React__default["default"].createElement(MRT_TableBodyCellValue, { cell: cell, table: table }))) : (React__default["default"].createElement(MRT_TableBodyCellValue, { cell: cell, table: table }))),
|
|
2017
|
+
cell.getIsGrouped() && !columnDef.GroupedCell && (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2018
|
+
" (", (_b = row.subRows) === null || _b === void 0 ? void 0 :
|
|
2019
|
+
_b.length,
|
|
2020
|
+
")"))));
|
|
2003
2021
|
};
|
|
2004
2022
|
|
|
2005
2023
|
const MRT_TableDetailPanel = ({ row, table }) => {
|
|
@@ -2314,7 +2332,7 @@ const MRT_TableRoot = (props) => {
|
|
|
2314
2332
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
2315
2333
|
return [
|
|
2316
2334
|
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
|
-
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' }),
|
|
2335
|
+
columnOrder.includes('mrt-row-actions') && Object.assign(Object.assign(Object.assign({ Cell: ({ cell, row }) => (React__default["default"].createElement(MRT_ToggleRowActionMenuButton, { cell: cell, 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
2336
|
columnOrder.includes('mrt-row-expand') &&
|
|
2319
2337
|
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' }),
|
|
2320
2338
|
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' }),
|
|
@@ -2395,6 +2413,7 @@ var MaterialReactTable = (_a) => {
|
|
|
2395
2413
|
return (React__default["default"].createElement(MRT_TableRoot, Object.assign({ aggregationFns: Object.assign(Object.assign({}, MRT_AggregationFns), aggregationFns), autoResetExpanded: autoResetExpanded, columnResizeMode: columnResizeMode, defaultColumn: defaultColumn, editingMode: editingMode, enableBottomToolbar: enableBottomToolbar, enableColumnActions: enableColumnActions, enableColumnFilterChangeMode: enableColumnFilterChangeMode, enableColumnFilters: enableColumnFilters, enableColumnOrdering: enableColumnOrdering, enableColumnResizing: enableColumnResizing, enableDensityToggle: enableDensityToggle, enableExpandAll: enableExpandAll, enableFilters: enableFilters, enableFullScreenToggle: enableFullScreenToggle, enableGlobalFilter: enableGlobalFilter, enableGlobalFilterChangeMode: enableGlobalFilterChangeMode, enableGlobalFilterRankedResults: enableGlobalFilterRankedResults, enableGrouping: enableGrouping, enableHiding: enableHiding, enableMultiRowSelection: enableMultiRowSelection, enableMultiSort: enableMultiSort, enablePagination: enablePagination, enablePinning: enablePinning, enableRowSelection: enableRowSelection, enableSelectAll: enableSelectAll, enableSorting: enableSorting, enableStickyHeader: enableStickyHeader, enableTableFooter: enableTableFooter, enableTableHead: enableTableHead, enableToolbarInternalActions: enableToolbarInternalActions, enableTopToolbar: enableTopToolbar, filterFns: Object.assign(Object.assign({}, MRT_FilterFns), filterFns), icons: Object.assign(Object.assign({}, MRT_Default_Icons), icons), localization: Object.assign(Object.assign({}, MRT_DefaultLocalization_EN), localization), positionActionsColumn: positionActionsColumn, positionExpandColumn: positionExpandColumn, positionGlobalFilter: positionGlobalFilter, positionPagination: positionPagination, positionToolbarAlertBanner: positionToolbarAlertBanner, positionToolbarDropZone: positionToolbarDropZone, rowNumberMode: rowNumberMode, selectAllMode: selectAllMode, sortingFns: Object.assign(Object.assign({}, MRT_SortingFns), sortingFns) }, rest)));
|
|
2396
2414
|
};
|
|
2397
2415
|
|
|
2416
|
+
exports.MRT_CopyButton = MRT_CopyButton;
|
|
2398
2417
|
exports.MRT_FullScreenToggleButton = MRT_FullScreenToggleButton;
|
|
2399
2418
|
exports.MRT_GlobalFilterTextField = MRT_GlobalFilterTextField;
|
|
2400
2419
|
exports.MRT_ShowHideColumnsButton = MRT_ShowHideColumnsButton;
|