material-react-table 2.0.0-alpha.1 → 2.0.0-alpha.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/README.md +2 -2
- package/dist/cjs/index.js +2400 -2365
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/MaterialReactTable.d.ts +1 -1
- package/dist/cjs/types/buttons/MRT_GrabHandleButton.d.ts +1 -1
- package/dist/cjs/types/buttons/MRT_RowPinButton.d.ts +2 -2
- package/dist/cjs/types/column.utils.d.ts +6 -6
- package/dist/cjs/types/filterFns.d.ts +14 -14
- package/dist/cjs/types/head/MRT_TableHeadCellFilterLabel.d.ts +1 -1
- package/dist/cjs/types/head/MRT_TableHeadCellSortLabel.d.ts +1 -1
- package/dist/cjs/types/hooks/useMRT_DisplayColumns.d.ts +3 -3
- package/dist/cjs/types/icons.d.ts +1 -1
- package/dist/cjs/types/inputs/MRT_FilterRangeSlider.d.ts +1 -1
- package/dist/cjs/types/menus/MRT_ColumnActionMenu.d.ts +4 -4
- package/dist/cjs/types/menus/MRT_ShowHideColumnsMenuItems.d.ts +1 -1
- package/dist/cjs/types/toolbar/MRT_TablePagination.d.ts +2 -2
- package/dist/cjs/types/toolbar/MRT_TopToolbar.d.ts +1 -1
- package/dist/cjs/types/types.d.ts +198 -198
- package/dist/esm/material-react-table.esm.js +2027 -1993
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/types/MaterialReactTable.d.ts +1 -1
- package/dist/esm/types/buttons/MRT_GrabHandleButton.d.ts +1 -1
- package/dist/esm/types/buttons/MRT_RowPinButton.d.ts +2 -2
- package/dist/esm/types/column.utils.d.ts +6 -6
- package/dist/esm/types/filterFns.d.ts +14 -14
- package/dist/esm/types/head/MRT_TableHeadCellFilterLabel.d.ts +1 -1
- package/dist/esm/types/head/MRT_TableHeadCellSortLabel.d.ts +1 -1
- package/dist/esm/types/hooks/useMRT_DisplayColumns.d.ts +3 -3
- package/dist/esm/types/icons.d.ts +1 -1
- package/dist/esm/types/inputs/MRT_FilterRangeSlider.d.ts +1 -1
- package/dist/esm/types/menus/MRT_ColumnActionMenu.d.ts +4 -4
- package/dist/esm/types/menus/MRT_ShowHideColumnsMenuItems.d.ts +1 -1
- package/dist/esm/types/toolbar/MRT_TablePagination.d.ts +2 -2
- package/dist/esm/types/toolbar/MRT_TopToolbar.d.ts +1 -1
- package/dist/esm/types/types.d.ts +198 -198
- package/dist/index.d.ts +239 -239
- package/locales/fr.esm.js +1 -1
- package/locales/fr.esm.js.map +1 -1
- package/locales/fr.js +1 -1
- package/locales/fr.js.map +1 -1
- package/locales/tr.d.ts +2 -0
- package/locales/tr.esm.d.ts +2 -0
- package/locales/tr.esm.js +93 -0
- package/locales/tr.esm.js.map +1 -0
- package/locales/tr.js +97 -0
- package/locales/tr.js.map +1 -0
- package/locales/uk.d.ts +2 -0
- package/locales/uk.esm.d.ts +2 -0
- package/locales/uk.esm.js +93 -0
- package/locales/uk.esm.js.map +1 -0
- package/locales/uk.js +97 -0
- package/locales/uk.js.map +1 -0
- package/locales/vi.d.ts +2 -0
- package/locales/vi.esm.d.ts +2 -0
- package/locales/vi.esm.js +93 -0
- package/locales/vi.esm.js.map +1 -0
- package/locales/vi.js +97 -0
- package/locales/vi.js.map +1 -0
- package/locales/zh-Hans.d.ts +2 -0
- package/locales/zh-Hans.esm.d.ts +2 -0
- package/locales/zh-Hans.esm.js +93 -0
- package/locales/zh-Hans.esm.js.map +1 -0
- package/locales/zh-Hans.js +97 -0
- package/locales/zh-Hans.js.map +1 -0
- package/locales/zh-Hant.d.ts +2 -0
- package/locales/zh-Hant.esm.d.ts +2 -0
- package/locales/zh-Hant.esm.js +93 -0
- package/locales/zh-Hant.esm.js.map +1 -0
- package/locales/zh-Hant.js +97 -0
- package/locales/zh-Hant.js.map +1 -0
- package/package.json +2 -1
- package/src/MaterialReactTable.tsx +2 -2
- package/src/body/MRT_TableBody.tsx +9 -9
- package/src/body/MRT_TableBodyCell.tsx +22 -22
- package/src/body/MRT_TableBodyCellValue.tsx +5 -5
- package/src/body/MRT_TableBodyRow.tsx +32 -32
- package/src/body/MRT_TableBodyRowGrabHandle.tsx +2 -2
- package/src/body/MRT_TableBodyRowPinButton.tsx +3 -3
- package/src/body/MRT_TableDetailPanel.tsx +3 -3
- package/src/buttons/MRT_CopyButton.tsx +1 -1
- package/src/buttons/MRT_EditActionButtons.tsx +4 -4
- package/src/buttons/MRT_ExpandAllButton.tsx +3 -3
- package/src/buttons/MRT_ExpandButton.tsx +1 -1
- package/src/buttons/MRT_GrabHandleButton.tsx +10 -10
- package/src/buttons/MRT_RowPinButton.tsx +5 -5
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +1 -1
- package/src/buttons/MRT_ToggleFullScreenButton.tsx +2 -2
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +8 -8
- package/src/column.utils.ts +23 -17
- package/src/filterFns.ts +29 -29
- package/src/footer/MRT_TableFooter.tsx +9 -9
- package/src/footer/MRT_TableFooterCell.tsx +1 -1
- package/src/footer/MRT_TableFooterRow.tsx +2 -2
- package/src/head/MRT_TableHead.tsx +9 -9
- package/src/head/MRT_TableHeadCell.tsx +10 -6
- package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +9 -6
- package/src/head/MRT_TableHeadCellFilterContainer.tsx +11 -4
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +106 -61
- package/src/head/MRT_TableHeadCellGrabHandle.tsx +2 -2
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +11 -11
- package/src/head/MRT_TableHeadCellSortLabel.tsx +8 -8
- package/src/head/MRT_TableHeadRow.tsx +2 -2
- package/src/hooks/useMRT_DisplayColumns.tsx +5 -5
- package/src/hooks/useMRT_Effects.ts +3 -3
- package/src/hooks/useMRT_TableInstance.ts +15 -14
- package/src/hooks/useMRT_TableOptions.ts +3 -3
- package/src/icons.ts +2 -2
- package/src/inputs/MRT_EditCellTextField.tsx +9 -9
- package/src/inputs/MRT_FilterCheckbox.tsx +7 -7
- package/src/inputs/MRT_FilterRangeFields.tsx +1 -1
- package/src/inputs/MRT_FilterRangeSlider.tsx +6 -6
- package/src/inputs/MRT_FilterTextField.tsx +75 -75
- package/src/inputs/MRT_GlobalFilterTextField.tsx +26 -26
- package/src/inputs/MRT_SelectCheckbox.tsx +7 -7
- package/src/locales/fr.ts +1 -1
- package/src/menus/MRT_ColumnActionMenu.tsx +14 -14
- package/src/menus/MRT_FilterOptionMenu.tsx +35 -35
- package/src/menus/MRT_RowActionMenu.tsx +7 -7
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +6 -6
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +5 -5
- package/src/modals/MRT_EditRowModal.tsx +8 -8
- package/src/sortingFns.ts +1 -1
- package/src/table/MRT_Table.tsx +7 -7
- package/src/table/MRT_TableContainer.tsx +10 -10
- package/src/table/MRT_TablePaper.tsx +9 -9
- package/src/toolbar/MRT_BottomToolbar.tsx +5 -5
- package/src/toolbar/MRT_LinearProgressBar.tsx +4 -4
- package/src/toolbar/MRT_TablePagination.tsx +19 -19
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +4 -4
- package/src/toolbar/MRT_ToolbarDropZone.tsx +6 -6
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +8 -5
- package/src/toolbar/MRT_TopToolbar.tsx +7 -7
- package/src/types.ts +263 -263
- package/src/useMaterialReactTable.ts +1 -1
package/src/column.utils.ts
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
import { type ReactNode } from 'react';
|
2
2
|
import {
|
3
|
-
type Row,
|
4
|
-
type Renderable,
|
5
|
-
flexRender as _flexRender,
|
6
3
|
createRow as _createRow,
|
4
|
+
flexRender as _flexRender,
|
5
|
+
type Renderable,
|
6
|
+
type Row,
|
7
7
|
} from '@tanstack/react-table';
|
8
|
+
import { type TableCellProps } from '@mui/material/TableCell';
|
8
9
|
import { alpha, lighten } from '@mui/material/styles';
|
10
|
+
import { type Theme } from '@mui/material/styles';
|
9
11
|
import { type MRT_AggregationFns } from './aggregationFns';
|
10
12
|
import { type MRT_FilterFns } from './filterFns';
|
11
13
|
import { type MRT_SortingFns } from './sortingFns';
|
12
|
-
import { type TableCellProps } from '@mui/material/TableCell';
|
13
|
-
import { type Theme } from '@mui/material/styles';
|
14
14
|
import {
|
15
|
-
type MRT_TableOptions,
|
16
15
|
type MRT_Column,
|
17
16
|
type MRT_ColumnDef,
|
18
17
|
type MRT_ColumnOrderState,
|
@@ -21,8 +20,9 @@ import {
|
|
21
20
|
type MRT_FilterOption,
|
22
21
|
type MRT_GroupingState,
|
23
22
|
type MRT_Header,
|
24
|
-
type MRT_TableInstance,
|
25
23
|
type MRT_Row,
|
24
|
+
type MRT_TableInstance,
|
25
|
+
type MRT_TableOptions,
|
26
26
|
} from './types';
|
27
27
|
|
28
28
|
export const getColumnId = <TData extends Record<string, any>>(
|
@@ -159,7 +159,7 @@ export const getLeadingDisplayColumnIds = <TData extends Record<string, any>>(
|
|
159
159
|
props.positionActionsColumn === 'first' &&
|
160
160
|
(props.enableRowActions ||
|
161
161
|
(props.enableEditing &&
|
162
|
-
['
|
162
|
+
['modal', 'row'].includes(props.editDisplayMode ?? ''))) &&
|
163
163
|
'mrt-row-actions',
|
164
164
|
props.positionExpandColumn === 'first' &&
|
165
165
|
showExpandColumn(props) &&
|
@@ -175,7 +175,7 @@ export const getTrailingDisplayColumnIds = <TData extends Record<string, any>>(
|
|
175
175
|
props.positionActionsColumn === 'last' &&
|
176
176
|
(props.enableRowActions ||
|
177
177
|
(props.enableEditing &&
|
178
|
-
['
|
178
|
+
['modal', 'row'].includes(props.editDisplayMode ?? ''))) &&
|
179
179
|
'mrt-row-actions',
|
180
180
|
props.positionExpandColumn === 'last' &&
|
181
181
|
showExpandColumn(props) &&
|
@@ -218,15 +218,21 @@ export const getIsFirstColumn = <TData extends Record<string, any>>(
|
|
218
218
|
column: MRT_Column<TData>,
|
219
219
|
table: MRT_TableInstance<TData>,
|
220
220
|
) => {
|
221
|
-
|
221
|
+
const leftColumns = table.getLeftVisibleLeafColumns();
|
222
|
+
return leftColumns.length
|
223
|
+
? leftColumns[0].id === column.id
|
224
|
+
: table.getVisibleLeafColumns()[0].id === column.id;
|
222
225
|
};
|
223
226
|
|
224
227
|
export const getIsLastColumn = <TData extends Record<string, any>>(
|
225
228
|
column: MRT_Column<TData>,
|
226
229
|
table: MRT_TableInstance<TData>,
|
227
230
|
) => {
|
231
|
+
const rightColumns = table.getRightVisibleLeafColumns();
|
228
232
|
const columns = table.getVisibleLeafColumns();
|
229
|
-
return
|
233
|
+
return rightColumns.length
|
234
|
+
? rightColumns[rightColumns.length - 1].id === column.id
|
235
|
+
: columns[columns.length - 1].id === column.id;
|
230
236
|
};
|
231
237
|
|
232
238
|
export const getIsLastLeftPinnedColumn = <TData extends Record<string, any>>(
|
@@ -258,15 +264,15 @@ export const getTotalRight = <TData extends Record<string, any>>(
|
|
258
264
|
export const getCanRankRows = <TData extends Record<string, any>>(
|
259
265
|
table: MRT_TableInstance<TData>,
|
260
266
|
) => {
|
261
|
-
const {
|
267
|
+
const { getState, options } = table;
|
262
268
|
const {
|
269
|
+
enableGlobalFilterRankedResults,
|
263
270
|
manualExpanding,
|
264
271
|
manualFiltering,
|
265
272
|
manualGrouping,
|
266
273
|
manualSorting,
|
267
|
-
enableGlobalFilterRankedResults,
|
268
274
|
} = options;
|
269
|
-
const {
|
275
|
+
const { expanded, globalFilterFn } = getState();
|
270
276
|
|
271
277
|
return (
|
272
278
|
!manualExpanding &&
|
@@ -366,8 +372,8 @@ export const getCommonCellStyles = <TData extends Record<string, any>>({
|
|
366
372
|
|
367
373
|
export const MRT_DefaultColumn = {
|
368
374
|
filterVariant: 'text',
|
369
|
-
minSize: 40,
|
370
375
|
maxSize: 1000,
|
376
|
+
minSize: 40,
|
371
377
|
size: 180,
|
372
378
|
} as const;
|
373
379
|
|
@@ -387,7 +393,7 @@ export const MRT_DefaultDisplayColumn = {
|
|
387
393
|
} as const;
|
388
394
|
|
389
395
|
export const parseFromValuesOrFunc = <T, U>(
|
390
|
-
fn:
|
396
|
+
fn: ((arg: U) => T) | T | undefined,
|
391
397
|
arg: U,
|
392
398
|
): T | undefined => (fn instanceof Function ? fn(arg) : fn);
|
393
399
|
|
@@ -396,7 +402,7 @@ export const parseCSSVarId = (id: string) => id.replace(/[^a-zA-Z0-9]/g, '_');
|
|
396
402
|
export const flexRender = _flexRender as (
|
397
403
|
Comp: Renderable<any>,
|
398
404
|
props: any,
|
399
|
-
) =>
|
405
|
+
) => JSX.Element | ReactNode;
|
400
406
|
|
401
407
|
export const createRow = <TData extends Record<string, any>>(
|
402
408
|
table: MRT_TableInstance<TData>,
|
package/src/filterFns.ts
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
import {
|
2
|
+
type RankingInfo,
|
2
3
|
rankItem,
|
3
4
|
rankings,
|
4
|
-
type RankingInfo,
|
5
5
|
} from '@tanstack/match-sorter-utils';
|
6
|
-
import {
|
6
|
+
import { type Row, filterFns } from '@tanstack/react-table';
|
7
7
|
|
8
8
|
const fuzzy = <TData extends Record<string, any>>(
|
9
9
|
row: Row<TData>,
|
10
10
|
columnId: string,
|
11
|
-
filterValue:
|
11
|
+
filterValue: number | string,
|
12
12
|
addMeta: (item: RankingInfo) => void,
|
13
13
|
) => {
|
14
14
|
const itemRank = rankItem(row.getValue(columnId), filterValue as string, {
|
@@ -23,10 +23,10 @@ fuzzy.autoRemove = (val: any) => !val;
|
|
23
23
|
const contains = <TData extends Record<string, any>>(
|
24
24
|
row: Row<TData>,
|
25
25
|
id: string,
|
26
|
-
filterValue:
|
26
|
+
filterValue: number | string,
|
27
27
|
) =>
|
28
28
|
row
|
29
|
-
.getValue<
|
29
|
+
.getValue<number | string>(id)
|
30
30
|
.toString()
|
31
31
|
.toLowerCase()
|
32
32
|
.trim()
|
@@ -37,10 +37,10 @@ contains.autoRemove = (val: any) => !val;
|
|
37
37
|
const startsWith = <TData extends Record<string, any>>(
|
38
38
|
row: Row<TData>,
|
39
39
|
id: string,
|
40
|
-
filterValue:
|
40
|
+
filterValue: number | string,
|
41
41
|
) =>
|
42
42
|
row
|
43
|
-
.getValue<
|
43
|
+
.getValue<number | string>(id)
|
44
44
|
.toString()
|
45
45
|
.toLowerCase()
|
46
46
|
.trim()
|
@@ -51,10 +51,10 @@ startsWith.autoRemove = (val: any) => !val;
|
|
51
51
|
const endsWith = <TData extends Record<string, any>>(
|
52
52
|
row: Row<TData>,
|
53
53
|
id: string,
|
54
|
-
filterValue:
|
54
|
+
filterValue: number | string,
|
55
55
|
) =>
|
56
56
|
row
|
57
|
-
.getValue<
|
57
|
+
.getValue<number | string>(id)
|
58
58
|
.toString()
|
59
59
|
.toLowerCase()
|
60
60
|
.trim()
|
@@ -65,9 +65,9 @@ endsWith.autoRemove = (val: any) => !val;
|
|
65
65
|
const equals = <TData extends Record<string, any>>(
|
66
66
|
row: Row<TData>,
|
67
67
|
id: string,
|
68
|
-
filterValue:
|
68
|
+
filterValue: number | string,
|
69
69
|
) =>
|
70
|
-
row.getValue<
|
70
|
+
row.getValue<number | string>(id).toString().toLowerCase().trim() ===
|
71
71
|
filterValue.toString().toLowerCase().trim();
|
72
72
|
|
73
73
|
equals.autoRemove = (val: any) => !val;
|
@@ -75,9 +75,9 @@ equals.autoRemove = (val: any) => !val;
|
|
75
75
|
const notEquals = <TData extends Record<string, any>>(
|
76
76
|
row: Row<TData>,
|
77
77
|
id: string,
|
78
|
-
filterValue:
|
78
|
+
filterValue: number | string,
|
79
79
|
) =>
|
80
|
-
row.getValue<
|
80
|
+
row.getValue<number | string>(id).toString().toLowerCase().trim() !==
|
81
81
|
filterValue.toString().toLowerCase().trim();
|
82
82
|
|
83
83
|
notEquals.autoRemove = (val: any) => !val;
|
@@ -85,11 +85,11 @@ notEquals.autoRemove = (val: any) => !val;
|
|
85
85
|
const greaterThan = <TData extends Record<string, any>>(
|
86
86
|
row: Row<TData>,
|
87
87
|
id: string,
|
88
|
-
filterValue:
|
88
|
+
filterValue: number | string,
|
89
89
|
) =>
|
90
|
-
!isNaN(+filterValue) && !isNaN(+row.getValue<
|
91
|
-
? +row.getValue<
|
92
|
-
: row.getValue<
|
90
|
+
!isNaN(+filterValue) && !isNaN(+row.getValue<number | string>(id))
|
91
|
+
? +row.getValue<number | string>(id) > +filterValue
|
92
|
+
: row.getValue<number | string>(id).toString().toLowerCase().trim() >
|
93
93
|
filterValue.toString().toLowerCase().trim();
|
94
94
|
|
95
95
|
greaterThan.autoRemove = (val: any) => !val;
|
@@ -97,7 +97,7 @@ greaterThan.autoRemove = (val: any) => !val;
|
|
97
97
|
const greaterThanOrEqualTo = <TData extends Record<string, any>>(
|
98
98
|
row: Row<TData>,
|
99
99
|
id: string,
|
100
|
-
filterValue:
|
100
|
+
filterValue: number | string,
|
101
101
|
) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
|
102
102
|
|
103
103
|
greaterThanOrEqualTo.autoRemove = (val: any) => !val;
|
@@ -105,11 +105,11 @@ greaterThanOrEqualTo.autoRemove = (val: any) => !val;
|
|
105
105
|
const lessThan = <TData extends Record<string, any>>(
|
106
106
|
row: Row<TData>,
|
107
107
|
id: string,
|
108
|
-
filterValue:
|
108
|
+
filterValue: number | string,
|
109
109
|
) =>
|
110
|
-
!isNaN(+filterValue) && !isNaN(+row.getValue<
|
111
|
-
? +row.getValue<
|
112
|
-
: row.getValue<
|
110
|
+
!isNaN(+filterValue) && !isNaN(+row.getValue<number | string>(id))
|
111
|
+
? +row.getValue<number | string>(id) < +filterValue
|
112
|
+
: row.getValue<number | string>(id).toString().toLowerCase().trim() <
|
113
113
|
filterValue.toString().toLowerCase().trim();
|
114
114
|
|
115
115
|
lessThan.autoRemove = (val: any) => !val;
|
@@ -117,7 +117,7 @@ lessThan.autoRemove = (val: any) => !val;
|
|
117
117
|
const lessThanOrEqualTo = <TData extends Record<string, any>>(
|
118
118
|
row: Row<TData>,
|
119
119
|
id: string,
|
120
|
-
filterValue:
|
120
|
+
filterValue: number | string,
|
121
121
|
) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
|
122
122
|
|
123
123
|
lessThanOrEqualTo.autoRemove = (val: any) => !val;
|
@@ -125,7 +125,7 @@ lessThanOrEqualTo.autoRemove = (val: any) => !val;
|
|
125
125
|
const between = <TData extends Record<string, any>>(
|
126
126
|
row: Row<TData>,
|
127
127
|
id: string,
|
128
|
-
filterValues: [
|
128
|
+
filterValues: [number | string, number | string],
|
129
129
|
) =>
|
130
130
|
((['', undefined] as any[]).includes(filterValues[0]) ||
|
131
131
|
greaterThan(row, id, filterValues[0])) &&
|
@@ -140,7 +140,7 @@ between.autoRemove = (val: any) => !val;
|
|
140
140
|
const betweenInclusive = <TData extends Record<string, any>>(
|
141
141
|
row: Row<TData>,
|
142
142
|
id: string,
|
143
|
-
filterValues: [
|
143
|
+
filterValues: [number | string, number | string],
|
144
144
|
) =>
|
145
145
|
((['', undefined] as any[]).includes(filterValues[0]) ||
|
146
146
|
greaterThanOrEqualTo(row, id, filterValues[0])) &&
|
@@ -155,16 +155,16 @@ betweenInclusive.autoRemove = (val: any) => !val;
|
|
155
155
|
const empty = <TData extends Record<string, any>>(
|
156
156
|
row: Row<TData>,
|
157
157
|
id: string,
|
158
|
-
_filterValue:
|
159
|
-
) => !row.getValue<
|
158
|
+
_filterValue: number | string,
|
159
|
+
) => !row.getValue<number | string>(id).toString().trim();
|
160
160
|
|
161
161
|
empty.autoRemove = (val: any) => !val;
|
162
162
|
|
163
163
|
const notEmpty = <TData extends Record<string, any>>(
|
164
164
|
row: Row<TData>,
|
165
165
|
id: string,
|
166
|
-
_filterValue:
|
167
|
-
) => !!row.getValue<
|
166
|
+
_filterValue: number | string,
|
167
|
+
) => !!row.getValue<number | string>(id).toString().trim();
|
168
168
|
|
169
169
|
notEmpty.autoRemove = (val: any) => !val;
|
170
170
|
|
@@ -1,8 +1,8 @@
|
|
1
|
+
import { type VirtualItem } from '@tanstack/react-virtual';
|
1
2
|
import TableFooter from '@mui/material/TableFooter';
|
2
3
|
import { MRT_TableFooterRow } from './MRT_TableFooterRow';
|
3
|
-
import { type VirtualItem } from '@tanstack/react-virtual';
|
4
|
-
import { type MRT_TableInstance } from '../types';
|
5
4
|
import { parseFromValuesOrFunc } from '../column.utils';
|
5
|
+
import { type MRT_TableInstance } from '../types';
|
6
6
|
|
7
7
|
interface Props<TData extends Record<string, any>> {
|
8
8
|
table: MRT_TableInstance<TData>;
|
@@ -35,6 +35,13 @@ export const MRT_TableFooter = <TData extends Record<string, any>>({
|
|
35
35
|
return (
|
36
36
|
<TableFooter
|
37
37
|
{...tableFooterProps}
|
38
|
+
ref={(ref: HTMLTableSectionElement) => {
|
39
|
+
tableFooterRef.current = ref;
|
40
|
+
if (tableFooterProps?.ref) {
|
41
|
+
// @ts-ignore
|
42
|
+
tableFooterProps.ref.current = ref;
|
43
|
+
}
|
44
|
+
}}
|
38
45
|
sx={(theme) => ({
|
39
46
|
bottom: stickFooter ? 0 : undefined,
|
40
47
|
display: layoutMode === 'grid' ? 'grid' : 'table-row-group',
|
@@ -48,13 +55,6 @@ export const MRT_TableFooter = <TData extends Record<string, any>>({
|
|
48
55
|
zIndex: stickFooter ? 1 : undefined,
|
49
56
|
...(parseFromValuesOrFunc(tableFooterProps?.sx, theme) as any),
|
50
57
|
})}
|
51
|
-
ref={(ref: HTMLTableSectionElement) => {
|
52
|
-
tableFooterRef.current = ref;
|
53
|
-
if (tableFooterProps?.ref) {
|
54
|
-
// @ts-ignore
|
55
|
-
tableFooterProps.ref.current = ref;
|
56
|
-
}
|
57
|
-
}}
|
58
58
|
>
|
59
59
|
{getFooterGroups().map((footerGroup) => (
|
60
60
|
<MRT_TableFooterRow
|
@@ -1,13 +1,13 @@
|
|
1
|
+
import { type VirtualItem } from '@tanstack/react-virtual';
|
1
2
|
import TableRow from '@mui/material/TableRow';
|
2
3
|
import { lighten } from '@mui/material/styles';
|
3
4
|
import { MRT_TableFooterCell } from './MRT_TableFooterCell';
|
4
|
-
import {
|
5
|
+
import { parseFromValuesOrFunc } from '../column.utils';
|
5
6
|
import {
|
6
7
|
type MRT_Header,
|
7
8
|
type MRT_HeaderGroup,
|
8
9
|
type MRT_TableInstance,
|
9
10
|
} from '../types';
|
10
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
11
11
|
|
12
12
|
interface Props<TData extends Record<string, any>> {
|
13
13
|
footerGroup: MRT_HeaderGroup<TData>;
|
@@ -1,8 +1,8 @@
|
|
1
|
+
import { type VirtualItem } from '@tanstack/react-virtual';
|
1
2
|
import TableHead from '@mui/material/TableHead';
|
2
3
|
import { MRT_TableHeadRow } from './MRT_TableHeadRow';
|
3
|
-
import { type VirtualItem } from '@tanstack/react-virtual';
|
4
|
-
import { type MRT_TableInstance } from '../types';
|
5
4
|
import { parseFromValuesOrFunc } from '../column.utils';
|
5
|
+
import { type MRT_TableInstance } from '../types';
|
6
6
|
|
7
7
|
interface Props<TData extends Record<string, any>> {
|
8
8
|
table: MRT_TableInstance<TData>;
|
@@ -32,6 +32,13 @@ export const MRT_TableHead = <TData extends Record<string, any>>({
|
|
32
32
|
return (
|
33
33
|
<TableHead
|
34
34
|
{...tableHeadProps}
|
35
|
+
ref={(ref: HTMLTableSectionElement) => {
|
36
|
+
tableHeadRef.current = ref;
|
37
|
+
if (tableHeadProps?.ref) {
|
38
|
+
// @ts-ignore
|
39
|
+
tableHeadProps.ref.current = ref;
|
40
|
+
}
|
41
|
+
}}
|
35
42
|
sx={(theme) => ({
|
36
43
|
display: layoutMode === 'grid' ? 'grid' : 'table-row-group',
|
37
44
|
opacity: 0.97,
|
@@ -40,13 +47,6 @@ export const MRT_TableHead = <TData extends Record<string, any>>({
|
|
40
47
|
zIndex: stickyHeader ? 2 : undefined,
|
41
48
|
...(parseFromValuesOrFunc(tableHeadProps?.sx, theme) as any),
|
42
49
|
})}
|
43
|
-
ref={(ref: HTMLTableSectionElement) => {
|
44
|
-
tableHeadRef.current = ref;
|
45
|
-
if (tableHeadProps?.ref) {
|
46
|
-
// @ts-ignore
|
47
|
-
tableHeadProps.ref.current = ref;
|
48
|
-
}
|
49
|
-
}}
|
50
50
|
>
|
51
51
|
{getHeaderGroups().map((headerGroup) => (
|
52
52
|
<MRT_TableHeadRow
|
@@ -2,6 +2,7 @@ import { type DragEvent, useMemo } from 'react';
|
|
2
2
|
import Box from '@mui/material/Box';
|
3
3
|
import TableCell from '@mui/material/TableCell';
|
4
4
|
import { useTheme } from '@mui/material/styles';
|
5
|
+
import { type Theme } from '@mui/material/styles';
|
5
6
|
import { MRT_TableHeadCellColumnActionsButton } from './MRT_TableHeadCellColumnActionsButton';
|
6
7
|
import { MRT_TableHeadCellFilterContainer } from './MRT_TableHeadCellFilterContainer';
|
7
8
|
import { MRT_TableHeadCellFilterLabel } from './MRT_TableHeadCellFilterLabel';
|
@@ -9,7 +10,6 @@ import { MRT_TableHeadCellGrabHandle } from './MRT_TableHeadCellGrabHandle';
|
|
9
10
|
import { MRT_TableHeadCellResizeHandle } from './MRT_TableHeadCellResizeHandle';
|
10
11
|
import { MRT_TableHeadCellSortLabel } from './MRT_TableHeadCellSortLabel';
|
11
12
|
import { getCommonCellStyles } from '../column.utils';
|
12
|
-
import { type Theme } from '@mui/material/styles';
|
13
13
|
import { parseFromValuesOrFunc } from '../column.utils';
|
14
14
|
import { type MRT_Header, type MRT_TableInstance } from '../types';
|
15
15
|
|
@@ -26,6 +26,7 @@ export const MRT_TableHeadCell = <TData extends Record<string, any>>({
|
|
26
26
|
const {
|
27
27
|
getState,
|
28
28
|
options: {
|
29
|
+
columnFilterDisplayMode,
|
29
30
|
enableColumnActions,
|
30
31
|
enableColumnDragging,
|
31
32
|
enableColumnOrdering,
|
@@ -50,7 +51,10 @@ export const MRT_TableHeadCell = <TData extends Record<string, any>>({
|
|
50
51
|
|
51
52
|
const tableCellProps = {
|
52
53
|
...parseFromValuesOrFunc(muiTableHeadCellProps, { column, table }),
|
53
|
-
...parseFromValuesOrFunc(columnDef.muiTableHeadCellProps, {
|
54
|
+
...parseFromValuesOrFunc(columnDef.muiTableHeadCellProps, {
|
55
|
+
column,
|
56
|
+
table,
|
57
|
+
}),
|
54
58
|
};
|
55
59
|
|
56
60
|
const showColumnActions =
|
@@ -205,14 +209,14 @@ export const MRT_TableHeadCell = <TData extends Record<string, any>>({
|
|
205
209
|
<Box
|
206
210
|
className="Mui-TableHeadCell-Content-Wrapper"
|
207
211
|
sx={{
|
212
|
+
'&:hover': {
|
213
|
+
textOverflow: 'clip',
|
214
|
+
},
|
208
215
|
minWidth: `${Math.min(columnDef.header?.length ?? 0, 5)}ch`,
|
209
216
|
overflow: columnDefType === 'data' ? 'hidden' : undefined,
|
210
217
|
textOverflow: 'ellipsis',
|
211
218
|
whiteSpace:
|
212
219
|
(columnDef.header?.length ?? 0) < 20 ? 'nowrap' : 'normal',
|
213
|
-
'&:hover': {
|
214
|
-
textOverflow: 'clip',
|
215
|
-
},
|
216
220
|
}}
|
217
221
|
title={columnDefType === 'data' ? columnDef.header : undefined}
|
218
222
|
>
|
@@ -256,7 +260,7 @@ export const MRT_TableHeadCell = <TData extends Record<string, any>>({
|
|
256
260
|
)}
|
257
261
|
</Box>
|
258
262
|
)}
|
259
|
-
{column.getCanFilter() && (
|
263
|
+
{columnFilterDisplayMode === 'subheader' && column.getCanFilter() && (
|
260
264
|
<MRT_TableHeadCellFilterContainer header={header} table={table} />
|
261
265
|
)}
|
262
266
|
</TableCell>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { type MouseEvent, useState } from 'react';
|
2
2
|
import IconButton from '@mui/material/IconButton';
|
3
3
|
import Tooltip from '@mui/material/Tooltip';
|
4
|
-
import { MRT_ColumnActionMenu } from '../menus/MRT_ColumnActionMenu';
|
5
4
|
import { parseFromValuesOrFunc } from '../column.utils';
|
5
|
+
import { MRT_ColumnActionMenu } from '../menus/MRT_ColumnActionMenu';
|
6
6
|
import { type MRT_Header, type MRT_TableInstance } from '../types';
|
7
7
|
|
8
8
|
interface Props<TData extends Record<string, any>> {
|
@@ -18,6 +18,7 @@ export const MRT_TableHeadCellColumnActionsButton = <
|
|
18
18
|
}: Props<TData>) => {
|
19
19
|
const {
|
20
20
|
options: {
|
21
|
+
columnFilterDisplayMode,
|
21
22
|
icons: { MoreVertIcon },
|
22
23
|
localization,
|
23
24
|
muiColumnActionsButtonProps,
|
@@ -26,7 +27,7 @@ export const MRT_TableHeadCellColumnActionsButton = <
|
|
26
27
|
const { column } = header;
|
27
28
|
const { columnDef } = column;
|
28
29
|
|
29
|
-
const [anchorEl, setAnchorEl] = useState<
|
30
|
+
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
|
30
31
|
|
31
32
|
const handleClick = (event: MouseEvent<HTMLElement>) => {
|
32
33
|
event.stopPropagation();
|
@@ -60,15 +61,17 @@ export const MRT_TableHeadCellColumnActionsButton = <
|
|
60
61
|
size="small"
|
61
62
|
{...iconButtonProps}
|
62
63
|
sx={(theme) => ({
|
64
|
+
'&:hover': {
|
65
|
+
opacity: 1,
|
66
|
+
},
|
63
67
|
height: '2rem',
|
64
68
|
m: '-8px -4px',
|
65
69
|
opacity: 0.5,
|
66
|
-
transform:
|
70
|
+
transform: `scale(0.85) ${
|
71
|
+
columnFilterDisplayMode !== 'popover' ? 'translateX(-4px)' : ''
|
72
|
+
}`,
|
67
73
|
transition: 'opacity 150ms',
|
68
74
|
width: '2rem',
|
69
|
-
'&:hover': {
|
70
|
-
opacity: 1,
|
71
|
-
},
|
72
75
|
...(parseFromValuesOrFunc(iconButtonProps?.sx, theme) as any),
|
73
76
|
})}
|
74
77
|
title={undefined}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import Collapse from '@mui/material/Collapse';
|
2
|
-
import { MRT_FilterRangeFields } from '../inputs/MRT_FilterRangeFields';
|
3
|
-
import { MRT_FilterTextField } from '../inputs/MRT_FilterTextField';
|
4
2
|
import { MRT_FilterCheckbox } from '../inputs/MRT_FilterCheckbox';
|
3
|
+
import { MRT_FilterRangeFields } from '../inputs/MRT_FilterRangeFields';
|
5
4
|
import { MRT_FilterRangeSlider } from '../inputs/MRT_FilterRangeSlider';
|
5
|
+
import { MRT_FilterTextField } from '../inputs/MRT_FilterTextField';
|
6
6
|
import { type MRT_Header, type MRT_TableInstance } from '../types';
|
7
7
|
|
8
8
|
interface Props<TData extends Record<string, any>> {
|
@@ -16,13 +16,20 @@ export const MRT_TableHeadCellFilterContainer = <
|
|
16
16
|
header,
|
17
17
|
table,
|
18
18
|
}: Props<TData>) => {
|
19
|
-
const {
|
19
|
+
const {
|
20
|
+
getState,
|
21
|
+
options: { columnFilterDisplayMode },
|
22
|
+
} = table;
|
20
23
|
const { showColumnFilters } = getState();
|
21
24
|
const { column } = header;
|
22
25
|
const { columnDef } = column;
|
23
26
|
|
24
27
|
return (
|
25
|
-
<Collapse
|
28
|
+
<Collapse
|
29
|
+
in={showColumnFilters || columnFilterDisplayMode === 'popover'}
|
30
|
+
mountOnEnter
|
31
|
+
unmountOnExit
|
32
|
+
>
|
26
33
|
{columnDef.filterVariant === 'checkbox' ? (
|
27
34
|
<MRT_FilterCheckbox column={column} table={table} />
|
28
35
|
) : columnDef.filterVariant === 'range-slider' ? (
|