material-react-table 1.1.0-beta.0 → 1.1.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/cjs/MaterialReactTable.d.ts +2 -2
- package/dist/cjs/_locales/ja.d.ts +2 -0
- package/dist/cjs/index.js +278 -278
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/table/MRT_TableRoot.d.ts +3 -3
- package/dist/esm/MaterialReactTable.d.ts +2 -2
- package/dist/esm/_locales/ja.d.ts +2 -0
- package/dist/esm/material-react-table.esm.js +278 -278
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/table/MRT_TableRoot.d.ts +3 -3
- package/dist/index.d.ts +34 -34
- package/locales/ja.d.ts +2 -0
- package/locales/ja.esm.d.ts +2 -0
- package/locales/ja.esm.js +92 -0
- package/locales/ja.esm.js.map +1 -0
- package/locales/ja.js +96 -0
- package/locales/ja.js.map +1 -0
- package/package.json +13 -13
- package/src/MaterialReactTable.tsx +5 -5
- package/src/_locales/ja.ts +92 -1
|
@@ -2,8 +2,8 @@ import { Dispatch, MutableRefObject, ReactNode, SetStateAction } from 'react';
|
|
|
2
2
|
import type { AlertProps, ButtonProps, CheckboxProps, ChipProps, IconButtonProps, LinearProgressProps, PaperProps, RadioProps, SkeletonProps, TableBodyProps, TableCellProps, TableContainerProps, TableFooterProps, TableHeadProps, TablePaginationProps, TableProps, TableRowProps, TextFieldProps, ToolbarProps } from '@mui/material';
|
|
3
3
|
import type { Cell, Column, ColumnDef, DeepKeys, FilterFn, Header, HeaderGroup, OnChangeFn, Row, SortingFn, Table, TableOptions, TableState } from '@tanstack/react-table';
|
|
4
4
|
import type { Options as VirtualizerOptions, VirtualItem } from 'react-virtual';
|
|
5
|
-
import { MRT_Icons } from './icons';
|
|
6
5
|
import { MRT_FilterFns } from './filterFns';
|
|
6
|
+
import { MRT_Icons } from './icons';
|
|
7
7
|
import { MRT_SortingFns } from './sortingFns';
|
|
8
8
|
/**
|
|
9
9
|
* Most of this file is just TypeScript types
|
|
@@ -329,7 +329,7 @@ export declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit
|
|
|
329
329
|
onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
|
|
330
330
|
table: MRT_TableInstance<TData>;
|
|
331
331
|
}) => ReactNode[];
|
|
332
|
-
sortingFn?: MRT_SortingFn
|
|
332
|
+
sortingFn?: MRT_SortingFn<TData>;
|
|
333
333
|
};
|
|
334
334
|
export declare type MRT_DefinedColumnDef<TData extends Record<string, any> = {}> = Omit<MRT_ColumnDef<TData>, 'id' | 'defaultDisplayColumn'> & {
|
|
335
335
|
defaultDisplayColumn: Partial<MRT_ColumnDef<TData>>;
|
package/dist/cjs/index.js
CHANGED
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var reactTable = require('@tanstack/react-table');
|
|
7
|
-
var iconsMaterial = require('@mui/icons-material');
|
|
8
|
-
var matchSorterUtils = require('@tanstack/match-sorter-utils');
|
|
9
7
|
var material = require('@mui/material');
|
|
8
|
+
var matchSorterUtils = require('@tanstack/match-sorter-utils');
|
|
9
|
+
var iconsMaterial = require('@mui/icons-material');
|
|
10
10
|
var reactVirtual = require('react-virtual');
|
|
11
11
|
|
|
12
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -42,37 +42,161 @@ function __rest(s, e) {
|
|
|
42
42
|
|
|
43
43
|
const MRT_AggregationFns = Object.assign({}, reactTable.aggregationFns);
|
|
44
44
|
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
45
|
+
const getColumnId = (columnDef) => { var _a, _b, _c, _d; return (_d = (_a = columnDef.id) !== null && _a !== void 0 ? _a : (_c = (_b = columnDef.accessorKey) === null || _b === void 0 ? void 0 : _b.toString) === null || _c === void 0 ? void 0 : _c.call(_b)) !== null && _d !== void 0 ? _d : columnDef.header; };
|
|
46
|
+
const getAllLeafColumnDefs = (columns) => {
|
|
47
|
+
const allLeafColumnDefs = [];
|
|
48
|
+
const getLeafColumns = (cols) => {
|
|
49
|
+
cols.forEach((col) => {
|
|
50
|
+
if (col.columns) {
|
|
51
|
+
getLeafColumns(col.columns);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
allLeafColumnDefs.push(col);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
getLeafColumns(columns);
|
|
59
|
+
return allLeafColumnDefs;
|
|
60
|
+
};
|
|
61
|
+
const prepareColumns = ({ columnDefs, columnFilterFns, defaultDisplayColumn, filterFns, sortingFns, }) => columnDefs.map((columnDef) => {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
if (!columnDef.id)
|
|
64
|
+
columnDef.id = getColumnId(columnDef);
|
|
65
|
+
if (process.env.NODE_ENV !== 'production' && !columnDef.id) {
|
|
66
|
+
console.error('Column definitions must have a valid `accessorKey` or `id` property');
|
|
67
|
+
}
|
|
68
|
+
if (!columnDef.columnDefType)
|
|
69
|
+
columnDef.columnDefType = 'data';
|
|
70
|
+
if (!!((_a = columnDef.columns) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
71
|
+
columnDef.columnDefType = 'group';
|
|
72
|
+
columnDef.columns = prepareColumns({
|
|
73
|
+
columnDefs: columnDef.columns,
|
|
74
|
+
columnFilterFns,
|
|
75
|
+
defaultDisplayColumn,
|
|
76
|
+
filterFns,
|
|
77
|
+
sortingFns,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
else if (columnDef.columnDefType === 'data') {
|
|
81
|
+
if (Object.keys(filterFns).includes(columnFilterFns[columnDef.id])) {
|
|
82
|
+
columnDef.filterFn =
|
|
83
|
+
(_b = filterFns[columnFilterFns[columnDef.id]]) !== null && _b !== void 0 ? _b : filterFns.fuzzy;
|
|
84
|
+
columnDef._filterFn =
|
|
85
|
+
columnFilterFns[columnDef.id];
|
|
86
|
+
}
|
|
87
|
+
if (Object.keys(sortingFns).includes(columnDef.sortingFn)) {
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
columnDef.sortingFn = sortingFns[columnDef.sortingFn];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else if (columnDef.columnDefType === 'display') {
|
|
93
|
+
columnDef = Object.assign(Object.assign({}, defaultDisplayColumn), columnDef);
|
|
94
|
+
}
|
|
95
|
+
return columnDef;
|
|
96
|
+
});
|
|
97
|
+
const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
|
|
98
|
+
if (draggedColumn.getCanPin()) {
|
|
99
|
+
draggedColumn.pin(targetColumn.getIsPinned());
|
|
100
|
+
}
|
|
101
|
+
columnOrder.splice(columnOrder.indexOf(targetColumn.id), 0, columnOrder.splice(columnOrder.indexOf(draggedColumn.id), 1)[0]);
|
|
102
|
+
return [...columnOrder];
|
|
103
|
+
};
|
|
104
|
+
const showExpandColumn = (props, grouping) => !!(props.enableExpanding ||
|
|
105
|
+
(props.enableGrouping && (grouping === undefined || (grouping === null || grouping === void 0 ? void 0 : grouping.length))) ||
|
|
106
|
+
props.renderDetailPanel);
|
|
107
|
+
const getLeadingDisplayColumnIds = (props) => {
|
|
108
|
+
var _a;
|
|
109
|
+
return [
|
|
110
|
+
(props.enableRowDragging || props.enableRowOrdering) && 'mrt-row-drag',
|
|
111
|
+
props.positionActionsColumn === 'first' &&
|
|
112
|
+
(props.enableRowActions ||
|
|
113
|
+
(props.enableEditing &&
|
|
114
|
+
['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
|
|
115
|
+
'mrt-row-actions',
|
|
116
|
+
props.positionExpandColumn === 'first' &&
|
|
117
|
+
showExpandColumn(props) &&
|
|
118
|
+
'mrt-row-expand',
|
|
119
|
+
props.enableRowSelection && 'mrt-row-select',
|
|
120
|
+
props.enableRowNumbers && 'mrt-row-numbers',
|
|
121
|
+
].filter(Boolean);
|
|
122
|
+
};
|
|
123
|
+
const getTrailingDisplayColumnIds = (props) => {
|
|
124
|
+
var _a;
|
|
125
|
+
return [
|
|
126
|
+
props.positionActionsColumn === 'last' &&
|
|
127
|
+
(props.enableRowActions ||
|
|
128
|
+
(props.enableEditing &&
|
|
129
|
+
['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
|
|
130
|
+
'mrt-row-actions',
|
|
131
|
+
props.positionExpandColumn === 'last' &&
|
|
132
|
+
showExpandColumn(props) &&
|
|
133
|
+
'mrt-row-expand',
|
|
134
|
+
];
|
|
135
|
+
};
|
|
136
|
+
const getDefaultColumnOrderIds = (props) => [
|
|
137
|
+
...getLeadingDisplayColumnIds(props),
|
|
138
|
+
...getAllLeafColumnDefs(props.columns).map((columnDef) => getColumnId(columnDef)),
|
|
139
|
+
...getTrailingDisplayColumnIds(props),
|
|
140
|
+
].filter(Boolean);
|
|
141
|
+
const getDefaultColumnFilterFn = (columnDef) => {
|
|
142
|
+
if (columnDef.filterVariant === 'multi-select')
|
|
143
|
+
return 'arrIncludesSome';
|
|
144
|
+
if (columnDef.filterVariant === 'range')
|
|
145
|
+
return 'betweenInclusive';
|
|
146
|
+
if (columnDef.filterVariant === 'select' ||
|
|
147
|
+
columnDef.filterVariant === 'checkbox')
|
|
148
|
+
return 'equals';
|
|
149
|
+
return 'fuzzy';
|
|
150
|
+
};
|
|
151
|
+
const getIsLastLeftPinnedColumn = (table, column) => {
|
|
152
|
+
return (column.getIsPinned() === 'left' &&
|
|
153
|
+
table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
|
|
154
|
+
};
|
|
155
|
+
const getIsFirstRightPinnedColumn = (column) => {
|
|
156
|
+
return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
|
|
157
|
+
};
|
|
158
|
+
const getTotalRight = (table, column) => {
|
|
159
|
+
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 160);
|
|
160
|
+
};
|
|
161
|
+
const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
|
|
162
|
+
var _a, _b, _c, _d;
|
|
163
|
+
return (Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
|
164
|
+
? material.alpha(material.lighten(theme.palette.background.default, 0.04), 0.97)
|
|
165
|
+
: 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn(table, column)
|
|
166
|
+
? `-4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
|
|
167
|
+
: getIsFirstRightPinnedColumn(column)
|
|
168
|
+
? `4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
|
|
169
|
+
: undefined, left: column.getIsPinned() === 'left'
|
|
170
|
+
? `${column.getStart('left')}px`
|
|
171
|
+
: undefined, opacity: ((_a = table.getState().draggingColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id ||
|
|
172
|
+
((_b = table.getState().hoveredColumn) === null || _b === void 0 ? void 0 : _b.id) === column.id
|
|
173
|
+
? 0.5
|
|
174
|
+
: 1, position: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
|
175
|
+
? 'sticky'
|
|
176
|
+
: undefined, right: column.getIsPinned() === 'right'
|
|
177
|
+
? `${getTotalRight(table, column)}px`
|
|
178
|
+
: undefined, transition: `all ${column.getIsResizing() ? 0 : '150ms'} ease-in-out` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
179
|
+
? tableCellProps.sx(theme)
|
|
180
|
+
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx)), { maxWidth: `min(${column.getSize()}px, fit-content)`, minWidth: `max(${column.getSize()}px, ${(_c = column.columnDef.minSize) !== null && _c !== void 0 ? _c : 30}px)`, width: (_d = header === null || header === void 0 ? void 0 : header.getSize()) !== null && _d !== void 0 ? _d : column.getSize() }));
|
|
181
|
+
};
|
|
182
|
+
const MRT_DefaultColumn = {
|
|
183
|
+
minSize: 40,
|
|
184
|
+
maxSize: 1000,
|
|
185
|
+
size: 180,
|
|
186
|
+
};
|
|
187
|
+
const MRT_DefaultDisplayColumn = {
|
|
188
|
+
columnDefType: 'display',
|
|
189
|
+
enableClickToCopy: false,
|
|
190
|
+
enableColumnActions: false,
|
|
191
|
+
enableColumnDragging: false,
|
|
192
|
+
enableColumnFilter: false,
|
|
193
|
+
enableColumnOrdering: false,
|
|
194
|
+
enableEditing: false,
|
|
195
|
+
enableGlobalFilter: false,
|
|
196
|
+
enableGrouping: false,
|
|
197
|
+
enableHiding: false,
|
|
198
|
+
enableResizing: false,
|
|
199
|
+
enableSorting: false,
|
|
76
200
|
};
|
|
77
201
|
|
|
78
202
|
const fuzzy$1 = (row, columnId, filterValue, addMeta) => {
|
|
@@ -159,94 +283,37 @@ const MRT_FilterFns = Object.assign(Object.assign({}, reactTable.filterFns), { b
|
|
|
159
283
|
notEquals,
|
|
160
284
|
startsWith });
|
|
161
285
|
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
filterIncludesString: 'Contains',
|
|
194
|
-
filterIncludesStringSensitive: 'Contains',
|
|
195
|
-
filterLessThan: 'Less Than',
|
|
196
|
-
filterLessThanOrEqualTo: 'Less Than Or Equal To',
|
|
197
|
-
filterMode: 'Filter Mode: {filterType}',
|
|
198
|
-
filterNotEmpty: 'Not Empty',
|
|
199
|
-
filterNotEquals: 'Not Equals',
|
|
200
|
-
filterStartsWith: 'Starts With',
|
|
201
|
-
filterWeakEquals: 'Equals',
|
|
202
|
-
filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
|
|
203
|
-
goToFirstPage: 'Go to first page',
|
|
204
|
-
goToLastPage: 'Go to last page',
|
|
205
|
-
goToNextPage: 'Go to next page',
|
|
206
|
-
goToPreviousPage: 'Go to previous page',
|
|
207
|
-
grab: 'Grab',
|
|
208
|
-
groupByColumn: 'Group by {column}',
|
|
209
|
-
groupedBy: 'Grouped by ',
|
|
210
|
-
hideAll: 'Hide all',
|
|
211
|
-
hideColumn: 'Hide {column} column',
|
|
212
|
-
max: 'Max',
|
|
213
|
-
min: 'Min',
|
|
214
|
-
move: 'Move',
|
|
215
|
-
noRecordsToDisplay: 'No records to display',
|
|
216
|
-
noResultsFound: 'No results found',
|
|
217
|
-
of: 'of',
|
|
218
|
-
or: 'or',
|
|
219
|
-
pinToLeft: 'Pin to left',
|
|
220
|
-
pinToRight: 'Pin to right',
|
|
221
|
-
resetColumnSize: 'Reset column size',
|
|
222
|
-
resetOrder: 'Reset order',
|
|
223
|
-
rowActions: 'Row Actions',
|
|
224
|
-
rowNumber: '#',
|
|
225
|
-
rowNumbers: 'Row Numbers',
|
|
226
|
-
rowsPerPage: 'Rows per page',
|
|
227
|
-
save: 'Save',
|
|
228
|
-
search: 'Search',
|
|
229
|
-
selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
|
|
230
|
-
select: 'Select',
|
|
231
|
-
showAll: 'Show all',
|
|
232
|
-
showAllColumns: 'Show all columns',
|
|
233
|
-
showHideColumns: 'Show/Hide columns',
|
|
234
|
-
showHideFilters: 'Show/Hide filters',
|
|
235
|
-
showHideSearch: 'Show/Hide search',
|
|
236
|
-
sortByColumnAsc: 'Sort by {column} ascending',
|
|
237
|
-
sortByColumnDesc: 'Sort by {column} descending',
|
|
238
|
-
sortedByColumnAsc: 'Sorted by {column} ascending',
|
|
239
|
-
sortedByColumnDesc: 'Sorted by {column} descending',
|
|
240
|
-
thenBy: ', then by ',
|
|
241
|
-
toggleDensity: 'Toggle density',
|
|
242
|
-
toggleFullScreen: 'Toggle full screen',
|
|
243
|
-
toggleSelectAll: 'Toggle select all',
|
|
244
|
-
toggleSelectRow: 'Toggle select row',
|
|
245
|
-
toggleVisibility: 'Toggle visibility',
|
|
246
|
-
ungroupByColumn: 'Ungroup by {column}',
|
|
247
|
-
unpin: 'Unpin',
|
|
248
|
-
unpinAll: 'Unpin all',
|
|
249
|
-
unsorted: 'Unsorted',
|
|
286
|
+
const MRT_Default_Icons = {
|
|
287
|
+
ArrowRightIcon: iconsMaterial.ArrowRight,
|
|
288
|
+
CancelIcon: iconsMaterial.Cancel,
|
|
289
|
+
CheckBoxIcon: iconsMaterial.CheckBox,
|
|
290
|
+
ClearAllIcon: iconsMaterial.ClearAll,
|
|
291
|
+
CloseIcon: iconsMaterial.Close,
|
|
292
|
+
DensityLargeIcon: iconsMaterial.DensityLarge,
|
|
293
|
+
DensityMediumIcon: iconsMaterial.DensityMedium,
|
|
294
|
+
DensitySmallIcon: iconsMaterial.DensitySmall,
|
|
295
|
+
DragHandleIcon: iconsMaterial.DragHandle,
|
|
296
|
+
DynamicFeedIcon: iconsMaterial.DynamicFeed,
|
|
297
|
+
EditIcon: iconsMaterial.Edit,
|
|
298
|
+
ExpandLessIcon: iconsMaterial.ExpandLess,
|
|
299
|
+
ExpandMoreIcon: iconsMaterial.ExpandMore,
|
|
300
|
+
FilterAltIcon: iconsMaterial.FilterAlt,
|
|
301
|
+
FilterAltOffIcon: iconsMaterial.FilterAltOff,
|
|
302
|
+
FilterListIcon: iconsMaterial.FilterList,
|
|
303
|
+
FilterListOffIcon: iconsMaterial.FilterListOff,
|
|
304
|
+
FullscreenExitIcon: iconsMaterial.FullscreenExit,
|
|
305
|
+
FullscreenIcon: iconsMaterial.Fullscreen,
|
|
306
|
+
KeyboardDoubleArrowDownIcon: iconsMaterial.KeyboardDoubleArrowDown,
|
|
307
|
+
MoreHorizIcon: iconsMaterial.MoreHoriz,
|
|
308
|
+
MoreVertIcon: iconsMaterial.MoreVert,
|
|
309
|
+
PushPinIcon: iconsMaterial.PushPin,
|
|
310
|
+
RestartAltIcon: iconsMaterial.RestartAlt,
|
|
311
|
+
SaveIcon: iconsMaterial.Save,
|
|
312
|
+
SearchIcon: iconsMaterial.Search,
|
|
313
|
+
SearchOffIcon: iconsMaterial.SearchOff,
|
|
314
|
+
SortIcon: iconsMaterial.Sort,
|
|
315
|
+
ViewColumnIcon: iconsMaterial.ViewColumn,
|
|
316
|
+
VisibilityOffIcon: iconsMaterial.VisibilityOff,
|
|
250
317
|
};
|
|
251
318
|
|
|
252
319
|
const fuzzy = (rowA, rowB, columnId) => {
|
|
@@ -508,163 +575,6 @@ const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table,
|
|
|
508
575
|
React__default["default"].createElement(DragHandleIcon, null))));
|
|
509
576
|
};
|
|
510
577
|
|
|
511
|
-
const getColumnId = (columnDef) => { var _a, _b, _c, _d; return (_d = (_a = columnDef.id) !== null && _a !== void 0 ? _a : (_c = (_b = columnDef.accessorKey) === null || _b === void 0 ? void 0 : _b.toString) === null || _c === void 0 ? void 0 : _c.call(_b)) !== null && _d !== void 0 ? _d : columnDef.header; };
|
|
512
|
-
const getAllLeafColumnDefs = (columns) => {
|
|
513
|
-
const allLeafColumnDefs = [];
|
|
514
|
-
const getLeafColumns = (cols) => {
|
|
515
|
-
cols.forEach((col) => {
|
|
516
|
-
if (col.columns) {
|
|
517
|
-
getLeafColumns(col.columns);
|
|
518
|
-
}
|
|
519
|
-
else {
|
|
520
|
-
allLeafColumnDefs.push(col);
|
|
521
|
-
}
|
|
522
|
-
});
|
|
523
|
-
};
|
|
524
|
-
getLeafColumns(columns);
|
|
525
|
-
return allLeafColumnDefs;
|
|
526
|
-
};
|
|
527
|
-
const prepareColumns = ({ columnDefs, columnFilterFns, defaultDisplayColumn, filterFns, sortingFns, }) => columnDefs.map((columnDef) => {
|
|
528
|
-
var _a, _b;
|
|
529
|
-
if (!columnDef.id)
|
|
530
|
-
columnDef.id = getColumnId(columnDef);
|
|
531
|
-
if (process.env.NODE_ENV !== 'production' && !columnDef.id) {
|
|
532
|
-
console.error('Column definitions must have a valid `accessorKey` or `id` property');
|
|
533
|
-
}
|
|
534
|
-
if (!columnDef.columnDefType)
|
|
535
|
-
columnDef.columnDefType = 'data';
|
|
536
|
-
if (!!((_a = columnDef.columns) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
537
|
-
columnDef.columnDefType = 'group';
|
|
538
|
-
columnDef.columns = prepareColumns({
|
|
539
|
-
columnDefs: columnDef.columns,
|
|
540
|
-
columnFilterFns,
|
|
541
|
-
defaultDisplayColumn,
|
|
542
|
-
filterFns,
|
|
543
|
-
sortingFns,
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
else if (columnDef.columnDefType === 'data') {
|
|
547
|
-
if (Object.keys(filterFns).includes(columnFilterFns[columnDef.id])) {
|
|
548
|
-
columnDef.filterFn =
|
|
549
|
-
(_b = filterFns[columnFilterFns[columnDef.id]]) !== null && _b !== void 0 ? _b : filterFns.fuzzy;
|
|
550
|
-
columnDef._filterFn =
|
|
551
|
-
columnFilterFns[columnDef.id];
|
|
552
|
-
}
|
|
553
|
-
if (Object.keys(sortingFns).includes(columnDef.sortingFn)) {
|
|
554
|
-
// @ts-ignore
|
|
555
|
-
columnDef.sortingFn = sortingFns[columnDef.sortingFn];
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
else if (columnDef.columnDefType === 'display') {
|
|
559
|
-
columnDef = Object.assign(Object.assign({}, defaultDisplayColumn), columnDef);
|
|
560
|
-
}
|
|
561
|
-
return columnDef;
|
|
562
|
-
});
|
|
563
|
-
const reorderColumn = (draggedColumn, targetColumn, columnOrder) => {
|
|
564
|
-
if (draggedColumn.getCanPin()) {
|
|
565
|
-
draggedColumn.pin(targetColumn.getIsPinned());
|
|
566
|
-
}
|
|
567
|
-
columnOrder.splice(columnOrder.indexOf(targetColumn.id), 0, columnOrder.splice(columnOrder.indexOf(draggedColumn.id), 1)[0]);
|
|
568
|
-
return [...columnOrder];
|
|
569
|
-
};
|
|
570
|
-
const showExpandColumn = (props, grouping) => !!(props.enableExpanding ||
|
|
571
|
-
(props.enableGrouping && (grouping === undefined || (grouping === null || grouping === void 0 ? void 0 : grouping.length))) ||
|
|
572
|
-
props.renderDetailPanel);
|
|
573
|
-
const getLeadingDisplayColumnIds = (props) => {
|
|
574
|
-
var _a;
|
|
575
|
-
return [
|
|
576
|
-
(props.enableRowDragging || props.enableRowOrdering) && 'mrt-row-drag',
|
|
577
|
-
props.positionActionsColumn === 'first' &&
|
|
578
|
-
(props.enableRowActions ||
|
|
579
|
-
(props.enableEditing &&
|
|
580
|
-
['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
|
|
581
|
-
'mrt-row-actions',
|
|
582
|
-
props.positionExpandColumn === 'first' &&
|
|
583
|
-
showExpandColumn(props) &&
|
|
584
|
-
'mrt-row-expand',
|
|
585
|
-
props.enableRowSelection && 'mrt-row-select',
|
|
586
|
-
props.enableRowNumbers && 'mrt-row-numbers',
|
|
587
|
-
].filter(Boolean);
|
|
588
|
-
};
|
|
589
|
-
const getTrailingDisplayColumnIds = (props) => {
|
|
590
|
-
var _a;
|
|
591
|
-
return [
|
|
592
|
-
props.positionActionsColumn === 'last' &&
|
|
593
|
-
(props.enableRowActions ||
|
|
594
|
-
(props.enableEditing &&
|
|
595
|
-
['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
|
|
596
|
-
'mrt-row-actions',
|
|
597
|
-
props.positionExpandColumn === 'last' &&
|
|
598
|
-
showExpandColumn(props) &&
|
|
599
|
-
'mrt-row-expand',
|
|
600
|
-
];
|
|
601
|
-
};
|
|
602
|
-
const getDefaultColumnOrderIds = (props) => [
|
|
603
|
-
...getLeadingDisplayColumnIds(props),
|
|
604
|
-
...getAllLeafColumnDefs(props.columns).map((columnDef) => getColumnId(columnDef)),
|
|
605
|
-
...getTrailingDisplayColumnIds(props),
|
|
606
|
-
].filter(Boolean);
|
|
607
|
-
const getDefaultColumnFilterFn = (columnDef) => {
|
|
608
|
-
if (columnDef.filterVariant === 'multi-select')
|
|
609
|
-
return 'arrIncludesSome';
|
|
610
|
-
if (columnDef.filterVariant === 'range')
|
|
611
|
-
return 'betweenInclusive';
|
|
612
|
-
if (columnDef.filterVariant === 'select' ||
|
|
613
|
-
columnDef.filterVariant === 'checkbox')
|
|
614
|
-
return 'equals';
|
|
615
|
-
return 'fuzzy';
|
|
616
|
-
};
|
|
617
|
-
const getIsLastLeftPinnedColumn = (table, column) => {
|
|
618
|
-
return (column.getIsPinned() === 'left' &&
|
|
619
|
-
table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex());
|
|
620
|
-
};
|
|
621
|
-
const getIsFirstRightPinnedColumn = (column) => {
|
|
622
|
-
return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
|
|
623
|
-
};
|
|
624
|
-
const getTotalRight = (table, column) => {
|
|
625
|
-
return ((table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 160);
|
|
626
|
-
};
|
|
627
|
-
const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
|
|
628
|
-
var _a, _b, _c, _d;
|
|
629
|
-
return (Object.assign(Object.assign({ backgroundColor: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
|
630
|
-
? material.alpha(material.lighten(theme.palette.background.default, 0.04), 0.97)
|
|
631
|
-
: 'inherit', backgroundImage: 'inherit', boxShadow: getIsLastLeftPinnedColumn(table, column)
|
|
632
|
-
? `-4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
|
|
633
|
-
: getIsFirstRightPinnedColumn(column)
|
|
634
|
-
? `4px 0 8px -6px ${material.alpha(theme.palette.common.black, 0.2)} inset`
|
|
635
|
-
: undefined, left: column.getIsPinned() === 'left'
|
|
636
|
-
? `${column.getStart('left')}px`
|
|
637
|
-
: undefined, opacity: ((_a = table.getState().draggingColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id ||
|
|
638
|
-
((_b = table.getState().hoveredColumn) === null || _b === void 0 ? void 0 : _b.id) === column.id
|
|
639
|
-
? 0.5
|
|
640
|
-
: 1, position: column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
|
641
|
-
? 'sticky'
|
|
642
|
-
: undefined, right: column.getIsPinned() === 'right'
|
|
643
|
-
? `${getTotalRight(table, column)}px`
|
|
644
|
-
: undefined, transition: `all ${column.getIsResizing() ? 0 : '150ms'} ease-in-out` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
|
|
645
|
-
? tableCellProps.sx(theme)
|
|
646
|
-
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx)), { maxWidth: `min(${column.getSize()}px, fit-content)`, minWidth: `max(${column.getSize()}px, ${(_c = column.columnDef.minSize) !== null && _c !== void 0 ? _c : 30}px)`, width: (_d = header === null || header === void 0 ? void 0 : header.getSize()) !== null && _d !== void 0 ? _d : column.getSize() }));
|
|
647
|
-
};
|
|
648
|
-
const MRT_DefaultColumn = {
|
|
649
|
-
minSize: 40,
|
|
650
|
-
maxSize: 1000,
|
|
651
|
-
size: 180,
|
|
652
|
-
};
|
|
653
|
-
const MRT_DefaultDisplayColumn = {
|
|
654
|
-
columnDefType: 'display',
|
|
655
|
-
enableClickToCopy: false,
|
|
656
|
-
enableColumnActions: false,
|
|
657
|
-
enableColumnDragging: false,
|
|
658
|
-
enableColumnFilter: false,
|
|
659
|
-
enableColumnOrdering: false,
|
|
660
|
-
enableEditing: false,
|
|
661
|
-
enableGlobalFilter: false,
|
|
662
|
-
enableGrouping: false,
|
|
663
|
-
enableHiding: false,
|
|
664
|
-
enableResizing: false,
|
|
665
|
-
enableSorting: false,
|
|
666
|
-
};
|
|
667
|
-
|
|
668
578
|
const MRT_ShowHideColumnsMenuItems = ({ allColumns, hoveredColumn, setHoveredColumn, column, isSubMenu, table, }) => {
|
|
669
579
|
var _a;
|
|
670
580
|
const { getState, options: { enableColumnOrdering, enableHiding, enablePinning, localization, }, setColumnOrder, } = table;
|
|
@@ -2719,6 +2629,96 @@ const MRT_TableRoot = (props) => {
|
|
|
2719
2629
|
editingRow && props.editingMode === 'modal' && (React__default["default"].createElement(MRT_EditRowModal, { row: editingRow, table: table, open: true }))));
|
|
2720
2630
|
};
|
|
2721
2631
|
|
|
2632
|
+
const MRT_Localization_EN = {
|
|
2633
|
+
actions: 'Actions',
|
|
2634
|
+
and: 'and',
|
|
2635
|
+
cancel: 'Cancel',
|
|
2636
|
+
changeFilterMode: 'Change filter mode',
|
|
2637
|
+
changeSearchMode: 'Change search mode',
|
|
2638
|
+
clearFilter: 'Clear filter',
|
|
2639
|
+
clearSearch: 'Clear search',
|
|
2640
|
+
clearSort: 'Clear sort',
|
|
2641
|
+
clickToCopy: 'Click to copy',
|
|
2642
|
+
columnActions: 'Column Actions',
|
|
2643
|
+
copiedToClipboard: 'Copied to clipboard',
|
|
2644
|
+
dropToGroupBy: 'Drop to group by {column}',
|
|
2645
|
+
edit: 'Edit',
|
|
2646
|
+
expand: 'Expand',
|
|
2647
|
+
expandAll: 'Expand all',
|
|
2648
|
+
filterArrIncludes: 'Includes',
|
|
2649
|
+
filterArrIncludesAll: 'Includes all',
|
|
2650
|
+
filterArrIncludesSome: 'Includes',
|
|
2651
|
+
filterBetween: 'Between',
|
|
2652
|
+
filterBetweenInclusive: 'Between Inclusive',
|
|
2653
|
+
filterByColumn: 'Filter by {column}',
|
|
2654
|
+
filterContains: 'Contains',
|
|
2655
|
+
filterEmpty: 'Empty',
|
|
2656
|
+
filterEndsWith: 'Ends With',
|
|
2657
|
+
filterEquals: 'Equals',
|
|
2658
|
+
filterEqualsString: 'Equals',
|
|
2659
|
+
filterFuzzy: 'Fuzzy',
|
|
2660
|
+
filterGreaterThan: 'Greater Than',
|
|
2661
|
+
filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
|
|
2662
|
+
filterInNumberRange: 'Between',
|
|
2663
|
+
filterIncludesString: 'Contains',
|
|
2664
|
+
filterIncludesStringSensitive: 'Contains',
|
|
2665
|
+
filterLessThan: 'Less Than',
|
|
2666
|
+
filterLessThanOrEqualTo: 'Less Than Or Equal To',
|
|
2667
|
+
filterMode: 'Filter Mode: {filterType}',
|
|
2668
|
+
filterNotEmpty: 'Not Empty',
|
|
2669
|
+
filterNotEquals: 'Not Equals',
|
|
2670
|
+
filterStartsWith: 'Starts With',
|
|
2671
|
+
filterWeakEquals: 'Equals',
|
|
2672
|
+
filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
|
|
2673
|
+
goToFirstPage: 'Go to first page',
|
|
2674
|
+
goToLastPage: 'Go to last page',
|
|
2675
|
+
goToNextPage: 'Go to next page',
|
|
2676
|
+
goToPreviousPage: 'Go to previous page',
|
|
2677
|
+
grab: 'Grab',
|
|
2678
|
+
groupByColumn: 'Group by {column}',
|
|
2679
|
+
groupedBy: 'Grouped by ',
|
|
2680
|
+
hideAll: 'Hide all',
|
|
2681
|
+
hideColumn: 'Hide {column} column',
|
|
2682
|
+
max: 'Max',
|
|
2683
|
+
min: 'Min',
|
|
2684
|
+
move: 'Move',
|
|
2685
|
+
noRecordsToDisplay: 'No records to display',
|
|
2686
|
+
noResultsFound: 'No results found',
|
|
2687
|
+
of: 'of',
|
|
2688
|
+
or: 'or',
|
|
2689
|
+
pinToLeft: 'Pin to left',
|
|
2690
|
+
pinToRight: 'Pin to right',
|
|
2691
|
+
resetColumnSize: 'Reset column size',
|
|
2692
|
+
resetOrder: 'Reset order',
|
|
2693
|
+
rowActions: 'Row Actions',
|
|
2694
|
+
rowNumber: '#',
|
|
2695
|
+
rowNumbers: 'Row Numbers',
|
|
2696
|
+
rowsPerPage: 'Rows per page',
|
|
2697
|
+
save: 'Save',
|
|
2698
|
+
search: 'Search',
|
|
2699
|
+
selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
|
|
2700
|
+
select: 'Select',
|
|
2701
|
+
showAll: 'Show all',
|
|
2702
|
+
showAllColumns: 'Show all columns',
|
|
2703
|
+
showHideColumns: 'Show/Hide columns',
|
|
2704
|
+
showHideFilters: 'Show/Hide filters',
|
|
2705
|
+
showHideSearch: 'Show/Hide search',
|
|
2706
|
+
sortByColumnAsc: 'Sort by {column} ascending',
|
|
2707
|
+
sortByColumnDesc: 'Sort by {column} descending',
|
|
2708
|
+
sortedByColumnAsc: 'Sorted by {column} ascending',
|
|
2709
|
+
sortedByColumnDesc: 'Sorted by {column} descending',
|
|
2710
|
+
thenBy: ', then by ',
|
|
2711
|
+
toggleDensity: 'Toggle density',
|
|
2712
|
+
toggleFullScreen: 'Toggle full screen',
|
|
2713
|
+
toggleSelectAll: 'Toggle select all',
|
|
2714
|
+
toggleSelectRow: 'Toggle select row',
|
|
2715
|
+
toggleVisibility: 'Toggle visibility',
|
|
2716
|
+
ungroupByColumn: 'Ungroup by {column}',
|
|
2717
|
+
unpin: 'Unpin',
|
|
2718
|
+
unpinAll: 'Unpin all',
|
|
2719
|
+
unsorted: 'Unsorted',
|
|
2720
|
+
};
|
|
2721
|
+
|
|
2722
2722
|
const MaterialReactTable = (_a) => {
|
|
2723
2723
|
var { aggregationFns, autoResetExpanded = false, columnResizeMode = 'onEnd', defaultColumn, defaultDisplayColumn, editingMode = 'modal', enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnResizing = false, enableDensityToggle = true, enableExpandAll = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enablePinning = false, enableRowSelection = false, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, localization, positionActionsColumn = 'first', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberMode = 'original', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnResizeMode", "defaultColumn", "defaultDisplayColumn", "editingMode", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnResizing", "enableDensityToggle", "enableExpandAll", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enablePinning", "enableRowSelection", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "localization", "positionActionsColumn", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberMode", "selectAllMode", "sortingFns"]);
|
|
2724
2724
|
const _icons = React.useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), []);
|