@lemon-fe/kits 1.0.0-52 → 1.0.0-53
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/es/components/DataGrid/hooks.d.ts +13 -1
- package/es/components/DataGrid/hooks.js +13 -3
- package/es/components/DataGrid/index.d.ts +2 -3
- package/es/components/DataGrid/index.js +12 -17
- package/es/components/DataGrid/renderer/CellIndexRenderer.js +1 -1
- package/es/components/DataGrid/typings.d.ts +1 -1
- package/package.json +1 -1
- package/es/components/DataGrid/modules/client-side-row-model/clientSideRowModel/clientSideNodeManager.d.ts +0 -35
- package/es/components/DataGrid/modules/client-side-row-model/clientSideRowModel/clientSideNodeManager.js +0 -378
- package/es/components/DataGrid/modules/client-side-row-model/clientSideRowModel/clientSideRowModel.d.ts +0 -99
- package/es/components/DataGrid/modules/client-side-row-model/clientSideRowModel/clientSideRowModel.js +0 -1160
- package/es/components/DataGrid/modules/client-side-row-model/clientSideRowModel/filterService.d.ts +0 -7
- package/es/components/DataGrid/modules/client-side-row-model/clientSideRowModel/filterService.js +0 -137
- package/es/components/DataGrid/modules/client-side-row-model/clientSideRowModel/filterStage.d.ts +0 -5
- package/es/components/DataGrid/modules/client-side-row-model/clientSideRowModel/filterStage.js +0 -60
- package/es/components/DataGrid/modules/client-side-row-model/clientSideRowModel/flattenStage.d.ts +0 -10
- package/es/components/DataGrid/modules/client-side-row-model/clientSideRowModel/flattenStage.js +0 -199
- package/es/components/DataGrid/modules/client-side-row-model/clientSideRowModel/immutableService.d.ts +0 -13
- package/es/components/DataGrid/modules/client-side-row-model/clientSideRowModel/immutableService.js +0 -175
- package/es/components/DataGrid/modules/client-side-row-model/clientSideRowModel/sortService.d.ts +0 -14
- package/es/components/DataGrid/modules/client-side-row-model/clientSideRowModel/sortService.js +0 -330
- package/es/components/DataGrid/modules/client-side-row-model/clientSideRowModel/sortStage.d.ts +0 -7
- package/es/components/DataGrid/modules/client-side-row-model/clientSideRowModel/sortStage.js +0 -75
- package/es/components/DataGrid/modules/client-side-row-model/clientSideRowModelModule.d.ts +0 -2
- package/es/components/DataGrid/modules/client-side-row-model/clientSideRowModelModule.js +0 -15
- package/es/components/DataGrid/modules/client-side-row-model/index.d.ts +0 -1
- package/es/components/DataGrid/modules/client-side-row-model/index.js +0 -1
- package/es/components/DataGrid/modules/server-side-row-model/index.d.ts +0 -1
- package/es/components/DataGrid/modules/server-side-row-model/index.js +0 -1
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/blocks/blockUtils.d.ts +0 -47
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/blocks/blockUtils.js +0 -444
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/blocks/infiniteStoreBlock.d.ts +0 -92
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/blocks/infiniteStoreBlock.js +0 -510
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/listeners/expandListener.d.ts +0 -9
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/listeners/expandListener.js +0 -115
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/listeners/filterListener.d.ts +0 -9
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/listeners/filterListener.js +0 -114
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/listeners/listenerUtils.d.ts +0 -5
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/listeners/listenerUtils.js +0 -68
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/listeners/sortListener.d.ts +0 -13
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/listeners/sortListener.js +0 -194
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/nodeManager.d.ts +0 -7
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/nodeManager.js +0 -63
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/serverSideRowModel.d.ts +0 -88
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/serverSideRowModel.js +0 -572
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/stores/fullStore.d.ts +0 -108
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/stores/fullStore.js +0 -876
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/stores/infiniteStore.d.ts +0 -102
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/stores/infiniteStore.js +0 -918
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/stores/storeFactory.d.ts +0 -12
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/stores/storeFactory.js +0 -141
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/stores/storeUtils.d.ts +0 -35
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/stores/storeUtils.js +0 -154
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/transactionManager.d.ts +0 -23
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModel/transactionManager.js +0 -210
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModelModule.d.ts +0 -18
- package/es/components/DataGrid/modules/server-side-row-model/serverSideRowModelModule.js +0 -18
|
@@ -2,7 +2,19 @@
|
|
|
2
2
|
import type { GridStore } from './typings';
|
|
3
3
|
import type DataGrid from './';
|
|
4
4
|
export declare function useGridStore<T>(getter: (state: GridStore) => T): T;
|
|
5
|
+
interface UseGrid<TData> {
|
|
6
|
+
/**
|
|
7
|
+
* @param 执行函数
|
|
8
|
+
*/
|
|
9
|
+
<T>(cb: (curr: DataGrid<TData>) => T): T;
|
|
10
|
+
/**
|
|
11
|
+
* @param 执行函数
|
|
12
|
+
* @param isAsync 是否启用异步形式
|
|
13
|
+
*/
|
|
14
|
+
(cb: (curr: DataGrid<TData>) => void, isAsync?: boolean): void;
|
|
15
|
+
}
|
|
5
16
|
export declare function useDataGrid<TData>(): {
|
|
6
17
|
ref: import("react").RefObject<DataGrid<TData>>;
|
|
7
|
-
use:
|
|
18
|
+
use: UseGrid<TData>;
|
|
8
19
|
};
|
|
20
|
+
export {};
|
|
@@ -10,7 +10,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
10
10
|
|
|
11
11
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
14
14
|
import shallowEqual from 'shallowequal';
|
|
15
15
|
import GridStoreContext from "./context/GridStore";
|
|
16
16
|
export function useGridStore(getter) {
|
|
@@ -52,7 +52,16 @@ export function useDataGrid() {
|
|
|
52
52
|
mounted.current = false;
|
|
53
53
|
};
|
|
54
54
|
}, []);
|
|
55
|
-
|
|
55
|
+
|
|
56
|
+
var use = function use(cb, isAsync) {
|
|
57
|
+
if (!isAsync) {
|
|
58
|
+
if (ref.current === null || !ref.current.ready()) {
|
|
59
|
+
throw new Error('Grid尚未初始化,请使用异步形式');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return cb(ref.current);
|
|
63
|
+
}
|
|
64
|
+
|
|
56
65
|
if (ref.current !== null) {
|
|
57
66
|
var grid = ref.current;
|
|
58
67
|
|
|
@@ -68,7 +77,8 @@ export function useDataGrid() {
|
|
|
68
77
|
|
|
69
78
|
delay();
|
|
70
79
|
}
|
|
71
|
-
}
|
|
80
|
+
};
|
|
81
|
+
|
|
72
82
|
return useMemo(function () {
|
|
73
83
|
return {
|
|
74
84
|
ref: ref,
|
|
@@ -46,13 +46,13 @@ export default class DataGrid<TData> extends Component<DataGridProps<TData>, Dat
|
|
|
46
46
|
Text: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any> & import("./typings").TextEditorParams & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
|
|
47
47
|
Date: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any> & import("./typings").DateEditorParams & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
|
|
48
48
|
Number: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any> & import("./typings").NumberEditorParams & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
|
|
49
|
-
Select: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any> & Pick<import("antd").SelectProps<any, import("antd/lib/select").BaseOptionType>, "disabled" | "
|
|
49
|
+
Select: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any> & Pick<import("antd").SelectProps<any, import("antd/lib/select").BaseOptionType>, "disabled" | "mode" | "allowClear" | "options" | "virtual" | "showSearch" | "listHeight"> & {
|
|
50
50
|
fieldNames?: {
|
|
51
51
|
label: string;
|
|
52
52
|
value: string;
|
|
53
53
|
} | undefined;
|
|
54
54
|
valueByOption?: boolean | undefined;
|
|
55
|
-
action?: "stop" | "
|
|
55
|
+
action?: "stop" | "none" | "next" | undefined;
|
|
56
56
|
} & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
|
|
57
57
|
Wrapper: typeof EditorWrapper;
|
|
58
58
|
};
|
|
@@ -68,7 +68,6 @@ export default class DataGrid<TData> extends Component<DataGridProps<TData>, Dat
|
|
|
68
68
|
private afterReady;
|
|
69
69
|
private updateRowData;
|
|
70
70
|
private getDataFromServer;
|
|
71
|
-
private sort;
|
|
72
71
|
private pagination;
|
|
73
72
|
private init;
|
|
74
73
|
private LoadingOverlay;
|
|
@@ -68,6 +68,7 @@ import { AgGridReact } from '@ag-grid-community/react';
|
|
|
68
68
|
import shallowEqual from 'shallowequal';
|
|
69
69
|
import { ModuleRegistry, GridApi, ColumnApi } from '@ag-grid-community/core';
|
|
70
70
|
import { InfiniteRowModelModule } from '@ag-grid-community/infinite-row-model';
|
|
71
|
+
import { ClientSideRowModelModule } from '@ag-grid-community/client-side-row-model';
|
|
71
72
|
import { get, set } from 'lodash';
|
|
72
73
|
import Scheme from 'async-validator';
|
|
73
74
|
import GridStoreContext from "./context/GridStore";
|
|
@@ -76,8 +77,6 @@ import { ClipboardModule } from "./modules/clipboard";
|
|
|
76
77
|
import { MenuModule } from "./modules/menu";
|
|
77
78
|
import { ColumnsToolPanelModule } from "./modules/column-tool-panel";
|
|
78
79
|
import { SideBarModule } from "./modules/side-bar";
|
|
79
|
-
import { ServerSideRowModelModule } from "./modules/server-side-row-model";
|
|
80
|
-
import { ClientSideRowModelModule } from "./modules/client-side-row-model";
|
|
81
80
|
import { Spin, Pagination, Empty } from 'antd';
|
|
82
81
|
import { prefix, getColField, isColumn, withSyncRender, Store, Selection, columnTypes } from "./utils";
|
|
83
82
|
import HeaderRenderer from "./renderer/HeaderRenderer";
|
|
@@ -89,7 +88,7 @@ import NumberEditor from "./cell-editors/Number";
|
|
|
89
88
|
import SelectEditor from "./cell-editors/Select";
|
|
90
89
|
import RowEditor, { RowEditorData } from "./cell-editors/Row";
|
|
91
90
|
import EditorWrapper from "./cell-editors/Wrapper";
|
|
92
|
-
ModuleRegistry.registerModules([ClientSideRowModelModule, RowGroupingModule, InfiniteRowModelModule, ClipboardModule, MenuModule, SideBarModule, ColumnsToolPanelModule
|
|
91
|
+
ModuleRegistry.registerModules([ClientSideRowModelModule, RowGroupingModule, InfiniteRowModelModule, ClipboardModule, MenuModule, SideBarModule, ColumnsToolPanelModule], false);
|
|
93
92
|
var defaultColDef = {
|
|
94
93
|
resizable: true,
|
|
95
94
|
width: 140,
|
|
@@ -175,8 +174,10 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
175
174
|
_this.getDataFromServer();
|
|
176
175
|
}
|
|
177
176
|
|
|
178
|
-
api.addEventListener('sortChanged', function (
|
|
179
|
-
_this.
|
|
177
|
+
api.addEventListener('sortChanged', function () {
|
|
178
|
+
if (!_this.isClientMode()) {
|
|
179
|
+
_this.getDataFromServer();
|
|
180
|
+
}
|
|
180
181
|
}); // 用于同步selection
|
|
181
182
|
|
|
182
183
|
api.addEventListener('rowSelected', function (_ref) {
|
|
@@ -765,7 +766,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
765
766
|
}).map(function (item) {
|
|
766
767
|
return {
|
|
767
768
|
field: item.colId,
|
|
768
|
-
order: item.sort
|
|
769
|
+
order: item.sort
|
|
769
770
|
};
|
|
770
771
|
})
|
|
771
772
|
}).then(function (res) {
|
|
@@ -818,16 +819,6 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
818
819
|
});
|
|
819
820
|
}
|
|
820
821
|
}
|
|
821
|
-
}, {
|
|
822
|
-
key: "sort",
|
|
823
|
-
value: function sort(evt) {
|
|
824
|
-
if (this.isClientMode()) {
|
|
825
|
-
var model = this.api.getModel();
|
|
826
|
-
model.onSortChanged(evt);
|
|
827
|
-
} else {
|
|
828
|
-
this.getDataFromServer();
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
822
|
}, {
|
|
832
823
|
key: "pagination",
|
|
833
824
|
value: function pagination(page, pageSize) {
|
|
@@ -1092,7 +1083,11 @@ var DataGrid = /*#__PURE__*/function (_Component) {
|
|
|
1092
1083
|
context: context,
|
|
1093
1084
|
rowSelection: rowSelection !== undefined ? rowSelection.type !== 'radio' ? 'multiple' : 'single' : undefined,
|
|
1094
1085
|
components: _objectSpread(_objectSpread({}, defaultComponents), componentsProp),
|
|
1095
|
-
defaultColDef: _objectSpread(_objectSpread({
|
|
1086
|
+
defaultColDef: _objectSpread(_objectSpread({
|
|
1087
|
+
comparator: this.isClientMode() ? undefined : function () {
|
|
1088
|
+
return 0;
|
|
1089
|
+
}
|
|
1090
|
+
}, defaultColDef), defaultColDefProp),
|
|
1096
1091
|
columnTypes: _objectSpread(_objectSpread({}, columnTypes), columnTypesProp)
|
|
1097
1092
|
})), /*#__PURE__*/React.createElement("div", {
|
|
1098
1093
|
className: prefix('bottom')
|
|
@@ -69,7 +69,7 @@ export declare type PaginationType = {
|
|
|
69
69
|
onChange?: (current: number, pageSize: number) => void;
|
|
70
70
|
};
|
|
71
71
|
export declare type SelectionType = AgGridReactProps['rowSelection'];
|
|
72
|
-
export declare type SortOrder = '
|
|
72
|
+
export declare type SortOrder = 'desc' | 'asc';
|
|
73
73
|
export declare type SortType = {
|
|
74
74
|
field: string;
|
|
75
75
|
order: SortOrder;
|
package/package.json
CHANGED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Beans, ColumnModel, EventService, GridOptionsWrapper, RowDataTransaction, RowNode, RowNodeTransaction, SelectionService } from "@ag-grid-community/core";
|
|
2
|
-
export declare class ClientSideNodeManager {
|
|
3
|
-
private static TOP_LEVEL;
|
|
4
|
-
private readonly rootNode;
|
|
5
|
-
private gridOptionsWrapper;
|
|
6
|
-
private eventService;
|
|
7
|
-
private columnModel;
|
|
8
|
-
private selectionService;
|
|
9
|
-
private beans;
|
|
10
|
-
private nextId;
|
|
11
|
-
private static ROOT_NODE_ID;
|
|
12
|
-
private isRowMasterFunc?;
|
|
13
|
-
private suppressParentsInRowNodes;
|
|
14
|
-
private doingTreeData;
|
|
15
|
-
private doingMasterDetail;
|
|
16
|
-
private allNodesMap;
|
|
17
|
-
constructor(rootNode: RowNode, gridOptionsWrapper: GridOptionsWrapper, eventService: EventService, columnModel: ColumnModel, selectionService: SelectionService, beans: Beans);
|
|
18
|
-
postConstruct(): void;
|
|
19
|
-
getCopyOfNodesMap(): {
|
|
20
|
-
[id: string]: RowNode;
|
|
21
|
-
};
|
|
22
|
-
getRowNode(id: string): RowNode | undefined;
|
|
23
|
-
setRowData(rowData: any[]): RowNode[] | undefined;
|
|
24
|
-
updateRowData(rowDataTran: RowDataTransaction, rowNodeOrder: {
|
|
25
|
-
[id: string]: number;
|
|
26
|
-
} | null | undefined): RowNodeTransaction;
|
|
27
|
-
private updateSelection;
|
|
28
|
-
private executeAdd;
|
|
29
|
-
private executeRemove;
|
|
30
|
-
private executeUpdate;
|
|
31
|
-
private lookupRowNode;
|
|
32
|
-
private createNode;
|
|
33
|
-
private setMasterForRow;
|
|
34
|
-
private isExpanded;
|
|
35
|
-
}
|
|
@@ -1,378 +0,0 @@
|
|
|
1
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
-
|
|
3
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
-
|
|
5
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
-
|
|
7
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
8
|
-
|
|
9
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
-
|
|
11
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
12
|
-
|
|
13
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
14
|
-
|
|
15
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
16
|
-
|
|
17
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
18
|
-
|
|
19
|
-
import { Events, RowNode, _ } from "@ag-grid-community/core";
|
|
20
|
-
export var ClientSideNodeManager = /*#__PURE__*/function () {
|
|
21
|
-
function ClientSideNodeManager(rootNode, gridOptionsWrapper, eventService, columnModel, selectionService, beans) {
|
|
22
|
-
_classCallCheck(this, ClientSideNodeManager);
|
|
23
|
-
|
|
24
|
-
this.nextId = 0; // when user is provide the id's, we also keep a map of ids to row nodes for convenience
|
|
25
|
-
|
|
26
|
-
this.allNodesMap = {};
|
|
27
|
-
this.rootNode = rootNode;
|
|
28
|
-
this.gridOptionsWrapper = gridOptionsWrapper;
|
|
29
|
-
this.eventService = eventService;
|
|
30
|
-
this.columnModel = columnModel;
|
|
31
|
-
this.beans = beans;
|
|
32
|
-
this.selectionService = selectionService;
|
|
33
|
-
this.rootNode.group = true;
|
|
34
|
-
this.rootNode.level = -1;
|
|
35
|
-
this.rootNode.id = ClientSideNodeManager.ROOT_NODE_ID;
|
|
36
|
-
this.rootNode.allLeafChildren = [];
|
|
37
|
-
this.rootNode.childrenAfterGroup = [];
|
|
38
|
-
this.rootNode.childrenAfterSort = [];
|
|
39
|
-
this.rootNode.childrenAfterAggFilter = [];
|
|
40
|
-
this.rootNode.childrenAfterFilter = []; // if we make this class a bean, then can annotate postConstruct
|
|
41
|
-
|
|
42
|
-
this.postConstruct();
|
|
43
|
-
} // @PostConstruct - this is not a bean, so postConstruct called by constructor
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
_createClass(ClientSideNodeManager, [{
|
|
47
|
-
key: "postConstruct",
|
|
48
|
-
value: function postConstruct() {
|
|
49
|
-
// func below doesn't have 'this' pointer, so need to pull out these bits
|
|
50
|
-
this.suppressParentsInRowNodes = this.gridOptionsWrapper.isSuppressParentsInRowNodes();
|
|
51
|
-
this.isRowMasterFunc = this.gridOptionsWrapper.getIsRowMasterFunc();
|
|
52
|
-
this.doingTreeData = this.gridOptionsWrapper.isTreeData();
|
|
53
|
-
this.doingMasterDetail = this.gridOptionsWrapper.isMasterDetail();
|
|
54
|
-
}
|
|
55
|
-
}, {
|
|
56
|
-
key: "getCopyOfNodesMap",
|
|
57
|
-
value: function getCopyOfNodesMap() {
|
|
58
|
-
return _.cloneObject(this.allNodesMap);
|
|
59
|
-
}
|
|
60
|
-
}, {
|
|
61
|
-
key: "getRowNode",
|
|
62
|
-
value: function getRowNode(id) {
|
|
63
|
-
return this.allNodesMap[id];
|
|
64
|
-
}
|
|
65
|
-
}, {
|
|
66
|
-
key: "setRowData",
|
|
67
|
-
value: function setRowData(rowData) {
|
|
68
|
-
var _this = this;
|
|
69
|
-
|
|
70
|
-
if (typeof rowData === 'string') {
|
|
71
|
-
console.warn('AG Grid: rowData must be an array, however you passed in a string. If you are loading JSON, make sure you convert the JSON string to JavaScript objects first');
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
var rootNode = this.rootNode;
|
|
76
|
-
var sibling = this.rootNode.sibling;
|
|
77
|
-
rootNode.childrenAfterFilter = null;
|
|
78
|
-
rootNode.childrenAfterGroup = null;
|
|
79
|
-
rootNode.childrenAfterAggFilter = null;
|
|
80
|
-
rootNode.childrenAfterSort = null;
|
|
81
|
-
rootNode.childrenMapped = null;
|
|
82
|
-
rootNode.updateHasChildren();
|
|
83
|
-
this.nextId = 0;
|
|
84
|
-
this.allNodesMap = {};
|
|
85
|
-
|
|
86
|
-
if (rowData) {
|
|
87
|
-
// we use rootNode as the parent, however if using ag-grid-enterprise, the grouping stage
|
|
88
|
-
// sets the parent node on each row (even if we are not grouping). so setting parent node
|
|
89
|
-
// here is for benefit of ag-grid-community users
|
|
90
|
-
rootNode.allLeafChildren = rowData.map(function (dataItem) {
|
|
91
|
-
return _this.createNode(dataItem, _this.rootNode, ClientSideNodeManager.TOP_LEVEL);
|
|
92
|
-
});
|
|
93
|
-
} else {
|
|
94
|
-
rootNode.allLeafChildren = [];
|
|
95
|
-
rootNode.childrenAfterGroup = [];
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (sibling) {
|
|
99
|
-
sibling.childrenAfterFilter = rootNode.childrenAfterFilter;
|
|
100
|
-
sibling.childrenAfterGroup = rootNode.childrenAfterGroup;
|
|
101
|
-
sibling.childrenAfterAggFilter = rootNode.childrenAfterAggFilter;
|
|
102
|
-
sibling.childrenAfterSort = rootNode.childrenAfterSort;
|
|
103
|
-
sibling.childrenMapped = rootNode.childrenMapped;
|
|
104
|
-
sibling.allLeafChildren = rootNode.allLeafChildren;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}, {
|
|
108
|
-
key: "updateRowData",
|
|
109
|
-
value: function updateRowData(rowDataTran, rowNodeOrder) {
|
|
110
|
-
var rowNodeTransaction = {
|
|
111
|
-
remove: [],
|
|
112
|
-
update: [],
|
|
113
|
-
add: []
|
|
114
|
-
};
|
|
115
|
-
var nodesToUnselect = [];
|
|
116
|
-
this.executeRemove(rowDataTran, rowNodeTransaction, nodesToUnselect);
|
|
117
|
-
this.executeUpdate(rowDataTran, rowNodeTransaction, nodesToUnselect);
|
|
118
|
-
this.executeAdd(rowDataTran, rowNodeTransaction);
|
|
119
|
-
this.updateSelection(nodesToUnselect);
|
|
120
|
-
|
|
121
|
-
if (rowNodeOrder) {
|
|
122
|
-
_.sortRowNodesByOrder(this.rootNode.allLeafChildren, rowNodeOrder);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return rowNodeTransaction;
|
|
126
|
-
}
|
|
127
|
-
}, {
|
|
128
|
-
key: "updateSelection",
|
|
129
|
-
value: function updateSelection(nodesToUnselect) {
|
|
130
|
-
var selectionChanged = nodesToUnselect.length > 0;
|
|
131
|
-
|
|
132
|
-
if (selectionChanged) {
|
|
133
|
-
nodesToUnselect.forEach(function (rowNode) {
|
|
134
|
-
rowNode.setSelected(false, false, true);
|
|
135
|
-
});
|
|
136
|
-
} // we do this regardless of nodes to unselect or not, as it's possible
|
|
137
|
-
// a new node was inserted, so a parent that was previously selected (as all
|
|
138
|
-
// children were selected) should not be tri-state (as new one unselected against
|
|
139
|
-
// all other selected children).
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
this.selectionService.updateGroupsFromChildrenSelections();
|
|
143
|
-
|
|
144
|
-
if (selectionChanged) {
|
|
145
|
-
var event = {
|
|
146
|
-
type: Events.EVENT_SELECTION_CHANGED
|
|
147
|
-
};
|
|
148
|
-
this.eventService.dispatchEvent(event);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}, {
|
|
152
|
-
key: "executeAdd",
|
|
153
|
-
value: function executeAdd(rowDataTran, rowNodeTransaction) {
|
|
154
|
-
var _this2 = this;
|
|
155
|
-
|
|
156
|
-
var add = rowDataTran.add,
|
|
157
|
-
addIndex = rowDataTran.addIndex;
|
|
158
|
-
|
|
159
|
-
if (_.missingOrEmpty(add)) {
|
|
160
|
-
return;
|
|
161
|
-
} // create new row nodes for each data item
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
var newNodes = add.map(function (item) {
|
|
165
|
-
return _this2.createNode(item, _this2.rootNode, ClientSideNodeManager.TOP_LEVEL);
|
|
166
|
-
}); // add new row nodes to the root nodes 'allLeafChildren'
|
|
167
|
-
|
|
168
|
-
var useIndex = typeof addIndex === 'number' && addIndex >= 0;
|
|
169
|
-
var nodesBeforeIndex;
|
|
170
|
-
var nodesAfterIndex;
|
|
171
|
-
|
|
172
|
-
if (useIndex) {
|
|
173
|
-
// new rows are inserted in one go by concatenating them in between the existing rows at the desired index.
|
|
174
|
-
// this is much faster than splicing them individually into 'allLeafChildren' when there are large inserts.
|
|
175
|
-
// allLeafChildren can be out of order, so we loop over all the Nodes to find the correct index that
|
|
176
|
-
// represents the position `addIndex` intended to be.
|
|
177
|
-
var allLeafChildren = this.rootNode.allLeafChildren; // if addIndex is 0, it should always be added at the start of the array
|
|
178
|
-
// there is no need to verify the order of node by nodeIndex.
|
|
179
|
-
|
|
180
|
-
var normalizedAddIndex = addIndex === 0 ? 0 : allLeafChildren.reduce(function (prevIdx, currNode, currIdx) {
|
|
181
|
-
var _a;
|
|
182
|
-
|
|
183
|
-
var rowIndex = currNode.rowIndex;
|
|
184
|
-
var prevValueAtIndex = (_a = allLeafChildren[prevIdx]) === null || _a === void 0 ? void 0 : _a.rowIndex;
|
|
185
|
-
var shouldUpdateIndex = rowIndex != null && prevValueAtIndex != null && rowIndex < addIndex && rowIndex > prevValueAtIndex;
|
|
186
|
-
return shouldUpdateIndex ? currIdx : prevIdx;
|
|
187
|
-
}, 0) + 1;
|
|
188
|
-
nodesBeforeIndex = allLeafChildren.slice(0, normalizedAddIndex);
|
|
189
|
-
nodesAfterIndex = allLeafChildren.slice(normalizedAddIndex, allLeafChildren.length);
|
|
190
|
-
} else {
|
|
191
|
-
nodesBeforeIndex = this.rootNode.allLeafChildren;
|
|
192
|
-
nodesAfterIndex = [];
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
this.rootNode.allLeafChildren = [].concat(_toConsumableArray(nodesBeforeIndex), _toConsumableArray(newNodes), _toConsumableArray(nodesAfterIndex));
|
|
196
|
-
|
|
197
|
-
if (this.rootNode.sibling) {
|
|
198
|
-
this.rootNode.sibling.allLeafChildren = this.rootNode.allLeafChildren;
|
|
199
|
-
} // add new row nodes to the transaction add items
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
rowNodeTransaction.add = newNodes;
|
|
203
|
-
}
|
|
204
|
-
}, {
|
|
205
|
-
key: "executeRemove",
|
|
206
|
-
value: function executeRemove(rowDataTran, rowNodeTransaction, nodesToUnselect) {
|
|
207
|
-
var _this3 = this;
|
|
208
|
-
|
|
209
|
-
var remove = rowDataTran.remove;
|
|
210
|
-
|
|
211
|
-
if (_.missingOrEmpty(remove)) {
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
var rowIdsRemoved = {};
|
|
216
|
-
remove.forEach(function (item) {
|
|
217
|
-
var rowNode = _this3.lookupRowNode(item);
|
|
218
|
-
|
|
219
|
-
if (!rowNode) {
|
|
220
|
-
return;
|
|
221
|
-
} // do delete - setting 'suppressFinishActions = true' to ensure EVENT_SELECTION_CHANGED is not raised for
|
|
222
|
-
// each row node updated, instead it is raised once by the calling code if any selected nodes exist.
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
if (rowNode.isSelected()) {
|
|
226
|
-
nodesToUnselect.push(rowNode);
|
|
227
|
-
} // so row renderer knows to fade row out (and not reposition it)
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
rowNode.clearRowTopAndRowIndex(); // NOTE: were we could remove from allLeaveChildren, however _.removeFromArray() is expensive, especially
|
|
231
|
-
// if called multiple times (eg deleting lots of rows) and if allLeafChildren is a large list
|
|
232
|
-
|
|
233
|
-
rowIdsRemoved[rowNode.id] = true; // _.removeFromArray(this.rootNode.allLeafChildren, rowNode);
|
|
234
|
-
|
|
235
|
-
delete _this3.allNodesMap[rowNode.id];
|
|
236
|
-
rowNodeTransaction.remove.push(rowNode);
|
|
237
|
-
});
|
|
238
|
-
this.rootNode.allLeafChildren = this.rootNode.allLeafChildren.filter(function (rowNode) {
|
|
239
|
-
return !rowIdsRemoved[rowNode.id];
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
if (this.rootNode.sibling) {
|
|
243
|
-
this.rootNode.sibling.allLeafChildren = this.rootNode.allLeafChildren;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}, {
|
|
247
|
-
key: "executeUpdate",
|
|
248
|
-
value: function executeUpdate(rowDataTran, rowNodeTransaction, nodesToUnselect) {
|
|
249
|
-
var _this4 = this;
|
|
250
|
-
|
|
251
|
-
var update = rowDataTran.update;
|
|
252
|
-
|
|
253
|
-
if (_.missingOrEmpty(update)) {
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
update.forEach(function (item) {
|
|
258
|
-
var rowNode = _this4.lookupRowNode(item);
|
|
259
|
-
|
|
260
|
-
if (!rowNode) {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
rowNode.updateData(item);
|
|
265
|
-
|
|
266
|
-
if (!rowNode.selectable && rowNode.isSelected()) {
|
|
267
|
-
nodesToUnselect.push(rowNode);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
_this4.setMasterForRow(rowNode, item, ClientSideNodeManager.TOP_LEVEL, false);
|
|
271
|
-
|
|
272
|
-
rowNodeTransaction.update.push(rowNode);
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
}, {
|
|
276
|
-
key: "lookupRowNode",
|
|
277
|
-
value: function lookupRowNode(data) {
|
|
278
|
-
var getRowIdFunc = this.gridOptionsWrapper.getRowIdFunc();
|
|
279
|
-
var rowNode;
|
|
280
|
-
|
|
281
|
-
if (getRowIdFunc) {
|
|
282
|
-
// find rowNode using id
|
|
283
|
-
var id = getRowIdFunc({
|
|
284
|
-
data: data,
|
|
285
|
-
level: 0
|
|
286
|
-
});
|
|
287
|
-
rowNode = this.allNodesMap[id];
|
|
288
|
-
|
|
289
|
-
if (!rowNode) {
|
|
290
|
-
console.error("AG Grid: could not find row id=".concat(id, ", data item was not found for this id"));
|
|
291
|
-
return null;
|
|
292
|
-
}
|
|
293
|
-
} else {
|
|
294
|
-
// find rowNode using object references
|
|
295
|
-
rowNode = this.rootNode.allLeafChildren.find(function (node) {
|
|
296
|
-
return node.data === data;
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
if (!rowNode) {
|
|
300
|
-
console.error("AG Grid: could not find data item as object was not found", data);
|
|
301
|
-
console.error("Consider using getRowId to help the Grid find matching row data");
|
|
302
|
-
return null;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
return rowNode || null;
|
|
307
|
-
}
|
|
308
|
-
}, {
|
|
309
|
-
key: "createNode",
|
|
310
|
-
value: function createNode(dataItem, parent, level) {
|
|
311
|
-
var node = new RowNode(this.beans);
|
|
312
|
-
node.group = false;
|
|
313
|
-
this.setMasterForRow(node, dataItem, level, true);
|
|
314
|
-
|
|
315
|
-
if (parent && !this.suppressParentsInRowNodes) {
|
|
316
|
-
node.parent = parent;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
node.level = level;
|
|
320
|
-
node.setDataAndId(dataItem, this.nextId.toString());
|
|
321
|
-
|
|
322
|
-
if (this.allNodesMap[node.id]) {
|
|
323
|
-
console.warn("AG Grid: duplicate node id '".concat(node.id, "' detected from getRowId callback, this could cause issues in your grid."));
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
this.allNodesMap[node.id] = node;
|
|
327
|
-
this.nextId++;
|
|
328
|
-
return node;
|
|
329
|
-
}
|
|
330
|
-
}, {
|
|
331
|
-
key: "setMasterForRow",
|
|
332
|
-
value: function setMasterForRow(rowNode, data, level, setExpanded) {
|
|
333
|
-
if (this.doingTreeData) {
|
|
334
|
-
rowNode.setMaster(false);
|
|
335
|
-
|
|
336
|
-
if (setExpanded) {
|
|
337
|
-
rowNode.expanded = false;
|
|
338
|
-
}
|
|
339
|
-
} else {
|
|
340
|
-
// this is the default, for when doing grid data
|
|
341
|
-
if (this.doingMasterDetail) {
|
|
342
|
-
// if we are doing master detail, then the
|
|
343
|
-
// default is that everything can be a Master Row.
|
|
344
|
-
if (this.isRowMasterFunc) {
|
|
345
|
-
rowNode.setMaster(this.isRowMasterFunc(data));
|
|
346
|
-
} else {
|
|
347
|
-
rowNode.setMaster(true);
|
|
348
|
-
}
|
|
349
|
-
} else {
|
|
350
|
-
rowNode.setMaster(false);
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
if (setExpanded) {
|
|
354
|
-
var rowGroupColumns = this.columnModel.getRowGroupColumns();
|
|
355
|
-
var numRowGroupColumns = rowGroupColumns ? rowGroupColumns.length : 0; // need to take row group into account when determining level
|
|
356
|
-
|
|
357
|
-
var masterRowLevel = level + numRowGroupColumns;
|
|
358
|
-
rowNode.expanded = rowNode.master ? this.isExpanded(masterRowLevel) : false;
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
}, {
|
|
363
|
-
key: "isExpanded",
|
|
364
|
-
value: function isExpanded(level) {
|
|
365
|
-
var expandByDefault = this.gridOptionsWrapper.getGroupDefaultExpanded();
|
|
366
|
-
|
|
367
|
-
if (expandByDefault === -1) {
|
|
368
|
-
return true;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
return level < expandByDefault;
|
|
372
|
-
}
|
|
373
|
-
}]);
|
|
374
|
-
|
|
375
|
-
return ClientSideNodeManager;
|
|
376
|
-
}();
|
|
377
|
-
ClientSideNodeManager.TOP_LEVEL = 0;
|
|
378
|
-
ClientSideNodeManager.ROOT_NODE_ID = 'ROOT_NODE_ID';
|