@tanstack/table-core 8.10.1 → 8.10.3

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.
Files changed (62) hide show
  1. package/build/lib/columnHelper.js.map +1 -1
  2. package/build/lib/core/cell.d.ts +36 -6
  3. package/build/lib/core/cell.js.map +1 -1
  4. package/build/lib/core/column.d.ts +46 -3
  5. package/build/lib/core/column.js.map +1 -1
  6. package/build/lib/core/headers.d.ts +160 -11
  7. package/build/lib/core/headers.js.map +1 -1
  8. package/build/lib/core/row.d.ts +81 -11
  9. package/build/lib/core/row.js.map +1 -1
  10. package/build/lib/core/table.d.ts +189 -28
  11. package/build/lib/core/table.js.map +1 -1
  12. package/build/lib/features/ColumnSizing.d.ts +140 -20
  13. package/build/lib/features/ColumnSizing.js.map +1 -1
  14. package/build/lib/features/Expanding.d.ts +126 -11
  15. package/build/lib/features/Expanding.js.map +1 -1
  16. package/build/lib/features/Filters.d.ts +225 -23
  17. package/build/lib/features/Filters.js.map +1 -1
  18. package/build/lib/features/Grouping.d.ts +151 -16
  19. package/build/lib/features/Grouping.js.map +1 -1
  20. package/build/lib/features/Ordering.d.ts +17 -2
  21. package/build/lib/features/Ordering.js.map +1 -1
  22. package/build/lib/features/Pagination.d.ts +118 -16
  23. package/build/lib/features/Pagination.js.map +1 -1
  24. package/build/lib/features/Pinning.d.ts +163 -13
  25. package/build/lib/features/Pinning.js.map +1 -1
  26. package/build/lib/features/RowSelection.d.ts +151 -16
  27. package/build/lib/features/RowSelection.js +7 -6
  28. package/build/lib/features/RowSelection.js.map +1 -1
  29. package/build/lib/features/Sorting.d.ts +187 -20
  30. package/build/lib/features/Sorting.js.map +1 -1
  31. package/build/lib/features/Visibility.d.ts +95 -12
  32. package/build/lib/features/Visibility.js.map +1 -1
  33. package/build/lib/filterFns.js.map +1 -1
  34. package/build/lib/index.esm.js +7 -6
  35. package/build/lib/index.esm.js.map +1 -1
  36. package/build/lib/index.mjs +7 -6
  37. package/build/lib/index.mjs.map +1 -1
  38. package/build/lib/utils.js.map +1 -1
  39. package/build/umd/index.development.js +7 -6
  40. package/build/umd/index.development.js.map +1 -1
  41. package/build/umd/index.production.js +1 -1
  42. package/build/umd/index.production.js.map +1 -1
  43. package/package.json +1 -1
  44. package/src/columnHelper.ts +2 -2
  45. package/src/core/cell.ts +36 -6
  46. package/src/core/column.ts +46 -3
  47. package/src/core/headers.ts +160 -11
  48. package/src/core/row.ts +88 -15
  49. package/src/core/table.ts +189 -28
  50. package/src/features/ColumnSizing.ts +143 -20
  51. package/src/features/Expanding.ts +126 -11
  52. package/src/features/Filters.ts +225 -24
  53. package/src/features/Grouping.ts +151 -17
  54. package/src/features/Ordering.ts +17 -2
  55. package/src/features/Pagination.ts +118 -16
  56. package/src/features/Pinning.ts +163 -13
  57. package/src/features/RowSelection.ts +162 -22
  58. package/src/features/Sorting.ts +187 -20
  59. package/src/features/Visibility.ts +98 -12
  60. package/src/filterFns.ts +2 -2
  61. package/src/types.ts +5 -5
  62. package/src/utils.ts +3 -3
