@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/index.dev.mjs
CHANGED
|
@@ -2479,6 +2479,30 @@ function FilterIcon(props) {
|
|
|
2479
2479
|
);
|
|
2480
2480
|
}
|
|
2481
2481
|
|
|
2482
|
+
// src/components/InfiniteTable/utils/getColumnComputedType.ts
|
|
2483
|
+
var emptyType = Object.freeze({});
|
|
2484
|
+
var defaultFilterTypes = {
|
|
2485
|
+
string: emptyType,
|
|
2486
|
+
number: {}
|
|
2487
|
+
};
|
|
2488
|
+
function getColumnComputedType(column, columnTypes) {
|
|
2489
|
+
const defaultType = columnTypes["default"] || emptyType;
|
|
2490
|
+
if (column.type === void 0) {
|
|
2491
|
+
return defaultType;
|
|
2492
|
+
}
|
|
2493
|
+
if (column.type === null) {
|
|
2494
|
+
return emptyType;
|
|
2495
|
+
}
|
|
2496
|
+
if (typeof column.type === "string") {
|
|
2497
|
+
const type = columnTypes[column.type] || defaultFilterTypes[column.type] || emptyType;
|
|
2498
|
+
return type;
|
|
2499
|
+
}
|
|
2500
|
+
return column.type.reduce(
|
|
2501
|
+
(acc, columnType) => Object.assign(acc, columnTypes[columnType]),
|
|
2502
|
+
{}
|
|
2503
|
+
);
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2482
2506
|
// src/components/flexbox/index.ts
|
|
2483
2507
|
var computeFlex = (params) => {
|
|
2484
2508
|
const {
|
|
@@ -2913,30 +2937,6 @@ function assignExcept(exceptKeys, target, ...rest) {
|
|
|
2913
2937
|
return assignFiltered((_value, key) => !(key in exceptKeys), target, ...rest);
|
|
2914
2938
|
}
|
|
2915
2939
|
|
|
2916
|
-
// src/components/InfiniteTable/utils/getColumnComputedType.ts
|
|
2917
|
-
var emptyType = Object.freeze({});
|
|
2918
|
-
var defaultFilterTypes = {
|
|
2919
|
-
string: emptyType,
|
|
2920
|
-
number: {}
|
|
2921
|
-
};
|
|
2922
|
-
function getColumnComputedType(column, columnTypes) {
|
|
2923
|
-
const defaultType = columnTypes["default"] || emptyType;
|
|
2924
|
-
if (column.type === void 0) {
|
|
2925
|
-
return defaultType;
|
|
2926
|
-
}
|
|
2927
|
-
if (column.type === null) {
|
|
2928
|
-
return emptyType;
|
|
2929
|
-
}
|
|
2930
|
-
if (typeof column.type === "string") {
|
|
2931
|
-
const type = columnTypes[column.type] || defaultFilterTypes[column.type] || emptyType;
|
|
2932
|
-
return type;
|
|
2933
|
-
}
|
|
2934
|
-
return column.type.reduce(
|
|
2935
|
-
(acc, columnType) => Object.assign(acc, columnTypes[columnType]),
|
|
2936
|
-
{}
|
|
2937
|
-
);
|
|
2938
|
-
}
|
|
2939
|
-
|
|
2940
2940
|
// src/components/InfiniteTable/utils/getComputedColumns.ts
|
|
2941
2941
|
var DEFAULT_SORTABLE = true;
|
|
2942
2942
|
var DEFAULT_RESIZABLE = true;
|
|
@@ -2955,8 +2955,63 @@ var getComputedPinned = (colId, columnPinning) => {
|
|
|
2955
2955
|
const computedPinned = pinned === "start" || pinned === true ? "start" : pinned === "end" ? "end" : false;
|
|
2956
2956
|
return computedPinned;
|
|
2957
2957
|
};
|
|
2958
|
+
function findColumnForField(columns, field) {
|
|
2959
|
+
if (!columns) {
|
|
2960
|
+
return void 0;
|
|
2961
|
+
}
|
|
2962
|
+
if (columns[field]) {
|
|
2963
|
+
return columns[field];
|
|
2964
|
+
}
|
|
2965
|
+
return Object.values(columns).find((col) => col.field === field);
|
|
2966
|
+
}
|
|
2967
|
+
function getSortTypeFromUserColumn(column, columnTypes) {
|
|
2968
|
+
const colType = getColumnComputedType(column, columnTypes);
|
|
2969
|
+
if (column.sortType) {
|
|
2970
|
+
return column.sortType;
|
|
2971
|
+
}
|
|
2972
|
+
if (colType.sortType) {
|
|
2973
|
+
return colType.sortType;
|
|
2974
|
+
}
|
|
2975
|
+
if (typeof column.type === "string") {
|
|
2976
|
+
return column.type;
|
|
2977
|
+
}
|
|
2978
|
+
return DEFAULT_DATA_TYPE;
|
|
2979
|
+
}
|
|
2980
|
+
function getSortTypeForGroupByFromUserColumns(groupByForColumn, userColumns, columnTypes) {
|
|
2981
|
+
const list = Array.isArray(groupByForColumn) ? groupByForColumn : groupByForColumn ? [groupByForColumn] : [];
|
|
2982
|
+
const types = list.flatMap((groupBy) => {
|
|
2983
|
+
const field = groupBy.field ?? groupBy.groupField;
|
|
2984
|
+
if (!field) {
|
|
2985
|
+
return [UNKNOWN_SORT_TYPE];
|
|
2986
|
+
}
|
|
2987
|
+
const userCol = findColumnForField(userColumns, field);
|
|
2988
|
+
if (!userCol) {
|
|
2989
|
+
return [UNKNOWN_SORT_TYPE];
|
|
2990
|
+
}
|
|
2991
|
+
const sortType = getSortTypeFromUserColumn(userCol, columnTypes);
|
|
2992
|
+
return Array.isArray(sortType) ? sortType : [sortType];
|
|
2993
|
+
});
|
|
2994
|
+
if (types.every((type) => type === UNKNOWN_SORT_TYPE)) {
|
|
2995
|
+
return UNKNOWN_SORT_TYPE;
|
|
2996
|
+
}
|
|
2997
|
+
return types.length === 1 ? types[0] : types;
|
|
2998
|
+
}
|
|
2999
|
+
function getColumnComputedSortable(column, options) {
|
|
3000
|
+
const { colType, sortable, columnDefaultSortable } = options;
|
|
3001
|
+
let sortableColumnOrType = column.defaultSortable ?? colType.defaultSortable;
|
|
3002
|
+
const isGroupColumn = !!column.groupByForColumn;
|
|
3003
|
+
if (sortableColumnOrType == null && !isGroupColumn) {
|
|
3004
|
+
const field = column.field ?? colType.field;
|
|
3005
|
+
const valueGetter = column.valueGetter ?? colType.valueGetter;
|
|
3006
|
+
if (field == null && valueGetter == null) {
|
|
3007
|
+
sortableColumnOrType = false;
|
|
3008
|
+
}
|
|
3009
|
+
}
|
|
3010
|
+
return sortable ?? sortableColumnOrType ?? columnDefaultSortable ?? DEFAULT_SORTABLE;
|
|
3011
|
+
}
|
|
2958
3012
|
var getComputedColumns = ({
|
|
2959
3013
|
columns,
|
|
3014
|
+
userColumns,
|
|
2960
3015
|
bodySize,
|
|
2961
3016
|
columnMinWidth,
|
|
2962
3017
|
columnMaxWidth,
|
|
@@ -3210,15 +3265,13 @@ var getComputedColumns = ({
|
|
|
3210
3265
|
if (c.groupByForColumn) {
|
|
3211
3266
|
computedGroupable = false;
|
|
3212
3267
|
}
|
|
3213
|
-
let sortableColumnOrType = c.defaultSortable ?? colType.defaultSortable;
|
|
3214
|
-
if (sortableColumnOrType == null && !c.groupByForColumn) {
|
|
3215
|
-
if (field == null && valueGetter == null) {
|
|
3216
|
-
sortableColumnOrType = false;
|
|
3217
|
-
}
|
|
3218
|
-
}
|
|
3219
3268
|
const computedGroupedBy = field ? groupByFields[field] !== void 0 : false;
|
|
3220
3269
|
const computedGroupedByIndex = computedGroupedBy ? groupByFields[field] : void 0;
|
|
3221
|
-
|
|
3270
|
+
const computedSortable = getColumnComputedSortable(c, {
|
|
3271
|
+
colType,
|
|
3272
|
+
sortable,
|
|
3273
|
+
columnDefaultSortable
|
|
3274
|
+
});
|
|
3222
3275
|
const computedResizable = c.resizable ?? colType.resizable ?? resizableColumns ?? DEFAULT_RESIZABLE;
|
|
3223
3276
|
const result2 = {
|
|
3224
3277
|
colType,
|
|
@@ -3308,7 +3361,11 @@ var getComputedColumns = ({
|
|
|
3308
3361
|
prevPinned = computedPinned;
|
|
3309
3362
|
}
|
|
3310
3363
|
if (result2.groupByForColumn) {
|
|
3311
|
-
result2.computedSortType = c.sortType || colType.sortType ||
|
|
3364
|
+
result2.computedSortType = c.sortType || colType.sortType || getSortTypeForGroupByFromUserColumns(
|
|
3365
|
+
result2.groupByForColumn,
|
|
3366
|
+
userColumns,
|
|
3367
|
+
columnTypes
|
|
3368
|
+
);
|
|
3312
3369
|
groupColumns.push(result2);
|
|
3313
3370
|
}
|
|
3314
3371
|
computedColumnsMap.set(result2.id, result2);
|
|
@@ -3320,6 +3377,8 @@ var getComputedColumns = ({
|
|
|
3320
3377
|
groupColumns.forEach((col) => {
|
|
3321
3378
|
col.computedSortable = isGroupColumnSortable(col, {
|
|
3322
3379
|
fieldsToColumn,
|
|
3380
|
+
userColumns,
|
|
3381
|
+
columnTypes,
|
|
3323
3382
|
sortable,
|
|
3324
3383
|
columnDefaultSortable
|
|
3325
3384
|
});
|
|
@@ -3368,7 +3427,13 @@ var getComputedColumns = ({
|
|
|
3368
3427
|
|
|
3369
3428
|
// src/components/InfiniteTable/api/getColumnApi.ts
|
|
3370
3429
|
function isGroupColumnSortable(column, options) {
|
|
3371
|
-
const {
|
|
3430
|
+
const {
|
|
3431
|
+
sortable,
|
|
3432
|
+
fieldsToColumn,
|
|
3433
|
+
columnDefaultSortable,
|
|
3434
|
+
userColumns,
|
|
3435
|
+
columnTypes
|
|
3436
|
+
} = options;
|
|
3372
3437
|
if (sortable) {
|
|
3373
3438
|
return sortable;
|
|
3374
3439
|
}
|
|
@@ -3377,7 +3442,8 @@ function isGroupColumnSortable(column, options) {
|
|
|
3377
3442
|
return sortableColumnOrType;
|
|
3378
3443
|
}
|
|
3379
3444
|
const defaultSortable = columnDefaultSortable ?? DEFAULT_SORTABLE;
|
|
3380
|
-
|
|
3445
|
+
const explicitSortType = column.sortType ?? column.colType.sortType;
|
|
3446
|
+
if (explicitSortType != null && explicitSortType !== UNKNOWN_SORT_TYPE && defaultSortable) {
|
|
3381
3447
|
return true;
|
|
3382
3448
|
}
|
|
3383
3449
|
const isSortable = (params) => {
|
|
@@ -3398,7 +3464,17 @@ function isGroupColumnSortable(column, options) {
|
|
|
3398
3464
|
if (foundCol && foundColApi) {
|
|
3399
3465
|
colSortable = foundColApi.isSortable();
|
|
3400
3466
|
} else {
|
|
3401
|
-
|
|
3467
|
+
const userCol = findColumnForField(userColumns, field);
|
|
3468
|
+
if (userCol) {
|
|
3469
|
+
const userSortable = getColumnComputedSortable(userCol, {
|
|
3470
|
+
colType: getColumnComputedType(userCol, columnTypes ?? {}),
|
|
3471
|
+
sortable,
|
|
3472
|
+
columnDefaultSortable
|
|
3473
|
+
});
|
|
3474
|
+
colSortable = typeof userSortable === "boolean" ? userSortable : void 0;
|
|
3475
|
+
} else {
|
|
3476
|
+
colSortable = false;
|
|
3477
|
+
}
|
|
3402
3478
|
}
|
|
3403
3479
|
}
|
|
3404
3480
|
if (colSortable === void 0 && groupBy.valueGetter) {
|
|
@@ -6140,7 +6216,6 @@ var useColumnPointerEvents = ({
|
|
|
6140
6216
|
const pointerId = e2.pointerId;
|
|
6141
6217
|
requestAnimationFrame(() => {
|
|
6142
6218
|
const { multiSortBehavior } = getState();
|
|
6143
|
-
const target2 = domRef.current;
|
|
6144
6219
|
const rootNode = rootRef.current;
|
|
6145
6220
|
rootNode?.classList.remove(InfiniteClsShiftingColumns);
|
|
6146
6221
|
dragger.stop();
|
|
@@ -6149,10 +6224,12 @@ var useColumnPointerEvents = ({
|
|
|
6149
6224
|
});
|
|
6150
6225
|
discardAlwaysRenderedColumn?.();
|
|
6151
6226
|
restoreRenderRange?.();
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6227
|
+
target.style.cursor = initialCursor;
|
|
6228
|
+
if (target.hasPointerCapture?.(pointerId)) {
|
|
6229
|
+
target.releasePointerCapture(pointerId);
|
|
6230
|
+
}
|
|
6231
|
+
target.removeEventListener("pointermove", onPointerMove);
|
|
6232
|
+
target.removeEventListener("pointerup", onPointerUp);
|
|
6156
6233
|
setProxyPosition(null);
|
|
6157
6234
|
const dragColumnSortable = api.getColumnApi(dragColumn.id)?.isSortable() ?? false;
|
|
6158
6235
|
if (!didDragAtLeastOnce && dragColumnSortable) {
|
|
@@ -20854,6 +20931,175 @@ function getDataSourceStateRestoreForDetails(state) {
|
|
|
20854
20931
|
};
|
|
20855
20932
|
}
|
|
20856
20933
|
|
|
20934
|
+
// src/components/DataSource/state/enrichSortInfoFromGroupBy.ts
|
|
20935
|
+
var GROUP_COLUMN_ID = "group-by";
|
|
20936
|
+
var GROUP_COLUMN_ID_PREFIX = "group-by-";
|
|
20937
|
+
function getSortFieldsForGroupBy(groupBy) {
|
|
20938
|
+
const fields = groupBy.map((g) => {
|
|
20939
|
+
if (g.valueGetter) {
|
|
20940
|
+
return (item) => g.valueGetter({ data: item, field: g.field });
|
|
20941
|
+
}
|
|
20942
|
+
return g.field ?? g.groupField;
|
|
20943
|
+
}).filter(Boolean);
|
|
20944
|
+
if (!fields.length) {
|
|
20945
|
+
return void 0;
|
|
20946
|
+
}
|
|
20947
|
+
if (fields.length === 1 && typeof fields[0] !== "function") {
|
|
20948
|
+
return fields[0];
|
|
20949
|
+
}
|
|
20950
|
+
return fields;
|
|
20951
|
+
}
|
|
20952
|
+
function enrichSortInfoFromGroupBy(sortInfo, groupBy) {
|
|
20953
|
+
if (!sortInfo?.length || !groupBy?.length) {
|
|
20954
|
+
return sortInfo;
|
|
20955
|
+
}
|
|
20956
|
+
let changed = false;
|
|
20957
|
+
const next = sortInfo.map((info) => {
|
|
20958
|
+
if (info.field != null || !info.id) {
|
|
20959
|
+
return info;
|
|
20960
|
+
}
|
|
20961
|
+
if (info.id === GROUP_COLUMN_ID) {
|
|
20962
|
+
const field = getSortFieldsForGroupBy(groupBy);
|
|
20963
|
+
if (field == null) {
|
|
20964
|
+
return info;
|
|
20965
|
+
}
|
|
20966
|
+
changed = true;
|
|
20967
|
+
return { ...info, field };
|
|
20968
|
+
}
|
|
20969
|
+
if (info.id.startsWith(GROUP_COLUMN_ID_PREFIX)) {
|
|
20970
|
+
const key = info.id.slice(GROUP_COLUMN_ID_PREFIX.length);
|
|
20971
|
+
const match = groupBy.find(
|
|
20972
|
+
(g) => String(g.field) === key || g.groupField === key
|
|
20973
|
+
);
|
|
20974
|
+
if (!match) {
|
|
20975
|
+
return info;
|
|
20976
|
+
}
|
|
20977
|
+
const field = getSortFieldsForGroupBy([match]);
|
|
20978
|
+
if (field == null) {
|
|
20979
|
+
return info;
|
|
20980
|
+
}
|
|
20981
|
+
changed = true;
|
|
20982
|
+
return { ...info, field };
|
|
20983
|
+
}
|
|
20984
|
+
return info;
|
|
20985
|
+
});
|
|
20986
|
+
return changed ? next : sortInfo;
|
|
20987
|
+
}
|
|
20988
|
+
|
|
20989
|
+
// src/components/DataSource/state/sortGroupedRowInfosByPivotColumns.ts
|
|
20990
|
+
function getRowNesting(row) {
|
|
20991
|
+
return "groupNesting" in row ? row.groupNesting ?? 0 : 0;
|
|
20992
|
+
}
|
|
20993
|
+
function getPivotCellValue(row, sort) {
|
|
20994
|
+
if (!row.isGroupRow || !sort.reducerId) {
|
|
20995
|
+
return void 0;
|
|
20996
|
+
}
|
|
20997
|
+
if (sort.pivotTotalColumn && (!sort.pivotGroupKeys || sort.pivotGroupKeys.length === 0)) {
|
|
20998
|
+
return row.reducerResults?.[sort.reducerId];
|
|
20999
|
+
}
|
|
21000
|
+
return row.pivotValuesMap?.get(sort.pivotGroupKeys)?.reducerResults?.[sort.reducerId];
|
|
21001
|
+
}
|
|
21002
|
+
function comparePivotValues(a, b, sort, sortTypes) {
|
|
21003
|
+
if (a == null && b == null) {
|
|
21004
|
+
return 0;
|
|
21005
|
+
}
|
|
21006
|
+
if (a == null) {
|
|
21007
|
+
return 1;
|
|
21008
|
+
}
|
|
21009
|
+
if (b == null) {
|
|
21010
|
+
return -1;
|
|
21011
|
+
}
|
|
21012
|
+
const type = Array.isArray(sort.type) ? sort.type[0] : sort.type;
|
|
21013
|
+
const fn = sort.fn || type && sortTypes[type] || sortTypes.string || sortTypes_default.string;
|
|
21014
|
+
const result = fn(a, b);
|
|
21015
|
+
return result === 0 ? 0 : sort.dir * result;
|
|
21016
|
+
}
|
|
21017
|
+
function toPivotSorts(sortInfo, pivotColumns) {
|
|
21018
|
+
if (!sortInfo?.length || !pivotColumns) {
|
|
21019
|
+
return [];
|
|
21020
|
+
}
|
|
21021
|
+
const result = [];
|
|
21022
|
+
for (const info of sortInfo) {
|
|
21023
|
+
const col = info.id ? pivotColumns[info.id] : void 0;
|
|
21024
|
+
if (!col?.pivotColumn || !col.pivotAggregator) {
|
|
21025
|
+
continue;
|
|
21026
|
+
}
|
|
21027
|
+
result.push({
|
|
21028
|
+
dir: info.dir,
|
|
21029
|
+
type: info.type,
|
|
21030
|
+
fn: info.fn,
|
|
21031
|
+
pivotGroupKeys: col.pivotGroupKeys ?? [],
|
|
21032
|
+
reducerId: col.pivotAggregator.id,
|
|
21033
|
+
pivotTotalColumn: !!col.pivotTotalColumn
|
|
21034
|
+
});
|
|
21035
|
+
}
|
|
21036
|
+
return result;
|
|
21037
|
+
}
|
|
21038
|
+
function buildTree(rows) {
|
|
21039
|
+
const roots = [];
|
|
21040
|
+
const stack = [];
|
|
21041
|
+
for (const row of rows) {
|
|
21042
|
+
const node = { row, children: [] };
|
|
21043
|
+
const nesting = getRowNesting(row);
|
|
21044
|
+
while (stack.length && getRowNesting(stack[stack.length - 1].row) >= nesting) {
|
|
21045
|
+
stack.pop();
|
|
21046
|
+
}
|
|
21047
|
+
if (!stack.length) {
|
|
21048
|
+
roots.push(node);
|
|
21049
|
+
} else {
|
|
21050
|
+
stack[stack.length - 1].children.push(node);
|
|
21051
|
+
}
|
|
21052
|
+
stack.push(node);
|
|
21053
|
+
}
|
|
21054
|
+
return roots;
|
|
21055
|
+
}
|
|
21056
|
+
function flattenSortedTree(roots) {
|
|
21057
|
+
const result = [];
|
|
21058
|
+
const walk = (nodes, parentIndexes) => {
|
|
21059
|
+
nodes.forEach((node, indexInGroup) => {
|
|
21060
|
+
const indexInParentGroups = [...parentIndexes, indexInGroup];
|
|
21061
|
+
const row = node.row;
|
|
21062
|
+
row.indexInGroup = indexInGroup;
|
|
21063
|
+
row.indexInParentGroups = indexInParentGroups;
|
|
21064
|
+
row.indexInAll = result.length;
|
|
21065
|
+
result.push(row);
|
|
21066
|
+
walk(node.children, indexInParentGroups);
|
|
21067
|
+
});
|
|
21068
|
+
};
|
|
21069
|
+
walk(roots, []);
|
|
21070
|
+
return result;
|
|
21071
|
+
}
|
|
21072
|
+
function sortGroupedRowInfosByPivotColumns(dataArray, sortInfo, pivotColumns, sortTypes) {
|
|
21073
|
+
const pivotSorts = toPivotSorts(sortInfo, pivotColumns);
|
|
21074
|
+
if (!pivotSorts.length || !dataArray.length) {
|
|
21075
|
+
return dataArray;
|
|
21076
|
+
}
|
|
21077
|
+
const knownSortTypes = { ...sortTypes_default, ...sortTypes };
|
|
21078
|
+
const roots = buildTree(dataArray);
|
|
21079
|
+
const compareNodes = (a, b) => {
|
|
21080
|
+
for (const sort of pivotSorts) {
|
|
21081
|
+
const result = comparePivotValues(
|
|
21082
|
+
getPivotCellValue(a.row, sort),
|
|
21083
|
+
getPivotCellValue(b.row, sort),
|
|
21084
|
+
sort,
|
|
21085
|
+
knownSortTypes
|
|
21086
|
+
);
|
|
21087
|
+
if (result !== 0) {
|
|
21088
|
+
return result;
|
|
21089
|
+
}
|
|
21090
|
+
}
|
|
21091
|
+
return 0;
|
|
21092
|
+
};
|
|
21093
|
+
const sortTree = (nodes) => {
|
|
21094
|
+
nodes.sort(compareNodes);
|
|
21095
|
+
for (const node of nodes) {
|
|
21096
|
+
sortTree(node.children);
|
|
21097
|
+
}
|
|
21098
|
+
};
|
|
21099
|
+
sortTree(roots);
|
|
21100
|
+
return flattenSortedTree(roots);
|
|
21101
|
+
}
|
|
21102
|
+
|
|
20857
21103
|
// src/components/DataSource/state/reducer.ts
|
|
20858
21104
|
function cleanupEmptyFilterValues(filterValue, filterTypes) {
|
|
20859
21105
|
if (!filterValue) {
|
|
@@ -21074,7 +21320,7 @@ function concludeReducer(params) {
|
|
|
21074
21320
|
rootMarker = getMarker(debugId).track.DataSource.label.PrepareData.start();
|
|
21075
21321
|
}
|
|
21076
21322
|
const cacheAffectedParts = getCacheAffectedParts(state);
|
|
21077
|
-
const sortInfo = state.sortInfo;
|
|
21323
|
+
const sortInfo = enrichSortInfoFromGroupBy(state.sortInfo, state.groupBy);
|
|
21078
21324
|
const sortMode = state.sortMode;
|
|
21079
21325
|
let shouldSort = !!sortInfo?.length ? sortMode === "local" : false;
|
|
21080
21326
|
if (state.lazyLoad || state.livePagination) {
|
|
@@ -21437,6 +21683,16 @@ function concludeReducer(params) {
|
|
|
21437
21683
|
}) : void 0;
|
|
21438
21684
|
state.pivotColumns = pivotGroupsAndCols?.columns;
|
|
21439
21685
|
state.pivotColumnGroups = pivotGroupsAndCols?.columnGroups;
|
|
21686
|
+
const pivotSortedRowInfos = sortGroupedRowInfosByPivotColumns(
|
|
21687
|
+
rowInfoDataArray,
|
|
21688
|
+
sortInfo,
|
|
21689
|
+
state.pivotColumns,
|
|
21690
|
+
state.sortTypes
|
|
21691
|
+
);
|
|
21692
|
+
if (pivotSortedRowInfos !== rowInfoDataArray) {
|
|
21693
|
+
rowInfoDataArray = pivotSortedRowInfos;
|
|
21694
|
+
state.groupRowsIndexesInDataArray = rowInfoDataArray.map((row, index) => row.isGroupRow ? index : -1).filter((index) => index >= 0);
|
|
21695
|
+
}
|
|
21440
21696
|
if (state.devToolsDetected) {
|
|
21441
21697
|
state.debugTimings.set("group-and-pivot", Date.now() - groupTimestamp);
|
|
21442
21698
|
}
|
|
@@ -21679,7 +21935,11 @@ var DATA_CHANGES_COMPARE_FUNCTIONS = {
|
|
|
21679
21935
|
}
|
|
21680
21936
|
};
|
|
21681
21937
|
function buildDataSourceDataParams(componentState, overrides, masterContext) {
|
|
21682
|
-
const
|
|
21938
|
+
const resolvedSortInfo = enrichSortInfoFromGroupBy(
|
|
21939
|
+
componentState.sortInfo,
|
|
21940
|
+
componentState.groupBy
|
|
21941
|
+
);
|
|
21942
|
+
const sortInfo = componentState.multiSort ? resolvedSortInfo : resolvedSortInfo?.[0] ?? null;
|
|
21683
21943
|
const dataSourceParams = {
|
|
21684
21944
|
append: false,
|
|
21685
21945
|
originalDataArray: componentState.originalDataArray,
|
|
@@ -23424,8 +23684,9 @@ var InfiniteTableApiImpl = class {
|
|
|
23424
23684
|
this.setSortInfoForColumn(columnId, null, options);
|
|
23425
23685
|
return;
|
|
23426
23686
|
}
|
|
23687
|
+
const isPivotColumn = !!c.pivotColumn;
|
|
23427
23688
|
const groupByForColumn = c.groupByForColumn;
|
|
23428
|
-
let field = c.field;
|
|
23689
|
+
let field = isPivotColumn ? void 0 : c.field;
|
|
23429
23690
|
const groupByForCol = groupByForColumn ? Array.isArray(groupByForColumn) ? groupByForColumn : [groupByForColumn] : [];
|
|
23430
23691
|
const fieldArr = groupByForCol.map((c2) => {
|
|
23431
23692
|
return c2.valueGetter ? (item) => c2.valueGetter({ data: item, field: c2.field }) : c2.field ? c2.field : c2.groupField ?? void 0;
|
|
@@ -23435,23 +23696,32 @@ var InfiniteTableApiImpl = class {
|
|
|
23435
23696
|
}
|
|
23436
23697
|
let computedSortType = c.computedSortType;
|
|
23437
23698
|
if (groupByForCol.length && computedSortType === UNKNOWN_SORT_TYPE) {
|
|
23699
|
+
const userColumns = this.getState().initialColumns;
|
|
23438
23700
|
const sortTypeForGroupCols = groupByForCol.flatMap((groupBy) => {
|
|
23439
23701
|
const field2 = groupBy.field ?? groupBy.groupField;
|
|
23440
23702
|
const col = field2 ? computedColumnsMap.get(field2) : null;
|
|
23441
|
-
if (
|
|
23442
|
-
return
|
|
23703
|
+
if (col) {
|
|
23704
|
+
return col.computedSortType;
|
|
23705
|
+
}
|
|
23706
|
+
const userCol = field2 ? findColumnForField(userColumns, field2) : void 0;
|
|
23707
|
+
if (userCol) {
|
|
23708
|
+
const type = userCol.sortType || (typeof userCol.type === "string" ? userCol.type : "string");
|
|
23709
|
+
return type;
|
|
23443
23710
|
}
|
|
23444
|
-
return
|
|
23711
|
+
return [UNKNOWN_SORT_TYPE];
|
|
23445
23712
|
});
|
|
23446
23713
|
computedSortType = sortTypeForGroupCols;
|
|
23447
23714
|
}
|
|
23715
|
+
if (groupByForCol.length && !Array.isArray(computedSortType)) {
|
|
23716
|
+
computedSortType = [computedSortType];
|
|
23717
|
+
}
|
|
23448
23718
|
const newColumnSortInfo = {
|
|
23449
23719
|
dir,
|
|
23450
23720
|
id: c.id,
|
|
23451
23721
|
field,
|
|
23452
23722
|
type: computedSortType
|
|
23453
23723
|
};
|
|
23454
|
-
if (c.valueGetter) {
|
|
23724
|
+
if (!isPivotColumn && c.valueGetter) {
|
|
23455
23725
|
newColumnSortInfo.valueGetter = (data) => c.valueGetter({ data, field: c.field });
|
|
23456
23726
|
}
|
|
23457
23727
|
this.setSortInfoForColumn(columnId, newColumnSortInfo, options);
|
|
@@ -26162,13 +26432,6 @@ function getColumnsWhenGrouping(params) {
|
|
|
26162
26432
|
computedColumns[groupColumnId] = singleGroupColumn;
|
|
26163
26433
|
}
|
|
26164
26434
|
if (pivotColumns) {
|
|
26165
|
-
const columnsByField = {};
|
|
26166
|
-
Object.keys(columns).forEach((colId) => {
|
|
26167
|
-
const col = columns[colId];
|
|
26168
|
-
if (col.field) {
|
|
26169
|
-
columnsByField[col.field] = col;
|
|
26170
|
-
}
|
|
26171
|
-
});
|
|
26172
26435
|
Object.keys(pivotColumns).forEach((key) => {
|
|
26173
26436
|
const col = pivotColumns[key];
|
|
26174
26437
|
const isSimpleTotalColumn = col.pivotTotalColumn && col.columnGroup;
|
|
@@ -26198,7 +26461,7 @@ function getColumnsWhenGrouping(params) {
|
|
|
26198
26461
|
}
|
|
26199
26462
|
}
|
|
26200
26463
|
if (column.inheritFromColumn !== false) {
|
|
26201
|
-
const colToInheritFrom = typeof column.inheritFromColumn === "string" ? columns[column.inheritFromColumn] : column.pivotAggregator?.field ?
|
|
26464
|
+
const colToInheritFrom = typeof column.inheritFromColumn === "string" ? columns[column.inheritFromColumn] : column.pivotAggregator?.field ? findColumnForField(columns, column.pivotAggregator.field) : void 0;
|
|
26202
26465
|
column = { ...colToInheritFrom, ...column };
|
|
26203
26466
|
}
|
|
26204
26467
|
if (!column.render && column.renderValue) {
|
|
@@ -26576,6 +26839,7 @@ function useHideColumns(groupByMap, state, actions) {
|
|
|
26576
26839
|
import { useMemo as useMemo14 } from "react";
|
|
26577
26840
|
var useComputedColumns = ({
|
|
26578
26841
|
columns,
|
|
26842
|
+
userColumns,
|
|
26579
26843
|
bodySize,
|
|
26580
26844
|
columnMinWidth,
|
|
26581
26845
|
columnMaxWidth,
|
|
@@ -26631,6 +26895,7 @@ var useComputedColumns = ({
|
|
|
26631
26895
|
} = useMemo14(() => {
|
|
26632
26896
|
return getComputedColumns({
|
|
26633
26897
|
columns,
|
|
26898
|
+
userColumns,
|
|
26634
26899
|
scrollbarWidth: scrollbarWidth2,
|
|
26635
26900
|
bodySize,
|
|
26636
26901
|
columnMinWidth,
|
|
@@ -26665,6 +26930,7 @@ var useComputedColumns = ({
|
|
|
26665
26930
|
});
|
|
26666
26931
|
}, [
|
|
26667
26932
|
columns,
|
|
26933
|
+
userColumns,
|
|
26668
26934
|
bodySize.width,
|
|
26669
26935
|
columnMinWidth,
|
|
26670
26936
|
columnMaxWidth,
|
|
@@ -26896,6 +27162,7 @@ function useComputed(options) {
|
|
|
26896
27162
|
onRowDetailHeightCSSVarChange,
|
|
26897
27163
|
onColumnHeaderHeightCSSVarChange,
|
|
26898
27164
|
computedColumns,
|
|
27165
|
+
initialColumns,
|
|
26899
27166
|
viewportReservedWidth,
|
|
26900
27167
|
resizableColumns,
|
|
26901
27168
|
sortable,
|
|
@@ -26972,6 +27239,7 @@ function useComputed(options) {
|
|
|
26972
27239
|
fieldsToColumn
|
|
26973
27240
|
} = useComputedColumns({
|
|
26974
27241
|
columns,
|
|
27242
|
+
userColumns: initialColumns,
|
|
26975
27243
|
// scrollbarWidth: scrollbars.vertical ? getScrollbarWidth() : 0,
|
|
26976
27244
|
// #scrollbarverticaltag
|
|
26977
27245
|
// we use the default scrollbar width - using it dynamically causes issues
|
|
@@ -27287,7 +27555,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
27287
27555
|
}
|
|
27288
27556
|
let valid2 = isValidLicense(licenseKey, {
|
|
27289
27557
|
publishedAt: 1624970570587,
|
|
27290
|
-
version: "9.0.0
|
|
27558
|
+
version: "9.0.0"
|
|
27291
27559
|
});
|
|
27292
27560
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
27293
27561
|
return true;
|