@tanstack/table-core 8.19.4 → 8.20.1
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/build/lib/core/column.js +1 -1
- package/build/lib/core/column.js.map +1 -1
- package/build/lib/index.esm.js +1 -1
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.mjs +1 -1
- package/build/lib/index.mjs.map +1 -1
- package/build/umd/index.development.js +1 -1
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/core/column.ts +5 -1
package/build/lib/core/column.js
CHANGED
|
@@ -20,7 +20,7 @@ function createColumn(table, columnDef, depth, parent) {
|
|
|
20
20
|
...columnDef
|
|
21
21
|
};
|
|
22
22
|
const accessorKey = resolvedColumnDef.accessorKey;
|
|
23
|
-
let id = (_ref = (_resolvedColumnDef$id = resolvedColumnDef.id) != null ? _resolvedColumnDef$id : accessorKey ? accessorKey.
|
|
23
|
+
let id = (_ref = (_resolvedColumnDef$id = resolvedColumnDef.id) != null ? _resolvedColumnDef$id : accessorKey ? typeof String.prototype.replaceAll === 'function' ? accessorKey.replaceAll('.', '_') : accessorKey.replace(/\./g, '_') : undefined) != null ? _ref : typeof resolvedColumnDef.header === 'string' ? resolvedColumnDef.header : undefined;
|
|
24
24
|
let accessorFn;
|
|
25
25
|
if (resolvedColumnDef.accessorFn) {
|
|
26
26
|
accessorFn = resolvedColumnDef.accessorFn;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column.js","sources":["../../../src/core/column.ts"],"sourcesContent":["import {\n Column,\n Table,\n AccessorFn,\n ColumnDef,\n RowData,\n ColumnDefResolved,\n} from '../types'\nimport { getMemoOptions, memo } from '../utils'\n\nexport interface CoreColumn<TData extends RowData, TValue> {\n /**\n * The resolved accessor function to use when extracting the value for the column from each row. Will only be defined if the column def has a valid accessor key or function defined.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#accessorfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n accessorFn?: AccessorFn<TData, TValue>\n /**\n * The original column def used to create the column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#columndef)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n columnDef: ColumnDef<TData, TValue>\n /**\n * The child column (if the column is a group column). Will be an empty array if the column is not a group column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#columns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n columns: Column<TData, TValue>[]\n /**\n * The depth of the column (if grouped) relative to the root column def array.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#depth)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n depth: number\n /**\n * Returns the flattened array of this column and all child/grand-child columns for this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#getflatcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n getFlatColumns: () => Column<TData, TValue>[]\n /**\n * Returns an array of all leaf-node columns for this column. If a column has no children, it is considered the only leaf-node column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#getleafcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n getLeafColumns: () => Column<TData, TValue>[]\n /**\n * The resolved unique identifier for the column resolved in this priority:\n - A manual `id` property from the column def\n - The accessor key from the column def\n - The header string from the column def\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#id)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n id: string\n /**\n * The parent column for this column. Will be undefined if this is a root column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#parent)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n parent?: Column<TData, TValue>\n}\n\nexport function createColumn<TData extends RowData, TValue>(\n table: Table<TData>,\n columnDef: ColumnDef<TData, TValue>,\n depth: number,\n parent?: Column<TData, TValue>\n): Column<TData, TValue> {\n const defaultColumn = table._getDefaultColumnDef()\n\n const resolvedColumnDef = {\n ...defaultColumn,\n ...columnDef,\n } as ColumnDefResolved<TData>\n\n const accessorKey = resolvedColumnDef.accessorKey\n\n let id =\n resolvedColumnDef.id ??\n (accessorKey ? accessorKey.
|
|
1
|
+
{"version":3,"file":"column.js","sources":["../../../src/core/column.ts"],"sourcesContent":["import {\n Column,\n Table,\n AccessorFn,\n ColumnDef,\n RowData,\n ColumnDefResolved,\n} from '../types'\nimport { getMemoOptions, memo } from '../utils'\n\nexport interface CoreColumn<TData extends RowData, TValue> {\n /**\n * The resolved accessor function to use when extracting the value for the column from each row. Will only be defined if the column def has a valid accessor key or function defined.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#accessorfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n accessorFn?: AccessorFn<TData, TValue>\n /**\n * The original column def used to create the column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#columndef)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n columnDef: ColumnDef<TData, TValue>\n /**\n * The child column (if the column is a group column). Will be an empty array if the column is not a group column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#columns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n columns: Column<TData, TValue>[]\n /**\n * The depth of the column (if grouped) relative to the root column def array.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#depth)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n depth: number\n /**\n * Returns the flattened array of this column and all child/grand-child columns for this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#getflatcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n getFlatColumns: () => Column<TData, TValue>[]\n /**\n * Returns an array of all leaf-node columns for this column. If a column has no children, it is considered the only leaf-node column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#getleafcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n getLeafColumns: () => Column<TData, TValue>[]\n /**\n * The resolved unique identifier for the column resolved in this priority:\n - A manual `id` property from the column def\n - The accessor key from the column def\n - The header string from the column def\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#id)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n id: string\n /**\n * The parent column for this column. Will be undefined if this is a root column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#parent)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n parent?: Column<TData, TValue>\n}\n\nexport function createColumn<TData extends RowData, TValue>(\n table: Table<TData>,\n columnDef: ColumnDef<TData, TValue>,\n depth: number,\n parent?: Column<TData, TValue>\n): Column<TData, TValue> {\n const defaultColumn = table._getDefaultColumnDef()\n\n const resolvedColumnDef = {\n ...defaultColumn,\n ...columnDef,\n } as ColumnDefResolved<TData>\n\n const accessorKey = resolvedColumnDef.accessorKey\n\n let id =\n resolvedColumnDef.id ??\n (accessorKey\n ? typeof String.prototype.replaceAll === 'function'\n ? accessorKey.replaceAll('.', '_')\n : accessorKey.replace(/\\./g, '_')\n : undefined) ??\n (typeof resolvedColumnDef.header === 'string'\n ? resolvedColumnDef.header\n : undefined)\n\n let accessorFn: AccessorFn<TData> | undefined\n\n if (resolvedColumnDef.accessorFn) {\n accessorFn = resolvedColumnDef.accessorFn\n } else if (accessorKey) {\n // Support deep accessor keys\n if (accessorKey.includes('.')) {\n accessorFn = (originalRow: TData) => {\n let result = originalRow as Record<string, any>\n\n for (const key of accessorKey.split('.')) {\n result = result?.[key]\n if (process.env.NODE_ENV !== 'production' && result === undefined) {\n console.warn(\n `\"${key}\" in deeply nested key \"${accessorKey}\" returned undefined.`\n )\n }\n }\n\n return result\n }\n } else {\n accessorFn = (originalRow: TData) =>\n (originalRow as any)[resolvedColumnDef.accessorKey]\n }\n }\n\n if (!id) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n resolvedColumnDef.accessorFn\n ? `Columns require an id when using an accessorFn`\n : `Columns require an id when using a non-string header`\n )\n }\n throw new Error()\n }\n\n let column: CoreColumn<TData, any> = {\n id: `${String(id)}`,\n accessorFn,\n parent: parent as any,\n depth,\n columnDef: resolvedColumnDef as ColumnDef<TData, any>,\n columns: [],\n getFlatColumns: memo(\n () => [true],\n () => {\n return [\n column as Column<TData, TValue>,\n ...column.columns?.flatMap(d => d.getFlatColumns()),\n ]\n },\n getMemoOptions(table.options, 'debugColumns', 'column.getFlatColumns')\n ),\n getLeafColumns: memo(\n () => [table._getOrderColumnsFn()],\n orderColumns => {\n if (column.columns?.length) {\n let leafColumns = column.columns.flatMap(column =>\n column.getLeafColumns()\n )\n\n return orderColumns(leafColumns)\n }\n\n return [column as Column<TData, TValue>]\n },\n getMemoOptions(table.options, 'debugColumns', 'column.getLeafColumns')\n ),\n }\n\n for (const feature of table._features) {\n feature.createColumn?.(column as Column<TData, TValue>, table)\n }\n\n // Yes, we have to convert table to unknown, because we know more than the compiler here.\n return column as Column<TData, TValue>\n}\n"],"names":["createColumn","table","columnDef","depth","parent","_ref","_resolvedColumnDef$id","defaultColumn","_getDefaultColumnDef","resolvedColumnDef","accessorKey","id","String","prototype","replaceAll","replace","undefined","header","accessorFn","includes","originalRow","result","key","split","_result","process","env","NODE_ENV","console","warn","Error","column","columns","getFlatColumns","memo","_column$columns","flatMap","d","getMemoOptions","options","getLeafColumns","_getOrderColumnsFn","orderColumns","_column$columns2","length","leafColumns","feature","_features"],"mappings":";;;;;;;;;;;;;;AAgEO,SAASA,YAAYA,CAC1BC,KAAmB,EACnBC,SAAmC,EACnCC,KAAa,EACbC,MAA8B,EACP;EAAA,IAAAC,IAAA,EAAAC,qBAAA,CAAA;AACvB,EAAA,MAAMC,aAAa,GAAGN,KAAK,CAACO,oBAAoB,EAAE,CAAA;AAElD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,gBAAA,CAAA;MACd,IAAAA,CAAAA,gBAAA,GAAIZ,MAAM,CAACC,OAAO,KAAdW,IAAAA,IAAAA,gBAAA,CAAgBC,MAAM,EAAE;AAC1B,QAAA,IAAIC,WAAW,GAAGd,MAAM,CAACC,OAAO,CAACI,OAAO,CAACL,MAAM,IAC7CA,MAAM,CAACS,cAAc,EACvB,CAAC,CAAA;QAED,OAAOE,YAAY,CAACG,WAAW,CAAC,CAAA;AAClC,OAAA;MAEA,OAAO,CAACd,MAAM,CAA0B,CAAA;KACzC,EACDO,oBAAc,CAACrC,KAAK,CAACsC,OAAO,EAAE,cAAc,EAAE,uBAAuB,CACvE,CAAA;GACD,CAAA;AAED,EAAA,KAAK,MAAMO,OAAO,IAAI7C,KAAK,CAAC8C,SAAS,EAAE;IACrCD,OAAO,CAAC9C,YAAY,IAAA,IAAA,IAApB8C,OAAO,CAAC9C,YAAY,CAAG+B,MAAM,EAA2B9B,KAAK,CAAC,CAAA;AAChE,GAAA;;AAEA;AACA,EAAA,OAAO8B,MAAM,CAAA;AACf;;;;"}
|
package/build/lib/index.esm.js
CHANGED
|
@@ -189,7 +189,7 @@ function createColumn(table, columnDef, depth, parent) {
|
|
|
189
189
|
...columnDef
|
|
190
190
|
};
|
|
191
191
|
const accessorKey = resolvedColumnDef.accessorKey;
|
|
192
|
-
let id = (_ref = (_resolvedColumnDef$id = resolvedColumnDef.id) != null ? _resolvedColumnDef$id : accessorKey ? accessorKey.
|
|
192
|
+
let id = (_ref = (_resolvedColumnDef$id = resolvedColumnDef.id) != null ? _resolvedColumnDef$id : accessorKey ? typeof String.prototype.replaceAll === 'function' ? accessorKey.replaceAll('.', '_') : accessorKey.replace(/\./g, '_') : undefined) != null ? _ref : typeof resolvedColumnDef.header === 'string' ? resolvedColumnDef.header : undefined;
|
|
193
193
|
let accessorFn;
|
|
194
194
|
if (resolvedColumnDef.accessorFn) {
|
|
195
195
|
accessorFn = resolvedColumnDef.accessorFn;
|