@infinite-table/infinite-react 2.0.1 → 2.0.2

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.d.ts CHANGED
@@ -1537,7 +1537,7 @@ declare type DataSourceRawReducer<T, RESULT_TYPE> = {
1537
1537
  declare type DataSourceAggregationReducer<T, AggregationResultType> = {
1538
1538
  name?: string;
1539
1539
  field?: keyof T;
1540
- initialValue?: AggregationResultType;
1540
+ initialValue?: AggregationResultType | (() => any);
1541
1541
  getter?: (data: T) => any;
1542
1542
  reducer: string | ((accumulator: any, value: any, data: T, index: number, groupKeys: any[] | undefined) => AggregationResultType | any);
1543
1543
  done?: (accumulatedValue: AggregationResultType | any, array: T[]) => AggregationResultType;
@@ -1890,6 +1890,7 @@ declare type InfiniteTable_HasGrouping_RowInfoNormal<T> = {
1890
1890
  declare type InfiniteTable_HasGrouping_RowInfoGroup<T> = {
1891
1891
  dataSourceHasGrouping: true;
1892
1892
  data: Partial<T> | null;
1893
+ reducerData?: Partial<Record<keyof T, any>>;
1893
1894
  isGroupRow: true;
1894
1895
  /**
1895
1896
  * This array contains all the (uncollapsed, so visible) row infos under this group, at any level of nesting,
package/index.dev.js CHANGED
@@ -8034,6 +8034,9 @@ function getRawValueForCell(column, rowInfo) {
8034
8034
  let value = isGroupRow && groupBy && column.groupByForColumn && // if this is a multi-group column we're good
8035
8035
  (Array.isArray(column.groupByForColumn) || // or it has to be a group column for the current group row
8036
8036
  column.groupByForColumn === groupBy[groupBy.length - 1]) ? rowInfo.value : isColumnWithField(column) ? data == null ? void 0 : data[column.field] : null;
8037
+ if (column.field && rowInfo.isGroupRow && rowInfo.reducerData && rowInfo.reducerData[column.field] != null) {
8038
+ value = rowInfo.reducerData[column.field];
8039
+ }
8037
8040
  if (column.valueGetter) {
8038
8041
  if (!rowInfo.isGroupRow && rowInfo.data) {
8039
8042
  value = column.valueGetter({ data: rowInfo.data, field: column.field });
@@ -10574,12 +10577,17 @@ function getEnhancedGroupData(options, deepMapValue) {
10574
10577
  commonData
10575
10578
  } = deepMapValue;
10576
10579
  let data = commonData != null ? commonData : null;
10580
+ let reducerData;
10577
10581
  if (Object.keys(reducerResults).length > 0) {
10578
10582
  data = __spreadValues({}, commonData);
10583
+ reducerData = {};
10579
10584
  for (const key in reducers)
10580
10585
  if (reducers.hasOwnProperty(key)) {
10581
10586
  const reducer = reducers[key];
10582
10587
  const field = reducer.field;
10588
+ if (field) {
10589
+ reducerData[field] = reducerResults[key];
10590
+ }
10583
10591
  if (field && data[field] == null) {
10584
10592
  data[field] = reducerResults[key];
10585
10593
  }
@@ -10604,6 +10612,7 @@ function getEnhancedGroupData(options, deepMapValue) {
10604
10612
  }
10605
10613
  const enhancedGroupData = {
10606
10614
  data,
10615
+ reducerData,
10607
10616
  groupCount: groupItems.length,
10608
10617
  groupData: groupItems,
10609
10618
  groupKeys,
@@ -16756,7 +16765,7 @@ var useLicense = (licenseKey = "") => {
16756
16765
  const valid = (0, import_react49.useMemo)(() => {
16757
16766
  let valid2 = isValidLicense(licenseKey, {
16758
16767
  publishedAt: 1624970570587,
16759
- version: "2.0.1"
16768
+ version: "2.0.2"
16760
16769
  });
16761
16770
  if (!licenseKey && !valid2 && isInsidePlayground) {
16762
16771
  return true;
package/index.dev.mjs CHANGED
@@ -8020,6 +8020,9 @@ function getRawValueForCell(column, rowInfo) {
8020
8020
  let value = isGroupRow && groupBy && column.groupByForColumn && // if this is a multi-group column we're good
8021
8021
  (Array.isArray(column.groupByForColumn) || // or it has to be a group column for the current group row
8022
8022
  column.groupByForColumn === groupBy[groupBy.length - 1]) ? rowInfo.value : isColumnWithField(column) ? data == null ? void 0 : data[column.field] : null;
8023
+ if (column.field && rowInfo.isGroupRow && rowInfo.reducerData && rowInfo.reducerData[column.field] != null) {
8024
+ value = rowInfo.reducerData[column.field];
8025
+ }
8023
8026
  if (column.valueGetter) {
8024
8027
  if (!rowInfo.isGroupRow && rowInfo.data) {
8025
8028
  value = column.valueGetter({ data: rowInfo.data, field: column.field });
@@ -10560,12 +10563,17 @@ function getEnhancedGroupData(options, deepMapValue) {
10560
10563
  commonData
10561
10564
  } = deepMapValue;
10562
10565
  let data = commonData != null ? commonData : null;
10566
+ let reducerData;
10563
10567
  if (Object.keys(reducerResults).length > 0) {
10564
10568
  data = __spreadValues({}, commonData);
10569
+ reducerData = {};
10565
10570
  for (const key in reducers)
10566
10571
  if (reducers.hasOwnProperty(key)) {
10567
10572
  const reducer = reducers[key];
10568
10573
  const field = reducer.field;
10574
+ if (field) {
10575
+ reducerData[field] = reducerResults[key];
10576
+ }
10569
10577
  if (field && data[field] == null) {
10570
10578
  data[field] = reducerResults[key];
10571
10579
  }
@@ -10590,6 +10598,7 @@ function getEnhancedGroupData(options, deepMapValue) {
10590
10598
  }
10591
10599
  const enhancedGroupData = {
10592
10600
  data,
10601
+ reducerData,
10593
10602
  groupCount: groupItems.length,
10594
10603
  groupData: groupItems,
10595
10604
  groupKeys,
@@ -16746,7 +16755,7 @@ var useLicense = (licenseKey = "") => {
16746
16755
  const valid = useMemo11(() => {
16747
16756
  let valid2 = isValidLicense(licenseKey, {
16748
16757
  publishedAt: 1624970570587,
16749
- version: "2.0.1"
16758
+ version: "2.0.2"
16750
16759
  });
16751
16760
  if (!licenseKey && !valid2 && isInsidePlayground) {
16752
16761
  return true;