@tanstack/react-table 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.
@@ -2669,7 +2669,7 @@ var drawChart = (function (exports) {
2669
2669
  </script>
2670
2670
  <script>
2671
2671
  /*<!--*/
2672
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"name":"packages","children":[{"name":"table-core/build/esm/index.js","uid":"1ed1-127"},{"name":"react-table/src/index.tsx","uid":"1ed1-129"}]}]}],"isRoot":true},"nodeParts":{"1ed1-127":{"renderedLength":142433,"gzipLength":24399,"brotliLength":0,"mainUid":"1ed1-126"},"1ed1-129":{"renderedLength":2102,"gzipLength":836,"brotliLength":0,"mainUid":"1ed1-128"}},"nodeMetas":{"1ed1-126":{"id":"/packages/table-core/build/esm/index.js","moduleParts":{"index.production.js":"1ed1-127"},"imported":[],"importedBy":[{"uid":"1ed1-128"}]},"1ed1-128":{"id":"/packages/react-table/src/index.tsx","moduleParts":{"index.production.js":"1ed1-129"},"imported":[{"uid":"1ed1-130"},{"uid":"1ed1-126"}],"importedBy":[],"isEntry":true},"1ed1-130":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"1ed1-128"}],"isExternal":true}},"env":{"rollup":"2.70.2"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
2672
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"name":"packages","children":[{"name":"table-core/build/esm/index.js","uid":"0ced-127"},{"name":"react-table/src/index.tsx","uid":"0ced-129"}]}]}],"isRoot":true},"nodeParts":{"0ced-127":{"renderedLength":139332,"gzipLength":23812,"brotliLength":0,"mainUid":"0ced-126"},"0ced-129":{"renderedLength":2102,"gzipLength":836,"brotliLength":0,"mainUid":"0ced-128"}},"nodeMetas":{"0ced-126":{"id":"/packages/table-core/build/esm/index.js","moduleParts":{"index.production.js":"0ced-127"},"imported":[],"importedBy":[{"uid":"0ced-128"}]},"0ced-128":{"id":"/packages/react-table/src/index.tsx","moduleParts":{"index.production.js":"0ced-129"},"imported":[{"uid":"0ced-130"},{"uid":"0ced-126"}],"importedBy":[],"isEntry":true},"0ced-130":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"0ced-128"}],"isExternal":true}},"env":{"rollup":"2.70.2"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
2673
2673
 
2674
2674
  const run = () => {
2675
2675
  const width = window.innerWidth;
@@ -11,11 +11,11 @@
11
11
  "children": [
12
12
  {
13
13
  "name": "table-core/build/esm/index.js",
14
- "uid": "1ed1-132"
14
+ "uid": "0ced-132"
15
15
  },
16
16
  {
17
17
  "name": "react-table/src/index.tsx",
18
- "uid": "1ed1-134"
18
+ "uid": "0ced-134"
19
19
  }
20
20
  ]
21
21
  }
@@ -25,55 +25,55 @@
25
25
  "isRoot": true
26
26
  },
