@tanstack/react-table 8.0.0-beta.2 → 8.0.0-beta.5

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.
@@ -66,6 +66,7 @@ function useTableInstance(table, options) {
66
66
  onStateChange: () => {},
67
67
  // noop
68
68
  render,
69
+ renderFallbackValue: null,
69
70
  ...options
70
71
  }; // Create a new table instance and store it in state
71
72
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\nexport * from '@tanstack/table-core'\n\nimport {\n createTableInstance,\n TableOptions,\n TableInstance,\n Table,\n TableGenerics,\n createTableFactory,\n Overwrite,\n PartialKeys,\n TableOptionsResolved,\n} from '@tanstack/table-core'\n\nexport type Renderable<TProps> =\n | React.ReactNode\n | React.FunctionComponent<TProps>\n | React.Component<TProps>\n\nexport type Render = <TProps extends {}>(\n Comp: Renderable<TProps>,\n props: TProps\n) => React.ReactNode | JSX.Element\n\nexport type ReactTableGenerics = Overwrite<\n TableGenerics,\n { Renderer: Render; Rendered: ReturnType<Render> }\n>\n\n//\n\nexport const render: Render = (Comp, props) =>\n !Comp ? null : isReactComponent(Comp) ? <Comp {...props} /> : Comp\n\nfunction isReactComponent(component: unknown): component is React.FC {\n return (\n isClassComponent(component) ||\n typeof component === 'function' ||\n isExoticComponent(component)\n )\n}\n\nfunction isClassComponent(component: any) {\n return (\n typeof component === 'function' &&\n (() => {\n const proto = Object.getPrototypeOf(component)\n return proto.prototype && proto.prototype.isReactComponent\n })()\n )\n}\n\nfunction isExoticComponent(component: any) {\n return (\n typeof component === 'object' &&\n typeof component.$$typeof === 'symbol' &&\n ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description)\n )\n}\n\nexport const createTable = createTableFactory({ render })\n\n// const useIsomorphicLayoutEffect =\n// typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect\n\nexport type UseTableInstanceOptions<TGenerics extends ReactTableGenerics> =\n TableOptions<TGenerics>\n\nexport function useTableInstance<TGenerics extends ReactTableGenerics>(\n table: Table<TGenerics>,\n options: UseTableInstanceOptions<TGenerics>\n): TableInstance<TGenerics> {\n // Compose in the generic options to the user options\n const resolvedOptions: TableOptionsResolved<TGenerics> = {\n ...table.options,\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n render,\n ...options,\n }\n\n // Create a new table instance and store it in state\n const [instanceRef] = React.useState(() => ({\n current: createTableInstance<TGenerics>(resolvedOptions),\n }))\n\n // By default, manage table state here using the instance's initial state\n const [state, setState] = React.useState(\n () => instanceRef.current.initialState\n )\n\n // Compose the default state above with any user state. This will allow the user\n // to only control a subset of the state if desired.\n instanceRef.current.setOptions(prev => ({\n ...prev,\n ...options,\n state: {\n ...state,\n ...options.state,\n },\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: updater => {\n setState(updater)\n options.onStateChange?.(updater)\n },\n }))\n\n return instanceRef.current\n}\n"],"names":["render","Comp","props","isReactComponent","React","component","isClassComponent","isExoticComponent","proto","Object","getPrototypeOf","prototype","$$typeof","includes","description","createTable","createTableFactory","useTableInstance","table","options","resolvedOptions","state","onStateChange","instanceRef","useState","current","createTableInstance","setState","initialState","setOptions","prev","updater"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA;AAEO,MAAMA,MAAc,GAAG,CAACC,IAAD,EAAOC,KAAP,KAC5B,CAACD,IAAD,GAAQ,IAAR,GAAeE,gBAAgB,CAACF,IAAD,CAAhB,gBAAyBG,gBAAA,CAAA,aAAA,CAAC,IAAD,EAAUF,KAAV,CAAzB,GAA+CD,KADzD;;AAGP,SAASE,gBAAT,CAA0BE,SAA1B,EAAqE;AACnE,EAAA,OACEC,gBAAgB,CAACD,SAAD,CAAhB,IACA,OAAOA,SAAP,KAAqB,UADrB,IAEAE,iBAAiB,CAACF,SAAD,CAHnB,CAAA;AAKD,CAAA;;AAED,SAASC,gBAAT,CAA0BD,SAA1B,EAA0C;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,CAAoBI,UAApB,CAA+BC,IAAI,KAAK,EACtC,GAAGA,IADmC;AAEtC,IAAA,GAAGX,OAFmC;AAGtCE,IAAAA,KAAK,EAAE,EACL,GAAGA,KADE;AAEL,MAAA,GAAGF,OAAO,CAACE,KAAAA;AAFN,KAH+B;AAOtC;AACA;AACAC,IAAAA,aAAa,EAAES,OAAO,IAAI;AACxBJ,MAAAA,QAAQ,CAACI,OAAD,CAAR,CAAA;AACAZ,MAAAA,OAAO,CAACG,aAAR,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAH,OAAO,CAACG,aAAR,CAAwBS,OAAxB,CAAA,CAAA;AACD,KAAA;AAZqC,GAAL,CAAnC,CAAA,CAAA;AAeA,EAAOR,OAAAA,WAAW,CAACE,OAAnB,CAAA;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\nexport * from '@tanstack/table-core'\n\nimport {\n createTableInstance,\n TableOptions,\n TableInstance,\n Table,\n TableGenerics,\n createTableFactory,\n Overwrite,\n PartialKeys,\n TableOptionsResolved,\n} from '@tanstack/table-core'\n\nexport type Renderable<TProps> =\n | React.ReactNode\n | React.FunctionComponent<TProps>\n | React.Component<TProps>\n\nexport type Render = <TProps extends {}>(\n Comp: Renderable<TProps>,\n props: TProps\n) => React.ReactNode | JSX.Element\n\nexport type ReactTableGenerics = Overwrite<\n TableGenerics,\n { Renderer: Render; Rendered: ReturnType<Render> }\n>\n\n//\n\nexport const render: Render = (Comp, props) =>\n !Comp ? null : isReactComponent(Comp) ? <Comp {...props} /> : Comp\n\nfunction isReactComponent(component: unknown): component is React.FC {\n return (\n isClassComponent(component) ||\n typeof component === 'function' ||\n isExoticComponent(component)\n )\n}\n\nfunction isClassComponent(component: any) {\n return (\n typeof component === 'function' &&\n (() => {\n const proto = Object.getPrototypeOf(component)\n return proto.prototype && proto.prototype.isReactComponent\n })()\n )\n}\n\nfunction isExoticComponent(component: any) {\n return (\n typeof component === 'object' &&\n typeof component.$$typeof === 'symbol' &&\n ['react.memo', 'react.forward_ref'].includes(component.$$typeof.description)\n )\n}\n\nexport const createTable = createTableFactory({ render })\n\n// const useIsomorphicLayoutEffect =\n// typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect\n\nexport type UseTableInstanceOptions<TGenerics extends ReactTableGenerics> =\n TableOptions<TGenerics>\n\nexport function useTableInstance<TGenerics extends ReactTableGenerics>(\n table: Table<TGenerics>,\n options: UseTableInstanceOptions<TGenerics>\n): TableInstance<TGenerics> {\n // Compose in the generic options to the user options\n const resolvedOptions: TableOptionsResolved<TGenerics> = {\n ...table.options,\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n render,\n renderFallbackValue: null,\n ...options,\n }\n\n // Create a new table instance and store it in state\n const [instanceRef] = React.useState(() => ({\n current: createTableInstance<TGenerics>(resolvedOptions),\n }))\n\n // By default, manage table state here using the instance's initial state\n const [state, setState] = React.useState(\n () => instanceRef.current.initialState\n )\n\n // Compose the default state above with any user state. This will allow the user\n // to only control a subset of the state if desired.\n instanceRef.current.setOptions(prev => ({\n ...prev,\n ...options,\n state: {\n ...state,\n ...options.state,\n },\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: updater => {\n setState(updater)\n options.onStateChange?.(updater)\n },\n }))\n\n return instanceRef.current\n}\n"],"names":["render","Comp","props","isReactComponent","React","component","isClassComponent","isExoticComponent","proto","Object","getPrototypeOf","prototype","$$typeof","includes","description","createTable","createTableFactory","useTableInstance","table","options","resolvedOptions","state","onStateChange","renderFallbackValue","instanceRef","useState","current","createTableInstance","setState","initialState","setOptions","prev","updater"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA;AAEO,MAAMA,MAAc,GAAG,CAACC,IAAD,EAAOC,KAAP,KAC5B,CAACD,IAAD,GAAQ,IAAR,GAAeE,gBAAgB,CAACF,IAAD,CA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AACK,WAAD,CAAA,GAAgBpB,gBAAK,CAACqB,QAAN,CAAe,OAAO;AAC1CC,IAAAA,OAAO,EAAEC,yBAAmB,CAAYP,eAAZ,CAAA;AADc,GAAP,CAAf,CAAtB,CAZ0B;;AAiB1B,EAAA,MAAM,CAACC,KAAD,EAAQO,QAAR,CAAA,GAAoBxB,gBAAK,CAACqB,QAAN,CACxB,MAAMD,WAAW,CAACE,OAAZ,CAAoBG,YADF,CAA1B,CAjB0B;AAsB1B;;AACAL,EAAAA,WAAW,CAACE,OAAZ,CAAoBI,UAApB,CAA+BC,IAAI,KAAK,EACtC,GAAGA,IADmC;AAEtC,IAAA,GAAGZ,OAFmC;AAGtCE,IAAAA,KAAK,EAAE,EACL,GAAGA,KADE;AAEL,MAAA,GAAGF,OAAO,CAACE,KAAAA;AAFN,KAH+B;AAOtC;AACA;AACAC,IAAAA,aAAa,EAAEU,OAAO,IAAI;AACxBJ,MAAAA,QAAQ,CAACI,OAAD,CAAR,CAAA;AACAb,MAAAA,OAAO,CAACG,aAAR,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAH,OAAO,CAACG,aAAR,CAAwBU,OAAxB,CAAA,CAAA;AACD,KAAA;AAZqC,GAAL,CAAnC,CAAA,CAAA;AAeA,EAAOR,OAAAA,WAAW,CAACE,OAAnB,CAAA;AACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1108,7 +1108,6 @@ const Filters = {
1108
1108
  },
