wenay-react2 1.0.14 → 1.0.16
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CellClassParams } from "ag-grid-community";
|
|
2
2
|
import type { Theme, ThemeDefaultParams } from "ag-grid-community";
|
|
3
3
|
import { provideGlobalGridOptions } from "ag-grid-community";
|
|
4
|
+
export { AllCommunityModule, ModuleRegistry } from "ag-grid-community";
|
|
4
5
|
export declare function GridStyleDefault(): {
|
|
5
6
|
theme: Theme<ThemeDefaultParams>;
|
|
6
7
|
provideGlobalGridOptions: typeof provideGlobalGridOptions;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { colorSchemeDarkBlue, iconSetMaterial, provideGlobalGridOptions, themeAlpine } from "ag-grid-community";
|
|
2
2
|
import { AllCommunityModule, ModuleRegistry } from "ag-grid-community";
|
|
3
|
-
|
|
3
|
+
export { AllCommunityModule, ModuleRegistry } from "ag-grid-community";
|
|
4
4
|
// import 'ag-grid-community/styles/ag-grid.css';
|
|
5
5
|
// import 'ag-grid-community/styles/ag-theme-alpine.css';
|
|
6
6
|
// Register all community features
|
|
@@ -4,6 +4,7 @@ declare const optionsDef: {
|
|
|
4
4
|
add: boolean;
|
|
5
5
|
updateBuffer: boolean;
|
|
6
6
|
sync: boolean;
|
|
7
|
+
remove: boolean;
|
|
7
8
|
};
|
|
8
9
|
type options = Partial<typeof optionsDef>;
|
|
9
10
|
export declare function applyTransactionAsyncUpdate<T>(grid: GridReadyEvent<T, any> | null | undefined, newData: (Partial<T>)[], getId: (...a: any[]) => string, bufTable: {
|
|
@@ -2,7 +2,8 @@ const optionsDef = {
|
|
|
2
2
|
update: true,
|
|
3
3
|
add: true,
|
|
4
4
|
updateBuffer: true,
|
|
5
|
-
sync: false
|
|
5
|
+
sync: false,
|
|
6
|
+
remove: false,
|
|
6
7
|
};
|
|
7
8
|
export function applyTransactionAsyncUpdate(grid, newData, getId, bufTable, option) {
|
|
8
9
|
// Установка параметров (объединение переданных опций с настройками по умолчанию)
|
|
@@ -10,6 +11,7 @@ export function applyTransactionAsyncUpdate(grid, newData, getId, bufTable, opti
|
|
|
10
11
|
// Проверка наличия сетки и доступа к данным через API
|
|
11
12
|
if (grid?.api.getRowNode) {
|
|
12
13
|
const arrNew = []; // Массив для новых данных (добавляемые строки)
|
|
14
|
+
const arrRemove = []; // Массив для удаляемых строк
|
|
13
15
|
// Основная обработка данных (map используется для обновления или создания записей)
|
|
14
16
|
const arr = newData.map(e => {
|
|
15
17
|
// Получение ID для текущей строки
|
|
@@ -29,7 +31,11 @@ export function applyTransactionAsyncUpdate(grid, newData, getId, bufTable, opti
|
|
|
29
31
|
}) // Убираем `null` и оставляем только существующие строки
|
|
30
32
|
.filter(e => e);
|
|
31
33
|
if (op.sync) {
|
|
32
|
-
grid.api.applyTransaction({
|
|
34
|
+
grid.api.applyTransaction({
|
|
35
|
+
add: op.add ? arrNew : [],
|
|
36
|
+
update: op.update ? arr : [],
|
|
37
|
+
remove: op.remove ? arrRemove : []
|
|
38
|
+
});
|
|
33
39
|
return;
|
|
34
40
|
}
|
|
35
41
|
// Добавление новых строк (если есть элементы)
|
|
@@ -41,6 +47,10 @@ export function applyTransactionAsyncUpdate(grid, newData, getId, bufTable, opti
|
|
|
41
47
|
if (arr.length && op.update) {
|
|
42
48
|
grid.api.applyTransactionAsync({ update: arr });
|
|
43
49
|
}
|
|
50
|
+
// Асинхронное удаление строк
|
|
51
|
+
if (arrRemove.length && op.remove) {
|
|
52
|
+
grid.api.applyTransactionAsync({ remove: arrRemove });
|
|
53
|
+
}
|
|
44
54
|
}
|
|
45
55
|
}
|
|
46
56
|
const map = new WeakMap();
|