@tanstack/react-table 8.0.0-alpha.73 → 8.0.0-alpha.78

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":"e8ea-127"},{"name":"react-table/src/index.tsx","uid":"e8ea-129"}]}]}],"isRoot":true},"nodeParts":{"e8ea-127":{"renderedLength":139809,"gzipLength":23894,"brotliLength":0,"mainUid":"e8ea-126"},"e8ea-129":{"renderedLength":2102,"gzipLength":836,"brotliLength":0,"mainUid":"e8ea-128"}},"nodeMetas":{"e8ea-126":{"id":"/packages/table-core/build/esm/index.js","moduleParts":{"index.production.js":"e8ea-127"},"imported":[],"importedBy":[{"uid":"e8ea-128"}]},"e8ea-128":{"id":"/packages/react-table/src/index.tsx","moduleParts":{"index.production.js":"e8ea-129"},"imported":[{"uid":"e8ea-130"},{"uid":"e8ea-126"}],"importedBy":[],"isEntry":true},"e8ea-130":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"e8ea-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": "e8ea-132"
15
15
  },
16
16
  {
17
17
  "name": "react-table/src/index.tsx",
18
- "uid": "1ed1-134"
18
+ "uid": "e8ea-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
+ "e8ea-132": {
29
+ "renderedLength": 139809,
30
+ "gzipLength": 23894,
31
31
  "brotliLength": 0,
32
- "mainUid": "1ed1-131"
32
+ "mainUid": "e8ea-131"
33
33
  },
34
- "1ed1-134": {
34
+ "e8ea-134": {
35
35
  "renderedLength": 2102,
36
36
  "gzipLength": 836,
37
37
  "brotliLength": 0,
38
- "mainUid": "1ed1-133"
38
+ "mainUid": "e8ea-133"
39
39
  }
40
40
  },
41
41
  "nodeMetas": {
42
- "1ed1-131": {
42
+ "e8ea-131": {
43
43
  "id": "/packages/table-core/build/esm/index.js",
44
44
  "moduleParts": {
45
- "index.production.js": "1ed1-132"
45
+ "index.production.js": "e8ea-132"
46
46
  },
47
47
  "imported": [],
48
48
  "importedBy": [
49
49
  {
50
- "uid": "1ed1-133"
50
+ "uid": "e8ea-133"
51
51
  }
52
52
  ]
53
53
  },
54
- "1ed1-133": {
54
+ "e8ea-133": {
55
55
  "id": "/packages/react-table/src/index.tsx",
56
56
  "moduleParts": {
57
- "index.production.js": "1ed1-134"
57
+ "index.production.js": "e8ea-134"
58
58
  },
59
59
  "imported": [
60
60
  {
61
- "uid": "1ed1-135"
61
+ "uid": "e8ea-135"
62
62
  },
63
63
  {
64
- "uid": "1ed1-131"
64
+ "uid": "e8ea-131"
65
65
  }
66
66
  ],
67
67
  "importedBy": [],
68
68
  "isEntry": true
69
69
  },
70
- "1ed1-135": {
70
+ "e8ea-135": {
71
71
  "id": "react",
72
72
  "moduleParts": {},
73
73
  "imported": [],
74
74
  "importedBy": [
75
75
  {
76
- "uid": "1ed1-133"
76
+ "uid": "e8ea-133"
77
77
  }
78
78
  ],
79
79
  "isExternal": true
@@ -2704,8 +2704,10 @@
2704
2704
  },
2705
2705
  // Header Groups
2706
2706
  getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2707
- const leftColumns = leafColumns.filter(column => left == null ? void 0 : left.includes(column.id));
2708
- const rightColumns = leafColumns.filter(column => right == null ? void 0 : right.includes(column.id));
2707
+ var _left$map$filter, _right$map$filter;
2708
+
2709
+ const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
2710
+ const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
2709
2711
  const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2710
2712
  const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
2711
2713
  return headerGroups;
@@ -2729,8 +2731,10 @@
2729
2731
  }
2730
2732
  }),
2731
2733
  getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
2732
- leafColumns = leafColumns.filter(column => left == null ? void 0 : left.includes(column.id));
2733
- return buildHeaderGroups(allColumns, leafColumns, instance, 'left');
2734
+ var _left$map$filter2;
2735
+
2736
+ const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
2737
+ return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
2734
2738
  }, {
2735
2739
  key: 'getLeftHeaderGroups',
2736
2740
  debug: () => {
@@ -2740,8 +2744,10 @@
2740
2744
  }
2741
2745
  }),
2742
2746
  getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
