material-react-table 2.8.0 → 2.9.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.
Files changed (36) hide show
  1. package/dist/index.d.ts +17 -9
  2. package/dist/index.esm.js +260 -218
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.js +259 -216
  5. package/dist/index.js.map +1 -1
  6. package/locales/ja/index.esm.js +4 -4
  7. package/locales/ja/index.js +4 -4
  8. package/package.json +6 -4
  9. package/src/components/body/MRT_TableBody.tsx +2 -3
  10. package/src/components/body/MRT_TableBodyCell.tsx +10 -3
  11. package/src/components/body/MRT_TableBodyRow.tsx +77 -57
  12. package/src/components/footer/MRT_TableFooterCell.tsx +10 -1
  13. package/src/components/footer/MRT_TableFooterRow.tsx +19 -8
  14. package/src/components/head/MRT_TableHeadCell.tsx +10 -0
  15. package/src/components/head/MRT_TableHeadCellResizeHandle.tsx +4 -2
  16. package/src/components/head/MRT_TableHeadRow.tsx +19 -8
  17. package/src/components/inputs/MRT_EditCellTextField.tsx +4 -3
  18. package/src/components/inputs/MRT_SelectCheckbox.tsx +4 -6
  19. package/src/components/table/MRT_Table.tsx +4 -0
  20. package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +1 -1
  21. package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +1 -0
  22. package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +1 -0
  23. package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +4 -2
  24. package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +1 -0
  25. package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +1 -0
  26. package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +2 -1
  27. package/src/hooks/useMRT_ColumnVirtualizer.ts +77 -76
  28. package/src/hooks/useMRT_RowVirtualizer.ts +30 -32
  29. package/src/hooks/useMRT_TableInstance.ts +1 -42
  30. package/src/hooks/useMRT_TableOptions.ts +60 -17
  31. package/src/locales/ja.ts +4 -4
  32. package/src/types.ts +3 -0
  33. package/src/utils/displayColumn.utils.ts +2 -2
  34. package/src/utils/row.utils.ts +25 -1
  35. package/src/utils/style.utils.ts +70 -30
  36. package/src/utils.ts +0 -0
@@ -86,9 +86,11 @@ export const getMRT_RowExpandColumnDef = <TData extends MRT_RowData>(
86
86
  id: 'mrt-row-expand',
87
87
  size:
88
88
  groupedColumnMode === 'remove'
89
- ? defaultColumn?.size
89
+ ? defaultColumn?.size ?? 180
90
90
  : renderDetailPanel
91
- ? 60
91
+ ? enableExpandAll
92
+ ? 60
93
+ : 70
92
94
  : 100,
93
95
  tableOptions,
94
96
  }),
@@ -30,6 +30,7 @@ export const getMRT_RowNumbersColumnDef = <TData extends MRT_RowData>(
30
30
  ...defaultDisplayColumnProps({
31
31
  header: 'rowNumbers',
32
32
  id: 'mrt-row-numbers',
33
+ size: 50,
33
34
  tableOptions,
34
35
  }),
35
36
  };
@@ -24,6 +24,7 @@ export const getMRT_RowPinningColumnDef = <TData extends MRT_RowData>(
24
24
  ...defaultDisplayColumnProps({
25
25
  header: 'pin',
26
26
  id: 'mrt-row-pin',
27
+ size: 60,
27
28
  tableOptions,
28
29
  }),
29
30
  };
@@ -28,12 +28,13 @@ export const getMRT_RowSelectColumnDef = <TData extends MRT_RowData>(
28
28
  ),
29
29
  Header:
30
30
  enableSelectAll && enableMultiRowSelection
31
- ? ({ table }) => <MRT_SelectCheckbox selectAll table={table} />
31
+ ? ({ table }) => <MRT_SelectCheckbox table={table} />
32
32
  : undefined,
33
33
  grow: false,
34
34
  ...defaultDisplayColumnProps({
35
35
  header: 'select',
36
36
  id: 'mrt-row-select',
37
+ size: enableSelectAll ? 60 : 70,
37
38
  tableOptions,
38
39
  }),
39
40
  };
