@infinite-table/infinite-react 2.0.3 → 2.0.4
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 +7 -3
- package/index.dev.js +41 -15
- package/index.dev.mjs +41 -15
- package/index.js +2 -2
- package/index.mjs +2 -2
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -1376,17 +1376,20 @@ declare type DataSourceMutation<T> = {
|
|
|
1376
1376
|
type: 'delete';
|
|
1377
1377
|
primaryKey: any;
|
|
1378
1378
|
originalData: T;
|
|
1379
|
+
metadata: any;
|
|
1379
1380
|
} | {
|
|
1380
1381
|
type: 'update';
|
|
1381
1382
|
primaryKey: any;
|
|
1382
1383
|
data: Partial<T>;
|
|
1383
1384
|
originalData: T;
|
|
1385
|
+
metadata: any;
|
|
1384
1386
|
} | {
|
|
1385
1387
|
type: 'insert';
|
|
1386
1388
|
primaryKey: any;
|
|
1387
1389
|
position: 'before' | 'after';
|
|
1388
1390
|
originalData: null;
|
|
1389
1391
|
data: T;
|
|
1392
|
+
metadata: any;
|
|
1390
1393
|
};
|
|
1391
1394
|
declare class DataSourceCache<DataType, PrimaryKeyType = string> {
|
|
1392
1395
|
private affectedFields;
|
|
@@ -1396,9 +1399,9 @@ declare class DataSourceCache<DataType, PrimaryKeyType = string> {
|
|
|
1396
1399
|
light?: boolean;
|
|
1397
1400
|
}): DataSourceCache<DataType, PrimaryKeyType>;
|
|
1398
1401
|
getAffectedFields: () => true | Set<keyof DataType>;
|
|
1399
|
-
delete: (primaryKey: PrimaryKeyType, originalData: DataType) => void;
|
|
1400
|
-
insert: (primaryKey: PrimaryKeyType, data: DataType, position: 'before' | 'after') => void;
|
|
1401
|
-
update: (primaryKey: PrimaryKeyType, data: Partial<DataType>, originalData: DataType) => void;
|
|
1402
|
+
delete: (primaryKey: PrimaryKeyType, originalData: DataType, metadata: any) => void;
|
|
1403
|
+
insert: (primaryKey: PrimaryKeyType, data: DataType, position: 'before' | 'after', metadata: any) => void;
|
|
1404
|
+
update: (primaryKey: PrimaryKeyType, data: Partial<DataType>, originalData: DataType, metadata: any) => void;
|
|
1402
1405
|
clear: () => void;
|
|
1403
1406
|
isEmpty: () => boolean;
|
|
1404
1407
|
removeInfo: (primaryKey: PrimaryKeyType) => void;
|
|
@@ -1639,6 +1642,7 @@ declare type DataSourcePropIsRowSelected<T> = (rowInfo: InfiniteTableRowInfo<T>,
|
|
|
1639
1642
|
declare type DataSourcePropSortFn<T> = (sortInfo: MultisortInfoAllowMultipleFields<T>[], array: T[], get?: (item: any) => T) => T[];
|
|
1640
1643
|
declare type DataSourceCRUDParam = {
|
|
1641
1644
|
flush?: boolean;
|
|
1645
|
+
metadata?: any;
|
|
1642
1646
|
};
|
|
1643
1647
|
declare type DataSourceInsertParam = DataSourceCRUDParam & ({
|
|
1644
1648
|
position: 'before' | 'after';
|
package/index.dev.js
CHANGED
|
@@ -10928,18 +10928,19 @@ var DataSourceCache = class {
|
|
|
10928
10928
|
}
|
|
10929
10929
|
return this.affectedFields;
|
|
10930
10930
|
};
|
|
10931
|
-
this.delete = (primaryKey, originalData) => {
|
|
10931
|
+
this.delete = (primaryKey, originalData, metadata) => {
|
|
10932
10932
|
this.allFieldsAffected = true;
|
|
10933
10933
|
const pk = `${primaryKey}`;
|
|
10934
10934
|
const value = this.primaryKeyToData.get(pk) || [];
|
|
10935
10935
|
value.push({
|
|
10936
10936
|
type: "delete",
|
|
10937
10937
|
primaryKey,
|
|
10938
|
-
originalData
|
|
10938
|
+
originalData,
|
|
10939
|
+
metadata
|
|
10939
10940
|
});
|
|
10940
10941
|
this.primaryKeyToData.set(pk, value);
|
|
10941
10942
|
};
|
|
10942
|
-
this.insert = (primaryKey, data, position2) => {
|
|
10943
|
+
this.insert = (primaryKey, data, position2, metadata) => {
|
|
10943
10944
|
const pk = `${primaryKey}`;
|
|
10944
10945
|
const value = this.primaryKeyToData.get(pk) || [];
|
|
10945
10946
|
this.allFieldsAffected = true;
|
|
@@ -10948,11 +10949,12 @@ var DataSourceCache = class {
|
|
|
10948
10949
|
primaryKey,
|
|
10949
10950
|
data,
|
|
10950
10951
|
position: position2,
|
|
10951
|
-
originalData: null
|
|
10952
|
+
originalData: null,
|
|
10953
|
+
metadata
|
|
10952
10954
|
});
|
|
10953
10955
|
this.primaryKeyToData.set(pk, value);
|
|
10954
10956
|
};
|
|
10955
|
-
this.update = (primaryKey, data, originalData) => {
|
|
10957
|
+
this.update = (primaryKey, data, originalData, metadata) => {
|
|
10956
10958
|
if (!this.allFieldsAffected) {
|
|
10957
10959
|
const keys = Object.keys(data);
|
|
10958
10960
|
keys.forEach((key) => this.affectedFields.add(key));
|
|
@@ -10963,7 +10965,8 @@ var DataSourceCache = class {
|
|
|
10963
10965
|
type: "update",
|
|
10964
10966
|
primaryKey,
|
|
10965
10967
|
data,
|
|
10966
|
-
originalData
|
|
10968
|
+
originalData,
|
|
10969
|
+
metadata
|
|
10967
10970
|
});
|
|
10968
10971
|
this.primaryKeyToData.set(`${primaryKey}`, value);
|
|
10969
10972
|
};
|
|
@@ -11038,7 +11041,12 @@ var DataSourceApiImpl = class {
|
|
|
11038
11041
|
const key = operation.primaryKeys[index];
|
|
11039
11042
|
const rowInfo = this.getRowInfoByPrimaryKey(key);
|
|
11040
11043
|
if (rowInfo && !rowInfo.isGroupRow) {
|
|
11041
|
-
cache.update(
|
|
11044
|
+
cache.update(
|
|
11045
|
+
operation.primaryKeys[index],
|
|
11046
|
+
data,
|
|
11047
|
+
rowInfo.data,
|
|
11048
|
+
operation.metadata
|
|
11049
|
+
);
|
|
11042
11050
|
}
|
|
11043
11051
|
});
|
|
11044
11052
|
break;
|
|
@@ -11046,7 +11054,7 @@ var DataSourceApiImpl = class {
|
|
|
11046
11054
|
operation.primaryKeys.forEach((key) => {
|
|
11047
11055
|
const rowInfo = this.getRowInfoByPrimaryKey(key);
|
|
11048
11056
|
if (rowInfo && !rowInfo.isGroupRow) {
|
|
11049
|
-
cache.delete(key, rowInfo.data);
|
|
11057
|
+
cache.delete(key, rowInfo.data, operation.metadata);
|
|
11050
11058
|
}
|
|
11051
11059
|
});
|
|
11052
11060
|
break;
|
|
@@ -11054,7 +11062,7 @@ var DataSourceApiImpl = class {
|
|
|
11054
11062
|
let pk = operation.primaryKey;
|
|
11055
11063
|
let position2 = operation.position;
|
|
11056
11064
|
operation.array.forEach((data) => {
|
|
11057
|
-
cache.insert(pk, data, position2);
|
|
11065
|
+
cache.insert(pk, data, position2, operation.metadata);
|
|
11058
11066
|
pk = this.toPrimaryKey(data);
|
|
11059
11067
|
position2 = "after";
|
|
11060
11068
|
});
|
|
@@ -11112,7 +11120,8 @@ var DataSourceApiImpl = class {
|
|
|
11112
11120
|
array: data,
|
|
11113
11121
|
primaryKeys: data.map((d) => {
|
|
11114
11122
|
return this.toPrimaryKey(d);
|
|
11115
|
-
})
|
|
11123
|
+
}),
|
|
11124
|
+
metadata: options == null ? void 0 : options.metadata
|
|
11116
11125
|
});
|
|
11117
11126
|
if (options == null ? void 0 : options.flush) {
|
|
11118
11127
|
this.commit();
|
|
@@ -11122,7 +11131,8 @@ var DataSourceApiImpl = class {
|
|
|
11122
11131
|
removeDataByPrimaryKey(id, options) {
|
|
11123
11132
|
const result = this.batchOperation({
|
|
11124
11133
|
type: "delete",
|
|
11125
|
-
primaryKeys: [id]
|
|
11134
|
+
primaryKeys: [id],
|
|
11135
|
+
metadata: options == null ? void 0 : options.metadata
|
|
11126
11136
|
});
|
|
11127
11137
|
if (options == null ? void 0 : options.flush) {
|
|
11128
11138
|
this.commit();
|
|
@@ -11132,7 +11142,8 @@ var DataSourceApiImpl = class {
|
|
|
11132
11142
|
removeData(data, options) {
|
|
11133
11143
|
const result = this.batchOperation({
|
|
11134
11144
|
type: "delete",
|
|
11135
|
-
primaryKeys: [this.toPrimaryKey(data)]
|
|
11145
|
+
primaryKeys: [this.toPrimaryKey(data)],
|
|
11146
|
+
metadata: options == null ? void 0 : options.metadata
|
|
11136
11147
|
});
|
|
11137
11148
|
if (options == null ? void 0 : options.flush) {
|
|
11138
11149
|
this.commit();
|
|
@@ -11142,7 +11153,8 @@ var DataSourceApiImpl = class {
|
|
|
11142
11153
|
removeDataArrayByPrimaryKeys(ids, options) {
|
|
11143
11154
|
const result = this.batchOperation({
|
|
11144
11155
|
type: "delete",
|
|
11145
|
-
primaryKeys: ids
|
|
11156
|
+
primaryKeys: ids,
|
|
11157
|
+
metadata: options == null ? void 0 : options.metadata
|
|
11146
11158
|
});
|
|
11147
11159
|
if (options == null ? void 0 : options.flush) {
|
|
11148
11160
|
this.commit();
|
|
@@ -11152,7 +11164,8 @@ var DataSourceApiImpl = class {
|
|
|
11152
11164
|
removeDataArray(data, options) {
|
|
11153
11165
|
const result = this.batchOperation({
|
|
11154
11166
|
type: "delete",
|
|
11155
|
-
primaryKeys: data.map(this.toPrimaryKey)
|
|
11167
|
+
primaryKeys: data.map(this.toPrimaryKey),
|
|
11168
|
+
metadata: options == null ? void 0 : options.metadata
|
|
11156
11169
|
});
|
|
11157
11170
|
if (options == null ? void 0 : options.flush) {
|
|
11158
11171
|
this.commit();
|
|
@@ -11190,6 +11203,7 @@ var DataSourceApiImpl = class {
|
|
|
11190
11203
|
type: "insert",
|
|
11191
11204
|
array: data,
|
|
11192
11205
|
position: position2,
|
|
11206
|
+
metadata: options == null ? void 0 : options.metadata,
|
|
11193
11207
|
primaryKey
|
|
11194
11208
|
});
|
|
11195
11209
|
if (options == null ? void 0 : options.flush) {
|
|
@@ -11576,6 +11590,17 @@ function getPivotColumnsAndColumnGroups({
|
|
|
11576
11590
|
).map((key) => {
|
|
11577
11591
|
return __spreadProps(__spreadValues({}, reducers[key]), { id: key });
|
|
11578
11592
|
});
|
|
11593
|
+
if (!aggregationReducers.length) {
|
|
11594
|
+
showSeparatePivotColumnForSingleAggregation = true;
|
|
11595
|
+
pivotGrandTotalColumnPosition = false;
|
|
11596
|
+
pivotTotalColumnPosition = false;
|
|
11597
|
+
aggregationReducers.push({
|
|
11598
|
+
id: "__empty-aggregation-reducer__",
|
|
11599
|
+
name: "-",
|
|
11600
|
+
initialValue: null,
|
|
11601
|
+
reducer: () => null
|
|
11602
|
+
});
|
|
11603
|
+
}
|
|
11579
11604
|
const columns = /* @__PURE__ */ new Map([
|
|
11580
11605
|
// [
|
|
11581
11606
|
// 'labels',
|
|
@@ -14104,6 +14129,7 @@ var InfiniteTableApiImpl = class {
|
|
|
14104
14129
|
valueToPersist = yield column.getValueToPersist(params);
|
|
14105
14130
|
}
|
|
14106
14131
|
params.value = valueToPersist;
|
|
14132
|
+
editingCell.value = valueToPersist;
|
|
14107
14133
|
const persistEdit = (_b = this.getState().persistEdit) != null ? _b : () => {
|
|
14108
14134
|
if (!params.column.field) {
|
|
14109
14135
|
return value;
|
|
@@ -16781,7 +16807,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
16781
16807
|
const valid = (0, import_react49.useMemo)(() => {
|
|
16782
16808
|
let valid2 = isValidLicense(licenseKey, {
|
|
16783
16809
|
publishedAt: 1624970570587,
|
|
16784
|
-
version: "2.0.
|
|
16810
|
+
version: "2.0.4"
|
|
16785
16811
|
});
|
|
16786
16812
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
16787
16813
|
return true;
|
package/index.dev.mjs
CHANGED
|
@@ -10914,18 +10914,19 @@ var DataSourceCache = class {
|
|
|
10914
10914
|
}
|
|
10915
10915
|
return this.affectedFields;
|
|
10916
10916
|
};
|
|
10917
|
-
this.delete = (primaryKey, originalData) => {
|
|
10917
|
+
this.delete = (primaryKey, originalData, metadata) => {
|
|
10918
10918
|
this.allFieldsAffected = true;
|
|
10919
10919
|
const pk = `${primaryKey}`;
|
|
10920
10920
|
const value = this.primaryKeyToData.get(pk) || [];
|
|
10921
10921
|
value.push({
|
|
10922
10922
|
type: "delete",
|
|
10923
10923
|
primaryKey,
|
|
10924
|
-
originalData
|
|
10924
|
+
originalData,
|
|
10925
|
+
metadata
|
|
10925
10926
|
});
|
|
10926
10927
|
this.primaryKeyToData.set(pk, value);
|
|
10927
10928
|
};
|
|
10928
|
-
this.insert = (primaryKey, data, position2) => {
|
|
10929
|
+
this.insert = (primaryKey, data, position2, metadata) => {
|
|
10929
10930
|
const pk = `${primaryKey}`;
|
|
10930
10931
|
const value = this.primaryKeyToData.get(pk) || [];
|
|
10931
10932
|
this.allFieldsAffected = true;
|
|
@@ -10934,11 +10935,12 @@ var DataSourceCache = class {
|
|
|
10934
10935
|
primaryKey,
|
|
10935
10936
|
data,
|
|
10936
10937
|
position: position2,
|
|
10937
|
-
originalData: null
|
|
10938
|
+
originalData: null,
|
|
10939
|
+
metadata
|
|
10938
10940
|
});
|
|
10939
10941
|
this.primaryKeyToData.set(pk, value);
|
|
10940
10942
|
};
|
|
10941
|
-
this.update = (primaryKey, data, originalData) => {
|
|
10943
|
+
this.update = (primaryKey, data, originalData, metadata) => {
|
|
10942
10944
|
if (!this.allFieldsAffected) {
|
|
10943
10945
|
const keys = Object.keys(data);
|
|
10944
10946
|
keys.forEach((key) => this.affectedFields.add(key));
|
|
@@ -10949,7 +10951,8 @@ var DataSourceCache = class {
|
|
|
10949
10951
|
type: "update",
|
|
10950
10952
|
primaryKey,
|
|
10951
10953
|
data,
|
|
10952
|
-
originalData
|
|
10954
|
+
originalData,
|
|
10955
|
+
metadata
|
|
10953
10956
|
});
|
|
10954
10957
|
this.primaryKeyToData.set(`${primaryKey}`, value);
|
|
10955
10958
|
};
|
|
@@ -11024,7 +11027,12 @@ var DataSourceApiImpl = class {
|
|
|
11024
11027
|
const key = operation.primaryKeys[index];
|
|
11025
11028
|
const rowInfo = this.getRowInfoByPrimaryKey(key);
|
|
11026
11029
|
if (rowInfo && !rowInfo.isGroupRow) {
|
|
11027
|
-
cache.update(
|
|
11030
|
+
cache.update(
|
|
11031
|
+
operation.primaryKeys[index],
|
|
11032
|
+
data,
|
|
11033
|
+
rowInfo.data,
|
|
11034
|
+
operation.metadata
|
|
11035
|
+
);
|
|
11028
11036
|
}
|
|
11029
11037
|
});
|
|
11030
11038
|
break;
|
|
@@ -11032,7 +11040,7 @@ var DataSourceApiImpl = class {
|
|
|
11032
11040
|
operation.primaryKeys.forEach((key) => {
|
|
11033
11041
|
const rowInfo = this.getRowInfoByPrimaryKey(key);
|
|
11034
11042
|
if (rowInfo && !rowInfo.isGroupRow) {
|
|
11035
|
-
cache.delete(key, rowInfo.data);
|
|
11043
|
+
cache.delete(key, rowInfo.data, operation.metadata);
|
|
11036
11044
|
}
|
|
11037
11045
|
});
|
|
11038
11046
|
break;
|
|
@@ -11040,7 +11048,7 @@ var DataSourceApiImpl = class {
|
|
|
11040
11048
|
let pk = operation.primaryKey;
|
|
11041
11049
|
let position2 = operation.position;
|
|
11042
11050
|
operation.array.forEach((data) => {
|
|
11043
|
-
cache.insert(pk, data, position2);
|
|
11051
|
+
cache.insert(pk, data, position2, operation.metadata);
|
|
11044
11052
|
pk = this.toPrimaryKey(data);
|
|
11045
11053
|
position2 = "after";
|
|
11046
11054
|
});
|
|
@@ -11098,7 +11106,8 @@ var DataSourceApiImpl = class {
|
|
|
11098
11106
|
array: data,
|
|
11099
11107
|
primaryKeys: data.map((d) => {
|
|
11100
11108
|
return this.toPrimaryKey(d);
|
|
11101
|
-
})
|
|
11109
|
+
}),
|
|
11110
|
+
metadata: options == null ? void 0 : options.metadata
|
|
11102
11111
|
});
|
|
11103
11112
|
if (options == null ? void 0 : options.flush) {
|
|
11104
11113
|
this.commit();
|
|
@@ -11108,7 +11117,8 @@ var DataSourceApiImpl = class {
|
|
|
11108
11117
|
removeDataByPrimaryKey(id, options) {
|
|
11109
11118
|
const result = this.batchOperation({
|
|
11110
11119
|
type: "delete",
|
|
11111
|
-
primaryKeys: [id]
|
|
11120
|
+
primaryKeys: [id],
|
|
11121
|
+
metadata: options == null ? void 0 : options.metadata
|
|
11112
11122
|
});
|
|
11113
11123
|
if (options == null ? void 0 : options.flush) {
|
|
11114
11124
|
this.commit();
|
|
@@ -11118,7 +11128,8 @@ var DataSourceApiImpl = class {
|
|
|
11118
11128
|
removeData(data, options) {
|
|
11119
11129
|
const result = this.batchOperation({
|
|
11120
11130
|
type: "delete",
|
|
11121
|
-
primaryKeys: [this.toPrimaryKey(data)]
|
|
11131
|
+
primaryKeys: [this.toPrimaryKey(data)],
|
|
11132
|
+
metadata: options == null ? void 0 : options.metadata
|
|
11122
11133
|
});
|
|
11123
11134
|
if (options == null ? void 0 : options.flush) {
|
|
11124
11135
|
this.commit();
|
|
@@ -11128,7 +11139,8 @@ var DataSourceApiImpl = class {
|
|
|
11128
11139
|
removeDataArrayByPrimaryKeys(ids, options) {
|
|
11129
11140
|
const result = this.batchOperation({
|
|
11130
11141
|
type: "delete",
|
|
11131
|
-
primaryKeys: ids
|
|
11142
|
+
primaryKeys: ids,
|
|
11143
|
+
metadata: options == null ? void 0 : options.metadata
|
|
11132
11144
|
});
|
|
11133
11145
|
if (options == null ? void 0 : options.flush) {
|
|
11134
11146
|
this.commit();
|
|
@@ -11138,7 +11150,8 @@ var DataSourceApiImpl = class {
|
|
|
11138
11150
|
removeDataArray(data, options) {
|
|
11139
11151
|
const result = this.batchOperation({
|
|
11140
11152
|
type: "delete",
|
|
11141
|
-
primaryKeys: data.map(this.toPrimaryKey)
|
|
11153
|
+
primaryKeys: data.map(this.toPrimaryKey),
|
|
11154
|
+
metadata: options == null ? void 0 : options.metadata
|
|
11142
11155
|
});
|
|
11143
11156
|
if (options == null ? void 0 : options.flush) {
|
|
11144
11157
|
this.commit();
|
|
@@ -11176,6 +11189,7 @@ var DataSourceApiImpl = class {
|
|
|
11176
11189
|
type: "insert",
|
|
11177
11190
|
array: data,
|
|
11178
11191
|
position: position2,
|
|
11192
|
+
metadata: options == null ? void 0 : options.metadata,
|
|
11179
11193
|
primaryKey
|
|
11180
11194
|
});
|
|
11181
11195
|
if (options == null ? void 0 : options.flush) {
|
|
@@ -11562,6 +11576,17 @@ function getPivotColumnsAndColumnGroups({
|
|
|
11562
11576
|
).map((key) => {
|
|
11563
11577
|
return __spreadProps(__spreadValues({}, reducers[key]), { id: key });
|
|
11564
11578
|
});
|
|
11579
|
+
if (!aggregationReducers.length) {
|
|
11580
|
+
showSeparatePivotColumnForSingleAggregation = true;
|
|
11581
|
+
pivotGrandTotalColumnPosition = false;
|
|
11582
|
+
pivotTotalColumnPosition = false;
|
|
11583
|
+
aggregationReducers.push({
|
|
11584
|
+
id: "__empty-aggregation-reducer__",
|
|
11585
|
+
name: "-",
|
|
11586
|
+
initialValue: null,
|
|
11587
|
+
reducer: () => null
|
|
11588
|
+
});
|
|
11589
|
+
}
|
|
11565
11590
|
const columns = /* @__PURE__ */ new Map([
|
|
11566
11591
|
// [
|
|
11567
11592
|
// 'labels',
|
|
@@ -14090,6 +14115,7 @@ var InfiniteTableApiImpl = class {
|
|
|
14090
14115
|
valueToPersist = yield column.getValueToPersist(params);
|
|
14091
14116
|
}
|
|
14092
14117
|
params.value = valueToPersist;
|
|
14118
|
+
editingCell.value = valueToPersist;
|
|
14093
14119
|
const persistEdit = (_b = this.getState().persistEdit) != null ? _b : () => {
|
|
14094
14120
|
if (!params.column.field) {
|
|
14095
14121
|
return value;
|
|
@@ -16771,7 +16797,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
16771
16797
|
const valid = useMemo11(() => {
|
|
16772
16798
|
let valid2 = isValidLicense(licenseKey, {
|
|
16773
16799
|
publishedAt: 1624970570587,
|
|
16774
|
-
version: "2.0.
|
|
16800
|
+
version: "2.0.4"
|
|
16775
16801
|
});
|
|
16776
16802
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
16777
16803
|
return true;
|