@dooherceg/material-react-table 3.2.2-alpha.0 → 3.2.2-alpha.10

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/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
+ import * as _tanstack_react_table from '@tanstack/react-table';
2
+ import { Row, ColumnFiltersState, ColumnOrderState, ColumnPinningState, ColumnSizingInfoState, ColumnSizingState, ExpandedState, GroupingState, PaginationState, RowSelectionState, SortingState, Updater, VisibilityState, AccessorFn, DeepKeys, DeepValue, Table, TableState, Column, Header, HeaderGroup, Cell, AggregationFn, SortingFn, FilterFn, TableOptions, OnChangeFn, ColumnDef, RowData, Renderable, RowPinningPosition } from '@tanstack/react-table';
1
3
  import * as React from 'react';
2
4
  import React__default, { ReactNode, RefObject, Dispatch, SetStateAction, ChangeEvent, MouseEvent, JSX, Ref, ReactElement, DragEventHandler, HTMLAttributes, FormEventHandler } from 'react';
3
5
  import { RegisterOptions, UseFormReturn } from 'react-hook-form';
4
- import * as _tanstack_react_table from '@tanstack/react-table';
5
- import { Row, ColumnFiltersState, ColumnOrderState, ColumnPinningState, ColumnSizingInfoState, ColumnSizingState, ExpandedState, GroupingState, PaginationState, RowSelectionState, SortingState, Updater, VisibilityState, AccessorFn, DeepKeys, DeepValue, Table, TableState, Column, Header, HeaderGroup, Cell, AggregationFn, SortingFn, FilterFn, TableOptions, OnChangeFn, ColumnDef, Renderable, RowPinningPosition } from '@tanstack/react-table';
6
6
  import { VirtualItem, VirtualizerOptions, Virtualizer } from '@tanstack/react-virtual';
7
7
  import { AlertProps } from '@mui/material/Alert';
8
8
  import { AutocompleteProps } from '@mui/material/Autocomplete';
@@ -579,13 +579,6 @@ interface MRT_TableState<TData extends MRT_RowData> extends TableState {
579
579
  rowReorderingSelection: MRT_RowReorderingSelectionState;
580
580
  }
581
581
  interface MRT_ColumnDefBase<TData extends MRT_RowData, TValue = unknown> extends Omit<ColumnDef<TData, TValue>, 'accessorKey' | 'aggregatedCell' | 'aggregationFn' | 'cell' | 'columns' | 'filterFn' | 'footer' | 'header' | 'id' | 'sortingFn'> {
582
- /**
583
- * Either an `accessorKey` or a combination of an `accessorFn` and `id` are required for a data column definition.
584
- * Specify a function here to point to the correct property in the data object.
585
- *
586
- * @example accessorFn: (row) => row.username
587
- */
588
- accessorFn?: (originalRow: TData) => TValue;
589
582
  /**
590
583
  * Either an `accessorKey` or a combination of an `accessorFn` and `id` are required for a data column definition.
591
584
  * Specify which key in the row this column should use to access the correct data.
@@ -594,7 +587,7 @@ interface MRT_ColumnDefBase<TData extends MRT_RowData, TValue = unknown> extends
594
587
  * @example accessorKey: 'username' //simple
595
588
  * @example accessorKey: 'name.firstName' //deep key dot notation
596
589
  */
597
- accessorKey?: DeepKeys<TData> | (string & {});
590
+ accessorKey: DeepKeys<TData> | (string & {});
598
591
  AggregatedCell?: (props: {
599
592
  cell: MRT_Cell<TData, TValue>;
600
593
  column: MRT_Column<TData, TValue>;
@@ -1552,6 +1545,37 @@ interface MRT_FormSectionConfig {
1552
1545
  columns?: number;
1553
1546
  }
1554
1547
 
1548
+ interface IIconColTypeValue {
1549
+ color: string;
1550
+ description: string;
1551
+ iconCode: number;
1552
+ additional?: Record<string, Omit<IIconColTypeValue, 'additional'>>;
1553
+ }
1554
+ type MRT_AvailableIconOption = {
1555
+ iconType: IIconColTypeValue;
1556
+ tooltip: string;
1557
+ value: unknown;
1558
+ };
1559
+ interface MRT_DimensionsDef {
1560
+ fields: string[];
1561
+ tolerance?: {
1562
+ min: number;
1563
+ max: number;
1564
+ };
1565
+ fieldsPerRow?: number;
1566
+ }
1567
+ declare module '@tanstack/react-table' {
1568
+ interface ColumnMeta<TData extends RowData, TValue> {
1569
+ enumValues?: Array<{
1570
+ value: string;
1571
+ label: string;
1572
+ }>;
1573
+ availableIcons?: MRT_AvailableIconOption[];
1574
+ dimensions?: MRT_DimensionsDef;
1575
+ extraFieldFilters?: TData extends MRT_RowData ? MRT_ColumnDef<TData>[] : MRT_ColumnDef<MRT_RowData>[];
1576
+ }
1577
+ }
1578
+
1555
1579
  declare const isCellEditable: <TData extends MRT_RowData>({ cell, table, }: {
1556
1580
  cell: MRT_Cell<TData>;
1557
1581
  table: MRT_TableInstance<TData>;
package/dist/index.esm.js CHANGED
@@ -710,10 +710,7 @@ const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
710
710
  const flexRender = flexRender$1;
711
711
  function createMRTColumnHelper() {
712
712
  return {
713
- accessor: (accessor, column) => {
714
- return typeof accessor === 'function'
715
- ? Object.assign(Object.assign({}, column), { accessorFn: accessor }) : Object.assign(Object.assign({}, column), { accessorKey: accessor });
716
- },
713
+ accessor: (accessor, column) => (Object.assign(Object.assign({}, column), { accessorKey: accessor })),
717
714
  display: (column) => column,
718
715
  group: (column) => column,
719
716
  };
@@ -4263,14 +4260,11 @@ const getFilterableColumns = (table) => {
4263
4260
  // Users define them as regular MRT_ColumnDef (same API), but they are not rendered as a column in the table.
4264
4261
  const virtualColumns = allLeafColumns.flatMap((column) => {
4265
4262
  var _a, _b;
4266
- return ((_b = (_a = column.columnDef.meta) === null || _a === void 0 ? void 0 : _a.extraFieldFilters) !== null && _b !== void 0 ? _b : []).map((extraColumnDef) => {
4267
- var _a;
4268
- return ({
4269
- // accessorKey is the primary identifier; id as fallback
4270
- id: String((_a = extraColumnDef.accessorKey) !== null && _a !== void 0 ? _a : extraColumnDef.field),
4271
- columnDef: Object.assign(Object.assign({}, extraColumnDef), { columnDefType: 'data', enableColumnFilter: true }),
4272
- });
4273
- });
4263
+ return ((_b = (_a = column.columnDef.meta) === null || _a === void 0 ? void 0 : _a.extraFieldFilters) !== null && _b !== void 0 ? _b : []).map((extraColumnDef) => ({
4264
+ // accessorKey is the primary identifier; id as fallback
4265
+ id: getColumnId(extraColumnDef),
4266
+ columnDef: Object.assign(Object.assign({}, extraColumnDef), { columnDefType: 'data', enableColumnFilter: true }),
4267
+ }));
4274
4268
  });
4275
4269
  return [...realFilterableColumns, ...virtualColumns];
4276
4270
  };