@tanstack/svelte-table 8.9.0 → 8.9.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.
@@ -13,7 +13,7 @@ export * from '@tanstack/table-core';
13
13
  import { SvelteComponent, init, safe_not_equal, text, claim_text, insert_hydration, set_data, noop, detach, create_ssr_component, escape, validate_component, create_component, claim_component, mount_component, transition_in, transition_out, destroy_component } from 'svelte/internal';
14
14
  import { readable, get, writable, derived } from 'svelte/store';
15
15
 
16
- /* packages/svelte-table/src/placeholder.svelte generated by Svelte v3.58.0 */
16
+ /* packages/svelte-table/src/placeholder.svelte generated by Svelte v3.59.1 */
17
17
 
18
18
  function create_fragment$1(ctx) {
19
19
  let t;
@@ -13,7 +13,7 @@ export * from '@tanstack/table-core';
13
13
  import { SvelteComponent, init, safe_not_equal, text, claim_text, insert_hydration, set_data, noop, detach, create_ssr_component, escape, validate_component, create_component, claim_component, mount_component, transition_in, transition_out, destroy_component } from 'svelte/internal';
14
14
  import { readable, get, writable, derived } from 'svelte/store';
15
15
 
16
- /* packages/svelte-table/src/placeholder.svelte generated by Svelte v3.58.0 */
16
+ /* packages/svelte-table/src/placeholder.svelte generated by Svelte v3.59.1 */
17
17
 
18
18
  function create_fragment$1(ctx) {
19
19
  let t;
@@ -14,7 +14,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
14
14
 
15
15
  var internal = require('svelte/internal');
16
16
 
17
- /* packages/svelte-table/src/placeholder.svelte generated by Svelte v3.58.0 */
17
+ /* packages/svelte-table/src/placeholder.svelte generated by Svelte v3.59.1 */
18
18
 
19
19
  function create_fragment(ctx) {
20
20
  let t;
@@ -49,6 +49,9 @@
49
49
  function isFunction(d) {
50
50
  return d instanceof Function;
51
51
  }
52
+ function isNumberArray(d) {
53
+ return Array.isArray(d) && d.every(val => typeof val === 'number');
54
+ }
52
55
  function flattenBy(arr, getChildren) {
53
56
  const flat = [];
54
57
  const recurse = subArr => {
@@ -1295,16 +1298,16 @@
1295
1298
  if (!leafRows.length) {
1296
1299
  return;
1297
1300
  }
1298
- let min = 0;
1299
- let max = 0;
1300
- leafRows.forEach(row => {
1301
- let value = row.getValue(columnId);
1302
- if (typeof value === 'number') {
1303
- min = Math.min(min, value);
1304
- max = Math.max(max, value);
1305
- }
1306
- });
1307
- return (min + max) / 2;
1301
+ const values = leafRows.map(row => row.getValue(columnId));
1302
+ if (!isNumberArray(values)) {
1303
+ return;
1304
+ }
1305
+ if (values.length === 1) {
1306
+ return values[0];
1307
+ }
1308
+ const mid = Math.floor(values.length / 2);
1309
+ const nums = values.sort((a, b) => a - b);
1310
+ return values.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2;
1308
1311
  };
1309
1312
  const unique = (columnId, leafRows) => {
1310
1313
  return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values());
@@ -3370,7 +3373,11 @@
3370
3373
  const aUndefined = typeof aValue === 'undefined';
3371
3374
  const bUndefined = typeof bValue === 'undefined';
3372
3375
  if (aUndefined || bUndefined) {
3373
- return aUndefined && bUndefined ? 0 : aUndefined ? columnInfo.sortUndefined : -columnInfo.sortUndefined;
3376
+ let undefinedSort = aUndefined && bUndefined ? 0 : aUndefined ? columnInfo.sortUndefined : -columnInfo.sortUndefined;
3377
+ if (isDesc && undefinedSort !== 0) {
3378
+ undefinedSort *= -1;
3379
+ }
3380
+ return undefinedSort;
3374
3381
  }
3375
3382
  }
3376
3383
 
@@ -3642,7 +3649,7 @@
3642
3649
  });
3643
3650
  }
3644
3651
 
3645
- /* packages/svelte-table/src/placeholder.svelte generated by Svelte v3.58.0 */
3652
+ /* packages/svelte-table/src/placeholder.svelte generated by Svelte v3.59.1 */
3646
3653
 
3647
3654
  function create_fragment$1(ctx) {
3648
3655
  let t;
@@ -3860,6 +3867,7 @@
3860
3867
  exports.getPaginationRowModel = getPaginationRowModel;
3861
3868
  exports.getSortedRowModel = getSortedRowModel;
3862
3869
  exports.isFunction = isFunction;
3870
+ exports.isNumberArray = isNumberArray;
3863
3871
  exports.isRowSelected = isRowSelected;
3864
3872
  exports.isSubRowSelected = isSubRowSelected;
3865
3873
  exports.makeStateUpdater = makeStateUpdater;