material-react-table 0.6.3 → 0.6.4
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 +1 -1
- package/dist/filtersFNs.d.ts +10 -10
- package/dist/material-react-table.cjs.development.js +50 -46
- 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 +50 -46
- package/dist/material-react-table.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +1 -1
- package/src/filtersFNs.ts +30 -30
- package/src/inputs/MRT_FilterTextField.tsx +24 -12
- package/src/menus/MRT_FilterTypeMenu.tsx +20 -20
- package/src/table/MRT_TableContainer.tsx +1 -1
- package/src/useMRT.tsx +1 -1
|
@@ -183,7 +183,7 @@ var MaterialReactTableProvider = function MaterialReactTableProvider(props) {
|
|
|
183
183
|
return applyFiltersToColumns(props.columns);
|
|
184
184
|
}, [props.columns, applyFiltersToColumns]);
|
|
185
185
|
var data = useMemo(function () {
|
|
186
|
-
return !props.isLoading || !!props.data.length ? props.data : [].concat(Array(10)).map(function (_) {
|
|
186
|
+
return !props.isLoading || !!props.data.length ? props.data : [].concat(Array(10).fill(null)).map(function (_) {
|
|
187
187
|
return Object.assign.apply(Object, [{}].concat(findLowestLevelCols(props.columns).map(function (c) {
|
|
188
188
|
var _ref3;
|
|
189
189
|
|
|
@@ -260,7 +260,7 @@ var MRT_FILTER_TYPE;
|
|
|
260
260
|
MRT_FILTER_TYPE["STARTS_WITH"] = "startsWith";
|
|
261
261
|
})(MRT_FILTER_TYPE || (MRT_FILTER_TYPE = {}));
|
|
262
262
|
|
|
263
|
-
var
|
|
263
|
+
var fuzzy = function fuzzy(rows, columnIds, filterValue) {
|
|
264
264
|
return matchSorter(rows, filterValue.toString().trim(), {
|
|
265
265
|
keys: Array.isArray(columnIds) ? columnIds.map(function (c) {
|
|
266
266
|
return "values." + c;
|
|
@@ -271,111 +271,111 @@ var fuzzyFilterFN = function fuzzyFilterFN(rows, columnIds, filterValue) {
|
|
|
271
271
|
});
|
|
272
272
|
};
|
|
273
273
|
|
|
274
|
-
|
|
274
|
+
fuzzy.autoRemove = function (val) {
|
|
275
275
|
return !val;
|
|
276
276
|
};
|
|
277
277
|
|
|
278
|
-
var
|
|
278
|
+
var contains = function contains(rows, id, filterValue) {
|
|
279
279
|
return rows.filter(function (row) {
|
|
280
280
|
return row.values[id].toString().toLowerCase().trim().includes(filterValue.toString().toLowerCase().trim());
|
|
281
281
|
});
|
|
282
282
|
};
|
|
283
283
|
|
|
284
|
-
|
|
284
|
+
contains.autoRemove = function (val) {
|
|
285
285
|
return !val;
|
|
286
286
|
};
|
|
287
287
|
|
|
288
|
-
var
|
|
288
|
+
var startsWith = function startsWith(rows, id, filterValue) {
|
|
289
289
|
return rows.filter(function (row) {
|
|
290
290
|
return row.values[id].toString().toLowerCase().trim().startsWith(filterValue.toString().toLowerCase().trim());
|
|
291
291
|
});
|
|
292
292
|
};
|
|
293
293
|
|
|
294
|
-
|
|
294
|
+
startsWith.autoRemove = function (val) {
|
|
295
295
|
return !val;
|
|
296
296
|
};
|
|
297
297
|
|
|
298
|
-
var
|
|
298
|
+
var endsWith = function endsWith(rows, id, filterValue) {
|
|
299
299
|
return rows.filter(function (row) {
|
|
300
300
|
return row.values[id].toString().toLowerCase().trim().endsWith(filterValue.toString().toLowerCase().trim());
|
|
301
301
|
});
|
|
302
302
|
};
|
|
303
303
|
|
|
304
|
-
|
|
304
|
+
endsWith.autoRemove = function (val) {
|
|
305
305
|
return !val;
|
|
306
306
|
};
|
|
307
307
|
|
|
308
|
-
var
|
|
308
|
+
var equals = function equals(rows, id, filterValue) {
|
|
309
309
|
return rows.filter(function (row) {
|
|
310
310
|
return row.values[id].toString().toLowerCase().trim() === filterValue.toString().toLowerCase().trim();
|
|
311
311
|
});
|
|
312
312
|
};
|
|
313
313
|
|
|
314
|
-
|
|
314
|
+
equals.autoRemove = function (val) {
|
|
315
315
|
return !val;
|
|
316
316
|
};
|
|
317
317
|
|
|
318
|
-
var
|
|
318
|
+
var notEquals = function notEquals(rows, id, filterValue) {
|
|
319
319
|
return rows.filter(function (row) {
|
|
320
320
|
return row.values[id].toString().toLowerCase().trim() !== filterValue.toString().toLowerCase().trim();
|
|
321
321
|
});
|
|
322
322
|
};
|
|
323
323
|
|
|
324
|
-
|
|
324
|
+
notEquals.autoRemove = function (val) {
|
|
325
325
|
return !val;
|
|
326
326
|
};
|
|
327
327
|
|
|
328
|
-
var
|
|
328
|
+
var greaterThan = function greaterThan(rows, id, filterValue) {
|
|
329
329
|
return rows.filter(function (row) {
|
|
330
330
|
return !isNaN(+filterValue) && !isNaN(+row.values[id]) ? +row.values[id] > +filterValue : row.values[id].toString().toLowerCase().trim() > filterValue.toString().toLowerCase().trim();
|
|
331
331
|
});
|
|
332
332
|
};
|
|
333
333
|
|
|
334
|
-
|
|
334
|
+
greaterThan.autoRemove = function (val) {
|
|
335
335
|
return !val;
|
|
336
336
|
};
|
|
337
337
|
|
|
338
|
-
var
|
|
338
|
+
var lessThan = function lessThan(rows, id, filterValue) {
|
|
339
339
|
return rows.filter(function (row) {
|
|
340
340
|
return !isNaN(+filterValue) && !isNaN(+row.values[id]) ? +row.values[id] < +filterValue : row.values[id].toString().toLowerCase().trim() < filterValue.toString().toLowerCase().trim();
|
|
341
341
|
});
|
|
342
342
|
};
|
|
343
343
|
|
|
344
|
-
|
|
344
|
+
lessThan.autoRemove = function (val) {
|
|
345
345
|
return !val;
|
|
346
346
|
};
|
|
347
347
|
|
|
348
|
-
var
|
|
348
|
+
var empty = function empty(rows, id, _filterValue) {
|
|
349
349
|
return rows.filter(function (row) {
|
|
350
350
|
return !row.values[id].toString().toLowerCase().trim();
|
|
351
351
|
});
|
|
352
352
|
};
|
|
353
353
|
|
|
354
|
-
|
|
354
|
+
empty.autoRemove = function (val) {
|
|
355
355
|
return !val;
|
|
356
356
|
};
|
|
357
357
|
|
|
358
|
-
var
|
|
358
|
+
var notEmpty = function notEmpty(rows, id, _filterValue) {
|
|
359
359
|
return rows.filter(function (row) {
|
|
360
360
|
return !!row.values[id].toString().toLowerCase().trim();
|
|
361
361
|
});
|
|
362
362
|
};
|
|
363
363
|
|
|
364
|
-
|
|
364
|
+
notEmpty.autoRemove = function (val) {
|
|
365
365
|
return !val;
|
|
366
366
|
};
|
|
367
367
|
|
|
368
368
|
var defaultFilterFNs = {
|
|
369
|
-
contains:
|
|
370
|
-
empty:
|
|
371
|
-
endsWith:
|
|
372
|
-
equals:
|
|
373
|
-
fuzzy:
|
|
374
|
-
greaterThan:
|
|
375
|
-
lessThan:
|
|
376
|
-
notEmpty:
|
|
377
|
-
notEquals:
|
|
378
|
-
startsWith:
|
|
369
|
+
contains: contains,
|
|
370
|
+
empty: empty,
|
|
371
|
+
endsWith: endsWith,
|
|
372
|
+
equals: equals,
|
|
373
|
+
fuzzy: fuzzy,
|
|
374
|
+
greaterThan: greaterThan,
|
|
375
|
+
lessThan: lessThan,
|
|
376
|
+
notEmpty: notEmpty,
|
|
377
|
+
notEquals: notEquals,
|
|
378
|
+
startsWith: startsWith
|
|
379
379
|
};
|
|
380
380
|
|
|
381
381
|
var commonMenuItemStyles = {
|
|
@@ -399,52 +399,52 @@ var MRT_FilterTypeMenu = function MRT_FilterTypeMenu(_ref) {
|
|
|
399
399
|
type: MRT_FILTER_TYPE.FUZZY,
|
|
400
400
|
label: localization.filterFuzzy,
|
|
401
401
|
divider: false,
|
|
402
|
-
fn:
|
|
402
|
+
fn: fuzzy
|
|
403
403
|
}, {
|
|
404
404
|
type: MRT_FILTER_TYPE.CONTAINS,
|
|
405
405
|
label: localization.filterContains,
|
|
406
406
|
divider: true,
|
|
407
|
-
fn:
|
|
407
|
+
fn: contains
|
|
408
408
|
}, {
|
|
409
409
|
type: MRT_FILTER_TYPE.STARTS_WITH,
|
|
410
410
|
label: localization.filterStartsWith,
|
|
411
411
|
divider: false,
|
|
412
|
-
fn:
|
|
412
|
+
fn: startsWith
|
|
413
413
|
}, {
|
|
414
414
|
type: MRT_FILTER_TYPE.ENDS_WITH,
|
|
415
415
|
label: localization.filterEndsWith,
|
|
416
416
|
divider: true,
|
|
417
|
-
fn:
|
|
417
|
+
fn: endsWith
|
|
418
418
|
}, {
|
|
419
419
|
type: MRT_FILTER_TYPE.EQUALS,
|
|
420
420
|
label: localization.filterEquals,
|
|
421
421
|
divider: false,
|
|
422
|
-
fn:
|
|
422
|
+
fn: equals
|
|
423
423
|
}, {
|
|
424
424
|
type: MRT_FILTER_TYPE.NOT_EQUALS,
|
|
425
425
|
label: localization.filterNotEquals,
|
|
426
426
|
divider: true,
|
|
427
|
-
fn:
|
|
427
|
+
fn: notEquals
|
|
428
428
|
}, {
|
|
429
429
|
type: MRT_FILTER_TYPE.GREATER_THAN,
|
|
430
430
|
label: localization.filterGreaterThan,
|
|
431
431
|
divider: false,
|
|
432
|
-
fn:
|
|
432
|
+
fn: greaterThan
|
|
433
433
|
}, {
|
|
434
434
|
type: MRT_FILTER_TYPE.LESS_THAN,
|
|
435
435
|
label: localization.filterLessThan,
|
|
436
436
|
divider: true,
|
|
437
|
-
fn:
|
|
437
|
+
fn: lessThan
|
|
438
438
|
}, {
|
|
439
439
|
type: MRT_FILTER_TYPE.EMPTY,
|
|
440
440
|
label: localization.filterEmpty,
|
|
441
441
|
divider: false,
|
|
442
|
-
fn:
|
|
442
|
+
fn: empty
|
|
443
443
|
}, {
|
|
444
444
|
type: MRT_FILTER_TYPE.NOT_EMPTY,
|
|
445
445
|
label: localization.filterNotEmpty,
|
|
446
446
|
divider: false,
|
|
447
|
-
fn:
|
|
447
|
+
fn: notEmpty
|
|
448
448
|
}];
|
|
449
449
|
}, []);
|
|
450
450
|
|
|
@@ -496,7 +496,7 @@ var MRT_FilterTypeMenu = function MRT_FilterTypeMenu(_ref) {
|
|
|
496
496
|
};
|
|
497
497
|
|
|
498
498
|
var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
499
|
-
var _localization$filterB, _localization$clearFi, _column$filterSelectO;
|
|
499
|
+
var _localization$filterB, _localization$filterM, _localization$, _localization$clearFi, _column$filterSelectO;
|
|
500
500
|
|
|
501
501
|
var column = _ref.column;
|
|
502
502
|
|
|
@@ -554,6 +554,7 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
554
554
|
}));
|
|
555
555
|
}
|
|
556
556
|
|
|
557
|
+
var filterId = "mrt-" + idPrefix + "-" + column.id + "-filter-text-field";
|
|
557
558
|
var filterType = tableInstance.state.currentFilterTypes[column.id];
|
|
558
559
|
var isSelectFilter = !!column.filterSelectOptions;
|
|
559
560
|
var filterChipLabel = !(filterType instanceof Function) && [MRT_FILTER_TYPE.EMPTY, MRT_FILTER_TYPE.NOT_EMPTY].includes(filterType) ? //@ts-ignore
|
|
@@ -561,7 +562,7 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
561
562
|
var filterPlaceholder = (_localization$filterB = localization.filterByColumn) == null ? void 0 : _localization$filterB.replace('{column}', String(column.Header));
|
|
562
563
|
return React.createElement(React.Fragment, null, React.createElement(TextField, Object.assign({
|
|
563
564
|
fullWidth: true,
|
|
564
|
-
id:
|
|
565
|
+
id: filterId,
|
|
565
566
|
inputProps: {
|
|
566
567
|
disabled: !!filterChipLabel,
|
|
567
568
|
sx: {
|
|
@@ -570,8 +571,11 @@ var MRT_FilterTextField = function MRT_FilterTextField(_ref) {
|
|
|
570
571
|
},
|
|
571
572
|
title: filterPlaceholder
|
|
572
573
|
},
|
|
573
|
-
helperText:
|
|
574
|
-
|
|
574
|
+
helperText: React.createElement("label", {
|
|
575
|
+
htmlFor: filterId
|
|
576
|
+
}, filterType instanceof Function ? (_localization$filterM = localization.filterMode.replace('{filterType}', // @ts-ignore
|
|
577
|
+
(_localization$ = localization["filter" + (filterType.name.charAt(0).toUpperCase() + filterType.name.slice(1))]) != null ? _localization$ : '')) != null ? _localization$filterM : '' : localization.filterMode.replace('{filterType}', // @ts-ignore
|
|
578
|
+
localization["filter" + (filterType.charAt(0).toUpperCase() + filterType.slice(1))])),
|
|
575
579
|
FormHelperTextProps: {
|
|
576
580
|
sx: {
|
|
577
581
|
fontSize: '0.6rem',
|
|
@@ -2971,7 +2975,7 @@ var MRT_TableContainer = function MRT_TableContainer() {
|
|
|
2971
2975
|
height: fullScreen ? '100%' : undefined,
|
|
2972
2976
|
left: fullScreen ? '0' : undefined,
|
|
2973
2977
|
m: fullScreen ? '0' : undefined,
|
|
2974
|
-
overflowY: 'hidden',
|
|
2978
|
+
overflowY: !fullScreen ? 'hidden' : undefined,
|
|
2975
2979
|
position: fullScreen ? 'fixed' : undefined,
|
|
2976
2980
|
right: fullScreen ? '0' : undefined,
|
|
2977
2981
|
top: fullScreen ? '0' : undefined,
|