material-react-table 2.7.0 → 2.8.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/index.d.ts +239 -93
- package/dist/index.esm.js +3489 -3470
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3486 -3470
- package/dist/index.js.map +1 -1
- package/package.json +20 -20
- package/src/{MaterialReactTable.tsx → components/MaterialReactTable.tsx} +3 -3
- package/src/{body → components/body}/MRT_TableBody.tsx +4 -4
- package/src/{body → components/body}/MRT_TableBodyCell.tsx +6 -23
- package/src/{body → components/body}/MRT_TableBodyCellValue.tsx +2 -2
- package/src/{body → components/body}/MRT_TableBodyRow.tsx +3 -3
- package/src/{body → components/body}/MRT_TableBodyRowGrabHandle.tsx +3 -3
- package/src/{body → components/body}/MRT_TableBodyRowPinButton.tsx +3 -3
- package/src/{body → components/body}/MRT_TableDetailPanel.tsx +3 -3
- package/src/{buttons → components/buttons}/MRT_ColumnPinningButtons.tsx +2 -2
- package/src/{buttons → components/buttons}/MRT_CopyButton.tsx +3 -3
- package/src/{buttons → components/buttons}/MRT_EditActionButtons.tsx +2 -2
- package/src/{buttons → components/buttons}/MRT_ExpandAllButton.tsx +3 -3
- package/src/{buttons → components/buttons}/MRT_ExpandButton.tsx +6 -3
- package/src/{buttons → components/buttons}/MRT_GrabHandleButton.tsx +3 -3
- package/src/{buttons → components/buttons}/MRT_RowPinButton.tsx +3 -3
- package/src/{buttons → components/buttons}/MRT_ShowHideColumnsButton.tsx +1 -1
- package/src/{buttons → components/buttons}/MRT_ToggleDensePaddingButton.tsx +1 -1
- package/src/{buttons → components/buttons}/MRT_ToggleFiltersButton.tsx +1 -1
- package/src/{buttons → components/buttons}/MRT_ToggleFullScreenButton.tsx +1 -1
- package/src/{buttons → components/buttons}/MRT_ToggleGlobalFilterButton.tsx +1 -1
- package/src/{buttons → components/buttons}/MRT_ToggleRowActionMenuButton.tsx +4 -4
- package/src/{footer → components/footer}/MRT_TableFooter.tsx +2 -2
- package/src/{footer → components/footer}/MRT_TableFooterCell.tsx +3 -3
- package/src/{footer → components/footer}/MRT_TableFooterRow.tsx +3 -3
- package/src/{head → components/head}/MRT_TableHead.tsx +3 -3
- package/src/{head → components/head}/MRT_TableHeadCell.tsx +3 -3
- package/src/{head → components/head}/MRT_TableHeadCellColumnActionsButton.tsx +4 -4
- package/src/{head → components/head}/MRT_TableHeadCellFilterContainer.tsx +5 -5
- package/src/{head → components/head}/MRT_TableHeadCellFilterLabel.tsx +2 -2
- package/src/{head → components/head}/MRT_TableHeadCellGrabHandle.tsx +4 -3
- package/src/{head → components/head}/MRT_TableHeadCellResizeHandle.tsx +2 -2
- package/src/{head → components/head}/MRT_TableHeadCellSortLabel.tsx +2 -2
- package/src/{head → components/head}/MRT_TableHeadRow.tsx +3 -3
- package/src/{inputs → components/inputs}/MRT_EditCellTextField.tsx +12 -4
- package/src/{inputs → components/inputs}/MRT_FilterCheckbox.tsx +3 -3
- package/src/{inputs → components/inputs}/MRT_FilterRangeFields.tsx +2 -2
- package/src/{inputs → components/inputs}/MRT_FilterRangeSlider.tsx +2 -2
- package/src/{inputs → components/inputs}/MRT_FilterTextField.tsx +3 -3
- package/src/{inputs → components/inputs}/MRT_GlobalFilterTextField.tsx +2 -2
- package/src/{inputs → components/inputs}/MRT_SelectCheckbox.tsx +3 -3
- package/src/{menus → components/menus}/MRT_ColumnActionMenu.tsx +8 -8
- package/src/{menus → components/menus}/MRT_FilterOptionMenu.tsx +2 -2
- package/src/{menus → components/menus}/MRT_RowActionMenu.tsx +9 -9
- package/src/{menus → components/menus}/MRT_ShowHideColumnsMenu.tsx +5 -7
- package/src/{menus → components/menus}/MRT_ShowHideColumnsMenuItems.tsx +6 -5
- package/src/{modals → components/modals}/MRT_EditRowModal.tsx +4 -4
- package/src/{table → components/table}/MRT_Table.tsx +4 -4
- package/src/{table → components/table}/MRT_TableContainer.tsx +2 -2
- package/src/{table → components/table}/MRT_TableLoadingOverlay.tsx +3 -3
- package/src/{table → components/table}/MRT_TablePaper.tsx +3 -3
- package/src/{toolbar → components/toolbar}/MRT_BottomToolbar.tsx +3 -3
- package/src/{toolbar → components/toolbar}/MRT_LinearProgressBar.tsx +2 -2
- package/src/{toolbar → components/toolbar}/MRT_TablePagination.tsx +3 -3
- package/src/{toolbar → components/toolbar}/MRT_ToolbarAlertBanner.tsx +2 -2
- package/src/{toolbar → components/toolbar}/MRT_ToolbarDropZone.tsx +2 -2
- package/src/{toolbar → components/toolbar}/MRT_ToolbarInternalButtons.tsx +2 -2
- package/src/{toolbar → components/toolbar}/MRT_TopToolbar.tsx +3 -3
- package/src/{filterFns.ts → fns/filterFns.ts} +1 -1
- package/src/{sortingFns.ts → fns/sortingFns.ts} +1 -1
- package/src/hooks/display-columns/getMRT_DisplayColumns.tsx +26 -0
- package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +34 -0
- package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +35 -0
- package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +96 -0
- package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +36 -0
- package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +30 -0
- package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +40 -0
- package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +40 -0
- package/src/hooks/useMRT_ColumnVirtualizer.ts +2 -4
- package/src/hooks/useMRT_Effects.ts +1 -1
- package/src/hooks/useMRT_RowVirtualizer.ts +2 -4
- package/src/hooks/useMRT_Rows.ts +2 -2
- package/src/hooks/useMRT_TableInstance.ts +54 -39
- package/src/hooks/useMRT_TableOptions.ts +3 -3
- package/src/{useMaterialReactTable.ts → hooks/useMaterialReactTable.ts} +3 -3
- package/src/index.ts +79 -82
- package/src/types.ts +54 -26
- package/src/utils/column.utils.ts +173 -0
- package/src/utils/displayColumn.utils.ts +134 -0
- package/src/utils/row.utils.ts +26 -0
- package/src/{style.utils.ts → utils/style.utils.ts} +21 -15
- package/src/utils/tanstack.helpers.ts +64 -0
- package/src/utils/utils.ts +23 -0
- package/src/utils/virtualization.utils.ts +19 -0
- package/src/utils.ts +0 -0
- package/src/column.utils.ts +0 -361
- package/src/hooks/useMRT_DisplayColumns.tsx +0 -290
- /package/src/{aggregationFns.ts → fns/aggregationFns.ts} +0 -0
@@ -1,15 +1,15 @@
|
|
1
1
|
import TableRow, { type TableRowProps } from '@mui/material/TableRow';
|
2
2
|
import { alpha } from '@mui/material/styles';
|
3
3
|
import { MRT_TableHeadCell } from './MRT_TableHeadCell';
|
4
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
5
|
-
import { getMRTTheme } from '../style.utils';
|
6
4
|
import {
|
7
5
|
type MRT_ColumnVirtualizer,
|
8
6
|
type MRT_Header,
|
9
7
|
type MRT_HeaderGroup,
|
10
8
|
type MRT_RowData,
|
11
9
|
type MRT_TableInstance,
|
12
|
-
} from '
|
10
|
+
} from '../../types';
|
11
|
+
import { getMRTTheme } from '../../utils/style.utils';
|
12
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
13
13
|
|
14
14
|
interface Props<TData extends MRT_RowData> extends TableRowProps {
|
15
15
|
columnVirtualizer?: MRT_ColumnVirtualizer;
|
@@ -7,12 +7,12 @@ import {
|
|
7
7
|
import MenuItem from '@mui/material/MenuItem';
|
8
8
|
import TextField from '@mui/material/TextField';
|
9
9
|
import { type TextFieldProps } from '@mui/material/TextField';
|
10
|
-
import { getValueAndLabel, parseFromValuesOrFunc } from '../column.utils';
|
11
10
|
import {
|
12
11
|
type MRT_Cell,
|
13
12
|
type MRT_RowData,
|
14
13
|
type MRT_TableInstance,
|
15
|
-
} from '
|
14
|
+
} from '../../types';
|
15
|
+
import { getValueAndLabel, parseFromValuesOrFunc } from '../../utils/utils';
|
16
16
|
|
17
17
|
interface Props<TData extends MRT_RowData> extends TextFieldProps<'standard'> {
|
18
18
|
cell: MRT_Cell<TData>;
|
@@ -35,6 +35,7 @@ export const MRT_EditCellTextField = <TData extends MRT_RowData>({
|
|
35
35
|
const { column, row } = cell;
|
36
36
|
const { columnDef } = column;
|
37
37
|
const { creatingRow, editingRow } = getState();
|
38
|
+
const { editSelectOptions } = columnDef;
|
38
39
|
|
39
40
|
const isCreating = creatingRow?.id === row.id;
|
40
41
|
const isEditing = editingRow?.id === row.id;
|
@@ -58,6 +59,13 @@ export const MRT_EditCellTextField = <TData extends MRT_RowData>({
|
|
58
59
|
...rest,
|
59
60
|
};
|
60
61
|
|
62
|
+
const selectOptions = parseFromValuesOrFunc(editSelectOptions, {
|
63
|
+
cell,
|
64
|
+
column,
|
65
|
+
row,
|
66
|
+
table,
|
67
|
+
});
|
68
|
+
|
61
69
|
const saveInputValueToRowCache = (newValue: string) => {
|
62
70
|
//@ts-ignore
|
63
71
|
row._valuesCache[column.id] = newValue;
|
@@ -123,7 +131,7 @@ export const MRT_EditCellTextField = <TData extends MRT_RowData>({
|
|
123
131
|
}
|
124
132
|
select={isSelectEdit}
|
125
133
|
size="small"
|
126
|
-
value={value}
|
134
|
+
value={value ?? ''}
|
127
135
|
variant="standard"
|
128
136
|
{...textFieldProps}
|
129
137
|
InputProps={{
|
@@ -152,7 +160,7 @@ export const MRT_EditCellTextField = <TData extends MRT_RowData>({
|
|
152
160
|
onKeyDown={handleEnterKeyDown}
|
153
161
|
>
|
154
162
|
{textFieldProps.children ??
|
155
|
-
|
163
|
+
selectOptions?.map((option) => {
|
156
164
|
const { label, value } = getValueAndLabel(option);
|
157
165
|
return (
|
158
166
|
<MenuItem
|
@@ -1,13 +1,13 @@
|
|
1
1
|
import Checkbox, { type CheckboxProps } from '@mui/material/Checkbox';
|
2
2
|
import FormControlLabel from '@mui/material/FormControlLabel';
|
3
3
|
import Tooltip from '@mui/material/Tooltip';
|
4
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
5
|
-
import { getCommonTooltipProps } from '../style.utils';
|
6
4
|
import {
|
7
5
|
type MRT_Column,
|
8
6
|
type MRT_RowData,
|
9
7
|
type MRT_TableInstance,
|
10
|
-
} from '
|
8
|
+
} from '../../types';
|
9
|
+
import { getCommonTooltipProps } from '../../utils/style.utils';
|
10
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
11
11
|
|
12
12
|
interface Props<TData extends MRT_RowData> extends CheckboxProps {
|
13
13
|
column: MRT_Column<TData>;
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import Box, { type BoxProps } from '@mui/material/Box';
|
2
2
|
import { MRT_FilterTextField } from './MRT_FilterTextField';
|
3
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
4
3
|
import {
|
5
4
|
type MRT_Header,
|
6
5
|
type MRT_RowData,
|
7
6
|
type MRT_TableInstance,
|
8
|
-
} from '
|
7
|
+
} from '../../types';
|
8
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
9
9
|
|
10
10
|
interface Props<TData extends MRT_RowData> extends BoxProps {
|
11
11
|
header: MRT_Header<TData>;
|
@@ -2,12 +2,12 @@ import { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import FormHelperText from '@mui/material/FormHelperText';
|
3
3
|
import Slider, { type SliderProps } from '@mui/material/Slider';
|
4
4
|
import Stack from '@mui/material/Stack';
|
5
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
6
5
|
import {
|
7
6
|
type MRT_Header,
|
8
7
|
type MRT_RowData,
|
9
8
|
type MRT_TableInstance,
|
10
|
-
} from '
|
9
|
+
} from '../../types';
|
10
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
11
11
|
|
12
12
|
interface Props<TData extends MRT_RowData> extends SliderProps {
|
13
13
|
header: MRT_Header<TData>;
|
@@ -29,13 +29,13 @@ import {
|
|
29
29
|
TimePicker,
|
30
30
|
type TimePickerProps,
|
31
31
|
} from '@mui/x-date-pickers/TimePicker';
|
32
|
-
import { getValueAndLabel, parseFromValuesOrFunc } from '../column.utils';
|
33
|
-
import { MRT_FilterOptionMenu } from '../menus/MRT_FilterOptionMenu';
|
34
32
|
import {
|
35
33
|
type MRT_Header,
|
36
34
|
type MRT_RowData,
|
37
35
|
type MRT_TableInstance,
|
38
|
-
} from '
|
36
|
+
} from '../../types';
|
37
|
+
import { getValueAndLabel, parseFromValuesOrFunc } from '../../utils/utils';
|
38
|
+
import { MRT_FilterOptionMenu } from '../menus/MRT_FilterOptionMenu';
|
39
39
|
|
40
40
|
interface Props<TData extends MRT_RowData> extends TextFieldProps<'standard'> {
|
41
41
|
header: MRT_Header<TData>;
|
@@ -12,9 +12,9 @@ import InputAdornment from '@mui/material/InputAdornment';
|
|
12
12
|
import TextField, { type TextFieldProps } from '@mui/material/TextField';
|
13
13
|
import Tooltip from '@mui/material/Tooltip';
|
14
14
|
import { debounce } from '@mui/material/utils';
|
15
|
-
import {
|
15
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
16
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
16
17
|
import { MRT_FilterOptionMenu } from '../menus/MRT_FilterOptionMenu';
|
17
|
-
import { type MRT_RowData, type MRT_TableInstance } from '../types';
|
18
18
|
|
19
19
|
interface Props<TData extends MRT_RowData> extends TextFieldProps<'standard'> {
|
20
20
|
table: MRT_TableInstance<TData>;
|
@@ -3,13 +3,13 @@ import Checkbox, { type CheckboxProps } from '@mui/material/Checkbox';
|
|
3
3
|
import Radio, { type RadioProps } from '@mui/material/Radio';
|
4
4
|
import Tooltip from '@mui/material/Tooltip';
|
5
5
|
import { type Theme } from '@mui/material/styles';
|
6
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
7
|
-
import { getCommonTooltipProps } from '../style.utils';
|
8
6
|
import {
|
9
7
|
type MRT_Row,
|
10
8
|
type MRT_RowData,
|
11
9
|
type MRT_TableInstance,
|
12
|
-
} from '
|
10
|
+
} from '../../types';
|
11
|
+
import { getCommonTooltipProps } from '../../utils/style.utils';
|
12
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
13
13
|
|
14
14
|
interface Props<TData extends MRT_RowData> extends CheckboxProps {
|
15
15
|
row?: MRT_Row<TData>;
|
@@ -7,12 +7,12 @@ import Menu, { type MenuProps } from '@mui/material/Menu';
|
|
7
7
|
import MenuItem from '@mui/material/MenuItem';
|
8
8
|
import { useTheme } from '@mui/material/styles';
|
9
9
|
import { MRT_FilterOptionMenu } from './MRT_FilterOptionMenu';
|
10
|
-
import { getMRTTheme } from '../style.utils';
|
11
10
|
import {
|
12
11
|
type MRT_Header,
|
13
12
|
type MRT_RowData,
|
14
13
|
type MRT_TableInstance,
|
15
|
-
} from '
|
14
|
+
} from '../../types';
|
15
|
+
import { getMRTTheme } from '../../utils/style.utils';
|
16
16
|
|
17
17
|
export const commonMenuItemStyles = {
|
18
18
|
alignItems: 'center',
|
@@ -403,12 +403,12 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
|
|
403
403
|
|
404
404
|
return (
|
405
405
|
<Menu
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
406
|
+
MenuListProps={{
|
407
|
+
dense: density === 'compact',
|
408
|
+
sx: {
|
409
|
+
backgroundColor: menuBackgroundColor,
|
410
|
+
},
|
411
|
+
}}
|
412
412
|
anchorEl={anchorEl}
|
413
413
|
onClose={() => setAnchorEl(null)}
|
414
414
|
open={!!anchorEl}
|
@@ -3,7 +3,6 @@ import Box from '@mui/material/Box';
|
|
3
3
|
import Menu, { type MenuProps } from '@mui/material/Menu';
|
4
4
|
import MenuItem from '@mui/material/MenuItem';
|
5
5
|
import { useTheme } from '@mui/material/styles';
|
6
|
-
import { getMRTTheme } from '../style.utils';
|
7
6
|
import {
|
8
7
|
type MRT_FilterOption,
|
9
8
|
type MRT_Header,
|
@@ -11,7 +10,8 @@ import {
|
|
11
10
|
type MRT_Localization,
|
12
11
|
type MRT_RowData,
|
13
12
|
type MRT_TableInstance,
|
14
|
-
} from '
|
13
|
+
} from '../../types';
|
14
|
+
import { getMRTTheme } from '../../utils/style.utils';
|
15
15
|
|
16
16
|
export const mrtFilterOptions = (
|
17
17
|
localization: MRT_Localization,
|
@@ -8,13 +8,13 @@ import {
|
|
8
8
|
commonListItemStyles,
|
9
9
|
commonMenuItemStyles,
|
10
10
|
} from './MRT_ColumnActionMenu';
|
11
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
12
|
-
import { getMRTTheme } from '../style.utils';
|
13
11
|
import {
|
14
12
|
type MRT_Row,
|
15
13
|
type MRT_RowData,
|
16
14
|
type MRT_TableInstance,
|
17
|
-
} from '
|
15
|
+
} from '../../types';
|
16
|
+
import { getMRTTheme } from '../../utils/style.utils';
|
17
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
18
18
|
|
19
19
|
interface Props<TData extends MRT_RowData> extends Partial<MenuProps> {
|
20
20
|
anchorEl: HTMLElement | null;
|
@@ -51,12 +51,12 @@ export const MRT_RowActionMenu = <TData extends MRT_RowData>({
|
|
51
51
|
|
52
52
|
return (
|
53
53
|
<Menu
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
54
|
+
MenuListProps={{
|
55
|
+
dense: density === 'compact',
|
56
|
+
sx: {
|
57
|
+
backgroundColor: menuBackgroundColor,
|
58
|
+
},
|
59
|
+
}}
|
60
60
|
anchorEl={anchorEl}
|
61
61
|
onClick={(event) => event.stopPropagation()}
|
62
62
|
onClose={() => setAnchorEl(null)}
|
@@ -1,17 +1,17 @@
|
|
1
1
|
import { useMemo, useState } from 'react';
|
2
|
-
import { useTheme } from '@mui/material';
|
3
2
|
import Box from '@mui/material/Box';
|
4
3
|
import Button from '@mui/material/Button';
|
5
4
|
import Divider from '@mui/material/Divider';
|
6
5
|
import Menu, { type MenuProps } from '@mui/material/Menu';
|
6
|
+
import { useTheme } from '@mui/material/styles';
|
7
7
|
import { MRT_ShowHideColumnsMenuItems } from './MRT_ShowHideColumnsMenuItems';
|
8
|
-
import { getDefaultColumnOrderIds } from '../column.utils';
|
9
|
-
import { getMRTTheme } from '../style.utils';
|
10
8
|
import {
|
11
9
|
type MRT_Column,
|
12
10
|
type MRT_RowData,
|
13
11
|
type MRT_TableInstance,
|
14
|
-
} from '
|
12
|
+
} from '../../types';
|
13
|
+
import { getDefaultColumnOrderIds } from '../../utils/displayColumn.utils';
|
14
|
+
import { getMRTTheme } from '../../utils/style.utils';
|
15
15
|
|
16
16
|
interface Props<TData extends MRT_RowData> extends Partial<MenuProps> {
|
17
17
|
anchorEl: HTMLElement | null;
|
@@ -114,9 +114,7 @@ export const MRT_ShowHideColumnsMenu = <TData extends MRT_RowData>({
|
|
114
114
|
{enableColumnOrdering && (
|
115
115
|
<Button
|
116
116
|
onClick={() =>
|
117
|
-
table.setColumnOrder(
|
118
|
-
getDefaultColumnOrderIds(table.options as any),
|
119
|
-
)
|
117
|
+
table.setColumnOrder(getDefaultColumnOrderIds(table.options))
|
120
118
|
}
|
121
119
|
>
|
122
120
|
{localization.resetOrder}
|
@@ -11,15 +11,16 @@ import MenuItem, { type MenuItemProps } from '@mui/material/MenuItem';
|
|
11
11
|
import Switch from '@mui/material/Switch';
|
12
12
|
import Tooltip from '@mui/material/Tooltip';
|
13
13
|
import Typography from '@mui/material/Typography';
|
14
|
-
import { MRT_ColumnPinningButtons } from '../buttons/MRT_ColumnPinningButtons';
|
15
|
-
import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton';
|
16
|
-
import { parseFromValuesOrFunc, reorderColumn } from '../column.utils';
|
17
|
-
import { getCommonTooltipProps, getMRTTheme } from '../style.utils';
|
18
14
|
import {
|
19
15
|
type MRT_Column,
|
20
16
|
type MRT_RowData,
|
21
17
|
type MRT_TableInstance,
|
22
|
-
} from '
|
18
|
+
} from '../../types';
|
19
|
+
import { reorderColumn } from '../../utils/column.utils';
|
20
|
+
import { getCommonTooltipProps, getMRTTheme } from '../../utils/style.utils';
|
21
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
22
|
+
import { MRT_ColumnPinningButtons } from '../buttons/MRT_ColumnPinningButtons';
|
23
|
+
import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton';
|
23
24
|
|
24
25
|
interface Props<TData extends MRT_RowData> extends MenuItemProps {
|
25
26
|
allColumns: MRT_Column<TData>[];
|
@@ -3,14 +3,14 @@ import DialogActions from '@mui/material/DialogActions';
|
|
3
3
|
import DialogContent from '@mui/material/DialogContent';
|
4
4
|
import DialogTitle from '@mui/material/DialogTitle';
|
5
5
|
import Stack from '@mui/material/Stack';
|
6
|
-
import { MRT_EditActionButtons } from '../buttons/MRT_EditActionButtons';
|
7
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
8
|
-
import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField';
|
9
6
|
import {
|
10
7
|
type MRT_Row,
|
11
8
|
type MRT_RowData,
|
12
9
|
type MRT_TableInstance,
|
13
|
-
} from '
|
10
|
+
} from '../../types';
|
11
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
12
|
+
import { MRT_EditActionButtons } from '../buttons/MRT_EditActionButtons';
|
13
|
+
import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField';
|
14
14
|
|
15
15
|
interface Props<TData extends MRT_RowData> extends Partial<DialogProps> {
|
16
16
|
open: boolean;
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import { useMemo } from 'react';
|
2
2
|
import Table, { type TableProps } from '@mui/material/Table';
|
3
|
+
import { useMRT_ColumnVirtualizer } from '../../hooks/useMRT_ColumnVirtualizer';
|
4
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
5
|
+
import { parseCSSVarId } from '../../utils/style.utils';
|
6
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
3
7
|
import { MRT_TableBody, Memo_MRT_TableBody } from '../body/MRT_TableBody';
|
4
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
5
8
|
import { MRT_TableFooter } from '../footer/MRT_TableFooter';
|
6
9
|
import { MRT_TableHead } from '../head/MRT_TableHead';
|
7
|
-
import { useMRT_ColumnVirtualizer } from '../hooks/useMRT_ColumnVirtualizer';
|
8
|
-
import { parseCSSVarId } from '../style.utils';
|
9
|
-
import { type MRT_RowData, type MRT_TableInstance } from '../types';
|
10
10
|
|
11
11
|
interface Props<TData extends MRT_RowData> extends TableProps {
|
12
12
|
table: MRT_TableInstance<TData>;
|
@@ -4,9 +4,9 @@ import TableContainer, {
|
|
4
4
|
} from '@mui/material/TableContainer';
|
5
5
|
import { MRT_Table } from './MRT_Table';
|
6
6
|
import { MRT_TableLoadingOverlay } from './MRT_TableLoadingOverlay';
|
7
|
-
import {
|
7
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
8
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
8
9
|
import { MRT_EditRowModal } from '../modals/MRT_EditRowModal';
|
9
|
-
import { type MRT_RowData, type MRT_TableInstance } from '../types';
|
10
10
|
|
11
11
|
const useIsomorphicLayoutEffect =
|
12
12
|
typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
@@ -3,9 +3,9 @@ import CircularProgress, {
|
|
3
3
|
type CircularProgressProps,
|
4
4
|
} from '@mui/material/CircularProgress';
|
5
5
|
import { alpha } from '@mui/material/styles';
|
6
|
-
import {
|
7
|
-
import { getMRTTheme } from '
|
8
|
-
import {
|
6
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
7
|
+
import { getMRTTheme } from '../../utils/style.utils';
|
8
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
9
9
|
|
10
10
|
interface Props<TData extends MRT_RowData> extends CircularProgressProps {
|
11
11
|
table: MRT_TableInstance<TData>;
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import Paper, { type PaperProps } from '@mui/material/Paper';
|
2
2
|
import { MRT_TableContainer } from './MRT_TableContainer';
|
3
|
-
import {
|
4
|
-
import { getMRTTheme } from '
|
3
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
4
|
+
import { getMRTTheme } from '../../utils/style.utils';
|
5
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
5
6
|
import { MRT_BottomToolbar } from '../toolbar/MRT_BottomToolbar';
|
6
7
|
import { MRT_TopToolbar } from '../toolbar/MRT_TopToolbar';
|
7
|
-
import { type MRT_RowData, type MRT_TableInstance } from '../types';
|
8
8
|
|
9
9
|
interface Props<TData extends MRT_RowData> extends PaperProps {
|
10
10
|
table: MRT_TableInstance<TData>;
|
@@ -5,9 +5,9 @@ import { MRT_LinearProgressBar } from './MRT_LinearProgressBar';
|
|
5
5
|
import { MRT_TablePagination } from './MRT_TablePagination';
|
6
6
|
import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
|
7
7
|
import { MRT_ToolbarDropZone } from './MRT_ToolbarDropZone';
|
8
|
-
import {
|
9
|
-
import { getCommonToolbarStyles } from '
|
10
|
-
import {
|
8
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
9
|
+
import { getCommonToolbarStyles } from '../../utils/style.utils';
|
10
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
11
11
|
|
12
12
|
interface Props<TData extends MRT_RowData> extends BoxProps {
|
13
13
|
table: MRT_TableInstance<TData>;
|
@@ -2,8 +2,8 @@ import Collapse from '@mui/material/Collapse';
|
|
2
2
|
import LinearProgress, {
|
3
3
|
type LinearProgressProps,
|
4
4
|
} from '@mui/material/LinearProgress';
|
5
|
-
import {
|
6
|
-
import {
|
5
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
6
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
7
7
|
|
8
8
|
interface Props<TData extends MRT_RowData> extends LinearProgressProps {
|
9
9
|
isTopToolbar: boolean;
|
@@ -8,9 +8,9 @@ import Select, { type SelectProps } from '@mui/material/Select';
|
|
8
8
|
import Tooltip from '@mui/material/Tooltip';
|
9
9
|
import Typography from '@mui/material/Typography';
|
10
10
|
import { useTheme } from '@mui/material/styles';
|
11
|
-
import {
|
12
|
-
import { flipIconStyles, getCommonTooltipProps } from '
|
13
|
-
import {
|
11
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
12
|
+
import { flipIconStyles, getCommonTooltipProps } from '../../utils/style.utils';
|
13
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
14
14
|
|
15
15
|
const defaultRowsPerPage = [5, 10, 15, 20, 25, 30, 50, 100];
|
16
16
|
|
@@ -5,9 +5,9 @@ import Box from '@mui/material/Box';
|
|
5
5
|
import Chip from '@mui/material/Chip';
|
6
6
|
import Collapse from '@mui/material/Collapse';
|
7
7
|
import Stack from '@mui/material/Stack';
|
8
|
-
import {
|
8
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
9
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
9
10
|
import { MRT_SelectCheckbox } from '../inputs/MRT_SelectCheckbox';
|
10
|
-
import { type MRT_RowData, type MRT_TableInstance } from '../types';
|
11
11
|
|
12
12
|
interface Props<TData extends MRT_RowData> extends AlertProps {
|
13
13
|
stackAlertBanner?: boolean;
|
@@ -3,8 +3,8 @@ import Box, { type BoxProps } from '@mui/material/Box';
|
|
3
3
|
import Fade from '@mui/material/Fade';
|
4
4
|
import Typography from '@mui/material/Typography';
|
5
5
|
import { alpha } from '@mui/material/styles';
|
6
|
-
import {
|
7
|
-
import {
|
6
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
7
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
8
8
|
|
9
9
|
interface Props<TData extends MRT_RowData> extends BoxProps {
|
10
10
|
table: MRT_TableInstance<TData>;
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import Box, { type BoxProps } from '@mui/material/Box';
|
2
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
3
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
2
4
|
import { MRT_ShowHideColumnsButton } from '../buttons/MRT_ShowHideColumnsButton';
|
3
5
|
import { MRT_ToggleDensePaddingButton } from '../buttons/MRT_ToggleDensePaddingButton';
|
4
6
|
import { MRT_ToggleFiltersButton } from '../buttons/MRT_ToggleFiltersButton';
|
5
7
|
import { MRT_ToggleFullScreenButton } from '../buttons/MRT_ToggleFullScreenButton';
|
6
8
|
import { MRT_ToggleGlobalFilterButton } from '../buttons/MRT_ToggleGlobalFilterButton';
|
7
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
8
|
-
import { type MRT_RowData, type MRT_TableInstance } from '../types';
|
9
9
|
|
10
10
|
interface Props<TData extends MRT_RowData> extends BoxProps {
|
11
11
|
table: MRT_TableInstance<TData>;
|
@@ -5,10 +5,10 @@ import { MRT_TablePagination } from './MRT_TablePagination';
|
|
5
5
|
import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
|
6
6
|
import { MRT_ToolbarDropZone } from './MRT_ToolbarDropZone';
|
7
7
|
import { MRT_ToolbarInternalButtons } from './MRT_ToolbarInternalButtons';
|
8
|
-
import {
|
8
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
9
|
+
import { getCommonToolbarStyles } from '../../utils/style.utils';
|
10
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
9
11
|
import { MRT_GlobalFilterTextField } from '../inputs/MRT_GlobalFilterTextField';
|
10
|
-
import { getCommonToolbarStyles } from '../style.utils';
|
11
|
-
import { type MRT_RowData, type MRT_TableInstance } from '../types';
|
12
12
|
|
13
13
|
interface Props<TData extends MRT_RowData> {
|
14
14
|
table: MRT_TableInstance<TData>;
|
@@ -4,7 +4,7 @@ import {
|
|
4
4
|
rankings,
|
5
5
|
} from '@tanstack/match-sorter-utils';
|
6
6
|
import { type Row, filterFns } from '@tanstack/react-table';
|
7
|
-
import { type MRT_RowData } from '
|
7
|
+
import { type MRT_RowData } from '../types';
|
8
8
|
|
9
9
|
const fuzzy = <TData extends MRT_RowData>(
|
10
10
|
row: Row<TData>,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { type RankingInfo, compareItems } from '@tanstack/match-sorter-utils';
|
2
2
|
import { type Row, sortingFns } from '@tanstack/react-table';
|
3
|
-
import { type MRT_Row, type MRT_RowData } from '
|
3
|
+
import { type MRT_Row, type MRT_RowData } from '../types';
|
4
4
|
|
5
5
|
const fuzzy = <TData extends MRT_RowData>(
|
6
6
|
rowA: Row<TData>,
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import {
|
2
|
+
type MRT_ColumnDef,
|
3
|
+
type MRT_RowData,
|
4
|
+
type MRT_StatefulTableOptions,
|
5
|
+
} from '../../types';
|
6
|
+
import { getMRT_RowActionsColumnDef } from './getMRT_RowActionsColumnDef';
|
7
|
+
import { getMRT_RowDragColumnDef } from './getMRT_RowDragColumnDef';
|
8
|
+
import { getMRT_RowExpandColumnDef } from './getMRT_RowExpandColumnDef';
|
9
|
+
import { getMRT_RowNumbersColumnDef } from './getMRT_RowNumbersColumnDef';
|
10
|
+
import { getMRT_RowPinningColumnDef } from './getMRT_RowPinningColumnDef';
|
11
|
+
import { getMRT_RowSelectColumnDef } from './getMRT_RowSelectColumnDef';
|
12
|
+
import { getMRT_RowSpacerColumnDef } from './getMRT_RowSpacerColumnDef';
|
13
|
+
|
14
|
+
export const getMRT_DisplayColumns = <TData extends MRT_RowData>(
|
15
|
+
tableOptions: MRT_StatefulTableOptions<TData>,
|
16
|
+
): MRT_ColumnDef<TData>[] => {
|
17
|
+
return [
|
18
|
+
getMRT_RowNumbersColumnDef(tableOptions),
|
19
|
+
getMRT_RowSelectColumnDef(tableOptions),
|
20
|
+
getMRT_RowExpandColumnDef(tableOptions),
|
21
|
+
getMRT_RowActionsColumnDef(tableOptions),
|
22
|
+
getMRT_RowDragColumnDef(tableOptions),
|
23
|
+
getMRT_RowPinningColumnDef(tableOptions),
|
24
|
+
getMRT_RowSpacerColumnDef(tableOptions),
|
25
|
+
].filter(Boolean) as MRT_ColumnDef<TData>[];
|
26
|
+
};
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import { MRT_ToggleRowActionMenuButton } from '../../components/buttons/MRT_ToggleRowActionMenuButton';
|
2
|
+
import {
|
3
|
+
type MRT_ColumnDef,
|
4
|
+
type MRT_RowData,
|
5
|
+
type MRT_StatefulTableOptions,
|
6
|
+
} from '../../types';
|
7
|
+
import {
|
8
|
+
defaultDisplayColumnProps,
|
9
|
+
showRowActionsColumn,
|
10
|
+
} from '../../utils/displayColumn.utils';
|
11
|
+
|
12
|
+
export const getMRT_RowActionsColumnDef = <TData extends MRT_RowData>(
|
13
|
+
tableOptions: MRT_StatefulTableOptions<TData>,
|
14
|
+
): MRT_ColumnDef<TData> | null => {
|
15
|
+
if (!showRowActionsColumn(tableOptions)) {
|
16
|
+
return null;
|
17
|
+
}
|
18
|
+
|
19
|
+
return {
|
20
|
+
Cell: ({ cell, row, staticRowIndex, table }) => (
|
21
|
+
<MRT_ToggleRowActionMenuButton
|
22
|
+
cell={cell}
|
23
|
+
row={row}
|
24
|
+
staticRowIndex={staticRowIndex}
|
25
|
+
table={table}
|
26
|
+
/>
|
27
|
+
),
|
28
|
+
...defaultDisplayColumnProps({
|
29
|
+
header: 'actions',
|
30
|
+
id: 'mrt-row-actions',
|
31
|
+
tableOptions,
|
32
|
+
}),
|
33
|
+
};
|
34
|
+
};
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { type RefObject } from 'react';
|
2
|
+
import { MRT_TableBodyRowGrabHandle } from '../../components/body/MRT_TableBodyRowGrabHandle';
|
3
|
+
import {
|
4
|
+
type MRT_ColumnDef,
|
5
|
+
type MRT_RowData,
|
6
|
+
type MRT_StatefulTableOptions,
|
7
|
+
} from '../../types';
|
8
|
+
import {
|
9
|
+
defaultDisplayColumnProps,
|
10
|
+
showRowDragColumn,
|
11
|
+
} from '../../utils/displayColumn.utils';
|
12
|
+
|
13
|
+
export const getMRT_RowDragColumnDef = <TData extends MRT_RowData>(
|
14
|
+
tableOptions: MRT_StatefulTableOptions<TData>,
|
15
|
+
): MRT_ColumnDef<TData> | null => {
|
16
|
+
if (!showRowDragColumn(tableOptions)) {
|
17
|
+
return null;
|
18
|
+
}
|
19
|
+
|
20
|
+
return {
|
21
|
+
Cell: ({ row, rowRef, table }) => (
|
22
|
+
<MRT_TableBodyRowGrabHandle
|
23
|
+
row={row}
|
24
|
+
rowRef={rowRef as RefObject<HTMLTableRowElement>}
|
25
|
+
table={table}
|
26
|
+
/>
|
27
|
+
),
|
28
|
+
grow: false,
|
29
|
+
...defaultDisplayColumnProps({
|
30
|
+
header: 'move',
|
31
|
+
id: 'mrt-row-drag',
|
32
|
+
tableOptions,
|
33
|
+
}),
|
34
|
+
};
|
35
|
+
};
|