@@ -16,7 +16,10 @@ export const useMRT_ColumnVirtualizer = <
16
16
  table: MRT_TableInstance<TData>,
17
17
  ): MRT_ColumnVirtualizer | undefined => {
18
18
  const {
19
+ getLeftLeafColumns,
20
+ getRightLeafColumns,
19
21
  getState,
22
+ getVisibleLeafColumns,
20
23
  options: {
21
24
  columnVirtualizerInstanceRef,
22
25
  columnVirtualizerOptions,
@@ -25,7 +28,9 @@ export const useMRT_ColumnVirtualizer = <
25
28
  },
26
29
  refs: { tableContainerRef },
27
30
  } = table;
28
- const { columnPinning, columnVisibility, draggingColumn } = getState();
31
+ const { columnPinning, draggingColumn } = getState();
32
+
33
+ if (!enableColumnVirtualization) return undefined;
29
34
 
30
35
  const columnVirtualizerProps = parseFromValuesOrFunc(
31
36
  columnVirtualizerOptions,
@@ -34,91 +39,87 @@ export const useMRT_ColumnVirtualizer = <
34
39
  },
35
40
  );
36
41
 
42
+ const visibleColumns = getVisibleLeafColumns();
43
+
37
44
  const [leftPinnedIndexes, rightPinnedIndexes] = useMemo(
38
45
  () =>
39
- enableColumnVirtualization && enableColumnPinning
46
+ enableColumnPinning
40
47
  ? [
41
- table.getLeftLeafColumns().map((c) => c.getPinnedIndex()),
42
- table
43
- .getRightLeafColumns()
48
+ getLeftLeafColumns().map((c) => c.getPinnedIndex()),
49
+ getRightLeafColumns()
44
50
  .map(
45
- (c) =>
46
- table.getVisibleLeafColumns().length - c.getPinnedIndex() - 1,
51
+ (column) => visibleColumns.length - column.getPinnedIndex() - 1,
47
52
  )
48
53
  .sort((a, b) => a - b),
49
54
  ]
50
55
  : [[], []],
51
- [columnPinning, enableColumnVirtualization, enableColumnPinning],
56
+ [columnPinning, enableColumnPinning],
52
57
  );
53
58
 
