material-react-table 0.40.5 → 0.40.8

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.
@@ -130,7 +130,7 @@ export declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit
130
130
  *
131
131
  * @example accessorFn: (row) => row.username
132
132
  */
133
- accessorFn?: (row: TData) => any;
133
+ accessorFn?: (originalRow: TData) => any;
134
134
  /**
135
135
  * Either an `accessorKey` or a combination of an `accessorFn` and `id` are required for a data column definition.
136
136
  * Specify which key in the row this column should use to access the correct data.
@@ -311,7 +311,7 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
311
311
  enableTableHead?: boolean;
312
312
  enableToolbarInternalActions?: boolean;
313
313
  enableTopToolbar?: boolean;
314
- enabledGlobalFilterOptions?: (MRT_FilterOption | string)[] | null;
314
+ globalFilterModeOptions?: (MRT_FilterOption | string)[] | null;
315
315
  expandRowsFn?: (dataRow: TData) => TData[];
316
316
  icons?: Partial<MRT_Icons>;
317
317
  initialState?: Partial<MRT_TableState<TData>>;
@@ -2,7 +2,7 @@ import React, { useMemo, useRef, useState, useCallback, Fragment, useEffect, use
2
2
  import { aggregationFns, filterFns, sortingFns, useReactTable, getCoreRowModel, getExpandedRowModel, getFacetedRowModel, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel } from '@tanstack/react-table';
3
3
  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';
4
4
  import { rankItem, rankings, compareItems } from '@tanstack/match-sorter-utils';
5
- import { Tooltip, IconButton, Menu, MenuItem, Box, FormControlLabel, Switch, Typography, Button, Divider, ListItemIcon, Checkbox, debounce, Collapse, TextField, InputAdornment, LinearProgress, TablePagination, Chip, Alert, AlertTitle, Fade, alpha, useMediaQuery, Toolbar, lighten, ListItemText, Grow, TableSortLabel, useTheme, TableCell, TableRow, TableHead, darken, Skeleton, TableBody, TableFooter, Table, TableContainer, Paper, Dialog, DialogTitle, DialogContent, Stack, DialogActions } from '@mui/material';
5
+ import { Tooltip, IconButton, Menu, MenuItem, Box, FormControlLabel, Switch, Typography, Button, Divider, ListItemIcon, Checkbox, debounce, Collapse, TextField, InputAdornment, LinearProgress, TablePagination, Chip, Alert, AlertTitle, Fade, alpha, useMediaQuery, Toolbar, lighten, Grow, TableSortLabel, useTheme, TableCell, TableRow, TableHead, darken, Skeleton, TableBody, TableFooter, Table, TableContainer, Paper, Dialog, DialogTitle, DialogContent, Stack, DialogActions } from '@mui/material';
6
6
  import { useVirtual } from 'react-virtual';
7
7
 
8
8
  /******************************************************************************
@@ -383,7 +383,7 @@ const mrtFilterOptions = (localization) => [
383
383
  ];
384
384
  const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, table, }) => {
385
385
  var _a, _b, _c, _d;
386
- const { getState, options: { enabledGlobalFilterOptions, columnFilterModeOptions, localization, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
386
+ const { getState, options: { columnFilterModeOptions, globalFilterModeOptions, localization, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
387
387
  const { globalFilterFn, density } = getState();
388
388
  const { column } = header !== null && header !== void 0 ? header : {};
389
389
  const { columnDef } = column !== null && column !== void 0 ? column : {};
@@ -391,8 +391,8 @@ const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, table,
391
391
  const internalFilterOptions = useMemo(() => mrtFilterOptions(localization).filter((filterOption) => columnDef
392
392
  ? allowedColumnFilterOptions === undefined ||
393
393
  (allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.includes(filterOption.option))
394
- : (!enabledGlobalFilterOptions ||
395
- enabledGlobalFilterOptions.includes(filterOption.option)) &&
394
+ : (!globalFilterModeOptions ||
395
+ globalFilterModeOptions.includes(filterOption.option)) &&
396
396
  ['fuzzy', 'contains', 'startsWith'].includes(filterOption.option)), []);
397
397
  const handleSelectFilterMode = (option) => {
398
398
  if (header && column) {
@@ -1503,9 +1503,14 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
1503
1503
  value = option.value;
1504
1504
  text = option.text;
1505
1505
  }
1506
- return (React.createElement(MenuItem, { key: value, value: value },
1506
+ return (React.createElement(MenuItem, { key: value, sx: {
1507
+ display: 'flex',
1508
+ m: 0,
1509
+ alignItems: 'center',
1510
+ gap: '0.5rem',
1511
+ }, value: value },
1507
1512
  isMultiSelectFilter && (React.createElement(Checkbox, { checked: ((_a = column.getFilterValue()) !== null && _a !== void 0 ? _a : []).includes(value), sx: { mr: '0.5rem' } })),
1508
- React.createElement(ListItemText, null, text)));
1513
+ text));
1509
1514
  })),
1510
1515
  React.createElement(MRT_FilterOptionMenu, { anchorEl: anchorEl, header: header, setAnchorEl: setAnchorEl, table: table })));
1511
1516
  };
@@ -1526,8 +1531,7 @@ const MRT_TableHeadCellFilterContainer = ({ header, table, }) => {
1526
1531
 
1527
1532
  const MRT_TableHeadCellFilterLabel = ({ header, table }) => {
1528
1533
  var _a, _b, _c;
1529
- const { getState, options: { icons: { FilterAltIcon }, localization, }, } = table;
1530
- const { columnFilterFns } = getState();
1534
+ const { options: { icons: { FilterAltIcon }, localization, }, } = table;
1531
1535
  const { column } = header;
1532
1536
  const { columnDef } = column;
1533
1537
  const isRangeFilter = [
@@ -1535,7 +1539,7 @@ const MRT_TableHeadCellFilterLabel = ({ header, table }) => {
1535
1539
  'betweenInclusive',
1536
1540
  'inNumberRange',
1537
1541
  ].includes(columnDef._filterFn);
1538
- const currentFilterOption = columnFilterFns === null || columnFilterFns === void 0 ? void 0 : columnFilterFns[header.id];
1542
+ const currentFilterOption = columnDef._filterFn;
1539
1543
  const filterTooltip = localization.filteringByColumn
1540
1544
  .replace('{column}', String(columnDef.header))
1541
1545
  .replace('{filterType}',
@@ -2150,7 +2154,8 @@ const MRT_TableBody = ({ table, tableContainerRef }) => {
2150
2154
  !Object.values(sorting).some(Boolean)) {
2151
2155
  const rankedRows = getPrePaginationRowModel().rows.sort((a, b) => rankGlobalFuzzy(a, b));
2152
2156
  if (enablePagination) {
2153
- return rankedRows.slice(pagination.pageIndex, pagination.pageSize);
2157
+ const start = pagination.pageIndex * pagination.pageSize;
2158
+ return rankedRows.slice(start, start + pagination.pageSize);
2154
2159
  }
2155
2160
  return rankedRows;
2156
2161
  }
@@ -2163,6 +2168,8 @@ const MRT_TableBody = ({ table, tableContainerRef }) => {
2163
2168
  ? getPrePaginationRowModel().rows
2164
2169
  : getRowModel().rows,
2165
2170
  globalFilter,
2171
+ pagination.pageIndex,
2172
+ pagination.pageSize,
2166
2173
  ]);
2167
2174
  const virtualizer = enableRowVirtualization
2168
2175
  ? useVirtual(Object.assign({ size: rows.length, parentRef: tableContainerRef, overscan: 15 }, vProps))
@@ -2419,6 +2426,7 @@ const MRT_TableRoot = (props) => {
2419
2426
  props.displayColumnDefOptions,
2420
2427
  props.editingMode,
2421
2428
  props.enableColumnDragging,
2429
+ props.enableColumnFilterModes,
2422
2430
  props.enableColumnOrdering,
2423
2431
  props.enableEditing,
2424
2432
  props.enableExpandAll,