@tanstack/react-table 8.2.4 → 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/react-table/src/index.js +1 -0
- package/build/cjs/react-table/src/index.js.map +1 -1
- package/build/cjs/table-core/build/esm/index.js +69 -5
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +69 -6
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1451 -106
- package/build/stats-react.json +18 -18
- package/build/umd/index.development.js +69 -5
- 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 +2 -2
package/build/esm/index.js
CHANGED
|
@@ -20,6 +20,9 @@ import * as React from 'react';
|
|
|
20
20
|
*
|
|
21
21
|
* @license MIT
|
|
22
22
|
*/
|
|
23
|
+
// Is this type a tuple?
|
|
24
|
+
// If this type is a tuple, what indices are allowed?
|
|
25
|
+
///
|
|
23
26
|
function functionalUpdate(updater, input) {
|
|
24
27
|
return typeof updater === 'function' ? updater(input) : updater;
|
|
25
28
|
}
|
|
@@ -105,13 +108,27 @@ function createColumn(table, columnDef, depth, parent) {
|
|
|
105
108
|
const resolvedColumnDef = { ...defaultColumn,
|
|
106
109
|
...columnDef
|
|
107
110
|
};
|
|
108
|
-
|
|
111
|
+
const accessorKey = resolvedColumnDef.accessorKey;
|
|
112
|
+
let id = (_ref = (_resolvedColumnDef$id = resolvedColumnDef.id) != null ? _resolvedColumnDef$id : accessorKey ? accessorKey.replace('.', '_') : undefined) != null ? _ref : typeof resolvedColumnDef.header === 'string' ? resolvedColumnDef.header : undefined;
|
|
109
113
|
let accessorFn;
|
|
110
114
|
|
|
111
115
|
if (resolvedColumnDef.accessorFn) {
|
|
112
116
|
accessorFn = resolvedColumnDef.accessorFn;
|
|
113
|
-
} else if (
|
|
114
|
-
|
|
117
|
+
} else if (accessorKey) {
|
|
118
|
+
// Support deep accessor keys
|
|
119
|
+
if (accessorKey.includes('.')) {
|
|
120
|
+
accessorFn = originalRow => {
|
|
121
|
+
let result = originalRow;
|
|
122
|
+
|
|
123
|
+
for (const key of accessorKey.split('.')) {
|
|
124
|
+
result = result[key];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return result;
|
|
128
|
+
};
|
|
129
|
+
} else {
|
|
130
|
+
accessorFn = originalRow => originalRow[resolvedColumnDef.accessorKey];
|
|
131
|
+
}
|
|
115
132
|
}
|
|
116
133
|
|
|
117
134
|
if (!id) {
|
|
@@ -961,7 +978,7 @@ const Expanding = {
|
|
|
961
978
|
getCanExpand: () => {
|
|
962
979
|
var _table$options$getRow, _table$options$enable, _row$subRows;
|
|
963
980
|
|
|
964
|
-
return (
|
|
981
|
+
return (_table$options$getRow = table.options.getRowCanExpand == null ? void 0 : table.options.getRowCanExpand(row)) != null ? _table$options$getRow : ((_table$options$enable = table.options.enableExpanding) != null ? _table$options$enable : true) && !!((_row$subRows = row.subRows) != null && _row$subRows.length);
|
|
965
982
|
},
|
|
966
983
|
getToggleExpandedHandler: () => {
|
|
967
984
|
const canExpand = row.getCanExpand();
|
|
@@ -1107,7 +1124,7 @@ const Filters = {
|
|
|
1107
1124
|
var _table$getCoreRowMode, _table$getCoreRowMode2;
|
|
1108
1125
|
|
|
1109
1126
|
const value = (_table$getCoreRowMode = table.getCoreRowModel().flatRows[0]) == null ? void 0 : (_table$getCoreRowMode2 = _table$getCoreRowMode._getAllCellsByColumnId()[column.id]) == null ? void 0 : _table$getCoreRowMode2.getValue();
|
|
1110
|
-
return typeof value === 'string';
|
|
1127
|
+
return typeof value === 'string' || typeof value === 'number';
|
|
1111
1128
|
}
|
|
1112
1129
|
};
|
|
1113
1130
|
},
|
|
@@ -3101,6 +3118,52 @@ const createRow = (table, id, original, rowIndex, depth, subRows) => {
|
|
|
3101
3118
|
return row;
|
|
3102
3119
|
};
|
|
3103
3120
|
|
|
3121
|
+
// type Person = {
|
|
3122
|
+
// firstName: string
|
|
3123
|
+
// lastName: string
|
|
3124
|
+
// age: number
|
|
3125
|
+
// visits: number
|
|
3126
|
+
// status: string
|
|
3127
|
+
// progress: number
|
|
3128
|
+
// nested: {
|
|
3129
|
+
// foo: [
|
|
3130
|
+
// {
|
|
3131
|
+
// bar: 'bar'
|
|
3132
|
+
// }
|
|
3133
|
+
// ]
|
|
3134
|
+
// bar: { subBar: boolean }[]
|
|
3135
|
+
// baz: {
|
|
3136
|
+
// foo: 'foo'
|
|
3137
|
+
// bar: {
|
|
3138
|
+
// baz: 'baz'
|
|
3139
|
+
// }
|
|
3140
|
+
// }
|
|
3141
|
+
// }
|
|
3142
|
+
// }
|
|
3143
|
+
// const test: DeepKeys<Person> = 'nested.foo.0.bar'
|
|
3144
|
+
// const test2: DeepKeys<Person> = 'nested.bar'
|
|
3145
|
+
// const helper = createColumnHelper<Person>()
|
|
3146
|
+
// helper.accessor('nested.foo', {
|
|
3147
|
+
// cell: info => info.getValue(),
|
|
3148
|
+
// })
|
|
3149
|
+
// helper.accessor('nested.foo.0.bar', {
|
|
3150
|
+
// cell: info => info.getValue(),
|
|
3151
|
+
// })
|
|
3152
|
+
// helper.accessor('nested.bar', {
|
|
3153
|
+
// cell: info => info.getValue(),
|
|
3154
|
+
// })
|
|
3155
|
+
function createColumnHelper() {
|
|
3156
|
+
return {
|
|
3157
|
+
accessor: (accessor, column) => {
|
|
3158
|
+
return typeof accessor === 'function' ? { ...column,
|
|
3159
|
+
accessorFn: accessor
|
|
3160
|
+
} : { ...column,
|
|
3161
|
+
accessorKey: accessor
|
|
3162
|
+
};
|
|
3163
|
+
}
|
|
3164
|
+
};
|
|
3165
|
+
}
|
|
3166
|
+
|
|
3104
3167
|
function getCoreRowModel() {
|
|
3105
3168
|
return table => memo(() => [table.options.data], data => {
|
|
3106
3169
|
const rowModel = {
|
|
@@ -3849,5 +3912,5 @@ function useReactTable(options) {
|
|
|
3849
3912
|
return tableRef.current;
|
|
3850
3913
|
}
|
|
3851
3914
|
|
|
3852
|
-
export { ColumnSizing, Expanding, Filters, Grouping, Headers, Ordering, Pagination, Pinning, RowSelection, Sorting, Visibility, aggregationFns, buildHeaderGroups, createColumn, createRow, createTable, defaultColumnSizing, expandRows, filterFns, flattenBy, flexRender, functionalUpdate, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, isFunction, isRowSelected, isSubRowSelected, makeStateUpdater, memo, noop, orderColumns, passiveEventSupported, reSplitAlphaNumeric, selectRowsFn, shouldAutoRemoveFilter, sortingFns, useReactTable };
|
|
3915
|
+
export { ColumnSizing, Expanding, Filters, Grouping, Headers, Ordering, Pagination, Pinning, RowSelection, Sorting, Visibility, aggregationFns, buildHeaderGroups, createColumn, createColumnHelper, createRow, createTable, defaultColumnSizing, expandRows, filterFns, flattenBy, flexRender, functionalUpdate, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, isFunction, isRowSelected, isSubRowSelected, makeStateUpdater, memo, noop, orderColumns, passiveEventSupported, reSplitAlphaNumeric, selectRowsFn, shouldAutoRemoveFilter, sortingFns, useReactTable };
|
|
3853
3916
|
//# sourceMappingURL=index.js.map
|