@tanstack/react-table 8.0.0-alpha.88 → 8.0.0-alpha.89

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":"8ad0-127"},{"name":"react-table/src/index.tsx","uid":"8ad0-129"}]}]}],"isRoot":true},"nodeParts":{"8ad0-127":{"renderedLength":137430,"gzipLength":23365,"brotliLength":0,"mainUid":"8ad0-126"},"8ad0-129":{"renderedLength":2102,"gzipLength":836,"brotliLength":0,"mainUid":"8ad0-128"}},"nodeMetas":{"8ad0-126":{"id":"/packages/table-core/build/esm/index.js","moduleParts":{"index.production.js":"8ad0-127"},"imported":[],"importedBy":[{"uid":"8ad0-128"}]},"8ad0-128":{"id":"/packages/react-table/src/index.tsx","moduleParts":{"index.production.js":"8ad0-129"},"imported":[{"uid":"8ad0-130"},{"uid":"8ad0-126"}],"importedBy":[],"isEntry":true},"8ad0-130":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"8ad0-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":"756b-127"},{"name":"react-table/src/index.tsx","uid":"756b-129"}]}]}],"isRoot":true},"nodeParts":{"756b-127":{"renderedLength":137942,"gzipLength":23472,"brotliLength":0,"mainUid":"756b-126"},"756b-129":{"renderedLength":2102,"gzipLength":836,"brotliLength":0,"mainUid":"756b-128"}},"nodeMetas":{"756b-126":{"id":"/packages/table-core/build/esm/index.js","moduleParts":{"index.production.js":"756b-127"},"imported":[],"importedBy":[{"uid":"756b-128"}]},"756b-128":{"id":"/packages/react-table/src/index.tsx","moduleParts":{"index.production.js":"756b-129"},"imported":[{"uid":"756b-130"},{"uid":"756b-126"}],"importedBy":[],"isEntry":true},"756b-130":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"756b-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": "8ad0-132"
14
+ "uid": "756b-132"
15
15
  },
16
16
  {
17
17
  "name": "react-table/src/index.tsx",
18
- "uid": "8ad0-134"
18
+ "uid": "756b-134"
19
19
  }
20
20
  ]
21
21
  }
@@ -25,55 +25,55 @@
25
25
  "isRoot": true
26
26
  },
