material-react-table 2.4.0 → 2.4.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 +43 -28
- package/dist/index.esm.js +65 -61
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +65 -61
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/body/MRT_TableBody.tsx +5 -12
- package/src/body/MRT_TableBodyRow.tsx +2 -3
- package/src/column.utils.ts +2 -1
- package/src/footer/MRT_TableFooter.tsx +0 -4
- package/src/footer/MRT_TableFooterRow.tsx +2 -4
- package/src/head/MRT_TableHead.tsx +0 -4
- package/src/head/MRT_TableHeadRow.tsx +2 -4
- package/src/hooks/useMRT_ColumnVirtualizer.ts +29 -26
- package/src/hooks/useMRT_RowVirtualizer.ts +7 -3
- package/src/menus/MRT_ColumnActionMenu.tsx +8 -1
- package/src/style.utils.ts +0 -19
- package/src/table/MRT_Table.tsx +0 -5
- package/src/toolbar/MRT_TablePagination.tsx +45 -33
- package/src/types.ts +37 -20
package/dist/index.d.ts
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
2
2
|
import { CSSProperties, MutableRefObject, Dispatch, SetStateAction, ReactNode, RefObject, DragEventHandler, MouseEvent } from 'react';
|
3
3
|
import * as _tanstack_react_table from '@tanstack/react-table';
|
4
|
-
import { Row, AccessorFn, DeepKeys, DeepValue, Table, TableState, ColumnDef, Column, Header, HeaderGroup, Cell, AggregationFn, SortingFn, FilterFn, TableOptions, OnChangeFn, RowPinningPosition,
|
5
|
-
|
6
|
-
import { Virtualizer, VirtualizerOptions, VirtualItem, Range } from '@tanstack/react-virtual';
|
7
|
-
export { VirtualItem as MRT_VirtualItem, Virtualizer as MRT_Virtualizer, VirtualizerOptions as MRT_VirtualizerOptions } from '@tanstack/react-virtual';
|
4
|
+
import { Row, ColumnFiltersState, ColumnOrderState, ColumnPinningState, ColumnSizingInfoState, ColumnSizingState, ExpandedState, GroupingState, PaginationState, RowSelectionState, SortingState, Updater, VisibilityState, AccessorFn, DeepKeys, DeepValue, Table, TableState, ColumnDef, Column, Header, HeaderGroup, Cell, AggregationFn, SortingFn, FilterFn, TableOptions, OnChangeFn, RowPinningPosition, Renderable } from '@tanstack/react-table';
|
5
|
+
import { VirtualItem, VirtualizerOptions, Virtualizer, Range } from '@tanstack/react-virtual';
|
8
6
|
import { AlertProps } from '@mui/material/Alert';
|
9
7
|
import { AutocompleteProps } from '@mui/material/Autocomplete';
|
10
8
|
import { BoxProps } from '@mui/material/Box';
|
@@ -177,12 +175,32 @@ type Xor<A, B> = Prettify<A & {
|
|
177
175
|
type MRT_DensityState = 'comfortable' | 'compact' | 'spacious';
|
178
176
|
type MRT_ColumnFilterFnsState = Record<string, MRT_FilterOption>;
|
179
177
|
type MRT_RowData = Record<string, any>;
|
180
|
-
|
178
|
+
type MRT_ColumnFiltersState = ColumnFiltersState;
|
179
|
+
type MRT_ColumnOrderState = ColumnOrderState;
|
180
|
+
type MRT_ColumnPinningState = ColumnPinningState;
|
181
|
+
type MRT_ColumnSizingInfoState = ColumnSizingInfoState;
|
182
|
+
type MRT_ColumnSizingState = ColumnSizingState;
|
183
|
+
type MRT_ExpandedState = ExpandedState;
|
184
|
+
type MRT_GroupingState = GroupingState;
|
185
|
+
type MRT_PaginationState = PaginationState;
|
186
|
+
type MRT_RowSelectionState = RowSelectionState;
|
187
|
+
type MRT_SortingState = SortingState;
|
188
|
+
type MRT_Updater<T> = Updater<T>;
|
189
|
+
type MRT_VirtualItem = VirtualItem;
|
190
|
+
type MRT_VisibilityState = VisibilityState;
|
191
|
+
type MRT_VirtualizerOptions<TScrollElement extends Element | Window = Element | Window, TItemElement extends Element = Element> = VirtualizerOptions<TScrollElement, TItemElement>;
|
181
192
|
type MRT_ColumnVirtualizer<TScrollElement extends Element | Window = HTMLDivElement, TItemElement extends Element = HTMLTableCellElement> = Virtualizer<TScrollElement, TItemElement> & {
|
193
|
+
virtualColumns: MRT_VirtualItem[];
|
182
194
|
virtualPaddingLeft?: number;
|
183
195
|
virtualPaddingRight?: number;
|
184
196
|
};
|
185
|
-
type MRT_RowVirtualizer<TScrollElement extends Element | Window = HTMLDivElement, TItemElement extends Element = HTMLTableRowElement> = Virtualizer<TScrollElement, TItemElement
|
197
|
+
type MRT_RowVirtualizer<TScrollElement extends Element | Window = HTMLDivElement, TItemElement extends Element = HTMLTableRowElement> = Virtualizer<TScrollElement, TItemElement> & {
|
198
|
+
virtualRows: MRT_VirtualItem[];
|
199
|
+
};
|
200
|
+
/**
|
201
|
+
* @deprecated use `MRT_ColumnVirtualizer` or `MRT_RowVirtualizer` instead
|
202
|
+
*/
|
203
|
+
type MRT_Virtualizer<_TScrollElement = any, _TItemElement = any> = MRT_ColumnVirtualizer | MRT_RowVirtualizer;
|
186
204
|
type MRT_ColumnHelper<TData extends MRT_RowData> = {
|
187
205
|
accessor: <TAccessor extends AccessorFn<TData> | DeepKeys<TData>, TValue extends TAccessor extends AccessorFn<TData, infer TReturn> ? TReturn : TAccessor extends DeepKeys<TData> ? DeepValue<TData, TAccessor> : never>(accessor: TAccessor, column: MRT_DisplayColumnDef<TData, TValue>) => MRT_ColumnDef<TData, TValue>;
|
188
206
|
display: (column: MRT_DisplayColumnDef<TData>) => MRT_ColumnDef<TData>;
|
@@ -628,7 +646,7 @@ type MRT_DisplayColumnIds = 'mrt-row-actions' | 'mrt-row-drag' | 'mrt-row-expand
|
|
628
646
|
type MRT_TableOptions<TData extends MRT_RowData> = Omit<Partial<TableOptions<TData>>, 'columns' | 'data' | 'defaultColumn' | 'enableRowSelection' | 'expandRowsFn' | 'getRowId' | 'globalFilterFn' | 'initialState' | 'onStateChange' | 'state'> & {
|
629
647
|
columnFilterDisplayMode?: 'custom' | 'popover' | 'subheader';
|
630
648
|
columnFilterModeOptions?: Array<LiteralUnion<string & MRT_FilterOption>> | null;
|
631
|
-
columnVirtualizerInstanceRef?: MutableRefObject<MRT_ColumnVirtualizer | null>;
|
649
|
+
columnVirtualizerInstanceRef?: MutableRefObject<MRT_ColumnVirtualizer | MRT_Virtualizer | null>;
|
632
650
|
columnVirtualizerOptions?: ((props: {
|
633
651
|
table: MRT_TableInstance<TData>;
|
634
652
|
}) => Partial<VirtualizerOptions<HTMLDivElement, HTMLTableCellElement>>) | Partial<VirtualizerOptions<HTMLDivElement, HTMLTableCellElement>>;
|
@@ -802,6 +820,7 @@ type MRT_TableOptions<TData extends MRT_RowData> = Omit<Partial<TableOptions<TDa
|
|
802
820
|
table: MRT_TableInstance<TData>;
|
803
821
|
}) => Partial<PaginationProps & {
|
804
822
|
SelectProps?: Partial<SelectProps>;
|
823
|
+
disabled?: boolean;
|
805
824
|
rowsPerPageOptions?: {
|
806
825
|
label: string;
|
807
826
|
value: number;
|
@@ -809,6 +828,7 @@ type MRT_TableOptions<TData extends MRT_RowData> = Omit<Partial<TableOptions<TDa
|
|
809
828
|
showRowsPerPage?: boolean;
|
810
829
|
}>) | Partial<PaginationProps & {
|
811
830
|
SelectProps?: Partial<SelectProps>;
|
831
|
+
disabled?: boolean;
|
812
832
|
rowsPerPageOptions?: {
|
813
833
|
label: string;
|
814
834
|
value: number;
|
@@ -1001,7 +1021,7 @@ type MRT_TableOptions<TData extends MRT_RowData> = Omit<Partial<TableOptions<TDa
|
|
1001
1021
|
rowCount?: number;
|
1002
1022
|
rowNumberDisplayMode?: 'original' | 'static';
|
1003
1023
|
rowPinningDisplayMode?: 'bottom' | 'select-bottom' | 'select-sticky' | 'select-top' | 'sticky' | 'top' | 'top-and-bottom';
|
1004
|
-
rowVirtualizerInstanceRef?: MutableRefObject<MRT_RowVirtualizer | null>;
|
1024
|
+
rowVirtualizerInstanceRef?: MutableRefObject<MRT_RowVirtualizer | MRT_Virtualizer | null>;
|
1005
1025
|
rowVirtualizerOptions?: ((props: {
|
1006
1026
|
table: MRT_TableInstance<TData>;
|
1007
1027
|
}) => Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>>) | Partial<VirtualizerOptions<HTMLDivElement, HTMLTableRowElement>>;
|
@@ -1021,10 +1041,9 @@ declare const MaterialReactTable: <TData extends MRT_RowData>(props: Props$U<TDa
|
|
1021
1041
|
interface Props$T<TData extends MRT_RowData> extends TableBodyProps {
|
1022
1042
|
columnVirtualizer?: MRT_ColumnVirtualizer;
|
1023
1043
|
table: MRT_TableInstance<TData>;
|
1024
|
-
virtualColumns?: VirtualItem[];
|
1025
1044
|
}
|
1026
|
-
declare const MRT_TableBody: <TData extends MRT_RowData>({ columnVirtualizer, table,
|
1027
|
-
declare const Memo_MRT_TableBody: <TData extends MRT_RowData>({ columnVirtualizer, table,
|
1045
|
+
declare const MRT_TableBody: <TData extends MRT_RowData>({ columnVirtualizer, table, ...rest }: Props$T<TData>) => react_jsx_runtime.JSX.Element;
|
1046
|
+
declare const Memo_MRT_TableBody: <TData extends MRT_RowData>({ columnVirtualizer, table, ...rest }: Props$T<TData>) => react_jsx_runtime.JSX.Element;
|
1028
1047
|
|
1029
1048
|
interface Props$S<TData extends MRT_RowData> extends TableCellProps {
|
1030
1049
|
cell: MRT_Cell<TData>;
|
@@ -1052,11 +1071,10 @@ interface Props$Q<TData extends MRT_RowData> {
|
|
1052
1071
|
row: MRT_Row<TData>;
|
1053
1072
|
rowIndex: number;
|
1054
1073
|
table: MRT_TableInstance<TData>;
|
1055
|
-
virtualColumns?: VirtualItem[];
|
1056
1074
|
virtualRow?: VirtualItem;
|
1057
1075
|
}
|
1058
|
-
declare const MRT_TableBodyRow: <TData extends MRT_RowData>({ columnVirtualizer, measureElement, numRows, pinnedRowIds, row, rowIndex, table,
|
1059
|
-
declare const Memo_MRT_TableBodyRow: <TData extends MRT_RowData>({ columnVirtualizer, measureElement, numRows, pinnedRowIds, row, rowIndex, table,
|
1076
|
+
declare const MRT_TableBodyRow: <TData extends MRT_RowData>({ columnVirtualizer, measureElement, numRows, pinnedRowIds, row, rowIndex, table, virtualRow, }: Props$Q<TData>) => react_jsx_runtime.JSX.Element;
|
1077
|
+
declare const Memo_MRT_TableBodyRow: <TData extends MRT_RowData>({ columnVirtualizer, measureElement, numRows, pinnedRowIds, row, rowIndex, table, virtualRow, }: Props$Q<TData>) => react_jsx_runtime.JSX.Element;
|
1060
1078
|
|
1061
1079
|
interface Props$P<TData extends MRT_RowData> extends IconButtonProps {
|
1062
1080
|
row: MRT_Row<TData>;
|
@@ -1253,8 +1271,8 @@ declare const prepareColumns: <TData extends MRT_RowData>({ aggregationFns, colu
|
|
1253
1271
|
basic: _tanstack_react_table.SortingFn<any>;
|
1254
1272
|
} & Record<string, _tanstack_react_table.SortingFn<any>>;
|
1255
1273
|
}) => MRT_DefinedColumnDef<TData>[];
|
1256
|
-
declare const reorderColumn: <TData extends MRT_RowData>(draggedColumn: MRT_Column<TData>, targetColumn: MRT_Column<TData>, columnOrder: ColumnOrderState) => ColumnOrderState;
|
1257
|
-
declare const showExpandColumn: <TData extends MRT_RowData>(props: MRT_TableOptions<TData>, grouping?:
|
1274
|
+
declare const reorderColumn: <TData extends MRT_RowData>(draggedColumn: MRT_Column<TData>, targetColumn: MRT_Column<TData>, columnOrder: _tanstack_react_table.ColumnOrderState) => _tanstack_react_table.ColumnOrderState;
|
1275
|
+
declare const showExpandColumn: <TData extends MRT_RowData>(props: MRT_TableOptions<TData>, grouping?: MRT_GroupingState) => boolean;
|
1258
1276
|
declare const getLeadingDisplayColumnIds: <TData extends MRT_RowData>(props: MRT_TableOptions<TData>) => MRT_DisplayColumnIds[];
|
1259
1277
|
declare const getTrailingDisplayColumnIds: <TData extends MRT_RowData>(props: MRT_TableOptions<TData>) => MRT_DisplayColumnIds[];
|
1260
1278
|
declare const getDefaultColumnOrderIds: <TData extends MRT_RowData>(props: MRT_TableOptions<TData>) => string[];
|
@@ -1268,7 +1286,7 @@ declare const getCanRankRows: <TData extends MRT_RowData>(table: MRT_TableInstan
|
|
1268
1286
|
declare const parseFromValuesOrFunc: <T, U>(fn: T | ((arg: U) => T) | undefined, arg: U) => T | undefined;
|
1269
1287
|
declare const flexRender: (Comp: Renderable<any>, props: any) => JSX.Element | ReactNode;
|
1270
1288
|
declare const createRow: <TData extends MRT_RowData>(table: MRT_TableInstance<TData>, originalRow?: TData | undefined) => MRT_Row<TData>;
|
1271
|
-
declare const extraIndexRangeExtractor: (range: Range, draggingIndex
|
1289
|
+
declare const extraIndexRangeExtractor: (range: Range, draggingIndex?: number) => number[];
|
1272
1290
|
declare function createMRTColumnHelper<TData extends MRT_RowData>(): MRT_ColumnHelper<TData>;
|
1273
1291
|
declare const getValueAndLabel: (option: {
|
1274
1292
|
label?: string;
|
@@ -1282,9 +1300,8 @@ declare const getValueAndLabel: (option: {
|
|
1282
1300
|
interface Props$z<TData extends MRT_RowData> extends TableFooterProps {
|
1283
1301
|
columnVirtualizer?: MRT_ColumnVirtualizer;
|
1284
1302
|
table: MRT_TableInstance<TData>;
|
1285
|
-
virtualColumns?: VirtualItem[];
|
1286
1303
|
}
|
1287
|
-
declare const MRT_TableFooter: <TData extends MRT_RowData>({ columnVirtualizer, table,
|
1304
|
+
declare const MRT_TableFooter: <TData extends MRT_RowData>({ columnVirtualizer, table, ...rest }: Props$z<TData>) => react_jsx_runtime.JSX.Element;
|
1288
1305
|
|
1289
1306
|
interface Props$y<TData extends MRT_RowData> extends TableCellProps {
|
1290
1307
|
footer: MRT_Header<TData>;
|
@@ -1296,16 +1313,14 @@ interface Props$x<TData extends MRT_RowData> extends TableRowProps {
|
|
1296
1313
|
columnVirtualizer?: MRT_ColumnVirtualizer;
|
1297
1314
|
footerGroup: MRT_HeaderGroup<TData>;
|
1298
1315
|
table: MRT_TableInstance<TData>;
|
1299
|
-
virtualColumns?: VirtualItem[];
|
1300
1316
|
}
|
1301
|
-
declare const MRT_TableFooterRow: <TData extends MRT_RowData>({ columnVirtualizer, footerGroup, table,
|
1317
|
+
declare const MRT_TableFooterRow: <TData extends MRT_RowData>({ columnVirtualizer, footerGroup, table, ...rest }: Props$x<TData>) => react_jsx_runtime.JSX.Element | null;
|
1302
1318
|
|
1303
1319
|
interface Props$w<TData extends MRT_RowData> extends TableHeadProps {
|
1304
1320
|
columnVirtualizer?: MRT_ColumnVirtualizer;
|
1305
1321
|
table: MRT_TableInstance<TData>;
|
1306
|
-
virtualColumns?: VirtualItem[];
|
1307
1322
|
}
|
1308
|
-
declare const MRT_TableHead: <TData extends MRT_RowData>({ columnVirtualizer, table,
|
1323
|
+
declare const MRT_TableHead: <TData extends MRT_RowData>({ columnVirtualizer, table, ...rest }: Props$w<TData>) => react_jsx_runtime.JSX.Element;
|
1309
1324
|
|
1310
1325
|
interface Props$v<TData extends MRT_RowData> extends TableCellProps {
|
1311
1326
|
header: MRT_Header<TData>;
|
@@ -1354,16 +1369,15 @@ interface Props$o<TData extends MRT_RowData> extends TableRowProps {
|
|
1354
1369
|
columnVirtualizer?: MRT_ColumnVirtualizer;
|
1355
1370
|
headerGroup: MRT_HeaderGroup<TData>;
|
1356
1371
|
table: MRT_TableInstance<TData>;
|
1357
|
-
virtualColumns?: VirtualItem[];
|
1358
1372
|
}
|
1359
|
-
declare const MRT_TableHeadRow: <TData extends MRT_RowData>({ columnVirtualizer, headerGroup, table,
|
1373
|
+
declare const MRT_TableHeadRow: <TData extends MRT_RowData>({ columnVirtualizer, headerGroup, table, ...rest }: Props$o<TData>) => react_jsx_runtime.JSX.Element;
|
1360
1374
|
|
1361
1375
|
declare const useMRT_ColumnVirtualizer: <TData extends MRT_RowData, TScrollElement extends Element | Window = HTMLDivElement, TItemElement extends Element = HTMLTableCellElement>(table: MRT_TableInstance<TData>) => MRT_ColumnVirtualizer | undefined;
|
1362
1376
|
|
1363
1377
|
interface Params<TData extends MRT_RowData> {
|
1364
|
-
columnOrder:
|
1378
|
+
columnOrder: MRT_ColumnOrderState;
|
1365
1379
|
creatingRow: MRT_Row<TData> | null;
|
1366
|
-
grouping:
|
1380
|
+
grouping: MRT_GroupingState;
|
1367
1381
|
tableOptions: MRT_DefinedTableOptions<TData>;
|
1368
1382
|
}
|
1369
1383
|
declare const useMRT_DisplayColumns: <TData extends MRT_RowData>(params: Params<TData>) => MRT_ColumnDef<TData>[];
|
@@ -1564,6 +1578,7 @@ interface Props$5<TData extends MRT_RowData> extends LinearProgressProps {
|
|
1564
1578
|
declare const MRT_LinearProgressBar: <TData extends MRT_RowData>({ isTopToolbar, table, ...rest }: Props$5<TData>) => react_jsx_runtime.JSX.Element;
|
1565
1579
|
|
1566
1580
|
interface Props$4<TData extends MRT_RowData> extends Partial<PaginationProps & {
|
1581
|
+
SelectProps?: Partial<SelectProps>;
|
1567
1582
|
disabled?: boolean;
|
1568
1583
|
rowsPerPageOptions?: {
|
1569
1584
|
label: string;
|
@@ -1599,4 +1614,4 @@ declare const MRT_TopToolbar: <TData extends MRT_RowData>({ table, }: Props<TDat
|
|
1599
1614
|
|
1600
1615
|
declare const useMaterialReactTable: <TData extends MRT_RowData>(tableOptions: MRT_TableOptions<TData>) => MRT_TableInstance<TData>;
|
1601
1616
|
|
1602
|
-
export { type LiteralUnion, type MRT_AggregationFn, MRT_AggregationFns, type MRT_AggregationOption, MRT_BottomToolbar, type MRT_Cell, type MRT_Column, MRT_ColumnActionMenu, type MRT_ColumnDef, type MRT_ColumnFilterFnsState, type MRT_ColumnHelper, MRT_ColumnPinningButtons, type MRT_ColumnVirtualizer, MRT_CopyButton, MRT_DefaultColumn, MRT_DefaultDisplayColumn, type MRT_DefinedColumnDef, type MRT_DefinedTableOptions, type MRT_DensityState, type MRT_DisplayColumnDef, type MRT_DisplayColumnIds, MRT_EditActionButtons, MRT_EditCellTextField, MRT_EditRowModal, MRT_ExpandAllButton, MRT_ExpandButton, MRT_FilterCheckbox, type MRT_FilterFn, MRT_FilterFns, type MRT_FilterOption, MRT_FilterOptionMenu, MRT_FilterRangeFields, MRT_FilterRangeSlider, MRT_FilterTextField, MRT_GlobalFilterTextField, MRT_GrabHandleButton, type MRT_GroupColumnDef, type MRT_Header, type MRT_HeaderGroup, type MRT_Icons, type MRT_InternalFilterOption, MRT_LinearProgressBar, type MRT_Localization, type MRT_Row, MRT_RowActionMenu, type MRT_RowData, type MRT_RowModel, MRT_RowPinButton, type MRT_RowVirtualizer, MRT_SelectCheckbox, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, type MRT_SortingFn, MRT_SortingFns, type MRT_SortingOption, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellColumnActionsButton, MRT_TableHeadCellFilterContainer, MRT_TableHeadCellFilterLabel, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, type MRT_TableInstance, MRT_TableLoadingOverlay, type MRT_TableOptions, MRT_TablePagination, MRT_TablePaper, type MRT_TableState, type MRT_Theme, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleFullScreenButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, type Prettify, type Xor, commonListItemStyles, commonMenuItemStyles, createMRTColumnHelper, createRow, extraIndexRangeExtractor, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnId, getCommonMRTCellStyles, getCommonToolbarStyles, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsFirstColumn, getIsFirstRightPinnedColumn, getIsLastColumn, getIsLastLeftPinnedColumn, getLeadingDisplayColumnIds, getMRTTheme, getTotalRight, getTrailingDisplayColumnIds, getValueAndLabel, mrtFilterOptions, parseCSSVarId, parseFromValuesOrFunc, prepareColumns, rankGlobalFuzzy, reorderColumn, showExpandColumn, useMRT_ColumnVirtualizer, useMRT_DisplayColumns, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
|
1617
|
+
export { type LiteralUnion, type MRT_AggregationFn, MRT_AggregationFns, type MRT_AggregationOption, MRT_BottomToolbar, type MRT_Cell, type MRT_Column, MRT_ColumnActionMenu, type MRT_ColumnDef, type MRT_ColumnFilterFnsState, type MRT_ColumnFiltersState, type MRT_ColumnHelper, type MRT_ColumnOrderState, MRT_ColumnPinningButtons, type MRT_ColumnPinningState, type MRT_ColumnSizingInfoState, type MRT_ColumnSizingState, type MRT_ColumnVirtualizer, MRT_CopyButton, MRT_DefaultColumn, MRT_DefaultDisplayColumn, type MRT_DefinedColumnDef, type MRT_DefinedTableOptions, type MRT_DensityState, type MRT_DisplayColumnDef, type MRT_DisplayColumnIds, MRT_EditActionButtons, MRT_EditCellTextField, MRT_EditRowModal, MRT_ExpandAllButton, MRT_ExpandButton, type MRT_ExpandedState, MRT_FilterCheckbox, type MRT_FilterFn, MRT_FilterFns, type MRT_FilterOption, MRT_FilterOptionMenu, MRT_FilterRangeFields, MRT_FilterRangeSlider, MRT_FilterTextField, MRT_GlobalFilterTextField, MRT_GrabHandleButton, type MRT_GroupColumnDef, type MRT_GroupingState, type MRT_Header, type MRT_HeaderGroup, type MRT_Icons, type MRT_InternalFilterOption, MRT_LinearProgressBar, type MRT_Localization, type MRT_PaginationState, type MRT_Row, MRT_RowActionMenu, type MRT_RowData, type MRT_RowModel, MRT_RowPinButton, type MRT_RowSelectionState, type MRT_RowVirtualizer, MRT_SelectCheckbox, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, type MRT_SortingFn, MRT_SortingFns, type MRT_SortingOption, type MRT_SortingState, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellColumnActionsButton, MRT_TableHeadCellFilterContainer, MRT_TableHeadCellFilterLabel, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, type MRT_TableInstance, MRT_TableLoadingOverlay, type MRT_TableOptions, MRT_TablePagination, MRT_TablePaper, type MRT_TableState, type MRT_Theme, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleFullScreenButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, type MRT_Updater, type MRT_VirtualItem, type MRT_Virtualizer, type MRT_VirtualizerOptions, type MRT_VisibilityState, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, type Prettify, type Xor, commonListItemStyles, commonMenuItemStyles, createMRTColumnHelper, createRow, extraIndexRangeExtractor, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnId, getCommonMRTCellStyles, getCommonToolbarStyles, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsFirstColumn, getIsFirstRightPinnedColumn, getIsLastColumn, getIsLastLeftPinnedColumn, getLeadingDisplayColumnIds, getMRTTheme, getTotalRight, getTrailingDisplayColumnIds, getValueAndLabel, mrtFilterOptions, parseCSSVarId, parseFromValuesOrFunc, prepareColumns, rankGlobalFuzzy, reorderColumn, showExpandColumn, useMRT_ColumnVirtualizer, useMRT_DisplayColumns, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
|
package/dist/index.esm.js
CHANGED
@@ -297,6 +297,8 @@ const createRow = (table, originalRow) => createRow$1(table, 'mrt-row-create', o
|
|
297
297
|
}))), -1, 0);
|
298
298
|
const extraIndexRangeExtractor = (range, draggingIndex) => {
|
299
299
|
const newIndexes = defaultRangeExtractor(range);
|
300
|
+
if (draggingIndex === undefined)
|
301
|
+
return newIndexes;
|
300
302
|
if (draggingIndex >= 0 &&
|
301
303
|
draggingIndex < Math.max(range.startIndex - range.overscan, 0)) {
|
302
304
|
newIndexes.unshift(draggingIndex);
|
@@ -341,7 +343,7 @@ const getMRTTheme = (table, theme) => (Object.assign({ baseBackgroundColor: them
|
|
341
343
|
? darken(theme.palette.warning.dark, 0.25)
|
342
344
|
: lighten(theme.palette.warning.light, 0.5), pinnedRowBackgroundColor: alpha(theme.palette.primary.main, 0.1), selectedRowBackgroundColor: alpha(theme.palette.primary.main, 0.2) }, parseFromValuesOrFunc(table.options.mrtTheme, theme)));
|
343
345
|
const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
|
344
|
-
var _a, _b, _c, _d, _e, _f
|
346
|
+
var _a, _b, _c, _d, _e, _f;
|
345
347
|
const { options: { layoutMode }, } = table;
|
346
348
|
const widthStyles = {
|
347
349
|
minWidth: `max(calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId((_a = header === null || header === void 0 ? void 0 : header.id) !== null && _a !== void 0 ? _a : column.id)}-size) * 1px), ${(_b = column.columnDef.minSize) !== null && _b !== void 0 ? _b : 30}px)`,
|
@@ -361,19 +363,8 @@ const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme,
|
|
361
363
|
? `4px 0 8px -6px ${alpha(theme.palette.grey[700], 0.5)} inset`
|
362
364
|
: undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, left: column.getIsPinned() === 'left'
|
363
365
|
? `${column.getStart('left')}px`
|
364
|
-
: undefined,
|
365
|
-
|
366
|
-
column.getPinnedIndex() === 0
|
367
|
-
? `-${column.getSize() *
|
368
|
-
((_f = (_e = table.getState().columnPinning.left) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 1)}px`
|
369
|
-
: undefined, mr: table.options.enableColumnVirtualization &&
|
370
|
-
column.getIsPinned() === 'right' &&
|
371
|
-
column.getPinnedIndex() === table.getVisibleLeafColumns().length - 1
|
372
|
-
? `-${column.getSize() *
|
373
|
-
((_h = (_g = table.getState().columnPinning.right) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 1) *
|
374
|
-
1.2}px`
|
375
|
-
: undefined, opacity: ((_j = table.getState().draggingColumn) === null || _j === void 0 ? void 0 : _j.id) === column.id ||
|
376
|
-
((_k = table.getState().hoveredColumn) === null || _k === void 0 ? void 0 : _k.id) === column.id
|
366
|
+
: undefined, opacity: ((_e = table.getState().draggingColumn) === null || _e === void 0 ? void 0 : _e.id) === column.id ||
|
367
|
+
((_f = table.getState().hoveredColumn) === null || _f === void 0 ? void 0 : _f.id) === column.id
|
377
368
|
? 0.5
|
378
369
|
: 1, position: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
379
370
|
? 'sticky'
|
@@ -804,12 +795,12 @@ const MRT_TableDetailPanel = (_a) => {
|
|
804
795
|
: undefined, borderBottom: !row.getIsExpanded() ? 'none' : undefined, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, py: row.getIsExpanded() ? '1rem' : 0, transition: 'all 150ms ease-in-out', width: `${table.getTotalSize()}px` }, parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme))), children: renderDetailPanel && (jsx(Collapse, { in: row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true, children: !isLoading && renderDetailPanel({ row, table }) })) })) })));
|
805
796
|
};
|
806
797
|
|
807
|
-
const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRowIds, row, rowIndex, table,
|
798
|
+
const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRowIds, row, rowIndex, table, virtualRow, }) => {
|
808
799
|
var _a, _b, _c, _d;
|
809
800
|
const theme = useTheme();
|
810
801
|
const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, memoMode, muiTableBodyRowProps, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table;
|
811
802
|
const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, isFullScreen, rowPinning, } = getState();
|
812
|
-
const { virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
|
803
|
+
const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
|
813
804
|
const isPinned = enableRowPinning && row.getIsPinned();
|
814
805
|
const tableRowProps = parseFromValuesOrFunc(muiTableBodyRowProps, {
|
815
806
|
row,
|
@@ -909,7 +900,7 @@ const MRT_TableBodyRow = ({ columnVirtualizer, measureElement, numRows, pinnedRo
|
|
909
900
|
const Memo_MRT_TableBodyRow = memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.rowIndex === next.rowIndex);
|
910
901
|
|
911
902
|
const useMRT_ColumnVirtualizer = (table) => {
|
912
|
-
var _a, _b, _c, _d;
|
903
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
913
904
|
const { getState, options: { columnVirtualizerInstanceRef, columnVirtualizerOptions, enableColumnPinning, enableColumnVirtualization, }, refs: { tableContainerRef }, } = table;
|
914
905
|
const { columnPinning, columnVisibility, draggingColumn } = getState();
|
915
906
|
const columnVirtualizerProps = parseFromValuesOrFunc(columnVirtualizerOptions, {
|
@@ -920,7 +911,8 @@ const useMRT_ColumnVirtualizer = (table) => {
|
|
920
911
|
table.getLeftLeafColumns().map((c) => c.getPinnedIndex()),
|
921
912
|
table
|
922
913
|
.getRightLeafColumns()
|
923
|
-
.map((c) => table.getVisibleLeafColumns().length - c.getPinnedIndex() - 1)
|
914
|
+
.map((c) => table.getVisibleLeafColumns().length - c.getPinnedIndex() - 1)
|
915
|
+
.sort((a, b) => a - b),
|
924
916
|
]
|
925
917
|
: [[], []], [columnPinning, enableColumnVirtualization, enableColumnPinning]);
|
926
918
|
//get first 16 column widths and average them if calc is needed
|
@@ -934,9 +926,11 @@ const useMRT_ColumnVirtualizer = (table) => {
|
|
934
926
|
.rows[0]) === null || _a === void 0 ? void 0 : _a.getCenterVisibleCells()) === null || _b === void 0 ? void 0 : _b.slice(0, 16)) === null || _c === void 0 ? void 0 : _c.map((cell) => cell.column.getSize() * 1.2)) !== null && _d !== void 0 ? _d : [];
|
935
927
|
return columnsWidths.reduce((a, b) => a + b, 0) / columnsWidths.length;
|
936
928
|
}, [table.getRowModel().rows, columnPinning, columnVisibility]);
|
937
|
-
const draggingColumnIndex =
|
938
|
-
|
939
|
-
|
929
|
+
const draggingColumnIndex = (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)
|
930
|
+
? table
|
931
|
+
.getVisibleLeafColumns()
|
932
|
+
.findIndex((c) => c.id === (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id))
|
933
|
+
: undefined;
|
940
934
|
const columnVirtualizer = enableColumnVirtualization
|
941
935
|
? useVirtualizer(Object.assign({ count: table.getVisibleLeafColumns().length, estimateSize: () => averageColumnWidth, getScrollElement: () => tableContainerRef.current, horizontal: true, overscan: 3, rangeExtractor: useCallback((range) => {
|
942
936
|
const newIndexes = extraIndexRangeExtractor(range, draggingColumnIndex);
|
@@ -949,21 +943,25 @@ const useMRT_ColumnVirtualizer = (table) => {
|
|
949
943
|
];
|
950
944
|
}, [leftPinnedIndexes, rightPinnedIndexes, draggingColumnIndex]) }, columnVirtualizerProps))
|
951
945
|
: undefined;
|
952
|
-
if (
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
946
|
+
if (columnVirtualizer) {
|
947
|
+
const virtualColumns = columnVirtualizer.getVirtualItems();
|
948
|
+
columnVirtualizer.virtualColumns = virtualColumns;
|
949
|
+
if (virtualColumns.length) {
|
950
|
+
columnVirtualizer.virtualPaddingLeft =
|
951
|
+
((_b = (_a = virtualColumns[leftPinnedIndexes.length]) === null || _a === void 0 ? void 0 : _a.start) !== null && _b !== void 0 ? _b : 0) -
|
952
|
+
((_d = (_c = virtualColumns[leftPinnedIndexes.length - 1]) === null || _c === void 0 ? void 0 : _c.end) !== null && _d !== void 0 ? _d : 0);
|
953
|
+
columnVirtualizer.virtualPaddingRight =
|
954
|
+
columnVirtualizer.getTotalSize() -
|
955
|
+
((_f = (_e = virtualColumns[virtualColumns.length - rightPinnedIndexes.length - 1]) === null || _e === void 0 ? void 0 : _e.end) !== null && _f !== void 0 ? _f : 0) -
|
956
|
+
(rightPinnedIndexes.length
|
957
|
+
? columnVirtualizer.getTotalSize() -
|
958
|
+
((_h = (_g = virtualColumns[virtualColumns.length - rightPinnedIndexes.length]) === null || _g === void 0 ? void 0 : _g.start) !== null && _h !== void 0 ? _h : 0)
|
959
|
+
: 0);
|
960
|
+
}
|
961
|
+
if (columnVirtualizerInstanceRef) {
|
962
|
+
//@ts-ignore
|
963
|
+
columnVirtualizerInstanceRef.current = columnVirtualizer;
|
964
|
+
}
|
967
965
|
}
|
968
966
|
return columnVirtualizer;
|
969
967
|
};
|
@@ -1302,7 +1300,7 @@ const commonListItemStyles = {
|
|
1302
1300
|
const MRT_ColumnActionMenu = (_a) => {
|
1303
1301
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
1304
1302
|
var { anchorEl, header, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "header", "setAnchorEl", "table"]);
|
1305
|
-
const { getState, options: { columnFilterDisplayMode, columnFilterModeOptions, enableColumnFilterModes, enableColumnFilters, enableColumnPinning, enableColumnResizing, enableGrouping, enableHiding, enableSorting, enableSortingRemoval, icons: { ArrowRightIcon, ClearAllIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, RestartAltIcon, SortIcon, ViewColumnIcon, VisibilityOffIcon, }, localization, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setColumnOrder, setColumnSizingInfo, setShowColumnFilters, toggleAllColumnsVisible, } = table;
|
1303
|
+
const { getState, options: { columnFilterDisplayMode, columnFilterModeOptions, enableColumnFilterModes, enableColumnFilters, enableColumnPinning, enableColumnResizing, enableGrouping, enableHiding, enableSorting, enableSortingRemoval, icons: { ArrowRightIcon, ClearAllIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, RestartAltIcon, SortIcon, ViewColumnIcon, VisibilityOffIcon, }, localization, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setColumnFilterFns, setColumnOrder, setColumnSizingInfo, setShowColumnFilters, toggleAllColumnsVisible, } = table;
|
1306
1304
|
const { column } = header;
|
1307
1305
|
const { columnDef } = column;
|
1308
1306
|
const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
|
@@ -1339,8 +1337,14 @@ const MRT_ColumnActionMenu = (_a) => {
|
|
1339
1337
|
setAnchorEl(null);
|
1340
1338
|
};
|
1341
1339
|
const handleClearFilter = () => {
|
1342
|
-
column.setFilterValue(
|
1340
|
+
column.setFilterValue(undefined);
|
1343
1341
|
setAnchorEl(null);
|
1342
|
+
if (['empty', 'notEmpty'].includes(columnDef._filterFn)) {
|
1343
|
+
setColumnFilterFns((prev) => {
|
1344
|
+
var _a;
|
1345
|
+
return (Object.assign(Object.assign({}, prev), { [header.id]: (_a = allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions[0]) !== null && _a !== void 0 ? _a : 'fuzzy' }));
|
1346
|
+
});
|
1347
|
+
}
|
1344
1348
|
};
|
1345
1349
|
const handleFilterByColumn = () => {
|
1346
1350
|
setShowColumnFilters(true);
|
@@ -1711,9 +1715,13 @@ const useMRT_RowVirtualizer = (table, rows) => {
|
|
1711
1715
|
return extraIndexRangeExtractor(range, (_a = draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.index) !== null && _a !== void 0 ? _a : 0);
|
1712
1716
|
}, [draggingRow]) }, rowVirtualizerProps))
|
1713
1717
|
: undefined;
|
1714
|
-
if (
|
1715
|
-
|
1716
|
-
|
1718
|
+
if (rowVirtualizer) {
|
1719
|
+
const virtualRows = rowVirtualizer.getVirtualItems();
|
1720
|
+
rowVirtualizer.virtualRows = virtualRows;
|
1721
|
+
if (rowVirtualizerInstanceRef) {
|
1722
|
+
//@ts-ignore
|
1723
|
+
rowVirtualizerInstanceRef.current = rowVirtualizer;
|
1724
|
+
}
|
1717
1725
|
}
|
1718
1726
|
return rowVirtualizer;
|
1719
1727
|
};
|
@@ -2272,7 +2280,7 @@ const useMRT_TableOptions = (_a) => {
|
|
2272
2280
|
|
2273
2281
|
const MRT_TableBody = (_a) => {
|
2274
2282
|
var _b, _c, _d, _e, _f, _g;
|
2275
|
-
var { columnVirtualizer, table
|
2283
|
+
var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
|
2276
2284
|
const { getBottomRows, getIsSomeRowsPinned, getRowModel, getState, getTopRows, options: { createDisplayMode, enableStickyFooter, enableStickyHeader, layoutMode, localization, memoMode, muiTableBodyProps, renderEmptyRowsFallback, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef, tablePaperRef }, } = table;
|
2277
2285
|
const { columnFilters, creatingRow, globalFilter, isFullScreen, rowPinning } = getState();
|
2278
2286
|
const tableBodyProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyProps, { table })), rest);
|
@@ -2290,14 +2298,11 @@ const MRT_TableBody = (_a) => {
|
|
2290
2298
|
}, [rowPinning, getRowModel().rows]);
|
2291
2299
|
const rows = useMRT_Rows(table, pinnedRowIds);
|
2292
2300
|
const rowVirtualizer = useMRT_RowVirtualizer(table, rows);
|
2293
|
-
const virtualRows = rowVirtualizer
|
2294
|
-
? rowVirtualizer.getVirtualItems()
|
2295
|
-
: undefined;
|
2301
|
+
const { virtualRows } = rowVirtualizer !== null && rowVirtualizer !== void 0 ? rowVirtualizer : {};
|
2296
2302
|
const commonRowProps = {
|
2297
2303
|
columnVirtualizer,
|
2298
2304
|
numRows: rows.length,
|
2299
2305
|
table,
|
2300
|
-
virtualColumns,
|
2301
2306
|
};
|
2302
2307
|
const CreatingRow = creatingRow && createDisplayMode === 'row' && (jsx(MRT_TableBodyRow, Object.assign({}, commonRowProps, { row: creatingRow, rowIndex: -1 })));
|
2303
2308
|
return (jsxs(Fragment, { children: [!(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
|
@@ -2328,12 +2333,13 @@ const MRT_TableBody = (_a) => {
|
|
2328
2333
|
row, rowIndex: rowVirtualizer ? rowOrVirtualRow.index : rowIndex, virtualRow: rowVirtualizer
|
2329
2334
|
? rowOrVirtualRow
|
2330
2335
|
: undefined });
|
2331
|
-
|
2336
|
+
const key = `${row.id}-${row.index}`;
|
2337
|
+
return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), key)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), key));
|
2332
2338
|
}) })))] })), !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
|
2333
2339
|
getIsSomeRowsPinned('bottom') && (jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ bottom: tableFooterHeight - 1, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'sticky', zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getBottomRows().map((row, rowIndex) => {
|
2334
2340
|
const props = Object.assign(Object.assign({}, commonRowProps), { row,
|
2335
2341
|
rowIndex });
|
2336
|
-
return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props),
|
2342
|
+
return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), row.id)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), row.id));
|
2337
2343
|
}) })))] }));
|
2338
2344
|
};
|
2339
2345
|
const Memo_MRT_TableBody = memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
|
@@ -2368,9 +2374,9 @@ const MRT_TableFooterCell = (_a) => {
|
|
2368
2374
|
|
2369
2375
|
const MRT_TableFooterRow = (_a) => {
|
2370
2376
|
var _b;
|
2371
|
-
var { columnVirtualizer, footerGroup, table
|
2377
|
+
var { columnVirtualizer, footerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "footerGroup", "table"]);
|
2372
2378
|
const { options: { layoutMode, muiTableFooterRowProps }, } = table;
|
2373
|
-
const { virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
|
2379
|
+
const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
|
2374
2380
|
// if no content in row, skip row
|
2375
2381
|
if (!((_b = footerGroup.headers) === null || _b === void 0 ? void 0 : _b.some((header) => (typeof header.column.columnDef.footer === 'string' &&
|
2376
2382
|
!!header.column.columnDef.footer) ||
|
@@ -2389,7 +2395,7 @@ const MRT_TableFooterRow = (_a) => {
|
|
2389
2395
|
};
|
2390
2396
|
|
2391
2397
|
const MRT_TableFooter = (_a) => {
|
2392
|
-
var { columnVirtualizer, table
|
2398
|
+
var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
|
2393
2399
|
const { getFooterGroups, getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, refs: { tableFooterRef }, } = table;
|
2394
2400
|
const { isFullScreen } = getState();
|
2395
2401
|
const tableFooterProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableFooterProps, {
|
@@ -2406,7 +2412,7 @@ const MRT_TableFooter = (_a) => {
|
|
2406
2412
|
? theme.palette.mode === 'light'
|
2407
2413
|
? `1px solid ${theme.palette.grey[300]}`
|
2408
2414
|
: `1px solid ${theme.palette.grey[700]}`
|
2409
|
-
: undefined, position: stickFooter ? 'sticky' : undefined, zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: getFooterGroups().map((footerGroup) => (jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table
|
2415
|
+
: undefined, position: stickFooter ? 'sticky' : undefined, zIndex: stickFooter ? 1 : undefined }, parseFromValuesOrFunc(tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx, theme))), children: getFooterGroups().map((footerGroup) => (jsx(MRT_TableFooterRow, { columnVirtualizer: columnVirtualizer, footerGroup: footerGroup, table: table }, footerGroup.id))) })));
|
2410
2416
|
};
|
2411
2417
|
|
2412
2418
|
const MRT_TableHeadCellColumnActionsButton = (_a) => {
|
@@ -3095,9 +3101,9 @@ const MRT_TableHeadCell = (_a) => {
|
|
3095
3101
|
};
|
3096
3102
|
|
3097
3103
|
const MRT_TableHeadRow = (_a) => {
|
3098
|
-
var { columnVirtualizer, headerGroup, table
|
3104
|
+
var { columnVirtualizer, headerGroup, table } = _a, rest = __rest(_a, ["columnVirtualizer", "headerGroup", "table"]);
|
3099
3105
|
const { options: { layoutMode, muiTableHeadRowProps }, } = table;
|
3100
|
-
const { virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
|
3106
|
+
const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
|
3101
3107
|
const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadRowProps, {
|
3102
3108
|
headerGroup,
|
3103
3109
|
table,
|
@@ -3140,6 +3146,8 @@ const MRT_TablePagination = (_a) => {
|
|
3140
3146
|
const firstRowIndex = pageIndex * pageSize;
|
3141
3147
|
const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount);
|
3142
3148
|
const _b = paginationProps !== null && paginationProps !== void 0 ? paginationProps : {}, { SelectProps, disabled = false, rowsPerPageOptions = defaultRowsPerPage, showFirstButton = showFirstLastPageButtons, showLastButton = showFirstLastPageButtons, showRowsPerPage = true } = _b, _rest = __rest(_b, ["SelectProps", "disabled", "rowsPerPageOptions", "showFirstButton", "showLastButton", "showRowsPerPage"]);
|
3149
|
+
const disableBack = pageIndex <= 0 || disabled;
|
3150
|
+
const disableNext = lastRowIndex >= totalRowCount || disabled;
|
3143
3151
|
return (jsxs(Box, { className: "MuiTablePagination-root", sx: {
|
3144
3152
|
alignItems: 'center',
|
3145
3153
|
display: 'flex',
|
@@ -3166,7 +3174,7 @@ const MRT_TablePagination = (_a) => {
|
|
3166
3174
|
last: LastPageIcon,
|
3167
3175
|
next: ChevronRightIcon,
|
3168
3176
|
previous: ChevronLeftIcon,
|
3169
|
-
} }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, _rest))) : paginationDisplayMode === 'default' ? (jsxs(Fragment, { children: [jsx(Typography, { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxs(Box, { gap: "xs", children: [showFirstButton && (jsx(Tooltip, { title: localization.goToFirstPage, children: jsx(IconButton, { "aria-label": localization.goToFirstPage, disabled:
|
3177
|
+
} }, item))), showFirstButton: showFirstButton, showLastButton: showLastButton }, _rest))) : paginationDisplayMode === 'default' ? (jsxs(Fragment, { children: [jsx(Typography, { align: "center", component: "span", sx: { m: '0 4px', minWidth: '8ch' }, variant: "body2", children: `${lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()}-${lastRowIndex.toLocaleString()} ${localization.of} ${totalRowCount.toLocaleString()}` }), jsxs(Box, { gap: "xs", children: [showFirstButton && (jsx(Tooltip, { enterDelay: 1000, title: localization.goToFirstPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToFirstPage, disabled: disableBack, onClick: () => setPageIndex(0), size: "small", children: jsx(FirstPageIcon, {}) }) }) })), jsx(Tooltip, { enterDelay: 1000, title: localization.goToPreviousPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToPreviousPage, disabled: disableBack, onClick: () => setPageIndex(pageIndex - 1), size: "small", children: jsx(ChevronLeftIcon, {}) }) }) }), jsx(Tooltip, { enterDelay: 1000, title: localization.goToNextPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToNextPage, disabled: disableNext, onClick: () => setPageIndex(pageIndex + 1), size: "small", children: jsx(ChevronRightIcon, {}) }) }) }), showLastButton && (jsx(Tooltip, { enterDelay: 1000, title: localization.goToLastPage, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.goToLastPage, disabled: disableNext, onClick: () => setPageIndex(numberOfPages - 1), size: "small", children: jsx(LastPageIcon, {}) }) }) }))] })] })) : null] }));
|
3170
3178
|
};
|
3171
3179
|
|
3172
3180
|
const MRT_GlobalFilterTextField = (_a) => {
|
@@ -3538,7 +3546,7 @@ const MRT_TopToolbar = ({ table, }) => {
|
|
3538
3546
|
};
|
3539
3547
|
|
3540
3548
|
const MRT_TableHead = (_a) => {
|
3541
|
-
var { columnVirtualizer, table
|
3549
|
+
var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
|
3542
3550
|
const { getHeaderGroups, getSelectedRowModel, getState, options: { enableStickyHeader, layoutMode, muiTableHeadProps, positionToolbarAlertBanner, }, refs: { tableHeadRef }, } = table;
|
3543
3551
|
const { isFullScreen, showAlertBanner } = getState();
|
3544
3552
|
const tableHeadProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadProps, { table })), rest);
|
@@ -3555,7 +3563,7 @@ const MRT_TableHead = (_a) => {
|
|
3555
3563
|
}, children: jsx("th", { colSpan: table.getVisibleLeafColumns().length, style: {
|
3556
3564
|
display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined,
|
3557
3565
|
padding: 0,
|
3558
|
-
}, children: jsx(MRT_ToolbarAlertBanner, { table: table }) }) })) : (getHeaderGroups().map((headerGroup) => (jsx(MRT_TableHeadRow, { columnVirtualizer: columnVirtualizer, headerGroup: headerGroup, table: table
|
3566
|
+
}, children: jsx(MRT_ToolbarAlertBanner, { table: table }) }) })) : (getHeaderGroups().map((headerGroup) => (jsx(MRT_TableHeadRow, { columnVirtualizer: columnVirtualizer, headerGroup: headerGroup, table: table }, headerGroup.id)))) })));
|
3559
3567
|
};
|
3560
3568
|
|
3561
3569
|
const MRT_Table = (_a) => {
|
@@ -3578,13 +3586,9 @@ const MRT_Table = (_a) => {
|
|
3578
3586
|
return colSizes;
|
3579
3587
|
}, [columns, columnSizing, columnSizingInfo, columnVisibility]);
|
3580
3588
|
const columnVirtualizer = useMRT_ColumnVirtualizer(table);
|
3581
|
-
const virtualColumns = columnVirtualizer
|
3582
|
-
? columnVirtualizer.getVirtualItems()
|
3583
|
-
: undefined;
|
3584
3589
|
const commonTableGroupProps = {
|
3585
3590
|
columnVirtualizer,
|
3586
3591
|
table,
|
3587
|
-
virtualColumns,
|
3588
3592
|
};
|
3589
3593
|
return (jsxs(Table, Object.assign({ stickyHeader: enableStickyHeader || isFullScreen }, tableProps, { style: Object.assign(Object.assign({}, columnSizeVars), tableProps === null || tableProps === void 0 ? void 0 : tableProps.style), sx: (theme) => (Object.assign({ borderCollapse: 'separate', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined }, parseFromValuesOrFunc(tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx, theme))), children: [enableTableHead && jsx(MRT_TableHead, Object.assign({}, commonTableGroupProps)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsx(Memo_MRT_TableBody, Object.assign({}, commonTableGroupProps))) : (jsx(MRT_TableBody, Object.assign({}, commonTableGroupProps))), enableTableFooter && jsx(MRT_TableFooter, Object.assign({}, commonTableGroupProps))] })));
|
3590
3594
|
};
|