@adaptabletools/adaptable-react-aggrid 18.1.2 → 18.1.4-canary.0
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/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaptabletools/adaptable-react-aggrid",
|
|
3
|
-
"version": "18.1.
|
|
3
|
+
"version": "18.1.4-canary.0",
|
|
4
4
|
"description": "React version of AdapTable - the powerful data-agnostic HTML5 AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "contact sales@adaptabletools.com for details",
|
|
7
7
|
"typings": "src/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"tslib": "^2.3.0",
|
|
10
|
-
"@adaptabletools/adaptable": "18.1.
|
|
10
|
+
"@adaptabletools/adaptable": "18.1.4-canary.0"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
13
|
"@ag-grid-community/core": ">=31.3.1",
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { AgGridReact } from '@ag-grid-community/react';
|
|
3
3
|
import AdaptableReactComponent from './AdaptableReact';
|
|
4
|
+
import { ComponentUtil } from '@ag-grid-community/core';
|
|
5
|
+
import { diff } from '@adaptabletools/adaptable/src/Utilities/Extensions/ObjectExtensions';
|
|
4
6
|
var AdaptableAgGridStateTransitions;
|
|
5
7
|
(function (AdaptableAgGridStateTransitions) {
|
|
6
8
|
AdaptableAgGridStateTransitions["AG_GRID_EMIT_PROPS"] = "AG_GRID_EMIT_PROPS";
|
|
7
9
|
AdaptableAgGridStateTransitions["INITIALIZE_ADAPTABLE"] = "INITIALIZE_ADAPTABLE";
|
|
8
10
|
AdaptableAgGridStateTransitions["INITIALIZE_AG_GRID"] = "INITIALIZE_AG_GRID";
|
|
9
11
|
})(AdaptableAgGridStateTransitions || (AdaptableAgGridStateTransitions = {}));
|
|
12
|
+
const agGridPropertySet = new Set(ComponentUtil.ALL_PROPERTIES);
|
|
10
13
|
// -- ADAPTABLE PROVIDER -
|
|
11
14
|
const AdaptableAgGridContext = React.createContext(null);
|
|
12
15
|
const useAdaptableAgGridContext = () => {
|
|
@@ -93,18 +96,20 @@ const AdaptableUI = (props) => {
|
|
|
93
96
|
};
|
|
94
97
|
const AdaptableAgGridReact = (props) => {
|
|
95
98
|
const agGridRef = React.useRef(null);
|
|
99
|
+
const [isAgGridReady, setAgGridIsReady] = React.useState(false);
|
|
96
100
|
const { modules, gridOptions, setAgGridApi, transition, setAgGridProps, agGridApi } = useAdaptableAgGridContext();
|
|
97
|
-
|
|
98
|
-
*
|
|
99
|
-
*/
|
|
100
|
-
const colDefsRef = React.useRef(props.columnDefs);
|
|
101
|
+
const propsRef = React.useRef(props);
|
|
101
102
|
React.useEffect(() => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
const prevProps = propsRef.current;
|
|
104
|
+
if (isAgGridReady && agGridApi && prevProps !== props) {
|
|
105
|
+
const changedProps = diff(prevProps, props);
|
|
106
|
+
for (const changedProp of changedProps) {
|
|
107
|
+
if (agGridPropertySet.has(changedProp)) {
|
|
108
|
+
agGridApi.setGridOption(changedProp, props[changedProp]);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
106
111
|
}
|
|
107
|
-
}, [props
|
|
112
|
+
}, [props, agGridApi]);
|
|
108
113
|
const LIST_OF_PROPS_NOT_ON_GRID_OPTIONS = [
|
|
109
114
|
'rowData',
|
|
110
115
|
'containerStyle',
|
|
@@ -143,6 +148,7 @@ const AdaptableAgGridReact = (props) => {
|
|
|
143
148
|
if (gridOptions.onGridReady) {
|
|
144
149
|
gridOptions.onGridReady(event);
|
|
145
150
|
}
|
|
151
|
+
setAgGridIsReady(true);
|
|
146
152
|
}, gridOptions: gridOptions })));
|
|
147
153
|
};
|
|
148
154
|
export const Adaptable = {
|
|
@@ -8,6 +8,7 @@ const getRandomInt = (max) => Math.floor(Math.random() * Math.floor(max));
|
|
|
8
8
|
const AdaptableReact = (_a) => {
|
|
9
9
|
var { adaptableOptions, gridOptions, onAdaptableReady } = _a, props = __rest(_a, ["adaptableOptions", "gridOptions", "onAdaptableReady"]);
|
|
10
10
|
const seedId = useMemo(() => `${getRandomInt(1000)}-${Date.now()}`, []);
|
|
11
|
+
// TODO: not sure this is used anywhere
|
|
11
12
|
const adaptableContainerId = `adaptable-${seedId}`;
|
|
12
13
|
const containerRef = useMemo(() => {
|
|
13
14
|
let adaptableApi;
|