@cutting/material-react-table 4.1.0 → 5.0.0-beta.1
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 +360 -333
- package/dist/index.js +919 -928
- package/dist/index.js.map +1 -1
- package/locales/ar/package.json +2 -2
- package/locales/az/package.json +2 -2
- package/locales/bg/package.json +2 -2
- package/locales/cs/package.json +2 -2
- package/locales/da/package.json +2 -2
- package/locales/de/package.json +2 -2
- package/locales/el/package.json +2 -2
- package/locales/en/package.json +2 -2
- package/locales/es/package.json +2 -2
- package/locales/et/package.json +2 -2
- package/locales/fa/package.json +2 -2
- package/locales/fi/package.json +2 -2
- package/locales/fr/package.json +2 -2
- package/locales/he/package.json +2 -2
- package/locales/hr/package.json +2 -2
- package/locales/hu/package.json +2 -2
- package/locales/hy/package.json +2 -2
- package/locales/id/package.json +2 -2
- package/locales/it/package.json +2 -2
- package/locales/ja/package.json +2 -2
- package/locales/ko/package.json +2 -2
- package/locales/nl/package.json +2 -2
- package/locales/no/package.json +2 -2
- package/locales/np/package.json +2 -2
- package/locales/pl/package.json +2 -2
- package/locales/pt/package.json +2 -2
- package/locales/pt-BR/package.json +2 -2
- package/locales/ro/package.json +2 -2
- package/locales/ru/package.json +2 -2
- package/locales/sk/package.json +2 -2
- package/locales/sr-Cyrl-RS/package.json +2 -2
- package/locales/sr-Latn-RS/package.json +2 -2
- package/locales/sv/package.json +2 -2
- package/locales/tr/package.json +2 -2
- package/locales/uk/package.json +2 -2
- package/locales/vi/package.json +2 -2
- package/locales/zh-Hans/package.json +2 -2
- package/locales/zh-Hant/package.json +2 -2
- package/package.json +46 -61
- package/src/components/body/MRT_TableBody.tsx +1 -2
- package/src/components/body/MRT_TableBodyCell.tsx +4 -5
- package/src/components/body/MRT_TableBodyCellValue.tsx +1 -2
- package/src/components/body/MRT_TableBodyRow.tsx +1 -2
- package/src/components/body/MRT_TableBodyRowGrabHandle.test.tsx +42 -0
- package/src/components/body/MRT_TableBodyRowPinButton.tsx +1 -2
- package/src/components/body/MRT_TableDetailPanel.test.tsx +40 -0
- package/src/components/body/MRT_TableDetailPanel.tsx +1 -2
- package/src/components/buttons/MRT_ColumnPinningButtons.test.tsx +69 -0
- package/src/components/buttons/MRT_ColumnPinningButtons.tsx +3 -3
- package/src/components/buttons/MRT_EditActionButtons.test.tsx +50 -0
- package/src/components/buttons/MRT_EditActionButtons.tsx +1 -3
- package/src/components/buttons/MRT_ExpandAllButton.tsx +1 -2
- package/src/components/buttons/MRT_ExpandButton.tsx +1 -2
- package/src/components/buttons/MRT_ToggleDensePaddingButton.test.tsx +38 -0
- package/src/components/buttons/MRT_ToggleDensePaddingButton.tsx +1 -2
- package/src/components/buttons/MRT_ToggleFiltersButton.test.tsx +38 -0
- package/src/components/buttons/MRT_ToggleFiltersButton.tsx +1 -2
- package/src/components/buttons/MRT_ToggleFullScreenButton.test.tsx +36 -0
- package/src/components/buttons/MRT_ToggleFullScreenButton.tsx +1 -2
- package/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx +1 -2
- package/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx +2 -3
- package/src/components/footer/MRT_TableFooter.tsx +1 -2
- package/src/components/footer/MRT_TableFooterCell.tsx +1 -2
- package/src/components/head/MRT_TableHead.tsx +1 -2
- package/src/components/head/MRT_TableHeadCell.tsx +9 -9
- package/src/components/head/MRT_TableHeadCellFilterContainer.tsx +1 -2
- package/src/components/head/MRT_TableHeadCellGrabHandle.test.tsx +61 -0
- package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +4 -5
- package/src/components/head/MRT_TableHeadCellResizeHandle.test.tsx +45 -0
- package/src/components/head/MRT_TableHeadCellResizeHandle.tsx +4 -5
- package/src/components/head/MRT_TableHeadCellSortLabel.tsx +1 -2
- package/src/components/inputs/MRT_EditCellTextField.test.tsx +36 -0
- package/src/components/inputs/MRT_EditCellTextField.tsx +1 -3
- package/src/components/inputs/MRT_FilterCheckbox.tsx +1 -2
- package/src/components/inputs/MRT_FilterRangeSlider.tsx +2 -1
- package/src/components/inputs/MRT_FilterTextField.test.tsx +75 -0
- package/src/components/inputs/MRT_GlobalFilterTextField.tsx +1 -2
- package/src/components/inputs/MRT_SelectCheckbox.test.tsx +69 -0
- package/src/components/inputs/MRT_SelectCheckbox.tsx +1 -2
- package/src/components/menus/MRT_CellActionMenu.tsx +1 -2
- package/src/components/menus/MRT_ColumnActionMenu.tsx +12 -13
- package/src/components/menus/MRT_FilterOptionMenu.tsx +1 -2
- package/src/components/menus/MRT_RowActionMenu.tsx +1 -2
- package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +1 -2
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +4 -5
- package/src/components/modals/MRT_EditRowModal.test.tsx +54 -0
- package/src/components/modals/MRT_EditRowModal.tsx +1 -2
- package/src/components/table/MRT_Table.tsx +4 -5
- package/src/components/table/MRT_TableContainer.tsx +1 -2
- package/src/components/table/MRT_TablePaper.tsx +1 -2
- package/src/components/toolbar/MRT_BottomToolbar.tsx +2 -3
- package/src/components/toolbar/MRT_LinearProgressBar.tsx +1 -2
- package/src/components/toolbar/MRT_TablePagination.tsx +1 -2
- package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +3 -4
- package/src/components/toolbar/MRT_ToolbarDropZone.test.tsx +42 -0
- package/src/components/toolbar/MRT_ToolbarDropZone.tsx +1 -2
- package/src/components/toolbar/MRT_TopToolbar.tsx +1 -2
- package/src/fns/aggregationFns.test.tsx +57 -0
- package/src/fns/filterFns.test.tsx +156 -0
- package/src/fns/filterFns.ts +36 -22
- package/src/fns/sortingFns.ts +14 -5
- package/src/fns/tableFeatures.test.tsx +106 -0
- package/src/fns/tableFeatures.ts +103 -0
- package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +2 -2
- package/src/hooks/useMRT_ColumnVirtualizer.ts +6 -5
- package/src/hooks/useMRT_Effects.ts +3 -4
- package/src/hooks/useMRT_RowVirtualizer.ts +1 -2
- package/src/hooks/useMRT_Rows.ts +1 -2
- package/src/hooks/useMRT_TableInstance.ts +82 -63
- package/src/hooks/useMRT_TableOptions.ts +5 -37
- package/src/icons.ts +1 -1
- package/src/types.ts +162 -134
- package/src/utils/column.utils.ts +31 -24
- package/src/utils/row.utils.ts +7 -10
- package/src/utils/style.utils.ts +9 -10
- package/src/utils/tanstack.helpers.ts +2 -2
- package/dist/index.d.mts +0 -1925
- package/dist/index.mjs +0 -5409
- package/dist/index.mjs.map +0 -1
- package/locales/ar/index.d.ts +0 -3
- package/locales/ar/index.js +0 -98
- package/locales/az/index.d.ts +0 -3
- package/locales/az/index.js +0 -98
- package/locales/bg/index.d.ts +0 -3
- package/locales/bg/index.js +0 -98
- package/locales/cs/index.d.ts +0 -3
- package/locales/cs/index.js +0 -98
- package/locales/da/index.d.ts +0 -3
- package/locales/da/index.js +0 -98
- package/locales/de/index.d.ts +0 -3
- package/locales/de/index.js +0 -98
- package/locales/el/index.d.ts +0 -3
- package/locales/el/index.js +0 -98
- package/locales/en/index.d.ts +0 -3
- package/locales/en/index.js +0 -98
- package/locales/es/index.d.ts +0 -3
- package/locales/es/index.js +0 -98
- package/locales/et/index.d.ts +0 -3
- package/locales/et/index.js +0 -98
- package/locales/fa/index.d.ts +0 -3
- package/locales/fa/index.js +0 -98
- package/locales/fi/index.d.ts +0 -3
- package/locales/fi/index.js +0 -98
- package/locales/fr/index.d.ts +0 -3
- package/locales/fr/index.js +0 -98
- package/locales/he/index.d.ts +0 -3
- package/locales/he/index.js +0 -98
- package/locales/hr/index.d.ts +0 -3
- package/locales/hr/index.js +0 -98
- package/locales/hu/index.d.ts +0 -3
- package/locales/hu/index.js +0 -98
- package/locales/hy/index.d.ts +0 -3
- package/locales/hy/index.js +0 -98
- package/locales/id/index.d.ts +0 -3
- package/locales/id/index.js +0 -98
- package/locales/it/index.d.ts +0 -3
- package/locales/it/index.js +0 -98
- package/locales/ja/index.d.ts +0 -3
- package/locales/ja/index.js +0 -98
- package/locales/ko/index.d.ts +0 -3
- package/locales/ko/index.js +0 -98
- package/locales/nl/index.d.ts +0 -3
- package/locales/nl/index.js +0 -98
- package/locales/no/index.d.ts +0 -3
- package/locales/no/index.js +0 -98
- package/locales/np/index.d.ts +0 -3
- package/locales/np/index.js +0 -98
- package/locales/pl/index.d.ts +0 -3
- package/locales/pl/index.js +0 -98
- package/locales/pt/index.d.ts +0 -3
- package/locales/pt/index.js +0 -98
- package/locales/pt-BR/index.d.ts +0 -3
- package/locales/pt-BR/index.js +0 -98
- package/locales/ro/index.d.ts +0 -3
- package/locales/ro/index.js +0 -98
- package/locales/ru/index.d.ts +0 -3
- package/locales/ru/index.js +0 -98
- package/locales/sk/index.d.ts +0 -3
- package/locales/sk/index.js +0 -98
- package/locales/sr-Cyrl-RS/index.d.ts +0 -3
- package/locales/sr-Cyrl-RS/index.js +0 -98
- package/locales/sr-Latn-RS/index.d.ts +0 -3
- package/locales/sr-Latn-RS/index.js +0 -98
- package/locales/sv/index.d.ts +0 -3
- package/locales/sv/index.js +0 -98
- package/locales/tr/index.d.ts +0 -3
- package/locales/tr/index.js +0 -98
- package/locales/uk/index.d.ts +0 -3
- package/locales/uk/index.js +0 -98
- package/locales/vi/index.d.ts +0 -3
- package/locales/vi/index.js +0 -98
- package/locales/zh-Hans/index.d.ts +0 -3
- package/locales/zh-Hans/index.js +0 -98
- package/locales/zh-Hant/index.d.ts +0 -3
- package/locales/zh-Hant/index.js +0 -98
package/src/types.ts
CHANGED
|
@@ -30,15 +30,16 @@ import {
|
|
|
30
30
|
} from '@mui/x-date-pickers';
|
|
31
31
|
import {
|
|
32
32
|
type AccessorFn,
|
|
33
|
-
type
|
|
33
|
+
type AggregationFnDef,
|
|
34
34
|
type Cell,
|
|
35
|
+
type CellData,
|
|
35
36
|
type Column,
|
|
36
37
|
type ColumnDef,
|
|
37
38
|
type ColumnFiltersState,
|
|
38
39
|
type ColumnOrderState,
|
|
39
40
|
type ColumnPinningState,
|
|
40
|
-
type ColumnSizingInfoState,
|
|
41
41
|
type ColumnSizingState,
|
|
42
|
+
type ColumnVisibilityState,
|
|
42
43
|
type DeepKeys,
|
|
43
44
|
type DeepValue,
|
|
44
45
|
type ExpandedState,
|
|
@@ -48,15 +49,18 @@ import {
|
|
|
48
49
|
type HeaderGroup,
|
|
49
50
|
type OnChangeFn,
|
|
50
51
|
type PaginationState,
|
|
52
|
+
type ReactTable,
|
|
51
53
|
type Row,
|
|
54
|
+
type RowData,
|
|
52
55
|
type RowSelectionState,
|
|
53
|
-
type
|
|
56
|
+
type SortFn,
|
|
54
57
|
type SortingState,
|
|
55
|
-
type
|
|
58
|
+
type TableFeature,
|
|
59
|
+
type TableFeatures,
|
|
56
60
|
type TableOptions,
|
|
57
61
|
type TableState,
|
|
62
|
+
type TableState_ColumnResizing,
|
|
58
63
|
type Updater,
|
|
59
|
-
type VisibilityState,
|
|
60
64
|
} from '@tanstack/react-table';
|
|
61
65
|
import {
|
|
62
66
|
type VirtualItem,
|
|
@@ -73,9 +77,11 @@ import {
|
|
|
73
77
|
import { type MRT_AggregationFns } from './fns/aggregationFns';
|
|
74
78
|
import { type MRT_FilterFns } from './fns/filterFns';
|
|
75
79
|
import { type MRT_SortingFns } from './fns/sortingFns';
|
|
80
|
+
import { type MRT_TableFeatures } from './fns/tableFeatures';
|
|
76
81
|
import { type MRT_Icons } from './icons';
|
|
77
82
|
|
|
78
83
|
export type { MRT_Icons };
|
|
84
|
+
|
|
79
85
|
export type DropdownOption =
|
|
80
86
|
| string
|
|
81
87
|
| {
|
|
@@ -87,61 +93,60 @@ export type LiteralUnion<T extends U, U = string> =
|
|
|
87
93
|
| (Record<never, never> & U)
|
|
88
94
|
| T;
|
|
89
95
|
|
|
96
|
+
/**
|
|
97
|
+
* v9 replaced the callable `AggregationFn` with `AggregationFnDef`, an object
|
|
98
|
+
* with an `aggregate` method that takes a single context argument.
|
|
99
|
+
*/
|
|
90
100
|
export type MRT_AggregationFn<TData extends MRT_RowData> =
|
|
91
|
-
|
|
|
101
|
+
| AggregationFnDef<any, TData, any, any>
|
|
92
102
|
| MRT_AggregationOption;
|
|
93
103
|
|
|
94
|
-
export type MRT_AggregationOption =
|
|
104
|
+
export type MRT_AggregationOption =
|
|
105
|
+
| (keyof typeof MRT_AggregationFns & string)
|
|
106
|
+
| (string & {});
|
|
95
107
|
|
|
96
|
-
export type MRT_Cell<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
>
|
|
100
|
-
column: MRT_Column<TData, TValue>;
|
|
101
|
-
row: MRT_Row<TData>;
|
|
102
|
-
};
|
|
108
|
+
export type MRT_Cell<
|
|
109
|
+
TData extends MRT_RowData,
|
|
110
|
+
TValue = unknown,
|
|
111
|
+
> = Cell<MRT_TableFeatures, TData, TValue>;
|
|
103
112
|
|
|
104
|
-
export type MRT_Column<
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
>
|
|
108
|
-
columnDef: MRT_DefinedColumnDef<TData, TValue>;
|
|
109
|
-
columns?: MRT_Column<TData, TValue>[];
|
|
110
|
-
filterFn?: MRT_FilterFn<TData>;
|
|
111
|
-
footer: string;
|
|
112
|
-
header: string;
|
|
113
|
-
};
|
|
113
|
+
export type MRT_Column<
|
|
114
|
+
TData extends MRT_RowData,
|
|
115
|
+
TValue = unknown,
|
|
116
|
+
> = Column<MRT_TableFeatures, TData, TValue>;
|
|
114
117
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
| 'aggregationFn'
|
|
121
|
-
| 'cell'
|
|
122
|
-
| 'columns'
|
|
123
|
-
| 'filterFn'
|
|
124
|
-
| 'footer'
|
|
125
|
-
| 'header'
|
|
126
|
-
| 'id'
|
|
127
|
-
| 'sortingFn'
|
|
118
|
+
declare module '@tanstack/table-core' {
|
|
119
|
+
interface ColumnDef_FeatureMap<
|
|
120
|
+
TFeatures extends TableFeatures,
|
|
121
|
+
TData extends RowData,
|
|
122
|
+
TValue extends CellData,
|
|
128
123
|
> {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
124
|
+
mrtFeature: MRT_ColumnDefExtras<TData, TValue>;
|
|
125
|
+
}
|
|
126
|
+
interface Plugins {
|
|
127
|
+
mrtFeature: TableFeature;
|
|
128
|
+
}
|
|
129
|
+
interface TableOptions_FeatureMap<
|
|
130
|
+
TFeatures extends TableFeatures,
|
|
131
|
+
TData extends RowData,
|
|
132
|
+
> {
|
|
133
|
+
mrtFeature: MRT_TableOptionExtras<TData>;
|
|
134
|
+
}
|
|
135
|
+
interface TableState_FeatureMap {
|
|
136
|
+
mrtFeature: MRT_StateExtras;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export type MRT_ColumnDef<
|
|
141
|
+
TData extends MRT_RowData,
|
|
142
|
+
TValue = unknown,
|
|
143
|
+
> = ColumnDef<MRT_TableFeatures, TData, TValue>;
|
|
144
|
+
|
|
145
|
+
export interface MRT_ColumnDefExtras<
|
|
146
|
+
TData extends MRT_RowData,
|
|
147
|
+
TValue = unknown,
|
|
148
|
+
> {
|
|
149
|
+
_filterFn?: MRT_FilterOption;
|
|
145
150
|
AggregatedCell?: (props: {
|
|
146
151
|
cell: MRT_Cell<TData, TValue>;
|
|
147
152
|
column: MRT_Column<TData, TValue>;
|
|
@@ -150,7 +155,6 @@ export interface MRT_ColumnDef<TData extends MRT_RowData, TValue = unknown>
|
|
|
150
155
|
staticRowIndex?: number;
|
|
151
156
|
table: MRT_TableInstance<TData>;
|
|
152
157
|
}) => ReactNode;
|
|
153
|
-
aggregationFn?: Array<MRT_AggregationFn<TData>> | MRT_AggregationFn<TData>;
|
|
154
158
|
Cell?: (props: {
|
|
155
159
|
cell: MRT_Cell<TData, TValue>;
|
|
156
160
|
column: MRT_Column<TData, TValue>;
|
|
@@ -173,7 +177,6 @@ export interface MRT_ColumnDef<TData extends MRT_RowData, TValue = unknown>
|
|
|
173
177
|
columnFilterModeOptions?: Array<
|
|
174
178
|
LiteralUnion<MRT_FilterOption & string>
|
|
175
179
|
> | null;
|
|
176
|
-
columns?: MRT_ColumnDef<TData, TValue>[];
|
|
177
180
|
Edit?: (props: {
|
|
178
181
|
cell: MRT_Cell<TData, TValue>;
|
|
179
182
|
column: MRT_Column<TData, TValue>;
|
|
@@ -205,7 +208,6 @@ export interface MRT_ColumnDef<TData extends MRT_RowData, TValue = unknown>
|
|
|
205
208
|
rangeFilterIndex?: number;
|
|
206
209
|
table: MRT_TableInstance<TData>;
|
|
207
210
|
}) => ReactNode;
|
|
208
|
-
filterFn?: MRT_FilterFn<TData>;
|
|
209
211
|
filterSelectOptions?: DropdownOption[];
|
|
210
212
|
filterVariant?:
|
|
211
213
|
| 'autocomplete'
|
|
@@ -221,9 +223,6 @@ export interface MRT_ColumnDef<TData extends MRT_RowData, TValue = unknown>
|
|
|
221
223
|
| 'text'
|
|
222
224
|
| 'time'
|
|
223
225
|
| 'time-range';
|
|
224
|
-
/**
|
|
225
|
-
* footer must be a string. If you want custom JSX to render the footer, you can also specify a `Footer` option. (Capital F)
|
|
226
|
-
*/
|
|
227
226
|
footer?: string;
|
|
228
227
|
Footer?:
|
|
229
228
|
| ((props: {
|
|
@@ -244,9 +243,6 @@ export interface MRT_ColumnDef<TData extends MRT_RowData, TValue = unknown>
|
|
|
244
243
|
* If `layoutMode` is `'grid'` or `'grid-no-grow'`, you can specify the flex grow value for individual columns to still grow and take up remaining space, or set to `false`/0 to not grow.
|
|
245
244
|
*/
|
|
246
245
|
grow?: boolean | number;
|
|
247
|
-
/**
|
|
248
|
-
* header must be a string. If you want custom JSX to render the header, you can also specify a `Header` option. (Capital H)
|
|
249
|
-
*/
|
|
250
246
|
header: string;
|
|
251
247
|
Header?:
|
|
252
248
|
| ((props: {
|
|
@@ -255,16 +251,6 @@ export interface MRT_ColumnDef<TData extends MRT_RowData, TValue = unknown>
|
|
|
255
251
|
table: MRT_TableInstance<TData>;
|
|
256
252
|
}) => ReactNode)
|
|
257
253
|
| ReactNode;
|
|
258
|
-
/**
|
|
259
|
-
* Either an `accessorKey` or a combination of an `accessorFn` and `id` are required for a data column definition.
|
|
260
|
-
*
|
|
261
|
-
* If you have also specified an `accessorFn`, MRT still needs to have a valid `id` to be able to identify the column uniquely.
|
|
262
|
-
*
|
|
263
|
-
* `id` defaults to the `accessorKey` or `header` if not specified.
|
|
264
|
-
*
|
|
265
|
-
* @default gets set to the same value as `accessorKey` by default
|
|
266
|
-
*/
|
|
267
|
-
id?: LiteralUnion<keyof TData & string>;
|
|
268
254
|
muiColumnActionsButtonProps?:
|
|
269
255
|
| ((props: {
|
|
270
256
|
column: MRT_Column<TData>;
|
|
@@ -387,12 +373,13 @@ export interface MRT_ColumnDef<TData extends MRT_RowData, TValue = unknown>
|
|
|
387
373
|
onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
|
|
388
374
|
table: MRT_TableInstance<TData>;
|
|
389
375
|
}) => ReactNode[];
|
|
390
|
-
sortingFn?: MRT_SortingFn<TData>;
|
|
391
376
|
visibleInShowHideMenu?: boolean;
|
|
392
377
|
}
|
|
393
378
|
|
|
394
379
|
export type MRT_ColumnFilterFnsState = Record<string, MRT_FilterOption>;
|
|
380
|
+
|
|
395
381
|
export type MRT_ColumnFiltersState = ColumnFiltersState;
|
|
382
|
+
|
|
396
383
|
export type MRT_ColumnHelper<TData extends MRT_RowData> = {
|
|
397
384
|
accessor: <
|
|
398
385
|
TAccessor extends AccessorFn<TData> | DeepKeys<TData>,
|
|
@@ -408,9 +395,11 @@ export type MRT_ColumnHelper<TData extends MRT_RowData> = {
|
|
|
408
395
|
display: (column: MRT_DisplayColumnDef<TData>) => MRT_ColumnDef<TData>;
|
|
409
396
|
group: (column: MRT_GroupColumnDef<TData>) => MRT_ColumnDef<TData>;
|
|
410
397
|
};
|
|
398
|
+
|
|
411
399
|
export type MRT_ColumnOrderState = ColumnOrderState;
|
|
412
400
|
export type MRT_ColumnPinningState = ColumnPinningState;
|
|
413
|
-
export type MRT_ColumnSizingInfoState =
|
|
401
|
+
export type MRT_ColumnSizingInfoState =
|
|
402
|
+
TableState_ColumnResizing['columnResizing'];
|
|
414
403
|
export type MRT_ColumnSizingState = ColumnSizingState;
|
|
415
404
|
export type MRT_ColumnVirtualizer<
|
|
416
405
|
TScrollElement extends Element | Window = HTMLDivElement,
|
|
@@ -449,13 +438,10 @@ export type MRT_DisplayColumnIds =
|
|
|
449
438
|
| 'mrt-row-pin'
|
|
450
439
|
| 'mrt-row-select'
|
|
451
440
|
| 'mrt-row-spacer';
|
|
452
|
-
|
|
453
441
|
export type MRT_ExpandedState = ExpandedState;
|
|
454
|
-
|
|
455
442
|
export type MRT_FilterFn<TData extends MRT_RowData> =
|
|
456
|
-
| FilterFn<TData>
|
|
443
|
+
| FilterFn<MRT_TableFeatures, TData>
|
|
457
444
|
| MRT_FilterOption;
|
|
458
|
-
|
|
459
445
|
export type MRT_FilterOption = LiteralUnion<
|
|
460
446
|
keyof typeof MRT_FilterFns & string
|
|
461
447
|
>;
|
|
@@ -468,14 +454,14 @@ export type MRT_GroupColumnDef<TData extends MRT_RowData> =
|
|
|
468
454
|
export type MRT_GroupingState = GroupingState;
|
|
469
455
|
|
|
470
456
|
export type MRT_Header<TData extends MRT_RowData> = Omit<
|
|
471
|
-
Header<TData, unknown>,
|
|
457
|
+
Header<MRT_TableFeatures, TData, unknown>,
|
|
472
458
|
'column'
|
|
473
459
|
> & {
|
|
474
460
|
column: MRT_Column<TData>;
|
|
475
461
|
};
|
|
476
462
|
|
|
477
463
|
export type MRT_HeaderGroup<TData extends MRT_RowData> = Omit<
|
|
478
|
-
HeaderGroup<TData>,
|
|
464
|
+
HeaderGroup<MRT_TableFeatures, TData>,
|
|
479
465
|
'headers'
|
|
480
466
|
> & {
|
|
481
467
|
headers: MRT_Header<TData>[];
|
|
@@ -586,24 +572,7 @@ export interface MRT_Localization {
|
|
|
586
572
|
|
|
587
573
|
export type MRT_PaginationState = PaginationState;
|
|
588
574
|
|
|
589
|
-
export type MRT_Row<TData extends MRT_RowData> =
|
|
590
|
-
Row<TData>,
|
|
591
|
-
| '_valuesCache'
|
|
592
|
-
| 'getAllCells'
|
|
593
|
-
| 'getParentRow'
|
|
594
|
-
| 'getParentRows'
|
|
595
|
-
| 'getRow'
|
|
596
|
-
| 'getVisibleCells'
|
|
597
|
-
| 'subRows'
|
|
598
|
-
> & {
|
|
599
|
-
_valuesCache: Record<LiteralUnion<DeepKeys<TData> & string>, any>;
|
|
600
|
-
getAllCells: () => MRT_Cell<TData>[];
|
|
601
|
-
getParentRow: () => MRT_Row<TData> | null;
|
|
602
|
-
getParentRows: () => MRT_Row<TData>[];
|
|
603
|
-
getRow: () => MRT_Row<TData>;
|
|
604
|
-
getVisibleCells: () => MRT_Cell<TData>[];
|
|
605
|
-
subRows?: MRT_Row<TData>[];
|
|
606
|
-
};
|
|
575
|
+
export type MRT_Row<TData extends MRT_RowData> = Row<MRT_TableFeatures, TData>;
|
|
607
576
|
|
|
608
577
|
export type MRT_RowData = Record<string, any>;
|
|
609
578
|
|
|
@@ -624,7 +593,7 @@ export type MRT_RowVirtualizer<
|
|
|
624
593
|
|
|
625
594
|
export type MRT_SortingFn<TData extends MRT_RowData> =
|
|
626
595
|
| MRT_SortingOption
|
|
627
|
-
|
|
|
596
|
+
| SortFn<MRT_TableFeatures, TData>;
|
|
628
597
|
|
|
629
598
|
export type MRT_SortingOption = LiteralUnion<
|
|
630
599
|
keyof typeof MRT_SortingFns & string
|
|
@@ -632,41 +601,43 @@ export type MRT_SortingOption = LiteralUnion<
|
|
|
632
601
|
|
|
633
602
|
export type MRT_SortingState = SortingState;
|
|
634
603
|
|
|
604
|
+
export type MRT_StatefulState<TData extends MRT_RowData> = Partial<Pick<MRT_TableState<TData>, 'isLoading' | 'showSkeletons'>> &
|
|
605
|
+
Pick<
|
|
606
|
+
MRT_TableState<TData>,
|
|
607
|
+
| 'columnFilterFns'
|
|
608
|
+
| 'columnOrder'
|
|
609
|
+
| 'columnResizing'
|
|
610
|
+
| 'creatingRow'
|
|
611
|
+
| 'density'
|
|
612
|
+
| 'draggingColumn'
|
|
613
|
+
| 'draggingRow'
|
|
614
|
+
| 'editingCell'
|
|
615
|
+
| 'editingRow'
|
|
616
|
+
| 'globalFilterFn'
|
|
617
|
+
| 'grouping'
|
|
618
|
+
| 'hoveredColumn'
|
|
619
|
+
| 'hoveredRow'
|
|
620
|
+
| 'isFullScreen'
|
|
621
|
+
| 'pagination'
|
|
622
|
+
| 'showAlertBanner'
|
|
623
|
+
| 'showColumnFilters'
|
|
624
|
+
| 'showGlobalFilter'
|
|
625
|
+
| 'showToolbarDropZone'
|
|
626
|
+
>;
|
|
627
|
+
|
|
635
628
|
export type MRT_StatefulTableOptions<TData extends MRT_RowData> =
|
|
636
629
|
MRT_DefinedTableOptions<TData> & {
|
|
637
|
-
state:
|
|
638
|
-
MRT_TableState<TData>,
|
|
639
|
-
| 'columnFilterFns'
|
|
640
|
-
| 'columnOrder'
|
|
641
|
-
| 'columnSizingInfo'
|
|
642
|
-
| 'creatingRow'
|
|
643
|
-
| 'density'
|
|
644
|
-
| 'draggingColumn'
|
|
645
|
-
| 'draggingRow'
|
|
646
|
-
| 'editingCell'
|
|
647
|
-
| 'editingRow'
|
|
648
|
-
| 'globalFilterFn'
|
|
649
|
-
| 'grouping'
|
|
650
|
-
| 'hoveredColumn'
|
|
651
|
-
| 'hoveredRow'
|
|
652
|
-
| 'isFullScreen'
|
|
653
|
-
| 'pagination'
|
|
654
|
-
| 'showAlertBanner'
|
|
655
|
-
| 'showColumnFilters'
|
|
656
|
-
| 'showGlobalFilter'
|
|
657
|
-
| 'showToolbarDropZone'
|
|
658
|
-
>;
|
|
630
|
+
state: MRT_StatefulState<TData>;
|
|
659
631
|
};
|
|
660
632
|
|
|
661
633
|
export type MRT_TableInstance<TData extends MRT_RowData> = Omit<
|
|
662
|
-
|
|
634
|
+
ReactTable<MRT_TableFeatures, TData>,
|
|
663
635
|
| 'getAllColumns'
|
|
664
636
|
| 'getAllFlatColumns'
|
|
665
637
|
| 'getAllLeafColumns'
|
|
666
638
|
| 'getBottomRows'
|
|
667
639
|
| 'getCenterLeafColumns'
|
|
668
640
|
| 'getCenterRows'
|
|
669
|
-
| 'getColumn'
|
|
670
641
|
| 'getExpandedRowModel'
|
|
671
642
|
| 'getFlatHeaders'
|
|
672
643
|
| 'getFooterGroups'
|
|
@@ -675,11 +646,10 @@ export type MRT_TableInstance<TData extends MRT_RowData> = Omit<
|
|
|
675
646
|
| 'getLeftLeafColumns'
|
|
676
647
|
| 'getPaginationRowModel'
|
|
677
648
|
| 'getPreFilteredRowModel'
|
|
678
|
-
| '
|
|
649
|
+
| 'getPrePaginatedRowModel'
|
|
679
650
|
| 'getRightLeafColumns'
|
|
680
651
|
| 'getRowModel'
|
|
681
652
|
| 'getSelectedRowModel'
|
|
682
|
-
| 'getState'
|
|
683
653
|
| 'getTopRows'
|
|
684
654
|
| 'options'
|
|
685
655
|
> & {
|
|
@@ -689,7 +659,6 @@ export type MRT_TableInstance<TData extends MRT_RowData> = Omit<
|
|
|
689
659
|
getBottomRows: () => MRT_Row<TData>[];
|
|
690
660
|
getCenterLeafColumns: () => MRT_Column<TData>[];
|
|
691
661
|
getCenterRows: () => MRT_Row<TData>[];
|
|
692
|
-
getColumn: (columnId: string) => MRT_Column<TData>;
|
|
693
662
|
getExpandedRowModel: () => MRT_RowModel<TData>;
|
|
694
663
|
getFlatHeaders: () => MRT_Header<TData>[];
|
|
695
664
|
getFooterGroups: () => MRT_HeaderGroup<TData>[];
|
|
@@ -698,11 +667,10 @@ export type MRT_TableInstance<TData extends MRT_RowData> = Omit<
|
|
|
698
667
|
getLeftLeafColumns: () => MRT_Column<TData>[];
|
|
699
668
|
getPaginationRowModel: () => MRT_RowModel<TData>;
|
|
700
669
|
getPreFilteredRowModel: () => MRT_RowModel<TData>;
|
|
701
|
-
|
|
670
|
+
getPrePaginatedRowModel: () => MRT_RowModel<TData>;
|
|
702
671
|
getRightLeafColumns: () => MRT_Column<TData>[];
|
|
703
672
|
getRowModel: () => MRT_RowModel<TData>;
|
|
704
673
|
getSelectedRowModel: () => MRT_RowModel<TData>;
|
|
705
|
-
getState: () => MRT_TableState<TData>;
|
|
706
674
|
getTopRows: () => MRT_Row<TData>[];
|
|
707
675
|
options: MRT_StatefulTableOptions<TData>;
|
|
708
676
|
refs: {
|
|
@@ -748,7 +716,7 @@ export type MRT_TableInstance<TData extends MRT_RowData> = Omit<
|
|
|
748
716
|
*/
|
|
749
717
|
export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
750
718
|
extends Omit<
|
|
751
|
-
Partial<TableOptions<TData>>,
|
|
719
|
+
Partial<Omit<TableOptions<MRT_TableFeatures, TData>, 'features'>>,
|
|
752
720
|
| 'columns'
|
|
753
721
|
| 'data'
|
|
754
722
|
| 'defaultColumn'
|
|
@@ -756,10 +724,18 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
|
756
724
|
| 'expandRowsFn'
|
|
757
725
|
| 'getRowId'
|
|
758
726
|
| 'globalFilterFn'
|
|
727
|
+
| 'icons'
|
|
759
728
|
| 'initialState'
|
|
729
|
+
| 'localization'
|
|
730
|
+
| 'mrtTheme'
|
|
760
731
|
| 'onStateChange'
|
|
761
732
|
| 'state'
|
|
762
733
|
> {
|
|
734
|
+
/**
|
|
735
|
+
* Custom aggregation functions, registered by name so column defs can select
|
|
736
|
+
* them with `aggregationFn: 'myFn'`.
|
|
737
|
+
*/
|
|
738
|
+
aggregationFns?: Record<string, AggregationFnDef<any, TData, any, any>>;
|
|
763
739
|
columnFilterDisplayMode?: 'custom' | 'popover' | 'subheader';
|
|
764
740
|
columnFilterModeOptions?: Array<
|
|
765
741
|
LiteralUnion<MRT_FilterOption & string>
|
|
@@ -774,7 +750,7 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
|
774
750
|
* See all Columns Options on the official docs site:
|
|
775
751
|
* @link https://www.material-react-table.com/docs/api/column-options
|
|
776
752
|
*/
|
|
777
|
-
columns: MRT_ColumnDef<TData, any
|
|
753
|
+
columns: ReadonlyArray<MRT_ColumnDef<TData, any>>;
|
|
778
754
|
columnVirtualizerInstanceRef?: RefObject<MRT_ColumnVirtualizer | null>;
|
|
779
755
|
columnVirtualizerOptions?:
|
|
780
756
|
| ((props: {
|
|
@@ -788,7 +764,7 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
|
788
764
|
* See the usage guide for more info on creating columns and data:
|
|
789
765
|
* @link https://www.material-react-table.com/docs/getting-started/usage
|
|
790
766
|
*/
|
|
791
|
-
data: TData[];
|
|
767
|
+
data: readonly TData[];
|
|
792
768
|
/**
|
|
793
769
|
* Instead of specifying a bunch of the same options for each column, you can just change an option in the `defaultColumn` table option to change a default option for all columns.
|
|
794
770
|
*/
|
|
@@ -837,10 +813,15 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
|
837
813
|
enableToolbarInternalActions?: boolean;
|
|
838
814
|
enableTopToolbar?: boolean;
|
|
839
815
|
expandRowsFn?: (dataRow: TData) => TData[];
|
|
816
|
+
/**
|
|
817
|
+
* Custom filter functions, registered by name so column defs can select them
|
|
818
|
+
* with `filterFn: 'myFn'` and `globalFilterFn` can name one.
|
|
819
|
+
*/
|
|
820
|
+
filterFns?: Record<string, FilterFn<any, TData>>;
|
|
840
821
|
getRowId?: (
|
|
841
822
|
originalRow: TData,
|
|
842
823
|
index: number,
|
|
843
|
-
parentRow
|
|
824
|
+
parentRow?: MRT_Row<TData>,
|
|
844
825
|
) => string;
|
|
845
826
|
globalFilterFn?: MRT_FilterOption;
|
|
846
827
|
globalFilterModeOptions?: MRT_FilterOption[] | null;
|
|
@@ -1232,13 +1213,28 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
|
1232
1213
|
}) => Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>>)
|
|
1233
1214
|
| Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>>;
|
|
1234
1215
|
selectAllMode?: 'all' | 'page';
|
|
1216
|
+
/**
|
|
1217
|
+
* Custom sort functions, registered by name so column defs can select them
|
|
1218
|
+
* with `sortFn: 'myFn'`.
|
|
1219
|
+
*/
|
|
1220
|
+
sortFns?: Record<string, SortFn<any, TData>>;
|
|
1235
1221
|
/**
|
|
1236
1222
|
* Manage state externally any way you want, then pass it back into MRT.
|
|
1237
1223
|
*/
|
|
1238
1224
|
state?: Partial<MRT_TableState<TData>>;
|
|
1239
1225
|
}
|
|
1240
1226
|
|
|
1241
|
-
export
|
|
1227
|
+
export type MRT_TableState<TData extends MRT_RowData> = Omit<
|
|
1228
|
+
TableState<MRT_TableFeatures>,
|
|
1229
|
+
| 'actionCell'
|
|
1230
|
+
| 'creatingRow'
|
|
1231
|
+
| 'draggingColumn'
|
|
1232
|
+
| 'draggingRow'
|
|
1233
|
+
| 'editingCell'
|
|
1234
|
+
| 'editingRow'
|
|
1235
|
+
| 'hoveredColumn'
|
|
1236
|
+
| 'hoveredRow'
|
|
1237
|
+
> & {
|
|
1242
1238
|
actionCell?: MRT_Cell<TData> | null;
|
|
1243
1239
|
columnFilterFns: MRT_ColumnFilterFnsState;
|
|
1244
1240
|
creatingRow: MRT_Row<TData> | null;
|
|
@@ -1281,10 +1277,42 @@ export type MRT_VirtualizerOptions<
|
|
|
1281
1277
|
TItemElement extends Element = Element,
|
|
1282
1278
|
> = VirtualizerOptions<TScrollElement, TItemElement>;
|
|
1283
1279
|
|
|
1284
|
-
export type MRT_VisibilityState =
|
|
1280
|
+
export type MRT_VisibilityState = ColumnVisibilityState;
|
|
1285
1281
|
|
|
1286
1282
|
export type Prettify<T> = unknown & { [K in keyof T]: T[K] };
|
|
1287
1283
|
|
|
1288
1284
|
export type Xor<A, B> =
|
|
1289
1285
|
| Prettify<A & { [k in keyof B]?: never }>
|
|
1290
1286
|
| Prettify<B & { [k in keyof A]?: never }>;
|
|
1287
|
+
|
|
1288
|
+
interface MRT_StateExtras {
|
|
1289
|
+
actionCell?: Cell<MRT_TableFeatures, any> | null;
|
|
1290
|
+
columnFilterFns: MRT_ColumnFilterFnsState;
|
|
1291
|
+
creatingRow: null | Row<MRT_TableFeatures, any>;
|
|
1292
|
+
density: MRT_DensityState;
|
|
1293
|
+
draggingColumn: Column<MRT_TableFeatures, any> | null;
|
|
1294
|
+
draggingRow: null | Row<MRT_TableFeatures, any>;
|
|
1295
|
+
editingCell: Cell<MRT_TableFeatures, any> | null;
|
|
1296
|
+
editingRow: null | Row<MRT_TableFeatures, any>;
|
|
1297
|
+
globalFilterFn: MRT_FilterOption;
|
|
1298
|
+
hoveredColumn: null | Partial<Column<MRT_TableFeatures, any>>;
|
|
1299
|
+
hoveredRow: null | Partial<Row<MRT_TableFeatures, any>>;
|
|
1300
|
+
isFullScreen: boolean;
|
|
1301
|
+
isLoading: boolean;
|
|
1302
|
+
isSaving: boolean;
|
|
1303
|
+
showAlertBanner: boolean;
|
|
1304
|
+
showColumnFilters: boolean;
|
|
1305
|
+
showGlobalFilter: boolean;
|
|
1306
|
+
showLoadingOverlay: boolean;
|
|
1307
|
+
showProgressBars: boolean;
|
|
1308
|
+
showSkeletons: boolean;
|
|
1309
|
+
showToolbarDropZone: boolean;
|
|
1310
|
+
}
|
|
1311
|
+
|
|
1312
|
+
interface MRT_TableOptionExtras<TData extends MRT_RowData> {
|
|
1313
|
+
globalFilterFn?: MRT_FilterOption;
|
|
1314
|
+
icons: MRT_Icons;
|
|
1315
|
+
localization: MRT_Localization;
|
|
1316
|
+
mrtTheme: Required<MRT_Theme>;
|
|
1317
|
+
state: MRT_StatefulState<TData>;
|
|
1318
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type Row } from '@tanstack/react-table';
|
|
2
1
|
import { useMemo } from 'react';
|
|
3
2
|
|
|
4
3
|
import {
|
|
@@ -14,19 +13,29 @@ import {
|
|
|
14
13
|
type MRT_TableInstance,
|
|
15
14
|
} from '../types';
|
|
16
15
|
|
|
16
|
+
export const getSubColumnDefs = <TData extends MRT_RowData>(
|
|
17
|
+
columnDef: MRT_ColumnDef<TData>,
|
|
18
|
+
): ReadonlyArray<MRT_ColumnDef<TData>> | undefined =>
|
|
19
|
+
'columns' in columnDef ? columnDef.columns : undefined;
|
|
20
|
+
|
|
17
21
|
export const getColumnId = <TData extends MRT_RowData>(
|
|
18
22
|
columnDef: MRT_ColumnDef<TData>,
|
|
19
23
|
): string =>
|
|
20
|
-
columnDef.id ??
|
|
24
|
+
columnDef.id ??
|
|
25
|
+
('accessorKey' in columnDef
|
|
26
|
+
? columnDef.accessorKey?.toString?.()
|
|
27
|
+
: undefined) ??
|
|
28
|
+
columnDef.header;
|
|
21
29
|
|
|
22
30
|
export const getAllLeafColumnDefs = <TData extends MRT_RowData>(
|
|
23
|
-
columns: MRT_ColumnDef<TData
|
|
31
|
+
columns: ReadonlyArray<MRT_ColumnDef<TData>>,
|
|
24
32
|
): MRT_ColumnDef<TData>[] => {
|
|
25
33
|
const allLeafColumnDefs: MRT_ColumnDef<TData>[] = [];
|
|
26
|
-
const getLeafColumns = (cols: MRT_ColumnDef<TData
|
|
34
|
+
const getLeafColumns = (cols: ReadonlyArray<MRT_ColumnDef<TData>>) => {
|
|
27
35
|
cols.forEach((col) => {
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
const subColumnDefs = getSubColumnDefs(col);
|
|
37
|
+
if (subColumnDefs) {
|
|
38
|
+
getLeafColumns(subColumnDefs);
|
|
30
39
|
} else {
|
|
31
40
|
allLeafColumnDefs.push(col);
|
|
32
41
|
}
|
|
@@ -47,7 +56,7 @@ export const prepareColumns = <TData extends MRT_RowData>({
|
|
|
47
56
|
aggregationFns = {},
|
|
48
57
|
defaultDisplayColumn,
|
|
49
58
|
filterFns = {},
|
|
50
|
-
|
|
59
|
+
sortFns = {},
|
|
51
60
|
state: { columnFilterFns = {} } = {},
|
|
52
61
|
} = tableOptions;
|
|
53
62
|
return columnDefs.map((columnDef) => {
|
|
@@ -55,25 +64,22 @@ export const prepareColumns = <TData extends MRT_RowData>({
|
|
|
55
64
|
if (!columnDef.id) columnDef.id = getColumnId(columnDef);
|
|
56
65
|
//assign columnDefType
|
|
57
66
|
if (!columnDef.columnDefType) columnDef.columnDefType = 'data';
|
|
58
|
-
|
|
67
|
+
const subColumnDefs = getSubColumnDefs(columnDef);
|
|
68
|
+
if (subColumnDefs?.length && 'columns' in columnDef) {
|
|
59
69
|
columnDef.columnDefType = 'group';
|
|
60
70
|
//recursively prepare columns if this is a group column
|
|
61
71
|
columnDef.columns = prepareColumns({
|
|
62
|
-
columnDefs:
|
|
72
|
+
columnDefs: [...subColumnDefs],
|
|
63
73
|
tableOptions,
|
|
64
74
|
});
|
|
65
75
|
} else if (columnDef.columnDefType === 'data') {
|
|
66
76
|
//assign aggregationFns if multiple aggregationFns are provided
|
|
67
77
|
if (Array.isArray(columnDef.aggregationFn)) {
|
|
68
78
|
const aggFns = columnDef.aggregationFn as string[];
|
|
69
|
-
columnDef.aggregationFn =
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
) =>
|
|
74
|
-
aggFns.map((fn) =>
|
|
75
|
-
aggregationFns[fn]?.(columnId, leafRows, childRows),
|
|
76
|
-
);
|
|
79
|
+
columnDef.aggregationFn = {
|
|
80
|
+
aggregate: (context) =>
|
|
81
|
+
aggFns.map((fn) => aggregationFns[fn]?.aggregate(context)),
|
|
82
|
+
};
|
|
77
83
|
}
|
|
78
84
|
|
|
79
85
|
//assign filterFns
|
|
@@ -84,10 +90,9 @@ export const prepareColumns = <TData extends MRT_RowData>({
|
|
|
84
90
|
columnFilterFns[columnDef.id];
|
|
85
91
|
}
|
|
86
92
|
|
|
87
|
-
//assign
|
|
88
|
-
if (Object.keys(
|
|
89
|
-
|
|
90
|
-
columnDef.sortingFn = sortingFns[columnDef.sortingFn];
|
|
93
|
+
//assign sortFns
|
|
94
|
+
if (Object.keys(sortFns).includes(columnDef.sortFn as string)) {
|
|
95
|
+
columnDef.sortFn = sortFns[columnDef.sortFn as string];
|
|
91
96
|
}
|
|
92
97
|
} else if (columnDef.columnDefType === 'display') {
|
|
93
98
|
columnDef = {
|
|
@@ -117,7 +122,7 @@ export const reorderColumn = <TData extends MRT_RowData>(
|
|
|
117
122
|
};
|
|
118
123
|
|
|
119
124
|
export const getDefaultColumnFilterFn = <TData extends MRT_RowData>(
|
|
120
|
-
columnDef: MRT_ColumnDef<TData>,
|
|
125
|
+
columnDef: Pick<MRT_ColumnDef<TData>, 'filterVariant'>,
|
|
121
126
|
): MRT_FilterOption => {
|
|
122
127
|
const { filterVariant } = columnDef;
|
|
123
128
|
if (filterVariant === 'multi-select') return 'arrIncludesSome';
|
|
@@ -145,17 +150,19 @@ export const getColumnFilterInfo = <TData extends MRT_RowData>({
|
|
|
145
150
|
filterVariant?.startsWith('date') || filterVariant?.startsWith('time')
|
|
146
151
|
);
|
|
147
152
|
const isAutocompleteFilter = filterVariant === 'autocomplete';
|
|
153
|
+
const currentFilterOption =
|
|
154
|
+
columnDef._filterFn ?? getDefaultColumnFilterFn(columnDef);
|
|
155
|
+
|
|
148
156
|
const isRangeFilter =
|
|
149
157
|
filterVariant?.includes('range') ||
|
|
150
158
|
['between', 'betweenInclusive', 'inNumberRange'].includes(
|
|
151
|
-
|
|
159
|
+
currentFilterOption,
|
|
152
160
|
);
|
|
153
161
|
const isSelectFilter = filterVariant === 'select';
|
|
154
162
|
const isMultiSelectFilter = filterVariant === 'multi-select';
|
|
155
163
|
const isTextboxFilter =
|
|
156
164
|
['autocomplete', 'text'].includes(filterVariant!) ||
|
|
157
165
|
(!isSelectFilter && !isMultiSelectFilter);
|
|
158
|
-
const currentFilterOption = columnDef._filterFn;
|
|
159
166
|
|
|
160
167
|
const allowedColumnFilterOptions =
|
|
161
168
|
columnDef?.columnFilterModeOptions ?? columnFilterModeOptions;
|