@tanstack/svelte-table 8.1.4 → 8.2.2

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":"8281-159"},{"name":"svelte-table/src","children":[{"uid":"8281-161","name":"placeholder.svelte"},{"uid":"8281-163","name":"placeholder.ts"},{"uid":"8281-165","name":"render-component.ts"},{"uid":"8281-167","name":"index.ts"}]}]}]}],"isRoot":true},"nodeParts":{"8281-159":{"renderedLength":134456,"gzipLength":23088,"brotliLength":0,"mainUid":"8281-158"},"8281-161":{"renderedLength":927,"gzipLength":445,"brotliLength":0,"mainUid":"8281-160"},"8281-163":{"renderedLength":246,"gzipLength":184,"brotliLength":0,"mainUid":"8281-162"},"8281-165":{"renderedLength":1458,"gzipLength":539,"brotliLength":0,"mainUid":"8281-164"},"8281-167":{"renderedLength":2915,"gzipLength":958,"brotliLength":0,"mainUid":"8281-166"}},"nodeMetas":{"8281-158":{"id":"/packages/table-core/build/esm/index.js","moduleParts":{"index.production.js":"8281-159"},"imported":[],"importedBy":[{"uid":"8281-166"}]},"8281-160":{"id":"/packages/svelte-table/src/placeholder.svelte","moduleParts":{"index.production.js":"8281-161"},"imported":[{"uid":"8281-168"}],"importedBy":[{"uid":"8281-162"}]},"8281-162":{"id":"/packages/svelte-table/src/placeholder.ts","moduleParts":{"index.production.js":"8281-163"},"imported":[{"uid":"8281-168"},{"uid":"8281-160"}],"importedBy":[{"uid":"8281-166"}]},"8281-164":{"id":"/packages/svelte-table/src/render-component.ts","moduleParts":{"index.production.js":"8281-165"},"imported":[{"uid":"8281-168"}],"importedBy":[{"uid":"8281-166"}]},"8281-166":{"id":"/packages/svelte-table/src/index.ts","moduleParts":{"index.production.js":"8281-167"},"imported":[{"uid":"8281-158"},{"uid":"8281-162"},{"uid":"8281-168"},{"uid":"8281-169"},{"uid":"8281-164"}],"importedBy":[],"isEntry":true},"8281-168":{"id":"svelte/internal","moduleParts":{},"imported":[],"importedBy":[{"uid":"8281-166"},{"uid":"8281-162"},{"uid":"8281-164"},{"uid":"8281-160"}],"isExternal":true},"8281-169":{"id":"svelte/store","moduleParts":{},"imported":[],"importedBy":[{"uid":"8281-166"}],"isExternal":true}},"env":{"rollup":"2.75.7"},"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":"a9b1-159"},{"name":"svelte-table/src","children":[{"uid":"a9b1-161","name":"placeholder.svelte"},{"uid":"a9b1-163","name":"placeholder.ts"},{"uid":"a9b1-165","name":"render-component.ts"},{"uid":"a9b1-167","name":"index.ts"}]}]}]}],"isRoot":true},"nodeParts":{"a9b1-159":{"renderedLength":134594,"gzipLength":23188,"brotliLength":0,"mainUid":"a9b1-158"},"a9b1-161":{"renderedLength":927,"gzipLength":445,"brotliLength":0,"mainUid":"a9b1-160"},"a9b1-163":{"renderedLength":246,"gzipLength":184,"brotliLength":0,"mainUid":"a9b1-162"},"a9b1-165":{"renderedLength":1458,"gzipLength":539,"brotliLength":0,"mainUid":"a9b1-164"},"a9b1-167":{"renderedLength":2915,"gzipLength":958,"brotliLength":0,"mainUid":"a9b1-166"}},"nodeMetas":{"a9b1-158":{"id":"/packages/table-core/build/esm/index.js","moduleParts":{"index.production.js":"a9b1-159"},"imported":[],"importedBy":[{"uid":"a9b1-166"}]},"a9b1-160":{"id":"/packages/svelte-table/src/placeholder.svelte","moduleParts":{"index.production.js":"a9b1-161"},"imported":[{"uid":"a9b1-168"}],"importedBy":[{"uid":"a9b1-162"}]},"a9b1-162":{"id":"/packages/svelte-table/src/placeholder.ts","moduleParts":{"index.production.js":"a9b1-163"},"imported":[{"uid":"a9b1-168"},{"uid":"a9b1-160"}],"importedBy":[{"uid":"a9b1-166"}]},"a9b1-164":{"id":"/packages/svelte-table/src/render-component.ts","moduleParts":{"index.production.js":"a9b1-165"},"imported":[{"uid":"a9b1-168"}],"importedBy":[{"uid":"a9b1-166"}]},"a9b1-166":{"id":"/packages/svelte-table/src/index.ts","moduleParts":{"index.production.js":"a9b1-167"},"imported":[{"uid":"a9b1-158"},{"uid":"a9b1-162"},{"uid":"a9b1-168"},{"uid":"a9b1-169"},{"uid":"a9b1-164"}],"importedBy":[],"isEntry":true},"a9b1-168":{"id":"svelte/internal","moduleParts":{},"imported":[],"importedBy":[{"uid":"a9b1-166"},{"uid":"a9b1-162"},{"uid":"a9b1-164"},{"uid":"a9b1-160"}],"isExternal":true},"a9b1-169":{"id":"svelte/store","moduleParts":{},"imported":[],"importedBy":[{"uid":"a9b1-166"}],"isExternal":true}},"env":{"rollup":"2.76.0"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
2673
2673
 
