@infinite-table/infinite-react 2.0.2 → 2.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.d.ts +10 -3
- package/index.dev.js +27 -11
- package/index.dev.mjs +27 -11
- package/index.js +3 -3
- package/index.mjs +3 -3
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -1375,14 +1375,17 @@ declare type RenderRange = {
|
|
|
1375
1375
|
declare type DataSourceMutation<T> = {
|
|
1376
1376
|
type: 'delete';
|
|
1377
1377
|
primaryKey: any;
|
|
1378
|
+
originalData: T;
|
|
1378
1379
|
} | {
|
|
1379
1380
|
type: 'update';
|
|
1380
1381
|
primaryKey: any;
|
|
1381
1382
|
data: Partial<T>;
|
|
1383
|
+
originalData: T;
|
|
1382
1384
|
} | {
|
|
1383
1385
|
type: 'insert';
|
|
1384
1386
|
primaryKey: any;
|
|
1385
1387
|
position: 'before' | 'after';
|
|
1388
|
+
originalData: null;
|
|
1386
1389
|
data: T;
|
|
1387
1390
|
};
|
|
1388
1391
|
declare class DataSourceCache<DataType, PrimaryKeyType = string> {
|
|
@@ -1393,9 +1396,9 @@ declare class DataSourceCache<DataType, PrimaryKeyType = string> {
|
|
|
1393
1396
|
light?: boolean;
|
|
1394
1397
|
}): DataSourceCache<DataType, PrimaryKeyType>;
|
|
1395
1398
|
getAffectedFields: () => true | Set<keyof DataType>;
|
|
1396
|
-
delete: (primaryKey: PrimaryKeyType) => void;
|
|
1399
|
+
delete: (primaryKey: PrimaryKeyType, originalData: DataType) => void;
|
|
1397
1400
|
insert: (primaryKey: PrimaryKeyType, data: DataType, position: 'before' | 'after') => void;
|
|
1398
|
-
update: (primaryKey: PrimaryKeyType, data: Partial<DataType
|
|
1401
|
+
update: (primaryKey: PrimaryKeyType, data: Partial<DataType>, originalData: DataType) => void;
|
|
1399
1402
|
clear: () => void;
|
|
1400
1403
|
isEmpty: () => boolean;
|
|
1401
1404
|
removeInfo: (primaryKey: PrimaryKeyType) => void;
|
|
@@ -1667,6 +1670,9 @@ declare type DataSourceRowInfoReducer<T> = DataSourceRawReducer<InfiniteTableRow
|
|
|
1667
1670
|
declare type DataSourceProps<T> = {
|
|
1668
1671
|
children: React$1.ReactNode | ((contextData: DataSourceState<T>) => React$1.ReactNode);
|
|
1669
1672
|
primaryKey: keyof T | ((data: T) => string);
|
|
1673
|
+
/**
|
|
1674
|
+
* @deprecated for now
|
|
1675
|
+
*/
|
|
1670
1676
|
fields?: (keyof T)[];
|
|
1671
1677
|
refetchKey?: number | string | object;
|
|
1672
1678
|
rowInfoReducers?: DataSourcePropRowInfoReducers<T>;
|
|
@@ -1704,7 +1710,8 @@ declare type DataSourceProps<T> = {
|
|
|
1704
1710
|
onSortInfoChange?: ((sortInfo: DataSourceSingleSortInfo<T> | null) => void) | ((sortInfo: DataSourceSingleSortInfo<T>[]) => void);
|
|
1705
1711
|
onDataParamsChange?: (dataParamsChange: DataSourceDataParams<T>) => void;
|
|
1706
1712
|
onDataArrayChange?: (dataArray: DataSourceState<T>['originalDataArray'], info: DataSourceState<T>['originalDataArrayChangedInfo']) => void;
|
|
1707
|
-
onDataMutations?: ({ dataArray, timestamp, mutations, }: {
|
|
1713
|
+
onDataMutations?: ({ dataArray, timestamp, mutations, primaryKeyField, }: {
|
|
1714
|
+
primaryKeyField: undefined | keyof T;
|
|
1708
1715
|
dataArray: DataSourceState<T>['originalDataArray'];
|
|
1709
1716
|
timestamp: number;
|
|
1710
1717
|
mutations: NonUndefined<DataSourceState<T>['originalDataArrayChangedInfo']['mutations']>;
|
package/index.dev.js
CHANGED
|
@@ -10928,13 +10928,14 @@ var DataSourceCache = class {
|
|
|
10928
10928
|
}
|
|
10929
10929
|
return this.affectedFields;
|
|
10930
10930
|
};
|
|
10931
|
-
this.delete = (primaryKey) => {
|
|
10931
|
+
this.delete = (primaryKey, originalData) => {
|
|
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
|
-
primaryKey
|
|
10937
|
+
primaryKey,
|
|
10938
|
+
originalData
|
|
10938
10939
|
});
|
|
10939
10940
|
this.primaryKeyToData.set(pk, value);
|
|
10940
10941
|
};
|
|
@@ -10946,11 +10947,12 @@ var DataSourceCache = class {
|
|
|
10946
10947
|
type: "insert",
|
|
10947
10948
|
primaryKey,
|
|
10948
10949
|
data,
|
|
10949
|
-
position: position2
|
|
10950
|
+
position: position2,
|
|
10951
|
+
originalData: null
|
|
10950
10952
|
});
|
|
10951
10953
|
this.primaryKeyToData.set(pk, value);
|
|
10952
10954
|
};
|
|
10953
|
-
this.update = (primaryKey, data) => {
|
|
10955
|
+
this.update = (primaryKey, data, originalData) => {
|
|
10954
10956
|
if (!this.allFieldsAffected) {
|
|
10955
10957
|
const keys = Object.keys(data);
|
|
10956
10958
|
keys.forEach((key) => this.affectedFields.add(key));
|
|
@@ -10960,7 +10962,8 @@ var DataSourceCache = class {
|
|
|
10960
10962
|
value.push({
|
|
10961
10963
|
type: "update",
|
|
10962
10964
|
primaryKey,
|
|
10963
|
-
data
|
|
10965
|
+
data,
|
|
10966
|
+
originalData
|
|
10964
10967
|
});
|
|
10965
10968
|
this.primaryKeyToData.set(`${primaryKey}`, value);
|
|
10966
10969
|
};
|
|
@@ -11031,13 +11034,20 @@ var DataSourceApiImpl = class {
|
|
|
11031
11034
|
operations.forEach((operation) => {
|
|
11032
11035
|
switch (operation.type) {
|
|
11033
11036
|
case "update":
|
|
11034
|
-
operation.array.forEach((
|
|
11035
|
-
|
|
11037
|
+
operation.array.forEach((data, index) => {
|
|
11038
|
+
const key = operation.primaryKeys[index];
|
|
11039
|
+
const rowInfo = this.getRowInfoByPrimaryKey(key);
|
|
11040
|
+
if (rowInfo && !rowInfo.isGroupRow) {
|
|
11041
|
+
cache.update(operation.primaryKeys[index], data, rowInfo.data);
|
|
11042
|
+
}
|
|
11036
11043
|
});
|
|
11037
11044
|
break;
|
|
11038
11045
|
case "delete":
|
|
11039
11046
|
operation.primaryKeys.forEach((key) => {
|
|
11040
|
-
|
|
11047
|
+
const rowInfo = this.getRowInfoByPrimaryKey(key);
|
|
11048
|
+
if (rowInfo && !rowInfo.isGroupRow) {
|
|
11049
|
+
cache.delete(key, rowInfo.data);
|
|
11050
|
+
}
|
|
11041
11051
|
});
|
|
11042
11052
|
break;
|
|
11043
11053
|
case "insert":
|
|
@@ -13976,6 +13986,7 @@ function DataSourceCmp({ children }) {
|
|
|
13976
13986
|
);
|
|
13977
13987
|
if (componentState.onDataMutations && componentState.originalDataArrayChangedInfo.mutations) {
|
|
13978
13988
|
componentState.onDataMutations({
|
|
13989
|
+
primaryKeyField: typeof componentState.primaryKey === "string" ? componentState.primaryKey : void 0,
|
|
13979
13990
|
dataArray: componentState.originalDataArray,
|
|
13980
13991
|
mutations: componentState.originalDataArrayChangedInfo.mutations,
|
|
13981
13992
|
timestamp: componentState.originalDataArrayChangedInfo.timestamp
|
|
@@ -14097,9 +14108,14 @@ var InfiniteTableApiImpl = class {
|
|
|
14097
14108
|
if (!params.column.field) {
|
|
14098
14109
|
return value;
|
|
14099
14110
|
}
|
|
14100
|
-
|
|
14111
|
+
const primaryKey = this.getDataSourceState().primaryKey;
|
|
14112
|
+
const newData = params.data && typeof primaryKey === "string" ? {
|
|
14113
|
+
[primaryKey]: params.data[primaryKey],
|
|
14101
14114
|
[params.column.field]: valueToPersist
|
|
14102
|
-
})
|
|
14115
|
+
} : __spreadProps(__spreadValues({}, params.data), {
|
|
14116
|
+
[params.column.field]: valueToPersist
|
|
14117
|
+
});
|
|
14118
|
+
return this.context.dataSourceApi.updateData(newData);
|
|
14103
14119
|
};
|
|
14104
14120
|
let response;
|
|
14105
14121
|
try {
|
|
@@ -16765,7 +16781,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
16765
16781
|
const valid = (0, import_react49.useMemo)(() => {
|
|
16766
16782
|
let valid2 = isValidLicense(licenseKey, {
|
|
16767
16783
|
publishedAt: 1624970570587,
|
|
16768
|
-
version: "2.0.
|
|
16784
|
+
version: "2.0.3"
|
|
16769
16785
|
});
|
|
16770
16786
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
16771
16787
|
return true;
|
package/index.dev.mjs
CHANGED
|
@@ -10914,13 +10914,14 @@ var DataSourceCache = class {
|
|
|
10914
10914
|
}
|
|
10915
10915
|
return this.affectedFields;
|
|
10916
10916
|
};
|
|
10917
|
-
this.delete = (primaryKey) => {
|
|
10917
|
+
this.delete = (primaryKey, originalData) => {
|
|
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
|
-
primaryKey
|
|
10923
|
+
primaryKey,
|
|
10924
|
+
originalData
|
|
10924
10925
|
});
|
|
10925
10926
|
this.primaryKeyToData.set(pk, value);
|
|
10926
10927
|
};
|
|
@@ -10932,11 +10933,12 @@ var DataSourceCache = class {
|
|
|
10932
10933
|
type: "insert",
|
|
10933
10934
|
primaryKey,
|
|
10934
10935
|
data,
|
|
10935
|
-
position: position2
|
|
10936
|
+
position: position2,
|
|
10937
|
+
originalData: null
|
|
10936
10938
|
});
|
|
10937
10939
|
this.primaryKeyToData.set(pk, value);
|
|
10938
10940
|
};
|
|
10939
|
-
this.update = (primaryKey, data) => {
|
|
10941
|
+
this.update = (primaryKey, data, originalData) => {
|
|
10940
10942
|
if (!this.allFieldsAffected) {
|
|
10941
10943
|
const keys = Object.keys(data);
|
|
10942
10944
|
keys.forEach((key) => this.affectedFields.add(key));
|
|
@@ -10946,7 +10948,8 @@ var DataSourceCache = class {
|
|
|
10946
10948
|
value.push({
|
|
10947
10949
|
type: "update",
|
|
10948
10950
|
primaryKey,
|
|
10949
|
-
data
|
|
10951
|
+
data,
|
|
10952
|
+
originalData
|
|
10950
10953
|
});
|
|
10951
10954
|
this.primaryKeyToData.set(`${primaryKey}`, value);
|
|
10952
10955
|
};
|
|
@@ -11017,13 +11020,20 @@ var DataSourceApiImpl = class {
|
|
|
11017
11020
|
operations.forEach((operation) => {
|
|
11018
11021
|
switch (operation.type) {
|
|
11019
11022
|
case "update":
|
|
11020
|
-
operation.array.forEach((
|
|
11021
|
-
|
|
11023
|
+
operation.array.forEach((data, index) => {
|
|
11024
|
+
const key = operation.primaryKeys[index];
|
|
11025
|
+
const rowInfo = this.getRowInfoByPrimaryKey(key);
|
|
11026
|
+
if (rowInfo && !rowInfo.isGroupRow) {
|
|
11027
|
+
cache.update(operation.primaryKeys[index], data, rowInfo.data);
|
|
11028
|
+
}
|
|
11022
11029
|
});
|
|
11023
11030
|
break;
|
|
11024
11031
|
case "delete":
|
|
11025
11032
|
operation.primaryKeys.forEach((key) => {
|
|
11026
|
-
|
|
11033
|
+
const rowInfo = this.getRowInfoByPrimaryKey(key);
|
|
11034
|
+
if (rowInfo && !rowInfo.isGroupRow) {
|
|
11035
|
+
cache.delete(key, rowInfo.data);
|
|
11036
|
+
}
|
|
11027
11037
|
});
|
|
11028
11038
|
break;
|
|
11029
11039
|
case "insert":
|
|
@@ -13962,6 +13972,7 @@ function DataSourceCmp({ children }) {
|
|
|
13962
13972
|
);
|
|
13963
13973
|
if (componentState.onDataMutations && componentState.originalDataArrayChangedInfo.mutations) {
|
|
13964
13974
|
componentState.onDataMutations({
|
|
13975
|
+
primaryKeyField: typeof componentState.primaryKey === "string" ? componentState.primaryKey : void 0,
|
|
13965
13976
|
dataArray: componentState.originalDataArray,
|
|
13966
13977
|
mutations: componentState.originalDataArrayChangedInfo.mutations,
|
|
13967
13978
|
timestamp: componentState.originalDataArrayChangedInfo.timestamp
|
|
@@ -14083,9 +14094,14 @@ var InfiniteTableApiImpl = class {
|
|
|
14083
14094
|
if (!params.column.field) {
|
|
14084
14095
|
return value;
|
|
14085
14096
|
}
|
|
14086
|
-
|
|
14097
|
+
const primaryKey = this.getDataSourceState().primaryKey;
|
|
14098
|
+
const newData = params.data && typeof primaryKey === "string" ? {
|
|
14099
|
+
[primaryKey]: params.data[primaryKey],
|
|
14087
14100
|
[params.column.field]: valueToPersist
|
|
14088
|
-
})
|
|
14101
|
+
} : __spreadProps(__spreadValues({}, params.data), {
|
|
14102
|
+
[params.column.field]: valueToPersist
|
|
14103
|
+
});
|
|
14104
|
+
return this.context.dataSourceApi.updateData(newData);
|
|
14089
14105
|
};
|
|
14090
14106
|
let response;
|
|
14091
14107
|
try {
|
|
@@ -16755,7 +16771,7 @@ var useLicense = (licenseKey = "") => {
|
|
|
16755
16771
|
const valid = useMemo11(() => {
|
|
16756
16772
|
let valid2 = isValidLicense(licenseKey, {
|
|
16757
16773
|
publishedAt: 1624970570587,
|
|
16758
|
-
version: "2.0.
|
|
16774
|
+
version: "2.0.3"
|
|
16759
16775
|
});
|
|
16760
16776
|
if (!licenseKey && !valid2 && isInsidePlayground) {
|
|
16761
16777
|
return true;
|