54
- //get first 16 column widths and average them if calc is needed
55
- const averageColumnWidth = useMemo(() => {
56
- if (!enableColumnVirtualization || columnVirtualizerProps?.estimateSize) {
57
- return 0;
58
- }
59
- const columnsWidths =
60
- table
61
- .getRowModel()
62
- .rows[0]?.getCenterVisibleCells()
63
- ?.slice(0, 16)
64
- ?.map((cell) => cell.column.getSize() * 1.2) ?? [];
65
- return columnsWidths.reduce((a, b) => a + b, 0) / columnsWidths.length;
66
- }, [table.getRowModel().rows, columnPinning, columnVisibility]);
67
-
68
- const draggingColumnIndex = draggingColumn?.id
69
- ? table
70
- .getVisibleLeafColumns()
71
- .findIndex((c) => c.id === draggingColumn?.id)
72
- : undefined;
73
-
74
- const columnVirtualizer = enableColumnVirtualization
75
- ? (useVirtualizer({
76
- count: table.getVisibleLeafColumns().length,
77
- estimateSize: () => averageColumnWidth,
78
- getScrollElement: () => tableContainerRef.current,
79
- horizontal: true,
80
- overscan: 3,
81
- rangeExtractor: useCallback(
82
- (range: Range) => {
83
- const newIndexes = extraIndexRangeExtractor(
84
- range,
85
- draggingColumnIndex,
86
- );
87
- return [
88
- ...new Set([
89
- ...leftPinnedIndexes,
90
- ...newIndexes,
91
- ...rightPinnedIndexes,
92
- ]),
93
- ];
94
- },
95
- [leftPinnedIndexes, rightPinnedIndexes, draggingColumnIndex],
96
- ),
97
- ...columnVirtualizerProps,
98
- }) as unknown as MRT_ColumnVirtualizer<TScrollElement, TItemElement>)
99
- : undefined;
100
-
101
- if (columnVirtualizer) {
102
- const virtualColumns = columnVirtualizer.getVirtualItems();
103
- columnVirtualizer.virtualColumns = virtualColumns;
104
- if (virtualColumns.length) {
105
- columnVirtualizer.virtualPaddingLeft =
106
- (virtualColumns[leftPinnedIndexes.length]?.start ?? 0) -
107
- (virtualColumns[leftPinnedIndexes.length - 1]?.end ?? 0);
108
- columnVirtualizer.virtualPaddingRight =
109
- columnVirtualizer.getTotalSize() -
110
- (virtualColumns[virtualColumns.length - rightPinnedIndexes.length - 1]
111
- ?.end ?? 0) -
112
- (rightPinnedIndexes.length
113
- ? columnVirtualizer.getTotalSize() -
114
- (virtualColumns[virtualColumns.length - rightPinnedIndexes.length]
115
- ?.start ?? 0)
116
- : 0);
117
- }
118
- if (columnVirtualizerInstanceRef) {
119
- //@ts-ignore
120
- columnVirtualizerInstanceRef.current = columnVirtualizer;
121
- }
59
+ const numPinnedLeft = leftPinnedIndexes.length;
60
+ const numPinnedRight = rightPinnedIndexes.length;
61
+
62
+ const draggingColumnIndex = useMemo(
63
+ () =>
64
+ draggingColumn?.id
65
+ ? visibleColumns.findIndex((c) => c.id === draggingColumn?.id)
66
+ : undefined,
67
+ [draggingColumn?.id],
68
+ );
69
+
70
+ const columnVirtualizer = useVirtualizer({
71
+ count: visibleColumns.length,
72
+ estimateSize: (index) => visibleColumns[index].getSize(),
73
+ getScrollElement: () => tableContainerRef.current,
74
+ horizontal: true,
75
+ overscan: 3,
76
+ rangeExtractor: useCallback(
77
+ (range: Range) => {
78
+ const newIndexes = extraIndexRangeExtractor(range, draggingColumnIndex);
79
+ if (!numPinnedLeft && !numPinnedRight) {
80
+ return newIndexes;
81
+ }
82
+ return [
83
+ ...new Set([
84
+ ...leftPinnedIndexes,
85
+ ...newIndexes,
86
+ ...rightPinnedIndexes,
87
+ ]),
88
+ ];
89
+ },
90
+ [leftPinnedIndexes, rightPinnedIndexes, draggingColumnIndex],
91
+ ),
92
+ ...columnVirtualizerProps,
93
+ }) as unknown as MRT_ColumnVirtualizer<TScrollElement, TItemElement>;
94
+
95
+ const virtualColumns = columnVirtualizer.getVirtualItems();
96
+ columnVirtualizer.virtualColumns = virtualColumns;
97
+ const numColumns = virtualColumns.length;
98
+
99
+ if (numColumns) {
100
+ const totalSize = columnVirtualizer.getTotalSize();
101
+
102
+ const leftNonPinnedStart = virtualColumns[numPinnedLeft]?.start || 0;
103
+ const leftNonPinnedEnd =
104
+ virtualColumns[leftPinnedIndexes.length - 1]?.end || 0;
105
+
106
+ const rightNonPinnedStart =
107
+ virtualColumns[numColumns - numPinnedRight]?.start || 0;
108
+ const rightNonPinnedEnd =
109
+ virtualColumns[numColumns - numPinnedRight - 1]?.end || 0;
110
+
111
+ columnVirtualizer.virtualPaddingLeft =
112
+ leftNonPinnedStart - leftNonPinnedEnd;
113
+
114
+ columnVirtualizer.virtualPaddingRight =
115
+ totalSize -
116
+ rightNonPinnedEnd -
117
+ (numPinnedRight ? totalSize - rightNonPinnedStart : 0);
118
+ }
119
+
120
+ if (columnVirtualizerInstanceRef) {
121
+ //@ts-ignore
122
+ columnVirtualizerInstanceRef.current = columnVirtualizer;
122
123
  }
123
124
 
124
125
  return columnVirtualizer as any;
@@ -30,6 +30,8 @@ export const useMRT_RowVirtualizer = <
30
30
  } = table;
31
31
  const { density, draggingRow, expanded } = getState();
