@infinite-table/infinite-react 9.0.0-canary.0 → 9.0.0
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/README.md +10 -0
- package/index.dev.js +324 -56
- package/index.dev.mjs +324 -56
- package/index.js +8 -8
- package/index.mjs +8 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
- [🤔 What is Infinite Table?](#-what-is-infinite-table)
|
|
22
22
|
- [📦 Installation](#-installation)
|
|
23
23
|
- [📄 Extensive documentation](#-extensive-documentation)
|
|
24
|
+
- [⚖️ Compare](#-compare)
|
|
24
25
|
- [❤️ TypeScript](#-typescript)
|
|
25
26
|
- [🏢 Enterprise-ready](#-enterprise-ready)
|
|
26
27
|
- [🔒 Secure by default](#-secure-by-default)
|
|
@@ -76,6 +77,15 @@ Our approach with the `InfiniteTable` is to go documentation first. From our dev
|
|
|
76
77
|
|
|
77
78
|
**[Visit our docs and getting-started guide](https://infinite-table.com/docs)**
|
|
78
79
|
|
|
80
|
+
## ⚖️ Compare
|
|
81
|
+
|
|
82
|
+
Choosing a React DataGrid is a big decision. We've put together honest comparisons so you can see where Infinite Table fits — particularly if you value a component that feels native to React (hooks, controlled/uncontrolled props).
|
|
83
|
+
|
|
84
|
+
- [Overview](https://infinite-table.com/docs/learn/compare)
|
|
85
|
+
- [vs AG Grid](https://infinite-table.com/docs/learn/compare/ag-grid)
|
|
86
|
+
- [vs TanStack Table](https://infinite-table.com/docs/learn/compare/tanstack-table)
|
|
87
|
+
- [vs MUI X Data Grid](https://infinite-table.com/docs/learn/compare/mui-x-data-grid)
|
|
88
|
+
|
|
79
89
|
## ❤️ TypeScript
|
|
80
90
|
|
|
81
91
|
It's fully typed and offers you great developer experience to help you get up and running quickly
|
package/index.dev.js
CHANGED
|
@@ -2552,6 +2552,30 @@ function FilterIcon(props) {
|
|
|
2552
2552
|
);
|
|
2553
2553
|
}
|
|
2554
2554
|
|
|
2555
|
+
// src/components/InfiniteTable/utils/getColumnComputedType.ts
|
|
2556
|
+
var emptyType = Object.freeze({});
|
|
2557
|
+
var defaultFilterTypes = {
|
|
2558
|
+
string: emptyType,
|
|
2559
|
+
number: {}
|
|
2560
|
+
};
|
|
2561
|
+
function getColumnComputedType(column, columnTypes) {
|
|
2562
|
+
const defaultType = columnTypes["default"] || emptyType;
|
|
2563
|
+
if (column.type === void 0) {
|
|
2564
|
+
return defaultType;
|
|
2565
|
+
}
|
|
2566
|
+
if (column.type === null) {
|
|
2567
|
+
return emptyType;
|
|
2568
|
+
}
|
|
2569
|
+
if (typeof column.type === "string") {
|
|
2570
|
+
const type = columnTypes[column.type] || defaultFilterTypes[column.type] || emptyType;
|
|
2571
|
+
return type;
|
|
2572
|
+
}
|
|
2573
|
+
return column.type.reduce(
|
|
2574
|
+
(acc, columnType) => Object.assign(acc, columnTypes[columnType]),
|
|
2575
|
+
{}
|
|
2576
|
+
);
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2555
2579
|
// src/components/flexbox/index.ts
|
|
2556
2580
|
var computeFlex = (params) => {
|
|
2557
2581
|
const {
|
|
@@ -2986,30 +3010,6 @@ function assignExcept(exceptKeys, target, ...rest) {
|
|
|
2986
3010
|
return assignFiltered((_value, key) => !(key in exceptKeys), target, ...rest);
|
|
2987
3011
|
}
|
|
2988
3012
|
|
|
2989
|
-
// src/components/InfiniteTable/utils/getColumnComputedType.ts
|
|
2990
|
-
var emptyType = Object.freeze({});
|
|
2991
|
-
var defaultFilterTypes = {
|
|
2992
|
-
string: emptyType,
|
|
2993
|
-
number: {}
|
|
2994
|
-
};
|
|
2995
|
-
function getColumnComputedType(column, columnTypes) {
|
|
2996
|
-
const defaultType = columnTypes["default"] || emptyType;
|
|
2997
|
-
if (column.type === void 0) {
|
|
2998
|
-
return defaultType;
|
|
2999
|
-
}
|
|
3000
|
-
if (column.type === null) {
|
|
3001
|
-
return emptyType;
|
|
3002
|
-
}
|
|
3003
|
-
if (typeof column.type === "string") {
|
|
3004
|
-
const type = columnTypes[column.type] || defaultFilterTypes[column.type] || emptyType;
|
|
3005
|
-
return type;
|
|
3006
|
-
}
|
|
3007
|
-
return column.type.reduce(
|
|
3008
|
-
(acc, columnType) => Object.assign(acc, columnTypes[columnType]),
|
|
3009
|
-
{}
|
|
3010
|
-
);
|
|
3011
|
-
}
|
|
3012
|
-
|
|
3013
3013
|
// src/components/InfiniteTable/utils/getComputedColumns.ts
|
|
3014
3014
|
var DEFAULT_SORTABLE = true;
|
|
3015
3015
|
var DEFAULT_RESIZABLE = true;
|
|
@@ -3028,8 +3028,63 @@ var getComputedPinned = (colId, columnPinning) => {
|
|
|
3028
3028
|
const computedPinned = pinned === "start" || pinned === true ? "start" : pinned === "end" ? "end" : false;
|
|
3029
3029
|
return computedPinned;
|
|
3030
3030
|
};
|
|
3031
|
+
function findColumnForField(columns, field) {
|
|
3032
|
+
if (!columns) {
|
|
3033
|
+
return void 0;
|
|
3034
|
+
}
|
|
3035
|
+
if (columns[field]) {
|
|
3036
|
+
return columns[field];
|
|
3037
|
+
}
|
|
3038
|
+
return Object.values(columns).find((col) => col.field === field);
|
|
3039
|
+
}
|
|
3040
|
+
function getSortTypeFromUserColumn(column, columnTypes) {
|
|
3041
|
+
const colType = getColumnComputedType(column, columnTypes);
|
|
3042
|
+
if (column.sortType) {
|
|
3043
|
+
return column.sortType;
|
|
3044
|
+
}
|
|
3045
|
+
if (colType.sortType) {
|
|
3046
|
+
return colType.sortType;
|
|
3047
|
+
}
|
|
3048
|
+
if (typeof column.type === "string") {
|
|
3049
|
+
return column.type;
|
|
3050
|
+
}
|
|
3051
|
+
return DEFAULT_DATA_TYPE;
|
|
3052
|
+
}
|
|
3053
|
+
function getSortTypeForGroupByFromUserColumns(groupByForColumn, userColumns, columnTypes) {
|
|
3054
|
+
const list = Array.isArray(groupByForColumn) ? groupByForColumn : groupByForColumn ? [groupByForColumn] : [];
|
|
3055
|
+
const types = list.flatMap((groupBy) => {
|
|
3056
|
+
const field = groupBy.field ?? groupBy.groupField;
|
|
3057
|
+
if (!field) {
|
|
3058
|
+
return [UNKNOWN_SORT_TYPE];
|
|
3059
|
+
}
|
|
3060
|
+
const userCol = findColumnForField(userColumns, field);
|
|
3061
|
+
if (!userCol) {
|
|
3062
|
+
return [UNKNOWN_SORT_TYPE];
|
|
3063
|
+
}
|
|
3064
|
+
const sortType = getSortTypeFromUserColumn(userCol, columnTypes);
|
|
3065
|
+
return Array.isArray(sortType) ? sortType : [sortType];
|
|
3066
|
+
});
|
|
3067
|
+
if (types.every((type) => type === UNKNOWN_SORT_TYPE)) {
|
|
3068
|
+
return UNKNOWN_SORT_TYPE;
|
|
3069
|
+
}
|
|
3070
|
+
return types.length === 1 ? types[0] : types;
|
|
3071
|
+
}
|
|
3072
|
+
function getColumnComputedSortable(column, options) {
|
|
3073
|
+
const { colType, sortable, columnDefaultSortable } = options;
|
|
3074
|
+
let sortableColumnOrType = column.defaultSortable ?? colType.defaultSortable;
|
|
3075
|
+
const isGroupColumn = !!column.groupByForColumn;
|
|
3076
|
+
if (sortableColumnOrType == null && !isGroupColumn) {
|
|
3077
|
+
const field = column.field ?? colType.field;
|
|
3078
|
+
const valueGetter = column.valueGetter ?? colType.valueGetter;
|
|
3079
|
+
if (field == null && valueGetter == null) {
|
|
3080
|
+
sortableColumnOrType = false;
|
|
3081
|
+
}
|
|
3082
|
+
}
|
|
3083
|
+
return sortable ?? sortableColumnOrType ?? columnDefaultSortable ?? DEFAULT_SORTABLE;
|
|
3084
|
+
}
|
|
3031
3085
|
var getComputedColumns = ({
|
|
3032
3086
|
columns,
|
|
3087
|
+
userColumns,
|
|
3033
3088
|
bodySize,
|
|
3034
3089
|
columnMinWidth,
|
|
3035
3090
|
columnMaxWidth,
|
|
@@ -3283,15 +3338,13 @@ var getComputedColumns = ({
|
|
|
3283
3338
|
if (c.groupByForColumn) {
|
|
3284
3339
|
computedGroupable = false;
|
|
3285
3340
|
}
|
|
3286
|
-
let sortableColumnOrType = c.defaultSortable ?? colType.defaultSortable;
|
|
3287
|
-
if (sortableColumnOrType == null && !c.groupByForColumn) {
|
|
3288
|
-
if (field == null && valueGetter == null) {
|
|
3289
|
-
sortableColumnOrType = false;
|
|
3290
|
-
}
|
|
3291
|
-
}
|
|
3292
3341
|
const computedGroupedBy = field ? groupByFields[field] !== void 0 : false;
|
|
3293
3342
|
const computedGroupedByIndex = computedGroupedBy ? groupByFields[field] : void 0;
|
|
3294
|
-
|
|
3343
|
+
const computedSortable = getColumnComputedSortable(c, {
|
|
3344
|
+
colType,
|
|
3345
|
+
sortable,
|
|
3346
|
+
columnDefaultSortable
|
|
3347
|
+
});
|
|
3295
3348
|
const computedResizable = c.resizable ?? colType.resizable ?? resizableColumns ?? DEFAULT_RESIZABLE;
|
|
3296
3349
|
const result2 = {
|
|
3297
3350
|
colType,
|
|
@@ -3381,7 +3434,11 @@ var getComputedColumns = ({
|
|
|
3381
3434
|
prevPinned = computedPinned;
|
|
3382
3435
|
}
|
|
3383
3436
|
if (result2.groupByForColumn) {
|
|
3384
|
-
result2.computedSortType = c.sortType || colType.sortType ||
|
|
3437
|
+
result2.computedSortType = c.sortType || colType.sortType || getSortTypeForGroupByFromUserColumns(
|
|
3438
|
+
result2.groupByForColumn,
|
|
3439
|
+
userColumns,
|
|
3440
|
+
columnTypes
|
|
3441
|
+
);
|
|
3385
3442
|
groupColumns.push(result2);
|
|
3386
3443
|
}
|
|
3387
3444
|
computedColumnsMap.set(result2.id, result2);
|
|
@@ -3393,6 +3450,8 @@ var getComputedColumns = ({
|
|
|
3393
3450
|
groupColumns.forEach((col) => {
|
|
3394
3451
|
col.computedSortable = isGroupColumnSortable(col, {
|
|
3395
3452
|
fieldsToColumn,
|
|
3453
|
+
userColumns,
|
|
3454
|
+
columnTypes,
|
|
3396
3455
|
sortable,
|
|
3397
3456
|
columnDefaultSortable
|
|
3398
3457
|
});
|
|
@@ -3441,7 +3500,13 @@ var getComputedColumns = ({
|
|
|
3441
3500
|
|
|
3442
3501
|
// src/components/InfiniteTable/api/getColumnApi.ts
|
|
3443
3502
|
function isGroupColumnSortable(column, options) {
|
|
3444
|
-
const {
|
|
3503
|
+
const {
|
|
3504
|
+
sortable,
|
|
3505
|
+
fieldsToColumn,
|
|
3506
|
+
columnDefaultSortable,
|
|
3507
|
+
userColumns,
|
|
3508
|
+
columnTypes
|
|
3509
|
+
} = options;
|
|
3445
3510
|
if (sortable) {
|
|
3446
3511
|
return sortable;
|
|
3447
3512
|
}
|
|
@@ -3450,7 +3515,8 @@ function isGroupColumnSortable(column, options) {
|
|
|
3450
3515
|
return sortableColumnOrType;
|
|
3451
3516
|
}
|
|
3452
3517
|
const defaultSortable = columnDefaultSortable ?? DEFAULT_SORTABLE;
|
|
3453
|
-
|
|
3518
|
+
const explicitSortType = column.sortType ?? column.colType.sortType;
|
|
3519
|
+
if (explicitSortType != null && explicitSortType !== UNKNOWN_SORT_TYPE && defaultSortable) {
|
|
3454
3520
|
return true;
|
|
3455
3521
|
}
|
|
3456
3522
|
const isSortable = (params) => {
|
|
@@ -3471,7 +3537,17 @@ function isGroupColumnSortable(column, options) {
|
|
|
3471
3537
|
if (foundCol && foundColApi) {
|
|
3472
3538
|
colSortable = foundColApi.isSortable();
|
|
3473
3539
|
} else {
|
|
3474
|
-
|
|
3540
|
+
const userCol = findColumnForField(userColumns, field);
|
|
3541
|
+
if (userCol) {
|
|
3542
|
+
const userSortable = getColumnComputedSortable(userCol, {
|
|
3543
|
+
colType: getColumnComputedType(userCol, columnTypes ?? {}),
|
|
3544
|
+
sortable,
|
|
3545
|
+
columnDefaultSortable
|
|
3546
|
+
});
|
|
3547
|
+
colSortable = typeof userSortable === "boolean" ? userSortable : void 0;
|
|
3548
|
+
} else {
|
|
3549
|
+
colSortable = false;
|
|
3550
|
+
}
|
|
3475
3551
|
}
|
|
3476
3552
|
}
|
|
3477
3553
|
if (colSortable === void 0 && groupBy.valueGetter) {
|
|
@@ -6213,7 +6289,6 @@ var useColumnPointerEvents = ({
|
|
|
6213
6289
|
const pointerId = e2.pointerId;
|
|
6214
6290
|
requestAnimationFrame(() => {
|
|
6215
6291
|
const { multiSortBehavior } = getState();
|
|
6216
|
-
const target2 = domRef.current;
|
|
6217
6292
|
const rootNode = rootRef.current;
|
|
6218
6293
|
rootNode?.classList.remove(InfiniteClsShiftingColumns);
|
|
6219
6294
|
dragger.stop();
|
|
@@ -6222,10 +6297,12 @@ var useColumnPointerEvents = ({
|
|
|
6222
6297
|
});
|
|
6223
6298
|
discardAlwaysRenderedColumn?.();
|
|
6224
6299
|
restoreRenderRange?.();
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6300
|
+
target.style.cursor = initialCursor;
|
|
6301
|
+
if (target.hasPointerCapture?.(pointerId)) {
|
|
6302
|
+
target.releasePointerCapture(pointerId);
|
|
6303
|
+
}
|
|
6304
|
+
target.removeEventListener("pointermove", onPointerMove);
|
|
6305
|
+
target.removeEventListener("pointerup", onPointerUp);
|
|
6229
6306
|
setProxyPosition(null);
|
|
6230
6307
|
const dragColumnSortable = api.getColumnApi(dragColumn.id)?.isSortable() ?? false;
|
|
6231
6308
|
if (!didDragAtLeastOnce && dragColumnSortable) {
|
|
@@ -20927,6 +21004,175 @@ function getDataSourceStateRestoreForDetails(state) {
|
|
|
20927
21004
|
};
|
|
20928
21005
|
}
|
|
20929
21006
|
|
|
21007
|
+
// src/components/DataSource/state/enrichSortInfoFromGroupBy.ts
|
|
21008
|
+
var GROUP_COLUMN_ID = "group-by";
|
|
21009
|
+
var GROUP_COLUMN_ID_PREFIX = "group-by-";
|
|
21010
|
+
function getSortFieldsForGroupBy(groupBy) {
|
|
21011
|
+
const fields = groupBy.map((g) => {
|
|
21012
|
+
if (g.valueGetter) {
|
|
21013
|
+
return (item) => g.valueGetter({ data: item, field: g.field });
|
|
21014
|
+
}
|
|
21015
|
+
return g.field ?? g.groupField;
|
|
21016
|
+
}).filter(Boolean);
|
|
21017
|
+
if (!fields.length) {
|
|
21018
|
+
return void 0;
|
|
21019
|
+
}
|
|
21020
|
+
if (fields.length === 1 && typeof fields[0] !== "function") {
|
|
21021
|
+
return fields[0];
|
|
21022
|
+
}
|
|
21023
|
+
return fields;
|
|
21024
|
+
}
|
|
21025
|
+
function enrichSortInfoFromGroupBy(sortInfo, groupBy) {
|
|
21026
|
+
if (!sortInfo?.length || !groupBy?.length) {
|
|
21027
|
+
return sortInfo;
|
|
21028
|
+
}
|
|
21029
|
+
let changed = false;
|
|
21030
|
+
const next = sortInfo.map((info) => {
|
|
21031
|
+
if (info.field != null || !info.id) {
|
|
21032
|
+
return info;
|
|
21033
|
+
}
|
|
21034
|
+
if (info.id === GROUP_COLUMN_ID) {
|
|
21035
|
+
const field = getSortFieldsForGroupBy(groupBy);
|
|
21036
|
+
if (field == null) {
|
|
21037
|
+
return info;
|
|
21038
|
+
}
|
|
21039
|
+
changed = true;
|
|
21040
|
+
return { ...info, field };
|
|
21041
|
+
}
|
|
21042
|
+
if (info.id.startsWith(GROUP_COLUMN_ID_PREFIX)) {
|
|
21043
|
+
const key = info.id.slice(GROUP_COLUMN_ID_PREFIX.length);
|
|
21044
|
+
const match = groupBy.find(
|
|
21045
|
+
(g) => String(g.field) === key || g.groupField === key
|
|
21046
|
+
);
|
|
21047
|
+
if (!match) {
|
|
21048
|
+
return info;
|
|
21049
|
+
}
|
|
21050
|
+
const field = getSortFieldsForGroupBy([match]);
|
|
21051
|
+
if (field == null) {
|
|
21052
|
+
return info;
|
|
21053
|
+
}
|
|
21054
|
+
changed = true;
|
|
21055
|
+
return { ...info, field };
|
|
21056
|
+
}
|
|
21057
|
+
return info;
|
|
21058
|
+
});
|
|
21059
|
+
return changed ? next : sortInfo;
|
|
21060
|
+
}
|
|
21061
|
+
|
|
21062
|
+
// src/components/DataSource/state/sortGroupedRowInfosByPivotColumns.ts
|
|
21063
|
+
function getRowNesting(row) {
|
|
21064
|
+
return "groupNesting" in row ? row.groupNesting ?? 0 : 0;
|
|
21065
|
+
}
|
|
21066
|
+
function getPivotCellValue(row, sort) {
|
|
21067
|
+
if (!row.isGroupRow || !sort.reducerId) {
|
|
21068
|
+
return void 0;
|
|
21069
|
+
}
|
|
21070
|
+
if (sort.pivotTotalColumn && (!sort.pivotGroupKeys || sort.pivotGroupKeys.length === 0)) {
|
|
21071
|
+
return row.reducerResults?.[sort.reducerId];
|
|
21072
|
+
}
|
|
21073
|
+
return row.pivotValuesMap?.get(sort.pivotGroupKeys)?.reducerResults?.[sort.reducerId];
|
|
21074
|
+
}
|
|
21075
|
+
function comparePivotValues(a, b, sort, sortTypes) {
|
|
21076
|
+
if (a == null && b == null) {
|
|
21077
|
+
return 0;
|
|
21078
|
+
}
|
|
21079
|
+
if (a == null) {
|
|
21080
|
+
return 1;
|
|
21081
|
+
}
|
|
21082
|
+
if (b == null) {
|
|
21083
|
+
return -1;
|
|
21084
|
+
}
|
|
21085
|
+
const type = Array.isArray(sort.type) ? sort.type[0] : sort.type;
|
|
21086
|
+
const fn = sort.fn || type && sortTypes[type] || sortTypes.string || sortTypes_default.string;
|
|
21087
|
+
const result = fn(a, b);
|
|
21088
|
+
return result === 0 ? 0 : sort.dir * result;
|
|
21089
|
+
}
|
|
21090
|
+
function toPivotSorts(sortInfo, pivotColumns) {
|
|
21091
|
+
if (!sortInfo?.length || !pivotColumns) {
|
|
21092
|
+
return [];
|
|
21093
|
+
}
|
|
21094
|
+
const result = [];
|
|
21095
|
+
for (const info of sortInfo) {
|
|
21096
|
+
const col = info.id ? pivotColumns[info.id] : void 0;
|
|
21097
|
+
if (!col?.pivotColumn || !col.pivotAggregator) {
|
|
21098
|
+
continue;
|
|
21099
|
+
}
|
|
21100
|
+
result.push({
|
|
21101
|
+
dir: info.dir,
|
|
21102
|
+
type: info.type,
|
|
21103
|
+
fn: info.fn,
|
|
21104
|
+
pivotGroupKeys: col.pivotGroupKeys ?? [],
|
|
21105
|
+
reducerId: col.pivotAggregator.id,
|
|
21106
|
+
pivotTotalColumn: !!col.pivotTotalColumn
|
|
21107
|
+
});
|
|
21108
|
+
}
|
|
21109
|
+
return result;
|
|
21110
|
+
}
|
|
21111
|
+
function buildTree(rows) {
|
|
21112
|
+
const roots = [];
|
|
21113
|
+
const stack = [];
|
|
21114
|
+
for (const row of rows) {
|
|
21115
|
+
const node = { row, children: [] };
|
|
21116
|
+
const nesting = getRowNesting(row);
|
|
21117
|
+
while (stack.length && getRowNesting(stack[stack.length - 1].row) >= nesting) {
|
|
21118
|
+
stack.pop();
|
|
21119
|
+
}
|
|
21120
|
+
if (!stack.length) {
|
|
21121
|
+
roots.push(node);
|
|
21122
|
+
} else {
|
|
21123
|
+
stack[stack.length - 1].children.push(node);
|
|
21124
|
+
}
|
|
21125
|
+
stack.push(node);
|
|
21126
|
+
}
|
|
21127
|
+
return roots;
|
|
21128
|
+
}
|
|
21129
|
+
function flattenSortedTree(roots) {
|
|
21130
|
+
const result = [];
|
|
21131
|
+
const walk = (nodes, parentIndexes) => {
|
|
21132
|
+
nodes.forEach((node, indexInGroup) => {
|
|
21133
|
+
const indexInParentGroups = [...parentIndexes, indexInGroup];
|
|
21134
|
+
const row = node.row;
|
|
21135
|
+
row.indexInGroup = indexInGroup;
|
|
21136
|
+
row.indexInParentGroups = indexInParentGroups;
|
|
21137
|
+
row.indexInAll = result.length;
|
|
21138
|
+
result.push(row);
|
|
21139
|
+
walk(node.children, indexInParentGroups);
|
|
21140
|
+
});
|
|
21141
|
+
};
|
|
21142
|
+
walk(roots, []);
|
|
21143
|
+
return result;
|
|
21144
|
+
}
|
|
21145
|
+
function sortGroupedRowInfosByPivotColumns(dataArray, sortInfo, pivotColumns, sortTypes) {
|
|
21146
|
+
const pivotSorts = toPivotSorts(sortInfo, pivotColumns);
|
|
21147
|
+
if (!pivotSorts.length || !dataArray.length) {
|
|
21148
|
+
return dataArray;
|
|
21149
|
+
}
|
|
21150
|
+
const knownSortTypes = { ...sortTypes_default, ...sortTypes };
|
|
21151
|
+
const roots = buildTree(dataArray);
|
|
21152
|
+
const compareNodes = (a, b) => {
|
|
21153
|
+
for (const sort of pivotSorts) {
|
|
21154
|
+
const result = comparePivotValues(
|
|
21155
|
+
getPivotCellValue(a.row, sort),
|
|
21156
|
+
getPivotCellValue(b.row, sort),
|
|
21157
|
+
sort,
|
|
21158
|
+
knownSortTypes
|
|
21159
|
+
);
|
|
21160
|
+
if (result !== 0) {
|
|
21161
|
+
return result;
|
|
21162
|
+
}
|
|
21163
|
+
}
|
|
21164
|
+
return 0;
|
|
21165
|
+
};
|
|
21166
|
+
const sortTree = (nodes) => {
|
|
21167
|
+
nodes.sort(compareNodes);
|
|
21168
|
+
for (const node of nodes) {
|
|
21169
|
+
sortTree(node.children);
|
|
21170
|
+
}
|
|
21171
|
+
};
|
|
21172
|
+
sortTree(roots);
|
|
21173
|
+
return flattenSortedTree(roots);
|
|
21174
|
+
}
|
|
21175
|
+
|
|
20930
21176
|
// src/components/DataSource/state/reducer.ts
|
|
20931
21177
|
function cleanupEmptyFilterValues(filterValue, filterTypes) {
|
|
20932
21178
|
if (!filterValue) {
|
|
@@ -21147,7 +21393,7 @@ function concludeReducer(params) {
|
|
|
21147
21393
|
rootMarker = getMarker(debugId).track.DataSource.label.PrepareData.start();
|
|
21148
21394
|
}
|
|
21149
21395
|
const cacheAffectedParts = getCacheAffectedParts(state);
|
|
21150
|
-
const sortInfo = state.sortInfo;
|
|
21396
|
+
const sortInfo = enrichSortInfoFromGroupBy(state.sortInfo, state.groupBy);
|
|
21151
21397
|
const sortMode = state.sortMode;
|
|
21152
21398
|
let shouldSort = !!sortInfo?.length ? sortMode === "local" : false;
|
|
21153
21399
|
if (state.lazyLoad || state.livePagination) {
|
|
@@ -21510,6 +21756,16 @@ function concludeReducer(params) {
|
|
|
21510
21756
|
}) : void 0;
|
|
21511
21757
|
state.pivotColumns = pivotGroupsAndCols?.columns;
|
|
21512
21758
|
state.pivotColumnGroups = pivotGroupsAndCols?.columnGroups;
|
|
21759
|
+
const pivotSortedRowInfos = sortGroupedRowInfosByPivotColumns(
|
|
21760
|
+
rowInfoDataArray,
|
|
21761
|
+
sortInfo,
|
|
21762
|
+
state.pivotColumns,
|
|
21763
|
+
state.sortTypes
|
|
21764
|
+
);
|
|
21765
|
+
if (pivotSortedRowInfos !== rowInfoDataArray) {
|
|
21766
|
+
rowInfoDataArray = pivotSortedRowInfos;
|
|
21767
|
+
state.groupRowsIndexesInDataArray = rowInfoDataArray.map((row, index) => row.isGroupRow ? index : -1).filter((index) => index >= 0);
|
|
21768
|
+
}
|
|
21513
21769
|
if (state.devToolsDetected) {
|
|
21514
21770
|
state.debugTimings.set("group-and-pivot", Date.now() - groupTimestamp);
|
|
21515
21771
|
}
|
|
@@ -21752,7 +22008,11 @@ var DATA_CHANGES_COMPARE_FUNCTIONS = {
|
|
|
21752
22008
|
}
|
|
21753
22009
|
};
|
|
21754
22010
|
function buildDataSourceDataParams(componentState, overrides, masterContext) {
|
|
21755
|
-
const
|
|
22011
|
+
const resolvedSortInfo = enrichSortInfoFromGroupBy(
|
|
22012
|
+
componentState.sortInfo,
|
|
22013
|
+
componentState.groupBy
|
|
22014
|
+
);
|
|
22015
|
+
const sortInfo = componentState.multiSort ? resolvedSortInfo : resolvedSortInfo?.[0] ?? null;
|
|
21756
22016
|
const dataSourceParams = {
|
|
21757
22017
|
append: false,
|
|
21758
22018
|
originalDataArray: componentState.originalDataArray,
|
|
@@ -23497,8 +23757,9 @@ var InfiniteTableApiImpl = class {
|
|
|
23497
23757
|
this.setSortInfoForColumn(columnId, null, options);
|
|
23498
23758
|
return;
|
|
23499
23759
|
}
|
|
23760
|
+
const isPivotColumn = !!c.pivotColumn;
|
|
23500
23761
|
const groupByForColumn = c.groupByForColumn;
|
|
23501
|
-
let field = c.field;
|
|
23762
|
+
let field = isPivotColumn ? void 0 : c.field;
|
|
23502
23763
|
const groupByForCol = groupByForColumn ? Array.isArray(groupByForColumn) ? groupByForColumn : [groupByForColumn] : [];
|
|
23503
23764
|
const fieldArr = groupByForCol.map((c2) => {
|
|
23504
23765
|
return c2.valueGetter ? (item) => c2.valueGetter({ data: item, field: c2.field }) : c2.field ? c2.field : c2.groupField ?? void 0;
|
|
@@ -23508,23 +23769,32 @@ var InfiniteTableApiImpl = class {
|
|
|
23508
23769
|
}
|
|
23509
23770
|
let computedSortType = c.computedSortType;
|
|
23510
23771
|
if (groupByForCol.length && computedSortType === UNKNOWN_SORT_TYPE) {
|
|
23772
|
+
const userColumns = this.getState().initialColumns;
|
|
23511
23773
|
const sortTypeForGroupCols = groupByForCol.flatMap((groupBy) => {
|
|
23512
23774
|
const field2 = groupBy.field ?? groupBy.groupField;
|
|
23513
23775
|
const col = field2 ? computedColumnsMap.get(field2) : null;
|
|
23514
|
-
if (
|
|
23515
|
-
return
|
|
23776
|
+
if (col) {
|
|
23777
|
+
return col.computedSortType;
|
|
23778
|
+
}
|
|
23779
|
+
const userCol = field2 ? findColumnForField(userColumns, field2) : void 0;
|
|
23780
|
+
if (userCol) {
|
|
23781
|
+
const type = userCol.sortType || (typeof userCol.type === "string" ? userCol.type : "string");
|
|
23782
|
+
return type;
|
|
23516
23783
|
}
|
|
23517
|
-
return
|
|
23784
|
+
return [UNKNOWN_SORT_TYPE];
|
|
23518
23785
|
});
|
|
23519
23786
|
computedSortType = sortTypeForGroupCols;
|
|
23520
23787
|
}
|
|
23788
|
+
if (groupByForCol.length && !Array.isArray(computedSortType)) {
|
|
23789
|
+
computedSortType = [computedSortType];
|
|
23790
|
+
}
|
|
23521
23791
|
const newColumnSortInfo = {
|
|
23522
23792
|
dir,
|
|
23523
23793
|
id: c.id,
|
|
23524
23794
|
field,
|
|
23525
23795
|
type: computedSortType
|
|
23526
23796
|
};
|
|
23527
|
-
if (c.valueGetter) {
|
|
23797
|
+
if (!isPivotColumn && c.valueGetter) {
|
|
23528
23798
|
newColumnSortInfo.valueGetter = (data) => c.valueGetter({ data, field: c.field });
|
|
23529
23799
|
}
|
|
23530
23800
|
this.setSortInfoForColumn(columnId, newColumnSortInfo, options);
|
|
@@ -26230,13 +26500,6 @@ function getColumnsWhenGrouping(params) {
|
|
|
26230
26500
|
computedColumns[groupColumnId] = singleGroupColumn;
|
|
26231
26501
|
}
|
|
26232
26502
|
if (pivotColumns) {
|
|
26233
|
-
const columnsByField = {};
|
|
26234
|
-
Object.keys(columns).forEach((colId) => {
|
|
26235
|
-
const col = columns[colId];
|
|
26236
|
-
if (col.field) {
|
|
26237
|
-
columnsByField[col.field] = col;
|
|
26238
|
-
}
|
|
26239
|
-
});
|
|
26240
26503
|
Object.keys(pivotColumns).forEach((key) => {
|
|
26241
26504
|
const col = pivotColumns[key];
|
|
26242
26505
|
const isSimpleTotalColumn = col.pivotTotalColumn && col.columnGroup;
|
|
@@ -26266,7 +26529,7 @@ function getColumnsWhenGrouping(params) {
|
|
|
26266
26529
|
}
|
|
26267
26530
|
}
|
|
26268
26531
|
if (column.inheritFromColumn !== false) {
|
|
26269
|
-
const colToInheritFrom = typeof column.inheritFromColumn === "string" ? columns[column.inheritFromColumn] : column.pivotAggregator?.field ?
|
|
26532
|
+
const colToInheritFrom = typeof column.inheritFromColumn === "string" ? columns[column.inheritFromColumn] : column.pivotAggregator?.field ? findColumnForField(columns, column.pivotAggregator.field) : void 0;
|
|
26270
26533
|
column = { ...colToInheritFrom, ...column };
|
|
26271
26534
|
}
|
|
26272
26535
|
if (!column.render && column.renderValue) {
|
|
@@ -26644,6 +26907,7 @@ function useHideColumns(groupByMap, state, actions) {
|
|
|
26644
26907
|
var import_react47 = require("react");
|
|
26645
26908
|
var useComputedColumns = ({
|
|
26646
26909
|
columns,
|
|
26910
|
+
userColumns,
|
|
26647
26911
|
bodySize,
|
|
26648
26912
|
columnMinWidth,
|
|
26649
26913
|
columnMaxWidth,
|
|
@@ -26699,6 +26963,7 @@ var useComputedColumns = ({
|
|
|
26699
26963
|
} = (0, import_react47.useMemo)(() => {
|
|
26700
26964
|
return getComputedColumns({
|
|
26701
26965
|
columns,
|
|
26966
|
+
userColumns,
|
|
26702
26967
|
scrollbarWidth: scrollbarWidth2,
|
|
26703
26968
|
bodySize,
|
|
26704
26969
|
columnMinWidth,
|
|
@@ -26733,6 +26998,7 @@ var useComputedColumns = ({
|
|
|
26733
26998
|
});
|
|
26734
26999
|
}, [
|
|
26735
27000
|
columns,
|
|
27001
|
+
userColumns,
|
|
26736
27002
|
bodySize.width,
|
|
26737
27003
|
columnMinWidth,
|
|
26738
27004
|
columnMaxWidth,
|
|
@@ -26964,6 +27230,7 @@ function useComputed(options) {
|
|
|
26964
27230
|
onRowDetailHeightCSSVarChange,
|
|
26965
27231
|
onColumnHeaderHeightCSSVarChange,
|
|
26966
27232
|
computedColumns,
|
|
27233
|
+
initialColumns,
|
|
26967
27234
|
viewportReservedWidth,
|
|
26968
27235
|
resizableColumns,
|
|
26969
27236
|
sortable,
|
|
@@ -27040,6 +27307,7 @@ function useComputed(options) {
|
|
|
27040
27307
|
fieldsToColumn
|
|
27041
27308
|
} = useComputedColumns({
|
|
27042
27309
|
columns,
|
|
27310
|
+
userColumns: initialColumns,
|
|
27043
27311
|
// scrollbarWidth: scrollbars.vertical ? getScrollbarWidth() : 0,
|
|
27044
27312
|
// #scrollbarverticaltag
|
|
27045
27313
|
// we use the default scrollbar width - using it dynamically causes issues
|
|
@@ -27355,7 +27623,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
27355
27623
|
}
|
|
27356
27624
|
let valid2 = isValidLicense(licenseKey, {
|
|
27357
27625
|
publishedAt: 1624970570587,
|
|
27358
|
-
version: "9.0.0
|
|
27626
|
+
version: "9.0.0"
|
|
27359
27627
|
});
|
|
27360
27628
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
27361
27629
|
return true;
|