material-react-table 2.7.0 → 2.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/index.d.ts +253 -99
- package/dist/index.esm.js +3546 -3475
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3567 -3498
- package/dist/index.js.map +1 -1
- package/locales/ja/index.esm.js +4 -4
- package/locales/ja/index.js +4 -4
- package/package.json +25 -23
- package/src/{MaterialReactTable.tsx → components/MaterialReactTable.tsx} +3 -3
- package/src/{body → components/body}/MRT_TableBody.tsx +6 -7
- package/src/{body → components/body}/MRT_TableBodyCell.tsx +16 -26
- package/src/{body → components/body}/MRT_TableBodyCellValue.tsx +2 -2
- package/src/{body → components/body}/MRT_TableBodyRow.tsx +79 -59
- 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 +13 -4
- package/src/{footer → components/footer}/MRT_TableFooterRow.tsx +22 -11
- package/src/{head → components/head}/MRT_TableHead.tsx +3 -3
- package/src/{head → components/head}/MRT_TableHeadCell.tsx +13 -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 +6 -4
- package/src/{head → components/head}/MRT_TableHeadCellSortLabel.tsx +2 -2
- package/src/{head → components/head}/MRT_TableHeadRow.tsx +22 -11
- package/src/{inputs → components/inputs}/MRT_EditCellTextField.tsx +15 -6
- 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 +7 -9
- 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 +8 -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 +3 -3
- 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 +35 -0
- package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +36 -0
- package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +98 -0
- package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +37 -0
- package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +31 -0
- package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +41 -0
- package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +40 -0
- package/src/hooks/useMRT_ColumnVirtualizer.ts +79 -80
- package/src/hooks/useMRT_Effects.ts +1 -1
- package/src/hooks/useMRT_RowVirtualizer.ts +32 -36
- package/src/hooks/useMRT_Rows.ts +2 -2
- package/src/hooks/useMRT_TableInstance.ts +54 -39
- package/src/hooks/useMRT_TableOptions.ts +30 -20
- package/src/{useMaterialReactTable.ts → hooks/useMaterialReactTable.ts} +3 -3
- package/src/index.ts +79 -82
- package/src/locales/ja.ts +4 -4
- package/src/types.ts +57 -26
- package/src/utils/column.utils.ts +173 -0
- package/src/utils/displayColumn.utils.ts +134 -0
- package/src/utils/row.utils.ts +47 -0
- package/src/{style.utils.ts → utils/style.utils.ts} +88 -42
- 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,9 +1,9 @@
|
|
1
1
|
import { type DragEventHandler } from 'react';
|
2
2
|
import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
|
3
3
|
import Tooltip from '@mui/material/Tooltip';
|
4
|
-
import {
|
5
|
-
import { getCommonTooltipProps } from '
|
6
|
-
import {
|
4
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
5
|
+
import { getCommonTooltipProps } from '../../utils/style.utils';
|
6
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
7
7
|
|
8
8
|
interface Props<TData extends MRT_RowData> extends IconButtonProps {
|
9
9
|
iconButtonProps?: IconButtonProps;
|
@@ -2,13 +2,13 @@ import { type MouseEvent, useState } from 'react';
|
|
2
2
|
import { type RowPinningPosition } from '@tanstack/react-table';
|
3
3
|
import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
|
4
4
|
import Tooltip from '@mui/material/Tooltip';
|
5
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
6
|
-
import { getCommonTooltipProps } from '../style.utils';
|
7
5
|
import {
|
8
6
|
type MRT_Row,
|
9
7
|
type MRT_RowData,
|
10
8
|
type MRT_TableInstance,
|
11
|
-
} from '
|
9
|
+
} from '../../types';
|
10
|
+
import { getCommonTooltipProps } from '../../utils/style.utils';
|
11
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
12
12
|
|
13
13
|
interface Props<TData extends MRT_RowData> extends IconButtonProps {
|
14
14
|
pinningPosition: RowPinningPosition;
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { type MouseEvent, useState } from 'react';
|
2
2
|
import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
|
3
3
|
import Tooltip from '@mui/material/Tooltip';
|
4
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
4
5
|
import { MRT_ShowHideColumnsMenu } from '../menus/MRT_ShowHideColumnsMenu';
|
5
|
-
import { type MRT_RowData, type MRT_TableInstance } from '../types';
|
6
6
|
|
7
7
|
interface Props<TData extends MRT_RowData> extends IconButtonProps {
|
8
8
|
table: MRT_TableInstance<TData>;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
|
2
2
|
import Tooltip from '@mui/material/Tooltip';
|
3
|
-
import { type MRT_RowData, type MRT_TableInstance } from '
|
3
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
4
4
|
|
5
5
|
interface Props<TData extends MRT_RowData> extends IconButtonProps {
|
6
6
|
table: MRT_TableInstance<TData>;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
|
2
2
|
import Tooltip from '@mui/material/Tooltip';
|
3
|
-
import { type MRT_RowData, type MRT_TableInstance } from '
|
3
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
4
4
|
|
5
5
|
interface Props<TData extends MRT_RowData> extends IconButtonProps {
|
6
6
|
table: MRT_TableInstance<TData>;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { useState } from 'react';
|
2
2
|
import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
|
3
3
|
import Tooltip from '@mui/material/Tooltip';
|
4
|
-
import { type MRT_RowData, type MRT_TableInstance } from '
|
4
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
5
5
|
|
6
6
|
interface Props<TData extends MRT_RowData> extends IconButtonProps {
|
7
7
|
table: MRT_TableInstance<TData>;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
|
2
2
|
import Tooltip from '@mui/material/Tooltip';
|
3
|
-
import { type MRT_RowData, type MRT_TableInstance } from '
|
3
|
+
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
4
4
|
|
5
5
|
interface Props<TData extends MRT_RowData> extends IconButtonProps {
|
6
6
|
table: MRT_TableInstance<TData>;
|
@@ -2,15 +2,15 @@ import { type MouseEvent, useState } from 'react';
|
|
2
2
|
import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
|
3
3
|
import Tooltip from '@mui/material/Tooltip';
|
4
4
|
import { MRT_EditActionButtons } from './MRT_EditActionButtons';
|
5
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
6
|
-
import { MRT_RowActionMenu } from '../menus/MRT_RowActionMenu';
|
7
|
-
import { getCommonTooltipProps } from '../style.utils';
|
8
5
|
import {
|
9
6
|
type MRT_Cell,
|
10
7
|
type MRT_Row,
|
11
8
|
type MRT_RowData,
|
12
9
|
type MRT_TableInstance,
|
13
|
-
} from '
|
10
|
+
} from '../../types';
|
11
|
+
import { getCommonTooltipProps } from '../../utils/style.utils';
|
12
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
13
|
+
import { MRT_RowActionMenu } from '../menus/MRT_RowActionMenu';
|
14
14
|
|
15
15
|
const commonIconButtonStyles = {
|
16
16
|
'&:hover': {
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import TableFooter, { type TableFooterProps } from '@mui/material/TableFooter';
|
2
2
|
import { MRT_TableFooterRow } from './MRT_TableFooterRow';
|
3
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
4
3
|
import {
|
5
4
|
type MRT_ColumnVirtualizer,
|
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 TableFooterProps {
|
11
11
|
columnVirtualizer?: MRT_ColumnVirtualizer;
|
@@ -1,33 +1,40 @@
|
|
1
1
|
import TableCell, { type TableCellProps } from '@mui/material/TableCell';
|
2
2
|
import { useTheme } from '@mui/material/styles';
|
3
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
4
|
-
import { getCommonMRTCellStyles } from '../style.utils';
|
5
3
|
import {
|
6
4
|
type MRT_Header,
|
7
5
|
type MRT_RowData,
|
8
6
|
type MRT_TableInstance,
|
9
|
-
} from '
|
7
|
+
} from '../../types';
|
8
|
+
import { getCommonMRTCellStyles } from '../../utils/style.utils';
|
9
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
10
10
|
|
11
11
|
interface Props<TData extends MRT_RowData> extends TableCellProps {
|
12
12
|
footer: MRT_Header<TData>;
|
13
|
+
staticColumnIndex?: number;
|
13
14
|
table: MRT_TableInstance<TData>;
|
14
15
|
}
|
15
16
|
|
16
17
|
export const MRT_TableFooterCell = <TData extends MRT_RowData>({
|
17
18
|
footer,
|
19
|
+
staticColumnIndex,
|
18
20
|
table,
|
19
21
|
...rest
|
20
22
|
}: Props<TData>) => {
|
21
23
|
const theme = useTheme();
|
22
24
|
const {
|
23
25
|
getState,
|
24
|
-
options: { layoutMode, muiTableFooterCellProps },
|
26
|
+
options: { enableColumnPinning, layoutMode, muiTableFooterCellProps },
|
25
27
|
} = table;
|
26
28
|
const { density } = getState();
|
27
29
|
const { column } = footer;
|
28
30
|
const { columnDef } = column;
|
29
31
|
const { columnDefType } = columnDef;
|
30
32
|
|
33
|
+
const isColumnPinned =
|
34
|
+
enableColumnPinning &&
|
35
|
+
columnDef.columnDefType !== 'group' &&
|
36
|
+
column.getIsPinned();
|
37
|
+
|
31
38
|
const args = { column, table };
|
32
39
|
const tableCellProps = {
|
33
40
|
...parseFromValuesOrFunc(muiTableFooterCellProps, args),
|
@@ -45,6 +52,8 @@ export const MRT_TableFooterCell = <TData extends MRT_RowData>({
|
|
45
52
|
: 'left'
|
46
53
|
}
|
47
54
|
colSpan={footer.colSpan}
|
55
|
+
data-index={staticColumnIndex}
|
56
|
+
data-pinned={!!isColumnPinned || undefined}
|
48
57
|
variant="footer"
|
49
58
|
{...tableCellProps}
|
50
59
|
sx={(theme) => ({
|
@@ -1,14 +1,15 @@
|
|
1
1
|
import TableRow, { type TableRowProps } from '@mui/material/TableRow';
|
2
2
|
import { MRT_TableFooterCell } from './MRT_TableFooterCell';
|
3
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
4
|
-
import { getMRTTheme } from '../style.utils';
|
5
3
|
import {
|
6
4
|
type MRT_ColumnVirtualizer,
|
7
5
|
type MRT_Header,
|
8
6
|
type MRT_HeaderGroup,
|
9
7
|
type MRT_RowData,
|
10
8
|
type MRT_TableInstance,
|
11
|
-
|
9
|
+
type MRT_VirtualItem,
|
10
|
+
} from '../../types';
|
11
|
+
import { getMRTTheme } from '../../utils/style.utils';
|
12
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
12
13
|
|
13
14
|
interface Props<TData extends MRT_RowData> extends TableRowProps {
|
14
15
|
columnVirtualizer?: MRT_ColumnVirtualizer;
|
@@ -61,15 +62,25 @@ export const MRT_TableFooterRow = <TData extends MRT_RowData>({
|
|
61
62
|
{virtualPaddingLeft ? (
|
62
63
|
<th style={{ display: 'flex', width: virtualPaddingLeft }} />
|
63
64
|
) : null}
|
64
|
-
{(virtualColumns ?? footerGroup.headers).map(
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
{(virtualColumns ?? footerGroup.headers).map(
|
66
|
+
(footerOrVirtualFooter, staticColumnIndex) => {
|
67
|
+
let footer = footerOrVirtualFooter as MRT_Header<TData>;
|
68
|
+
if (columnVirtualizer) {
|
69
|
+
staticColumnIndex = (footerOrVirtualFooter as MRT_VirtualItem)
|
70
|
+
.index;
|
71
|
+
footer = footerGroup.headers[staticColumnIndex];
|
72
|
+
}
|
68
73
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
74
|
+
return footer ? (
|
75
|
+
<MRT_TableFooterCell
|
76
|
+
footer={footer}
|
77
|
+
key={footer.id}
|
78
|
+
staticColumnIndex={staticColumnIndex}
|
79
|
+
table={table}
|
80
|
+
/>
|
81
|
+
) : null;
|
82
|
+
},
|
83
|
+
)}
|
73
84
|
{virtualPaddingRight ? (
|
74
85
|
<th style={{ display: 'flex', width: virtualPaddingRight }} />
|
75
86
|
) : null}
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import TableHead, { type TableHeadProps } from '@mui/material/TableHead';
|
2
2
|
import { MRT_TableHeadRow } from './MRT_TableHeadRow';
|
3
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
4
|
-
import { MRT_ToolbarAlertBanner } from '../toolbar/MRT_ToolbarAlertBanner';
|
5
3
|
import {
|
6
4
|
type MRT_ColumnVirtualizer,
|
7
5
|
type MRT_RowData,
|
8
6
|
type MRT_TableInstance,
|
9
|
-
} from '
|
7
|
+
} from '../../types';
|
8
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
9
|
+
import { MRT_ToolbarAlertBanner } from '../toolbar/MRT_ToolbarAlertBanner';
|
10
10
|
|
11
11
|
interface Props<TData extends MRT_RowData> extends TableHeadProps {
|
12
12
|
columnVirtualizer?: MRT_ColumnVirtualizer;
|
@@ -9,21 +9,23 @@ import { MRT_TableHeadCellFilterLabel } from './MRT_TableHeadCellFilterLabel';
|
|
9
9
|
import { MRT_TableHeadCellGrabHandle } from './MRT_TableHeadCellGrabHandle';
|
10
10
|
import { MRT_TableHeadCellResizeHandle } from './MRT_TableHeadCellResizeHandle';
|
11
11
|
import { MRT_TableHeadCellSortLabel } from './MRT_TableHeadCellSortLabel';
|
12
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
13
|
-
import { getCommonMRTCellStyles, getMRTTheme } from '../style.utils';
|
14
12
|
import {
|
15
13
|
type MRT_Header,
|
16
14
|
type MRT_RowData,
|
17
15
|
type MRT_TableInstance,
|
18
|
-
} from '
|
16
|
+
} from '../../types';
|
17
|
+
import { getCommonMRTCellStyles, getMRTTheme } from '../../utils/style.utils';
|
18
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
19
19
|
|
20
20
|
interface Props<TData extends MRT_RowData> extends TableCellProps {
|
21
21
|
header: MRT_Header<TData>;
|
22
|
+
staticColumnIndex?: number;
|
22
23
|
table: MRT_TableInstance<TData>;
|
23
24
|
}
|
24
25
|
|
25
26
|
export const MRT_TableHeadCell = <TData extends MRT_RowData>({
|
26
27
|
header,
|
28
|
+
staticColumnIndex,
|
27
29
|
table,
|
28
30
|
...rest
|
29
31
|
}: Props<TData>) => {
|
@@ -37,6 +39,7 @@ export const MRT_TableHeadCell = <TData extends MRT_RowData>({
|
|
37
39
|
enableColumnActions,
|
38
40
|
enableColumnDragging,
|
39
41
|
enableColumnOrdering,
|
42
|
+
enableColumnPinning,
|
40
43
|
enableGrouping,
|
41
44
|
enableMultiSort,
|
42
45
|
layoutMode,
|
@@ -68,6 +71,11 @@ export const MRT_TableHeadCell = <TData extends MRT_RowData>({
|
|
68
71
|
|
69
72
|
const { draggingBorderColor } = getMRTTheme(table, theme);
|
70
73
|
|
74
|
+
const isColumnPinned =
|
75
|
+
enableColumnPinning &&
|
76
|
+
columnDef.columnDefType !== 'group' &&
|
77
|
+
column.getIsPinned();
|
78
|
+
|
71
79
|
const showColumnActions =
|
72
80
|
(enableColumnActions || columnDef.enableColumnActions) &&
|
73
81
|
columnDef.enableColumnActions !== false;
|
@@ -147,6 +155,8 @@ export const MRT_TableHeadCell = <TData extends MRT_RowData>({
|
|
147
155
|
: 'left'
|
148
156
|
}
|
149
157
|
colSpan={header.colSpan}
|
158
|
+
data-index={staticColumnIndex}
|
159
|
+
data-pinned={!!isColumnPinned || undefined}
|
150
160
|
onDragEnter={handleDragEnter}
|
151
161
|
ref={(node: HTMLTableCellElement) => {
|
152
162
|
if (node) {
|
@@ -1,14 +1,14 @@
|
|
1
1
|
import { type MouseEvent, useState } from 'react';
|
2
2
|
import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
|
3
3
|
import Tooltip from '@mui/material/Tooltip';
|
4
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
5
|
-
import { MRT_ColumnActionMenu } from '../menus/MRT_ColumnActionMenu';
|
6
|
-
import { getCommonTooltipProps } from '../style.utils';
|
7
4
|
import {
|
8
5
|
type MRT_Header,
|
9
6
|
type MRT_RowData,
|
10
7
|
type MRT_TableInstance,
|
11
|
-
} from '
|
8
|
+
} from '../../types';
|
9
|
+
import { getCommonTooltipProps } from '../../utils/style.utils';
|
10
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
11
|
+
import { MRT_ColumnActionMenu } from '../menus/MRT_ColumnActionMenu';
|
12
12
|
|
13
13
|
interface Props<TData extends MRT_RowData> extends IconButtonProps {
|
14
14
|
header: MRT_Header<TData>;
|
@@ -1,13 +1,13 @@
|
|
1
1
|
import Collapse, { type CollapseProps } from '@mui/material/Collapse';
|
2
|
-
import { MRT_FilterCheckbox } from '../inputs/MRT_FilterCheckbox';
|
3
|
-
import { MRT_FilterRangeFields } from '../inputs/MRT_FilterRangeFields';
|
4
|
-
import { MRT_FilterRangeSlider } from '../inputs/MRT_FilterRangeSlider';
|
5
|
-
import { MRT_FilterTextField } from '../inputs/MRT_FilterTextField';
|
6
2
|
import {
|
7
3
|
type MRT_Header,
|
8
4
|
type MRT_RowData,
|
9
5
|
type MRT_TableInstance,
|
10
|
-
} from '
|
6
|
+
} from '../../types';
|
7
|
+
import { MRT_FilterCheckbox } from '../inputs/MRT_FilterCheckbox';
|
8
|
+
import { MRT_FilterRangeFields } from '../inputs/MRT_FilterRangeFields';
|
9
|
+
import { MRT_FilterRangeSlider } from '../inputs/MRT_FilterRangeSlider';
|
10
|
+
import { MRT_FilterTextField } from '../inputs/MRT_FilterTextField';
|
11
11
|
|
12
12
|
interface Props<TData extends MRT_RowData> extends CollapseProps {
|
13
13
|
header: MRT_Header<TData>;
|
@@ -5,12 +5,12 @@ import IconButton, { type IconButtonProps } from '@mui/material/IconButton';
|
|
5
5
|
import Popover from '@mui/material/Popover';
|
6
6
|
import Tooltip from '@mui/material/Tooltip';
|
7
7
|
import { MRT_TableHeadCellFilterContainer } from './MRT_TableHeadCellFilterContainer';
|
8
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
9
8
|
import {
|
10
9
|
type MRT_Header,
|
11
10
|
type MRT_RowData,
|
12
11
|
type MRT_TableInstance,
|
13
|
-
} from '
|
12
|
+
} from '../../types';
|
13
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
14
14
|
|
15
15
|
interface Props<TData extends MRT_RowData> extends IconButtonProps {
|
16
16
|
header: MRT_Header<TData>;
|
@@ -1,12 +1,13 @@
|
|
1
1
|
import { type DragEvent, type RefObject } from 'react';
|
2
2
|
import { type IconButtonProps } from '@mui/material/IconButton';
|
3
|
-
import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton';
|
4
|
-
import { parseFromValuesOrFunc, reorderColumn } from '../column.utils';
|
5
3
|
import {
|
6
4
|
type MRT_Column,
|
7
5
|
type MRT_RowData,
|
8
6
|
type MRT_TableInstance,
|
9
|
-
} from '
|
7
|
+
} from '../../types';
|
8
|
+
import { reorderColumn } from '../../utils/column.utils';
|
9
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
10
|
+
import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton';
|
10
11
|
|
11
12
|
interface Props<TData extends MRT_RowData> extends IconButtonProps {
|
12
13
|
column: MRT_Column<TData>;
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import Box from '@mui/material/Box';
|
2
2
|
import Divider, { type DividerProps } from '@mui/material/Divider';
|
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 DividerProps {
|
11
11
|
header: MRT_Header<TData>;
|
@@ -25,6 +25,8 @@ export const MRT_TableHeadCellResizeHandle = <TData extends MRT_RowData>({
|
|
25
25
|
const { density } = getState();
|
26
26
|
const { column } = header;
|
27
27
|
|
28
|
+
const handler = header.getResizeHandler();
|
29
|
+
|
28
30
|
const mx =
|
29
31
|
density === 'compact'
|
30
32
|
? '-8px'
|
@@ -44,8 +46,8 @@ export const MRT_TableHeadCellResizeHandle = <TData extends MRT_RowData>({
|
|
44
46
|
}));
|
45
47
|
column.resetSize();
|
46
48
|
}}
|
47
|
-
onMouseDown={
|
48
|
-
onTouchStart={
|
49
|
+
onMouseDown={handler}
|
50
|
+
onTouchStart={handler}
|
49
51
|
style={{
|
50
52
|
transform:
|
51
53
|
column.getIsResizing() && columnResizeMode === 'onEnd'
|
@@ -3,12 +3,12 @@ import TableSortLabel, {
|
|
3
3
|
type TableSortLabelProps,
|
4
4
|
} from '@mui/material/TableSortLabel';
|
5
5
|
import Tooltip from '@mui/material/Tooltip';
|
6
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
7
6
|
import {
|
8
7
|
type MRT_Header,
|
9
8
|
type MRT_RowData,
|
10
9
|
type MRT_TableInstance,
|
11
|
-
} from '
|
10
|
+
} from '../../types';
|
11
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
12
12
|
|
13
13
|
interface Props<TData extends MRT_RowData> extends TableSortLabelProps {
|
14
14
|
header: MRT_Header<TData>;
|
@@ -1,15 +1,16 @@
|
|
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
|
-
|
10
|
+
type MRT_VirtualItem,
|
11
|
+
} from '../../types';
|
12
|
+
import { getMRTTheme } from '../../utils/style.utils';
|
13
|
+
import { parseFromValuesOrFunc } from '../../utils/utils';
|
13
14
|
|
14
15
|
interface Props<TData extends MRT_RowData> extends TableRowProps {
|
15
16
|
columnVirtualizer?: MRT_ColumnVirtualizer;
|
@@ -52,15 +53,25 @@ export const MRT_TableHeadRow = <TData extends MRT_RowData>({
|
|
52
53
|
{virtualPaddingLeft ? (
|
53
54
|
<th style={{ display: 'flex', width: virtualPaddingLeft }} />
|
54
55
|
) : null}
|
55
|
-
{(virtualColumns ?? headerGroup.headers).map(
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
{(virtualColumns ?? headerGroup.headers).map(
|
57
|
+
(headerOrVirtualHeader, staticColumnIndex) => {
|
58
|
+
let header = headerOrVirtualHeader as MRT_Header<TData>;
|
59
|
+
if (columnVirtualizer) {
|
60
|
+
staticColumnIndex = (headerOrVirtualHeader as MRT_VirtualItem)
|
61
|
+
.index;
|
62
|
+
header = headerGroup.headers[staticColumnIndex];
|
63
|
+
}
|
59
64
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
65
|
+
return header ? (
|
66
|
+
<MRT_TableHeadCell
|
67
|
+
header={header}
|
68
|
+
key={header.id}
|
69
|
+
staticColumnIndex={staticColumnIndex}
|
70
|
+
table={table}
|
71
|
+
/>
|
72
|
+
) : null;
|
73
|
+
},
|
74
|
+
)}
|
64
75
|
{virtualPaddingRight ? (
|
65
76
|
<th style={{ display: 'flex', width: virtualPaddingRight }} />
|
66
77
|
) : null}
|
@@ -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,10 +35,10 @@ 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, editVariant } = columnDef;
|
38
39
|
|
39
40
|
const isCreating = creatingRow?.id === row.id;
|
40
41
|
const isEditing = editingRow?.id === row.id;
|
41
|
-
const isSelectEdit = columnDef.editVariant === 'select';
|
42
42
|
|
43
43
|
const [value, setValue] = useState(() => cell.getValue<string>());
|
44
44
|
|
@@ -58,6 +58,15 @@ export const MRT_EditCellTextField = <TData extends MRT_RowData>({
|
|
58
58
|
...rest,
|
59
59
|
};
|
60
60
|
|
61
|
+
const selectOptions = parseFromValuesOrFunc(editSelectOptions, {
|
62
|
+
cell,
|
63
|
+
column,
|
64
|
+
row,
|
65
|
+
table,
|
66
|
+
});
|
67
|
+
|
68
|
+
const isSelectEdit = editVariant === 'select' || textFieldProps?.select;
|
69
|
+
|
61
70
|
const saveInputValueToRowCache = (newValue: string) => {
|
62
71
|
//@ts-ignore
|
63
72
|
row._valuesCache[column.id] = newValue;
|
@@ -71,7 +80,7 @@ export const MRT_EditCellTextField = <TData extends MRT_RowData>({
|
|
71
80
|
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
72
81
|
textFieldProps.onChange?.(event);
|
73
82
|
setValue(event.target.value);
|
74
|
-
if (
|
83
|
+
if (isSelectEdit) {
|
75
84
|
saveInputValueToRowCache(event.target.value);
|
76
85
|
}
|
77
86
|
};
|
@@ -123,7 +132,7 @@ export const MRT_EditCellTextField = <TData extends MRT_RowData>({
|
|
123
132
|
}
|
124
133
|
select={isSelectEdit}
|
125
134
|
size="small"
|
126
|
-
value={value}
|
135
|
+
value={value ?? ''}
|
127
136
|
variant="standard"
|
128
137
|
{...textFieldProps}
|
129
138
|
InputProps={{
|
@@ -152,7 +161,7 @@ export const MRT_EditCellTextField = <TData extends MRT_RowData>({
|
|
152
161
|
onKeyDown={handleEnterKeyDown}
|
153
162
|
>
|
154
163
|
{textFieldProps.children ??
|
155
|
-
|
164
|
+
selectOptions?.map((option) => {
|
156
165
|
const { label, value } = getValueAndLabel(option);
|
157
166
|
return (
|
158
167
|
<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>;
|