@tanstack/react-table 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/table-core/build/esm/index.js +51 -155
- package/build/cjs/table-core/build/esm/index.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 +17 -17
- 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 +2 -2
|
@@ -387,7 +387,7 @@ const Cells = {
|
|
|
387
387
|
row,
|
|
388
388
|
column,
|
|
389
389
|
getValue: () => row.getValue(columnId),
|
|
390
|
-
renderCell: () => column.cell ? instance.
|
|
390
|
+
renderCell: () => column.cell ? instance._render(column.cell, {
|
|
391
391
|
instance,
|
|
392
392
|
column,
|
|
393
393
|
row,
|
|
@@ -715,9 +715,10 @@ const Expanding = {
|
|
|
715
715
|
return {
|
|
716
716
|
_autoResetExpanded: () => {
|
|
717
717
|
if (!registered) {
|
|
718
|
-
instance.
|
|
718
|
+
instance._queue(() => {
|
|
719
719
|
registered = true;
|
|
720
720
|
});
|
|
721
|
+
|
|
721
722
|
return;
|
|
722
723
|
}
|
|
723
724
|
|
|
@@ -728,7 +729,8 @@ const Expanding = {
|
|
|
728
729
|
if (instance.options.autoResetAll === true || instance.options.autoResetExpanded) {
|
|
729
730
|
if (queued) return;
|
|
730
731
|
queued = true;
|
|
731
|
-
|
|
732
|
+
|
|
733
|
+
instance._queue(() => {
|
|
732
734
|
instance.resetExpanded();
|
|
733
735
|
queued = false;
|
|
734
736
|
});
|
|
@@ -1412,7 +1414,7 @@ const Grouping = {
|
|
|
1412
1414
|
var _column$aggregatedCel;
|
|
1413
1415
|
|
|
1414
1416
|
const template = (_column$aggregatedCel = column.aggregatedCell) != null ? _column$aggregatedCel : column.cell;
|
|
1415
|
-
return template ? instance.
|
|
1417
|
+
return template ? instance._render(template, {
|
|
1416
1418
|
instance,
|
|
1417
1419
|
column,
|
|
1418
1420
|
row,
|
|
@@ -1513,8 +1515,7 @@ const Pagination = {
|
|
|
1513
1515
|
},
|
|
1514
1516
|
getDefaultOptions: instance => {
|
|
1515
1517
|
return {
|
|
1516
|
-
onPaginationChange: makeStateUpdater('pagination', instance)
|
|
1517
|
-
autoResetPageIndex: true
|
|
1518
|
+
onPaginationChange: makeStateUpdater('pagination', instance)
|
|
1518
1519
|
};
|
|
1519
1520
|
},
|
|
1520
1521
|
createInstance: instance => {
|
|
@@ -1522,21 +1523,21 @@ const Pagination = {
|
|
|
1522
1523
|
let queued = false;
|
|
1523
1524
|
return {
|
|
1524
1525
|
_autoResetPageIndex: () => {
|
|
1526
|
+
var _ref, _instance$options$aut;
|
|
1527
|
+
|
|
1525
1528
|
if (!registered) {
|
|
1526
|
-
instance.
|
|
1529
|
+
instance._queue(() => {
|
|
1527
1530
|
registered = true;
|
|
1528
1531
|
});
|
|
1529
|
-
return;
|
|
1530
|
-
}
|
|
1531
1532
|
|
|
1532
|
-
if (instance.options.autoResetAll === false) {
|
|
1533
1533
|
return;
|
|
1534
1534
|
}
|
|
1535
1535
|
|
|
1536
|
-
if (instance.options.autoResetAll
|
|
1536
|
+
if ((_ref = (_instance$options$aut = instance.options.autoResetAll) != null ? _instance$options$aut : instance.options.autoResetPageIndex) != null ? _ref : !instance.options.manualPagination) {
|
|
1537
1537
|
if (queued) return;
|
|
1538
1538
|
queued = true;
|
|
1539
|
-
|
|
1539
|
+
|
|
1540
|
+
instance._queue(() => {
|
|
1540
1541
|
instance.resetPageIndex();
|
|
1541
1542
|
queued = false;
|
|
1542
1543
|
});
|
|
@@ -1558,7 +1559,7 @@ const Pagination = {
|
|
|
1558
1559
|
setPageIndex: updater => {
|
|
1559
1560
|
instance.setPagination(old => {
|
|
1560
1561
|
let pageIndex = functionalUpdate(updater, old.pageIndex);
|
|
1561
|
-
const maxPageIndex =
|
|
1562
|
+
const maxPageIndex = typeof old.pageCount !== 'undefined' ? old.pageCount - 1 : Number.MAX_SAFE_INTEGER;
|
|
1562
1563
|
pageIndex = Math.min(Math.max(0, pageIndex), maxPageIndex);
|
|
1563
1564
|
return { ...old,
|
|
1564
1565
|
pageIndex
|
|
@@ -2669,12 +2670,12 @@ const Headers = {
|
|
|
2669
2670
|
recurseHeader(header);
|
|
2670
2671
|
return leafHeaders;
|
|
2671
2672
|
},
|
|
2672
|
-
renderHeader: () => column.header ? instance.
|
|
2673
|
+
renderHeader: () => column.header ? instance._render(column.header, {
|
|
2673
2674
|
instance,
|
|
2674
2675
|
header: header,
|
|
2675
2676
|
column
|
|
2676
2677
|
}) : null,
|
|
2677
|
-
renderFooter: () => column.footer ? instance.
|
|
2678
|
+
renderFooter: () => column.footer ? instance._render(column.footer, {
|
|
2678
2679
|
instance,
|
|
2679
2680
|
header: header,
|
|
2680
2681
|
column
|
|
@@ -3037,7 +3038,6 @@ function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
|
|
|
3037
3038
|
// data: Batch[]
|
|
3038
3039
|
// facets: Batch[]
|
|
3039
3040
|
// }
|
|
3040
|
-
// export type TaskPriority = keyof CoreBatches
|
|
3041
3041
|
function createTableInstance(options) {
|
|
3042
3042
|
var _options$initialState;
|
|
3043
3043
|
|
|
@@ -3076,64 +3076,7 @@ function createTableInstance(options) {
|
|
|
3076
3076
|
});
|
|
3077
3077
|
|
|
3078
3078
|
const queued = [];
|
|
3079
|
-
let queuedTimeout = false;
|
|
3080
|
-
// let working = false
|
|
3081
|
-
// let latestCallback: ReturnType<typeof requestIdleCallback>
|
|
3082
|
-
// let batchUid = 0
|
|
3083
|
-
// const onProgress = () => {}
|
|
3084
|
-
// const getBatch = () => {
|
|
3085
|
-
// instance.batches.data = instance.batches.data.filter(d => d.tasks.length)
|
|
3086
|
-
// instance.batches.facets = instance.batches.facets.filter(
|
|
3087
|
-
// d => d.tasks.length
|
|
3088
|
-
// )
|
|
3089
|
-
// return (
|
|
3090
|
-
// instance.batches.data.find(d => d.tasks.length) ??
|
|
3091
|
-
// instance.batches.facets.find(d => d.tasks.length)
|
|
3092
|
-
// )
|
|
3093
|
-
// }
|
|
3094
|
-
// const startWorkLoop = () => {
|
|
3095
|
-
// working = true
|
|
3096
|
-
// const workLoop = (deadline: IdleDeadline) => {
|
|
3097
|
-
// const batch = getBatch()
|
|
3098
|
-
// if (!batch) {
|
|
3099
|
-
// working = false
|
|
3100
|
-
// return
|
|
3101
|
-
// }
|
|
3102
|
-
// // Prioritize tasks
|
|
3103
|
-
// while (deadline.timeRemaining() > 0 && batch.tasks.length) {
|
|
3104
|
-
// batch.tasks.shift()!()
|
|
3105
|
-
// }
|
|
3106
|
-
// onProgress()
|
|
3107
|
-
// if (working) {
|
|
3108
|
-
// latestCallback = requestIdleCallback(workLoop, { timeout: 10000 })
|
|
3109
|
-
// }
|
|
3110
|
-
// }
|
|
3111
|
-
// latestCallback = requestIdleCallback(workLoop, { timeout: 10000 })
|
|
3112
|
-
// }
|
|
3113
|
-
// const startWork = () => {
|
|
3114
|
-
// if (getBatch() && !working) {
|
|
3115
|
-
// if (
|
|
3116
|
-
// (process.env.NODE_ENV === 'development' && instance.options.debugAll) ??
|
|
3117
|
-
// instance.options.debugTable
|
|
3118
|
-
// ) {
|
|
3119
|
-
// console.info('Starting work...')
|
|
3120
|
-
// }
|
|
3121
|
-
// startWorkLoop()
|
|
3122
|
-
// }
|
|
3123
|
-
// }
|
|
3124
|
-
// const stopWork = () => {
|
|
3125
|
-
// if (working) {
|
|
3126
|
-
// if (
|
|
3127
|
-
// (process.env.NODE_ENV === 'development' && instance.options.debugAll) ??
|
|
3128
|
-
// instance.options.debugTable
|
|
3129
|
-
// ) {
|
|
3130
|
-
// console.info('Stopping work...')
|
|
3131
|
-
// }
|
|
3132
|
-
// working = false
|
|
3133
|
-
// cancelIdleCallback(latestCallback)
|
|
3134
|
-
// }
|
|
3135
|
-
// }
|
|
3136
|
-
|
|
3079
|
+
let queuedTimeout = false;
|
|
3137
3080
|
const midInstance = { ...instance,
|
|
3138
3081
|
// init: () => {
|
|
3139
3082
|
// startWork()
|
|
@@ -3148,7 +3091,7 @@ function createTableInstance(options) {
|
|
|
3148
3091
|
...options
|
|
3149
3092
|
},
|
|
3150
3093
|
initialState,
|
|
3151
|
-
|
|
3094
|
+
_queue: cb => {
|
|
3152
3095
|
queued.push(cb);
|
|
3153
3096
|
|
|
3154
3097
|
if (!queuedTimeout) {
|
|
@@ -3166,39 +3109,6 @@ function createTableInstance(options) {
|
|
|
3166
3109
|
}));
|
|
3167
3110
|
}
|
|
3168
3111
|
},
|
|
3169
|
-
// batches: {
|
|
3170
|
-
// data: [],
|
|
3171
|
-
// facets: [],
|
|
3172
|
-
// },
|
|
3173
|
-
// createBatch: priority => {
|
|
3174
|
-
// const batchId = batchUid++
|
|
3175
|
-
// let canceled: boolean
|
|
3176
|
-
// const batch: Batch = {
|
|
3177
|
-
// id: batchId,
|
|
3178
|
-
// priority,
|
|
3179
|
-
// tasks: [],
|
|
3180
|
-
// schedule: cb => {
|
|
3181
|
-
// if (canceled) return
|
|
3182
|
-
// batch.tasks.push(cb)
|
|
3183
|
-
// if (!working && !workScheduled) {
|
|
3184
|
-
// workScheduled = true
|
|
3185
|
-
// instance.queue(() => {
|
|
3186
|
-
// workScheduled = false
|
|
3187
|
-
// instance.setState(old => ({ ...old }))
|
|
3188
|
-
// })
|
|
3189
|
-
// }
|
|
3190
|
-
// },
|
|
3191
|
-
// cancel: () => {
|
|
3192
|
-
// canceled = true
|
|
3193
|
-
// batch.tasks = []
|
|
3194
|
-
// instance.batches[priority] = instance.batches[priority].filter(
|
|
3195
|
-
// b => b.id !== batchId
|
|
3196
|
-
// )
|
|
3197
|
-
// },
|
|
3198
|
-
// }
|
|
3199
|
-
// instance.batches[priority].push(batch)
|
|
3200
|
-
// return batch
|
|
3201
|
-
// },
|
|
3202
3112
|
reset: () => {
|
|
3203
3113
|
instance.setState(instance.initialState);
|
|
3204
3114
|
},
|
|
@@ -3206,7 +3116,7 @@ function createTableInstance(options) {
|
|
|
3206
3116
|
const newOptions = functionalUpdate(updater, instance.options);
|
|
3207
3117
|
instance.options = mergeOptions(newOptions);
|
|
3208
3118
|
},
|
|
3209
|
-
|
|
3119
|
+
_render: (template, props) => {
|
|
3210
3120
|
if (typeof instance.options.render === 'function') {
|
|
3211
3121
|
return instance.options.render(template, props);
|
|
3212
3122
|
}
|
|
@@ -3309,69 +3219,55 @@ function createTable(_, __, options) {
|
|
|
3309
3219
|
|
|
3310
3220
|
function getCoreRowModel() {
|
|
3311
3221
|
return instance => memo(() => [instance.options.data], data => {
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3222
|
+
const rowModel = {
|
|
3223
|
+
rows: [],
|
|
3224
|
+
flatRows: [],
|
|
3225
|
+
rowsById: {}
|
|
3226
|
+
};
|
|
3227
|
+
let rows;
|
|
3228
|
+
let row;
|
|
3229
|
+
let originalRow;
|
|
3317
3230
|
|
|
3318
|
-
const
|
|
3231
|
+
const accessRows = function (originalRows, depth, parent) {
|
|
3319
3232
|
if (depth === void 0) {
|
|
3320
3233
|
depth = 0;
|
|
3321
3234
|
}
|
|
3322
3235
|
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
if (!id) {
|
|
3326
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
3327
|
-
throw new Error("getRowId expected an ID, but got " + id);
|
|
3328
|
-
}
|
|
3329
|
-
}
|
|
3330
|
-
|
|
3331
|
-
const values = {};
|
|
3332
|
-
|
|
3333
|
-
for (let i = 0; i < leafColumns.length; i++) {
|
|
3334
|
-
const column = leafColumns[i];
|
|
3335
|
-
|
|
3336
|
-
if (column && column.accessorFn) {
|
|
3337
|
-
values[column.id] = column.accessorFn(originalRow, rowIndex);
|
|
3338
|
-
}
|
|
3339
|
-
} // Make the row
|
|
3236
|
+
rows = [];
|
|
3340
3237
|
|
|
3238
|
+
for (let i = 0; i < originalRows.length; i++) {
|
|
3239
|
+
originalRow = originalRows[i]; // This could be an expensive check at scale, so we should move it somewhere else, but where?
|
|
3240
|
+
// if (!id) {
|
|
3241
|
+
// if (process.env.NODE_ENV !== 'production') {
|
|
3242
|
+
// throw new Error(`getRowId expected an ID, but got ${id}`)
|
|
3243
|
+
// }
|
|
3244
|
+
// }
|
|
3245
|
+
// Make the row
|
|
3341
3246
|
|
|
3342
|
-
|
|
3247
|
+
row = instance.createRow(instance.getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
|
|
3343
3248
|
|
|
3344
|
-
|
|
3249
|
+
rowModel.flatRows.push(row); // Also keep track of every row by its ID
|
|
3345
3250
|
|
|
3346
|
-
|
|
3251
|
+
rowModel.rowsById[row.id] = row; // Push instance row into parent
|
|
3347
3252
|
|
|
3348
|
-
|
|
3253
|
+
rows.push(row); // Get the original subrows
|
|
3349
3254
|
|
|
3350
|
-
|
|
3351
|
-
|
|
3255
|
+
if (instance.options.getSubRows) {
|
|
3256
|
+
var _row$originalSubRows;
|
|
3352
3257
|
|
|
3353
|
-
|
|
3354
|
-
row.originalSubRows = originalSubRows;
|
|
3355
|
-
const subRows = [];
|
|
3258
|
+
row.originalSubRows = instance.options.getSubRows(originalRow, i); // Then recursively access them
|
|
3356
3259
|
|
|
3357
|
-
|
|
3358
|
-
|
|
3260
|
+
if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
|
|
3261
|
+
row.subRows = accessRows(row.originalSubRows, depth + 1, row);
|
|
3359
3262
|
}
|
|
3360
|
-
|
|
3361
|
-
row.subRows = subRows;
|
|
3362
3263
|
}
|
|
3363
3264
|
}
|
|
3364
|
-
};
|
|
3365
3265
|
|
|
3366
|
-
|
|
3367
|
-
accessRow(data[i], i, 0, rows);
|
|
3368
|
-
}
|
|
3369
|
-
|
|
3370
|
-
return {
|
|
3371
|
-
rows,
|
|
3372
|
-
flatRows,
|
|
3373
|
-
rowsById
|
|
3266
|
+
return rows;
|
|
3374
3267
|
};
|
|
3268
|
+
|
|
3269
|
+
rowModel.rows = accessRows(data);
|
|
3270
|
+
return rowModel;
|
|
3375
3271
|
}, {
|
|
3376
3272
|
key: process.env.NODE_ENV === 'development' && 'getRowModel',
|
|
3377
3273
|
debug: () => {
|
|
@@ -3905,7 +3801,7 @@ function getGroupedRowModel() {
|
|
|
3905
3801
|
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
|
|
3906
3802
|
},
|
|
3907
3803
|
onChange: () => {
|
|
3908
|
-
instance.
|
|
3804
|
+
instance._queue(() => {
|
|
3909
3805
|
instance._autoResetExpanded();
|
|
3910
3806
|
|
|
3911
3807
|
instance._autoResetPageIndex();
|