@tanstack/table-core 8.15.2 → 8.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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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/api/features/sorting#sortundefined)
60
60
  * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)
61
61
  */
62
- sortUndefined?: false | -1 | 1;
62
+ sortUndefined?: false | -1 | 1 | 'first' | 'last';
63
63
  }
64
64
  export interface SortingColumn<TData extends RowData> {
65
65
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"RowSorting.js","sources":["../../../src/features/RowSorting.ts"],"sourcesContent":["import { RowModel } from '..'\nimport {\n BuiltInSortingFn,\n reSplitAlphaNumeric,\n sortingFns,\n} from '../sortingFns'\n\nimport {\n Column,\n OnChangeFn,\n Table,\n Row,\n Updater,\n RowData,\n SortingFns,\n TableFeature,\n} from '../types'\n\nimport { isFunction, makeStateUpdater } from '../utils'\n\nexport type SortDirection = 'asc' | 'desc'\n\nexport interface ColumnSort {\n desc: boolean\n id: string\n}\n\nexport type SortingState = ColumnSort[]\n\nexport interface SortingTableState {\n sorting: SortingState\n}\n\nexport interface SortingFn<TData extends RowData> {\n (rowA: Row<TData>, rowB: Row<TData>, columnId: string): number\n}\n\nexport type CustomSortingFns<TData extends RowData> = Record<\n string,\n SortingFn<TData>\n>\n\nexport type SortingFnOption<TData extends RowData> =\n | 'auto'\n | keyof SortingFns\n | BuiltInSortingFn\n | SortingFn<TData>\n\nexport interface SortingColumnDef<TData extends RowData> {\n /**\n * Enables/Disables multi-sorting for this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#enablemultisort)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n enableMultiSort?: boolean\n /**\n * Enables/Disables sorting for this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#enablesorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n enableSorting?: boolean\n /**\n * Inverts the order of the sorting for this column. This is useful for values that have an inverted best/worst scale where lower numbers are better, eg. a ranking (1st, 2nd, 3rd) or golf-like scoring\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#invertsorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n invertSorting?: boolean\n /**\n * Set to `true` for sorting toggles on this column to start in the descending direction.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#sortdescfirst)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n sortDescFirst?: boolean\n /**\n * The sorting function to use with this column.\n * - A `string` referencing a built-in sorting function\n * - A custom sorting function\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#sortingfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n sortingFn?: SortingFnOption<TData>\n /**\n * The priority of undefined values when sorting this column.\n * - `false`\n * - Undefined values will be considered tied and need to be sorted by the next column filter or original index (whichever applies)\n * - `-1`\n * - Undefined values will be sorted with higher priority (ascending) (if ascending, undefined will appear on the beginning of the list)\n * - `1`\n * - Undefined values will be sorted with lower priority (descending) (if ascending, undefined will appear on the end of the list)\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#sortundefined)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n sortUndefined?: false | -1 | 1\n}\n\nexport interface SortingColumn<TData extends RowData> {\n /**\n * Removes this column from the table's sorting state\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#clearsorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n clearSorting: () => void\n /**\n * Returns a sort direction automatically inferred based on the columns values.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getautosortdir)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getAutoSortDir: () => SortDirection\n /**\n * Returns a sorting function automatically inferred based on the columns values.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getautosortingfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getAutoSortingFn: () => SortingFn<TData>\n /**\n * Returns whether this column can be multi-sorted.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getcanmultisort)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getCanMultiSort: () => boolean\n /**\n * Returns whether this column can be sorted.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getcansort)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getCanSort: () => boolean\n /**\n * Returns the first direction that should be used when sorting this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getfirstsortdir)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getFirstSortDir: () => SortDirection\n /**\n * Returns the current sort direction of this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getissorted)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getIsSorted: () => false | SortDirection\n /**\n * Returns the next sorting order.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getnextsortingorder)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getNextSortingOrder: () => SortDirection | false\n /**\n * Returns the index position of this column's sorting within the sorting state\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getsortindex)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getSortIndex: () => number\n /**\n * Returns the resolved sorting function to be used for this column\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getsortingfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getSortingFn: () => SortingFn<TData>\n /**\n * Returns a function that can be used to toggle this column's sorting state. This is useful for attaching a click handler to the column header.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#gettogglesortinghandler)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getToggleSortingHandler: () => undefined | ((event: unknown) => void)\n /**\n * Toggles this columns sorting state. If `desc` is provided, it will force the sort direction to that value. If `isMulti` is provided, it will additivity multi-sort the column (or toggle it if it is already sorted).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#togglesorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n toggleSorting: (desc?: boolean, isMulti?: boolean) => void\n}\n\ninterface SortingOptionsBase {\n /**\n * Enables/disables the ability to remove multi-sorts\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#enablemultiremove)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n enableMultiRemove?: boolean\n /**\n * Enables/Disables multi-sorting for the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#enablemultisort)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n enableMultiSort?: boolean\n /**\n * Enables/Disables sorting for the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#enablesorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n enableSorting?: boolean\n /**\n * Enables/Disables the ability to remove sorting for the table.\n * - If `true` then changing sort order will circle like: 'none' -> 'desc' -> 'asc' -> 'none' -> ...\n * - If `false` then changing sort order will circle like: 'none' -> 'desc' -> 'asc' -> 'desc' -> 'asc' -> ...\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#enablesortingremoval)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n enableSortingRemoval?: boolean\n /**\n * This function is used to retrieve the sorted row model. If using server-side sorting, this function is not required. To use client-side sorting, pass the exported `getSortedRowModel()` from your adapter to your table or implement your own.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getsortedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getSortedRowModel?: (table: Table<any>) => () => RowModel<any>\n /**\n * Pass a custom function that will be used to determine if a multi-sort event should be triggered. It is passed the event from the sort toggle handler and should return `true` if the event should trigger a multi-sort.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#ismultisortevent)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n isMultiSortEvent?: (e: unknown) => boolean\n /**\n * Enables manual sorting for the table. If this is `true`, you will be expected to sort your data before it is passed to the table. This is useful if you are doing server-side sorting.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#manualsorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n manualSorting?: boolean\n /**\n * Set a maximum number of columns that can be multi-sorted.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#maxmultisortcolcount)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n maxMultiSortColCount?: number\n /**\n * If provided, this function will be called with an `updaterFn` when `state.sorting` 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/sorting#onsortingchange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n onSortingChange?: OnChangeFn<SortingState>\n /**\n * If `true`, all sorts will default to descending as their first toggle state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#sortdescfirst)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n sortDescFirst?: boolean\n}\n\ntype ResolvedSortingFns = keyof SortingFns extends never\n ? {\n sortingFns?: Record<string, SortingFn<any>>\n }\n : {\n sortingFns: Record<keyof SortingFns, SortingFn<any>>\n }\n\nexport interface SortingOptions<TData extends RowData>\n extends SortingOptionsBase,\n ResolvedSortingFns {}\n\nexport interface SortingInstance<TData extends RowData> {\n _getSortedRowModel?: () => RowModel<TData>\n /**\n * Returns the row model for the table before any sorting has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getpresortedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getPreSortedRowModel: () => RowModel<TData>\n /**\n * Returns the row model for the table after sorting has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getsortedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getSortedRowModel: () => RowModel<TData>\n /**\n * Resets the **sorting** state to `initialState.sorting`, 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/sorting#resetsorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n resetSorting: (defaultState?: boolean) => void\n /**\n * Sets or updates the `state.sorting` state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#setsorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n setSorting: (updater: Updater<SortingState>) => void\n}\n\n//\n\nexport const RowSorting: TableFeature = {\n getInitialState: (state): SortingTableState => {\n return {\n sorting: [],\n ...state,\n }\n },\n\n getDefaultColumnDef: <TData extends RowData>(): SortingColumnDef<TData> => {\n return {\n sortingFn: 'auto',\n sortUndefined: 1,\n }\n },\n\n getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): SortingOptions<TData> => {\n return {\n onSortingChange: makeStateUpdater('sorting', table),\n isMultiSortEvent: (e: unknown) => {\n return (e as MouseEvent).shiftKey\n },\n }\n },\n\n createColumn: <TData extends RowData, TValue>(\n column: Column<TData, TValue>,\n table: Table<TData>\n ): void => {\n column.getAutoSortingFn = () => {\n const firstRows = table.getFilteredRowModel().flatRows.slice(10)\n\n let isString = false\n\n for (const row of firstRows) {\n const value = row?.getValue(column.id)\n\n if (Object.prototype.toString.call(value) === '[object Date]') {\n return sortingFns.datetime\n }\n\n if (typeof value === 'string') {\n isString = true\n\n if (value.split(reSplitAlphaNumeric).length > 1) {\n return sortingFns.alphanumeric\n }\n }\n }\n\n if (isString) {\n return sortingFns.text\n }\n\n return sortingFns.basic\n }\n column.getAutoSortDir = () => {\n const firstRow = table.getFilteredRowModel().flatRows[0]\n\n const value = firstRow?.getValue(column.id)\n\n if (typeof value === 'string') {\n return 'asc'\n }\n\n return 'desc'\n }\n column.getSortingFn = () => {\n if (!column) {\n throw new Error()\n }\n\n return isFunction(column.columnDef.sortingFn)\n ? column.columnDef.sortingFn\n : column.columnDef.sortingFn === 'auto'\n ? column.getAutoSortingFn()\n : table.options.sortingFns?.[column.columnDef.sortingFn as string] ??\n sortingFns[column.columnDef.sortingFn as BuiltInSortingFn]\n }\n column.toggleSorting = (desc, multi) => {\n // if (column.columns.length) {\n // column.columns.forEach((c, i) => {\n // if (c.id) {\n // table.toggleColumnSorting(c.id, undefined, multi || !!i)\n // }\n // })\n // return\n // }\n\n // this needs to be outside of table.setSorting to be in sync with rerender\n const nextSortingOrder = column.getNextSortingOrder()\n const hasManualValue = typeof desc !== 'undefined' && desc !== null\n\n table.setSorting(old => {\n // Find any existing sorting for this column\n const existingSorting = old?.find(d => d.id === column.id)\n const existingIndex = old?.findIndex(d => d.id === column.id)\n\n let newSorting: SortingState = []\n\n // What should we do with this sort action?\n let sortAction: 'add' | 'remove' | 'toggle' | 'replace'\n let nextDesc = hasManualValue ? desc : nextSortingOrder === 'desc'\n\n // Multi-mode\n if (old?.length && column.getCanMultiSort() && multi) {\n if (existingSorting) {\n sortAction = 'toggle'\n } else {\n sortAction = 'add'\n }\n } else {\n // Normal mode\n if (old?.length && existingIndex !== old.length - 1) {\n sortAction = 'replace'\n } else if (existingSorting) {\n sortAction = 'toggle'\n } else {\n sortAction = 'replace'\n }\n }\n\n // Handle toggle states that will remove the sorting\n if (sortAction === 'toggle') {\n // If we are \"actually\" toggling (not a manual set value), should we remove the sorting?\n if (!hasManualValue) {\n // Is our intention to remove?\n if (!nextSortingOrder) {\n sortAction = 'remove'\n }\n }\n }\n\n if (sortAction === 'add') {\n newSorting = [\n ...old,\n {\n id: column.id,\n desc: nextDesc,\n },\n ]\n // Take latest n columns\n newSorting.splice(\n 0,\n newSorting.length -\n (table.options.maxMultiSortColCount ?? Number.MAX_SAFE_INTEGER)\n )\n } else if (sortAction === 'toggle') {\n // This flips (or sets) the\n newSorting = old.map(d => {\n if (d.id === column.id) {\n return {\n ...d,\n desc: nextDesc,\n }\n }\n return d\n })\n } else if (sortAction === 'remove') {\n newSorting = old.filter(d => d.id !== column.id)\n } else {\n newSorting = [\n {\n id: column.id,\n desc: nextDesc,\n },\n ]\n }\n\n return newSorting\n })\n }\n\n column.getFirstSortDir = () => {\n const sortDescFirst =\n column.columnDef.sortDescFirst ??\n table.options.sortDescFirst ??\n column.getAutoSortDir() === 'desc'\n return sortDescFirst ? 'desc' : 'asc'\n }\n\n column.getNextSortingOrder = (multi?: boolean) => {\n const firstSortDirection = column.getFirstSortDir()\n const isSorted = column.getIsSorted()\n\n if (!isSorted) {\n return firstSortDirection\n }\n\n if (\n isSorted !== firstSortDirection &&\n (table.options.enableSortingRemoval ?? true) && // If enableSortRemove, enable in general\n (multi ? table.options.enableMultiRemove ?? true : true) // If multi, don't allow if enableMultiRemove))\n ) {\n return false\n }\n return isSorted === 'desc' ? 'asc' : 'desc'\n }\n\n column.getCanSort = () => {\n return (\n (column.columnDef.enableSorting ?? true) &&\n (table.options.enableSorting ?? true) &&\n !!column.accessorFn\n )\n }\n\n column.getCanMultiSort = () => {\n return (\n column.columnDef.enableMultiSort ??\n table.options.enableMultiSort ??\n !!column.accessorFn\n )\n }\n\n column.getIsSorted = () => {\n const columnSort = table.getState().sorting?.find(d => d.id === column.id)\n\n return !columnSort ? false : columnSort.desc ? 'desc' : 'asc'\n }\n\n column.getSortIndex = () =>\n table.getState().sorting?.findIndex(d => d.id === column.id) ?? -1\n\n column.clearSorting = () => {\n //clear sorting for just 1 column\n table.setSorting(old =>\n old?.length ? old.filter(d => d.id !== column.id) : []\n )\n }\n\n column.getToggleSortingHandler = () => {\n const canSort = column.getCanSort()\n\n return (e: unknown) => {\n if (!canSort) return\n ;(e as any).persist?.()\n column.toggleSorting?.(\n undefined,\n column.getCanMultiSort() ? table.options.isMultiSortEvent?.(e) : false\n )\n }\n }\n },\n\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n table.setSorting = updater => table.options.onSortingChange?.(updater)\n table.resetSorting = defaultState => {\n table.setSorting(defaultState ? [] : table.initialState?.sorting ?? [])\n }\n table.getPreSortedRowModel = () => table.getGroupedRowModel()\n table.getSortedRowModel = () => {\n if (!table._getSortedRowModel && table.options.getSortedRowModel) {\n table._getSortedRowModel = table.options.getSortedRowModel(table)\n }\n\n if (table.options.manualSorting || !table._getSortedRowModel) {\n return table.getPreSortedRowModel()\n }\n\n return table._getSortedRowModel()\n }\n },\n}\n"],"names":["RowSorting","getInitialState","state","sorting","getDefaultColumnDef","sortingFn","sortUndefined","getDefaultOptions","table","onSortingChange","makeStateUpdater","isMultiSortEvent","e","shiftKey","createColumn","column","getAutoSortingFn","firstRows","getFilteredRowModel","flatRows","slice","isString","row","value","getValue","id","Object","prototype","toString","call","sortingFns","datetime","split","reSplitAlphaNumeric","length","alphanumeric","text","basic","getAutoSortDir","firstRow","getSortingFn","_table$options$sortin","_table$options$sortin2","Error","isFunction","columnDef","options","toggleSorting","desc","multi","nextSortingOrder","getNextSortingOrder","hasManualValue","setSorting","old","existingSorting","find","d","existingIndex","findIndex","newSorting","sortAction","nextDesc","getCanMultiSort","_table$options$maxMul","splice","maxMultiSortColCount","Number","MAX_SAFE_INTEGER","map","filter","getFirstSortDir","_ref","_column$columnDef$sor","sortDescFirst","_table$options$enable","_table$options$enable2","firstSortDirection","isSorted","getIsSorted","enableSortingRemoval","enableMultiRemove","getCanSort","_column$columnDef$ena","_table$options$enable3","enableSorting","accessorFn","_ref2","_column$columnDef$ena2","enableMultiSort","_table$getState$sorti","columnSort","getState","getSortIndex","_table$getState$sorti2","_table$getState$sorti3","clearSorting","getToggleSortingHandler","canSort","persist","undefined","createTable","updater","resetSorting","defaultState","_table$initialState$s","_table$initialState","initialState","getPreSortedRowModel","getGroupedRowModel","getSortedRowModel","_getSortedRowModel","manualSorting"],"mappings":";;;;;;;;;;;;;;;AAmRA;;AAEO,MAAMA,UAAwB,GAAG;EACtCC,eAAe,EAAGC,KAAK,IAAwB;IAC7C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,KACnE,CAAC,CAAA;OACF,CAAA;KACF,CAAA;GACF;EAEDyF,WAAW,EAA0B7F,KAAmB,IAAW;AACjEA,IAAAA,KAAK,CAAC6C,UAAU,GAAGiD,OAAO,IAAI9F,KAAK,CAACsC,OAAO,CAACrC,eAAe,IAAA,IAAA,GAAA,KAAA,CAAA,GAA7BD,KAAK,CAACsC,OAAO,CAACrC,eAAe,CAAG6F,OAAO,CAAC,CAAA;AACtE9F,IAAAA,KAAK,CAAC+F,YAAY,GAAGC,YAAY,IAAI;MAAA,IAAAC,qBAAA,EAAAC,mBAAA,CAAA;MACnClG,KAAK,CAAC6C,UAAU,CAACmD,YAAY,GAAG,EAAE,GAAA,CAAAC,qBAAA,GAAA,CAAAC,mBAAA,GAAGlG,KAAK,CAACmG,YAAY,qBAAlBD,mBAAA,CAAoBvG,OAAO,KAAAsG,IAAAA,GAAAA,qBAAA,GAAI,EAAE,CAAC,CAAA;KACxE,CAAA;IACDjG,KAAK,CAACoG,oBAAoB,GAAG,MAAMpG,KAAK,CAACqG,kBAAkB,EAAE,CAAA;IAC7DrG,KAAK,CAACsG,iBAAiB,GAAG,MAAM;MAC9B,IAAI,CAACtG,KAAK,CAACuG,kBAAkB,IAAIvG,KAAK,CAACsC,OAAO,CAACgE,iBAAiB,EAAE;QAChEtG,KAAK,CAACuG,kBAAkB,GAAGvG,KAAK,CAACsC,OAAO,CAACgE,iBAAiB,CAACtG,KAAK,CAAC,CAAA;AACnE,OAAA;MAEA,IAAIA,KAAK,CAACsC,OAAO,CAACkE,aAAa,IAAI,CAACxG,KAAK,CAACuG,kBAAkB,EAAE;AAC5D,QAAA,OAAOvG,KAAK,CAACoG,oBAAoB,EAAE,CAAA;AACrC,OAAA;AAEA,MAAA,OAAOpG,KAAK,CAACuG,kBAAkB,EAAE,CAAA;KAClC,CAAA;AACH,GAAA;AACF;;;;"}
1
+ {"version":3,"file":"RowSorting.js","sources":["../../../src/features/RowSorting.ts"],"sourcesContent":["import { RowModel } from '..'\nimport {\n BuiltInSortingFn,\n reSplitAlphaNumeric,\n sortingFns,\n} from '../sortingFns'\n\nimport {\n Column,\n OnChangeFn,\n Table,\n Row,\n Updater,\n RowData,\n SortingFns,\n TableFeature,\n} from '../types'\n\nimport { isFunction, makeStateUpdater } from '../utils'\n\nexport type SortDirection = 'asc' | 'desc'\n\nexport interface ColumnSort {\n desc: boolean\n id: string\n}\n\nexport type SortingState = ColumnSort[]\n\nexport interface SortingTableState {\n sorting: SortingState\n}\n\nexport interface SortingFn<TData extends RowData> {\n (rowA: Row<TData>, rowB: Row<TData>, columnId: string): number\n}\n\nexport type CustomSortingFns<TData extends RowData> = Record<\n string,\n SortingFn<TData>\n>\n\nexport type SortingFnOption<TData extends RowData> =\n | 'auto'\n | keyof SortingFns\n | BuiltInSortingFn\n | SortingFn<TData>\n\nexport interface SortingColumnDef<TData extends RowData> {\n /**\n * Enables/Disables multi-sorting for this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#enablemultisort)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n enableMultiSort?: boolean\n /**\n * Enables/Disables sorting for this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#enablesorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n enableSorting?: boolean\n /**\n * Inverts the order of the sorting for this column. This is useful for values that have an inverted best/worst scale where lower numbers are better, eg. a ranking (1st, 2nd, 3rd) or golf-like scoring\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#invertsorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n invertSorting?: boolean\n /**\n * Set to `true` for sorting toggles on this column to start in the descending direction.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#sortdescfirst)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n sortDescFirst?: boolean\n /**\n * The sorting function to use with this column.\n * - A `string` referencing a built-in sorting function\n * - A custom sorting function\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#sortingfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n sortingFn?: SortingFnOption<TData>\n /**\n * The priority of undefined values when sorting this column.\n * - `false`\n * - Undefined values will be considered tied and need to be sorted by the next column filter or original index (whichever applies)\n * - `-1`\n * - Undefined values will be sorted with higher priority (ascending) (if ascending, undefined will appear on the beginning of the list)\n * - `1`\n * - Undefined values will be sorted with lower priority (descending) (if ascending, undefined will appear on the end of the list)\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#sortundefined)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n sortUndefined?: false | -1 | 1 | 'first' | 'last'\n}\n\nexport interface SortingColumn<TData extends RowData> {\n /**\n * Removes this column from the table's sorting state\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#clearsorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n clearSorting: () => void\n /**\n * Returns a sort direction automatically inferred based on the columns values.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getautosortdir)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getAutoSortDir: () => SortDirection\n /**\n * Returns a sorting function automatically inferred based on the columns values.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getautosortingfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getAutoSortingFn: () => SortingFn<TData>\n /**\n * Returns whether this column can be multi-sorted.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getcanmultisort)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getCanMultiSort: () => boolean\n /**\n * Returns whether this column can be sorted.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getcansort)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getCanSort: () => boolean\n /**\n * Returns the first direction that should be used when sorting this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getfirstsortdir)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getFirstSortDir: () => SortDirection\n /**\n * Returns the current sort direction of this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getissorted)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getIsSorted: () => false | SortDirection\n /**\n * Returns the next sorting order.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getnextsortingorder)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getNextSortingOrder: () => SortDirection | false\n /**\n * Returns the index position of this column's sorting within the sorting state\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getsortindex)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getSortIndex: () => number\n /**\n * Returns the resolved sorting function to be used for this column\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getsortingfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getSortingFn: () => SortingFn<TData>\n /**\n * Returns a function that can be used to toggle this column's sorting state. This is useful for attaching a click handler to the column header.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#gettogglesortinghandler)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getToggleSortingHandler: () => undefined | ((event: unknown) => void)\n /**\n * Toggles this columns sorting state. If `desc` is provided, it will force the sort direction to that value. If `isMulti` is provided, it will additivity multi-sort the column (or toggle it if it is already sorted).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#togglesorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n toggleSorting: (desc?: boolean, isMulti?: boolean) => void\n}\n\ninterface SortingOptionsBase {\n /**\n * Enables/disables the ability to remove multi-sorts\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#enablemultiremove)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n enableMultiRemove?: boolean\n /**\n * Enables/Disables multi-sorting for the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#enablemultisort)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n enableMultiSort?: boolean\n /**\n * Enables/Disables sorting for the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#enablesorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n enableSorting?: boolean\n /**\n * Enables/Disables the ability to remove sorting for the table.\n * - If `true` then changing sort order will circle like: 'none' -> 'desc' -> 'asc' -> 'none' -> ...\n * - If `false` then changing sort order will circle like: 'none' -> 'desc' -> 'asc' -> 'desc' -> 'asc' -> ...\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#enablesortingremoval)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n enableSortingRemoval?: boolean\n /**\n * This function is used to retrieve the sorted row model. If using server-side sorting, this function is not required. To use client-side sorting, pass the exported `getSortedRowModel()` from your adapter to your table or implement your own.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getsortedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getSortedRowModel?: (table: Table<any>) => () => RowModel<any>\n /**\n * Pass a custom function that will be used to determine if a multi-sort event should be triggered. It is passed the event from the sort toggle handler and should return `true` if the event should trigger a multi-sort.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#ismultisortevent)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n isMultiSortEvent?: (e: unknown) => boolean\n /**\n * Enables manual sorting for the table. If this is `true`, you will be expected to sort your data before it is passed to the table. This is useful if you are doing server-side sorting.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#manualsorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n manualSorting?: boolean\n /**\n * Set a maximum number of columns that can be multi-sorted.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#maxmultisortcolcount)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n maxMultiSortColCount?: number\n /**\n * If provided, this function will be called with an `updaterFn` when `state.sorting` 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/sorting#onsortingchange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n onSortingChange?: OnChangeFn<SortingState>\n /**\n * If `true`, all sorts will default to descending as their first toggle state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#sortdescfirst)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n sortDescFirst?: boolean\n}\n\ntype ResolvedSortingFns = keyof SortingFns extends never\n ? {\n sortingFns?: Record<string, SortingFn<any>>\n }\n : {\n sortingFns: Record<keyof SortingFns, SortingFn<any>>\n }\n\nexport interface SortingOptions<TData extends RowData>\n extends SortingOptionsBase,\n ResolvedSortingFns {}\n\nexport interface SortingInstance<TData extends RowData> {\n _getSortedRowModel?: () => RowModel<TData>\n /**\n * Returns the row model for the table before any sorting has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getpresortedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getPreSortedRowModel: () => RowModel<TData>\n /**\n * Returns the row model for the table after sorting has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#getsortedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n getSortedRowModel: () => RowModel<TData>\n /**\n * Resets the **sorting** state to `initialState.sorting`, 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/sorting#resetsorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n resetSorting: (defaultState?: boolean) => void\n /**\n * Sets or updates the `state.sorting` state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/sorting#setsorting)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/sorting)\n */\n setSorting: (updater: Updater<SortingState>) => void\n}\n\n//\n\nexport const RowSorting: TableFeature = {\n getInitialState: (state): SortingTableState => {\n return {\n sorting: [],\n ...state,\n }\n },\n\n getDefaultColumnDef: <TData extends RowData>(): SortingColumnDef<TData> => {\n return {\n sortingFn: 'auto',\n sortUndefined: 1,\n }\n },\n\n getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): SortingOptions<TData> => {\n return {\n onSortingChange: makeStateUpdater('sorting', table),\n isMultiSortEvent: (e: unknown) => {\n return (e as MouseEvent).shiftKey\n },\n }\n },\n\n createColumn: <TData extends RowData, TValue>(\n column: Column<TData, TValue>,\n table: Table<TData>\n ): void => {\n column.getAutoSortingFn = () => {\n const firstRows = table.getFilteredRowModel().flatRows.slice(10)\n\n let isString = false\n\n for (const row of firstRows) {\n const value = row?.getValue(column.id)\n\n if (Object.prototype.toString.call(value) === '[object Date]') {\n return sortingFns.datetime\n }\n\n if (typeof value === 'string') {\n isString = true\n\n if (value.split(reSplitAlphaNumeric).length > 1) {\n return sortingFns.alphanumeric\n }\n }\n }\n\n if (isString) {\n return sortingFns.text\n }\n\n return sortingFns.basic\n }\n column.getAutoSortDir = () => {\n const firstRow = table.getFilteredRowModel().flatRows[0]\n\n const value = firstRow?.getValue(column.id)\n\n if (typeof value === 'string') {\n return 'asc'\n }\n\n return 'desc'\n }\n column.getSortingFn = () => {\n if (!column) {\n throw new Error()\n }\n\n return isFunction(column.columnDef.sortingFn)\n ? column.columnDef.sortingFn\n : column.columnDef.sortingFn === 'auto'\n ? column.getAutoSortingFn()\n : table.options.sortingFns?.[column.columnDef.sortingFn as string] ??\n sortingFns[column.columnDef.sortingFn as BuiltInSortingFn]\n }\n column.toggleSorting = (desc, multi) => {\n // if (column.columns.length) {\n // column.columns.forEach((c, i) => {\n // if (c.id) {\n // table.toggleColumnSorting(c.id, undefined, multi || !!i)\n // }\n // })\n // return\n // }\n\n // this needs to be outside of table.setSorting to be in sync with rerender\n const nextSortingOrder = column.getNextSortingOrder()\n const hasManualValue = typeof desc !== 'undefined' && desc !== null\n\n table.setSorting(old => {\n // Find any existing sorting for this column\n const existingSorting = old?.find(d => d.id === column.id)\n const existingIndex = old?.findIndex(d => d.id === column.id)\n\n let newSorting: SortingState = []\n\n // What should we do with this sort action?\n let sortAction: 'add' | 'remove' | 'toggle' | 'replace'\n let nextDesc = hasManualValue ? desc : nextSortingOrder === 'desc'\n\n // Multi-mode\n if (old?.length && column.getCanMultiSort() && multi) {\n if (existingSorting) {\n sortAction = 'toggle'\n } else {\n sortAction = 'add'\n }\n } else {\n // Normal mode\n if (old?.length && existingIndex !== old.length - 1) {\n sortAction = 'replace'\n } else if (existingSorting) {\n sortAction = 'toggle'\n } else {\n sortAction = 'replace'\n }\n }\n\n // Handle toggle states that will remove the sorting\n if (sortAction === 'toggle') {\n // If we are \"actually\" toggling (not a manual set value), should we remove the sorting?\n if (!hasManualValue) {\n // Is our intention to remove?\n if (!nextSortingOrder) {\n sortAction = 'remove'\n }\n }\n }\n\n if (sortAction === 'add') {\n newSorting = [\n ...old,\n {\n id: column.id,\n desc: nextDesc,\n },\n ]\n // Take latest n columns\n newSorting.splice(\n 0,\n newSorting.length -\n (table.options.maxMultiSortColCount ?? Number.MAX_SAFE_INTEGER)\n )\n } else if (sortAction === 'toggle') {\n // This flips (or sets) the\n newSorting = old.map(d => {\n if (d.id === column.id) {\n return {\n ...d,\n desc: nextDesc,\n }\n }\n return d\n })\n } else if (sortAction === 'remove') {\n newSorting = old.filter(d => d.id !== column.id)\n } else {\n newSorting = [\n {\n id: column.id,\n desc: nextDesc,\n },\n ]\n }\n\n return newSorting\n })\n }\n\n column.getFirstSortDir = () => {\n const sortDescFirst =\n column.columnDef.sortDescFirst ??\n table.options.sortDescFirst ??\n column.getAutoSortDir() === 'desc'\n return sortDescFirst ? 'desc' : 'asc'\n }\n\n column.getNextSortingOrder = (multi?: boolean) => {\n const firstSortDirection = column.getFirstSortDir()\n const isSorted = column.getIsSorted()\n\n if (!isSorted) {\n return firstSortDirection\n }\n\n if (\n isSorted !== firstSortDirection &&\n (table.options.enableSortingRemoval ?? true) && // If enableSortRemove, enable in general\n (multi ? table.options.enableMultiRemove ?? true : true) // If multi, don't allow if enableMultiRemove))\n ) {\n return false\n }\n return isSorted === 'desc' ? 'asc' : 'desc'\n }\n\n column.getCanSort = () => {\n return (\n (column.columnDef.enableSorting ?? true) &&\n (table.options.enableSorting ?? true) &&\n !!column.accessorFn\n )\n }\n\n column.getCanMultiSort = () => {\n return (\n column.columnDef.enableMultiSort ??\n table.options.enableMultiSort ??\n !!column.accessorFn\n )\n }\n\n column.getIsSorted = () => {\n const columnSort = table.getState().sorting?.find(d => d.id === column.id)\n\n return !columnSort ? false : columnSort.desc ? 'desc' : 'asc'\n }\n\n column.getSortIndex = () =>\n table.getState().sorting?.findIndex(d => d.id === column.id) ?? -1\n\n column.clearSorting = () => {\n //clear sorting for just 1 column\n table.setSorting(old =>\n old?.length ? old.filter(d => d.id !== column.id) : []\n )\n }\n\n column.getToggleSortingHandler = () => {\n const canSort = column.getCanSort()\n\n return (e: unknown) => {\n if (!canSort) return\n ;(e as any).persist?.()\n column.toggleSorting?.(\n undefined,\n column.getCanMultiSort() ? table.options.isMultiSortEvent?.(e) : false\n )\n }\n }\n },\n\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n table.setSorting = updater => table.options.onSortingChange?.(updater)\n table.resetSorting = defaultState => {\n table.setSorting(defaultState ? [] : table.initialState?.sorting ?? [])\n }\n table.getPreSortedRowModel = () => table.getGroupedRowModel()\n table.getSortedRowModel = () => {\n if (!table._getSortedRowModel && table.options.getSortedRowModel) {\n table._getSortedRowModel = table.options.getSortedRowModel(table)\n }\n\n if (table.options.manualSorting || !table._getSortedRowModel) {\n return table.getPreSortedRowModel()\n }\n\n return table._getSortedRowModel()\n }\n },\n}\n"],"names":["RowSorting","getInitialState","state","sorting","getDefaultColumnDef","sortingFn","sortUndefined","getDefaultOptions","table","onSortingChange","makeStateUpdater","isMultiSortEvent","e","shiftKey","createColumn","column","getAutoSortingFn","firstRows","getFilteredRowModel","flatRows","slice","isString","row","value","getValue","id","Object","prototype","toString","call","sortingFns","datetime","split","reSplitAlphaNumeric","length","alphanumeric","text","basic","getAutoSortDir","firstRow","getSortingFn","_table$options$sortin","_table$options$sortin2","Error","isFunction","columnDef","options","toggleSorting","desc","multi","nextSortingOrder","getNextSortingOrder","hasManualValue","setSorting","old","existingSorting","find","d","existingIndex","findIndex","newSorting","sortAction","nextDesc","getCanMultiSort","_table$options$maxMul","splice","maxMultiSortColCount","Number","MAX_SAFE_INTEGER","map","filter","getFirstSortDir","_ref","_column$columnDef$sor","sortDescFirst","_table$options$enable","_table$options$enable2","firstSortDirection","isSorted","getIsSorted","enableSortingRemoval","enableMultiRemove","getCanSort","_column$columnDef$ena","_table$options$enable3","enableSorting","accessorFn","_ref2","_column$columnDef$ena2","enableMultiSort","_table$getState$sorti","columnSort","getState","getSortIndex","_table$getState$sorti2","_table$getState$sorti3","clearSorting","getToggleSortingHandler","canSort","persist","undefined","createTable","updater","resetSorting","defaultState","_table$initialState$s","_table$initialState","initialState","getPreSortedRowModel","getGroupedRowModel","getSortedRowModel","_getSortedRowModel","manualSorting"],"mappings":";;;;;;;;;;;;;;;AAmRA;;AAEO,MAAMA,UAAwB,GAAG;EACtCC,eAAe,EAAGC,KAAK,IAAwB;IAC7C,OAAO;AACLC,MAAAA,OAAO,EAAE,EAAE;MACX,GAAGD,KAAAA;KACJ,CAAA;GACF;EAEDE,mBAAmB,EAAEA,MAAsD;IACzE,OAAO;AACLC,MAAAA,SAAS,EAAE,MAAM;AACjBC,MAAAA,aAAa,EAAE,CAAA;KAChB,CAAA;GACF;EAEDC,iBAAiB,EACfC,KAAmB,IACO;IAC1B,OAAO;AACLC,MAAAA,eAAe,E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CAAA;AACtE9F,IAAAA,KAAK,CAAC+F,YAAY,GAAGC,YAAY,IAAI;MAAA,IAAAC,qBAAA,EAAAC,mBAAA,CAAA;MACnClG,KAAK,CAAC6C,UAAU,CAACmD,YAAY,GAAG,EAAE,GAAA,CAAAC,qBAAA,GAAA,CAAAC,mBAAA,GAAGlG,KAAK,CAACmG,YAAY,qBAAlBD,mBAAA,CAAoBvG,OAAO,KAAAsG,IAAAA,GAAAA,qBAAA,GAAI,EAAE,CAAC,CAAA;KACxE,CAAA;IACDjG,KAAK,CAACoG,oBAAoB,GAAG,MAAMpG,KAAK,CAACqG,kBAAkB,EAAE,CAAA;IAC7DrG,KAAK,CAACsG,iBAAiB,GAAG,MAAM;MAC9B,IAAI,CAACtG,KAAK,CAACuG,kBAAkB,IAAIvG,KAAK,CAACsC,OAAO,CAACgE,iBAAiB,EAAE;QAChEtG,KAAK,CAACuG,kBAAkB,GAAGvG,KAAK,CAACsC,OAAO,CAACgE,iBAAiB,CAACtG,KAAK,CAAC,CAAA;AACnE,OAAA;MAEA,IAAIA,KAAK,CAACsC,OAAO,CAACkE,aAAa,IAAI,CAACxG,KAAK,CAACuG,kBAAkB,EAAE;AAC5D,QAAA,OAAOvG,KAAK,CAACoG,oBAAoB,EAAE,CAAA;AACrC,OAAA;AAEA,MAAA,OAAOpG,KAAK,CAACuG,kBAAkB,EAAE,CAAA;KAClC,CAAA;AACH,GAAA;AACF;;;;"}
@@ -940,8 +940,8 @@ const ColumnGrouping = {
940
940
  });
