material-react-table 1.8.4 → 1.9.0
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/index.js +64 -62
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/MaterialReactTable.d.ts +3 -3
- package/dist/cjs/types/_locales/sr-Cyrl-RS.d.ts +2 -0
- package/dist/cjs/types/_locales/sr-Latn-RS.d.ts +2 -0
- package/dist/cjs/types/body/MRT_TableBodyCell.d.ts +2 -3
- package/dist/cjs/types/buttons/MRT_ExpandButton.d.ts +4 -4
- package/dist/cjs/types/column.utils.d.ts +3 -3
- package/dist/cjs/types/index.d.ts +5 -3
- package/dist/cjs/types/sortingFns.d.ts +6 -6
- package/dist/esm/material-react-table.esm.js +62 -63
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/types/MaterialReactTable.d.ts +3 -3
- package/dist/esm/types/_locales/sr-Cyrl-RS.d.ts +2 -0
- package/dist/esm/types/_locales/sr-Latn-RS.d.ts +2 -0
- package/dist/esm/types/body/MRT_TableBodyCell.d.ts +2 -3
- package/dist/esm/types/buttons/MRT_ExpandButton.d.ts +4 -4
- package/dist/esm/types/column.utils.d.ts +3 -3
- package/dist/esm/types/index.d.ts +5 -3
- package/dist/esm/types/sortingFns.d.ts +6 -6
- package/dist/index.d.ts +42 -28
- package/locales/sr-Cyrl-RS.d.ts +2 -0
- package/locales/sr-Cyrl-RS.esm.d.ts +2 -0
- package/locales/sr-Cyrl-RS.esm.js +94 -0
- package/locales/sr-Cyrl-RS.esm.js.map +1 -0
- package/locales/sr-Cyrl-RS.js +98 -0
- package/locales/sr-Cyrl-RS.js.map +1 -0
- package/locales/sr-Latn-RS.d.ts +2 -0
- package/locales/sr-Latn-RS.esm.d.ts +2 -0
- package/locales/sr-Latn-RS.esm.js +94 -0
- package/locales/sr-Latn-RS.esm.js.map +1 -0
- package/locales/sr-Latn-RS.js +98 -0
- package/locales/sr-Latn-RS.js.map +1 -0
- package/locales/zh-Hans.esm.js +5 -5
- package/locales/zh-Hans.js +5 -5
- package/locales/zh-Hant.esm.js +1 -1
- package/locales/zh-Hant.esm.js.map +1 -1
- package/locales/zh-Hant.js +1 -1
- package/locales/zh-Hant.js.map +1 -1
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +4 -2
- package/src/_locales/sr-Cyrl-RS.ts +94 -0
- package/src/_locales/sr-Latn-RS.ts +94 -0
- package/src/_locales/zh-Hans.ts +5 -5
- package/src/_locales/zh-Hant.ts +1 -1
- package/src/body/MRT_TableBodyCell.tsx +9 -14
- package/src/body/MRT_TableBodyRow.tsx +1 -4
- package/src/buttons/MRT_ExpandButton.tsx +7 -4
- package/src/buttons/MRT_GrabHandleButton.tsx +1 -1
- package/src/column.utils.ts +4 -8
- package/src/head/MRT_TableHeadCell.tsx +4 -0
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +3 -1
- package/src/head/MRT_TableHeadCellSortLabel.tsx +30 -22
- package/src/index.tsx +8 -4
- package/src/menus/MRT_FilterOptionMenu.tsx +1 -3
- package/src/menus/MRT_RowActionMenu.tsx +1 -0
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +2 -1
- package/src/table/MRT_Table.tsx +3 -3
|
@@ -32,7 +32,6 @@ export const MRT_TableBodyRow = ({
|
|
|
32
32
|
virtualRow,
|
|
33
33
|
}: Props) => {
|
|
34
34
|
const {
|
|
35
|
-
getIsSomeColumnsPinned,
|
|
36
35
|
getState,
|
|
37
36
|
options: {
|
|
38
37
|
enableRowOrdering,
|
|
@@ -63,7 +62,6 @@ export const MRT_TableBodyRow = ({
|
|
|
63
62
|
<>
|
|
64
63
|
<TableRow
|
|
65
64
|
data-index={virtualRow?.index}
|
|
66
|
-
hover
|
|
67
65
|
onDragEnter={handleDragEnter}
|
|
68
66
|
selected={row.getIsSelected()}
|
|
69
67
|
ref={(node: HTMLTableRowElement) => {
|
|
@@ -87,7 +85,7 @@ export const MRT_TableBodyRow = ({
|
|
|
87
85
|
width: '100%',
|
|
88
86
|
'&:hover td': {
|
|
89
87
|
backgroundColor:
|
|
90
|
-
tableRowProps?.hover !== false
|
|
88
|
+
tableRowProps?.hover !== false
|
|
91
89
|
? theme.palette.mode === 'dark'
|
|
92
90
|
? `${lighten(theme.palette.background.default, 0.12)}`
|
|
93
91
|
: `${darken(theme.palette.background.default, 0.05)}`
|
|
@@ -107,7 +105,6 @@ export const MRT_TableBodyRow = ({
|
|
|
107
105
|
: (cellOrVirtualCell as MRT_Cell);
|
|
108
106
|
const props = {
|
|
109
107
|
cell,
|
|
110
|
-
enableHover: tableRowProps?.hover !== false,
|
|
111
108
|
key: cell.id,
|
|
112
109
|
measureElement: columnVirtualizer?.measureElement,
|
|
113
110
|
numRows,
|
|
@@ -3,12 +3,15 @@ import IconButton from '@mui/material/IconButton';
|
|
|
3
3
|
import Tooltip from '@mui/material/Tooltip';
|
|
4
4
|
import type { MRT_Row, MRT_TableInstance } from '..';
|
|
5
5
|
|
|
6
|
-
interface Props {
|
|
7
|
-
row: MRT_Row
|
|
8
|
-
table: MRT_TableInstance
|
|
6
|
+
interface Props<TData extends Record<string, any> = {}> {
|
|
7
|
+
row: MRT_Row<TData>;
|
|
8
|
+
table: MRT_TableInstance<TData>;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const MRT_ExpandButton =
|
|
11
|
+
export const MRT_ExpandButton = <TData extends Record<string, any> = {}>({
|
|
12
|
+
row,
|
|
13
|
+
table,
|
|
14
|
+
}: Props<TData>) => {
|
|
12
15
|
const {
|
|
13
16
|
getState,
|
|
14
17
|
options: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { DragEventHandler } from 'react';
|
|
2
2
|
import IconButton from '@mui/material/IconButton';
|
|
3
|
-
import type { IconButtonProps } from '@mui/material/IconButton';
|
|
4
3
|
import Tooltip from '@mui/material/Tooltip';
|
|
4
|
+
import type { IconButtonProps } from '@mui/material/IconButton';
|
|
5
5
|
import type { MRT_TableInstance } from '..';
|
|
6
6
|
|
|
7
7
|
interface Props<TData extends Record<string, any> = {}> {
|
package/src/column.utils.ts
CHANGED
|
@@ -264,7 +264,9 @@ export const getCommonCellStyles = ({
|
|
|
264
264
|
display: table.options.layoutMode === 'grid' ? 'flex' : 'table-cell',
|
|
265
265
|
flex:
|
|
266
266
|
table.options.layoutMode === 'grid'
|
|
267
|
-
? `var(
|
|
267
|
+
? `var(--${header ? 'header' : 'col'}-${parseCSSVarId(
|
|
268
|
+
header?.id ?? column.id,
|
|
269
|
+
)}-size) 0 auto`
|
|
268
270
|
: undefined,
|
|
269
271
|
left:
|
|
270
272
|
column.getIsPinned() === 'left'
|
|
@@ -337,10 +339,4 @@ export const MRT_DefaultDisplayColumn = {
|
|
|
337
339
|
enableSorting: false,
|
|
338
340
|
} as const;
|
|
339
341
|
|
|
340
|
-
export const parseCSSVarId = (id: string) =>
|
|
341
|
-
id
|
|
342
|
-
.replaceAll('.', '_')
|
|
343
|
-
.replaceAll(' ', '_')
|
|
344
|
-
.replaceAll('+', '_')
|
|
345
|
-
.replaceAll('(', '_')
|
|
346
|
-
.replaceAll(')', '_');
|
|
342
|
+
export const parseCSSVarId = (id: string) => id.replace(/[^a-zA-Z0-9]/g, '_');
|
|
@@ -213,10 +213,14 @@ export const MRT_TableHeadCell = ({ header, table }: Props) => {
|
|
|
213
213
|
<Box
|
|
214
214
|
className="Mui-TableHeadCell-Content-Wrapper"
|
|
215
215
|
sx={{
|
|
216
|
+
minWidth: '5ch',
|
|
216
217
|
overflow: columnDefType === 'data' ? 'hidden' : undefined,
|
|
217
218
|
textOverflow: 'ellipsis',
|
|
218
219
|
whiteSpace:
|
|
219
220
|
(columnDef.header?.length ?? 0) < 20 ? 'nowrap' : 'normal',
|
|
221
|
+
'&:hover': {
|
|
222
|
+
textOverflow: 'clip',
|
|
223
|
+
},
|
|
220
224
|
}}
|
|
221
225
|
title={columnDefType === 'data' ? columnDef.header : undefined}
|
|
222
226
|
>
|
|
@@ -19,6 +19,7 @@ export const MRT_TableHeadCellResizeHandle = ({ header, table }: Props) => {
|
|
|
19
19
|
|
|
20
20
|
return (
|
|
21
21
|
<Box
|
|
22
|
+
className="Mui-TableHeadCell-ResizeHandle-Wrapper"
|
|
22
23
|
onDoubleClick={() => {
|
|
23
24
|
setColumnSizingInfo((old) => ({
|
|
24
25
|
...old,
|
|
@@ -30,7 +31,7 @@ export const MRT_TableHeadCellResizeHandle = ({ header, table }: Props) => {
|
|
|
30
31
|
onTouchStart={header.getResizeHandler()}
|
|
31
32
|
sx={(theme) => ({
|
|
32
33
|
cursor: 'col-resize',
|
|
33
|
-
mr: density === 'compact' ? '-0.
|
|
34
|
+
mr: density === 'compact' ? '-0.75rem' : '-1rem',
|
|
34
35
|
position: 'absolute',
|
|
35
36
|
right: '1px',
|
|
36
37
|
px: '4px',
|
|
@@ -47,6 +48,7 @@ export const MRT_TableHeadCellResizeHandle = ({ header, table }: Props) => {
|
|
|
47
48
|
}}
|
|
48
49
|
>
|
|
49
50
|
<Divider
|
|
51
|
+
className="Mui-TableHeadCell-ResizeHandle-Divider"
|
|
50
52
|
flexItem
|
|
51
53
|
orientation="vertical"
|
|
52
54
|
sx={{
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import Badge from '@mui/material/Badge';
|
|
2
3
|
import TableSortLabel from '@mui/material/TableSortLabel';
|
|
3
4
|
import Tooltip from '@mui/material/Tooltip';
|
|
4
5
|
import { MRT_Header, MRT_TableInstance } from '..';
|
|
@@ -16,6 +17,7 @@ export const MRT_TableHeadCellSortLabel = ({
|
|
|
16
17
|
tableCellProps,
|
|
17
18
|
}: Props) => {
|
|
18
19
|
const {
|
|
20
|
+
getState,
|
|
19
21
|
options: {
|
|
20
22
|
icons: { ArrowDownwardIcon },
|
|
21
23
|
localization,
|
|
@@ -23,6 +25,7 @@ export const MRT_TableHeadCellSortLabel = ({
|
|
|
23
25
|
} = table;
|
|
24
26
|
const { column } = header;
|
|
25
27
|
const { columnDef } = column;
|
|
28
|
+
const { sorting } = getState();
|
|
26
29
|
|
|
27
30
|
const sortTooltip = column.getIsSorted()
|
|
28
31
|
? column.getIsSorted() === 'desc'
|
|
@@ -32,28 +35,33 @@ export const MRT_TableHeadCellSortLabel = ({
|
|
|
32
35
|
|
|
33
36
|
return (
|
|
34
37
|
<Tooltip arrow placement="top" title={sortTooltip}>
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
38
|
+
<Badge
|
|
39
|
+
badgeContent={sorting.length > 1 ? column.getSortIndex() + 1 : 0}
|
|
40
|
+
overlap="circular"
|
|
41
|
+
>
|
|
42
|
+
<TableSortLabel
|
|
43
|
+
aria-label={sortTooltip}
|
|
44
|
+
active={!!column.getIsSorted()}
|
|
45
|
+
direction={
|
|
46
|
+
column.getIsSorted()
|
|
47
|
+
? (column.getIsSorted() as 'asc' | 'desc')
|
|
48
|
+
: undefined
|
|
49
|
+
}
|
|
50
|
+
sx={{
|
|
51
|
+
flex: '0 0',
|
|
52
|
+
width: '2.4ch',
|
|
53
|
+
transform:
|
|
54
|
+
tableCellProps?.align !== 'right'
|
|
55
|
+
? 'translateX(-0.5ch)'
|
|
56
|
+
: undefined,
|
|
57
|
+
}}
|
|
58
|
+
IconComponent={ArrowDownwardIcon}
|
|
59
|
+
onClick={(e) => {
|
|
60
|
+
e.stopPropagation();
|
|
61
|
+
header.column.getToggleSortingHandler()?.(e);
|
|
62
|
+
}}
|
|
63
|
+
/>
|
|
64
|
+
</Badge>
|
|
57
65
|
</Tooltip>
|
|
58
66
|
);
|
|
59
67
|
};
|
package/src/index.tsx
CHANGED
|
@@ -5,38 +5,42 @@ export * from './MaterialReactTable';
|
|
|
5
5
|
import type { MRT_Icons } from './icons';
|
|
6
6
|
export type { MRT_Icons };
|
|
7
7
|
|
|
8
|
+
import { MRT_BottomToolbar } from './toolbar/MRT_BottomToolbar';
|
|
8
9
|
import { MRT_CopyButton } from './buttons/MRT_CopyButton';
|
|
9
10
|
import { MRT_EditActionButtons } from './buttons/MRT_EditActionButtons';
|
|
11
|
+
import { MRT_ExpandButton } from './buttons/MRT_ExpandButton';
|
|
10
12
|
import { MRT_FilterOptionMenu } from './menus/MRT_FilterOptionMenu';
|
|
11
13
|
import { MRT_FullScreenToggleButton } from './buttons/MRT_FullScreenToggleButton';
|
|
14
|
+
import { MRT_GrabHandleButton } from './buttons/MRT_GrabHandleButton';
|
|
12
15
|
import { MRT_GlobalFilterTextField } from './inputs/MRT_GlobalFilterTextField';
|
|
13
16
|
import { MRT_ShowHideColumnsButton } from './buttons/MRT_ShowHideColumnsButton';
|
|
14
17
|
import { MRT_TablePagination } from './toolbar/MRT_TablePagination';
|
|
15
18
|
import { MRT_ToggleDensePaddingButton } from './buttons/MRT_ToggleDensePaddingButton';
|
|
16
19
|
import { MRT_ToggleFiltersButton } from './buttons/MRT_ToggleFiltersButton';
|
|
17
20
|
import { MRT_ToggleGlobalFilterButton } from './buttons/MRT_ToggleGlobalFilterButton';
|
|
21
|
+
import { MRT_ToggleRowActionMenuButton } from './buttons/MRT_ToggleRowActionMenuButton';
|
|
18
22
|
import { MRT_ToolbarAlertBanner } from './toolbar/MRT_ToolbarAlertBanner';
|
|
19
23
|
import { MRT_ToolbarDropZone } from './toolbar/MRT_ToolbarDropZone';
|
|
20
24
|
import { MRT_ToolbarInternalButtons } from './toolbar/MRT_ToolbarInternalButtons';
|
|
21
|
-
import { MRT_ToggleRowActionMenuButton } from './buttons/MRT_ToggleRowActionMenuButton';
|
|
22
25
|
import { MRT_TopToolbar } from './toolbar/MRT_TopToolbar';
|
|
23
|
-
import { MRT_BottomToolbar } from './toolbar/MRT_BottomToolbar';
|
|
24
26
|
|
|
25
27
|
export {
|
|
28
|
+
MRT_BottomToolbar,
|
|
26
29
|
MRT_CopyButton,
|
|
27
30
|
MRT_EditActionButtons,
|
|
31
|
+
MRT_ExpandButton,
|
|
28
32
|
MRT_FilterOptionMenu,
|
|
29
33
|
MRT_FullScreenToggleButton,
|
|
34
|
+
MRT_GrabHandleButton,
|
|
30
35
|
MRT_GlobalFilterTextField,
|
|
31
36
|
MRT_ShowHideColumnsButton,
|
|
32
37
|
MRT_TablePagination,
|
|
33
38
|
MRT_ToggleDensePaddingButton,
|
|
34
39
|
MRT_ToggleFiltersButton,
|
|
35
40
|
MRT_ToggleGlobalFilterButton,
|
|
41
|
+
MRT_ToggleRowActionMenuButton,
|
|
36
42
|
MRT_ToolbarAlertBanner,
|
|
37
43
|
MRT_ToolbarDropZone,
|
|
38
44
|
MRT_ToolbarInternalButtons,
|
|
39
|
-
MRT_ToggleRowActionMenuButton,
|
|
40
45
|
MRT_TopToolbar,
|
|
41
|
-
MRT_BottomToolbar,
|
|
42
46
|
};
|
|
@@ -156,9 +156,7 @@ export const MRT_FilterOptionMenu = <TData extends Record<string, any> = {}>({
|
|
|
156
156
|
[header.id]: option,
|
|
157
157
|
}));
|
|
158
158
|
if (['empty', 'notEmpty'].includes(option as string)) {
|
|
159
|
-
|
|
160
|
-
column.setFilterValue(' ');
|
|
161
|
-
}
|
|
159
|
+
column.setFilterValue(' ');
|
|
162
160
|
} else if (
|
|
163
161
|
columnDef?.filterVariant === 'multi-select' ||
|
|
164
162
|
['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'].includes(
|
|
@@ -98,8 +98,9 @@ export const MRT_ShowHideColumnsMenuItems = <
|
|
|
98
98
|
justifyContent: 'flex-start',
|
|
99
99
|
my: 0,
|
|
100
100
|
opacity: isDragging ? 0.5 : 1,
|
|
101
|
+
outlineOffset: '-2px',
|
|
101
102
|
outline: isDragging
|
|
102
|
-
? `
|
|
103
|
+
? `2px dashed ${theme.palette.divider}`
|
|
103
104
|
: hoveredColumn?.id === column.id
|
|
104
105
|
? `2px dashed ${theme.palette.primary.main}`
|
|
105
106
|
: 'none',
|
package/src/table/MRT_Table.tsx
CHANGED
|
@@ -59,9 +59,9 @@ export const MRT_Table = ({ table }: Props) => {
|
|
|
59
59
|
const colSizes: { [key: string]: number } = {};
|
|
60
60
|
for (let i = 0; i < headers.length; i++) {
|
|
61
61
|
const header = headers[i];
|
|
62
|
-
|
|
63
|
-
colSizes[`--
|
|
64
|
-
|
|
62
|
+
const colSize = header.getSize();
|
|
63
|
+
colSizes[`--header-${parseCSSVarId(header.id)}-size`] = colSize;
|
|
64
|
+
colSizes[`--col-${parseCSSVarId(header.column.id)}-size`] = colSize;
|
|
65
65
|
}
|
|
66
66
|
return colSizes;
|
|
67
67
|
}, [columns, columnSizing, columnSizingInfo, columnVisibility]);
|