@tanstack/table-core 9.0.0-beta.36 → 9.0.0-beta.38
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/headers/buildHeaderGroups.cjs.map +1 -1
- package/dist/core/headers/buildHeaderGroups.d.cts +1 -1
- package/dist/core/headers/buildHeaderGroups.d.ts +1 -1
- package/dist/core/headers/buildHeaderGroups.js.map +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.cjs +7 -7
- package/dist/core/headers/coreHeadersFeature.utils.cjs.map +1 -1
- package/dist/core/headers/coreHeadersFeature.utils.js +7 -7
- package/dist/core/headers/coreHeadersFeature.utils.js.map +1 -1
- package/dist/features/column-filtering/columnFilteringFeature.types.d.cts +2 -2
- package/dist/features/column-filtering/columnFilteringFeature.types.d.ts +2 -2
- package/dist/features/column-grouping/columnGroupingFeature.types.d.cts +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.types.d.ts +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.cjs.map +1 -1
- package/dist/features/column-grouping/columnGroupingFeature.utils.js.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.types.d.cts +6 -6
- package/dist/features/column-ordering/columnOrderingFeature.types.d.ts +6 -6
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs +6 -6
- package/dist/features/column-ordering/columnOrderingFeature.utils.cjs.map +1 -1
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.cts +3 -3
- package/dist/features/column-ordering/columnOrderingFeature.utils.d.ts +3 -3
- package/dist/features/column-ordering/columnOrderingFeature.utils.js +6 -6
- package/dist/features/column-ordering/columnOrderingFeature.utils.js.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.cjs +44 -39
- package/dist/features/column-pinning/columnPinningFeature.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.d.cts +6 -1
- package/dist/features/column-pinning/columnPinningFeature.d.ts +6 -1
- package/dist/features/column-pinning/columnPinningFeature.js +45 -40
- package/dist/features/column-pinning/columnPinningFeature.js.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.types.d.cts +49 -38
- package/dist/features/column-pinning/columnPinningFeature.types.d.ts +49 -38
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs +154 -146
- package/dist/features/column-pinning/columnPinningFeature.utils.cjs.map +1 -1
- package/dist/features/column-pinning/columnPinningFeature.utils.d.cts +81 -73
- package/dist/features/column-pinning/columnPinningFeature.utils.d.ts +81 -73
- package/dist/features/column-pinning/columnPinningFeature.utils.js +141 -133
- package/dist/features/column-pinning/columnPinningFeature.utils.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.cjs +4 -4
- package/dist/features/column-sizing/columnSizingFeature.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.js +5 -5
- package/dist/features/column-sizing/columnSizingFeature.js.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.types.d.cts +18 -12
- package/dist/features/column-sizing/columnSizingFeature.types.d.ts +18 -12
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs +24 -20
- package/dist/features/column-sizing/columnSizingFeature.utils.cjs.map +1 -1
- package/dist/features/column-sizing/columnSizingFeature.utils.d.cts +18 -14
- package/dist/features/column-sizing/columnSizingFeature.utils.d.ts +18 -14
- package/dist/features/column-sizing/columnSizingFeature.utils.js +24 -20
- package/dist/features/column-sizing/columnSizingFeature.utils.js.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs +16 -16
- package/dist/features/column-visibility/columnVisibilityFeature.utils.cjs.map +1 -1
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.cts +3 -3
- package/dist/features/column-visibility/columnVisibilityFeature.utils.d.ts +3 -3
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js +16 -16
- package/dist/features/column-visibility/columnVisibilityFeature.utils.js.map +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.types.d.cts +1 -1
- package/dist/features/row-expanding/rowExpandingFeature.types.d.ts +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.types.d.cts +1 -1
- package/dist/features/row-pagination/rowPaginationFeature.types.d.ts +1 -1
- package/dist/features/row-sorting/rowSortingFeature.types.d.cts +1 -1
- package/dist/features/row-sorting/rowSortingFeature.types.d.ts +1 -1
- package/dist/static-functions.cjs +16 -16
- package/dist/static-functions.d.cts +3 -3
- package/dist/static-functions.d.ts +3 -3
- package/dist/static-functions.js +3 -3
- package/dist/utils.cjs +3 -15
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +3 -15
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/core/headers/buildHeaderGroups.ts +1 -1
- package/src/core/headers/coreHeadersFeature.utils.ts +7 -8
- package/src/core/row-models/coreRowModelsFeature.types.ts +0 -1
- package/src/core/table/coreTablesFeature.types.ts +1 -0
- package/src/features/column-faceting/columnFacetingFeature.types.ts +0 -1
- package/src/features/column-filtering/columnFilteringFeature.types.ts +3 -3
- package/src/features/column-grouping/columnGroupingFeature.types.ts +2 -2
- package/src/features/column-grouping/columnGroupingFeature.utils.ts +2 -0
- package/src/features/column-ordering/columnOrderingFeature.types.ts +7 -7
- package/src/features/column-ordering/columnOrderingFeature.utils.ts +9 -9
- package/src/features/column-pinning/columnPinningFeature.ts +64 -59
- package/src/features/column-pinning/columnPinningFeature.types.ts +49 -38
- package/src/features/column-pinning/columnPinningFeature.utils.ts +163 -155
- package/src/features/column-sizing/columnSizingFeature.ts +6 -6
- package/src/features/column-sizing/columnSizingFeature.types.ts +18 -12
- package/src/features/column-sizing/columnSizingFeature.utils.ts +31 -27
- package/src/features/column-visibility/columnVisibilityFeature.utils.ts +15 -15
- package/src/features/row-expanding/rowExpandingFeature.types.ts +2 -3
- package/src/features/row-pagination/rowPaginationFeature.types.ts +2 -3
- package/src/features/row-sorting/rowSortingFeature.types.ts +2 -2
- package/src/types/ColumnDef.ts +1 -0
- package/src/utils.ts +3 -4
package/dist/utils.js
CHANGED
|
@@ -133,16 +133,12 @@ const pad = (str, num) => {
|
|
|
133
133
|
* This wraps `memo` with table debug options and feature metadata so row models and derived APIs can share consistent diagnostics.
|
|
134
134
|
*/
|
|
135
135
|
function tableMemo({ feature, fnName, objectId, onAfterUpdate, table, ...memoOptions }) {
|
|
136
|
-
let beforeCompareTime;
|
|
137
|
-
let afterCompareTime;
|
|
138
136
|
let startCalcTime;
|
|
139
137
|
let endCalcTime;
|
|
140
138
|
let runCount = 0;
|
|
141
139
|
let debug;
|
|
142
|
-
let debugCache;
|
|
143
140
|
if (process.env.NODE_ENV === "development") {
|
|
144
|
-
const {
|
|
145
|
-
debugCache = _debugCache;
|
|
141
|
+
const { debugAll } = table.options;
|
|
146
142
|
const { parentName } = getFunctionNameInfo(fnName, ".");
|
|
147
143
|
debug = debugAll || table.options[`debug${(parentName != "table" ? parentName + "s" : parentName).replace(parentName, parentName.charAt(0).toUpperCase() + parentName.slice(1))}`] || (feature ? table.options[`debug${feature.charAt(0).toUpperCase() + feature.slice(1)}`] : false);
|
|
148
144
|
}
|
|
@@ -165,16 +161,8 @@ function tableMemo({ feature, fnName, objectId, onAfterUpdate, table, ...memoOpt
|
|
|
165
161
|
schedule(() => untrack(() => onAfterUpdate()));
|
|
166
162
|
};
|
|
167
163
|
const debugOptions = process.env.NODE_ENV === "development" ? {
|
|
168
|
-
onBeforeCompare: () => {
|
|
169
|
-
|
|
170
|
-
},
|
|
171
|
-
onAfterCompare: (depsChanged) => {
|
|
172
|
-
if (debugCache) {
|
|
173
|
-
afterCompareTime = performance.now();
|
|
174
|
-
const compareTime = Math.round((afterCompareTime - beforeCompareTime) * 100) / 100;
|
|
175
|
-
if (!depsChanged) logTime(compareTime, depsChanged);
|
|
176
|
-
}
|
|
177
|
-
},
|
|
164
|
+
onBeforeCompare: () => {},
|
|
165
|
+
onAfterCompare: (depsChanged) => {},
|
|
178
166
|
onBeforeUpdate: () => {
|
|
179
167
|
if (debug) startCalcTime = performance.now();
|
|
180
168
|
},
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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> = proto === null ? makeObjectMap() : {}\n const keys = Object.keys(value)\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]!\n Object.defineProperty(copy, key, {\n configurable: true,\n enumerable: true,\n value: cloneState((value as Record<string, unknown>)[key]),\n writable: true,\n })\n }\n\n return copy as T\n }\n\n return value\n}\n\n/**\n * Copies prototype-instance own properties without carrying over lazy memo\n * closures or the per-row cell cache, both of which are bound to the source\n * instance (cached cells reference the source row).\n */\nexport function copyInstancePropertiesWithoutMemos<\n TTarget extends Record<string, any>,\n TSource extends Record<string, any>,\n>(target: TTarget, source: TSource): TTarget & TSource {\n const keys = Object.keys(source)\n const targetRecord = target as Record<string, any>\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]!\n if (!key.startsWith('_memo_') && key !== '_cellsCache') {\n targetRecord[key] = source[key]\n }\n }\n\n return target as TTarget & TSource\n}\n\n/**\n * Creates an object intended only for string-keyed dictionary lookups.\n *\n * The null prototype keeps user-controlled ids such as `__proto__` and\n * `hasOwnProperty` as plain data keys.\n */\nexport function makeObjectMap<TValue = unknown>(): Record<string, TValue> {\n return Object.create(null) as Record<string, TValue>\n}\n\n/**\n * Checks whether an object owns a key, including null-prototype dictionaries.\n */\nexport function hasOwn(obj: object, key: PropertyKey): boolean {\n return Object.prototype.hasOwnProperty.call(obj, key)\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 {\n return (\n (obj[fnKey] as Function | undefined)?.(...args) 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AAQ,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,OACG,IAAI,MAAM,GAA4B,GAAG,IAAI,KAAK,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> = proto === null ? makeObjectMap() : {}\n const keys = Object.keys(value)\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]!\n Object.defineProperty(copy, key, {\n configurable: true,\n enumerable: true,\n value: cloneState((value as Record<string, unknown>)[key]),\n writable: true,\n })\n }\n\n return copy as T\n }\n\n return value\n}\n\n/**\n * Copies prototype-instance own properties without carrying over lazy memo\n * closures or the per-row cell cache, both of which are bound to the source\n * instance (cached cells reference the source row).\n */\nexport function copyInstancePropertiesWithoutMemos<\n TTarget extends Record<string, any>,\n TSource extends Record<string, any>,\n>(target: TTarget, source: TSource): TTarget & TSource {\n const keys = Object.keys(source)\n const targetRecord = target as Record<string, any>\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]!\n if (!key.startsWith('_memo_') && key !== '_cellsCache') {\n targetRecord[key] = source[key]\n }\n }\n\n return target as TTarget & TSource\n}\n\n/**\n * Creates an object intended only for string-keyed dictionary lookups.\n *\n * The null prototype keeps user-controlled ids such as `__proto__` and\n * `hasOwnProperty` as plain data keys.\n */\nexport function makeObjectMap<TValue = unknown>(): Record<string, TValue> {\n return Object.create(null) as Record<string, TValue>\n}\n\n/**\n * Checks whether an object owns a key, including null-prototype dictionaries.\n */\nexport function hasOwn(obj: object, key: PropertyKey): boolean {\n return Object.prototype.hasOwnProperty.call(obj, key)\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 { debugAll } = table.options\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,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,IAAI,UAAU;CAG7B,IAAI,SAAS,OAAO,UAAU,UAAU;EACtC,MAAM,QAAQ,OAAO,eAAe,KAAK;EAEzC,IAAI,UAAU,OAAO,aAAa,UAAU,MAC1C,OAAO;EAGT,MAAM,OAAgC,UAAU,OAAO,cAAc,IAAI,CAAC;EAC1E,MAAM,OAAO,OAAO,KAAK,KAAK;EAE9B,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;GACpC,MAAM,MAAM,KAAK;GACjB,OAAO,eAAe,MAAM,KAAK;IAC/B,cAAc;IACd,YAAY;IACZ,OAAO,WAAY,MAAkC,IAAI;IACzD,UAAU;GACZ,CAAC;EACH;EAEA,OAAO;CACT;CAEA,OAAO;AACT;;;;;;AAOA,SAAgB,mCAGd,QAAiB,QAAoC;CACrD,MAAM,OAAO,OAAO,KAAK,MAAM;CAC/B,MAAM,eAAe;CAErB,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,MAAM,KAAK;EACjB,IAAI,CAAC,IAAI,WAAW,QAAQ,KAAK,QAAQ,eACvC,aAAa,OAAO,OAAO;CAE/B;CAEA,OAAO;AACT;;;;;;;AAQA,SAAgB,gBAA0D;CACxE,OAAO,OAAO,OAAO,IAAI;AAC3B;;;;AAKA,SAAgB,OAAO,KAAa,KAA2B;CAC7D,OAAO,OA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AAkB;GAC3D,OAAO,GAAG,MAAM,GAAG,IAAI;EACzB;CAEJ;AACF;;;;AAKA,SAAgB,mBAKd,KACA,OACA,UACA,GAAG,MACM;CACT,OACG,IAAI,MAAM,GAA4B,GAAG,IAAI,KAAK,SAAS,KAAK,GAAG,IAAI;AAE5E"}
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@ export function buildHeaderGroups<
|
|
|
21
21
|
allColumns: Array<Column<TFeatures, TData, TValue>>,
|
|
22
22
|
columnsToGroup: Array<Column<TFeatures, TData, TValue>>,
|
|
23
23
|
table: Table_Internal<TFeatures, TData>,
|
|
24
|
-
headerFamily?: 'center' | '
|
|
24
|
+
headerFamily?: 'center' | 'start' | 'end',
|
|
25
25
|
) {
|
|
26
26
|
// Find the max depth of the columns:
|
|
27
27
|
// build the leaf column row
|
|
@@ -10,7 +10,6 @@ import type { Header } from '../../types/Header'
|
|
|
10
10
|
import type { RowData } from '../../types/type-utils'
|
|
11
11
|
import type { TableFeatures } from '../../types/TableFeatures'
|
|
12
12
|
import type { Header_Header } from './coreHeadersFeature.types'
|
|
13
|
-
import type { Column } from '../../types/Column'
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* Walks a header tree and collects all descendant leaf headers.
|
|
@@ -79,7 +78,7 @@ export function table_getHeaderGroups<
|
|
|
79
78
|
TFeatures extends TableFeatures,
|
|
80
79
|
TData extends RowData,
|
|
81
80
|
>(table: Table_Internal<TFeatures, TData>) {
|
|
82
|
-
const {
|
|
81
|
+
const { start, end } =
|
|
83
82
|
table.atoms.columnPinning?.get() ?? getDefaultColumnPinningState()
|
|
84
83
|
const allColumns = table.getAllColumns()
|
|
85
84
|
const leafColumns = callMemoOrStaticFn(
|
|
@@ -89,15 +88,15 @@ export function table_getHeaderGroups<
|
|
|
89
88
|
)
|
|
90
89
|
|
|
91
90
|
// Fast path: no columns are pinned — skip per-side lookups, partition, and spread.
|
|
92
|
-
if (!
|
|
91
|
+
if (!start.length && !end.length) {
|
|
93
92
|
return buildHeaderGroups(allColumns, leafColumns, table)
|
|
94
93
|
}
|
|
95
94
|
|
|
96
95
|
const leafColumnsById = table.getAllLeafColumnsById()
|
|
97
96
|
|
|
98
97
|
const leftColumns: typeof leafColumns = []
|
|
99
|
-
for (let i = 0; i <
|
|
100
|
-
const column = leafColumnsById[
|
|
98
|
+
for (let i = 0; i < start.length; i++) {
|
|
99
|
+
const column = leafColumnsById[start[i]!]
|
|
101
100
|
if (
|
|
102
101
|
column &&
|
|
103
102
|
callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)
|
|
@@ -107,8 +106,8 @@ export function table_getHeaderGroups<
|
|
|
107
106
|
}
|
|
108
107
|
|
|
109
108
|
const rightColumns: typeof leafColumns = []
|
|
110
|
-
for (let i = 0; i <
|
|
111
|
-
const column = leafColumnsById[
|
|
109
|
+
for (let i = 0; i < end.length; i++) {
|
|
110
|
+
const column = leafColumnsById[end[i]!]
|
|
112
111
|
if (
|
|
113
112
|
column &&
|
|
114
113
|
callMemoOrStaticFn(column, 'getIsVisible', column_getIsVisible)
|
|
@@ -118,7 +117,7 @@ export function table_getHeaderGroups<
|
|
|
118
117
|
}
|
|
119
118
|
|
|
120
119
|
const centerColumns = leafColumns.filter(
|
|
121
|
-
(column) => !
|
|
120
|
+
(column) => !start.includes(column.id) && !end.includes(column.id),
|
|
122
121
|
)
|
|
123
122
|
|
|
124
123
|
return buildHeaderGroups(
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Table } from '../../types/Table'
|
|
2
1
|
import type { Table_RowModels_Faceted } from '../../features/column-faceting/columnFacetingFeature.types'
|
|
3
2
|
import type { Table_RowModels_Filtered } from '../../features/column-filtering/columnFilteringFeature.types'
|
|
4
3
|
import type { Table_RowModels_Grouped } from '../../features/column-grouping/columnGroupingFeature.types'
|
|
@@ -12,6 +12,7 @@ import type { CachedRowModels } from '../../types/RowModel'
|
|
|
12
12
|
import type { TableOptions } from '../../types/TableOptions'
|
|
13
13
|
import type { TableState, TableState_All } from '../../types/TableState'
|
|
14
14
|
|
|
15
|
+
// @ts-expect-error Phantom type params: unused in this empty base declaration, but required with these exact names so user `declare module` augmentations merge correctly.
|
|
15
16
|
export interface TableMeta<
|
|
16
17
|
in out TFeatures extends TableFeatures,
|
|
17
18
|
in out TData extends RowData,
|
|
@@ -165,7 +165,7 @@ export interface Column_ColumnFiltering<
|
|
|
165
165
|
|
|
166
166
|
export interface Row_ColumnFiltering<
|
|
167
167
|
in out TFeatures extends TableFeatures,
|
|
168
|
-
in out
|
|
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
|
-
in out
|
|
182
|
-
in out
|
|
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.
|
|
@@ -197,8 +197,8 @@ export interface TableOptions_ColumnGrouping {
|
|
|
197
197
|
export type GroupingColumnMode = false | 'reorder' | 'remove'
|
|
198
198
|
|
|
199
199
|
export interface Table_ColumnGrouping<
|
|
200
|
-
in out
|
|
201
|
-
in out
|
|
200
|
+
in out _TFeatures extends TableFeatures,
|
|
201
|
+
in out _TData extends RowData,
|
|
202
202
|
> {
|
|
203
203
|
/**
|
|
204
204
|
* Resets `grouping` to `initialState.grouping`.
|
|
@@ -14,13 +14,13 @@ export interface ColumnIndexes {
|
|
|
14
14
|
*/
|
|
15
15
|
center: Record<string, number>
|
|
16
16
|
/**
|
|
17
|
-
* Maps each
|
|
17
|
+
* Maps each start-pinned visible leaf column id to its index within the start region.
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
start: Record<string, number>
|
|
20
20
|
/**
|
|
21
|
-
* Maps each
|
|
21
|
+
* Maps each end-pinned visible leaf column id to its index within the end region.
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
end: Record<string, number>
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export interface TableState_ColumnOrdering {
|
|
@@ -40,7 +40,7 @@ export interface Column_ColumnOrdering {
|
|
|
40
40
|
/**
|
|
41
41
|
* Finds this column's zero-based index among visible columns.
|
|
42
42
|
*
|
|
43
|
-
* Pass `'
|
|
43
|
+
* Pass `'start'`, `'center'`, or `'end'` to measure within that pinned
|
|
44
44
|
* region instead of the full visible leaf order.
|
|
45
45
|
*/
|
|
46
46
|
getIndex: (position?: ColumnPinningPosition | 'center') => number
|
|
@@ -63,8 +63,8 @@ export interface ColumnOrderDefaultOptions {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
export interface Table_ColumnOrdering<
|
|
66
|
-
in out
|
|
67
|
-
in out
|
|
66
|
+
in out _TFeatures extends TableFeatures,
|
|
67
|
+
in out _TData extends RowData,
|
|
68
68
|
> {
|
|
69
69
|
/**
|
|
70
70
|
* Builds column-id to index records for each visible pinning region.
|
|
@@ -57,15 +57,15 @@ export function table_getColumnIndexes<
|
|
|
57
57
|
return {
|
|
58
58
|
all: buildIndexes(table_getPinnedVisibleLeafColumns(table)),
|
|
59
59
|
center: buildIndexes(table_getPinnedVisibleLeafColumns(table, 'center')),
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
start: buildIndexes(table_getPinnedVisibleLeafColumns(table, 'start')),
|
|
61
|
+
end: buildIndexes(table_getPinnedVisibleLeafColumns(table, 'end')),
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Finds this column's index within a visible pinning region.
|
|
67
67
|
*
|
|
68
|
-
* Pass `'
|
|
68
|
+
* Pass `'start'`, `'center'`, or `'end'` to search that region; omit the
|
|
69
69
|
* position to search the full visible leaf column list.
|
|
70
70
|
*
|
|
71
71
|
* @example
|
|
@@ -87,10 +87,10 @@ export function column_getIndex<
|
|
|
87
87
|
table_getColumnIndexes,
|
|
88
88
|
)
|
|
89
89
|
const key =
|
|
90
|
-
position === '
|
|
91
|
-
? '
|
|
92
|
-
: position === '
|
|
93
|
-
? '
|
|
90
|
+
position === 'start'
|
|
91
|
+
? 'start'
|
|
92
|
+
: position === 'end'
|
|
93
|
+
? 'end'
|
|
94
94
|
: position === 'center'
|
|
95
95
|
? 'center'
|
|
96
96
|
: 'all'
|
|
@@ -104,7 +104,7 @@ export function column_getIndex<
|
|
|
104
104
|
*
|
|
105
105
|
* @example
|
|
106
106
|
* ```ts
|
|
107
|
-
* const isFirst = column_getIsFirstColumn(column, '
|
|
107
|
+
* const isFirst = column_getIsFirstColumn(column, 'start')
|
|
108
108
|
* ```
|
|
109
109
|
*/
|
|
110
110
|
export function column_getIsFirstColumn<
|
|
@@ -126,7 +126,7 @@ export function column_getIsFirstColumn<
|
|
|
126
126
|
*
|
|
127
127
|
* @example
|
|
128
128
|
* ```ts
|
|
129
|
-
* const isLast = column_getIsLastColumn(column, '
|
|
129
|
+
* const isLast = column_getIsLastColumn(column, 'end')
|
|
130
130
|
* ```
|
|
131
131
|
*/
|
|
132
132
|
export function column_getIsLastColumn<
|
|
@@ -12,36 +12,41 @@ import {
|
|
|
12
12
|
column_pin,
|
|
13
13
|
getDefaultColumnPinningState,
|
|
14
14
|
row_getCenterVisibleCells,
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
row_getEndVisibleCells,
|
|
16
|
+
row_getStartVisibleCells,
|
|
17
17
|
table_getCenterFlatHeaders,
|
|
18
18
|
table_getCenterFooterGroups,
|
|
19
19
|
table_getCenterHeaderGroups,
|
|
20
20
|
table_getCenterLeafColumns,
|
|
21
21
|
table_getCenterLeafHeaders,
|
|
22
22
|
table_getCenterVisibleLeafColumns,
|
|
23
|
+
table_getEndFlatHeaders,
|
|
24
|
+
table_getEndFooterGroups,
|
|
25
|
+
table_getEndHeaderGroups,
|
|
26
|
+
table_getEndLeafColumns,
|
|
27
|
+
table_getEndLeafHeaders,
|
|
28
|
+
table_getEndVisibleLeafColumns,
|
|
23
29
|
table_getIsSomeColumnsPinned,
|
|
24
|
-
table_getLeftFlatHeaders,
|
|
25
|
-
table_getLeftFooterGroups,
|
|
26
|
-
table_getLeftHeaderGroups,
|
|
27
|
-
table_getLeftLeafColumns,
|
|
28
|
-
table_getLeftLeafHeaders,
|
|
29
|
-
table_getLeftVisibleLeafColumns,
|
|
30
30
|
table_getPinnedLeafColumns,
|
|
31
31
|
table_getPinnedVisibleLeafColumns,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
table_getStartFlatHeaders,
|
|
33
|
+
table_getStartFooterGroups,
|
|
34
|
+
table_getStartHeaderGroups,
|
|
35
|
+
table_getStartLeafColumns,
|
|
36
|
+
table_getStartLeafHeaders,
|
|
37
|
+
table_getStartVisibleLeafColumns,
|
|
38
38
|
table_resetColumnPinning,
|
|
39
39
|
table_setColumnPinning,
|
|
40
40
|
} from './columnPinningFeature.utils'
|
|
41
41
|
import type { TableFeature } from '../../types/TableFeatures'
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* Feature that adds column pinning state and APIs for
|
|
44
|
+
* Feature that adds column pinning state and APIs for logical start, center,
|
|
45
|
+
* and end regions.
|
|
46
|
+
*
|
|
47
|
+
* In LTR languages/layouts, start usually corresponds to left and end to
|
|
48
|
+
* right. In RTL languages/layouts, start usually corresponds to right and end
|
|
49
|
+
* to left.
|
|
45
50
|
*/
|
|
46
51
|
export const columnPinningFeature: TableFeature = {
|
|
47
52
|
getInitialState: (initialState) => {
|
|
@@ -87,19 +92,19 @@ export const columnPinningFeature: TableFeature = {
|
|
|
87
92
|
row.table.atoms.columnVisibility?.get(),
|
|
88
93
|
],
|
|
89
94
|
},
|
|
90
|
-
|
|
91
|
-
fn: (row) =>
|
|
95
|
+
row_getStartVisibleCells: {
|
|
96
|
+
fn: (row) => row_getStartVisibleCells(row),
|
|
92
97
|
memoDeps: (row) => [
|
|
93
98
|
row.getAllCells(),
|
|
94
|
-
row.table.atoms.columnPinning?.get()?.
|
|
99
|
+
row.table.atoms.columnPinning?.get()?.start,
|
|
95
100
|
row.table.atoms.columnVisibility?.get(),
|
|
96
101
|
],
|
|
97
102
|
},
|
|
98
|
-
|
|
99
|
-
fn: (row) =>
|
|
103
|
+
row_getEndVisibleCells: {
|
|
104
|
+
fn: (row) => row_getEndVisibleCells(row),
|
|
100
105
|
memoDeps: (row) => [
|
|
101
106
|
row.getAllCells(),
|
|
102
|
-
row.table.atoms.columnPinning?.get()?.
|
|
107
|
+
row.table.atoms.columnPinning?.get()?.end,
|
|
103
108
|
row.table.atoms.columnVisibility?.get(),
|
|
104
109
|
],
|
|
105
110
|
},
|
|
@@ -118,8 +123,8 @@ export const columnPinningFeature: TableFeature = {
|
|
|
118
123
|
fn: (position) => table_getIsSomeColumnsPinned(table, position),
|
|
119
124
|
},
|
|
120
125
|
// header groups
|
|
121
|
-
|
|
122
|
-
fn: () =>
|
|
126
|
+
table_getStartHeaderGroups: {
|
|
127
|
+
fn: () => table_getStartHeaderGroups(table),
|
|
123
128
|
memoDeps: () => [
|
|
124
129
|
table.getAllColumns(),
|
|
125
130
|
callMemoOrStaticFn(
|
|
@@ -127,7 +132,7 @@ export const columnPinningFeature: TableFeature = {
|
|
|
127
132
|
'getVisibleLeafColumns',
|
|
128
133
|
table_getVisibleLeafColumns,
|
|
129
134
|
),
|
|
130
|
-
table.atoms.columnPinning?.get()?.
|
|
135
|
+
table.atoms.columnPinning?.get()?.start,
|
|
131
136
|
table.atoms.columnOrder?.get(),
|
|
132
137
|
],
|
|
133
138
|
},
|
|
@@ -144,8 +149,8 @@ export const columnPinningFeature: TableFeature = {
|
|
|
144
149
|
table.atoms.columnOrder?.get(),
|
|
145
150
|
],
|
|
146
151
|
},
|
|
147
|
-
|
|
148
|
-
fn: () =>
|
|
152
|
+
table_getEndHeaderGroups: {
|
|
153
|
+
fn: () => table_getEndHeaderGroups(table),
|
|
149
154
|
memoDeps: () => [
|
|
150
155
|
table.getAllColumns(),
|
|
151
156
|
callMemoOrStaticFn(
|
|
@@ -153,18 +158,18 @@ export const columnPinningFeature: TableFeature = {
|
|
|
153
158
|
'getVisibleLeafColumns',
|
|
154
159
|
table_getVisibleLeafColumns,
|
|
155
160
|
),
|
|
156
|
-
table.atoms.columnPinning?.get()?.
|
|
161
|
+
table.atoms.columnPinning?.get()?.end,
|
|
157
162
|
table.atoms.columnOrder?.get(),
|
|
158
163
|
],
|
|
159
164
|
},
|
|
160
165
|
// footer groups
|
|
161
|
-
|
|
162
|
-
fn: () =>
|
|
166
|
+
table_getStartFooterGroups: {
|
|
167
|
+
fn: () => table_getStartFooterGroups(table),
|
|
163
168
|
memoDeps: () => [
|
|
164
169
|
callMemoOrStaticFn(
|
|
165
170
|
table,
|
|
166
|
-
'
|
|
167
|
-
|
|
171
|
+
'getStartHeaderGroups',
|
|
172
|
+
table_getStartHeaderGroups,
|
|
168
173
|
),
|
|
169
174
|
],
|
|
170
175
|
},
|
|
@@ -178,34 +183,34 @@ export const columnPinningFeature: TableFeature = {
|
|
|
178
183
|
),
|
|
179
184
|
],
|
|
180
185
|
},
|
|
181
|
-
|
|
182
|
-
fn: () =>
|
|
186
|
+
table_getEndFooterGroups: {
|
|
187
|
+
fn: () => table_getEndFooterGroups(table),
|
|
183
188
|
memoDeps: () => [
|
|
184
189
|
callMemoOrStaticFn(
|
|
185
190
|
table,
|
|
186
|
-
'
|
|
187
|
-
|
|
191
|
+
'getEndHeaderGroups',
|
|
192
|
+
table_getEndHeaderGroups,
|
|
188
193
|
),
|
|
189
194
|
],
|
|
190
195
|
},
|
|
191
196
|
// flat headers
|
|
192
|
-
|
|
193
|
-
fn: () =>
|
|
197
|
+
table_getStartFlatHeaders: {
|
|
198
|
+
fn: () => table_getStartFlatHeaders(table),
|
|
194
199
|
memoDeps: () => [
|
|
195
200
|
callMemoOrStaticFn(
|
|
196
201
|
table,
|
|
197
|
-
'
|
|
198
|
-
|
|
202
|
+
'getStartHeaderGroups',
|
|
203
|
+
table_getStartHeaderGroups,
|
|
199
204
|
),
|
|
200
205
|
],
|
|
201
206
|
},
|
|
202
|
-
|
|
203
|
-
fn: () =>
|
|
207
|
+
table_getEndFlatHeaders: {
|
|
208
|
+
fn: () => table_getEndFlatHeaders(table),
|
|
204
209
|
memoDeps: () => [
|
|
205
210
|
callMemoOrStaticFn(
|
|
206
211
|
table,
|
|
207
|
-
'
|
|
208
|
-
|
|
212
|
+
'getEndHeaderGroups',
|
|
213
|
+
table_getEndHeaderGroups,
|
|
209
214
|
),
|
|
210
215
|
],
|
|
211
216
|
},
|
|
@@ -220,23 +225,23 @@ export const columnPinningFeature: TableFeature = {
|
|
|
220
225
|
],
|
|
221
226
|
},
|
|
222
227
|
// leaf headers
|
|
223
|
-
|
|
224
|
-
fn: () =>
|
|
228
|
+
table_getStartLeafHeaders: {
|
|
229
|
+
fn: () => table_getStartLeafHeaders(table),
|
|
225
230
|
memoDeps: () => [
|
|
226
231
|
callMemoOrStaticFn(
|
|
227
232
|
table,
|
|
228
|
-
'
|
|
229
|
-
|
|
233
|
+
'getStartHeaderGroups',
|
|
234
|
+
table_getStartHeaderGroups,
|
|
230
235
|
),
|
|
231
236
|
],
|
|
232
237
|
},
|
|
233
|
-
|
|
234
|
-
fn: () =>
|
|
238
|
+
table_getEndLeafHeaders: {
|
|
239
|
+
fn: () => table_getEndLeafHeaders(table),
|
|
235
240
|
memoDeps: () => [
|
|
236
241
|
callMemoOrStaticFn(
|
|
237
242
|
table,
|
|
238
|
-
'
|
|
239
|
-
|
|
243
|
+
'getEndHeaderGroups',
|
|
244
|
+
table_getEndHeaderGroups,
|
|
240
245
|
),
|
|
241
246
|
],
|
|
242
247
|
},
|
|
@@ -251,8 +256,8 @@ export const columnPinningFeature: TableFeature = {
|
|
|
251
256
|
],
|
|
252
257
|
},
|
|
253
258
|
// leaf columns
|
|
254
|
-
|
|
255
|
-
fn: () =>
|
|
259
|
+
table_getStartLeafColumns: {
|
|
260
|
+
fn: () => table_getStartLeafColumns(table),
|
|
256
261
|
memoDeps: () => [
|
|
257
262
|
table.options.columns,
|
|
258
263
|
table.atoms.columnPinning?.get(),
|
|
@@ -261,8 +266,8 @@ export const columnPinningFeature: TableFeature = {
|
|
|
261
266
|
table.options.groupedColumnMode,
|
|
262
267
|
],
|
|
263
268
|
},
|
|
264
|
-
|
|
265
|
-
fn: () =>
|
|
269
|
+
table_getEndLeafColumns: {
|
|
270
|
+
fn: () => table_getEndLeafColumns(table),
|
|
266
271
|
memoDeps: () => [
|
|
267
272
|
table.options.columns,
|
|
268
273
|
table.atoms.columnPinning?.get(),
|
|
@@ -286,8 +291,8 @@ export const columnPinningFeature: TableFeature = {
|
|
|
286
291
|
// must not memo here as it's just a shortcut function
|
|
287
292
|
},
|
|
288
293
|
// visible leaf columns
|
|
289
|
-
|
|
290
|
-
fn: () =>
|
|
294
|
+
table_getStartVisibleLeafColumns: {
|
|
295
|
+
fn: () => table_getStartVisibleLeafColumns(table),
|
|
291
296
|
memoDeps: () => [
|
|
292
297
|
table.options.columns,
|
|
293
298
|
table.atoms.columnPinning?.get(),
|
|
@@ -308,8 +313,8 @@ export const columnPinningFeature: TableFeature = {
|
|
|
308
313
|
table.options.groupedColumnMode,
|
|
309
314
|
],
|
|
310
315
|
},
|
|
311
|
-
|
|
312
|
-
fn: () =>
|
|
316
|
+
table_getEndVisibleLeafColumns: {
|
|
317
|
+
fn: () => table_getEndVisibleLeafColumns(table),
|
|
313
318
|
memoDeps: () => [
|
|
314
319
|
table.options.columns,
|
|
315
320
|
table.atoms.columnPinning?.get(),
|