material-react-table 0.14.1 → 0.14.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/head/MRT_TableHeadCell.d.ts +1 -1
- package/dist/{buttons/MRT_ToggleColumnActionMenuButton.d.ts → head/MRT_TableHeadCellColumnActionsButton.d.ts} +1 -1
- package/dist/material-react-table.cjs.development.js +36 -33
- 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 +37 -34
- package/dist/material-react-table.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/head/MRT_TableHeadCell.tsx +17 -16
- package/src/{buttons/MRT_ToggleColumnActionMenuButton.tsx → head/MRT_TableHeadCellColumnActionsButton.tsx} +1 -2
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +55 -56
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +1 -0
- package/src/head/MRT_TableHeadCellSortLabel.tsx +4 -0
- package/src/toolbar/MRT_ToolbarBottom.tsx +2 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useMemo, forwardRef, useState, useCallback, Fragment, useLayoutEffect, useEffect } from 'react';
|
|
2
2
|
import { ArrowRight, Cancel, CheckBox, ClearAll, Close, DensityLarge, DensityMedium, DensitySmall, DragHandle, DynamicFeed, Edit, ExpandLess, ExpandMore, FilterAlt, FilterAltOff, FilterList, FilterListOff, FullscreenExit, Fullscreen, KeyboardDoubleArrowDown, MoreHoriz, MoreVert, PushPin, RestartAlt, Save, Search, SearchOff, Sort, ViewColumn, VisibilityOff } from '@mui/icons-material';
|
|
3
3
|
import { createTable, getCoreRowModel, getExpandedRowModel, getFacetedRowModel, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, useTableInstance } from '@tanstack/react-table';
|
|
4
|
-
import { Tooltip, IconButton, Menu, MenuItem, Box, FormControlLabel, Switch, Button, Divider, ListItemIcon, Checkbox, debounce, Collapse, TextField, InputAdornment, TablePagination, Chip, Alert, LinearProgress, useMediaQuery, Toolbar, lighten, alpha, TableSortLabel, TableCell, TableRow, TableHead, darken, Skeleton, TableBody, TableFooter, Table, TableContainer, Paper, Dialog
|
|
4
|
+
import { Tooltip, IconButton, Menu, MenuItem, Box, FormControlLabel, Switch, Button, Divider, ListItemIcon, Checkbox, debounce, Collapse, TextField, InputAdornment, TablePagination, Chip, Alert, LinearProgress, useMediaQuery, Toolbar, lighten, alpha, Grow, TableSortLabel, TableCell, TableRow, TableHead, darken, Skeleton, TableBody, TableFooter, Table, TableContainer, Paper, Dialog } from '@mui/material';
|
|
5
5
|
import { rankItem, rankings } from '@tanstack/match-sorter-utils';
|
|
6
6
|
import { useDrop, useDrag, DndProvider } from 'react-dnd';
|
|
7
7
|
import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
@@ -1935,7 +1935,9 @@ var MRT_ToolbarBottom = function MRT_ToolbarBottom(_ref) {
|
|
|
1935
1935
|
}), {
|
|
1936
1936
|
bottom: isFullScreen ? '0' : undefined,
|
|
1937
1937
|
boxShadow: "-3px 0 6px " + alpha(theme.palette.common.black, 0.1),
|
|
1938
|
-
|
|
1938
|
+
left: 0,
|
|
1939
|
+
position: isFullScreen ? 'fixed' : 'relative',
|
|
1940
|
+
right: 0
|
|
1939
1941
|
}, toolbarProps == null ? void 0 : toolbarProps.sx);
|
|
1940
1942
|
}
|
|
1941
1943
|
}), React.createElement(MRT_LinearProgressBar, {
|
|
@@ -2260,27 +2262,28 @@ var MRT_TableHeadCellFilterContainer = function MRT_TableHeadCellFilterContainer
|
|
|
2260
2262
|
};
|
|
2261
2263
|
|
|
2262
2264
|
var MRT_TableHeadCellFilterLabel = function MRT_TableHeadCellFilterLabel(_ref) {
|
|
2263
|
-
var
|
|
2265
|
+
var _column$getFilterValu, _column$getFilterValu2;
|
|
2264
2266
|
|
|
2265
2267
|
var header = _ref.header,
|
|
2266
2268
|
instance = _ref.instance;
|
|
2267
2269
|
var getState = instance.getState,
|
|
2268
2270
|
_instance$options = instance.options,
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
FilterAltOffIcon = _instance$options$ico.FilterAltOffIcon,
|
|
2272
|
-
localization = _instance$options.localization,
|
|
2273
|
-
setShowFilters = instance.setShowFilters;
|
|
2271
|
+
FilterAltIcon = _instance$options.icons.FilterAltIcon,
|
|
2272
|
+
localization = _instance$options.localization;
|
|
2274
2273
|
|
|
2275
2274
|
var _getState = getState(),
|
|
2276
|
-
|
|
2275
|
+
currentFilterFns = _getState.currentFilterFns;
|
|
2277
2276
|
|
|
2278
2277
|
var column = header.column;
|
|
2279
2278
|
var columnDef = column.columnDef;
|
|
2280
|
-
var filterFn =
|
|
2281
|
-
var filterTooltip =
|
|
2282
|
-
localization["filter" + (filterFn.charAt(0).toUpperCase() + filterFn.slice(1))]).replace('{filterValue}', "\"" + (Array.isArray(column.getFilterValue()) ? column.getFilterValue().join("\" " + localization.and + " \"") : column.getFilterValue()) + "\"").replace('" "', '')
|
|
2283
|
-
return React.createElement(
|
|
2279
|
+
var filterFn = currentFilterFns == null ? void 0 : currentFilterFns[header.id];
|
|
2280
|
+
var filterTooltip = localization.filteringByColumn.replace('{column}', String(columnDef.header)).replace('{filterType}', filterFn instanceof Function ? '' : // @ts-ignore
|
|
2281
|
+
localization["filter" + (filterFn.charAt(0).toUpperCase() + filterFn.slice(1))]).replace('{filterValue}', "\"" + (Array.isArray(column.getFilterValue()) ? column.getFilterValue().join("\" " + localization.and + " \"") : column.getFilterValue()) + "\"").replace('" "', '');
|
|
2282
|
+
return React.createElement(Grow, {
|
|
2283
|
+
unmountOnExit: true,
|
|
2284
|
+
"in": !!column.getFilterValue() && filterFn !== 'between' || filterFn === 'between' && ( // @ts-ignore
|
|
2285
|
+
!!((_column$getFilterValu = column.getFilterValue()) != null && _column$getFilterValu[0]) || !!((_column$getFilterValu2 = column.getFilterValue()) != null && _column$getFilterValu2[1]))
|
|
2286
|
+
}, React.createElement("span", null, React.createElement(Tooltip, {
|
|
2284
2287
|
arrow: true,
|
|
2285
2288
|
placement: "top",
|
|
2286
2289
|
title: filterTooltip
|
|
@@ -2288,21 +2291,16 @@ var MRT_TableHeadCellFilterLabel = function MRT_TableHeadCellFilterLabel(_ref) {
|
|
|
2288
2291
|
disableRipple: true,
|
|
2289
2292
|
onClick: function onClick(event) {
|
|
2290
2293
|
event.stopPropagation();
|
|
2291
|
-
setShowFilters(!showFilters);
|
|
2292
2294
|
},
|
|
2293
2295
|
size: "small",
|
|
2294
2296
|
sx: {
|
|
2295
2297
|
m: 0,
|
|
2296
|
-
opacity:
|
|
2298
|
+
opacity: 0.8,
|
|
2297
2299
|
p: '2px',
|
|
2298
|
-
transition: 'all 0.2s ease-in-out',
|
|
2299
2300
|
transform: 'scale(0.66)',
|
|
2300
|
-
'
|
|
2301
|
-
backgroundColor: 'transparent',
|
|
2302
|
-
opacity: 0.8
|
|
2303
|
-
}
|
|
2301
|
+
width: '1.5ch'
|
|
2304
2302
|
}
|
|
2305
|
-
},
|
|
2303
|
+
}, React.createElement(FilterAltIcon, null)))));
|
|
2306
2304
|
};
|
|
2307
2305
|
|
|
2308
2306
|
var MRT_TableHeadCellResizeHandle = function MRT_TableHeadCellResizeHandle(_ref) {
|
|
@@ -2329,6 +2327,7 @@ var MRT_TableHeadCellResizeHandle = function MRT_TableHeadCellResizeHandle(_ref)
|
|
|
2329
2327
|
height: showFilters && columnDefType === 'data' ? '4rem' : '2rem',
|
|
2330
2328
|
opacity: 0.8,
|
|
2331
2329
|
position: 'absolute',
|
|
2330
|
+
mr: '-1rem',
|
|
2332
2331
|
right: '1px',
|
|
2333
2332
|
touchAction: 'none',
|
|
2334
2333
|
transition: column.getIsResizing() ? undefined : 'all 0.2s ease-in-out',
|
|
@@ -2362,11 +2361,15 @@ var MRT_TableHeadCellSortLabel = function MRT_TableHeadCellSortLabel(_ref) {
|
|
|
2362
2361
|
}, React.createElement(TableSortLabel, {
|
|
2363
2362
|
"aria-label": sortTooltip,
|
|
2364
2363
|
active: !!column.getIsSorted(),
|
|
2365
|
-
direction: column.getIsSorted() ? column.getIsSorted() : undefined
|
|
2364
|
+
direction: column.getIsSorted() ? column.getIsSorted() : undefined,
|
|
2365
|
+
sx: {
|
|
2366
|
+
width: '2ch',
|
|
2367
|
+
transform: 'translateX(-0.5ch)'
|
|
2368
|
+
}
|
|
2366
2369
|
}));
|
|
2367
2370
|
};
|
|
2368
2371
|
|
|
2369
|
-
var
|
|
2372
|
+
var MRT_TableHeadCellColumnActionsButton = function MRT_TableHeadCellColumnActionsButton(_ref) {
|
|
2370
2373
|
var header = _ref.header,
|
|
2371
2374
|
instance = _ref.instance;
|
|
2372
2375
|
var _instance$options = instance.options,
|
|
@@ -2410,7 +2413,6 @@ var MRT_ToggleColumnActionMenuButton = function MRT_ToggleColumnActionMenuButton
|
|
|
2410
2413
|
}, iconButtonProps, {
|
|
2411
2414
|
sx: _extends({
|
|
2412
2415
|
height: '2rem',
|
|
2413
|
-
mr: '2px',
|
|
2414
2416
|
mt: '-0.2rem',
|
|
2415
2417
|
opacity: 0.5,
|
|
2416
2418
|
transition: 'opacity 0.2s',
|
|
@@ -2433,20 +2435,21 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
|
2433
2435
|
var dragRef = _ref.dragRef,
|
|
2434
2436
|
dropRef = _ref.dropRef,
|
|
2435
2437
|
header = _ref.header,
|
|
2438
|
+
instance = _ref.instance,
|
|
2436
2439
|
isDragging = _ref.isDragging,
|
|
2437
|
-
previewRef = _ref.previewRef
|
|
2438
|
-
instance = _ref.instance;
|
|
2440
|
+
previewRef = _ref.previewRef;
|
|
2439
2441
|
var getState = instance.getState,
|
|
2440
2442
|
_instance$options = instance.options,
|
|
2441
2443
|
enableColumnActions = _instance$options.enableColumnActions,
|
|
2442
|
-
enableColumnFilters = _instance$options.enableColumnFilters,
|
|
2443
2444
|
enableColumnOrdering = _instance$options.enableColumnOrdering,
|
|
2444
2445
|
enableColumnResizing = _instance$options.enableColumnResizing,
|
|
2445
2446
|
enableGrouping = _instance$options.enableGrouping,
|
|
2447
|
+
enableMultiSort = _instance$options.enableMultiSort,
|
|
2446
2448
|
muiTableHeadCellProps = _instance$options.muiTableHeadCellProps;
|
|
2447
2449
|
|
|
2448
2450
|
var _getState = getState(),
|
|
2449
|
-
density = _getState.density
|
|
2451
|
+
density = _getState.density,
|
|
2452
|
+
showFilters = _getState.showFilters;
|
|
2450
2453
|
|
|
2451
2454
|
var column = header.column;
|
|
2452
2455
|
var columnDef = column.columnDef,
|
|
@@ -2501,7 +2504,8 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
|
2501
2504
|
pt: columnDefType !== 'data' ? 0 : density === 'compact' ? '0.25' : density === 'comfortable' ? '.75rem' : '1.25rem',
|
|
2502
2505
|
right: column.getIsPinned() === 'right' ? getTotalRight() + "px" : undefined,
|
|
2503
2506
|
transition: "all " + (enableColumnResizing ? 0 : '0.2s') + " ease-in-out",
|
|
2504
|
-
|
|
2507
|
+
userSelect: enableMultiSort ? 'none' : undefined,
|
|
2508
|
+
verticalAlign: columnDefType === 'display' && showFilters ? 'center' : 'text-top',
|
|
2505
2509
|
zIndex: column.getIsResizing() ? 3 : column.getIsPinned() && columnDefType !== 'group' ? 2 : 1
|
|
2506
2510
|
}, tableCellProps == null ? void 0 : tableCellProps.sx, {
|
|
2507
2511
|
maxWidth: "min(" + column.getSize() + "px, fit-content)",
|
|
@@ -2516,12 +2520,11 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
|
2516
2520
|
display: 'flex',
|
|
2517
2521
|
justifyContent: columnDefType === 'group' ? 'center' : 'space-between',
|
|
2518
2522
|
opacity: isDragging ? 0.5 : 1,
|
|
2523
|
+
position: 'relative',
|
|
2519
2524
|
width: '100%'
|
|
2520
2525
|
}
|
|
2521
2526
|
}, React.createElement(Box, {
|
|
2522
|
-
onClick:
|
|
2523
|
-
return column.toggleSorting();
|
|
2524
|
-
},
|
|
2527
|
+
onClick: column.getToggleSortingHandler(),
|
|
2525
2528
|
sx: {
|
|
2526
2529
|
alignItems: 'center',
|
|
2527
2530
|
cursor: column.getCanSort() && columnDefType !== 'group' ? 'pointer' : undefined,
|
|
@@ -2532,7 +2535,7 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
|
2532
2535
|
}, headerElement, columnDefType === 'data' && column.getCanSort() && React.createElement(MRT_TableHeadCellSortLabel, {
|
|
2533
2536
|
header: header,
|
|
2534
2537
|
instance: instance
|
|
2535
|
-
}), columnDefType === 'data' &&
|
|
2538
|
+
}), columnDefType === 'data' && column.getCanFilter() && React.createElement(MRT_TableHeadCellFilterLabel, {
|
|
2536
2539
|
header: header,
|
|
2537
2540
|
instance: instance
|
|
2538
2541
|
})), React.createElement(Box, {
|
|
@@ -2542,7 +2545,7 @@ var MRT_TableHeadCell = function MRT_TableHeadCell(_ref) {
|
|
|
2542
2545
|
}, columnDefType === 'data' && (enableColumnOrdering && columnDef.enableColumnOrdering !== false || enableGrouping && columnDef.enableGrouping !== false) && React.createElement(MRT_GrabHandleButton, {
|
|
2543
2546
|
ref: dragRef,
|
|
2544
2547
|
instance: instance
|
|
2545
|
-
}), (enableColumnActions || columnDef.enableColumnActions) && columnDef.enableColumnActions !== false && columnDefType !== 'group' && React.createElement(
|
|
2548
|
+
}), (enableColumnActions || columnDef.enableColumnActions) && columnDef.enableColumnActions !== false && columnDefType !== 'group' && React.createElement(MRT_TableHeadCellColumnActionsButton, {
|
|
2546
2549
|
header: header,
|
|
2547
2550
|
instance: instance
|
|
2548
2551
|
})), column.getCanResize() && React.createElement(MRT_TableHeadCellResizeHandle, {
|