@infinite-table/infinite-react 9.0.2 → 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
@@ -6841,6 +6841,22 @@ function getColumnRenderParam(options) {
6841
6841
  });
6842
6842
  return renderParam;
6843
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
+ }
6844
6860
  function getRawValueForCell(column, rowInfo) {
6845
6861
  const { data, isGroupRow, dataSourceHasGrouping } = rowInfo;
6846
6862
  const groupBy = dataSourceHasGrouping ? rowInfo.groupBy : void 0;
@@ -6853,6 +6869,9 @@ function getRawValueForCell(column, rowInfo) {
6853
6869
  if (column.field && rowInfo.isGroupRow && rowInfo.reducerData && rowInfo.reducerData[column.field] != null) {
6854
6870
  value = rowInfo.reducerData[column.field];
6855
6871
  }
6872
+ if (value === void 0 && rowInfo.isGroupRow && column.groupByForColumn && isColumnWithField(column)) {
6873
+ value = getUniqueFieldValueFromGroupItems(rowInfo, column.field);
6874
+ }
6856
6875
  if (column.valueGetter) {
6857
6876
  if (!rowInfo.isGroupRow && rowInfo.data) {
6858
6877
  value = column.valueGetter({ data: rowInfo.data, field: column.field });
@@ -6954,10 +6973,24 @@ var InfiniteTableColumnCellClassName = `${rootClassName3}ColumnCell`;
6954
6973
  var columnZIndexAtIndex3 = stripVar(InternalVars.columnZIndexAtIndex);
6955
6974
  var columnVisibilityAtIndex2 = stripVar(InternalVars.columnVisibilityAtIndex);
6956
6975
  function styleForGroupColumn({
6957
- rowInfo
6976
+ rowInfo,
6977
+ column
6958
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
+ }
6959
6992
  return {
6960
- [stripVar(ThemeVars.components.Row.groupNesting)]: rowInfo.dataSourceHasGrouping ? rowInfo.isGroupRow ? rowInfo.groupNesting - 1 : rowInfo.groupNesting : 0
6993
+ [stripVar(ThemeVars.components.Row.groupNesting)]: nesting
6961
6994
  };
6962
6995
  }
6963
6996
  function styleForTreeColumn({
@@ -7049,7 +7082,7 @@ function getColumnCellStyling(options) {
7049
7082
  }
7050
7083
  let style2;
7051
7084
  if (rowInfo.dataSourceHasGrouping && column.groupByForColumn) {
7052
- style2 = styleForGroupColumn({ rowInfo });
7085
+ style2 = styleForGroupColumn({ rowInfo, column });
7053
7086
  }
7054
7087
  if (columnIsTree) {
7055
7088
  style2 = styleForTreeColumn({
@@ -27626,7 +27659,7 @@ var useLicense = (licenseKey = "") => {
27626
27659
  }
27627
27660
  let valid2 = isValidLicense(licenseKey, {
27628
27661
  publishedAt: 1624970570587,
27629
- version: "9.0.2"
27662
+ version: "9.0.3"
27630
27663
  });
27631
27664
  if (!licenseKey && !valid2 && isInsidePlayground) {
27632
27665
  return true;
package/index.dev.mjs CHANGED
@@ -6768,6 +6768,22 @@ function getColumnRenderParam(options) {
6768
6768
  });
6769
6769
  return renderParam;
6770
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
+ }
6771
6787
  function getRawValueForCell(column, rowInfo) {
6772
6788
  const { data, isGroupRow, dataSourceHasGrouping } = rowInfo;
6773
6789
  const groupBy = dataSourceHasGrouping ? rowInfo.groupBy : void 0;
@@ -6780,6 +6796,9 @@ function getRawValueForCell(column, rowInfo) {
6780
6796
  if (column.field && rowInfo.isGroupRow && rowInfo.reducerData && rowInfo.reducerData[column.field] != null) {
6781
6797
  value = rowInfo.reducerData[column.field];
6782
6798
  }
6799
+ if (value === void 0 && rowInfo.isGroupRow && column.groupByForColumn && isColumnWithField(column)) {
6800
+ value = getUniqueFieldValueFromGroupItems(rowInfo, column.field);
6801
+ }
6783
6802
  if (column.valueGetter) {
6784
6803
  if (!rowInfo.isGroupRow && rowInfo.data) {
6785
6804
  value = column.valueGetter({ data: rowInfo.data, field: column.field });
@@ -6881,10 +6900,24 @@ var InfiniteTableColumnCellClassName = `${rootClassName3}ColumnCell`;
6881
6900
  var columnZIndexAtIndex3 = stripVar(InternalVars.columnZIndexAtIndex);
6882
6901
  var columnVisibilityAtIndex2 = stripVar(InternalVars.columnVisibilityAtIndex);
6883
6902
  function styleForGroupColumn({
6884
- rowInfo
6903
+ rowInfo,
6904
+ column
6885
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
+ }
6886
6919
  return {
6887
- [stripVar(ThemeVars.components.Row.groupNesting)]: rowInfo.dataSourceHasGrouping ? rowInfo.isGroupRow ? rowInfo.groupNesting - 1 : rowInfo.groupNesting : 0
6920
+ [stripVar(ThemeVars.components.Row.groupNesting)]: nesting
6888
6921
  };
6889
6922
  }
6890
6923
  function styleForTreeColumn({
@@ -6976,7 +7009,7 @@ function getColumnCellStyling(options) {
6976
7009
  }
6977
7010
  let style2;
6978
7011
  if (rowInfo.dataSourceHasGrouping && column.groupByForColumn) {
6979
- style2 = styleForGroupColumn({ rowInfo });
7012
+ style2 = styleForGroupColumn({ rowInfo, column });
6980
7013
  }
6981
7014
  if (columnIsTree) {
6982
7015
  style2 = styleForTreeColumn({
@@ -27558,7 +27591,7 @@ var useLicense = (licenseKey = "") => {
27558
27591
  }
27559
27592
  let valid2 = isValidLicense(licenseKey, {
27560
27593
  publishedAt: 1624970570587,
27561
- version: "9.0.2"
27594
+ version: "9.0.3"
27562
27595
  });
27563
27596
  if (!licenseKey && !valid2 && isInsidePlayground) {
27564
27597
  return true;