material-react-table 1.0.11 → 1.1.0-beta.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/dist/cjs/MaterialReactTable.d.ts +12 -5
- package/dist/cjs/_locales/ja.d.ts +2 -0
- package/dist/cjs/body/MRT_TableBody.d.ts +2 -1
- package/dist/cjs/body/MRT_TableBodyCell.d.ts +2 -1
- package/dist/cjs/body/MRT_TableBodyRow.d.ts +2 -1
- package/dist/cjs/index.js +352 -323
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/table/MRT_TableRoot.d.ts +5 -4
- package/dist/esm/MaterialReactTable.d.ts +12 -5
- package/dist/esm/_locales/ja.d.ts +2 -0
- package/dist/esm/body/MRT_TableBody.d.ts +2 -1
- package/dist/esm/body/MRT_TableBodyCell.d.ts +2 -1
- package/dist/esm/body/MRT_TableBodyRow.d.ts +2 -1
- package/dist/esm/material-react-table.esm.js +353 -324
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/table/MRT_TableRoot.d.ts +5 -4
- package/dist/index.d.ts +44 -37
- package/locales/ja.d.ts +2 -0
- package/locales/ja.esm.d.ts +2 -0
- package/locales/ja.esm.js +92 -0
- package/locales/ja.esm.js.map +1 -0
- package/locales/ja.js +96 -0
- package/locales/ja.js.map +1 -0
- package/package.json +13 -13
- package/src/MaterialReactTable.tsx +15 -7
- package/src/_locales/ja.ts +92 -1
- package/src/body/MRT_TableBody.tsx +18 -12
- package/src/body/MRT_TableBodyCell.tsx +7 -1
- package/src/body/MRT_TableBodyRow.tsx +36 -15
- package/src/body/MRT_TableDetailPanel.tsx +1 -1
- package/src/buttons/MRT_ExpandAllButton.tsx +1 -1
- package/src/buttons/MRT_ExpandButton.tsx +1 -1
- package/src/buttons/MRT_GrabHandleButton.tsx +1 -1
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +1 -1
- package/src/column.utils.ts +1 -1
- package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +9 -7
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +3 -1
- package/src/inputs/MRT_SelectCheckbox.tsx +51 -46
- package/src/table/MRT_Table.tsx +7 -2
- package/src/table/MRT_TablePaper.tsx +1 -1
- package/src/table/MRT_TableRoot.tsx +1 -1
- package/src/toolbar/MRT_TopToolbar.tsx +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, {
|
|
2
2
|
DragEvent,
|
|
3
3
|
FC,
|
|
4
|
+
memo,
|
|
4
5
|
MouseEvent,
|
|
5
6
|
RefObject,
|
|
6
7
|
useEffect,
|
|
@@ -167,7 +168,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
167
168
|
onDragEnter={handleDragEnter}
|
|
168
169
|
onDoubleClick={handleDoubleClick}
|
|
169
170
|
sx={(theme) => ({
|
|
170
|
-
cursor: isEditable && editingMode === 'cell' ? 'pointer' : '
|
|
171
|
+
cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'inherit',
|
|
171
172
|
overflow: 'hidden',
|
|
172
173
|
p:
|
|
173
174
|
density === 'compact'
|
|
@@ -251,3 +252,8 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
251
252
|
</TableCell>
|
|
252
253
|
);
|
|
253
254
|
};
|
|
255
|
+
|
|
256
|
+
export const Memo_MRT_TableBodyCell = memo(
|
|
257
|
+
MRT_TableBodyCell,
|
|
258
|
+
(prev, next) => next.cell === prev.cell,
|
|
259
|
+
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React, { DragEvent, FC, useRef } from 'react';
|
|
1
|
+
import React, { DragEvent, FC, memo, useRef } from 'react';
|
|
2
2
|
import { darken, lighten, TableRow, useTheme } from '@mui/material';
|
|
3
|
-
import { MRT_TableBodyCell } from './MRT_TableBodyCell';
|
|
3
|
+
import { Memo_MRT_TableBodyCell, MRT_TableBodyCell } from './MRT_TableBodyCell';
|
|
4
4
|
import { MRT_TableDetailPanel } from './MRT_TableDetailPanel';
|
|
5
5
|
import type { MRT_Row, MRT_TableInstance } from '..';
|
|
6
6
|
|
|
@@ -21,10 +21,16 @@ export const MRT_TableBodyRow: FC<Props> = ({
|
|
|
21
21
|
const {
|
|
22
22
|
getIsSomeColumnsPinned,
|
|
23
23
|
getState,
|
|
24
|
-
options: {
|
|
24
|
+
options: {
|
|
25
|
+
enableRowOrdering,
|
|
26
|
+
memoMode,
|
|
27
|
+
muiTableBodyRowProps,
|
|
28
|
+
renderDetailPanel,
|
|
29
|
+
},
|
|
25
30
|
setHoveredRow,
|
|
26
31
|
} = table;
|
|
27
|
-
const { draggingRow, hoveredRow } =
|
|
32
|
+
const { draggingColumn, draggingRow, editingCell, editingRow, hoveredRow } =
|
|
33
|
+
getState();
|
|
28
34
|
|
|
29
35
|
const tableRowProps =
|
|
30
36
|
muiTableBodyRowProps instanceof Function
|
|
@@ -69,7 +75,7 @@ export const MRT_TableBodyRow: FC<Props> = ({
|
|
|
69
75
|
backgroundColor: lighten(theme.palette.background.default, 0.06),
|
|
70
76
|
opacity:
|
|
71
77
|
draggingRow?.id === row.id || hoveredRow?.id === row.id ? 0.5 : 1,
|
|
72
|
-
transition: 'all
|
|
78
|
+
transition: 'all 150ms ease-in-out',
|
|
73
79
|
'&:hover td': {
|
|
74
80
|
backgroundColor:
|
|
75
81
|
tableRowProps?.hover !== false && getIsSomeColumnsPinned()
|
|
@@ -84,16 +90,26 @@ export const MRT_TableBodyRow: FC<Props> = ({
|
|
|
84
90
|
...draggingBorders,
|
|
85
91
|
})}
|
|
86
92
|
>
|
|
87
|
-
{row?.getVisibleCells()?.map?.((cell) =>
|
|
88
|
-
|
|
89
|
-
cell
|
|
90
|
-
enableHover
|
|
91
|
-
key
|
|
92
|
-
rowIndex
|
|
93
|
-
rowRef
|
|
94
|
-
table
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
{row?.getVisibleCells()?.map?.((cell) => {
|
|
94
|
+
const props = {
|
|
95
|
+
cell,
|
|
96
|
+
enableHover: tableRowProps?.hover !== false,
|
|
97
|
+
key: cell.id,
|
|
98
|
+
rowIndex,
|
|
99
|
+
rowRef,
|
|
100
|
+
table,
|
|
101
|
+
};
|
|
102
|
+
return memoMode === 'cell' &&
|
|
103
|
+
cell.column.columnDef.columnDefType === 'data' &&
|
|
104
|
+
!draggingColumn &&
|
|
105
|
+
!draggingRow &&
|
|
106
|
+
editingCell?.id !== cell.id &&
|
|
107
|
+
editingRow?.id !== row.id ? (
|
|
108
|
+
<Memo_MRT_TableBodyCell {...props} />
|
|
109
|
+
) : (
|
|
110
|
+
<MRT_TableBodyCell {...props} />
|
|
111
|
+
);
|
|
112
|
+
})}
|
|
97
113
|
</TableRow>
|
|
98
114
|
{renderDetailPanel && !row.getIsGrouped() && (
|
|
99
115
|
<MRT_TableDetailPanel row={row} table={table} />
|
|
@@ -101,3 +117,8 @@ export const MRT_TableBodyRow: FC<Props> = ({
|
|
|
101
117
|
</>
|
|
102
118
|
);
|
|
103
119
|
};
|
|
120
|
+
|
|
121
|
+
export const Memo_MRT_TableBodyRow = memo(
|
|
122
|
+
MRT_TableBodyRow,
|
|
123
|
+
(prev, next) => prev.row === next.row,
|
|
124
|
+
);
|
|
@@ -36,7 +36,7 @@ export const MRT_TableDetailPanel: FC<Props> = ({ row, table }) => {
|
|
|
36
36
|
borderBottom: !row.getIsExpanded() ? 'none' : undefined,
|
|
37
37
|
pb: row.getIsExpanded() ? '1rem' : 0,
|
|
38
38
|
pt: row.getIsExpanded() ? '1rem' : 0,
|
|
39
|
-
transition: 'all
|
|
39
|
+
transition: 'all 150ms ease-in-out',
|
|
40
40
|
width: `${table.getTotalSize()}px`,
|
|
41
41
|
...(tableCellProps?.sx instanceof Function
|
|
42
42
|
? tableCellProps.sx(theme)
|
|
@@ -46,7 +46,7 @@ export const MRT_GrabHandleButton = <TData extends Record<string, any> = {}>({
|
|
|
46
46
|
m: 0,
|
|
47
47
|
opacity: 0.5,
|
|
48
48
|
p: '2px',
|
|
49
|
-
transition: 'all
|
|
49
|
+
transition: 'all 150ms ease-in-out',
|
|
50
50
|
'&:hover': {
|
|
51
51
|
backgroundColor: 'transparent',
|
|
52
52
|
opacity: 1,
|
package/src/column.utils.ts
CHANGED
|
@@ -234,7 +234,7 @@ export const getCommonCellStyles = ({
|
|
|
234
234
|
column.getIsPinned() === 'right'
|
|
235
235
|
? `${getTotalRight(table, column)}px`
|
|
236
236
|
: undefined,
|
|
237
|
-
transition: `all ${column.getIsResizing() ? 0 : '
|
|
237
|
+
transition: `all ${column.getIsResizing() ? 0 : '150ms'} ease-in-out`,
|
|
238
238
|
...(tableCellProps?.sx instanceof Function
|
|
239
239
|
? tableCellProps.sx(theme)
|
|
240
240
|
: (tableCellProps?.sx as any)),
|
|
@@ -66,7 +66,7 @@ export const MRT_TableHeadCellColumnActionsButton: FC<Props> = ({
|
|
|
66
66
|
height: '2rem',
|
|
67
67
|
mt: '-0.2rem',
|
|
68
68
|
opacity: 0.5,
|
|
69
|
-
transition: 'opacity
|
|
69
|
+
transition: 'opacity 150ms',
|
|
70
70
|
width: '2rem',
|
|
71
71
|
'&:hover': {
|
|
72
72
|
opacity: 1,
|
|
@@ -80,12 +80,14 @@ export const MRT_TableHeadCellColumnActionsButton: FC<Props> = ({
|
|
|
80
80
|
<MoreVertIcon />
|
|
81
81
|
</IconButton>
|
|
82
82
|
</Tooltip>
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
{anchorEl && (
|
|
84
|
+
<MRT_ColumnActionMenu
|
|
85
|
+
anchorEl={anchorEl}
|
|
86
|
+
header={header}
|
|
87
|
+
setAnchorEl={setAnchorEl}
|
|
88
|
+
table={table}
|
|
89
|
+
/>
|
|
90
|
+
)}
|
|
89
91
|
</>
|
|
90
92
|
);
|
|
91
93
|
};
|
|
@@ -32,7 +32,9 @@ export const MRT_TableHeadCellResizeHandle: FC<Props> = ({ header, table }) => {
|
|
|
32
32
|
position: 'absolute',
|
|
33
33
|
right: '1px',
|
|
34
34
|
touchAction: 'none',
|
|
35
|
-
transition: column.getIsResizing()
|
|
35
|
+
transition: column.getIsResizing()
|
|
36
|
+
? undefined
|
|
37
|
+
: 'all 150ms ease-in-out',
|
|
36
38
|
userSelect: 'none',
|
|
37
39
|
zIndex: 4,
|
|
38
40
|
'&:active': {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
2
|
-
import { Checkbox, Tooltip } from '@mui/material';
|
|
1
|
+
import React, { FC, MouseEvent } from 'react';
|
|
2
|
+
import { Checkbox, Tooltip, Radio, Theme } from '@mui/material';
|
|
3
3
|
import type { MRT_Row, MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
@@ -13,6 +13,7 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll, table }) => {
|
|
|
13
13
|
getState,
|
|
14
14
|
options: {
|
|
15
15
|
localization,
|
|
16
|
+
enableMultiRowSelection,
|
|
16
17
|
muiSelectCheckboxProps,
|
|
17
18
|
muiSelectAllCheckboxProps,
|
|
18
19
|
selectAllMode,
|
|
@@ -28,6 +29,39 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll, table }) => {
|
|
|
28
29
|
? muiSelectCheckboxProps({ row, table })
|
|
29
30
|
: muiSelectCheckboxProps;
|
|
30
31
|
|
|
32
|
+
const commonProps = {
|
|
33
|
+
checked: selectAll
|
|
34
|
+
? selectAllMode === 'page'
|
|
35
|
+
? table.getIsAllPageRowsSelected()
|
|
36
|
+
: table.getIsAllRowsSelected()
|
|
37
|
+
: row?.getIsSelected(),
|
|
38
|
+
inputProps: {
|
|
39
|
+
'aria-label': selectAll
|
|
40
|
+
? localization.toggleSelectAll
|
|
41
|
+
: localization.toggleSelectRow,
|
|
42
|
+
},
|
|
43
|
+
onChange: row
|
|
44
|
+
? row.getToggleSelectedHandler()
|
|
45
|
+
: selectAllMode === 'all'
|
|
46
|
+
? table.getToggleAllRowsSelectedHandler()
|
|
47
|
+
: table.getToggleAllPageRowsSelectedHandler(),
|
|
48
|
+
size: (density === 'compact' ? 'small' : 'medium') as 'small' | 'medium',
|
|
49
|
+
...checkboxProps,
|
|
50
|
+
onClick: (e: MouseEvent<HTMLButtonElement>) => {
|
|
51
|
+
e.stopPropagation();
|
|
52
|
+
checkboxProps?.onClick?.(e);
|
|
53
|
+
},
|
|
54
|
+
sx: (theme: Theme) => ({
|
|
55
|
+
height: density === 'compact' ? '1.75rem' : '2.5rem',
|
|
56
|
+
width: density === 'compact' ? '1.75rem' : '2.5rem',
|
|
57
|
+
m: density !== 'compact' ? '-0.4rem' : undefined,
|
|
58
|
+
...(checkboxProps?.sx instanceof Function
|
|
59
|
+
? checkboxProps.sx(theme)
|
|
60
|
+
: (checkboxProps?.sx as any)),
|
|
61
|
+
}),
|
|
62
|
+
title: undefined,
|
|
63
|
+
};
|
|
64
|
+
|
|
31
65
|
return (
|
|
32
66
|
<Tooltip
|
|
33
67
|
arrow
|
|
@@ -40,50 +74,21 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll, table }) => {
|
|
|
40
74
|
: localization.toggleSelectRow)
|
|
41
75
|
}
|
|
42
76
|
>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
inputProps={{
|
|
60
|
-
'aria-label': selectAll
|
|
61
|
-
? localization.toggleSelectAll
|
|
62
|
-
: localization.toggleSelectRow,
|
|
63
|
-
}}
|
|
64
|
-
onChange={
|
|
65
|
-
row
|
|
66
|
-
? row.getToggleSelectedHandler()
|
|
67
|
-
: selectAllMode === 'all'
|
|
68
|
-
? table.getToggleAllRowsSelectedHandler()
|
|
69
|
-
: table.getToggleAllPageRowsSelectedHandler()
|
|
70
|
-
}
|
|
71
|
-
size={density === 'compact' ? 'small' : 'medium'}
|
|
72
|
-
{...checkboxProps}
|
|
73
|
-
onClick={(e) => {
|
|
74
|
-
e.stopPropagation();
|
|
75
|
-
checkboxProps?.onClick?.(e);
|
|
76
|
-
}}
|
|
77
|
-
sx={(theme) => ({
|
|
78
|
-
height: density === 'compact' ? '1.75rem' : '2.5rem',
|
|
79
|
-
width: density === 'compact' ? '1.75rem' : '2.5rem',
|
|
80
|
-
m: density !== 'compact' ? '-0.4rem' : undefined,
|
|
81
|
-
...(checkboxProps?.sx instanceof Function
|
|
82
|
-
? checkboxProps.sx(theme)
|
|
83
|
-
: (checkboxProps?.sx as any)),
|
|
84
|
-
})}
|
|
85
|
-
title={undefined}
|
|
86
|
-
/>
|
|
77
|
+
{enableMultiRowSelection === false ? (
|
|
78
|
+
<Radio {...commonProps} />
|
|
79
|
+
) : (
|
|
80
|
+
<Checkbox
|
|
81
|
+
indeterminate={
|
|
82
|
+
selectAll
|
|
83
|
+
? table.getIsSomeRowsSelected() &&
|
|
84
|
+
!(selectAllMode === 'page'
|
|
85
|
+
? table.getIsAllPageRowsSelected()
|
|
86
|
+
: table.getIsAllRowsSelected())
|
|
87
|
+
: row?.getIsSomeSelected()
|
|
88
|
+
}
|
|
89
|
+
{...commonProps}
|
|
90
|
+
/>
|
|
91
|
+
)}
|
|
87
92
|
</Tooltip>
|
|
88
93
|
);
|
|
89
94
|
};
|
package/src/table/MRT_Table.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { Table } from '@mui/material';
|
|
3
3
|
import { MRT_TableHead } from '../head/MRT_TableHead';
|
|
4
|
-
import { MRT_TableBody } from '../body/MRT_TableBody';
|
|
4
|
+
import { Memo_MRT_TableBody, MRT_TableBody } from '../body/MRT_TableBody';
|
|
5
5
|
import { MRT_TableFooter } from '../footer/MRT_TableFooter';
|
|
6
6
|
import { MRT_TableInstance } from '..';
|
|
7
7
|
|
|
@@ -18,6 +18,7 @@ export const MRT_Table: FC<Props> = ({ table }) => {
|
|
|
18
18
|
enableStickyHeader,
|
|
19
19
|
enableTableFooter,
|
|
20
20
|
enableTableHead,
|
|
21
|
+
memoMode,
|
|
21
22
|
muiTableProps,
|
|
22
23
|
},
|
|
23
24
|
} = table;
|
|
@@ -43,7 +44,11 @@ export const MRT_Table: FC<Props> = ({ table }) => {
|
|
|
43
44
|
})}
|
|
44
45
|
>
|
|
45
46
|
{enableTableHead && <MRT_TableHead table={table} />}
|
|
46
|
-
|
|
47
|
+
{memoMode === 'table-body' ? (
|
|
48
|
+
<Memo_MRT_TableBody table={table} />
|
|
49
|
+
) : (
|
|
50
|
+
<MRT_TableBody table={table} />
|
|
51
|
+
)}
|
|
47
52
|
{enableTableFooter && <MRT_TableFooter table={table} />}
|
|
48
53
|
</Table>
|
|
49
54
|
);
|
|
@@ -40,7 +40,7 @@ export const MRT_TablePaper: FC<Props> = ({ table }) => {
|
|
|
40
40
|
}
|
|
41
41
|
}}
|
|
42
42
|
sx={(theme) => ({
|
|
43
|
-
transition: 'all
|
|
43
|
+
transition: 'all 150ms ease-in-out',
|
|
44
44
|
...(tablePaperProps?.sx instanceof Function
|
|
45
45
|
? tablePaperProps?.sx(theme)
|
|
46
46
|
: (tablePaperProps?.sx as any)),
|
|
@@ -164,7 +164,7 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
164
164
|
<MRT_SelectCheckbox row={row as any} table={table as any} />
|
|
165
165
|
),
|
|
166
166
|
Header: () =>
|
|
167
|
-
props.enableSelectAll ? (
|
|
167
|
+
props.enableSelectAll && props.enableMultiRowSelection ? (
|
|
168
168
|
<MRT_SelectCheckbox selectAll table={table as any} />
|
|
169
169
|
) : null,
|
|
170
170
|
header: props.localization.select,
|