material-react-table 1.0.5 → 1.0.7

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.
@@ -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 {};
package/dist/cjs/index.js CHANGED
@@ -574,9 +574,10 @@ const getLeadingDisplayColumnIds = (props) => {
574
574
  var _a;
575
575
  return [
576
576
  (props.enableRowDragging || props.enableRowOrdering) && 'mrt-row-drag',
577
- ((props.positionActionsColumn === 'first' && props.enableRowActions) ||
578
- (props.enableEditing &&
579
- ['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
577
+ props.positionActionsColumn === 'first' &&
578
+ (props.enableRowActions ||
579
+ (props.enableEditing &&
580
+ ['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
580
581
  'mrt-row-actions',
581
582
  props.positionExpandColumn === 'first' &&
582
583
  showExpandColumn(props) &&
@@ -588,9 +589,10 @@ const getLeadingDisplayColumnIds = (props) => {
588
589
  const getTrailingDisplayColumnIds = (props) => {
589
590
  var _a;
590
591
  return [
591
- ((props.positionActionsColumn === 'last' && props.enableRowActions) ||
592
- (props.enableEditing &&
593
- ['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
592
+ props.positionActionsColumn === 'last' &&
593
+ (props.enableRowActions ||
594
+ (props.enableEditing &&
595
+ ['row', 'modal'].includes((_a = props.editingMode) !== null && _a !== void 0 ? _a : ''))) &&
594
596
  'mrt-row-actions',
595
597
  props.positionExpandColumn === 'last' &&
596
598
  showExpandColumn(props) &&
@@ -2079,7 +2081,7 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
2079
2081
  return (React__default["default"].createElement(MRT_GrabHandleButton, { iconButtonProps: iconButtonProps, onDragStart: handleDragStart, onDragEnd: handleDragEnd, table: table }));
2080
2082
  };
2081
2083
 
2082
- const _MRT_TableBodyCellValue = ({ cell, table }) => {
2084
+ const MRT_TableBodyCellValue = ({ cell, table }) => {
2083
2085
  var _a, _b;
2084
2086
  const { column, row } = cell;
2085
2087
  const { columnDef } = column;
@@ -2101,7 +2103,6 @@ const _MRT_TableBodyCellValue = ({ cell, table }) => {
2101
2103
  })
2102
2104
  : (_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()));
2103
2105
  };
2104
- const MRT_TableBodyCellValue = React.memo(_MRT_TableBodyCellValue, (prev, next) => prev.cell.getValue() === next.cell.getValue());
2105
2106
 
2106
2107
  const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
2107
2108
  var _a, _b;