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