@tanstack/react-table 8.0.0-alpha.72 → 8.0.0-alpha.76
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 +59 -159
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +59 -159
- 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 +59 -159
- 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 +4 -4
|
@@ -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
|
|
@@ -2714,8 +2715,10 @@ const Headers = {
|
|
|
2714
2715
|
}
|
|
2715
2716
|
}),
|
|
2716
2717
|
getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
|
|
2717
|
-
|
|
2718
|
-
|
|
2718
|
+
var _left$map$filter;
|
|
2719
|
+
|
|
2720
|
+
const orderedLeafColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
|
|
2721
|
+
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
|
|
2719
2722
|
}, {
|
|
2720
2723
|
key: process.env.NODE_ENV === 'development' && 'getLeftHeaderGroups',
|
|
2721
2724
|
debug: () => {
|
|
@@ -2725,8 +2728,10 @@ const Headers = {
|
|
|
2725
2728
|
}
|
|
2726
2729
|
}),
|
|
2727
2730
|
getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
|
|
2728
|
-
|
|
2729
|
-
|
|
2731
|
+
var _right$map$filter;
|
|
2732
|
+
|
|
2733
|
+
const orderedLeafColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
|
|
2734
|
+
return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
|
|
2730
2735
|
}, {
|
|
2731
2736
|
key: process.env.NODE_ENV === 'development' && 'getRightHeaderGroups',
|
|
2732
2737
|
debug: () => {
|
|
@@ -3037,7 +3042,6 @@ function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
|
|
|
3037
3042
|
// data: Batch[]
|
|
3038
3043
|
// facets: Batch[]
|
|
3039
3044
|
// }
|
|
3040
|
-
// export type TaskPriority = keyof CoreBatches
|
|
3041
3045
|
function createTableInstance(options) {
|
|
3042
3046
|
var _options$initialState;
|
|
3043
3047
|
|
|
@@ -3076,64 +3080,7 @@ function createTableInstance(options) {
|
|
|
3076
3080
|
});
|
|
3077
3081
|
|
|
3078
3082
|
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
|
-
|
|
3083
|
+
let queuedTimeout = false;
|
|
3137
3084
|
const midInstance = { ...instance,
|
|
3138
3085
|
// init: () => {
|
|
3139
3086
|
// startWork()
|
|
@@ -3148,7 +3095,7 @@ function createTableInstance(options) {
|
|
|
3148
3095
|
...options
|
|
3149
3096
|
},
|
|
3150
3097
|
initialState,
|
|
3151
|
-
|
|
3098
|
+
_queue: cb => {
|
|
3152
3099
|
queued.push(cb);
|
|
3153
3100
|
|
|
3154
3101
|
if (!queuedTimeout) {
|
|
@@ -3166,39 +3113,6 @@ function createTableInstance(options) {
|
|
|
3166
3113
|
}));
|
|
3167
3114
|
}
|
|
3168
3115
|
},
|
|
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
3116
|
reset: () => {
|
|
3203
3117
|
instance.setState(instance.initialState);
|
|
3204
3118
|
},
|
|
@@ -3206,7 +3120,7 @@ function createTableInstance(options) {
|
|
|
3206
3120
|
const newOptions = functionalUpdate(updater, instance.options);
|
|
3207
3121
|
instance.options = mergeOptions(newOptions);
|
|
3208
3122
|
},
|
|
3209
|
-
|
|
3123
|
+
_render: (template, props) => {
|
|
3210
3124
|
if (typeof instance.options.render === 'function') {
|
|
3211
3125
|
return instance.options.render(template, props);
|
|
3212
3126
|
}
|
|
@@ -3309,69 +3223,55 @@ function createTable(_, __, options) {
|
|
|
3309
3223
|
|
|
3310
3224
|
function getCoreRowModel() {
|
|
3311
3225
|
return instance => memo(() => [instance.options.data], data => {
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3226
|
+
const rowModel = {
|
|
3227
|
+
rows: [],
|
|
3228
|
+
flatRows: [],
|
|
3229
|
+
rowsById: {}
|
|
3230
|
+
};
|
|
3231
|
+
let rows;
|
|
3232
|
+
let row;
|
|
3233
|
+
let originalRow;
|
|
3317
3234
|
|
|
3318
|
-
const
|
|
3235
|
+
const accessRows = function (originalRows, depth, parent) {
|
|
3319
3236
|
if (depth === void 0) {
|
|
3320
3237
|
depth = 0;
|
|
3321
3238
|
}
|
|
3322
3239
|
|
|
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
|
|
3240
|
+
rows = [];
|
|
3340
3241
|
|
|
3242
|
+
for (let i = 0; i < originalRows.length; i++) {
|
|
3243
|
+
originalRow = originalRows[i]; // This could be an expensive check at scale, so we should move it somewhere else, but where?
|
|
3244
|
+
// if (!id) {
|
|
3245
|
+
// if (process.env.NODE_ENV !== 'production') {
|
|
3246
|
+
// throw new Error(`getRowId expected an ID, but got ${id}`)
|
|
3247
|
+
// }
|
|
3248
|
+
// }
|
|
3249
|
+
// Make the row
|
|
3341
3250
|
|
|
3342
|
-
|
|
3251
|
+
row = instance.createRow(instance.getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
|
|
3343
3252
|
|
|
3344
|
-
|
|
3253
|
+
rowModel.flatRows.push(row); // Also keep track of every row by its ID
|
|
3345
3254
|
|
|
3346
|
-
|
|
3255
|
+
rowModel.rowsById[row.id] = row; // Push instance row into parent
|
|
3347
3256
|
|
|
3348
|
-
|
|
3257
|
+
rows.push(row); // Get the original subrows
|
|
3349
3258
|
|
|
3350
|
-
|
|
3351
|
-
|
|
3259
|
+
if (instance.options.getSubRows) {
|
|
3260
|
+
var _row$originalSubRows;
|
|
3352
3261
|
|
|
3353
|
-
|
|
3354
|
-
row.originalSubRows = originalSubRows;
|
|
3355
|
-
const subRows = [];
|
|
3262
|
+
row.originalSubRows = instance.options.getSubRows(originalRow, i); // Then recursively access them
|
|
3356
3263
|
|
|
3357
|
-
|
|
3358
|
-
|
|
3264
|
+
if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
|
|
3265
|
+
row.subRows = accessRows(row.originalSubRows, depth + 1, row);
|
|
3359
3266
|
}
|
|
3360
|
-
|
|
3361
|
-
row.subRows = subRows;
|
|
3362
3267
|
}
|
|
3363
3268
|
}
|
|
3364
|
-
};
|
|
3365
|
-
|
|
3366
|
-
for (let i = 0; i < data.length; i++) {
|
|
3367
|
-
accessRow(data[i], i, 0, rows);
|
|
3368
|
-
}
|
|
3369
3269
|
|
|
3370
|
-
|
|
3371
|
-
rows,
|
|
3372
|
-
flatRows,
|
|
3373
|
-
rowsById
|
|
3270
|
+
return rows;
|
|
3374
3271
|
};
|
|
3272
|
+
|
|
3273
|
+
rowModel.rows = accessRows(data);
|
|
3274
|
+
return rowModel;
|
|
3375
3275
|
}, {
|
|
3376
3276
|
key: process.env.NODE_ENV === 'development' && 'getRowModel',
|
|
3377
3277
|
debug: () => {
|
|
@@ -3905,7 +3805,7 @@ function getGroupedRowModel() {
|
|
|
3905
3805
|
return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
|
|
3906
3806
|
},
|
|
3907
3807
|
onChange: () => {
|
|
3908
|
-
instance.
|
|
3808
|
+
instance._queue(() => {
|
|
3909
3809
|
instance._autoResetExpanded();
|
|
3910
3810
|
|
|
3911
3811
|
instance._autoResetPageIndex();
|