@tanstack/table-core 8.2.6 → 8.3.0
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/cjs/columnHelper.js +62 -0
- package/build/cjs/columnHelper.js.map +1 -0
- package/build/cjs/core/cell.js.map +1 -1
- package/build/cjs/core/column.js +17 -3
- package/build/cjs/core/column.js.map +1 -1
- package/build/cjs/core/headers.js.map +1 -1
- package/build/cjs/core/table.js.map +1 -1
- package/build/cjs/index.js +2 -0
- package/build/cjs/index.js.map +1 -1
- package/build/cjs/utils.js +3 -0
- package/build/cjs/utils.js.map +1 -1
- package/build/esm/index.js +67 -4
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1451 -106
- package/build/stats-react.json +329 -304
- package/build/types/index.d.ts +52 -32
- package/build/umd/index.development.js +67 -3
- 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/columnHelper.ts +74 -0
- package/src/core/cell.ts +17 -10
- package/src/core/column.ts +43 -34
- package/src/core/headers.ts +8 -6
- package/src/core/table.ts +9 -7
- package/src/index.ts +1 -0
- package/src/utils.ts +51 -1
package/build/esm/index.js
CHANGED
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
+
// Is this type a tuple?
|
|
12
|
+
// If this type is a tuple, what indices are allowed?
|
|
13
|
+
///
|
|
11
14
|
function functionalUpdate(updater, input) {
|
|
12
15
|
return typeof updater === 'function' ? updater(input) : updater;
|
|
13
16
|
}
|
|
@@ -93,13 +96,27 @@ function createColumn(table, columnDef, depth, parent) {
|
|
|
93
96
|
const resolvedColumnDef = { ...defaultColumn,
|
|
94
97
|
...columnDef
|
|
95
98
|
};
|
|
96
|
-
|
|
99
|
+
const accessorKey = resolvedColumnDef.accessorKey;
|
|
100
|
+
let id = (_ref = (_resolvedColumnDef$id = resolvedColumnDef.id) != null ? _resolvedColumnDef$id : accessorKey ? accessorKey.replace('.', '_') : undefined) != null ? _ref : typeof resolvedColumnDef.header === 'string' ? resolvedColumnDef.header : undefined;
|
|
97
101
|
let accessorFn;
|
|
98
102
|
|
|
99
103
|
if (resolvedColumnDef.accessorFn) {
|
|
100
104
|
accessorFn = resolvedColumnDef.accessorFn;
|
|
101
|
-
} else if (
|
|
102
|
-
|
|
105
|
+
} else if (accessorKey) {
|
|
106
|
+
// Support deep accessor keys
|
|
107
|
+
if (accessorKey.includes('.')) {
|
|
108
|
+
accessorFn = originalRow => {
|
|
109
|
+
let result = originalRow;
|
|
110
|
+
|
|
111
|
+
for (const key of accessorKey.split('.')) {
|
|
112
|
+
result = result[key];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return result;
|
|
116
|
+
};
|
|
117
|
+
} else {
|
|
118
|
+
accessorFn = originalRow => originalRow[resolvedColumnDef.accessorKey];
|
|
119
|
+
}
|
|
103
120
|
}
|
|
104
121
|
|
|
105
122
|
if (!id) {
|
|
@@ -3089,6 +3106,52 @@ const createRow = (table, id, original, rowIndex, depth, subRows) => {
|
|
|
3089
3106
|
return row;
|
|
3090
3107
|
};
|
|
3091
3108
|
|
|
3109
|
+
// type Person = {
|
|
3110
|
+
// firstName: string
|
|
3111
|
+
// lastName: string
|
|
3112
|
+
// age: number
|
|
3113
|
+
// visits: number
|
|
3114
|
+
// status: string
|
|
3115
|
+
// progress: number
|
|
3116
|
+
// nested: {
|
|
3117
|
+
// foo: [
|
|
3118
|
+
// {
|
|
3119
|
+
// bar: 'bar'
|
|
3120
|
+
// }
|
|
3121
|
+
// ]
|
|
3122
|
+
// bar: { subBar: boolean }[]
|
|
3123
|
+
// baz: {
|
|
3124
|
+
// foo: 'foo'
|
|
3125
|
+
// bar: {
|
|
3126
|
+
// baz: 'baz'
|
|
3127
|
+
// }
|
|
3128
|
+
// }
|
|
3129
|
+
// }
|
|
3130
|
+
// }
|
|
3131
|
+
// const test: DeepKeys<Person> = 'nested.foo.0.bar'
|
|
3132
|
+
// const test2: DeepKeys<Person> = 'nested.bar'
|
|
3133
|
+
// const helper = createColumnHelper<Person>()
|
|
3134
|
+
// helper.accessor('nested.foo', {
|
|
3135
|
+
// cell: info => info.getValue(),
|
|
3136
|
+
// })
|
|
3137
|
+
// helper.accessor('nested.foo.0.bar', {
|
|
3138
|
+
// cell: info => info.getValue(),
|
|
3139
|
+
// })
|
|
3140
|
+
// helper.accessor('nested.bar', {
|
|
3141
|
+
// cell: info => info.getValue(),
|
|
3142
|
+
// })
|
|
3143
|
+
function createColumnHelper() {
|
|
3144
|
+
return {
|
|
3145
|
+
accessor: (accessor, column) => {
|
|
3146
|
+
return typeof accessor === 'function' ? { ...column,
|
|
3147
|
+
accessorFn: accessor
|
|
3148
|
+
} : { ...column,
|
|
3149
|
+
accessorKey: accessor
|
|
3150
|
+
};
|
|
3151
|
+
}
|
|
3152
|
+
};
|
|
3153
|
+
}
|
|
3154
|
+
|
|
3092
3155
|
function getCoreRowModel() {
|
|
3093
3156
|
return table => memo(() => [table.options.data], data => {
|
|
3094
3157
|
const rowModel = {
|
|
@@ -3784,5 +3847,5 @@ function getPaginationRowModel(opts) {
|
|
|
3784
3847
|
});
|
|
3785
3848
|
}
|
|
3786
3849
|
|
|
3787
|
-
export { ColumnSizing, Expanding, Filters, Grouping, Headers, Ordering, Pagination, Pinning, RowSelection, Sorting, Visibility, aggregationFns, buildHeaderGroups, createColumn, createRow, createTable, defaultColumnSizing, expandRows, filterFns, flattenBy, functionalUpdate, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, isFunction, isRowSelected, isSubRowSelected, makeStateUpdater, memo, noop, orderColumns, passiveEventSupported, reSplitAlphaNumeric, selectRowsFn, shouldAutoRemoveFilter, sortingFns };
|
|
3850
|
+
export { ColumnSizing, Expanding, Filters, Grouping, Headers, Ordering, Pagination, Pinning, RowSelection, Sorting, Visibility, aggregationFns, buildHeaderGroups, createColumn, createColumnHelper, createRow, createTable, defaultColumnSizing, expandRows, filterFns, flattenBy, functionalUpdate, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, isFunction, isRowSelected, isSubRowSelected, makeStateUpdater, memo, noop, orderColumns, passiveEventSupported, reSplitAlphaNumeric, selectRowsFn, shouldAutoRemoveFilter, sortingFns };
|
|
3788
3851
|
//# sourceMappingURL=index.js.map
|