@tanstack/table-core 8.0.0-alpha.73 → 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.
@@ -3022,7 +3022,6 @@
3022
3022
  // data: Batch[]
3023
3023
  // facets: Batch[]
3024
3024
  // }
3025
- // export type TaskPriority = keyof CoreBatches
3026
3025
  function createTableInstance(options) {
3027
3026
  var _options$initialState;
3028
3027
 
@@ -3061,64 +3060,7 @@
3061
3060
  });
3062
3061
 
3063
3062
  const queued = [];
3064
- let queuedTimeout = false; // let workScheduled = false
3065
- // let working = false
3066
- // let latestCallback: ReturnType<typeof requestIdleCallback>
3067
- // let batchUid = 0
3068
- // const onProgress = () => {}
3069
- // const getBatch = () => {
3070
- // instance.batches.data = instance.batches.data.filter(d => d.tasks.length)
3071
- // instance.batches.facets = instance.batches.facets.filter(
3072
- // d => d.tasks.length
3073
- // )
3074
- // return (
3075
- // instance.batches.data.find(d => d.tasks.length) ??
3076
- // instance.batches.facets.find(d => d.tasks.length)
3077
- // )
3078
- // }
3079
- // const startWorkLoop = () => {
3080
- // working = true
3081
- // const workLoop = (deadline: IdleDeadline) => {
3082
- // const batch = getBatch()
3083
- // if (!batch) {
3084
- // working = false
3085
- // return
3086
- // }
3087
- // // Prioritize tasks
3088
- // while (deadline.timeRemaining() > 0 && batch.tasks.length) {
3089
- // batch.tasks.shift()!()
3090
- // }
3091
- // onProgress()
3092
- // if (working) {
3093
- // latestCallback = requestIdleCallback(workLoop, { timeout: 10000 })
3094
- // }
3095
- // }
3096
- // latestCallback = requestIdleCallback(workLoop, { timeout: 10000 })
3097
- // }
3098
- // const startWork = () => {
3099
- // if (getBatch() && !working) {
3100
- // if (
3101
- // ("development" === 'development' && instance.options.debugAll) ??
3102
- // instance.options.debugTable
3103
- // ) {
3104
- // console.info('Starting work...')
3105
- // }
3106
- // startWorkLoop()
3107
- // }
3108
- // }
3109
- // const stopWork = () => {
3110
- // if (working) {
3111
- // if (
3112
- // ("development" === 'development' && instance.options.debugAll) ??
3113
- // instance.options.debugTable
3114
- // ) {
3115
- // console.info('Stopping work...')
3116
- // }
3117
- // working = false
3118
- // cancelIdleCallback(latestCallback)
3119
- // }
3120
- // }
3121
-
3063
+ let queuedTimeout = false;
3122
3064
  const midInstance = { ...instance,
3123
3065
  // init: () => {
3124
3066
  // startWork()
@@ -3151,39 +3093,6 @@
3151
3093
  }));
3152
3094
  }
3153
3095
  },
3154
- // batches: {
3155
- // data: [],
3156
- // facets: [],
3157
- // },
3158
- // createBatch: priority => {
3159
- // const batchId = batchUid++
3160
- // let canceled: boolean
3161
- // const batch: Batch = {
3162
- // id: batchId,
3163
- // priority,
3164
- // tasks: [],
3165
- // schedule: cb => {
3166
- // if (canceled) return
3167
- // batch.tasks.push(cb)
3168
- // if (!working && !workScheduled) {
3169
- // workScheduled = true
3170
- // instance.queue(() => {
3171
- // workScheduled = false
3172
- // instance.setState(old => ({ ...old }))
3173
- // })
3174
- // }
3175
- // },
3176
- // cancel: () => {
3177
- // canceled = true
3178
- // batch.tasks = []
3179
- // instance.batches[priority] = instance.batches[priority].filter(
3180
- // b => b.id !== batchId
3181
- // )
3182
- // },
3183
- // }
3184
- // instance.batches[priority].push(batch)
3185
- // return batch
3186
- // },
3187
3096
  reset: () => {
3188
3097
  instance.setState(instance.initialState);
3189
3098
  },
