@tanstack/table-core 8.15.2 → 8.15.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.
@@ -48,8 +48,8 @@ const ColumnGrouping = {
48
48
  });
49
49
  };
50
50
  column.getCanGroup = () => {
51
- var _ref, _ref2, _ref3, _column$columnDef$ena;
52
- return (_ref = (_ref2 = (_ref3 = (_column$columnDef$ena = column.columnDef.enableGrouping) != null ? _column$columnDef$ena : true) != null ? _ref3 : table.options.enableGrouping) != null ? _ref2 : true) != null ? _ref : !!column.accessorFn;
51
+ var _column$columnDef$ena, _table$options$enable;
52
+ return ((_column$columnDef$ena = column.columnDef.enableGrouping) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableGrouping) != null ? _table$options$enable : true) && (!!column.accessorFn || !!column.columnDef.getGroupingValue);
53
53
  };
54
54
  column.getIsGrouped = () => {
55
55
  var _table$getState$group;
@@ -1 +1 @@
1
- {"version":3,"file":"ColumnGrouping.js","sources":["../../../src/features/ColumnGrouping.ts"],"sourcesContent":["import { RowModel } from '..'\nimport { BuiltInAggregationFn, aggregationFns } from '../aggregationFns'\nimport {\n AggregationFns,\n Cell,\n Column,\n ColumnDefTemplate,\n OnChangeFn,\n Row,\n RowData,\n Table,\n TableFeature,\n Updater,\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 ColumnGrouping: 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[\n column.columnDef.aggregationFn as BuiltInAggregationFn\n ]\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":["ColumnGrouping","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,cAA4B,GAAG;EAC1CC,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,GAAG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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":"ColumnGrouping.js","sources":["../../../src/features/ColumnGrouping.ts"],"sourcesContent":["import { RowModel } from '..'\nimport { BuiltInAggregationFn, aggregationFns } from '../aggregationFns'\nimport {\n AggregationFns,\n Cell,\n Column,\n ColumnDefTemplate,\n OnChangeFn,\n Row,\n RowData,\n Table,\n TableFeature,\n Updater,\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 ColumnGrouping: 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 ?? true) &&\n (table.options.enableGrouping ?? true) &&\n (!!column.accessorFn || !!column.columnDef.getGroupingValue)\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[\n column.columnDef.aggregationFn as BuiltInAggregationFn\n ]\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":["ColumnGrouping","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","_column$columnDef$ena","_table$options$enable","columnDef","enableGrouping","options","accessorFn","getGroupingValue","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","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,cAA4B,GAAG;EAC1CC,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;AACrDG,MAAAA,iBAAiB,EAAE,SAAA;KACpB,CAAA;GACF;AAEDC,EAAAA,YAAY,EAAEA,CACZC,MAA6B,EAC7BL,KAAmB,KACV;IACTK,MAAM,CAACC,cAAc,GAAG,MAAM;AAC5BN,MAA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_ref2, _ref3, _column$columnDef$ena;
944
- return (_ref = (_ref2 = (_ref3 = (_column$columnDef$ena = column.columnDef.enableGrouping) != null ? _column$columnDef$ena : true) != null ? _ref3 : table.options.enableGrouping) != null ? _ref2 : true) != null ? _ref : !!column.accessorFn;
943
+ var _column$columnDef$ena, _table$options$enable;
944
+ return ((_column$columnDef$ena = column.columnDef.enableGrouping) != null ? _column$columnDef$ena : true) && ((_table$options$enable = table.options.enableGrouping) != null ? _table$options$enable : true) && (!!column.accessorFn || !!column.columnDef.getGroupingValue);
945
945
  };
946
946
  column.getIsGrouped = () => {
947
947
  var _table$getState$group;