@@ -10,42 +10,157 @@ export type AggregationFn<TData extends RowData> = (columnId: string, leafRows:
10
10
  export type CustomAggregationFns = Record<string, AggregationFn<any>>;
11
11
  export type AggregationFnOption<TData extends RowData> = 'auto' | keyof AggregationFns | BuiltInAggregationFn | AggregationFn<TData>;
12
12
  export interface GroupingColumnDef<TData extends RowData, TValue> {
13
- aggregationFn?: AggregationFnOption<TData>;
13
+ /**
14
+ * The cell to display each row for the column if the cell is an aggregate. If a function is passed, it will be passed a props object with the context of the cell and should return the property type for your adapter (the exact type depends on the adapter being used).
15
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#aggregatedcell)
16
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
17
+ */
14
18
  aggregatedCell?: ColumnDefTemplate<ReturnType<Cell<TData, TValue>['getContext']>>;
19
+ /**
20
+ * The resolved aggregation function for the column.
21
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#aggregationfn)
22
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
23
+ */
24
+ aggregationFn?: AggregationFnOption<TData>;
25
+ /**
26
+ * Enables/disables grouping for this column.
27
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#enablegrouping)
28
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
29
+ */
15
30
  enableGrouping?: boolean;
31
+ /**
32
+ * Specify a value to be used for grouping rows on this column. If this option is not specified, the value derived from `accessorKey` / `accessorFn` will be used instead.
33
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getgroupingvalue)
34
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
35
+ */
16
36
  getGroupingValue?: (row: TData) => any;
17
37
  }
18
38
  export interface GroupingColumn<TData extends RowData> {
39
+ /**
40
+ * Returns the aggregation function for the column.
41
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getaggregationfn)
42
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
43
+ */
44
+ getAggregationFn: () => AggregationFn<TData> | undefined;
45
+ /**
46
+ * Returns the automatically inferred aggregation function for the column.
47
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getautoaggregationfn)
48
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
49
+ */
50
+ getAutoAggregationFn: () => AggregationFn<TData> | undefined;
51
+ /**
52
+ * Returns whether or not the column can be grouped.
53
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getcangroup)
54
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
55
+ */
19
56
  getCanGroup: () => boolean;
20
- getIsGrouped: () => boolean;
57
+ /**
58
+ * Returns the index of the column in the grouping state.
59
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getgroupedindex)
60
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
61
+ */
21
62
  getGroupedIndex: () => number;
22
- toggleGrouping: () => void;
63
+ /**
64
+ * Returns whether or not the column is currently grouped.
65
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getisgrouped)
66
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
67
+ */
68
+ getIsGrouped: () => boolean;
69
+ /**
70
+ * Returns a function that toggles the grouping state of the column. This is useful for passing to the `onClick` prop of a button.
71
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#gettogglegroupinghandler)
72
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
73
+ */
23
74
  getToggleGroupingHandler: () => () => void;
24
- getAutoAggregationFn: () => AggregationFn<TData> | undefined;
25
- getAggregationFn: () => AggregationFn<TData> | undefined;
75
+ /**
76
+ * Toggles the grouping state of the column.
77
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#togglegrouping)
78
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
79
+ */
80
+ toggleGrouping: () => void;
26
81
  }
27
82
  export interface GroupingRow {
83
+ _groupingValuesCache: Record<string, any>;
84
+ /**
85
+ * Returns the grouping value for any row and column (including leaf rows).
86
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getgroupingvalue)
87
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
88
+ */
89
+ getGroupingValue: (columnId: string) => unknown;
90
+ /**
91
+ * Returns whether or not the row is currently grouped.
92
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getisgrouped)
93
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
94
+ */
95
+ getIsGrouped: () => boolean;
96
+ /**
97
+ * If this row is grouped, this is the id of the column that this row is grouped by.
98
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#groupingcolumnid)
99
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
100
+ */
28
101
  groupingColumnId?: string;
102
+ /**
103
+ * If this row is grouped, this is the unique/shared value for the `groupingColumnId` for all of the rows in this group.
104
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#groupingvalue)
105
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
106
+ */
29
107
  groupingValue?: unknown;
30
- getIsGrouped: () => boolean;
31
- getGroupingValue: (columnId: string) => unknown;
32
- _groupingValuesCache: Record<string, any>;
33
108
  }
34
109
  export interface GroupingCell {
110
+ /**
111
+ * Returns whether or not the cell is currently aggregated.
112
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getisaggregated)
113
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
114
+ */
115
+ getIsAggregated: () => boolean;
116
+ /**
117
+ * Returns whether or not the cell is currently grouped.
118
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getisgrouped)
119
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
120
+ */
35
121
  getIsGrouped: () => boolean;
122
+ /**
123
+ * Returns whether or not the cell is currently a placeholder cell.
124
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getisplaceholder)
125
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
126
+ */
36
127
  getIsPlaceholder: () => boolean;
37
- getIsAggregated: () => boolean;
38
128
  }
39
129
  export interface ColumnDefaultOptions {
40
- onGroupingChange: OnChangeFn<GroupingState>;
41
130
  enableGrouping: boolean;
131
+ onGroupingChange: OnChangeFn<GroupingState>;
42
132
  }
43
133
  interface GroupingOptionsBase {
44
- manualGrouping?: boolean;
45
- onGroupingChange?: OnChangeFn<GroupingState>;
134
+ /**
135
+ * Enables/disables grouping for the table.
136
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#enablegrouping)
137
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
138
+ */
46
139
  enableGrouping?: boolean;
140
+ /**
141
+ * Returns the row model after grouping has taken place, but no further.
142
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getgroupedrowmodel)
143
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
144
+ */
47
145
  getGroupedRowModel?: (table: Table<any>) => () => RowModel<any>;
146
+ /**
147
+ * Grouping columns are automatically reordered by default to the start of the columns list. If you would rather remove them or leave them as-is, set the appropriate mode here.
148
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#groupedcolumnmode)
149
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
150
+ */
48
151
  groupedColumnMode?: false | 'reorder' | 'remove';
152
+ /**
153
+ * Enables manual grouping. If this option is set to `true`, the table will not automatically group rows using `getGroupedRowModel()` and instead will expect you to manually group the rows before passing them to the table. This is useful if you are doing server-side grouping and aggregation.
154
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#manualgrouping)
155
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
156
+ */
157
+ manualGrouping?: boolean;
158
+ /**
159
+ * If this function is provided, it will be called when the grouping state changes and you will be expected to manage the state yourself. You can pass the managed state back to the table via the `tableOptions.state.grouping` option.
160
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#ongroupingchange)
161
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
162
+ */
163
+ onGroupingChange?: OnChangeFn<GroupingState>;
49
164
  }
50
165
  type ResolvedAggregationFns = keyof AggregationFns extends never ? {
51
166
  aggregationFns?: Record<string, AggregationFn<any>>;
@@ -56,11 +171,31 @@ export interface GroupingOptions extends GroupingOptionsBase, ResolvedAggregatio
56
171
  }
57
172
  export type GroupingColumnMode = false | 'reorder' | 'remove';
58
173
  export interface GroupingInstance<TData extends RowData> {
59
- setGrouping: (updater: Updater<GroupingState>) => void;
60
- resetGrouping: (defaultState?: boolean) => void;
61
- getPreGroupedRowModel: () => RowModel<TData>;
62
- getGroupedRowModel: () => RowModel<TData>;
63
174
  _getGroupedRowModel?: () => RowModel<TData>;
175
+ /**
176
+ * Returns the row model for the table after grouping has been applied.
177
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getgroupedrowmodel)
178
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
179
+ */
180
+ getGroupedRowModel: () => RowModel<TData>;
181
+ /**
182
+ * Returns the row model for the table before any grouping has been applied.
183
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getpregroupedrowmodel)
184
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
185
+ */
186
+ getPreGroupedRowModel: () => RowModel<TData>;
187
+ /**
188
+ * Resets the **grouping** state to `initialState.grouping`, or `true` can be passed to force a default blank state reset to `[]`.
189
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#resetgrouping)
190
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
191
+ */
192
+ resetGrouping: (defaultState?: boolean) => void;
193
+ /**
194
+ * Updates the grouping state of the table via an update function or value.
195
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#setgrouping)
196
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)
197
+ */
198
+ setGrouping: (updater: Updater<GroupingState>) => void;
64
199
  }
65
200
  export declare const Grouping: TableFeature;
66
201
  export declare function orderColumns<TData extends RowData>(leafColumns: Column<TData, unknown>[], grouping: string[], groupedColumnMode?: GroupingColumnMode): Column<TData, unknown>[];
@@ -1 +1 @@
1
- {"version":3,"file":"Grouping.js","sources":["../../../src/features/Grouping.ts"],"sourcesContent":["import { RowModel } from '..'\nimport { BuiltInAggregationFn, aggregationFns } from '../aggregationFns'\nimport { TableFeature } from '../core/table'\nimport {\n Cell,\n Column,\n OnChangeFn,\n Table,\n Row,\n Updater,\n ColumnDefTemplate,\n RowData,\n AggregationFns,\n} from '../types'\nimport { isFunction, makeStateUpdater } from '../utils'\n\nexport type GroupingState = string[]\n\nexport interface GroupingTableState {\n grouping: GroupingState\n}\n\nexport type AggregationFn<TData extends RowData> = (\n columnId: string,\n leafRows: Row<TData>[],\n childRows: Row<TData>[]\n) => any\n\nexport type CustomAggregationFns = Record<string, AggregationFn<any>>\n\nexport type AggregationFnOption<TData extends RowData> =\n | 'auto'\n | keyof AggregationFns\n | BuiltInAggregationFn\n | AggregationFn<TData>\n\nexport interface GroupingColumnDef<TData extends RowData, TValue> {\n aggregationFn?: AggregationFnOption<TData>\n aggregatedCell?: ColumnDefTemplate<\n ReturnType<Cell<TData, TValue>['getContext']>\n >\n enableGrouping?: boolean\n getGroupingValue?: (row: TData) => any\n}\n\nexport interface GroupingColumn<TData extends RowData> {\n getCanGroup: () => boolean\n getIsGrouped: () => boolean\n getGroupedIndex: () => number\n toggleGrouping: () => void\n getToggleGroupingHandler: () => () => void\n getAutoAggregationFn: () => AggregationFn<TData> | undefined\n getAggregationFn: () => AggregationFn<TData> | undefined\n}\n\nexport interface GroupingRow {\n groupingColumnId?: string\n groupingValue?: unknown\n getIsGrouped: () => boolean\n getGroupingValue: (columnId: string) => unknown\n _groupingValuesCache: Record<string, any>\n}\n\nexport interface GroupingCell {\n getIsGrouped: () => boolean\n getIsPlaceholder: () => boolean\n getIsAggregated: () => boolean\n}\n\nexport interface ColumnDefaultOptions {\n // Column\n onGroupingChange: OnChangeFn<GroupingState>\n enableGrouping: boolean\n}\n\ninterface GroupingOptionsBase {\n manualGrouping?: boolean\n onGroupingChange?: OnChangeFn<GroupingState>\n enableGrouping?: boolean\n getGroupedRowModel?: (table: Table<any>) => () => RowModel<any>\n groupedColumnMode?: false | 'reorder' | 'remove'\n}\n\ntype ResolvedAggregationFns = keyof AggregationFns extends never\n ? {\n aggregationFns?: Record<string, AggregationFn<any>>\n }\n : {\n aggregationFns: Record<keyof AggregationFns, AggregationFn<any>>\n }\n\nexport interface GroupingOptions\n extends GroupingOptionsBase,\n ResolvedAggregationFns {}\n\nexport type GroupingColumnMode = false | 'reorder' | 'remove'\n\nexport interface GroupingInstance<TData extends RowData> {\n setGrouping: (updater: Updater<GroupingState>) => void\n resetGrouping: (defaultState?: boolean) => void\n getPreGroupedRowModel: () => RowModel<TData>\n getGroupedRowModel: () => RowModel<TData>\n _getGroupedRowModel?: () => RowModel<TData>\n}\n\n//\n\nexport const Grouping: TableFeature = {\n getDefaultColumnDef: <TData extends RowData>(): GroupingColumnDef<\n TData,\n unknown\n > => {\n return {\n aggregatedCell: props => (props.getValue() as any)?.toString?.() ?? null,\n aggregationFn: 'auto',\n }\n },\n\n getInitialState: (state): GroupingTableState => {\n return {\n grouping: [],\n ...state,\n }\n },\n\n getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): GroupingOptions => {\n return {\n onGroupingChange: makeStateUpdater('grouping', table),\n groupedColumnMode: 'reorder',\n }\n },\n\n createColumn: <TData extends RowData, TValue>(\n column: Column<TData, TValue>,\n table: Table<TData>\n ): void => {\n column.toggleGrouping = () => {\n table.setGrouping(old => {\n // Find any existing grouping for this column\n if (old?.includes(column.id)) {\n return old.filter(d => d !== column.id)\n }\n\n return [...(old ?? []), column.id]\n })\n }\n\n column.getCanGroup = () => {\n return (\n column.columnDef.enableGrouping ??\n true ??\n table.options.enableGrouping ??\n true ??\n !!column.accessorFn\n )\n }\n\n column.getIsGrouped = () => {\n return table.getState().grouping?.includes(column.id)\n }\n\n column.getGroupedIndex = () => table.getState().grouping?.indexOf(column.id)\n\n column.getToggleGroupingHandler = () => {\n const canGroup = column.getCanGroup()\n\n return () => {\n if (!canGroup) return\n column.toggleGrouping()\n }\n }\n column.getAutoAggregationFn = () => {\n const firstRow = table.getCoreRowModel().flatRows[0]\n\n const value = firstRow?.getValue(column.id)\n\n if (typeof value === 'number') {\n return aggregationFns.sum\n }\n\n if (Object.prototype.toString.call(value) === '[object Date]') {\n return aggregationFns.extent\n }\n }\n column.getAggregationFn = () => {\n if (!column) {\n throw new Error()\n }\n\n return isFunction(column.columnDef.aggregationFn)\n ? column.columnDef.aggregationFn\n : column.columnDef.aggregationFn === 'auto'\n ? column.getAutoAggregationFn()\n : table.options.aggregationFns?.[\n column.columnDef.aggregationFn as string\n ] ??\n aggregationFns[column.columnDef.aggregationFn as BuiltInAggregationFn]\n }\n },\n\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n table.setGrouping = updater => table.options.onGroupingChange?.(updater)\n\n table.resetGrouping = defaultState => {\n table.setGrouping(defaultState ? [] : table.initialState?.grouping ?? [])\n }\n\n table.getPreGroupedRowModel = () => table.getFilteredRowModel()\n table.getGroupedRowModel = () => {\n if (!table._getGroupedRowModel && table.options.getGroupedRowModel) {\n table._getGroupedRowModel = table.options.getGroupedRowModel(table)\n }\n\n if (table.options.manualGrouping || !table._getGroupedRowModel) {\n return table.getPreGroupedRowModel()\n }\n\n return table._getGroupedRowModel()\n }\n },\n\n createRow: <TData extends RowData>(\n row: Row<TData>,\n table: Table<TData>\n ): void => {\n row.getIsGrouped = () => !!row.groupingColumnId\n row.getGroupingValue = columnId => {\n if (row._groupingValuesCache.hasOwnProperty(columnId)) {\n return row._groupingValuesCache[columnId]\n }\n\n const column = table.getColumn(columnId)\n\n if (!column?.columnDef.getGroupingValue) {\n return row.getValue(columnId)\n }\n\n row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(\n row.original\n )\n\n return row._groupingValuesCache[columnId]\n }\n row._groupingValuesCache = {}\n },\n\n createCell: <TData extends RowData, TValue>(\n cell: Cell<TData, TValue>,\n column: Column<TData, TValue>,\n row: Row<TData>,\n table: Table<TData>\n ): void => {\n const getRenderValue = () =>\n cell.getValue() ?? table.options.renderFallbackValue\n\n cell.getIsGrouped = () =>\n column.getIsGrouped() && column.id === row.groupingColumnId\n cell.getIsPlaceholder = () => !cell.getIsGrouped() && column.getIsGrouped()\n cell.getIsAggregated = () =>\n !cell.getIsGrouped() && !cell.getIsPlaceholder() && !!row.subRows?.length\n },\n}\n\nexport function orderColumns<TData extends RowData>(\n leafColumns: Column<TData, unknown>[],\n grouping: string[],\n groupedColumnMode?: GroupingColumnMode\n) {\n if (!grouping?.length || !groupedColumnMode) {\n return leafColumns\n }\n\n const nonGroupingColumns = leafColumns.filter(\n col => !grouping.includes(col.id)\n )\n\n if (groupedColumnMode === 'remove') {\n return nonGroupingColumns\n }\n\n const groupingColumns = grouping\n .map(g => leafColumns.find(col => col.id === g)!)\n .filter(Boolean)\n\n return [...groupingColumns, ...nonGroupingColumns]\n}\n"],"names":["Grouping","getDefaultColumnDef","aggregatedCell","props","_toString","_props$getValue","getValue","toString","aggregationFn","getInitialState","state","grouping","getDefaultOptions","table","onGroupingChange","makeStateUpdater","groupedColumnMode","createColumn","column","toggleGrouping","setGrouping","old","includes","id","filter","d","getCanGroup","_ref","_ref2","_ref3","_column$columnDef$ena","columnDef","enableGrouping","options","accessorFn","getIsGrouped","_table$getState$group","getState","getGroupedIndex","_table$getState$group2","indexOf","getToggleGroupingHandler","canGroup","getAutoAggregationFn","firstRow","getCoreRowModel","flatRows","value","aggregationFns","sum","Object","prototype","call","extent","getAggregationFn","_table$options$aggreg","_table$options$aggreg2","Error","isFunction","createTable","updater","resetGrouping","defaultState","_table$initialState$g","_table$initialState","initialState","getPreGroupedRowModel","getFilteredRowModel","getGroupedRowModel","_getGroupedRowModel","manualGrouping","createRow","row","groupingColumnId","getGroupingValue","columnId","_groupingValuesCache","hasOwnProperty","getColumn","original","createCell","cell","getIsPlaceholder","getIsAggregated","_row$subRows","subRows","length","orderColumns","leafColumns","nonGroupingColumns","col","groupingColumns","map","g","find","Boolean"],"mappings":";;;;;;;;;;;;;;;;;AAyGA;;AAEO,MAAMA,QAAsB,GAAG;EACpCC,mBAAmB,EAAEA,MAGhB;IACH,OAAO;AACLC,MAAAA,cAAc,EAAEC,KAAK,IAAA;QAAA,IAAAC,SAAA,EAAAC,eAAA,CAAA;QAAA,OAAAD,CAAAA,SAAA,IAAAC,eAAA,GAAKF,KAAK,CAACG,QAAQ,EAAE,KAAjBD,IAAAA,IAAAA,eAAA,CAA2BE,QAAQ,IAAA,IAAA,GAAA,KAAA,CAAA,GAAnCF,eAAA,CAA2BE,QAAQ,EAAI,KAAA,IAAA,GA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CAC3CkE,GAAG,IAAI,CAAC/E,QAAQ,CAACW,QAAQ,CAACoE,GAAG,CAACnE,EAAE,CAClC,CAAC,CAAA;EAED,IAAIP,iBAAiB,KAAK,QAAQ,EAAE;AAClC,IAAA,OAAOyE,kBAAkB,CAAA;AAC3B,GAAA;EAEA,MAAME,eAAe,GAAGhF,QAAQ,CAC7BiF,GAAG,CAACC,CAAC,IAAIL,WAAW,CAACM,IAAI,CAACJ,GAAG,IAAIA,GAAG,CAACnE,EAAE,KAAKsE,CAAC,CAAE,CAAC,CAChDrE,MAAM,CAACuE,OAAO,CAAC,CAAA;AAElB,EAAA,OAAO,CAAC,GAAGJ,eAAe,EAAE,GAAGF,kBAAkB,CAAC,CAAA;AACpD;;;;;"}
1
+ {"version":3,"file":"Grouping.js","sources":["../../../src/features/Grouping.ts"],"sourcesContent":["import { RowModel } from '..'\nimport { BuiltInAggregationFn, aggregationFns } from '../aggregationFns'\nimport { TableFeature } from '../core/table'\nimport {\n Cell,\n Column,\n OnChangeFn,\n Table,\n Row,\n Updater,\n ColumnDefTemplate,\n RowData,\n AggregationFns,\n} from '../types'\nimport { isFunction, makeStateUpdater } from '../utils'\n\nexport type GroupingState = string[]\n\nexport interface GroupingTableState {\n grouping: GroupingState\n}\n\nexport type AggregationFn<TData extends RowData> = (\n columnId: string,\n leafRows: Row<TData>[],\n childRows: Row<TData>[]\n) => any\n\nexport type CustomAggregationFns = Record<string, AggregationFn<any>>\n\nexport type AggregationFnOption<TData extends RowData> =\n | 'auto'\n | keyof AggregationFns\n | BuiltInAggregationFn\n | AggregationFn<TData>\n\nexport interface GroupingColumnDef<TData extends RowData, TValue> {\n /**\n * The cell to display each row for the column if the cell is an aggregate. If a function is passed, it will be passed a props object with the context of the cell and should return the property type for your adapter (the exact type depends on the adapter being used).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#aggregatedcell)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n aggregatedCell?: ColumnDefTemplate<\n ReturnType<Cell<TData, TValue>['getContext']>\n >\n /**\n * The resolved aggregation function for the column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#aggregationfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n aggregationFn?: AggregationFnOption<TData>\n /**\n * Enables/disables grouping for this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#enablegrouping)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n enableGrouping?: boolean\n /**\n * Specify a value to be used for grouping rows on this column. If this option is not specified, the value derived from `accessorKey` / `accessorFn` will be used instead.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getgroupingvalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n getGroupingValue?: (row: TData) => any\n}\n\nexport interface GroupingColumn<TData extends RowData> {\n /**\n * Returns the aggregation function for the column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getaggregationfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n getAggregationFn: () => AggregationFn<TData> | undefined\n /**\n * Returns the automatically inferred aggregation function for the column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getautoaggregationfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n getAutoAggregationFn: () => AggregationFn<TData> | undefined\n /**\n * Returns whether or not the column can be grouped.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getcangroup)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n getCanGroup: () => boolean\n /**\n * Returns the index of the column in the grouping state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getgroupedindex)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n getGroupedIndex: () => number\n /**\n * Returns whether or not the column is currently grouped.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getisgrouped)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n getIsGrouped: () => boolean\n /**\n * Returns a function that toggles the grouping state of the column. This is useful for passing to the `onClick` prop of a button.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#gettogglegroupinghandler)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n getToggleGroupingHandler: () => () => void\n /**\n * Toggles the grouping state of the column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#togglegrouping)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n toggleGrouping: () => void\n}\n\nexport interface GroupingRow {\n _groupingValuesCache: Record<string, any>\n /**\n * Returns the grouping value for any row and column (including leaf rows).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getgroupingvalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n getGroupingValue: (columnId: string) => unknown\n /**\n * Returns whether or not the row is currently grouped.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getisgrouped)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n getIsGrouped: () => boolean\n /**\n * If this row is grouped, this is the id of the column that this row is grouped by.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#groupingcolumnid)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n groupingColumnId?: string\n /**\n * If this row is grouped, this is the unique/shared value for the `groupingColumnId` for all of the rows in this group.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#groupingvalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n groupingValue?: unknown\n}\n\nexport interface GroupingCell {\n /**\n * Returns whether or not the cell is currently aggregated.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getisaggregated)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n getIsAggregated: () => boolean\n /**\n * Returns whether or not the cell is currently grouped.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getisgrouped)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n getIsGrouped: () => boolean\n /**\n * Returns whether or not the cell is currently a placeholder cell.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getisplaceholder)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n getIsPlaceholder: () => boolean\n}\n\nexport interface ColumnDefaultOptions {\n enableGrouping: boolean\n onGroupingChange: OnChangeFn<GroupingState>\n}\n\ninterface GroupingOptionsBase {\n /**\n * Enables/disables grouping for the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#enablegrouping)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n enableGrouping?: boolean\n /**\n * Returns the row model after grouping has taken place, but no further.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getgroupedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n getGroupedRowModel?: (table: Table<any>) => () => RowModel<any>\n /**\n * Grouping columns are automatically reordered by default to the start of the columns list. If you would rather remove them or leave them as-is, set the appropriate mode here.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#groupedcolumnmode)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n groupedColumnMode?: false | 'reorder' | 'remove'\n /**\n * Enables manual grouping. If this option is set to `true`, the table will not automatically group rows using `getGroupedRowModel()` and instead will expect you to manually group the rows before passing them to the table. This is useful if you are doing server-side grouping and aggregation.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#manualgrouping)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n manualGrouping?: boolean\n /**\n * If this function is provided, it will be called when the grouping state changes and you will be expected to manage the state yourself. You can pass the managed state back to the table via the `tableOptions.state.grouping` option.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#ongroupingchange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n onGroupingChange?: OnChangeFn<GroupingState>\n}\n\ntype ResolvedAggregationFns = keyof AggregationFns extends never\n ? {\n aggregationFns?: Record<string, AggregationFn<any>>\n }\n : {\n aggregationFns: Record<keyof AggregationFns, AggregationFn<any>>\n }\n\nexport interface GroupingOptions\n extends GroupingOptionsBase,\n ResolvedAggregationFns {}\n\nexport type GroupingColumnMode = false | 'reorder' | 'remove'\n\nexport interface GroupingInstance<TData extends RowData> {\n _getGroupedRowModel?: () => RowModel<TData>\n /**\n * Returns the row model for the table after grouping has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getgroupedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n getGroupedRowModel: () => RowModel<TData>\n /**\n * Returns the row model for the table before any grouping has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#getpregroupedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n getPreGroupedRowModel: () => RowModel<TData>\n /**\n * Resets the **grouping** state to `initialState.grouping`, or `true` can be passed to force a default blank state reset to `[]`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#resetgrouping)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n resetGrouping: (defaultState?: boolean) => void\n /**\n * Updates the grouping state of the table via an update function or value.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/grouping#setgrouping)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/grouping)\n */\n setGrouping: (updater: Updater<GroupingState>) => void\n}\n\n//\n\nexport const Grouping: TableFeature = {\n getDefaultColumnDef: <TData extends RowData>(): GroupingColumnDef<\n TData,\n unknown\n > => {\n return {\n aggregatedCell: props => (props.getValue() as any)?.toString?.() ?? null,\n aggregationFn: 'auto',\n }\n },\n\n getInitialState: (state): GroupingTableState => {\n return {\n grouping: [],\n ...state,\n }\n },\n\n getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): GroupingOptions => {\n return {\n onGroupingChange: makeStateUpdater('grouping', table),\n groupedColumnMode: 'reorder',\n }\n },\n\n createColumn: <TData extends RowData, TValue>(\n column: Column<TData, TValue>,\n table: Table<TData>\n ): void => {\n column.toggleGrouping = () => {\n table.setGrouping(old => {\n // Find any existing grouping for this column\n if (old?.includes(column.id)) {\n return old.filter(d => d !== column.id)\n }\n\n return [...(old ?? []), column.id]\n })\n }\n\n column.getCanGroup = () => {\n return (\n column.columnDef.enableGrouping ??\n true ??\n table.options.enableGrouping ??\n true ??\n !!column.accessorFn\n )\n }\n\n column.getIsGrouped = () => {\n return table.getState().grouping?.includes(column.id)\n }\n\n column.getGroupedIndex = () => table.getState().grouping?.indexOf(column.id)\n\n column.getToggleGroupingHandler = () => {\n const canGroup = column.getCanGroup()\n\n return () => {\n if (!canGroup) return\n column.toggleGrouping()\n }\n }\n column.getAutoAggregationFn = () => {\n const firstRow = table.getCoreRowModel().flatRows[0]\n\n const value = firstRow?.getValue(column.id)\n\n if (typeof value === 'number') {\n return aggregationFns.sum\n }\n\n if (Object.prototype.toString.call(value) === '[object Date]') {\n return aggregationFns.extent\n }\n }\n column.getAggregationFn = () => {\n if (!column) {\n throw new Error()\n }\n\n return isFunction(column.columnDef.aggregationFn)\n ? column.columnDef.aggregationFn\n : column.columnDef.aggregationFn === 'auto'\n ? column.getAutoAggregationFn()\n : table.options.aggregationFns?.[\n column.columnDef.aggregationFn as string\n ] ??\n aggregationFns[column.columnDef.aggregationFn as BuiltInAggregationFn]\n }\n },\n\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n table.setGrouping = updater => table.options.onGroupingChange?.(updater)\n\n table.resetGrouping = defaultState => {\n table.setGrouping(defaultState ? [] : table.initialState?.grouping ?? [])\n }\n\n table.getPreGroupedRowModel = () => table.getFilteredRowModel()\n table.getGroupedRowModel = () => {\n if (!table._getGroupedRowModel && table.options.getGroupedRowModel) {\n table._getGroupedRowModel = table.options.getGroupedRowModel(table)\n }\n\n if (table.options.manualGrouping || !table._getGroupedRowModel) {\n return table.getPreGroupedRowModel()\n }\n\n return table._getGroupedRowModel()\n }\n },\n\n createRow: <TData extends RowData>(\n row: Row<TData>,\n table: Table<TData>\n ): void => {\n row.getIsGrouped = () => !!row.groupingColumnId\n row.getGroupingValue = columnId => {\n if (row._groupingValuesCache.hasOwnProperty(columnId)) {\n return row._groupingValuesCache[columnId]\n }\n\n const column = table.getColumn(columnId)\n\n if (!column?.columnDef.getGroupingValue) {\n return row.getValue(columnId)\n }\n\n row._groupingValuesCache[columnId] = column.columnDef.getGroupingValue(\n row.original\n )\n\n return row._groupingValuesCache[columnId]\n }\n row._groupingValuesCache = {}\n },\n\n createCell: <TData extends RowData, TValue>(\n cell: Cell<TData, TValue>,\n column: Column<TData, TValue>,\n row: Row<TData>,\n table: Table<TData>\n ): void => {\n const getRenderValue = () =>\n cell.getValue() ?? table.options.renderFallbackValue\n\n cell.getIsGrouped = () =>\n column.getIsGrouped() && column.id === row.groupingColumnId\n cell.getIsPlaceholder = () => !cell.getIsGrouped() && column.getIsGrouped()\n cell.getIsAggregated = () =>\n !cell.getIsGrouped() && !cell.getIsPlaceholder() && !!row.subRows?.length\n },\n}\n\nexport function orderColumns<TData extends RowData>(\n leafColumns: Column<TData, unknown>[],\n grouping: string[],\n groupedColumnMode?: GroupingColumnMode\n) {\n if (!grouping?.length || !groupedColumnMode) {\n return leafColumns\n }\n\n const nonGroupingColumns = leafColumns.filter(\n col => !grouping.includes(col.id)\n )\n\n if (groupedColumnMode === 'remove') {\n return nonGroupingColumns\n }\n\n const groupingColumns = grouping\n .map(g => leafColumns.find(col => col.id === g)!)\n .filter(Boolean)\n\n return [...groupingColumns, ...nonGroupingColumns]\n}\n"],"names":["Grouping","getDefaultColumnDef","aggregatedCell","props","_toString","_props$getValue","getValue","toString","aggregationFn","getInitialState","state","grouping","getDefaultOptions","table","onGroupingChange","makeStateUpdater","groupedColumnMode","createColumn","column","toggleGrouping","setGrouping","old","includes","id","filter","d","getCanGroup","_ref","_ref2","_ref3","_column$columnDef$ena","columnDef","enableGrouping","options","accessorFn","getIsGrouped","_table$getState$group","getState","getGroupedIndex","_table$getState$group2","indexOf","getToggleGroupingHandler","canGroup","getAutoAggregationFn","firstRow","getCoreRowModel","flatRows","value","aggregationFns","sum","Object","prototype","call","extent","getAggregationFn","_table$options$aggreg","_table$options$aggreg2","Error","isFunction","createTable","updater","resetGrouping","defaultState","_table$initialState$g","_table$initialState","initialState","getPreGroupedRowModel","getFilteredRowModel","getGroupedRowModel","_getGroupedRowModel","manualGrouping","createRow","row","groupingColumnId","getGroupingValue","columnId","_groupingValuesCache","hasOwnProperty","getColumn","original","createCell","cell","getIsPlaceholder","getIsAggregated","_row$subRows","subRows","length","orderColumns","leafColumns","nonGroupingColumns","col","groupingColumns","map","g","find","Boolean"],"mappings":";;;;;;;;;;;;;;;;;AA+OA;;AAEO,MAAMA,QAAsB,GAAG;EACpCC,mBAAmB,EAAEA,MAGhB;IACH,OAAO;AACLC,MAAAA,cAAc,EAAEC,KAAK,IAAA;QAAA,IAAAC,SAAA,EAAAC,eAAA,CAAA;QAAA,OAAAD,CAAAA,SAAA,IAAAC,eAAA,GAAKF,KAAK,CAACG,QAAQ,EAAE,KAAjBD,IAAAA,IAAAA,eAAA,CAA2BE,QAAQ,IAAA,IAAA,GAAA,KAAA,CAAA,GAAnCF,eAAA,CAA2BE,QAAQ,EAAI,KAAA,IAAA,GAAAH,SAAA,GAAI,IAAI,CAAA;AAAA,OAAA;AACxEI,MAAAA,aAAa,EAAE,MAAA;KAChB,CAAA;GACF;EAEDC,eAAe,EAAGC,KAAK,IAAyB;IAC9C,OAAO;AACLC,MAAAA,QAAQ,EAAE,EAAE;MACZ,GAAGD,KAAAA;KACJ,CAAA;GACF;EAEDE,iBAAiB,EACfC,KAAmB,IACC;IACpB,OAAO;AACLC,MAAAA,gBAAgB,EAAEC,sBAAgB,CAAC,UAAU,EAAEF,KAAK,CAAC;AAC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CAAE,CAAC,CAChDrE,MAAM,CAACuE,OAAO,CAAC,CAAA;AAElB,EAAA,OAAO,CAAC,GAAGJ,eAAe,EAAE,GAAGF,kBAAkB,CAAC,CAAA;AACpD;;;;;"}
@@ -5,14 +5,29 @@ export interface ColumnOrderTableState {
5
5
  }
6
6
  export type ColumnOrderState = string[];
7
7
  export interface ColumnOrderOptions {
8
+ /**
9
+ * If provided, this function will be called with an `updaterFn` when `state.columnOrder` changes. This overrides the default internal state management, so you will need to persist the state change either fully or partially outside of the table.
10
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-ordering#oncolumnorderchange)
11
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-ordering)
12
+ */
8
13
  onColumnOrderChange?: OnChangeFn<ColumnOrderState>;
9
14
  }
10
15
  export interface ColumnOrderDefaultOptions {
11
16
  onColumnOrderChange: OnChangeFn<ColumnOrderState>;
12
17
  }
13
18
  export interface ColumnOrderInstance<TData extends RowData> {
14
- setColumnOrder: (updater: Updater<ColumnOrderState>) => void;
15
- resetColumnOrder: (defaultState?: boolean) => void;
16
19
  _getOrderColumnsFn: () => (columns: Column<TData, unknown>[]) => Column<TData, unknown>[];
20
+ /**
21
+ * Resets the **columnOrder** state to `initialState.columnOrder`, or `true` can be passed to force a default blank state reset to `[]`.
22
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-ordering#resetcolumnorder)
23
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-ordering)
24
+ */
25
+ resetColumnOrder: (defaultState?: boolean) => void;
26
+ /**
27
+ * Sets or updates the `state.columnOrder` state.
28
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-ordering#setcolumnorder)
29
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-ordering)
30
+ */
31
+ setColumnOrder: (updater: Updater<ColumnOrderState>) => void;
17
32
  }
18
33
  export declare const Ordering: TableFeature;
@@ -1 +1 @@
1
- {"version":3,"file":"Ordering.js","sources":["../../../src/features/Ordering.ts"],"sourcesContent":["import { makeStateUpdater, memo } from '../utils'\n\nimport { Table, OnChangeFn, Updater, Column, RowData } from '../types'\n\nimport { orderColumns } from './Grouping'\nimport { TableFeature } from '../core/table'\n\nexport interface ColumnOrderTableState {\n columnOrder: ColumnOrderState\n}\n\nexport type ColumnOrderState = string[]\n\nexport interface ColumnOrderOptions {\n onColumnOrderChange?: OnChangeFn<ColumnOrderState>\n}\n\nexport interface ColumnOrderDefaultOptions {\n onColumnOrderChange: OnChangeFn<ColumnOrderState>\n}\n\nexport interface ColumnOrderInstance<TData extends RowData> {\n setColumnOrder: (updater: Updater<ColumnOrderState>) => void\n resetColumnOrder: (defaultState?: boolean) => void\n _getOrderColumnsFn: () => (\n columns: Column<TData, unknown>[]\n ) => Column<TData, unknown>[]\n}\n\n//\n\nexport const Ordering: TableFeature = {\n getInitialState: (state): ColumnOrderTableState => {\n return {\n columnOrder: [],\n ...state,\n }\n },\n\n getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): ColumnOrderDefaultOptions => {\n return {\n onColumnOrderChange: makeStateUpdater('columnOrder', table),\n }\n },\n\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n table.setColumnOrder = updater =>\n table.options.onColumnOrderChange?.(updater)\n table.resetColumnOrder = defaultState => {\n table.setColumnOrder(\n defaultState ? [] : table.initialState.columnOrder ?? []\n )\n }\n table._getOrderColumnsFn = memo(\n () => [\n table.getState().columnOrder,\n table.getState().grouping,\n table.options.groupedColumnMode,\n ],\n (columnOrder, grouping, groupedColumnMode) => columns => {\n // Sort grouped columns to the start of the column list\n // before the headers are built\n let orderedColumns: Column<TData, unknown>[] = []\n\n // If there is no order, return the normal columns\n if (!columnOrder?.length) {\n orderedColumns = columns\n } else {\n const columnOrderCopy = [...columnOrder]\n\n // If there is an order, make a copy of the columns\n const columnsCopy = [...columns]\n\n // And make a new ordered array of the columns\n\n // Loop over the columns and place them in order into the new array\n while (columnsCopy.length && columnOrderCopy.length) {\n const targetColumnId = columnOrderCopy.shift()\n const foundIndex = columnsCopy.findIndex(\n d => d.id === targetColumnId\n )\n if (foundIndex > -1) {\n orderedColumns.push(columnsCopy.splice(foundIndex, 1)[0]!)\n }\n }\n\n // If there are any columns left, add them to the end\n orderedColumns = [...orderedColumns, ...columnsCopy]\n }\n\n return orderColumns(orderedColumns, grouping, groupedColumnMode)\n },\n {\n key: process.env.NODE_ENV === 'development' && 'getOrderColumnsFn',\n // debug: () => table.options.debugAll ?? table.options.debugTable,\n }\n )\n },\n}\n"],"names":["Ordering","getInitialState","state","columnOrder","getDefaultOptions","table","onColumnOrderChange","makeStateUpdater","createTable","setColumnOrder","updater","options","resetColumnOrder","defaultState","_table$initialState$c","initialState","_getOrderColumnsFn","memo","getState","grouping","groupedColumnMode","columns","orderedColumns","length","columnOrderCopy","columnsCopy","targetColumnId","shift","foundIndex","findIndex","d","id","push","splice","orderColumns","key","process","env","NODE_ENV"],"mappings":";;;;;;;;;;;;;;;;;AA6BA;;AAEO,MAAMA,QAAsB,GAAG;EACpCC,eAAe,EAAGC,KAAK,IAA4B;IACjD,OAAO;AACLC,MAAAA,WAAW,EAAE,EAAE;MACf,GAAGD,KAAAA;KACJ,CAAA;GACF;EAEDE,iBAAiB,EACfC,KAAmB,IACW;IAC9B,OAAO;AACLC,MAAAA,mBAAmB,EAAEC,sBAAgB,CAAC,aAAa,EAAEF,KAAK,CAAA;KAC3D,CAAA;GACF;EAEDG,WAAW,EAA0BH,KAAmB,IAAW;AACjEA,IAAAA,KAAK,CAACI,cAAc,GAAGC,OAAO,IAC5BL,KAAK,CAACM,OAAO,CAACL,mBAAmB,IAAA,IAAA,GAAA,KAAA,CAAA,GAAjCD,KAAK,CAACM,OAAO,CAACL,mBAAmB,CAAGI,OAAO,CAAC,CAAA;AAC9CL,IAAAA,KAAK,CAACO,gBAAgB,GAAGC,YAAY,IAAI;AAAA,MAAA,IAAAC,qBAAA,CAAA;AACvCT,MAAAA,KAAK,CAACI,cAAc,CAClBI,YAAY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W,CAAC,CAAA;AACtD,OAAA;AAEA,MAAA,OAAOS,qBAAY,CAACZ,cAAc,EAAEH,QAAQ,EAAEC,iBAAiB,CAAC,CAAA;AAClE,KAAC,EACD;MACEe,GAAG,EAAEC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,IAAI,mBAAA;AAC/C;AACF,KACF,CAAC,CAAA;AACH,GAAA;AACF;;;;"}
1
+ {"version":3,"file":"Ordering.js","sources":["../../../src/features/Ordering.ts"],"sourcesContent":["import { makeStateUpdater, memo } from '../utils'\n\nimport { Table, OnChangeFn, Updater, Column, RowData } from '../types'\n\nimport { orderColumns } from './Grouping'\nimport { TableFeature } from '../core/table'\n\nexport interface ColumnOrderTableState {\n columnOrder: ColumnOrderState\n}\n\nexport type ColumnOrderState = string[]\n\nexport interface ColumnOrderOptions {\n /**\n * If provided, this function will be called with an `updaterFn` when `state.columnOrder` changes. This overrides the default internal state management, so you will need to persist the state change either fully or partially outside of the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-ordering#oncolumnorderchange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-ordering)\n */\n onColumnOrderChange?: OnChangeFn<ColumnOrderState>\n}\n\nexport interface ColumnOrderDefaultOptions {\n onColumnOrderChange: OnChangeFn<ColumnOrderState>\n}\n\nexport interface ColumnOrderInstance<TData extends RowData> {\n _getOrderColumnsFn: () => (\n columns: Column<TData, unknown>[]\n ) => Column<TData, unknown>[]\n /**\n * Resets the **columnOrder** state to `initialState.columnOrder`, or `true` can be passed to force a default blank state reset to `[]`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-ordering#resetcolumnorder)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-ordering)\n */\n resetColumnOrder: (defaultState?: boolean) => void\n /**\n * Sets or updates the `state.columnOrder` state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-ordering#setcolumnorder)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-ordering)\n */\n setColumnOrder: (updater: Updater<ColumnOrderState>) => void\n}\n\n//\n\nexport const Ordering: TableFeature = {\n getInitialState: (state): ColumnOrderTableState => {\n return {\n columnOrder: [],\n ...state,\n }\n },\n\n getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): ColumnOrderDefaultOptions => {\n return {\n onColumnOrderChange: makeStateUpdater('columnOrder', table),\n }\n },\n\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n table.setColumnOrder = updater =>\n table.options.onColumnOrderChange?.(updater)\n table.resetColumnOrder = defaultState => {\n table.setColumnOrder(\n defaultState ? [] : table.initialState.columnOrder ?? []\n )\n }\n table._getOrderColumnsFn = memo(\n () => [\n table.getState().columnOrder,\n table.getState().grouping,\n table.options.groupedColumnMode,\n ],\n (columnOrder, grouping, groupedColumnMode) => columns => {\n // Sort grouped columns to the start of the column list\n // before the headers are built\n let orderedColumns: Column<TData, unknown>[] = []\n\n // If there is no order, return the normal columns\n if (!columnOrder?.length) {\n orderedColumns = columns\n } else {\n const columnOrderCopy = [...columnOrder]\n\n // If there is an order, make a copy of the columns\n const columnsCopy = [...columns]\n\n // And make a new ordered array of the columns\n\n // Loop over the columns and place them in order into the new array\n while (columnsCopy.length && columnOrderCopy.length) {\n const targetColumnId = columnOrderCopy.shift()\n const foundIndex = columnsCopy.findIndex(\n d => d.id === targetColumnId\n )\n if (foundIndex > -1) {\n orderedColumns.push(columnsCopy.splice(foundIndex, 1)[0]!)\n }\n }\n\n // If there are any columns left, add them to the end\n orderedColumns = [...orderedColumns, ...columnsCopy]\n }\n\n return orderColumns(orderedColumns, grouping, groupedColumnMode)\n },\n {\n key: process.env.NODE_ENV === 'development' && 'getOrderColumnsFn',\n // debug: () => table.options.debugAll ?? table.options.debugTable,\n }\n )\n },\n}\n"],"names":["Ordering","getInitialState","state","columnOrder","getDefaultOptions","table","onColumnOrderChange","makeStateUpdater","createTable","setColumnOrder","updater","options","resetColumnOrder","defaultState","_table$initialState$c","initialState","_getOrderColumnsFn","memo","getState","grouping","groupedColumnMode","columns","orderedColumns","length","columnOrderCopy","columnsCopy","targetColumnId","shift","foundIndex","findIndex","d","id","push","splice","orderColumns","key","process","env","NODE_ENV"],"mappings":";;;;;;;;;;;;;;;;;AA4CA;;AAEO,MAAMA,QAAsB,GAAG;EACpCC,eAAe,EAAGC,KAAK,IAA4B;IACjD,OAAO;AACLC,MAAAA,WAAW,EAAE,EAAE;MACf,GAAGD,KAAAA;KACJ,CAAA;GACF;EAEDE,iBAAiB,EACfC,KAAmB,IACW;IAC9B,OAAO;AACLC,MAAAA,mBAAmB,EAAEC,sBAAgB,CAAC,aAAa,EAAEF,KAAK,CAAA;KAC3D,CAAA;GACF;EAEDG,WAAW,EAA0BH,KAAmB,IAAW;AACjEA,IAAAA,KAAK,CAACI,cAAc,GAAGC,OAAO,IAC5BL,KAAK,CAACM,OAAO,CAACL,mBAAmB,IAAA,IAAA,GAAA,KAAA,CAAA,GAAjCD,KAAK,CAACM,OAAO,CAACL,mBAAmB,CAAGI,OAAO,CAAC,CAAA;AAC9CL,IAAAA,KAAK,CAACO,gBAAgB,GAAGC,YAAY,IAAI;AAAA,MAAA,IAAAC,qBAAA,CAAA;AACvCT,MAAAA,KAAK,CAACI,cAAc,CAClBI,YAAY,GAAG,EAAE,IAAAC,qBAAA,GAAGT,KAAK,CAACU,YAAY,CAACZ,WAAW,YAAAW,qBAAA,GAAI,EACxD,CAAC,CAAA;KACF,CAAA;AACDT,IAAAA,KAAK,CAACW,kBAAkB,GAAGC,UAAI,CAC7B,MAAM,CACJZ,KAAK,CAACa,QAAQ,EAAE,CAACf,WAAW,EAC5BE,KAAK,CAACa,QAAQ,EAAE,CAACC,QAAQ,EACzBd,KAAK,CAACM,OAAO,CAACS,iBAAiB,CAChC,EACD,CAACjB,WAAW,EAAEgB,QAAQ,EAAEC,iBAAiB,KAAKC,OAAO,IAAI;AACvD;AACA;MACA,IAAIC,cAAwC,GAAG,EAAE,CAAA;;AAEjD;AACA,MAAA,IAAI,EAACnB,WAAW,IAAA,IAAA,IAAXA,WAAW,CAAEoB,MAAM,CAAE,EAAA;AACxBD,QAAAA,cAAc,GAAGD,OAAO,CAAA;AAC1B,OAAC,MAAM;AACL,QAAA,MAAMG,eAAe,GAAG,CAAC,GAAGrB,WAAW,CAAC,CAAA;;AAExC;AACA,QAAA,MAAMsB,WAAW,GAAG,CAAC,GAAGJ,OAAO,CAAC,CAAA;;AAEhC;;AAEA;AACA,QAAA,OAAOI,WAAW,CAACF,MAAM,IAAIC,eAAe,CAACD,MAAM,EAAE;AACnD,UAAA,MAAMG,cAAc,GAAGF,eAAe,CAACG,KAAK,EAAE,CAAA;AAC9C,UAAA,MAAMC,UAAU,GAAGH,WAAW,CAACI,SAAS,CACtCC,CAAC,IAAIA,CAAC,CAACC,EAAE,KAAKL,cAChB,CAAC,CAAA;AACD,UAAA,IAAIE,UAAU,GAAG,CAAC,CAAC,EAAE;AACnBN,YAAAA,cAAc,CAACU,IAAI,CAACP,WAAW,CAACQ,MAAM,CAACL,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAA;AAC5D,WAAA;AACF,SAAA;;AAEA;AACAN,QAAAA,cAAc,GAAG,CAAC,GAAGA,cAAc,EAAE,GAAGG,WAAW,CAAC,CAAA;AACtD,OAAA;AAEA,MAAA,OAAOS,qBAAY,CAACZ,cAAc,EAAEH,QAAQ,EAAEC,iBAAiB,CAAC,CAAA;AAClE,KAAC,EACD;MACEe,GAAG,EAAEC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa,IAAI,mBAAA;AAC/C;AACF,KACF,CAAC,CAAA;AACH,GAAA;AACF;;;;"}
@@ -11,32 +11,134 @@ export interface PaginationInitialTableState {
11
11
  pagination?: Partial<PaginationState>;
12
12
  }
13
13
  export interface PaginationOptions {
14
- pageCount?: number;
15
- manualPagination?: boolean;
16
- onPaginationChange?: OnChangeFn<PaginationState>;
14
+ /**
15
+ * If set to `true`, pagination will be reset to the first page when page-altering state changes eg. `data` is updated, filters change, grouping changes, etc.
16
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#autoresetpageindex)
17
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
18
+ */
17
19
  autoResetPageIndex?: boolean;
20
+ /**
21
+ * Returns the row model after pagination has taken place, but no further.
22
+ *
23
+ * Pagination columns are automatically reordered by default to the start of the columns list. If you would rather remove them or leave them as-is, set the appropriate mode here.
24
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#getpaginationrowmodel)
25
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
26
+ */
18
27
  getPaginationRowModel?: (table: Table<any>) => () => RowModel<any>;
28
+ /**
29
+ * Enables manual pagination. If this option is set to `true`, the table will not automatically paginate rows using `getPaginationRowModel()` and instead will expect you to manually paginate the rows before passing them to the table. This is useful if you are doing server-side pagination and aggregation.
30
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#manualpagination)
31
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
32
+ */
33
+ manualPagination?: boolean;
34
+ /**
35
+ * If this function is provided, it will be called when the pagination state changes and you will be expected to manage the state yourself. You can pass the managed state back to the table via the `tableOptions.state.pagination` option.
36
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#onpaginationchange)
37
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
38
+ */
39
+ onPaginationChange?: OnChangeFn<PaginationState>;
40
+ /**
41
+ * When manually controlling pagination, you should supply a total `pageCount` value to the table if you know it. If you do not know how many pages there are, you can set this to `-1`.
42
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#pagecount)
43
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
44
+ */
45
+ pageCount?: number;
19
46
  }
20
47
  export interface PaginationDefaultOptions {
21
48
  onPaginationChange: OnChangeFn<PaginationState>;
22
49
  }
23
50
  export interface PaginationInstance<TData extends RowData> {
24
51
  _autoResetPageIndex: () => void;
25
- setPagination: (updater: Updater<PaginationState>) => void;
26
- resetPagination: (defaultState?: boolean) => void;
27
- setPageIndex: (updater: Updater<number>) => void;
52
+ _getPaginationRowModel?: () => RowModel<TData>;
53
+ /**
54
+ * Returns whether the table can go to the next page.
55
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#getcannextpage)
56
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
57
+ */
58
+ getCanNextPage: () => boolean;
59
+ /**
60
+ * Returns whether the table can go to the previous page.
61
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#getcanpreviouspage)
62
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
63
+ */
64
+ getCanPreviousPage: () => boolean;
65
+ /**
66
+ * Returns the page count. If manually paginating or controlling the pagination state, this will come directly from the `options.pageCount` table option, otherwise it will be calculated from the table data using the total row count and current page size.
67
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#getpagecount)
68
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
69
+ */
70
+ getPageCount: () => number;
71
+ /**
72
+ * Returns an array of page options (zero-index-based) for the current page size.
73
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#getpageoptions)
74
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
75
+ */
76
+ getPageOptions: () => number[];
77
+ /**
78
+ * Returns the row model for the table after pagination has been applied.
79
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#getpaginationrowmodel)
80
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
81
+ */
82
+ getPaginationRowModel: () => RowModel<TData>;
83
+ /**
84
+ * Returns the row model for the table before any pagination has been applied.
85
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#getprepaginationrowmodel)
86
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
87
+ */
88
+ getPrePaginationRowModel: () => RowModel<TData>;
89
+ /**
90
+ * Increments the page index by one, if possible.
91
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#nextpage)
92
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
93
+ */
94
+ nextPage: () => void;
95
+ /**
96
+ * Decrements the page index by one, if possible.
97
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#previouspage)
98
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
99
+ */
100
+ previousPage: () => void;
101
+ /**
102
+ * Resets the page index to its initial state. If `defaultState` is `true`, the page index will be reset to `0` regardless of initial state.
103
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#resetpageindex)
104
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
105
+ */
28
106
  resetPageIndex: (defaultState?: boolean) => void;
29
- setPageSize: (updater: Updater<number>) => void;
107
+ /**
108
+ * Resets the page size to its initial state. If `defaultState` is `true`, the page size will be reset to `10` regardless of initial state.
109
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#resetpagesize)
110
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
111
+ */
30
112
  resetPageSize: (defaultState?: boolean) => void;
113
+ /**
114
+ * Resets the **pagination** state to `initialState.pagination`, or `true` can be passed to force a default blank state reset to `[]`.
115
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#resetpagination)
116
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
117
+ */
118
+ resetPagination: (defaultState?: boolean) => void;
119
+ /**
120
+ * Updates the page count using the provided function or value.
121
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#setpagecount)
122
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
123
+ */
31
124
  setPageCount: (updater: Updater<number>) => void;
32
- getPageOptions: () => number[];
33
- getCanPreviousPage: () => boolean;
34
- getCanNextPage: () => boolean;
35
- previousPage: () => void;
36
- nextPage: () => void;
37
- getPrePaginationRowModel: () => RowModel<TData>;
38
- getPaginationRowModel: () => RowModel<TData>;
39
- _getPaginationRowModel?: () => RowModel<TData>;
40
- getPageCount: () => number;
125
+ /**
126
+ * Updates the page index using the provided function or value in the `state.pagination.pageIndex` state.
127
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#setpageindex)
128
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
129
+ */
130
+ setPageIndex: (updater: Updater<number>) => void;
131
+ /**
132
+ * Updates the page size using the provided function or value in the `state.pagination.pageSize` state.
133
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#setpagesize)
134
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
135
+ */
136
+ setPageSize: (updater: Updater<number>) => void;
137
+ /**
138
+ * Sets or updates the `state.pagination` state.
139
+ * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/pagination#setpagination)
140
+ * @link [Guide](https://tanstack.com/table/v8/docs/guide/pagination)
141
+ */
142
+ setPagination: (updater: Updater<PaginationState>) => void;
41
143
  }
42
144
  export declare const Pagination: TableFeature;