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

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
 
@@ -88,7 +88,7 @@ var check = function (it) {
88
88
  };
89
89
 
90
90
  // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
91
- var global$b =
91
+ var globalThis_1 =
92
92
  // eslint-disable-next-line es/no-global-this -- safe
93
93
  check(typeof globalThis == 'object' && globalThis) ||
94
94
  check(typeof window == 'object' && window) ||
@@ -101,30 +101,30 @@ var global$b =
101
101
 
102
102
  var sharedStore = {exports: {}};
103
103
 
104
- var global$a = global$b;
104
+ var globalThis$c = globalThis_1;
105
105
 
106
106
  // eslint-disable-next-line es/no-object-defineproperty -- safe
107
107
  var defineProperty$5 = Object.defineProperty;
108
108
 
109
109
  var defineGlobalProperty$3 = function (key, value) {
110
110
  try {
111
- defineProperty$5(global$a, key, { value: value, configurable: true, writable: true });
111
+ defineProperty$5(globalThis$c, key, { value: value, configurable: true, writable: true });
112
112
  } catch (error) {
113
- global$a[key] = value;
113
+ globalThis$c[key] = value;
114
114
  } return value;
115
115
  };
116
116
 
117
- var globalThis$1 = global$b;
117
+ var globalThis$b = globalThis_1;
118
118
  var defineGlobalProperty$2 = defineGlobalProperty$3;
119
119
 
120
120
  var SHARED = '__core-js_shared__';
121
- var store$3 = sharedStore.exports = globalThis$1[SHARED] || defineGlobalProperty$2(SHARED, {});
121
+ var store$3 = sharedStore.exports = globalThis$b[SHARED] || defineGlobalProperty$2(SHARED, {});
122
122
 
123
123
  (store$3.versions || (store$3.versions = [])).push({
124
- version: '3.37.1',
124
+ version: '3.39.0',
125
125
  mode: 'global',
126
126
  copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)',
127
- license: 'https://github.com/zloirock/core-js/blob/v3.37.1/LICENSE',
127
+ license: 'https://github.com/zloirock/core-js/blob/v3.39.0/LICENSE',
128
128
  source: 'https://github.com/zloirock/core-js'
129
129
  });
130
130
 
@@ -166,13 +166,18 @@ var uid$2 = function (key) {
166
166
  return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString(++id + postfix, 36);
167
167
  };
168
168
 
169
- var engineUserAgent = typeof navigator != 'undefined' && String(navigator.userAgent) || '';
169
+ var globalThis$a = globalThis_1;
170
170
 
171
- var global$9 = global$b;
172
- var userAgent = engineUserAgent;
171
+ var navigator = globalThis$a.navigator;
172
+ var userAgent$1 = navigator && navigator.userAgent;
173
173
 
174
- var process = global$9.process;
175
- var Deno = global$9.Deno;
174
+ var environmentUserAgent = userAgent$1 ? String(userAgent$1) : '';
175
+
176
+ var globalThis$9 = globalThis_1;
177
+ var userAgent = environmentUserAgent;
178
+
179
+ var process = globalThis$9.process;
180
+ var Deno = globalThis$9.Deno;
176
181
  var versions = process && process.versions || Deno && Deno.version;
177
182
  var v8 = versions && versions.v8;
178
183
  var match, version;
@@ -194,14 +199,14 @@ if (!version && userAgent) {
194
199
  }
195
200
  }
196
201
 
197
- var engineV8Version = version;
202
+ var environmentV8Version = version;
198
203
 
199
204
  /* eslint-disable es/no-symbol -- required for testing */
200
- var V8_VERSION = engineV8Version;
205
+ var V8_VERSION = environmentV8Version;
201
206
  var fails$8 = fails$b;
202
- var global$8 = global$b;
207
+ var globalThis$8 = globalThis_1;
203
208
 
204
- var $String$4 = global$8.String;
209
+ var $String$4 = globalThis$8.String;
205
210
 
206
211
  // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
