material-react-table 0.6.3 → 0.6.6
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/MaterialReactTable.d.ts +5 -3
- package/dist/buttons/MRT_CopyButton.d.ts +7 -0
- package/dist/filtersFNs.d.ts +10 -10
- package/dist/icons.d.ts +2 -0
- package/dist/localization.d.ts +2 -0
- package/dist/material-react-table.cjs.development.js +149 -70
- package/dist/material-react-table.cjs.development.js.map +1 -1
- package/dist/material-react-table.cjs.production.min.js +1 -1
- package/dist/material-react-table.cjs.production.min.js.map +1 -1
- package/dist/material-react-table.esm.js +150 -71
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ColumnActionMenu.d.ts +0 -1
- package/package.json +4 -4
- package/src/MaterialReactTable.tsx +5 -3
- package/src/body/MRT_TableBodyCell.tsx +10 -2
- package/src/body/MRT_TableBodyRow.tsx +2 -9
- package/src/buttons/MRT_CopyButton.tsx +50 -0
- package/src/buttons/MRT_ExpandButton.tsx +9 -1
- package/src/filtersFNs.ts +30 -30
- package/src/icons.ts +6 -0
- package/src/inputs/MRT_EditCellTextField.tsx +1 -1
- package/src/inputs/MRT_FilterTextField.tsx +24 -12
- package/src/localization.ts +4 -0
- package/src/menus/MRT_ColumnActionMenu.tsx +25 -11
- package/src/menus/MRT_FilterTypeMenu.tsx +76 -72
- package/src/menus/MRT_RowActionMenu.tsx +11 -4
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +3 -0
- package/src/table/MRT_TableContainer.tsx +1 -1
- package/src/useMRT.tsx +1 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React, { useState, useCallback, useMemo, useContext, createContext, Fragment, useEffect } from 'react';
|
|
2
2
|
import { useTable, useFilters, useGlobalFilter, useGroupBy, useSortBy, useExpanded, usePagination, useRowSelect, useResizeColumns, useFlexLayout, useAsyncDebounce } from 'react-table';
|
|
3
|
-
import { Menu, MenuItem, TextField, InputAdornment, Tooltip, IconButton, Chip, FormControlLabel, Switch, Box, Button, Divider, TableCell, TableSortLabel, Collapse, Skeleton, Checkbox, TableRow, TableHead,
|
|
3
|
+
import { Menu, MenuItem, TextField, InputAdornment, Tooltip, IconButton, Chip, FormControlLabel, Switch, Box, Button, Divider, ListItemIcon, TableCell, TableSortLabel, Collapse, Skeleton, Checkbox, TableRow, TableHead, TableBody, TableFooter, Table, TablePagination, useMediaQuery, Alert, LinearProgress, Toolbar, alpha, TableContainer, Paper } from '@mui/material';
|
|
4
4
|
import { matchSorter } from 'match-sorter';
|
|
5
5
|
import ArrowRightIcon from '@mui/icons-material/ArrowRight';
|
|
6
6
|
import CancelIcon from '@mui/icons-material/Cancel';
|
|
7
|
+
import CheckBoxIcon from '@mui/icons-material/CheckBox';
|
|
7
8
|
import ClearAllIcon from '@mui/icons-material/ClearAll';
|
|
8
9
|
import CloseIcon from '@mui/icons-material/Close';
|
|
10
|
+
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
|
|
9
11
|
import DensityMediumIcon from '@mui/icons-material/DensityMedium';
|
|
10
12
|
import DensitySmallIcon from '@mui/icons-material/DensitySmall';
|
|
11
13
|
import DoubleArrowDownIcon from '@mui/icons-material/KeyboardDoubleArrowDown';
|
|
@@ -183,7 +185,7 @@ var MaterialReactTableProvider = function MaterialReactTableProvider(props) {
|
|
|
183
185
|
return applyFiltersToColumns(props.columns);
|
|
184
186
|
}, [props.columns, applyFiltersToColumns]);
|
|
185
187
|
var data = useMemo(function () {
|
|
186
|
-
return !props.isLoading || !!props.data.length ? props.data : [].concat(Array(10)).map(function (_) {
|
|
188
|
+
return !props.isLoading || !!props.data.length ? props.data : [].concat(Array(10).fill(null)).map(function (_) {
|
|
187
189
|
return Object.assign.apply(Object, [{}].concat(findLowestLevelCols(props.columns).map(function (c) {
|
|
188
190
|
var _ref3;
|
|
189
191
|
|
|
@@ -260,7 +262,7 @@ var MRT_FILTER_TYPE;
|
|
|
260
262
|
MRT_FILTER_TYPE["STARTS_WITH"] = "startsWith";
|
|
261
263
|
})(MRT_FILTER_TYPE || (MRT_FILTER_TYPE = {}));
|
|
262
264
|
|
|
263
|
-
var
|
|
265
|
+
var fuzzy = function fuzzy(rows, columnIds, filterValue) {
|
|
264
266
|
return matchSorter(rows, filterValue.toString().trim(), {
|
|
265
267
|
keys: Array.isArray(columnIds) ? columnIds.map(function (c) {
|
|
266
268
|
return "values." + c;
|
|
@@ -271,111 +273,111 @@ var fuzzyFilterFN = function fuzzyFilterFN(rows, columnIds, filterValue) {
|
|
|
271
273
|
});
|
|
272
274
|
};
|
|
273
275
|
|
|
274
|
-
|
|
276
|
+
fuzzy.autoRemove = function (val) {
|
|
275
277
|
return !val;
|
|
276
278
|
};
|
|
277
279
|
|
|
278
|
-
var
|
|
280
|
+
var contains = function contains(rows, id, filterValue) {
|
|
279
281
|
return rows.filter(function (row) {
|
|
280
282
|
return row.values[id].toString().toLowerCase().trim().includes(filterValue.toString().toLowerCase().trim());
|
|
281
283
|
});
|
|
282
284
|
};
|
|
283
285
|
|
|
284
|
-
|
|
286
|
+
contains.autoRemove = function (val) {
|
|
285
287
|
return !val;
|
|
286
288
|
};
|
|
287
289
|
|
|
288
|
-
var
|
|
290
|
+
var startsWith = function startsWith(rows, id, filterValue) {
|
|
289
291
|
return rows.filter(function (row) {
|
|
290
292
|
return row.values[id].toString().toLowerCase().trim().startsWith(filterValue.toString().toLowerCase().trim());
|
|
291
293
|
});
|
|
292
294
|
};
|
|
293
295
|
|
|
294
|
-
|
|
296
|
+
startsWith.autoRemove = function (val) {
|
|
295
297
|
return !val;
|
|
296
298
|
};
|
|
297
299
|
|
|
298
|
-
var
|
|
300
|
+
var endsWith = function endsWith(rows, id, filterValue) {
|
|
299
301
|
return rows.filter(function (row) {
|
|
300
302
|
return row.values[id].toString().toLowerCase().trim().endsWith(filterValue.toString().toLowerCase().trim());
|
|
301
303
|
});
|
|
302
304
|
};
|
|
303
305
|
|
|
304
|
-
|
|
306
|
+
endsWith.autoRemove = function (val) {
|
|
305
307
|
return !val;
|
|
306
308
|
};
|
|
307
309
|
|
|
308
|
-
var
|
|
310
|
+
var equals = function equals(rows, id, filterValue) {
|
|
309
311
|
return rows.filter(function (row) {
|
|
310
312
|
return row.values[id].toString().toLowerCase().trim() === filterValue.toString().toLowerCase().trim();
|
|
311
313
|
});
|
|
312
314
|
};
|
|
313
315
|
|
|
314
|
-
|
|
316
|
+
equals.autoRemove = function (val) {
|
|
315
317
|
return !val;
|
|
316
318
|
};
|
|
317
319
|
|
|
318
|
-
var
|
|
320
|
+
var notEquals = function notEquals(rows, id, filterValue) {
|
|
319
321
|
return rows.filter(function (row) {
|
|
320
322
|
return row.values[id].toString().toLowerCase().trim() !== filterValue.toString().toLowerCase().trim();
|
|
321
323
|
});
|
|
322
324
|
};
|
|
323
325
|
|
|
324
|
-
|
|
326
|
+
notEquals.autoRemove = function (val) {
|
|
325
327
|
return !val;
|
|
326
328
|
};
|
|
327
329
|
|
|
328
|
-
var
|
|
330
|
+
var greaterThan = function greaterThan(rows, id, filterValue) {
|
|
329
331
|
return rows.filter(function (row) {
|
|
330
332
|
return !isNaN(+filterValue) && !isNaN(+row.values[id]) ? +row.values[id] > +filterValue : row.values[id].toString().toLowerCase().trim() > filterValue.toString().toLowerCase().trim();
|
|
331
333
|
});
|
|
332
334
|
};
|
|
333
335
|
|
|
334
|
-
|
|
336
|
+
greaterThan.autoRemove = function (val) {
|
|
335
337
|
return !val;
|
|
336
338
|
};
|
|
337
339
|
|
|
338
|
-
var
|
|
340
|
+
var lessThan = function lessThan(rows, id, filterValue) {
|
|
339
341
|
return rows.filter(function (row) {
|
|
340
342
|
return !isNaN(+filterValue) && !isNaN(+row.values[id]) ? +row.values[id] < +filterValue : row.values[id].toString().toLowerCase().trim() < filterValue.toString().toLowerCase().trim();
|
|
341
343
|
});
|
|
342
344
|
};
|
|
343
345
|
|
|
344
|
-
|
|
346
|
+
lessThan.autoRemove = function (val) {
|
|
345
347
|
return !val;
|
|
346
348
|
};
|
|
347
349
|
|
|
348
|
-
var
|
|
350
|
+
var empty = function empty(rows, id, _filterValue) {
|
|
349
351
|
return rows.filter(function (row) {
|
|
350
352
|
return !row.values[id].toString().toLowerCase().trim();
|
|
351
353
|
});
|
|
352
354
|
};
|
|
353
355
|
|
|
354
|
-
|
|
356
|
+
empty.autoRemove = function (val) {
|
|
355
357
|
return !val;
|
|
356
358
|
};
|
|
357
359
|
|
|
358
|
-
var
|
|
360
|
+
var notEmpty = function notEmpty(rows, id, _filterValue) {
|
|
359
361
|
return rows.filter(function (row) {
|
|
360
362
|
return !!row.values[id].toString().toLowerCase().trim();
|
|
361
363
|
});
|
|
362
364
|
};
|
|
363
365
|
|
|
364
|
-
|
|
366
|
+
notEmpty.autoRemove = function (val) {
|
|
365
367
|
return !val;
|
|
366
368
|
};
|
|
367
369
|
|
|
368
370
|
var defaultFilterFNs = {
|
|
369
|
-
contains:
|
|
370
|
-
empty:
|
|
371
|
-
endsWith:
|
|
372
|
-
equals:
|
|
373
|
-
fuzzy:
|
|
374
|
-
greaterThan:
|
|
375
|
-
lessThan:
|
|
376
|
-
notEmpty:
|
|
377
|
-
notEquals:
|
|
378
|
-
startsWith:
|
|
371
|
+
contains: contains,
|
|
372
|
+
empty: empty,
|
|
373
|
+
endsWith: endsWith,
|
|
374
|
+
equals: equals,
|
|
375
|
+
fuzzy: fuzzy,
|
|
376
|
+
greaterThan: greaterThan,
|
|
377
|
+
lessThan: lessThan,
|
|
378
|
+
notEmpty: notEmpty,
|
|
379
|
+
notEquals: notEquals,
|
|
380
|
+
startsWith: startsWith
|
|
379
381
|
};
|
|
380
382
|
|
|
381
383
|
var commonMenuItemStyles = {
|
|
@@ -399,53 +401,55 @@ var MRT_FilterTypeMenu = function MRT_FilterTypeMenu(_ref) {
|
|
|
399
401
|
type: MRT_FILTER_TYPE.FUZZY,
|
|
400
402
|
label: localization.filterFuzzy,
|
|
401
403
|
divider: false,
|
|
402
|
-
fn:
|
|
404
|
+
fn: fuzzy
|
|
403
405
|
}, {
|
|
404
406
|
type: MRT_FILTER_TYPE.CONTAINS,
|
|
405
407
|
label: localization.filterContains,
|
|
406
408
|
divider: true,
|
|
407
|
-
fn:
|
|
409
|
+
fn: contains
|
|
408
410
|
}, {
|
|
409
411
|
type: MRT_FILTER_TYPE.STARTS_WITH,
|
|
410
412
|
label: localization.filterStartsWith,
|
|
411
413
|
divider: false,
|
|
412
|
-
fn:
|
|
414
|
+
fn: startsWith
|
|
413
415
|
}, {
|
|
414
416
|
type: MRT_FILTER_TYPE.ENDS_WITH,
|
|
415
417
|
label: localization.filterEndsWith,
|
|
416
418
|
divider: true,
|
|
417
|
-
fn:
|
|
419
|
+
fn: endsWith
|
|
418
420
|
}, {
|
|
419
421
|
type: MRT_FILTER_TYPE.EQUALS,
|
|
420
422
|
label: localization.filterEquals,
|
|
421
423
|
divider: false,
|
|
422
|
-
fn:
|
|
424
|
+
fn: equals
|
|
423
425
|
}, {
|
|
424
426
|
type: MRT_FILTER_TYPE.NOT_EQUALS,
|
|
425
427
|
label: localization.filterNotEquals,
|
|
426
428
|
divider: true,
|
|
427
|
-
fn:
|
|
429
|
+
fn: notEquals
|
|
428
430
|
}, {
|
|
429
431
|
type: MRT_FILTER_TYPE.GREATER_THAN,
|
|
430
432
|
label: localization.filterGreaterThan,
|
|
431
433
|
divider: false,
|
|
432
|
-
fn:
|
|
434
|
+
fn: greaterThan
|
|
433
435
|
}, {
|
|
434
436
|
type: MRT_FILTER_TYPE.LESS_THAN,
|
|
435
437
|
label: localization.filterLessThan,
|
|
436
438
|
divider: true,
|
|
437
|
-
fn:
|
|
439
|
+
fn: lessThan
|
|
438
440
|
}, {
|
|
439
441
|
type: MRT_FILTER_TYPE.EMPTY,
|
|
440
442
|
label: localization.filterEmpty,
|
|
441
443
|
divider: false,
|
|
442
|
-
fn:
|
|
444
|
+
fn: empty
|
|
443
445
|
}, {
|
|
444
446
|
type: MRT_FILTER_TYPE.NOT_EMPTY,
|
|
445
447
|
label: localization.filterNotEmpty,
|
|
446
448
|
divider: false,
|
|
447
|
-
fn:
|
|
448
|
-
}]
|
|
449
|
+
fn: notEmpty
|
|
450
|
+
}].filter(function (filterType) {
|
|
451
|
+
return !column.filterTypes || column.filterTypes.includes(filterType.type);
|
|
452
|
+
});
|
|
449
453
|
}, []);
|
|
450
454
|
|
|
451
455
|
var handleSelectFilterType = function handleSelectFilterType(value) {
|
|
@@ -496,7 +500,7 @@ var MRT_FilterTypeMenu = function MRT_FilterTypeMenu(_ref) {
|
|
|
496
500
|
};
|
|
497
501
|
|
|
498
502
|
var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
499
|
-
var _localization$filterB, _localization$clearFi, _column$filterSelectO;
|
|
503
|
+
var _localization$filterB, _localization$filterM, _localization$, _localization$clearFi, _column$filterSelectO;
|
|
500
504
|
|
|
501
505
|
var column = _ref.column;
|
|
502
506
|
|
|
@@ -554,6 +558,7 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
554
558
|
}));
|
|
555
559
|
}
|
|
556
560
|
|
|
561
|
+
var filterId = "mrt-" + idPrefix + "-" + column.id + "-filter-text-field";
|
|
557
562
|
var filterType = tableInstance.state.currentFilterTypes[column.id];
|
|
558
563
|
var isSelectFilter = !!column.filterSelectOptions;
|
|
559
564
|
var filterChipLabel = !(filterType instanceof Function) && [MRT_FILTER_TYPE.EMPTY, MRT_FILTER_TYPE.NOT_EMPTY].includes(filterType) ? //@ts-ignore
|
|
@@ -561,7 +566,7 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
561
566
|
var filterPlaceholder = (_localization$filterB = localization.filterByColumn) == null ? void 0 : _localization$filterB.replace('{column}', String(column.Header));
|
|
562
567
|
return React.createElement(React.Fragment, null, React.createElement(TextField, Object.assign({
|
|
563
568
|
fullWidth: true,
|
|
564
|
-
id:
|
|
569
|
+
id: filterId,
|
|
565
570
|
inputProps: {
|
|
566
571
|
disabled: !!filterChipLabel,
|
|
567
572
|
sx: {
|
|
@@ -570,8 +575,11 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
570
575
|
},
|
|
571
576
|
title: filterPlaceholder
|
|
572
577
|
},
|
|
573
|
-
helperText:
|
|
574
|
-
|
|
578
|
+
helperText: React.createElement("label", {
|
|
579
|
+
htmlFor: filterId
|
|
580
|
+
}, filterType instanceof Function ? (_localization$filterM = localization.filterMode.replace('{filterType}', // @ts-ignore
|
|
581
|
+
(_localization$ = localization["filter" + (filterType.name.charAt(0).toUpperCase() + filterType.name.slice(1))]) != null ? _localization$ : '')) != null ? _localization$filterM : '' : localization.filterMode.replace('{filterType}', // @ts-ignore
|
|
582
|
+
localization["filter" + (filterType.charAt(0).toUpperCase() + filterType.slice(1))])),
|
|
575
583
|
FormHelperTextProps: {
|
|
576
584
|
sx: {
|
|
577
585
|
fontSize: '0.6rem',
|
|
@@ -679,6 +687,11 @@ var MRT_ShowHideColumnsMenuItems = function MRT_ShowHideColumnsMenuItems(_ref) {
|
|
|
679
687
|
|
|
680
688
|
var column = _ref.column,
|
|
681
689
|
isSubMenu = _ref.isSubMenu;
|
|
690
|
+
|
|
691
|
+
var _useMRT = useMRT(),
|
|
692
|
+
onColumnHide = _useMRT.onColumnHide,
|
|
693
|
+
tableInstance = _useMRT.tableInstance;
|
|
694
|
+
|
|
682
695
|
var isParentHeader = !!(column != null && (_column$columns = column.columns) != null && _column$columns.length);
|
|
683
696
|
var allChildColumnsVisible = isParentHeader && !!((_column$columns2 = column.columns) != null && _column$columns2.every(function (childColumn) {
|
|
684
697
|
return childColumn.isVisible;
|
|
@@ -695,6 +708,8 @@ var MRT_ShowHideColumnsMenuItems = function MRT_ShowHideColumnsMenuItems(_ref) {
|
|
|
695
708
|
} else {
|
|
696
709
|
column.toggleHidden();
|
|
697
710
|
}
|
|
711
|
+
|
|
712
|
+
onColumnHide == null ? void 0 : onColumnHide(column, tableInstance.state.hiddenColumns);
|
|
698
713
|
};
|
|
699
714
|
|
|
700
715
|
return React.createElement(React.Fragment, null, React.createElement(MenuItem, {
|
|
@@ -777,7 +792,6 @@ var commonMenuItemStyles$1 = {
|
|
|
777
792
|
};
|
|
778
793
|
var commonListItemStyles = {
|
|
779
794
|
display: 'flex',
|
|
780
|
-
gap: '0.75rem',
|
|
781
795
|
alignItems: 'center'
|
|
782
796
|
};
|
|
783
797
|
var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
@@ -886,14 +900,14 @@ var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
|
886
900
|
sx: commonMenuItemStyles$1
|
|
887
901
|
}, React.createElement(Box, {
|
|
888
902
|
sx: commonListItemStyles
|
|
889
|
-
}, React.createElement(ClearAllIcon, null), localization.clearSort)), React.createElement(MenuItem, {
|
|
903
|
+
}, React.createElement(ListItemIcon, null, React.createElement(ClearAllIcon, null)), localization.clearSort)), React.createElement(MenuItem, {
|
|
890
904
|
disabled: column.isSorted && !column.isSortedDesc,
|
|
891
905
|
key: 1,
|
|
892
906
|
onClick: handleSortAsc,
|
|
893
907
|
sx: commonMenuItemStyles$1
|
|
894
908
|
}, React.createElement(Box, {
|
|
895
909
|
sx: commonListItemStyles
|
|
896
|
-
}, React.createElement(SortIcon, null), (_localization$sortByC = localization.sortByColumnAsc) == null ? void 0 : _localization$sortByC.replace('{column}', String(column.Header)))), React.createElement(MenuItem, {
|
|
910
|
+
}, React.createElement(ListItemIcon, null, React.createElement(SortIcon, null)), (_localization$sortByC = localization.sortByColumnAsc) == null ? void 0 : _localization$sortByC.replace('{column}', String(column.Header)))), React.createElement(MenuItem, {
|
|
897
911
|
divider: !disableFilters || enableColumnGrouping || !disableColumnHiding,
|
|
898
912
|
key: 2,
|
|
899
913
|
disabled: column.isSorted && column.isSortedDesc,
|
|
@@ -901,25 +915,25 @@ var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
|
901
915
|
sx: commonMenuItemStyles$1
|
|
902
916
|
}, React.createElement(Box, {
|
|
903
917
|
sx: commonListItemStyles
|
|
904
|
-
}, React.createElement(SortIcon, {
|
|
918
|
+
}, React.createElement(ListItemIcon, null, React.createElement(SortIcon, {
|
|
905
919
|
style: {
|
|
906
920
|
transform: 'rotate(180deg) scaleX(-1)'
|
|
907
921
|
}
|
|
908
|
-
}), (_localization$sortByC2 = localization.sortByColumnDesc) == null ? void 0 : _localization$sortByC2.replace('{column}', String(column.Header))))], !disableFilters && column.canFilter && [React.createElement(MenuItem, {
|
|
922
|
+
})), (_localization$sortByC2 = localization.sortByColumnDesc) == null ? void 0 : _localization$sortByC2.replace('{column}', String(column.Header))))], !disableFilters && column.canFilter && [React.createElement(MenuItem, {
|
|
909
923
|
disabled: !column.filterValue,
|
|
910
924
|
key: 0,
|
|
911
925
|
onClick: handleClearFilter,
|
|
912
926
|
sx: commonMenuItemStyles$1
|
|
913
927
|
}, React.createElement(Box, {
|
|
914
928
|
sx: commonListItemStyles
|
|
915
|
-
}, React.createElement(FilterListOffIcon, null), localization.clearFilter)), React.createElement(MenuItem, {
|
|
929
|
+
}, React.createElement(ListItemIcon, null, React.createElement(FilterListOffIcon, null)), localization.clearFilter)), React.createElement(MenuItem, {
|
|
916
930
|
divider: enableColumnGrouping || !disableColumnHiding,
|
|
917
931
|
key: 1,
|
|
918
932
|
onClick: handleFilterByColumn,
|
|
919
933
|
sx: commonMenuItemStyles$1
|
|
920
934
|
}, React.createElement(Box, {
|
|
921
935
|
sx: commonListItemStyles
|
|
922
|
-
}, React.createElement(FilterListIcon, null), (_localization$filterB = localization.filterByColumn) == null ? void 0 : _localization$filterB.replace('{column}', String(column.Header))), !column.filterSelectOptions && React.createElement(IconButton, {
|
|
936
|
+
}, React.createElement(ListItemIcon, null, React.createElement(FilterListIcon, null)), (_localization$filterB = localization.filterByColumn) == null ? void 0 : _localization$filterB.replace('{column}', String(column.Header))), !column.filterSelectOptions && React.createElement(IconButton, {
|
|
923
937
|
onClick: handleOpenFilterModeMenu,
|
|
924
938
|
onMouseEnter: handleOpenFilterModeMenu,
|
|
925
939
|
size: "small",
|
|
@@ -939,20 +953,20 @@ var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
|
939
953
|
sx: commonMenuItemStyles$1
|
|
940
954
|
}, React.createElement(Box, {
|
|
941
955
|
sx: commonListItemStyles
|
|
942
|
-
}, React.createElement(DynamicFeedIcon, null), (_localization = localization[column.isGrouped ? 'ungroupByColumn' : 'groupByColumn']) == null ? void 0 : _localization.replace('{column}', String(column.Header))))], !disableColumnHiding && [React.createElement(MenuItem, {
|
|
956
|
+
}, React.createElement(ListItemIcon, null, React.createElement(DynamicFeedIcon, null)), (_localization = localization[column.isGrouped ? 'ungroupByColumn' : 'groupByColumn']) == null ? void 0 : _localization.replace('{column}', String(column.Header))))], !disableColumnHiding && [React.createElement(MenuItem, {
|
|
943
957
|
key: 0,
|
|
944
958
|
onClick: handleHideColumn,
|
|
945
959
|
sx: commonMenuItemStyles$1
|
|
946
960
|
}, React.createElement(Box, {
|
|
947
961
|
sx: commonListItemStyles
|
|
948
|
-
}, React.createElement(VisibilityOffIcon, null), (_localization$hideCol = localization.hideColumn) == null ? void 0 : _localization$hideCol.replace('{column}', String(column.Header)))), React.createElement(MenuItem, {
|
|
962
|
+
}, React.createElement(ListItemIcon, null, React.createElement(VisibilityOffIcon, null)), (_localization$hideCol = localization.hideColumn) == null ? void 0 : _localization$hideCol.replace('{column}', String(column.Header)))), React.createElement(MenuItem, {
|
|
949
963
|
disabled: !((_tableInstance$state$ = tableInstance.state.hiddenColumns) != null && _tableInstance$state$.length),
|
|
950
964
|
key: 1,
|
|
951
965
|
onClick: handleShowAllColumns,
|
|
952
966
|
sx: commonMenuItemStyles$1
|
|
953
967
|
}, React.createElement(Box, {
|
|
954
968
|
sx: commonListItemStyles
|
|
955
|
-
}, React.createElement(ViewColumnIcon, null), (_localization$showAll = localization.showAllColumns) == null ? void 0 : _localization$showAll.replace('{column}', String(column.Header))), !column.filterSelectOptions && React.createElement(IconButton, {
|
|
969
|
+
}, React.createElement(ListItemIcon, null, React.createElement(ViewColumnIcon, null)), (_localization$showAll = localization.showAllColumns) == null ? void 0 : _localization$showAll.replace('{column}', String(column.Header))), !column.filterSelectOptions && React.createElement(IconButton, {
|
|
956
970
|
onClick: handleOpenShowHideColumnsMenu,
|
|
957
971
|
onMouseEnter: handleOpenShowHideColumnsMenu,
|
|
958
972
|
size: "small",
|
|
@@ -1157,7 +1171,7 @@ var MRT_EditCellTextField = function MRT_EditCellTextField(_ref) {
|
|
|
1157
1171
|
style: _extends({}, muiTableBodyCellEditTextFieldProps == null ? void 0 : muiTableBodyCellEditTextFieldProps.style, (_cell$column$muiTable = cell.column.muiTableBodyCellEditTextFieldProps) == null ? void 0 : _cell$column$muiTable.style)
|
|
1158
1172
|
});
|
|
1159
1173
|
|
|
1160
|
-
if (cell.column.
|
|
1174
|
+
if (!cell.column.disableEditing && cell.column.Edit) {
|
|
1161
1175
|
return React.createElement(React.Fragment, null, cell.column.Edit(_extends({}, textFieldProps, {
|
|
1162
1176
|
cell: cell
|
|
1163
1177
|
})));
|
|
@@ -1175,6 +1189,52 @@ var MRT_EditCellTextField = function MRT_EditCellTextField(_ref) {
|
|
|
1175
1189
|
}, textFieldProps));
|
|
1176
1190
|
};
|
|
1177
1191
|
|
|
1192
|
+
var MRT_CopyButton = function MRT_CopyButton(_ref) {
|
|
1193
|
+
var cell = _ref.cell;
|
|
1194
|
+
|
|
1195
|
+
var _useMRT = useMRT(),
|
|
1196
|
+
_useMRT$icons = _useMRT.icons,
|
|
1197
|
+
CheckBoxIcon = _useMRT$icons.CheckBoxIcon,
|
|
1198
|
+
ContentCopyIcon = _useMRT$icons.ContentCopyIcon,
|
|
1199
|
+
localization = _useMRT.localization;
|
|
1200
|
+
|
|
1201
|
+
var _useState = useState(false),
|
|
1202
|
+
copied = _useState[0],
|
|
1203
|
+
setCopied = _useState[1];
|
|
1204
|
+
|
|
1205
|
+
var handleCopy = function handleCopy(text) {
|
|
1206
|
+
navigator.clipboard.writeText(text);
|
|
1207
|
+
setCopied(true);
|
|
1208
|
+
setTimeout(function () {
|
|
1209
|
+
return setCopied(false);
|
|
1210
|
+
}, 2000);
|
|
1211
|
+
};
|
|
1212
|
+
|
|
1213
|
+
return React.createElement(Tooltip, {
|
|
1214
|
+
arrow: true,
|
|
1215
|
+
title: copied ? localization.copiedToClipboard : localization.clickToCopy
|
|
1216
|
+
}, React.createElement(IconButton, {
|
|
1217
|
+
"aria-label": localization.clickToCopy,
|
|
1218
|
+
onClick: function onClick() {
|
|
1219
|
+
return handleCopy(cell.value);
|
|
1220
|
+
},
|
|
1221
|
+
size: "small",
|
|
1222
|
+
sx: {
|
|
1223
|
+
opacity: 0.05,
|
|
1224
|
+
m: '0 0.5rem',
|
|
1225
|
+
transition: 'all 0.2s ease-in-out',
|
|
1226
|
+
'&:hover': {
|
|
1227
|
+
opacity: 1
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
}, copied ? React.createElement(CheckBoxIcon, {
|
|
1231
|
+
color: "success",
|
|
1232
|
+
fontSize: "small"
|
|
1233
|
+
}) : React.createElement(ContentCopyIcon, {
|
|
1234
|
+
fontSize: "small"
|
|
1235
|
+
})));
|
|
1236
|
+
};
|
|
1237
|
+
|
|
1178
1238
|
var commonTableBodyCellStyles = function commonTableBodyCellStyles(densePadding) {
|
|
1179
1239
|
return {
|
|
1180
1240
|
p: densePadding ? '0.5rem' : '1rem',
|
|
@@ -1193,6 +1253,7 @@ var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
|
|
1193
1253
|
var cell = _ref.cell;
|
|
1194
1254
|
|
|
1195
1255
|
var _useMRT = useMRT(),
|
|
1256
|
+
enableCellCopyButtons = _useMRT.enableCellCopyButtons,
|
|
1196
1257
|
isLoading = _useMRT.isLoading,
|
|
1197
1258
|
muiTableBodyCellProps = _useMRT.muiTableBodyCellProps,
|
|
1198
1259
|
muiTableBodyCellSkeletonProps = _useMRT.muiTableBodyCellSkeletonProps,
|
|
@@ -1218,9 +1279,15 @@ var MRT_TableBodyCell = function MRT_TableBodyCell(_ref) {
|
|
|
1218
1279
|
animation: "wave",
|
|
1219
1280
|
height: 20,
|
|
1220
1281
|
width: Math.random() * (120 - 60) + 60
|
|
1221
|
-
}, muiTableBodyCellSkeletonProps)) : (currentEditingRow == null ? void 0 : currentEditingRow.id) === cell.row.id ? React.createElement(MRT_EditCellTextField, {
|
|
1282
|
+
}, muiTableBodyCellSkeletonProps)) : !cell.column.disableEditing && (currentEditingRow == null ? void 0 : currentEditingRow.id) === cell.row.id ? React.createElement(MRT_EditCellTextField, {
|
|
1283
|
+
cell: cell
|
|
1284
|
+
}) : cell.isPlaceholder ? null : cell.isAggregated ? cell.render('Aggregated') : cell.isGrouped ? React.createElement("span", null, cell.render('Cell'), " (", cell.row.subRows.length, ")") : enableCellCopyButtons && !cell.column.disableCellCopyButton ? React.createElement(Box, {
|
|
1285
|
+
sx: {
|
|
1286
|
+
whiteSpace: 'nowrap'
|
|
1287
|
+
}
|
|
1288
|
+
}, cell.render('Cell'), React.createElement(MRT_CopyButton, {
|
|
1222
1289
|
cell: cell
|
|
1223
|
-
})
|
|
1290
|
+
})) : cell.render('Cell'));
|
|
1224
1291
|
};
|
|
1225
1292
|
|
|
1226
1293
|
var MRT_SelectCheckbox = function MRT_SelectCheckbox(_ref) {
|
|
@@ -1414,9 +1481,18 @@ var MRT_ExpandButton = function MRT_ExpandButton(_ref) {
|
|
|
1414
1481
|
var _useMRT = useMRT(),
|
|
1415
1482
|
ExpandMoreIcon = _useMRT.icons.ExpandMoreIcon,
|
|
1416
1483
|
localization = _useMRT.localization,
|
|
1484
|
+
onRowExpandChange = _useMRT.onRowExpandChange,
|
|
1417
1485
|
renderDetailPanel = _useMRT.renderDetailPanel,
|
|
1418
1486
|
densePadding = _useMRT.tableInstance.state.densePadding;
|
|
1419
1487
|
|
|
1488
|
+
var handleToggleExpand = function handleToggleExpand(event) {
|
|
1489
|
+
var _row$getToggleRowExpa;
|
|
1490
|
+
|
|
1491
|
+
// @ts-ignore
|
|
1492
|
+
(_row$getToggleRowExpa = row.getToggleRowExpandedProps()) == null ? void 0 : _row$getToggleRowExpa.onClick(event);
|
|
1493
|
+
onRowExpandChange == null ? void 0 : onRowExpandChange(event, row);
|
|
1494
|
+
};
|
|
1495
|
+
|
|
1420
1496
|
return React.createElement(TableCell, {
|
|
1421
1497
|
size: "small",
|
|
1422
1498
|
sx: _extends({}, commonTableBodyButtonCellStyles(densePadding), {
|
|
@@ -1427,7 +1503,9 @@ var MRT_ExpandButton = function MRT_ExpandButton(_ref) {
|
|
|
1427
1503
|
"aria-label": localization.expand,
|
|
1428
1504
|
disabled: !row.canExpand && !renderDetailPanel,
|
|
1429
1505
|
title: localization.expand
|
|
1430
|
-
}, row.getToggleRowExpandedProps()
|
|
1506
|
+
}, row.getToggleRowExpandedProps(), {
|
|
1507
|
+
onClick: handleToggleExpand
|
|
1508
|
+
}), React.createElement(ExpandMoreIcon, {
|
|
1431
1509
|
style: {
|
|
1432
1510
|
transform: "rotate(" + (!row.canExpand && !renderDetailPanel ? -90 : row.isExpanded ? -180 : 0) + "deg)",
|
|
1433
1511
|
transition: 'transform 0.2s'
|
|
@@ -1462,7 +1540,9 @@ var MRT_RowActionMenu = function MRT_RowActionMenu(_ref) {
|
|
|
1462
1540
|
}, enableRowEditing && React.createElement(MenuItem, {
|
|
1463
1541
|
onClick: handleEdit,
|
|
1464
1542
|
sx: commonMenuItemStyles$1
|
|
1465
|
-
}, React.createElement(
|
|
1543
|
+
}, React.createElement(Box, {
|
|
1544
|
+
sx: commonListItemStyles
|
|
1545
|
+
}, React.createElement(ListItemIcon, null, React.createElement(EditIcon, null)), localization.edit)), (_renderRowActionMenuI = renderRowActionMenuItems == null ? void 0 : renderRowActionMenuItems(row, tableInstance, function () {
|
|
1466
1546
|
return setAnchorEl(null);
|
|
1467
1547
|
})) != null ? _renderRowActionMenuI : null);
|
|
1468
1548
|
};
|
|
@@ -2385,14 +2465,9 @@ var MRT_TableBodyRow = function MRT_TableBodyRow(_ref) {
|
|
|
2385
2465
|
hover: true,
|
|
2386
2466
|
onClick: function onClick(event) {
|
|
2387
2467
|
return onRowClick == null ? void 0 : onRowClick(event, row);
|
|
2388
|
-
}
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
return _extends({
|
|
2392
|
-
backgroundColor: row.isSelected ? alpha(theme.palette.primary.light, 0.1) : 'transparent'
|
|
2393
|
-
}, tableRowProps == null ? void 0 : tableRowProps.sx);
|
|
2394
|
-
}
|
|
2395
|
-
}), enableRowNumbers && React.createElement(TableCell, {
|
|
2468
|
+
},
|
|
2469
|
+
selected: row.isSelected
|
|
2470
|
+
}, tableRowProps), enableRowNumbers && React.createElement(TableCell, {
|
|
2396
2471
|
sx: _extends({}, commonTableBodyCellStyles(densePadding))
|
|
2397
2472
|
}, row.index + 1), (enableRowActions || enableRowEditing) && positionActionsColumn === 'first' && React.createElement(MRT_ToggleRowActionMenuButton, {
|
|
2398
2473
|
row: row
|
|
@@ -2971,7 +3046,7 @@ var MRT_TableContainer = function MRT_TableContainer() {
|
|
|
2971
3046
|
height: fullScreen ? '100%' : undefined,
|
|
2972
3047
|
left: fullScreen ? '0' : undefined,
|
|
2973
3048
|
m: fullScreen ? '0' : undefined,
|
|
2974
|
-
overflowY: 'hidden',
|
|
3049
|
+
overflowY: !fullScreen ? 'hidden' : undefined,
|
|
2975
3050
|
position: fullScreen ? 'fixed' : undefined,
|
|
2976
3051
|
right: fullScreen ? '0' : undefined,
|
|
2977
3052
|
top: fullScreen ? '0' : undefined,
|
|
@@ -2994,7 +3069,9 @@ var MRT_DefaultLocalization_EN = {
|
|
|
2994
3069
|
clearFilter: 'Clear filter',
|
|
2995
3070
|
clearSearch: 'Clear search',
|
|
2996
3071
|
clearSort: 'Clear sort',
|
|
3072
|
+
clickToCopy: 'Click to copy',
|
|
2997
3073
|
columnActions: 'Column Actions',
|
|
3074
|
+
copiedToClipboard: 'Copied to clipboard',
|
|
2998
3075
|
edit: 'Edit',
|
|
2999
3076
|
expand: 'Expand',
|
|
3000
3077
|
expandAll: 'Expand all',
|
|
@@ -3037,8 +3114,10 @@ var MRT_DefaultLocalization_EN = {
|
|
|
3037
3114
|
var MRT_Default_Icons = {
|
|
3038
3115
|
ArrowRightIcon: ArrowRightIcon,
|
|
3039
3116
|
CancelIcon: CancelIcon,
|
|
3117
|
+
CheckBoxIcon: CheckBoxIcon,
|
|
3040
3118
|
ClearAllIcon: ClearAllIcon,
|
|
3041
3119
|
CloseIcon: CloseIcon,
|
|
3120
|
+
ContentCopyIcon: ContentCopyIcon,
|
|
3042
3121
|
DensityMediumIcon: DensityMediumIcon,
|
|
3043
3122
|
DensitySmallIcon: DensitySmallIcon,
|
|
3044
3123
|
DoubleArrowDownIcon: DoubleArrowDownIcon,
|