@tanstack/table-core 9.0.0-alpha.4 → 9.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/aggregationFns.cjs +4 -8
- package/dist/cjs/aggregationFns.cjs.map +1 -1
- package/dist/cjs/core/cell.cjs +3 -3
- package/dist/cjs/core/cell.cjs.map +1 -1
- package/dist/cjs/core/cell.d.cts +1 -1
- package/dist/cjs/core/column.cjs +3 -3
- package/dist/cjs/core/column.cjs.map +1 -1
- package/dist/cjs/core/column.d.cts +1 -1
- package/dist/cjs/core/headers.cjs +5 -5
- package/dist/cjs/core/headers.cjs.map +1 -1
- package/dist/cjs/core/row.cjs +5 -6
- package/dist/cjs/core/row.cjs.map +1 -1
- package/dist/cjs/core/row.d.cts +1 -1
- package/dist/cjs/core/table.cjs +11 -7
- package/dist/cjs/core/table.cjs.map +1 -1
- package/dist/cjs/core/table.d.cts +9 -1
- package/dist/cjs/features/ColumnFaceting.cjs +1 -1
- package/dist/cjs/features/ColumnFaceting.cjs.map +1 -1
- package/dist/cjs/features/ColumnFiltering.cjs +6 -6
- package/dist/cjs/features/ColumnFiltering.cjs.map +1 -1
- package/dist/cjs/features/ColumnGrouping.cjs +8 -9
- package/dist/cjs/features/ColumnGrouping.cjs.map +1 -1
- package/dist/cjs/features/ColumnOrdering.cjs +4 -4
- package/dist/cjs/features/ColumnOrdering.cjs.map +1 -1
- package/dist/cjs/features/ColumnPinning.cjs +5 -5
- package/dist/cjs/features/ColumnPinning.cjs.map +1 -1
- package/dist/cjs/features/ColumnSizing.cjs +7 -8
- package/dist/cjs/features/ColumnSizing.cjs.map +1 -1
- package/dist/cjs/features/ColumnVisibility.cjs +5 -5
- package/dist/cjs/features/ColumnVisibility.cjs.map +1 -1
- package/dist/cjs/features/GlobalFaceting.cjs +1 -1
- package/dist/cjs/features/GlobalFaceting.cjs.map +1 -1
- package/dist/cjs/features/GlobalFiltering.cjs +4 -4
- package/dist/cjs/features/GlobalFiltering.cjs.map +1 -1
- package/dist/cjs/features/RowExpanding.cjs +6 -8
- package/dist/cjs/features/RowExpanding.cjs.map +1 -1
- package/dist/cjs/features/RowPagination.cjs +4 -5
- package/dist/cjs/features/RowPagination.cjs.map +1 -1
- package/dist/cjs/features/RowPinning.cjs +5 -6
- package/dist/cjs/features/RowPinning.cjs.map +1 -1
- package/dist/cjs/features/RowSelection.cjs +6 -8
- package/dist/cjs/features/RowSelection.cjs.map +1 -1
- package/dist/cjs/features/RowSorting.cjs +6 -7
- package/dist/cjs/features/RowSorting.cjs.map +1 -1
- package/dist/cjs/filterFns.cjs.map +1 -1
- package/dist/cjs/index.cjs +5 -4
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/types.d.cts +8 -8
- package/dist/cjs/utils/filterRowsUtils.cjs +2 -2
- package/dist/cjs/utils/filterRowsUtils.cjs.map +1 -1
- package/dist/cjs/utils/getCoreRowModel.cjs +1 -1
- package/dist/cjs/utils/getCoreRowModel.cjs.map +1 -1
- package/dist/cjs/utils/getFacetedMinMaxValues.cjs +1 -2
- package/dist/cjs/utils/getFacetedMinMaxValues.cjs.map +1 -1
- package/dist/cjs/utils/getFacetedUniqueValues.cjs +1 -2
- package/dist/cjs/utils/getFacetedUniqueValues.cjs.map +1 -1
- package/dist/cjs/utils/getGroupedRowModel.cjs +1 -1
- package/dist/cjs/utils/getGroupedRowModel.cjs.map +1 -1
- package/dist/cjs/utils/getSortedRowModel.cjs +3 -6
- package/dist/cjs/utils/getSortedRowModel.cjs.map +1 -1
- package/dist/cjs/utils.cjs +2 -4
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/esm/aggregationFns.js +4 -8
- package/dist/esm/aggregationFns.js.map +1 -1
- package/dist/esm/core/cell.d.ts +1 -1
- package/dist/esm/core/cell.js +3 -3
- package/dist/esm/core/cell.js.map +1 -1
- package/dist/esm/core/column.d.ts +1 -1
- package/dist/esm/core/column.js +3 -3
- package/dist/esm/core/column.js.map +1 -1
- package/dist/esm/core/headers.js +5 -5
- package/dist/esm/core/headers.js.map +1 -1
- package/dist/esm/core/row.d.ts +1 -1
- package/dist/esm/core/row.js +6 -7
- package/dist/esm/core/row.js.map +1 -1
- package/dist/esm/core/table.d.ts +9 -1
- package/dist/esm/core/table.js +12 -8
- package/dist/esm/core/table.js.map +1 -1
- package/dist/esm/features/ColumnFaceting.js +1 -1
- package/dist/esm/features/ColumnFaceting.js.map +1 -1
- package/dist/esm/features/ColumnFiltering.js +6 -6
- package/dist/esm/features/ColumnFiltering.js.map +1 -1
- package/dist/esm/features/ColumnGrouping.js +8 -9
- package/dist/esm/features/ColumnGrouping.js.map +1 -1
- package/dist/esm/features/ColumnOrdering.js +4 -4
- package/dist/esm/features/ColumnOrdering.js.map +1 -1
- package/dist/esm/features/ColumnPinning.js +5 -5
- package/dist/esm/features/ColumnPinning.js.map +1 -1
- package/dist/esm/features/ColumnSizing.js +7 -8
- package/dist/esm/features/ColumnSizing.js.map +1 -1
- package/dist/esm/features/ColumnVisibility.js +5 -5
- package/dist/esm/features/ColumnVisibility.js.map +1 -1
- package/dist/esm/features/GlobalFaceting.js +1 -1
- package/dist/esm/features/GlobalFaceting.js.map +1 -1
- package/dist/esm/features/GlobalFiltering.js +4 -4
- package/dist/esm/features/GlobalFiltering.js.map +1 -1
- package/dist/esm/features/RowExpanding.js +6 -8
- package/dist/esm/features/RowExpanding.js.map +1 -1
- package/dist/esm/features/RowPagination.js +4 -5
- package/dist/esm/features/RowPagination.js.map +1 -1
- package/dist/esm/features/RowPinning.js +5 -6
- package/dist/esm/features/RowPinning.js.map +1 -1
- package/dist/esm/features/RowSelection.js +6 -8
- package/dist/esm/features/RowSelection.js.map +1 -1
- package/dist/esm/features/RowSorting.js +6 -7
- package/dist/esm/features/RowSorting.js.map +1 -1
- package/dist/esm/filterFns.js.map +1 -1
- package/dist/esm/index.js +10 -9
- package/dist/esm/types.d.ts +8 -8
- package/dist/esm/utils/filterRowsUtils.js +3 -3
- package/dist/esm/utils/filterRowsUtils.js.map +1 -1
- package/dist/esm/utils/getCoreRowModel.js +2 -2
- package/dist/esm/utils/getCoreRowModel.js.map +1 -1
- package/dist/esm/utils/getFacetedMinMaxValues.js +1 -2
- package/dist/esm/utils/getFacetedMinMaxValues.js.map +1 -1
- package/dist/esm/utils/getFacetedUniqueValues.js +1 -2
- package/dist/esm/utils/getFacetedUniqueValues.js.map +1 -1
- package/dist/esm/utils/getGroupedRowModel.js +2 -2
- package/dist/esm/utils/getGroupedRowModel.js.map +1 -1
- package/dist/esm/utils/getSortedRowModel.js +3 -6
- package/dist/esm/utils/getSortedRowModel.js.map +1 -1
- package/dist/esm/utils.js +2 -4
- package/dist/esm/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/core/cell.ts +2 -2
- package/src/core/column.ts +2 -2
- package/src/core/headers.ts +5 -5
- package/src/core/row.ts +4 -4
- package/src/core/table.ts +43 -7
- package/src/features/ColumnFaceting.ts +1 -1
- package/src/features/ColumnFiltering.ts +6 -6
- package/src/features/ColumnGrouping.ts +7 -7
- package/src/features/ColumnOrdering.ts +4 -4
- package/src/features/ColumnPinning.ts +5 -5
- package/src/features/ColumnSizing.ts +6 -6
- package/src/features/ColumnVisibility.ts +5 -5
- package/src/features/GlobalFaceting.ts +1 -1
- package/src/features/GlobalFiltering.ts +4 -4
- package/src/features/RowExpanding.ts +4 -4
- package/src/features/RowPagination.ts +3 -3
- package/src/features/RowPinning.ts +4 -4
- package/src/features/RowSelection.ts +4 -4
- package/src/features/RowSorting.ts +5 -5
- package/src/filterFns.ts +2 -2
- package/src/types.ts +8 -8
- package/src/utils/filterRowsUtils.ts +3 -3
- package/src/utils/getCoreRowModel.ts +2 -2
- package/src/utils/getGroupedRowModel.ts +2 -2
- package/src/utils/getSortedRowModel.ts +2 -2
- package/src/utils.ts +6 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.cjs","sources":["../../../src/core/table.ts"],"sourcesContent":["import { functionalUpdate, getMemoOptions, memo, RequiredKeys } from '../utils'\n\nimport {\n Updater,\n TableOptionsResolved,\n TableState,\n Table,\n InitialTableState,\n Row,\n Column,\n RowModel,\n ColumnDef,\n TableOptions,\n RowData,\n TableMeta,\n ColumnDefResolved,\n GroupColumnDef,\n TableFeature,\n} from '../types'\n\n//\nimport { createColumn } from './column'\nimport { Headers } from './headers'\n//\n\nimport { ColumnFaceting } from '../features/ColumnFaceting'\nimport { ColumnFiltering } from '../features/ColumnFiltering'\nimport { ColumnGrouping } from '../features/ColumnGrouping'\nimport { ColumnOrdering } from '../features/ColumnOrdering'\nimport { ColumnPinning } from '../features/ColumnPinning'\nimport { ColumnSizing } from '../features/ColumnSizing'\nimport { ColumnVisibility } from '../features/ColumnVisibility'\nimport { GlobalFaceting } from '../features/GlobalFaceting'\nimport { GlobalFiltering } from '../features/GlobalFiltering'\nimport { RowExpanding } from '../features/RowExpanding'\nimport { RowPagination } from '../features/RowPagination'\nimport { RowPinning } from '../features/RowPinning'\nimport { RowSelection } from '../features/RowSelection'\nimport { RowSorting } from '../features/RowSorting'\n\nconst builtInFeatures = [\n Headers,\n ColumnVisibility,\n ColumnOrdering,\n ColumnPinning,\n ColumnFaceting,\n ColumnFiltering,\n GlobalFaceting, //depends on ColumnFaceting\n GlobalFiltering, //depends on ColumnFiltering\n RowSorting,\n ColumnGrouping, //depends on RowSorting\n RowExpanding,\n RowPagination,\n RowPinning,\n RowSelection,\n ColumnSizing,\n] as const\n\n//\n\nexport interface CoreTableState {}\n\nexport interface CoreOptions<TData extends RowData> {\n /**\n * An array of extra features that you can add to the table instance.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#_features)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n _features?: TableFeature[]\n /**\n * Set this option to override any of the `autoReset...` feature options.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#autoresetall)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n autoResetAll?: boolean\n /**\n * The array of column defs to use for the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#columns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n columns: ColumnDef<TData, any>[]\n /**\n * The data for the table to display. This array should match the type you provided to `table.setRowType<...>`. Columns can access this data via string/index or a functional accessor. When the `data` option changes reference, the table will reprocess the data.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#data)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n data: TData[]\n /**\n * Set this option to `true` to output all debugging information to the console.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#debugall)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n debugAll?: boolean\n /**\n * Set this option to `true` to output cell debugging information to the console.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#debugcells]\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n debugCells?: boolean\n /**\n * Set this option to `true` to output column debugging information to the console.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#debugcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n debugColumns?: boolean\n /**\n * Set this option to `true` to output header debugging information to the console.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#debugheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n debugHeaders?: boolean\n /**\n * Set this option to `true` to output row debugging information to the console.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#debugrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n debugRows?: boolean\n /**\n * Set this option to `true` to output table debugging information to the console.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#debugtable)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n debugTable?: boolean\n /**\n * Default column options to use for all column defs supplied to the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#defaultcolumn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n defaultColumn?: Partial<ColumnDef<TData, unknown>>\n /**\n * This required option is a factory for a function that computes and returns the core row model for the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getcorerowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getCoreRowModel: (table: Table<any>) => () => RowModel<any>\n /**\n * This optional function is used to derive a unique ID for any given row. If not provided the rows index is used (nested rows join together with `.` using their grandparents' index eg. `index.index.index`). If you need to identify individual rows that are originating from any server-side operations, it's suggested you use this function to return an ID that makes sense regardless of network IO/ambiguity eg. a userId, taskId, database ID field, etc.\n * @example getRowId: row => row.userId\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getrowid)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getRowId?: (originalRow: TData, index: number, parent?: Row<TData>) => string\n /**\n * This optional function is used to access the sub rows for any given row. If you are using nested rows, you will need to use this function to return the sub rows object (or undefined) from the row.\n * @example getSubRows: row => row.subRows\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getsubrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getSubRows?: (originalRow: TData, index: number) => undefined | TData[]\n /**\n * Use this option to optionally pass initial state to the table. This state will be used when resetting various table states either automatically by the table (eg. `options.autoResetPageIndex`) or via functions like `table.resetRowSelection()`. Most reset function allow you optionally pass a flag to reset to a blank/default state instead of the initial state.\n *\n * Table state will not be reset when this object changes, which also means that the initial state object does not need to be stable.\n *\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#initialstate)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n initialState?: InitialTableState\n /**\n * This option is used to optionally implement the merging of table options.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#mergeoptions)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n mergeOptions?: (\n defaultOptions: TableOptions<TData>,\n options: Partial<TableOptions<TData>>\n ) => TableOptions<TData>\n /**\n * You can pass any object to `options.meta` and access it anywhere the `table` is available via `table.options.meta`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#meta)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n meta?: TableMeta<TData>\n /**\n * The `onStateChange` option can be used to optionally listen to state changes within the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#onstatechange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n onStateChange: (updater: Updater<TableState>) => void\n /**\n * Value used when the desired value is not found in the data.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#renderfallbackvalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n renderFallbackValue: any\n /**\n * The `state` option can be used to optionally _control_ part or all of the table state. The state you pass here will merge with and overwrite the internal automatically-managed state to produce the final state for the table. You can also listen to state changes via the `onStateChange` option.\n * > Note: Any state passed in here will override both the internal state and any other `initialState` you provide.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#state)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n state: Partial<TableState>\n}\n\nexport interface CoreInstance<TData extends RowData> {\n _features: readonly TableFeature[]\n _getAllFlatColumnsById: () => Record<string, Column<TData, unknown>>\n _getColumnDefs: () => ColumnDef<TData, unknown>[]\n _getCoreRowModel?: () => RowModel<TData>\n _getDefaultColumnDef: () => Partial<ColumnDef<TData, unknown>>\n _getRowId: (_: TData, index: number, parent?: Row<TData>) => string\n _queue: (cb: () => void) => void\n /**\n * Returns all columns in the table in their normalized and nested hierarchy.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getallcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getAllColumns: () => Column<TData, unknown>[]\n /**\n * Returns all columns in the table flattened to a single level.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getallflatcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getAllFlatColumns: () => Column<TData, unknown>[]\n /**\n * Returns all leaf-node columns in the table flattened to a single level. This does not include parent columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getallleafcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getAllLeafColumns: () => Column<TData, unknown>[]\n /**\n * Returns a single column by its ID.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getcolumn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getColumn: (columnId: string) => Column<TData, unknown> | undefined\n /**\n * Returns the core row model before any processing has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getcorerowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getCoreRowModel: () => RowModel<TData>\n /**\n * Returns the row with the given ID.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getrow)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getRow: (id: string, searchAll?: boolean) => Row<TData>\n /**\n * Returns the final model after all processing from other used features has been applied. This is the row model that is most commonly used for rendering.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getRowModel: () => RowModel<TData>\n /**\n * Call this function to get the table's current state. It's recommended to use this function and its state, especially when managing the table state manually. It is the exact same state used internally by the table for every feature and function it provides.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getstate)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getState: () => TableState\n /**\n * This is the resolved initial state of the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#initialstate)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n initialState: TableState\n /**\n * A read-only reference to the table's current options.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#options)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n options: RequiredKeys<TableOptionsResolved<TData>, 'state'>\n /**\n * Call this function to reset the table state to the initial state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#reset)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n reset: () => void\n /**\n * This function can be used to update the table options.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#setoptions)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n setOptions: (newOptions: Updater<TableOptionsResolved<TData>>) => void\n /**\n * Call this function to update the table state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#setstate)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n setState: (updater: Updater<TableState>) => void\n}\n\nexport function createTable<TData extends RowData>(\n options: TableOptionsResolved<TData>\n): Table<TData> {\n if (\n process.env.NODE_ENV !== 'production' &&\n (options.debugAll || options.debugTable)\n ) {\n console.info('Creating Table Instance...')\n }\n\n const _features = [...builtInFeatures, ...(options._features ?? [])]\n\n let table = { _features } as unknown as Table<TData>\n\n const defaultOptions = table._features.reduce((obj, feature) => {\n return Object.assign(obj, feature.getDefaultOptions?.(table))\n }, {}) as TableOptionsResolved<TData>\n\n const mergeOptions = (options: TableOptionsResolved<TData>) => {\n if (table.options.mergeOptions) {\n return table.options.mergeOptions(defaultOptions, options)\n }\n\n return {\n ...defaultOptions,\n ...options,\n }\n }\n\n const coreInitialState: CoreTableState = {}\n\n let initialState = {\n ...coreInitialState,\n ...(options.initialState ?? {}),\n } as TableState\n\n table._features.forEach(feature => {\n initialState = (feature.getInitialState?.(initialState) ??\n initialState) as TableState\n })\n\n const queued: (() => void)[] = []\n let queuedTimeout = false\n\n const coreInstance: CoreInstance<TData> = {\n _features,\n options: {\n ...defaultOptions,\n ...options,\n },\n initialState,\n _queue: cb => {\n queued.push(cb)\n\n if (!queuedTimeout) {\n queuedTimeout = true\n\n // Schedule a microtask to run the queued callbacks after\n // the current call stack (render, etc) has finished.\n Promise.resolve()\n .then(() => {\n while (queued.length) {\n queued.shift()!()\n }\n queuedTimeout = false\n })\n .catch(error =>\n setTimeout(() => {\n throw error\n })\n )\n }\n },\n reset: () => {\n table.setState(table.initialState)\n },\n setOptions: updater => {\n const newOptions = functionalUpdate(updater, table.options)\n table.options = mergeOptions(newOptions) as RequiredKeys<\n TableOptionsResolved<TData>,\n 'state'\n >\n },\n\n getState: () => {\n return table.options.state as TableState\n },\n\n setState: (updater: Updater<TableState>) => {\n table.options.onStateChange?.(updater)\n },\n\n _getRowId: (row: TData, index: number, parent?: Row<TData>) =>\n table.options.getRowId?.(row, index, parent) ??\n `${parent ? [parent.id, index].join('.') : index}`,\n\n getCoreRowModel: () => {\n if (!table._getCoreRowModel) {\n table._getCoreRowModel = table.options.getCoreRowModel(table)\n }\n\n return table._getCoreRowModel!()\n },\n\n // The final calls start at the bottom of the model,\n // expanded rows, which then work their way up\n\n getRowModel: () => {\n return table.getPaginationRowModel()\n },\n //in next version, we should just pass in the row model as the optional 2nd arg\n getRow: (id: string, searchAll?: boolean) => {\n let row = (\n searchAll ? table.getPrePaginationRowModel() : table.getRowModel()\n ).rowsById[id]\n\n if (!row) {\n row = table.getCoreRowModel().rowsById[id]\n if (!row) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(`getRow could not find row with ID: ${id}`)\n }\n throw new Error()\n }\n }\n\n return row\n },\n _getDefaultColumnDef: memo(\n () => [table.options.defaultColumn],\n defaultColumn => {\n defaultColumn = (defaultColumn ?? {}) as Partial<\n ColumnDef<TData, unknown>\n >\n\n return {\n header: props => {\n const resolvedColumnDef = props.header.column\n .columnDef as ColumnDefResolved<TData>\n\n if (resolvedColumnDef.accessorKey) {\n return resolvedColumnDef.accessorKey\n }\n\n if (resolvedColumnDef.accessorFn) {\n return resolvedColumnDef.id\n }\n\n return null\n },\n // footer: props => props.header.column.id,\n cell: props => props.renderValue<any>()?.toString?.() ?? null,\n ...table._features.reduce((obj, feature) => {\n return Object.assign(obj, feature.getDefaultColumnDef?.())\n }, {}),\n ...defaultColumn,\n } as Partial<ColumnDef<TData, unknown>>\n },\n getMemoOptions(options, 'debugColumns', '_getDefaultColumnDef')\n ),\n\n _getColumnDefs: () => table.options.columns,\n\n getAllColumns: memo(\n () => [table._getColumnDefs()],\n columnDefs => {\n const recurseColumns = (\n columnDefs: ColumnDef<TData, unknown>[],\n parent?: Column<TData, unknown>,\n depth = 0\n ): Column<TData, unknown>[] => {\n return columnDefs.map(columnDef => {\n const column = createColumn(table, columnDef, depth, parent)\n\n const groupingColumnDef = columnDef as GroupColumnDef<\n TData,\n unknown\n >\n\n column.columns = groupingColumnDef.columns\n ? recurseColumns(groupingColumnDef.columns, column, depth + 1)\n : []\n\n return column\n })\n }\n\n return recurseColumns(columnDefs)\n },\n getMemoOptions(options, 'debugColumns', 'getAllColumns')\n ),\n\n getAllFlatColumns: memo(\n () => [table.getAllColumns()],\n allColumns => {\n return allColumns.flatMap(column => {\n return column.getFlatColumns()\n })\n },\n getMemoOptions(options, 'debugColumns', 'getAllFlatColumns')\n ),\n\n _getAllFlatColumnsById: memo(\n () => [table.getAllFlatColumns()],\n flatColumns => {\n return flatColumns.reduce(\n (acc, column) => {\n acc[column.id] = column\n return acc\n },\n {} as Record<string, Column<TData, unknown>>\n )\n },\n getMemoOptions(options, 'debugColumns', 'getAllFlatColumnsById')\n ),\n\n getAllLeafColumns: memo(\n () => [table.getAllColumns(), table._getOrderColumnsFn()],\n (allColumns, orderColumns) => {\n let leafColumns = allColumns.flatMap(column => column.getLeafColumns())\n return orderColumns(leafColumns)\n },\n getMemoOptions(options, 'debugColumns', 'getAllLeafColumns')\n ),\n\n getColumn: columnId => {\n const column = table._getAllFlatColumnsById()[columnId]\n\n if (process.env.NODE_ENV !== 'production' && !column) {\n console.error(`[Table] Column with id '${columnId}' does not exist.`)\n }\n\n return column\n },\n }\n\n Object.assign(table, coreInstance)\n\n for (let index = 0; index < table._features.length; index++) {\n const feature = table._features[index]\n feature?.createTable?.(table)\n }\n\n return table\n}\n"],"names":["Headers","ColumnVisibility","ColumnOrdering","ColumnPinning","ColumnFaceting","ColumnFiltering","GlobalFaceting","GlobalFiltering","RowSorting","ColumnGrouping","RowExpanding","RowPagination","RowPinning","RowSelection","ColumnSizing","_a","options","functionalUpdate","memo","getMemoOptions","columnDefs","column","createColumn"],"mappings":";;;;;;;;;;;;;;;;;;;AAwCA,MAAM,kBAAkB;AAAA,EACtBA,QAAA;AAAA,EACAC,iBAAA;AAAA,EACAC,eAAA;AAAA,EACAC,cAAA;AAAA,EACAC,eAAA;AAAA,EACAC,gBAAA;AAAA,EACAC,eAAA;AAAA;AAAA,EACAC,gBAAA;AAAA;AAAA,EACAC,WAAA;AAAA,EACAC,eAAA;AAAA;AAAA,EACAC,aAAA;AAAA,EACAC,cAAA;AAAA,EACAC,WAAA;AAAA,EACAC,aAAA;AAAA,EACAC,aAAA;AACF;AAkOO,SAAS,YACd,SACc;;AACd,MACE,QAAQ,IAAI,aAAa,iBACxB,QAAQ,YAAY,QAAQ,aAC7B;AACA,YAAQ,KAAK,4BAA4B;AAAA,EAC3C;AAEM,QAAA,YAAY,CAAC,GAAG,iBAAiB,GAAI,QAAQ,aAAa,CAAA,CAAG;AAE/D,MAAA,QAAQ,EAAE;AAEd,QAAM,iBAAiB,MAAM,UAAU,OAAO,CAAC,KAAK,YAAY;;AAC9D,WAAO,OAAO,OAAO,MAAKC,MAAA,QAAQ,sBAAR,gBAAAA,IAAA,cAA4B,MAAM;AAAA,EAC9D,GAAG,CAAE,CAAA;AAEC,QAAA,eAAe,CAACC,aAAyC;AACzD,QAAA,MAAM,QAAQ,cAAc;AAC9B,aAAO,MAAM,QAAQ,aAAa,gBAAgBA,QAAO;AAAA,IAC3D;AAEO,WAAA;AAAA,MACL,GAAG;AAAA,MACH,GAAGA;AAAAA,IAAA;AAAA,EACL;AAGF,QAAM,mBAAmC,CAAA;AAEzC,MAAI,eAAe;AAAA,IACjB,GAAG;AAAA,IACH,GAAI,QAA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F,qBAAe,SAAS,gBAAgB,mBAAmB;AAAA,IAC7D;AAAA,IAEA,WAAW,CAAY,aAAA;AACrB,YAAME,UAAS,MAAM,uBAAuB,EAAE,QAAQ;AAEtD,UAAI,QAAQ,IAAI,aAAa,gBAAgB,CAACA,SAAQ;AAC5C,gBAAA,MAAM,2BAA2B,QAAQ,mBAAmB;AAAA,MACtE;AAEO,aAAAA;AAAA,IACT;AAAA,EAAA;AAGK,SAAA,OAAO,OAAO,YAAY;AAEjC,WAAS,QAAQ,GAAG,QAAQ,MAAM,UAAU,QAAQ,SAAS;AACrD,UAAA,UAAU,MAAM,UAAU,KAAK;AACrC,6CAAS,gBAAT,iCAAuB;AAAA,EACzB;AAEO,SAAA;AACT;;"}
|
|
1
|
+
{"version":3,"file":"table.cjs","sources":["../../../src/core/table.ts"],"sourcesContent":["import { functionalUpdate, getMemoOptions, memo, RequiredKeys } from '../utils'\n\nimport {\n Updater,\n TableOptionsResolved,\n TableState,\n Table,\n InitialTableState,\n Row,\n Column,\n RowModel,\n ColumnDef,\n TableOptions,\n RowData,\n TableMeta,\n ColumnDefResolved,\n GroupColumnDef,\n TableFeature,\n} from '../types'\n\n//\nimport { _createColumn } from './column'\nimport { Headers } from './headers'\n//\n\nimport { ColumnFaceting } from '../features/ColumnFaceting'\nimport { ColumnFiltering } from '../features/ColumnFiltering'\nimport { ColumnGrouping } from '../features/ColumnGrouping'\nimport { ColumnOrdering } from '../features/ColumnOrdering'\nimport { ColumnPinning } from '../features/ColumnPinning'\nimport { ColumnSizing } from '../features/ColumnSizing'\nimport { ColumnVisibility } from '../features/ColumnVisibility'\nimport { GlobalFaceting } from '../features/GlobalFaceting'\nimport { GlobalFiltering } from '../features/GlobalFiltering'\nimport { RowExpanding } from '../features/RowExpanding'\nimport { RowPagination } from '../features/RowPagination'\nimport { RowPinning } from '../features/RowPinning'\nimport { RowSelection } from '../features/RowSelection'\nimport { RowSorting } from '../features/RowSorting'\n\nconst builtInFeatures = [\n Headers,\n ColumnVisibility,\n ColumnOrdering,\n ColumnPinning,\n ColumnFaceting,\n ColumnFiltering,\n GlobalFaceting, //depends on ColumnFaceting\n GlobalFiltering, //depends on ColumnFiltering\n RowSorting,\n ColumnGrouping, //depends on RowSorting\n RowExpanding,\n RowPagination,\n RowPinning,\n RowSelection,\n ColumnSizing,\n] as const\n\n//\n\nexport interface CoreTableState {}\n\nexport interface CoreOptions<TData extends RowData> {\n /**\n * An array of extra features that you can add to the table instance.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#_features)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n _features?: TableFeature[]\n /**\n * Set this option to override any of the `autoReset...` feature options.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#autoresetall)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n autoResetAll?: boolean\n /**\n * The array of column defs to use for the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#columns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n columns: ColumnDef<TData, any>[]\n /**\n * The data for the table to display. This array should match the type you provided to `table.setRowType<...>`. Columns can access this data via string/index or a functional accessor. When the `data` option changes reference, the table will reprocess the data.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#data)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n data: TData[]\n /**\n * Set this option to `true` to output all debugging information to the console.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#debugall)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n debugAll?: boolean\n /**\n * Set this option to `true` to output cell debugging information to the console.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#debugcells]\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n debugCells?: boolean\n /**\n * Set this option to `true` to output column debugging information to the console.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#debugcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n debugColumns?: boolean\n /**\n * Set this option to `true` to output header debugging information to the console.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#debugheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n debugHeaders?: boolean\n /**\n * Set this option to `true` to output row debugging information to the console.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#debugrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n debugRows?: boolean\n /**\n * Set this option to `true` to output table debugging information to the console.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#debugtable)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n debugTable?: boolean\n /**\n * Default column options to use for all column defs supplied to the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#defaultcolumn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n defaultColumn?: Partial<ColumnDef<TData, unknown>>\n /**\n * This required option is a factory for a function that computes and returns the core row model for the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getcorerowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getCoreRowModel: (table: Table<any>) => () => RowModel<any>\n /**\n * This optional function is used to derive a unique ID for any given row. If not provided the rows index is used (nested rows join together with `.` using their grandparents' index eg. `index.index.index`). If you need to identify individual rows that are originating from any server-side operations, it's suggested you use this function to return an ID that makes sense regardless of network IO/ambiguity eg. a userId, taskId, database ID field, etc.\n * @example getRowId: row => row.userId\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getrowid)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getRowId?: (originalRow: TData, index: number, parent?: Row<TData>) => string\n /**\n * This optional function is used to access the sub rows for any given row. If you are using nested rows, you will need to use this function to return the sub rows object (or undefined) from the row.\n * @example getSubRows: row => row.subRows\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getsubrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getSubRows?: (originalRow: TData, index: number) => undefined | TData[]\n /**\n * Use this option to optionally pass initial state to the table. This state will be used when resetting various table states either automatically by the table (eg. `options.autoResetPageIndex`) or via functions like `table.resetRowSelection()`. Most reset function allow you optionally pass a flag to reset to a blank/default state instead of the initial state.\n *\n * Table state will not be reset when this object changes, which also means that the initial state object does not need to be stable.\n *\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#initialstate)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n initialState?: InitialTableState\n /**\n * This option is used to optionally implement the merging of table options.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#mergeoptions)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n mergeOptions?: (\n defaultOptions: TableOptions<TData>,\n options: Partial<TableOptions<TData>>\n ) => TableOptions<TData>\n /**\n * You can pass any object to `options.meta` and access it anywhere the `table` is available via `table.options.meta`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#meta)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n meta?: TableMeta<TData>\n /**\n * The `onStateChange` option can be used to optionally listen to state changes within the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#onstatechange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n onStateChange: (updater: Updater<TableState>) => void\n /**\n * Value used when the desired value is not found in the data.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#renderfallbackvalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n renderFallbackValue: any\n /**\n * The `state` option can be used to optionally _control_ part or all of the table state. The state you pass here will merge with and overwrite the internal automatically-managed state to produce the final state for the table. You can also listen to state changes via the `onStateChange` option.\n * > Note: Any state passed in here will override both the internal state and any other `initialState` you provide.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#state)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n state: Partial<TableState>\n}\n\nexport function tableOptions<TData extends RowData = any>(\n options: Omit<TableOptions<TData>, 'columns'>\n): Omit<TableOptions<TData>, 'columns'>\n\nexport function tableOptions<TData extends RowData = any>(\n options: Omit<TableOptions<TData>, 'data'>\n): Omit<TableOptions<TData>, 'data'>\n\nexport function tableOptions<TData extends RowData = any>(\n options: Omit<TableOptions<TData>, 'getCoreRowModel'>\n): Omit<TableOptions<TData>, 'getCoreRowModel'>\n\nexport function tableOptions<TData extends RowData = any>(\n options: Omit<TableOptions<TData>, 'data' | 'columns'>\n): Omit<TableOptions<TData>, 'data' | 'columns'>\n\nexport function tableOptions<TData extends RowData = any>(\n options: Omit<TableOptions<TData>, 'getCoreRowModel' | 'columns'>\n): Omit<TableOptions<TData>, 'getCoreRowModel' | 'columns'>\n\nexport function tableOptions<TData extends RowData = any>(\n options: Omit<TableOptions<TData>, 'data' | 'getCoreRowModel'>\n): Omit<TableOptions<TData>, 'data' | 'getCoreRowModel'>\n\nexport function tableOptions<TData extends RowData = any>(\n options: Omit<TableOptions<TData>, 'data' | 'columns' | 'getCoreRowModel'>\n): Omit<TableOptions<TData>, 'data' | 'columns' | 'getCoreRowModel'>\n\nexport function tableOptions<TData extends RowData = any>(\n options: TableOptions<TData>\n): TableOptions<TData>\n\nexport function tableOptions(options: unknown) {\n return options\n}\n\nexport interface CoreInstance<TData extends RowData> {\n _features: readonly TableFeature[]\n _getAllFlatColumnsById: () => Record<string, Column<TData, unknown>>\n _getColumnDefs: () => ColumnDef<TData, unknown>[]\n _getCoreRowModel?: () => RowModel<TData>\n _getDefaultColumnDef: () => Partial<ColumnDef<TData, unknown>>\n _getRowId: (_: TData, index: number, parent?: Row<TData>) => string\n _queue: (cb: () => void) => void\n /**\n * Returns all columns in the table in their normalized and nested hierarchy.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getallcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getAllColumns: () => Column<TData, unknown>[]\n /**\n * Returns all columns in the table flattened to a single level.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getallflatcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getAllFlatColumns: () => Column<TData, unknown>[]\n /**\n * Returns all leaf-node columns in the table flattened to a single level. This does not include parent columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getallleafcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getAllLeafColumns: () => Column<TData, unknown>[]\n /**\n * Returns a single column by its ID.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getcolumn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getColumn: (columnId: string) => Column<TData, unknown> | undefined\n /**\n * Returns the core row model before any processing has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getcorerowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getCoreRowModel: () => RowModel<TData>\n /**\n * Returns the row with the given ID.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getrow)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getRow: (id: string, searchAll?: boolean) => Row<TData>\n /**\n * Returns the final model after all processing from other used features has been applied. This is the row model that is most commonly used for rendering.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getRowModel: () => RowModel<TData>\n /**\n * Call this function to get the table's current state. It's recommended to use this function and its state, especially when managing the table state manually. It is the exact same state used internally by the table for every feature and function it provides.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#getstate)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n getState: () => TableState\n /**\n * This is the resolved initial state of the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#initialstate)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n initialState: TableState\n /**\n * A read-only reference to the table's current options.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#options)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n options: RequiredKeys<TableOptionsResolved<TData>, 'state'>\n /**\n * Call this function to reset the table state to the initial state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#reset)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n reset: () => void\n /**\n * This function can be used to update the table options.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#setoptions)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n setOptions: (newOptions: Updater<TableOptionsResolved<TData>>) => void\n /**\n * Call this function to update the table state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/table#setstate)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/tables)\n */\n setState: (updater: Updater<TableState>) => void\n}\n\nexport function _createTable<TData extends RowData>(\n options: TableOptionsResolved<TData>\n): Table<TData> {\n if (\n process.env.NODE_ENV !== 'production' &&\n (options.debugAll || options.debugTable)\n ) {\n console.info('Creating Table Instance...')\n }\n\n const _features = [...builtInFeatures, ...(options._features ?? [])]\n\n let table = { _features } as unknown as Table<TData>\n\n const defaultOptions = table._features.reduce((obj, feature) => {\n return Object.assign(obj, feature._getDefaultOptions?.(table))\n }, {}) as TableOptionsResolved<TData>\n\n const mergeOptions = (options: TableOptionsResolved<TData>) => {\n if (table.options.mergeOptions) {\n return table.options.mergeOptions(defaultOptions, options)\n }\n\n return {\n ...defaultOptions,\n ...options,\n }\n }\n\n const coreInitialState: CoreTableState = {}\n\n let initialState = {\n ...coreInitialState,\n ...(options.initialState ?? {}),\n } as TableState\n\n table._features.forEach(feature => {\n initialState = (feature._getInitialState?.(initialState) ??\n initialState) as TableState\n })\n\n const queued: (() => void)[] = []\n let queuedTimeout = false\n\n const coreInstance: CoreInstance<TData> = {\n _features,\n options: {\n ...defaultOptions,\n ...options,\n },\n initialState,\n _queue: cb => {\n queued.push(cb)\n\n if (!queuedTimeout) {\n queuedTimeout = true\n\n // Schedule a microtask to run the queued callbacks after\n // the current call stack (render, etc) has finished.\n Promise.resolve()\n .then(() => {\n while (queued.length) {\n queued.shift()!()\n }\n queuedTimeout = false\n })\n .catch(error =>\n setTimeout(() => {\n throw error\n })\n )\n }\n },\n reset: () => {\n table.setState(table.initialState)\n },\n setOptions: updater => {\n const newOptions = functionalUpdate(updater, table.options)\n table.options = mergeOptions(newOptions) as RequiredKeys<\n TableOptionsResolved<TData>,\n 'state'\n >\n },\n\n getState: () => {\n return table.options.state as TableState\n },\n\n setState: (updater: Updater<TableState>) => {\n table.options.onStateChange?.(updater)\n },\n\n _getRowId: (row: TData, index: number, parent?: Row<TData>) =>\n table.options.getRowId?.(row, index, parent) ??\n `${parent ? [parent.id, index].join('.') : index}`,\n\n getCoreRowModel: () => {\n if (!table._getCoreRowModel) {\n table._getCoreRowModel = table.options.getCoreRowModel(table)\n }\n\n return table._getCoreRowModel!()\n },\n\n // The final calls start at the bottom of the model,\n // expanded rows, which then work their way up\n\n getRowModel: () => {\n return table.getPaginationRowModel()\n },\n //in next version, we should just pass in the row model as the optional 2nd arg\n getRow: (id: string, searchAll?: boolean) => {\n let row = (\n searchAll ? table.getPrePaginationRowModel() : table.getRowModel()\n ).rowsById[id]\n\n if (!row) {\n row = table.getCoreRowModel().rowsById[id]\n if (!row) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(`getRow could not find row with ID: ${id}`)\n }\n throw new Error()\n }\n }\n\n return row\n },\n _getDefaultColumnDef: memo(\n () => [table.options.defaultColumn],\n defaultColumn => {\n defaultColumn = (defaultColumn ?? {}) as Partial<\n ColumnDef<TData, unknown>\n >\n\n return {\n header: props => {\n const resolvedColumnDef = props.header.column\n .columnDef as ColumnDefResolved<TData>\n\n if (resolvedColumnDef.accessorKey) {\n return resolvedColumnDef.accessorKey\n }\n\n if (resolvedColumnDef.accessorFn) {\n return resolvedColumnDef.id\n }\n\n return null\n },\n // footer: props => props.header.column.id,\n cell: props => props.renderValue<any>()?.toString?.() ?? null,\n ...table._features.reduce((obj, feature) => {\n return Object.assign(obj, feature._getDefaultColumnDef?.())\n }, {}),\n ...defaultColumn,\n } as Partial<ColumnDef<TData, unknown>>\n },\n getMemoOptions(options, 'debugColumns', '_getDefaultColumnDef')\n ),\n\n _getColumnDefs: () => table.options.columns,\n\n getAllColumns: memo(\n () => [table._getColumnDefs()],\n columnDefs => {\n const recurseColumns = (\n columnDefs: ColumnDef<TData, unknown>[],\n parent?: Column<TData, unknown>,\n depth = 0\n ): Column<TData, unknown>[] => {\n return columnDefs.map(columnDef => {\n const column = _createColumn(table, columnDef, depth, parent)\n\n const groupingColumnDef = columnDef as GroupColumnDef<\n TData,\n unknown\n >\n\n column.columns = groupingColumnDef.columns\n ? recurseColumns(groupingColumnDef.columns, column, depth + 1)\n : []\n\n return column\n })\n }\n\n return recurseColumns(columnDefs)\n },\n getMemoOptions(options, 'debugColumns', 'getAllColumns')\n ),\n\n getAllFlatColumns: memo(\n () => [table.getAllColumns()],\n allColumns => {\n return allColumns.flatMap(column => {\n return column.getFlatColumns()\n })\n },\n getMemoOptions(options, 'debugColumns', 'getAllFlatColumns')\n ),\n\n _getAllFlatColumnsById: memo(\n () => [table.getAllFlatColumns()],\n flatColumns => {\n return flatColumns.reduce(\n (acc, column) => {\n acc[column.id] = column\n return acc\n },\n {} as Record<string, Column<TData, unknown>>\n )\n },\n getMemoOptions(options, 'debugColumns', 'getAllFlatColumnsById')\n ),\n\n getAllLeafColumns: memo(\n () => [table.getAllColumns(), table._getOrderColumnsFn()],\n (allColumns, orderColumns) => {\n let leafColumns = allColumns.flatMap(column => column.getLeafColumns())\n return orderColumns(leafColumns)\n },\n getMemoOptions(options, 'debugColumns', 'getAllLeafColumns')\n ),\n\n getColumn: columnId => {\n const column = table._getAllFlatColumnsById()[columnId]\n\n if (process.env.NODE_ENV !== 'production' && !column) {\n console.error(`[Table] Column with id '${columnId}' does not exist.`)\n }\n\n return column\n },\n }\n\n Object.assign(table, coreInstance)\n\n for (let index = 0; index < table._features.length; index++) {\n const feature = table._features[index]\n feature?._createTable?.(table)\n }\n\n return table\n}\n"],"names":["Headers","ColumnVisibility","ColumnOrdering","ColumnPinning","ColumnFaceting","ColumnFiltering","GlobalFaceting","GlobalFiltering","RowSorting","ColumnGrouping","RowExpanding","RowPagination","RowPinning","RowSelection","ColumnSizing","_a","options","functionalUpdate","memo","getMemoOptions","columnDefs","column","_createColumn"],"mappings":";;;;;;;;;;;;;;;;;;;AAwCA,MAAM,kBAAkB;AAAA,EACtBA,QAAA;AAAA,EACAC,iBAAA;AAAA,EACAC,eAAA;AAAA,EACAC,cAAA;AAAA,EACAC,eAAA;AAAA,EACAC,gBAAA;AAAA,EACAC,eAAA;AAAA;AAAA,EACAC,gBAAA;AAAA;AAAA,EACAC,WAAA;AAAA,EACAC,eAAA;AAAA;AAAA,EACAC,aAAA;AAAA,EACAC,cAAA;AAAA,EACAC,WAAA;AAAA,EACAC,aAAA;AAAA,EACAC,aAAA;AACF;AA0KO,SAAS,aAAa,SAAkB;AACtC,SAAA;AACT;AA0FO,SAAS,aACd,SACc;;AACd,MACE,QAAQ,IAAI,aAAa,iBACxB,QAAQ,YAAY,QAAQ,aAC7B;AACA,YAAQ,KAAK,4BAA4B;AAAA,EAC3C;AAEM,QAAA,YAAY,CAAC,GAAG,iBAAiB,GAAI,QAAQ,aAAa,CAAA,CAAG;AAE/D,MAAA,QAAQ,EAAE;AAEd,QAAM,iBAAiB,MAAM,UAAU,OAAO,CAAC,KAAK,YAAY;;AAC9D,WAAO,OAAO,OAAO,MAAKC,MAAA,QAAQ,uBAAR,gBAAAA,IAAA,cAA6B,MAAM;AAAA,EAC/D,GAAG,CAAE,CAAA;AAEC,QAAA,eAAe,CAACC,aAAyC;AACzD,QAAA,MAAM,QAAQ,cAAc;AAC9B,aAAO,MAAM,QAAQ,aAAa,gBAAgBA,QAAO;AAAA,IAC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AAA,MAAM,oBAAoB;AAAA,MACxD,CAAC,YAAY,iBAAiB;AAC5B,YAAI,cAAc,WAAW,QAAQ,CAAUG,YAAAA,QAAO,gBAAgB;AACtE,eAAO,aAAa,WAAW;AAAA,MACjC;AAAA,MACAF,qBAAe,SAAS,gBAAgB,mBAAmB;AAAA,IAC7D;AAAA,IAEA,WAAW,CAAY,aAAA;AACrB,YAAME,UAAS,MAAM,uBAAuB,EAAE,QAAQ;AAEtD,UAAI,QAAQ,IAAI,aAAa,gBAAgB,CAACA,SAAQ;AAC5C,gBAAA,MAAM,2BAA2B,QAAQ,mBAAmB;AAAA,MACtE;AAEO,aAAAA;AAAA,IACT;AAAA,EAAA;AAGK,SAAA,OAAO,OAAO,YAAY;AAEjC,WAAS,QAAQ,GAAG,QAAQ,MAAM,UAAU,QAAQ,SAAS;AACrD,UAAA,UAAU,MAAM,UAAU,KAAK;AACrC,6CAAS,iBAAT,iCAAwB;AAAA,EAC1B;AAEO,SAAA;AACT;;;"}
|
|
@@ -131,6 +131,14 @@ export interface CoreOptions<TData extends RowData> {
|
|
|
131
131
|
*/
|
|
132
132
|
state: Partial<TableState>;
|
|
133
133
|
}
|
|
134
|
+
export declare function tableOptions<TData extends RowData = any>(options: Omit<TableOptions<TData>, 'columns'>): Omit<TableOptions<TData>, 'columns'>;
|
|
135
|
+
export declare function tableOptions<TData extends RowData = any>(options: Omit<TableOptions<TData>, 'data'>): Omit<TableOptions<TData>, 'data'>;
|
|
136
|
+
export declare function tableOptions<TData extends RowData = any>(options: Omit<TableOptions<TData>, 'getCoreRowModel'>): Omit<TableOptions<TData>, 'getCoreRowModel'>;
|
|
137
|
+
export declare function tableOptions<TData extends RowData = any>(options: Omit<TableOptions<TData>, 'data' | 'columns'>): Omit<TableOptions<TData>, 'data' | 'columns'>;
|
|
138
|
+
export declare function tableOptions<TData extends RowData = any>(options: Omit<TableOptions<TData>, 'getCoreRowModel' | 'columns'>): Omit<TableOptions<TData>, 'getCoreRowModel' | 'columns'>;
|
|
139
|
+
export declare function tableOptions<TData extends RowData = any>(options: Omit<TableOptions<TData>, 'data' | 'getCoreRowModel'>): Omit<TableOptions<TData>, 'data' | 'getCoreRowModel'>;
|
|
140
|
+
export declare function tableOptions<TData extends RowData = any>(options: Omit<TableOptions<TData>, 'data' | 'columns' | 'getCoreRowModel'>): Omit<TableOptions<TData>, 'data' | 'columns' | 'getCoreRowModel'>;
|
|
141
|
+
export declare function tableOptions<TData extends RowData = any>(options: TableOptions<TData>): TableOptions<TData>;
|
|
134
142
|
export interface CoreInstance<TData extends RowData> {
|
|
135
143
|
_features: readonly TableFeature[];
|
|
136
144
|
_getAllFlatColumnsById: () => Record<string, Column<TData, unknown>>;
|
|
@@ -218,4 +226,4 @@ export interface CoreInstance<TData extends RowData> {
|
|
|
218
226
|
*/
|
|
219
227
|
setState: (updater: Updater<TableState>) => void;
|
|
220
228
|
}
|
|
221
|
-
export declare function
|
|
229
|
+
export declare function _createTable<TData extends RowData>(options: TableOptionsResolved<TData>): Table<TData>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const ColumnFaceting = {
|
|
4
|
-
|
|
4
|
+
_createColumn: (column, table) => {
|
|
5
5
|
column._getFacetedRowModel = table.options.getFacetedRowModel && table.options.getFacetedRowModel(table, column.id);
|
|
6
6
|
column.getFacetedRowModel = () => {
|
|
7
7
|
if (!column._getFacetedRowModel) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColumnFaceting.cjs","sources":["../../../src/features/ColumnFaceting.ts"],"sourcesContent":["import { RowModel } from '..'\nimport { Column, RowData, Table, TableFeature } from '../types'\n\nexport interface FacetedColumn<TData extends RowData> {\n _getFacetedMinMaxValues?: () => undefined | [number, number]\n _getFacetedRowModel?: () => RowModel<TData>\n _getFacetedUniqueValues?: () => Map<any, number>\n /**\n * A function that **computes and returns** a min/max tuple derived from `column.getFacetedRowModel`. Useful for displaying faceted result values.\n * > ⚠️ Requires that you pass a valid `getFacetedMinMaxValues` function to `options.getFacetedMinMaxValues`. A default implementation is provided via the exported `getFacetedMinMaxValues` function.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-faceting#getfacetedminmaxvalues)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-faceting)\n */\n getFacetedMinMaxValues: () => undefined | [number, number]\n /**\n * Returns the row model with all other column filters applied, excluding its own filter. Useful for displaying faceted result counts.\n * > ⚠️ Requires that you pass a valid `getFacetedRowModel` function to `options.facetedRowModel`. A default implementation is provided via the exported `getFacetedRowModel` function.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-faceting#getfacetedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-faceting)\n */\n getFacetedRowModel: () => RowModel<TData>\n /**\n * A function that **computes and returns** a `Map` of unique values and their occurrences derived from `column.getFacetedRowModel`. Useful for displaying faceted result values.\n * > ⚠️ Requires that you pass a valid `getFacetedUniqueValues` function to `options.getFacetedUniqueValues`. A default implementation is provided via the exported `getFacetedUniqueValues` function.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-faceting#getfaceteduniquevalues)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-faceting)\n */\n getFacetedUniqueValues: () => Map<any, number>\n}\n\nexport interface FacetedOptions<TData extends RowData> {\n getFacetedMinMaxValues?: (\n table: Table<TData>,\n columnId: string\n ) => () => undefined | [number, number]\n getFacetedRowModel?: (\n table: Table<TData>,\n columnId: string\n ) => () => RowModel<TData>\n getFacetedUniqueValues?: (\n table: Table<TData>,\n columnId: string\n ) => () => Map<any, number>\n}\n\n//\n\nexport const ColumnFaceting: TableFeature = {\n
|
|
1
|
+
{"version":3,"file":"ColumnFaceting.cjs","sources":["../../../src/features/ColumnFaceting.ts"],"sourcesContent":["import { RowModel } from '..'\nimport { Column, RowData, Table, TableFeature } from '../types'\n\nexport interface FacetedColumn<TData extends RowData> {\n _getFacetedMinMaxValues?: () => undefined | [number, number]\n _getFacetedRowModel?: () => RowModel<TData>\n _getFacetedUniqueValues?: () => Map<any, number>\n /**\n * A function that **computes and returns** a min/max tuple derived from `column.getFacetedRowModel`. Useful for displaying faceted result values.\n * > ⚠️ Requires that you pass a valid `getFacetedMinMaxValues` function to `options.getFacetedMinMaxValues`. A default implementation is provided via the exported `getFacetedMinMaxValues` function.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-faceting#getfacetedminmaxvalues)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-faceting)\n */\n getFacetedMinMaxValues: () => undefined | [number, number]\n /**\n * Returns the row model with all other column filters applied, excluding its own filter. Useful for displaying faceted result counts.\n * > ⚠️ Requires that you pass a valid `getFacetedRowModel` function to `options.facetedRowModel`. A default implementation is provided via the exported `getFacetedRowModel` function.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-faceting#getfacetedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-faceting)\n */\n getFacetedRowModel: () => RowModel<TData>\n /**\n * A function that **computes and returns** a `Map` of unique values and their occurrences derived from `column.getFacetedRowModel`. Useful for displaying faceted result values.\n * > ⚠️ Requires that you pass a valid `getFacetedUniqueValues` function to `options.getFacetedUniqueValues`. A default implementation is provided via the exported `getFacetedUniqueValues` function.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-faceting#getfaceteduniquevalues)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-faceting)\n */\n getFacetedUniqueValues: () => Map<any, number>\n}\n\nexport interface FacetedOptions<TData extends RowData> {\n getFacetedMinMaxValues?: (\n table: Table<TData>,\n columnId: string\n ) => () => undefined | [number, number]\n getFacetedRowModel?: (\n table: Table<TData>,\n columnId: string\n ) => () => RowModel<TData>\n getFacetedUniqueValues?: (\n table: Table<TData>,\n columnId: string\n ) => () => Map<any, number>\n}\n\n//\n\nexport const ColumnFaceting: TableFeature = {\n _createColumn: <TData extends RowData>(\n column: Column<TData, unknown>,\n table: Table<TData>\n ): void => {\n column._getFacetedRowModel =\n table.options.getFacetedRowModel &&\n table.options.getFacetedRowModel(table, column.id)\n column.getFacetedRowModel = () => {\n if (!column._getFacetedRowModel) {\n return table.getPreFilteredRowModel()\n }\n\n return column._getFacetedRowModel()\n }\n column._getFacetedUniqueValues =\n table.options.getFacetedUniqueValues &&\n table.options.getFacetedUniqueValues(table, column.id)\n column.getFacetedUniqueValues = () => {\n if (!column._getFacetedUniqueValues) {\n return new Map()\n }\n\n return column._getFacetedUniqueValues()\n }\n column._getFacetedMinMaxValues =\n table.options.getFacetedMinMaxValues &&\n table.options.getFacetedMinMaxValues(table, column.id)\n column.getFacetedMinMaxValues = () => {\n if (!column._getFacetedMinMaxValues) {\n return undefined\n }\n\n return column._getFacetedMinMaxValues()\n }\n },\n}\n"],"names":[],"mappings":";;AA+CO,MAAM,iBAA+B;AAAA,EAC1C,eAAe,CACb,QACA,UACS;AACF,WAAA,sBACL,MAAM,QAAQ,sBACd,MAAM,QAAQ,mBAAmB,OAAO,OAAO,EAAE;AACnD,WAAO,qBAAqB,MAAM;AAC5B,UAAA,CAAC,OAAO,qBAAqB;AAC/B,eAAO,MAAM;MACf;AAEA,aAAO,OAAO;IAAoB;AAE7B,WAAA,0BACL,MAAM,QAAQ,0BACd,MAAM,QAAQ,uBAAuB,OAAO,OAAO,EAAE;AACvD,WAAO,yBAAyB,MAAM;AAChC,UAAA,CAAC,OAAO,yBAAyB;AACnC,mCAAW,IAAI;AAAA,MACjB;AAEA,aAAO,OAAO;IAAwB;AAEjC,WAAA,0BACL,MAAM,QAAQ,0BACd,MAAM,QAAQ,uBAAuB,OAAO,OAAO,EAAE;AACvD,WAAO,yBAAyB,MAAM;AAChC,UAAA,CAAC,OAAO,yBAAyB;AAC5B,eAAA;AAAA,MACT;AAEA,aAAO,OAAO;IAAwB;AAAA,EAE1C;AACF;;"}
|
|
@@ -3,25 +3,25 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const filterFns = require("../filterFns.cjs");
|
|
4
4
|
const utils = require("../utils.cjs");
|
|
5
5
|
const ColumnFiltering = {
|
|
6
|
-
|
|
6
|
+
_getDefaultColumnDef: () => {
|
|
7
7
|
return {
|
|
8
8
|
filterFn: "auto"
|
|
9
9
|
};
|
|
10
10
|
},
|
|
11
|
-
|
|
11
|
+
_getInitialState: (state) => {
|
|
12
12
|
return {
|
|
13
13
|
columnFilters: [],
|
|
14
14
|
...state
|
|
15
15
|
};
|
|
16
16
|
},
|
|
17
|
-
|
|
17
|
+
_getDefaultOptions: (table) => {
|
|
18
18
|
return {
|
|
19
19
|
onColumnFiltersChange: utils.makeStateUpdater("columnFilters", table),
|
|
20
20
|
filterFromLeafRows: false,
|
|
21
21
|
maxLeafRowFilterDepth: 100
|
|
22
22
|
};
|
|
23
23
|
},
|
|
24
|
-
|
|
24
|
+
_createColumn: (column, table) => {
|
|
25
25
|
column.getAutoFilterFn = () => {
|
|
26
26
|
const firstRow = table.getCoreRowModel().flatRows[0];
|
|
27
27
|
const value = firstRow == null ? void 0 : firstRow.getValue(column.id);
|
|
@@ -88,11 +88,11 @@ const ColumnFiltering = {
|
|
|
88
88
|
});
|
|
89
89
|
};
|
|
90
90
|
},
|
|
91
|
-
|
|
91
|
+
_createRow: (row, _table) => {
|
|
92
92
|
row.columnFilters = {};
|
|
93
93
|
row.columnFiltersMeta = {};
|
|
94
94
|
},
|
|
95
|
-
|
|
95
|
+
_createTable: (table) => {
|
|
96
96
|
table.setColumnFilters = (updater) => {
|
|
97
97
|
var _a, _b;
|
|
98
98
|
const leafColumns = table.getAllLeafColumns();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColumnFiltering.cjs","sources":["../../../src/features/ColumnFiltering.ts"],"sourcesContent":["import { RowModel } from '..'\nimport { BuiltInFilterFn, filterFns } from '../filterFns'\nimport {\n Column,\n FilterFns,\n FilterMeta,\n OnChangeFn,\n Row,\n RowData,\n Table,\n TableFeature,\n Updater,\n} from '../types'\nimport { functionalUpdate, isFunction, makeStateUpdater } from '../utils'\n\nexport interface ColumnFiltersTableState {\n columnFilters: ColumnFiltersState\n}\n\nexport type ColumnFiltersState = ColumnFilter[]\n\nexport interface ColumnFilter {\n id: string\n value: unknown\n}\n\nexport interface ResolvedColumnFilter<TData extends RowData> {\n filterFn: FilterFn<TData>\n id: string\n resolvedValue: unknown\n}\n\nexport interface FilterFn<TData extends RowData> {\n (\n row: Row<TData>,\n columnId: string,\n filterValue: any,\n addMeta: (meta: FilterMeta) => void\n ): boolean\n autoRemove?: ColumnFilterAutoRemoveTestFn<TData>\n resolveFilterValue?: TransformFilterValueFn<TData>\n}\n\nexport type TransformFilterValueFn<TData extends RowData> = (\n value: any,\n column?: Column<TData, unknown>\n) => unknown\n\nexport type ColumnFilterAutoRemoveTestFn<TData extends RowData> = (\n value: any,\n column?: Column<TData, unknown>\n) => boolean\n\nexport type CustomFilterFns<TData extends RowData> = Record<\n string,\n FilterFn<TData>\n>\n\nexport type FilterFnOption<TData extends RowData> =\n | 'auto'\n | BuiltInFilterFn\n | keyof FilterFns\n | FilterFn<TData>\n\nexport interface ColumnFiltersColumnDef<TData extends RowData> {\n /**\n * Enables/disables the **column** filter for this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#enablecolumnfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n enableColumnFilter?: boolean\n /**\n * The filter function to use with this column. Can be the name of a built-in filter function or a custom filter function.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#filterfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n filterFn?: FilterFnOption<TData>\n}\n\nexport interface ColumnFiltersColumn<TData extends RowData> {\n /**\n * Returns an automatically calculated filter function for the column based off of the columns first known value.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getautofilterfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n getAutoFilterFn: () => FilterFn<TData> | undefined\n /**\n * Returns whether or not the column can be **column** filtered.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getcanfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n getCanFilter: () => boolean\n /**\n * Returns the filter function (either user-defined or automatic, depending on configuration) for the columnId specified.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getfilterfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n getFilterFn: () => FilterFn<TData> | undefined\n /**\n * Returns the index (including `-1`) of the column filter in the table's `state.columnFilters` array.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getfilterindex)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n getFilterIndex: () => number\n /**\n * Returns the current filter value for the column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getfiltervalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n getFilterValue: () => unknown\n /**\n * Returns whether or not the column is currently filtered.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getisfiltered)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n getIsFiltered: () => boolean\n /**\n * A function that sets the current filter value for the column. You can pass it a value or an updater function for immutability-safe operations on existing values.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#setfiltervalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n setFilterValue: (updater: Updater<any>) => void\n}\n\nexport interface ColumnFiltersRow<TData extends RowData> {\n /**\n * The column filters map for the row. This object tracks whether a row is passing/failing specific filters by their column ID.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#columnfilters)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n columnFilters: Record<string, boolean>\n /**\n * The column filters meta map for the row. This object tracks any filter meta for a row as optionally provided during the filtering process.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#columnfiltersmeta)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n columnFiltersMeta: Record<string, FilterMeta>\n}\n\ninterface ColumnFiltersOptionsBase<TData extends RowData> {\n /**\n * Enables/disables **column** filtering for all columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#enablecolumnfilters)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n enableColumnFilters?: boolean\n /**\n * Enables/disables all filtering for the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#enablefilters)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n enableFilters?: boolean\n /**\n * By default, filtering is done from parent rows down (so if a parent row is filtered out, all of its children will be filtered out as well). Setting this option to `true` will cause filtering to be done from leaf rows up (which means parent rows will be included so long as one of their child or grand-child rows is also included).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#filterfromleafrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n filterFromLeafRows?: boolean\n /**\n * If provided, this function is called **once** per table and should return a **new function** which will calculate and return the row model for the table when it's filtered.\n * - For server-side filtering, this function is unnecessary and can be ignored since the server should already return the filtered row model.\n * - For client-side filtering, this function is required. A default implementation is provided via any table adapter's `{ getFilteredRowModel }` export.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getfilteredrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n getFilteredRowModel?: (table: Table<any>) => () => RowModel<any>\n /**\n * Disables the `getFilteredRowModel` from being used to filter data. This may be useful if your table needs to dynamically support both client-side and server-side filtering.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#manualfiltering)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n manualFiltering?: boolean\n /**\n * By default, filtering is done for all rows (max depth of 100), no matter if they are root level parent rows or the child leaf rows of a parent row. Setting this option to `0` will cause filtering to only be applied to the root level parent rows, with all sub-rows remaining unfiltered. Similarly, setting this option to `1` will cause filtering to only be applied to child leaf rows 1 level deep, and so on.\n\n * This is useful for situations where you want a row's entire child hierarchy to be visible regardless of the applied filter.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#maxleafrowfilterdepth)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n maxLeafRowFilterDepth?: number\n /**\n * If provided, this function will be called with an `updaterFn` when `state.columnFilters` changes. This overrides the default internal state management, so you will need to persist the state change either fully or partially outside of the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#oncolumnfilterschange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n onColumnFiltersChange?: OnChangeFn<ColumnFiltersState>\n}\n\ntype ResolvedFilterFns = keyof FilterFns extends never\n ? {\n filterFns?: Record<string, FilterFn<any>>\n }\n : {\n filterFns: Record<keyof FilterFns, FilterFn<any>>\n }\n\nexport interface ColumnFiltersOptions<TData extends RowData>\n extends ColumnFiltersOptionsBase<TData>,\n ResolvedFilterFns {}\n\nexport interface ColumnFiltersInstance<TData extends RowData> {\n _getFilteredRowModel?: () => RowModel<TData>\n /**\n * Returns the row model for the table after **column** filtering has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getfilteredrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n getFilteredRowModel: () => RowModel<TData>\n /**\n * Returns the row model for the table before any **column** filtering has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getprefilteredrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n getPreFilteredRowModel: () => RowModel<TData>\n /**\n * Resets the **columnFilters** state to `initialState.columnFilters`, or `true` can be passed to force a default blank state reset to `[]`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#resetcolumnfilters)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n resetColumnFilters: (defaultState?: boolean) => void\n /**\n * Resets the **globalFilter** state to `initialState.globalFilter`, or `true` can be passed to force a default blank state reset to `undefined`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#resetglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n resetGlobalFilter: (defaultState?: boolean) => void\n /**\n * Sets or updates the `state.columnFilters` state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#setcolumnfilters)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n setColumnFilters: (updater: Updater<ColumnFiltersState>) => void\n /**\n * Sets or updates the `state.globalFilter` state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#setglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n setGlobalFilter: (updater: Updater<any>) => void\n}\n\n//\n\nexport const ColumnFiltering: TableFeature = {\n getDefaultColumnDef: <\n TData extends RowData,\n >(): ColumnFiltersColumnDef<TData> => {\n return {\n filterFn: 'auto',\n }\n },\n\n getInitialState: (state): ColumnFiltersTableState => {\n return {\n columnFilters: [],\n ...state,\n }\n },\n\n getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): ColumnFiltersOptions<TData> => {\n return {\n onColumnFiltersChange: makeStateUpdater('columnFilters', table),\n filterFromLeafRows: false,\n maxLeafRowFilterDepth: 100,\n } as ColumnFiltersOptions<TData>\n },\n\n createColumn: <TData extends RowData>(\n column: Column<TData, unknown>,\n table: Table<TData>\n ): void => {\n column.getAutoFilterFn = () => {\n const firstRow = table.getCoreRowModel().flatRows[0]\n\n const value = firstRow?.getValue(column.id)\n\n if (typeof value === 'string') {\n return filterFns.includesString\n }\n\n if (typeof value === 'number') {\n return filterFns.inNumberRange\n }\n\n if (typeof value === 'boolean') {\n return filterFns.equals\n }\n\n if (value !== null && typeof value === 'object') {\n return filterFns.equals\n }\n\n if (Array.isArray(value)) {\n return filterFns.arrIncludes\n }\n\n return filterFns.weakEquals\n }\n column.getFilterFn = () => {\n return isFunction(column.columnDef.filterFn)\n ? column.columnDef.filterFn\n : column.columnDef.filterFn === 'auto'\n ? column.getAutoFilterFn()\n : // @ts-ignore\n table.options.filterFns?.[column.columnDef.filterFn as string] ??\n filterFns[column.columnDef.filterFn as BuiltInFilterFn]\n }\n column.getCanFilter = () => {\n return (\n (column.columnDef.enableColumnFilter ?? true) &&\n (table.options.enableColumnFilters ?? true) &&\n (table.options.enableFilters ?? true) &&\n !!column.accessorFn\n )\n }\n\n column.getIsFiltered = () => column.getFilterIndex() > -1\n\n column.getFilterValue = () =>\n table.getState().columnFilters?.find(d => d.id === column.id)?.value\n\n column.getFilterIndex = () =>\n table.getState().columnFilters?.findIndex(d => d.id === column.id) ?? -1\n\n column.setFilterValue = value => {\n table.setColumnFilters(old => {\n const filterFn = column.getFilterFn()\n const previousFilter = old?.find(d => d.id === column.id)\n\n const newFilter = functionalUpdate(\n value,\n previousFilter ? previousFilter.value : undefined\n )\n\n //\n if (\n shouldAutoRemoveFilter(filterFn as FilterFn<TData>, newFilter, column)\n ) {\n return old?.filter(d => d.id !== column.id) ?? []\n }\n\n const newFilterObj = { id: column.id, value: newFilter }\n\n if (previousFilter) {\n return (\n old?.map(d => {\n if (d.id === column.id) {\n return newFilterObj\n }\n return d\n }) ?? []\n )\n }\n\n if (old?.length) {\n return [...old, newFilterObj]\n }\n\n return [newFilterObj]\n })\n }\n },\n\n createRow: <TData extends RowData>(\n row: Row<TData>,\n _table: Table<TData>\n ): void => {\n row.columnFilters = {}\n row.columnFiltersMeta = {}\n },\n\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n table.setColumnFilters = (updater: Updater<ColumnFiltersState>) => {\n const leafColumns = table.getAllLeafColumns()\n\n const updateFn = (old: ColumnFiltersState) => {\n return functionalUpdate(updater, old)?.filter(filter => {\n const column = leafColumns.find(d => d.id === filter.id)\n\n if (column) {\n const filterFn = column.getFilterFn()\n\n if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {\n return false\n }\n }\n\n return true\n })\n }\n\n table.options.onColumnFiltersChange?.(updateFn)\n }\n\n table.resetColumnFilters = defaultState => {\n table.setColumnFilters(\n defaultState ? [] : table.initialState?.columnFilters ?? []\n )\n }\n\n table.getPreFilteredRowModel = () => table.getCoreRowModel()\n table.getFilteredRowModel = () => {\n if (!table._getFilteredRowModel && table.options.getFilteredRowModel) {\n table._getFilteredRowModel = table.options.getFilteredRowModel(table)\n }\n\n if (table.options.manualFiltering || !table._getFilteredRowModel) {\n return table.getPreFilteredRowModel()\n }\n\n return table._getFilteredRowModel()\n }\n },\n}\n\nexport function shouldAutoRemoveFilter<TData extends RowData>(\n filterFn?: FilterFn<TData>,\n value?: any,\n column?: Column<TData, unknown>\n) {\n return (\n (filterFn && filterFn.autoRemove\n ? filterFn.autoRemove(value, column)\n : false) ||\n typeof value === 'undefined' ||\n (typeof value === 'string' && !value)\n )\n}\n"],"names":["makeStateUpdater","filterFns","isFunction","functionalUpdate"],"mappings":";;;;AAkPO,MAAM,kBAAgC;AAAA,EAC3C,qBAAqB,MAEiB;AAC7B,WAAA;AAAA,MACL,UAAU;AAAA,IAAA;AAAA,EAEd;AAAA,EAEA,iBAAiB,CAAC,UAAmC;AAC5C,WAAA;AAAA,MACL,eAAe,CAAC;AAAA,MAChB,GAAG;AAAA,IAAA;AAAA,EAEP;AAAA,EAEA,mBAAmB,CACjB,UACgC;AACzB,WAAA;AAAA,MACL,uBAAuBA,MAAAA,iBAAiB,iBAAiB,KAAK;AAAA,MAC9D,oBAAoB;AAAA,MACpB,uBAAuB;AAAA,IAAA;AAAA,EAE3B;AAAA,EAEA,cAAc,CACZ,QACA,UACS;AACT,WAAO,kBAAkB,MAAM;A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Q;AAGhD,UAAM,qBAAqB,CAAgB,iBAAA;;AACnC,YAAA;AAAA,QACJ,eAAe,CAAA,MAAK,WAAM,iBAAN,mBAAoB,kBAAiB,CAAC;AAAA,MAAA;AAAA,IAC5D;AAGI,UAAA,yBAAyB,MAAM,MAAM,gBAAgB;AAC3D,UAAM,sBAAsB,MAAM;AAChC,UAAI,CAAC,MAAM,wBAAwB,MAAM,QAAQ,qBAAqB;AACpE,cAAM,uBAAuB,MAAM,QAAQ,oBAAoB,KAAK;AAAA,MACtE;AAEA,UAAI,MAAM,QAAQ,mBAAmB,CAAC,MAAM,sBAAsB;AAChE,eAAO,MAAM;MACf;AAEA,aAAO,MAAM;IAAqB;AAAA,EAEtC;AACF;AAEgB,SAAA,uBACd,UACA,OACA,QACA;AACA,UACG,YAAY,SAAS,aAClB,SAAS,WAAW,OAAO,MAAM,IACjC,UACJ,OAAO,UAAU,eAChB,OAAO,UAAU,YAAY,CAAC;AAEnC;;;"}
|
|
1
|
+
{"version":3,"file":"ColumnFiltering.cjs","sources":["../../../src/features/ColumnFiltering.ts"],"sourcesContent":["import { RowModel } from '..'\nimport { BuiltInFilterFn, filterFns } from '../filterFns'\nimport {\n Column,\n FilterFns,\n FilterMeta,\n OnChangeFn,\n Row,\n RowData,\n Table,\n TableFeature,\n Updater,\n} from '../types'\nimport { functionalUpdate, isFunction, makeStateUpdater } from '../utils'\n\nexport interface ColumnFiltersTableState {\n columnFilters: ColumnFiltersState\n}\n\nexport type ColumnFiltersState = ColumnFilter[]\n\nexport interface ColumnFilter {\n id: string\n value: unknown\n}\n\nexport interface ResolvedColumnFilter<TData extends RowData> {\n filterFn: FilterFn<TData>\n id: string\n resolvedValue: unknown\n}\n\nexport interface FilterFn<TData extends RowData> {\n (\n row: Row<TData>,\n columnId: string,\n filterValue: any,\n addMeta: (meta: FilterMeta) => void\n ): boolean\n autoRemove?: ColumnFilterAutoRemoveTestFn<TData>\n resolveFilterValue?: TransformFilterValueFn<TData>\n}\n\nexport type TransformFilterValueFn<TData extends RowData> = (\n value: any,\n column?: Column<TData, unknown>\n) => unknown\n\nexport type ColumnFilterAutoRemoveTestFn<TData extends RowData> = (\n value: any,\n column?: Column<TData, unknown>\n) => boolean\n\nexport type CustomFilterFns<TData extends RowData> = Record<\n string,\n FilterFn<TData>\n>\n\nexport type FilterFnOption<TData extends RowData> =\n | 'auto'\n | BuiltInFilterFn\n | keyof FilterFns\n | FilterFn<TData>\n\nexport interface ColumnFiltersColumnDef<TData extends RowData> {\n /**\n * Enables/disables the **column** filter for this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#enablecolumnfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n enableColumnFilter?: boolean\n /**\n * The filter function to use with this column. Can be the name of a built-in filter function or a custom filter function.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#filterfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n filterFn?: FilterFnOption<TData>\n}\n\nexport interface ColumnFiltersColumn<TData extends RowData> {\n /**\n * Returns an automatically calculated filter function for the column based off of the columns first known value.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getautofilterfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n getAutoFilterFn: () => FilterFn<TData> | undefined\n /**\n * Returns whether or not the column can be **column** filtered.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getcanfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n getCanFilter: () => boolean\n /**\n * Returns the filter function (either user-defined or automatic, depending on configuration) for the columnId specified.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getfilterfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n getFilterFn: () => FilterFn<TData> | undefined\n /**\n * Returns the index (including `-1`) of the column filter in the table's `state.columnFilters` array.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getfilterindex)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n getFilterIndex: () => number\n /**\n * Returns the current filter value for the column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getfiltervalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n getFilterValue: () => unknown\n /**\n * Returns whether or not the column is currently filtered.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getisfiltered)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n getIsFiltered: () => boolean\n /**\n * A function that sets the current filter value for the column. You can pass it a value or an updater function for immutability-safe operations on existing values.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#setfiltervalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n setFilterValue: (updater: Updater<any>) => void\n}\n\nexport interface ColumnFiltersRow<TData extends RowData> {\n /**\n * The column filters map for the row. This object tracks whether a row is passing/failing specific filters by their column ID.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#columnfilters)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n columnFilters: Record<string, boolean>\n /**\n * The column filters meta map for the row. This object tracks any filter meta for a row as optionally provided during the filtering process.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#columnfiltersmeta)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n columnFiltersMeta: Record<string, FilterMeta>\n}\n\ninterface ColumnFiltersOptionsBase<TData extends RowData> {\n /**\n * Enables/disables **column** filtering for all columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#enablecolumnfilters)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n enableColumnFilters?: boolean\n /**\n * Enables/disables all filtering for the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#enablefilters)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n enableFilters?: boolean\n /**\n * By default, filtering is done from parent rows down (so if a parent row is filtered out, all of its children will be filtered out as well). Setting this option to `true` will cause filtering to be done from leaf rows up (which means parent rows will be included so long as one of their child or grand-child rows is also included).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#filterfromleafrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n filterFromLeafRows?: boolean\n /**\n * If provided, this function is called **once** per table and should return a **new function** which will calculate and return the row model for the table when it's filtered.\n * - For server-side filtering, this function is unnecessary and can be ignored since the server should already return the filtered row model.\n * - For client-side filtering, this function is required. A default implementation is provided via any table adapter's `{ getFilteredRowModel }` export.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getfilteredrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n getFilteredRowModel?: (table: Table<any>) => () => RowModel<any>\n /**\n * Disables the `getFilteredRowModel` from being used to filter data. This may be useful if your table needs to dynamically support both client-side and server-side filtering.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#manualfiltering)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n manualFiltering?: boolean\n /**\n * By default, filtering is done for all rows (max depth of 100), no matter if they are root level parent rows or the child leaf rows of a parent row. Setting this option to `0` will cause filtering to only be applied to the root level parent rows, with all sub-rows remaining unfiltered. Similarly, setting this option to `1` will cause filtering to only be applied to child leaf rows 1 level deep, and so on.\n\n * This is useful for situations where you want a row's entire child hierarchy to be visible regardless of the applied filter.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#maxleafrowfilterdepth)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n maxLeafRowFilterDepth?: number\n /**\n * If provided, this function will be called with an `updaterFn` when `state.columnFilters` changes. This overrides the default internal state management, so you will need to persist the state change either fully or partially outside of the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#oncolumnfilterschange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n onColumnFiltersChange?: OnChangeFn<ColumnFiltersState>\n}\n\ntype ResolvedFilterFns = keyof FilterFns extends never\n ? {\n filterFns?: Record<string, FilterFn<any>>\n }\n : {\n filterFns: Record<keyof FilterFns, FilterFn<any>>\n }\n\nexport interface ColumnFiltersOptions<TData extends RowData>\n extends ColumnFiltersOptionsBase<TData>,\n ResolvedFilterFns {}\n\nexport interface ColumnFiltersInstance<TData extends RowData> {\n _getFilteredRowModel?: () => RowModel<TData>\n /**\n * Returns the row model for the table after **column** filtering has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getfilteredrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n getFilteredRowModel: () => RowModel<TData>\n /**\n * Returns the row model for the table before any **column** filtering has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#getprefilteredrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n getPreFilteredRowModel: () => RowModel<TData>\n /**\n * Resets the **columnFilters** state to `initialState.columnFilters`, or `true` can be passed to force a default blank state reset to `[]`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#resetcolumnfilters)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n resetColumnFilters: (defaultState?: boolean) => void\n /**\n * Resets the **globalFilter** state to `initialState.globalFilter`, or `true` can be passed to force a default blank state reset to `undefined`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#resetglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n resetGlobalFilter: (defaultState?: boolean) => void\n /**\n * Sets or updates the `state.columnFilters` state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#setcolumnfilters)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n setColumnFilters: (updater: Updater<ColumnFiltersState>) => void\n /**\n * Sets or updates the `state.globalFilter` state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-filtering#setglobalfilter)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-filtering)\n */\n setGlobalFilter: (updater: Updater<any>) => void\n}\n\n//\n\nexport const ColumnFiltering: TableFeature = {\n _getDefaultColumnDef: <\n TData extends RowData,\n >(): ColumnFiltersColumnDef<TData> => {\n return {\n filterFn: 'auto',\n }\n },\n\n _getInitialState: (state): ColumnFiltersTableState => {\n return {\n columnFilters: [],\n ...state,\n }\n },\n\n _getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): ColumnFiltersOptions<TData> => {\n return {\n onColumnFiltersChange: makeStateUpdater('columnFilters', table),\n filterFromLeafRows: false,\n maxLeafRowFilterDepth: 100,\n } as ColumnFiltersOptions<TData>\n },\n\n _createColumn: <TData extends RowData>(\n column: Column<TData, unknown>,\n table: Table<TData>\n ): void => {\n column.getAutoFilterFn = () => {\n const firstRow = table.getCoreRowModel().flatRows[0]\n\n const value = firstRow?.getValue(column.id)\n\n if (typeof value === 'string') {\n return filterFns.includesString\n }\n\n if (typeof value === 'number') {\n return filterFns.inNumberRange\n }\n\n if (typeof value === 'boolean') {\n return filterFns.equals\n }\n\n if (value !== null && typeof value === 'object') {\n return filterFns.equals\n }\n\n if (Array.isArray(value)) {\n return filterFns.arrIncludes\n }\n\n return filterFns.weakEquals\n }\n column.getFilterFn = () => {\n return isFunction(column.columnDef.filterFn)\n ? column.columnDef.filterFn\n : column.columnDef.filterFn === 'auto'\n ? column.getAutoFilterFn()\n : // @ts-ignore\n table.options.filterFns?.[column.columnDef.filterFn as string] ??\n filterFns[column.columnDef.filterFn as BuiltInFilterFn]\n }\n column.getCanFilter = () => {\n return (\n (column.columnDef.enableColumnFilter ?? true) &&\n (table.options.enableColumnFilters ?? true) &&\n (table.options.enableFilters ?? true) &&\n !!column.accessorFn\n )\n }\n\n column.getIsFiltered = () => column.getFilterIndex() > -1\n\n column.getFilterValue = () =>\n table.getState().columnFilters?.find(d => d.id === column.id)?.value\n\n column.getFilterIndex = () =>\n table.getState().columnFilters?.findIndex(d => d.id === column.id) ?? -1\n\n column.setFilterValue = value => {\n table.setColumnFilters(old => {\n const filterFn = column.getFilterFn()\n const previousFilter = old?.find(d => d.id === column.id)\n\n const newFilter = functionalUpdate(\n value,\n previousFilter ? previousFilter.value : undefined\n )\n\n //\n if (\n shouldAutoRemoveFilter(filterFn as FilterFn<TData>, newFilter, column)\n ) {\n return old?.filter(d => d.id !== column.id) ?? []\n }\n\n const newFilterObj = { id: column.id, value: newFilter }\n\n if (previousFilter) {\n return (\n old?.map(d => {\n if (d.id === column.id) {\n return newFilterObj\n }\n return d\n }) ?? []\n )\n }\n\n if (old?.length) {\n return [...old, newFilterObj]\n }\n\n return [newFilterObj]\n })\n }\n },\n\n _createRow: <TData extends RowData>(\n row: Row<TData>,\n _table: Table<TData>\n ): void => {\n row.columnFilters = {}\n row.columnFiltersMeta = {}\n },\n\n _createTable: <TData extends RowData>(table: Table<TData>): void => {\n table.setColumnFilters = (updater: Updater<ColumnFiltersState>) => {\n const leafColumns = table.getAllLeafColumns()\n\n const updateFn = (old: ColumnFiltersState) => {\n return functionalUpdate(updater, old)?.filter(filter => {\n const column = leafColumns.find(d => d.id === filter.id)\n\n if (column) {\n const filterFn = column.getFilterFn()\n\n if (shouldAutoRemoveFilter(filterFn, filter.value, column)) {\n return false\n }\n }\n\n return true\n })\n }\n\n table.options.onColumnFiltersChange?.(updateFn)\n }\n\n table.resetColumnFilters = defaultState => {\n table.setColumnFilters(\n defaultState ? [] : table.initialState?.columnFilters ?? []\n )\n }\n\n table.getPreFilteredRowModel = () => table.getCoreRowModel()\n table.getFilteredRowModel = () => {\n if (!table._getFilteredRowModel && table.options.getFilteredRowModel) {\n table._getFilteredRowModel = table.options.getFilteredRowModel(table)\n }\n\n if (table.options.manualFiltering || !table._getFilteredRowModel) {\n return table.getPreFilteredRowModel()\n }\n\n return table._getFilteredRowModel()\n }\n },\n}\n\nexport function shouldAutoRemoveFilter<TData extends RowData>(\n filterFn?: FilterFn<TData>,\n value?: any,\n column?: Column<TData, unknown>\n) {\n return (\n (filterFn && filterFn.autoRemove\n ? filterFn.autoRemove(value, column)\n : false) ||\n typeof value === 'undefined' ||\n (typeof value === 'string' && !value)\n )\n}\n"],"names":["makeStateUpdater","filterFns","isFunction","functionalUpdate"],"mappings":";;;;AAkPO,MAAM,kBAAgC;AAAA,EAC3C,sBAAsB,MAEgB;AAC7B,WAAA;AAAA,MACL,UAAU;AAAA,IAAA;AAAA,EAEd;AAAA,EAEA,kBAAkB,CAAC,UAAmC;AAC7C,WAAA;AAAA,MACL,eAAe,CAAC;AAAA,MAChB,GAAG;AAAA,IAAA;AAAA,EAEP;AAAA,EAEA,oBAAoB,CAClB,UACgC;AACzB,WAAA;AAAA,MACL,uBAAuBA,MAAAA,iBAAiB,iBAAiB,KAAK;AAAA,MAC9D,oBAAoB;AAAA,MACpB,uBAAuB;AAAA,IAAA;AAAA,EAE3B;AAAA,EAEA,eAAe,CACb,QACA,UACS;AACT,WAAO,kBAAkB,MAAM;AAC7B,YAAM,WAAW,MAAM,gBAAgB,EAAE,SAAS,CAAC;AAEnD,YAAM,QAAQ,qCAAU,SAAS,OAAO;AAEpC,UAAA,OAAO,UAAU,UAAU;AAC7B,eAAOC,UAAAA,UAAU;AAAA,MACnB;AAEI,UAAA,OAAO,UAAU,UAAU;AAC7B,eAAOA,UAAAA,UAAU;AAAA,MACnB;AAEI,UAAA,OAAO,UAAU,WAAW;AAC9B,eAAOA,UAAAA,UAAU;AAAA,MACnB;AAEA,UAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;AAC/C,eAAOA,UAAAA,UAAU;AAAA,MACnB;AAEI,UAAA,MAAM,QAAQ,KAAK,GAAG;AACxB,eAAOA,UAAAA,UAAU;AAAA,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,SAAA,uBACd,UACA,OACA,QACA;AACA,UACG,YAAY,SAAS,aAClB,SAAS,WAAW,OAAO,MAAM,IACjC,UACJ,OAAO,UAAU,eAChB,OAAO,UAAU,YAAY,CAAC;AAEnC;;;"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const aggregationFns = require("../aggregationFns.cjs");
|
|
4
4
|
const utils = require("../utils.cjs");
|
|
5
5
|
const ColumnGrouping = {
|
|
6
|
-
|
|
6
|
+
_getDefaultColumnDef: () => {
|
|
7
7
|
return {
|
|
8
8
|
aggregatedCell: (props) => {
|
|
9
9
|
var _a, _b;
|
|
@@ -12,19 +12,19 @@ const ColumnGrouping = {
|
|
|
12
12
|
aggregationFn: "auto"
|
|
13
13
|
};
|
|
14
14
|
},
|
|
15
|
-
|
|
15
|
+
_getInitialState: (state) => {
|
|
16
16
|
return {
|
|
17
17
|
grouping: [],
|
|
18
18
|
...state
|
|
19
19
|
};
|
|
20
20
|
},
|
|
21
|
-
|
|
21
|
+
_getDefaultOptions: (table) => {
|
|
22
22
|
return {
|
|
23
23
|
onGroupingChange: utils.makeStateUpdater("grouping", table),
|
|
24
24
|
groupedColumnMode: "reorder"
|
|
25
25
|
};
|
|
26
26
|
},
|
|
27
|
-
|
|
27
|
+
_createColumn: (column, table) => {
|
|
28
28
|
column.toggleGrouping = () => {
|
|
29
29
|
table.setGrouping((old) => {
|
|
30
30
|
if (old == null ? void 0 : old.includes(column.id)) {
|
|
@@ -47,8 +47,7 @@ const ColumnGrouping = {
|
|
|
47
47
|
column.getToggleGroupingHandler = () => {
|
|
48
48
|
const canGroup = column.getCanGroup();
|
|
49
49
|
return () => {
|
|
50
|
-
if (!canGroup)
|
|
51
|
-
return;
|
|
50
|
+
if (!canGroup) return;
|
|
52
51
|
column.toggleGrouping();
|
|
53
52
|
};
|
|
54
53
|
};
|
|
@@ -70,7 +69,7 @@ const ColumnGrouping = {
|
|
|
70
69
|
return utils.isFunction(column.columnDef.aggregationFn) ? column.columnDef.aggregationFn : column.columnDef.aggregationFn === "auto" ? column.getAutoAggregationFn() : ((_a = table.options.aggregationFns) == null ? void 0 : _a[column.columnDef.aggregationFn]) ?? aggregationFns.aggregationFns[column.columnDef.aggregationFn];
|
|
71
70
|
};
|
|
72
71
|
},
|
|
73
|
-
|
|
72
|
+
_createTable: (table) => {
|
|
74
73
|
table.setGrouping = (updater) => {
|
|
75
74
|
var _a, _b;
|
|
76
75
|
return (_b = (_a = table.options).onGroupingChange) == null ? void 0 : _b.call(_a, updater);
|
|
@@ -90,7 +89,7 @@ const ColumnGrouping = {
|
|
|
90
89
|
return table._getGroupedRowModel();
|
|
91
90
|
};
|
|
92
91
|
},
|
|
93
|
-
|
|
92
|
+
_createRow: (row, table) => {
|
|
94
93
|
row.getIsGrouped = () => !!row.groupingColumnId;
|
|
95
94
|
row.getGroupingValue = (columnId) => {
|
|
96
95
|
if (row._groupingValuesCache.hasOwnProperty(columnId)) {
|
|
@@ -107,7 +106,7 @@ const ColumnGrouping = {
|
|
|
107
106
|
};
|
|
108
107
|
row._groupingValuesCache = {};
|
|
109
108
|
},
|
|
110
|
-
|
|
109
|
+
_createCell: (cell, column, row, table) => {
|
|
111
110
|
cell.getIsGrouped = () => column.getIsGrouped() && column.id === row.groupingColumnId;
|
|
112
111
|
cell.getIsPlaceholder = () => !cell.getIsGrouped() && column.getIsGrouped();
|
|
113
112
|
cell.getIsAggregated = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColumnGrouping.cjs","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":["makeStateUpdater","aggregationFns","isFunction"],"mappings":";;;;AAiPO,MAAM,iBAA+B;AAAA,EAC1C,qBAAqB,MAGhB;AACI,WAAA;AAAA,MACL,gBAAgB,CAAU,UAAA;;AAAA,kCAAM,SAAS,MAAf,mBAA0B,aAA1B,gCAA0C;AAAA;AAAA,MACpE,eAAe;AAAA,IAAA;AAAA,EAEnB;AAAA,EAEA,iBAAiB,CAAC,UAA8B;AACvC,WAAA;AAAA,MACL,UAAU,CAAC;AAAA,MACX,GAAG;AAAA,IAAA;AAAA,EAEP;AAAA,EAEA,mBAAmB,CACjB,UACoB;AACb,WAAA;AAAA,MACL,kBAAkBA,MAAAA,iBAAiB,YAAY,KAAK;AAAA,MACpD,mBAAmB;AAAA,IAAA;AAAA,EAEvB;AAAA,EAEA,cAAc,CACZ,QACA,UACS;AACT,WAAO,iBAAiB,MAAM;AAC5B,YAAM,YAAY,CAAO,QAAA;AAEvB,YAAI,2BAAK,SAAS,OAAO,KAAK;AAC5B,iBAAO,IAAI,OAAO,CAAK,MAAA,MAAM,OAAO,EAAE;AAAA,QACxC;AAEA,eAAO,CAAC,GAAI,OAAO,CAAC,GAAI,OAAO,EAAE;AAAA,MAAA,CAClC;AAAA,IAAA;AAGH,WAAO,cAAc,MAAM;AACzB,cACG,OAAO,UAAU,kBAAkB,UACnC,MAAM,QAAQ,kBAAkB,UAChC,CAAC,CAAC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AAGlC,MAAI,sBAAsB,UAAU;AAC3B,WAAA;AAAA,EACT;AAEA,QAAM,kBAAkB,SACrB,IAAI,CAAA,MAAK,YAAY,KAAK,CAAO,QAAA,IAAI,OAAO,CAAC,CAAE,EAC/C,OAAO,OAAO;AAEjB,SAAO,CAAC,GAAG,iBAAiB,GAAG,kBAAkB;AACnD;;;"}
|
|
1
|
+
{"version":3,"file":"ColumnGrouping.cjs","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":["makeStateUpdater","aggregationFns","isFunction"],"mappings":";;;;AAiPO,MAAM,iBAA+B;AAAA,EAC1C,sBAAsB,MAGjB;AACI,WAAA;AAAA,MACL,gBAAgB,CAAU,UAAA;;AAAA,kCAAM,SAAS,MAAf,mBAA0B,aAA1B,gCAA0C;AAAA;AAAA,MACpE,eAAe;AAAA,IAAA;AAAA,EAEnB;AAAA,EAEA,kBAAkB,CAAC,UAA8B;AACxC,WAAA;AAAA,MACL,UAAU,CAAC;AAAA,MACX,GAAG;AAAA,IAA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AAA,IAAA;AAE1C,QAAI,uBAAuB;EAC7B;AAAA,EAEA,aAAa,CACX,MACA,QACA,KACA,UACS;AAIT,SAAK,eAAe,MAClB,OAAO,aAAkB,KAAA,OAAO,OAAO,IAAI;AAC7C,SAAK,mBAAmB,MAAM,CAAC,KAAK,kBAAkB,OAAO;AAC7D,SAAK,kBAAkB,MAAA;;AACrB,cAAC,KAAK,aAAa,KAAK,CAAC,KAAK,iBAAiB,KAAK,CAAC,GAAC,SAAI,YAAJ,mBAAa;AAAA;AAAA,EACvE;AACF;AAEgB,SAAA,aACd,aACA,UACA,mBACA;AACA,MAAI,EAAC,qCAAU,WAAU,CAAC,mBAAmB;AACpC,WAAA;AAAA,EACT;AAEA,QAAM,qBAAqB,YAAY;AAAA,IACrC,CAAO,QAAA,CAAC,SAAS,SAAS,IAAI,EAAE;AAAA,EAAA;AAGlC,MAAI,sBAAsB,UAAU;AAC3B,WAAA;AAAA,EACT;AAEA,QAAM,kBAAkB,SACrB,IAAI,CAAA,MAAK,YAAY,KAAK,CAAO,QAAA,IAAI,OAAO,CAAC,CAAE,EAC/C,OAAO,OAAO;AAEjB,SAAO,CAAC,GAAG,iBAAiB,GAAG,kBAAkB;AACnD;;;"}
|
|
@@ -4,18 +4,18 @@ const utils = require("../utils.cjs");
|
|
|
4
4
|
const ColumnGrouping = require("./ColumnGrouping.cjs");
|
|
5
5
|
const ColumnVisibility = require("./ColumnVisibility.cjs");
|
|
6
6
|
const ColumnOrdering = {
|
|
7
|
-
|
|
7
|
+
_getInitialState: (state) => {
|
|
8
8
|
return {
|
|
9
9
|
columnOrder: [],
|
|
10
10
|
...state
|
|
11
11
|
};
|
|
12
12
|
},
|
|
13
|
-
|
|
13
|
+
_getDefaultOptions: (table) => {
|
|
14
14
|
return {
|
|
15
15
|
onColumnOrderChange: utils.makeStateUpdater("columnOrder", table)
|
|
16
16
|
};
|
|
17
17
|
},
|
|
18
|
-
|
|
18
|
+
_createColumn: (column, table) => {
|
|
19
19
|
column.getIndex = utils.memo(
|
|
20
20
|
(position) => [ColumnVisibility._getVisibleLeafColumns(table, position)],
|
|
21
21
|
(columns) => columns.findIndex((d) => d.id === column.id),
|
|
@@ -32,7 +32,7 @@ const ColumnOrdering = {
|
|
|
32
32
|
return ((_a = columns[columns.length - 1]) == null ? void 0 : _a.id) === column.id;
|
|
33
33
|
};
|
|
34
34
|
},
|
|
35
|
-
|
|
35
|
+
_createTable: (table) => {
|
|
36
36
|
table.setColumnOrder = (updater) => {
|
|
37
37
|
var _a, _b;
|
|
38
38
|
return (_b = (_a = table.options).onColumnOrderChange) == null ? void 0 : _b.call(_a, updater);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColumnOrdering.cjs","sources":["../../../src/features/ColumnOrdering.ts"],"sourcesContent":["import { getMemoOptions, makeStateUpdater, memo } from '../utils'\n\nimport {\n Column,\n OnChangeFn,\n RowData,\n Table,\n TableFeature,\n Updater,\n} from '../types'\n\nimport { orderColumns } from './ColumnGrouping'\nimport { ColumnPinningPosition, _getVisibleLeafColumns } from '..'\n\nexport interface ColumnOrderTableState {\n columnOrder: ColumnOrderState\n}\n\nexport type ColumnOrderState = string[]\n\nexport interface ColumnOrderOptions {\n /**\n * If provided, this function will be called with an `updaterFn` when `state.columnOrder` changes. This overrides the default internal state management, so you will need to persist the state change either fully or partially outside of the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-ordering#oncolumnorderchange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-ordering)\n */\n onColumnOrderChange?: OnChangeFn<ColumnOrderState>\n}\n\nexport interface ColumnOrderColumn {\n /**\n * Returns the index of the column in the order of the visible columns. Optionally pass a `position` parameter to get the index of the column in a sub-section of the table\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-ordering#getindex)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-ordering)\n */\n getIndex: (position?: ColumnPinningPosition | 'center') => number\n /**\n * Returns `true` if the column is the first column in the order of the visible columns. Optionally pass a `position` parameter to check if the column is the first in a sub-section of the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-ordering#getisfirstcolumn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-ordering)\n */\n getIsFirstColumn: (position?: ColumnPinningPosition | 'center') => boolean\n /**\n * Returns `true` if the column is the last column in the order of the visible columns. Optionally pass a `position` parameter to check if the column is the last in a sub-section of the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-ordering#getislastcolumn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-ordering)\n */\n getIsLastColumn: (position?: ColumnPinningPosition | 'center') => boolean\n}\n\nexport interface ColumnOrderDefaultOptions {\n onColumnOrderChange: OnChangeFn<ColumnOrderState>\n}\n\nexport interface ColumnOrderInstance<TData extends RowData> {\n _getOrderColumnsFn: () => (\n columns: Column<TData, unknown>[]\n ) => Column<TData, unknown>[]\n /**\n * Resets the **columnOrder** state to `initialState.columnOrder`, or `true` can be passed to force a default blank state reset to `[]`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-ordering#resetcolumnorder)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-ordering)\n */\n resetColumnOrder: (defaultState?: boolean) => void\n /**\n * Sets or updates the `state.columnOrder` state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-ordering#setcolumnorder)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-ordering)\n */\n setColumnOrder: (updater: Updater<ColumnOrderState>) => void\n}\n\n//\n\nexport const ColumnOrdering: TableFeature = {\n
|
|
1
|
+
{"version":3,"file":"ColumnOrdering.cjs","sources":["../../../src/features/ColumnOrdering.ts"],"sourcesContent":["import { getMemoOptions, makeStateUpdater, memo } from '../utils'\n\nimport {\n Column,\n OnChangeFn,\n RowData,\n Table,\n TableFeature,\n Updater,\n} from '../types'\n\nimport { orderColumns } from './ColumnGrouping'\nimport { ColumnPinningPosition, _getVisibleLeafColumns } from '..'\n\nexport interface ColumnOrderTableState {\n columnOrder: ColumnOrderState\n}\n\nexport type ColumnOrderState = string[]\n\nexport interface ColumnOrderOptions {\n /**\n * If provided, this function will be called with an `updaterFn` when `state.columnOrder` changes. This overrides the default internal state management, so you will need to persist the state change either fully or partially outside of the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-ordering#oncolumnorderchange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-ordering)\n */\n onColumnOrderChange?: OnChangeFn<ColumnOrderState>\n}\n\nexport interface ColumnOrderColumn {\n /**\n * Returns the index of the column in the order of the visible columns. Optionally pass a `position` parameter to get the index of the column in a sub-section of the table\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-ordering#getindex)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-ordering)\n */\n getIndex: (position?: ColumnPinningPosition | 'center') => number\n /**\n * Returns `true` if the column is the first column in the order of the visible columns. Optionally pass a `position` parameter to check if the column is the first in a sub-section of the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-ordering#getisfirstcolumn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-ordering)\n */\n getIsFirstColumn: (position?: ColumnPinningPosition | 'center') => boolean\n /**\n * Returns `true` if the column is the last column in the order of the visible columns. Optionally pass a `position` parameter to check if the column is the last in a sub-section of the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-ordering#getislastcolumn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-ordering)\n */\n getIsLastColumn: (position?: ColumnPinningPosition | 'center') => boolean\n}\n\nexport interface ColumnOrderDefaultOptions {\n onColumnOrderChange: OnChangeFn<ColumnOrderState>\n}\n\nexport interface ColumnOrderInstance<TData extends RowData> {\n _getOrderColumnsFn: () => (\n columns: Column<TData, unknown>[]\n ) => Column<TData, unknown>[]\n /**\n * Resets the **columnOrder** state to `initialState.columnOrder`, or `true` can be passed to force a default blank state reset to `[]`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-ordering#resetcolumnorder)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-ordering)\n */\n resetColumnOrder: (defaultState?: boolean) => void\n /**\n * Sets or updates the `state.columnOrder` state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/column-ordering#setcolumnorder)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-ordering)\n */\n setColumnOrder: (updater: Updater<ColumnOrderState>) => void\n}\n\n//\n\nexport const ColumnOrdering: TableFeature = {\n _getInitialState: (state): ColumnOrderTableState => {\n return {\n columnOrder: [],\n ...state,\n }\n },\n\n _getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): ColumnOrderDefaultOptions => {\n return {\n onColumnOrderChange: makeStateUpdater('columnOrder', table),\n }\n },\n\n _createColumn: <TData extends RowData>(\n column: Column<TData, unknown>,\n table: Table<TData>\n ): void => {\n column.getIndex = memo(\n position => [_getVisibleLeafColumns(table, position)],\n columns => columns.findIndex(d => d.id === column.id),\n getMemoOptions(table.options, 'debugColumns', 'getIndex')\n )\n column.getIsFirstColumn = position => {\n const columns = _getVisibleLeafColumns(table, position)\n return columns[0]?.id === column.id\n }\n column.getIsLastColumn = position => {\n const columns = _getVisibleLeafColumns(table, position)\n return columns[columns.length - 1]?.id === column.id\n }\n },\n\n _createTable: <TData extends RowData>(table: Table<TData>): void => {\n table.setColumnOrder = updater =>\n table.options.onColumnOrderChange?.(updater)\n table.resetColumnOrder = defaultState => {\n table.setColumnOrder(\n defaultState ? [] : table.initialState.columnOrder ?? []\n )\n }\n table._getOrderColumnsFn = memo(\n () => [\n table.getState().columnOrder,\n table.getState().grouping,\n table.options.groupedColumnMode,\n ],\n (columnOrder, grouping, groupedColumnMode) =>\n (columns: Column<TData, unknown>[]) => {\n // Sort grouped columns to the start of the column list\n // before the headers are built\n let orderedColumns: Column<TData, unknown>[] = []\n\n // If there is no order, return the normal columns\n if (!columnOrder?.length) {\n orderedColumns = columns\n } else {\n const columnOrderCopy = [...columnOrder]\n\n // If there is an order, make a copy of the columns\n const columnsCopy = [...columns]\n\n // And make a new ordered array of the columns\n\n // Loop over the columns and place them in order into the new array\n while (columnsCopy.length && columnOrderCopy.length) {\n const targetColumnId = columnOrderCopy.shift()\n const foundIndex = columnsCopy.findIndex(\n d => d.id === targetColumnId\n )\n if (foundIndex > -1) {\n orderedColumns.push(columnsCopy.splice(foundIndex, 1)[0]!)\n }\n }\n\n // If there are any columns left, add them to the end\n orderedColumns = [...orderedColumns, ...columnsCopy]\n }\n\n return orderColumns(orderedColumns, grouping, groupedColumnMode)\n },\n getMemoOptions(table.options, 'debugTable', '_getOrderColumnsFn')\n )\n },\n}\n"],"names":["makeStateUpdater","memo","_getVisibleLeafColumns","getMemoOptions","orderColumns"],"mappings":";;;;;AA0EO,MAAM,iBAA+B;AAAA,EAC1C,kBAAkB,CAAC,UAAiC;AAC3C,WAAA;AAAA,MACL,aAAa,CAAC;AAAA,MACd,GAAG;AAAA,IAAA;AAAA,EAEP;AAAA,EAEA,oBAAoB,CAClB,UAC8B;AACvB,WAAA;AAAA,MACL,qBAAqBA,MAAAA,iBAAiB,eAAe,KAAK;AAAA,IAAA;AAAA,EAE9D;AAAA,EAEA,eAAe,CACb,QACA,UACS;AACT,WAAO,WAAWC,MAAA;AAAA,MAChB,CAAY,aAAA,CAACC,iBAAAA,uBAAuB,OAAO,QAAQ,CAAC;AAAA,MACpD,aAAW,QAAQ,UAAU,OAAK,EAAE,OAAO,OAAO,EAAE;AAAA,MACpDC,MAAAA,eAAe,MAAM,SAAS,gBAAgB,UAAU;AAAA,IAAA;AAE1D,WAAO,mBAAmB,CAAY,aAAA;;AAC9B,YAAA,UAAUD,iBAAAA,uBAAuB,OAAO,QAAQ;AACtD,eAAO,aAAQ,CAAC,MAAT,mBAAY,QAAO,OAAO;AAAA,IAAA;AAEnC,WAAO,kBAAkB,CAAY,aAAA;;AAC7B,YAAA,UAAUA,iBAAAA,uBAAuB,OAAO,QAAQ;AACtD,eAAO,aAAQ,Q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