27
27
  "nodeParts": {
28
- "1ed1-132": {
29
- "renderedLength": 142433,
30
- "gzipLength": 24399,
28
+ "0ced-132": {
29
+ "renderedLength": 139332,
30
+ "gzipLength": 23812,
31
31
  "brotliLength": 0,
32
- "mainUid": "1ed1-131"
32
+ "mainUid": "0ced-131"
33
33
  },
34
- "1ed1-134": {
34
+ "0ced-134": {
35
35
  "renderedLength": 2102,
36
36
  "gzipLength": 836,
37
37
  "brotliLength": 0,
38
- "mainUid": "1ed1-133"
38
+ "mainUid": "0ced-133"
39
39
  }
40
40
  },
41
41
  "nodeMetas": {
42
- "1ed1-131": {
42
+ "0ced-131": {
43
43
  "id": "/packages/table-core/build/esm/index.js",
44
44
  "moduleParts": {
45
- "index.production.js": "1ed1-132"
45
+ "index.production.js": "0ced-132"
46
46
  },
47
47
  "imported": [],
48
48
  "importedBy": [
49
49
  {
50
- "uid": "1ed1-133"
50
+ "uid": "0ced-133"
51
51
  }
52
52
  ]
53
53
  },
54
- "1ed1-133": {
54
+ "0ced-133": {
55
55
  "id": "/packages/react-table/src/index.tsx",
56
56
  "moduleParts": {
57
- "index.production.js": "1ed1-134"
57
+ "index.production.js": "0ced-134"
58
58
  },
59
59
  "imported": [
60
60
  {
61
- "uid": "1ed1-135"
61
+ "uid": "0ced-135"
62
62
  },
63
63
  {
64
- "uid": "1ed1-131"
64
+ "uid": "0ced-131"
65
65
  }
66
66
  ],
67
67
  "importedBy": [],
68
68
  "isEntry": true
69
69
  },
70
- "1ed1-135": {
70
+ "0ced-135": {
71
71
  "id": "react",
72
72
  "moduleParts": {},
73
73
  "imported": [],
74
74
  "importedBy": [
75
75
  {
76
- "uid": "1ed1-133"
76
+ "uid": "0ced-133"
77
77
  }
78
78
  ],
79
79
  "isExternal": true
@@ -3052,7 +3052,6 @@
3052
3052
  // data: Batch[]
3053
3053
  // facets: Batch[]
3054
3054
  // }
3055
- // export type TaskPriority = keyof CoreBatches
3056
3055
  function createTableInstance(options) {
3057
3056
  var _options$initialState;
3058
3057
 
@@ -3091,64 +3090,7 @@
3091
3090
  });
3092
3091
 
3093
3092
  const queued = [];
3094
- let queuedTimeout = false; // let workScheduled = false
3095
- // let working = false
3096
- // let latestCallback: ReturnType<typeof requestIdleCallback>
3097
- // let batchUid = 0
3098
- // const onProgress = () => {}
3099
- // const getBatch = () => {
3100
- // instance.batches.data = instance.batches.data.filter(d => d.tasks.length)
3101
- // instance.batches.facets = instance.batches.facets.filter(
3102
- // d => d.tasks.length
3103
- // )
3104
- // return (
3105
- // instance.batches.data.find(d => d.tasks.length) ??
3106
- // instance.batches.facets.find(d => d.tasks.length)
3107
- // )
3108
- // }
3109
- // const startWorkLoop = () => {
3110
- // working = true
3111
- // const workLoop = (deadline: IdleDeadline) => {
3112
- // const batch = getBatch()
3113
- // if (!batch) {
3114
- // working = false
3115
- // return
3116
- // }
3117
- // // Prioritize tasks
3118
- // while (deadline.timeRemaining() > 0 && batch.tasks.length) {
3119
- // batch.tasks.shift()!()
3120
- // }
3121
- // onProgress()
3122
- // if (working) {
3123
- // latestCallback = requestIdleCallback(workLoop, { timeout: 10000 })
3124
- // }
3125
- // }
3126
- // latestCallback = requestIdleCallback(workLoop, { timeout: 10000 })
3127
- // }
3128
- // const startWork = () => {
3129
- // if (getBatch() && !working) {
3130
- // if (
3131
- // ("development" === 'development' && instance.options.debugAll) ??
3132
- // instance.options.debugTable
3133
- // ) {
3134
- // console.info('Starting work...')
3135
- // }
3136
- // startWorkLoop()
3137
- // }
3138
- // }
3139
- // const stopWork = () => {
3140
- // if (working) {
3141
- // if (
3142
- // ("development" === 'development' && instance.options.debugAll) ??
3143
- // instance.options.debugTable
3144
- // ) {
3145
- // console.info('Stopping work...')
3146
- // }
3147
- // working = false
3148
- // cancelIdleCallback(latestCallback)
3149
- // }
3150
- // }
3151
-
3093
+ let queuedTimeout = false;
3152
3094
  const midInstance = { ...instance,
3153
3095
  // init: () => {
3154
3096
  // startWork()
@@ -3181,39 +3123,6 @@
3181
3123
  }));
3182
3124
  }
3183
3125
  },
3184
- // batches: {
3185
- // data: [],
3186
- // facets: [],
3187
- // },
3188
- // createBatch: priority => {
3189
- // const batchId = batchUid++
3190
- // let canceled: boolean
3191
- // const batch: Batch = {
3192
- // id: batchId,
3193
- // priority,
3194
- // tasks: [],
3195
- // schedule: cb => {
3196
- // if (canceled) return
3197
- // batch.tasks.push(cb)
3198
- // if (!working && !workScheduled) {
3199
- // workScheduled = true
3200
- // instance.queue(() => {
3201
- // workScheduled = false
3202
- // instance.setState(old => ({ ...old }))
3203
- // })
3204
- // }
3205
- // },
3206
- // cancel: () => {
3207
- // canceled = true
3208
- // batch.tasks = []
3209
- // instance.batches[priority] = instance.batches[priority].filter(
3210
- // b => b.id !== batchId
3211
- // )
3212
- // },
3213
- // }
3214
- // instance.batches[priority].push(batch)
3215
- // return batch
3216
- // },
3217
3126
  reset: () => {
3218
3127
  instance.setState(instance.initialState);
3219
3128
  },
@@ -3324,69 +3233,55 @@
3324
3233
 
3325
3234
  function getCoreRowModel() {
3326
3235
  return instance => memo(() => [instance.options.data], data => {
3327
- // Access the row model using initial columns
3328
- const rows = [];
3329
- const flatRows = [];
3330
- const rowsById = {};
3331
- const leafColumns = instance.getAllLeafColumns();
3236
+ const rowModel = {
3237
+ rows: [],
3238
+ flatRows: [],
3239
+ rowsById: {}
3240
+ };
3241
+ let rows;
3242
+ let row;
3243
+ let originalRow;
3332
3244
 
3333
- const accessRow = function (originalRow, rowIndex, depth, parentRows, parent) {
3245
+ const accessRows = function (originalRows, depth, parent) {
3334
3246
  if (depth === void 0) {
3335
3247
  depth = 0;
3336
3248
  }
3337
3249
 
3338
- const id = instance.getRowId(originalRow, rowIndex, parent);
3339
-
3340
- if (!id) {
3341
- {
3342
- throw new Error("getRowId expected an ID, but got " + id);
3343
- }
3344
- }
3345
-
3346
- const values = {};
3347
-
3348
- for (let i = 0; i < leafColumns.length; i++) {
3349
- const column = leafColumns[i];
3350
-
3351
- if (column && column.accessorFn) {
3352
- values[column.id] = column.accessorFn(originalRow, rowIndex);
3353
- }
3354
- } // Make the row
3250
+ rows = [];
3355
3251
 
3252
+ for (let i = 0; i < originalRows.length; i++) {
3253
+ originalRow = originalRows[i]; // This could be an expensive check at scale, so we should move it somewhere else, but where?
3254
+ // if (!id) {
3255
+ // if ("development" !== 'production') {
3256
+ // throw new Error(`getRowId expected an ID, but got ${id}`)
3257
+ // }
3258
+ // }
3259
+ // Make the row
3356
3260
 
3357
- const row = instance.createRow(id, originalRow, rowIndex, depth); // Push instance row into the parentRows array
3261
+ row = instance.createRow(instance.getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
3358
3262
 
3359
- parentRows.push(row); // Keep track of every row in a flat array
3263
+ rowModel.flatRows.push(row); // Also keep track of every row by its ID
3360
3264
 
3361
- flatRows.push(row); // Also keep track of every row by its ID
3265
+ rowModel.rowsById[row.id] = row; // Push instance row into parent
3362
3266
 
3363
- rowsById[id] = row; // Get the original subrows
3267
+ rows.push(row); // Get the original subrows
3364
3268
 
3365
- if (instance.options.getSubRows) {
3366
- const originalSubRows = instance.options.getSubRows(originalRow, rowIndex); // Then recursively access them
3269
+ if (instance.options.getSubRows) {
3270
+ var _row$originalSubRows;
3367
3271
 
3368
- if (originalSubRows != null && originalSubRows.length) {
3369
- row.originalSubRows = originalSubRows;
3370
- const subRows = [];
3272
+ row.originalSubRows = instance.options.getSubRows(originalRow, i); // Then recursively access them
3371
3273
 
3372
- for (let i = 0; i < row.originalSubRows.length; i++) {
3373
- accessRow(row.originalSubRows[i], i, depth + 1, subRows, row);
3274
+ if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
3275
+ row.subRows = accessRows(row.originalSubRows, depth + 1, row);
3374
3276
  }
3375
-
3376
- row.subRows = subRows;
3377
3277
  }
3378
3278
  }
3379
- };
3380
-
3381
- for (let i = 0; i < data.length; i++) {
3382
- accessRow(data[i], i, 0, rows);
3383
- }
3384
3279
 
3385
- return {
3386
- rows,
3387
- flatRows,
3388
- rowsById
3280
+ return rows;
3389
3281
  };
3282
+
3283
+ rowModel.rows = accessRows(data);
3284
+ return rowModel;
3390
3285
  }, {
3391
3286
  key: 'getRowModel',
3392
3287
  debug: () => {