@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.
@@ -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":"9906-127"},{"name":"react-table/src/index.tsx","uid":"9906-129"}]}]}],"isRoot":true},"nodeParts":{"9906-127":{"renderedLength":142387,"gzipLength":24367,"brotliLength":0,"mainUid":"9906-126"},"9906-129":{"renderedLength":2102,"gzipLength":836,"brotliLength":0,"mainUid":"9906-128"}},"nodeMetas":{"9906-126":{"id":"/packages/table-core/build/esm/index.js","moduleParts":{"index.production.js":"9906-127"},"imported":[],"importedBy":[{"uid":"9906-128"}]},"9906-128":{"id":"/packages/react-table/src/index.tsx","moduleParts":{"index.production.js":"9906-129"},"imported":[{"uid":"9906-130"},{"uid":"9906-126"}],"importedBy":[],"isEntry":true},"9906-130":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"9906-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": "9906-132"
14
+ "uid": "0ced-132"
15
15
  },
16
16
  {
17
17
  "name": "react-table/src/index.tsx",
18
- "uid": "9906-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
- "9906-132": {
29
- "renderedLength": 142387,
30
- "gzipLength": 24367,
28
+ "0ced-132": {
29
+ "renderedLength": 139332,
30
+ "gzipLength": 23812,
31
31
  "brotliLength": 0,
32
- "mainUid": "9906-131"
32
+ "mainUid": "0ced-131"
33
33
  },
34
- "9906-134": {
34
+ "0ced-134": {
35
35
  "renderedLength": 2102,
36
36
  "gzipLength": 836,
37
37
  "brotliLength": 0,
38
- "mainUid": "9906-133"
38
+ "mainUid": "0ced-133"
39
39
  }
40
40
  },
41
41
  "nodeMetas": {
42
- "9906-131": {
42
+ "0ced-131": {
43
43
  "id": "/packages/table-core/build/esm/index.js",
44
44
  "moduleParts": {
45
- "index.production.js": "9906-132"
45
+ "index.production.js": "0ced-132"
46
46
  },
47
47
  "imported": [],
48
48
  "importedBy": [
49
49
  {
50
- "uid": "9906-133"
50
+ "uid": "0ced-133"
51
51
  }
52
52
  ]
53
53
  },
54
- "9906-133": {
54
+ "0ced-133": {
55
55
  "id": "/packages/react-table/src/index.tsx",
56
56
  "moduleParts": {
57
- "index.production.js": "9906-134"
57
+ "index.production.js": "0ced-134"
58
58
  },
59
59
  "imported": [
60
60
  {
61
- "uid": "9906-135"
61
+ "uid": "0ced-135"
62
62
  },
63
63
  {
64
- "uid": "9906-131"
64
+ "uid": "0ced-131"
65
65
  }
66
66
  ],
67
67
  "importedBy": [],
68
68
  "isEntry": true
69
69
  },
70
- "9906-135": {
70
+ "0ced-135": {
71
71
  "id": "react",
72
72
  "moduleParts": {},
73
73
  "imported": [],
74
74
  "importedBy": [
75
75
  {
76
- "uid": "9906-133"
76
+ "uid": "0ced-133"
77
77
  }
78
78
  ],
79
79
  "isExternal": true
@@ -405,7 +405,7 @@
405
405
  row,
406
406
  column,
407
407
  getValue: () => row.getValue(columnId),
408
- renderCell: () => column.cell ? instance.render(column.cell, {
408
+ renderCell: () => column.cell ? instance._render(column.cell, {
409
409
  instance,
410
410
  column,
411
411
  row,
@@ -729,9 +729,10 @@
729
729
  return {
730
730
  _autoResetExpanded: () => {
731
731
  if (!registered) {
732
- instance.queue(() => {
732
+ instance._queue(() => {
733
733
  registered = true;
734
734
  });
735
+
735
736
  return;
736
737
  }
737
738
 
@@ -742,7 +743,8 @@
742
743
  if (instance.options.autoResetAll === true || instance.options.autoResetExpanded) {
743
744
  if (queued) return;
744
745
  queued = true;
745
- instance.queue(() => {
746
+
747
+ instance._queue(() => {
746
748
  instance.resetExpanded();
747
749
  queued = false;
748
750
  });
@@ -1426,7 +1428,7 @@
1426
1428
  var _column$aggregatedCel;
1427
1429
 
1428
1430
  const template = (_column$aggregatedCel = column.aggregatedCell) != null ? _column$aggregatedCel : column.cell;
1429
- return template ? instance.render(template, {
1431
+ return template ? instance._render(template, {
1430
1432
  instance,
1431
1433
  column,
1432
1434
  row,
@@ -1527,8 +1529,7 @@
1527
1529
  },
1528
1530
  getDefaultOptions: instance => {
1529
1531
  return {
1530
- onPaginationChange: makeStateUpdater('pagination', instance),
1531
- autoResetPageIndex: true
1532
+ onPaginationChange: makeStateUpdater('pagination', instance)
1532
1533
  };
1533
1534
  },
1534
1535
  createInstance: instance => {
@@ -1536,21 +1537,21 @@
1536
1537
  let queued = false;
1537
1538
  return {
1538
1539
  _autoResetPageIndex: () => {
1540
+ var _ref, _instance$options$aut;
1541
+
1539
1542
  if (!registered) {
1540
- instance.queue(() => {
1543
+ instance._queue(() => {
1541
1544
  registered = true;
1542
1545
  });
1543
- return;
1544
- }
1545
1546
 
1546
- if (instance.options.autoResetAll === false) {
1547
1547
  return;
1548
1548
  }
1549
1549
 
1550
- if (instance.options.autoResetAll === true || instance.options.autoResetPageIndex) {
1550
+ if ((_ref = (_instance$options$aut = instance.options.autoResetAll) != null ? _instance$options$aut : instance.options.autoResetPageIndex) != null ? _ref : !instance.options.manualPagination) {
1551
1551
  if (queued) return;
1552
1552
  queued = true;
1553
- instance.queue(() => {
1553
+
1554
+ instance._queue(() => {
1554
1555
  instance.resetPageIndex();
1555
1556
  queued = false;
1556
1557
  });
@@ -1572,7 +1573,7 @@
1572
1573
  setPageIndex: updater => {
1573
1574
  instance.setPagination(old => {
1574
1575
  let pageIndex = functionalUpdate(updater, old.pageIndex);
1575
- const maxPageIndex = old.pageCount && old.pageCount > 0 ? old.pageCount - 1 : Number.MAX_SAFE_INTEGER;
1576
+ const maxPageIndex = typeof old.pageCount !== 'undefined' ? old.pageCount - 1 : Number.MAX_SAFE_INTEGER;
1576
1577
  pageIndex = Math.min(Math.max(0, pageIndex), maxPageIndex);
1577
1578
  return { ...old,
1578
1579
  pageIndex
@@ -2683,12 +2684,12 @@
2683
2684
  recurseHeader(header);
2684
2685
  return leafHeaders;
2685
2686
  },
2686
- renderHeader: () => column.header ? instance.render(column.header, {
2687
+ renderHeader: () => column.header ? instance._render(column.header, {
2687
2688
  instance,
2688
2689
  header: header,
2689
2690
  column
2690
2691
  }) : null,
2691
- renderFooter: () => column.footer ? instance.render(column.footer, {
2692
+ renderFooter: () => column.footer ? instance._render(column.footer, {
2692
2693
  instance,
2693
2694
  header: header,
2694
2695
  column
@@ -3051,7 +3052,6 @@
3051
3052
  // data: Batch[]
3052
3053
  // facets: Batch[]
3053
3054
  // }
3054
- // export type TaskPriority = keyof CoreBatches
3055
3055
  function createTableInstance(options) {
3056
3056
  var _options$initialState;
3057
3057
 
@@ -3090,64 +3090,7 @@
3090
3090
  });
3091
3091
 
3092
3092
  const queued = [];
3093
- let queuedTimeout = false; // let workScheduled = false
3094
- // let working = false
3095
- // let latestCallback: ReturnType<typeof requestIdleCallback>
3096
- // let batchUid = 0
3097
- // const onProgress = () => {}
3098
- // const getBatch = () => {
3099
- // instance.batches.data = instance.batches.data.filter(d => d.tasks.length)
3100
- // instance.batches.facets = instance.batches.facets.filter(
3101
- // d => d.tasks.length
3102
- // )
3103
- // return (
3104
- // instance.batches.data.find(d => d.tasks.length) ??
3105
- // instance.batches.facets.find(d => d.tasks.length)
3106
- // )
3107
- // }
3108
- // const startWorkLoop = () => {
3109
- // working = true
3110
- // const workLoop = (deadline: IdleDeadline) => {
3111
- // const batch = getBatch()
3112
- // if (!batch) {
3113
- // working = false
3114
- // return
3115
- // }
3116
- // // Prioritize tasks
3117
- // while (deadline.timeRemaining() > 0 && batch.tasks.length) {
3118
- // batch.tasks.shift()!()
3119
- // }
3120
- // onProgress()
3121
- // if (working) {
3122
- // latestCallback = requestIdleCallback(workLoop, { timeout: 10000 })
3123
- // }
3124
- // }
3125
- // latestCallback = requestIdleCallback(workLoop, { timeout: 10000 })
3126
- // }
3127
- // const startWork = () => {
3128
- // if (getBatch() && !working) {
3129
- // if (
3130
- // ("development" === 'development' && instance.options.debugAll) ??
3131
- // instance.options.debugTable
3132
- // ) {
3133
- // console.info('Starting work...')
3134
- // }
3135
- // startWorkLoop()
3136
- // }
3137
- // }
3138
- // const stopWork = () => {
3139
- // if (working) {
3140
- // if (
3141
- // ("development" === 'development' && instance.options.debugAll) ??
3142
- // instance.options.debugTable
3143
- // ) {
3144
- // console.info('Stopping work...')
3145
- // }
3146
- // working = false
3147
- // cancelIdleCallback(latestCallback)
3148
- // }
3149
- // }
3150
-
3093
+ let queuedTimeout = false;
3151
3094
  const midInstance = { ...instance,
3152
3095
  // init: () => {
3153
3096
  // startWork()
@@ -3162,7 +3105,7 @@
3162
3105
  ...options
3163
3106
  },
3164
3107
  initialState,
3165
- queue: cb => {
3108
+ _queue: cb => {
3166
3109
  queued.push(cb);
3167
3110
 
3168
3111
  if (!queuedTimeout) {
@@ -3180,39 +3123,6 @@
3180
3123
  }));
3181
3124
  }
3182
3125
  },
3183
- // batches: {
3184
- // data: [],
3185
- // facets: [],
3186
- // },
3187
- // createBatch: priority => {
3188
- // const batchId = batchUid++
3189
- // let canceled: boolean
3190
- // const batch: Batch = {
3191
- // id: batchId,
3192
- // priority,
3193
- // tasks: [],
3194
- // schedule: cb => {
3195
- // if (canceled) return
3196
- // batch.tasks.push(cb)
3197
- // if (!working && !workScheduled) {
3198
- // workScheduled = true
3199
- // instance.queue(() => {
3200
- // workScheduled = false
3201
- // instance.setState(old => ({ ...old }))
3202
- // })
3203
- // }
3204
- // },
3205
- // cancel: () => {
3206
- // canceled = true
3207
- // batch.tasks = []
3208
- // instance.batches[priority] = instance.batches[priority].filter(
3209
- // b => b.id !== batchId
3210
- // )
3211
- // },
3212
- // }
3213
- // instance.batches[priority].push(batch)
3214
- // return batch
3215
- // },
3216
3126
  reset: () => {
3217
3127
  instance.setState(instance.initialState);
3218
3128
  },
@@ -3220,7 +3130,7 @@
3220
3130
  const newOptions = functionalUpdate(updater, instance.options);
3221
3131
  instance.options = mergeOptions(newOptions);
3222
3132
  },
3223
- render: (template, props) => {
3133
+ _render: (template, props) => {
3224
3134
  if (typeof instance.options.render === 'function') {
3225
3135
  return instance.options.render(template, props);
3226
3136
  }
@@ -3323,69 +3233,55 @@
3323
3233
 
3324
3234
  function getCoreRowModel() {
3325
3235
  return instance => memo(() => [instance.options.data], data => {
3326
- // Access the row model using initial columns
3327
- const rows = [];
3328
- const flatRows = [];
3329
- const rowsById = {};
3330
- const leafColumns = instance.getAllLeafColumns();
3236
+ const rowModel = {
3237
+ rows: [],
3238
+ flatRows: [],
3239
+ rowsById: {}
3240
+ };
3241
+ let rows;
3242
+ let row;
3243
+ let originalRow;
3331
3244
 
3332
- const accessRow = function (originalRow, rowIndex, depth, parentRows, parent) {
3245
+ const accessRows = function (originalRows, depth, parent) {
3333
3246
  if (depth === void 0) {
3334
3247
  depth = 0;
3335
3248
  }
3336
3249
 
3337
- const id = instance.getRowId(originalRow, rowIndex, parent);
3338
-
3339
- if (!id) {
3340
- {
3341
- throw new Error("getRowId expected an ID, but got " + id);
3342
- }
3343
- }
3344
-
3345
- const values = {};
3346
-
3347
- for (let i = 0; i < leafColumns.length; i++) {
3348
- const column = leafColumns[i];
3349
-
3350
- if (column && column.accessorFn) {
3351
- values[column.id] = column.accessorFn(originalRow, rowIndex);
3352
- }
3353
- } // Make the row
3250
+ rows = [];
3354
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
3355
3260
 
3356
- 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
3357
3262
 
3358
- 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
3359
3264
 
3360
- flatRows.push(row); // Also keep track of every row by its ID
3265
+ rowModel.rowsById[row.id] = row; // Push instance row into parent
3361
3266
 
3362
- rowsById[id] = row; // Get the original subrows
3267
+ rows.push(row); // Get the original subrows
3363
3268
 
3364
- if (instance.options.getSubRows) {
3365
- const originalSubRows = instance.options.getSubRows(originalRow, rowIndex); // Then recursively access them
3269
+ if (instance.options.getSubRows) {
3270
+ var _row$originalSubRows;
3366
3271
 
3367
- if (originalSubRows != null && originalSubRows.length) {
3368
- row.originalSubRows = originalSubRows;
3369
- const subRows = [];
3272
+ row.originalSubRows = instance.options.getSubRows(originalRow, i); // Then recursively access them
3370
3273
 
3371
- for (let i = 0; i < row.originalSubRows.length; i++) {
3372
- 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);
3373
3276
  }
3374
-
3375
- row.subRows = subRows;
3376
3277
  }
3377
3278
  }
3378
- };
3379
3279
 
3380
- for (let i = 0; i < data.length; i++) {
3381
- accessRow(data[i], i, 0, rows);
3382
- }
3383
-
3384
- return {
3385
- rows,
3386
- flatRows,
3387
- rowsById
3280
+ return rows;
3388
3281
  };
3282
+
3283
+ rowModel.rows = accessRows(data);
3284
+ return rowModel;
3389
3285
  }, {
3390
3286
  key: 'getRowModel',
3391
3287
  debug: () => {
@@ -3919,7 +3815,7 @@
3919
3815
  return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugTable;
3920
3816
  },
3921
3817
  onChange: () => {
3922
- instance.queue(() => {
3818
+ instance._queue(() => {
3923
3819
  instance._autoResetExpanded();
3924
3820
 
3925
3821
  instance._autoResetPageIndex();