@bolttech/form-engine 3.1.0-beta.14 → 3.1.0-beta.15

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { createContext, useContext, useRef, useEffect, useState, useMemo, useCallback, Suspense } from 'react';
3
- import { FormGroup, FormCore, FormField } from '@bolttech/form-engine-core';
3
+ import { FormGroup, FormField } from '@bolttech/form-engine-core';
4
4
 
5
5
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
6
6
 
@@ -1656,6 +1656,7 @@ const IsolatedContext = ({
1656
1656
  const formGroupInstance = useRef(new FormGroup({
1657
1657
  config
1658
1658
  }));
1659
+ const formGroupContextMountRef = useRef(false);
1659
1660
  const addFormWithIndex = index => {
1660
1661
  formGroupInstance.current.createFormWithIndex({
1661
1662
  index,
@@ -1664,11 +1665,11 @@ const IsolatedContext = ({
1664
1665
  };
1665
1666
  const addForm = ({
1666
1667
  key,
1667
- formInstance
1668
+ params
1668
1669
  }) => {
1669
1670
  formGroupInstance.current.addForm({
1670
1671
  key,
1671
- formInstance
1672
+ params
1672
1673
  });
1673
1674
  };
1674
1675
  const removeForm = ({
@@ -1689,6 +1690,20 @@ const IsolatedContext = ({
1689
1690
  function submitMultipleFormsByIndex(indexes) {
1690
1691
  return formGroupInstance.current.submitMultipleFormsByIndex(indexes);
1691
1692
  }
1693
+ useEffect(() => {
1694
+ return () => {
1695
+ if (formGroupContextMountRef.current) {
1696
+ // strictMode made me do this, Beato Carlo Acutis please forgive me
1697
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1698
+ formGroupInstance.current.destroy();
1699
+ }
1700
+ };
1701
+ }, []);
1702
+ useEffect(() => {
1703
+ return () => {
1704
+ formGroupContextMountRef.current = true;
1705
+ };
1706
+ }, []);
1692
1707
  return {
1693
1708
  addFormWithIndex,
1694
1709
  addForm,
@@ -1941,7 +1956,7 @@ function Form({
1941
1956
  if (mountedRef.current) return;
1942
1957
  formGroupInstance.addForm({
1943
1958
  key: schemaIndex,
1944
- formInstance: new FormCore({
1959
+ params: {
1945
1960
  schema,
1946
1961
  initialValues: initialValues || (schema === null || schema === void 0 ? void 0 : schema.initialValues),
1947
1962
  iVars: iVars || (schema === null || schema === void 0 ? void 0 : schema.iVars),
@@ -1950,7 +1965,7 @@ function Form({
1950
1965
  index: schemaIndex,
1951
1966
  mappers,
1952
1967
  config: config || formGroupInstance.config
1953
- })
1968
+ }
1954
1969
  });
1955
1970
  setMounted(true);
1956
1971
  mountedRef.current = true;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@bolttech/form-engine",
3
- "version": "3.1.0-beta.14",
3
+ "version": "3.1.0-beta.15",
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.14",
9
+ "@bolttech/form-engine-core": "1.0.0-beta.15",
10
10
  "react": "18.2.0"
11
11
  },
12
12
  "peerDependencies": {}
@@ -1,4 +1,4 @@
1
- import { FormCore, TFormCore, TFormGroup, TMapper, TSchemaFormConfig } from '@bolttech/form-engine-core';
1
+ import { FormCore, TFormEntry, TFormGroup, TMapper, TSchemaFormConfig } from '@bolttech/form-engine-core';
2
2
  import { ElementType } from 'react';
3
3
  /**
4
4
  * Represents the context for managing forms within a form group.
@@ -18,7 +18,7 @@ type TFormContext = {
18
18
  addFormWithIndex: (index: string) => void;
19
19
  addForm: (payload: {
20
20
  key: string;
21
- formInstance: TFormCore;
21
+ params: TFormEntry;
22
22
  }) => void;
23
23
  getForm: (payload: {
24
24
  key: string;