@infinite-table/infinite-react 0.2.2 → 0.2.6
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 +17 -8
- package/index.esm.js +113 -44
- package/index.js +113 -44
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -348,8 +348,7 @@ declare module "components/DataSource/types" {
|
|
|
348
348
|
export interface DataSourceMappedState<T> {
|
|
349
349
|
aggregationReducers?: DataSourceProps<T>['aggregationReducers'];
|
|
350
350
|
livePagination: DataSourceProps<T>['livePagination'];
|
|
351
|
-
|
|
352
|
-
lazyLoadBatchSize: DataSourceProps<T>['lazyLoadBatchSize'];
|
|
351
|
+
lazyLoad: DataSourceProps<T>['lazyLoad'];
|
|
353
352
|
onDataParamsChange: DataSourceProps<T>['onDataParamsChange'];
|
|
354
353
|
data: DataSourceProps<T>['data'];
|
|
355
354
|
primaryKey: DataSourceProps<T>['primaryKey'];
|
|
@@ -418,8 +417,9 @@ declare module "components/DataSource/types" {
|
|
|
418
417
|
primaryKey: keyof T;
|
|
419
418
|
fields?: (keyof T)[];
|
|
420
419
|
data: DataSourceData<T>;
|
|
421
|
-
|
|
422
|
-
|
|
420
|
+
lazyLoad?: boolean | {
|
|
421
|
+
batchSize?: number;
|
|
422
|
+
};
|
|
423
423
|
loading?: boolean;
|
|
424
424
|
defaultLoading?: boolean;
|
|
425
425
|
onLoadingChange?: (loading: boolean) => void;
|
|
@@ -457,6 +457,7 @@ declare module "components/DataSource/types" {
|
|
|
457
457
|
multiSort: boolean;
|
|
458
458
|
controlledSort: boolean;
|
|
459
459
|
livePaginationCursor?: DataSourceLivePaginationCursorValue;
|
|
460
|
+
lazyLoadBatchSize?: number;
|
|
460
461
|
}
|
|
461
462
|
export type DataSourceComponentActions<T> = ComponentStateActions<DataSourceState<T>>;
|
|
462
463
|
export interface DataSourceContextValue<T> {
|
|
@@ -533,10 +534,13 @@ declare module "components/DataSource/state/getInitialState" {
|
|
|
533
534
|
sortInfo: 1 | ((value: import("components/DataSource").DataSourceSortInfo<T> | undefined) => import("components/DataSource").DataSourceSingleSortInfo<T>[] | null);
|
|
534
535
|
groupBy: 1 | ((value: import("components/DataSource").DataSourcePropGroupBy<T> | undefined) => import("components/DataSource").DataSourcePropGroupBy<T>);
|
|
535
536
|
pivotBy: 1 | ((value: import("components/DataSource").DataSourcePropPivotBy<T> | undefined) => import("components/DataSource").DataSourcePropPivotBy<T> | undefined);
|
|
536
|
-
lazyLoadBatchSize: 1 | ((value: number | undefined) => number | undefined);
|
|
537
537
|
aggregationReducers: 1 | ((value: import("components/DataSource").DataSourcePropAggregationReducers<T> | undefined) => import("components/DataSource").DataSourcePropAggregationReducers<T> | undefined);
|
|
538
538
|
livePagination: 1 | ((value: boolean | undefined) => boolean | undefined);
|
|
539
|
-
|
|
539
|
+
lazyLoad: 1 | ((value: boolean | {
|
|
540
|
+
batchSize?: number | undefined;
|
|
541
|
+
} | undefined) => boolean | {
|
|
542
|
+
batchSize?: number | undefined;
|
|
543
|
+
} | undefined);
|
|
540
544
|
onDataParamsChange: 1 | ((value: ((dataParamsChange: DataSourceDataParams<T>) => void) | undefined) => ((dataParamsChange: DataSourceDataParams<T>) => void) | undefined);
|
|
541
545
|
primaryKey: 1 | ((value: keyof T) => keyof T);
|
|
542
546
|
groupRowsState: 1 | ((value: GroupRowsState<any> | undefined) => GroupRowsState<any>);
|
|
@@ -550,6 +554,7 @@ declare module "components/DataSource/state/getInitialState" {
|
|
|
550
554
|
export function onPropChange<T>(params: {
|
|
551
555
|
name: keyof T;
|
|
552
556
|
newValue: any;
|
|
557
|
+
oldValue: any;
|
|
553
558
|
}, props: DataSourceProps<T>, actions: DataSourceComponentActions<T>): void;
|
|
554
559
|
export function getInterceptActions<T>(): ComponentInterceptedActions<DataSourceState<T>>;
|
|
555
560
|
}
|
|
@@ -670,7 +675,9 @@ declare module "components/InfiniteTable/types/InfiniteTableColumn" {
|
|
|
670
675
|
draggable?: boolean;
|
|
671
676
|
resizable?: boolean;
|
|
672
677
|
comparer?: InfiniteTableColumnComparer<T>;
|
|
673
|
-
|
|
678
|
+
defaultHiddenWhenGroupedBy?: '*' | keyof T | {
|
|
679
|
+
[k in keyof Partial<T>]: true;
|
|
680
|
+
};
|
|
674
681
|
align?: InfiniteTableColumnAlign;
|
|
675
682
|
verticalAlign?: InfiniteTableColumnVerticalAlign;
|
|
676
683
|
columnGroup?: string;
|
|
@@ -865,6 +872,7 @@ declare module "utils/groupAndPivot/index" {
|
|
|
865
872
|
export type PivotValuesDeepMap<DataType, KeyType> = DeepMap<GroupKeyType<KeyType>, PivotGroupValueType<DataType, KeyType>>;
|
|
866
873
|
export type DeepMapGroupValueType<DataType, KeyType> = {
|
|
867
874
|
items: DataType[];
|
|
875
|
+
commonData?: Partial<DataType>;
|
|
868
876
|
reducerResults: Record<string, AggregationReducerResult>;
|
|
869
877
|
pivotDeepMap?: DeepMap<GroupKeyType<KeyType>, PivotGroupValueType<DataType, KeyType>>;
|
|
870
878
|
};
|
|
@@ -1130,6 +1138,7 @@ declare module "components/InfiniteTable/types/InfiniteTableProps" {
|
|
|
1130
1138
|
defaultWidth?: number;
|
|
1131
1139
|
defaultFlex?: number;
|
|
1132
1140
|
defaultPinned?: InfiniteTableColumnPinnedValues;
|
|
1141
|
+
defaultHiddenWhenGroupedBy?: InfiniteTableColumn<T>['defaultHiddenWhenGroupedBy'];
|
|
1133
1142
|
header?: InfiniteTableColumn<T>['header'];
|
|
1134
1143
|
comparer?: InfiniteTableColumn<T>['comparer'];
|
|
1135
1144
|
draggable?: InfiniteTableColumn<T>['draggable'];
|
|
@@ -1412,6 +1421,7 @@ declare module "components/InfiniteTable/types/InfiniteTableState" {
|
|
|
1412
1421
|
computedColumnGroups: InfiniteTablePropColumnGroupsMap;
|
|
1413
1422
|
rowHeightCSSVar: string;
|
|
1414
1423
|
headerHeightCSSVar: string;
|
|
1424
|
+
controlledColumnVisibility: boolean;
|
|
1415
1425
|
}
|
|
1416
1426
|
export type InfiniteTableActions<T> = ComponentStateActions<InfiniteTableState<T>>;
|
|
1417
1427
|
export interface InfiniteTableState<T> extends InfiniteTableMappedState<T>, InfiniteTableDerivedState<T>, InfiniteTableSetupState<T> {
|
|
@@ -1660,7 +1670,6 @@ declare module "components/InfiniteTable/utils/getComputedVisibleColumns" {
|
|
|
1660
1670
|
index: number;
|
|
1661
1671
|
};
|
|
1662
1672
|
};
|
|
1663
|
-
export const IS_GROUP_COLUMN_ID: (columnId: string) => boolean;
|
|
1664
1673
|
export type GetComputedVisibleColumnsResult<T> = {
|
|
1665
1674
|
computedRemainingSpace: number;
|
|
1666
1675
|
computedPinnedStartColumnsWidth: number;
|
package/index.esm.js
CHANGED
|
@@ -856,6 +856,7 @@ var mapPropsToState = (params) => {
|
|
|
856
856
|
});
|
|
857
857
|
const computedColumns = state.columnsWhenGrouping || state.columnsWhenInlineGroupRenderStrategy || state.columns;
|
|
858
858
|
return {
|
|
859
|
+
controlledColumnVisibility: !!props.columnVisibility,
|
|
859
860
|
groupRenderStrategy,
|
|
860
861
|
groupBy,
|
|
861
862
|
computedColumns,
|
|
@@ -1389,6 +1390,7 @@ var getComputedVisibleColumns = ({
|
|
|
1389
1390
|
const result2 = __spreadProps(__spreadValues({
|
|
1390
1391
|
align: colType.align,
|
|
1391
1392
|
verticalAlign: colType.verticalAlign,
|
|
1393
|
+
defaultHiddenWhenGroupedBy: colType.defaultHiddenWhenGroupedBy,
|
|
1392
1394
|
valueGetter: colType.valueGetter,
|
|
1393
1395
|
renderValue: colType.renderValue,
|
|
1394
1396
|
render: colType.render
|
|
@@ -2662,6 +2664,13 @@ function lazyGroup(groupParams, rootData) {
|
|
|
2662
2664
|
rootData.visitDepthFirst((lazyGroupRowInfo, keys, _index, next) => {
|
|
2663
2665
|
const [_rootKey, ...currentGroupKeys] = keys;
|
|
2664
2666
|
const dataArray = lazyGroupRowInfo.items;
|
|
2667
|
+
if (currentGroupKeys.length == groupBy.length) {
|
|
2668
|
+
const deepMapGroupValue = deepMap.get(currentGroupKeys);
|
|
2669
|
+
if (deepMapGroupValue) {
|
|
2670
|
+
deepMapGroupValue.items = dataArray;
|
|
2671
|
+
}
|
|
2672
|
+
return next == null ? void 0 : next();
|
|
2673
|
+
}
|
|
2665
2674
|
for (let i = 0, len = dataArray.length; i < len; i++) {
|
|
2666
2675
|
if (!dataArray[i]) {
|
|
2667
2676
|
const deepMapGroupValue2 = {
|
|
@@ -2682,6 +2691,7 @@ function lazyGroup(groupParams, rootData) {
|
|
|
2682
2691
|
currentGroupKeys.push(key);
|
|
2683
2692
|
const deepMapGroupValue = {
|
|
2684
2693
|
items: [],
|
|
2694
|
+
commonData: dataObject,
|
|
2685
2695
|
reducerResults: dataArray[i].aggregations || {}
|
|
2686
2696
|
};
|
|
2687
2697
|
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
@@ -2817,10 +2827,15 @@ function flatten(groupResult) {
|
|
|
2817
2827
|
function getEnhancedGroupData(options, deepMapValue) {
|
|
2818
2828
|
const { groupBy, groupKeys, collapsed, parents, reducers } = options;
|
|
2819
2829
|
const groupNesting = groupKeys.length;
|
|
2820
|
-
const {
|
|
2830
|
+
const {
|
|
2831
|
+
items: groupItems,
|
|
2832
|
+
reducerResults,
|
|
2833
|
+
pivotDeepMap,
|
|
2834
|
+
commonData
|
|
2835
|
+
} = deepMapValue;
|
|
2821
2836
|
let data = null;
|
|
2822
2837
|
if (Object.keys(reducerResults).length > 0) {
|
|
2823
|
-
data = {};
|
|
2838
|
+
data = commonData || {};
|
|
2824
2839
|
for (let key in reducers)
|
|
2825
2840
|
if (reducers.hasOwnProperty(key)) {
|
|
2826
2841
|
const reducer = reducers[key];
|
|
@@ -2839,7 +2854,7 @@ function getEnhancedGroupData(options, deepMapValue) {
|
|
|
2839
2854
|
groupCount: groupItems.length,
|
|
2840
2855
|
groupData: groupItems,
|
|
2841
2856
|
groupKeys,
|
|
2842
|
-
id: groupKeys
|
|
2857
|
+
id: `${groupKeys}`,
|
|
2843
2858
|
collapsed,
|
|
2844
2859
|
parents,
|
|
2845
2860
|
collapsedChildrenCount: 0,
|
|
@@ -2916,7 +2931,7 @@ function enhancedFlatten(param) {
|
|
|
2916
2931
|
const startIndex = result.length;
|
|
2917
2932
|
result.push(...items.map((item, index) => {
|
|
2918
2933
|
return {
|
|
2919
|
-
id: toPrimaryKey(item)
|
|
2934
|
+
id: item ? toPrimaryKey(item) : `${groupKeys}-${index}`,
|
|
2920
2935
|
data: item,
|
|
2921
2936
|
isGroupRow: false,
|
|
2922
2937
|
collapsed: false,
|
|
@@ -3012,7 +3027,7 @@ function buildDataSourceDataParams(componentState, overrides) {
|
|
|
3012
3027
|
dataSourceParams.livePaginationCursor = componentState.livePaginationCursor;
|
|
3013
3028
|
dataSourceParams.cursorId = componentState.cursorId;
|
|
3014
3029
|
}
|
|
3015
|
-
if (componentState.
|
|
3030
|
+
if (componentState.lazyLoad) {
|
|
3016
3031
|
if (componentState.lazyLoadBatchSize != null && componentState.lazyLoadBatchSize > 0) {
|
|
3017
3032
|
dataSourceParams.lazyLoadBatchSize = componentState.lazyLoadBatchSize;
|
|
3018
3033
|
dataSourceParams.lazyLoadStartIndex = 0;
|
|
@@ -3037,9 +3052,9 @@ function buildDataSourceDataParams(componentState, overrides) {
|
|
|
3037
3052
|
}
|
|
3038
3053
|
function loadData(data, componentState, actions, overrides) {
|
|
3039
3054
|
const dataParams = buildDataSourceDataParams(componentState, overrides);
|
|
3040
|
-
if (componentState.
|
|
3055
|
+
if (componentState.lazyLoad) {
|
|
3041
3056
|
const lazyGroupData = componentState.originalLazyGroupData;
|
|
3042
|
-
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys];
|
|
3057
|
+
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys || []];
|
|
3043
3058
|
const existingGroupRowInfo = lazyGroupData.get(key);
|
|
3044
3059
|
if (existingGroupRowInfo && existingGroupRowInfo.cache) {
|
|
3045
3060
|
const items = existingGroupRowInfo.items;
|
|
@@ -3060,7 +3075,7 @@ function loadData(data, componentState, actions, overrides) {
|
|
|
3060
3075
|
data = data(dataParams);
|
|
3061
3076
|
}
|
|
3062
3077
|
const dataIsPromise = typeof data === "object" && typeof data.then === "function";
|
|
3063
|
-
if (dataIsPromise && !componentState.
|
|
3078
|
+
if (dataIsPromise && !componentState.lazyLoad) {
|
|
3064
3079
|
actions.loading = true;
|
|
3065
3080
|
}
|
|
3066
3081
|
return Promise.resolve(data).then((dataParam) => {
|
|
@@ -3076,9 +3091,9 @@ function loadData(data, componentState, actions, overrides) {
|
|
|
3076
3091
|
if (remoteData.mappings) {
|
|
3077
3092
|
actions.pivotMappings = remoteData.mappings;
|
|
3078
3093
|
}
|
|
3079
|
-
if (componentState.
|
|
3094
|
+
if (componentState.lazyLoad) {
|
|
3080
3095
|
const lazyGroupData = componentState.originalLazyGroupData;
|
|
3081
|
-
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys];
|
|
3096
|
+
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys || []];
|
|
3082
3097
|
const newGroupRowInfo = {
|
|
3083
3098
|
cache: !!remoteData.cache,
|
|
3084
3099
|
totalCount: (_a = remoteData.totalCount) != null ? _a : dataArray.length,
|
|
@@ -3108,6 +3123,10 @@ function loadData(data, componentState, actions, overrides) {
|
|
|
3108
3123
|
}
|
|
3109
3124
|
skipAssign = true;
|
|
3110
3125
|
actions.originalLazyGroupDataChangeDetect = getChangeDetect();
|
|
3126
|
+
if (!dataParams.groupKeys || !dataParams.groupKeys.length) {
|
|
3127
|
+
const topLevelItems = lazyGroupData.get([LAZY_ROOT_KEY_FOR_GROUPS]);
|
|
3128
|
+
actions.originalDataArray = [...topLevelItems.items];
|
|
3129
|
+
}
|
|
3111
3130
|
}
|
|
3112
3131
|
} else {
|
|
3113
3132
|
dataArray = dataParam;
|
|
@@ -3115,7 +3134,7 @@ function loadData(data, componentState, actions, overrides) {
|
|
|
3115
3134
|
if (!skipAssign) {
|
|
3116
3135
|
actions.originalDataArray = dataArray;
|
|
3117
3136
|
}
|
|
3118
|
-
if (dataIsPromise && !componentState.
|
|
3137
|
+
if (dataIsPromise && !componentState.lazyLoad) {
|
|
3119
3138
|
actions.loading = false;
|
|
3120
3139
|
}
|
|
3121
3140
|
});
|
|
@@ -3266,34 +3285,34 @@ function lazyLoadRange(options, cache) {
|
|
|
3266
3285
|
continue;
|
|
3267
3286
|
}
|
|
3268
3287
|
const rowLoaded = rowInfo.data != null;
|
|
3269
|
-
const
|
|
3270
|
-
if (rowInfo.groupKeys) {
|
|
3271
|
-
|
|
3288
|
+
const theGroupKeys = rowInfo.groupKeys ? [...rowInfo.groupKeys] : [];
|
|
3289
|
+
if (rowInfo.groupKeys && rowInfo.isGroupRow) {
|
|
3290
|
+
theGroupKeys.pop();
|
|
3272
3291
|
}
|
|
3273
|
-
const cacheKeys =
|
|
3292
|
+
const cacheKeys = theGroupKeys.length ? theGroupKeys : rootGroupKeys;
|
|
3274
3293
|
const indexInGroup = rowInfo.indexInGroup;
|
|
3275
3294
|
if (!rowLoaded) {
|
|
3276
|
-
let
|
|
3295
|
+
let cachedFnCalls = perGroupFnCalls.get(cacheKeys);
|
|
3277
3296
|
const batchStartIndexInGroup = Math.floor(indexInGroup / lazyLoadBatchSize) * lazyLoadBatchSize;
|
|
3278
3297
|
const offset = rowInfo.indexInGroup - batchStartIndexInGroup;
|
|
3279
3298
|
const absoluteIndexOfBatchStart = dataArray[rowInfo.indexInAll - offset].indexInAll;
|
|
3280
3299
|
const batchStartRowLoaded = isRowLoaded(absoluteIndexOfBatchStart);
|
|
3281
3300
|
const batchStartRowId = dataArray[absoluteIndexOfBatchStart].id;
|
|
3282
|
-
if (batchStartRowLoaded || (
|
|
3301
|
+
if (batchStartRowLoaded || (cachedFnCalls == null ? void 0 : cachedFnCalls[batchStartRowId])) {
|
|
3283
3302
|
continue;
|
|
3284
3303
|
}
|
|
3285
|
-
const shouldSetFnCalls = !
|
|
3286
|
-
|
|
3304
|
+
const shouldSetFnCalls = !cachedFnCalls;
|
|
3305
|
+
cachedFnCalls = cachedFnCalls || {};
|
|
3287
3306
|
const currentFnCall = {
|
|
3288
3307
|
lazyLoadStartIndex: batchStartIndexInGroup,
|
|
3289
3308
|
lazyLoadBatchSize,
|
|
3290
|
-
groupKeys:
|
|
3309
|
+
groupKeys: theGroupKeys
|
|
3291
3310
|
};
|
|
3292
|
-
if (!
|
|
3293
|
-
|
|
3311
|
+
if (!cachedFnCalls[batchStartRowId]) {
|
|
3312
|
+
cachedFnCalls[batchStartRowId] = currentFnCall;
|
|
3294
3313
|
}
|
|
3295
3314
|
if (shouldSetFnCalls) {
|
|
3296
|
-
perGroupFnCalls.set(cacheKeys,
|
|
3315
|
+
perGroupFnCalls.set(cacheKeys, cachedFnCalls);
|
|
3297
3316
|
}
|
|
3298
3317
|
}
|
|
3299
3318
|
}
|
|
@@ -3550,12 +3569,11 @@ function getCompareObjectForDataParams(dataParams) {
|
|
|
3550
3569
|
var forwardProps3 = (setupState) => {
|
|
3551
3570
|
return {
|
|
3552
3571
|
onDataParamsChange: (fn) => fn ? discardCallsWithEqualArg(fn, 100, getCompareObjectForDataParams) : void 0,
|
|
3553
|
-
|
|
3572
|
+
lazyLoad: (lazyLoad) => !!lazyLoad,
|
|
3554
3573
|
data: 1,
|
|
3555
3574
|
pivotBy: 1,
|
|
3556
3575
|
primaryKey: 1,
|
|
3557
3576
|
livePagination: 1,
|
|
3558
|
-
lazyLoadBatchSize: (lazyLoadBatchSize) => lazyLoadBatchSize != null ? lazyLoadBatchSize : -1,
|
|
3559
3577
|
aggregationReducers: 1,
|
|
3560
3578
|
collapseGroupRowsOnDataFunctionChange: (collapseGroupRowsOnDataFunctionChange) => collapseGroupRowsOnDataFunctionChange != null ? collapseGroupRowsOnDataFunctionChange : true,
|
|
3561
3579
|
loading: (loading) => loading != null ? loading : false,
|
|
@@ -3582,7 +3600,8 @@ function mapPropsToState2(params) {
|
|
|
3582
3600
|
const controlledSort = isControlledValue(props.sortInfo);
|
|
3583
3601
|
const result = {
|
|
3584
3602
|
controlledSort,
|
|
3585
|
-
multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo)
|
|
3603
|
+
multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo),
|
|
3604
|
+
lazyLoadBatchSize: typeof props.lazyLoad === "object" ? props.lazyLoad.batchSize : void 0
|
|
3586
3605
|
};
|
|
3587
3606
|
if (props.livePagination) {
|
|
3588
3607
|
const dataArrayChanged = !oldState || oldState.originalDataArray !== state.originalDataArray;
|
|
@@ -3595,7 +3614,7 @@ var debugFullLazyLoad = dbg("DataSource:fullLazyLoad");
|
|
|
3595
3614
|
function onPropChange(params, props, actions) {
|
|
3596
3615
|
const { name, newValue } = params;
|
|
3597
3616
|
if (name === "data" && typeof newValue === "function" && !props.groupRowsState) {
|
|
3598
|
-
if (props.
|
|
3617
|
+
if (props.lazyLoad) {
|
|
3599
3618
|
debugFullLazyLoad(`"data" function prop has changed`);
|
|
3600
3619
|
}
|
|
3601
3620
|
if (props.collapseGroupRowsOnDataFunctionChange !== false) {
|
|
@@ -3862,17 +3881,29 @@ function concludeReducer(params) {
|
|
|
3862
3881
|
var _a;
|
|
3863
3882
|
const { state, previousState } = params;
|
|
3864
3883
|
const sortInfo = state.sortInfo;
|
|
3865
|
-
|
|
3866
|
-
|
|
3884
|
+
let shouldSort = !!(sortInfo == null ? void 0 : sortInfo.length) && !state.controlledSort;
|
|
3885
|
+
if (state.lazyLoad || state.livePagination) {
|
|
3886
|
+
shouldSort = false;
|
|
3887
|
+
}
|
|
3888
|
+
let originalDataArrayChanged = haveDepsChanged(previousState, state, [
|
|
3867
3889
|
"originalDataArray"
|
|
3868
3890
|
]);
|
|
3891
|
+
const dataSourceChange = previousState && state.data !== previousState.data;
|
|
3892
|
+
let lazyLoadGroupDataChange = state.lazyLoad && previousState && (previousState.groupBy !== state.groupBy || previousState.sortInfo !== state.sortInfo);
|
|
3893
|
+
if (dataSourceChange) {
|
|
3894
|
+
lazyLoadGroupDataChange = true;
|
|
3895
|
+
}
|
|
3896
|
+
if (lazyLoadGroupDataChange) {
|
|
3897
|
+
state.originalLazyGroupData = new DeepMap();
|
|
3898
|
+
originalDataArrayChanged = true;
|
|
3899
|
+
}
|
|
3869
3900
|
const sortInfoChanged = haveDepsChanged(previousState, state, ["sortInfo"]);
|
|
3870
3901
|
const sortDepsChanged = originalDataArrayChanged || sortInfoChanged;
|
|
3871
3902
|
const shouldSortAgain = shouldSort && (sortDepsChanged || !state.lastSortDataArray);
|
|
3872
3903
|
const groupBy = state.groupBy;
|
|
3873
3904
|
const pivotBy = state.pivotBy;
|
|
3874
3905
|
const shouldGroup = groupBy.length || pivotBy;
|
|
3875
|
-
const groupsDepsChanged = haveDepsChanged(previousState, state, [
|
|
3906
|
+
const groupsDepsChanged = originalDataArrayChanged || haveDepsChanged(previousState, state, [
|
|
3876
3907
|
"generateGroupRows",
|
|
3877
3908
|
"originalDataArray",
|
|
3878
3909
|
"originalLazyGroupData",
|
|
@@ -3897,11 +3928,15 @@ function concludeReducer(params) {
|
|
|
3897
3928
|
state.postSortDataArray = dataArray;
|
|
3898
3929
|
state.groupDeepMap = void 0;
|
|
3899
3930
|
const toPrimaryKey = (data) => {
|
|
3900
|
-
|
|
3931
|
+
const pk = data[state.primaryKey];
|
|
3932
|
+
if (Array.isArray(pk)) {
|
|
3933
|
+
debugger;
|
|
3934
|
+
}
|
|
3935
|
+
return pk;
|
|
3901
3936
|
};
|
|
3902
3937
|
if (shouldGroup) {
|
|
3903
3938
|
if (shouldGroupAgain) {
|
|
3904
|
-
const groupResult = state.
|
|
3939
|
+
const groupResult = state.lazyLoad ? lazyGroup({
|
|
3905
3940
|
groupBy,
|
|
3906
3941
|
pivot: pivotBy,
|
|
3907
3942
|
mappings: state.pivotMappings,
|
|
@@ -3938,8 +3973,8 @@ function concludeReducer(params) {
|
|
|
3938
3973
|
state.groupDeepMap = void 0;
|
|
3939
3974
|
state.pivotColumns = void 0;
|
|
3940
3975
|
const arrayDifferentAfterSortStep = previousState.postSortDataArray != state.postSortDataArray;
|
|
3941
|
-
if (arrayDifferentAfterSortStep) {
|
|
3942
|
-
rowInfoDataArray = dataArray.map((data, index) => toRowInfo(data, toPrimaryKey(data), index));
|
|
3976
|
+
if (arrayDifferentAfterSortStep || groupsDepsChanged) {
|
|
3977
|
+
rowInfoDataArray = dataArray.map((data, index) => toRowInfo(data, data ? toPrimaryKey(data) : index, index));
|
|
3943
3978
|
}
|
|
3944
3979
|
}
|
|
3945
3980
|
state.postGroupDataArray = rowInfoDataArray;
|
|
@@ -4010,7 +4045,7 @@ function useToggleGroupRow() {
|
|
|
4010
4045
|
const newState = new GroupRowsState(state.groupRowsState);
|
|
4011
4046
|
newState.toggleGroupRow(groupKeys);
|
|
4012
4047
|
dataSourceActions.groupRowsState = newState;
|
|
4013
|
-
if (state.
|
|
4048
|
+
if (state.lazyLoad && newState.isGroupRowExpanded(groupKeys)) {
|
|
4014
4049
|
loadData(state.data, state, dataSourceActions, {
|
|
4015
4050
|
groupKeys
|
|
4016
4051
|
});
|
|
@@ -4049,7 +4084,7 @@ function useColumnsWhen() {
|
|
|
4049
4084
|
}, [pivotTotalColumnPosition]);
|
|
4050
4085
|
useColumnsWhenInlineGroupRenderStrategy(groupByMap);
|
|
4051
4086
|
const { toggleGroupRow } = useColumnsWhenGrouping();
|
|
4052
|
-
|
|
4087
|
+
useHideColumns(groupByMap);
|
|
4053
4088
|
return { toggleGroupRow };
|
|
4054
4089
|
}
|
|
4055
4090
|
function useColumnsWhenInlineGroupRenderStrategy(groupByMap) {
|
|
@@ -4171,27 +4206,33 @@ function useColumnsWhenGrouping() {
|
|
|
4171
4206
|
]);
|
|
4172
4207
|
return { toggleGroupRow };
|
|
4173
4208
|
}
|
|
4174
|
-
function
|
|
4209
|
+
function useHideColumns(groupByMap) {
|
|
4175
4210
|
const {
|
|
4176
|
-
componentState: {
|
|
4211
|
+
componentState: {
|
|
4212
|
+
dataArray,
|
|
4213
|
+
groupBy,
|
|
4214
|
+
groupRowsState,
|
|
4215
|
+
originalLazyGroupDataChangeDetect
|
|
4216
|
+
},
|
|
4177
4217
|
getState: getDataSourceState
|
|
4178
4218
|
} = useDataSourceContextValue();
|
|
4179
4219
|
const {
|
|
4180
4220
|
getComponentState,
|
|
4181
4221
|
componentActions,
|
|
4182
4222
|
componentState: {
|
|
4223
|
+
columnTypes,
|
|
4224
|
+
computedColumns,
|
|
4183
4225
|
columnsWhenGrouping: generatedColumns,
|
|
4184
4226
|
hideEmptyGroupColumns,
|
|
4185
4227
|
groupRenderStrategy
|
|
4186
4228
|
}
|
|
4187
4229
|
} = useComponentState();
|
|
4188
4230
|
useEffect9(() => {
|
|
4189
|
-
if (groupRenderStrategy !== "multi-column") {
|
|
4231
|
+
if (groupRenderStrategy !== "multi-column" || !hideEmptyGroupColumns) {
|
|
4190
4232
|
return;
|
|
4191
4233
|
}
|
|
4192
4234
|
const groupsLength = groupBy.length;
|
|
4193
4235
|
let expandedGroupsLevel = 0;
|
|
4194
|
-
const { dataArray } = getDataSourceState();
|
|
4195
4236
|
const len = dataArray.length;
|
|
4196
4237
|
for (let i = 0; i < len; i++) {
|
|
4197
4238
|
const data = dataArray[i];
|
|
@@ -4201,10 +4242,10 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
4201
4242
|
}
|
|
4202
4243
|
}
|
|
4203
4244
|
const currentState = getComponentState();
|
|
4204
|
-
const { computedColumns } = currentState;
|
|
4245
|
+
const { computedColumns: computedColumns2 } = currentState;
|
|
4205
4246
|
let updated = false;
|
|
4206
4247
|
const columnVisibility = __spreadValues({}, currentState.columnVisibility);
|
|
4207
|
-
const cols =
|
|
4248
|
+
const cols = computedColumns2;
|
|
4208
4249
|
groupBy.forEach(({ field, column: groupColumn }, index) => {
|
|
4209
4250
|
const colId = (groupColumn == null ? void 0 : groupColumn.id) || `group-by-${field}`;
|
|
4210
4251
|
let col = cols.get(colId);
|
|
@@ -4226,11 +4267,39 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
4226
4267
|
getDataSourceState,
|
|
4227
4268
|
groupRenderStrategy,
|
|
4228
4269
|
generatedColumns,
|
|
4270
|
+
originalLazyGroupDataChangeDetect,
|
|
4229
4271
|
groupBy,
|
|
4230
|
-
|
|
4272
|
+
hideEmptyGroupColumns ? dataArray : null,
|
|
4231
4273
|
hideEmptyGroupColumns ? groupRowsState : null,
|
|
4232
4274
|
hideEmptyGroupColumns
|
|
4233
4275
|
]);
|
|
4276
|
+
useEffect9(() => {
|
|
4277
|
+
const isGrouped = groupBy.length > 0;
|
|
4278
|
+
const currentState = getComponentState();
|
|
4279
|
+
const { controlledColumnVisibility, columnVisibility } = currentState;
|
|
4280
|
+
if (controlledColumnVisibility) {
|
|
4281
|
+
return;
|
|
4282
|
+
}
|
|
4283
|
+
const newColumnVisibility = __spreadValues({}, columnVisibility);
|
|
4284
|
+
let updated = false;
|
|
4285
|
+
computedColumns.forEach((col, id) => {
|
|
4286
|
+
if (col.defaultHiddenWhenGroupedBy) {
|
|
4287
|
+
const nowHidden = columnVisibility[id] === false;
|
|
4288
|
+
const shouldBeHidden = col.defaultHiddenWhenGroupedBy === "*" && isGrouped || typeof col.defaultHiddenWhenGroupedBy === "string" && groupByMap.get(col.defaultHiddenWhenGroupedBy) || typeof col.defaultHiddenWhenGroupedBy === "object" && Object.keys(col.defaultHiddenWhenGroupedBy).reduce((acc, field) => acc || groupByMap.has(field), false);
|
|
4289
|
+
if (nowHidden !== shouldBeHidden) {
|
|
4290
|
+
updated = true;
|
|
4291
|
+
if (shouldBeHidden) {
|
|
4292
|
+
newColumnVisibility[id] = false;
|
|
4293
|
+
} else {
|
|
4294
|
+
delete newColumnVisibility[id];
|
|
4295
|
+
}
|
|
4296
|
+
}
|
|
4297
|
+
}
|
|
4298
|
+
});
|
|
4299
|
+
if (updated) {
|
|
4300
|
+
componentActions.columnVisibility = newColumnVisibility;
|
|
4301
|
+
}
|
|
4302
|
+
}, [computedColumns, columnTypes, groupBy, groupByMap]);
|
|
4234
4303
|
}
|
|
4235
4304
|
function getColumnsWhenGrouping(params) {
|
|
4236
4305
|
const {
|
|
@@ -7702,7 +7771,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
7702
7771
|
const valid = useMemo12(() => {
|
|
7703
7772
|
let valid2 = isValidLicense(licenseKey, {
|
|
7704
7773
|
publishedAt: 1624970570587,
|
|
7705
|
-
version: "0.2.
|
|
7774
|
+
version: "0.2.6"
|
|
7706
7775
|
});
|
|
7707
7776
|
if (!licenseKey && !valid2 && isInsideSandbox) {
|
|
7708
7777
|
return true;
|
package/index.js
CHANGED
|
@@ -873,6 +873,7 @@ var mapPropsToState = (params) => {
|
|
|
873
873
|
});
|
|
874
874
|
const computedColumns = state.columnsWhenGrouping || state.columnsWhenInlineGroupRenderStrategy || state.columns;
|
|
875
875
|
return {
|
|
876
|
+
controlledColumnVisibility: !!props.columnVisibility,
|
|
876
877
|
groupRenderStrategy,
|
|
877
878
|
groupBy,
|
|
878
879
|
computedColumns,
|
|
@@ -1398,6 +1399,7 @@ var getComputedVisibleColumns = ({
|
|
|
1398
1399
|
const result2 = __spreadProps(__spreadValues({
|
|
1399
1400
|
align: colType.align,
|
|
1400
1401
|
verticalAlign: colType.verticalAlign,
|
|
1402
|
+
defaultHiddenWhenGroupedBy: colType.defaultHiddenWhenGroupedBy,
|
|
1401
1403
|
valueGetter: colType.valueGetter,
|
|
1402
1404
|
renderValue: colType.renderValue,
|
|
1403
1405
|
render: colType.render
|
|
@@ -2648,6 +2650,13 @@ function lazyGroup(groupParams, rootData) {
|
|
|
2648
2650
|
rootData.visitDepthFirst((lazyGroupRowInfo, keys, _index, next) => {
|
|
2649
2651
|
const [_rootKey, ...currentGroupKeys] = keys;
|
|
2650
2652
|
const dataArray = lazyGroupRowInfo.items;
|
|
2653
|
+
if (currentGroupKeys.length == groupBy.length) {
|
|
2654
|
+
const deepMapGroupValue = deepMap.get(currentGroupKeys);
|
|
2655
|
+
if (deepMapGroupValue) {
|
|
2656
|
+
deepMapGroupValue.items = dataArray;
|
|
2657
|
+
}
|
|
2658
|
+
return next == null ? void 0 : next();
|
|
2659
|
+
}
|
|
2651
2660
|
for (let i = 0, len = dataArray.length; i < len; i++) {
|
|
2652
2661
|
if (!dataArray[i]) {
|
|
2653
2662
|
const deepMapGroupValue2 = {
|
|
@@ -2668,6 +2677,7 @@ function lazyGroup(groupParams, rootData) {
|
|
|
2668
2677
|
currentGroupKeys.push(key);
|
|
2669
2678
|
const deepMapGroupValue = {
|
|
2670
2679
|
items: [],
|
|
2680
|
+
commonData: dataObject,
|
|
2671
2681
|
reducerResults: dataArray[i].aggregations || {}
|
|
2672
2682
|
};
|
|
2673
2683
|
deepMap.set(currentGroupKeys, deepMapGroupValue);
|
|
@@ -2803,10 +2813,15 @@ function flatten(groupResult) {
|
|
|
2803
2813
|
function getEnhancedGroupData(options, deepMapValue) {
|
|
2804
2814
|
const { groupBy, groupKeys, collapsed, parents, reducers } = options;
|
|
2805
2815
|
const groupNesting = groupKeys.length;
|
|
2806
|
-
const {
|
|
2816
|
+
const {
|
|
2817
|
+
items: groupItems,
|
|
2818
|
+
reducerResults,
|
|
2819
|
+
pivotDeepMap,
|
|
2820
|
+
commonData
|
|
2821
|
+
} = deepMapValue;
|
|
2807
2822
|
let data = null;
|
|
2808
2823
|
if (Object.keys(reducerResults).length > 0) {
|
|
2809
|
-
data = {};
|
|
2824
|
+
data = commonData || {};
|
|
2810
2825
|
for (let key in reducers)
|
|
2811
2826
|
if (reducers.hasOwnProperty(key)) {
|
|
2812
2827
|
const reducer = reducers[key];
|
|
@@ -2825,7 +2840,7 @@ function getEnhancedGroupData(options, deepMapValue) {
|
|
|
2825
2840
|
groupCount: groupItems.length,
|
|
2826
2841
|
groupData: groupItems,
|
|
2827
2842
|
groupKeys,
|
|
2828
|
-
id: groupKeys
|
|
2843
|
+
id: `${groupKeys}`,
|
|
2829
2844
|
collapsed,
|
|
2830
2845
|
parents,
|
|
2831
2846
|
collapsedChildrenCount: 0,
|
|
@@ -2902,7 +2917,7 @@ function enhancedFlatten(param) {
|
|
|
2902
2917
|
const startIndex = result.length;
|
|
2903
2918
|
result.push(...items.map((item, index) => {
|
|
2904
2919
|
return {
|
|
2905
|
-
id: toPrimaryKey(item)
|
|
2920
|
+
id: item ? toPrimaryKey(item) : `${groupKeys}-${index}`,
|
|
2906
2921
|
data: item,
|
|
2907
2922
|
isGroupRow: false,
|
|
2908
2923
|
collapsed: false,
|
|
@@ -2998,7 +3013,7 @@ function buildDataSourceDataParams(componentState, overrides) {
|
|
|
2998
3013
|
dataSourceParams.livePaginationCursor = componentState.livePaginationCursor;
|
|
2999
3014
|
dataSourceParams.cursorId = componentState.cursorId;
|
|
3000
3015
|
}
|
|
3001
|
-
if (componentState.
|
|
3016
|
+
if (componentState.lazyLoad) {
|
|
3002
3017
|
if (componentState.lazyLoadBatchSize != null && componentState.lazyLoadBatchSize > 0) {
|
|
3003
3018
|
dataSourceParams.lazyLoadBatchSize = componentState.lazyLoadBatchSize;
|
|
3004
3019
|
dataSourceParams.lazyLoadStartIndex = 0;
|
|
@@ -3023,9 +3038,9 @@ function buildDataSourceDataParams(componentState, overrides) {
|
|
|
3023
3038
|
}
|
|
3024
3039
|
function loadData(data, componentState, actions, overrides) {
|
|
3025
3040
|
const dataParams = buildDataSourceDataParams(componentState, overrides);
|
|
3026
|
-
if (componentState.
|
|
3041
|
+
if (componentState.lazyLoad) {
|
|
3027
3042
|
const lazyGroupData = componentState.originalLazyGroupData;
|
|
3028
|
-
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys];
|
|
3043
|
+
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys || []];
|
|
3029
3044
|
const existingGroupRowInfo = lazyGroupData.get(key);
|
|
3030
3045
|
if (existingGroupRowInfo && existingGroupRowInfo.cache) {
|
|
3031
3046
|
const items = existingGroupRowInfo.items;
|
|
@@ -3046,7 +3061,7 @@ function loadData(data, componentState, actions, overrides) {
|
|
|
3046
3061
|
data = data(dataParams);
|
|
3047
3062
|
}
|
|
3048
3063
|
const dataIsPromise = typeof data === "object" && typeof data.then === "function";
|
|
3049
|
-
if (dataIsPromise && !componentState.
|
|
3064
|
+
if (dataIsPromise && !componentState.lazyLoad) {
|
|
3050
3065
|
actions.loading = true;
|
|
3051
3066
|
}
|
|
3052
3067
|
return Promise.resolve(data).then((dataParam) => {
|
|
@@ -3062,9 +3077,9 @@ function loadData(data, componentState, actions, overrides) {
|
|
|
3062
3077
|
if (remoteData.mappings) {
|
|
3063
3078
|
actions.pivotMappings = remoteData.mappings;
|
|
3064
3079
|
}
|
|
3065
|
-
if (componentState.
|
|
3080
|
+
if (componentState.lazyLoad) {
|
|
3066
3081
|
const lazyGroupData = componentState.originalLazyGroupData;
|
|
3067
|
-
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys];
|
|
3082
|
+
const key = [LAZY_ROOT_KEY_FOR_GROUPS, ...dataParams.groupKeys || []];
|
|
3068
3083
|
const newGroupRowInfo = {
|
|
3069
3084
|
cache: !!remoteData.cache,
|
|
3070
3085
|
totalCount: (_a = remoteData.totalCount) != null ? _a : dataArray.length,
|
|
@@ -3094,6 +3109,10 @@ function loadData(data, componentState, actions, overrides) {
|
|
|
3094
3109
|
}
|
|
3095
3110
|
skipAssign = true;
|
|
3096
3111
|
actions.originalLazyGroupDataChangeDetect = getChangeDetect();
|
|
3112
|
+
if (!dataParams.groupKeys || !dataParams.groupKeys.length) {
|
|
3113
|
+
const topLevelItems = lazyGroupData.get([LAZY_ROOT_KEY_FOR_GROUPS]);
|
|
3114
|
+
actions.originalDataArray = [...topLevelItems.items];
|
|
3115
|
+
}
|
|
3097
3116
|
}
|
|
3098
3117
|
} else {
|
|
3099
3118
|
dataArray = dataParam;
|
|
@@ -3101,7 +3120,7 @@ function loadData(data, componentState, actions, overrides) {
|
|
|
3101
3120
|
if (!skipAssign) {
|
|
3102
3121
|
actions.originalDataArray = dataArray;
|
|
3103
3122
|
}
|
|
3104
|
-
if (dataIsPromise && !componentState.
|
|
3123
|
+
if (dataIsPromise && !componentState.lazyLoad) {
|
|
3105
3124
|
actions.loading = false;
|
|
3106
3125
|
}
|
|
3107
3126
|
});
|
|
@@ -3252,34 +3271,34 @@ function lazyLoadRange(options, cache) {
|
|
|
3252
3271
|
continue;
|
|
3253
3272
|
}
|
|
3254
3273
|
const rowLoaded = rowInfo.data != null;
|
|
3255
|
-
const
|
|
3256
|
-
if (rowInfo.groupKeys) {
|
|
3257
|
-
|
|
3274
|
+
const theGroupKeys = rowInfo.groupKeys ? [...rowInfo.groupKeys] : [];
|
|
3275
|
+
if (rowInfo.groupKeys && rowInfo.isGroupRow) {
|
|
3276
|
+
theGroupKeys.pop();
|
|
3258
3277
|
}
|
|
3259
|
-
const cacheKeys =
|
|
3278
|
+
const cacheKeys = theGroupKeys.length ? theGroupKeys : rootGroupKeys;
|
|
3260
3279
|
const indexInGroup = rowInfo.indexInGroup;
|
|
3261
3280
|
if (!rowLoaded) {
|
|
3262
|
-
let
|
|
3281
|
+
let cachedFnCalls = perGroupFnCalls.get(cacheKeys);
|
|
3263
3282
|
const batchStartIndexInGroup = Math.floor(indexInGroup / lazyLoadBatchSize) * lazyLoadBatchSize;
|
|
3264
3283
|
const offset = rowInfo.indexInGroup - batchStartIndexInGroup;
|
|
3265
3284
|
const absoluteIndexOfBatchStart = dataArray[rowInfo.indexInAll - offset].indexInAll;
|
|
3266
3285
|
const batchStartRowLoaded = isRowLoaded(absoluteIndexOfBatchStart);
|
|
3267
3286
|
const batchStartRowId = dataArray[absoluteIndexOfBatchStart].id;
|
|
3268
|
-
if (batchStartRowLoaded || (
|
|
3287
|
+
if (batchStartRowLoaded || (cachedFnCalls == null ? void 0 : cachedFnCalls[batchStartRowId])) {
|
|
3269
3288
|
continue;
|
|
3270
3289
|
}
|
|
3271
|
-
const shouldSetFnCalls = !
|
|
3272
|
-
|
|
3290
|
+
const shouldSetFnCalls = !cachedFnCalls;
|
|
3291
|
+
cachedFnCalls = cachedFnCalls || {};
|
|
3273
3292
|
const currentFnCall = {
|
|
3274
3293
|
lazyLoadStartIndex: batchStartIndexInGroup,
|
|
3275
3294
|
lazyLoadBatchSize,
|
|
3276
|
-
groupKeys:
|
|
3295
|
+
groupKeys: theGroupKeys
|
|
3277
3296
|
};
|
|
3278
|
-
if (!
|
|
3279
|
-
|
|
3297
|
+
if (!cachedFnCalls[batchStartRowId]) {
|
|
3298
|
+
cachedFnCalls[batchStartRowId] = currentFnCall;
|
|
3280
3299
|
}
|
|
3281
3300
|
if (shouldSetFnCalls) {
|
|
3282
|
-
perGroupFnCalls.set(cacheKeys,
|
|
3301
|
+
perGroupFnCalls.set(cacheKeys, cachedFnCalls);
|
|
3283
3302
|
}
|
|
3284
3303
|
}
|
|
3285
3304
|
}
|
|
@@ -3536,12 +3555,11 @@ function getCompareObjectForDataParams(dataParams) {
|
|
|
3536
3555
|
var forwardProps3 = (setupState) => {
|
|
3537
3556
|
return {
|
|
3538
3557
|
onDataParamsChange: (fn) => fn ? discardCallsWithEqualArg(fn, 100, getCompareObjectForDataParams) : void 0,
|
|
3539
|
-
|
|
3558
|
+
lazyLoad: (lazyLoad) => !!lazyLoad,
|
|
3540
3559
|
data: 1,
|
|
3541
3560
|
pivotBy: 1,
|
|
3542
3561
|
primaryKey: 1,
|
|
3543
3562
|
livePagination: 1,
|
|
3544
|
-
lazyLoadBatchSize: (lazyLoadBatchSize) => lazyLoadBatchSize != null ? lazyLoadBatchSize : -1,
|
|
3545
3563
|
aggregationReducers: 1,
|
|
3546
3564
|
collapseGroupRowsOnDataFunctionChange: (collapseGroupRowsOnDataFunctionChange) => collapseGroupRowsOnDataFunctionChange != null ? collapseGroupRowsOnDataFunctionChange : true,
|
|
3547
3565
|
loading: (loading) => loading != null ? loading : false,
|
|
@@ -3568,7 +3586,8 @@ function mapPropsToState2(params) {
|
|
|
3568
3586
|
const controlledSort = isControlledValue(props.sortInfo);
|
|
3569
3587
|
const result = {
|
|
3570
3588
|
controlledSort,
|
|
3571
|
-
multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo)
|
|
3589
|
+
multiSort: Array.isArray(controlledSort ? props.sortInfo : props.defaultSortInfo),
|
|
3590
|
+
lazyLoadBatchSize: typeof props.lazyLoad === "object" ? props.lazyLoad.batchSize : void 0
|
|
3572
3591
|
};
|
|
3573
3592
|
if (props.livePagination) {
|
|
3574
3593
|
const dataArrayChanged = !oldState || oldState.originalDataArray !== state.originalDataArray;
|
|
@@ -3581,7 +3600,7 @@ var debugFullLazyLoad = dbg("DataSource:fullLazyLoad");
|
|
|
3581
3600
|
function onPropChange(params, props, actions) {
|
|
3582
3601
|
const { name, newValue } = params;
|
|
3583
3602
|
if (name === "data" && typeof newValue === "function" && !props.groupRowsState) {
|
|
3584
|
-
if (props.
|
|
3603
|
+
if (props.lazyLoad) {
|
|
3585
3604
|
debugFullLazyLoad(`"data" function prop has changed`);
|
|
3586
3605
|
}
|
|
3587
3606
|
if (props.collapseGroupRowsOnDataFunctionChange !== false) {
|
|
@@ -3848,17 +3867,29 @@ function concludeReducer(params) {
|
|
|
3848
3867
|
var _a;
|
|
3849
3868
|
const { state, previousState } = params;
|
|
3850
3869
|
const sortInfo = state.sortInfo;
|
|
3851
|
-
|
|
3852
|
-
|
|
3870
|
+
let shouldSort = !!(sortInfo == null ? void 0 : sortInfo.length) && !state.controlledSort;
|
|
3871
|
+
if (state.lazyLoad || state.livePagination) {
|
|
3872
|
+
shouldSort = false;
|
|
3873
|
+
}
|
|
3874
|
+
let originalDataArrayChanged = haveDepsChanged(previousState, state, [
|
|
3853
3875
|
"originalDataArray"
|
|
3854
3876
|
]);
|
|
3877
|
+
const dataSourceChange = previousState && state.data !== previousState.data;
|
|
3878
|
+
let lazyLoadGroupDataChange = state.lazyLoad && previousState && (previousState.groupBy !== state.groupBy || previousState.sortInfo !== state.sortInfo);
|
|
3879
|
+
if (dataSourceChange) {
|
|
3880
|
+
lazyLoadGroupDataChange = true;
|
|
3881
|
+
}
|
|
3882
|
+
if (lazyLoadGroupDataChange) {
|
|
3883
|
+
state.originalLazyGroupData = new DeepMap();
|
|
3884
|
+
originalDataArrayChanged = true;
|
|
3885
|
+
}
|
|
3855
3886
|
const sortInfoChanged = haveDepsChanged(previousState, state, ["sortInfo"]);
|
|
3856
3887
|
const sortDepsChanged = originalDataArrayChanged || sortInfoChanged;
|
|
3857
3888
|
const shouldSortAgain = shouldSort && (sortDepsChanged || !state.lastSortDataArray);
|
|
3858
3889
|
const groupBy = state.groupBy;
|
|
3859
3890
|
const pivotBy = state.pivotBy;
|
|
3860
3891
|
const shouldGroup = groupBy.length || pivotBy;
|
|
3861
|
-
const groupsDepsChanged = haveDepsChanged(previousState, state, [
|
|
3892
|
+
const groupsDepsChanged = originalDataArrayChanged || haveDepsChanged(previousState, state, [
|
|
3862
3893
|
"generateGroupRows",
|
|
3863
3894
|
"originalDataArray",
|
|
3864
3895
|
"originalLazyGroupData",
|
|
@@ -3883,11 +3914,15 @@ function concludeReducer(params) {
|
|
|
3883
3914
|
state.postSortDataArray = dataArray;
|
|
3884
3915
|
state.groupDeepMap = void 0;
|
|
3885
3916
|
const toPrimaryKey = (data) => {
|
|
3886
|
-
|
|
3917
|
+
const pk = data[state.primaryKey];
|
|
3918
|
+
if (Array.isArray(pk)) {
|
|
3919
|
+
debugger;
|
|
3920
|
+
}
|
|
3921
|
+
return pk;
|
|
3887
3922
|
};
|
|
3888
3923
|
if (shouldGroup) {
|
|
3889
3924
|
if (shouldGroupAgain) {
|
|
3890
|
-
const groupResult = state.
|
|
3925
|
+
const groupResult = state.lazyLoad ? lazyGroup({
|
|
3891
3926
|
groupBy,
|
|
3892
3927
|
pivot: pivotBy,
|
|
3893
3928
|
mappings: state.pivotMappings,
|
|
@@ -3924,8 +3959,8 @@ function concludeReducer(params) {
|
|
|
3924
3959
|
state.groupDeepMap = void 0;
|
|
3925
3960
|
state.pivotColumns = void 0;
|
|
3926
3961
|
const arrayDifferentAfterSortStep = previousState.postSortDataArray != state.postSortDataArray;
|
|
3927
|
-
if (arrayDifferentAfterSortStep) {
|
|
3928
|
-
rowInfoDataArray = dataArray.map((data, index) => toRowInfo(data, toPrimaryKey(data), index));
|
|
3962
|
+
if (arrayDifferentAfterSortStep || groupsDepsChanged) {
|
|
3963
|
+
rowInfoDataArray = dataArray.map((data, index) => toRowInfo(data, data ? toPrimaryKey(data) : index, index));
|
|
3929
3964
|
}
|
|
3930
3965
|
}
|
|
3931
3966
|
state.postGroupDataArray = rowInfoDataArray;
|
|
@@ -3996,7 +4031,7 @@ function useToggleGroupRow() {
|
|
|
3996
4031
|
const newState = new GroupRowsState(state.groupRowsState);
|
|
3997
4032
|
newState.toggleGroupRow(groupKeys);
|
|
3998
4033
|
dataSourceActions.groupRowsState = newState;
|
|
3999
|
-
if (state.
|
|
4034
|
+
if (state.lazyLoad && newState.isGroupRowExpanded(groupKeys)) {
|
|
4000
4035
|
loadData(state.data, state, dataSourceActions, {
|
|
4001
4036
|
groupKeys
|
|
4002
4037
|
});
|
|
@@ -4035,7 +4070,7 @@ function useColumnsWhen() {
|
|
|
4035
4070
|
}, [pivotTotalColumnPosition]);
|
|
4036
4071
|
useColumnsWhenInlineGroupRenderStrategy(groupByMap);
|
|
4037
4072
|
const { toggleGroupRow } = useColumnsWhenGrouping();
|
|
4038
|
-
|
|
4073
|
+
useHideColumns(groupByMap);
|
|
4039
4074
|
return { toggleGroupRow };
|
|
4040
4075
|
}
|
|
4041
4076
|
function useColumnsWhenInlineGroupRenderStrategy(groupByMap) {
|
|
@@ -4157,27 +4192,33 @@ function useColumnsWhenGrouping() {
|
|
|
4157
4192
|
]);
|
|
4158
4193
|
return { toggleGroupRow };
|
|
4159
4194
|
}
|
|
4160
|
-
function
|
|
4195
|
+
function useHideColumns(groupByMap) {
|
|
4161
4196
|
const {
|
|
4162
|
-
componentState: {
|
|
4197
|
+
componentState: {
|
|
4198
|
+
dataArray,
|
|
4199
|
+
groupBy,
|
|
4200
|
+
groupRowsState,
|
|
4201
|
+
originalLazyGroupDataChangeDetect
|
|
4202
|
+
},
|
|
4163
4203
|
getState: getDataSourceState
|
|
4164
4204
|
} = useDataSourceContextValue();
|
|
4165
4205
|
const {
|
|
4166
4206
|
getComponentState,
|
|
4167
4207
|
componentActions,
|
|
4168
4208
|
componentState: {
|
|
4209
|
+
columnTypes,
|
|
4210
|
+
computedColumns,
|
|
4169
4211
|
columnsWhenGrouping: generatedColumns,
|
|
4170
4212
|
hideEmptyGroupColumns,
|
|
4171
4213
|
groupRenderStrategy
|
|
4172
4214
|
}
|
|
4173
4215
|
} = useComponentState();
|
|
4174
4216
|
(0, import_react17.useEffect)(() => {
|
|
4175
|
-
if (groupRenderStrategy !== "multi-column") {
|
|
4217
|
+
if (groupRenderStrategy !== "multi-column" || !hideEmptyGroupColumns) {
|
|
4176
4218
|
return;
|
|
4177
4219
|
}
|
|
4178
4220
|
const groupsLength = groupBy.length;
|
|
4179
4221
|
let expandedGroupsLevel = 0;
|
|
4180
|
-
const { dataArray } = getDataSourceState();
|
|
4181
4222
|
const len = dataArray.length;
|
|
4182
4223
|
for (let i = 0; i < len; i++) {
|
|
4183
4224
|
const data = dataArray[i];
|
|
@@ -4187,10 +4228,10 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
4187
4228
|
}
|
|
4188
4229
|
}
|
|
4189
4230
|
const currentState = getComponentState();
|
|
4190
|
-
const { computedColumns } = currentState;
|
|
4231
|
+
const { computedColumns: computedColumns2 } = currentState;
|
|
4191
4232
|
let updated = false;
|
|
4192
4233
|
const columnVisibility = __spreadValues({}, currentState.columnVisibility);
|
|
4193
|
-
const cols =
|
|
4234
|
+
const cols = computedColumns2;
|
|
4194
4235
|
groupBy.forEach(({ field, column: groupColumn }, index) => {
|
|
4195
4236
|
const colId = (groupColumn == null ? void 0 : groupColumn.id) || `group-by-${field}`;
|
|
4196
4237
|
let col = cols.get(colId);
|
|
@@ -4212,11 +4253,39 @@ function useHideEmptyGroupColumns(groupRowsMap) {
|
|
|
4212
4253
|
getDataSourceState,
|
|
4213
4254
|
groupRenderStrategy,
|
|
4214
4255
|
generatedColumns,
|
|
4256
|
+
originalLazyGroupDataChangeDetect,
|
|
4215
4257
|
groupBy,
|
|
4216
|
-
|
|
4258
|
+
hideEmptyGroupColumns ? dataArray : null,
|
|
4217
4259
|
hideEmptyGroupColumns ? groupRowsState : null,
|
|
4218
4260
|
hideEmptyGroupColumns
|
|
4219
4261
|
]);
|
|
4262
|
+
(0, import_react17.useEffect)(() => {
|
|
4263
|
+
const isGrouped = groupBy.length > 0;
|
|
4264
|
+
const currentState = getComponentState();
|
|
4265
|
+
const { controlledColumnVisibility, columnVisibility } = currentState;
|
|
4266
|
+
if (controlledColumnVisibility) {
|
|
4267
|
+
return;
|
|
4268
|
+
}
|
|
4269
|
+
const newColumnVisibility = __spreadValues({}, columnVisibility);
|
|
4270
|
+
let updated = false;
|
|
4271
|
+
computedColumns.forEach((col, id) => {
|
|
4272
|
+
if (col.defaultHiddenWhenGroupedBy) {
|
|
4273
|
+
const nowHidden = columnVisibility[id] === false;
|
|
4274
|
+
const shouldBeHidden = col.defaultHiddenWhenGroupedBy === "*" && isGrouped || typeof col.defaultHiddenWhenGroupedBy === "string" && groupByMap.get(col.defaultHiddenWhenGroupedBy) || typeof col.defaultHiddenWhenGroupedBy === "object" && Object.keys(col.defaultHiddenWhenGroupedBy).reduce((acc, field) => acc || groupByMap.has(field), false);
|
|
4275
|
+
if (nowHidden !== shouldBeHidden) {
|
|
4276
|
+
updated = true;
|
|
4277
|
+
if (shouldBeHidden) {
|
|
4278
|
+
newColumnVisibility[id] = false;
|
|
4279
|
+
} else {
|
|
4280
|
+
delete newColumnVisibility[id];
|
|
4281
|
+
}
|
|
4282
|
+
}
|
|
4283
|
+
}
|
|
4284
|
+
});
|
|
4285
|
+
if (updated) {
|
|
4286
|
+
componentActions.columnVisibility = newColumnVisibility;
|
|
4287
|
+
}
|
|
4288
|
+
}, [computedColumns, columnTypes, groupBy, groupByMap]);
|
|
4220
4289
|
}
|
|
4221
4290
|
function getColumnsWhenGrouping(params) {
|
|
4222
4291
|
const {
|
|
@@ -7609,7 +7678,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
7609
7678
|
const valid = (0, import_react43.useMemo)(() => {
|
|
7610
7679
|
let valid2 = isValidLicense(licenseKey, {
|
|
7611
7680
|
publishedAt: 1624970570587,
|
|
7612
|
-
version: "0.2.
|
|
7681
|
+
version: "0.2.6"
|
|
7613
7682
|
});
|
|
7614
7683
|
if (!licenseKey && !valid2 && isInsideSandbox) {
|
|
7615
7684
|
return true;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infinite-table/infinite-react",
|
|
3
3
|
"description": "Infinite Table for React",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.6",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.esm.js",
|
|
7
7
|
"typings": "index.d.ts",
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
},
|
|
15
15
|
"license": "Commercial & Open Source",
|
|
16
16
|
"//": "will be updated at build time",
|
|
17
|
-
"publishedAt":
|
|
17
|
+
"publishedAt": 1644931690394
|
|
18
18
|
}
|