material-react-table 0.19.0-alpha.1 → 0.21.0

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.
@@ -6,6 +6,7 @@ import { MRT_Localization } from './localization';
6
6
  import { MRT_Icons } from './icons';
7
7
  import { MRT_FilterFns } from './filtersFns';
8
8
  import { MRT_SortingFns } from './sortingFns';
9
+ declare type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);
9
10
  export declare type MRT_TableOptions<D extends Record<string, any> = {}> = Partial<Omit<TableOptions<D>, 'columns' | 'data' | 'initialState' | 'state' | 'expandRowsFn'>> & {
10
11
  columns: MRT_ColumnDef<D>[];
11
12
  data: D[];
@@ -105,7 +106,7 @@ export declare type MRT_ColumnDef<D extends Record<string, any> = {}> = Omit<Col
105
106
  *
106
107
  * @example accessorKey: 'username'
107
108
  */
108
- accessorKey?: keyof D;
109
+ accessorKey?: LiteralUnion<string & keyof D>;
109
110
  /**
110
111
  * Specify what type of column this is. Either `data`, `display`, or `group`. Defaults to `data`.
111
112
  * Leave this blank if you are just creating a normal data column.
@@ -131,12 +132,14 @@ export declare type MRT_ColumnDef<D extends Record<string, any> = {}> = Omit<Col
131
132
  header: string;
132
133
  /**
133
134
  * Either an `accessorKey` or a combination of an `accessorFn` and `id` are required for a data column definition.
135
+ *
134
136
  * If you have also specified an `accessorFn`, MRT still needs to have a valid `id` to be able to identify the column uniquely.
137
+ *
135
138
  * `id` defaults to the `accessorKey` or `header` if not specified.
136
139
  *
137
140
  * @default gets set to the same value as `accessorKey` by default
138
141
  */
139
- id?: string;
142
+ id?: LiteralUnion<string & keyof D>;
140
143
  muiTableBodyCellCopyButtonProps?: ButtonProps | (({ table, cell, }: {
141
144
  table: MRT_TableInstance<D>;
142
145
  cell: MRT_Cell<D>;
@@ -7263,13 +7263,20 @@ var MRT_TableBody = function MRT_TableBody(_ref) {
7263
7263
  return enablePagination ? getRowModel().rows : getPrePaginationRowModel().rows;
7264
7264
  }, [enableGlobalFilterRankedResults, enableGlobalFilterRankedResults && globalFilter || !enablePagination ? getPrePaginationRowModel().rows : getRowModel().rows, globalFilter]);
7265
7265
  var rowVirtualizer = enableRowVirtualization ? useVirtual(_extends({
7266
- overscan: density === 'compact' ? 20 : 10,
7267
- size: rows.length,
7268
- parentRef: tableContainerRef
7266
+ // estimateSize: () => (density === 'compact' ? 25 : 50),
7267
+ overscan: density === 'compact' ? 30 : 10,
7268
+ parentRef: tableContainerRef,
7269
+ size: rows.length
7269
7270
  }, virtualizerProps)) : {};
7270
- var virtualRows = rowVirtualizer.virtualItems;
7271
- var paddingTop = (virtualRows == null ? void 0 : virtualRows.length) > 0 ? virtualRows[0].start : 0;
7272
- var paddingBottom = (virtualRows == null ? void 0 : virtualRows.length) > 0 ? rowVirtualizer.totalSize - virtualRows[virtualRows.length - 1].end : 0;
7271
+ var virtualRows = enableRowVirtualization ? rowVirtualizer.virtualItems : [];
7272
+ var paddingTop = 0;
7273
+ var paddingBottom = 0;
7274
+
7275
+ if (enableRowVirtualization) {
7276
+ paddingTop = virtualRows.length > 0 ? virtualRows[0].start : 0;
7277
+ paddingBottom = virtualRows.length > 0 ? rowVirtualizer.totalSize - virtualRows[virtualRows.length - 1].end : 0;
7278
+ }
7279
+
7273
7280
  return React__default.createElement(material.TableBody, Object.assign({}, tableBodyProps), enableRowVirtualization && paddingTop > 0 && React__default.createElement("tr", null, React__default.createElement("td", {
7274
7281
  style: {
7275
7282
  height: paddingTop + "px"