32
32
 
33
+ if (!enableRowVirtualization) return undefined;
34
+
33
35
  const rowVirtualizerProps = parseFromValuesOrFunc(rowVirtualizerOptions, {
34
36
  table,
35
37
  });
@@ -39,39 +41,35 @@ export const useMRT_RowVirtualizer = <
39
41
  const normalRowHeight =
40
42
  density === 'compact' ? 37 : density === 'comfortable' ? 58 : 73;
41
43
 
42
- const rowVirtualizer = enableRowVirtualization
43
- ? (useVirtualizer({
44
- count: renderDetailPanel ? rowCount * 2 : rowCount,
45
- estimateSize: (index) =>
46
- renderDetailPanel && index % 2 === 1
47
- ? expanded === true
48
- ? 100
49
- : 0
50
- : normalRowHeight,
51
- getScrollElement: () => tableContainerRef.current,
52
- measureElement:
53
- typeof window !== 'undefined' &&
54
- navigator.userAgent.indexOf('Firefox') === -1
55
- ? (element) => element?.getBoundingClientRect().height
56
- : undefined,
57
- overscan: 4,
58
- rangeExtractor: useCallback(
59
- (range: Range) => {
60
- return extraIndexRangeExtractor(range, draggingRow?.index ?? 0);
61
- },
62
- [draggingRow],
63
- ),
64
- ...rowVirtualizerProps,
65
- }) as unknown as MRT_RowVirtualizer<TScrollElement, TItemElement>)
66
- : undefined;
44
+ const rowVirtualizer = useVirtualizer({
45
+ count: renderDetailPanel ? rowCount * 2 : rowCount,
46
+ estimateSize: (index) =>
47
+ renderDetailPanel && index % 2 === 1
48
+ ? expanded === true
49
+ ? 100
50
+ : 0
51
+ : normalRowHeight,
52
+ getScrollElement: () => tableContainerRef.current,
53
+ measureElement:
54
+ typeof window !== 'undefined' &&
55
+ navigator.userAgent.indexOf('Firefox') === -1
56
+ ? (element) => element?.getBoundingClientRect().height
57
+ : undefined,
58
+ overscan: 4,
59
+ rangeExtractor: useCallback(
60
+ (range: Range) => {
61
+ return extraIndexRangeExtractor(range, draggingRow?.index ?? 0);
62
+ },
63
+ [draggingRow],
64
+ ),
65
+ ...rowVirtualizerProps,
66
+ }) as unknown as MRT_RowVirtualizer<TScrollElement, TItemElement>;
67
+
68
+ rowVirtualizer.virtualRows = rowVirtualizer.getVirtualItems();
67
69
 