27
27
  "nodeParts": {
28
- "8ad0-132": {
29
- "renderedLength": 137430,
30
- "gzipLength": 23365,
28
+ "756b-132": {
29
+ "renderedLength": 137942,
30
+ "gzipLength": 23472,
31
31
  "brotliLength": 0,
32
- "mainUid": "8ad0-131"
32
+ "mainUid": "756b-131"
33
33
  },
34
- "8ad0-134": {
34
+ "756b-134": {
35
35
  "renderedLength": 2102,
36
36
  "gzipLength": 836,
37
37
  "brotliLength": 0,
38
- "mainUid": "8ad0-133"
38
+ "mainUid": "756b-133"
39
39
  }
40
40
  },
41
41
  "nodeMetas": {
42
- "8ad0-131": {
42
+ "756b-131": {
43
43
  "id": "/packages/table-core/build/esm/index.js",
44
44
  "moduleParts": {
45
- "index.production.js": "8ad0-132"
45
+ "index.production.js": "756b-132"
46
46
  },
47
47
  "imported": [],
48
48
  "importedBy": [
49
49
  {
50
- "uid": "8ad0-133"
50
+ "uid": "756b-133"
51
51
  }
52
52
  ]
53
53
  },
54
- "8ad0-133": {
54
+ "756b-133": {
55
55
  "id": "/packages/react-table/src/index.tsx",
56
56
  "moduleParts": {
57
- "index.production.js": "8ad0-134"
57
+ "index.production.js": "756b-134"
58
58
  },
59
59
  "imported": [
60
60
  {
61
- "uid": "8ad0-135"
61
+ "uid": "756b-135"
62
62
  },
63
63
  {
64
- "uid": "8ad0-131"
64
+ "uid": "756b-131"
65
65
  }
66
66
  ],
67
67
  "importedBy": [],
68
68
  "isEntry": true
69
69
  },
70
- "8ad0-135": {
70
+ "756b-135": {
71
71
  "id": "react",
72
72
  "moduleParts": {},
73
73
  "imported": [],
74
74
  "importedBy": [
75
75
  {
76
- "uid": "8ad0-133"
76
+ "uid": "756b-133"
77
77
  }
78
78
  ],
79
79
  "isExternal": true
@@ -2553,8 +2553,10 @@
2553
2553
  // })
2554
2554
  // return
2555
2555
  // }
2556
+ // this needs to be outside of instance.setSorting to be in sync with rerender
2557
+ const nextSortingOrder = column.getNextSortingOrder();
2556
2558
  instance.setSorting(old => {
2557
- var _ref2, _column$columnDef$sor, _instance$options$ena, _instance$options$ena2;
2559
+ var _instance$options$ena, _instance$options$ena2;
2558
2560
 
2559
2561
  // Find any existing sorting for this column
2560
2562
  const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
@@ -2579,30 +2581,29 @@
2579
2581
  } else {
2580
2582
  sortAction = 'replace';
2581
2583
  }
2582
- }
2584
+ } // Handle toggle states that will remove the sorting
2583
2585
 
2584
- const sortDescFirst = (_ref2 = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : instance.options.sortDescFirst) != null ? _ref2 : column.getAutoSortDir() === 'desc'; // Handle toggle states that will remove the sorting
2585
2586
 
2586
2587
  if (sortAction === 'toggle' && ( // Must be toggling
2587
2588
  (_instance$options$ena = instance.options.enableSortingRemoval) != null ? _instance$options$ena : true) && // If enableSortRemove, enable in general
2588
2589
  !hasDescDefined && ( // Must not be setting desc
2589
- multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) && ( // If multi, don't allow if enableMultiRemove
2590
- existingSorting != null && existingSorting.desc // Finally, detect if it should indeed be removed
2591
- ? !sortDescFirst : sortDescFirst)) {
2590
+ multi ? (_instance$options$ena2 = instance.options.enableMultiRemove) != null ? _instance$options$ena2 : true : true) && // If multi, don't allow if enableMultiRemove
2591
+ !nextSortingOrder // Finally, detect if it should indeed be removed
2592
+ ) {
2592
2593
  sortAction = 'remove';
2593
2594
  }
2594
2595
 
2595
2596
  if (sortAction === 'replace') {
2596
2597
  newSorting = [{
2597
2598
  id: column.id,
2598
- desc: hasDescDefined ? desc : !!sortDescFirst
2599
+ desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
2599
2600
  }];
2600
2601
  } else if (sortAction === 'add' && old != null && old.length) {
2601
2602
  var _instance$options$max;
2602
2603
 
2603
2604
  newSorting = [...old, {
2604
2605
  id: column.id,
2605
- desc: hasDescDefined ? desc : !!sortDescFirst
2606
+ desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
2606
2607
  }]; // Take latest n columns
2607
2608
 
2608
2609
  newSorting.splice(0, newSorting.length - ((_instance$options$max = instance.options.maxMultiSortColCount) != null ? _instance$options$max : Number.MAX_SAFE_INTEGER));
@@ -2611,7 +2612,7 @@
2611
2612
  newSorting = old.map(d => {
2612
2613
  if (d.id === column.id) {
2613
2614
  return { ...d,
2614
- desc: hasDescDefined ? desc : !(existingSorting != null && existingSorting.desc)
2615
+ desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
2615
2616
  };
2616
2617
  }
2617
2618
 
@@ -2624,6 +2625,23 @@
2624
2625
  return newSorting;
2625
2626
  });
2626
2627
  },
2628
+ getNextSortingOrder: () => {
2629
+ var _ref2, _column$columnDef$sor;
2630
+
2631
+ const sortDescFirst = (_ref2 = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : instance.options.sortDescFirst) != null ? _ref2 : column.getAutoSortDir() === 'desc';
2632
+ const firstSortDirection = sortDescFirst ? 'desc' : 'asc';
2633
+ const isSorted = column.getIsSorted();
2634
+
2635
+ if (!isSorted) {
2636
+ return firstSortDirection;
2637
+ }
2638
+
2639
+ if (isSorted === firstSortDirection) {
2640
+ return isSorted === 'desc' ? 'asc' : 'desc';
2641
+ } else {
2642
+ return false;
2643
+ }
2644
+ },
2627
2645
  getCanSort: () => {
2628
2646
  var _column$columnDef$ena, _instance$options$ena3;
2629
2647