@infinite-table/infinite-react 9.0.1 → 9.0.3

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/index.dev.js CHANGED
@@ -6516,9 +6516,12 @@ function getGroupByColumnReference(options) {
6516
6516
  if (column.groupByForColumn) {
6517
6517
  if (rowInfo.isGroupRow) {
6518
6518
  const rowGroupBy = rowInfo.groupBy[rowInfo.groupBy.length - 1];
6519
- groupByColumn = rowGroupBy ? fieldsToColumn.get(
6520
- rowGroupBy.field || rowGroupBy.groupField
6521
- ) : void 0;
6519
+ const isThisColumnGroupLevel = Array.isArray(column.groupByForColumn) || column.groupByForColumn === rowGroupBy;
6520
+ if (isThisColumnGroupLevel) {
6521
+ groupByColumn = rowGroupBy ? fieldsToColumn.get(
6522
+ rowGroupBy.field || rowGroupBy.groupField
6523
+ ) : void 0;
6524
+ }
6522
6525
  }
6523
6526
  if (!groupByColumn && column.field) {
6524
6527
  groupByColumn = fieldsToColumn.get(column.field);
@@ -6838,6 +6841,22 @@ function getColumnRenderParam(options) {
6838
6841
  });
6839
6842
  return renderParam;
6840
6843
  }
6844
+ function getUniqueFieldValueFromGroupItems(rowInfo, field) {
6845
+ if (!rowInfo.isGroupRow) {
6846
+ return void 0;
6847
+ }
6848
+ const items = rowInfo.groupData;
6849
+ if (!items.length) {
6850
+ return void 0;
6851
+ }
6852
+ const first = items[0][field];
6853
+ for (let i = 1, len = items.length; i < len; i++) {
6854
+ if (items[i][field] !== first) {
6855
+ return void 0;
6856
+ }
6857
+ }
6858
+ return first;
6859
+ }
6841
6860
  function getRawValueForCell(column, rowInfo) {
6842
6861
  const { data, isGroupRow, dataSourceHasGrouping } = rowInfo;
6843
6862
  const groupBy = dataSourceHasGrouping ? rowInfo.groupBy : void 0;
@@ -6850,6 +6869,9 @@ function getRawValueForCell(column, rowInfo) {
6850
6869
  if (column.field && rowInfo.isGroupRow && rowInfo.reducerData && rowInfo.reducerData[column.field] != null) {
6851
6870
  value = rowInfo.reducerData[column.field];
6852
6871
  }
6872
+ if (value === void 0 && rowInfo.isGroupRow && column.groupByForColumn && isColumnWithField(column)) {
6873
+ value = getUniqueFieldValueFromGroupItems(rowInfo, column.field);
6874
+ }
6853
6875
  if (column.valueGetter) {
6854
6876
  if (!rowInfo.isGroupRow && rowInfo.data) {
6855
6877
  value = column.valueGetter({ data: rowInfo.data, field: column.field });
@@ -6951,10 +6973,24 @@ var InfiniteTableColumnCellClassName = `${rootClassName3}ColumnCell`;
6951
6973
  var columnZIndexAtIndex3 = stripVar(InternalVars.columnZIndexAtIndex);
6952
6974
  var columnVisibilityAtIndex2 = stripVar(InternalVars.columnVisibilityAtIndex);
6953
6975
  function styleForGroupColumn({
6954
- rowInfo
6976
+ rowInfo,
6977
+ column
6955
6978
  }) {
6979
+ let nesting = 0;
6980
+ if (rowInfo.dataSourceHasGrouping) {
6981
+ if (rowInfo.isGroupRow) {
6982
+ const colGroupBy = column?.groupByForColumn;
6983
+ const rowGroupBy = rowInfo.groupBy[rowInfo.groupBy.length - 1];
6984
+ const isPivot = !!rowInfo.pivotValuesMap;
6985
+ const isNestedBoundFieldInPivot = isPivot && !!column?.field && !!colGroupBy && !Array.isArray(colGroupBy) && (colGroupBy.field ?? colGroupBy.groupField) !== (rowGroupBy?.field ?? rowGroupBy?.groupField);
6986
+ const isPivotLeafGroupInSingleColumn = isPivot && Array.isArray(colGroupBy) && rowInfo.groupNesting === rowInfo.rootGroupBy.length;
6987
+ nesting = isNestedBoundFieldInPivot || isPivotLeafGroupInSingleColumn ? rowInfo.groupNesting : rowInfo.groupNesting - 1;
6988
+ } else {
6989
+ nesting = rowInfo.groupNesting;
6990
+ }
6991
+ }
6956
6992
  return {
6957
- [stripVar(ThemeVars.components.Row.groupNesting)]: rowInfo.dataSourceHasGrouping ? rowInfo.isGroupRow ? rowInfo.groupNesting - 1 : rowInfo.groupNesting : 0
6993
+ [stripVar(ThemeVars.components.Row.groupNesting)]: nesting
6958
6994
  };
6959
6995
  }
6960
6996
  function styleForTreeColumn({
@@ -7046,7 +7082,7 @@ function getColumnCellStyling(options) {
7046
7082
  }
7047
7083
  let style2;
7048
7084
  if (rowInfo.dataSourceHasGrouping && column.groupByForColumn) {
7049
- style2 = styleForGroupColumn({ rowInfo });
7085
+ style2 = styleForGroupColumn({ rowInfo, column });
7050
7086
  }
7051
7087
  if (columnIsTree) {
7052
7088
  style2 = styleForTreeColumn({
@@ -26331,17 +26367,19 @@ function getGroupColumnRender({
26331
26367
  const { rowInfo, renderBag, column, align: align2 } = renderOptions;
26332
26368
  let { value: valueToRender, groupIcon, selectionCheckBox } = renderBag;
26333
26369
  const groupRowInfo = rowInfo;
26370
+ const isNestedGroupRow = groupRenderStrategy === "multi-column" && groupRowInfo.isGroupRow && groupIndexForColumn + 1 !== groupRowInfo.groupNesting;
26334
26371
  const className = join(
26335
26372
  display.flex,
26336
26373
  column.align === "end" ? flexFlow.rowReverse : flexFlow.row,
26337
26374
  alignItems.center,
26338
26375
  `${InfiniteTableColumnCellClassName}Expander`,
26339
- groupRenderStrategy === "single-column" || groupRenderStrategy === "multi-column" && (!rowInfo.isGroupRow || selectionCheckBox) ? GroupRowExpanderCls({ align: align2 }) : null
26376
+ groupRenderStrategy === "single-column" || groupRenderStrategy === "multi-column" && (!rowInfo.isGroupRow || selectionCheckBox || isNestedGroupRow && column.field) ? GroupRowExpanderCls({ align: align2 }) : null
26340
26377
  );
26341
- if (groupRenderStrategy === "multi-column") {
26342
- if (groupIndexForColumn + 1 !== groupRowInfo.groupNesting && groupRowInfo.isGroupRow) {
26378
+ if (isNestedGroupRow) {
26379
+ if (!column.field) {
26343
26380
  return selectionCheckBox ? /* @__PURE__ */ React56.createElement("div", { className }, selectionCheckBox) : null;
26344
26381
  }
26382
+ return /* @__PURE__ */ React56.createElement("div", { className }, selectionCheckBox, /* @__PURE__ */ React56.createElement("div", { className: cssEllipsisClassName }, valueToRender ?? null));
26345
26383
  } else if (groupRenderStrategy === "single-column" && !groupRowInfo.isGroupRow) {
26346
26384
  }
26347
26385
  return /* @__PURE__ */ React56.createElement("div", { className }, groupIcon, selectionCheckBox, /* @__PURE__ */ React56.createElement("div", { className: cssEllipsisClassName }, valueToRender ?? null));
@@ -27621,7 +27659,7 @@ var useLicense = (licenseKey = "") => {
27621
27659
  }
27622
27660
  let valid2 = isValidLicense(licenseKey, {
27623
27661
  publishedAt: 1624970570587,
27624
- version: "9.0.1"
27662
+ version: "9.0.3"
27625
27663
  });
27626
27664
  if (!licenseKey && !valid2 && isInsidePlayground) {
27627
27665
  return true;
package/index.dev.mjs CHANGED
@@ -6443,9 +6443,12 @@ function getGroupByColumnReference(options) {
6443
6443
  if (column.groupByForColumn) {
6444
6444
  if (rowInfo.isGroupRow) {
6445
6445
  const rowGroupBy = rowInfo.groupBy[rowInfo.groupBy.length - 1];
6446
- groupByColumn = rowGroupBy ? fieldsToColumn.get(
6447
- rowGroupBy.field || rowGroupBy.groupField
6448
- ) : void 0;
6446
+ const isThisColumnGroupLevel = Array.isArray(column.groupByForColumn) || column.groupByForColumn === rowGroupBy;
6447
+ if (isThisColumnGroupLevel) {
6448
+ groupByColumn = rowGroupBy ? fieldsToColumn.get(
6449
+ rowGroupBy.field || rowGroupBy.groupField
6450
+ ) : void 0;
6451
+ }
6449
6452
  }
6450
6453
  if (!groupByColumn && column.field) {
6451
6454
  groupByColumn = fieldsToColumn.get(column.field);
@@ -6765,6 +6768,22 @@ function getColumnRenderParam(options) {
6765
6768
  });
6766
6769
  return renderParam;
6767
6770
  }
6771
+ function getUniqueFieldValueFromGroupItems(rowInfo, field) {
6772
+ if (!rowInfo.isGroupRow) {
6773
+ return void 0;
6774
+ }
6775
+ const items = rowInfo.groupData;
6776
+ if (!items.length) {
6777
+ return void 0;
6778
+ }
6779
+ const first = items[0][field];
6780
+ for (let i = 1, len = items.length; i < len; i++) {
6781
+ if (items[i][field] !== first) {
6782
+ return void 0;
6783
+ }
6784
+ }
6785
+ return first;
6786
+ }
6768
6787
  function getRawValueForCell(column, rowInfo) {
6769
6788
  const { data, isGroupRow, dataSourceHasGrouping } = rowInfo;
6770
6789
  const groupBy = dataSourceHasGrouping ? rowInfo.groupBy : void 0;
@@ -6777,6 +6796,9 @@ function getRawValueForCell(column, rowInfo) {
6777
6796
  if (column.field && rowInfo.isGroupRow && rowInfo.reducerData && rowInfo.reducerData[column.field] != null) {
6778
6797
  value = rowInfo.reducerData[column.field];
6779
6798
  }
6799
+ if (value === void 0 && rowInfo.isGroupRow && column.groupByForColumn && isColumnWithField(column)) {
6800
+ value = getUniqueFieldValueFromGroupItems(rowInfo, column.field);
6801
+ }
6780
6802
  if (column.valueGetter) {
6781
6803
  if (!rowInfo.isGroupRow && rowInfo.data) {
6782
6804
  value = column.valueGetter({ data: rowInfo.data, field: column.field });
@@ -6878,10 +6900,24 @@ var InfiniteTableColumnCellClassName = `${rootClassName3}ColumnCell`;
6878
6900
  var columnZIndexAtIndex3 = stripVar(InternalVars.columnZIndexAtIndex);
6879
6901
  var columnVisibilityAtIndex2 = stripVar(InternalVars.columnVisibilityAtIndex);
6880
6902
  function styleForGroupColumn({
6881
- rowInfo
6903
+ rowInfo,
6904
+ column
6882
6905
  }) {
6906
+ let nesting = 0;
6907
+ if (rowInfo.dataSourceHasGrouping) {
6908
+ if (rowInfo.isGroupRow) {
6909
+ const colGroupBy = column?.groupByForColumn;
6910
+ const rowGroupBy = rowInfo.groupBy[rowInfo.groupBy.length - 1];
6911
+ const isPivot = !!rowInfo.pivotValuesMap;
6912
+ const isNestedBoundFieldInPivot = isPivot && !!column?.field && !!colGroupBy && !Array.isArray(colGroupBy) && (colGroupBy.field ?? colGroupBy.groupField) !== (rowGroupBy?.field ?? rowGroupBy?.groupField);
6913
+ const isPivotLeafGroupInSingleColumn = isPivot && Array.isArray(colGroupBy) && rowInfo.groupNesting === rowInfo.rootGroupBy.length;
6914
+ nesting = isNestedBoundFieldInPivot || isPivotLeafGroupInSingleColumn ? rowInfo.groupNesting : rowInfo.groupNesting - 1;
6915
+ } else {
6916
+ nesting = rowInfo.groupNesting;
6917
+ }
6918
+ }
6883
6919
  return {
6884
- [stripVar(ThemeVars.components.Row.groupNesting)]: rowInfo.dataSourceHasGrouping ? rowInfo.isGroupRow ? rowInfo.groupNesting - 1 : rowInfo.groupNesting : 0
6920
+ [stripVar(ThemeVars.components.Row.groupNesting)]: nesting
6885
6921
  };
6886
6922
  }
6887
6923
  function styleForTreeColumn({
@@ -6973,7 +7009,7 @@ function getColumnCellStyling(options) {
6973
7009
  }
6974
7010
  let style2;
6975
7011
  if (rowInfo.dataSourceHasGrouping && column.groupByForColumn) {
6976
- style2 = styleForGroupColumn({ rowInfo });
7012
+ style2 = styleForGroupColumn({ rowInfo, column });
6977
7013
  }
6978
7014
  if (columnIsTree) {
6979
7015
  style2 = styleForTreeColumn({
@@ -26263,17 +26299,19 @@ function getGroupColumnRender({
26263
26299
  const { rowInfo, renderBag, column, align: align2 } = renderOptions;
26264
26300
  let { value: valueToRender, groupIcon, selectionCheckBox } = renderBag;
26265
26301
  const groupRowInfo = rowInfo;
26302
+ const isNestedGroupRow = groupRenderStrategy === "multi-column" && groupRowInfo.isGroupRow && groupIndexForColumn + 1 !== groupRowInfo.groupNesting;
26266
26303
  const className = join(
26267
26304
  display.flex,
26268
26305
  column.align === "end" ? flexFlow.rowReverse : flexFlow.row,
26269
26306
  alignItems.center,
26270
26307
  `${InfiniteTableColumnCellClassName}Expander`,
26271
- groupRenderStrategy === "single-column" || groupRenderStrategy === "multi-column" && (!rowInfo.isGroupRow || selectionCheckBox) ? GroupRowExpanderCls({ align: align2 }) : null
26308
+ groupRenderStrategy === "single-column" || groupRenderStrategy === "multi-column" && (!rowInfo.isGroupRow || selectionCheckBox || isNestedGroupRow && column.field) ? GroupRowExpanderCls({ align: align2 }) : null
26272
26309
  );
26273
- if (groupRenderStrategy === "multi-column") {
26274
- if (groupIndexForColumn + 1 !== groupRowInfo.groupNesting && groupRowInfo.isGroupRow) {
26310
+ if (isNestedGroupRow) {
26311
+ if (!column.field) {
26275
26312
  return selectionCheckBox ? /* @__PURE__ */ React56.createElement("div", { className }, selectionCheckBox) : null;
26276
26313
  }
26314
+ return /* @__PURE__ */ React56.createElement("div", { className }, selectionCheckBox, /* @__PURE__ */ React56.createElement("div", { className: cssEllipsisClassName }, valueToRender ?? null));
26277
26315
  } else if (groupRenderStrategy === "single-column" && !groupRowInfo.isGroupRow) {
26278
26316
  }
26279
26317
  return /* @__PURE__ */ React56.createElement("div", { className }, groupIcon, selectionCheckBox, /* @__PURE__ */ React56.createElement("div", { className: cssEllipsisClassName }, valueToRender ?? null));
@@ -27553,7 +27591,7 @@ var useLicense = (licenseKey = "") => {
27553
27591
  }
27554
27592
  let valid2 = isValidLicense(licenseKey, {
27555
27593
  publishedAt: 1624970570587,
27556
- version: "9.0.1"
27594
+ version: "9.0.3"
27557
27595
  });
27558
27596
  if (!licenseKey && !valid2 && isInsidePlayground) {
27559
27597
  return true;