@tanstack/table-core 9.0.0-beta.10 → 9.0.0-beta.12
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/core/cells/coreCellsFeature.types.d.cts +3 -3
- package/dist/core/cells/coreCellsFeature.types.d.ts +3 -3
- package/dist/core/columns/coreColumnsFeature.types.d.cts +4 -4
- package/dist/core/columns/coreColumnsFeature.types.d.ts +4 -4
- package/dist/core/columns/coreColumnsFeature.utils.cjs.map +1 -1
- package/dist/core/columns/coreColumnsFeature.utils.js.map +1 -1
- package/dist/core/headers/buildHeaderGroups.cjs.map +1 -1
- package/dist/core/headers/buildHeaderGroups.js.map +1 -1
- package/dist/core/headers/coreHeadersFeature.types.d.cts +5 -5
- package/dist/core/headers/coreHeadersFeature.types.d.ts +5 -5
- package/dist/core/row-models/coreRowModelsFeature.types.d.cts +3 -3
- package/dist/core/row-models/coreRowModelsFeature.types.d.ts +3 -3
- package/dist/core/row-models/createCoreRowModel.cjs +1 -2
- package/dist/core/row-models/createCoreRowModel.cjs.map +1 -1
- package/dist/core/row-models/createCoreRowModel.d.cts +2 -2
- package/dist/core/row-models/createCoreRowModel.d.ts +2 -2
- package/dist/core/row-models/createCoreRowModel.js +1 -2
- package/dist/core/row-models/createCoreRowModel.js.map +1 -1
- package/dist/core/rows/coreRowsFeature.types.d.cts +4 -4
- package/dist/core/rows/coreRowsFeature.types.d.ts +4 -4
- package/dist/core/table/constructTable.cjs.map +1 -1
- package/dist/core/table/constructTable.js.map +1 -1
- package/dist/core/table/coreTablesFeature.types.d.cts +4 -4
- package/dist/core/table/coreTablesFeature.types.d.ts +4 -4
- package/dist/core/table/coreTablesFeature.utils.cjs.map +1 -1
- package/dist/core/table/coreTablesFeature.utils.js.map +1 -1
- package/dist/features/column-faceting/columnFacetingFeature.types.d.cts +4 -4
- package/dist/features/column-faceting/columnFacetingFeature.types.d.ts +4 -4
- package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +9 -9
- package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +9 -9
- package/dist/features/column-filtering/columnFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.utils.js.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.types.d.cts +6 -6
- package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +6 -6
- package/dist/features/column-ordering/columnOrderingFeature.types.d.cts +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.types.d.ts +1 -1
- package/dist/features/column-pinning/columnPinningFeature.types.d.cts +2 -2
- package/dist/features/column-pinning/columnPinningFeature.types.d.ts +2 -2
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +3 -2
- package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +3 -2
- package/dist/features/column-pinning/columnPinningFeature.utils.js.map +1 -1
- package/dist/features/column-resizing/columnResizingFeature.types.d.cts +1 -4
- package/dist/features/column-resizing/columnResizingFeature.types.d.ts +1 -4
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.cts +2 -2
- package/dist/features/column-visibility/columnVisibilityFeature.types.d.ts +2 -2
- package/dist/features/global-filtering/globalFilteringFeature.types.d.cts +2 -2
- package/dist/features/global-filtering/globalFilteringFeature.types.d.ts +2 -2
- package/dist/features/global-filtering/globalFilteringFeature.utils.cjs.map +1 -1
- package/dist/features/global-filtering/globalFilteringFeature.utils.js.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.types.d.cts +4 -4
- package/dist/features/row-expanding/rowExpandingFeature.types.d.ts +4 -4
- package/dist/features/row-pagination/rowPaginationFeature.types.d.cts +3 -3
- package/dist/features/row-pagination/rowPaginationFeature.types.d.ts +3 -3
- package/dist/features/row-pinning/rowPinningFeature.types.d.cts +2 -2
- package/dist/features/row-pinning/rowPinningFeature.types.d.ts +2 -2
- package/dist/features/row-selection/rowSelectionFeature.types.d.cts +2 -2
- package/dist/features/row-selection/rowSelectionFeature.types.d.ts +2 -2
- package/dist/features/row-sorting/rowSortingFeature.types.d.cts +7 -7
- package/dist/features/row-sorting/rowSortingFeature.types.d.ts +7 -7
- package/dist/helpers/columnHelper.cjs.map +1 -1
- package/dist/helpers/columnHelper.d.cts +2 -2
- package/dist/helpers/columnHelper.d.ts +2 -2
- package/dist/helpers/columnHelper.js.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/types/Cell.d.cts +1 -1
- package/dist/types/Cell.d.ts +1 -1
- package/dist/types/Column.d.cts +4 -4
- package/dist/types/Column.d.ts +4 -4
- package/dist/types/ColumnDef.d.cts +3 -3
- package/dist/types/ColumnDef.d.ts +3 -3
- package/dist/types/Header.d.cts +1 -1
- package/dist/types/Header.d.ts +1 -1
- package/dist/types/HeaderGroup.d.cts +2 -2
- package/dist/types/HeaderGroup.d.ts +2 -2
- package/dist/types/Row.d.cts +2 -2
- package/dist/types/Row.d.ts +2 -2
- package/dist/types/RowModel.d.cts +2 -2
- package/dist/types/RowModel.d.ts +2 -2
- package/dist/types/RowModelFns.d.cts +2 -2
- package/dist/types/RowModelFns.d.ts +2 -2
- package/dist/types/Table.d.cts +21 -12
- package/dist/types/Table.d.ts +21 -12
- package/dist/types/TableOptions.d.cts +11 -5
- package/dist/types/TableOptions.d.ts +11 -5
- package/dist/types/TableState.d.cts +1 -1
- package/dist/types/TableState.d.ts +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +7 -2
- package/dist/utils.d.ts +7 -2
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/core/cells/coreCellsFeature.types.ts +6 -6
- package/src/core/columns/coreColumnsFeature.types.ts +8 -8
- package/src/core/columns/coreColumnsFeature.utils.ts +1 -1
- package/src/core/headers/buildHeaderGroups.ts +3 -1
- package/src/core/headers/coreHeadersFeature.types.ts +10 -10
- package/src/core/row-models/coreRowModelsFeature.types.ts +6 -6
- package/src/core/row-models/createCoreRowModel.ts +5 -4
- package/src/core/rows/coreRowsFeature.types.ts +8 -8
- package/src/core/table/constructTable.ts +1 -1
- package/src/core/table/coreTablesFeature.types.ts +8 -8
- package/src/core/table/coreTablesFeature.utils.ts +8 -2
- package/src/features/column-faceting/columnFacetingFeature.types.ts +8 -8
- package/src/features/column-filtering/columnFilteringFeature.types.ts +18 -18
- package/src/features/column-filtering/columnFilteringFeature.utils.ts +1 -1
- package/src/features/column-grouping/columnGroupingFeature.types.ts +12 -12
- package/src/features/column-ordering/columnOrderingFeature.types.ts +2 -2
- package/src/features/column-pinning/columnPinningFeature.types.ts +4 -4
- package/src/features/column-pinning/columnPinningFeature.utils.ts +6 -14
- package/src/features/column-resizing/columnResizingFeature.types.ts +1 -4
- package/src/features/column-visibility/columnVisibilityFeature.types.ts +4 -4
- package/src/features/global-filtering/globalFilteringFeature.types.ts +4 -4
- package/src/features/global-filtering/globalFilteringFeature.utils.ts +1 -1
- package/src/features/row-expanding/rowExpandingFeature.types.ts +8 -8
- package/src/features/row-pagination/rowPaginationFeature.types.ts +6 -6
- package/src/features/row-pinning/rowPinningFeature.types.ts +4 -4
- package/src/features/row-selection/rowSelectionFeature.types.ts +4 -4
- package/src/features/row-sorting/rowSortingFeature.types.ts +14 -14
- package/src/helpers/columnHelper.ts +4 -4
- package/src/types/Cell.ts +2 -2
- package/src/types/Column.ts +8 -8
- package/src/types/ColumnDef.ts +6 -6
- package/src/types/Header.ts +2 -2
- package/src/types/HeaderGroup.ts +6 -6
- package/src/types/Row.ts +4 -4
- package/src/types/RowModel.ts +7 -7
- package/src/types/RowModelFns.ts +7 -7
- package/src/types/Table.ts +51 -25
- package/src/types/TableOptions.ts +54 -12
- package/src/types/TableState.ts +15 -1
- package/src/utils.ts +11 -2
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NoInfer, RowData, Updater } from "./types/type-utils.js";
|
|
2
2
|
import { TableState, TableState_All } from "./types/TableState.js";
|
|
3
|
-
import {
|
|
3
|
+
import { Table_Internal } from "./types/Table.js";
|
|
4
4
|
import { TableFeatures } from "./types/TableFeatures.js";
|
|
5
5
|
|
|
6
6
|
//#region src/utils.d.ts
|
|
@@ -21,7 +21,12 @@ declare function cloneState<T>(value: T): T;
|
|
|
21
21
|
*
|
|
22
22
|
* The updater writes through the table base atom for the slice and supports both value and functional updater forms.
|
|
23
23
|
*/
|
|
24
|
-
declare function makeStateUpdater<TFeatures extends TableFeatures, K extends (string & {}) | keyof TableState_All | keyof TableState<TFeatures>>(key: K, instance:
|
|
24
|
+
declare function makeStateUpdater<TFeatures extends TableFeatures, K extends (string & {}) | keyof TableState_All | keyof TableState<TFeatures>>(key: K, instance: {
|
|
25
|
+
readonly options: {
|
|
26
|
+
readonly atoms?: object | undefined;
|
|
27
|
+
};
|
|
28
|
+
readonly baseAtoms: object;
|
|
29
|
+
}): (updater: Updater<TableState<any>[K & keyof TableState<any>]>) => void;
|
|
25
30
|
type AnyFunction = (...args: any) => any;
|
|
26
31
|
/**
|
|
27
32
|
* Returns whether a value is a function.
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import type { Table, Table_Internal } from './types/Table'\nimport type { NoInfer, RowData, Updater } from './types/type-utils'\nimport type { TableFeatures } from './types/TableFeatures'\nimport type { TableState, TableState_All } from './types/TableState'\n\n/**\n * Applies a TanStack updater to a value.\n *\n * If the updater is a function it is called with the previous value; otherwise the updater value is returned directly.\n */\nexport function functionalUpdate<T>(updater: Updater<T>, input: T): T {\n return typeof updater === 'function'\n ? (updater as (i: T) => T)(input)\n : updater\n}\n\n/**\n * Clones table state values while preserving non-plain objects.\n *\n * Plain objects and arrays are copied recursively so state updates can avoid mutating existing references.\n */\nexport function cloneState<T>(value: T): T {\n if (Array.isArray(value)) {\n return value.map(cloneState) as T\n }\n\n if (value && typeof value === 'object') {\n const proto = Object.getPrototypeOf(value)\n\n if (proto !== Object.prototype && proto !== null) {\n return value\n }\n\n const copy: Record<string, unknown> = {}\n const keys = Object.keys(value)\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]!\n copy[key] = cloneState((value as Record<string, unknown>)[key])\n }\n\n return copy as T\n }\n\n return value\n}\n\n/**\n * Creates a table state updater for a single state slice.\n *\n * The updater writes through the table base atom for the slice and supports both value and functional updater forms.\n */\nexport function makeStateUpdater<\n TFeatures extends TableFeatures,\n K extends (string & {}) | keyof TableState_All | keyof TableState<TFeatures>,\n>(key: K, instance: Table<TFeatures, any>) {\n return (updater: Updater<TableState<any>[K & keyof TableState<any>]>) => {\n const externalAtom = (instance.options as any).atoms?.[key]\n const targetAtom = externalAtom ?? (instance.baseAtoms as any)[key]\n targetAtom.set((old: any) => functionalUpdate(updater, old))\n }\n}\n\ntype AnyFunction = (...args: any) => any\n\n/**\n * Returns whether a value is a function.\n */\nexport function isFunction<T extends AnyFunction>(d: any): d is T {\n return d instanceof Function\n}\n\n/**\n * Flattens a tree of nodes by recursively reading child nodes.\n *\n * The original nodes are preserved in depth-first order.\n */\nexport function flattenBy<TNode>(\n arr: Array<TNode>,\n getChildren: (item: TNode) => Array<TNode>,\n) {\n const flat: Array<TNode> = []\n\n const recurse = (subArr: Array<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\ninterface MemoOptions<TDeps extends ReadonlyArray<any>, TDepArgs, TResult> {\n fn: (...args: NoInfer<TDeps>) => TResult\n memoDeps?: (depArgs?: TDepArgs) => [...TDeps] | undefined\n onAfterCompare?: (depsChanged: boolean) => void\n onAfterUpdate?: (result: TResult) => void\n onBeforeCompare?: () => void\n onBeforeUpdate?: () => void\n}\n\n/**\n * Creates a dependency-tracked memoized function for table internals.\n *\n * The memo recomputes only when its dependency tuple changes and can emit debug timing information.\n */\nexport const memo = <TDeps extends ReadonlyArray<any>, TDepArgs, TResult>({\n fn,\n memoDeps,\n onAfterCompare,\n onAfterUpdate,\n onBeforeCompare,\n onBeforeUpdate,\n}: MemoOptions<TDeps, TDepArgs, TResult>): ((\n depArgs?: TDepArgs,\n) => TResult) => {\n let deps: Array<any> | undefined = []\n let result: TResult | undefined\n\n const memoizedFn = (depArgs?: TDepArgs): TResult => {\n onBeforeCompare?.()\n const newDeps = memoDeps?.(depArgs)\n let depsChanged = !newDeps || newDeps.length !== deps?.length\n if (!depsChanged && newDeps) {\n for (let i = 0; i < newDeps.length; i++) {\n if (newDeps[i] !== deps![i]) {\n depsChanged = true\n break\n }\n }\n }\n onAfterCompare?.(depsChanged)\n\n if (!depsChanged) {\n return result!\n }\n\n deps = newDeps\n\n onBeforeUpdate?.()\n result = fn(...(newDeps ?? ([] as any)))\n onAfterUpdate?.(result)\n\n return result\n }\n\n return memoizedFn\n}\n\ninterface TableMemoOptions<\n TFeatures extends TableFeatures,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n TResult,\n> extends MemoOptions<TDeps, TDepArgs, TResult> {\n feature?: keyof TFeatures & string\n fnName: string\n objectId?: string\n onAfterUpdate?: () => void\n table: Table_Internal<TFeatures, any>\n}\n\nconst 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/**\n * Creates a table-aware memoized function.\n *\n * This wraps `memo` with table debug options and feature metadata so row models and derived APIs can share consistent diagnostics.\n */\nexport function tableMemo<\n TFeatures extends TableFeatures,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n TResult,\n>({\n feature,\n fnName,\n objectId,\n onAfterUpdate,\n table,\n ...memoOptions\n}: TableMemoOptions<TFeatures, TDeps, TDepArgs, TResult>) {\n let beforeCompareTime: number\n let afterCompareTime: number\n let startCalcTime: number\n let endCalcTime: number\n let runCount = 0\n let debug: boolean | undefined\n let debugCache: boolean | undefined\n\n if (process.env.NODE_ENV === 'development') {\n const { debugCache: _debugCache, debugAll } = table.options\n debugCache = _debugCache\n const { parentName } = getFunctionNameInfo(fnName, '.')\n\n const debugByParent =\n // @ts-expect-error\n table.options[\n `debug${(parentName != 'table' ? parentName + 's' : parentName).replace(\n parentName,\n parentName.charAt(0).toUpperCase() + parentName.slice(1),\n )}`\n ]\n const debugByFeature = feature\n ? // @ts-expect-error\n table.options[\n `debug${feature.charAt(0).toUpperCase() + feature.slice(1)}`\n ]\n : false\n\n debug = debugAll || debugByParent || debugByFeature\n }\n\n function logTime(time: number, depsChanged: boolean) {\n const runType =\n runCount === 0\n ? '(1st run)'\n : depsChanged\n ? '(rerun #' + runCount + ')'\n : '(cache)'\n runCount++\n\n console.groupCollapsed(\n `%c⏱ ${pad(`${time.toFixed(1)} ms`, 12)} %c${runType}%c ${fnName}%c ${objectId ? `(${fnName.split('.')[0]}Id: ${objectId})` : ''}`,\n `font-size: .6rem; font-weight: bold; ${\n depsChanged\n ? `color: hsl(\n ${Math.max(0, Math.min(120 - Math.log10(time) * 60, 120))}deg 100% 31%);`\n : ''\n } `,\n `color: ${runCount < 2 ? '#FF00FF' : '#FF1493'}`,\n 'color: #666',\n 'color: #87CEEB',\n )\n console.info({\n feature,\n state: table.store.state,\n deps: memoOptions.memoDeps?.toString(),\n })\n console.trace()\n console.groupEnd()\n }\n\n const onAfterUpdateHandler = () => {\n if (!onAfterUpdate) {\n return\n }\n\n const { schedule, untrack } = table._reactivity\n schedule(() => untrack(() => onAfterUpdate()))\n }\n\n const debugOptions =\n process.env.NODE_ENV === 'development'\n ? {\n onBeforeCompare: () => {\n if (debugCache) {\n beforeCompareTime = performance.now()\n }\n },\n onAfterCompare: (depsChanged: boolean) => {\n if (debugCache) {\n afterCompareTime = performance.now()\n const compareTime =\n Math.round((afterCompareTime - beforeCompareTime) * 100) / 100\n if (!depsChanged) {\n logTime(compareTime, depsChanged)\n }\n }\n },\n onBeforeUpdate: () => {\n if (debug) {\n startCalcTime = performance.now()\n }\n },\n onAfterUpdate: () => {\n if (debug) {\n endCalcTime = performance.now()\n const executionTime =\n Math.round((endCalcTime - startCalcTime) * 100) / 100\n logTime(executionTime, true)\n }\n onAfterUpdateHandler()\n },\n }\n : {\n onAfterUpdate: () => {\n onAfterUpdateHandler()\n },\n }\n\n return memo({\n ...memoOptions,\n ...debugOptions,\n })\n}\n\nexport interface API<TDeps extends ReadonlyArray<any>, TDepArgs> {\n fn: (...args: any) => any\n memoDeps?: (depArgs?: any) => [...any] | undefined\n}\n\nexport type APIObject<TDeps extends ReadonlyArray<any>, TDepArgs> = Record<\n string,\n API<TDeps, TDepArgs>\n>\n\n/**\n * Assumes that a function name is in the format of `parentName_fnKey` and returns the `fnKey` and `fnName` in the format of `parentName.fnKey`.\n */\nexport function getFunctionNameInfo(\n staticFnName: string,\n splitBy: '_' | '.' = '_',\n) {\n const [parentName, fnKey] = staticFnName.split(splitBy)\n const fnName = `${parentName}.${fnKey}`\n return { fnKey, fnName, parentName } as {\n fnKey: string\n fnName: string\n parentName: string\n }\n}\n\n/**\n * Assigns Table API methods directly to the table instance.\n * Unlike row/cell/column/header, the table is a singleton so methods are assigned directly.\n */\nexport function assignTableAPIs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n>(\n feature: keyof TFeatures & string,\n table: Table_Internal<TFeatures, TData>,\n apis: APIObject<TDeps, NoInfer<TDepArgs>>,\n): void {\n for (const [staticFnName, { fn, memoDeps }] of Object.entries(apis)) {\n const { fnKey, fnName } = getFunctionNameInfo(staticFnName)\n\n ;(table as Record<string, any>)[fnKey] = memoDeps\n ? tableMemo({\n memoDeps,\n fn,\n fnName,\n table,\n feature,\n })\n : fn\n }\n}\n\nexport interface PrototypeAPI<TDeps extends ReadonlyArray<any>, TDepArgs> {\n fn: (self: any, ...args: any) => any\n memoDeps?: (self: any, depArgs?: any) => [...any] | undefined\n}\n\nexport type PrototypeAPIObject<\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n> = Record<string, PrototypeAPI<TDeps, TDepArgs>>\n\n/**\n * Assigns API methods to a prototype object for memory-efficient method sharing.\n * All instances created with this prototype will share the same method references.\n *\n * For memoized methods, the memo state is lazily created and stored on each instance.\n * This provides the best of both worlds: shared method code + per-instance caching.\n */\nexport function assignPrototypeAPIs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n>(\n feature: keyof TFeatures & string,\n prototype: Record<string, any>,\n table: Table_Internal<TFeatures, TData>,\n apis: PrototypeAPIObject<TDeps, NoInfer<TDepArgs>>,\n): void {\n for (const [staticFnName, { fn, memoDeps }] of Object.entries(apis)) {\n const { fnKey, fnName } = getFunctionNameInfo(staticFnName)\n\n if (memoDeps) {\n // For memoized methods, create a function that lazily initializes\n // the memo on first access and stores it on the instance\n const memoKey = `_memo_${fnKey}`\n\n prototype[fnKey] = function (this: any, ...args: Array<any>) {\n // Lazily create memo on first access for this instance\n if (!this[memoKey]) {\n const self = this\n this[memoKey] = tableMemo({\n memoDeps: (depArgs) => memoDeps(self, depArgs),\n fn: (...deps) => fn(self, ...deps),\n fnName,\n objectId: self.id,\n table,\n feature,\n })\n }\n return this[memoKey](...args)\n }\n } else {\n // Non-memoized methods just call the static function with `this`\n prototype[fnKey] = function (this: any, ...args: Array<any>) {\n return fn(this, ...args)\n }\n }\n }\n}\n\n/**\n * Looks to run the memoized function with the builder pattern on the object if it exists, otherwise fallback to the static method passed in.\n */\nexport function callMemoOrStaticFn<\n TObject extends Record<string, any>,\n TArgs extends Array<any>,\n TReturn,\n>(\n obj: TObject,\n fnKey: string,\n staticFn: (obj: TObject, ...args: TArgs) => TReturn,\n ...args: TArgs\n): TReturn {\n return (\n (obj[fnKey] as Function | undefined)?.(...args) ?? staticFn(obj, ...args)\n )\n}\n"],"mappings":";;;;;;AAUA,SAAgB,iBAAoB,SAAqB,OAAa;CACpE,OAAO,OAAO,YAAY,aACrB,QAAwB,KAAK,IAC9B;AACN;;;;;;AAOA,SAAgB,WAAc,OAAa;CACzC,IAAI,MA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AS,WACrC,UAAU;GACR;GACA;GACA;GACA;GACA;EACF,CAAC,IACD;CACN;AACF;;;;;;;;AAmBA,SAAgB,oBAMd,SACA,WACA,OACA,MACM;CACN,KAAK,MAAM,CAAC,cAAc,EAAE,IAAI,eAAe,OAAO,QAAQ,IAAI,GAAG;EACnE,MAAM,EAAE,OAAO,WAAW,oBAAoB,YAAY;EAE1D,IAAI,UAAU;GAGZ,MAAM,UAAU,SAAS;GAEzB,UAAU,SAAS,SAAqB,GAAG,MAAkB;IAE3D,IAAI,CAAC,KAAK,UAAU;KAClB,MAAM,OAAO;KACb,KAAK,WAAW,UAAU;MACxB,WAAW,YAAY,SAAS,MAAM,OAAO;MAC7C,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI;MACjC;MACA,UAAU,KAAK;MACf;MACA;KACF,CAAC;IACH;IACA,OAAO,KAAK,QAAQ,CAAC,GAAG,IAAI;GAC9B;EACF,OAEE,UAAU,SAAS,SAAqB,GAAG,MAAkB;GAC3D,OAAO,GAAG,MAAM,GAAG,IAAI;EACzB;CAEJ;AACF;;;;AAKA,SAAgB,mBAKd,KACA,OACA,UACA,GAAG,MACM;;CACT,sBACG,IAAI,0EAAkC,GAAG,IAAI,MAAK,SAAS,KAAK,GAAG,IAAI;AAE5E"}
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import type { Table_Internal } from './types/Table'\nimport type { NoInfer, RowData, Updater } from './types/type-utils'\nimport type { TableFeatures } from './types/TableFeatures'\nimport type { TableState, TableState_All } from './types/TableState'\n\n/**\n * Applies a TanStack updater to a value.\n *\n * If the updater is a function it is called with the previous value; otherwise the updater value is returned directly.\n */\nexport function functionalUpdate<T>(updater: Updater<T>, input: T): T {\n return typeof updater === 'function'\n ? (updater as (i: T) => T)(input)\n : updater\n}\n\n/**\n * Clones table state values while preserving non-plain objects.\n *\n * Plain objects and arrays are copied recursively so state updates can avoid mutating existing references.\n */\nexport function cloneState<T>(value: T): T {\n if (Array.isArray(value)) {\n return value.map(cloneState) as T\n }\n\n if (value && typeof value === 'object') {\n const proto = Object.getPrototypeOf(value)\n\n if (proto !== Object.prototype && proto !== null) {\n return value\n }\n\n const copy: Record<string, unknown> = {}\n const keys = Object.keys(value)\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]!\n copy[key] = cloneState((value as Record<string, unknown>)[key])\n }\n\n return copy as T\n }\n\n return value\n}\n\n/**\n * Creates a table state updater for a single state slice.\n *\n * The updater writes through the table base atom for the slice and supports both value and functional updater forms.\n */\nexport function makeStateUpdater<\n TFeatures extends TableFeatures,\n K extends (string & {}) | keyof TableState_All | keyof TableState<TFeatures>,\n>(\n key: K,\n // Minimal structural shape so any table view (public `Table`,\n // `Table_Internal`, or a custom plugin table) can be passed without forcing\n // the compiler to relate the full table types.\n instance: {\n readonly options: { readonly atoms?: object | undefined }\n readonly baseAtoms: object\n },\n) {\n return (updater: Updater<TableState<any>[K & keyof TableState<any>]>) => {\n const externalAtom = (instance.options as any).atoms?.[key]\n const targetAtom = externalAtom ?? (instance.baseAtoms as any)[key]\n targetAtom.set((old: any) => functionalUpdate(updater, old))\n }\n}\n\ntype AnyFunction = (...args: any) => any\n\n/**\n * Returns whether a value is a function.\n */\nexport function isFunction<T extends AnyFunction>(d: any): d is T {\n return d instanceof Function\n}\n\n/**\n * Flattens a tree of nodes by recursively reading child nodes.\n *\n * The original nodes are preserved in depth-first order.\n */\nexport function flattenBy<TNode>(\n arr: Array<TNode>,\n getChildren: (item: TNode) => Array<TNode>,\n) {\n const flat: Array<TNode> = []\n\n const recurse = (subArr: Array<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\ninterface MemoOptions<TDeps extends ReadonlyArray<any>, TDepArgs, TResult> {\n fn: (...args: NoInfer<TDeps>) => TResult\n memoDeps?: (depArgs?: TDepArgs) => [...TDeps] | undefined\n onAfterCompare?: (depsChanged: boolean) => void\n onAfterUpdate?: (result: TResult) => void\n onBeforeCompare?: () => void\n onBeforeUpdate?: () => void\n}\n\n/**\n * Creates a dependency-tracked memoized function for table internals.\n *\n * The memo recomputes only when its dependency tuple changes and can emit debug timing information.\n */\nexport const memo = <TDeps extends ReadonlyArray<any>, TDepArgs, TResult>({\n fn,\n memoDeps,\n onAfterCompare,\n onAfterUpdate,\n onBeforeCompare,\n onBeforeUpdate,\n}: MemoOptions<TDeps, TDepArgs, TResult>): ((\n depArgs?: TDepArgs,\n) => TResult) => {\n let deps: Array<any> | undefined = []\n let result: TResult | undefined\n\n const memoizedFn = (depArgs?: TDepArgs): TResult => {\n onBeforeCompare?.()\n const newDeps = memoDeps?.(depArgs)\n let depsChanged = !newDeps || newDeps.length !== deps?.length\n if (!depsChanged && newDeps) {\n for (let i = 0; i < newDeps.length; i++) {\n if (newDeps[i] !== deps![i]) {\n depsChanged = true\n break\n }\n }\n }\n onAfterCompare?.(depsChanged)\n\n if (!depsChanged) {\n return result!\n }\n\n deps = newDeps\n\n onBeforeUpdate?.()\n result = fn(...(newDeps ?? ([] as any)))\n onAfterUpdate?.(result)\n\n return result\n }\n\n return memoizedFn\n}\n\ninterface TableMemoOptions<\n TFeatures extends TableFeatures,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n TResult,\n> extends MemoOptions<TDeps, TDepArgs, TResult> {\n feature?: keyof TFeatures & string\n fnName: string\n objectId?: string\n onAfterUpdate?: () => void\n table: Table_Internal<TFeatures, any>\n}\n\nconst 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/**\n * Creates a table-aware memoized function.\n *\n * This wraps `memo` with table debug options and feature metadata so row models and derived APIs can share consistent diagnostics.\n */\nexport function tableMemo<\n TFeatures extends TableFeatures,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n TResult,\n>({\n feature,\n fnName,\n objectId,\n onAfterUpdate,\n table,\n ...memoOptions\n}: TableMemoOptions<TFeatures, TDeps, TDepArgs, TResult>) {\n let beforeCompareTime: number\n let afterCompareTime: number\n let startCalcTime: number\n let endCalcTime: number\n let runCount = 0\n let debug: boolean | undefined\n let debugCache: boolean | undefined\n\n if (process.env.NODE_ENV === 'development') {\n const { debugCache: _debugCache, debugAll } = table.options\n debugCache = _debugCache\n const { parentName } = getFunctionNameInfo(fnName, '.')\n\n const debugByParent =\n // @ts-expect-error\n table.options[\n `debug${(parentName != 'table' ? parentName + 's' : parentName).replace(\n parentName,\n parentName.charAt(0).toUpperCase() + parentName.slice(1),\n )}`\n ]\n const debugByFeature = feature\n ? // @ts-expect-error\n table.options[\n `debug${feature.charAt(0).toUpperCase() + feature.slice(1)}`\n ]\n : false\n\n debug = debugAll || debugByParent || debugByFeature\n }\n\n function logTime(time: number, depsChanged: boolean) {\n const runType =\n runCount === 0\n ? '(1st run)'\n : depsChanged\n ? '(rerun #' + runCount + ')'\n : '(cache)'\n runCount++\n\n console.groupCollapsed(\n `%c⏱ ${pad(`${time.toFixed(1)} ms`, 12)} %c${runType}%c ${fnName}%c ${objectId ? `(${fnName.split('.')[0]}Id: ${objectId})` : ''}`,\n `font-size: .6rem; font-weight: bold; ${\n depsChanged\n ? `color: hsl(\n ${Math.max(0, Math.min(120 - Math.log10(time) * 60, 120))}deg 100% 31%);`\n : ''\n } `,\n `color: ${runCount < 2 ? '#FF00FF' : '#FF1493'}`,\n 'color: #666',\n 'color: #87CEEB',\n )\n console.info({\n feature,\n state: table.store.state,\n deps: memoOptions.memoDeps?.toString(),\n })\n console.trace()\n console.groupEnd()\n }\n\n const onAfterUpdateHandler = () => {\n if (!onAfterUpdate) {\n return\n }\n\n const { schedule, untrack } = table._reactivity\n schedule(() => untrack(() => onAfterUpdate()))\n }\n\n const debugOptions =\n process.env.NODE_ENV === 'development'\n ? {\n onBeforeCompare: () => {\n if (debugCache) {\n beforeCompareTime = performance.now()\n }\n },\n onAfterCompare: (depsChanged: boolean) => {\n if (debugCache) {\n afterCompareTime = performance.now()\n const compareTime =\n Math.round((afterCompareTime - beforeCompareTime) * 100) / 100\n if (!depsChanged) {\n logTime(compareTime, depsChanged)\n }\n }\n },\n onBeforeUpdate: () => {\n if (debug) {\n startCalcTime = performance.now()\n }\n },\n onAfterUpdate: () => {\n if (debug) {\n endCalcTime = performance.now()\n const executionTime =\n Math.round((endCalcTime - startCalcTime) * 100) / 100\n logTime(executionTime, true)\n }\n onAfterUpdateHandler()\n },\n }\n : {\n onAfterUpdate: () => {\n onAfterUpdateHandler()\n },\n }\n\n return memo({\n ...memoOptions,\n ...debugOptions,\n })\n}\n\nexport interface API<TDeps extends ReadonlyArray<any>, TDepArgs> {\n fn: (...args: any) => any\n memoDeps?: (depArgs?: any) => [...any] | undefined\n}\n\nexport type APIObject<TDeps extends ReadonlyArray<any>, TDepArgs> = Record<\n string,\n API<TDeps, TDepArgs>\n>\n\n/**\n * Assumes that a function name is in the format of `parentName_fnKey` and returns the `fnKey` and `fnName` in the format of `parentName.fnKey`.\n */\nexport function getFunctionNameInfo(\n staticFnName: string,\n splitBy: '_' | '.' = '_',\n) {\n const [parentName, fnKey] = staticFnName.split(splitBy)\n const fnName = `${parentName}.${fnKey}`\n return { fnKey, fnName, parentName } as {\n fnKey: string\n fnName: string\n parentName: string\n }\n}\n\n/**\n * Assigns Table API methods directly to the table instance.\n * Unlike row/cell/column/header, the table is a singleton so methods are assigned directly.\n */\nexport function assignTableAPIs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n>(\n feature: keyof TFeatures & string,\n table: Table_Internal<TFeatures, TData>,\n apis: APIObject<TDeps, NoInfer<TDepArgs>>,\n): void {\n for (const [staticFnName, { fn, memoDeps }] of Object.entries(apis)) {\n const { fnKey, fnName } = getFunctionNameInfo(staticFnName)\n\n ;(table as Record<string, any>)[fnKey] = memoDeps\n ? tableMemo({\n memoDeps,\n fn,\n fnName,\n table,\n feature,\n })\n : fn\n }\n}\n\nexport interface PrototypeAPI<TDeps extends ReadonlyArray<any>, TDepArgs> {\n fn: (self: any, ...args: any) => any\n memoDeps?: (self: any, depArgs?: any) => [...any] | undefined\n}\n\nexport type PrototypeAPIObject<\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n> = Record<string, PrototypeAPI<TDeps, TDepArgs>>\n\n/**\n * Assigns API methods to a prototype object for memory-efficient method sharing.\n * All instances created with this prototype will share the same method references.\n *\n * For memoized methods, the memo state is lazily created and stored on each instance.\n * This provides the best of both worlds: shared method code + per-instance caching.\n */\nexport function assignPrototypeAPIs<\n TFeatures extends TableFeatures,\n TData extends RowData,\n TDeps extends ReadonlyArray<any>,\n TDepArgs,\n>(\n feature: keyof TFeatures & string,\n prototype: Record<string, any>,\n table: Table_Internal<TFeatures, TData>,\n apis: PrototypeAPIObject<TDeps, NoInfer<TDepArgs>>,\n): void {\n for (const [staticFnName, { fn, memoDeps }] of Object.entries(apis)) {\n const { fnKey, fnName } = getFunctionNameInfo(staticFnName)\n\n if (memoDeps) {\n // For memoized methods, create a function that lazily initializes\n // the memo on first access and stores it on the instance\n const memoKey = `_memo_${fnKey}`\n\n prototype[fnKey] = function (this: any, ...args: Array<any>) {\n // Lazily create memo on first access for this instance\n if (!this[memoKey]) {\n const self = this\n this[memoKey] = tableMemo({\n memoDeps: (depArgs) => memoDeps(self, depArgs),\n fn: (...deps) => fn(self, ...deps),\n fnName,\n objectId: self.id,\n table,\n feature,\n })\n }\n return this[memoKey](...args)\n }\n } else {\n // Non-memoized methods just call the static function with `this`\n prototype[fnKey] = function (this: any, ...args: Array<any>) {\n return fn(this, ...args)\n }\n }\n }\n}\n\n/**\n * Looks to run the memoized function with the builder pattern on the object if it exists, otherwise fallback to the static method passed in.\n */\nexport function callMemoOrStaticFn<\n TObject extends Record<string, any>,\n TArgs extends Array<any>,\n TReturn,\n>(\n obj: TObject,\n fnKey: string,\n staticFn: (obj: TObject, ...args: TArgs) => TReturn,\n ...args: TArgs\n): TReturn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,WAAW,GAAG;EACR;CAAW;AAKrC;;;;;AAMA,SAAgB,gBAMd,SACA,OACA,MACM;CACN,KAAK,MAAM,CAAC,cAAc,EAAE,IAAI,eAAe,OAAO,QAAQ,IAAI,GAAG;EACnE,MAAM,EAAE,OAAO,WAAW,oBAAoB,YAAY;EAEzD,AAAC,MAA8B,SAAS,WACrC,UAAU;GACR;GACA;GACA;GACA;GACA;EACF,CAAC,IACD;CACN;AACF;;;;;;;;AAmBA,SAAgB,oBAMd,SACA,WACA,OACA,MACM;CACN,KAAK,MAAM,CAAC,cAAc,EAAE,IAAI,eAAe,OAAO,QAAQ,IAAI,GAAG;EACnE,MAAM,EAAE,OAAO,WAAW,oBAAoB,YAAY;EAE1D,IAAI,UAAU;GAGZ,MAAM,UAAU,SAAS;GAEzB,UAAU,SAAS,SAAqB,GAAG,MAAkB;IAE3D,IAAI,CAAC,KAAK,UAAU;KAClB,MAAM,OAAO;KACb,KAAK,WAAW,UAAU;MACxB,WAAW,YAAY,SAAS,MAAM,OAAO;MAC7C,KAAK,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI;MACjC;MACA,UAAU,KAAK;MACf;MACA;KACF,CAAC;IACH;IACA,OAAO,KAAK,QAAQ,CAAC,GAAG,IAAI;GAC9B;EACF,OAEE,UAAU,SAAS,SAAqB,GAAG,MAAkB;GAC3D,OAAO,GAAG,MAAM,GAAG,IAAI;EACzB;CAEJ;AACF;;;;AAKA,SAAgB,mBAKd,KACA,OACA,UACA,GAAG,MACM;;CACT,sBACG,IAAI,0EAAkC,GAAG,IAAI,MAAK,SAAS,KAAK,GAAG,IAAI;AAE5E"}
|
package/package.json
CHANGED
|
@@ -6,8 +6,8 @@ import type { Cell } from '../../types/Cell'
|
|
|
6
6
|
import type { Column } from '../../types/Column'
|
|
7
7
|
|
|
8
8
|
export interface CellContext<
|
|
9
|
-
TFeatures extends TableFeatures,
|
|
10
|
-
TData extends RowData,
|
|
9
|
+
in out TFeatures extends TableFeatures,
|
|
10
|
+
in out TData extends RowData,
|
|
11
11
|
TValue extends CellData = CellData,
|
|
12
12
|
> {
|
|
13
13
|
cell: Cell<TFeatures, TData, TValue>
|
|
@@ -19,8 +19,8 @@ export interface CellContext<
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export interface Cell_CoreProperties<
|
|
22
|
-
TFeatures extends TableFeatures,
|
|
23
|
-
TData extends RowData,
|
|
22
|
+
in out TFeatures extends TableFeatures,
|
|
23
|
+
in out TData extends RowData,
|
|
24
24
|
TValue extends CellData = CellData,
|
|
25
25
|
> {
|
|
26
26
|
/**
|
|
@@ -42,8 +42,8 @@ export interface Cell_CoreProperties<
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
export interface Cell_Cell<
|
|
45
|
-
TFeatures extends TableFeatures,
|
|
46
|
-
TData extends RowData,
|
|
45
|
+
in out TFeatures extends TableFeatures,
|
|
46
|
+
in out TData extends RowData,
|
|
47
47
|
TValue extends CellData = CellData,
|
|
48
48
|
> extends Cell_CoreProperties<TFeatures, TData, TValue> {
|
|
49
49
|
/**
|
|
@@ -5,8 +5,8 @@ import type { AccessorFn, ColumnDef } from '../../types/ColumnDef'
|
|
|
5
5
|
import type { Column } from '../../types/Column'
|
|
6
6
|
|
|
7
7
|
export interface Column_CoreProperties<
|
|
8
|
-
TFeatures extends TableFeatures,
|
|
9
|
-
TData extends RowData,
|
|
8
|
+
in out TFeatures extends TableFeatures,
|
|
9
|
+
in out TData extends RowData,
|
|
10
10
|
TValue extends CellData = CellData,
|
|
11
11
|
> {
|
|
12
12
|
/**
|
|
@@ -43,8 +43,8 @@ export interface Column_CoreProperties<
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export interface Column_Column<
|
|
46
|
-
TFeatures extends TableFeatures,
|
|
47
|
-
TData extends RowData,
|
|
46
|
+
in out TFeatures extends TableFeatures,
|
|
47
|
+
in out TData extends RowData,
|
|
48
48
|
TValue extends CellData = CellData,
|
|
49
49
|
> extends Column_CoreProperties<TFeatures, TData, TValue> {
|
|
50
50
|
/**
|
|
@@ -59,8 +59,8 @@ export interface Column_Column<
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
export interface TableOptions_Columns<
|
|
62
|
-
TFeatures extends TableFeatures,
|
|
63
|
-
TData extends RowData,
|
|
62
|
+
in out TFeatures extends TableFeatures,
|
|
63
|
+
in out TData extends RowData,
|
|
64
64
|
TValue extends CellData = CellData,
|
|
65
65
|
> {
|
|
66
66
|
/**
|
|
@@ -74,8 +74,8 @@ export interface TableOptions_Columns<
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
export interface Table_Columns<
|
|
77
|
-
TFeatures extends TableFeatures,
|
|
78
|
-
TData extends RowData,
|
|
77
|
+
in out TFeatures extends TableFeatures,
|
|
78
|
+
in out TData extends RowData,
|
|
79
79
|
> {
|
|
80
80
|
/**
|
|
81
81
|
* Returns a map of all flat columns by their ID.
|
|
@@ -113,7 +113,9 @@ export function buildHeaderGroups<
|
|
|
113
113
|
pendingParentHeaders.push(header)
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
headerGroup.headers.push(
|
|
116
|
+
headerGroup.headers.push(
|
|
117
|
+
headerToGroup as Header<TFeatures, TData, unknown>,
|
|
118
|
+
)
|
|
117
119
|
headerToGroup.headerGroup = headerGroup
|
|
118
120
|
})
|
|
119
121
|
|
|
@@ -6,8 +6,8 @@ import type { HeaderGroup } from '../../types/HeaderGroup'
|
|
|
6
6
|
import type { Column } from '../../types/Column'
|
|
7
7
|
|
|
8
8
|
export interface Table_Headers<
|
|
9
|
-
TFeatures extends TableFeatures,
|
|
10
|
-
TData extends RowData,
|
|
9
|
+
in out TFeatures extends TableFeatures,
|
|
10
|
+
in out TData extends RowData,
|
|
11
11
|
> {
|
|
12
12
|
/**
|
|
13
13
|
* Builds the visible header groups for the current column tree, visibility,
|
|
@@ -30,8 +30,8 @@ export interface Table_Headers<
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export interface HeaderContext<
|
|
33
|
-
TFeatures extends TableFeatures,
|
|
34
|
-
TData extends RowData,
|
|
33
|
+
in out TFeatures extends TableFeatures,
|
|
34
|
+
in out TData extends RowData,
|
|
35
35
|
TValue extends CellData = CellData,
|
|
36
36
|
> {
|
|
37
37
|
/**
|
|
@@ -49,8 +49,8 @@ export interface HeaderContext<
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export interface Header_CoreProperties<
|
|
52
|
-
TFeatures extends TableFeatures,
|
|
53
|
-
TData extends RowData,
|
|
52
|
+
in out TFeatures extends TableFeatures,
|
|
53
|
+
in out TData extends RowData,
|
|
54
54
|
TValue extends CellData = CellData,
|
|
55
55
|
> {
|
|
56
56
|
/**
|
|
@@ -100,8 +100,8 @@ export interface Header_CoreProperties<
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
export interface Header_Header<
|
|
103
|
-
TFeatures extends TableFeatures,
|
|
104
|
-
TData extends RowData,
|
|
103
|
+
in out TFeatures extends TableFeatures,
|
|
104
|
+
in out TData extends RowData,
|
|
105
105
|
TValue extends CellData = CellData,
|
|
106
106
|
> extends Header_CoreProperties<TFeatures, TData, TValue> {
|
|
107
107
|
/**
|
|
@@ -115,8 +115,8 @@ export interface Header_Header<
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
export interface HeaderGroup_Header<
|
|
118
|
-
TFeatures extends TableFeatures,
|
|
119
|
-
TData extends RowData,
|
|
118
|
+
in out TFeatures extends TableFeatures,
|
|
119
|
+
in out TData extends RowData,
|
|
120
120
|
TValue extends CellData = CellData,
|
|
121
121
|
> {
|
|
122
122
|
depth: number
|
|
@@ -10,8 +10,8 @@ import type { TableFeatures } from '../../types/TableFeatures'
|
|
|
10
10
|
import type { RowData } from '../../types/type-utils'
|
|
11
11
|
|
|
12
12
|
export interface RowModel<
|
|
13
|
-
TFeatures extends TableFeatures,
|
|
14
|
-
TData extends RowData,
|
|
13
|
+
in out TFeatures extends TableFeatures,
|
|
14
|
+
in out TData extends RowData,
|
|
15
15
|
> {
|
|
16
16
|
rows: Array<Row<TFeatures, TData>>
|
|
17
17
|
flatRows: Array<Row<TFeatures, TData>>
|
|
@@ -19,15 +19,15 @@ export interface RowModel<
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export interface CachedRowModel_Core<
|
|
22
|
-
TFeatures extends TableFeatures,
|
|
23
|
-
TData extends RowData,
|
|
22
|
+
in out TFeatures extends TableFeatures,
|
|
23
|
+
in out TData extends RowData,
|
|
24
24
|
> {
|
|
25
25
|
coreRowModel: () => RowModel<TFeatures, TData>
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export interface Table_RowModels_Core<
|
|
29
|
-
TFeatures extends TableFeatures,
|
|
30
|
-
TData extends RowData,
|
|
29
|
+
in out TFeatures extends TableFeatures,
|
|
30
|
+
in out TData extends RowData,
|
|
31
31
|
> {
|
|
32
32
|
/**
|
|
33
33
|
* Returns the core row model before any processing has been applied.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { constructRow } from '../rows/constructRow'
|
|
2
2
|
import { tableMemo } from '../../utils'
|
|
3
3
|
import { table_autoResetPageIndex } from '../../features/row-pagination/rowPaginationFeature.utils'
|
|
4
|
-
import type {
|
|
4
|
+
import type { Table_Internal } from '../../types/Table'
|
|
5
5
|
import type { RowModel } from './coreRowModelsFeature.types'
|
|
6
6
|
import type { TableFeatures } from '../../types/TableFeatures'
|
|
7
7
|
import type { Row } from '../../types/Row'
|
|
@@ -15,9 +15,10 @@ import type { RowData } from '../../types/type-utils'
|
|
|
15
15
|
export function createCoreRowModel<
|
|
16
16
|
TFeatures extends TableFeatures,
|
|
17
17
|
TData extends RowData,
|
|
18
|
-
>(): (
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
>(): (
|
|
19
|
+
table: Table_Internal<TFeatures, TData>,
|
|
20
|
+
) => () => RowModel<TFeatures, TData> {
|
|
21
|
+
return (table) => {
|
|
21
22
|
return tableMemo({
|
|
22
23
|
feature: 'coreRowModelsFeature',
|
|
23
24
|
table,
|
|
@@ -5,8 +5,8 @@ import type { Row } from '../../types/Row'
|
|
|
5
5
|
import type { Cell } from '../../types/Cell'
|
|
6
6
|
|
|
7
7
|
export interface Row_CoreProperties<
|
|
8
|
-
TFeatures extends TableFeatures,
|
|
9
|
-
TData extends RowData,
|
|
8
|
+
in out TFeatures extends TableFeatures,
|
|
9
|
+
in out TData extends RowData,
|
|
10
10
|
> {
|
|
11
11
|
_uniqueValuesCache: Record<string, unknown>
|
|
12
12
|
_valuesCache: Record<string, unknown>
|
|
@@ -45,8 +45,8 @@ export interface Row_CoreProperties<
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export interface Row_Row<
|
|
48
|
-
TFeatures extends TableFeatures,
|
|
49
|
-
TData extends RowData,
|
|
48
|
+
in out TFeatures extends TableFeatures,
|
|
49
|
+
in out TData extends RowData,
|
|
50
50
|
> extends Row_CoreProperties<TFeatures, TData> {
|
|
51
51
|
/**
|
|
52
52
|
* Builds a lookup of this row's cells keyed by leaf column id.
|
|
@@ -83,8 +83,8 @@ export interface Row_Row<
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
export interface TableOptions_Rows<
|
|
86
|
-
TFeatures extends TableFeatures,
|
|
87
|
-
TData extends RowData,
|
|
86
|
+
in out TFeatures extends TableFeatures,
|
|
87
|
+
in out TData extends RowData,
|
|
88
88
|
> {
|
|
89
89
|
/**
|
|
90
90
|
* 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.
|
|
@@ -106,8 +106,8 @@ export interface TableOptions_Rows<
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
export interface Table_Rows<
|
|
109
|
-
TFeatures extends TableFeatures,
|
|
110
|
-
TData extends RowData,
|
|
109
|
+
in out TFeatures extends TableFeatures,
|
|
110
|
+
in out TData extends RowData,
|
|
111
111
|
> {
|
|
112
112
|
getRowId: (_: TData, index: number, parent?: Row<TFeatures, TData>) => string
|
|
113
113
|
/**
|
|
@@ -13,8 +13,8 @@ import type { TableOptions } from '../../types/TableOptions'
|
|
|
13
13
|
import type { TableState, TableState_All } from '../../types/TableState'
|
|
14
14
|
|
|
15
15
|
export interface TableMeta<
|
|
16
|
-
TFeatures extends TableFeatures,
|
|
17
|
-
TData extends RowData,
|
|
16
|
+
in out TFeatures extends TableFeatures,
|
|
17
|
+
in out TData extends RowData,
|
|
18
18
|
> {}
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -84,8 +84,8 @@ export type ExternalAtoms_All = Partial<{
|
|
|
84
84
|
}>
|
|
85
85
|
|
|
86
86
|
export interface TableOptions_Table<
|
|
87
|
-
TFeatures extends TableFeatures,
|
|
88
|
-
TData extends RowData,
|
|
87
|
+
in out TFeatures extends TableFeatures,
|
|
88
|
+
in out TData extends RowData,
|
|
89
89
|
> {
|
|
90
90
|
/**
|
|
91
91
|
* The feature modules registered on this table instance.
|
|
@@ -152,8 +152,8 @@ export interface TableOptions_Table<
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
export interface Table_CoreProperties<
|
|
155
|
-
TFeatures extends TableFeatures,
|
|
156
|
-
TData extends RowData,
|
|
155
|
+
in out TFeatures extends TableFeatures,
|
|
156
|
+
in out TData extends RowData,
|
|
157
157
|
> {
|
|
158
158
|
/**
|
|
159
159
|
* Table reactivity bindings for interacting with TanStack Store.
|
|
@@ -220,8 +220,8 @@ export interface Table_CoreProperties<
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
export interface Table_Table<
|
|
223
|
-
TFeatures extends TableFeatures,
|
|
224
|
-
TData extends RowData,
|
|
223
|
+
in out TFeatures extends TableFeatures,
|
|
224
|
+
in out TData extends RowData,
|
|
225
225
|
> extends Table_CoreProperties<TFeatures, TData> {
|
|
226
226
|
/**
|
|
227
227
|
* Resets the table's internal base atoms to `table.initialState`.
|
|
@@ -83,7 +83,10 @@ export function table_mergeOptions<
|
|
|
83
83
|
newOptions: TableOptions<TFeatures, TData>,
|
|
84
84
|
) {
|
|
85
85
|
if (table.options.mergeOptions) {
|
|
86
|
-
return table.options.mergeOptions(
|
|
86
|
+
return table.options.mergeOptions(
|
|
87
|
+
table.options as TableOptions<TFeatures, TData>,
|
|
88
|
+
newOptions,
|
|
89
|
+
)
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
return {
|
|
@@ -110,7 +113,10 @@ export function table_setOptions<
|
|
|
110
113
|
table: Table_Internal<TFeatures, TData>,
|
|
111
114
|
updater: Updater<TableOptions<TFeatures, TData>>,
|
|
112
115
|
): void {
|
|
113
|
-
const newOptions = functionalUpdate(
|
|
116
|
+
const newOptions = functionalUpdate(
|
|
117
|
+
updater,
|
|
118
|
+
table.options as TableOptions<TFeatures, TData>,
|
|
119
|
+
)
|
|
114
120
|
// table static options that should never change after initialization
|
|
115
121
|
const { features, atoms, initialState } = table.options
|
|
116
122
|
const mergedOptions = Object.assign(table_mergeOptions(table, newOptions), {
|
|
@@ -4,8 +4,8 @@ import type { TableFeatures } from '../../types/TableFeatures'
|
|
|
4
4
|
import type { RowModel } from '../../core/row-models/coreRowModelsFeature.types'
|
|
5
5
|
|
|
6
6
|
export interface Column_ColumnFaceting<
|
|
7
|
-
TFeatures extends TableFeatures,
|
|
8
|
-
TData extends RowData,
|
|
7
|
+
in out TFeatures extends TableFeatures,
|
|
8
|
+
in out TData extends RowData,
|
|
9
9
|
> {
|
|
10
10
|
/**
|
|
11
11
|
* Computes min/max numeric facet values for this column.
|
|
@@ -25,8 +25,8 @@ export interface Column_ColumnFaceting<
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export interface Table_RowModels_Faceted<
|
|
28
|
-
TFeatures extends TableFeatures,
|
|
29
|
-
TData extends RowData,
|
|
28
|
+
in out TFeatures extends TableFeatures,
|
|
29
|
+
in out TData extends RowData,
|
|
30
30
|
> {
|
|
31
31
|
/**
|
|
32
32
|
* Computes min/max numeric facet values for the active faceting context.
|
|
@@ -49,8 +49,8 @@ export interface Table_RowModels_Faceted<
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export interface CachedRowModel_Faceted<
|
|
52
|
-
TFeatures extends TableFeatures,
|
|
53
|
-
TData extends RowData,
|
|
52
|
+
in out TFeatures extends TableFeatures,
|
|
53
|
+
in out TData extends RowData,
|
|
54
54
|
> {
|
|
55
55
|
facetedRowModel?: (columnId: string) => () => RowModel<TFeatures, TData>
|
|
56
56
|
facetedMinMaxValues?: (columnId: string) => [number, number]
|
|
@@ -58,8 +58,8 @@ export interface CachedRowModel_Faceted<
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
export interface Table_ColumnFaceting<
|
|
61
|
-
TFeatures extends TableFeatures,
|
|
62
|
-
TData extends RowData,
|
|
61
|
+
in out TFeatures extends TableFeatures,
|
|
62
|
+
in out TData extends RowData,
|
|
63
63
|
> {
|
|
64
64
|
/**
|
|
65
65
|
* Returns the min and max values for the global filter.
|
|
@@ -41,8 +41,8 @@ export interface ColumnFilter {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export interface ResolvedColumnFilter<
|
|
44
|
-
TFeatures extends TableFeatures,
|
|
45
|
-
TData extends RowData,
|
|
44
|
+
in out TFeatures extends TableFeatures,
|
|
45
|
+
in out TData extends RowData,
|
|
46
46
|
> {
|
|
47
47
|
filterFn: FilterFn<TFeatures, TData>
|
|
48
48
|
id: string
|
|
@@ -50,15 +50,15 @@ export interface ResolvedColumnFilter<
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
export interface RowModelFns_ColumnFiltering<
|
|
53
|
-
TFeatures extends TableFeatures,
|
|
54
|
-
TData extends RowData,
|
|
53
|
+
in out TFeatures extends TableFeatures,
|
|
54
|
+
in out TData extends RowData,
|
|
55
55
|
> {
|
|
56
56
|
filterFns: Record<string, FilterFn<TFeatures, TData>>
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
export interface FilterFn<
|
|
60
|
-
TFeatures extends TableFeatures,
|
|
61
|
-
TData extends RowData,
|
|
60
|
+
in out TFeatures extends TableFeatures,
|
|
61
|
+
in out TData extends RowData,
|
|
62
62
|
> {
|
|
63
63
|
(
|
|
64
64
|
row: Row<TFeatures, TData>,
|
|
@@ -110,8 +110,8 @@ export type FilterFnOption<
|
|
|
110
110
|
> = 'auto' | ExtractFilterFnKeys<TFeatures> | FilterFn<TFeatures, TData>
|
|
111
111
|
|
|
112
112
|
export interface ColumnDef_ColumnFiltering<
|
|
113
|
-
TFeatures extends TableFeatures,
|
|
114
|
-
TData extends RowData,
|
|
113
|
+
in out TFeatures extends TableFeatures,
|
|
114
|
+
in out TData extends RowData,
|
|
115
115
|
> {
|
|
116
116
|
/**
|
|
117
117
|
* Enables this column to participate in column-specific filtering.
|
|
@@ -127,8 +127,8 @@ export interface ColumnDef_ColumnFiltering<
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
export interface Column_ColumnFiltering<
|
|
130
|
-
TFeatures extends TableFeatures,
|
|
131
|
-
TData extends RowData,
|
|
130
|
+
in out TFeatures extends TableFeatures,
|
|
131
|
+
in out TData extends RowData,
|
|
132
132
|
> {
|
|
133
133
|
/**
|
|
134
134
|
* Returns an automatically calculated filter function for the column based off of the columns first known value.
|
|
@@ -164,8 +164,8 @@ export interface Column_ColumnFiltering<
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
export interface Row_ColumnFiltering<
|
|
167
|
-
TFeatures extends TableFeatures,
|
|
168
|
-
TData extends RowData,
|
|
167
|
+
in out TFeatures extends TableFeatures,
|
|
168
|
+
in out TData extends RowData,
|
|
169
169
|
> {
|
|
170
170
|
/**
|
|
171
171
|
* The column filters map for the row. This object tracks whether a row is passing/failing specific filters by their column ID.
|
|
@@ -178,8 +178,8 @@ export interface Row_ColumnFiltering<
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
export interface TableOptions_ColumnFiltering<
|
|
181
|
-
TFeatures extends TableFeatures,
|
|
182
|
-
TData extends RowData,
|
|
181
|
+
in out TFeatures extends TableFeatures,
|
|
182
|
+
in out TData extends RowData,
|
|
183
183
|
> {
|
|
184
184
|
/**
|
|
185
185
|
* Enables column-specific filtering for all columns that also allow it.
|
|
@@ -227,8 +227,8 @@ export interface Table_ColumnFiltering {
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
export interface Table_RowModels_Filtered<
|
|
230
|
-
TFeatures extends TableFeatures,
|
|
231
|
-
TData extends RowData,
|
|
230
|
+
in out TFeatures extends TableFeatures,
|
|
231
|
+
in out TData extends RowData,
|
|
232
232
|
> {
|
|
233
233
|
/**
|
|
234
234
|
* Resolves the row model after column and global filters have been applied.
|
|
@@ -241,8 +241,8 @@ export interface Table_RowModels_Filtered<
|
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
export interface CachedRowModel_Filtered<
|
|
244
|
-
TFeatures extends TableFeatures,
|
|
245
|
-
TData extends RowData,
|
|
244
|
+
in out TFeatures extends TableFeatures,
|
|
245
|
+
in out TData extends RowData,
|
|
246
246
|
> {
|
|
247
247
|
filteredRowModel: () => RowModel<TFeatures, TData>
|
|
248
248
|
}
|
|
@@ -323,7 +323,7 @@ export function shouldAutoRemoveFilter<
|
|
|
323
323
|
) {
|
|
324
324
|
return (
|
|
325
325
|
(filterFn && filterFn.autoRemove
|
|
326
|
-
? filterFn.autoRemove(value, column as
|
|
326
|
+
? filterFn.autoRemove(value, column as any)
|
|
327
327
|
: false) ||
|
|
328
328
|
typeof value === 'undefined' ||
|
|
329
329
|
(typeof value === 'string' && !value)
|
|
@@ -18,8 +18,8 @@ export interface TableState_ColumnGrouping {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export interface RowModelFns_ColumnGrouping<
|
|
21
|
-
TFeatures extends TableFeatures,
|
|
22
|
-
TData extends RowData,
|
|
21
|
+
in out TFeatures extends TableFeatures,
|
|
22
|
+
in out TData extends RowData,
|
|
23
23
|
> {
|
|
24
24
|
aggregationFns: Record<string, AggregationFn<TFeatures, TData>>
|
|
25
25
|
}
|
|
@@ -66,8 +66,8 @@ export type AggregationFnOption<
|
|
|
66
66
|
| AggregationFn<TFeatures, TData>
|
|
67
67
|
|
|
68
68
|
export interface ColumnDef_ColumnGrouping<
|
|
69
|
-
TFeatures extends TableFeatures,
|
|
70
|
-
TData extends RowData,
|
|
69
|
+
in out TFeatures extends TableFeatures,
|
|
70
|
+
in out TData extends RowData,
|
|
71
71
|
TValue extends CellData = CellData,
|
|
72
72
|
> {
|
|
73
73
|
/**
|
|
@@ -93,8 +93,8 @@ export interface ColumnDef_ColumnGrouping<
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
export interface Column_ColumnGrouping<
|
|
96
|
-
TFeatures extends TableFeatures,
|
|
97
|
-
TData extends RowData,
|
|
96
|
+
in out TFeatures extends TableFeatures,
|
|
97
|
+
in out TData extends RowData,
|
|
98
98
|
> {
|
|
99
99
|
/**
|
|
100
100
|
* Returns the aggregation function for the column.
|
|
@@ -190,8 +190,8 @@ export interface TableOptions_ColumnGrouping {
|
|
|
190
190
|
export type GroupingColumnMode = false | 'reorder' | 'remove'
|
|
191
191
|
|
|
192
192
|
export interface Table_ColumnGrouping<
|
|
193
|
-
TFeatures extends TableFeatures,
|
|
194
|
-
TData extends RowData,
|
|
193
|
+
in out TFeatures extends TableFeatures,
|
|
194
|
+
in out TData extends RowData,
|
|
195
195
|
> {
|
|
196
196
|
/**
|
|
197
197
|
* Resets `grouping` to `initialState.grouping`.
|
|
@@ -206,8 +206,8 @@ export interface Table_ColumnGrouping<
|
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
export interface Table_RowModels_Grouped<
|
|
209
|
-
TFeatures extends TableFeatures,
|
|
210
|
-
TData extends RowData,
|
|
209
|
+
in out TFeatures extends TableFeatures,
|
|
210
|
+
in out TData extends RowData,
|
|
211
211
|
> {
|
|
212
212
|
/**
|
|
213
213
|
* Resolves the row model after grouping and aggregation have been applied.
|
|
@@ -220,8 +220,8 @@ export interface Table_RowModels_Grouped<
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
export interface CachedRowModel_Grouped<
|
|
223
|
-
TFeatures extends TableFeatures,
|
|
224
|
-
TData extends RowData,
|
|
223
|
+
in out TFeatures extends TableFeatures,
|
|
224
|
+
in out TData extends RowData,
|
|
225
225
|
> {
|
|
226
226
|
groupedRowModel: () => RowModel<TFeatures, TData>
|
|
227
227
|
}
|