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