material-react-table 1.0.6 → 1.0.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.
@@ -168,7 +168,7 @@ export declare const MRT_TableRoot: <TData extends Record<string, any> = {}>(pro
168
168
  muiTopToolbarProps?: import("@mui/material").ToolbarProps<"div", {}> | (({ table }: {
169
169
  table: MRT_TableInstance<TData>;
170
170
  }) => import("@mui/material").ToolbarProps<"div", {}>) | undefined;
171
- onDensityChange?: import("@tanstack/table-core").OnChangeFn<boolean> | undefined;
171
+ onDensityChange?: import("@tanstack/table-core").OnChangeFn<"compact" | "comfortable" | "spacious"> | undefined;
172
172
  onDraggingColumnChange?: import("@tanstack/table-core").OnChangeFn<MRT_Column<TData> | null> | undefined;
173
173
  onDraggingRowChange?: import("@tanstack/table-core").OnChangeFn<MRT_Row<TData> | null> | undefined;
174
174
  onEditingCellChange?: import("@tanstack/table-core").OnChangeFn<MRT_Cell<TData> | null> | undefined;
@@ -5,6 +5,10 @@ import type { Options as VirtualizerOptions, VirtualItem } from 'react-virtual';
5
5
  import { MRT_Icons } from './icons';
6
6
  import { MRT_FilterFns } from './filterFns';
7
7
  import { MRT_SortingFns } from './sortingFns';
8
+ /**
9
+ * Most of this file is just TypeScript types
10
+ */
11
+ declare type DensityState = 'comfortable' | 'compact' | 'spacious';
8
12
  declare type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);
9
13
  export interface MRT_Localization {
10
14
  actions: string;
@@ -134,7 +138,7 @@ export declare type MRT_TableInstance<TData extends Record<string, any> = {}> =
134
138
  setColumnFilterFns: Dispatch<SetStateAction<{
135
139
  [key: string]: MRT_FilterOption;
136
140
  }>>;
137
- setDensity: Dispatch<SetStateAction<'comfortable' | 'compact' | 'spacious'>>;
141
+ setDensity: Dispatch<SetStateAction<DensityState>>;
138
142
  setDraggingColumn: Dispatch<SetStateAction<MRT_Column<TData> | null>>;
139
143
  setDraggingRow: Dispatch<SetStateAction<MRT_Row<TData> | null>>;
140
144
  setEditingCell: Dispatch<SetStateAction<MRT_Cell<TData> | null>>;
@@ -153,7 +157,7 @@ export declare type MRT_TableInstance<TData extends Record<string, any> = {}> =
153
157
  };
154
158
  export declare type MRT_TableState<TData extends Record<string, any> = {}> = TableState & {
155
159
  columnFilterFns: Record<string, MRT_FilterOption>;
156
- density: 'comfortable' | 'compact' | 'spacious';
160
+ density: DensityState;
157
161
  draggingColumn: MRT_Column<TData> | null;
158
162
  draggingRow: MRT_Row<TData> | null;
159
163
  editingCell: MRT_Cell<TData> | null;
@@ -377,9 +381,31 @@ export declare type MRT_DisplayColumnIds = 'mrt-row-actions' | 'mrt-row-drag' |
377
381
  */
378
382
  export declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = Omit<Partial<TableOptions<TData>>, 'columns' | 'data' | 'defaultColumn' | 'enableRowSelection' | 'expandRowsFn' | 'initialState' | 'onStateChange' | 'state'> & {
379
383
  columnFilterModeOptions?: (MRT_FilterOption | string)[] | null;
384
+ /**
385
+ * The columns to display in the table. `accessorKey`s or `accessorFn`s must match keys in the `data` prop.
386
+ *
387
+ * See more info on creating columns on the official docs site:
388
+ * @link https://www.material-react-table.com/docs/guides/data-columns
389
+ * @link https://www.material-react-table.com/docs/guides/display-columns
390
+ *
391
+ * See all Columns Options on the official docs site:
392
+ * @link https://www.material-react-table.com/docs/api/column-options
393
+ */
380
394
  columns: MRT_ColumnDef<TData>[];
395
+ /**
396
+ * Pass your data as an array of objects. Objects can theoretically be any shape, but it's best to keep them consistent.
397
+ *
398
+ * See the usage guide for more info on creating columns and data:
399
+ * @link https://www.material-react-table.com/docs/getting-started/usage
400
+ */
381
401
  data: TData[];
402
+ /**
403
+ * Instead of specifying a bunch of the same options for each column, you can just change an option in the `defaultColumn` prop to change a default option for all columns.
404
+ */
382
405
  defaultColumn?: Partial<MRT_ColumnDef<TData>>;
406
+ /**
407
+ * Change the default options for display columns.
408
+ */
383
409
  defaultDisplayColumn?: Partial<MRT_ColumnDef<TData>>;
384
410
  displayColumnDefOptions?: Partial<{
385
411
  [key in MRT_DisplayColumnIds]: Partial<MRT_ColumnDef>;
@@ -539,7 +565,7 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
539
565
  muiTopToolbarProps?: ToolbarProps | (({ table }: {
540
566
  table: MRT_TableInstance<TData>;
541
567
  }) => ToolbarProps);
542
- onDensityChange?: OnChangeFn<boolean>;
568
+ onDensityChange?: OnChangeFn<DensityState>;
543
569
  onDraggingColumnChange?: OnChangeFn<MRT_Column<TData> | null>;
544
570
  onDraggingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
545
571
  onEditingCellChange?: OnChangeFn<MRT_Cell<TData> | null>;
@@ -1,8 +1,8 @@
1
- import React from 'react';
1
+ import { FC } from 'react';
2
2
  import { MRT_Cell, MRT_TableInstance } from '..';
3
3
  interface Props {
4
4
  cell: MRT_Cell;
5
5
  table: MRT_TableInstance;
6
6
  }
7
- export declare const MRT_TableBodyCellValue: React.NamedExoticComponent<Props>;
7
+ export declare const MRT_TableBodyCellValue: FC<Props>;
8
8
  export {};
@@ -1,4 +1,4 @@
1
- import React, { useMemo, useRef, useState, useCallback, useEffect, Fragment, memo, useLayoutEffect } from 'react';
1
+ import React, { useMemo, useRef, useState, useCallback, useEffect, Fragment, useLayoutEffect } from 'react';
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';
@@ -2073,7 +2073,7 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
2073
2073
  return (React.createElement(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
2074
2074
  };
2075
2075
 
2076
- const _MRT_TableBodyCellValue = ({ cell, table }) => {
2076
+ const MRT_TableBodyCellValue = ({ cell, table }) => {
2077
2077
  var _a, _b;
2078
2078
  const { column, row } = cell;
2079
2079
  const { columnDef } = column;
@@ -2095,7 +2095,6 @@ const _MRT_TableBodyCellValue = ({ cell, table }) => {
2095
2095
  })
2096
2096
  : (_b = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Cell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table })) !== null && _b !== void 0 ? _b : cell.renderValue()));
2097
2097
  };
2098
- const MRT_TableBodyCellValue = memo(_MRT_TableBodyCellValue, (prev, next) => prev.cell.getValue() === next.cell.getValue());
2099
2098
 
2100
2099
  const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
2101
2100
  var _a, _b;