material-react-table 2.11.2 → 2.11.3
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/index.d.ts +12 -16
- package/dist/index.esm.js +50 -87
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +49 -91
- package/dist/index.js.map +1 -1
- package/package.json +21 -21
- package/src/components/body/MRT_TableBodyCell.tsx +4 -6
- package/src/components/body/MRT_TableBodyCellValue.tsx +5 -4
- package/src/components/body/MRT_TableBodyRow.tsx +5 -7
- package/src/components/body/MRT_TableDetailPanel.tsx +2 -4
- package/src/components/footer/MRT_TableFooterRow.tsx +6 -3
- package/src/components/head/MRT_TableHeadCell.tsx +2 -3
- package/src/components/head/MRT_TableHeadRow.tsx +7 -3
- package/src/components/inputs/MRT_SelectCheckbox.tsx +2 -1
- package/src/components/menus/MRT_CellActionMenu.tsx +1 -5
- package/src/components/menus/MRT_ColumnActionMenu.tsx +1 -5
- package/src/components/menus/MRT_FilterOptionMenu.tsx +1 -5
- package/src/components/menus/MRT_RowActionMenu.tsx +1 -5
- package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +1 -5
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +3 -2
- package/src/components/table/MRT_TableLoadingOverlay.tsx +8 -8
- package/src/components/table/MRT_TablePaper.tsx +2 -2
- package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +3 -1
- package/src/hooks/useMRT_TableOptions.ts +4 -0
- package/src/types.ts +15 -13
- package/src/utils/column.utils.ts +0 -48
- package/src/utils/row.utils.ts +2 -1
- package/src/utils/style.utils.ts +24 -26
@@ -7,7 +7,6 @@ import {
|
|
7
7
|
type MRT_DefinedTableOptions,
|
8
8
|
type MRT_FilterOption,
|
9
9
|
type MRT_RowData,
|
10
|
-
type MRT_TableInstance,
|
11
10
|
} from '../types';
|
12
11
|
|
13
12
|
export const getColumnId = <TData extends MRT_RowData>(
|
@@ -122,50 +121,3 @@ export const getDefaultColumnFilterFn = <TData extends MRT_RowData>(
|
|
122
121
|
return 'equals';
|
123
122
|
return 'fuzzy';
|
124
123
|
};
|
125
|
-
|
126
|
-
export const getIsFirstColumn = <TData extends MRT_RowData>(
|
127
|
-
column: MRT_Column<TData>,
|
128
|
-
table: MRT_TableInstance<TData>,
|
129
|
-
) => {
|
130
|
-
const leftColumns = table.getLeftVisibleLeafColumns();
|
131
|
-
return leftColumns.length
|
132
|
-
? leftColumns[0].id === column.id
|
133
|
-
: table.getVisibleLeafColumns()[0].id === column.id;
|
134
|
-
};
|
135
|
-
|
136
|
-
export const getIsLastColumn = <TData extends MRT_RowData>(
|
137
|
-
column: MRT_Column<TData>,
|
138
|
-
table: MRT_TableInstance<TData>,
|
139
|
-
) => {
|
140
|
-
const rightColumns = table.getRightVisibleLeafColumns();
|
141
|
-
const columns = table.getVisibleLeafColumns();
|
142
|
-
return rightColumns.length
|
143
|
-
? rightColumns[rightColumns.length - 1].id === column.id
|
144
|
-
: columns[columns.length - 1].id === column.id;
|
145
|
-
};
|
146
|
-
|
147
|
-
export const getIsLastLeftPinnedColumn = <TData extends MRT_RowData>(
|
148
|
-
table: MRT_TableInstance<TData>,
|
149
|
-
column: MRT_Column<TData>,
|
150
|
-
) => {
|
151
|
-
return (
|
152
|
-
column.getIsPinned() === 'left' &&
|
153
|
-
table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex()
|
154
|
-
);
|
155
|
-
};
|
156
|
-
|
157
|
-
export const getIsFirstRightPinnedColumn = <TData extends MRT_RowData>(
|
158
|
-
column: MRT_Column<TData>,
|
159
|
-
) => {
|
160
|
-
return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
|
161
|
-
};
|
162
|
-
|
163
|
-
export const getTotalRight = <TData extends MRT_RowData>(
|
164
|
-
table: MRT_TableInstance<TData>,
|
165
|
-
column: MRT_Column<TData>,
|
166
|
-
) => {
|
167
|
-
return table
|
168
|
-
.getRightLeafHeaders()
|
169
|
-
.slice(column.getPinnedIndex() + 1)
|
170
|
-
.reduce((acc, col) => acc + col.getSize(), 0);
|
171
|
-
};
|
package/src/utils/row.utils.ts
CHANGED
@@ -243,13 +243,14 @@ export const getMRT_SelectAllHandler =
|
|
243
243
|
(
|
244
244
|
event: ChangeEvent<HTMLInputElement> | MouseEvent<HTMLButtonElement>,
|
245
245
|
value?: boolean,
|
246
|
+
forceAll?: boolean,
|
246
247
|
) => {
|
247
248
|
const {
|
248
249
|
options: { enableRowPinning, rowPinningDisplayMode, selectAllMode },
|
249
250
|
refs: { lastSelectedRowId },
|
250
251
|
} = table;
|
251
252
|
|
252
|
-
selectAllMode === 'all'
|
253
|
+
selectAllMode === 'all' || forceAll
|
253
254
|
? table.toggleAllRowsSelected(value ?? (event as any).target.checked)
|
254
255
|
: table.toggleAllPageRowsSelected(value ?? (event as any).target.checked);
|
255
256
|
if (enableRowPinning && rowPinningDisplayMode?.includes('select')) {
|
package/src/utils/style.utils.ts
CHANGED
@@ -8,37 +8,34 @@ import {
|
|
8
8
|
type MRT_Header,
|
9
9
|
type MRT_RowData,
|
10
10
|
type MRT_TableInstance,
|
11
|
+
type MRT_TableOptions,
|
12
|
+
type MRT_Theme,
|
11
13
|
} from '../types';
|
12
|
-
import {
|
13
|
-
getIsFirstRightPinnedColumn,
|
14
|
-
getIsLastLeftPinnedColumn,
|
15
|
-
getTotalRight,
|
16
|
-
} from '../utils/column.utils';
|
17
14
|
import { parseFromValuesOrFunc } from './utils';
|
18
15
|
|
19
16
|
export const parseCSSVarId = (id: string) => id.replace(/[^a-zA-Z0-9]/g, '_');
|
20
17
|
|
21
18
|
export const getMRTTheme = <TData extends MRT_RowData>(
|
22
|
-
|
23
|
-
|
24
|
-
) => {
|
25
|
-
const
|
19
|
+
mrtTheme: MRT_TableOptions<TData>['mrtTheme'],
|
20
|
+
muiTheme: Theme,
|
21
|
+
): MRT_Theme => {
|
22
|
+
const mrtThemeOverrides = parseFromValuesOrFunc(mrtTheme, muiTheme);
|
26
23
|
const baseBackgroundColor =
|
27
|
-
|
28
|
-
(
|
29
|
-
? lighten(
|
30
|
-
:
|
24
|
+
mrtThemeOverrides?.baseBackgroundColor ??
|
25
|
+
(muiTheme.palette.mode === 'dark'
|
26
|
+
? lighten(muiTheme.palette.background.default, 0.05)
|
27
|
+
: muiTheme.palette.background.default);
|
31
28
|
return {
|
32
29
|
baseBackgroundColor,
|
33
|
-
draggingBorderColor:
|
30
|
+
draggingBorderColor: muiTheme.palette.primary.main,
|
34
31
|
matchHighlightColor:
|
35
|
-
|
36
|
-
? darken(
|
37
|
-
: lighten(
|
32
|
+
muiTheme.palette.mode === 'dark'
|
33
|
+
? darken(muiTheme.palette.warning.dark, 0.25)
|
34
|
+
: lighten(muiTheme.palette.warning.light, 0.5),
|
38
35
|
menuBackgroundColor: lighten(baseBackgroundColor, 0.07),
|
39
|
-
pinnedRowBackgroundColor: alpha(
|
40
|
-
selectedRowBackgroundColor: alpha(
|
41
|
-
...
|
36
|
+
pinnedRowBackgroundColor: alpha(muiTheme.palette.primary.main, 0.1),
|
37
|
+
selectedRowBackgroundColor: alpha(muiTheme.palette.primary.main, 0.2),
|
38
|
+
...mrtThemeOverrides,
|
42
39
|
};
|
43
40
|
};
|
44
41
|
|
@@ -61,7 +58,9 @@ export const getCommonPinnedCellStyles = <TData extends MRT_RowData>({
|
|
61
58
|
table: MRT_TableInstance<TData>;
|
62
59
|
theme: Theme;
|
63
60
|
}) => {
|
64
|
-
const { baseBackgroundColor } =
|
61
|
+
const { baseBackgroundColor } = table.options.mrtTheme;
|
62
|
+
const isPinned = column?.getIsPinned();
|
63
|
+
|
65
64
|
return {
|
66
65
|
'&[data-pinned="true"]': {
|
67
66
|
'&:before': {
|
@@ -73,9 +72,9 @@ export const getCommonPinnedCellStyles = <TData extends MRT_RowData>({
|
|
73
72
|
0.97,
|
74
73
|
),
|
75
74
|
boxShadow: column
|
76
|
-
?
|
75
|
+
? isPinned === 'left' && column.getIsLastColumn(isPinned)
|
77
76
|
? `-4px 0 4px -4px ${alpha(theme.palette.grey[700], 0.5)} inset`
|
78
|
-
:
|
77
|
+
: isPinned === 'right' && column.getIsFirstColumn(isPinned)
|
79
78
|
? `4px 0 4px -4px ${alpha(theme.palette.grey[700], 0.5)} inset`
|
80
79
|
: undefined
|
81
80
|
: undefined,
|
@@ -141,7 +140,7 @@ export const getCommonMRTCellStyles = <TData extends MRT_RowData>({
|
|
141
140
|
position: 'sticky',
|
142
141
|
right:
|
143
142
|
isColumnPinned === 'right'
|
144
|
-
? `${
|
143
|
+
? `${column.getAfter('right')}px`
|
145
144
|
: undefined,
|
146
145
|
}
|
147
146
|
: {};
|
@@ -179,13 +178,12 @@ export const getCommonMRTCellStyles = <TData extends MRT_RowData>({
|
|
179
178
|
|
180
179
|
export const getCommonToolbarStyles = <TData extends MRT_RowData>({
|
181
180
|
table,
|
182
|
-
theme,
|
183
181
|
}: {
|
184
182
|
table: MRT_TableInstance<TData>;
|
185
183
|
theme: Theme;
|
186
184
|
}) => ({
|
187
185
|
alignItems: 'flex-start',
|
188
|
-
backgroundColor:
|
186
|
+
backgroundColor: table.options.mrtTheme.baseBackgroundColor,
|
189
187
|
display: 'grid',
|
190
188
|
flexWrap: 'wrap-reverse',
|
191
189
|
minHeight: '3.5rem',
|