material-react-table 0.37.1 → 0.37.2
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/cjs/MaterialReactTable.d.ts +2 -1
- 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 +36 -30
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/MaterialReactTable.d.ts +2 -1
- 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 +36 -31
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/index.d.ts +10 -2
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +2 -0
- package/src/body/MRT_TableBodyCell.tsx +6 -18
- package/src/body/MRT_TableBodyCellValue.tsx +27 -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/table/MRT_TableRoot.tsx +6 -2
- package/src/toolbar/MRT_BottomToolbar.tsx +1 -3
package/dist/index.d.ts
CHANGED
|
@@ -650,7 +650,8 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
|
|
|
650
650
|
row: MRT_Row<TData>;
|
|
651
651
|
table: MRT_TableInstance<TData>;
|
|
652
652
|
}) => ReactNode[];
|
|
653
|
-
renderRowActions?: ({ row, table, }: {
|
|
653
|
+
renderRowActions?: ({ cell, row, table, }: {
|
|
654
|
+
cell: MRT_Cell<TData>;
|
|
654
655
|
row: MRT_Row<TData>;
|
|
655
656
|
table: MRT_TableInstance<TData>;
|
|
656
657
|
}) => ReactNode;
|
|
@@ -670,6 +671,13 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
|
|
|
670
671
|
};
|
|
671
672
|
declare const _default: <TData extends Record<string, any> = {}>({ aggregationFns, autoResetExpanded, columnResizeMode, defaultColumn, editingMode, enableBottomToolbar, enableColumnActions, enableColumnFilterChangeMode, enableColumnFilters, enableColumnOrdering, enableColumnResizing, enableDensityToggle, enableExpandAll, enableFilters, enableFullScreenToggle, enableGlobalFilter, enableGlobalFilterChangeMode, enableGlobalFilterRankedResults, enableGrouping, enableHiding, enableMultiRowSelection, enableMultiSort, enablePagination, enablePinning, enableRowSelection, enableSelectAll, enableSorting, enableStickyHeader, enableTableFooter, enableTableHead, enableToolbarInternalActions, enableTopToolbar, filterFns, icons, localization, positionActionsColumn, positionExpandColumn, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, rowNumberMode, selectAllMode, sortingFns, ...rest }: MaterialReactTableProps<TData>) => JSX.Element;
|
|
672
673
|
|
|
674
|
+
interface Props$6<TData extends Record<string, any> = {}> {
|
|
675
|
+
cell: MRT_Cell<TData>;
|
|
676
|
+
children: ReactNode;
|
|
677
|
+
table: MRT_TableInstance<TData>;
|
|
678
|
+
}
|
|
679
|
+
declare const MRT_CopyButton: <TData extends Record<string, any> = {}>({ cell, children, table, }: Props$6<TData>) => JSX.Element;
|
|
680
|
+
|
|
673
681
|
interface Props$5<TData extends Record<string, any> = {}> extends IconButtonProps {
|
|
674
682
|
table: MRT_TableInstance<TData>;
|
|
675
683
|
}
|
|
@@ -700,4 +708,4 @@ interface Props<TData extends Record<string, any> = {}> extends IconButtonProps
|
|
|
700
708
|
}
|
|
701
709
|
declare const MRT_ToggleGlobalFilterButton: <TData extends Record<string, any> = {}>({ table, ...rest }: Props<TData>) => JSX.Element;
|
|
702
710
|
|
|
703
|
-
export { MRT_Cell, MRT_Column, MRT_ColumnDef, MRT_DefinedColumnDef, MRT_DisplayColumnIds, MRT_FilterFn, MRT_FilterOption, MRT_FullScreenToggleButton, MRT_GlobalFilterTextField, MRT_Header, MRT_HeaderGroup, MRT_Icons, MRT_Localization, MRT_Row, MRT_RowModel, MRT_ShowHideColumnsButton, MRT_SortingFn, MRT_SortingOption, MRT_TableInstance, MRT_TableState, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton, MaterialReactTableProps, _default as default };
|
|
711
|
+
export { MRT_Cell, MRT_Column, MRT_ColumnDef, MRT_CopyButton, MRT_DefinedColumnDef, MRT_DisplayColumnIds, MRT_FilterFn, MRT_FilterOption, MRT_FullScreenToggleButton, MRT_GlobalFilterTextField, MRT_Header, MRT_HeaderGroup, MRT_Icons, MRT_Localization, MRT_Row, MRT_RowModel, MRT_ShowHideColumnsButton, MRT_SortingFn, MRT_SortingOption, MRT_TableInstance, MRT_TableState, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton, MaterialReactTableProps, _default as default };
|
package/package.json
CHANGED
|
@@ -769,9 +769,11 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
769
769
|
table: MRT_TableInstance<TData>;
|
|
770
770
|
}) => ReactNode[];
|
|
771
771
|
renderRowActions?: ({
|
|
772
|
+
cell,
|
|
772
773
|
row,
|
|
773
774
|
table,
|
|
774
775
|
}: {
|
|
776
|
+
cell: MRT_Cell<TData>;
|
|
775
777
|
row: MRT_Row<TData>;
|
|
776
778
|
table: MRT_TableInstance<TData>;
|
|
777
779
|
}) => ReactNode;
|
|
@@ -18,6 +18,7 @@ import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField';
|
|
|
18
18
|
import { MRT_CopyButton } from '../buttons/MRT_CopyButton';
|
|
19
19
|
import type { MRT_Cell, MRT_TableInstance } from '..';
|
|
20
20
|
import { MRT_TableBodyRowGrabHandle } from './MRT_TableBodyRowGrabHandle';
|
|
21
|
+
import { MRT_TableBodyCellValue } from './MRT_TableBodyCellValue';
|
|
21
22
|
|
|
22
23
|
interface Props {
|
|
23
24
|
cell: MRT_Cell;
|
|
@@ -282,27 +283,14 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
282
283
|
<MRT_EditCellTextField cell={cell} table={table} />
|
|
283
284
|
) : (enableClickToCopy || columnDef.enableClickToCopy) &&
|
|
284
285
|
columnDef.enableClickToCopy !== false ? (
|
|
285
|
-
|
|
286
|
-
<
|
|
287
|
-
|
|
288
|
-
{row.getIsGrouped() && !cell.getIsGrouped()
|
|
289
|
-
? null
|
|
290
|
-
: columnDef?.Cell?.({ cell, column, row, table }) ??
|
|
291
|
-
cell.renderValue()}
|
|
292
|
-
</>
|
|
293
|
-
</MRT_CopyButton>
|
|
294
|
-
{cell.getIsGrouped() && <> ({row.subRows?.length})</>}
|
|
295
|
-
</>
|
|
286
|
+
<MRT_CopyButton cell={cell} table={table}>
|
|
287
|
+
<MRT_TableBodyCellValue cell={cell} table={table} />
|
|
288
|
+
</MRT_CopyButton>
|
|
296
289
|
) : (
|
|
297
|
-
|
|
298
|
-
{row.getIsGrouped() && !cell.getIsGrouped()
|
|
299
|
-
? null
|
|
300
|
-
: columnDef?.Cell?.({ cell, column, row, table }) ??
|
|
301
|
-
cell.renderValue()}
|
|
302
|
-
{cell.getIsGrouped() && <> ({row.subRows?.length ?? ''})</>}
|
|
303
|
-
</>
|
|
290
|
+
<MRT_TableBodyCellValue cell={cell} table={table} />
|
|
304
291
|
)}
|
|
305
292
|
</>
|
|
293
|
+
{cell.getIsGrouped() && <> ({row.subRows?.length})</>}
|
|
306
294
|
</TableCell>
|
|
307
295
|
);
|
|
308
296
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { MRT_Cell, MRT_TableInstance } from '..';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
cell: MRT_Cell;
|
|
6
|
+
table: MRT_TableInstance;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const MRT_TableBodyCellValue: FC<Props> = ({ cell, table }) => {
|
|
10
|
+
const { column, row } = cell;
|
|
11
|
+
const { columnDef } = column;
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
{cell.getIsAggregated() && column.columnDef.aggregationFn
|
|
16
|
+
? columnDef.AggregatedCell?.({
|
|
17
|
+
cell,
|
|
18
|
+
column,
|
|
19
|
+
row,
|
|
20
|
+
table,
|
|
21
|
+
})
|
|
22
|
+
: row.getIsGrouped() && !cell.getIsGrouped()
|
|
23
|
+
? null
|
|
24
|
+
: columnDef?.Cell?.({ cell, column, row, table }) ?? cell.renderValue()}
|
|
25
|
+
</>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ReactNode, useState } from 'react';
|
|
2
2
|
import { Button, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_Cell, MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
|
-
interface Props {
|
|
6
|
-
cell: MRT_Cell
|
|
5
|
+
interface Props<TData extends Record<string, any> = {}> {
|
|
6
|
+
cell: MRT_Cell<TData>;
|
|
7
7
|
children: ReactNode;
|
|
8
|
-
table: MRT_TableInstance
|
|
8
|
+
table: MRT_TableInstance<TData>;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const MRT_CopyButton
|
|
11
|
+
export const MRT_CopyButton = <TData extends Record<string, any> = {}>({
|
|
12
|
+
cell,
|
|
13
|
+
children,
|
|
14
|
+
table,
|
|
15
|
+
}: Props<TData>) => {
|
|
12
16
|
const {
|
|
13
17
|
options: { localization, muiTableBodyCellCopyButtonProps },
|
|
14
18
|
} = table;
|
|
@@ -2,7 +2,7 @@ import React, { FC, MouseEvent, useState } from 'react';
|
|
|
2
2
|
import { IconButton, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_RowActionMenu } from '../menus/MRT_RowActionMenu';
|
|
4
4
|
import { MRT_EditActionButtons } from './MRT_EditActionButtons';
|
|
5
|
-
import type { MRT_Row, MRT_TableInstance } from '..';
|
|
5
|
+
import type { MRT_Cell, MRT_Row, MRT_TableInstance } from '..';
|
|
6
6
|
|
|
7
7
|
const commonIconButtonStyles = {
|
|
8
8
|
height: '2rem',
|
|
@@ -16,11 +16,12 @@ const commonIconButtonStyles = {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
interface Props {
|
|
19
|
+
cell: MRT_Cell
|
|
19
20
|
row: MRT_Row;
|
|
20
21
|
table: MRT_TableInstance;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row, table }) => {
|
|
24
|
+
export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ cell, row, table }) => {
|
|
24
25
|
const {
|
|
25
26
|
getState,
|
|
26
27
|
options: {
|
|
@@ -52,12 +53,16 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row, table }) => {
|
|
|
52
53
|
return (
|
|
53
54
|
<>
|
|
54
55
|
{renderRowActions ? (
|
|
55
|
-
<>{renderRowActions({ row, table })}</>
|
|
56
|
+
<>{renderRowActions({ cell, row, table })}</>
|
|
56
57
|
) : row.id === editingRow?.id && editingMode === 'row' ? (
|
|
57
58
|
<MRT_EditActionButtons row={row} table={table} />
|
|
58
59
|
) : !renderRowActionMenuItems && enableEditing ? (
|
|
59
60
|
<Tooltip placement="right" arrow title={localization.edit}>
|
|
60
|
-
<IconButton
|
|
61
|
+
<IconButton
|
|
62
|
+
aria-label={localization.edit}
|
|
63
|
+
sx={commonIconButtonStyles}
|
|
64
|
+
onClick={handleStartEditMode}
|
|
65
|
+
>
|
|
61
66
|
<EditIcon />
|
|
62
67
|
</IconButton>
|
|
63
68
|
</Tooltip>
|
|
@@ -70,7 +70,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
|
|
|
70
70
|
if (enableGrouping && hoveredColumn?.id === 'drop-zone') {
|
|
71
71
|
setHoveredColumn(null);
|
|
72
72
|
}
|
|
73
|
-
if (enableColumnOrdering && draggingColumn) {
|
|
73
|
+
if (enableColumnOrdering && draggingColumn && columnDefType !== 'group') {
|
|
74
74
|
setHoveredColumn(
|
|
75
75
|
columnDef.enableColumnOrdering !== false ? column : null,
|
|
76
76
|
);
|
|
@@ -151,10 +151,8 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
|
|
|
151
151
|
? 'sticky'
|
|
152
152
|
: undefined,
|
|
153
153
|
pt:
|
|
154
|
-
columnDefType === 'group'
|
|
155
|
-
? 0
|
|
156
|
-
: density === 'compact'
|
|
157
|
-
? '0.25'
|
|
154
|
+
columnDefType === 'group' || density === 'compact'
|
|
155
|
+
? '0.25rem'
|
|
158
156
|
: density === 'comfortable'
|
|
159
157
|
? '.75rem'
|
|
160
158
|
: '1.25rem',
|
package/src/index.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import type { MRT_Icons } from './icons';
|
|
|
6
6
|
import type { MRT_Localization } from './localization';
|
|
7
7
|
export type { MRT_Localization, MRT_Icons };
|
|
8
8
|
|
|
9
|
+
import { MRT_CopyButton } from './buttons/MRT_CopyButton';
|
|
9
10
|
import { MRT_FullScreenToggleButton } from './buttons/MRT_FullScreenToggleButton';
|
|
10
11
|
import { MRT_GlobalFilterTextField } from './inputs/MRT_GlobalFilterTextField';
|
|
11
12
|
import { MRT_ShowHideColumnsButton } from './buttons/MRT_ShowHideColumnsButton';
|
|
@@ -20,4 +21,5 @@ export {
|
|
|
20
21
|
MRT_ToggleDensePaddingButton,
|
|
21
22
|
MRT_ToggleFiltersButton,
|
|
22
23
|
MRT_ToggleGlobalFilterButton,
|
|
24
|
+
MRT_CopyButton,
|
|
23
25
|
};
|
|
@@ -131,8 +131,12 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
131
131
|
id: 'mrt-row-drag',
|
|
132
132
|
},
|
|
133
133
|
columnOrder.includes('mrt-row-actions') && {
|
|
134
|
-
Cell: ({ row }) => (
|
|
135
|
-
<MRT_ToggleRowActionMenuButton
|
|
134
|
+
Cell: ({ cell, row }) => (
|
|
135
|
+
<MRT_ToggleRowActionMenuButton
|
|
136
|
+
cell={cell as any}
|
|
137
|
+
row={row as any}
|
|
138
|
+
table={table}
|
|
139
|
+
/>
|
|
136
140
|
),
|
|
137
141
|
header: props.localization?.actions,
|
|
138
142
|
size: 70,
|
|
@@ -75,9 +75,7 @@ export const MRT_BottomToolbar: FC<Props> = ({ table }) => {
|
|
|
75
75
|
}}
|
|
76
76
|
>
|
|
77
77
|
{renderBottomToolbarCustomActions ? (
|
|
78
|
-
|
|
79
|
-
{renderBottomToolbarCustomActions({ table })}
|
|
80
|
-
</Box>
|
|
78
|
+
renderBottomToolbarCustomActions({ table })
|
|
81
79
|
) : (
|
|
82
80
|
<span />
|
|
83
81
|
)}
|