2674
2674
  const run = () => {
2675
2675
  const width = window.innerWidth;
@@ -11,25 +11,25 @@
11
11
  "children": [
12
12
  {
13
13
  "name": "table-core/build/esm/index.js",
14
- "uid": "8281-171"
14
+ "uid": "a9b1-171"
15
15
  },
16
16
  {
17
17
  "name": "svelte-table/src",
18
18
  "children": [
19
19
  {
20
- "uid": "8281-173",
20
+ "uid": "a9b1-173",
21
21
  "name": "placeholder.svelte"
22
22
  },
23
23
  {
24
- "uid": "8281-175",
24
+ "uid": "a9b1-175",
25
25
  "name": "placeholder.ts"
26
26
  },
27
27
  {
28
- "uid": "8281-177",
28
+ "uid": "a9b1-177",
29
29
  "name": "render-component.ts"
30
30
  },
31
31
  {
32
- "uid": "8281-179",
32
+ "uid": "a9b1-179",
33
33
  "name": "index.ts"
34
34
  }
35
35
  ]
@@ -42,160 +42,160 @@
42
42
  "isRoot": true
43
43
  },
44
44
  "nodeParts": {
45
- "8281-171": {
46
- "renderedLength": 134456,
47
- "gzipLength": 23088,
45
+ "a9b1-171": {
46
+ "renderedLength": 134594,
47
+ "gzipLength": 23188,
48
48
  "brotliLength": 0,
49
- "mainUid": "8281-170"
49
+ "mainUid": "a9b1-170"
50
50
  },
51
- "8281-173": {
51
+ "a9b1-173": {
52
52
  "renderedLength": 927,
53
53
  "gzipLength": 445,
54
54
  "brotliLength": 0,
55
- "mainUid": "8281-172"
55
+ "mainUid": "a9b1-172"
56
56
  },
57
- "8281-175": {
57
+ "a9b1-175": {
58
58
  "renderedLength": 246,
59
59
  "gzipLength": 184,
60
60
  "brotliLength": 0,
61
- "mainUid": "8281-174"
61
+ "mainUid": "a9b1-174"
62
62
  },
63
- "8281-177": {
63
+ "a9b1-177": {
64
64
  "renderedLength": 1458,
65
65
  "gzipLength": 539,
66
66
  "brotliLength": 0,
67
- "mainUid": "8281-176"
67
+ "mainUid": "a9b1-176"
68
68
  },
69
- "8281-179": {
69
+ "a9b1-179": {
70
70
  "renderedLength": 2915,
71
71
  "gzipLength": 958,
72
72
  "brotliLength": 0,
73
- "mainUid": "8281-178"
73
+ "mainUid": "a9b1-178"
74
74
  }
75
75
  },
76
76
  "nodeMetas": {
77
- "8281-170": {
77
+ "a9b1-170": {
78
78
  "id": "/packages/table-core/build/esm/index.js",
79
79
  "moduleParts": {
80
- "index.production.js": "8281-171"
80
+ "index.production.js": "a9b1-171"
81
81
  },
82
82
  "imported": [],
83
83
  "importedBy": [
84
84
  {
85
- "uid": "8281-178"
85
+ "uid": "a9b1-178"
86
86
  }
87
87
  ]
88
88
  },
89
- "8281-172": {
89
+ "a9b1-172": {
90
90
  "id": "/packages/svelte-table/src/placeholder.svelte",
91
91
  "moduleParts": {
92
- "index.production.js": "8281-173"
92
+ "index.production.js": "a9b1-173"
93
93
  },
94
94
  "imported": [
95
95
  {
96
- "uid": "8281-180"
96
+ "uid": "a9b1-180"
97
97
  }
98
98
  ],
99
99
  "importedBy": [
100
100
  {
101
- "uid": "8281-174"
101
+ "uid": "a9b1-174"
102
102
  }
103
103
  ]
104
104
  },
105
- "8281-174": {
105
+ "a9b1-174": {
106
106
  "id": "/packages/svelte-table/src/placeholder.ts",
107
107
  "moduleParts": {
108
- "index.production.js": "8281-175"
108
+ "index.production.js": "a9b1-175"
109
109
  },
110
110
  "imported": [
111
111
  {
112
- "uid": "8281-180"
112
+ "uid": "a9b1-180"
113
113
  },
114
114
  {
115
- "uid": "8281-172"
115
+ "uid": "a9b1-172"
116
116
  }
117
117
  ],
118
118
  "importedBy": [
119
119
  {
120
- "uid": "8281-178"
120
+ "uid": "a9b1-178"
121
121
  }
122
122
  ]
123
123
  },
124
- "8281-176": {
124
+ "a9b1-176": {
125
125
  "id": "/packages/svelte-table/src/render-component.ts",
126
126
  "moduleParts": {
127
- "index.production.js": "8281-177"
127
+ "index.production.js": "a9b1-177"
128
128
  },
129
129
  "imported": [
130
130
  {
131
- "uid": "8281-180"
131
+ "uid": "a9b1-180"
132
132
  }
133
133
  ],
134
134
  "importedBy": [
135
135
  {
136
- "uid": "8281-178"
136
+ "uid": "a9b1-178"
137
137
  }
138
138
  ]
139
139
  },
140
- "8281-178": {
140
+ "a9b1-178": {
141
141
  "id": "/packages/svelte-table/src/index.ts",
142
142
  "moduleParts": {
143
- "index.production.js": "8281-179"
143
+ "index.production.js": "a9b1-179"
144
144
  },
145
145
  "imported": [
146
146
  {
147
- "uid": "8281-170"
147
+ "uid": "a9b1-170"
148
148
  },
149
149
  {
150
- "uid": "8281-174"
150
+ "uid": "a9b1-174"
151
151
  },
152
152
  {
153
- "uid": "8281-180"
153
+ "uid": "a9b1-180"
154
154
  },
155
155
  {
156
- "uid": "8281-181"
156
+ "uid": "a9b1-181"
157
157
  },
158
158
  {
159
- "uid": "8281-176"
159
+ "uid": "a9b1-176"
160
160
  }
161
161
  ],
162
162
  "importedBy": [],
163
163
  "isEntry": true
164
164
  },
165
- "8281-180": {
165
+ "a9b1-180": {
166
166
  "id": "svelte/internal",
167
167
  "moduleParts": {},
168
168
  "imported": [],
169
169
  "importedBy": [
170
170
  {
171
- "uid": "8281-178"
171
+ "uid": "a9b1-178"
172
172
  },
173
173
  {
174
- "uid": "8281-174"
174
+ "uid": "a9b1-174"
175
175
  },
176
176
  {
177
- "uid": "8281-176"
177
+ "uid": "a9b1-176"
178
178
  },
179
179
  {
180
- "uid": "8281-172"
180
+ "uid": "a9b1-172"
181
181
  }
182
182
  ],
183
183
  "isExternal": true
184
184
  },
185
- "8281-181": {
185
+ "a9b1-181": {
186
186
  "id": "svelte/store",
187
187
  "moduleParts": {},
188
188
  "imported": [],
189
189
  "importedBy": [
190
190
  {
191
- "uid": "8281-178"
191
+ "uid": "a9b1-178"
192
192
  }
193
193
  ],
194
194
  "isExternal": true
195
195
  }
196
196
  },
197
197
  "env": {
198
- "rollup": "2.75.7"
198
+ "rollup": "2.76.0"
199
199
  },
200
200
  "options": {
201
201
  "gzip": true,
@@ -2363,7 +2363,12 @@
2363
2363
  };
2364
2364
 
2365
2365
  const datetime = (rowA, rowB, columnId) => {
2366
- return compareBasic(rowA.getValue(columnId).getTime(), rowB.getValue(columnId).getTime());
2366
+ const a = rowA.getValue(columnId);
2367
+ const b = rowB.getValue(columnId); // Can handle nullish values
2368
+ // Use > and < because == (and ===) doesn't work with
2369
+ // Date objects (would require calling getTime()).
2370
+
2371
+ return a > b ? 1 : a < b ? -1 : 0;
2367
2372
  };
2368
2373
 
2369
2374
  const basic = (rowA, rowB, columnId) => {
@@ -2524,18 +2529,17 @@
2524
2529
  // }
2525
2530
  // this needs to be outside of table.setSorting to be in sync with rerender
2526
2531
  const nextSortingOrder = column.getNextSortingOrder();
2532
+ const hasManualValue = typeof desc !== 'undefined' && desc !== null;
2527
2533
  table.setSorting(old => {
2528
- var _table$options$enable, _table$options$enable2;
2529
-
2530
2534
  // Find any existing sorting for this column
2531
2535
  const existingSorting = old == null ? void 0 : old.find(d => d.id === column.id);
2532
2536
  const existingIndex = old == null ? void 0 : old.findIndex(d => d.id === column.id);
2533
- const hasDescDefined = typeof desc !== 'undefined' && desc !== null;
2534
2537
  let newSorting = []; // What should we do with this sort action?
2535
2538
 
2536
2539
  let sortAction;
2540
+ let nextDesc = hasManualValue ? desc : nextSortingOrder === 'desc'; // Multi-mode
2537
2541
 
2538
- if (column.getCanMultiSort() && multi) {
2542
+ if (old != null && old.length && column.getCanMultiSort() && multi) {
2539
2543
  if (existingSorting) {
2540
2544
  sortAction = 'toggle';
2541
2545
  } else {
@@ -2553,63 +2557,71 @@
2553
2557
  } // Handle toggle states that will remove the sorting
2554
2558
 
2555
2559
 
2556
- if (sortAction === 'toggle' && ( // Must be toggling
2557
- (_table$options$enable = table.options.enableSortingRemoval) != null ? _table$options$enable : true) && // If enableSortRemove, enable in general
2558
- !hasDescDefined && ( // Must not be setting desc
2559
- multi ? (_table$options$enable2 = table.options.enableMultiRemove) != null ? _table$options$enable2 : true : true) && // If multi, don't allow if enableMultiRemove
2560
- !nextSortingOrder // Finally, detect if it should indeed be removed
2561
- ) {
2562
- sortAction = 'remove';
2560
+ if (sortAction === 'toggle') {
2561
+ // If we are "actually" toggling (not a manual set value), should we remove the sorting?
2562
+ if (!hasManualValue) {
2563
+ // Is our intention to remove?
2564
+ if (!nextSortingOrder) {
2565
+ sortAction = 'remove';
2566
+ }
2567
+ }
2563
2568
  }
2564
2569
 
2565
- if (sortAction === 'replace') {
2566
- newSorting = [{
2567
- id: column.id,
2568
- desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
2569
- }];
2570
- } else if (sortAction === 'add' && old != null && old.length) {
2570
+ if (sortAction === 'add') {
2571
2571
  var _table$options$maxMul;
2572
2572
 
2573
2573
  newSorting = [...old, {
2574
2574
  id: column.id,
2575
- desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
2575
+ desc: nextDesc
2576
2576
  }]; // Take latest n columns
2577
2577
 
2578
2578
  newSorting.splice(0, newSorting.length - ((_table$options$maxMul = table.options.maxMultiSortColCount) != null ? _table$options$maxMul : Number.MAX_SAFE_INTEGER));
2579
- } else if (sortAction === 'toggle' && old != null && old.length) {
2579
+ } else if (sortAction === 'toggle') {
2580
2580
  // This flips (or sets) the
2581
2581
  newSorting = old.map(d => {
2582
2582
  if (d.id === column.id) {
2583
2583
  return { ...d,
2584
- desc: hasDescDefined ? desc : nextSortingOrder === 'desc'
2584
+ desc: nextDesc
2585
2585
  };
2586
2586
  }
2587
2587
 
2588
2588
  return d;
2589
2589
  });
2590
- } else if (sortAction === 'remove' && old != null && old.length) {
2590
+ } else if (sortAction === 'remove') {
2591
2591
  newSorting = old.filter(d => d.id !== column.id);
2592
+ } else {
2593
+ newSorting = [{
2594
+ id: column.id,
2595
+ desc: nextDesc
2596
+ }];
2592
2597
  }
2593
2598
 
2594
2599
  return newSorting;
2595
2600
  });
2596
2601
  },
2597
- getNextSortingOrder: () => {
2602
+ getFirstSortDir: () => {
2598
2603
  var _ref, _column$columnDef$sor;
2599
2604
 
2600
2605
  const sortDescFirst = (_ref = (_column$columnDef$sor = column.columnDef.sortDescFirst) != null ? _column$columnDef$sor : table.options.sortDescFirst) != null ? _ref : column.getAutoSortDir() === 'desc';
2601
- const firstSortDirection = sortDescFirst ? 'desc' : 'asc';
2606
+ return sortDescFirst ? 'desc' : 'asc';
2607
+ },
2608
+ getNextSortingOrder: multi => {
2609
+ var _table$options$enable, _table$options$enable2;
2610
+
2611
+ const firstSortDirection = column.getFirstSortDir();
2602
2612
  const isSorted = column.getIsSorted();
2603
2613
 
2604
2614
  if (!isSorted) {
2605
2615
  return firstSortDirection;
2606
2616
  }
2607
2617
 
2608
- if (isSorted === firstSortDirection) {
2609
- return isSorted === 'desc' ? 'asc' : 'desc';
2610
- } else {
2618
+ if (isSorted !== firstSortDirection && ((_table$options$enable = table.options.enableSortingRemoval) != null ? _table$options$enable : true) && ( // If enableSortRemove, enable in general
2619
+ multi ? (_table$options$enable2 = table.options.enableMultiRemove) != null ? _table$options$enable2 : true : true) // If multi, don't allow if enableMultiRemove))
2620
+ ) {
2611
2621
  return false;
2612
2622
  }
2623
+
2624
+ return isSorted === 'desc' ? 'asc' : 'desc';
2613
2625
  },
2614
2626
  getCanSort: () => {
2615
2627
  var _column$columnDef$ena, _table$options$enable3;
@@ -2891,9 +2903,9 @@
2891
2903
  header: props => props.header.column.id,
2892
2904
  footer: props => props.header.column.id,
2893
2905
  cell: props => {
2894
- var _toString, _props$renderValue;
2906
+ var _props$renderValue$to, _props$renderValue;
2895
2907
 
2896
- return (_toString = (_props$renderValue = props.renderValue()) == null ? void 0 : _props$renderValue.toString == null ? void 0 : _props$renderValue.toString()) != null ? _toString : null;
2908
+ return (_props$renderValue$to = (_props$renderValue = props.renderValue()) == null ? void 0 : _props$renderValue.toString == null ? void 0 : _props$renderValue.toString()) != null ? _props$renderValue$to : null;
2897
2909
  },
2898
2910
  ...table._features.reduce((obj, feature) => {
2899
2911
  return Object.assign(obj, feature.getDefaultColumnDef == null ? void 0 : feature.getDefaultColumnDef());
@@ -3423,9 +3435,7 @@
3423
3435
  let facetedMinMaxValues = [firstValue, firstValue];
3424
3436
 
3425
3437
  for (let i = 0; i < facetedRowModel.flatRows.length; i++) {
3426
- var _facetedRowModel$flat2;
3427
-
3428
- const value = (_facetedRowModel$flat2 = facetedRowModel.flatRows[i]) == null ? void 0 : _facetedRowModel$flat2.getValue(columnId);
3438
+ const value = facetedRowModel.flatRows[i].getValue(columnId);
3429
3439
 
3430
3440
  if (value < facetedMinMaxValues[0]) {
3431
3441
  facetedMinMaxValues[0] = value;
@@ -3575,7 +3585,7 @@
3575
3585
  const subRows = groupUpRecursively(groupedRows, depth + 1, id); // Flatten the leaf rows of the rows in this group
3576
3586
 
3577
3587
  const leafRows = depth ? flattenBy(groupedRows, row => row.subRows) : groupedRows;
3578
- const row = createRow(table, id, undefined, index, depth);
3588
+ const row = createRow(table, id, leafRows[0].original, index, depth);
3579
3589
  Object.assign(row, {
3580
3590
  groupingColumnId: columnId,
3581
3591
  groupingValue,
@@ -3769,7 +3779,7 @@
3769
3779
  });
3770
3780
  }
3771
3781
 
3772
- /* packages/svelte-table/src/placeholder.svelte generated by Svelte v3.48.0 */
3782
+ /* packages/svelte-table/src/placeholder.svelte generated by Svelte v3.49.0 */
3773
3783
 
3774
3784
  function create_fragment$1(ctx) {
3775
3785
  let t;