@bolttech/form-engine 3.1.0-beta.6 → 3.1.0-beta.7
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.esm.js +18 -6
- package/package.json +2 -2
package/index.esm.js
CHANGED
|
@@ -2176,12 +2176,13 @@ const FieldWrapper = ({
|
|
|
2176
2176
|
visibility: typeof visibility === 'boolean' ? visibility : true,
|
|
2177
2177
|
props: filteredProps
|
|
2178
2178
|
});
|
|
2179
|
+
const mountedRef = useRef(false);
|
|
2179
2180
|
/**
|
|
2180
2181
|
* handles the mounting and unmounting logic onto the field instance
|
|
2181
2182
|
*/
|
|
2182
2183
|
useEffect(() => {
|
|
2183
|
-
if (!
|
|
2184
|
-
fieldInstance
|
|
2184
|
+
if (!fieldInstance || mountedRef.current) return;
|
|
2185
|
+
fieldInstance.mountField({
|
|
2185
2186
|
valueSubscription: value => {
|
|
2186
2187
|
setValueState(value);
|
|
2187
2188
|
},
|
|
@@ -2197,10 +2198,13 @@ const FieldWrapper = ({
|
|
|
2197
2198
|
}));
|
|
2198
2199
|
}
|
|
2199
2200
|
});
|
|
2201
|
+
mountedRef.current = true;
|
|
2202
|
+
}, [fieldInstance]);
|
|
2203
|
+
useEffect(() => {
|
|
2200
2204
|
return () => {
|
|
2201
|
-
|
|
2205
|
+
mountedRef.current && (fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.destroyField());
|
|
2202
2206
|
};
|
|
2203
|
-
}, [
|
|
2207
|
+
}, []);
|
|
2204
2208
|
/**
|
|
2205
2209
|
* handles the value change onto the field instance
|
|
2206
2210
|
*/
|
|
@@ -2478,6 +2482,7 @@ function Form({
|
|
|
2478
2482
|
} = useFormGroupContext({});
|
|
2479
2483
|
const schemaIndex = useRef(index || (schema === null || schema === void 0 ? void 0 : schema.index) || 'defaultChange').current;
|
|
2480
2484
|
const [mounted, setMounted] = useState(false);
|
|
2485
|
+
const mountedRef = useRef(false);
|
|
2481
2486
|
// const formInstance = useRef(
|
|
2482
2487
|
// new FormCore({
|
|
2483
2488
|
// schema,
|
|
@@ -2491,7 +2496,7 @@ function Form({
|
|
|
2491
2496
|
// })
|
|
2492
2497
|
// );
|
|
2493
2498
|
useEffect(() => {
|
|
2494
|
-
|
|
2499
|
+
if (mountedRef.current) return;
|
|
2495
2500
|
formGroupInstance.addForm({
|
|
2496
2501
|
key: schemaIndex,
|
|
2497
2502
|
formInstance: new FormCore({
|
|
@@ -2506,6 +2511,7 @@ function Form({
|
|
|
2506
2511
|
})
|
|
2507
2512
|
});
|
|
2508
2513
|
setMounted(true);
|
|
2514
|
+
mountedRef.current = true;
|
|
2509
2515
|
// }
|
|
2510
2516
|
}, []);
|
|
2511
2517
|
// useEffect(() => {
|
|
@@ -2643,6 +2649,7 @@ const AsFormFieldBuilder = props => {
|
|
|
2643
2649
|
*/
|
|
2644
2650
|
useEffect(() => {
|
|
2645
2651
|
var _a;
|
|
2652
|
+
if (mountedRef.current) return;
|
|
2646
2653
|
if (typeof props.formMounted === 'undefined' && !((_a = context.formGroupInstance) === null || _a === void 0 ? void 0 : _a.forms.has(props.formIndex))) {
|
|
2647
2654
|
context.addFormWithIndex(props.formIndex);
|
|
2648
2655
|
}
|
|
@@ -2662,7 +2669,12 @@ const AsFormFieldBuilder = props => {
|
|
|
2662
2669
|
}, [props.formMounted]);
|
|
2663
2670
|
useEffect(() => {
|
|
2664
2671
|
return () => {
|
|
2665
|
-
|
|
2672
|
+
var _a, _b;
|
|
2673
|
+
if ((_b = (_a = context.getForm({
|
|
2674
|
+
key: props.formIndex
|
|
2675
|
+
})) === null || _a === void 0 ? void 0 : _a.getField({
|
|
2676
|
+
key: props.name
|
|
2677
|
+
})) === null || _b === void 0 ? void 0 : _b.mounted) context.formGroupInstance.removeField({
|
|
2666
2678
|
formIndex: props.formIndex,
|
|
2667
2679
|
fieldIndex: props.name
|
|
2668
2680
|
});
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bolttech/form-engine",
|
|
3
|
-
"version": "3.1.0-beta.
|
|
3
|
+
"version": "3.1.0-beta.7",
|
|
4
4
|
"description": "A react adapter for bolttech form engine",
|
|
5
5
|
"module": "./index.esm.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./index.esm.js",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@bolttech/form-engine-core": "1.0.0-beta.
|
|
9
|
+
"@bolttech/form-engine-core": "1.0.0-beta.7",
|
|
10
10
|
"react": "18.2.0"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {}
|