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