@infinite-table/infinite-react 9.0.0-canary.0 → 9.0.1

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 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
- let computedSortable = sortable ?? sortableColumnOrType ?? columnDefaultSortable ?? DEFAULT_SORTABLE;
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 || UNKNOWN_SORT_TYPE;
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 { sortable, fieldsToColumn, columnDefaultSortable } = options;
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
- if (column.computedSortType !== UNKNOWN_SORT_TYPE && defaultSortable) {
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
- colSortable = false;
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
- target2.style.cursor = initialCursor;
6226
- target2.releasePointerCapture(pointerId);
6227
- target2.removeEventListener("pointermove", onPointerMove);
6228
- target2.removeEventListener("pointerup", onPointerUp);
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) {
@@ -16182,7 +16259,6 @@ function getPivotColumnsAndColumnGroups({
16182
16259
  pivotGroupKey: keys[keys.length - 1],
16183
16260
  pivotIndex: keys.length - 1,
16184
16261
  pivotByAtIndex: pivotByForColumn,
16185
- defaultSortable: false,
16186
16262
  columnGroup: parentColumnGroupId,
16187
16263
  header,
16188
16264
  valueFormatter: ({ rowInfo }) => {
@@ -16238,7 +16314,6 @@ function getPivotColumnsAndColumnGroups({
16238
16314
  pivotByAtIndex: pivotByForColumn,
16239
16315
  pivotIndex: keys.length - 1,
16240
16316
  pivotBy,
16241
- defaultSortable: false,
16242
16317
  valueFormatter: ({ rowInfo }) => {
16243
16318
  if (!rowInfo.isGroupRow) {
16244
16319
  return null;
@@ -20927,6 +21002,175 @@ function getDataSourceStateRestoreForDetails(state) {
20927
21002
  };
20928
21003
  }
20929
21004
 
21005
+ // src/components/DataSource/state/enrichSortInfoFromGroupBy.ts
21006
+ var GROUP_COLUMN_ID = "group-by";
21007
+ var GROUP_COLUMN_ID_PREFIX = "group-by-";
21008
+ function getSortFieldsForGroupBy(groupBy) {
21009
+ const fields = groupBy.map((g) => {
21010
+ if (g.valueGetter) {
21011
+ return (item) => g.valueGetter({ data: item, field: g.field });
21012
+ }
21013
+ return g.field ?? g.groupField;
21014
+ }).filter(Boolean);
21015
+ if (!fields.length) {
21016
+ return void 0;
21017
+ }
21018
+ if (fields.length === 1 && typeof fields[0] !== "function") {
21019
+ return fields[0];
21020
+ }
21021
+ return fields;
21022
+ }
21023
+ function enrichSortInfoFromGroupBy(sortInfo, groupBy) {
21024
+ if (!sortInfo?.length || !groupBy?.length) {
21025
+ return sortInfo;
21026
+ }
21027
+ let changed = false;
21028
+ const next = sortInfo.map((info) => {
21029
+ if (info.field != null || !info.id) {
21030
+ return info;
21031
+ }
21032
+ if (info.id === GROUP_COLUMN_ID) {
21033
+ const field = getSortFieldsForGroupBy(groupBy);
21034
+ if (field == null) {
21035
+ return info;
21036
+ }
21037
+ changed = true;
21038
+ return { ...info, field };
21039
+ }
21040
+ if (info.id.startsWith(GROUP_COLUMN_ID_PREFIX)) {
21041
+ const key = info.id.slice(GROUP_COLUMN_ID_PREFIX.length);
21042
+ const match = groupBy.find(
21043
+ (g) => String(g.field) === key || g.groupField === key
21044
+ );
21045
+ if (!match) {
21046
+ return info;
21047
+ }
21048
+ const field = getSortFieldsForGroupBy([match]);
21049
+ if (field == null) {
21050
+ return info;
21051
+ }
21052
+ changed = true;
21053
+ return { ...info, field };
21054
+ }
21055
+ return info;
21056
+ });
21057
+ return changed ? next : sortInfo;
21058
+ }
21059
+
21060
+ // src/components/DataSource/state/sortGroupedRowInfosByPivotColumns.ts
21061
+ function getRowNesting(row) {
21062
+ return "groupNesting" in row ? row.groupNesting ?? 0 : 0;
21063
+ }
21064
+ function getPivotCellValue(row, sort) {
21065
+ if (!row.isGroupRow || !sort.reducerId) {
21066
+ return void 0;
21067
+ }
21068
+ if (sort.pivotTotalColumn && (!sort.pivotGroupKeys || sort.pivotGroupKeys.length === 0)) {
21069
+ return row.reducerResults?.[sort.reducerId];
21070
+ }
21071
+ return row.pivotValuesMap?.get(sort.pivotGroupKeys)?.reducerResults?.[sort.reducerId];
21072
+ }
21073
+ function comparePivotValues(a, b, sort, sortTypes) {
21074
+ if (a == null && b == null) {
21075
+ return 0;
21076
+ }
21077
+ if (a == null) {
21078
+ return 1;
21079
+ }
21080
+ if (b == null) {
21081
+ return -1;
21082
+ }
21083
+ const type = Array.isArray(sort.type) ? sort.type[0] : sort.type;
21084
+ const fn = sort.fn || type && sortTypes[type] || sortTypes.string || sortTypes_default.string;
21085
+ const result = fn(a, b);
21086
+ return result === 0 ? 0 : sort.dir * result;
21087
+ }
21088
+ function toPivotSorts(sortInfo, pivotColumns) {
21089
+ if (!sortInfo?.length || !pivotColumns) {
21090
+ return [];
21091
+ }
21092
+ const result = [];
21093
+ for (const info of sortInfo) {
21094
+ const col = info.id ? pivotColumns[info.id] : void 0;
21095
+ if (!col?.pivotColumn || !col.pivotAggregator) {
21096
+ continue;
21097
+ }
21098
+ result.push({
21099
+ dir: info.dir,
21100
+ type: info.type,
21101
+ fn: info.fn,
21102
+ pivotGroupKeys: col.pivotGroupKeys ?? [],
21103
+ reducerId: col.pivotAggregator.id,
21104
+ pivotTotalColumn: !!col.pivotTotalColumn
21105
+ });
21106
+ }
21107
+ return result;
21108
+ }
21109
+ function buildTree(rows) {
21110
+ const roots = [];
21111
+ const stack = [];
21112
+ for (const row of rows) {
21113
+ const node = { row, children: [] };
21114
+ const nesting = getRowNesting(row);
21115
+ while (stack.length && getRowNesting(stack[stack.length - 1].row) >= nesting) {
21116
+ stack.pop();
21117
+ }
21118
+ if (!stack.length) {
21119
+ roots.push(node);
21120
+ } else {
21121
+ stack[stack.length - 1].children.push(node);
21122
+ }
21123
+ stack.push(node);
21124
+ }
21125
+ return roots;
21126
+ }
21127
+ function flattenSortedTree(roots) {
21128
+ const result = [];
21129
+ const walk = (nodes, parentIndexes) => {
21130
+ nodes.forEach((node, indexInGroup) => {
21131
+ const indexInParentGroups = [...parentIndexes, indexInGroup];
21132
+ const row = node.row;
21133
+ row.indexInGroup = indexInGroup;
21134
+ row.indexInParentGroups = indexInParentGroups;
21135
+ row.indexInAll = result.length;
21136
+ result.push(row);
21137
+ walk(node.children, indexInParentGroups);
21138
+ });
21139
+ };
21140
+ walk(roots, []);
21141
+ return result;
21142
+ }
21143
+ function sortGroupedRowInfosByPivotColumns(dataArray, sortInfo, pivotColumns, sortTypes) {
21144
+ const pivotSorts = toPivotSorts(sortInfo, pivotColumns);
21145
+ if (!pivotSorts.length || !dataArray.length) {
21146
+ return dataArray;
21147
+ }
21148
+ const knownSortTypes = { ...sortTypes_default, ...sortTypes };
21149
+ const roots = buildTree(dataArray);
21150
+ const compareNodes = (a, b) => {
21151
+ for (const sort of pivotSorts) {
21152
+ const result = comparePivotValues(
21153
+ getPivotCellValue(a.row, sort),
21154
+ getPivotCellValue(b.row, sort),
21155
+ sort,
21156
+ knownSortTypes
21157
+ );
21158
+ if (result !== 0) {
21159
+ return result;
21160
+ }
21161
+ }
21162
+ return 0;
21163
+ };
21164
+ const sortTree = (nodes) => {
21165
+ nodes.sort(compareNodes);
21166
+ for (const node of nodes) {
21167
+ sortTree(node.children);
21168
+ }
21169
+ };
21170
+ sortTree(roots);
21171
+ return flattenSortedTree(roots);
21172
+ }
21173
+
20930
21174
  // src/components/DataSource/state/reducer.ts
20931
21175
  function cleanupEmptyFilterValues(filterValue, filterTypes) {
20932
21176
  if (!filterValue) {
@@ -21147,7 +21391,7 @@ function concludeReducer(params) {
21147
21391
  rootMarker = getMarker(debugId).track.DataSource.label.PrepareData.start();
21148
21392
  }
21149
21393
  const cacheAffectedParts = getCacheAffectedParts(state);
21150
- const sortInfo = state.sortInfo;
21394
+ const sortInfo = enrichSortInfoFromGroupBy(state.sortInfo, state.groupBy);
21151
21395
  const sortMode = state.sortMode;
21152
21396
  let shouldSort = !!sortInfo?.length ? sortMode === "local" : false;
21153
21397
  if (state.lazyLoad || state.livePagination) {
@@ -21510,6 +21754,16 @@ function concludeReducer(params) {
21510
21754
  }) : void 0;
21511
21755
  state.pivotColumns = pivotGroupsAndCols?.columns;
21512
21756
  state.pivotColumnGroups = pivotGroupsAndCols?.columnGroups;
21757
+ const pivotSortedRowInfos = sortGroupedRowInfosByPivotColumns(
21758
+ rowInfoDataArray,
21759
+ sortInfo,
21760
+ state.pivotColumns,
21761
+ state.sortTypes
21762
+ );
21763
+ if (pivotSortedRowInfos !== rowInfoDataArray) {
21764
+ rowInfoDataArray = pivotSortedRowInfos;
21765
+ state.groupRowsIndexesInDataArray = rowInfoDataArray.map((row, index) => row.isGroupRow ? index : -1).filter((index) => index >= 0);
21766
+ }
21513
21767
  if (state.devToolsDetected) {
21514
21768
  state.debugTimings.set("group-and-pivot", Date.now() - groupTimestamp);
21515
21769
  }
@@ -21752,7 +22006,11 @@ var DATA_CHANGES_COMPARE_FUNCTIONS = {
21752
22006
  }
21753
22007
  };
21754
22008
  function buildDataSourceDataParams(componentState, overrides, masterContext) {
21755
- const sortInfo = componentState.multiSort ? componentState.sortInfo : componentState.sortInfo?.[0] ?? null;
22009
+ const resolvedSortInfo = enrichSortInfoFromGroupBy(
22010
+ componentState.sortInfo,
22011
+ componentState.groupBy
22012
+ );
22013
+ const sortInfo = componentState.multiSort ? resolvedSortInfo : resolvedSortInfo?.[0] ?? null;
21756
22014
  const dataSourceParams = {
21757
22015
  append: false,
21758
22016
  originalDataArray: componentState.originalDataArray,
@@ -23497,8 +23755,9 @@ var InfiniteTableApiImpl = class {
23497
23755
  this.setSortInfoForColumn(columnId, null, options);
23498
23756
  return;
23499
23757
  }
23758
+ const isPivotColumn = !!c.pivotColumn;
23500
23759
  const groupByForColumn = c.groupByForColumn;
23501
- let field = c.field;
23760
+ let field = isPivotColumn ? void 0 : c.field;
23502
23761
  const groupByForCol = groupByForColumn ? Array.isArray(groupByForColumn) ? groupByForColumn : [groupByForColumn] : [];
23503
23762
  const fieldArr = groupByForCol.map((c2) => {
23504
23763
  return c2.valueGetter ? (item) => c2.valueGetter({ data: item, field: c2.field }) : c2.field ? c2.field : c2.groupField ?? void 0;
@@ -23508,23 +23767,32 @@ var InfiniteTableApiImpl = class {
23508
23767
  }
23509
23768
  let computedSortType = c.computedSortType;
23510
23769
  if (groupByForCol.length && computedSortType === UNKNOWN_SORT_TYPE) {
23770
+ const userColumns = this.getState().initialColumns;
23511
23771
  const sortTypeForGroupCols = groupByForCol.flatMap((groupBy) => {
23512
23772
  const field2 = groupBy.field ?? groupBy.groupField;
23513
23773
  const col = field2 ? computedColumnsMap.get(field2) : null;
23514
- if (!col) {
23515
- return UNKNOWN_SORT_TYPE;
23774
+ if (col) {
23775
+ return col.computedSortType;
23776
+ }
23777
+ const userCol = field2 ? findColumnForField(userColumns, field2) : void 0;
23778
+ if (userCol) {
23779
+ const type = userCol.sortType || (typeof userCol.type === "string" ? userCol.type : "string");
23780
+ return type;
23516
23781
  }
23517
- return col.computedSortType;
23782
+ return [UNKNOWN_SORT_TYPE];
23518
23783
  });
23519
23784
  computedSortType = sortTypeForGroupCols;
23520
23785
  }
23786
+ if (groupByForCol.length && !Array.isArray(computedSortType)) {
23787
+ computedSortType = [computedSortType];
23788
+ }
23521
23789
  const newColumnSortInfo = {
23522
23790
  dir,
23523
23791
  id: c.id,
23524
23792
  field,
23525
23793
  type: computedSortType
23526
23794
  };
23527
- if (c.valueGetter) {
23795
+ if (!isPivotColumn && c.valueGetter) {
23528
23796
  newColumnSortInfo.valueGetter = (data) => c.valueGetter({ data, field: c.field });
23529
23797
  }
23530
23798
  this.setSortInfoForColumn(columnId, newColumnSortInfo, options);
@@ -26230,13 +26498,6 @@ function getColumnsWhenGrouping(params) {
26230
26498
  computedColumns[groupColumnId] = singleGroupColumn;
26231
26499
  }
26232
26500
  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
26501
  Object.keys(pivotColumns).forEach((key) => {
26241
26502
  const col = pivotColumns[key];
26242
26503
  const isSimpleTotalColumn = col.pivotTotalColumn && col.columnGroup;
@@ -26266,7 +26527,7 @@ function getColumnsWhenGrouping(params) {
26266
26527
  }
26267
26528
  }
26268
26529
  if (column.inheritFromColumn !== false) {
26269
- const colToInheritFrom = typeof column.inheritFromColumn === "string" ? columns[column.inheritFromColumn] : column.pivotAggregator?.field ? columnsByField[column.pivotAggregator?.field] : void 0;
26530
+ const colToInheritFrom = typeof column.inheritFromColumn === "string" ? columns[column.inheritFromColumn] : column.pivotAggregator?.field ? findColumnForField(columns, column.pivotAggregator.field) : void 0;
26270
26531
  column = { ...colToInheritFrom, ...column };
26271
26532
  }
26272
26533
  if (!column.render && column.renderValue) {
@@ -26644,6 +26905,7 @@ function useHideColumns(groupByMap, state, actions) {
26644
26905
  var import_react47 = require("react");
26645
26906
  var useComputedColumns = ({
26646
26907
  columns,
26908
+ userColumns,
26647
26909
  bodySize,
26648
26910
  columnMinWidth,
26649
26911
  columnMaxWidth,
@@ -26699,6 +26961,7 @@ var useComputedColumns = ({
26699
26961
  } = (0, import_react47.useMemo)(() => {
26700
26962
  return getComputedColumns({
26701
26963
  columns,
26964
+ userColumns,
26702
26965
  scrollbarWidth: scrollbarWidth2,
26703
26966
  bodySize,
26704
26967
  columnMinWidth,
@@ -26733,6 +26996,7 @@ var useComputedColumns = ({
26733
26996
  });
26734
26997
  }, [
26735
26998
  columns,
26999
+ userColumns,
26736
27000
  bodySize.width,
26737
27001
  columnMinWidth,
26738
27002
  columnMaxWidth,
@@ -26964,6 +27228,7 @@ function useComputed(options) {
26964
27228
  onRowDetailHeightCSSVarChange,
26965
27229
  onColumnHeaderHeightCSSVarChange,
26966
27230
  computedColumns,
27231
+ initialColumns,
26967
27232
  viewportReservedWidth,
26968
27233
  resizableColumns,
26969
27234
  sortable,
@@ -27040,6 +27305,7 @@ function useComputed(options) {
27040
27305
  fieldsToColumn
27041
27306
  } = useComputedColumns({
27042
27307
  columns,
27308
+ userColumns: initialColumns,
27043
27309
  // scrollbarWidth: scrollbars.vertical ? getScrollbarWidth() : 0,
27044
27310
  // #scrollbarverticaltag
27045
27311
  // we use the default scrollbar width - using it dynamically causes issues
@@ -27355,7 +27621,7 @@ var useLicense = (licenseKey = "") => {
27355
27621
  }
27356
27622
  let valid2 = isValidLicense(licenseKey, {
27357
27623
  publishedAt: 1624970570587,
27358
- version: "9.0.0-canary.0"
27624
+ version: "9.0.1"
27359
27625
  });
27360
27626
  if (!licenseKey && !valid2 && isInsidePlayground) {
27361
27627
  return true;