@tanstack/table-core 8.0.0-alpha.71 → 8.0.0-alpha.74
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 +3 -94
- package/build/cjs/core.js.map +1 -1
- package/build/cjs/features/Cells.js +1 -1
- package/build/cjs/features/Cells.js.map +1 -1
- package/build/cjs/features/Expanding.js +4 -2
- package/build/cjs/features/Expanding.js.map +1 -1
- package/build/cjs/features/Grouping.js +1 -1
- package/build/cjs/features/Grouping.js.map +1 -1
- package/build/cjs/features/Headers.js +2 -2
- package/build/cjs/features/Headers.js.map +1 -1
- package/build/cjs/features/Pagination.js +8 -9
- package/build/cjs/features/Pagination.js.map +1 -1
- package/build/cjs/utils/getCoreRowModel.js +31 -45
- package/build/cjs/utils/getCoreRowModel.js.map +1 -1
- package/build/cjs/utils/getGroupedRowModel.js +1 -1
- package/build/cjs/utils/getGroupedRowModel.js.map +1 -1
- package/build/esm/index.js +51 -155
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +307 -307
- package/build/types/core.d.ts +2 -3
- package/build/types/features/Pagination.d.ts +0 -1
- package/build/umd/index.development.js +51 -155
- 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.ts +6 -113
- package/src/features/Cells.ts +1 -1
- package/src/features/Expanding.ts +2 -2
- package/src/features/Grouping.ts +1 -1
- package/src/features/Headers.ts +2 -2
- package/src/features/Pagination.ts +6 -11
- package/src/utils/getCoreRowModel.ts +42 -55
- package/src/utils/getGroupedRowModel.ts +1 -1
package/build/esm/index.js
CHANGED
|
@@ -373,7 +373,7 @@ const Cells = {
|
|
|
373
373
|
row,
|
|
374
374
|
column,
|
|
375
375
|
getValue: () => row.getValue(columnId),
|
|
376
|
-
renderCell: () => column.cell ? instance.
|
|
376
|
+
renderCell: () => column.cell ? instance._render(column.cell, {
|
|
377
377
|
instance,
|
|
378
378
|
column,
|
|
379
379
|
row,
|
|
@@ -701,9 +701,10 @@ const Expanding = {
|
|
|
701
701
|
return {
|
|
702
702
|
_autoResetExpanded: () => {
|
|
703
703
|
if (!registered) {
|
|
704
|
-
instance.
|
|
704
|
+
instance._queue(() => {
|
|
705
705
|
registered = true;
|
|
706
706
|
});
|
|
707
|
+
|
|
707
708
|
return;
|
|
708
709
|
}
|
|
709
710
|
|
|
@@ -714,7 +715,8 @@ const Expanding = {
|
|
|
714
715
|
if (instance.options.autoResetAll === true || instance.options.autoResetExpanded) {
|
|
715
716
|
if (queued) return;
|
|
716
717
|
queued = true;
|
|
717
|
-
|
|
718
|
+
|
|
719
|
+
instance._queue(() => {
|
|
718
720
|
instance.resetExpanded();
|
|
719
721
|
queued = false;
|
|
720
722
|
});
|
|
@@ -1398,7 +1400,7 @@ const Grouping = {
|
|
|
1398
1400
|
var _column$aggregatedCel;
|
|
1399
1401
|
|
|
1400
1402
|
const template = (_column$aggregatedCel = column.aggregatedCell) != null ? _column$aggregatedCel : column.cell;
|
|
1401
|
-
return template ? instance.
|
|
1403
|
+
return template ? instance._render(template, {
|
|
1402
1404
|
instance,
|
|
1403
1405
|
column,
|
|
1404
1406
|
row,
|
|
@@ -1499,8 +1501,7 @@ const Pagination = {
|
|
|
1499
1501
|
},
|
|
1500
1502
|
getDefaultOptions: instance => {
|
|
1501
1503
|
return {
|
|
1502
|
-
onPaginationChange: makeStateUpdater('pagination', instance)
|
|
1503
|
-
autoResetPageIndex: true
|
|
1504
|
+
onPaginationChange: makeStateUpdater('pagination', instance)
|
|
1504
1505
|
};
|
|
1505
1506
|
},
|
|
1506
1507
|
createInstance: instance => {
|
|
@@ -1508,21 +1509,21 @@ const Pagination = {
|
|
|
1508
1509
|
let queued = false;
|
|
1509
1510
|
return {
|
|
1510
1511
|
_autoResetPageIndex: () => {
|
|
1512
|
+
var _ref, _instance$options$aut;
|
|
1513
|
+
|
|
1511
1514
|
if (!registered) {
|
|
1512
|
-
instance.
|
|
1515
|
+
instance._queue(() => {
|
|
1513
1516
|
registered = true;
|
|
1514
1517
|
});
|
|
1515
|
-
return;
|
|
1516
|
-
}
|
|
1517
1518
|
|
|
1518
|
-
if (instance.options.autoResetAll === false) {
|
|
1519
1519
|
return;
|
|
1520
1520
|
}
|
|
1521
1521
|
|
|
1522
|
-
if (instance.options.autoResetAll
|
|
1522
|
+
if ((_ref = (_instance$options$aut = instance.options.autoResetAll) != null ? _instance$options$aut : instance.options.autoResetPageIndex) != null ? _ref : !instance.options.manualPagination) {
|
|
1523
1523
|
if (queued) return;
|
|
1524
1524
|
queued = true;
|
|
1525
|
-
|
|
1525
|
+
|
|
1526
|
+
instance._queue(() => {
|
|
1526
1527
|
instance.resetPageIndex();
|
|
1527
1528
|
queued = false;
|
|
1528
1529
|
});
|
|
@@ -1544,7 +1545,7 @@ const Pagination = {
|
|
|
1544
1545
|
setPageIndex: updater => {
|
|
1545
1546
|
instance.setPagination(old => {
|
|
1546
1547
|
let pageIndex = functionalUpdate(updater, old.pageIndex);
|
|
1547
|
-
const maxPageIndex =
|
|
1548
|
+
const maxPageIndex = typeof old.pageCount !== 'undefined' ? old.pageCount - 1 : Number.MAX_SAFE_INTEGER;
|
|
1548
1549
|
pageIndex = Math.min(Math.max(0, pageIndex), maxPageIndex);
|
|
1549
1550
|
return { ...old,
|
|
1550
1551
|
pageIndex
|
|
@@ -2655,12 +2656,12 @@ const Headers = {
|
|
|
2655
2656
|
recurseHeader(header);
|
|
2656
2657
|
return leafHeaders;
|
|
2657
2658
|
},
|
|
2658
|
-
renderHeader: () => column.header ? instance.
|
|
2659
|
+
renderHeader: () => column.header ? instance._render(column.header, {
|
|
2659
2660
|
instance,
|
|
2660
2661
|
header: header,
|
|
2661
2662
|
column
|
|
2662
2663
|
}) : null,
|
|
2663
|
-
renderFooter: () => column.footer ? instance.
|
|
2664
|
+
renderFooter: () => column.footer ? instance._render(column.footer, {
|
|
2664
2665
|
instance,
|
|
2665
2666
|
header: header,
|
|
2666
2667
|
column
|
|
@@ -3023,7 +3024,6 @@ function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
|
|
|
3023
3024
|
// data: Batch[]
|
|
3024
3025
|
// facets: Batch[]
|
|
3025
3026
|
// }
|
|
3026
|
-
// export type TaskPriority = keyof CoreBatches
|
|
3027
3027
|
function createTableInstance(options) {
|
|
3028
3028
|
var _options$initialState;
|
|
3029
3029
|
|
|
@@ -3062,64 +3062,7 @@ function createTableInstance(options) {
|
|
|
3062
3062
|
});
|
|
3063
3063
|
|
|
3064
3064
|
const queued = [];
|
|
3065
|
-
let queuedTimeout = false;
|
|
3066
|
-
// let working = false
|
|
3067
|
-
// let latestCallback: ReturnType<typeof requestIdleCallback>
|
|
3068
|
-
// let batchUid = 0
|
|
3069
|
-
// const onProgress = () => {}
|
|
3070
|
-
// const getBatch = () => {
|
|
3071
|
-
// instance.batches.data = instance.batches.data.filter(d => d.tasks.length)
|
|
3072
|
-
// instance.batches.facets = instance.batches.facets.filter(
|
|
3073
|
-
// d => d.tasks.length
|
|
3074
|
-
// )
|
|
3075
|
-
// return (
|
|
3076
|
-
// instance.batches.data.find(d => d.tasks.length) ??
|
|
3077
|
-
// instance.batches.facets.find(d => d.tasks.length)
|
|
3078
|
-
// )
|
|
3079
|
-
// }
|
|
3080
|
-
// const startWorkLoop = () => {
|
|
3081
|
-
// working = true
|
|
3082
|
-
// const workLoop = (deadline: IdleDeadline) => {
|
|
3083
|
-
// const batch = getBatch()
|
|
3084
|
-
// if (!batch) {
|
|
3085
|
-
// working = false
|
|
3086
|
-
// return
|
|
3087
|
-
// }
|
|
3088
|
-
// // Prioritize tasks
|
|
3089
|
-
// while (deadline.timeRemaining() > 0 && batch.tasks.length) {
|
|
3090
|
-
// batch.tasks.shift()!()
|
|
3091
|
-
// }
|
|
3092
|
-
// onProgress()
|
|
3093
|
-
// if (working) {
|
|
3094
|
-
// latestCallback = requestIdleCallback(workLoop, { timeout: 10000 })
|
|
3095
|
-
// }
|
|
3096
|
-
// }
|
|
3097
|
-
// latestCallback = requestIdleCallback(workLoop, { timeout: 10000 })
|
|
3098
|
-
// }
|
|
3099
|
-
// const startWork = () => {
|
|
3100
|
-
// if (getBatch() && !working) {
|
|
3101
|
-
// if (
|
|
3102
|
-
// (process.env.NODE_ENV === 'development' && instance.options.debugAll) ??
|
|
3103
|
-
// instance.options.debugTable
|
|
3104
|
-
// ) {
|
|
3105
|
-
// console.info('Starting work...')
|
|
3106
|
-
// }
|
|
3107
|
-
// startWorkLoop()
|
|
3108
|
-
// }
|
|
3109
|
-
// }
|
|
3110
|
-
// const stopWork = () => {
|
|
3111
|
-
// if (working) {
|
|
3112
|
-
// if (
|
|
3113
|
-
// (process.env.NODE_ENV === 'development' && instance.options.debugAll) ??
|
|
3114
|
-
// instance.options.debugTable
|
|
3115
|
-
// ) {
|
|
3116
|
-
// console.info('Stopping work...')
|
|
3117
|
-
// }
|
|
3118
|
-
// working = false
|
|
3119
|
-
// cancelIdleCallback(latestCallback)
|
|
3120
|
-
// }
|
|
3121
|
-
// }
|
|
3122
|
-
|
|
3065
|
+
let queuedTimeout = false;
|
|
3123
3066
|
const midInstance = { ...instance,
|
|
3124
3067
|
// init: () => {
|
|
3125
3068
|
// startWork()
|
|
@@ -3134,7 +3077,7 @@ function createTableInstance(options) {
|
|
|
3134
3077
|
...options
|
|
3135
3078
|
},
|
|
3136
3079
|
initialState,
|
|
3137
|
-
|
|
3080
|
+
_queue: cb => {
|
|
3138
3081
|
queued.push(cb);
|
|
3139
3082
|
|
|
3140
3083
|
if (!queuedTimeout) {
|
|
@@ -3152,39 +3095,6 @@ function createTableInstance(options) {
|
|
|
3152
3095
|
}));
|
|
3153
3096
|
}
|
|
3154
3097
|
},
|
|
3155
|
-
// batches: {
|
|
3156
|
-
// data: [],
|
|
3157
|
-
// facets: [],
|
|
3158
|
-
// },
|
|
3159
|
-
// createBatch: priority => {
|
|
3160
|
-
// const batchId = batchUid++
|
|
3161
|
-
// let canceled: boolean
|
|
3162
|
-
// const batch: Batch = {
|
|
3163
|
-
// id: batchId,
|
|
3164
|
-
// priority,
|
|
3165
|
-
// tasks: [],
|
|
3166
|
-
// schedule: cb => {
|
|
3167
|
-
// if (canceled) return
|
|
3168
|
-
// batch.tasks.push(cb)
|
|
3169
|
-
// if (!working && !workScheduled) {
|
|
3170
|
-
// workScheduled = true
|
|
3171
|
-
// instance.queue(() => {
|
|
3172
|
-
// workScheduled = false
|
|
3173
|
-
// instance.setState(old => ({ ...old }))
|
|
3174
|
-
// })
|
|
3175
|
-
// }
|
|
3176
|
-
// },
|
|
3177
|
-
// cancel: () => {
|
|
3178
|
-
// canceled = true
|
|
3179
|
-
// batch.tasks = []
|
|
3180
|
-
// instance.batches[priority] = instance.batches[priority].filter(
|
|
3181
|
-
// b => b.id !== batchId
|
|
3182
|
-
// )
|
|
3183
|
-
// },
|
|
3184
|
-
// }
|
|
3185
|
-
// instance.batches[priority].push(batch)
|
|
3186
|
-
// return batch
|
|
3187
|
-
// },
|
|
3188
3098
|
reset: () => {
|
|
3189
3099
|
instance.setState(instance.initialState);
|
|
3190
3100
|
},
|
|
@@ -3192,7 +3102,7 @@ function createTableInstance(options) {
|
|
|
3192
3102
|
const newOptions = functionalUpdate(updater, instance.options);
|
|
3193
3103
|
instance.options = mergeOptions(newOptions);
|
|
3194
3104
|
},
|
|
3195
|
-
|
|
3105
|
+
_render: (template, props) => {
|
|
3196
3106
|
if (typeof instance.options.render === 'function') {
|
|
3197
3107
|
return instance.options.render(template, props);
|
|
3198
3108
|
}
|
|
@@ -3295,69 +3205,55 @@ function createTable(_, __, options) {
|
|
|
3295
3205
|
|
|
3296
3206
|
function getCoreRowModel() {
|
|
3297
3207
|
return instance => memo(() => [instance.options.data], data => {
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3208
|
+
const rowModel = {
|
|
3209
|
+
rows: [],
|
|
3210
|
+
flatRows: [],
|
|
3211
|
+
rowsById: {}
|
|
3212
|
+
};
|
|
3213
|
+
let rows;
|
|
3214
|
+
let row;
|
|
3215
|
+
let originalRow;
|
|
3303
3216
|
|
|
3304
|
-
const
|
|
3217
|
+
const accessRows = function (originalRows, depth, parent) {
|
|
3305
3218
|
if (depth === void 0) {
|
|
3306
3219
|
depth = 0;
|
|
3307
3220
|
}
|
|
3308
3221
|
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
if (!id) {
|
|
3312
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
3313
|
-
throw new Error("getRowId expected an ID, but got " + id);
|
|
3314
|
-
}
|
|
3315
|
-
}
|
|
3316
|
-
|
|
3317
|
-
const values = {};
|
|
3318
|
-
|
|
3319
|
-
for (let i = 0; i < leafColumns.length; i++) {
|
|
3320
|
-
const column = leafColumns[i];
|
|
3321
|
-
|
|
3322
|
-
if (column && column.accessorFn) {
|
|
3323
|
-
values[column.id] = column.accessorFn(originalRow, rowIndex);
|
|
3324
|
-
}
|
|
3325
|
-
} // Make the row
|
|
3222
|
+
rows = [];
|
|
3326
3223
|
|
|
3224
|
+
for (let i = 0; i < originalRows.length; i++) {
|
|
3225
|
+
originalRow = originalRows[i]; // This could be an expensive check at scale, so we should move it somewhere else, but where?
|
|
3226
|
+
// if (!id) {
|
|
3227
|
+
// if (process.env.NODE_ENV !== 'production') {
|
|
3228
|
+
// throw new Error(`getRowId expected an ID, but got ${id}`)
|
|
3229
|
+
// }
|
|
3230
|
+
// }
|
|
3231
|
+
// Make the row
|
|
3327
3232
|
|
|
3328
|
-
|
|
3233
|
+
row = instance.createRow(instance.getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
|
|
3329
3234
|
|
|
3330
|
-
|
|
3235
|
+
rowModel.flatRows.push(row); // Also keep track of every row by its ID
|
|
3331
3236
|
|
|
3332
|
-
|
|
3237
|
+
rowModel.rowsById[row.id] = row; // Push instance row into parent
|
|
3333
3238
|
|
|
3334
|
-
|
|
3239
|
+
rows.push(row); // Get the original subrows
|
|
3335
3240
|
|
|
3336
|
-
|
|
3337
|
-
|
|
3241
|
+
if (instance.options.getSubRows) {
|
|
3242
|
+
var _row$originalSubRows;
|
|
3338
3243
|
|
|
3339
|
-
|
|
3340
|
-
row.originalSubRows = originalSubRows;
|
|
3341
|
-
const subRows = [];
|
|
3244
|
+
row.originalSubRows = instance.options.getSubRows(originalRow, i); // Then recursively access them
|
|
3342
3245
|
|
|
3343
|
-
|
|
3344
|
-
|
|
3246
|
+
if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
|
|
3247
|
+
row.subRows = accessRows(row.originalSubRows, depth + 1, row);
|
|
3345
3248
|
}
|
|
3346
|
-
|
|
3347
|
-
row.subRows = subRows;
|
|
3348
3249
|
}
|
|
3349
3250
|
}
|
|
3350
|
-
};
|
|
3351
3251
|
|
|
3352
|
-
|
|
3353
|
-
accessRow(data[i], i, 0, rows);
|
|
3354
|
-
}
|
|
3355
|
-
|
|
3356
|
-
return {
|
|
3357
|
-
rows,
|
|
3358
|
-
flatRows,
|
|
3359
|
-
rowsById
|
|
3252
|
+
return rows;
|
|
3360
3253
|
};
|
|
3254
|
+
|
|
3255
|
+
rowModel.rows = accessRows(data);
|
|
3256
|
+
return rowModel;
|
|
3361
3257
|
}, {
|
|
3362
3258
|
key: process.env.NODE_ENV === 'development' && 'getRowModel',
|
|
3363
3259
|
debug: () => {
|
|
@@ -3891,7 +3787,7 @@ function getGroupedRowModel() {
|
|
|
3891
3787
|
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
|
|
3892
3788
|
},
|
|
3893
3789
|
onChange: () => {
|
|
3894
|
-
instance.
|
|
3790
|
+
instance._queue(() => {
|
|
3895
3791
|
instance._autoResetExpanded();
|
|
3896
3792
|
|
|
3897
3793
|
instance._autoResetPageIndex();
|