material-react-table 0.40.6 → 0.40.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/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Material React Table
2
2
 
3
+ __Built with [Material UI <sup>V5</sup>](https://mui.com) and [TanStack Table <sup>V8</sup>](https://tanstack.com/table/v8)__
4
+
5
+ _Quickly Create React Data Tables with Material Design_
6
+
3
7
  <a href="https://npmjs.com/package/material-react-table" target="_blank">
4
8
  <img alt="" src="https://badgen.net/npm/v/material-react-table?color=blue" />
5
9
  </a>
@@ -19,8 +23,6 @@
19
23
  <img alt="" src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square" />
20
24
  </a>
21
25
 
22
- ---
23
-
24
26
  ## About
25
27
 
26
28
  > This project is still in alpha, but is expected to enter beta by August 2022, and a stable 1.0 release shortly thereafter.
@@ -36,12 +38,10 @@ View the [Docs Website](https://www.material-react-table.com/)
36
38
 
37
39
  See all [Props and Options](https://www.material-react-table.com/docs/api)
38
40
 
39
- ---
40
-
41
41
  ## Quick Examples
42
42
 
43
43
  - [Basic Table](https://www.material-react-table.com/docs/examples/basic/) (See Default Features)
44
- - [Minimal Table](https://www.material-react-table.com/docs/examples/minimal/) (Turn off Features)
44
+ - [Minimal Table](https://www.material-react-table.com/docs/examples/minimal/) (Turn off Features like Pagination, Sorting, Filtering, and Toolbars)
45
45
  - [Advanced Table](https://www.material-react-table.com/docs/examples/advanced/) (See some of the Advanced Features)
46
46
  - [Aggregation/Grouping](https://www.material-react-table.com/docs/examples/aggregation-and-grouping/) (Aggregation features such as Sum, Average, Count, etc.)
47
47
  - [Data Export Table](https://www.material-react-table.com/docs/examples/data-export/) (Export to CSV, Excel, etc.)
@@ -53,8 +53,6 @@ See all [Props and Options](https://www.material-react-table.com/docs/api)
53
53
 
54
54
  View additional [storybook examples](https://www.material-react-table.dev/)
55
55
 
56
- ---
57
-
58
56
  ## Features (All Features work and are MVP, but are still being polished)
59
57
 
60
58
  _All features can easily be enabled/disabled_
@@ -91,8 +89,6 @@ _All features can easily be enabled/disabled_
91
89
  - [x] Tree Data / Expanding Sub-rows
92
90
  - [x] Virtualization (react-virtual)
93
91
 
94
- ---
95
-
96
92
  ## Getting Started
97
93
 
98
94
  ### Installation
@@ -113,13 +109,11 @@ npm install material-react-table
113
109
 
114
110
  > _`@tanstack/react-table`, `@tanstack/react-virtual`, and `@tanstack/match-sorter-utils`_ are internal dependencies, so you don't need to install them yourself.
115
111
 
116
- ---
117
-
118
112
  ### Usage
119
113
 
120
114
  > Read the full usage docs [here](https://www.material-react-table.com/docs/getting-started/usage/)
121
115
 
122
- ```tsx
116
+ ```jsx
123
117
  import React, { useMemo, useState, useEffect } from 'react';
124
118
  import MaterialReactTable from 'material-react-table';
125
119
 
@@ -178,8 +172,6 @@ export default function App() {
178
172
 
179
173
  _Open in [Code Sandbox](https://codesandbox.io/s/simple-material-react-table-example-t5c3ji)_
180
174
 
181
- ---
182
-
183
175
  ## Contributors
184
176
 
185
177
  <a href="https://github.com/kevinvandy/material-react-table/graphs/contributors">
@@ -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.
@@ -160,7 +160,7 @@ export declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit
160
160
  filterFn?: MRT_FilterFn<TData>;
161
161
  filterSelectOptions?: (string | {
162
162
  text: string;
163
- value: string;
163
+ value: any;
164
164
  })[];
165
165
  filterVariant?: 'text' | 'select' | 'multi-select' | 'range';
166
166
  /**
@@ -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>>;
package/dist/cjs/index.js CHANGED
@@ -391,7 +391,7 @@ const mrtFilterOptions = (localization) => [
391
391
  ];
392
392
  const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, table, }) => {
393
393
  var _a, _b, _c, _d;
394
- const { getState, options: { enabledGlobalFilterOptions, columnFilterModeOptions, localization, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
394
+ const { getState, options: { columnFilterModeOptions, globalFilterModeOptions, localization, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
395
395
  const { globalFilterFn, density } = getState();
396
396
  const { column } = header !== null && header !== void 0 ? header : {};
397
397
  const { columnDef } = column !== null && column !== void 0 ? column : {};
@@ -399,8 +399,8 @@ const MRT_FilterOptionMenu = ({ anchorEl, header, onSelect, setAnchorEl, table,
399
399
  const internalFilterOptions = React.useMemo(() => mrtFilterOptions(localization).filter((filterOption) => columnDef
400
400
  ? allowedColumnFilterOptions === undefined ||
401
401
  (allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.includes(filterOption.option))
402
- : (!enabledGlobalFilterOptions ||
403
- enabledGlobalFilterOptions.includes(filterOption.option)) &&
402
+ : (!globalFilterModeOptions ||
403
+ globalFilterModeOptions.includes(filterOption.option)) &&
404
404
  ['fuzzy', 'contains', 'startsWith'].includes(filterOption.option)), []);
405
405
  const handleSelectFilterMode = (option) => {
406
406
  if (header && column) {
@@ -2162,7 +2162,8 @@ const MRT_TableBody = ({ table, tableContainerRef }) => {
2162
2162
  !Object.values(sorting).some(Boolean)) {
2163
2163
  const rankedRows = getPrePaginationRowModel().rows.sort((a, b) => rankGlobalFuzzy(a, b));
2164
2164
  if (enablePagination) {
2165
- return rankedRows.slice(pagination.pageIndex, pagination.pageSize);
2165
+ const start = pagination.pageIndex * pagination.pageSize;
2166
+ return rankedRows.slice(start, start + pagination.pageSize);
2166
2167
  }
2167
2168
  return rankedRows;
2168
2169
  }
@@ -2175,6 +2176,8 @@ const MRT_TableBody = ({ table, tableContainerRef }) => {
2175
2176
  ? getPrePaginationRowModel().rows
2176
2177
  : getRowModel().rows,
2177
2178
  globalFilter,
2179
+ pagination.pageIndex,
2180
+ pagination.pageSize,
2178
2181
  ]);
2179
2182
  const virtualizer = enableRowVirtualization
2180
2183
  ? reactVirtual.useVirtual(Object.assign({ size: rows.length, parentRef: tableContainerRef, overscan: 15 }, vProps))