@tanstack/table-core
Version:
Headless UI for building powerful tables & datagrids for TS/JS.
1 lines • 456 kB
Source Map (JSON)
{"version":3,"file":"index.mjs","sources":["../../src/columnHelper.ts","../../src/utils.ts","../../src/core/cell.ts","../../src/core/column.ts","../../src/core/headers.ts","../../src/core/row.ts","../../src/features/ColumnFaceting.ts","../../src/filterFns.ts","../../src/features/ColumnFiltering.ts","../../src/aggregationFns.ts","../../src/features/ColumnGrouping.ts","../../src/features/ColumnOrdering.ts","../../src/features/ColumnPinning.ts","../../src/features/ColumnSizing.ts","../../src/features/ColumnVisibility.ts","../../src/features/GlobalFaceting.ts","../../src/features/GlobalFiltering.ts","../../src/features/RowExpanding.ts","../../src/features/RowPagination.ts","../../src/features/RowPinning.ts","../../src/features/RowSelection.ts","../../src/sortingFns.ts","../../src/features/RowSorting.ts","../../src/core/table.ts","../../src/utils/getCoreRowModel.ts","../../src/utils/getExpandedRowModel.ts","../../src/utils/getFacetedMinMaxValues.ts","../../src/utils/filterRowsUtils.ts","../../src/utils/getFacetedRowModel.ts","../../src/utils/getFacetedUniqueValues.ts","../../src/utils/getFilteredRowModel.ts","../../src/utils/getGroupedRowModel.ts","../../src/utils/getPaginationRowModel.ts","../../src/utils/getSortedRowModel.ts"],"sourcesContent":["import {\n AccessorFn,\n AccessorFnColumnDef,\n AccessorKeyColumnDef,\n DisplayColumnDef,\n GroupColumnDef,\n IdentifiedColumnDef,\n RowData,\n} from './types'\nimport { DeepKeys, DeepValue } from './utils'\n\n// type Person = {\n// firstName: string\n// lastName: string\n// age: number\n// visits: number\n// status: string\n// progress: number\n// createdAt: Date\n// nested: {\n// foo: [\n// {\n// bar: 'bar'\n// }\n// ]\n// bar: { subBar: boolean }[]\n// baz: {\n// foo: 'foo'\n// bar: {\n// baz: 'baz'\n// }\n// }\n// }\n// }\n\n// const test: DeepKeys<Person> = 'nested.foo.0.bar'\n// const test2: DeepKeys<Person> = 'nested.bar'\n\n// const helper = createColumnHelper<Person>()\n\n// helper.accessor('nested.foo', {\n// cell: info => info.getValue(),\n// })\n\n// helper.accessor('nested.foo.0.bar', {\n// cell: info => info.getValue(),\n// })\n\n// helper.accessor('nested.bar', {\n// cell: info => info.getValue(),\n// })\n\nexport type ColumnHelper<TData extends RowData> = {\n accessor: <\n TAccessor extends AccessorFn<TData> | DeepKeys<TData>,\n TValue extends TAccessor extends AccessorFn<TData, infer TReturn>\n ? TReturn\n : TAccessor extends DeepKeys<TData>\n ? DeepValue<TData, TAccessor>\n : never,\n >(\n accessor: TAccessor,\n column: TAccessor extends AccessorFn<TData>\n ? DisplayColumnDef<TData, TValue>\n : IdentifiedColumnDef<TData, TValue>\n ) => TAccessor extends AccessorFn<TData>\n ? AccessorFnColumnDef<TData, TValue>\n : AccessorKeyColumnDef<TData, TValue>\n display: (column: DisplayColumnDef<TData>) => DisplayColumnDef<TData, unknown>\n group: (column: GroupColumnDef<TData>) => GroupColumnDef<TData, unknown>\n}\n\nexport function createColumnHelper<\n TData extends RowData,\n>(): ColumnHelper<TData> {\n return {\n accessor: (accessor, column) => {\n return typeof accessor === 'function'\n ? ({\n ...column,\n accessorFn: accessor,\n } as any)\n : {\n ...column,\n accessorKey: accessor,\n }\n },\n display: column => column,\n group: column => column,\n }\n}\n","import { TableOptionsResolved, TableState, Updater } from './types'\n\nexport type PartialKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>\nexport type RequiredKeys<T, K extends keyof T> = Omit<T, K> &\n Required<Pick<T, K>>\nexport type Overwrite<T, U extends { [TKey in keyof T]?: any }> = Omit<\n T,\n keyof U\n> &\n U\n\nexport type UnionToIntersection<T> = (\n T extends any ? (x: T) => any : never\n) extends (x: infer R) => any\n ? R\n : never\n\nexport type IsAny<T, Y, N> = 1 extends 0 & T ? Y : N\nexport type IsKnown<T, Y, N> = unknown extends T ? N : Y\n\ntype ComputeRange<\n N extends number,\n Result extends Array<unknown> = [],\n> = Result['length'] extends N\n ? Result\n : ComputeRange<N, [...Result, Result['length']]>\ntype Index40 = ComputeRange<40>[number]\n\n// Is this type a tuple?\ntype IsTuple<T> = T extends readonly any[] & { length: infer Length }\n ? Length extends Index40\n ? T\n : never\n : never\n\n// If this type is a tuple, what indices are allowed?\ntype AllowedIndexes<\n Tuple extends ReadonlyArray<any>,\n Keys extends number = never,\n> = Tuple extends readonly []\n ? Keys\n : Tuple extends readonly [infer _, ...infer Tail]\n ? AllowedIndexes<Tail, Keys | Tail['length']>\n : Keys\n\nexport type DeepKeys<T, TDepth extends any[] = []> = TDepth['length'] extends 5\n ? never\n : unknown extends T\n ? string\n : T extends readonly any[] & IsTuple<T>\n ? AllowedIndexes<T> | DeepKeysPrefix<T, AllowedIndexes<T>, TDepth>\n : T extends any[]\n ? DeepKeys<T[number], [...TDepth, any]>\n : T extends Date\n ? never\n : T extends object\n ? (keyof T & string) | DeepKeysPrefix<T, keyof T, TDepth>\n : never\n\ntype DeepKeysPrefix<\n T,\n TPrefix,\n TDepth extends any[],\n> = TPrefix extends keyof T & (number | string)\n ? `${TPrefix}.${DeepKeys<T[TPrefix], [...TDepth, any]> & string}`\n : never\n\nexport type DeepValue<T, TProp> =\n T extends Record<string | number, any>\n ? TProp extends `${infer TBranch}.${infer TDeepProp}`\n ? DeepValue<T[TBranch], TDeepProp>\n : T[TProp & string]\n : never\n\nexport type NoInfer<T> = [T][T extends any ? 0 : never]\n\nexport type Getter<TValue> = <TTValue = TValue>() => NoInfer<TTValue>\n\n///\n\nexport function functionalUpdate<T>(updater: Updater<T>, input: T): T {\n return typeof updater === 'function'\n ? (updater as (input: T) => T)(input)\n : updater\n}\n\nexport function noop() {\n //\n}\n\nexport function makeStateUpdater<K extends keyof TableState>(\n key: K,\n instance: unknown\n) {\n return (updater: Updater<TableState[K]>) => {\n ;(instance as any).setState(<TTableState>(old: TTableState) => {\n return {\n ...old,\n [key]: functionalUpdate(updater, (old as any)[key]),\n }\n })\n }\n}\n\ntype AnyFunction = (...args: any) => any\n\nexport function isFunction<T extends AnyFunction>(d: any): d is T {\n return d instanceof Function\n}\n\nexport function isNumberArray(d: any): d is number[] {\n return Array.isArray(d) && d.every(val => typeof val === 'number')\n}\n\nexport function flattenBy<TNode>(\n arr: TNode[],\n getChildren: (item: TNode) => TNode[]\n) {\n const flat: TNode[] = []\n\n const recurse = (subArr: TNode[]) => {\n subArr.forEach(item => {\n flat.push(item)\n const children = getChildren(item)\n if (children?.length) {\n recurse(children)\n }\n })\n }\n\n recurse(arr)\n\n return flat\n}\n\nexport function memo<TDeps extends readonly any[], TDepArgs, TResult>(\n getDeps: (depArgs?: TDepArgs) => [...TDeps],\n fn: (...args: NoInfer<[...TDeps]>) => TResult,\n opts: {\n key: any\n debug?: () => any\n onChange?: (result: TResult) => void\n }\n): (depArgs?: TDepArgs) => TResult {\n let deps: any[] = []\n let result: TResult | undefined\n\n return depArgs => {\n let depTime: number\n if (opts.key && opts.debug) depTime = Date.now()\n\n const newDeps = getDeps(depArgs)\n\n const depsChanged =\n newDeps.length !== deps.length ||\n newDeps.some((dep: any, index: number) => deps[index] !== dep)\n\n if (!depsChanged) {\n return result!\n }\n\n deps = newDeps\n\n let resultTime: number\n if (opts.key && opts.debug) resultTime = Date.now()\n\n result = fn(...newDeps)\n opts?.onChange?.(result)\n\n if (opts.key && opts.debug) {\n if (opts?.debug()) {\n const depEndTime = Math.round((Date.now() - depTime!) * 100) / 100\n const resultEndTime = Math.round((Date.now() - resultTime!) * 100) / 100\n const resultFpsPercentage = resultEndTime / 16\n\n const pad = (str: number | string, num: number) => {\n str = String(str)\n while (str.length < num) {\n str = ' ' + str\n }\n return str\n }\n\n console.info(\n `%c⏱ ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`,\n `\n font-size: .6rem;\n font-weight: bold;\n color: hsl(${Math.max(\n 0,\n Math.min(120 - 120 * resultFpsPercentage, 120)\n )}deg 100% 31%);`,\n opts?.key\n )\n }\n }\n\n return result!\n }\n}\n\nexport function getMemoOptions(\n tableOptions: Partial<TableOptionsResolved<any>>,\n debugLevel:\n | 'debugAll'\n | 'debugCells'\n | 'debugTable'\n | 'debugColumns'\n | 'debugRows'\n | 'debugHeaders',\n key: string,\n onChange?: (result: any) => void\n) {\n return {\n debug: () => tableOptions?.debugAll ?? tableOptions[debugLevel],\n key: process.env.NODE_ENV === 'development' && key,\n onChange,\n }\n}\n","import { RowData, Cell, Column, Row, Table } from '../types'\nimport { Getter, getMemoOptions, memo } from '../utils'\n\nexport interface CellContext<TData extends RowData, TValue> {\n cell: Cell<TData, TValue>\n column: Column<TData, TValue>\n getValue: Getter<TValue>\n renderValue: Getter<TValue | null>\n row: Row<TData>\n table: Table<TData>\n}\n\nexport interface CoreCell<TData extends RowData, TValue> {\n /**\n * The associated Column object for the cell.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#column)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)\n */\n column: Column<TData, TValue>\n /**\n * Returns the rendering context (or props) for cell-based components like cells and aggregated cells. Use these props with your framework's `flexRender` utility to render these using the template of your choice:\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#getcontext)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)\n */\n getContext: () => CellContext<TData, TValue>\n /**\n * Returns the value for the cell, accessed via the associated column's accessor key or accessor function.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#getvalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)\n */\n getValue: CellContext<TData, TValue>['getValue']\n /**\n * The unique ID for the cell across the entire table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#id)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)\n */\n id: string\n /**\n * Renders the value for a cell the same as `getValue`, but will return the `renderFallbackValue` if no value is found.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#rendervalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)\n */\n renderValue: CellContext<TData, TValue>['renderValue']\n /**\n * The associated Row object for the cell.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#row)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)\n */\n row: Row<TData>\n}\n\nexport function createCell<TData extends RowData, TValue>(\n table: Table<TData>,\n row: Row<TData>,\n column: Column<TData, TValue>,\n columnId: string\n): Cell<TData, TValue> {\n const getRenderValue = () =>\n cell.getValue() ?? table.options.renderFallbackValue\n\n const cell: CoreCell<TData, TValue> = {\n id: `${row.id}_${column.id}`,\n row,\n column,\n getValue: () => row.getValue(columnId),\n renderValue: getRenderValue,\n getContext: memo(\n () => [table, column, row, cell],\n (table, column, row, cell) => ({\n table,\n column,\n row,\n cell: cell as Cell<TData, TValue>,\n getValue: cell.getValue,\n renderValue: cell.renderValue,\n }),\n getMemoOptions(table.options, 'debugCells', 'cell.getContext')\n ),\n }\n\n table._features.forEach(feature => {\n feature.createCell?.(\n cell as Cell<TData, TValue>,\n column,\n row as Row<TData>,\n table\n )\n }, {})\n\n return cell as Cell<TData, TValue>\n}\n","import {\n Column,\n Table,\n AccessorFn,\n ColumnDef,\n RowData,\n ColumnDefResolved,\n} from '../types'\nimport { getMemoOptions, memo } from '../utils'\n\nexport interface CoreColumn<TData extends RowData, TValue> {\n /**\n * The resolved accessor function to use when extracting the value for the column from each row. Will only be defined if the column def has a valid accessor key or function defined.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#accessorfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n accessorFn?: AccessorFn<TData, TValue>\n /**\n * The original column def used to create the column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#columndef)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n columnDef: ColumnDef<TData, TValue>\n /**\n * The child column (if the column is a group column). Will be an empty array if the column is not a group column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#columns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n columns: Column<TData, TValue>[]\n /**\n * The depth of the column (if grouped) relative to the root column def array.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#depth)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n depth: number\n /**\n * Returns the flattened array of this column and all child/grand-child columns for this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#getflatcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n getFlatColumns: () => Column<TData, TValue>[]\n /**\n * Returns an array of all leaf-node columns for this column. If a column has no children, it is considered the only leaf-node column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#getleafcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n getLeafColumns: () => Column<TData, TValue>[]\n /**\n * The resolved unique identifier for the column resolved in this priority:\n - A manual `id` property from the column def\n - The accessor key from the column def\n - The header string from the column def\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#id)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n id: string\n /**\n * The parent column for this column. Will be undefined if this is a root column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#parent)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n parent?: Column<TData, TValue>\n}\n\nexport function createColumn<TData extends RowData, TValue>(\n table: Table<TData>,\n columnDef: ColumnDef<TData, TValue>,\n depth: number,\n parent?: Column<TData, TValue>\n): Column<TData, TValue> {\n const defaultColumn = table._getDefaultColumnDef()\n\n const resolvedColumnDef = {\n ...defaultColumn,\n ...columnDef,\n } as ColumnDefResolved<TData>\n\n const accessorKey = resolvedColumnDef.accessorKey\n\n let id =\n resolvedColumnDef.id ??\n (accessorKey\n ? typeof String.prototype.replaceAll === 'function'\n ? accessorKey.replaceAll('.', '_')\n : accessorKey.replace(/\\./g, '_')\n : undefined) ??\n (typeof resolvedColumnDef.header === 'string'\n ? resolvedColumnDef.header\n : undefined)\n\n let accessorFn: AccessorFn<TData> | undefined\n\n if (resolvedColumnDef.accessorFn) {\n accessorFn = resolvedColumnDef.accessorFn\n } else if (accessorKey) {\n // Support deep accessor keys\n if (accessorKey.includes('.')) {\n accessorFn = (originalRow: TData) => {\n let result = originalRow as Record<string, any>\n\n for (const key of accessorKey.split('.')) {\n result = result?.[key]\n if (process.env.NODE_ENV !== 'production' && result === undefined) {\n console.warn(\n `\"${key}\" in deeply nested key \"${accessorKey}\" returned undefined.`\n )\n }\n }\n\n return result\n }\n } else {\n accessorFn = (originalRow: TData) =>\n (originalRow as any)[resolvedColumnDef.accessorKey]\n }\n }\n\n if (!id) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n resolvedColumnDef.accessorFn\n ? `Columns require an id when using an accessorFn`\n : `Columns require an id when using a non-string header`\n )\n }\n throw new Error()\n }\n\n let column: CoreColumn<TData, any> = {\n id: `${String(id)}`,\n accessorFn,\n parent: parent as any,\n depth,\n columnDef: resolvedColumnDef as ColumnDef<TData, any>,\n columns: [],\n getFlatColumns: memo(\n () => [true],\n () => {\n return [\n column as Column<TData, TValue>,\n ...column.columns?.flatMap(d => d.getFlatColumns()),\n ]\n },\n getMemoOptions(table.options, 'debugColumns', 'column.getFlatColumns')\n ),\n getLeafColumns: memo(\n () => [table._getOrderColumnsFn()],\n orderColumns => {\n if (column.columns?.length) {\n let leafColumns = column.columns.flatMap(column =>\n column.getLeafColumns()\n )\n\n return orderColumns(leafColumns)\n }\n\n return [column as Column<TData, TValue>]\n },\n getMemoOptions(table.options, 'debugColumns', 'column.getLeafColumns')\n ),\n }\n\n for (const feature of table._features) {\n feature.createColumn?.(column as Column<TData, TValue>, table)\n }\n\n // Yes, we have to convert table to unknown, because we know more than the compiler here.\n return column as Column<TData, TValue>\n}\n","import {\n RowData,\n Column,\n Header,\n HeaderGroup,\n Table,\n TableFeature,\n} from '../types'\nimport { getMemoOptions, memo } from '../utils'\n\nconst debug = 'debugHeaders'\n\nexport interface CoreHeaderGroup<TData extends RowData> {\n depth: number\n headers: Header<TData, unknown>[]\n id: string\n}\n\nexport interface HeaderContext<TData, TValue> {\n /**\n * An instance of a column.\n */\n column: Column<TData, TValue>\n /**\n * An instance of a header.\n */\n header: Header<TData, TValue>\n /**\n * The table instance.\n */\n table: Table<TData>\n}\n\nexport interface CoreHeader<TData extends RowData, TValue> {\n /**\n * The col-span for the header.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#colspan)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n colSpan: number\n /**\n * The header's associated column object.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#column)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n column: Column<TData, TValue>\n /**\n * The depth of the header, zero-indexed based.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#depth)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n depth: number\n /**\n * Returns the rendering context (or props) for column-based components like headers, footers and filters.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#getcontext)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getContext: () => HeaderContext<TData, TValue>\n /**\n * Returns the leaf headers hierarchically nested under this header.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#getleafheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getLeafHeaders: () => Header<TData, unknown>[]\n /**\n * The header's associated header group object.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#headergroup)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n headerGroup: HeaderGroup<TData>\n /**\n * The unique identifier for the header.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#id)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n id: string\n /**\n * The index for the header within the header group.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#index)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n index: number\n /**\n * A boolean denoting if the header is a placeholder header.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#isplaceholder)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n isPlaceholder: boolean\n /**\n * If the header is a placeholder header, this will be a unique header ID that does not conflict with any other headers across the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#placeholderid)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n placeholderId?: string\n /**\n * The row-span for the header.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#rowspan)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n rowSpan: number\n /**\n * The header's hierarchical sub/child headers. Will be empty if the header's associated column is a leaf-column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#subheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n subHeaders: Header<TData, TValue>[]\n}\n\nexport interface HeadersInstance<TData extends RowData> {\n /**\n * Returns all header groups for the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getheadergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getHeaderGroups: () => HeaderGroup<TData>[]\n /**\n * If pinning, returns the header groups for the left pinned columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getleftheadergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getLeftHeaderGroups: () => HeaderGroup<TData>[]\n /**\n * If pinning, returns the header groups for columns that are not pinned.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getcenterheadergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getCenterHeaderGroups: () => HeaderGroup<TData>[]\n /**\n * If pinning, returns the header groups for the right pinned columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getrightheadergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getRightHeaderGroups: () => HeaderGroup<TData>[]\n\n /**\n * Returns the footer groups for the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getfootergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getFooterGroups: () => HeaderGroup<TData>[]\n /**\n * If pinning, returns the footer groups for the left pinned columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getleftfootergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getLeftFooterGroups: () => HeaderGroup<TData>[]\n /**\n * If pinning, returns the footer groups for columns that are not pinned.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getcenterfootergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getCenterFooterGroups: () => HeaderGroup<TData>[]\n /**\n * If pinning, returns the footer groups for the right pinned columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getrightfootergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getRightFooterGroups: () => HeaderGroup<TData>[]\n\n /**\n * Returns headers for all columns in the table, including parent headers.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getflatheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getFlatHeaders: () => Header<TData, unknown>[]\n /**\n * If pinning, returns headers for all left pinned columns in the table, including parent headers.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getleftflatheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getLeftFlatHeaders: () => Header<TData, unknown>[]\n /**\n * If pinning, returns headers for all columns that are not pinned, including parent headers.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getcenterflatheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getCenterFlatHeaders: () => Header<TData, unknown>[]\n /**\n * If pinning, returns headers for all right pinned columns in the table, including parent headers.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getrightflatheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getRightFlatHeaders: () => Header<TData, unknown>[]\n\n /**\n * Returns headers for all leaf columns in the table, (not including parent headers).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getleafheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getLeafHeaders: () => Header<TData, unknown>[]\n /**\n * If pinning, returns headers for all left pinned leaf columns in the table, (not including parent headers).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getleftleafheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getLeftLeafHeaders: () => Header<TData, unknown>[]\n /**\n * If pinning, returns headers for all columns that are not pinned, (not including parent headers).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getcenterleafheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getCenterLeafHeaders: () => Header<TData, unknown>[]\n /**\n * If pinning, returns headers for all right pinned leaf columns in the table, (not including parent headers).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getrightleafheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getRightLeafHeaders: () => Header<TData, unknown>[]\n}\n\n//\n\nfunction createHeader<TData extends RowData, TValue>(\n table: Table<TData>,\n column: Column<TData, TValue>,\n options: {\n id?: string\n isPlaceholder?: boolean\n placeholderId?: string\n index: number\n depth: number\n }\n): Header<TData, TValue> {\n const id = options.id ?? column.id\n\n let header: CoreHeader<TData, TValue> = {\n id,\n column,\n index: options.index,\n isPlaceholder: !!options.isPlaceholder,\n placeholderId: options.placeholderId,\n depth: options.depth,\n subHeaders: [],\n colSpan: 0,\n rowSpan: 0,\n headerGroup: null!,\n getLeafHeaders: (): Header<TData, unknown>[] => {\n const leafHeaders: Header<TData, unknown>[] = []\n\n const recurseHeader = (h: CoreHeader<TData, any>) => {\n if (h.subHeaders && h.subHeaders.length) {\n h.subHeaders.map(recurseHeader)\n }\n leafHeaders.push(h as Header<TData, unknown>)\n }\n\n recurseHeader(header)\n\n return leafHeaders\n },\n getContext: () => ({\n table,\n header: header as Header<TData, TValue>,\n column,\n }),\n }\n\n table._features.forEach(feature => {\n feature.createHeader?.(header as Header<TData, TValue>, table)\n })\n\n return header as Header<TData, TValue>\n}\n\nexport const Headers: TableFeature = {\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n // Header Groups\n\n table.getHeaderGroups = memo(\n () => [\n table.getAllColumns(),\n table.getVisibleLeafColumns(),\n table.getState().columnPinning.left,\n table.getState().columnPinning.right,\n ],\n (allColumns, leafColumns, left, right) => {\n const leftColumns =\n left\n ?.map(columnId => leafColumns.find(d => d.id === columnId)!)\n .filter(Boolean) ?? []\n\n const rightColumns =\n right\n ?.map(columnId => leafColumns.find(d => d.id === columnId)!)\n .filter(Boolean) ?? []\n\n const centerColumns = leafColumns.filter(\n column => !left?.includes(column.id) && !right?.includes(column.id)\n )\n\n const headerGroups = buildHeaderGroups(\n allColumns,\n [...leftColumns, ...centerColumns, ...rightColumns],\n table\n )\n\n return headerGroups\n },\n getMemoOptions(table.options, debug, 'getHeaderGroups')\n )\n\n table.getCenterHeaderGroups = memo(\n () => [\n table.getAllColumns(),\n table.getVisibleLeafColumns(),\n table.getState().columnPinning.left,\n table.getState().columnPinning.right,\n ],\n (allColumns, leafColumns, left, right) => {\n leafColumns = leafColumns.filter(\n column => !left?.includes(column.id) && !right?.includes(column.id)\n )\n return buildHeaderGroups(allColumns, leafColumns, table, 'center')\n },\n getMemoOptions(table.options, debug, 'getCenterHeaderGroups')\n )\n\n table.getLeftHeaderGroups = memo(\n () => [\n table.getAllColumns(),\n table.getVisibleLeafColumns(),\n table.getState().columnPinning.left,\n ],\n (allColumns, leafColumns, left) => {\n const orderedLeafColumns =\n left\n ?.map(columnId => leafColumns.find(d => d.id === columnId)!)\n .filter(Boolean) ?? []\n\n return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'left')\n },\n getMemoOptions(table.options, debug, 'getLeftHeaderGroups')\n )\n\n table.getRightHeaderGroups = memo(\n () => [\n table.getAllColumns(),\n table.getVisibleLeafColumns(),\n table.getState().columnPinning.right,\n ],\n (allColumns, leafColumns, right) => {\n const orderedLeafColumns =\n right\n ?.map(columnId => leafColumns.find(d => d.id === columnId)!)\n .filter(Boolean) ?? []\n\n return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'right')\n },\n getMemoOptions(table.options, debug, 'getRightHeaderGroups')\n )\n\n // Footer Groups\n\n table.getFooterGroups = memo(\n () => [table.getHeaderGroups()],\n headerGroups => {\n return [...headerGroups].reverse()\n },\n getMemoOptions(table.options, debug, 'getFooterGroups')\n )\n\n table.getLeftFooterGroups = memo(\n () => [table.getLeftHeaderGroups()],\n headerGroups => {\n return [...headerGroups].reverse()\n },\n getMemoOptions(table.options, debug, 'getLeftFooterGroups')\n )\n\n table.getCenterFooterGroups = memo(\n () => [table.getCenterHeaderGroups()],\n headerGroups => {\n return [...headerGroups].reverse()\n },\n getMemoOptions(table.options, debug, 'getCenterFooterGroups')\n )\n\n table.getRightFooterGroups = memo(\n () => [table.getRightHeaderGroups()],\n headerGroups => {\n return [...headerGroups].reverse()\n },\n getMemoOptions(table.options, debug, 'getRightFooterGroups')\n )\n\n // Flat Headers\n\n table.getFlatHeaders = memo(\n () => [table.getHeaderGroups()],\n headerGroups => {\n return headerGroups\n .map(headerGroup => {\n return headerGroup.headers\n })\n .flat()\n },\n getMemoOptions(table.options, debug, 'getFlatHeaders')\n )\n\n table.getLeftFlatHeaders = memo(\n () => [table.getLeftHeaderGroups()],\n left => {\n return left\n .map(headerGroup => {\n return headerGroup.headers\n })\n .flat()\n },\n getMemoOptions(table.options, debug, 'getLeftFlatHeaders')\n )\n\n table.getCenterFlatHeaders = memo(\n () => [table.getCenterHeaderGroups()],\n left => {\n return left\n .map(headerGroup => {\n return headerGroup.headers\n })\n .flat()\n },\n getMemoOptions(table.options, debug, 'getCenterFlatHeaders')\n )\n\n table.getRightFlatHeaders = memo(\n () => [table.getRightHeaderGroups()],\n left => {\n return left\n .map(headerGroup => {\n return headerGroup.headers\n })\n .flat()\n },\n getMemoOptions(table.options, debug, 'getRightFlatHeaders')\n )\n\n // Leaf Headers\n\n table.getCenterLeafHeaders = memo(\n () => [table.getCenterFlatHeaders()],\n flatHeaders => {\n return flatHeaders.filter(header => !header.subHeaders?.length)\n },\n getMemoOptions(table.options, debug, 'getCenterLeafHeaders')\n )\n\n table.getLeftLeafHeaders = memo(\n () => [table.getLeftFlatHeaders()],\n flatHeaders => {\n return flatHeaders.filter(header => !header.subHeaders?.length)\n },\n getMemoOptions(table.options, debug, 'getLeftLeafHeaders')\n )\n\n table.getRightLeafHeaders = memo(\n () => [table.getRightFlatHeaders()],\n flatHeaders => {\n return flatHeaders.filter(header => !header.subHeaders?.length)\n },\n getMemoOptions(table.options, debug, 'getRightLeafHeaders')\n )\n\n table.getLeafHeaders = memo(\n () => [\n table.getLeftHeaderGroups(),\n table.getCenterHeaderGroups(),\n table.getRightHeaderGroups(),\n ],\n (left, center, right) => {\n return [\n ...(left[0]?.headers ?? []),\n ...(center[0]?.headers ?? []),\n ...(right[0]?.headers ?? []),\n ]\n .map(header => {\n return header.getLeafHeaders()\n })\n .flat()\n },\n getMemoOptions(table.options, debug, 'getLeafHeaders')\n )\n },\n}\n\nexport function buildHeaderGroups<TData extends RowData>(\n allColumns: Column<TData, unknown>[],\n columnsToGroup: Column<TData, unknown>[],\n table: Table<TData>,\n headerFamily?: 'center' | 'left' | 'right'\n) {\n // Find the max depth of the columns:\n // build the leaf column row\n // build each buffer row going up\n // placeholder for non-existent level\n // real column for existing level\n\n let maxDepth = 0\n\n const findMaxDepth = (columns: Column<TData, unknown>[], depth = 1) => {\n maxDepth = Math.max(maxDepth, depth)\n\n columns\n .filter(column => column.getIsVisible())\n .forEach(column => {\n if (column.columns?.length) {\n findMaxDepth(column.columns, depth + 1)\n }\n }, 0)\n }\n\n findMaxDepth(allColumns)\n\n let headerGroups: HeaderGroup<TData>[] = []\n\n const createHeaderGroup = (\n headersToGroup: Header<TData, unknown>[],\n depth: number\n ) => {\n // The header group we are creating\n const headerGroup: HeaderGroup<TData> = {\n depth,\n id: [headerFamily, `${depth}`].filter(Boolean).join('_'),\n headers: [],\n }\n\n // The parent columns we're going to scan next\n const pendingParentHeaders: Header<TData, unknown>[] = []\n\n // Scan each column for parents\n headersToGroup.forEach(headerToGroup => {\n // What is the latest (last) parent column?\n\n const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0]\n\n const isLeafHeader = headerToGroup.column.depth === headerGroup.depth\n\n let column: Column<TData, unknown>\n let isPlaceholder = false\n\n if (isLeafHeader && headerToGroup.column.parent) {\n // The parent header is new\n column = headerToGroup.column.parent\n } else {\n // The parent header is repeated\n column = headerToGroup.column\n isPlaceholder = true\n }\n\n if (\n latestPendingParentHeader &&\n latestPendingParentHeader?.column === column\n ) {\n // This column is repeated. Add it as a sub header to the next batch\n latestPendingParentHeader.subHeaders.push(headerToGroup)\n } else {\n // This is a new header. Let's create it\n const header = createHeader(table, column, {\n id: [headerFamily, depth, column.id, headerToGroup?.id]\n .filter(Boolean)\n .join('_'),\n isPlaceholder,\n placeholderId: isPlaceholder\n ? `${pendingParentHeaders.filter(d => d.column === column).length}`\n : undefined,\n depth,\n index: pendingParentHeaders.length,\n })\n\n // Add the headerToGroup as a subHeader of the new header\n header.subHeaders.push(headerToGroup)\n // Add the new header to the pendingParentHeaders to get grouped\n // in the next batch\n pendingParentHeaders.push(header)\n }\n\n headerGroup.headers.push(headerToGroup)\n headerToGroup.headerGroup = headerGroup\n })\n\n headerGroups.push(headerGroup)\n\n if (depth > 0) {\n createHeaderGroup(pendingParentHeaders, depth - 1)\n }\n }\n\n const bottomHeaders = columnsToGroup.map((column, index) =>\n createHeader(table, column, {\n depth: maxDepth,\n index,\n })\n )\n\n createHeaderGroup(bottomHeaders, maxDepth - 1)\n\n headerGroups.reverse()\n\n // headerGroups = headerGroups.filter(headerGroup => {\n // return !headerGroup.headers.every(header => header.isPlaceholder)\n // })\n\n const recurseHeadersForSpans = (\n headers: Header<TData, unknown>[]\n ): { colSpan: number; rowSpan: number }[] => {\n const filteredHeaders = headers.filter(header =>\n header.column.getIsVisible()\n )\n\n return filteredHeaders.map(header => {\n let colSpan = 0\n let rowSpan = 0\n let childRowSpans = [0]\n\n if (header.subHeaders && header.subHeaders.length) {\n childRowSpans = []\n\n recurseHeadersForSpans(header.subHeaders).forEach(\n ({ colSpan: childColSpan, rowSpan: childRowSpan }) => {\n colSpan += childColSpan\n childRowSpans.push(childRowSpan)\n }\n )\n } else {\n colSpan = 1\n }\n\n const minChildRowSpan = Math.min(...childRowSpans)\n rowSpan = rowSpan + minChildRowSpan\n\n header.colSpan = colSpan\n header.rowSpan = rowSpan\n\n return { colSpan, rowSpan }\n })\n }\n\n recurseHeadersForSpans(headerGroups[0]?.headers ?? [])\n\n return headerGroups\n}\n","import { RowData, Cell, Row, Table } from '../types'\nimport { flattenBy, getMemoOptions, memo } from '../utils'\nimport { createCell } from './cell'\n\nexport interface CoreRow<TData extends RowData> {\n _getAllCellsByColumnId: () => Record<string, Cell<TData, unknown>>\n _uniqueValuesCache: Record<string, unknown>\n _valuesCache: Record<string, unknown>\n /**\n * The depth of the row (if nested or grouped) relative to the root row array.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#depth)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n depth: number\n /**\n * Returns all of the cells for the row.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getallcells)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getAllCells: () => Cell<TData, unknown>[]\n /**\n * Returns the leaf rows for the row, not including any parent rows.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getleafrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getLeafRows: () => Row<TData>[]\n /**\n * Returns the parent row for the row, if it exists.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getparentrow)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getParentRow: () => Row<TData> | undefined\n /**\n * Returns the parent rows for the row, all the way up to a root row.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getparentrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getParentRows: () => Row<TData>[]\n /**\n * Returns a unique array of values from the row for a given columnId.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getuniquevalues)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getUniqueValues: <TValue>(columnId: string) => TValue[]\n /**\n * Returns the value from the row for a given columnId.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getvalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getValue: <TValue>(columnId: string) => TValue\n /**\n * The resolved unique identifier for the row resolved via the `options.getRowId` option. Defaults to the row's index (or relative index if it is a subRow).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#id)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n id: string\n /**\n * The index of the row within its parent array (or the root data array).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#index)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n index: number\n /**\n * The original row object provided to the table. If the row is a grouped row, the original row object will be the first original in the group.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#original)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n original: TData\n /**\n * An array of the original subRows as returned by the `options.getSubRows` option.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#originalsubrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n originalSubRows?: TData[]\n /**\n * If nested, this row's parent row id.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#parentid)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n parentId?: string\n /**\n * Renders the value for the row in a given columnId the same as `getValue`, but will return the `renderFallbackValue` if no value is found.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#rendervalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n renderValue: <TValue>(columnId: string) => TValue\n /**\n * An array of subRows for the row as returned and created by the `options.getSubRows` option.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#subrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n subRows: Row<TData>[]\n}\n\nexport const createRow = <TData extends RowData>(\n table: Table<TData>,\n id: string,\n original: TData,\n rowIndex: number,\n depth: number,\n subRows?: Row<TData>[],\n parentId?: string\n): Row<TData> => {\n let row: CoreRow<TData> = {\n id,\n index: rowIndex,\n original,\n depth,\n parentId,\n _valuesCache: {},\n _uniqueValuesCache: {},\n getValue: columnId => {\n if (row._valuesCache.hasOwnProperty(columnId)) {\n return row._valuesCache[columnId]\n }\n\n const column = table.getColumn(columnId)\n\n if (!column?.accessorFn) {\n return undefined\n }\n\n row._valuesCache[columnId] = column.accessorFn(\n row.original as TData,\n rowIndex\n )\n\n return row._valuesCache[columnId] as any\n },\n getUniqueValues: columnId => {\n if (row._uniqueValuesCache.hasOwnProperty(columnId)) {\n return row._uniqueValuesCache[columnId]\n }\n\n const column = table.getColumn(columnId)\n\n if (!column?.accessorFn) {\n return undefined\n }\n\n if (!column.columnDef.getUniqueValues) {\n row._uniqueValuesCache[columnId] = [row.getValue(columnId)]\n return row._uniqueValuesCache[columnId]\n }\n\n row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(\n row.original as TData,\n rowIndex\n )\n\n return row._uniqueValuesCache[columnId] as any\n },\n renderValue: columnId =>\n row.getValue(columnId) ?? table.options.renderFallbackValue,\n subRows: subRows ?? [],\n getLeafRows: () => flattenBy(row.subRows, d => d.subRows),\n getParentRow: () =>\n row.parentId ? table.getRow(row.parentId, true) : undefined,\n getParentRows: () => {\n let parentRows: Row<TData>[] = []\n let currentRow = row\n while (true) {\n const parentRow = currentRow.getParentRow()\n if (!parentRow) break\n parentRows.push(parentRow)\n currentRow = parentRow\n }\n return parentRows.reverse()\n },\n getAllCells: memo(\n () => [table.getAllLeafColumns()],\n leafColumns => {\n return leafColumns.map(column => {\n return createCell(table, row as Row<TData>, column, column.id)\n })\n },\n getMemoOptions(table.options, 'debugRows', 'getAllCells')\n ),\n\n _getAllCellsByColumnId: memo(\n () => [row.getAllCells()],\n allCells => {\n return allCells.reduce(\n (acc, cell) => {\n acc[cell.column.id] = cell\n return acc\n },\n {} as Record<string, Cell<TData, unknown>>\n )\n },\n getMemoOptions(table.options, 'debugRows', 'getAllCellsByColumnId')\n ),\n }\n\n for (let i = 0; i < table._features.length; i++) {\n const feature = table._features[i]\n feature?.createRow?.(row as Row<TData>, table)\n }\n\n return row as Row<TData>\n}\n","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.getFaceted