207
212
  var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails$8(function () {
@@ -218,18 +223,18 @@ var symbolConstructorDetection = !!Object.getOwnPropertySymbols && !fails$8(func
218
223
  /* eslint-disable es/no-symbol -- required for testing */
219
224
  var NATIVE_SYMBOL$1 = symbolConstructorDetection;
220
225
 
221
- var useSymbolAsUid = NATIVE_SYMBOL$1
222
- && !Symbol.sham
223
- && typeof Symbol.iterator == 'symbol';
226
+ var useSymbolAsUid = NATIVE_SYMBOL$1 &&
227
+ !Symbol.sham &&
228
+ typeof Symbol.iterator == 'symbol';
224
229
 
225
- var global$7 = global$b;
230
+ var globalThis$7 = globalThis_1;
226
231
  var shared$2 = shared$3;
227
232
  var hasOwn$8 = hasOwnProperty_1;
228
233
  var uid$1 = uid$2;
229
234
  var NATIVE_SYMBOL = symbolConstructorDetection;
230
235
  var USE_SYMBOL_AS_UID$1 = useSymbolAsUid;
231
236
 
232
- var Symbol$1 = global$7.Symbol;
237
+ var Symbol$1 = globalThis$7.Symbol;
233
238
  var WellKnownSymbolsStore = shared$2('wks');
234
239
  var createWellKnownSymbol = USE_SYMBOL_AS_UID$1 ? Symbol$1['for'] || Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1;
235
240
 
@@ -295,10 +300,10 @@ var v8PrototypeDefineBug = DESCRIPTORS$9 && fails$6(function () {
295
300
 
296
301
  var objectDefineProperty = {};
297
302
 
298
- var global$6 = global$b;
303
+ var globalThis$6 = globalThis_1;
299
304
  var isObject$6 = isObject$8;
300
305
 
301
- var document$1 = global$6.document;
306
+ var document$1 = globalThis$6.document;
302
307
  // typeof document.createElement is 'object' in old IE
303
308
  var EXISTS$1 = isObject$6(document$1) && isObject$6(document$1.createElement);
304
309
 
@@ -326,7 +331,7 @@ var functionCall = NATIVE_BIND ? call$5.bind(call$5) : function () {
326
331
  return call$5.apply(call$5, arguments);
327
332
  };
328
333
 
329
- var global$5 = global$b;
334
+ var globalThis$5 = globalThis_1;
330
335
  var isCallable$b = isCallable$d;
331
336
 
332
337
  var aFunction = function (argument) {
@@ -334,7 +339,7 @@ var aFunction = function (argument) {
334
339
  };
335
340
 
336
341
  var getBuiltIn$3 = function (namespace, method) {
337
- return arguments.length < 2 ? aFunction(global$5[namespace]) : global$5[namespace] && global$5[namespace][method];
342
+ return arguments.length < 2 ? aFunction(globalThis$5[namespace]) : globalThis$5[namespace] && globalThis$5[namespace][method];
338
343
  };
339
344
 
340
345
  var uncurryThis$6 = functionUncurryThis;
@@ -673,7 +678,8 @@ var NullProtoObjectViaActiveX = function (activeXDocument) {
673
678
  activeXDocument.write(scriptTag(''));
674
679
  activeXDocument.close();
675
680
  var temp = activeXDocument.parentWindow.Object;
676
- activeXDocument = null; // avoid memory leak
681
+ // eslint-disable-next-line no-useless-assignment -- avoid memory leak
682
+ activeXDocument = null;
677
683
  return temp;
678
684
  };
679
685
 
@@ -754,10 +760,10 @@ var addToUnscopables$1 = function (key) {
754
760
 
755
761
  var iterators = {};
756
762
 
757
- var global$4 = global$b;
763
+ var globalThis$4 = globalThis_1;
758
764
  var isCallable$7 = isCallable$d;
759
765
 
760
- var WeakMap$1 = global$4.WeakMap;
766
+ var WeakMap$1 = globalThis$4.WeakMap;
761
767
 
762
768
  var weakMapBasicDetection = isCallable$7(WeakMap$1) && /native code/.test(String(WeakMap$1));
763
769
 
@@ -782,7 +788,7 @@ var createNonEnumerableProperty$4 = DESCRIPTORS$5 ? function (object, key, value
782
788
  };
783
789
 
784
790
  var NATIVE_WEAK_MAP = weakMapBasicDetection;
785
- var global$3 = global$b;
791
+ var globalThis$3 = globalThis_1;
786
792
  var isObject$3 = isObject$8;
787
793
  var createNonEnumerableProperty$3 = createNonEnumerableProperty$4;
788
794
  var hasOwn$6 = hasOwnProperty_1;
@@ -791,8 +797,8 @@ var sharedKey$1 = sharedKey$3;
791
797
  var hiddenKeys$1 = hiddenKeys$4;
792
798
 
793
799
  var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
794
- var TypeError$1 = global$3.TypeError;
795
- var WeakMap = global$3.WeakMap;
800
+ var TypeError$1 = globalThis$3.TypeError;
801
+ var WeakMap = globalThis$3.WeakMap;
796
802
  var set, get, has;
797
803
 
798
804
  var enforce = function (it) {
@@ -1085,7 +1091,7 @@ var POLYFILL = isForced$1.POLYFILL = 'P';
1085
1091
 
1086
1092
  var isForced_1 = isForced$1;
1087
1093
 
1088
- var global$2 = global$b;
1094
+ var globalThis$2 = globalThis_1;
1089
1095
  var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
1090
1096
  var createNonEnumerableProperty$2 = createNonEnumerableProperty$4;
1091
1097
  var defineBuiltIn$2 = defineBuiltIn$3;
@@ -1114,11 +1120,11 @@ var _export = function (options, source) {
1114
1120
  var STATIC = options.stat;
1115
1121
  var FORCED, target, key, targetProperty, sourceProperty, descriptor;
1116
1122
  if (GLOBAL) {
1117
- target = global$2;
1123
+ target = globalThis$2;
1118
1124
  } else if (STATIC) {
1119
- target = global$2[TARGET] || defineGlobalProperty(TARGET, {});
1125
+ target = globalThis$2[TARGET] || defineGlobalProperty(TARGET, {});
1120
1126
  } else {
1121
- target = global$2[TARGET] && global$2[TARGET].prototype;
1127
+ target = globalThis$2[TARGET] && globalThis$2[TARGET].prototype;
1122
1128
  }
1123
1129
  if (target) for (key in source) {
1124
1130
  sourceProperty = source[key];
@@ -1444,7 +1450,7 @@ var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind)
1444
1450
  var target = state.target;
1445
1451
  var index = state.index++;
1446
1452
  if (!target || index >= target.length) {
1447
- state.target = undefined;
1453
+ state.target = null;
1448
1454
  return createIterResultObject(undefined, true);
1449
1455
  }
1450
1456
  switch (state.kind) {
@@ -1512,7 +1518,7 @@ var DOMTokenListPrototype$1 = classList && classList.constructor && classList.co
1512
1518
 
1513
1519
  var domTokenListPrototype = DOMTokenListPrototype$1 === Object.prototype ? undefined : DOMTokenListPrototype$1;
1514
1520
 
1515
- var global$1 = global$b;
1521
+ var globalThis$1 = globalThis_1;
1516
1522
  var DOMIterables = domIterables;
1517
1523
  var DOMTokenListPrototype = domTokenListPrototype;
1518
1524
  var ArrayIteratorMethods = es_array_iterator;
@@ -1544,7 +1550,7 @@ var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) {
1544
1550
  };
1545
1551
 
1546
1552
  for (var COLLECTION_NAME in DOMIterables) {
1547
- handlePrototype(global$1[COLLECTION_NAME] && global$1[COLLECTION_NAME].prototype, COLLECTION_NAME);
1553
+ handlePrototype(globalThis$1[COLLECTION_NAME] && globalThis$1[COLLECTION_NAME].prototype, COLLECTION_NAME);
1548
1554
  }
1549
1555
 
1550
1556
  handlePrototype(DOMTokenListPrototype, 'DOMTokenList');
@@ -1656,6 +1662,7 @@ const IsolatedContext = ({
1656
1662
  const formGroupInstance = useRef(new FormGroup({
1657
1663
  config
1658
1664
  }));
1665
+ const formGroupContextMountRef = useRef(false);
1659
1666
  const addFormWithIndex = index => {
1660
1667
  formGroupInstance.current.createFormWithIndex({
1661
1668
  index,
@@ -1664,11 +1671,11 @@ const IsolatedContext = ({
1664
1671
  };
1665
1672
  const addForm = ({
1666
1673
  key,
1667
- formInstance
1674
+ params
1668
1675
  }) => {
1669
1676
  formGroupInstance.current.addForm({
1670
1677
  key,
1671
- formInstance
1678
+ params
1672
1679
  });
1673
1680
  };
1674
1681
  const removeForm = ({
@@ -1689,6 +1696,20 @@ const IsolatedContext = ({
1689
1696
  function submitMultipleFormsByIndex(indexes) {
1690
1697
  return formGroupInstance.current.submitMultipleFormsByIndex(indexes);
1691
1698
  }
1699
+ useEffect(() => {
1700
+ return () => {
1701
+ if (formGroupContextMountRef.current) {
1702
+ // strictMode made me do this, Beato Carlo Acutis please forgive me
1703
+ // eslint-disable-next-line react-hooks/exhaustive-deps
1704
+ formGroupInstance.current.destroy();
1705
+ }
1706
+ };
1707
+ }, []);
1708
+ useEffect(() => {
1709
+ return () => {
1710
+ formGroupContextMountRef.current = true;
1711
+ };
1712
+ }, []);
1692
1713
  return {
1693
1714
  addFormWithIndex,
1694
1715
  addForm,
@@ -1941,7 +1962,7 @@ function Form({
1941
1962
  if (mountedRef.current) return;
1942
1963
  formGroupInstance.addForm({
1943
1964
  key: schemaIndex,
1944
- formInstance: new FormCore({
1965
+ params: {
1945
1966
  schema,
1946
1967
  initialValues: initialValues || (schema === null || schema === void 0 ? void 0 : schema.initialValues),
1947
1968
  iVars: iVars || (schema === null || schema === void 0 ? void 0 : schema.iVars),
@@ -1950,7 +1971,7 @@ function Form({
1950
1971
  index: schemaIndex,
1951
1972
  mappers,
1952
1973
  config: config || formGroupInstance.config
1953
- })
1974
+ }
1954
1975
  });
1955
1976
  setMounted(true);
1956
1977
  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.16",
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.16",
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;