1109
1109
  createColumn: (column, instance) => {
1110
1110
  return {
1111
- filterFn: column.filterFn,
1112
1111
  getAutoFilterFn: () => {
1113
1112
  const firstRow = instance.getCoreRowModel().flatRows[0];
1114
1113
  const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
@@ -1139,7 +1138,7 @@ const Filters = {
1139
1138
  var _ref;
1140
1139
 
1141
1140
  const userFilterFns = instance.options.filterFns;
1142
- return isFunction(column.filterFn) ? column.filterFn : column.filterFn === 'auto' ? column.getAutoFilterFn() : (_ref = userFilterFns == null ? void 0 : userFilterFns[column.filterFn]) != null ? _ref : filterFns[column.filterFn];
1141
+ return isFunction(column.columnDef.filterFn) ? column.columnDef.filterFn : column.columnDef.filterFn === 'auto' ? column.getAutoFilterFn() : (_ref = userFilterFns == null ? void 0 : userFilterFns[column.columnDef.filterFn]) != null ? _ref : filterFns[column.columnDef.filterFn];
1143
1142
  },
1144
1143
  getCanFilter: () => {
1145
1144
  var _column$columnDef$ena, _instance$options$ena, _instance$options$ena2;
@@ -1428,6 +1427,11 @@ const aggregationFns = {
1428
1427
  const Grouping = {
1429
1428
  getDefaultColumnDef: () => {
1430
1429
  return {
1430
+ aggregatedCell: props => {
1431
+ var _props$getValue$toStr, _props$getValue;
1432
+
1433
+ return (_props$getValue$toStr = (_props$getValue = props.getValue()) == null ? void 0 : _props$getValue.toString == null ? void 0 : _props$getValue.toString()) != null ? _props$getValue$toStr : null;
1434
+ },
1431
1435
  aggregationFn: 'auto'
1432
1436
  };
1433
1437
  },
@@ -1488,8 +1492,6 @@ const Grouping = {
1488
1492
  if (Object.prototype.toString.call(value) === '[object Date]') {
1489
1493
  return aggregationFns.extent;
1490
1494
  }
1491
-
1492
- return aggregationFns.count;
1493
1495
  },
1494
1496
  getAggregationFn: () => {
1495
1497
  var _ref4;
@@ -1500,7 +1502,7 @@ const Grouping = {
1500
1502
  throw new Error();
1501
1503
  }
1502
1504
 
1503
- return isFunction(column.aggregationFn) ? column.aggregationFn : column.aggregationFn === 'auto' ? column.getAutoAggregationFn() : (_ref4 = userAggregationFns == null ? void 0 : userAggregationFns[column.aggregationFn]) != null ? _ref4 : aggregationFns[column.aggregationFn];
1505
+ return isFunction(column.columnDef.aggregationFn) ? column.columnDef.aggregationFn : column.columnDef.aggregationFn === 'auto' ? column.getAutoAggregationFn() : (_ref4 = userAggregationFns == null ? void 0 : userAggregationFns[column.columnDef.aggregationFn]) != null ? _ref4 : aggregationFns[column.columnDef.aggregationFn];
1504
1506
  }
1505
1507
  };
1506
1508
  },
@@ -1533,6 +1535,12 @@ const Grouping = {
1533
1535
  };
1534
1536
  },
1535
1537
  createCell: (cell, column, row, instance) => {
1538
+ const getRenderValue = () => {
1539
+ var _cell$getValue;
1540
+
1541
+ return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : instance.options.renderFallbackValue;
1542
+ };
1543
+
1536
1544
  return {
1537
1545
  getIsGrouped: () => column.getIsGrouped() && column.id === row.groupingColumnId,
1538
1546
  getIsPlaceholder: () => !cell.getIsGrouped() && column.getIsGrouped(),
@@ -1542,15 +1550,19 @@ const Grouping = {
1542
1550
  return !cell.getIsGrouped() && !cell.getIsPlaceholder() && ((_row$subRows = row.subRows) == null ? void 0 : _row$subRows.length) > 1;
1543
1551
  },
1544
1552
  renderAggregatedCell: () => {
1545
- var _column$columnDef$agg;
1553
+ if (process.env.NODE_ENV === 'development') {
1554
+ if (!column.columnDef.aggregatedCell) {
1555
+ console.warn('A columnDef.aggregatedCell template is recommended for displaying aggregated values.');
1556
+ }
1557
+ }
1546
1558
 
1547
- const template = (_column$columnDef$agg = column.columnDef.aggregatedCell) != null ? _column$columnDef$agg : column.columnDef.cell;
1559
+ const template = column.columnDef.aggregatedCell || column.columnDef.cell;
1548
1560
  return template ? instance._render(template, {
1549
1561
  instance,
1550
1562
  column,
1551
1563
  row,
1552
1564
  cell,
1553
- getValue: cell.getValue
1565
+ getValue: getRenderValue
1554
1566
  }) : null;
1555
1567
  }
1556
1568
  };
@@ -2020,11 +2032,11 @@ const RowSelection = {
2020
2032
  });
2021
2033
  },
2022
2034
  toggleAllPageRowsSelected: value => instance.setRowSelection(old => {
2023
- typeof value !== 'undefined' ? value : !instance.getIsAllPageRowsSelected();
2035
+ const resolvedValue = typeof value !== 'undefined' ? value : !instance.getIsAllPageRowsSelected();
2024
2036
  const rowSelection = { ...old
2025
2037
  };
2026
2038
  instance.getRowModel().rows.forEach(row => {
2027
- mutateRowIsSelected(rowSelection, row.id, value, instance);
2039
+ mutateRowIsSelected(rowSelection, row.id, resolvedValue, instance);
2028
2040
  });
2029
2041
  return rowSelection;
2030
2042
  }),
@@ -2179,7 +2191,7 @@ const RowSelection = {
2179
2191
  },
2180
2192
  getIsSomePageRowsSelected: () => {
2181
2193
  const paginationFlatRows = instance.getPaginationRowModel().flatRows;
2182
- return instance.getIsAllPageRowsSelected() ? false : !!(paginationFlatRows != null && paginationFlatRows.length);
2194
+ return instance.getIsAllPageRowsSelected() ? false : paginationFlatRows.some(d => d.getIsSelected() || d.getIsSomeSelected());
2183
2195
  },
2184
2196
  getToggleAllRowsSelectedHandler: () => {
2185
2197
  return e => {
@@ -2533,8 +2545,10 @@ const Sorting = {
2533
2545
  // })
2534
2546
  // return
2535
2547
  // }
2548
+ // this needs to be outside of instance.setSorting to be in sync with rerender
2549
+ const nextSortingOrder = column.getNextSortingOrder();
2536
2550
  instance.setSorting(old => {
2537
- var _ref2, _column$columnDef$sor, _instance$options$ena, _instance$options$ena2;
2551
+ var _instance$options$ena, _instance$options$ena2;
2538
2552
 
2539
2553
  // Find any existing sorting for this column
2540
2554
  const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
@@ -2559,30 +2573,29 @@ const Sorting = {
2559
2573
  } else {
2560
2574
  sortAction = 'replace';
2561
2575
  }
2562
- }
2576
+ } // Handle toggle states that will remove the sorting
2563
2577
 
2564
- const sortDescFirst = (_ref2 = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : instance.options.sortDescFirst) != null ? _ref2 : column.getAutoSortDir() === 'desc'; // Handle toggle states that will remove the sorting
2565
2578
 
2566
2579
  if (sortAction === 'toggle' && ( // Must be toggling
2567
2580
  (_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
2568
2581
  !hasDescDefined && ( // Must not be setting desc
2569
- multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) && ( // If multi, don't allow if enableMultiRemove
2570
- existingSorting != null && existingSorting.desc // Finally, detect if it should indeed be removed
2571
- ? !sortDescFirst : sortDescFirst)) {
2582
+ multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) && // If multi, don't allow if enableMultiRemove
2583
+ !nextSortingOrder // Finally, detect if it should indeed be removed
2584
+ ) {
2572
2585
  sortAction = 'remove';
2573
2586
  }
2574
2587
 
2575
2588
  if (sortAction === 'replace') {
2576
2589
  newSorting = [{
2577
2590
  id: column.id,
2578
- desc: hasDescDefined ? desc : !!sortDescFirst
2591
+ desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
2579
2592
  }];
2580
2593
  } else if (sortAction === 'add' && old != null && old.length) {
2581
2594
  var _instance$options$max;
2582
2595
 
2583
2596
  newSorting = [...old, {
2584
2597
  id: column.id,
2585
- desc: hasDescDefined ? desc : !!sortDescFirst
2598
+ desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
2586
2599
  }]; // Take latest n columns
2587
2600
 
2588
2601
  newSorting.splice(0, newSorting.length - ((_instance$options$max = instance.options.maxMultiSortColCount) != null ? _instance$options$max : Number.MAX_SAFE_INTEGER));
@@ -2591,7 +2604,7 @@ const Sorting = {
2591
2604
  newSorting = old.map(d => {
2592
2605
  if (d.id === column.id) {
2593
2606
  return { ...d,
2594
- desc: hasDescDefined ? desc : !(existingSorting != null && existingSorting.desc)
2607
+ desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
2595
2608
  };
2596
2609
  }
2597
2610
 
@@ -2604,6 +2617,23 @@ const Sorting = {
2604
2617
  return newSorting;
2605
2618
  });
2606
2619
  },
2620
+ getNextSortingOrder: () => {
2621
+ var _ref2, _column$columnDef$sor;
2622
+
2623
+ const sortDescFirst = (_ref2 = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : instance.options.sortDescFirst) != null ? _ref2 : column.getAutoSortDir() === 'desc';
2624
+ const firstSortDirection = sortDescFirst ? 'desc' : 'asc';
2625
+ const isSorted = column.getIsSorted();
2626
+
2627
+ if (!isSorted) {
2628
+ return firstSortDirection;
2629
+ }
2630
+
2631
+ if (isSorted === firstSortDirection) {
2632
+ return isSorted === 'desc' ? 'asc' : 'desc';
2633
+ } else {
2634
+ return false;
2635
+ }
2636
+ },
2607
2637
  getCanSort: () => {
2608
2638
  var _column$columnDef$ena, _instance$options$ena3;
2609
2639
 
@@ -2897,9 +2927,9 @@ function createTableInstance(options) {
2897
2927
  header: props => props.header.column.id,
2898
2928
  footer: props => props.header.column.id,
2899
2929
  cell: props => {
2900
- var _props$getValue$toStr, _props$getValue$toStr2, _props$getValue;
2930
+ var _props$getValue$toStr, _props$getValue;
2901
2931
 
2902
- return (_props$getValue$toStr = (_props$getValue$toStr2 = (_props$getValue = props.getValue()).toString) == null ? void 0 : _props$getValue$toStr2.call(_props$getValue)) != null ? _props$getValue$toStr : null;
2932
+ return (_props$getValue$toStr = (_props$getValue = props.getValue()) == null ? void 0 : _props$getValue.toString == null ? void 0 : _props$getValue.toString()) != null ? _props$getValue$toStr : null;
2903
2933
  },
2904
2934
  ...instance._features.reduce((obj, feature) => {
2905
2935
  return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
@@ -3053,6 +3083,12 @@ function createTable(_, __, options) {
3053
3083
  }
3054
3084
 
3055
3085
  function createCell(instance, row, column, columnId) {
3086
+ const getRenderValue = () => {
3087
+ var _cell$getValue;
3088
+
3089
+ return (_cell$getValue = cell.getValue()) != null ? _cell$getValue : instance.options.renderFallbackValue;
3090
+ };
3091
+
3056
3092
  const cell = {
3057
3093
  id: row.id + "_" + column.id,
3058
3094
  row,
@@ -3064,7 +3100,7 @@ function createCell(instance, row, column, columnId) {
3064
3100
  column,
3065
3101
  row,
3066
3102
  cell: cell,
3067
- getValue: cell.getValue
3103
+ getValue: getRenderValue
3068
3104
  }) : null;
3069
3105
  }
3070
3106
  };
@@ -3670,11 +3706,6 @@ function getGroupedRowModel() {
3670
3706
  if (aggregateFn) {
3671
3707
  row._groupingValuesCache[columnId] = aggregateFn(columnId, leafRows, groupedRows);
3672
3708
  return row._groupingValuesCache[columnId];
3673
- } else if (column.aggregationFn) {
3674
- console.info({
3675
- column
3676
- });
3677
- throw new Error(process.env.NODE_ENV !== 'production' ? "Table: Invalid column.aggregateType option for column listed above" : '');
3678
3709
  }
3679
3710
  }
3680
3711
  });
@@ -3798,20 +3829,34 @@ function getPaginationRowModel(opts) {
3798
3829
  const pageStart = pageSize * pageIndex;
3799
3830
  const pageEnd = pageStart + pageSize;
3800
3831
  rows = rows.slice(pageStart, pageEnd);
3832
+ let paginatedRowModel;
3801
3833
 
3802
3834
  if (!instance.options.paginateExpandedRows) {
3803
- return expandRows({
3835
+ paginatedRowModel = expandRows({
3804
3836
  rows,
3805
3837
  flatRows,
3806
3838
  rowsById
3807
3839
  });
3840
+ } else {
3841
+ paginatedRowModel = {
3842
+ rows,
3843
+ flatRows,
3844
+ rowsById
3845
+ };
3808
3846
  }
3809
3847
 
3810
- return {
3811
- rows,
3812
- flatRows,
3813
- rowsById
3848
+ paginatedRowModel.flatRows = [];
3849
+
3850
+ const handleRow = row => {
3851
+ paginatedRowModel.flatRows.push(row);
3852
+
3853
+ if (row.subRows.length) {
3854
+ row.subRows.forEach(handleRow);
3855
+ }
3814
3856
  };
3857
+
3858
+ paginatedRowModel.rows.forEach(handleRow);
3859
+ return paginatedRowModel;
3815
3860
  }, {
3816
3861
  key: process.env.NODE_ENV === 'development' && 'getPaginationRowModel',
3817
3862
  debug: () => {