@@ -3294,69 +3203,55 @@
3294
3203
 
3295
3204
  function getCoreRowModel() {
3296
3205
  return instance => memo(() => [instance.options.data], data => {
3297
- // Access the row model using initial columns
3298
- const rows = [];
3299
- const flatRows = [];
3300
- const rowsById = {};
3301
- const leafColumns = instance.getAllLeafColumns();
3206
+ const rowModel = {
3207
+ rows: [],
3208
+ flatRows: [],
3209
+ rowsById: {}
3210
+ };
3211
+ let rows;
3212
+ let row;
3213
+ let originalRow;
3302
3214
 
3303
- const accessRow = function (originalRow, rowIndex, depth, parentRows, parent) {
3215
+ const accessRows = function (originalRows, depth, parent) {
3304
3216
  if (depth === void 0) {
3305
3217
  depth = 0;
3306
3218
  }
3307
3219
 
3308
- const id = instance.getRowId(originalRow, rowIndex, parent);
3309
-
3310
- if (!id) {
3311
- {
3312
- throw new Error("getRowId expected an ID, but got " + id);
3313
- }
3314
- }
3315
-
3316
- const values = {};
3317
-
3318
- for (let i = 0; i < leafColumns.length; i++) {
3319
- const column = leafColumns[i];
3320
-
3321
- if (column && column.accessorFn) {
3322
- values[column.id] = column.accessorFn(originalRow, rowIndex);
3323
- }
3324
- } // Make the row
3220
+ rows = [];
3325
3221
 
3222
+ for (let i = 0; i < originalRows.length; i++) {
3223
+ originalRow = originalRows[i]; // This could be an expensive check at scale, so we should move it somewhere else, but where?
3224
+ // if (!id) {
3225
+ // if ("development" !== 'production') {
3226
+ // throw new Error(`getRowId expected an ID, but got ${id}`)
3227
+ // }
3228
+ // }
3229
+ // Make the row
3326
3230
 
3327
- const row = instance.createRow(id, originalRow, rowIndex, depth); // Push instance row into the parentRows array
3231
+ row = instance.createRow(instance.getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
3328
3232
 
3329
- parentRows.push(row); // Keep track of every row in a flat array
3233
+ rowModel.flatRows.push(row); // Also keep track of every row by its ID
3330
3234
 
3331
- flatRows.push(row); // Also keep track of every row by its ID
3235
+ rowModel.rowsById[row.id] = row; // Push instance row into parent
3332
3236
 
3333
- rowsById[id] = row; // Get the original subrows
3237
+ rows.push(row); // Get the original subrows
3334
3238
 
3335
- if (instance.options.getSubRows) {
3336
- const originalSubRows = instance.options.getSubRows(originalRow, rowIndex); // Then recursively access them
3239
+ if (instance.options.getSubRows) {
3240
+ var _row$originalSubRows;
3337
3241
 
3338
- if (originalSubRows != null && originalSubRows.length) {
3339
- row.originalSubRows = originalSubRows;
3340
- const subRows = [];
3242
+ row.originalSubRows = instance.options.getSubRows(originalRow, i); // Then recursively access them
3341
3243
 
3342
- for (let i = 0; i < row.originalSubRows.length; i++) {
3343
- accessRow(row.originalSubRows[i], i, depth + 1, subRows, row);
3244
+ if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
3245
+ row.subRows = accessRows(row.originalSubRows, depth + 1, row);
3344
3246
  }
3345
-
3346
- row.subRows = subRows;
3347
3247
  }
3348
3248
  }
3349
- };
3350
-
3351
- for (let i = 0; i < data.length; i++) {
3352
- accessRow(data[i], i, 0, rows);
3353
- }
3354
3249
 
3355
- return {
3356
- rows,
3357
- flatRows,
3358
- rowsById
3250
+ return rows;
3359
3251
  };
3252
+
3253
+ rowModel.rows = accessRows(data);
3254
+ return rowModel;
3360
3255
  }, {
3361
3256
  key: 'getRowModel',
3362
3257
  debug: () => {