@tanstack/table-core 8.0.0-alpha.55 → 8.0.0-alpha.57

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.
Files changed (74) hide show
  1. package/build/cjs/core.js +9 -384
  2. package/build/cjs/core.js.map +1 -1
  3. package/build/cjs/features/Cells.js +122 -0
  4. package/build/cjs/features/Cells.js.map +1 -0
  5. package/build/cjs/features/ColumnSizing.js +90 -37
  6. package/build/cjs/features/ColumnSizing.js.map +1 -1
  7. package/build/cjs/features/Columns.js +216 -0
  8. package/build/cjs/features/Columns.js.map +1 -0
  9. package/build/cjs/features/Expanding.js +1 -1
  10. package/build/cjs/features/Expanding.js.map +1 -1
  11. package/build/cjs/features/Filters.js +1 -1
  12. package/build/cjs/features/Filters.js.map +1 -1
  13. package/build/cjs/features/Grouping.js +1 -1
  14. package/build/cjs/features/Grouping.js.map +1 -1
  15. package/build/cjs/features/Headers.js +78 -153
  16. package/build/cjs/features/Headers.js.map +1 -1
  17. package/build/cjs/features/Ordering.js +1 -1
  18. package/build/cjs/features/Ordering.js.map +1 -1
  19. package/build/cjs/features/Pagination.js +1 -1
  20. package/build/cjs/features/Pagination.js.map +1 -1
  21. package/build/cjs/features/Pinning.js +172 -2
  22. package/build/cjs/features/Pinning.js.map +1 -1
  23. package/build/cjs/features/RowSelection.js +1 -1
  24. package/build/cjs/features/RowSelection.js.map +1 -1
  25. package/build/cjs/features/Rows.js +99 -0
  26. package/build/cjs/features/Rows.js.map +1 -0
  27. package/build/cjs/features/Sorting.js +1 -1
  28. package/build/cjs/features/Sorting.js.map +1 -1
  29. package/build/cjs/features/Visibility.js +51 -17
  30. package/build/cjs/features/Visibility.js.map +1 -1
  31. package/build/cjs/utils.js.map +1 -1
  32. package/build/esm/index.js +876 -690
  33. package/build/esm/index.js.map +1 -1
  34. package/build/stats-html.html +1 -1
  35. package/build/stats-react.json +418 -316
  36. package/build/types/core.d.ts +2 -79
  37. package/build/types/features/Cells.d.ts +14 -0
  38. package/build/types/features/ColumnSizing.d.ts +23 -15
  39. package/build/types/features/Columns.d.ts +54 -0
  40. package/build/types/features/Expanding.d.ts +1 -1
  41. package/build/types/features/Filters.d.ts +1 -1
  42. package/build/types/features/Grouping.d.ts +1 -1
  43. package/build/types/features/Headers.d.ts +3 -11
  44. package/build/types/features/Ordering.d.ts +1 -1
  45. package/build/types/features/Pagination.d.ts +1 -1
  46. package/build/types/features/Pinning.d.ts +18 -4
  47. package/build/types/features/RowSelection.d.ts +1 -1
  48. package/build/types/features/Rows.d.ts +29 -0
  49. package/build/types/features/Sorting.d.ts +1 -1
  50. package/build/types/features/Visibility.d.ts +7 -2
  51. package/build/types/types.d.ts +18 -10
  52. package/build/types/utils.d.ts +0 -1
  53. package/build/umd/index.development.js +854 -668
  54. package/build/umd/index.development.js.map +1 -1
  55. package/build/umd/index.production.js +1 -1
  56. package/build/umd/index.production.js.map +1 -1
  57. package/package.json +1 -1
  58. package/src/core.ts +28 -550
  59. package/src/features/Cells.ts +156 -0
  60. package/src/features/ColumnSizing.ts +99 -47
  61. package/src/features/Columns.ts +290 -0
  62. package/src/features/Expanding.ts +1 -1
  63. package/src/features/Filters.ts +1 -1
  64. package/src/features/Grouping.ts +1 -1
  65. package/src/features/Headers.ts +48 -138
  66. package/src/features/Ordering.ts +1 -1
  67. package/src/features/Pagination.ts +1 -1
  68. package/src/features/Pinning.ts +194 -3
  69. package/src/features/RowSelection.ts +1 -1
  70. package/src/features/Rows.ts +151 -0
  71. package/src/features/Sorting.ts +1 -1
  72. package/src/features/Visibility.ts +67 -20
  73. package/src/types.ts +25 -37
  74. package/src/utils.ts +1 -3
@@ -361,11 +361,393 @@ function incrementalMemo(getDeps, getInitialValue, schedule, opts) {
361
361
  };
362
362
  } // opts?.onChange?.(result, oldResult)
363
363
 
