@tanstack/table-core 8.0.0-alpha.73 → 8.0.0-alpha.78
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/core.js +1 -92
- package/build/cjs/core.js.map +1 -1
- package/build/cjs/features/Headers.js +12 -6
- package/build/cjs/features/Headers.js.map +1 -1
- package/build/cjs/utils/getCoreRowModel.js +31 -45
- package/build/cjs/utils/getCoreRowModel.js.map +1 -1
- package/build/esm/index.js +44 -143
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +300 -300
- package/build/umd/index.development.js +44 -143
- 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/src/core.ts +0 -107
- package/src/features/Headers.ts +33 -10
- package/src/utils/getCoreRowModel.ts +42 -55
package/build/esm/index.js
CHANGED
|
@@ -2676,8 +2676,10 @@ const Headers = {
|
|
|
2676
2676
|
},
|
|
2677
2677
|
// Header Groups
|
|
2678
2678
|
getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
|
|
2679
|
-
|
|
2680
|
-
|
|
2679
|
+
var _left$map$filter, _right$map$filter;
|
|
2680
|
+
|
|
2681
|
+
const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
|
|
2682
|
+
const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
|
|
2681
2683
|
const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
|
|
2682
2684
|
const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
|
|
2683
2685
|
return headerGroups;
|
|
@@ -2701,8 +2703,10 @@ const Headers = {
|
|
|
2701
2703
|
}
|
|
2702
2704
|
}),
|
|
2703
2705
|
getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
+
var _left$map$filter2;
|
|
2707
|
+
|
|
2708
|
+
const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
|
|
2709
|
+
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
|
|
2706
2710
|
}, {
|
|
2707
2711
|
key: process.env.NODE_ENV === 'development' && 'getLeftHeaderGroups',
|
|
2708
2712
|
debug: () => {
|
|
@@ -2712,8 +2716,10 @@ const Headers = {
|
|
|
2712
2716
|
}
|
|
2713
2717
|
}),
|
|
2714
2718
|
getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
2715
|
-
|
|
2716
|
-
|
|
2719
|
+
var _right$map$filter2;
|
|
2720
|
+
|
|
2721
|
+
const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
|
|
2722
|
+
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
|
|
2717
2723
|
}, {
|
|
2718
2724
|
key: process.env.NODE_ENV === 'development' && 'getRightHeaderGroups',
|
|
2719
2725
|
debug: () => {
|
|
@@ -3024,7 +3030,6 @@ function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
|
|
|
3024
3030
|
// data: Batch[]
|
|
3025
3031
|
// facets: Batch[]
|
|
3026
3032
|
// }
|
|
3027
|
-
// export type TaskPriority = keyof CoreBatches
|
|
3028
3033
|
function createTableInstance(options) {
|
|
3029
3034
|
var _options$initialState;
|
|
3030
3035
|
|
|
@@ -3063,64 +3068,7 @@ function createTableInstance(options) {
|
|
|
3063
3068
|
});
|
|
3064
3069
|
|
|
3065
3070
|
const queued = [];
|
|
3066
|
-
let queuedTimeout = false;
|
|
3067
|
-
// let working = false
|
|
3068
|
-
// let latestCallback: ReturnType<typeof requestIdleCallback>
|
|
3069
|
-
// let batchUid = 0
|
|
3070
|
-
// const onProgress = () => {}
|
|
3071
|
-
// const getBatch = () => {
|
|
3072
|
-
// instance.batches.data = instance.batches.data.filter(d => d.tasks.length)
|
|
3073
|
-
// instance.batches.facets = instance.batches.facets.filter(
|
|
3074
|
-
// d => d.tasks.length
|
|
3075
|
-
// )
|
|
3076
|
-
// return (
|
|
3077
|
-
// instance.batches.data.find(d => d.tasks.length) ??
|
|
3078
|
-
// instance.batches.facets.find(d => d.tasks.length)
|
|
3079
|
-
// )
|
|
3080
|
-
// }
|
|
3081
|
-
// const startWorkLoop = () => {
|
|
3082
|
-
// working = true
|
|
3083
|
-
// const workLoop = (deadline: IdleDeadline) => {
|
|
3084
|
-
// const batch = getBatch()
|
|
3085
|
-
// if (!batch) {
|
|
3086
|
-
// working = false
|
|
3087
|
-
// return
|
|
3088
|
-
// }
|
|
3089
|
-
// // Prioritize tasks
|
|
3090
|
-
// while (deadline.timeRemaining() > 0 && batch.tasks.length) {
|
|
3091
|
-
// batch.tasks.shift()!()
|
|
3092
|
-
// }
|
|
3093
|
-
// onProgress()
|
|
3094
|
-
// if (working) {
|
|
3095
|
-
// latestCallback = requestIdleCallback(workLoop, { timeout: 10000 })
|
|
3096
|
-
// }
|
|
3097
|
-
// }
|
|
3098
|
-
// latestCallback = requestIdleCallback(workLoop, { timeout: 10000 })
|
|
3099
|
-
// }
|
|
3100
|
-
// const startWork = () => {
|
|
3101
|
-
// if (getBatch() && !working) {
|
|
3102
|
-
// if (
|
|
3103
|
-
// (process.env.NODE_ENV === 'development' && instance.options.debugAll) ??
|
|
3104
|
-
// instance.options.debugTable
|
|
3105
|
-
// ) {
|
|
3106
|
-
// console.info('Starting work...')
|
|
3107
|
-
// }
|
|
3108
|
-
// startWorkLoop()
|
|
3109
|
-
// }
|
|
3110
|
-
// }
|
|
3111
|
-
// const stopWork = () => {
|
|
3112
|
-
// if (working) {
|
|
3113
|
-
// if (
|
|
3114
|
-
// (process.env.NODE_ENV === 'development' && instance.options.debugAll) ??
|
|
3115
|
-
// instance.options.debugTable
|
|
3116
|
-
// ) {
|
|
3117
|
-
// console.info('Stopping work...')
|
|
3118
|
-
// }
|
|
3119
|
-
// working = false
|
|
3120
|
-
// cancelIdleCallback(latestCallback)
|
|
3121
|
-
// }
|
|
3122
|
-
// }
|
|
3123
|
-
|
|
3071
|
+
let queuedTimeout = false;
|
|
3124
3072
|
const midInstance = { ...instance,
|
|
3125
3073
|
// init: () => {
|
|
3126
3074
|
// startWork()
|
|
@@ -3153,39 +3101,6 @@ function createTableInstance(options) {
|
|
|
3153
3101
|
}));
|
|
3154
3102
|
}
|
|
3155
3103
|
},
|
|
3156
|
-
// batches: {
|
|
3157
|
-
// data: [],
|
|
3158
|
-
// facets: [],
|
|
3159
|
-
// },
|
|
3160
|
-
// createBatch: priority => {
|
|
3161
|
-
// const batchId = batchUid++
|
|
3162
|
-
// let canceled: boolean
|
|
3163
|
-
// const batch: Batch = {
|
|
3164
|
-
// id: batchId,
|
|
3165
|
-
// priority,
|
|
3166
|
-
// tasks: [],
|
|
3167
|
-
// schedule: cb => {
|
|
3168
|
-
// if (canceled) return
|
|
3169
|
-
// batch.tasks.push(cb)
|
|
3170
|
-
// if (!working && !workScheduled) {
|
|
3171
|
-
// workScheduled = true
|
|
3172
|
-
// instance.queue(() => {
|
|
3173
|
-
// workScheduled = false
|
|
3174
|
-
// instance.setState(old => ({ ...old }))
|
|
3175
|
-
// })
|
|
3176
|
-
// }
|
|
3177
|
-
// },
|
|
3178
|
-
// cancel: () => {
|
|
3179
|
-
// canceled = true
|
|
3180
|
-
// batch.tasks = []
|
|
3181
|
-
// instance.batches[priority] = instance.batches[priority].filter(
|
|
3182
|
-
// b => b.id !== batchId
|
|
3183
|
-
// )
|
|
3184
|
-
// },
|
|
3185
|
-
// }
|
|
3186
|
-
// instance.batches[priority].push(batch)
|
|
3187
|
-
// return batch
|
|
3188
|
-
// },
|
|
3189
3104
|
reset: () => {
|
|
3190
3105
|
instance.setState(instance.initialState);
|
|
3191
3106
|
},
|
|
@@ -3296,69 +3211,55 @@ function createTable(_, __, options) {
|
|
|
3296
3211
|
|
|
3297
3212
|
function getCoreRowModel() {
|
|
3298
3213
|
return instance => memo(() => [instance.options.data], data => {
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3214
|
+
const rowModel = {
|
|
3215
|
+
rows: [],
|
|
3216
|
+
flatRows: [],
|
|
3217
|
+
rowsById: {}
|
|
3218
|
+
};
|
|
3219
|
+
let rows;
|
|
3220
|
+
let row;
|
|
3221
|
+
let originalRow;
|
|
3304
3222
|
|
|
3305
|
-
const
|
|
3223
|
+
const accessRows = function (originalRows, depth, parent) {
|
|
3306
3224
|
if (depth === void 0) {
|
|
3307
3225
|
depth = 0;
|
|
3308
3226
|
}
|
|
3309
3227
|
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
if (!id) {
|
|
3313
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
3314
|
-
throw new Error("getRowId expected an ID, but got " + id);
|
|
3315
|
-
}
|
|
3316
|
-
}
|
|
3317
|
-
|
|
3318
|
-
const values = {};
|
|
3319
|
-
|
|
3320
|
-
for (let i = 0; i < leafColumns.length; i++) {
|
|
3321
|
-
const column = leafColumns[i];
|
|
3322
|
-
|
|
3323
|
-
if (column && column.accessorFn) {
|
|
3324
|
-
values[column.id] = column.accessorFn(originalRow, rowIndex);
|
|
3325
|
-
}
|
|
3326
|
-
} // Make the row
|
|
3228
|
+
rows = [];
|
|
3327
3229
|
|
|
3230
|
+
for (let i = 0; i < originalRows.length; i++) {
|
|
3231
|
+
originalRow = originalRows[i]; // This could be an expensive check at scale, so we should move it somewhere else, but where?
|
|
3232
|
+
// if (!id) {
|
|
3233
|
+
// if (process.env.NODE_ENV !== 'production') {
|
|
3234
|
+
// throw new Error(`getRowId expected an ID, but got ${id}`)
|
|
3235
|
+
// }
|
|
3236
|
+
// }
|
|
3237
|
+
// Make the row
|
|
3328
3238
|
|
|
3329
|
-
|
|
3239
|
+
row = instance.createRow(instance.getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
|
|
3330
3240
|
|
|
3331
|
-
|
|
3241
|
+
rowModel.flatRows.push(row); // Also keep track of every row by its ID
|
|
3332
3242
|
|
|
3333
|
-
|
|
3243
|
+
rowModel.rowsById[row.id] = row; // Push instance row into parent
|
|
3334
3244
|
|
|
3335
|
-
|
|
3245
|
+
rows.push(row); // Get the original subrows
|
|
3336
3246
|
|
|
3337
|
-
|
|
3338
|
-
|
|
3247
|
+
if (instance.options.getSubRows) {
|
|
3248
|
+
var _row$originalSubRows;
|
|
3339
3249
|
|
|
3340
|
-
|
|
3341
|
-
row.originalSubRows = originalSubRows;
|
|
3342
|
-
const subRows = [];
|
|
3250
|
+
row.originalSubRows = instance.options.getSubRows(originalRow, i); // Then recursively access them
|
|
3343
3251
|
|
|
3344
|
-
|
|
3345
|
-
|
|
3252
|
+
if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
|
|
3253
|
+
row.subRows = accessRows(row.originalSubRows, depth + 1, row);
|
|
3346
3254
|
}
|
|
3347
|
-
|
|
3348
|
-
row.subRows = subRows;
|
|
3349
3255
|
}
|
|
3350
3256
|
}
|
|
3351
|
-
};
|
|
3352
3257
|
|
|
3353
|
-
|
|
3354
|
-
accessRow(data[i], i, 0, rows);
|
|
3355
|
-
}
|
|
3356
|
-
|
|
3357
|
-
return {
|
|
3358
|
-
rows,
|
|
3359
|
-
flatRows,
|
|
3360
|
-
rowsById
|
|
3258
|
+
return rows;
|
|
3361
3259
|
};
|
|
3260
|
+
|
|
3261
|
+
rowModel.rows = accessRows(data);
|
|
3262
|
+
return rowModel;
|
|
3362
3263
|
}, {
|
|
3363
3264
|
key: process.env.NODE_ENV === 'development' && 'getRowModel',
|
|
3364
3265
|
debug: () => {
|