941
941
  };
942
942
  column.getCanGroup = () => {
943
- var _ref, _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;
@@ -3466,17 +3466,20 @@ function getSortedRowModel() {
3466
3466
  var _sortEntry$desc;
3467
3467
  const sortEntry = availableSorting[i];
3468
3468
  const columnInfo = columnInfoById[sortEntry.id];
3469
+ const sortUndefined = columnInfo.sortUndefined;
3469
3470
  const isDesc = (_sortEntry$desc = sortEntry == null ? void 0 : sortEntry.desc) != null ? _sortEntry$desc : false;
3470
3471
  let sortInt = 0;
3471
3472
 
3472
3473
  // All sorting ints should always return in ascending order
3473
- if (columnInfo.sortUndefined) {
3474
+ if (sortUndefined) {
3474
3475
  const aValue = rowA.getValue(sortEntry.id);
3475
3476
  const bValue = rowB.getValue(sortEntry.id);
3476
3477
  const aUndefined = aValue === undefined;
3477
3478
  const bUndefined = bValue === undefined;
3478
3479
  if (aUndefined || bUndefined) {
3479
- sortInt = aUndefined && bUndefined ? 0 : aUndefined ? columnInfo.sortUndefined : -columnInfo.sortUndefined;
3480
+ if (sortUndefined === 'first') return aUndefined ? -1 : 1;
3481
+ if (sortUndefined === 'last') return aUndefined ? 1 : -1;
3482
+ sortInt = aUndefined && bUndefined ? 0 : aUndefined ? sortUndefined : -sortUndefined;
3480
3483
  }
3481
3484
  }
3482
3485
  if (sortInt === 0) {