@adaptabletools/adaptable-react-aggrid-cjs 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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaptabletools/adaptable-react-aggrid-cjs",
|
|
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",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"typings": "src/index.d.ts",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"tslib": "^2.3.0",
|
|
11
|
-
"@adaptabletools/adaptable-cjs": "18.1.
|
|
11
|
+
"@adaptabletools/adaptable-cjs": "18.1.4-canary.0"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
14
|
"react": "^18.0.0",
|
|
@@ -5,12 +5,15 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const React = tslib_1.__importStar(require("react"));
|
|
6
6
|
const react_1 = require("ag-grid-community");
|
|
7
7
|
const AdaptableReact_1 = tslib_1.__importDefault(require("./AdaptableReact"));
|
|
8
|
+
const core_1 = require("ag-grid-community");
|
|
9
|
+
const ObjectExtensions_1 = require("@adaptabletools/adaptable-cjs/src/Utilities/Extensions/ObjectExtensions");
|
|
8
10
|
var AdaptableAgGridStateTransitions;
|
|
9
11
|
(function (AdaptableAgGridStateTransitions) {
|
|
10
12
|
AdaptableAgGridStateTransitions["AG_GRID_EMIT_PROPS"] = "AG_GRID_EMIT_PROPS";
|
|
11
13
|
AdaptableAgGridStateTransitions["INITIALIZE_ADAPTABLE"] = "INITIALIZE_ADAPTABLE";
|
|
12
14
|
AdaptableAgGridStateTransitions["INITIALIZE_AG_GRID"] = "INITIALIZE_AG_GRID";
|
|
13
15
|
})(AdaptableAgGridStateTransitions || (AdaptableAgGridStateTransitions = {}));
|
|
16
|
+
const agGridPropertySet = new Set(core_1.ComponentUtil.ALL_PROPERTIES);
|
|
14
17
|
// -- ADAPTABLE PROVIDER -
|
|
15
18
|
const AdaptableAgGridContext = React.createContext(null);
|
|
16
19
|
const useAdaptableAgGridContext = () => {
|
|
@@ -97,18 +100,20 @@ const AdaptableUI = (props) => {
|
|
|
97
100
|
};
|
|
98
101
|
const AdaptableAgGridReact = (props) => {
|
|
99
102
|
const agGridRef = React.useRef(null);
|
|
103
|
+
const [isAgGridReady, setAgGridIsReady] = React.useState(false);
|
|
100
104
|
const { modules, gridOptions, setAgGridApi, transition, setAgGridProps, agGridApi } = useAdaptableAgGridContext();
|
|
101
|
-
|
|
102
|
-
*
|
|
103
|
-
*/
|
|
104
|
-
const colDefsRef = React.useRef(props.columnDefs);
|
|
105
|
+
const propsRef = React.useRef(props);
|
|
105
106
|
React.useEffect(() => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
const prevProps = propsRef.current;
|
|
108
|
+
if (isAgGridReady && agGridApi && prevProps !== props) {
|
|
109
|
+
const changedProps = (0, ObjectExtensions_1.diff)(prevProps, props);
|
|
110
|
+
for (const changedProp of changedProps) {
|
|
111
|
+
if (agGridPropertySet.has(changedProp)) {
|
|
112
|
+
agGridApi.setGridOption(changedProp, props[changedProp]);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
110
115
|
}
|
|
111
|
-
}, [props
|
|
116
|
+
}, [props, agGridApi]);
|
|
112
117
|
const LIST_OF_PROPS_NOT_ON_GRID_OPTIONS = [
|
|
113
118
|
'rowData',
|
|
114
119
|
'containerStyle',
|
|
@@ -147,6 +152,7 @@ const AdaptableAgGridReact = (props) => {
|
|
|
147
152
|
if (gridOptions.onGridReady) {
|
|
148
153
|
gridOptions.onGridReady(event);
|
|
149
154
|
}
|
|
155
|
+
setAgGridIsReady(true);
|
|
150
156
|
}, gridOptions: gridOptions })));
|
|
151
157
|
};
|
|
152
158
|
exports.Adaptable = {
|
|
@@ -10,6 +10,7 @@ const getRandomInt = (max) => Math.floor(Math.random() * Math.floor(max));
|
|
|
10
10
|
const AdaptableReact = (_a) => {
|
|
11
11
|
var { adaptableOptions, gridOptions, onAdaptableReady } = _a, props = tslib_1.__rest(_a, ["adaptableOptions", "gridOptions", "onAdaptableReady"]);
|
|
12
12
|
const seedId = (0, react_1.useMemo)(() => `${getRandomInt(1000)}-${Date.now()}`, []);
|
|
13
|
+
// TODO: not sure this is used anywhere
|
|
13
14
|
const adaptableContainerId = `adaptable-${seedId}`;
|
|
14
15
|
const containerRef = (0, react_1.useMemo)(() => {
|
|
15
16
|
let adaptableApi;
|