@bolttech/form-engine 3.1.0-beta.3 → 3.1.0-beta.5
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/README.md +0 -14
- package/index.esm.js +517 -509
- package/package.json +2 -2
- package/src/components/FieldWrapper/FieldWrapper.d.ts +1 -1
- package/src/components/FieldWrapper/FieldWrapper.type.d.ts +6 -2
- package/assets/asformfield-current.gif +0 -0
- package/assets/asformfield-ssr.gif +0 -0
- package/assets/form-engine-ssr.gif +0 -0
- package/assets/form-engine-without-ssr.gif +0 -0
package/README.md
CHANGED
|
@@ -2,20 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
This is an adapter to be used with the bolttech form engine. Compatible with Next.js 13 and 14 and react 18.
|
|
4
4
|
|
|
5
|
-
## SSR compatibility
|
|
6
|
-
|
|
7
|
-
Leaving behind the slowness that the old version gave us to render the form on the screen, this new version increases the speed of your project a million times,
|
|
8
|
-
adding to Form-Engine a 🚀 Blazing Fast 🚀 React feature that we can render the Form on the Server, so that it is instantly displayed to the user!
|
|
9
|
-
|
|
10
|
-
| Without SSR (Form engine v2) | With SSR (Form engine v3) |
|
|
11
|
-
|------------------------------------------------|----------------------------------------|
|
|
12
|
-
| \<Form> Component | \<Form> Component |
|
|
13
|
-
|  |  |
|
|
14
|
-
| \<AsFormField> Component | \<AsFormField> Component |
|
|
15
|
-
|  |  |
|
|
16
|
-
|
|
17
|
-
## Summary
|
|
18
|
-
|
|
19
5
|
1. [Sample](#sample)
|
|
20
6
|
2. [mappers](#mappers)
|
|
21
7
|
3. [Form Group Context](#form-group-context)
|
package/index.esm.js
CHANGED
|
@@ -1468,73 +1468,6 @@ if (DESCRIPTORS$1 && values.name !== 'values') try {
|
|
|
1468
1468
|
defineProperty$1(values, 'name', { value: 'values' });
|
|
1469
1469
|
} catch (error) { /* empty */ }
|
|
1470
1470
|
|
|
1471
|
-
var DESCRIPTORS = descriptors;
|
|
1472
|
-
var uncurryThis$5 = functionUncurryThis;
|
|
1473
|
-
var call$2 = functionCall;
|
|
1474
|
-
var fails$6 = fails$h;
|
|
1475
|
-
var objectKeys = objectKeys$2;
|
|
1476
|
-
var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
|
|
1477
|
-
var propertyIsEnumerableModule = objectPropertyIsEnumerable;
|
|
1478
|
-
var toObject$1 = toObject$4;
|
|
1479
|
-
var IndexedObject = indexedObject;
|
|
1480
|
-
|
|
1481
|
-
// eslint-disable-next-line es/no-object-assign -- safe
|
|
1482
|
-
var $assign = Object.assign;
|
|
1483
|
-
// eslint-disable-next-line es/no-object-defineproperty -- required for testing
|
|
1484
|
-
var defineProperty = Object.defineProperty;
|
|
1485
|
-
var concat = uncurryThis$5([].concat);
|
|
1486
|
-
|
|
1487
|
-
// `Object.assign` method
|
|
1488
|
-
// https://tc39.es/ecma262/#sec-object.assign
|
|
1489
|
-
var objectAssign = !$assign || fails$6(function () {
|
|
1490
|
-
// should have correct order of operations (Edge bug)
|
|
1491
|
-
if (DESCRIPTORS && $assign({ b: 1 }, $assign(defineProperty({}, 'a', {
|
|
1492
|
-
enumerable: true,
|
|
1493
|
-
get: function () {
|
|
1494
|
-
defineProperty(this, 'b', {
|
|
1495
|
-
value: 3,
|
|
1496
|
-
enumerable: false
|
|
1497
|
-
});
|
|
1498
|
-
}
|
|
1499
|
-
}), { b: 2 })).b !== 1) return true;
|
|
1500
|
-
// should work with symbols and should have deterministic property order (V8 bug)
|
|
1501
|
-
var A = {};
|
|
1502
|
-
var B = {};
|
|
1503
|
-
// eslint-disable-next-line es/no-symbol -- safe
|
|
1504
|
-
var symbol = Symbol('assign detection');
|
|
1505
|
-
var alphabet = 'abcdefghijklmnopqrst';
|
|
1506
|
-
A[symbol] = 7;
|
|
1507
|
-
alphabet.split('').forEach(function (chr) { B[chr] = chr; });
|
|
1508
|
-
return $assign({}, A)[symbol] !== 7 || objectKeys($assign({}, B)).join('') !== alphabet;
|
|
1509
|
-
}) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length`
|
|
1510
|
-
var T = toObject$1(target);
|
|
1511
|
-
var argumentsLength = arguments.length;
|
|
1512
|
-
var index = 1;
|
|
1513
|
-
var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
|
|
1514
|
-
var propertyIsEnumerable = propertyIsEnumerableModule.f;
|
|
1515
|
-
while (argumentsLength > index) {
|
|
1516
|
-
var S = IndexedObject(arguments[index++]);
|
|
1517
|
-
var keys = getOwnPropertySymbols ? concat(objectKeys(S), getOwnPropertySymbols(S)) : objectKeys(S);
|
|
1518
|
-
var length = keys.length;
|
|
1519
|
-
var j = 0;
|
|
1520
|
-
var key;
|
|
1521
|
-
while (length > j) {
|
|
1522
|
-
key = keys[j++];
|
|
1523
|
-
if (!DESCRIPTORS || call$2(propertyIsEnumerable, S, key)) T[key] = S[key];
|
|
1524
|
-
}
|
|
1525
|
-
} return T;
|
|
1526
|
-
} : $assign;
|
|
1527
|
-
|
|
1528
|
-
var $$3 = _export;
|
|
1529
|
-
var assign = objectAssign;
|
|
1530
|
-
|
|
1531
|
-
// `Object.assign` method
|
|
1532
|
-
// https://tc39.es/ecma262/#sec-object.assign
|
|
1533
|
-
// eslint-disable-next-line es/no-object-assign -- required for testing
|
|
1534
|
-
$$3({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
|
|
1535
|
-
assign: assign
|
|
1536
|
-
});
|
|
1537
|
-
|
|
1538
1471
|
// iterable DOM collections
|
|
1539
1472
|
// flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
|
|
1540
1473
|
var domIterables = {
|
|
@@ -1672,9 +1605,9 @@ var toString$3 = function (argument) {
|
|
|
1672
1605
|
return $String(argument);
|
|
1673
1606
|
};
|
|
1674
1607
|
|
|
1675
|
-
var uncurryThis$
|
|
1608
|
+
var uncurryThis$5 = functionUncurryThis;
|
|
1676
1609
|
|
|
1677
|
-
var arraySlice$1 = uncurryThis$
|
|
1610
|
+
var arraySlice$1 = uncurryThis$5([].slice);
|
|
1678
1611
|
|
|
1679
1612
|
var arraySlice = arraySlice$1;
|
|
1680
1613
|
|
|
@@ -1718,11 +1651,11 @@ var sort = function (array, comparefn) {
|
|
|
1718
1651
|
|
|
1719
1652
|
var arraySort = sort;
|
|
1720
1653
|
|
|
1721
|
-
var fails$
|
|
1654
|
+
var fails$6 = fails$h;
|
|
1722
1655
|
|
|
1723
1656
|
var arrayMethodIsStrict$1 = function (METHOD_NAME, argument) {
|
|
1724
1657
|
var method = [][METHOD_NAME];
|
|
1725
|
-
return !!method && fails$
|
|
1658
|
+
return !!method && fails$6(function () {
|
|
1726
1659
|
// eslint-disable-next-line no-useless-call -- required for testing
|
|
1727
1660
|
method.call(null, argument || function () { return 1; }, 1);
|
|
1728
1661
|
});
|
|
@@ -1744,14 +1677,14 @@ var webkit = userAgent.match(/AppleWebKit\/(\d+)\./);
|
|
|
1744
1677
|
|
|
1745
1678
|
var engineWebkitVersion = !!webkit && +webkit[1];
|
|
1746
1679
|
|
|
1747
|
-
var $$
|
|
1748
|
-
var uncurryThis$
|
|
1680
|
+
var $$3 = _export;
|
|
1681
|
+
var uncurryThis$4 = functionUncurryThis;
|
|
1749
1682
|
var aCallable = aCallable$3;
|
|
1750
|
-
var toObject = toObject$4;
|
|
1683
|
+
var toObject$1 = toObject$4;
|
|
1751
1684
|
var lengthOfArrayLike = lengthOfArrayLike$2;
|
|
1752
1685
|
var deletePropertyOrThrow = deletePropertyOrThrow$1;
|
|
1753
1686
|
var toString$2 = toString$3;
|
|
1754
|
-
var fails$
|
|
1687
|
+
var fails$5 = fails$h;
|
|
1755
1688
|
var internalSort = arraySort;
|
|
1756
1689
|
var arrayMethodIsStrict = arrayMethodIsStrict$1;
|
|
1757
1690
|
var FF = engineFfVersion;
|
|
@@ -1760,21 +1693,21 @@ var V8 = engineV8Version;
|
|
|
1760
1693
|
var WEBKIT = engineWebkitVersion;
|
|
1761
1694
|
|
|
1762
1695
|
var test = [];
|
|
1763
|
-
var nativeSort = uncurryThis$
|
|
1764
|
-
var push = uncurryThis$
|
|
1696
|
+
var nativeSort = uncurryThis$4(test.sort);
|
|
1697
|
+
var push = uncurryThis$4(test.push);
|
|
1765
1698
|
|
|
1766
1699
|
// IE8-
|
|
1767
|
-
var FAILS_ON_UNDEFINED = fails$
|
|
1700
|
+
var FAILS_ON_UNDEFINED = fails$5(function () {
|
|
1768
1701
|
test.sort(undefined);
|
|
1769
1702
|
});
|
|
1770
1703
|
// V8 bug
|
|
1771
|
-
var FAILS_ON_NULL = fails$
|
|
1704
|
+
var FAILS_ON_NULL = fails$5(function () {
|
|
1772
1705
|
test.sort(null);
|
|
1773
1706
|
});
|
|
1774
1707
|
// Old WebKit
|
|
1775
1708
|
var STRICT_METHOD = arrayMethodIsStrict('sort');
|
|
1776
1709
|
|
|
1777
|
-
var STABLE_SORT = !fails$
|
|
1710
|
+
var STABLE_SORT = !fails$5(function () {
|
|
1778
1711
|
// feature detection can be too slow, so check engines versions
|
|
1779
1712
|
if (V8) return V8 < 70;
|
|
1780
1713
|
if (FF && FF > 3) return;
|
|
@@ -1822,11 +1755,11 @@ var getSortCompare = function (comparefn) {
|
|
|
1822
1755
|
|
|
1823
1756
|
// `Array.prototype.sort` method
|
|
1824
1757
|
// https://tc39.es/ecma262/#sec-array.prototype.sort
|
|
1825
|
-
$$
|
|
1758
|
+
$$3({ target: 'Array', proto: true, forced: FORCED }, {
|
|
1826
1759
|
sort: function sort(comparefn) {
|
|
1827
1760
|
if (comparefn !== undefined) aCallable(comparefn);
|
|
1828
1761
|
|
|
1829
|
-
var array = toObject(this);
|
|
1762
|
+
var array = toObject$1(this);
|
|
1830
1763
|
|
|
1831
1764
|
if (STABLE_SORT) return comparefn === undefined ? nativeSort(array) : nativeSort(array, comparefn);
|
|
1832
1765
|
|
|
@@ -1850,6 +1783,73 @@ $$2({ target: 'Array', proto: true, forced: FORCED }, {
|
|
|
1850
1783
|
}
|
|
1851
1784
|
});
|
|
1852
1785
|
|
|
1786
|
+
var DESCRIPTORS = descriptors;
|
|
1787
|
+
var uncurryThis$3 = functionUncurryThis;
|
|
1788
|
+
var call$2 = functionCall;
|
|
1789
|
+
var fails$4 = fails$h;
|
|
1790
|
+
var objectKeys = objectKeys$2;
|
|
1791
|
+
var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols;
|
|
1792
|
+
var propertyIsEnumerableModule = objectPropertyIsEnumerable;
|
|
1793
|
+
var toObject = toObject$4;
|
|
1794
|
+
var IndexedObject = indexedObject;
|
|
1795
|
+
|
|
1796
|
+
// eslint-disable-next-line es/no-object-assign -- safe
|
|
1797
|
+
var $assign = Object.assign;
|
|
1798
|
+
// eslint-disable-next-line es/no-object-defineproperty -- required for testing
|
|
1799
|
+
var defineProperty = Object.defineProperty;
|
|
1800
|
+
var concat = uncurryThis$3([].concat);
|
|
1801
|
+
|
|
1802
|
+
// `Object.assign` method
|
|
1803
|
+
// https://tc39.es/ecma262/#sec-object.assign
|
|
1804
|
+
var objectAssign = !$assign || fails$4(function () {
|
|
1805
|
+
// should have correct order of operations (Edge bug)
|
|
1806
|
+
if (DESCRIPTORS && $assign({ b: 1 }, $assign(defineProperty({}, 'a', {
|
|
1807
|
+
enumerable: true,
|
|
1808
|
+
get: function () {
|
|
1809
|
+
defineProperty(this, 'b', {
|
|
1810
|
+
value: 3,
|
|
1811
|
+
enumerable: false
|
|
1812
|
+
});
|
|
1813
|
+
}
|
|
1814
|
+
}), { b: 2 })).b !== 1) return true;
|
|
1815
|
+
// should work with symbols and should have deterministic property order (V8 bug)
|
|
1816
|
+
var A = {};
|
|
1817
|
+
var B = {};
|
|
1818
|
+
// eslint-disable-next-line es/no-symbol -- safe
|
|
1819
|
+
var symbol = Symbol('assign detection');
|
|
1820
|
+
var alphabet = 'abcdefghijklmnopqrst';
|
|
1821
|
+
A[symbol] = 7;
|
|
1822
|
+
alphabet.split('').forEach(function (chr) { B[chr] = chr; });
|
|
1823
|
+
return $assign({}, A)[symbol] !== 7 || objectKeys($assign({}, B)).join('') !== alphabet;
|
|
1824
|
+
}) ? function assign(target, source) { // eslint-disable-line no-unused-vars -- required for `.length`
|
|
1825
|
+
var T = toObject(target);
|
|
1826
|
+
var argumentsLength = arguments.length;
|
|
1827
|
+
var index = 1;
|
|
1828
|
+
var getOwnPropertySymbols = getOwnPropertySymbolsModule.f;
|
|
1829
|
+
var propertyIsEnumerable = propertyIsEnumerableModule.f;
|
|
1830
|
+
while (argumentsLength > index) {
|
|
1831
|
+
var S = IndexedObject(arguments[index++]);
|
|
1832
|
+
var keys = getOwnPropertySymbols ? concat(objectKeys(S), getOwnPropertySymbols(S)) : objectKeys(S);
|
|
1833
|
+
var length = keys.length;
|
|
1834
|
+
var j = 0;
|
|
1835
|
+
var key;
|
|
1836
|
+
while (length > j) {
|
|
1837
|
+
key = keys[j++];
|
|
1838
|
+
if (!DESCRIPTORS || call$2(propertyIsEnumerable, S, key)) T[key] = S[key];
|
|
1839
|
+
}
|
|
1840
|
+
} return T;
|
|
1841
|
+
} : $assign;
|
|
1842
|
+
|
|
1843
|
+
var $$2 = _export;
|
|
1844
|
+
var assign = objectAssign;
|
|
1845
|
+
|
|
1846
|
+
// `Object.assign` method
|
|
1847
|
+
// https://tc39.es/ecma262/#sec-object.assign
|
|
1848
|
+
// eslint-disable-next-line es/no-object-assign -- required for testing
|
|
1849
|
+
$$2({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }, {
|
|
1850
|
+
assign: assign
|
|
1851
|
+
});
|
|
1852
|
+
|
|
1853
1853
|
var anObject$1 = anObject$6;
|
|
1854
1854
|
|
|
1855
1855
|
// `RegExp.prototype.flags` getter implementation
|
|
@@ -1987,128 +1987,309 @@ $$1({ target: 'String', proto: true, forced: !MDN_POLYFILL_BUG && !CORRECT_IS_RE
|
|
|
1987
1987
|
}
|
|
1988
1988
|
});
|
|
1989
1989
|
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
* context interface to be used isolated or with the context provider
|
|
1993
|
-
*
|
|
1994
|
-
* @param {TFormContextProvider} param context parameters
|
|
1995
|
-
* @returns {TFormContext}
|
|
1996
|
-
*/
|
|
1997
|
-
const IsolatedContext = ({
|
|
1998
|
-
debugMode: _debugMode = false,
|
|
1999
|
-
mappers,
|
|
2000
|
-
config
|
|
2001
|
-
}) => {
|
|
2002
|
-
const formGroupInstance = useRef(new FormGroup({
|
|
2003
|
-
config
|
|
2004
|
-
}));
|
|
2005
|
-
const addFormWithIndex = index => {
|
|
2006
|
-
formGroupInstance.current.createFormWithIndex({
|
|
2007
|
-
index,
|
|
2008
|
-
mappers
|
|
2009
|
-
});
|
|
2010
|
-
};
|
|
2011
|
-
const addForm = ({
|
|
2012
|
-
key,
|
|
2013
|
-
formInstance
|
|
2014
|
-
}) => {
|
|
2015
|
-
formGroupInstance.current.addForm({
|
|
2016
|
-
key,
|
|
2017
|
-
formInstance
|
|
2018
|
-
});
|
|
2019
|
-
};
|
|
2020
|
-
const removeForm = ({
|
|
2021
|
-
key
|
|
2022
|
-
}) => {
|
|
2023
|
-
formGroupInstance.current.removeForm({
|
|
2024
|
-
key
|
|
2025
|
-
});
|
|
2026
|
-
};
|
|
2027
|
-
const getForm = ({
|
|
2028
|
-
key
|
|
2029
|
-
}) => formGroupInstance.current.getForm({
|
|
2030
|
-
key
|
|
2031
|
-
});
|
|
2032
|
-
const printFormGroupInstance = () => {
|
|
2033
|
-
console.log(formGroupInstance.current.printFormGroupInstance());
|
|
2034
|
-
};
|
|
2035
|
-
function submitMultipleFormsByIndex(indexes) {
|
|
2036
|
-
return formGroupInstance.current.submitMultipleFormsByIndex(indexes);
|
|
2037
|
-
}
|
|
2038
|
-
return {
|
|
2039
|
-
addFormWithIndex,
|
|
2040
|
-
addForm,
|
|
2041
|
-
getForm,
|
|
2042
|
-
removeForm,
|
|
2043
|
-
mappers,
|
|
2044
|
-
formGroupInstance: formGroupInstance.current,
|
|
2045
|
-
printFormGroupInstance,
|
|
2046
|
-
submitMultipleFormsByIndex,
|
|
2047
|
-
debugMode: _debugMode,
|
|
2048
|
-
active: false
|
|
2049
|
-
};
|
|
2050
|
-
};
|
|
2051
|
-
/**
|
|
2052
|
-
* context provider to wrap form-engine adapter elements
|
|
2053
|
-
*
|
|
2054
|
-
* @param {PropsWithChildren<TFormContextProvider>} param context parameters
|
|
2055
|
-
* @returns {ReactElement}
|
|
2056
|
-
*/
|
|
2057
|
-
const FormGroupContextProvider = ({
|
|
2058
|
-
children,
|
|
2059
|
-
mappers,
|
|
2060
|
-
debugMode: _debugMode2 = false,
|
|
2061
|
-
config
|
|
2062
|
-
}) => {
|
|
2063
|
-
const contextValue = IsolatedContext({
|
|
2064
|
-
mappers,
|
|
2065
|
-
debugMode: _debugMode2,
|
|
2066
|
-
config
|
|
2067
|
-
});
|
|
2068
|
-
contextValue.debugMode = _debugMode2;
|
|
2069
|
-
contextValue.active = true;
|
|
2070
|
-
contextValue.config = config;
|
|
2071
|
-
return jsxs(FormGroupContext.Provider, {
|
|
2072
|
-
value: contextValue,
|
|
2073
|
-
children: [_debugMode2 && jsxs(Fragment, {
|
|
2074
|
-
children: [jsx("button", {
|
|
2075
|
-
onClick: () => console.log(contextValue.formGroupInstance),
|
|
2076
|
-
children: "printGroupInstance"
|
|
2077
|
-
}), jsx("br", {}), jsx("hr", {})]
|
|
2078
|
-
}), children]
|
|
2079
|
-
});
|
|
2080
|
-
};
|
|
2081
|
-
/**
|
|
2082
|
-
* FormGroup context hook to handle context or isolated context implementations
|
|
2083
|
-
*
|
|
2084
|
-
* @param {TFormContextProvider} props form group context parameters
|
|
2085
|
-
* @returns {TFormContext}
|
|
2086
|
-
*/
|
|
2087
|
-
const useFormGroupContext = props => {
|
|
2088
|
-
const context = useContext(FormGroupContext);
|
|
2089
|
-
if (Object.keys(context).length === 0 && props) {
|
|
2090
|
-
return IsolatedContext({
|
|
2091
|
-
debugMode: props.debugMode,
|
|
2092
|
-
mappers: props.mappers
|
|
2093
|
-
});
|
|
2094
|
-
}
|
|
2095
|
-
return context;
|
|
2096
|
-
};
|
|
1990
|
+
var fails$2 = fails$h;
|
|
1991
|
+
var global$3 = global$e;
|
|
2097
1992
|
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
1993
|
+
// babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
|
|
1994
|
+
var $RegExp$2 = global$3.RegExp;
|
|
1995
|
+
|
|
1996
|
+
var UNSUPPORTED_Y$1 = fails$2(function () {
|
|
1997
|
+
var re = $RegExp$2('a', 'y');
|
|
1998
|
+
re.lastIndex = 2;
|
|
1999
|
+
return re.exec('abcd') !== null;
|
|
2000
|
+
});
|
|
2001
|
+
|
|
2002
|
+
// UC Browser bug
|
|
2003
|
+
// https://github.com/zloirock/core-js/issues/1008
|
|
2004
|
+
var MISSED_STICKY = UNSUPPORTED_Y$1 || fails$2(function () {
|
|
2005
|
+
return !$RegExp$2('a', 'y').sticky;
|
|
2006
|
+
});
|
|
2007
|
+
|
|
2008
|
+
var BROKEN_CARET = UNSUPPORTED_Y$1 || fails$2(function () {
|
|
2009
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=773687
|
|
2010
|
+
var re = $RegExp$2('^r', 'gy');
|
|
2011
|
+
re.lastIndex = 2;
|
|
2012
|
+
return re.exec('str') !== null;
|
|
2013
|
+
});
|
|
2014
|
+
|
|
2015
|
+
var regexpStickyHelpers = {
|
|
2016
|
+
BROKEN_CARET: BROKEN_CARET,
|
|
2017
|
+
MISSED_STICKY: MISSED_STICKY,
|
|
2018
|
+
UNSUPPORTED_Y: UNSUPPORTED_Y$1
|
|
2019
|
+
};
|
|
2020
|
+
|
|
2021
|
+
var fails$1 = fails$h;
|
|
2022
|
+
var global$2 = global$e;
|
|
2023
|
+
|
|
2024
|
+
// babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError
|
|
2025
|
+
var $RegExp$1 = global$2.RegExp;
|
|
2026
|
+
|
|
2027
|
+
var regexpUnsupportedDotAll = fails$1(function () {
|
|
2028
|
+
var re = $RegExp$1('.', 's');
|
|
2029
|
+
return !(re.dotAll && re.test('\n') && re.flags === 's');
|
|
2030
|
+
});
|
|
2031
|
+
|
|
2032
|
+
var fails = fails$h;
|
|
2033
|
+
var global$1 = global$e;
|
|
2034
|
+
|
|
2035
|
+
// babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError
|
|
2036
|
+
var $RegExp = global$1.RegExp;
|
|
2037
|
+
|
|
2038
|
+
var regexpUnsupportedNcg = fails(function () {
|
|
2039
|
+
var re = $RegExp('(?<a>b)', 'g');
|
|
2040
|
+
return re.exec('b').groups.a !== 'b' ||
|
|
2041
|
+
'b'.replace(re, '$<a>c') !== 'bc';
|
|
2042
|
+
});
|
|
2043
|
+
|
|
2044
|
+
/* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */
|
|
2045
|
+
/* eslint-disable regexp/no-useless-quantifier -- testing */
|
|
2046
|
+
var call = functionCall;
|
|
2047
|
+
var uncurryThis = functionUncurryThis;
|
|
2048
|
+
var toString = toString$3;
|
|
2049
|
+
var regexpFlags = regexpFlags$1;
|
|
2050
|
+
var stickyHelpers = regexpStickyHelpers;
|
|
2051
|
+
var shared = shared$4;
|
|
2052
|
+
var create = objectCreate;
|
|
2053
|
+
var getInternalState = internalState.get;
|
|
2054
|
+
var UNSUPPORTED_DOT_ALL = regexpUnsupportedDotAll;
|
|
2055
|
+
var UNSUPPORTED_NCG = regexpUnsupportedNcg;
|
|
2056
|
+
|
|
2057
|
+
var nativeReplace = shared('native-string-replace', String.prototype.replace);
|
|
2058
|
+
var nativeExec = RegExp.prototype.exec;
|
|
2059
|
+
var patchedExec = nativeExec;
|
|
2060
|
+
var charAt = uncurryThis(''.charAt);
|
|
2061
|
+
var indexOf = uncurryThis(''.indexOf);
|
|
2062
|
+
var replace = uncurryThis(''.replace);
|
|
2063
|
+
var stringSlice = uncurryThis(''.slice);
|
|
2064
|
+
|
|
2065
|
+
var UPDATES_LAST_INDEX_WRONG = (function () {
|
|
2066
|
+
var re1 = /a/;
|
|
2067
|
+
var re2 = /b*/g;
|
|
2068
|
+
call(nativeExec, re1, 'a');
|
|
2069
|
+
call(nativeExec, re2, 'a');
|
|
2070
|
+
return re1.lastIndex !== 0 || re2.lastIndex !== 0;
|
|
2071
|
+
})();
|
|
2072
|
+
|
|
2073
|
+
var UNSUPPORTED_Y = stickyHelpers.BROKEN_CARET;
|
|
2074
|
+
|
|
2075
|
+
// nonparticipating capturing group, copied from es5-shim's String#split patch.
|
|
2076
|
+
var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
|
|
2077
|
+
|
|
2078
|
+
var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG;
|
|
2079
|
+
|
|
2080
|
+
if (PATCH) {
|
|
2081
|
+
patchedExec = function exec(string) {
|
|
2082
|
+
var re = this;
|
|
2083
|
+
var state = getInternalState(re);
|
|
2084
|
+
var str = toString(string);
|
|
2085
|
+
var raw = state.raw;
|
|
2086
|
+
var result, reCopy, lastIndex, match, i, object, group;
|
|
2087
|
+
|
|
2088
|
+
if (raw) {
|
|
2089
|
+
raw.lastIndex = re.lastIndex;
|
|
2090
|
+
result = call(patchedExec, raw, str);
|
|
2091
|
+
re.lastIndex = raw.lastIndex;
|
|
2092
|
+
return result;
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2095
|
+
var groups = state.groups;
|
|
2096
|
+
var sticky = UNSUPPORTED_Y && re.sticky;
|
|
2097
|
+
var flags = call(regexpFlags, re);
|
|
2098
|
+
var source = re.source;
|
|
2099
|
+
var charsAdded = 0;
|
|
2100
|
+
var strCopy = str;
|
|
2101
|
+
|
|
2102
|
+
if (sticky) {
|
|
2103
|
+
flags = replace(flags, 'y', '');
|
|
2104
|
+
if (indexOf(flags, 'g') === -1) {
|
|
2105
|
+
flags += 'g';
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2108
|
+
strCopy = stringSlice(str, re.lastIndex);
|
|
2109
|
+
// Support anchored sticky behavior.
|
|
2110
|
+
if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt(str, re.lastIndex - 1) !== '\n')) {
|
|
2111
|
+
source = '(?: ' + source + ')';
|
|
2112
|
+
strCopy = ' ' + strCopy;
|
|
2113
|
+
charsAdded++;
|
|
2114
|
+
}
|
|
2115
|
+
// ^(? + rx + ) is needed, in combination with some str slicing, to
|
|
2116
|
+
// simulate the 'y' flag.
|
|
2117
|
+
reCopy = new RegExp('^(?:' + source + ')', flags);
|
|
2118
|
+
}
|
|
2119
|
+
|
|
2120
|
+
if (NPCG_INCLUDED) {
|
|
2121
|
+
reCopy = new RegExp('^' + source + '$(?!\\s)', flags);
|
|
2122
|
+
}
|
|
2123
|
+
if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
|
|
2124
|
+
|
|
2125
|
+
match = call(nativeExec, sticky ? reCopy : re, strCopy);
|
|
2126
|
+
|
|
2127
|
+
if (sticky) {
|
|
2128
|
+
if (match) {
|
|
2129
|
+
match.input = stringSlice(match.input, charsAdded);
|
|
2130
|
+
match[0] = stringSlice(match[0], charsAdded);
|
|
2131
|
+
match.index = re.lastIndex;
|
|
2132
|
+
re.lastIndex += match[0].length;
|
|
2133
|
+
} else re.lastIndex = 0;
|
|
2134
|
+
} else if (UPDATES_LAST_INDEX_WRONG && match) {
|
|
2135
|
+
re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
|
|
2136
|
+
}
|
|
2137
|
+
if (NPCG_INCLUDED && match && match.length > 1) {
|
|
2138
|
+
// Fix browsers whose `exec` methods don't consistently return `undefined`
|
|
2139
|
+
// for NPCG, like IE8. NOTE: This doesn't work for /(.?)?/
|
|
2140
|
+
call(nativeReplace, match[0], reCopy, function () {
|
|
2141
|
+
for (i = 1; i < arguments.length - 2; i++) {
|
|
2142
|
+
if (arguments[i] === undefined) match[i] = undefined;
|
|
2143
|
+
}
|
|
2144
|
+
});
|
|
2145
|
+
}
|
|
2146
|
+
|
|
2147
|
+
if (match && groups) {
|
|
2148
|
+
match.groups = object = create(null);
|
|
2149
|
+
for (i = 0; i < groups.length; i++) {
|
|
2150
|
+
group = groups[i];
|
|
2151
|
+
object[group[0]] = match[group[1]];
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
|
|
2155
|
+
return match;
|
|
2156
|
+
};
|
|
2157
|
+
}
|
|
2158
|
+
|
|
2159
|
+
var regexpExec = patchedExec;
|
|
2160
|
+
|
|
2161
|
+
var $ = _export;
|
|
2162
|
+
var exec = regexpExec;
|
|
2163
|
+
|
|
2164
|
+
// `RegExp.prototype.exec` method
|
|
2165
|
+
// https://tc39.es/ecma262/#sec-regexp.prototype.exec
|
|
2166
|
+
$({ target: 'RegExp', proto: true, forced: /./.exec !== exec }, {
|
|
2167
|
+
exec: exec
|
|
2168
|
+
});
|
|
2169
|
+
|
|
2170
|
+
const FormGroupContext = /*#__PURE__*/createContext({});
|
|
2171
|
+
/**
|
|
2172
|
+
* context interface to be used isolated or with the context provider
|
|
2173
|
+
*
|
|
2174
|
+
* @param {TFormContextProvider} param context parameters
|
|
2175
|
+
* @returns {TFormContext}
|
|
2176
|
+
*/
|
|
2177
|
+
const IsolatedContext = ({
|
|
2178
|
+
debugMode: _debugMode = false,
|
|
2179
|
+
mappers,
|
|
2180
|
+
config
|
|
2181
|
+
}) => {
|
|
2182
|
+
const formGroupInstance = useRef(new FormGroup({
|
|
2183
|
+
config
|
|
2184
|
+
}));
|
|
2185
|
+
const addFormWithIndex = index => {
|
|
2186
|
+
formGroupInstance.current.createFormWithIndex({
|
|
2187
|
+
index,
|
|
2188
|
+
mappers
|
|
2189
|
+
});
|
|
2190
|
+
};
|
|
2191
|
+
const addForm = ({
|
|
2192
|
+
key,
|
|
2193
|
+
formInstance
|
|
2194
|
+
}) => {
|
|
2195
|
+
formGroupInstance.current.addForm({
|
|
2196
|
+
key,
|
|
2197
|
+
formInstance
|
|
2198
|
+
});
|
|
2199
|
+
};
|
|
2200
|
+
const removeForm = ({
|
|
2201
|
+
key
|
|
2202
|
+
}) => {
|
|
2203
|
+
formGroupInstance.current.removeForm({
|
|
2204
|
+
key
|
|
2205
|
+
});
|
|
2206
|
+
};
|
|
2207
|
+
const getForm = ({
|
|
2208
|
+
key
|
|
2209
|
+
}) => formGroupInstance.current.getForm({
|
|
2210
|
+
key
|
|
2211
|
+
});
|
|
2212
|
+
const printFormGroupInstance = () => {
|
|
2213
|
+
console.log(formGroupInstance.current.printFormGroupInstance());
|
|
2214
|
+
};
|
|
2215
|
+
function submitMultipleFormsByIndex(indexes) {
|
|
2216
|
+
return formGroupInstance.current.submitMultipleFormsByIndex(indexes);
|
|
2217
|
+
}
|
|
2218
|
+
return {
|
|
2219
|
+
addFormWithIndex,
|
|
2220
|
+
addForm,
|
|
2221
|
+
getForm,
|
|
2222
|
+
removeForm,
|
|
2223
|
+
mappers,
|
|
2224
|
+
formGroupInstance: formGroupInstance.current,
|
|
2225
|
+
printFormGroupInstance,
|
|
2226
|
+
submitMultipleFormsByIndex,
|
|
2227
|
+
debugMode: _debugMode,
|
|
2228
|
+
active: false
|
|
2229
|
+
};
|
|
2230
|
+
};
|
|
2231
|
+
/**
|
|
2232
|
+
* context provider to wrap form-engine adapter elements
|
|
2233
|
+
*
|
|
2234
|
+
* @param {PropsWithChildren<TFormContextProvider>} param context parameters
|
|
2235
|
+
* @returns {ReactElement}
|
|
2236
|
+
*/
|
|
2237
|
+
const FormGroupContextProvider = ({
|
|
2238
|
+
children,
|
|
2239
|
+
mappers,
|
|
2240
|
+
debugMode: _debugMode2 = false,
|
|
2241
|
+
config
|
|
2242
|
+
}) => {
|
|
2243
|
+
const contextValue = IsolatedContext({
|
|
2244
|
+
mappers,
|
|
2245
|
+
debugMode: _debugMode2,
|
|
2246
|
+
config
|
|
2247
|
+
});
|
|
2248
|
+
contextValue.debugMode = _debugMode2;
|
|
2249
|
+
contextValue.active = true;
|
|
2250
|
+
contextValue.config = config;
|
|
2251
|
+
return jsxs(FormGroupContext.Provider, {
|
|
2252
|
+
value: contextValue,
|
|
2253
|
+
children: [_debugMode2 && jsxs(Fragment, {
|
|
2254
|
+
children: [jsx("button", {
|
|
2255
|
+
onClick: () => console.log(contextValue.formGroupInstance),
|
|
2256
|
+
children: "printGroupInstance"
|
|
2257
|
+
}), jsx("br", {}), jsx("hr", {})]
|
|
2258
|
+
}), children]
|
|
2259
|
+
});
|
|
2260
|
+
};
|
|
2261
|
+
/**
|
|
2262
|
+
* FormGroup context hook to handle context or isolated context implementations
|
|
2263
|
+
*
|
|
2264
|
+
* @param {TFormContextProvider} props form group context parameters
|
|
2265
|
+
* @returns {TFormContext}
|
|
2266
|
+
*/
|
|
2267
|
+
const useFormGroupContext = props => {
|
|
2268
|
+
const context = useContext(FormGroupContext);
|
|
2269
|
+
if (Object.keys(context).length === 0 && props) {
|
|
2270
|
+
return IsolatedContext({
|
|
2271
|
+
debugMode: props.debugMode,
|
|
2272
|
+
mappers: props.mappers
|
|
2273
|
+
});
|
|
2274
|
+
}
|
|
2275
|
+
return context;
|
|
2276
|
+
};
|
|
2277
|
+
|
|
2278
|
+
/**
|
|
2279
|
+
* Renders the React element defined on the mappers configuration
|
|
2280
|
+
*
|
|
2281
|
+
* @param param component props, field instance and children to render
|
|
2282
|
+
* @returns
|
|
2283
|
+
*/
|
|
2284
|
+
const FieldWrapperComponentRender = ({
|
|
2285
|
+
props,
|
|
2286
|
+
fieldInstance,
|
|
2287
|
+
children,
|
|
2288
|
+
mapper
|
|
2108
2289
|
}) => {
|
|
2109
2290
|
var _a, _b, _c;
|
|
2110
|
-
const Component = (_a = fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.mapper) === null || _a === void 0 ? void 0 : _a.component;
|
|
2111
|
-
const Asynccomponent = (_b = fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.mapper) === null || _b === void 0 ? void 0 : _b.asynccomponent;
|
|
2291
|
+
const Component = (mapper === null || mapper === void 0 ? void 0 : mapper.component) || ((_a = fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.mapper) === null || _a === void 0 ? void 0 : _a.component);
|
|
2292
|
+
const Asynccomponent = (mapper === null || mapper === void 0 ? void 0 : mapper.asynccomponent) || ((_b = fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.mapper) === null || _b === void 0 ? void 0 : _b.asynccomponent);
|
|
2112
2293
|
if (Component) return jsx(Component, Object.assign({}, props, {
|
|
2113
2294
|
children: children && children
|
|
2114
2295
|
}));
|
|
@@ -2133,7 +2314,10 @@ const FieldWrapper = ({
|
|
|
2133
2314
|
formIndex,
|
|
2134
2315
|
children,
|
|
2135
2316
|
props,
|
|
2136
|
-
context
|
|
2317
|
+
context,
|
|
2318
|
+
mounted,
|
|
2319
|
+
mapper,
|
|
2320
|
+
visibility
|
|
2137
2321
|
}) => {
|
|
2138
2322
|
var _a, _b, _c;
|
|
2139
2323
|
const localContext = useFormGroupContext({});
|
|
@@ -2144,20 +2328,45 @@ const FieldWrapper = ({
|
|
|
2144
2328
|
formGroupInstance,
|
|
2145
2329
|
debugMode
|
|
2146
2330
|
} = useMemo(() => context ? context : localContext, [context, localContext]);
|
|
2147
|
-
const fieldInstance =
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2331
|
+
const fieldInstance = useMemo(() => {
|
|
2332
|
+
var _a;
|
|
2333
|
+
return (_a = formGroupInstance.getForm({
|
|
2334
|
+
key: formIndex
|
|
2335
|
+
})) === null || _a === void 0 ? void 0 : _a.getField({
|
|
2336
|
+
key: name
|
|
2337
|
+
});
|
|
2338
|
+
}, [mounted]);
|
|
2339
|
+
const filteredProps = useMemo(() => {
|
|
2340
|
+
let returnProps = {};
|
|
2341
|
+
if (props) {
|
|
2342
|
+
returnProps = Object.assign({}, props);
|
|
2343
|
+
Object.keys(returnProps).forEach(propKey => {
|
|
2344
|
+
if (typeof (returnProps === null || returnProps === void 0 ? void 0 : returnProps[propKey]) === 'string' &&
|
|
2345
|
+
/**
|
|
2346
|
+
* need to check linting on build, this needs to be casted in order to build..
|
|
2347
|
+
*/
|
|
2348
|
+
/\$/.test(returnProps === null || returnProps === void 0 ? void 0 : returnProps[propKey])) {
|
|
2349
|
+
delete returnProps[propKey];
|
|
2350
|
+
}
|
|
2351
|
+
});
|
|
2352
|
+
if (mounted) {
|
|
2353
|
+
fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.propsSubject$.next(Object.assign(Object.assign({}, fieldInstance.props), returnProps));
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
return returnProps;
|
|
2357
|
+
}, [props]);
|
|
2358
|
+
const [valueState, setValueState] = useState((fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.stateValue) || {
|
|
2359
|
+
[((_a = mapper === null || mapper === void 0 ? void 0 : mapper.events) === null || _a === void 0 ? void 0 : _a.setValue) || 'value']: ''
|
|
2360
|
+
});
|
|
2153
2361
|
const [state, setState] = useState({
|
|
2154
|
-
visibility:
|
|
2155
|
-
props: (fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.props) ||
|
|
2362
|
+
visibility: visibility,
|
|
2363
|
+
props: (fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.props) || filteredProps
|
|
2156
2364
|
});
|
|
2157
2365
|
/**
|
|
2158
2366
|
* handles the mounting and unmounting logic onto the field instance
|
|
2159
2367
|
*/
|
|
2160
2368
|
useEffect(() => {
|
|
2369
|
+
if (!mounted) return;
|
|
2161
2370
|
fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.mountField({
|
|
2162
2371
|
valueSubscription: value => {
|
|
2163
2372
|
setValueState(value);
|
|
@@ -2175,33 +2384,34 @@ const FieldWrapper = ({
|
|
|
2175
2384
|
}
|
|
2176
2385
|
});
|
|
2177
2386
|
return () => {
|
|
2178
|
-
fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.destroyField();
|
|
2387
|
+
mounted && (fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.destroyField());
|
|
2179
2388
|
};
|
|
2180
|
-
}, []);
|
|
2389
|
+
}, [mounted]);
|
|
2181
2390
|
/**
|
|
2182
2391
|
* handles the value change onto the field instance
|
|
2183
2392
|
*/
|
|
2184
2393
|
const handleChange = useCallback(event => {
|
|
2394
|
+
if (!mounted) return;
|
|
2185
2395
|
fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.emitValue({
|
|
2186
2396
|
value: event,
|
|
2187
2397
|
event: 'ON_FIELD_CHANGE'
|
|
2188
2398
|
});
|
|
2189
|
-
}, []);
|
|
2399
|
+
}, [mounted]);
|
|
2190
2400
|
/**
|
|
2191
2401
|
* handles the event emission onto the field instance
|
|
2192
2402
|
*/
|
|
2193
2403
|
const handleEvent = useCallback(event => {
|
|
2404
|
+
if (!mounted) return;
|
|
2194
2405
|
fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.emitEvents({
|
|
2195
2406
|
event
|
|
2196
2407
|
});
|
|
2197
|
-
}, []);
|
|
2408
|
+
}, [mounted]);
|
|
2198
2409
|
/**
|
|
2199
2410
|
* handles the mappers configuration to bind the event submission callback
|
|
2200
2411
|
* to the corresponding prop defined on the mappers
|
|
2201
2412
|
*/
|
|
2202
2413
|
const mapProps = useMemo(() => {
|
|
2203
|
-
|
|
2204
|
-
const events = (_a = fieldInstance === null || fieldInstance === void 0 ? void 0 : fieldInstance.mapper) === null || _a === void 0 ? void 0 : _a.events;
|
|
2414
|
+
const events = mapper === null || mapper === void 0 ? void 0 : mapper.events;
|
|
2205
2415
|
const props = {};
|
|
2206
2416
|
if (events === null || events === void 0 ? void 0 : events.onBlur) props[events.onBlur] = () => handleEvent('ON_FIELD_BLUR');
|
|
2207
2417
|
if (events === null || events === void 0 ? void 0 : events.getValue) props[events.getValue] = handleChange;
|
|
@@ -2211,8 +2421,8 @@ const FieldWrapper = ({
|
|
|
2211
2421
|
if (events === null || events === void 0 ? void 0 : events.onKeyUp) props[events.onKeyUp] = () => handleEvent('ON_FIELD_KEYUP');
|
|
2212
2422
|
if (events === null || events === void 0 ? void 0 : events.onKeyDown) props[events.onKeyDown] = () => handleEvent('ON_FIELD_KEYDOWN');
|
|
2213
2423
|
return props;
|
|
2214
|
-
}, []);
|
|
2215
|
-
return
|
|
2424
|
+
}, [mounted]);
|
|
2425
|
+
return state.visibility ? jsxs(Fragment, {
|
|
2216
2426
|
children: [debugMode && jsxs("div", {
|
|
2217
2427
|
style: {
|
|
2218
2428
|
width: '100%',
|
|
@@ -2241,6 +2451,7 @@ const FieldWrapper = ({
|
|
|
2241
2451
|
}), jsx(FieldWrapperComponentRender, {
|
|
2242
2452
|
props: Object.assign(Object.assign(Object.assign(Object.assign({}, mapProps), state.props), state.errors), valueState),
|
|
2243
2453
|
fieldInstance: fieldInstance,
|
|
2454
|
+
mapper: mapper,
|
|
2244
2455
|
children: children ? children : ((_c = state === null || state === void 0 ? void 0 : state.props) === null || _c === void 0 ? void 0 : _c.children) ? state === null || state === void 0 ? void 0 : state.props.children : null
|
|
2245
2456
|
})]
|
|
2246
2457
|
}) : jsx(Fragment, {});
|
|
@@ -2260,7 +2471,7 @@ const BuildTree = ({
|
|
|
2260
2471
|
prevPath,
|
|
2261
2472
|
formIndex
|
|
2262
2473
|
}) => {
|
|
2263
|
-
|
|
2474
|
+
const tree = Array.from(fields).sort(([, field], [, field2]) => {
|
|
2264
2475
|
var _a, _b;
|
|
2265
2476
|
return (((_a = field.originalSchema) === null || _a === void 0 ? void 0 : _a.order) || 0) - (((_b = field2.originalSchema) === null || _b === void 0 ? void 0 : _b.order) || 0);
|
|
2266
2477
|
}).filter(([, value]) => {
|
|
@@ -2276,9 +2487,12 @@ const BuildTree = ({
|
|
|
2276
2487
|
return jsx(FieldWrapper, {
|
|
2277
2488
|
name: fieldName,
|
|
2278
2489
|
formIndex: formIndex,
|
|
2490
|
+
visibility: value.visibility,
|
|
2279
2491
|
children: lenght > 0 ? children : null
|
|
2280
2492
|
}, fieldName);
|
|
2281
2493
|
});
|
|
2494
|
+
console.log(tree);
|
|
2495
|
+
return tree;
|
|
2282
2496
|
};
|
|
2283
2497
|
/**
|
|
2284
2498
|
* function to transform AsFormField elements onto a JSON schema
|
|
@@ -2521,53 +2735,71 @@ function Form({
|
|
|
2521
2735
|
getForm,
|
|
2522
2736
|
mappers,
|
|
2523
2737
|
debugMode,
|
|
2524
|
-
formGroupInstance
|
|
2525
|
-
} = useFormGroupContext({});
|
|
2526
|
-
const
|
|
2527
|
-
const
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2738
|
+
formGroupInstance
|
|
2739
|
+
} = useFormGroupContext({});
|
|
2740
|
+
const [tree, setTree] = useState();
|
|
2741
|
+
const schemaIndex = useMemo(() => index || (schema === null || schema === void 0 ? void 0 : schema.index) || 'defaultChange', [index, schema]);
|
|
2742
|
+
/**
|
|
2743
|
+
* logic to initialize the form instance and it's removal
|
|
2744
|
+
*/
|
|
2745
|
+
useEffect(() => {
|
|
2746
|
+
if (schemaIndex === 'defaultChange') {
|
|
2747
|
+
console.warn('please, add an unique id to the form, otherwise multiple forms will break');
|
|
2748
|
+
}
|
|
2749
|
+
const formInstance = new FormCore({
|
|
2750
|
+
schema,
|
|
2751
|
+
initialValues: initialValues || (schema === null || schema === void 0 ? void 0 : schema.initialValues),
|
|
2752
|
+
iVars: iVars || (schema === null || schema === void 0 ? void 0 : schema.iVars),
|
|
2753
|
+
action: action || (schema === null || schema === void 0 ? void 0 : schema.action),
|
|
2754
|
+
method: method || (schema === null || schema === void 0 ? void 0 : schema.method),
|
|
2755
|
+
index: schemaIndex,
|
|
2756
|
+
mappers,
|
|
2757
|
+
config: config || formGroupInstance.config
|
|
2758
|
+
});
|
|
2759
|
+
addForm({
|
|
2760
|
+
key: schemaIndex,
|
|
2761
|
+
formInstance
|
|
2762
|
+
});
|
|
2763
|
+
let subMounted;
|
|
2764
|
+
if (onFormMount) {
|
|
2765
|
+
subMounted = formInstance.subscribeOnMount(onFormMount);
|
|
2766
|
+
}
|
|
2767
|
+
formInstance === null || formInstance === void 0 ? void 0 : formInstance.mounted();
|
|
2768
|
+
/*
|
|
2769
|
+
@TODO check if form instance is killed each time it is unmounted
|
|
2770
|
+
the management of multiple forms needs to be planned
|
|
2771
|
+
*/
|
|
2772
|
+
return () => {
|
|
2773
|
+
subMounted === null || subMounted === void 0 ? void 0 : subMounted.unsubscribe();
|
|
2774
|
+
removeForm({
|
|
2775
|
+
key: schemaIndex
|
|
2776
|
+
});
|
|
2777
|
+
};
|
|
2778
|
+
}, []);
|
|
2547
2779
|
/**
|
|
2548
2780
|
* logic to transform AsFormFields onto JSON schema
|
|
2549
2781
|
* and JSON schema onto FieldWrappers, refreshes when
|
|
2550
2782
|
* the react tree changes it's children
|
|
2551
2783
|
*/
|
|
2552
|
-
|
|
2553
|
-
var _a
|
|
2554
|
-
const
|
|
2784
|
+
useEffect(() => {
|
|
2785
|
+
var _a;
|
|
2786
|
+
const schema = BuildAsFormFieldTree({
|
|
2555
2787
|
children
|
|
2556
2788
|
});
|
|
2557
|
-
|
|
2558
|
-
key:
|
|
2559
|
-
})
|
|
2560
|
-
const fields = (
|
|
2561
|
-
key:
|
|
2562
|
-
})) === null ||
|
|
2789
|
+
schema && getForm({
|
|
2790
|
+
key: index
|
|
2791
|
+
}).refreshFields(schema);
|
|
2792
|
+
const fields = (_a = getForm({
|
|
2793
|
+
key: index
|
|
2794
|
+
})) === null || _a === void 0 ? void 0 : _a.fields;
|
|
2563
2795
|
if (fields) {
|
|
2564
2796
|
const buildTree = BuildTree({
|
|
2565
2797
|
fields,
|
|
2566
|
-
formIndex:
|
|
2798
|
+
formIndex: index
|
|
2567
2799
|
});
|
|
2568
|
-
|
|
2800
|
+
setTree(buildTree);
|
|
2569
2801
|
}
|
|
2570
|
-
}, [children
|
|
2802
|
+
}, [children]);
|
|
2571
2803
|
/**
|
|
2572
2804
|
* iVars change tracker to update iVars onto form instance
|
|
2573
2805
|
*/
|
|
@@ -2584,29 +2816,6 @@ function Form({
|
|
|
2584
2816
|
key: schemaIndex
|
|
2585
2817
|
}).setInitialValues(initialValues);
|
|
2586
2818
|
}, [initialValues]);
|
|
2587
|
-
/**
|
|
2588
|
-
* logic to mount and manage form removal
|
|
2589
|
-
*/
|
|
2590
|
-
useEffect(() => {
|
|
2591
|
-
setRender(true);
|
|
2592
|
-
let subMounted;
|
|
2593
|
-
if (onFormMount) {
|
|
2594
|
-
subMounted = formInstance.current.subscribeOnMount(onFormMount);
|
|
2595
|
-
}
|
|
2596
|
-
formInstance.current.mounted();
|
|
2597
|
-
/*
|
|
2598
|
-
@TODO check if form instance is killed each time it is unmounted
|
|
2599
|
-
the management of multiple forms needs to be planned
|
|
2600
|
-
*/
|
|
2601
|
-
return () => {
|
|
2602
|
-
subMounted === null || subMounted === void 0 ? void 0 : subMounted.unsubscribe();
|
|
2603
|
-
if (render) {
|
|
2604
|
-
removeForm({
|
|
2605
|
-
key: schemaIndex
|
|
2606
|
-
});
|
|
2607
|
-
}
|
|
2608
|
-
};
|
|
2609
|
-
}, []);
|
|
2610
2819
|
/**
|
|
2611
2820
|
* hook usage to keep event bindings updated on callback functions passed as props
|
|
2612
2821
|
*/
|
|
@@ -2624,7 +2833,7 @@ function Form({
|
|
|
2624
2833
|
onFormMount,
|
|
2625
2834
|
onData,
|
|
2626
2835
|
onValid
|
|
2627
|
-
}
|
|
2836
|
+
});
|
|
2628
2837
|
/*
|
|
2629
2838
|
@TODO move this logic inside form-core, add action and method onto form element,
|
|
2630
2839
|
might need a ref of the form to collect all the form parameters when there is a
|
|
@@ -2671,7 +2880,13 @@ function Form({
|
|
|
2671
2880
|
}), jsx("br", {}), jsx("hr", {})]
|
|
2672
2881
|
}), jsx("form", {
|
|
2673
2882
|
onSubmit: handleSubmit,
|
|
2674
|
-
children:
|
|
2883
|
+
children: BuildTree({
|
|
2884
|
+
fields: FormCore.serializeStructure({
|
|
2885
|
+
mappers: mappers || [],
|
|
2886
|
+
struct: schema === null || schema === void 0 ? void 0 : schema.components
|
|
2887
|
+
}),
|
|
2888
|
+
formIndex: schemaIndex
|
|
2889
|
+
})
|
|
2675
2890
|
})]
|
|
2676
2891
|
});
|
|
2677
2892
|
}
|
|
@@ -2689,186 +2904,6 @@ const AsFormField = props => {
|
|
|
2689
2904
|
return props.children;
|
|
2690
2905
|
};
|
|
2691
2906
|
|
|
2692
|
-
var fails$2 = fails$h;
|
|
2693
|
-
var global$3 = global$e;
|
|
2694
|
-
|
|
2695
|
-
// babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
|
|
2696
|
-
var $RegExp$2 = global$3.RegExp;
|
|
2697
|
-
|
|
2698
|
-
var UNSUPPORTED_Y$1 = fails$2(function () {
|
|
2699
|
-
var re = $RegExp$2('a', 'y');
|
|
2700
|
-
re.lastIndex = 2;
|
|
2701
|
-
return re.exec('abcd') !== null;
|
|
2702
|
-
});
|
|
2703
|
-
|
|
2704
|
-
// UC Browser bug
|
|
2705
|
-
// https://github.com/zloirock/core-js/issues/1008
|
|
2706
|
-
var MISSED_STICKY = UNSUPPORTED_Y$1 || fails$2(function () {
|
|
2707
|
-
return !$RegExp$2('a', 'y').sticky;
|
|
2708
|
-
});
|
|
2709
|
-
|
|
2710
|
-
var BROKEN_CARET = UNSUPPORTED_Y$1 || fails$2(function () {
|
|
2711
|
-
// https://bugzilla.mozilla.org/show_bug.cgi?id=773687
|
|
2712
|
-
var re = $RegExp$2('^r', 'gy');
|
|
2713
|
-
re.lastIndex = 2;
|
|
2714
|
-
return re.exec('str') !== null;
|
|
2715
|
-
});
|
|
2716
|
-
|
|
2717
|
-
var regexpStickyHelpers = {
|
|
2718
|
-
BROKEN_CARET: BROKEN_CARET,
|
|
2719
|
-
MISSED_STICKY: MISSED_STICKY,
|
|
2720
|
-
UNSUPPORTED_Y: UNSUPPORTED_Y$1
|
|
2721
|
-
};
|
|
2722
|
-
|
|
2723
|
-
var fails$1 = fails$h;
|
|
2724
|
-
var global$2 = global$e;
|
|
2725
|
-
|
|
2726
|
-
// babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError
|
|
2727
|
-
var $RegExp$1 = global$2.RegExp;
|
|
2728
|
-
|
|
2729
|
-
var regexpUnsupportedDotAll = fails$1(function () {
|
|
2730
|
-
var re = $RegExp$1('.', 's');
|
|
2731
|
-
return !(re.dotAll && re.test('\n') && re.flags === 's');
|
|
2732
|
-
});
|
|
2733
|
-
|
|
2734
|
-
var fails = fails$h;
|
|
2735
|
-
var global$1 = global$e;
|
|
2736
|
-
|
|
2737
|
-
// babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError
|
|
2738
|
-
var $RegExp = global$1.RegExp;
|
|
2739
|
-
|
|
2740
|
-
var regexpUnsupportedNcg = fails(function () {
|
|
2741
|
-
var re = $RegExp('(?<a>b)', 'g');
|
|
2742
|
-
return re.exec('b').groups.a !== 'b' ||
|
|
2743
|
-
'b'.replace(re, '$<a>c') !== 'bc';
|
|
2744
|
-
});
|
|
2745
|
-
|
|
2746
|
-
/* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */
|
|
2747
|
-
/* eslint-disable regexp/no-useless-quantifier -- testing */
|
|
2748
|
-
var call = functionCall;
|
|
2749
|
-
var uncurryThis = functionUncurryThis;
|
|
2750
|
-
var toString = toString$3;
|
|
2751
|
-
var regexpFlags = regexpFlags$1;
|
|
2752
|
-
var stickyHelpers = regexpStickyHelpers;
|
|
2753
|
-
var shared = shared$4;
|
|
2754
|
-
var create = objectCreate;
|
|
2755
|
-
var getInternalState = internalState.get;
|
|
2756
|
-
var UNSUPPORTED_DOT_ALL = regexpUnsupportedDotAll;
|
|
2757
|
-
var UNSUPPORTED_NCG = regexpUnsupportedNcg;
|
|
2758
|
-
|
|
2759
|
-
var nativeReplace = shared('native-string-replace', String.prototype.replace);
|
|
2760
|
-
var nativeExec = RegExp.prototype.exec;
|
|
2761
|
-
var patchedExec = nativeExec;
|
|
2762
|
-
var charAt = uncurryThis(''.charAt);
|
|
2763
|
-
var indexOf = uncurryThis(''.indexOf);
|
|
2764
|
-
var replace = uncurryThis(''.replace);
|
|
2765
|
-
var stringSlice = uncurryThis(''.slice);
|
|
2766
|
-
|
|
2767
|
-
var UPDATES_LAST_INDEX_WRONG = (function () {
|
|
2768
|
-
var re1 = /a/;
|
|
2769
|
-
var re2 = /b*/g;
|
|
2770
|
-
call(nativeExec, re1, 'a');
|
|
2771
|
-
call(nativeExec, re2, 'a');
|
|
2772
|
-
return re1.lastIndex !== 0 || re2.lastIndex !== 0;
|
|
2773
|
-
})();
|
|
2774
|
-
|
|
2775
|
-
var UNSUPPORTED_Y = stickyHelpers.BROKEN_CARET;
|
|
2776
|
-
|
|
2777
|
-
// nonparticipating capturing group, copied from es5-shim's String#split patch.
|
|
2778
|
-
var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
|
|
2779
|
-
|
|
2780
|
-
var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG;
|
|
2781
|
-
|
|
2782
|
-
if (PATCH) {
|
|
2783
|
-
patchedExec = function exec(string) {
|
|
2784
|
-
var re = this;
|
|
2785
|
-
var state = getInternalState(re);
|
|
2786
|
-
var str = toString(string);
|
|
2787
|
-
var raw = state.raw;
|
|
2788
|
-
var result, reCopy, lastIndex, match, i, object, group;
|
|
2789
|
-
|
|
2790
|
-
if (raw) {
|
|
2791
|
-
raw.lastIndex = re.lastIndex;
|
|
2792
|
-
result = call(patchedExec, raw, str);
|
|
2793
|
-
re.lastIndex = raw.lastIndex;
|
|
2794
|
-
return result;
|
|
2795
|
-
}
|
|
2796
|
-
|
|
2797
|
-
var groups = state.groups;
|
|
2798
|
-
var sticky = UNSUPPORTED_Y && re.sticky;
|
|
2799
|
-
var flags = call(regexpFlags, re);
|
|
2800
|
-
var source = re.source;
|
|
2801
|
-
var charsAdded = 0;
|
|
2802
|
-
var strCopy = str;
|
|
2803
|
-
|
|
2804
|
-
if (sticky) {
|
|
2805
|
-
flags = replace(flags, 'y', '');
|
|
2806
|
-
if (indexOf(flags, 'g') === -1) {
|
|
2807
|
-
flags += 'g';
|
|
2808
|
-
}
|
|
2809
|
-
|
|
2810
|
-
strCopy = stringSlice(str, re.lastIndex);
|
|
2811
|
-
// Support anchored sticky behavior.
|
|
2812
|
-
if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt(str, re.lastIndex - 1) !== '\n')) {
|
|
2813
|
-
source = '(?: ' + source + ')';
|
|
2814
|
-
strCopy = ' ' + strCopy;
|
|
2815
|
-
charsAdded++;
|
|
2816
|
-
}
|
|
2817
|
-
// ^(? + rx + ) is needed, in combination with some str slicing, to
|
|
2818
|
-
// simulate the 'y' flag.
|
|
2819
|
-
reCopy = new RegExp('^(?:' + source + ')', flags);
|
|
2820
|
-
}
|
|
2821
|
-
|
|
2822
|
-
if (NPCG_INCLUDED) {
|
|
2823
|
-
reCopy = new RegExp('^' + source + '$(?!\\s)', flags);
|
|
2824
|
-
}
|
|
2825
|
-
if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
|
|
2826
|
-
|
|
2827
|
-
match = call(nativeExec, sticky ? reCopy : re, strCopy);
|
|
2828
|
-
|
|
2829
|
-
if (sticky) {
|
|
2830
|
-
if (match) {
|
|
2831
|
-
match.input = stringSlice(match.input, charsAdded);
|
|
2832
|
-
match[0] = stringSlice(match[0], charsAdded);
|
|
2833
|
-
match.index = re.lastIndex;
|
|
2834
|
-
re.lastIndex += match[0].length;
|
|
2835
|
-
} else re.lastIndex = 0;
|
|
2836
|
-
} else if (UPDATES_LAST_INDEX_WRONG && match) {
|
|
2837
|
-
re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
|
|
2838
|
-
}
|
|
2839
|
-
if (NPCG_INCLUDED && match && match.length > 1) {
|
|
2840
|
-
// Fix browsers whose `exec` methods don't consistently return `undefined`
|
|
2841
|
-
// for NPCG, like IE8. NOTE: This doesn't work for /(.?)?/
|
|
2842
|
-
call(nativeReplace, match[0], reCopy, function () {
|
|
2843
|
-
for (i = 1; i < arguments.length - 2; i++) {
|
|
2844
|
-
if (arguments[i] === undefined) match[i] = undefined;
|
|
2845
|
-
}
|
|
2846
|
-
});
|
|
2847
|
-
}
|
|
2848
|
-
|
|
2849
|
-
if (match && groups) {
|
|
2850
|
-
match.groups = object = create(null);
|
|
2851
|
-
for (i = 0; i < groups.length; i++) {
|
|
2852
|
-
group = groups[i];
|
|
2853
|
-
object[group[0]] = match[group[1]];
|
|
2854
|
-
}
|
|
2855
|
-
}
|
|
2856
|
-
|
|
2857
|
-
return match;
|
|
2858
|
-
};
|
|
2859
|
-
}
|
|
2860
|
-
|
|
2861
|
-
var regexpExec = patchedExec;
|
|
2862
|
-
|
|
2863
|
-
var $ = _export;
|
|
2864
|
-
var exec = regexpExec;
|
|
2865
|
-
|
|
2866
|
-
// `RegExp.prototype.exec` method
|
|
2867
|
-
// https://tc39.es/ecma262/#sec-regexp.prototype.exec
|
|
2868
|
-
$({ target: 'RegExp', proto: true, forced: /./.exec !== exec }, {
|
|
2869
|
-
exec: exec
|
|
2870
|
-
});
|
|
2871
|
-
|
|
2872
2907
|
/**
|
|
2873
2908
|
* Component Wrapper to render form fields without the Form component, gets additional formId and mapper since
|
|
2874
2909
|
* it won't rely on them and needs to be manually declared
|
|
@@ -2877,65 +2912,35 @@ $({ target: 'RegExp', proto: true, forced: /./.exec !== exec }, {
|
|
|
2877
2912
|
* @returns {ReactElement}
|
|
2878
2913
|
*/
|
|
2879
2914
|
const AsFormFieldBuilder = props => {
|
|
2880
|
-
var _a;
|
|
2881
2915
|
const context = useFormGroupContext({});
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
const
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2916
|
+
/**
|
|
2917
|
+
* state to track the field instance creation process
|
|
2918
|
+
*/
|
|
2919
|
+
const [mounted, setMounted] = useState(false);
|
|
2920
|
+
/**
|
|
2921
|
+
* initializer to create or add a form instance to the formGroup by it's formId
|
|
2922
|
+
* and add the field to the form instance
|
|
2923
|
+
* Also has the logic to remove it once this element is removed
|
|
2924
|
+
*/
|
|
2925
|
+
useEffect(() => {
|
|
2926
|
+
var _a;
|
|
2927
|
+
if (!((_a = context.formGroupInstance) === null || _a === void 0 ? void 0 : _a.forms.has(props.formIndex))) {
|
|
2928
|
+
context.addFormWithIndex(props.formIndex);
|
|
2929
|
+
}
|
|
2930
|
+
const fieldSchema = Object.assign(Object.assign({}, props), {
|
|
2890
2931
|
component: props.mapper.componentName,
|
|
2891
2932
|
children: undefined
|
|
2892
2933
|
});
|
|
2934
|
+
const formInstance = context.formGroupInstance.forms.get(props.formIndex);
|
|
2893
2935
|
formInstance === null || formInstance === void 0 ? void 0 : formInstance.addField({
|
|
2894
2936
|
fieldSchema,
|
|
2895
2937
|
mapperElement: props.mapper
|
|
2896
2938
|
});
|
|
2897
|
-
|
|
2898
|
-
|
|
2939
|
+
setMounted(true);
|
|
2940
|
+
return () => formInstance === null || formInstance === void 0 ? void 0 : formInstance.removeField({
|
|
2941
|
+
key: props.name
|
|
2899
2942
|
});
|
|
2900
|
-
if (typeof (props === null || props === void 0 ? void 0 : props.visibility) !== 'undefined' && field) {
|
|
2901
|
-
field.visibility = props.visibility;
|
|
2902
|
-
}
|
|
2903
|
-
}
|
|
2904
|
-
/**
|
|
2905
|
-
* initializer to create or add a form instance to the formGroup by it's formId
|
|
2906
|
-
* and add the field to the form instance
|
|
2907
|
-
* Also has the logic to remove it once this element is removed
|
|
2908
|
-
*/
|
|
2909
|
-
useEffect(() => {
|
|
2910
|
-
setRender(true);
|
|
2911
|
-
return () => {
|
|
2912
|
-
if (render) formInstance === null || formInstance === void 0 ? void 0 : formInstance.removeField({
|
|
2913
|
-
key: fieldName
|
|
2914
|
-
});
|
|
2915
|
-
};
|
|
2916
2943
|
}, []);
|
|
2917
|
-
/**
|
|
2918
|
-
* expensive function to allow both external props and templating work
|
|
2919
|
-
* evaluate if templating will be done onto form-engine or not
|
|
2920
|
-
*/
|
|
2921
|
-
useEffect(() => {
|
|
2922
|
-
var _a;
|
|
2923
|
-
const field = (_a = context.formGroupInstance.forms.get(props.formIndex)) === null || _a === void 0 ? void 0 : _a.fields.get(fieldName);
|
|
2924
|
-
const fieldProps = field === null || field === void 0 ? void 0 : field.props;
|
|
2925
|
-
if (props.props) {
|
|
2926
|
-
Object.keys(props.props).forEach(propKey => {
|
|
2927
|
-
var _a, _b;
|
|
2928
|
-
if (typeof ((_a = props.props) === null || _a === void 0 ? void 0 : _a[propKey]) === 'string' &&
|
|
2929
|
-
/**
|
|
2930
|
-
* need to check linting on build, this needs to be casted in order to build..
|
|
2931
|
-
*/
|
|
2932
|
-
/\$/.test((_b = props.props) === null || _b === void 0 ? void 0 : _b[propKey])) {
|
|
2933
|
-
delete props.props[propKey];
|
|
2934
|
-
}
|
|
2935
|
-
});
|
|
2936
|
-
}
|
|
2937
|
-
field === null || field === void 0 ? void 0 : field.propsSubject$.next(Object.assign(Object.assign({}, fieldProps), props.props));
|
|
2938
|
-
}, [props.props, fieldName]);
|
|
2939
2944
|
/**
|
|
2940
2945
|
* allows to control field selected value on each event
|
|
2941
2946
|
*/
|
|
@@ -2954,9 +2959,12 @@ const AsFormFieldBuilder = props => {
|
|
|
2954
2959
|
}, [props.onSelected]);
|
|
2955
2960
|
return jsx(FieldWrapper, {
|
|
2956
2961
|
formIndex: props.formIndex,
|
|
2957
|
-
name:
|
|
2962
|
+
name: props.name,
|
|
2958
2963
|
props: props.props,
|
|
2959
2964
|
context: !context.active ? context : null,
|
|
2965
|
+
mounted: mounted,
|
|
2966
|
+
mapper: props.mapper,
|
|
2967
|
+
visibility: props.visibility || true,
|
|
2960
2968
|
children: props.children && props.children
|
|
2961
2969
|
});
|
|
2962
2970
|
};
|
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.5",
|
|
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.5",
|
|
10
10
|
"react": "18.2.0",
|
|
11
11
|
"rxjs": "7.8.1"
|
|
12
12
|
},
|
|
@@ -7,5 +7,5 @@ import { TFieldWrapperProps } from './FieldWrapper.type';
|
|
|
7
7
|
* @param {TFieldWrapperProps} param FieldWrapper params
|
|
8
8
|
* @returns {ReactElement}
|
|
9
9
|
*/
|
|
10
|
-
declare const FieldWrapper: ({ name, formIndex, children, props, context, }: TFieldWrapperProps) => ReactElement;
|
|
10
|
+
declare const FieldWrapper: ({ name, formIndex, children, props, context, mounted, mapper, visibility, }: TFieldWrapperProps) => ReactElement;
|
|
11
11
|
export default FieldWrapper;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PropsWithChildren } from 'react';
|
|
1
|
+
import { ElementType, PropsWithChildren } from 'react';
|
|
2
2
|
import { TFieldWrapper } from '../../types';
|
|
3
3
|
import { TFormContext } from '../../context/FormGroupContext';
|
|
4
|
-
import { FormField } from '@bolttech/form-engine-core';
|
|
4
|
+
import { FormField, TMapper } from '@bolttech/form-engine-core';
|
|
5
5
|
/**
|
|
6
6
|
* Represents the props for a field wrapper component, including children.
|
|
7
7
|
*
|
|
@@ -13,6 +13,9 @@ import { FormField } from '@bolttech/form-engine-core';
|
|
|
13
13
|
type TFieldWrapperProps = PropsWithChildren<TFieldWrapper & {
|
|
14
14
|
props?: Record<string, unknown>;
|
|
15
15
|
context?: TFormContext | null;
|
|
16
|
+
mounted?: boolean;
|
|
17
|
+
mapper?: TMapper<ElementType>;
|
|
18
|
+
visibility?: boolean;
|
|
16
19
|
}>;
|
|
17
20
|
/**
|
|
18
21
|
* Represents the props for rendering a field wrapper component, including children.
|
|
@@ -24,5 +27,6 @@ type TFieldWrapperProps = PropsWithChildren<TFieldWrapper & {
|
|
|
24
27
|
type TFieldWrapperComponentRenderProps = PropsWithChildren<{
|
|
25
28
|
props: Record<string, unknown>;
|
|
26
29
|
fieldInstance?: FormField;
|
|
30
|
+
mapper?: TMapper<ElementType>;
|
|
27
31
|
}>;
|
|
28
32
|
export type { TFieldWrapperProps, TFieldWrapperComponentRenderProps };
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|