@tanstack/table-core 8.0.0-alpha.86 → 8.0.0-alpha.87
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.
- package/build/cjs/features/Sorting.js.map +1 -1
- package/build/cjs/sortingFns.js +53 -51
- package/build/cjs/sortingFns.js.map +1 -1
- package/build/esm/index.js +53 -51
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +308 -308
- package/build/types/features/Sorting.d.ts +3 -3
- package/build/types/sortingFns.d.ts +7 -14
- package/build/umd/index.development.js +53 -51
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/features/Sorting.ts +4 -4
- package/src/sortingFns.ts +59 -81
|
@@ -9,13 +9,13 @@ export declare type ColumnSort = {
|
|
|
9
9
|
desc: boolean;
|
|
10
10
|
};
|
|
11
11
|
export declare type SortingState = ColumnSort[];
|
|
12
|
+
export declare type SortingTableState = {
|
|
13
|
+
sorting: SortingState;
|
|
14
|
+
};
|
|
12
15
|
export declare type SortingFn<TGenerics extends TableGenerics> = {
|
|
13
16
|
(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): number;
|
|
14
17
|
};
|
|
15
18
|
export declare type CustomSortingFns<TGenerics extends TableGenerics> = Record<string, SortingFn<TGenerics>>;
|
|
16
|
-
export declare type SortingTableState = {
|
|
17
|
-
sorting: SortingState;
|
|
18
|
-
};
|
|
19
19
|
export declare type SortingFnOption<TGenerics extends TableGenerics> = 'auto' | BuiltInSortingFn | keyof TGenerics['SortingFns'] | SortingFn<TGenerics>;
|
|
20
20
|
export declare type SortingColumnDef<TGenerics extends TableGenerics> = {
|
|
21
21
|
sortingFn?: SortingFnOption<Overwrite<TGenerics, {
|
|
@@ -1,18 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SortingFn } from './features/Sorting';
|
|
2
2
|
export declare const reSplitAlphaNumeric: RegExp;
|
|
3
3
|
export declare const sortingFns: {
|
|
4
|
-
alphanumeric:
|
|
5
|
-
alphanumericCaseSensitive:
|
|
6
|
-
text:
|
|
7
|
-
textCaseSensitive:
|
|
8
|
-
datetime:
|
|
9
|
-
basic:
|
|
4
|
+
alphanumeric: SortingFn<any>;
|
|
5
|
+
alphanumericCaseSensitive: SortingFn<any>;
|
|
6
|
+
text: SortingFn<any>;
|
|
7
|
+
textCaseSensitive: SortingFn<any>;
|
|
8
|
+
datetime: SortingFn<any>;
|
|
9
|
+
basic: SortingFn<any>;
|
|
10
10
|
};
|
|
11
11
|
export declare type BuiltInSortingFn = keyof typeof sortingFns;
|
|
12
|
-
declare function alphanumeric<TGenerics extends TableGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): number;
|
|
13
|
-
declare function alphanumericCaseSensitive<TGenerics extends TableGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): number;
|
|
14
|
-
declare function text<TGenerics extends TableGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): 1 | -1 | 0;
|
|
15
|
-
declare function textCaseSensitive<TGenerics extends TableGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): 1 | -1 | 0;
|
|
16
|
-
declare function datetime<TGenerics extends TableGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): 1 | -1 | 0;
|
|
17
|
-
declare function basic<TGenerics extends TableGenerics>(rowA: Row<TGenerics>, rowB: Row<TGenerics>, columnId: string): 1 | -1 | 0;
|
|
18
|
-
export {};
|
|
@@ -2334,21 +2334,54 @@
|
|
|
2334
2334
|
}
|
|
2335
2335
|
|
|
2336
2336
|
const reSplitAlphaNumeric = /([0-9]+)/gm;
|
|
2337
|
-
const sortingFns = {
|
|
2338
|
-
alphanumeric,
|
|
2339
|
-
alphanumericCaseSensitive,
|
|
2340
|
-
text,
|
|
2341
|
-
textCaseSensitive,
|
|
2342
|
-
datetime,
|
|
2343
|
-
basic
|
|
2344
|
-
};
|
|
2345
2337
|
|
|
2346
|
-
|
|
2338
|
+
const alphanumeric = (rowA, rowB, columnId) => {
|
|
2347
2339
|
return compareAlphanumeric(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2348
|
-
}
|
|
2340
|
+
};
|
|
2349
2341
|
|
|
2350
|
-
|
|
2342
|
+
const alphanumericCaseSensitive = (rowA, rowB, columnId) => {
|
|
2351
2343
|
return compareAlphanumeric(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
|
2344
|
+
}; // The text filter is more basic (less numeric support)
|
|
2345
|
+
// but is much faster
|
|
2346
|
+
|
|
2347
|
+
|
|
2348
|
+
const text = (rowA, rowB, columnId) => {
|
|
2349
|
+
return compareBasic(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2350
|
+
}; // The text filter is more basic (less numeric support)
|
|
2351
|
+
// but is much faster
|
|
2352
|
+
|
|
2353
|
+
|
|
2354
|
+
const textCaseSensitive = (rowA, rowB, columnId) => {
|
|
2355
|
+
return compareBasic(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
|
2356
|
+
};
|
|
2357
|
+
|
|
2358
|
+
const datetime = (rowA, rowB, columnId) => {
|
|
2359
|
+
return compareBasic(rowA.getValue(columnId).getTime(), rowB.getValue(columnId).getTime());
|
|
2360
|
+
};
|
|
2361
|
+
|
|
2362
|
+
const basic = (rowA, rowB, columnId) => {
|
|
2363
|
+
return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
|
|
2364
|
+
}; // Utils
|
|
2365
|
+
|
|
2366
|
+
|
|
2367
|
+
function compareBasic(a, b) {
|
|
2368
|
+
return a === b ? 0 : a > b ? 1 : -1;
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
function toString(a) {
|
|
2372
|
+
if (typeof a === 'number') {
|
|
2373
|
+
if (isNaN(a) || a === Infinity || a === -Infinity) {
|
|
2374
|
+
return '';
|
|
2375
|
+
}
|
|
2376
|
+
|
|
2377
|
+
return String(a);
|
|
2378
|
+
}
|
|
2379
|
+
|
|
2380
|
+
if (typeof a === 'string') {
|
|
2381
|
+
return a;
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
return '';
|
|
2352
2385
|
} // Mixed sorting is slow, but very inclusive of many edge cases.
|
|
2353
2386
|
// It handles numbers, mixed alphanumeric combinations, and even
|
|
2354
2387
|
// null, undefined, and Infinity
|
|
@@ -2395,48 +2428,17 @@
|
|
|
2395
2428
|
}
|
|
2396
2429
|
|
|
2397
2430
|
return a.length - b.length;
|
|
2398
|
-
} //
|
|
2399
|
-
// but is much faster
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
function text(rowA, rowB, columnId) {
|
|
2403
|
-
return compareBasic(toString(rowA.getValue(columnId)).toLowerCase(), toString(rowB.getValue(columnId)).toLowerCase());
|
|
2404
|
-
} // The text filter is more basic (less numeric support)
|
|
2405
|
-
// but is much faster
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
function textCaseSensitive(rowA, rowB, columnId) {
|
|
2409
|
-
return compareBasic(toString(rowA.getValue(columnId)), toString(rowB.getValue(columnId)));
|
|
2410
|
-
}
|
|
2411
|
-
|
|
2412
|
-
function datetime(rowA, rowB, columnId) {
|
|
2413
|
-
return compareBasic(rowA.getValue(columnId).getTime(), rowB.getValue(columnId).getTime());
|
|
2414
|
-
}
|
|
2415
|
-
|
|
2416
|
-
function basic(rowA, rowB, columnId) {
|
|
2417
|
-
return compareBasic(rowA.getValue(columnId), rowB.getValue(columnId));
|
|
2418
|
-
} // Utils
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
function compareBasic(a, b) {
|
|
2422
|
-
return a === b ? 0 : a > b ? 1 : -1;
|
|
2423
|
-
}
|
|
2424
|
-
|
|
2425
|
-
function toString(a) {
|
|
2426
|
-
if (typeof a === 'number') {
|
|
2427
|
-
if (isNaN(a) || a === Infinity || a === -Infinity) {
|
|
2428
|
-
return '';
|
|
2429
|
-
}
|
|
2431
|
+
} // Exports
|
|
2430
2432
|
|
|
2431
|
-
return String(a);
|
|
2432
|
-
}
|
|
2433
|
-
|
|
2434
|
-
if (typeof a === 'string') {
|
|
2435
|
-
return a;
|
|
2436
|
-
}
|
|
2437
2433
|
|
|
2438
|
-
|
|
2439
|
-
|
|
2434
|
+
const sortingFns = {
|
|
2435
|
+
alphanumeric,
|
|
2436
|
+
alphanumericCaseSensitive,
|
|
2437
|
+
text,
|
|
2438
|
+
textCaseSensitive,
|
|
2439
|
+
datetime,
|
|
2440
|
+
basic
|
|
2441
|
+
};
|
|
2440
2442
|
|
|
2441
2443
|
//
|
|
2442
2444
|
const Sorting = {
|