68
- if (rowVirtualizer) {
69
- const virtualRows = rowVirtualizer.getVirtualItems();
70
- rowVirtualizer.virtualRows = virtualRows;
71
- if (rowVirtualizerInstanceRef) {
72
- //@ts-ignore
73
- rowVirtualizerInstanceRef.current = rowVirtualizer;
74
- }
70
+ if (rowVirtualizerInstanceRef) {
71
+ //@ts-ignore
72
+ rowVirtualizerInstanceRef.current = rowVirtualizer;
75
73
  }
76
74
 
77
75
  return rowVirtualizer;
@@ -1,16 +1,5 @@
1
1
  import { useMemo, useRef, useState } from 'react';
2
- import {
3
- getCoreRowModel,
4
- getExpandedRowModel,
5
- getFacetedMinMaxValues,
6
- getFacetedRowModel,
7
- getFacetedUniqueValues,
8
- getFilteredRowModel,
9
- getGroupedRowModel,
10
- getPaginationRowModel,
11
- getSortedRowModel,
12
- useReactTable,
13
- } from '@tanstack/react-table';
2
+ import { useReactTable } from '@tanstack/react-table';
14
3
  import {
15
4
  type MRT_Cell,
16
5
  type MRT_Column,
@@ -207,36 +196,6 @@ export const useMRT_TableInstance = <TData extends MRT_RowData>(
207
196
 
208
197
  //@ts-ignore
209
198
  const table = useReactTable({
210
- getCoreRowModel: getCoreRowModel(),
211
- getExpandedRowModel:
212
- tableOptions.enableExpanding || tableOptions.enableGrouping
213
- ? getExpandedRowModel()
214
- : undefined,
215
- getFacetedMinMaxValues: tableOptions.enableFacetedValues
216
- ? getFacetedMinMaxValues()
217
- : undefined,
218
- getFacetedRowModel: tableOptions.enableFacetedValues
219
- ? getFacetedRowModel()
220
- : undefined,
221
- getFacetedUniqueValues: tableOptions.enableFacetedValues
222
- ? getFacetedUniqueValues()
223
- : undefined,
224
- getFilteredRowModel:
225
- tableOptions.enableColumnFilters ||
226
- tableOptions.enableGlobalFilter ||
227
- tableOptions.enableFilters
228
- ? getFilteredRowModel()
229
- : undefined,
230
- getGroupedRowModel: tableOptions.enableGrouping
231
- ? getGroupedRowModel()
232
- : undefined,
233
- getPaginationRowModel: tableOptions.enablePagination
234
- ? getPaginationRowModel()
235
- : undefined,
236
- getSortedRowModel: tableOptions.enableSorting
237
- ? getSortedRowModel()
238
- : undefined,
239
- getSubRows: (row) => row?.subRows,
240
199
  onColumnOrderChange,
241
200
  onColumnSizingInfoChange,
242
201
  onGroupingChange,
@@ -1,4 +1,15 @@
1
1
  import { useMemo } from 'react';
2
+ import {
3
+ getCoreRowModel,
4
+ getExpandedRowModel,
5
+ getFacetedMinMaxValues,
6
+ getFacetedRowModel,
7
+ getFacetedUniqueValues,
8
+ getFilteredRowModel,
9
+ getGroupedRowModel,
10
+ getPaginationRowModel,
11
+ getSortedRowModel,
12
+ } from '@tanstack/react-table';
2
13
  import { useTheme } from '@mui/material/styles';
3
14
  import { MRT_AggregationFns } from '../fns/aggregationFns';
4
15
  import { MRT_FilterFns } from '../fns/filterFns';
@@ -51,9 +62,11 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
51
62
  enableColumnOrdering = false,
52
63
  enableColumnPinning = false,
53
64
  enableColumnResizing = false,
65
+ enableColumnVirtualization,
54
66
  enableDensityToggle = true,
55
67
  enableExpandAll = true,
56
68
  enableExpanding,
69
+ enableFacetedValues = false,
57
70
  enableFilterMatchHighlighting = true,
58
71
  enableFilters = true,
59
72
  enableFullScreenToggle = true,
@@ -66,6 +79,7 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
66
79
  enablePagination = true,
67
80
  enableRowPinning = false,
68
81
  enableRowSelection = false,
82
+ enableRowVirtualization,
69
83
  enableSelectAll = true,
70
84
  enableSorting = true,
71
85
  enableStickyHeader = false,
@@ -96,31 +110,37 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
96
110
  ...rest
97
111
  }: MRT_TableOptions<TData>) => {
98
112
  const theme = useTheme();
99
- const _icons = useMemo(() => ({ ...MRT_Default_Icons, ...icons }), [icons]);
100
- const _localization = useMemo(
113
+
114
+ icons = useMemo(() => ({ ...MRT_Default_Icons, ...icons }), [icons]);
115
+ localization = useMemo(
101
116
  () => ({
102
117
  ...MRT_Localization_EN,
103
118
  ...localization,
104
119
  }),
105
120
  [localization],
106
121
  );
107
- const _aggregationFns = useMemo(
122
+ aggregationFns = useMemo(
108
123
  () => ({ ...MRT_AggregationFns, ...aggregationFns }),
109
124
  [],
110
125
  );
111
- const _filterFns = useMemo(() => ({ ...MRT_FilterFns, ...filterFns }), []);
112
- const _sortingFns = useMemo(() => ({ ...MRT_SortingFns, ...sortingFns }), []);
113
- const _defaultColumn = useMemo(
126
+ filterFns = useMemo(() => ({ ...MRT_FilterFns, ...filterFns }), []);
127
+ sortingFns = useMemo(() => ({ ...MRT_SortingFns, ...sortingFns }), []);
128
+ defaultColumn = useMemo(
114
129
  () => ({ ...MRT_DefaultColumn, ...defaultColumn }),
115
130
  [defaultColumn],
116
131
  );
117
- const _defaultDisplayColumn = useMemo(
132
+ defaultDisplayColumn = useMemo(
118
133
  () => ({
119
134
  ...MRT_DefaultDisplayColumn,
120
135
  ...defaultDisplayColumn,
121
136
  }),
122
137
  [defaultDisplayColumn],
123
138
  );
139
+ //cannot be changed after initialization
140
+ [enableColumnVirtualization, enableRowVirtualization] = useMemo(
141
+ () => [enableColumnVirtualization, enableRowVirtualization],
142
+ [],
143
+ );
124
144
 
125
145
  if (!columnResizeDirection) {
126
146
  columnResizeDirection = theme.direction || 'ltr';
@@ -130,12 +150,12 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
130
150
  layoutMode || (enableColumnResizing ? 'grid-no-grow' : 'semantic');
131
151
  if (
132
152
  layoutMode === 'semantic' &&
133
- (rest.enableRowVirtualization || rest.enableColumnVirtualization)
153
+ (enableRowVirtualization || enableColumnVirtualization)
134
154
  ) {
135
155
  layoutMode = 'grid';
136
156
  }
137
157
 
138
- if (rest.enableRowVirtualization) {
158
+ if (enableRowVirtualization) {
139
159
  enableStickyHeader = true;
140
160
  }
141
161
 
@@ -151,14 +171,14 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
151
171
  }
152
172
 
153
173
  return {
154
- aggregationFns: _aggregationFns,
174
+ aggregationFns,
155
175
  autoResetExpanded,
156
176
  columnFilterDisplayMode,
157
177
  columnResizeDirection,
158
178
  columnResizeMode,
159
179
  createDisplayMode,
160
- defaultColumn: _defaultColumn,
161
- defaultDisplayColumn: _defaultDisplayColumn,
180
+ defaultColumn,
181
+ defaultDisplayColumn,
162
182
  editDisplayMode,
163
183
  enableBottomToolbar,
164
184
  enableColumnActions,
@@ -166,9 +186,11 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
166
186
  enableColumnOrdering,
167
187
  enableColumnPinning,
168
188
  enableColumnResizing,
189
+ enableColumnVirtualization,
169
190
  enableDensityToggle,
170
191
  enableExpandAll,
171
192
  enableExpanding,
193
+ enableFacetedValues,
172
194
  enableFilterMatchHighlighting,
173
195
  enableFilters,
174
196
  enableFullScreenToggle,
@@ -181,6 +203,7 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
181
203
  enablePagination,
182
204
  enableRowPinning,
183
205
  enableRowSelection,
206
+ enableRowVirtualization,
184
207
  enableSelectAll,
185
208
  enableSorting,
186
209
  enableStickyHeader,
@@ -188,10 +211,30 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
188
211
  enableTableHead,
189
212
  enableToolbarInternalActions,
190
213
  enableTopToolbar,
191
- filterFns: _filterFns,
192
- icons: _icons,
214
+ filterFns,
215
+ getCoreRowModel: getCoreRowModel(),
216
+ getExpandedRowModel:
217
+ enableExpanding || enableGrouping ? getExpandedRowModel() : undefined,
218
+ getFacetedMinMaxValues: enableFacetedValues
219
+ ? getFacetedMinMaxValues()
220
+ : undefined,
221
+ getFacetedRowModel: enableFacetedValues ? getFacetedRowModel() : undefined,
222
+ getFacetedUniqueValues: enableFacetedValues
223
+ ? getFacetedUniqueValues()
224
+ : undefined,
225
+ getFilteredRowModel:
226
+ enableColumnFilters || enableGlobalFilter || enableFilters
227
+ ? getFilteredRowModel()
228
+ : undefined,
229
+ getGroupedRowModel: enableGrouping ? getGroupedRowModel() : undefined,
230
+ getPaginationRowModel: enablePagination
231
+ ? getPaginationRowModel()
232
+ : undefined,
233
+ getSortedRowModel: enableSorting ? getSortedRowModel() : undefined,
234
+ getSubRows: (row) => row?.subRows,
235
+ icons,
193
236
  layoutMode,
194
- localization: _localization,
237
+ localization,
195
238
  manualFiltering,
196
239
  manualGrouping,
197
240
  manualPagination,
@@ -207,7 +250,7 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
207
250
  rowNumberDisplayMode,
208
251
  rowPinningDisplayMode,
209
252
  selectAllMode,
210
- sortingFns: _sortingFns,
253
+ sortingFns,
211
254
  ...rest,
212
- };
255
+ } as MRT_DefinedTableOptions<TData>;
213
256
  };
package/src/locales/ja.ts CHANGED
@@ -78,10 +78,10 @@ export const MRT_Localization_JA: MRT_Localization = {
78
78
  showHideColumns: '列の表示状態',
79
79
  showHideFilters: '検索バーを表示',
80
80
  showHideSearch: '検索',
81
- sortByColumnAsc: '{column}を昇順でを並べ替え',
82
- sortByColumnDesc: '{column}を降順でを並べ替え',
83
- sortedByColumnAsc: '{column}を昇順でを並べ替え',
84
- sortedByColumnDesc: '{column}を降順でを並べ替え',
81
+ sortByColumnAsc: '{column}を昇順で並べ替え',
82
+ sortByColumnDesc: '{column}を降順で並べ替え',
83
+ sortedByColumnAsc: '{column}を昇順で並べ替え',
84
+ sortedByColumnDesc: '{column}を降順で並べ替え',
85
85
  thenBy: 'さらに',
86
86
  toggleDensity: 'テーブルの高さを変更',
87
87
  toggleFullScreen: 'フルスクリーン切り替え',
package/src/types.ts CHANGED
@@ -1164,6 +1164,9 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
1164
1164
  renderBottomToolbarCustomActions?: (props: {
1165
1165
  table: MRT_TableInstance<TData>;
1166
1166
  }) => ReactNode;
1167
+ renderCaption?:
1168
+ | ((props: { table: MRT_TableInstance<TData> }) => ReactNode)
1169
+ | ReactNode;
1167
1170
  renderColumnActionsMenuItems?: (props: {
1168
1171
  closeMenu: () => void;
1169
1172
  column: MRT_Column<TData>;
@@ -10,12 +10,12 @@ import { getAllLeafColumnDefs, getColumnId } from './column.utils';
10
10
  export function defaultDisplayColumnProps<TData extends MRT_RowData>({
11
11
  header,
12
12
  id,
13
- size = 60,
13
+ size,
14
14
  tableOptions,
15
15
  }: {
16
16
  header?: keyof MRT_Localization;
17
17
  id: MRT_DisplayColumnIds;
18
- size?: number;
18
+ size: number;
19
19
  tableOptions: MRT_DefinedTableOptions<TData>;
20
20
  }) {
21
21
  const { defaultDisplayColumn, displayColumnDefOptions, localization } =
@@ -1,4 +1,28 @@
1
- import { type MRT_RowData, type MRT_TableInstance } from '../types';
1
+ import {
2
+ type MRT_Row,
3
+ type MRT_RowData,
4
+ type MRT_TableInstance,
5
+ } from '../types';
6
+ import { parseFromValuesOrFunc } from './utils';
7
+
8
+ export const getIsRowSelected = <TData extends MRT_RowData>({
9
+ row,
10
+ table,
11
+ }: {
12
+ row: MRT_Row<TData>;
13
+ table: MRT_TableInstance<TData>;
14
+ }) => {
15
+ const {
16
+ options: { enableRowSelection },
17
+ } = table;
18
+
19
+ return (
20
+ row.getIsSelected() ||
21
+ (parseFromValuesOrFunc(enableRowSelection, row) &&
22
+ row.getCanSelectSubRows() &&
23
+ row.getIsAllSubRowsSelected())
24
+ );
25
+ };
2
26
 
3
27
  export const getCanRankRows = <TData extends MRT_RowData>(
4
28
  table: MRT_TableInstance<TData>,