material-react-table 0.5.6 → 0.5.9
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 +8 -2
- package/dist/body/MRT_TableBodyCell.d.ts +1 -1
- package/dist/body/MRT_TableBodyRow.d.ts +1 -1
- package/dist/body/MRT_TableDetailPanel.d.ts +1 -1
- package/dist/buttons/MRT_EditActionButtons.d.ts +1 -1
- package/dist/buttons/MRT_ExpandButton.d.ts +1 -1
- package/dist/buttons/MRT_ToggleColumnActionMenuButton.d.ts +1 -1
- package/dist/buttons/MRT_ToggleRowActionMenuButton.d.ts +1 -1
- package/dist/enums.d.ts +12 -0
- package/dist/filtersFNs.d.ts +20 -0
- package/dist/footer/MRT_TableFooterCell.d.ts +1 -1
- package/dist/footer/MRT_TableFooterRow.d.ts +1 -1
- package/dist/head/MRT_TableHeadCell.d.ts +1 -1
- package/dist/head/MRT_TableHeadRow.d.ts +1 -1
- package/dist/inputs/MRT_EditCellTextField.d.ts +1 -1
- package/dist/inputs/MRT_FilterTextField.d.ts +1 -1
- package/dist/inputs/MRT_SelectCheckbox.d.ts +1 -1
- package/dist/localization.d.ts +3 -0
- package/dist/material-react-table.cjs.development.js +234 -68
- 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 +235 -69
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ColumnActionMenu.d.ts +12 -1
- package/dist/menus/MRT_FilterTypeMenu.d.ts +1 -1
- package/dist/menus/MRT_RowActionMenu.d.ts +1 -1
- package/dist/menus/MRT_ShowHideColumnsMenu.d.ts +1 -1
- package/dist/useMRT.d.ts +1 -1
- package/package.json +3 -4
- package/src/MaterialReactTable.tsx +5 -9
- package/src/body/MRT_TableBody.tsx +1 -1
- package/src/body/MRT_TableBodyCell.tsx +1 -1
- package/src/body/MRT_TableBodyRow.tsx +1 -1
- package/src/body/MRT_TableDetailPanel.tsx +1 -1
- package/src/buttons/MRT_EditActionButtons.tsx +1 -1
- package/src/buttons/MRT_ExpandButton.tsx +1 -1
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +1 -2
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +2 -1
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +1 -1
- package/src/enums.ts +12 -0
- package/src/filtersFNs.ts +42 -0
- package/src/footer/MRT_TableFooter.tsx +1 -1
- package/src/footer/MRT_TableFooterCell.tsx +1 -1
- package/src/footer/MRT_TableFooterRow.tsx +1 -1
- package/src/head/MRT_TableHead.tsx +1 -1
- package/src/head/MRT_TableHeadCell.tsx +7 -16
- package/src/head/MRT_TableHeadRow.tsx +1 -1
- package/src/inputs/MRT_EditCellTextField.tsx +1 -1
- package/src/inputs/MRT_FilterTextField.tsx +70 -16
- package/src/inputs/MRT_SelectCheckbox.tsx +1 -1
- package/src/localization.ts +6 -0
- package/src/menus/MRT_ColumnActionMenu.tsx +51 -43
- package/src/menus/MRT_FilterTypeMenu.tsx +56 -16
- package/src/menus/MRT_RowActionMenu.tsx +6 -8
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +6 -2
- package/src/useMRT.tsx +36 -14
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState, useMemo, useContext, createContext, Fragment, useRef, useEffect } from 'react';
|
|
2
2
|
import { useTable, useFilters, useGlobalFilter, useGroupBy, useSortBy, useExpanded, usePagination, useRowSelect, useResizeColumns, useFlexLayout, useAsyncDebounce } from 'react-table';
|
|
3
3
|
import { matchSorter } from 'match-sorter';
|
|
4
|
-
import { Menu, MenuItem, TextField, InputAdornment, Tooltip, IconButton, Chip,
|
|
4
|
+
import { Menu, MenuItem, TextField, InputAdornment, Tooltip, IconButton, Chip, Box, TableCell, TableSortLabel, Divider, Collapse, Skeleton, Checkbox, TableRow, TableHead, alpha, TableBody, TableFooter, Table, FormControlLabel, Switch, Button, TablePagination, useMediaQuery, Alert, Toolbar, TableContainer, Paper, LinearProgress } from '@mui/material';
|
|
5
5
|
import ArrowRightIcon from '@mui/icons-material/ArrowRight';
|
|
6
6
|
import CancelIcon from '@mui/icons-material/Cancel';
|
|
7
7
|
import ClearAllIcon from '@mui/icons-material/ClearAll';
|
|
@@ -160,6 +160,26 @@ notEqualsFilterFN.autoRemove = function (val) {
|
|
|
160
160
|
return !val;
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
+
var greaterThanFilterFN = function greaterThanFilterFN(rows, id, filterValue) {
|
|
164
|
+
return rows.filter(function (row) {
|
|
165
|
+
return !isNaN(+filterValue) && !isNaN(+row.values[id]) ? +row.values[id] > +filterValue : row.values[id].toString().toLowerCase().trim() > filterValue.toString().toLowerCase().trim();
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
greaterThanFilterFN.autoRemove = function (val) {
|
|
170
|
+
return !val;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
var lessThanFilterFN = function lessThanFilterFN(rows, id, filterValue) {
|
|
174
|
+
return rows.filter(function (row) {
|
|
175
|
+
return !isNaN(+filterValue) && !isNaN(+row.values[id]) ? +row.values[id] < +filterValue : row.values[id].toString().toLowerCase().trim() < filterValue.toString().toLowerCase().trim();
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
lessThanFilterFN.autoRemove = function (val) {
|
|
180
|
+
return !val;
|
|
181
|
+
};
|
|
182
|
+
|
|
163
183
|
var emptyFilterFN = function emptyFilterFN(rows, id, _filterValue) {
|
|
164
184
|
return rows.filter(function (row) {
|
|
165
185
|
return !row.values[id].toString().toLowerCase().trim();
|
|
@@ -184,6 +204,8 @@ var defaultFilterFNs = {
|
|
|
184
204
|
contains: containsFilterFN,
|
|
185
205
|
empty: emptyFilterFN,
|
|
186
206
|
endsWith: endsWithFilterFN,
|
|
207
|
+
greaterThan: greaterThanFilterFN,
|
|
208
|
+
lessThan: lessThanFilterFN,
|
|
187
209
|
equals: equalsFilterFN,
|
|
188
210
|
fuzzy: fuzzyFilterFN,
|
|
189
211
|
notEmpty: notEmptyFilterFN,
|
|
@@ -225,16 +247,40 @@ var MaterialReactTableProvider = function MaterialReactTableProvider(props) {
|
|
|
225
247
|
return _extends({}, defaultFilterFNs, props.filterTypes);
|
|
226
248
|
}, [props.filterTypes]);
|
|
227
249
|
|
|
228
|
-
var
|
|
229
|
-
|
|
230
|
-
|
|
250
|
+
var getInitialFilterTypeState = function getInitialFilterTypeState() {
|
|
251
|
+
var lowestLevelColumns = props.columns;
|
|
252
|
+
var currentCols = props.columns;
|
|
253
|
+
|
|
254
|
+
while (!!currentCols.length && currentCols.some(function (col) {
|
|
255
|
+
return col.columns;
|
|
256
|
+
})) {
|
|
257
|
+
var nextCols = currentCols.filter(function (col) {
|
|
258
|
+
return !!col.columns;
|
|
259
|
+
}).map(function (col) {
|
|
260
|
+
return col.columns;
|
|
261
|
+
}).flat();
|
|
262
|
+
|
|
263
|
+
if (nextCols.every(function (col) {
|
|
264
|
+
return !col.columns;
|
|
265
|
+
})) {
|
|
266
|
+
lowestLevelColumns = [].concat(lowestLevelColumns, nextCols);
|
|
267
|
+
}
|
|
231
268
|
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
var _props$initialState$f2, _props$initialState5, _props$initialState5$, _ref;
|
|
269
|
+
currentCols = nextCols;
|
|
270
|
+
}
|
|
235
271
|
|
|
236
|
-
|
|
272
|
+
lowestLevelColumns = lowestLevelColumns.filter(function (col) {
|
|
273
|
+
return !col.columns;
|
|
274
|
+
});
|
|
275
|
+
return Object.assign.apply(Object, [{}].concat(lowestLevelColumns.map(function (c) {
|
|
276
|
+
var _ref, _c$filter, _props$initialState5, _props$initialState5$, _ref2;
|
|
277
|
+
|
|
278
|
+
return _ref2 = {}, _ref2[c.accessor] = (_ref = (_c$filter = c.filter) != null ? _c$filter : props == null ? void 0 : (_props$initialState5 = props.initialState) == null ? void 0 : (_props$initialState5$ = _props$initialState5.filters) == null ? void 0 : _props$initialState5$[c.accessor]) != null ? _ref : !!c.filterSelectOptions ? 'equals' : 'fuzzy', _ref2;
|
|
237
279
|
})));
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
var _useState6 = useState(function () {
|
|
283
|
+
return getInitialFilterTypeState();
|
|
238
284
|
}),
|
|
239
285
|
currentFilterTypes = _useState6[0],
|
|
240
286
|
setCurrentFilterTypes = _useState6[1];
|
|
@@ -249,6 +295,7 @@ var MaterialReactTableProvider = function MaterialReactTableProvider(props) {
|
|
|
249
295
|
columns: columns,
|
|
250
296
|
// @ts-ignore
|
|
251
297
|
filterTypes: filterTypes,
|
|
298
|
+
globalFilterValue: 'fuzzy',
|
|
252
299
|
useControlledState: function useControlledState(state) {
|
|
253
300
|
return useMemo(function () {
|
|
254
301
|
return _extends({}, state, {
|
|
@@ -298,6 +345,26 @@ var useMRT = function useMRT() {
|
|
|
298
345
|
return useContext(MaterialReactTableContext);
|
|
299
346
|
};
|
|
300
347
|
|
|
348
|
+
var MRT_FILTER_TYPE;
|
|
349
|
+
|
|
350
|
+
(function (MRT_FILTER_TYPE) {
|
|
351
|
+
MRT_FILTER_TYPE["CONTAINS"] = "contains";
|
|
352
|
+
MRT_FILTER_TYPE["EMPTY"] = "empty";
|
|
353
|
+
MRT_FILTER_TYPE["ENDS_WITH"] = "endsWith";
|
|
354
|
+
MRT_FILTER_TYPE["EQUALS"] = "equals";
|
|
355
|
+
MRT_FILTER_TYPE["FUZZY"] = "fuzzy";
|
|
356
|
+
MRT_FILTER_TYPE["GREATER_THAN"] = "greaterThan";
|
|
357
|
+
MRT_FILTER_TYPE["LESS_THAN"] = "lessThan";
|
|
358
|
+
MRT_FILTER_TYPE["NOT_EMPTY"] = "notEmpty";
|
|
359
|
+
MRT_FILTER_TYPE["NOT_EQUALS"] = "notEquals";
|
|
360
|
+
MRT_FILTER_TYPE["STARTS_WITH"] = "startsWith";
|
|
361
|
+
})(MRT_FILTER_TYPE || (MRT_FILTER_TYPE = {}));
|
|
362
|
+
|
|
363
|
+
var commonMenuItemStyles = {
|
|
364
|
+
py: '6px',
|
|
365
|
+
my: 0,
|
|
366
|
+
alignItems: 'center'
|
|
367
|
+
};
|
|
301
368
|
var MRT_FilterTypeMenu = function MRT_FilterTypeMenu(_ref) {
|
|
302
369
|
var anchorEl = _ref.anchorEl,
|
|
303
370
|
column = _ref.column,
|
|
@@ -311,37 +378,55 @@ var MRT_FilterTypeMenu = function MRT_FilterTypeMenu(_ref) {
|
|
|
311
378
|
|
|
312
379
|
var filterTypes = useMemo(function () {
|
|
313
380
|
return [{
|
|
314
|
-
type:
|
|
381
|
+
type: MRT_FILTER_TYPE.FUZZY,
|
|
315
382
|
label: localization.filterMenuItemFuzzy,
|
|
316
|
-
divider: false
|
|
383
|
+
divider: false,
|
|
384
|
+
fn: fuzzyFilterFN
|
|
317
385
|
}, {
|
|
318
|
-
type:
|
|
386
|
+
type: MRT_FILTER_TYPE.CONTAINS,
|
|
319
387
|
label: localization.filterMenuItemContains,
|
|
320
|
-
divider: true
|
|
388
|
+
divider: true,
|
|
389
|
+
fn: containsFilterFN
|
|
321
390
|
}, {
|
|
322
|
-
type:
|
|
391
|
+
type: MRT_FILTER_TYPE.STARTS_WITH,
|
|
323
392
|
label: localization.filterMenuItemStartsWith,
|
|
324
|
-
divider: false
|
|
393
|
+
divider: false,
|
|
394
|
+
fn: startsWithFilterFN
|
|
325
395
|
}, {
|
|
326
|
-
type:
|
|
396
|
+
type: MRT_FILTER_TYPE.ENDS_WITH,
|
|
327
397
|
label: localization.filterMenuItemEndsWith,
|
|
328
|
-
divider: true
|
|
398
|
+
divider: true,
|
|
399
|
+
fn: endsWithFilterFN
|
|
329
400
|
}, {
|
|
330
|
-
type:
|
|
401
|
+
type: MRT_FILTER_TYPE.EQUALS,
|
|
331
402
|
label: localization.filterMenuItemEquals,
|
|
332
|
-
divider: false
|
|
403
|
+
divider: false,
|
|
404
|
+
fn: equalsFilterFN
|
|
333
405
|
}, {
|
|
334
|
-
type:
|
|
406
|
+
type: MRT_FILTER_TYPE.NOT_EQUALS,
|
|
335
407
|
label: localization.filterMenuItemNotEquals,
|
|
336
|
-
divider: true
|
|
408
|
+
divider: true,
|
|
409
|
+
fn: notEqualsFilterFN
|
|
410
|
+
}, {
|
|
411
|
+
type: MRT_FILTER_TYPE.GREATER_THAN,
|
|
412
|
+
label: localization.filterMenuItemGreaterThan,
|
|
413
|
+
divider: false,
|
|
414
|
+
fn: greaterThanFilterFN
|
|
337
415
|
}, {
|
|
338
|
-
type:
|
|
416
|
+
type: MRT_FILTER_TYPE.LESS_THAN,
|
|
417
|
+
label: localization.filterMenuItemLessThan,
|
|
418
|
+
divider: true,
|
|
419
|
+
fn: lessThanFilterFN
|
|
420
|
+
}, {
|
|
421
|
+
type: MRT_FILTER_TYPE.EMPTY,
|
|
339
422
|
label: localization.filterMenuItemEmpty,
|
|
340
|
-
divider: false
|
|
423
|
+
divider: false,
|
|
424
|
+
fn: emptyFilterFN
|
|
341
425
|
}, {
|
|
342
|
-
type:
|
|
426
|
+
type: MRT_FILTER_TYPE.NOT_EMPTY,
|
|
343
427
|
label: localization.filterMenuItemNotEmpty,
|
|
344
|
-
divider: false
|
|
428
|
+
divider: false,
|
|
429
|
+
fn: notEmptyFilterFN
|
|
345
430
|
}];
|
|
346
431
|
}, []);
|
|
347
432
|
|
|
@@ -353,7 +438,7 @@ var MRT_FilterTypeMenu = function MRT_FilterTypeMenu(_ref) {
|
|
|
353
438
|
return _extends({}, prev, (_extends2 = {}, _extends2[column.id] = value, _extends2));
|
|
354
439
|
});
|
|
355
440
|
|
|
356
|
-
if ([
|
|
441
|
+
if ([MRT_FILTER_TYPE.EMPTY, MRT_FILTER_TYPE.NOT_EMPTY].includes(value)) {
|
|
357
442
|
column.setFilter(' ');
|
|
358
443
|
}
|
|
359
444
|
|
|
@@ -372,27 +457,28 @@ var MRT_FilterTypeMenu = function MRT_FilterTypeMenu(_ref) {
|
|
|
372
457
|
},
|
|
373
458
|
open: !!anchorEl,
|
|
374
459
|
MenuListProps: {
|
|
375
|
-
dense: tableInstance.state.densePadding
|
|
376
|
-
disablePadding: true
|
|
460
|
+
dense: tableInstance.state.densePadding
|
|
377
461
|
}
|
|
378
|
-
}, filterTypes.map(function (_ref2) {
|
|
462
|
+
}, filterTypes.map(function (_ref2, index) {
|
|
379
463
|
var type = _ref2.type,
|
|
380
464
|
label = _ref2.label,
|
|
381
|
-
divider = _ref2.divider
|
|
465
|
+
divider = _ref2.divider,
|
|
466
|
+
fn = _ref2.fn;
|
|
382
467
|
return React.createElement(MenuItem, {
|
|
383
468
|
divider: divider,
|
|
384
|
-
key:
|
|
469
|
+
key: index,
|
|
385
470
|
onClick: function onClick() {
|
|
386
471
|
return handleSelectFilterType(type);
|
|
387
472
|
},
|
|
388
|
-
selected: type === filterType,
|
|
473
|
+
selected: type === filterType || fn === filterType,
|
|
474
|
+
sx: commonMenuItemStyles,
|
|
389
475
|
value: type
|
|
390
476
|
}, label);
|
|
391
477
|
}));
|
|
392
478
|
};
|
|
393
479
|
|
|
394
480
|
var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
395
|
-
var _localization$filterT, _localization$filterT2;
|
|
481
|
+
var _localization$filterT, _localization$filterT2, _column$filterSelectO;
|
|
396
482
|
|
|
397
483
|
var column = _ref.column;
|
|
398
484
|
|
|
@@ -440,7 +526,7 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
440
526
|
setCurrentFilterTypes(function (prev) {
|
|
441
527
|
var _extends2;
|
|
442
528
|
|
|
443
|
-
return _extends({}, prev, (_extends2 = {}, _extends2[column.id] =
|
|
529
|
+
return _extends({}, prev, (_extends2 = {}, _extends2[column.id] = MRT_FILTER_TYPE.FUZZY, _extends2));
|
|
444
530
|
});
|
|
445
531
|
};
|
|
446
532
|
|
|
@@ -451,7 +537,9 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
451
537
|
}
|
|
452
538
|
|
|
453
539
|
var filterType = tableInstance.state.currentFilterTypes[column.id];
|
|
454
|
-
var
|
|
540
|
+
var isCustomFilterType = filterType instanceof Function;
|
|
541
|
+
var isSelectFilter = !!column.filterSelectOptions;
|
|
542
|
+
var filterChipLabel = !isCustomFilterType && [MRT_FILTER_TYPE.EMPTY, MRT_FILTER_TYPE.NOT_EMPTY].includes(filterType);
|
|
455
543
|
var filterPlaceholder = (_localization$filterT = localization.filterTextFieldPlaceholder) == null ? void 0 : _localization$filterT.replace('{column}', String(column.Header));
|
|
456
544
|
return React.createElement(React.Fragment, null, React.createElement(TextField, Object.assign({
|
|
457
545
|
fullWidth: true,
|
|
@@ -464,8 +552,16 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
464
552
|
},
|
|
465
553
|
title: filterPlaceholder
|
|
466
554
|
},
|
|
555
|
+
label: isSelectFilter && !filterValue ? filterPlaceholder : undefined,
|
|
556
|
+
InputLabelProps: {
|
|
557
|
+
shrink: false,
|
|
558
|
+
sx: {
|
|
559
|
+
maxWidth: 'calc(100% - 2.5rem)'
|
|
560
|
+
},
|
|
561
|
+
title: filterPlaceholder
|
|
562
|
+
},
|
|
467
563
|
margin: "none",
|
|
468
|
-
placeholder: filterChipLabel ?
|
|
564
|
+
placeholder: filterChipLabel || isSelectFilter ? undefined : filterPlaceholder,
|
|
469
565
|
onChange: function onChange(e) {
|
|
470
566
|
setFilterValue(e.target.value);
|
|
471
567
|
handleChange(e.target.value);
|
|
@@ -473,22 +569,23 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
473
569
|
onClick: function onClick(e) {
|
|
474
570
|
return e.stopPropagation();
|
|
475
571
|
},
|
|
572
|
+
select: isSelectFilter,
|
|
476
573
|
value: filterValue != null ? filterValue : '',
|
|
477
574
|
variant: "standard",
|
|
478
575
|
InputProps: {
|
|
479
|
-
startAdornment: React.createElement(InputAdornment, {
|
|
576
|
+
startAdornment: !isSelectFilter && React.createElement(InputAdornment, {
|
|
480
577
|
position: "start"
|
|
481
578
|
}, React.createElement(Tooltip, {
|
|
482
579
|
arrow: true,
|
|
483
|
-
title:
|
|
484
|
-
}, React.createElement(IconButton, {
|
|
580
|
+
title: localization.changeFilterMode
|
|
581
|
+
}, React.createElement("span", null, React.createElement(IconButton, {
|
|
485
582
|
onClick: handleFilterMenuOpen,
|
|
486
583
|
size: "small",
|
|
487
584
|
sx: {
|
|
488
585
|
height: '1.75rem',
|
|
489
586
|
width: '1.75rem'
|
|
490
587
|
}
|
|
491
|
-
}, React.createElement(FilterListIcon, null))), filterChipLabel && React.createElement(Chip, {
|
|
588
|
+
}, React.createElement(FilterListIcon, null)))), filterChipLabel && React.createElement(Chip, {
|
|
492
589
|
onDelete: handleClearFilterChip,
|
|
493
590
|
label: filterType
|
|
494
591
|
})),
|
|
@@ -496,11 +593,12 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
496
593
|
position: "end"
|
|
497
594
|
}, React.createElement(Tooltip, {
|
|
498
595
|
arrow: true,
|
|
596
|
+
disableHoverListener: isSelectFilter,
|
|
499
597
|
placement: "right",
|
|
500
598
|
title: (_localization$filterT2 = localization.filterTextFieldClearButtonTitle) != null ? _localization$filterT2 : ''
|
|
501
599
|
}, React.createElement("span", null, React.createElement(IconButton, {
|
|
502
600
|
"aria-label": localization.filterTextFieldClearButtonTitle,
|
|
503
|
-
disabled: (filterValue
|
|
601
|
+
disabled: !(filterValue != null && filterValue.length),
|
|
504
602
|
onClick: handleClear,
|
|
505
603
|
size: "small",
|
|
506
604
|
sx: {
|
|
@@ -515,8 +613,32 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
515
613
|
sx: _extends({
|
|
516
614
|
m: '0 -0.25rem',
|
|
517
615
|
minWidth: !filterChipLabel ? '5rem' : 'auto',
|
|
518
|
-
width: 'calc(100% + 0.5rem)'
|
|
616
|
+
width: 'calc(100% + 0.5rem)',
|
|
617
|
+
mt: isSelectFilter && !filterValue ? '-1rem' : undefined,
|
|
618
|
+
'& .MuiSelect-icon': {
|
|
619
|
+
mr: '1.5rem'
|
|
620
|
+
}
|
|
519
621
|
}, textFieldProps == null ? void 0 : textFieldProps.sx)
|
|
622
|
+
}), isSelectFilter && React.createElement(MenuItem, {
|
|
623
|
+
divider: true,
|
|
624
|
+
disabled: !filterValue,
|
|
625
|
+
value: ""
|
|
626
|
+
}, localization.filterTextFieldClearButtonTitle), column == null ? void 0 : (_column$filterSelectO = column.filterSelectOptions) == null ? void 0 : _column$filterSelectO.map(function (option) {
|
|
627
|
+
var value;
|
|
628
|
+
var text;
|
|
629
|
+
|
|
630
|
+
if (typeof option === 'string') {
|
|
631
|
+
value = option;
|
|
632
|
+
text = option;
|
|
633
|
+
} else if (typeof option === 'object') {
|
|
634
|
+
value = option.value;
|
|
635
|
+
text = option.text;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
return React.createElement(MenuItem, {
|
|
639
|
+
key: value,
|
|
640
|
+
value: value
|
|
641
|
+
}, text);
|
|
520
642
|
})), React.createElement(MRT_FilterTypeMenu, {
|
|
521
643
|
anchorEl: anchorEl,
|
|
522
644
|
column: column,
|
|
@@ -524,8 +646,15 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
524
646
|
}));
|
|
525
647
|
};
|
|
526
648
|
|
|
527
|
-
var commonMenuItemStyles = {
|
|
649
|
+
var commonMenuItemStyles$1 = {
|
|
650
|
+
py: '6px',
|
|
651
|
+
my: 0,
|
|
652
|
+
justifyContent: 'space-between',
|
|
653
|
+
alignItems: 'center'
|
|
654
|
+
};
|
|
655
|
+
var commonListItemStyles = {
|
|
528
656
|
display: 'flex',
|
|
657
|
+
gap: '0.75rem',
|
|
529
658
|
alignItems: 'center'
|
|
530
659
|
};
|
|
531
660
|
var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
@@ -545,6 +674,7 @@ var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
|
545
674
|
ClearAllIcon = _useMRT$icons.ClearAllIcon,
|
|
546
675
|
DynamicFeedIcon = _useMRT$icons.DynamicFeedIcon,
|
|
547
676
|
FilterListIcon = _useMRT$icons.FilterListIcon,
|
|
677
|
+
FilterListOffIcon = _useMRT$icons.FilterListOffIcon,
|
|
548
678
|
SortIcon = _useMRT$icons.SortIcon,
|
|
549
679
|
VisibilityOffIcon = _useMRT$icons.VisibilityOffIcon,
|
|
550
680
|
idPrefix = _useMRT.idPrefix,
|
|
@@ -581,6 +711,11 @@ var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
|
581
711
|
setAnchorEl(null);
|
|
582
712
|
};
|
|
583
713
|
|
|
714
|
+
var handleClearFilter = function handleClearFilter() {
|
|
715
|
+
column.setFilter('');
|
|
716
|
+
setAnchorEl(null);
|
|
717
|
+
};
|
|
718
|
+
|
|
584
719
|
var handleFilterByColumn = function handleFilterByColumn() {
|
|
585
720
|
setShowFilters(true);
|
|
586
721
|
setTimeout(function () {
|
|
@@ -604,35 +739,49 @@ var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
|
604
739
|
return setAnchorEl(null);
|
|
605
740
|
},
|
|
606
741
|
MenuListProps: {
|
|
607
|
-
dense: tableInstance.state.densePadding
|
|
608
|
-
disablePadding: true
|
|
742
|
+
dense: tableInstance.state.densePadding
|
|
609
743
|
}
|
|
610
744
|
}, !disableSortBy && column.canSort && [React.createElement(MenuItem, {
|
|
611
|
-
key: 1,
|
|
612
745
|
disabled: !column.isSorted,
|
|
746
|
+
key: 1,
|
|
613
747
|
onClick: handleClearSort,
|
|
614
|
-
sx: commonMenuItemStyles
|
|
615
|
-
}, React.createElement(
|
|
748
|
+
sx: commonMenuItemStyles$1
|
|
749
|
+
}, React.createElement(Box, {
|
|
750
|
+
sx: commonListItemStyles
|
|
751
|
+
}, React.createElement(ClearAllIcon, null), localization.columnActionMenuItemClearSort)), React.createElement(MenuItem, {
|
|
616
752
|
disabled: column.isSorted && !column.isSortedDesc,
|
|
617
753
|
key: 2,
|
|
618
754
|
onClick: handleSortAsc,
|
|
619
|
-
sx: commonMenuItemStyles
|
|
620
|
-
}, React.createElement(
|
|
755
|
+
sx: commonMenuItemStyles$1
|
|
756
|
+
}, React.createElement(Box, {
|
|
757
|
+
sx: commonListItemStyles
|
|
758
|
+
}, React.createElement(SortIcon, null), (_localization$columnA = localization.columnActionMenuItemSortAsc) == null ? void 0 : _localization$columnA.replace('{column}', String(column.Header)))), React.createElement(MenuItem, {
|
|
621
759
|
divider: !disableFilters || enableColumnGrouping || !disableColumnHiding,
|
|
622
760
|
key: 3,
|
|
623
761
|
disabled: column.isSorted && column.isSortedDesc,
|
|
624
762
|
onClick: handleSortDesc,
|
|
625
|
-
sx: commonMenuItemStyles
|
|
626
|
-
}, React.createElement(
|
|
763
|
+
sx: commonMenuItemStyles$1
|
|
764
|
+
}, React.createElement(Box, {
|
|
765
|
+
sx: commonListItemStyles
|
|
766
|
+
}, React.createElement(SortIcon, {
|
|
627
767
|
style: {
|
|
628
768
|
transform: 'rotate(180deg) scaleX(-1)'
|
|
629
769
|
}
|
|
630
|
-
})
|
|
770
|
+
}), (_localization$columnA2 = localization.columnActionMenuItemSortDesc) == null ? void 0 : _localization$columnA2.replace('{column}', String(column.Header))))], !disableFilters && column.canFilter && [React.createElement(MenuItem, {
|
|
771
|
+
disabled: !column.filterValue,
|
|
772
|
+
key: 0,
|
|
773
|
+
onClick: handleClearFilter,
|
|
774
|
+
sx: commonMenuItemStyles$1
|
|
775
|
+
}, React.createElement(Box, {
|
|
776
|
+
sx: commonListItemStyles
|
|
777
|
+
}, React.createElement(FilterListOffIcon, null), localization.filterTextFieldClearButtonTitle)), React.createElement(MenuItem, {
|
|
631
778
|
divider: enableColumnGrouping || !disableColumnHiding,
|
|
632
779
|
key: 1,
|
|
633
780
|
onClick: handleFilterByColumn,
|
|
634
|
-
sx: commonMenuItemStyles
|
|
635
|
-
}, React.createElement(
|
|
781
|
+
sx: commonMenuItemStyles$1
|
|
782
|
+
}, React.createElement(Box, {
|
|
783
|
+
sx: commonListItemStyles
|
|
784
|
+
}, React.createElement(FilterListIcon, null), (_localization$filterT = localization.filterTextFieldPlaceholder) == null ? void 0 : _localization$filterT.replace('{column}', String(column.Header))), !column.filterSelectOptions && React.createElement(IconButton, {
|
|
636
785
|
onClick: handleOpenFilterModeMenu,
|
|
637
786
|
onMouseEnter: handleOpenFilterModeMenu,
|
|
638
787
|
size: "small",
|
|
@@ -649,12 +798,16 @@ var MRT_ColumnActionMenu = function MRT_ColumnActionMenu(_ref) {
|
|
|
649
798
|
divider: !disableColumnHiding,
|
|
650
799
|
key: 2,
|
|
651
800
|
onClick: handleGroupByColumn,
|
|
652
|
-
sx: commonMenuItemStyles
|
|
653
|
-
}, React.createElement(
|
|
801
|
+
sx: commonMenuItemStyles$1
|
|
802
|
+
}, React.createElement(Box, {
|
|
803
|
+
sx: commonListItemStyles
|
|
804
|
+
}, React.createElement(DynamicFeedIcon, null), (_localization = localization[column.isGrouped ? 'columnActionMenuItemUnGroupBy' : 'columnActionMenuItemGroupBy']) == null ? void 0 : _localization.replace('{column}', String(column.Header))))], !disableColumnHiding && [React.createElement(MenuItem, {
|
|
654
805
|
key: 1,
|
|
655
806
|
onClick: handleHideColumn,
|
|
656
|
-
sx: commonMenuItemStyles
|
|
657
|
-
}, React.createElement(
|
|
807
|
+
sx: commonMenuItemStyles$1
|
|
808
|
+
}, React.createElement(Box, {
|
|
809
|
+
sx: commonListItemStyles
|
|
810
|
+
}, React.createElement(VisibilityOffIcon, null), (_localization$columnA3 = localization.columnActionMenuItemHideColumn) == null ? void 0 : _localization$columnA3.replace('{column}', String(column.Header))))]);
|
|
658
811
|
};
|
|
659
812
|
|
|
660
813
|
var MRT_ToggleColumnActionMenuButton = function MRT_ToggleColumnActionMenuButton(_ref) {
|
|
@@ -678,6 +831,7 @@ var MRT_ToggleColumnActionMenuButton = function MRT_ToggleColumnActionMenuButton
|
|
|
678
831
|
arrow: true,
|
|
679
832
|
enterDelay: 1000,
|
|
680
833
|
enterNextDelay: 1000,
|
|
834
|
+
placement: "top",
|
|
681
835
|
title: localization.columnActionMenuButtonTitle
|
|
682
836
|
}, React.createElement(IconButton, {
|
|
683
837
|
"aria-label": localization.columnActionMenuButtonTitle,
|
|
@@ -737,8 +891,7 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
|
737
891
|
});
|
|
738
892
|
|
|
739
893
|
var sortTooltip = column.isSorted ? column.isSortedDesc ? localization.columnActionMenuItemClearSort : (_localization$columnA = localization.columnActionMenuItemSortDesc) == null ? void 0 : _localization$columnA.replace('{column}', column.Header) : (_localization$columnA2 = localization.columnActionMenuItemSortAsc) == null ? void 0 : _localization$columnA2.replace('{column}', column.Header);
|
|
740
|
-
var filterTooltip = !!column.filterValue ? localization.filterApplied.replace('{column}', String(column.Header)).replace('{filterType}',
|
|
741
|
-
localization["filterMenuItem" + (tableInstance.state.currentFilterTypes[column.id].charAt(0).toUpperCase() + tableInstance.state.currentFilterTypes[column.id].slice(1))]) : localization.toggleFilterButtonTitle;
|
|
894
|
+
var filterTooltip = !!column.filterValue ? localization.filterApplied.replace('{column}', String(column.Header)).replace('{filterType}', column.filterValue) : localization.toggleFilterButtonTitle;
|
|
742
895
|
var columnHeader = column.render('Header');
|
|
743
896
|
return React.createElement(TableCell, Object.assign({
|
|
744
897
|
align: isParentHeader ? 'center' : 'left'
|
|
@@ -761,6 +914,7 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
|
761
914
|
title: undefined
|
|
762
915
|
}), column.render('Header'), !isParentHeader && column.canSort && React.createElement(Tooltip, {
|
|
763
916
|
arrow: true,
|
|
917
|
+
placement: "top",
|
|
764
918
|
title: sortTooltip
|
|
765
919
|
}, React.createElement(TableSortLabel, {
|
|
766
920
|
"aria-label": sortTooltip,
|
|
@@ -768,19 +922,22 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
|
768
922
|
direction: column.isSortedDesc ? 'desc' : 'asc'
|
|
769
923
|
})), !isParentHeader && !!column.canFilter && React.createElement(Tooltip, {
|
|
770
924
|
arrow: true,
|
|
925
|
+
placement: "top",
|
|
771
926
|
title: filterTooltip
|
|
772
927
|
}, React.createElement(IconButton, {
|
|
928
|
+
disableRipple: true,
|
|
773
929
|
onClick: function onClick(event) {
|
|
774
930
|
event.stopPropagation();
|
|
775
931
|
setShowFilters(!tableInstance.state.showFilters);
|
|
776
932
|
},
|
|
777
933
|
size: "small",
|
|
778
934
|
sx: {
|
|
935
|
+
m: 0,
|
|
779
936
|
opacity: !!column.filterValue ? 0.8 : 0,
|
|
780
937
|
p: '2px',
|
|
781
|
-
m: 0,
|
|
782
938
|
transition: 'all 0.2s ease-in-out',
|
|
783
939
|
'&:hover': {
|
|
940
|
+
backgroundColor: 'transparent',
|
|
784
941
|
opacity: 0.8
|
|
785
942
|
}
|
|
786
943
|
}
|
|
@@ -1141,12 +1298,12 @@ var MRT_RowActionMenu = function MRT_RowActionMenu(_ref) {
|
|
|
1141
1298
|
return setAnchorEl(null);
|
|
1142
1299
|
},
|
|
1143
1300
|
MenuListProps: {
|
|
1144
|
-
dense: tableInstance.state.densePadding
|
|
1145
|
-
disablePadding: true
|
|
1301
|
+
dense: tableInstance.state.densePadding
|
|
1146
1302
|
}
|
|
1147
1303
|
}, enableRowEditing && React.createElement(MenuItem, {
|
|
1148
|
-
onClick: handleEdit
|
|
1149
|
-
|
|
1304
|
+
onClick: handleEdit,
|
|
1305
|
+
sx: commonMenuItemStyles$1
|
|
1306
|
+
}, React.createElement(EditIcon, null), localization.rowActionMenuItemEdit), (_renderRowActionMenuI = renderRowActionMenuItems == null ? void 0 : renderRowActionMenuItems(row, tableInstance, function () {
|
|
1150
1307
|
return setAnchorEl(null);
|
|
1151
1308
|
})) != null ? _renderRowActionMenuI : null);
|
|
1152
1309
|
};
|
|
@@ -2330,10 +2487,17 @@ var MRT_ShowHideColumnsMenu = function MRT_ShowHideColumnsMenu(_ref) {
|
|
|
2330
2487
|
};
|
|
2331
2488
|
|
|
2332
2489
|
return React.createElement(React.Fragment, null, React.createElement(MenuItem, {
|
|
2333
|
-
sx: {
|
|
2490
|
+
sx: _extends({}, commonMenuItemStyles$1, {
|
|
2334
2491
|
pl: (column.depth + 0.5) * 2 + "rem"
|
|
2335
|
-
}
|
|
2492
|
+
})
|
|
2336
2493
|
}, React.createElement(FormControlLabel, {
|
|
2494
|
+
componentsProps: {
|
|
2495
|
+
typography: {
|
|
2496
|
+
sx: {
|
|
2497
|
+
marginBottom: 0
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
},
|
|
2337
2501
|
checked: switchChecked,
|
|
2338
2502
|
control: React.createElement(Switch, null),
|
|
2339
2503
|
label: column.Header,
|
|
@@ -2378,8 +2542,7 @@ var MRT_ShowHideColumnsButton = function MRT_ShowHideColumnsButton(_ref) {
|
|
|
2378
2542
|
return setAnchorEl(null);
|
|
2379
2543
|
},
|
|
2380
2544
|
MenuListProps: {
|
|
2381
|
-
dense: tableInstance.state.densePadding
|
|
2382
|
-
disablePadding: true
|
|
2545
|
+
dense: tableInstance.state.densePadding
|
|
2383
2546
|
}
|
|
2384
2547
|
}, React.createElement(Box, {
|
|
2385
2548
|
sx: {
|
|
@@ -2741,6 +2904,7 @@ var MRT_TableContainer = function MRT_TableContainer() {
|
|
|
2741
2904
|
|
|
2742
2905
|
var MRT_DefaultLocalization_EN = {
|
|
2743
2906
|
actionsHeadColumnTitle: 'Actions',
|
|
2907
|
+
changeFilterMode: 'Change filter mode',
|
|
2744
2908
|
columnActionMenuButtonTitle: 'Column Actions',
|
|
2745
2909
|
columnActionMenuItemClearSort: 'Clear sort',
|
|
2746
2910
|
columnActionMenuItemGroupBy: 'Group by {column}',
|
|
@@ -2758,6 +2922,8 @@ var MRT_DefaultLocalization_EN = {
|
|
|
2758
2922
|
filterMenuItemEndsWith: 'Ends With',
|
|
2759
2923
|
filterMenuItemEquals: 'Equals',
|
|
2760
2924
|
filterMenuItemFuzzy: 'Fuzzy Match (Default)',
|
|
2925
|
+
filterMenuItemGreaterThan: 'Greater Than',
|
|
2926
|
+
filterMenuItemLessThan: 'Less Than',
|
|
2761
2927
|
filterMenuItemNotEmpty: 'Not Empty',
|
|
2762
2928
|
filterMenuItemNotEquals: 'Not Equals',
|
|
2763
2929
|
filterMenuItemStartsWith: 'Starts With',
|