2743
- leafColumns = leafColumns.filter(column => right == null ? void 0 : right.includes(column.id));
2744
- return buildHeaderGroups(allColumns, leafColumns, instance, 'right');
2747
+ var _right$map$filter2;
2748
+
2749
+ const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
2750
+ return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
2745
2751
  }, {
2746
2752
  key: 'getRightHeaderGroups',
2747
2753
  debug: () => {
@@ -3052,7 +3058,6 @@
3052
3058
  // data: Batch[]
3053
3059
  // facets: Batch[]
3054
3060
  // }
3055
- // export type TaskPriority = keyof CoreBatches
3056
3061
  function createTableInstance(options) {
3057
3062
  var _options$initialState;
3058
3063
 
@@ -3091,64 +3096,7 @@
3091
3096
  });
3092
3097
 
3093
3098
  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
-
3099
+ let queuedTimeout = false;
3152
3100
  const midInstance = { ...instance,
3153
3101
  // init: () => {
3154
3102
  // startWork()
@@ -3181,39 +3129,6 @@
3181
3129
  }));
3182
3130
  }
3183
3131
  },
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
3132
  reset: () => {
3218
3133
  instance.setState(instance.initialState);
3219
3134
  },
@@ -3324,69 +3239,55 @@
3324
3239
 
3325
3240
  function getCoreRowModel() {
3326
3241
  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();
3242
+ const rowModel = {
3243
+ rows: [],
3244
+ flatRows: [],
3245
+ rowsById: {}
3246
+ };
3247
+ let rows;
3248
+ let row;
3249
+ let originalRow;
3332
3250
 
3333
- const accessRow = function (originalRow, rowIndex, depth, parentRows, parent) {
3251
+ const accessRows = function (originalRows, depth, parent) {
3334
3252
  if (depth === void 0) {
3335
3253
  depth = 0;
3336
3254
  }
3337
3255
 
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
3256
+ rows = [];
3355
3257
 
3258
+ for (let i = 0; i < originalRows.length; i++) {
3259
+ originalRow = originalRows[i]; // This could be an expensive check at scale, so we should move it somewhere else, but where?
3260
+ // if (!id) {
3261
+ // if ("development" !== 'production') {
3262
+ // throw new Error(`getRowId expected an ID, but got ${id}`)
3263
+ // }
3264
+ // }
3265
+ // Make the row
3356
3266
 
3357
- const row = instance.createRow(id, originalRow, rowIndex, depth); // Push instance row into the parentRows array
3267
+ row = instance.createRow(instance.getRowId(originalRow, i, parent), originalRow, i, depth); // Keep track of every row in a flat array
3358
3268
 
3359
- parentRows.push(row); // Keep track of every row in a flat array
3269
+ rowModel.flatRows.push(row); // Also keep track of every row by its ID
3360
3270
 
3361
- flatRows.push(row); // Also keep track of every row by its ID
3271
+ rowModel.rowsById[row.id] = row; // Push instance row into parent
3362
3272
 
3363
- rowsById[id] = row; // Get the original subrows
3273
+ rows.push(row); // Get the original subrows
3364
3274
 
3365
- if (instance.options.getSubRows) {
3366
- const originalSubRows = instance.options.getSubRows(originalRow, rowIndex); // Then recursively access them
3275
+ if (instance.options.getSubRows) {
3276
+ var _row$originalSubRows;
3367
3277
 
3368
- if (originalSubRows != null && originalSubRows.length) {
3369
- row.originalSubRows = originalSubRows;
3370
- const subRows = [];
3278
+ row.originalSubRows = instance.options.getSubRows(originalRow, i); // Then recursively access them
3371
3279
 
3372
- for (let i = 0; i < row.originalSubRows.length; i++) {
3373
- accessRow(row.originalSubRows[i], i, depth + 1, subRows, row);
3280
+ if ((_row$originalSubRows = row.originalSubRows) != null && _row$originalSubRows.length) {
3281
+ row.subRows = accessRows(row.originalSubRows, depth + 1, row);
3374
3282
  }
3375
-
3376
- row.subRows = subRows;
3377
3283
  }
3378
3284
  }
3379
- };
3380
3285
 
3381
- for (let i = 0; i < data.length; i++) {
3382
- accessRow(data[i], i, 0, rows);
3383
- }
3384
-
3385
- return {
3386
- rows,
3387
- flatRows,
3388
- rowsById
3286
+ return rows;
3389
3287
  };
3288
+
3289
+ rowModel.rows = accessRows(data);
3290
+ return rowModel;
3390
3291
  }, {
3391
3292
  key: 'getRowModel',
3392
3293
  debug: () => {