material-react-table 0.7.0-alpha.7 → 0.7.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/README.md +3 -5
- package/dist/MaterialReactTable.d.ts +42 -23
- package/dist/buttons/{MRT_ToggleSearchButton.d.ts → MRT_ToggleGlobalFilterButton.d.ts} +1 -1
- package/dist/localization.d.ts +3 -0
- package/dist/material-react-table.cjs.development.js +142 -108
- package/dist/material-react-table.cjs.development.js.map +1 -1
- package/dist/material-react-table.cjs.production.min.js +1 -1
- package/dist/material-react-table.cjs.production.min.js.map +1 -1
- package/dist/material-react-table.esm.js +144 -110
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +5 -5
- package/src/MaterialReactTable.tsx +69 -33
- package/src/body/MRT_TableBodyCell.tsx +7 -5
- package/src/buttons/MRT_EditActionButtons.tsx +1 -1
- package/src/buttons/MRT_FullScreenToggleButton.tsx +13 -4
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +0 -1
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +13 -4
- package/src/buttons/MRT_ToggleFiltersButton.tsx +13 -4
- package/src/buttons/{MRT_ToggleSearchButton.tsx → MRT_ToggleGlobalFilterButton.tsx} +14 -8
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +1 -1
- package/src/head/MRT_TableHeadCell.tsx +7 -8
- package/src/inputs/MRT_EditCellTextField.tsx +2 -5
- package/src/inputs/MRT_FilterTextField.tsx +2 -2
- package/src/inputs/MRT_SearchTextField.tsx +6 -6
- package/src/localization.ts +6 -0
- package/src/menus/MRT_ColumnActionMenu.tsx +4 -4
- package/src/menus/MRT_FilterTypeMenu.tsx +3 -6
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +2 -2
- package/src/table/MRT_TableContainer.tsx +4 -4
- package/src/table/MRT_TableRoot.tsx +60 -56
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +8 -9
package/dist/utils.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ export declare const createGroup: <D extends Record<string, any> = {}>(table: Ta
|
|
|
7
7
|
export declare const createDataColumn: <D extends Record<string, any> = {}>(table: Table<D>, column: MRT_ColumnInterface<D>, currentFilterTypes: {
|
|
8
8
|
[key: string]: MRT_FilterType;
|
|
9
9
|
}) => ColumnDef<D>;
|
|
10
|
-
export declare const createDisplayColumn: <D extends Record<string, any> = {}>(table: Table<D>, column: Pick<MRT_ColumnInterface<D>, "footer" | "columns" | "id" | "accessorKey" | "accessorFn" | "cell" | "meta" | "enableHiding" | "defaultCanHide" | "defaultIsVisible" | "enablePinning" | "defaultCanPin" | "filterType" | "enableAllFilters" | "enableColumnFilter" | "enableGlobalFilter" | "defaultCanFilter" | "defaultCanColumnFilter" | "defaultCanGlobalFilter" | "sortType" | "sortDescFirst" | "enableSorting" | "enableMultiSort" | "defaultCanSort" | "invertSorting" | "sortUndefined" | "aggregationType" | "aggregateValue" | "aggregatedCell" | "enableGrouping" | "defaultCanGroup" | "enableResizing" | "defaultCanResize" | "width" | "minWidth" | "maxWidth" | "Edit" | "Filter" | "Footer" | "Header" | "Cell" | "enableClickToCopy" | "enableColumnActions" | "enableEditing" | "enabledFilterTypes" | "filter" | "filterSelectOptions" | "muiTableBodyCellCopyButtonProps" | "muiTableBodyCellEditTextFieldProps" | "muiTableBodyCellProps" | "muiTableFooterCellProps" | "muiTableHeadCellColumnActionsButtonProps" | "muiTableHeadCellFilterTextFieldProps" | "muiTableHeadCellProps" | "onCellEditChange" | "onColumnFilterValueChange"> & {
|
|
10
|
+
export declare const createDisplayColumn: <D extends Record<string, any> = {}>(table: Table<D>, column: Pick<MRT_ColumnInterface<D>, "footer" | "columns" | "id" | "accessorKey" | "accessorFn" | "cell" | "meta" | "enableHiding" | "defaultCanHide" | "defaultIsVisible" | "enablePinning" | "defaultCanPin" | "filterType" | "enableAllFilters" | "enableColumnFilter" | "enableGlobalFilter" | "defaultCanFilter" | "defaultCanColumnFilter" | "defaultCanGlobalFilter" | "sortType" | "sortDescFirst" | "enableSorting" | "enableMultiSort" | "defaultCanSort" | "invertSorting" | "sortUndefined" | "aggregationType" | "aggregateValue" | "aggregatedCell" | "enableGrouping" | "defaultCanGroup" | "enableResizing" | "defaultCanResize" | "width" | "minWidth" | "maxWidth" | "Edit" | "Filter" | "Footer" | "Header" | "Cell" | "enableClickToCopy" | "enableColumnActions" | "enableEditing" | "enabledFilterTypes" | "filter" | "filterSelectOptions" | "muiTableBodyCellCopyButtonProps" | "muiTableBodyCellEditTextFieldProps" | "muiTableBodyCellProps" | "muiTableFooterCellProps" | "muiTableHeadCellColumnActionsButtonProps" | "muiTableHeadCellFilterTextFieldProps" | "muiTableHeadCellProps" | "onCellEditBlur" | "onCellEditChange" | "onColumnFilterValueChange"> & {
|
|
11
11
|
header?: string | undefined;
|
|
12
12
|
}) => ColumnDef<D>;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.7.0
|
|
2
|
+
"version": "0.7.0",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "material-react-table",
|
|
5
5
|
"description": "A fully featured Material UI implementation of react-table, inspired by material-table and the MUI X DataGrid, written from the ground up in TypeScript.",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"@emotion/styled": "^11.8.1",
|
|
61
61
|
"@etchteam/storybook-addon-status": "^4.2.1",
|
|
62
62
|
"@faker-js/faker": "^6.1.2",
|
|
63
|
-
"@mui/icons-material": "^5.6.
|
|
64
|
-
"@mui/material": "^5.6.
|
|
63
|
+
"@mui/icons-material": "^5.6.2",
|
|
64
|
+
"@mui/material": "^5.6.2",
|
|
65
65
|
"@size-limit/preset-small-lib": "^7.0.8",
|
|
66
66
|
"@storybook/addon-a11y": "^6.4.22",
|
|
67
67
|
"@storybook/addon-actions": "^6.4.22",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@storybook/react": "^6.4.22",
|
|
75
75
|
"@types/react": "^17.0.41",
|
|
76
76
|
"@types/react-dom": "^17.0.14",
|
|
77
|
-
"babel-loader": "^8.2.
|
|
77
|
+
"babel-loader": "^8.2.5",
|
|
78
78
|
"eslint": "^8.13.0",
|
|
79
79
|
"eslint-plugin-react-hooks": "^4.4.0",
|
|
80
80
|
"husky": "^7.0.4",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"react": ">=16.8"
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
|
-
"@tanstack/react-table": "^8.0.0-alpha.
|
|
100
|
+
"@tanstack/react-table": "^8.0.0-alpha.43",
|
|
101
101
|
"match-sorter": "^6.3.1"
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -47,11 +47,6 @@ import { MRT_Default_Icons, MRT_Icons } from './icons';
|
|
|
47
47
|
import { MRT_FILTER_TYPE } from './enums';
|
|
48
48
|
import { MRT_TableRoot } from './table/MRT_TableRoot';
|
|
49
49
|
|
|
50
|
-
//@ts-ignore
|
|
51
|
-
global.performance = global.performance || {
|
|
52
|
-
now: () => new Date().getTime(),
|
|
53
|
-
};
|
|
54
|
-
|
|
55
50
|
export type MRT_TableOptions<D extends Record<string, any> = {}> = Partial<
|
|
56
51
|
Omit<
|
|
57
52
|
Options<D>,
|
|
@@ -103,18 +98,18 @@ export type MRT_TableInstance<D extends Record<string, any> = {}> = Omit<
|
|
|
103
98
|
idPrefix: string;
|
|
104
99
|
filterTypes: { [key in MRT_FILTER_TYPE]: any };
|
|
105
100
|
localization: MRT_Localization;
|
|
106
|
-
setCurrentEditingRow: Dispatch<SetStateAction<MRT_Row<D> | null>>;
|
|
107
|
-
setCurrentFilterTypes: Dispatch<
|
|
108
|
-
SetStateAction<{
|
|
109
|
-
[key: string]: MRT_FilterType;
|
|
110
|
-
}>
|
|
111
|
-
>;
|
|
112
|
-
setCurrentGlobalFilterType: Dispatch<SetStateAction<MRT_FILTER_TYPE>>;
|
|
113
|
-
setIsDensePadding: Dispatch<SetStateAction<boolean>>;
|
|
114
|
-
setIsFullScreen: Dispatch<SetStateAction<boolean>>;
|
|
115
|
-
setShowFilters: Dispatch<SetStateAction<boolean>>;
|
|
116
|
-
setShowSearch: Dispatch<SetStateAction<boolean>>;
|
|
117
101
|
};
|
|
102
|
+
setCurrentEditingRow: Dispatch<SetStateAction<MRT_Row<D> | null>>;
|
|
103
|
+
setCurrentFilterTypes: Dispatch<
|
|
104
|
+
SetStateAction<{
|
|
105
|
+
[key: string]: MRT_FilterType;
|
|
106
|
+
}>
|
|
107
|
+
>;
|
|
108
|
+
setCurrentGlobalFilterType: Dispatch<SetStateAction<MRT_FILTER_TYPE>>;
|
|
109
|
+
setIsDensePadding: Dispatch<SetStateAction<boolean>>;
|
|
110
|
+
setIsFullScreen: Dispatch<SetStateAction<boolean>>;
|
|
111
|
+
setShowFilters: Dispatch<SetStateAction<boolean>>;
|
|
112
|
+
setShowGlobalFilter: Dispatch<SetStateAction<boolean>>;
|
|
118
113
|
};
|
|
119
114
|
|
|
120
115
|
export type MRT_TableState<D extends Record<string, any> = {}> = Omit<
|
|
@@ -127,7 +122,7 @@ export type MRT_TableState<D extends Record<string, any> = {}> = Omit<
|
|
|
127
122
|
isDensePadding: boolean;
|
|
128
123
|
isFullScreen: boolean;
|
|
129
124
|
showFilters: boolean;
|
|
130
|
-
|
|
125
|
+
showGlobalFilter: boolean;
|
|
131
126
|
pagination: Partial<PaginationState>;
|
|
132
127
|
};
|
|
133
128
|
|
|
@@ -329,16 +324,15 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
329
324
|
MRT_TableOptions<D> & {
|
|
330
325
|
enableClickToCopy?: boolean;
|
|
331
326
|
enableColumnActions?: boolean;
|
|
332
|
-
enableColumnPinning?: boolean;
|
|
333
327
|
enableDensePaddingToggle?: boolean;
|
|
328
|
+
enableEditing?: boolean;
|
|
334
329
|
enableExpandAll?: boolean;
|
|
335
330
|
enableFullScreenToggle?: boolean;
|
|
336
331
|
enablePagination?: boolean;
|
|
337
332
|
enableRowActions?: boolean;
|
|
338
|
-
enableStickyHeader?: boolean;
|
|
339
|
-
enableEditing?: boolean;
|
|
340
333
|
enableRowNumbers?: boolean;
|
|
341
334
|
enableSelectAll?: boolean;
|
|
335
|
+
enableStickyHeader?: boolean;
|
|
342
336
|
enabledGlobalFilterTypes?: (MRT_FILTER_TYPE | string)[];
|
|
343
337
|
filterTypes?: { [key in MRT_FILTER_TYPE]: any };
|
|
344
338
|
hideTableFooter?: boolean;
|
|
@@ -348,8 +342,8 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
348
342
|
hideToolbarTop?: boolean;
|
|
349
343
|
icons?: Partial<MRT_Icons>;
|
|
350
344
|
idPrefix?: string;
|
|
351
|
-
isReloading?: boolean;
|
|
352
345
|
isLoading?: boolean;
|
|
346
|
+
isReloading?: boolean;
|
|
353
347
|
localization?: Partial<MRT_Localization>;
|
|
354
348
|
muiLinearProgressProps?:
|
|
355
349
|
| LinearProgressProps
|
|
@@ -563,15 +557,6 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
563
557
|
tableInstance: MRT_TableInstance<D>;
|
|
564
558
|
event: MouseEvent<HTMLTableCellElement>;
|
|
565
559
|
}) => void;
|
|
566
|
-
onColumnHide?: ({
|
|
567
|
-
column,
|
|
568
|
-
columnVisibility,
|
|
569
|
-
tableInstance,
|
|
570
|
-
}: {
|
|
571
|
-
column: MRT_ColumnInstance<D>;
|
|
572
|
-
columnVisibility: VisibilityState;
|
|
573
|
-
tableInstance: MRT_TableInstance<D>;
|
|
574
|
-
}) => void;
|
|
575
560
|
onDetailPanelClick?: ({
|
|
576
561
|
event,
|
|
577
562
|
row,
|
|
@@ -581,7 +566,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
581
566
|
row: MRT_Row<D>;
|
|
582
567
|
tableInstance: MRT_TableInstance<D>;
|
|
583
568
|
}) => void;
|
|
584
|
-
|
|
569
|
+
onGlobalSearchFilterChange?: ({
|
|
585
570
|
event,
|
|
586
571
|
tableInstance,
|
|
587
572
|
}: {
|
|
@@ -632,6 +617,51 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
632
617
|
selectedRows: MRT_Row<D>[];
|
|
633
618
|
tableInstance: MRT_TableInstance<D>;
|
|
634
619
|
}) => void;
|
|
620
|
+
onToggleColumnVisibility?: ({
|
|
621
|
+
column,
|
|
622
|
+
columnVisibility,
|
|
623
|
+
tableInstance,
|
|
624
|
+
}: {
|
|
625
|
+
column: MRT_ColumnInstance<D>;
|
|
626
|
+
columnVisibility: VisibilityState;
|
|
627
|
+
tableInstance: MRT_TableInstance<D>;
|
|
628
|
+
}) => void;
|
|
629
|
+
onToggleDensePadding?: ({
|
|
630
|
+
event,
|
|
631
|
+
isDensePadding,
|
|
632
|
+
tableInstance,
|
|
633
|
+
}: {
|
|
634
|
+
event: MouseEvent<HTMLButtonElement>;
|
|
635
|
+
isDensePadding: boolean;
|
|
636
|
+
tableInstance: MRT_TableInstance<D>;
|
|
637
|
+
}) => void;
|
|
638
|
+
onToggleFullScreen?: ({
|
|
639
|
+
event,
|
|
640
|
+
isFullScreen,
|
|
641
|
+
tableInstance,
|
|
642
|
+
}: {
|
|
643
|
+
event: MouseEvent<HTMLButtonElement>;
|
|
644
|
+
isFullScreen: boolean;
|
|
645
|
+
tableInstance: MRT_TableInstance<D>;
|
|
646
|
+
}) => void;
|
|
647
|
+
onToggleShowFilters?: ({
|
|
648
|
+
event,
|
|
649
|
+
showFilters,
|
|
650
|
+
tableInstance,
|
|
651
|
+
}: {
|
|
652
|
+
event: MouseEvent<HTMLButtonElement>;
|
|
653
|
+
showFilters: boolean;
|
|
654
|
+
tableInstance: MRT_TableInstance<D>;
|
|
655
|
+
}) => void;
|
|
656
|
+
onToggleShowGlobalFilter?: ({
|
|
657
|
+
event,
|
|
658
|
+
showGlobalFilter,
|
|
659
|
+
tableInstance,
|
|
660
|
+
}: {
|
|
661
|
+
event: MouseEvent<HTMLButtonElement>;
|
|
662
|
+
showGlobalFilter: boolean;
|
|
663
|
+
tableInstance: MRT_TableInstance<D>;
|
|
664
|
+
}) => void;
|
|
635
665
|
positionActionsColumn?: 'first' | 'last';
|
|
636
666
|
positionPagination?: 'bottom' | 'top' | 'both';
|
|
637
667
|
positionToolbarActions?: 'bottom' | 'top';
|
|
@@ -666,14 +696,14 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
666
696
|
}) => ReactNode;
|
|
667
697
|
renderToolbarInternalActions?: ({
|
|
668
698
|
tableInstance,
|
|
669
|
-
|
|
699
|
+
MRT_ToggleGlobalFilterButton,
|
|
670
700
|
MRT_ToggleFiltersButton,
|
|
671
701
|
MRT_ShowHideColumnsButton,
|
|
672
702
|
MRT_ToggleDensePaddingButton,
|
|
673
703
|
MRT_FullScreenToggleButton,
|
|
674
704
|
}: {
|
|
675
705
|
tableInstance: MRT_TableInstance<D>;
|
|
676
|
-
|
|
706
|
+
MRT_ToggleGlobalFilterButton: FC<
|
|
677
707
|
IconButtonProps & { tableInstance: MRT_TableInstance<D> }
|
|
678
708
|
>;
|
|
679
709
|
MRT_ToggleFiltersButton: FC<
|
|
@@ -692,13 +722,16 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
692
722
|
};
|
|
693
723
|
|
|
694
724
|
export default <D extends Record<string, any> = {}>({
|
|
725
|
+
autoResetExpanded = false,
|
|
695
726
|
enableColumnActions = true,
|
|
696
727
|
enableColumnFilters = true,
|
|
697
728
|
enableDensePaddingToggle = true,
|
|
698
729
|
enableExpandAll = true,
|
|
730
|
+
enableFilters = true,
|
|
699
731
|
enableFullScreenToggle = true,
|
|
700
732
|
enableGlobalFilter = true,
|
|
701
733
|
enableHiding = true,
|
|
734
|
+
enableMultiRowSelection = true,
|
|
702
735
|
enablePagination = true,
|
|
703
736
|
enableSelectAll = true,
|
|
704
737
|
enableSorting = true,
|
|
@@ -712,13 +745,16 @@ export default <D extends Record<string, any> = {}>({
|
|
|
712
745
|
...rest
|
|
713
746
|
}: MaterialReactTableProps<D>) => (
|
|
714
747
|
<MRT_TableRoot
|
|
748
|
+
autoResetExpanded={autoResetExpanded}
|
|
715
749
|
enableColumnActions={enableColumnActions}
|
|
716
750
|
enableColumnFilters={enableColumnFilters}
|
|
717
751
|
enableDensePaddingToggle={enableDensePaddingToggle}
|
|
718
752
|
enableExpandAll={enableExpandAll}
|
|
753
|
+
enableFilters={enableFilters}
|
|
719
754
|
enableFullScreenToggle={enableFullScreenToggle}
|
|
720
755
|
enableGlobalFilter={enableGlobalFilter}
|
|
721
756
|
enableHiding={enableHiding}
|
|
757
|
+
enableMultiRowSelection={enableMultiRowSelection}
|
|
722
758
|
enablePagination={enablePagination}
|
|
723
759
|
enableSelectAll={enableSelectAll}
|
|
724
760
|
enableSorting={enableSorting}
|
|
@@ -15,7 +15,7 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell, tableInstance }) => {
|
|
|
15
15
|
getState,
|
|
16
16
|
options: {
|
|
17
17
|
enableClickToCopy,
|
|
18
|
-
|
|
18
|
+
enablePinning,
|
|
19
19
|
enableEditing,
|
|
20
20
|
isLoading,
|
|
21
21
|
muiTableBodyCellProps,
|
|
@@ -73,7 +73,7 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell, tableInstance }) => {
|
|
|
73
73
|
: undefined,
|
|
74
74
|
transition: 'all 0.2s ease-in-out',
|
|
75
75
|
whiteSpace:
|
|
76
|
-
isDensePadding || (
|
|
76
|
+
isDensePadding || (enablePinning && getIsSomeColumnsPinned())
|
|
77
77
|
? 'nowrap'
|
|
78
78
|
: 'normal',
|
|
79
79
|
//@ts-ignore
|
|
@@ -94,19 +94,21 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell, tableInstance }) => {
|
|
|
94
94
|
column.id !==
|
|
95
95
|
row.groupingColumnId) ? null : cell.getIsAggregated() ? (
|
|
96
96
|
cell.renderAggregatedCell()
|
|
97
|
-
) :
|
|
97
|
+
) : enableEditing &&
|
|
98
|
+
column.enableEditing !== false &&
|
|
99
|
+
currentEditingRow?.id === row.id ? (
|
|
98
100
|
<MRT_EditCellTextField cell={cell} tableInstance={tableInstance} />
|
|
99
101
|
) : (enableClickToCopy || column.enableClickToCopy) &&
|
|
100
102
|
column.enableClickToCopy !== false ? (
|
|
101
103
|
<>
|
|
102
104
|
<MRT_CopyButton cell={cell} tableInstance={tableInstance}>
|
|
103
|
-
{cell.renderCell()}
|
|
105
|
+
{cell.column?.Cell?.({ cell, tableInstance }) ?? cell.renderCell()}
|
|
104
106
|
</MRT_CopyButton>
|
|
105
107
|
{row.getIsGrouped() && <> ({row.subRows?.length})</>}
|
|
106
108
|
</>
|
|
107
109
|
) : (
|
|
108
110
|
<>
|
|
109
|
-
{cell.renderCell()}
|
|
111
|
+
{cell.column?.Cell?.({ cell, tableInstance }) ?? cell.renderCell()}
|
|
110
112
|
{row.getIsGrouped() && <> ({row.subRows?.length})</>}
|
|
111
113
|
</>
|
|
112
114
|
)}
|
|
@@ -15,8 +15,8 @@ export const MRT_EditActionButtons: FC<Props> = ({ row, tableInstance }) => {
|
|
|
15
15
|
icons: { CancelIcon, SaveIcon },
|
|
16
16
|
localization,
|
|
17
17
|
onEditSubmit,
|
|
18
|
-
setCurrentEditingRow,
|
|
19
18
|
},
|
|
19
|
+
setCurrentEditingRow,
|
|
20
20
|
} = tableInstance;
|
|
21
21
|
|
|
22
22
|
const { currentEditingRow } = getState();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { FC, MouseEvent } from 'react';
|
|
2
2
|
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
@@ -15,18 +15,27 @@ export const MRT_FullScreenToggleButton: FC<Props> = ({
|
|
|
15
15
|
options: {
|
|
16
16
|
icons: { FullscreenExitIcon, FullscreenIcon },
|
|
17
17
|
localization,
|
|
18
|
-
|
|
18
|
+
onToggleFullScreen,
|
|
19
19
|
},
|
|
20
|
+
setIsFullScreen,
|
|
20
21
|
} = tableInstance;
|
|
21
22
|
|
|
22
23
|
const { isFullScreen } = getState();
|
|
23
24
|
|
|
25
|
+
const handleToggleFullScreen = (event: MouseEvent<HTMLButtonElement>) => {
|
|
26
|
+
onToggleFullScreen?.({
|
|
27
|
+
event,
|
|
28
|
+
isFullScreen: !isFullScreen,
|
|
29
|
+
tableInstance,
|
|
30
|
+
});
|
|
31
|
+
setIsFullScreen(!isFullScreen);
|
|
32
|
+
};
|
|
33
|
+
|
|
24
34
|
return (
|
|
25
35
|
<Tooltip arrow title={localization.toggleFullScreen}>
|
|
26
36
|
<IconButton
|
|
27
37
|
aria-label={localization.showHideFilters}
|
|
28
|
-
onClick={
|
|
29
|
-
size="small"
|
|
38
|
+
onClick={handleToggleFullScreen}
|
|
30
39
|
{...rest}
|
|
31
40
|
>
|
|
32
41
|
{isFullScreen ? <FullscreenExitIcon /> : <FullscreenIcon />}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { FC, MouseEvent } from 'react';
|
|
2
2
|
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
@@ -15,18 +15,27 @@ export const MRT_ToggleDensePaddingButton: FC<Props> = ({
|
|
|
15
15
|
options: {
|
|
16
16
|
icons: { DensityMediumIcon, DensitySmallIcon },
|
|
17
17
|
localization,
|
|
18
|
-
|
|
18
|
+
onToggleDensePadding,
|
|
19
19
|
},
|
|
20
|
+
setIsDensePadding,
|
|
20
21
|
} = tableInstance;
|
|
21
22
|
|
|
22
23
|
const { isDensePadding } = getState();
|
|
23
24
|
|
|
25
|
+
const handleToggleDensePadding = (event: MouseEvent<HTMLButtonElement>) => {
|
|
26
|
+
onToggleDensePadding?.({
|
|
27
|
+
event,
|
|
28
|
+
isDensePadding: !isDensePadding,
|
|
29
|
+
tableInstance,
|
|
30
|
+
});
|
|
31
|
+
setIsDensePadding(!isDensePadding);
|
|
32
|
+
};
|
|
33
|
+
|
|
24
34
|
return (
|
|
25
35
|
<Tooltip arrow title={localization.toggleDensePadding}>
|
|
26
36
|
<IconButton
|
|
27
37
|
aria-label={localization.toggleDensePadding}
|
|
28
|
-
onClick={
|
|
29
|
-
size="small"
|
|
38
|
+
onClick={handleToggleDensePadding}
|
|
30
39
|
{...rest}
|
|
31
40
|
>
|
|
32
41
|
{isDensePadding ? <DensitySmallIcon /> : <DensityMediumIcon />}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { FC, MouseEvent } from 'react';
|
|
2
2
|
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
@@ -15,18 +15,27 @@ export const MRT_ToggleFiltersButton: FC<Props> = ({
|
|
|
15
15
|
options: {
|
|
16
16
|
icons: { FilterListIcon, FilterListOffIcon },
|
|
17
17
|
localization,
|
|
18
|
-
|
|
18
|
+
onToggleShowFilters,
|
|
19
19
|
},
|
|
20
|
+
setShowFilters,
|
|
20
21
|
} = tableInstance;
|
|
21
22
|
|
|
22
23
|
const { showFilters } = getState();
|
|
23
24
|
|
|
25
|
+
const handleToggleShowFilters = (event: MouseEvent<HTMLButtonElement>) => {
|
|
26
|
+
onToggleShowFilters?.({
|
|
27
|
+
event,
|
|
28
|
+
showFilters: !showFilters,
|
|
29
|
+
tableInstance,
|
|
30
|
+
});
|
|
31
|
+
setShowFilters(!showFilters);
|
|
32
|
+
};
|
|
33
|
+
|
|
24
34
|
return (
|
|
25
35
|
<Tooltip arrow title={localization.showHideFilters}>
|
|
26
36
|
<IconButton
|
|
27
37
|
aria-label={localization.showHideFilters}
|
|
28
|
-
onClick={
|
|
29
|
-
size="small"
|
|
38
|
+
onClick={handleToggleShowFilters}
|
|
30
39
|
{...rest}
|
|
31
40
|
>
|
|
32
41
|
{showFilters ? <FilterListOffIcon /> : <FilterListIcon />}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { FC, MouseEvent } from 'react';
|
|
2
2
|
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ interface Props extends IconButtonProps {
|
|
|
6
6
|
tableInstance: MRT_TableInstance;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export const
|
|
9
|
+
export const MRT_ToggleGlobalFilterButton: FC<Props> = ({
|
|
10
10
|
tableInstance,
|
|
11
11
|
...rest
|
|
12
12
|
}) => {
|
|
@@ -17,19 +17,25 @@ export const MRT_ToggleSearchButton: FC<Props> = ({
|
|
|
17
17
|
idPrefix,
|
|
18
18
|
localization,
|
|
19
19
|
muiSearchTextFieldProps,
|
|
20
|
-
|
|
20
|
+
onToggleShowGlobalFilter,
|
|
21
21
|
},
|
|
22
|
+
setShowGlobalFilter,
|
|
22
23
|
} = tableInstance;
|
|
23
24
|
|
|
24
|
-
const {
|
|
25
|
+
const { showGlobalFilter } = getState();
|
|
25
26
|
|
|
26
27
|
const textFieldProps =
|
|
27
28
|
muiSearchTextFieldProps instanceof Function
|
|
28
29
|
? muiSearchTextFieldProps({ tableInstance })
|
|
29
30
|
: muiSearchTextFieldProps;
|
|
30
31
|
|
|
31
|
-
const handleToggleSearch = () => {
|
|
32
|
-
|
|
32
|
+
const handleToggleSearch = (event: MouseEvent<HTMLButtonElement>) => {
|
|
33
|
+
onToggleShowGlobalFilter?.({
|
|
34
|
+
event,
|
|
35
|
+
showGlobalFilter: !showGlobalFilter,
|
|
36
|
+
tableInstance,
|
|
37
|
+
});
|
|
38
|
+
setShowGlobalFilter(!showGlobalFilter);
|
|
33
39
|
setTimeout(
|
|
34
40
|
() =>
|
|
35
41
|
document
|
|
@@ -43,8 +49,8 @@ export const MRT_ToggleSearchButton: FC<Props> = ({
|
|
|
43
49
|
|
|
44
50
|
return (
|
|
45
51
|
<Tooltip arrow title={localization.showHideSearch}>
|
|
46
|
-
<IconButton
|
|
47
|
-
{
|
|
52
|
+
<IconButton onClick={handleToggleSearch} {...rest}>
|
|
53
|
+
{showGlobalFilter ? <SearchOffIcon /> : <SearchIcon />}
|
|
48
54
|
</IconButton>
|
|
49
55
|
</Tooltip>
|
|
50
56
|
);
|
|
@@ -30,8 +30,8 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
|
|
|
30
30
|
icons: { FilterAltIcon, FilterAltOff },
|
|
31
31
|
localization,
|
|
32
32
|
muiTableHeadCellProps,
|
|
33
|
-
setShowFilters,
|
|
34
33
|
},
|
|
34
|
+
setShowFilters,
|
|
35
35
|
} = tableInstance;
|
|
36
36
|
|
|
37
37
|
const { isDensePadding, showFilters } = getState();
|
|
@@ -56,9 +56,9 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
|
|
|
56
56
|
|
|
57
57
|
const sortTooltip = !!column.getIsSorted()
|
|
58
58
|
? column.getIsSorted() === 'desc'
|
|
59
|
-
? localization.
|
|
60
|
-
: localization.
|
|
61
|
-
: localization.
|
|
59
|
+
? localization.sortedByColumnDesc.replace('{column}', column.header)
|
|
60
|
+
: localization.sortedByColumnAsc.replace('{column}', column.header)
|
|
61
|
+
: localization.unsorted;
|
|
62
62
|
|
|
63
63
|
const filterType = getState()?.currentFilterTypes?.[header.id];
|
|
64
64
|
|
|
@@ -135,7 +135,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
|
|
|
135
135
|
}}
|
|
136
136
|
>
|
|
137
137
|
<Box
|
|
138
|
-
{
|
|
138
|
+
onClick={() => column.toggleSorting()}
|
|
139
139
|
sx={{
|
|
140
140
|
alignItems: 'center',
|
|
141
141
|
cursor:
|
|
@@ -146,7 +146,6 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
|
|
|
146
146
|
flexWrap: 'nowrap',
|
|
147
147
|
whiteSpace: column.header.length < 15 ? 'nowrap' : 'normal',
|
|
148
148
|
}}
|
|
149
|
-
title={undefined}
|
|
150
149
|
>
|
|
151
150
|
{headerElement}
|
|
152
151
|
{column.columnDefType !== 'group' && column.getCanSort() && (
|
|
@@ -185,9 +184,9 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
|
|
|
185
184
|
}}
|
|
186
185
|
>
|
|
187
186
|
{showFilters && !column.getColumnFilterValue() ? (
|
|
188
|
-
<FilterAltOff
|
|
187
|
+
<FilterAltOff />
|
|
189
188
|
) : (
|
|
190
|
-
<FilterAltIcon
|
|
189
|
+
<FilterAltIcon />
|
|
191
190
|
)}
|
|
192
191
|
</IconButton>
|
|
193
192
|
</Tooltip>
|
|
@@ -16,11 +16,8 @@ interface Props {
|
|
|
16
16
|
export const MRT_EditCellTextField: FC<Props> = ({ cell, tableInstance }) => {
|
|
17
17
|
const {
|
|
18
18
|
getState,
|
|
19
|
-
options: {
|
|
20
|
-
|
|
21
|
-
muiTableBodyCellEditTextFieldProps,
|
|
22
|
-
setCurrentEditingRow,
|
|
23
|
-
},
|
|
19
|
+
options: { enableEditing, muiTableBodyCellEditTextFieldProps },
|
|
20
|
+
setCurrentEditingRow,
|
|
24
21
|
} = tableInstance;
|
|
25
22
|
|
|
26
23
|
const [value, setValue] = useState(cell.value);
|
|
@@ -32,8 +32,8 @@ export const MRT_FilterTextField: FC<Props> = ({ header, tableInstance }) => {
|
|
|
32
32
|
idPrefix,
|
|
33
33
|
localization,
|
|
34
34
|
muiTableHeadCellFilterTextFieldProps,
|
|
35
|
-
setCurrentFilterTypes,
|
|
36
35
|
},
|
|
36
|
+
setCurrentFilterTypes,
|
|
37
37
|
} = tableInstance;
|
|
38
38
|
|
|
39
39
|
const { column } = header;
|
|
@@ -206,7 +206,7 @@ export const MRT_FilterTextField: FC<Props> = ({ header, tableInstance }) => {
|
|
|
206
206
|
width: '1.75rem',
|
|
207
207
|
}}
|
|
208
208
|
>
|
|
209
|
-
<CloseIcon
|
|
209
|
+
<CloseIcon />
|
|
210
210
|
</IconButton>
|
|
211
211
|
</span>
|
|
212
212
|
</Tooltip>
|
|
@@ -29,11 +29,11 @@ export const MRT_SearchTextField: FC<Props> = ({ tableInstance }) => {
|
|
|
29
29
|
idPrefix,
|
|
30
30
|
localization,
|
|
31
31
|
muiSearchTextFieldProps,
|
|
32
|
-
|
|
32
|
+
onGlobalSearchFilterChange,
|
|
33
33
|
},
|
|
34
34
|
} = tableInstance;
|
|
35
35
|
|
|
36
|
-
const { globalFilter,
|
|
36
|
+
const { globalFilter, showGlobalFilter } = getState();
|
|
37
37
|
|
|
38
38
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
39
39
|
const [searchValue, setSearchValue] = useState(globalFilter ?? '');
|
|
@@ -41,7 +41,7 @@ export const MRT_SearchTextField: FC<Props> = ({ tableInstance }) => {
|
|
|
41
41
|
const handleChange = useCallback(
|
|
42
42
|
debounce((event: ChangeEvent<HTMLInputElement>) => {
|
|
43
43
|
setGlobalFilter(event.target.value ?? undefined);
|
|
44
|
-
|
|
44
|
+
onGlobalSearchFilterChange?.({ event, tableInstance });
|
|
45
45
|
}, 200),
|
|
46
46
|
[],
|
|
47
47
|
);
|
|
@@ -61,7 +61,7 @@ export const MRT_SearchTextField: FC<Props> = ({ tableInstance }) => {
|
|
|
61
61
|
: muiSearchTextFieldProps;
|
|
62
62
|
|
|
63
63
|
return (
|
|
64
|
-
<Collapse in={
|
|
64
|
+
<Collapse in={showGlobalFilter} orientation="horizontal">
|
|
65
65
|
<TextField
|
|
66
66
|
id={`mrt-${idPrefix}-search-text-field`}
|
|
67
67
|
placeholder={localization.search}
|
|
@@ -82,7 +82,7 @@ export const MRT_SearchTextField: FC<Props> = ({ tableInstance }) => {
|
|
|
82
82
|
size="small"
|
|
83
83
|
sx={{ height: '1.75rem', width: '1.75rem' }}
|
|
84
84
|
>
|
|
85
|
-
<SearchIcon
|
|
85
|
+
<SearchIcon />
|
|
86
86
|
</IconButton>
|
|
87
87
|
</span>
|
|
88
88
|
</Tooltip>
|
|
@@ -97,7 +97,7 @@ export const MRT_SearchTextField: FC<Props> = ({ tableInstance }) => {
|
|
|
97
97
|
size="small"
|
|
98
98
|
title={localization.clearSearch}
|
|
99
99
|
>
|
|
100
|
-
<CloseIcon
|
|
100
|
+
<CloseIcon />
|
|
101
101
|
</IconButton>
|
|
102
102
|
</InputAdornment>
|
|
103
103
|
),
|
package/src/localization.ts
CHANGED
|
@@ -46,6 +46,8 @@ export interface MRT_Localization {
|
|
|
46
46
|
showHideSearch: string;
|
|
47
47
|
sortByColumnAsc: string;
|
|
48
48
|
sortByColumnDesc: string;
|
|
49
|
+
sortedByColumnAsc: string;
|
|
50
|
+
sortedByColumnDesc: string;
|
|
49
51
|
thenBy: string;
|
|
50
52
|
toggleDensePadding: string;
|
|
51
53
|
toggleFullScreen: string;
|
|
@@ -53,6 +55,7 @@ export interface MRT_Localization {
|
|
|
53
55
|
toggleSelectRow: string;
|
|
54
56
|
ungroupByColumn: string;
|
|
55
57
|
unpin: string;
|
|
58
|
+
unsorted: string;
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
@@ -104,6 +107,8 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
|
104
107
|
showHideSearch: 'Show/Hide search',
|
|
105
108
|
sortByColumnAsc: 'Sort by {column} ascending',
|
|
106
109
|
sortByColumnDesc: 'Sort by {column} descending',
|
|
110
|
+
sortedByColumnAsc: 'Sorted by {column} ascending',
|
|
111
|
+
sortedByColumnDesc: 'Sorted by {column} descending',
|
|
107
112
|
thenBy: ', then by ',
|
|
108
113
|
toggleDensePadding: 'Toggle dense padding',
|
|
109
114
|
toggleFullScreen: 'Toggle full screen',
|
|
@@ -111,4 +116,5 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
|
111
116
|
toggleSelectRow: 'Toggle select row',
|
|
112
117
|
ungroupByColumn: 'Ungroup by {column}',
|
|
113
118
|
unpin: 'Unpin',
|
|
119
|
+
unsorted: 'Unsorted',
|
|
114
120
|
};
|