364
+ //
365
+ var Columns = {
366
+ createInstance: function createInstance(instance) {
367
+ return {
368
+ getDefaultColumn: memo(function () {
369
+ return [instance.options.defaultColumn];
370
+ }, function (defaultColumn) {
371
+ var _defaultColumn;
372
+
373
+ defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
374
+ return _extends({
375
+ header: function header(props) {
376
+ return props.header.column.id;
377
+ },
378
+ footer: function footer(props) {
379
+ return props.header.column.id;
380
+ },
381
+ cell: function cell(_ref) {
382
+ var _ref$value = _ref.value,
383
+ value = _ref$value === void 0 ? '' : _ref$value;
384
+ return typeof value === 'boolean' ? value.toString() : value;
385
+ }
386
+ }, instance._features.reduce(function (obj, feature) {
387
+ return Object.assign(obj, feature.getDefaultColumn == null ? void 0 : feature.getDefaultColumn());
388
+ }, {}), defaultColumn);
389
+ }, {
390
+ debug: function debug() {
391
+ var _instance$options$deb;
392
+
393
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
394
+ },
395
+ key: 'getDefaultColumn'
396
+ }),
397
+ getColumnDefs: function getColumnDefs() {
398
+ return instance.options.columns;
399
+ },
400
+ createColumn: function createColumn(columnDef, depth, parent) {
401
+ var _ref2, _columnDef$id;
402
+
403
+ var defaultColumn = instance.getDefaultColumn();
404
+ var id = (_ref2 = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref2 : typeof columnDef.header === 'string' ? columnDef.header : undefined;
405
+ var accessorFn;
406
+
407
+ if (columnDef.accessorFn) {
408
+ accessorFn = columnDef.accessorFn;
409
+ } else if (columnDef.accessorKey) {
410
+ accessorFn = function accessorFn(originalRow) {
411
+ return originalRow[columnDef.accessorKey];
412
+ };
413
+ }
414
+
415
+ if (!id) {
416
+ if (process.env.NODE_ENV !== 'production') {
417
+ throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
418
+ }
419
+
420
+ throw new Error();
421
+ }
422
+
423
+ var column = _extends({}, defaultColumn, columnDef, {
424
+ id: "" + id,
425
+ accessorFn: accessorFn,
426
+ parent: parent,
427
+ depth: depth,
428
+ columnDef: columnDef,
429
+ columnDefType: columnDef.columnDefType,
430
+ columns: [],
431
+ getFlatColumns: memo(function () {
432
+ return [true];
433
+ }, function () {
434
+ var _column$columns;
435
+
436
+ return [column].concat((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(function (d) {
437
+ return d.getFlatColumns();
438
+ }));
439
+ }, {
440
+ key: 'column.getFlatColumns',
441
+ debug: function debug() {
442
+ var _instance$options$deb2;
443
+
444
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
445
+ }
446
+ }),
447
+ getLeafColumns: memo(function () {
448
+ return [instance._getOrderColumnsFn()];
449
+ }, function (orderColumns) {
450
+ var _column$columns2;
451
+
452
+ if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
453
+ var leafColumns = column.columns.flatMap(function (column) {
454
+ return column.getLeafColumns();
455
+ });
456
+ return orderColumns(leafColumns);
457
+ }
458
+
459
+ return [column];
460
+ }, {
461
+ key: 'column.getLeafColumns',
462
+ debug: function debug() {
463
+ var _instance$options$deb3;
464
+
465
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
466
+ }
467
+ })
468
+ });
469
+
470
+ column = instance._features.reduce(function (obj, feature) {
471
+ return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
472
+ }, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
473
+
474
+ return column;
475
+ },
476
+ getAllColumns: memo(function () {
477
+ return [instance.getColumnDefs()];
478
+ }, function (columnDefs) {
479
+ var recurseColumns = function recurseColumns(columnDefs, parent, depth) {
480
+ if (depth === void 0) {
481
+ depth = 0;
482
+ }
483
+
484
+ return columnDefs.map(function (columnDef) {
485
+ var column = instance.createColumn(columnDef, depth, parent);
486
+ column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
487
+ return column;
488
+ });
489
+ };
490
+
491
+ return recurseColumns(columnDefs);
492
+ }, {
493
+ key: 'getAllColumns',
494
+ debug: function debug() {
495
+ var _instance$options$deb4;
496
+
497
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
498
+ }
499
+ }),
500
+ getAllFlatColumns: memo(function () {
501
+ return [instance.getAllColumns()];
502
+ }, function (allColumns) {
503
+ return allColumns.flatMap(function (column) {
504
+ return column.getFlatColumns();
505
+ });
506
+ }, {
507
+ key: 'getAllFlatColumns',
508
+ debug: function debug() {
509
+ var _instance$options$deb5;
510
+
511
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
512
+ }
513
+ }),
514
+ getAllFlatColumnsById: memo(function () {
515
+ return [instance.getAllFlatColumns()];
516
+ }, function (flatColumns) {
517
+ return flatColumns.reduce(function (acc, column) {
518
+ acc[column.id] = column;
519
+ return acc;
520
+ }, {});
521
+ }, {
522
+ key: 'getAllFlatColumnsById',
523
+ debug: function debug() {
524
+ var _instance$options$deb6;
525
+
526
+ return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugColumns;
527
+ }
528
+ }),
529
+ getAllLeafColumns: memo(function () {
530
+ return [instance.getAllColumns(), instance._getOrderColumnsFn()];
531
+ }, function (allColumns, orderColumns) {
532
+ var leafColumns = allColumns.flatMap(function (column) {
533
+ return column.getLeafColumns();
534
+ });
535
+ return orderColumns(leafColumns);
536
+ }, {
537
+ key: 'getAllLeafColumns',
538
+ debug: function debug() {
539
+ var _instance$options$deb7;
540
+
541
+ return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugColumns;
542
+ }
543
+ }),
544
+ getColumn: function getColumn(columnId) {
545
+ var column = instance.getAllFlatColumnsById()[columnId];
546
+
547
+ if (!column) {
548
+ if (process.env.NODE_ENV !== 'production') {
549
+ console.warn("[Table] Column with id " + columnId + " does not exist.");
550
+ }
551
+
552
+ throw new Error();
553
+ }
554
+
555
+ return column;
556
+ }
557
+ };
558
+ }
559
+ };
560
+
561
+ //
562
+ var Rows = {
563
+ // createRow: <TGenerics extends TableGenerics>(
564
+ // row: Row<TGenerics>,
565
+ // instance: TableInstance<TGenerics>
566
+ // ): CellsRow<TGenerics> => {
567
+ // return {}
568
+ // },
569
+ createInstance: function createInstance(instance) {
570
+ return {
571
+ getRowId: function getRowId(row, index, parent) {
572
+ var _instance$options$get;
573
+
574
+ return (_instance$options$get = instance.options.getRowId == null ? void 0 : instance.options.getRowId(row, index, parent)) != null ? _instance$options$get : "" + (parent ? [parent.id, index].join('.') : index);
575
+ },
576
+ createRow: function createRow(id, original, rowIndex, depth, values) {
577
+ var row = {
578
+ id: id,
579
+ index: rowIndex,
580
+ original: original,
581
+ depth: depth,
582
+ values: values,
583
+ subRows: [],
584
+ getLeafRows: function getLeafRows() {
585
+ return flattenBy(row.subRows, function (d) {
586
+ return d.subRows;
587
+ });
588
+ },
589
+ getRowProps: function getRowProps(userProps) {
590
+ return instance.getRowProps(row.id, userProps);
591
+ }
592
+ };
593
+
594
+ for (var i = 0; i < instance._features.length; i++) {
595
+ var feature = instance._features[i];
596
+ Object.assign(row, feature.createRow == null ? void 0 : feature.createRow(row, instance));
597
+ }
598
+
599
+ return row;
600
+ },
601
+ getCoreRowModel: function getCoreRowModel() {
602
+ if (!instance._getCoreRowModel) {
603
+ instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
604
+ }
605
+
606
+ return instance._getCoreRowModel();
607
+ },
608
+ // The final calls start at the bottom of the model,
609
+ // expanded rows, which then work their way up
610
+ getRowModel: function getRowModel() {
611
+ return instance.getPaginationRowModel();
612
+ },
613
+ getRow: function getRow(id) {
614
+ var row = instance.getRowModel().rowsById[id];
615
+
616
+ if (!row) {
617
+ if (process.env.NODE_ENV !== 'production') {
618
+ throw new Error("getRow expected an ID, but got " + id);
619
+ }
620
+
621
+ throw new Error();
622
+ }
623
+
624
+ return row;
625
+ },
626
+ getRowProps: function getRowProps(rowId, userProps) {
627
+ var row = instance.getRow(rowId);
628
+
629
+ if (!row) {
630
+ return;
631
+ }
632
+
633
+ return propGetter({
634
+ key: row.id,
635
+ role: 'row'
636
+ }, userProps);
637
+ }
638
+ };
639
+ }
640
+ };
641
+
642
+ //
643
+ var Cells = {
644
+ createRow: function createRow(row, instance) {
645
+ return {
646
+ getAllCells: memo(function () {
647
+ return [instance.getAllLeafColumns()];
648
+ }, function (leafColumns) {
649
+ return leafColumns.map(function (column) {
650
+ return instance.createCell(row, column, row.values[column.id]);
651
+ });
652
+ }, {
653
+ key: process.env.NODE_ENV !== 'production' ? 'row.getAllCells' : '',
654
+ debug: function debug() {
655
+ var _instance$options$deb;
656
+
657
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
658
+ }
659
+ }),
660
+ getAllCellsByColumnId: memo(function () {
661
+ return [row.getAllCells()];
662
+ }, function (allCells) {
663
+ return allCells.reduce(function (acc, cell) {
664
+ acc[cell.columnId] = cell;
665
+ return acc;
666
+ }, {});
667
+ }, {
668
+ key: 'row.getAllCellsByColumnId',
669
+ debug: function debug() {
670
+ var _instance$options$deb2;
671
+
672
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
673
+ }
674
+ })
675
+ };
676
+ },
677
+ createInstance: function createInstance(instance) {
678
+ return {
679
+ createCell: function createCell(row, column, value) {
680
+ var cell = {
681
+ id: row.id + "_" + column.id,
682
+ rowId: row.id,
683
+ columnId: column.id,
684
+ row: row,
685
+ column: column,
686
+ value: value,
687
+ getCellProps: function getCellProps(userProps) {
688
+ return instance.getCellProps(row.id, column.id, userProps);
689
+ },
690
+ renderCell: function renderCell() {
691
+ return column.cell ? instance.render(column.cell, {
692
+ instance: instance,
693
+ column: column,
694
+ row: row,
695
+ cell: cell,
696
+ value: value
697
+ }) : null;
698
+ }
699
+ };
700
+
701
+ instance._features.forEach(function (feature) {
702
+ Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
703
+ }, {});
704
+
705
+ return cell;
706
+ },
707
+ getCell: function getCell(rowId, columnId) {
708
+ var row = instance.getRow(rowId);
709
+
710
+ if (!row) {
711
+ if (process.env.NODE_ENV !== 'production') {
712
+ throw new Error("[Table] could not find row with id " + rowId);
713
+ }
714
+
715
+ throw new Error();
716
+ }
717
+
718
+ var cell = row.getAllCellsByColumnId()[columnId];
719
+
720
+ if (!cell) {
721
+ if (process.env.NODE_ENV !== 'production') {
722
+ throw new Error("[Table] could not find cell " + columnId + " in row " + rowId);
723
+ }
724
+
725
+ throw new Error();
726
+ }
727
+
728
+ return cell;
729
+ },
730
+ getCellProps: function getCellProps(rowId, columnId, userProps) {
731
+ var cell = instance.getCell(rowId, columnId);
732
+
733
+ if (!cell) {
734
+ return;
735
+ }
736
+
737
+ return propGetter({
738
+ key: cell.id,
739
+ role: 'gridcell'
740
+ }, userProps);
741
+ }
742
+ };
743
+ }
744
+ };
745
+
364
746
  //
365
747
  var defaultColumnSizing = {
366
- width: 150,
367
- minWidth: 20,
368
- maxWidth: Number.MAX_SAFE_INTEGER
748
+ size: 150,
749
+ minSize: 20,
750
+ maxSize: Number.MAX_SAFE_INTEGER
369
751
  };
370
752
  var ColumnSizing = {
371
753
  getDefaultColumn: function getDefaultColumn() {
@@ -391,10 +773,45 @@ var ColumnSizing = {
391
773
  onColumnSizingInfoChange: makeStateUpdater('columnSizingInfo', instance)
392
774
  };
393
775
  },
394
- getInstance: function getInstance(instance) {
776
+ createColumn: function createColumn(column, instance) {
777
+ return {
778
+ getSize: function getSize() {
779
+ return instance.getColumnSize(column.id);
780
+ },
781
+ getStart: function getStart(position) {
782
+ return instance.getColumnStart(column.id, position);
783
+ },
784
+ getIsResizing: function getIsResizing() {
785
+ return instance.getColumnIsResizing(column.id);
786
+ },
787
+ getCanResize: function getCanResize() {
788
+ return instance.getColumnCanResize(column.id);
789
+ },
790
+ resetSize: function resetSize() {
791
+ return instance.resetColumnSize(column.id);
792
+ }
793
+ };
794
+ },
795
+ createHeader: function createHeader(header, instance) {
796
+ return {
797
+ getIsResizing: function getIsResizing() {
798
+ return instance.getColumnIsResizing(header.column.id);
799
+ },
800
+ getCanResize: function getCanResize() {
801
+ return instance.getColumnCanResize(header.column.id);
802
+ },
803
+ resetSize: function resetSize() {
804
+ return instance.resetColumnSize(header.column.id);
805
+ },
806
+ getResizerProps: function getResizerProps(userProps) {
807
+ return instance.getHeaderResizerProps(header.id, userProps);
808
+ }
809
+ };
810
+ },
811
+ createInstance: function createInstance(instance) {
395
812
  return {
396
- getColumnWidth: function getColumnWidth(columnId) {
397
- var _column$minWidth, _ref, _column$maxWidth;
813
+ getColumnSize: function getColumnSize(columnId) {
814
+ var _column$minSize, _ref, _column$maxSize;
398
815
 
399
816
  var column = instance.getColumn(columnId);
400
817
 
@@ -403,7 +820,26 @@ var ColumnSizing = {
403
820
  }
404
821
 
405
822
  var columnSize = instance.getState().columnSizing[column.id];
406
- return Math.min(Math.max((_column$minWidth = column.minWidth) != null ? _column$minWidth : defaultColumnSizing.minWidth, (_ref = columnSize != null ? columnSize : column.width) != null ? _ref : defaultColumnSizing.width), (_column$maxWidth = column.maxWidth) != null ? _column$maxWidth : defaultColumnSizing.maxWidth);
823
+ return Math.min(Math.max((_column$minSize = column.minSize) != null ? _column$minSize : defaultColumnSizing.minSize, (_ref = columnSize != null ? columnSize : column.size) != null ? _ref : defaultColumnSizing.size), (_column$maxSize = column.maxSize) != null ? _column$maxSize : defaultColumnSizing.maxSize);
824
+ },
825
+ getColumnStart: function getColumnStart(columnId, position) {
826
+ var column = instance.getColumn(columnId);
827
+
828
+ if (!column) {
829
+ throw new Error();
830
+ }
831
+
832
+ var columns = !position ? instance.getVisibleLeafColumns() : position === 'left' ? instance.getLeftVisibleLeafColumns() : instance.getRightVisibleLeafColumns();
833
+ var index = columns.findIndex(function (d) {
834
+ return d.id === columnId;
835
+ });
836
+
837
+ if (index > 0) {
838
+ var prevSiblingColumn = columns[index - 1];
839
+ return instance.getColumnStart(prevSiblingColumn.id, position) + prevSiblingColumn.getSize();
840
+ }
841
+
842
+ return 0;
407
843
  },
408
844
  setColumnSizing: function setColumnSizing(updater) {
409
845
  return instance.options.onColumnSizingChange == null ? void 0 : instance.options.onColumnSizingChange(updater);
@@ -485,10 +921,10 @@ var ColumnSizing = {
485
921
  }
486
922
 
487
923
  var header = headerId ? instance.getHeader(headerId) : undefined;
488
- var startSize = header ? header.getWidth() : column.getWidth();
924
+ var startSize = header ? header.getSize() : column.getSize();
489
925
  var columnSizingStart = header ? header.getLeafHeaders().map(function (d) {
490
- return [d.column.id, d.getWidth()];
491
- }) : [[column.id, column.getWidth()]];
926
+ return [d.column.id, d.getSize()];
927
+ }) : [[column.id, column.getSize()]];
492
928
  var clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
493
929
 
494
930
  var updateOffset = function updateOffset(eventType, clientXPos) {
@@ -504,8 +940,8 @@ var ColumnSizing = {
504
940
  var deltaPercentage = Math.max(deltaOffset / ((_old$startSize = old == null ? void 0 : old.startSize) != null ? _old$startSize : 0), -0.999999);
505
941
  old.columnSizingStart.forEach(function (_ref5) {
506
942
  var columnId = _ref5[0],
507
- headerWidth = _ref5[1];
508
- newColumnSizing[columnId] = Math.round(Math.max(headerWidth + headerWidth * deltaPercentage, 0) * 100) / 100;
943
+ headerSize = _ref5[1];
944
+ newColumnSizing[columnId] = Math.round(Math.max(headerSize + headerSize * deltaPercentage, 0) * 100) / 100;
509
945
  });
510
946
  return _extends({}, old, {
511
947
  deltaOffset: deltaOffset,
@@ -608,35 +1044,34 @@ var ColumnSizing = {
608
1044
  }
609
1045
  } : {};
610
1046
  return propGetter(initialProps, userProps);
611
- }
612
- };
613
- },
614
- createColumn: function createColumn(column, instance) {
615
- return {
616
- getIsResizing: function getIsResizing() {
617
- return instance.getColumnIsResizing(column.id);
618
1047
  },
619
- getCanResize: function getCanResize() {
620
- return instance.getColumnCanResize(column.id);
621
- },
622
- resetSize: function resetSize() {
623
- return instance.resetColumnSize(column.id);
624
- }
625
- };
626
- },
627
- createHeader: function createHeader(header, instance) {
628
- return {
629
- getIsResizing: function getIsResizing() {
630
- return instance.getColumnIsResizing(header.column.id);
1048
+ getTotalSize: function getTotalSize() {
1049
+ var _instance$getHeaderGr, _instance$getHeaderGr2;
1050
+
1051
+ return (_instance$getHeaderGr = (_instance$getHeaderGr2 = instance.getHeaderGroups()[0]) == null ? void 0 : _instance$getHeaderGr2.headers.reduce(function (sum, header) {
1052
+ return sum + header.getSize();
1053
+ }, 0)) != null ? _instance$getHeaderGr : 0;
631
1054
  },
632
- getCanResize: function getCanResize() {
633
- return instance.getColumnCanResize(header.column.id);
1055
+ getLeftTotalSize: function getLeftTotalSize() {
1056
+ var _instance$getLeftHead, _instance$getLeftHead2;
1057
+
1058
+ return (_instance$getLeftHead = (_instance$getLeftHead2 = instance.getLeftHeaderGroups()[0]) == null ? void 0 : _instance$getLeftHead2.headers.reduce(function (sum, header) {
1059
+ return sum + header.getSize();
1060
+ }, 0)) != null ? _instance$getLeftHead : 0;
634
1061
  },
635
- resetSize: function resetSize() {
636
- return instance.resetColumnSize(header.column.id);
1062
+ getCenterTotalSize: function getCenterTotalSize() {
1063
+ var _instance$getCenterHe, _instance$getCenterHe2;
1064
+
1065
+ return (_instance$getCenterHe = (_instance$getCenterHe2 = instance.getCenterHeaderGroups()[0]) == null ? void 0 : _instance$getCenterHe2.headers.reduce(function (sum, header) {
1066
+ return sum + header.getSize();
1067
+ }, 0)) != null ? _instance$getCenterHe : 0;
637
1068
  },
638
- getResizerProps: function getResizerProps(userProps) {
639
- return instance.getHeaderResizerProps(header.id, userProps);
1069
+ getRightTotalSize: function getRightTotalSize() {
1070
+ var _instance$getRightHea, _instance$getRightHea2;
1071
+
1072
+ return (_instance$getRightHea = (_instance$getRightHea2 = instance.getRightHeaderGroups()[0]) == null ? void 0 : _instance$getRightHea2.headers.reduce(function (sum, header) {
1073
+ return sum + header.getSize();
1074
+ }, 0)) != null ? _instance$getRightHea : 0;
640
1075
  }
641
1076
  };
642
1077
  }
@@ -686,7 +1121,7 @@ var Expanding = {
686
1121
  paginateExpandedRows: true
687
1122
  };
688
1123
  },
689
- getInstance: function getInstance(instance) {
1124
+ createInstance: function createInstance(instance) {
690
1125
  var registered = false;
691
1126
  return {
692
1127
  queueResetExpanded: function queueResetExpanded() {
@@ -1145,7 +1580,7 @@ var Filters = {
1145
1580
  }
1146
1581
  };
1147
1582
  },
1148
- getInstance: function getInstance(instance) {
1583
+ createInstance: function createInstance(instance) {
1149
1584
  var registered = false;
1150
1585
  return {
1151
1586
  queueResetFilters: function queueResetFilters() {
@@ -1527,7 +1962,7 @@ var Grouping = {
1527
1962
  }
1528
1963
  };
1529
1964
  },
1530
- getInstance: function getInstance(instance) {
1965
+ createInstance: function createInstance(instance) {
1531
1966
  var registered = false;
1532
1967
  return {
1533
1968
  queueResetGrouping: function queueResetGrouping() {
@@ -1713,7 +2148,7 @@ var Ordering = {
1713
2148
  onColumnOrderChange: makeStateUpdater('columnOrder', instance)
1714
2149
  };
1715
2150
  },
1716
- getInstance: function getInstance(instance) {
2151
+ createInstance: function createInstance(instance) {
1717
2152
  return {
1718
2153
  setColumnOrder: function setColumnOrder(updater) {
1719
2154
  return instance.options.onColumnOrderChange == null ? void 0 : instance.options.onColumnOrderChange(updater);
@@ -1785,7 +2220,7 @@ var Pagination = {
1785
2220
  autoResetPageIndex: true
1786
2221
  };
1787
2222
  },
1788
- getInstance: function getInstance(instance) {
2223
+ createInstance: function createInstance(instance) {
1789
2224
  var registered = false;
1790
2225
  return {
1791
2226
  queueResetPageIndex: function queueResetPageIndex() {
@@ -1916,57 +2351,179 @@ var Pagination = {
1916
2351
  instance._getPaginationRowModel = instance.options.getPaginationRowModel(instance);
1917
2352
  }
1918
2353
 
1919
- if (!instance._getPaginationRowModel) {
1920
- return instance.getPrePaginationRowModel();
2354
+ if (!instance._getPaginationRowModel) {
2355
+ return instance.getPrePaginationRowModel();
2356
+ }
2357
+
2358
+ return instance._getPaginationRowModel();
2359
+ },
2360
+ getPageCount: function getPageCount() {
2361
+ var pageCount = instance.getState().pagination.pageCount;
2362
+
2363
+ if (pageCount > 0) {
2364
+ return pageCount;
2365
+ }
2366
+
2367
+ return Math.ceil(instance.getPrePaginationRowModel().rows.length / instance.getState().pagination.pageSize);
2368
+ }
2369
+ };
2370
+ }
2371
+ };
2372
+
2373
+ //
2374
+ var Pinning = {
2375
+ getInitialState: function getInitialState() {
2376
+ return {
2377
+ columnPinning: {
2378
+ left: [],
2379
+ right: []
2380
+ }
2381
+ };
2382
+ },
2383
+ getDefaultOptions: function getDefaultOptions(instance) {
2384
+ return {
2385
+ onColumnPinningChange: makeStateUpdater('columnPinning', instance)
2386
+ };
2387
+ },
2388
+ createColumn: function createColumn(column, instance) {
2389
+ return {
2390
+ getCanPin: function getCanPin() {
2391
+ return instance.getColumnCanPin(column.id);
2392
+ },
2393
+ getPinnedIndex: function getPinnedIndex() {
2394
+ return instance.getColumnPinnedIndex(column.id);
2395
+ },
2396
+ getIsPinned: function getIsPinned() {
2397
+ return instance.getColumnIsPinned(column.id);
2398
+ },
2399
+ pin: function pin(position) {
2400
+ return instance.pinColumn(column.id, position);
2401
+ }
2402
+ };
2403
+ },
2404
+ createRow: function createRow(row, instance) {
2405
+ return {
2406
+ getCenterVisibleCells: memo(function () {
2407
+ return [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
2408
+ }, function (allCells, left, right) {
2409
+ var leftAndRight = [].concat(left != null ? left : [], right != null ? right : []);
2410
+ return allCells.filter(function (d) {
2411
+ return !leftAndRight.includes(d.columnId);
2412
+ });
2413
+ }, {
2414
+ key: 'row.getCenterVisibleCells',
2415
+ debug: function debug() {
2416
+ var _instance$options$deb;
2417
+
2418
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
2419
+ }
2420
+ }),
2421
+ getLeftVisibleCells: memo(function () {
2422
+ return [row._getAllVisibleCells(), instance.getState().columnPinning.left,,];
2423
+ }, function (allCells, left) {
2424
+ var cells = (left != null ? left : []).map(function (columnId) {
2425
+ return allCells.find(function (cell) {
2426
+ return cell.columnId === columnId;
2427
+ });
2428
+ }).filter(Boolean).map(function (d) {
2429
+ return _extends({}, d, {
2430
+ position: 'left'
2431
+ });
2432
+ });
2433
+ return cells;
2434
+ }, {
2435
+ key: 'row.getLeftVisibleCells',
2436
+ debug: function debug() {
2437
+ var _instance$options$deb2;
2438
+
2439
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
2440
+ }
2441
+ }),
2442
+ getRightVisibleCells: memo(function () {
2443
+ return [row._getAllVisibleCells(), instance.getState().columnPinning.right];
2444
+ }, function (allCells, right) {
2445
+ var cells = (right != null ? right : []).map(function (columnId) {
2446
+ return allCells.find(function (cell) {
2447
+ return cell.columnId === columnId;
2448
+ });
2449
+ }).filter(Boolean).map(function (d) {
2450
+ return _extends({}, d, {
2451
+ position: 'left'
2452
+ });
2453
+ });
2454
+ return cells;
2455
+ }, {
2456
+ key: 'row.getRightVisibleCells',
2457
+ debug: function debug() {
2458
+ var _instance$options$deb3;
2459
+
2460
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugRows;
2461
+ }
2462
+ })
2463
+ };
2464
+ },
2465
+ createCell: function createCell(cell, instance) {
2466
+ return {
2467
+ getCenterVisibleCells: memo(function () {
2468
+ return [cell.row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
2469
+ }, function (allCells, left, right) {
2470
+ var leftAndRight = [].concat(left != null ? left : [], right != null ? right : []);
2471
+ return allCells.filter(function (d) {
2472
+ return !leftAndRight.includes(d.columnId);
2473
+ });
2474
+ }, {
2475
+ key: 'row.getCenterVisibleCells',
2476
+ debug: function debug() {
2477
+ var _instance$options$deb4;
2478
+
2479
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugRows;
2480
+ }
2481
+ }),
2482
+ getLeftVisibleCells: memo(function () {
2483
+ return [cell.row._getAllVisibleCells(), instance.getState().columnPinning.left,,];
2484
+ }, function (allCells, left) {
2485
+ var cells = (left != null ? left : []).map(function (columnId) {
2486
+ return allCells.find(function (cell) {
2487
+ return cell.columnId === columnId;
2488
+ });
2489
+ }).filter(Boolean).map(function (d) {
2490
+ return _extends({}, d, {
2491
+ position: 'left'
2492
+ });
2493
+ });
2494
+ return cells;
2495
+ }, {
2496
+ key: 'row.getLeftVisibleCells',
2497
+ debug: function debug() {
2498
+ var _instance$options$deb5;
2499
+
2500
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugRows;
1921
2501
  }
2502
+ }),
2503
+ getRightVisibleCells: memo(function () {
2504
+ return [cell.row._getAllVisibleCells(), instance.getState().columnPinning.right];
2505
+ }, function (allCells, right) {
2506
+ var cells = (right != null ? right : []).map(function (columnId) {
2507
+ return allCells.find(function (cell) {
2508
+ return cell.columnId === columnId;
2509
+ });
2510
+ }).filter(Boolean).map(function (d) {
2511
+ return _extends({}, d, {
2512
+ position: 'left'
2513
+ });
2514
+ });
2515
+ return cells;
2516
+ }, {
2517
+ key: 'row.getRightVisibleCells',
2518
+ debug: function debug() {
2519
+ var _instance$options$deb6;
1922
2520
 
1923
- return instance._getPaginationRowModel();
1924
- },
1925
- getPageCount: function getPageCount() {
1926
- var pageCount = instance.getState().pagination.pageCount;
1927
-
1928
- if (pageCount > 0) {
1929
- return pageCount;
2521
+ return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugRows;
1930
2522
  }
1931
-
1932
- return Math.ceil(instance.getPrePaginationRowModel().rows.length / instance.getState().pagination.pageSize);
1933
- }
1934
- };
1935
- }
1936
- };
1937
-
1938
- //
1939
- var Pinning = {
1940
- getInitialState: function getInitialState() {
1941
- return {
1942
- columnPinning: {
1943
- left: [],
1944
- right: []
1945
- }
1946
- };
1947
- },
1948
- getDefaultOptions: function getDefaultOptions(instance) {
1949
- return {
1950
- onColumnPinningChange: makeStateUpdater('columnPinning', instance)
1951
- };
1952
- },
1953
- createColumn: function createColumn(column, instance) {
1954
- return {
1955
- getCanPin: function getCanPin() {
1956
- return instance.getColumnCanPin(column.id);
1957
- },
1958
- getPinnedIndex: function getPinnedIndex() {
1959
- return instance.getColumnPinnedIndex(column.id);
1960
- },
1961
- getIsPinned: function getIsPinned() {
1962
- return instance.getColumnIsPinned(column.id);
1963
- },
1964
- pin: function pin(position) {
1965
- return instance.pinColumn(column.id, position);
1966
- }
2523
+ })
1967
2524
  };
1968
2525
  },
1969
- getInstance: function getInstance(instance) {
2526
+ createInstance: function createInstance(instance) {
1970
2527
  return {
1971
2528
  setColumnPinning: function setColumnPinning(updater) {
1972
2529
  return instance.options.onColumnPinningChange == null ? void 0 : instance.options.onColumnPinningChange(updater);
@@ -2066,7 +2623,54 @@ var Pinning = {
2066
2623
  left = _instance$getState$co5.left,
2067
2624
  right = _instance$getState$co5.right;
2068
2625
  return Boolean((left == null ? void 0 : left.length) || (right == null ? void 0 : right.length));
2069
- }
2626
+ },
2627
+ getLeftLeafColumns: memo(function () {
2628
+ return [instance.getAllLeafColumns(), instance.getState().columnPinning.left];
2629
+ }, function (allColumns, left) {
2630
+ return (left != null ? left : []).map(function (columnId) {
2631
+ return allColumns.find(function (column) {
2632
+ return column.id === columnId;
2633
+ });
2634
+ }).filter(Boolean);
2635
+ }, {
2636
+ key: 'getLeftLeafColumns',
2637
+ debug: function debug() {
2638
+ var _instance$options$deb7;
2639
+
2640
+ return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugColumns;
2641
+ }
2642
+ }),
2643
+ getRightLeafColumns: memo(function () {
2644
+ return [instance.getAllLeafColumns(), instance.getState().columnPinning.right];
2645
+ }, function (allColumns, right) {
2646
+ return (right != null ? right : []).map(function (columnId) {
2647
+ return allColumns.find(function (column) {
2648
+ return column.id === columnId;
2649
+ });
2650
+ }).filter(Boolean);
2651
+ }, {
2652
+ key: 'getRightLeafColumns',
2653
+ debug: function debug() {
2654
+ var _instance$options$deb8;
2655
+
2656
+ return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugColumns;
2657
+ }
2658
+ }),
2659
+ getCenterLeafColumns: memo(function () {
2660
+ return [instance.getAllLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
2661
+ }, function (allColumns, left, right) {
2662
+ var leftAndRight = [].concat(left != null ? left : [], right != null ? right : []);
2663
+ return allColumns.filter(function (d) {
2664
+ return !leftAndRight.includes(d.id);
2665
+ });
2666
+ }, {
2667
+ key: 'getCenterLeafColumns',
2668
+ debug: function debug() {
2669
+ var _instance$options$deb9;
2670
+
2671
+ return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugColumns;
2672
+ }
2673
+ })
2070
2674
  };
2071
2675
  }
2072
2676
  };
@@ -2090,7 +2694,7 @@ var RowSelection = {
2090
2694
 
2091
2695
  };
2092
2696
  },
2093
- getInstance: function getInstance(instance) {
2697
+ createInstance: function createInstance(instance) {
2094
2698
  var registered = false; // const pageRows = instance.getPageRows()
2095
2699
 
2096
2700
  return {
@@ -2733,7 +3337,7 @@ var Sorting = {
2733
3337
  }
2734
3338
  };
2735
3339
  },
2736
- getInstance: function getInstance(instance) {
3340
+ createInstance: function createInstance(instance) {
2737
3341
  var registered = false;
2738
3342
  return {
2739
3343
  queueResetSorting: function queueResetSorting() {
@@ -3025,43 +3629,77 @@ var Visibility = {
3025
3629
  }
3026
3630
  };
3027
3631
  },
3028
- getInstance: function getInstance(instance) {
3632
+ createRow: function createRow(row, instance) {
3029
3633
  return {
3030
- getVisibleFlatColumns: memo(function () {
3031
- return [instance.getAllFlatColumns(), instance.getAllFlatColumns().filter(function (d) {
3032
- return d.getIsVisible == null ? void 0 : d.getIsVisible();
3634
+ _getAllVisibleCells: memo(function () {
3635
+ return [row.getAllCells().filter(function (cell) {
3636
+ return cell.column.getIsVisible();
3033
3637
  }).map(function (d) {
3034
3638
  return d.id;
3035
3639
  }).join('_')];
3036
- }, function (allFlatColumns) {
3037
- return allFlatColumns.filter(function (d) {
3038
- return d.getIsVisible == null ? void 0 : d.getIsVisible();
3640
+ }, function (_) {
3641
+ return row.getAllCells().filter(function (cell) {
3642
+ return cell.column.getIsVisible();
3039
3643
  });
3040
3644
  }, {
3041
- key: 'getVisibleFlatColumns',
3645
+ key: 'row._getAllVisibleCells',
3042
3646
  debug: function debug() {
3043
3647
  var _instance$options$deb;
3044
3648
 
3045
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
3649
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
3046
3650
  }
3047
3651
  }),
3048
- getVisibleLeafColumns: memo(function () {
3049
- return [instance.getAllLeafColumns(), instance.getAllLeafColumns().filter(function (d) {
3050
- return d.getIsVisible == null ? void 0 : d.getIsVisible();
3652
+ getVisibleCells: memo(function () {
3653
+ return [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()];
3654
+ }, function (left, center, right) {
3655
+ return [].concat(left, center, right);
3656
+ }, {
3657
+ key: 'row.getVisibleCells',
3658
+ debug: function debug() {
3659
+ var _instance$options$deb2;
3660
+
3661
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
3662
+ }
3663
+ })
3664
+ };
3665
+ },
3666
+ createInstance: function createInstance(instance) {
3667
+ var makeVisibleColumnsMethod = function makeVisibleColumnsMethod(key, getColumns) {
3668
+ return memo(function () {
3669
+ return [getColumns(), getColumns().filter(function (d) {
3670
+ return d.getIsVisible();
3051
3671
  }).map(function (d) {
3052
3672
  return d.id;
3053
3673
  }).join('_')];
3054
- }, function (allFlatColumns) {
3055
- return allFlatColumns.filter(function (d) {
3674
+ }, function (columns) {
3675
+ return columns.filter(function (d) {
3056
3676
  return d.getIsVisible == null ? void 0 : d.getIsVisible();
3057
3677
  });
3058
3678
  }, {
3059
- key: 'getVisibleLeafColumns',
3679
+ key: key,
3060
3680
  debug: function debug() {
3061
- var _instance$options$deb2;
3681
+ var _instance$options$deb3;
3062
3682
 
3063
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
3683
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
3064
3684
  }
3685
+ });
3686
+ };
3687
+
3688
+ return {
3689
+ getVisibleFlatColumns: makeVisibleColumnsMethod('getVisibleFlatColumns', function () {
3690
+ return instance.getAllFlatColumns();
3691
+ }),
3692
+ getVisibleLeafColumns: makeVisibleColumnsMethod('getVisibleLeafColumns', function () {
3693
+ return instance.getAllLeafColumns();
3694
+ }),
3695
+ getLeftVisibleLeafColumns: makeVisibleColumnsMethod('getLeftVisibleLeafColumns', function () {
3696
+ return instance.getLeftLeafColumns();
3697
+ }),
3698
+ getRightVisibleLeafColumns: makeVisibleColumnsMethod('getRightVisibleLeafColumns', function () {
3699
+ return instance.getRightLeafColumns();
3700
+ }),
3701
+ getCenterVisibleLeafColumns: makeVisibleColumnsMethod('getCenterVisibleLeafColumns', function () {
3702
+ return instance.getCenterLeafColumns();
3065
3703
  }),
3066
3704
  setColumnVisibility: function setColumnVisibility(updater) {
3067
3705
  return instance.options.onColumnVisibilityChange == null ? void 0 : instance.options.onColumnVisibilityChange(updater);
@@ -3090,139 +3728,56 @@ var Visibility = {
3090
3728
  getColumnIsVisible: function getColumnIsVisible(columnId) {
3091
3729
  var _ref, _instance$getState$co, _instance$getState$co2;
3092
3730
 
3093
- var column = instance.getColumn(columnId);
3094
-
3095
- if (!column) {
3096
- throw new Error();
3097
- }
3098
-
3099
- return (_ref = (_instance$getState$co = (_instance$getState$co2 = instance.getState().columnVisibility) == null ? void 0 : _instance$getState$co2[columnId]) != null ? _instance$getState$co : column.defaultIsVisible) != null ? _ref : true;
3100
- },
3101
- getColumnCanHide: function getColumnCanHide(columnId) {
3102
- var _ref2, _ref3, _instance$options$ena;
3103
-
3104
- var column = instance.getColumn(columnId);
3105
-
3106
- if (!column) {
3107
- throw new Error();
3108
- }
3109
-
3110
- return (_ref2 = (_ref3 = (_instance$options$ena = instance.options.enableHiding) != null ? _instance$options$ena : column.enableHiding) != null ? _ref3 : column.defaultCanHide) != null ? _ref2 : true;
3111
- },
3112
- getIsAllColumnsVisible: function getIsAllColumnsVisible() {
3113
- return !instance.getAllLeafColumns().some(function (column) {
3114
- return !(column.getIsVisible != null && column.getIsVisible());
3115
- });
3116
- },
3117
- getIsSomeColumnsVisible: function getIsSomeColumnsVisible() {
3118
- return instance.getAllLeafColumns().some(function (column) {
3119
- return column.getIsVisible == null ? void 0 : column.getIsVisible();
3120
- });
3121
- },
3122
- getToggleAllColumnsVisibilityProps: function getToggleAllColumnsVisibilityProps(userProps) {
3123
- var props = {
3124
- onChange: function onChange(e) {
3125
- var _e$target;
3126
-
3127
- instance.toggleAllColumnsVisible((_e$target = e.target) == null ? void 0 : _e$target.checked);
3128
- },
3129
- type: 'checkbox',
3130
- title: 'Toggle visibility for all columns',
3131
- checked: instance.getIsAllColumnsVisible(),
3132
- indeterminate: !instance.getIsAllColumnsVisible() && instance.getIsSomeColumnsVisible() ? 'indeterminate' : undefined
3133
- };
3134
- return propGetter(props, userProps);
3135
- }
3136
- };
3137
- }
3138
- };
3139
-
3140
- //
3141
- var Headers = {
3142
- createRow: function createRow(row, instance) {
3143
- return {
3144
- _getAllVisibleCells: memo(function () {
3145
- return [row.getAllCells().filter(function (cell) {
3146
- return cell.column.getIsVisible();
3147
- }).map(function (d) {
3148
- return d.id;
3149
- }).join('_')];
3150
- }, function (_) {
3151
- return row.getAllCells().filter(function (cell) {
3152
- return cell.column.getIsVisible();
3153
- });
3154
- }, {
3155
- key: 'row._getAllVisibleCells',
3156
- debug: function debug() {
3157
- var _instance$options$deb;
3158
-
3159
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
3160
- }
3161
- }),
3162
- getVisibleCells: memo(function () {
3163
- return [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()];
3164
- }, function (left, center, right) {
3165
- return [].concat(left, center, right);
3166
- }, {
3167
- key: 'row.getVisibleCells',
3168
- debug: function debug() {
3169
- var _instance$options$deb2;
3170
-
3171
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
3172
- }
3173
- }),
3174
- getCenterVisibleCells: memo(function () {
3175
- return [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
3176
- }, function (allCells, left, right) {
3177
- var leftAndRight = [].concat(left != null ? left : [], right != null ? right : []);
3178
- return allCells.filter(function (d) {
3179
- return !leftAndRight.includes(d.columnId);
3180
- });
3181
- }, {
3182
- key: 'row.getCenterVisibleCells',
3183
- debug: function debug() {
3184
- var _instance$options$deb3;
3185
-
3186
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugRows;
3187
- }
3188
- }),
3189
- getLeftVisibleCells: memo(function () {
3190
- return [row._getAllVisibleCells(), instance.getState().columnPinning.left,,];
3191
- }, function (allCells, left) {
3192
- var cells = (left != null ? left : []).map(function (columnId) {
3193
- return allCells.find(function (cell) {
3194
- return cell.columnId === columnId;
3195
- });
3196
- }).filter(Boolean);
3197
- return cells;
3198
- }, {
3199
- key: 'row.getLeftVisibleCells',
3200
- debug: function debug() {
3201
- var _instance$options$deb4;
3202
-
3203
- return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugRows;
3204
- }
3205
- }),
3206
- getRightVisibleCells: memo(function () {
3207
- return [row._getAllVisibleCells(), instance.getState().columnPinning.right];
3208
- }, function (allCells, right) {
3209
- var cells = (right != null ? right : []).map(function (columnId) {
3210
- return allCells.find(function (cell) {
3211
- return cell.columnId === columnId;
3212
- });
3213
- }).filter(Boolean);
3214
- return cells;
3215
- }, {
3216
- key: 'row.getRightVisibleCells',
3217
- debug: function debug() {
3218
- var _instance$options$deb5;
3731
+ var column = instance.getColumn(columnId);
3219
3732
 
3220
- return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugRows;
3733
+ if (!column) {
3734
+ throw new Error();
3221
3735
  }
3222
- })
3736
+
3737
+ return (_ref = (_instance$getState$co = (_instance$getState$co2 = instance.getState().columnVisibility) == null ? void 0 : _instance$getState$co2[columnId]) != null ? _instance$getState$co : column.defaultIsVisible) != null ? _ref : true;
3738
+ },
3739
+ getColumnCanHide: function getColumnCanHide(columnId) {
3740
+ var _ref2, _ref3, _instance$options$ena;
3741
+
3742
+ var column = instance.getColumn(columnId);
3743
+
3744
+ if (!column) {
3745
+ throw new Error();
3746
+ }
3747
+
3748
+ return (_ref2 = (_ref3 = (_instance$options$ena = instance.options.enableHiding) != null ? _instance$options$ena : column.enableHiding) != null ? _ref3 : column.defaultCanHide) != null ? _ref2 : true;
3749
+ },
3750
+ getIsAllColumnsVisible: function getIsAllColumnsVisible() {
3751
+ return !instance.getAllLeafColumns().some(function (column) {
3752
+ return !(column.getIsVisible != null && column.getIsVisible());
3753
+ });
3754
+ },
3755
+ getIsSomeColumnsVisible: function getIsSomeColumnsVisible() {
3756
+ return instance.getAllLeafColumns().some(function (column) {
3757
+ return column.getIsVisible == null ? void 0 : column.getIsVisible();
3758
+ });
3759
+ },
3760
+ getToggleAllColumnsVisibilityProps: function getToggleAllColumnsVisibilityProps(userProps) {
3761
+ var props = {
3762
+ onChange: function onChange(e) {
3763
+ var _e$target;
3764
+
3765
+ instance.toggleAllColumnsVisible((_e$target = e.target) == null ? void 0 : _e$target.checked);
3766
+ },
3767
+ type: 'checkbox',
3768
+ title: 'Toggle visibility for all columns',
3769
+ checked: instance.getIsAllColumnsVisible(),
3770
+ indeterminate: !instance.getIsAllColumnsVisible() && instance.getIsSomeColumnsVisible() ? 'indeterminate' : undefined
3771
+ };
3772
+ return propGetter(props, userProps);
3773
+ }
3223
3774
  };
3224
- },
3225
- getInstance: function getInstance(instance) {
3775
+ }
3776
+ };
3777
+
3778
+ //
3779
+ var Headers = {
3780
+ createInstance: function createInstance(instance) {
3226
3781
  return {
3227
3782
  createHeader: function createHeader(column, options) {
3228
3783
  var _options$id;
@@ -3231,28 +3786,38 @@ var Headers = {
3231
3786
  var header = {
3232
3787
  id: id,
3233
3788
  column: column,
3789
+ index: options.index,
3234
3790
  isPlaceholder: options.isPlaceholder,
3235
3791
  placeholderId: options.placeholderId,
3236
3792
  depth: options.depth,
3237
3793
  subHeaders: [],
3238
3794
  colSpan: 0,
3239
3795
  rowSpan: 0,
3240
- getWidth: function getWidth() {
3796
+ headerGroup: null,
3797
+ getSize: function getSize() {
3241
3798
  var sum = 0;
3242
3799
 
3243
3800
  var recurse = function recurse(header) {
3244
3801
  if (header.subHeaders.length) {
3245
3802
  header.subHeaders.forEach(recurse);
3246
3803
  } else {
3247
- var _header$column$getWid;
3804
+ var _header$column$getSiz;
3248
3805
 
3249
- sum += (_header$column$getWid = header.column.getWidth()) != null ? _header$column$getWid : 0;
3806
+ sum += (_header$column$getSiz = header.column.getSize()) != null ? _header$column$getSiz : 0;
3250
3807
  }
3251
3808
  };
3252
3809
 
3253
3810
  recurse(header);
3254
3811
  return sum;
3255
3812
  },
3813
+ getStart: function getStart() {
3814
+ if (header.index > 0) {
3815
+ var prevSiblingHeader = header.headerGroup.headers[header.index - 1];
3816
+ return prevSiblingHeader.getStart() + prevSiblingHeader.getSize();
3817
+ }
3818
+
3819
+ return 0;
3820
+ },
3256
3821
  getLeafHeaders: function getLeafHeaders() {
3257
3822
  var leafHeaders = [];
3258
3823
 
@@ -3287,9 +3852,13 @@ var Headers = {
3287
3852
  column: column
3288
3853
  }) : null;
3289
3854
  }
3290
- }; // Yes, we have to convert instance to unknown, because we know more than the compiler here.
3855
+ };
3856
+
3857
+ instance._features.forEach(function (feature) {
3858
+ Object.assign(header, feature.createHeader == null ? void 0 : feature.createHeader(header, instance));
3859
+ });
3291
3860
 
3292
- return Object.assign(header, ColumnSizing.createHeader(header, instance));
3861
+ return header;
3293
3862
  },
3294
3863
  // Header Groups
3295
3864
  getHeaderGroups: memo(function () {
@@ -3309,9 +3878,9 @@ var Headers = {
3309
3878
  }, {
3310
3879
  key: 'getHeaderGroups',
3311
3880
  debug: function debug() {
3312
- var _instance$options$deb6;
3881
+ var _instance$options$deb;
3313
3882
 
3314
- return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
3883
+ return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugHeaders;
3315
3884
  }
3316
3885
  }),
3317
3886
  getCenterHeaderGroups: memo(function () {
@@ -3324,9 +3893,9 @@ var Headers = {
3324
3893
  }, {
3325
3894
  key: 'getCenterHeaderGroups',
3326
3895
  debug: function debug() {
3327
- var _instance$options$deb7;
3896
+ var _instance$options$deb2;
3328
3897
 
3329
- return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
3898
+ return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugHeaders;
3330
3899
  }
3331
3900
  }),
3332
3901
  getLeftHeaderGroups: memo(function () {
@@ -3339,9 +3908,9 @@ var Headers = {
3339
3908
  }, {
3340
3909
  key: 'getLeftHeaderGroups',
3341
3910
  debug: function debug() {
3342
- var _instance$options$deb8;
3911
+ var _instance$options$deb3;
3343
3912
 
3344
- return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
3913
+ return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugHeaders;
3345
3914
  }
3346
3915
  }),
3347
3916
  getRightHeaderGroups: memo(function () {
@@ -3354,9 +3923,9 @@ var Headers = {
3354
3923
  }, {
3355
3924
  key: 'getRightHeaderGroups',
3356
3925
  debug: function debug() {
3357
- var _instance$options$deb9;
3926
+ var _instance$options$deb4;
3358
3927
 
3359
- return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
3928
+ return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugHeaders;
3360
3929
  }
3361
3930
  }),
3362
3931
  // Footer Groups
@@ -3367,9 +3936,9 @@ var Headers = {
3367
3936
  }, {
3368
3937
  key: 'getFooterGroups',
3369
3938
  debug: function debug() {
3370
- var _instance$options$deb10;
3939
+ var _instance$options$deb5;
3371
3940
 
3372
- return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
3941
+ return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugHeaders;
3373
3942
  }
3374
3943
  }),
3375
3944
  getLeftFooterGroups: memo(function () {
@@ -3379,9 +3948,9 @@ var Headers = {
3379
3948
  }, {
3380
3949
  key: 'getLeftFooterGroups',
3381
3950
  debug: function debug() {
3382
- var _instance$options$deb11;
3951
+ var _instance$options$deb6;
3383
3952
 
3384
- return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
3953
+ return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
3385
3954
  }
3386
3955
  }),
3387
3956
  getCenterFooterGroups: memo(function () {
@@ -3391,9 +3960,9 @@ var Headers = {
3391
3960
  }, {
3392
3961
  key: 'getCenterFooterGroups',
3393
3962
  debug: function debug() {
3394
- var _instance$options$deb12;
3963
+ var _instance$options$deb7;
3395
3964
 
3396
- return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
3965
+ return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
3397
3966
  }
3398
3967
  }),
3399
3968
  getRightFooterGroups: memo(function () {
@@ -3403,9 +3972,9 @@ var Headers = {
3403
3972
  }, {
3404
3973
  key: 'getRightFooterGroups',
3405
3974
  debug: function debug() {
3406
- var _instance$options$deb13;
3975
+ var _instance$options$deb8;
3407
3976
 
3408
- return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
3977
+ return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
3409
3978
  }
3410
3979
  }),
3411
3980
  // Flat Headers
@@ -3418,9 +3987,9 @@ var Headers = {
3418
3987
  }, {
3419
3988
  key: 'getFlatHeaders',
3420
3989
  debug: function debug() {
3421
- var _instance$options$deb14;
3990
+ var _instance$options$deb9;
3422
3991
 
3423
- return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
3992
+ return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
3424
3993
  }
3425
3994
  }),
3426
3995
  getLeftFlatHeaders: memo(function () {
@@ -3432,9 +4001,9 @@ var Headers = {
3432
4001
  }, {
3433
4002
  key: 'getLeftFlatHeaders',
3434
4003
  debug: function debug() {
3435
- var _instance$options$deb15;
4004
+ var _instance$options$deb10;
3436
4005
 
3437
- return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
4006
+ return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
3438
4007
  }
3439
4008
  }),
3440
4009
  getCenterFlatHeaders: memo(function () {
@@ -3446,9 +4015,9 @@ var Headers = {
3446
4015
  }, {
3447
4016
  key: 'getCenterFlatHeaders',
3448
4017
  debug: function debug() {
3449
- var _instance$options$deb16;
4018
+ var _instance$options$deb11;
3450
4019
 
3451
- return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
4020
+ return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
3452
4021
  }
3453
4022
  }),
3454
4023
  getRightFlatHeaders: memo(function () {
@@ -3460,9 +4029,9 @@ var Headers = {
3460
4029
  }, {
3461
4030
  key: 'getRightFlatHeaders',
3462
4031
  debug: function debug() {
3463
- var _instance$options$deb17;
4032
+ var _instance$options$deb12;
3464
4033
 
3465
- return (_instance$options$deb17 = instance.options.debugAll) != null ? _instance$options$deb17 : instance.options.debugHeaders;
4034
+ return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
3466
4035
  }
3467
4036
  }),
3468
4037
  // Leaf Headers
@@ -3477,9 +4046,9 @@ var Headers = {
3477
4046
  }, {
3478
4047
  key: 'getCenterLeafHeaders',
3479
4048
  debug: function debug() {
3480
- var _instance$options$deb18;
4049
+ var _instance$options$deb13;
3481
4050
 
3482
- return (_instance$options$deb18 = instance.options.debugAll) != null ? _instance$options$deb18 : instance.options.debugHeaders;
4051
+ return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
3483
4052
  }
3484
4053
  }),
3485
4054
  getLeftLeafHeaders: memo(function () {
@@ -3493,9 +4062,9 @@ var Headers = {
3493
4062
  }, {
3494
4063
  key: 'getLeftLeafHeaders',
3495
4064
  debug: function debug() {
3496
- var _instance$options$deb19;
4065
+ var _instance$options$deb14;
3497
4066
 
3498
- return (_instance$options$deb19 = instance.options.debugAll) != null ? _instance$options$deb19 : instance.options.debugHeaders;
4067
+ return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
3499
4068
  }
3500
4069
  }),
3501
4070
  getRightLeafHeaders: memo(function () {
@@ -3509,9 +4078,9 @@ var Headers = {
3509
4078
  }, {
3510
4079
  key: 'getRightLeafHeaders',
3511
4080
  debug: function debug() {
3512
- var _instance$options$deb20;
4081
+ var _instance$options$deb15;
3513
4082
 
3514
- return (_instance$options$deb20 = instance.options.debugAll) != null ? _instance$options$deb20 : instance.options.debugHeaders;
4083
+ return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
3515
4084
  }
3516
4085
  }),
3517
4086
  getLeafHeaders: memo(function () {
@@ -3525,9 +4094,9 @@ var Headers = {
3525
4094
  }, {
3526
4095
  key: 'getLeafHeaders',
3527
4096
  debug: function debug() {
3528
- var _instance$options$deb21;
4097
+ var _instance$options$deb16;
3529
4098
 
3530
- return (_instance$options$deb21 = instance.options.debugAll) != null ? _instance$options$deb21 : instance.options.debugHeaders;
4099
+ return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
3531
4100
  }
3532
4101
  }),
3533
4102
  getHeader: function getHeader(id) {
@@ -3598,15 +4167,6 @@ var Headers = {
3598
4167
  rowSpan: header.rowSpan
3599
4168
  };
3600
4169
  return propGetter(initialProps, userProps);
3601
- },
3602
- getTotalWidth: function getTotalWidth() {
3603
- var width = 0;
3604
- instance.getVisibleLeafColumns().forEach(function (column) {
3605
- var _column$getWidth;
3606
-
3607
- width += (_column$getWidth = column.getWidth()) != null ? _column$getWidth : 0;
3608
- });
3609
- return width;
3610
4170
  }
3611
4171
  };
3612
4172
  }
@@ -3655,11 +4215,11 @@ function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
3655
4215
  }
3656
4216
  }; // The parent columns we're going to scan next
3657
4217
 
3658
- var parentHeaders = []; // Scan each column for parents
4218
+ var pendingParentHeaders = []; // Scan each column for parents
3659
4219
 
3660
4220
  headersToGroup.forEach(function (headerToGroup) {
3661
4221
  // What is the latest (last) parent column?
3662
- var latestParentHeader = [].concat(parentHeaders).reverse()[0];
4222
+ var latestPendingParentHeader = [].concat(pendingParentHeaders).reverse()[0];
3663
4223
  var isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
3664
4224
  var column;
3665
4225
  var isPlaceholder = false;
@@ -3673,37 +4233,41 @@ function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
3673
4233
  isPlaceholder = true;
3674
4234
  }
3675
4235
 
3676
- var header = instance.createHeader(column, {
3677
- id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
3678
- isPlaceholder: isPlaceholder,
3679
- placeholderId: isPlaceholder ? "" + parentHeaders.filter(function (d) {
3680
- return d.column === column;
3681
- }).length : undefined,
3682
- depth: depth
3683
- });
3684
-
3685
- if (!latestParentHeader || latestParentHeader.column !== header.column) {
3686
- header.subHeaders.push(headerToGroup);
3687
- parentHeaders.push(header);
4236
+ if ((latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
4237
+ // This column is repeated. Add it as a sub header to the next batch
4238
+ latestPendingParentHeader.subHeaders.push(headerToGroup);
3688
4239
  } else {
3689
- latestParentHeader.subHeaders.push(headerToGroup);
3690
- } // if (!headerToGroup.isPlaceholder) {
3691
- // headerToGroup.column.header = headerToGroup;
3692
- // }
3693
-
4240
+ // This is a new header. Let's create it
4241
+ var header = instance.createHeader(column, {
4242
+ id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
4243
+ isPlaceholder: isPlaceholder,
4244
+ placeholderId: isPlaceholder ? "" + pendingParentHeaders.filter(function (d) {
4245
+ return d.column === column;
4246
+ }).length : undefined,
4247
+ depth: depth,
4248
+ index: pendingParentHeaders.length
4249
+ }); // Add the headerToGroup as a subHeader of the new header
4250
+
4251
+ header.subHeaders.push(headerToGroup); // Add the new header to the pendingParentHeaders to get grouped
4252
+ // in the next batch
4253
+
4254
+ pendingParentHeaders.push(header);
4255
+ }
3694
4256
 
3695
4257
  headerGroup.headers.push(headerToGroup);
4258
+ headerToGroup.headerGroup = headerGroup;
3696
4259
  });
3697
4260
  headerGroups.push(headerGroup);
3698
4261
 
3699
4262
  if (depth > 0) {
3700
- createHeaderGroup(parentHeaders, depth - 1);
4263
+ createHeaderGroup(pendingParentHeaders, depth - 1);
3701
4264
  }
3702
4265
  };
3703
4266
 
3704
- var bottomHeaders = columnsToGroup.map(function (column) {
4267
+ var bottomHeaders = columnsToGroup.map(function (column, index) {
3705
4268
  return instance.createHeader(column, {
3706
- depth: maxDepth
4269
+ depth: maxDepth,
4270
+ index: index
3707
4271
  });
3708
4272
  });
3709
4273
  createHeaderGroup(bottomHeaders, maxDepth - 1);
@@ -3747,7 +4311,6 @@ function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
3747
4311
  return headerGroups;
3748
4312
  }
3749
4313
 
3750
- var features = [Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing];
3751
4314
  function createTableInstance(options) {
3752
4315
  var _options$initialState;
3753
4316
 
@@ -3756,7 +4319,9 @@ function createTableInstance(options) {
3756
4319
  }
3757
4320
 
3758
4321
  var instance = {};
3759
- var defaultOptions = features.reduce(function (obj, feature) {
4322
+ instance._features = [Columns, Rows, Cells, Headers, Visibility, Ordering, Pinning, Filters, Sorting, Grouping, Expanding, Pagination, RowSelection, ColumnSizing];
4323
+
4324
+ var defaultOptions = instance._features.reduce(function (obj, feature) {
3760
4325
  return Object.assign(obj, feature.getDefaultOptions == null ? void 0 : feature.getDefaultOptions(instance));
3761
4326
  }, {});
3762
4327
 
@@ -3769,15 +4334,15 @@ function createTableInstance(options) {
3769
4334
  coreProgress: 1
3770
4335
  };
3771
4336
 
3772
- var initialState = _extends({}, coreInitialState, features.reduce(function (obj, feature) {
4337
+ var initialState = _extends({}, coreInitialState, instance._features.reduce(function (obj, feature) {
3773
4338
  return Object.assign(obj, feature.getInitialState == null ? void 0 : feature.getInitialState());
3774
4339
  }, {}), (_options$initialState = options.initialState) != null ? _options$initialState : {});
3775
4340
 
3776
4341
  var queued = [];
3777
4342
  var queuedTimeout;
3778
4343
 
3779
- var finalInstance = _extends({}, instance, features.reduce(function (obj, feature) {
3780
- return Object.assign(obj, feature.getInstance == null ? void 0 : feature.getInstance(instance));
4344
+ var finalInstance = _extends({}, instance, instance._features.reduce(function (obj, feature) {
4345
+ return Object.assign(obj, feature.createInstance == null ? void 0 : feature.createInstance(instance));
3781
4346
  }, {}), {
3782
4347
  queue: function queue(cb) {
3783
4348
  queued.push(cb);
@@ -3821,339 +4386,12 @@ function createTableInstance(options) {
3821
4386
 
3822
4387
  return template;
3823
4388
  },
3824
- getRowId: function getRowId(row, index, parent) {
3825
- var _instance$options$get;
3826
-
3827
- return (_instance$options$get = instance.options.getRowId == null ? void 0 : instance.options.getRowId(row, index, parent)) != null ? _instance$options$get : "" + (parent ? [parent.id, index].join('.') : index);
3828
- },
3829
4389
  getState: function getState() {
3830
4390
  return instance.options.state;
3831
4391
  },
3832
4392
  setState: function setState(updater) {
3833
4393
  instance.options.onStateChange == null ? void 0 : instance.options.onStateChange(updater);
3834
4394
  },
3835
- getDefaultColumn: memo(function () {
3836
- return [instance.options.defaultColumn];
3837
- }, function (defaultColumn) {
3838
- var _defaultColumn;
3839
-
3840
- defaultColumn = (_defaultColumn = defaultColumn) != null ? _defaultColumn : {};
3841
- return _extends({
3842
- header: function header(props) {
3843
- return props.header.column.id;
3844
- },
3845
- footer: function footer(props) {
3846
- return props.header.column.id;
3847
- },
3848
- cell: function cell(_ref) {
3849
- var _ref$value = _ref.value,
3850
- value = _ref$value === void 0 ? '' : _ref$value;
3851
- return typeof value === 'boolean' ? value.toString() : value;
3852
- }
3853
- }, features.reduce(function (obj, feature) {
3854
- return Object.assign(obj, feature.getDefaultColumn == null ? void 0 : feature.getDefaultColumn());
3855
- }, {}), defaultColumn);
3856
- }, {
3857
- debug: function debug() {
3858
- var _instance$options$deb;
3859
-
3860
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugColumns;
3861
- },
3862
- key: 'getDefaultColumn'
3863
- }),
3864
- getColumnDefs: function getColumnDefs() {
3865
- return instance.options.columns;
3866
- },
3867
- createColumn: function createColumn(columnDef, depth, parent) {
3868
- var _ref2, _columnDef$id;
3869
-
3870
- var defaultColumn = instance.getDefaultColumn();
3871
- var id = (_ref2 = (_columnDef$id = columnDef.id) != null ? _columnDef$id : columnDef.accessorKey) != null ? _ref2 : typeof columnDef.header === 'string' ? columnDef.header : undefined;
3872
- var accessorFn;
3873
-
3874
- if (columnDef.accessorFn) {
3875
- accessorFn = columnDef.accessorFn;
3876
- } else if (columnDef.accessorKey) {
3877
- accessorFn = function accessorFn(originalRow) {
3878
- return originalRow[columnDef.accessorKey];
3879
- };
3880
- }
3881
-
3882
- if (!id) {
3883
- if (process.env.NODE_ENV !== 'production') {
3884
- throw new Error(columnDef.accessorFn ? "Columns require an id when using an accessorFn" : "Columns require an id when using a non-string header");
3885
- }
3886
-
3887
- throw new Error();
3888
- }
3889
-
3890
- var column = _extends({}, defaultColumn, columnDef, {
3891
- id: "" + id,
3892
- accessorFn: accessorFn,
3893
- parent: parent,
3894
- depth: depth,
3895
- columnDef: columnDef,
3896
- columnDefType: columnDef.columnDefType,
3897
- columns: [],
3898
- getWidth: function getWidth() {
3899
- return instance.getColumnWidth(column.id);
3900
- },
3901
- getFlatColumns: memo(function () {
3902
- return [true];
3903
- }, function () {
3904
- var _column$columns;
3905
-
3906
- return [column].concat((_column$columns = column.columns) == null ? void 0 : _column$columns.flatMap(function (d) {
3907
- return d.getFlatColumns();
3908
- }));
3909
- }, {
3910
- key: 'column.getFlatColumns',
3911
- debug: function debug() {
3912
- var _instance$options$deb2;
3913
-
3914
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugColumns;
3915
- }
3916
- }),
3917
- getLeafColumns: memo(function () {
3918
- return [instance._getOrderColumnsFn()];
3919
- }, function (orderColumns) {
3920
- var _column$columns2;
3921
-
3922
- if ((_column$columns2 = column.columns) != null && _column$columns2.length) {
3923
- var leafColumns = column.columns.flatMap(function (column) {
3924
- return column.getLeafColumns();
3925
- });
3926
- return orderColumns(leafColumns);
3927
- }
3928
-
3929
- return [column];
3930
- }, {
3931
- key: 'column.getLeafColumns',
3932
- debug: function debug() {
3933
- var _instance$options$deb3;
3934
-
3935
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugColumns;
3936
- }
3937
- })
3938
- });
3939
-
3940
- column = features.reduce(function (obj, feature) {
3941
- return Object.assign(obj, feature.createColumn == null ? void 0 : feature.createColumn(column, instance));
3942
- }, column); // Yes, we have to convert instance to uknown, because we know more than the compiler here.
3943
-
3944
- return column;
3945
- },
3946
- getAllColumns: memo(function () {
3947
- return [instance.getColumnDefs()];
3948
- }, function (columnDefs) {
3949
- var recurseColumns = function recurseColumns(columnDefs, parent, depth) {
3950
- if (depth === void 0) {
3951
- depth = 0;
3952
- }
3953
-
3954
- return columnDefs.map(function (columnDef) {
3955
- var column = instance.createColumn(columnDef, depth, parent);
3956
- column.columns = columnDef.columns ? recurseColumns(columnDef.columns, column, depth + 1) : [];
3957
- return column;
3958
- });
3959
- };
3960
-
3961
- return recurseColumns(columnDefs);
3962
- }, {
3963
- key: 'getAllColumns',
3964
- debug: function debug() {
3965
- var _instance$options$deb4;
3966
-
3967
- return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugColumns;
3968
- }
3969
- }),
3970
- getAllFlatColumns: memo(function () {
3971
- return [instance.getAllColumns()];
3972
- }, function (allColumns) {
3973
- return allColumns.flatMap(function (column) {
3974
- return column.getFlatColumns();
3975
- });
3976
- }, {
3977
- key: 'getAllFlatColumns',
3978
- debug: function debug() {
3979
- var _instance$options$deb5;
3980
-
3981
- return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugColumns;
3982
- }
3983
- }),
3984
- getAllFlatColumnsById: memo(function () {
3985
- return [instance.getAllFlatColumns()];
3986
- }, function (flatColumns) {
3987
- return flatColumns.reduce(function (acc, column) {
3988
- acc[column.id] = column;
3989
- return acc;
3990
- }, {});
3991
- }, {
3992
- key: 'getAllFlatColumnsById',
3993
- debug: function debug() {
3994
- var _instance$options$deb6;
3995
-
3996
- return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugColumns;
3997
- }
3998
- }),
3999
- getAllLeafColumns: memo(function () {
4000
- return [instance.getAllColumns(), instance._getOrderColumnsFn()];
4001
- }, function (allColumns, orderColumns) {
4002
- var leafColumns = allColumns.flatMap(function (column) {
4003
- return column.getLeafColumns();
4004
- });
4005
- return orderColumns(leafColumns);
4006
- }, {
4007
- key: 'getAllLeafColumns',
4008
- debug: function debug() {
4009
- var _instance$options$deb7;
4010
-
4011
- return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugColumns;
4012
- }
4013
- }),
4014
- getColumn: function getColumn(columnId) {
4015
- var column = instance.getAllFlatColumnsById()[columnId];
4016
-
4017
- if (!column) {
4018
- if (process.env.NODE_ENV !== 'production') {
4019
- console.warn("[Table] Column with id " + columnId + " does not exist.");
4020
- }
4021
-
4022
- throw new Error();
4023
- }
4024
-
4025
- return column;
4026
- },
4027
- createCell: function createCell(row, column, value) {
4028
- var cell = {
4029
- id: row.id + "_" + column.id,
4030
- rowId: row.id,
4031
- columnId: column.id,
4032
- row: row,
4033
- column: column,
4034
- value: value,
4035
- getCellProps: function getCellProps(userProps) {
4036
- return instance.getCellProps(row.id, column.id, userProps);
4037
- },
4038
- renderCell: function renderCell() {
4039
- return column.cell ? instance.render(column.cell, {
4040
- instance: instance,
4041
- column: column,
4042
- row: row,
4043
- cell: cell,
4044
- value: value
4045
- }) : null;
4046
- }
4047
- };
4048
- features.forEach(function (feature) {
4049
- Object.assign(cell, feature.createCell == null ? void 0 : feature.createCell(cell, column, row, instance));
4050
- }, {});
4051
- return cell;
4052
- },
4053
- createRow: function createRow(id, original, rowIndex, depth, values) {
4054
- var row = {
4055
- id: id,
4056
- index: rowIndex,
4057
- original: original,
4058
- depth: depth,
4059
- values: values,
4060
- subRows: [],
4061
- getLeafRows: function getLeafRows() {
4062
- return flattenBy(row.subRows, function (d) {
4063
- return d.subRows;
4064
- });
4065
- },
4066
- getRowProps: function getRowProps(userProps) {
4067
- return instance.getRowProps(row.id, userProps);
4068
- },
4069
- getAllCells: undefined,
4070
- getAllCellsByColumnId: undefined
4071
- };
4072
- row.getAllCells = memo(function () {
4073
- return [instance.getAllLeafColumns()];
4074
- }, function (leafColumns) {
4075
- return leafColumns.map(function (column) {
4076
- return instance.createCell(row, column, row.values[column.id]);
4077
- });
4078
- }, {
4079
- key: process.env.NODE_ENV !== 'production' ? 'row.getAllCells' : '',
4080
- debug: function debug() {
4081
- var _instance$options$deb8;
4082
-
4083
- return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugRows;
4084
- }
4085
- });
4086
- row.getAllCellsByColumnId = memo(function () {
4087
- return [row.getAllCells()];
4088
- }, function (allCells) {
4089
- return allCells.reduce(function (acc, cell) {
4090
- acc[cell.columnId] = cell;
4091
- return acc;
4092
- }, {});
4093
- }, {
4094
- key: 'row.getAllCellsByColumnId',
4095
- debug: function debug() {
4096
- var _instance$options$deb9;
4097
-
4098
- return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugRows;
4099
- }
4100
- });
4101
-
4102
- for (var i = 0; i < features.length; i++) {
4103
- var feature = features[i];
4104
- Object.assign(row, feature.createRow == null ? void 0 : feature.createRow(row, instance));
4105
- }
4106
-
4107
- return row;
4108
- },
4109
- getCoreRowModel: function getCoreRowModel() {
4110
- if (!instance._getCoreRowModel) {
4111
- instance._getCoreRowModel = instance.options.getCoreRowModel(instance);
4112
- }
4113
-
4114
- return instance._getCoreRowModel();
4115
- },
4116
- // The final calls start at the bottom of the model,
4117
- // expanded rows, which then work their way up
4118
- getRowModel: function getRowModel() {
4119
- return instance.getPaginationRowModel();
4120
- },
4121
- getRow: function getRow(id) {
4122
- var row = instance.getRowModel().rowsById[id];
4123
-
4124
- if (!row) {
4125
- if (process.env.NODE_ENV !== 'production') {
4126
- throw new Error("getRow expected an ID, but got " + id);
4127
- }
4128
-
4129
- throw new Error();
4130
- }
4131
-
4132
- return row;
4133
- },
4134
- getCell: function getCell(rowId, columnId) {
4135
- var row = instance.getRow(rowId);
4136
-
4137
- if (!row) {
4138
- if (process.env.NODE_ENV !== 'production') {
4139
- throw new Error("[Table] could not find row with id " + rowId);
4140
- }
4141
-
4142
- throw new Error();
4143
- }
4144
-
4145
- var cell = row.getAllCellsByColumnId()[columnId];
4146
-
4147
- if (!cell) {
4148
- if (process.env.NODE_ENV !== 'production') {
4149
- throw new Error("[Table] could not find cell " + columnId + " in row " + rowId);
4150
- }
4151
-
4152
- throw new Error();
4153
- }
4154
-
4155
- return cell;
4156
- },
4157
4395
  getTableProps: function getTableProps(userProps) {
4158
4396
  return propGetter({
4159
4397
  role: 'table'
@@ -4164,58 +4402,6 @@ function createTableInstance(options) {
4164
4402
  role: 'rowgroup'
4165
4403
  }, userProps);
4166
4404
  },
4167
- getRowProps: function getRowProps(rowId, userProps) {
4168
- var row = instance.getRow(rowId);
4169
-
4170
- if (!row) {
4171
- return;
4172
- }
4173
-
4174
- return propGetter({
4175
- key: row.id,
4176
- role: 'row'
4177
- }, userProps);
4178
- },
4179
- getCellProps: function getCellProps(rowId, columnId, userProps) {
4180
- var cell = instance.getCell(rowId, columnId);
4181
-
4182
- if (!cell) {
4183
- return;
4184
- }
4185
-
4186
- return propGetter({
4187
- key: cell.id,
4188
- role: 'gridcell'
4189
- }, userProps);
4190
- },
4191
- getTableWidth: function getTableWidth() {
4192
- var _instance$getHeaderGr, _instance$getHeaderGr2;
4193
-
4194
- return (_instance$getHeaderGr = (_instance$getHeaderGr2 = instance.getHeaderGroups()[0]) == null ? void 0 : _instance$getHeaderGr2.headers.reduce(function (sum, header) {
4195
- return sum + header.getWidth();
4196
- }, 0)) != null ? _instance$getHeaderGr : 0;
4197
- },
4198
- getLeftTableWidth: function getLeftTableWidth() {
4199
- var _instance$getLeftHead, _instance$getLeftHead2;
4200
-
4201
- return (_instance$getLeftHead = (_instance$getLeftHead2 = instance.getLeftHeaderGroups()[0]) == null ? void 0 : _instance$getLeftHead2.headers.reduce(function (sum, header) {
4202
- return sum + header.getWidth();
4203
- }, 0)) != null ? _instance$getLeftHead : 0;
4204
- },
4205
- getCenterTableWidth: function getCenterTableWidth() {
4206
- var _instance$getCenterHe, _instance$getCenterHe2;
4207
-
4208
- return (_instance$getCenterHe = (_instance$getCenterHe2 = instance.getCenterHeaderGroups()[0]) == null ? void 0 : _instance$getCenterHe2.headers.reduce(function (sum, header) {
4209
- return sum + header.getWidth();
4210
- }, 0)) != null ? _instance$getCenterHe : 0;
4211
- },
4212
- getRightTableWidth: function getRightTableWidth() {
4213
- var _instance$getRightHea, _instance$getRightHea2;
4214
-
4215
- return (_instance$getRightHea = (_instance$getRightHea2 = instance.getRightHeaderGroups()[0]) == null ? void 0 : _instance$getRightHea2.headers.reduce(function (sum, header) {
4216
- return sum + header.getWidth();
4217
- }, 0)) != null ? _instance$getRightHea : 0;
4218
- },
4219
4405
  getOverallProgress: function getOverallProgress() {
4220
4406
  var _instance$getState = instance.getState(),
4221
4407
  coreProgress = _instance$getState.coreProgress,