@bolttech/form-engine 3.0.2-beta.7 → 3.1.0-beta.2
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 +167 -161
- package/package.json +2 -2
package/index.esm.js
CHANGED
|
@@ -1468,6 +1468,73 @@ 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
|
+
|
|
1471
1538
|
// iterable DOM collections
|
|
1472
1539
|
// flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
|
|
1473
1540
|
var domIterables = {
|
|
@@ -1605,9 +1672,9 @@ var toString$3 = function (argument) {
|
|
|
1605
1672
|
return $String(argument);
|
|
1606
1673
|
};
|
|
1607
1674
|
|
|
1608
|
-
var uncurryThis$
|
|
1675
|
+
var uncurryThis$4 = functionUncurryThis;
|
|
1609
1676
|
|
|
1610
|
-
var arraySlice$1 = uncurryThis$
|
|
1677
|
+
var arraySlice$1 = uncurryThis$4([].slice);
|
|
1611
1678
|
|
|
1612
1679
|
var arraySlice = arraySlice$1;
|
|
1613
1680
|
|
|
@@ -1651,11 +1718,11 @@ var sort = function (array, comparefn) {
|
|
|
1651
1718
|
|
|
1652
1719
|
var arraySort = sort;
|
|
1653
1720
|
|
|
1654
|
-
var fails$
|
|
1721
|
+
var fails$5 = fails$h;
|
|
1655
1722
|
|
|
1656
1723
|
var arrayMethodIsStrict$1 = function (METHOD_NAME, argument) {
|
|
1657
1724
|
var method = [][METHOD_NAME];
|
|
1658
|
-
return !!method && fails$
|
|
1725
|
+
return !!method && fails$5(function () {
|
|
1659
1726
|
// eslint-disable-next-line no-useless-call -- required for testing
|
|
1660
1727
|
method.call(null, argument || function () { return 1; }, 1);
|
|
1661
1728
|
});
|
|
@@ -1677,14 +1744,14 @@ var webkit = userAgent.match(/AppleWebKit\/(\d+)\./);
|
|
|
1677
1744
|
|
|
1678
1745
|
var engineWebkitVersion = !!webkit && +webkit[1];
|
|
1679
1746
|
|
|
1680
|
-
var $$
|
|
1681
|
-
var uncurryThis$
|
|
1747
|
+
var $$2 = _export;
|
|
1748
|
+
var uncurryThis$3 = functionUncurryThis;
|
|
1682
1749
|
var aCallable = aCallable$3;
|
|
1683
|
-
var toObject
|
|
1750
|
+
var toObject = toObject$4;
|
|
1684
1751
|
var lengthOfArrayLike = lengthOfArrayLike$2;
|
|
1685
1752
|
var deletePropertyOrThrow = deletePropertyOrThrow$1;
|
|
1686
1753
|
var toString$2 = toString$3;
|
|
1687
|
-
var fails$
|
|
1754
|
+
var fails$4 = fails$h;
|
|
1688
1755
|
var internalSort = arraySort;
|
|
1689
1756
|
var arrayMethodIsStrict = arrayMethodIsStrict$1;
|
|
1690
1757
|
var FF = engineFfVersion;
|
|
@@ -1693,21 +1760,21 @@ var V8 = engineV8Version;
|
|
|
1693
1760
|
var WEBKIT = engineWebkitVersion;
|
|
1694
1761
|
|
|
1695
1762
|
var test = [];
|
|
1696
|
-
var nativeSort = uncurryThis$
|
|
1697
|
-
var push = uncurryThis$
|
|
1763
|
+
var nativeSort = uncurryThis$3(test.sort);
|
|
1764
|
+
var push = uncurryThis$3(test.push);
|
|
1698
1765
|
|
|
1699
1766
|
// IE8-
|
|
1700
|
-
var FAILS_ON_UNDEFINED = fails$
|
|
1767
|
+
var FAILS_ON_UNDEFINED = fails$4(function () {
|
|
1701
1768
|
test.sort(undefined);
|
|
1702
1769
|
});
|
|
1703
1770
|
// V8 bug
|
|
1704
|
-
var FAILS_ON_NULL = fails$
|
|
1771
|
+
var FAILS_ON_NULL = fails$4(function () {
|
|
1705
1772
|
test.sort(null);
|
|
1706
1773
|
});
|
|
1707
1774
|
// Old WebKit
|
|
1708
1775
|
var STRICT_METHOD = arrayMethodIsStrict('sort');
|
|
1709
1776
|
|
|
1710
|
-
var STABLE_SORT = !fails$
|
|
1777
|
+
var STABLE_SORT = !fails$4(function () {
|
|
1711
1778
|
// feature detection can be too slow, so check engines versions
|
|
1712
1779
|
if (V8) return V8 < 70;
|
|
1713
1780
|
if (FF && FF > 3) return;
|
|
@@ -1755,11 +1822,11 @@ var getSortCompare = function (comparefn) {
|
|
|
1755
1822
|
|
|
1756
1823
|
// `Array.prototype.sort` method
|
|
1757
1824
|
// https://tc39.es/ecma262/#sec-array.prototype.sort
|
|
1758
|
-
$$
|
|
1825
|
+
$$2({ target: 'Array', proto: true, forced: FORCED }, {
|
|
1759
1826
|
sort: function sort(comparefn) {
|
|
1760
1827
|
if (comparefn !== undefined) aCallable(comparefn);
|
|
1761
1828
|
|
|
1762
|
-
var array = toObject
|
|
1829
|
+
var array = toObject(this);
|
|
1763
1830
|
|
|
1764
1831
|
if (STABLE_SORT) return comparefn === undefined ? nativeSort(array) : nativeSort(array, comparefn);
|
|
1765
1832
|
|
|
@@ -1783,73 +1850,6 @@ $$3({ target: 'Array', proto: true, forced: FORCED }, {
|
|
|
1783
1850
|
}
|
|
1784
1851
|
});
|
|
1785
1852
|
|
|
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
|
|
@@ -2523,69 +2523,51 @@ function Form({
|
|
|
2523
2523
|
debugMode,
|
|
2524
2524
|
formGroupInstance
|
|
2525
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
|
-
|
|
2547
|
-
formInstance
|
|
2548
|
-
});
|
|
2549
|
-
let subMounted;
|
|
2550
|
-
if (onFormMount) {
|
|
2551
|
-
subMounted = formInstance.subscribeOnMount(onFormMount);
|
|
2552
|
-
}
|
|
2553
|
-
formInstance === null || formInstance === void 0 ? void 0 : formInstance.mounted();
|
|
2554
|
-
/*
|
|
2555
|
-
@TODO check if form instance is killed each time it is unmounted
|
|
2556
|
-
the management of multiple forms needs to be planned
|
|
2557
|
-
*/
|
|
2558
|
-
return () => {
|
|
2559
|
-
subMounted === null || subMounted === void 0 ? void 0 : subMounted.unsubscribe();
|
|
2560
|
-
removeForm({
|
|
2561
|
-
key: schemaIndex
|
|
2562
|
-
});
|
|
2563
|
-
};
|
|
2564
|
-
}, []);
|
|
2526
|
+
const schemaIndex = useMemo(() => index || (schema === null || schema === void 0 ? void 0 : schema.index) || 'defaultChange', [index, schema === null || schema === void 0 ? void 0 : schema.index]);
|
|
2527
|
+
const [render, setRender] = useState(false);
|
|
2528
|
+
const formInstance = useRef(new FormCore({
|
|
2529
|
+
schema: Object.assign(Object.assign({}, schema), {
|
|
2530
|
+
index: schemaIndex
|
|
2531
|
+
}),
|
|
2532
|
+
initialValues: initialValues || (schema === null || schema === void 0 ? void 0 : schema.initialValues),
|
|
2533
|
+
iVars: iVars || (schema === null || schema === void 0 ? void 0 : schema.iVars),
|
|
2534
|
+
action: action || (schema === null || schema === void 0 ? void 0 : schema.action),
|
|
2535
|
+
method: method || (schema === null || schema === void 0 ? void 0 : schema.method),
|
|
2536
|
+
index: schemaIndex,
|
|
2537
|
+
mappers,
|
|
2538
|
+
config: config || formGroupInstance.config
|
|
2539
|
+
}));
|
|
2540
|
+
if (schemaIndex === 'defaultChange' || schemaIndex === 'defaultChange-ssr') {
|
|
2541
|
+
console.warn('please, add an unique id to the form, otherwise multiple forms will break');
|
|
2542
|
+
}
|
|
2543
|
+
if (!formGroupInstance.forms.has(schemaIndex)) addForm({
|
|
2544
|
+
key: schemaIndex,
|
|
2545
|
+
formInstance: formInstance.current
|
|
2546
|
+
});
|
|
2565
2547
|
/**
|
|
2566
2548
|
* logic to transform AsFormFields onto JSON schema
|
|
2567
2549
|
* and JSON schema onto FieldWrappers, refreshes when
|
|
2568
2550
|
* the react tree changes it's children
|
|
2569
2551
|
*/
|
|
2570
|
-
|
|
2571
|
-
var _a;
|
|
2572
|
-
const
|
|
2552
|
+
const tree = useMemo(() => {
|
|
2553
|
+
var _a, _b;
|
|
2554
|
+
const parsedSchema = BuildAsFormFieldTree({
|
|
2573
2555
|
children
|
|
2574
2556
|
});
|
|
2575
|
-
|
|
2576
|
-
key:
|
|
2577
|
-
}).refreshFields(
|
|
2578
|
-
const fields = (
|
|
2579
|
-
key:
|
|
2580
|
-
})) === null ||
|
|
2557
|
+
parsedSchema && ((_a = getForm({
|
|
2558
|
+
key: schemaIndex
|
|
2559
|
+
})) === null || _a === void 0 ? void 0 : _a.refreshFields(parsedSchema));
|
|
2560
|
+
const fields = (_b = getForm({
|
|
2561
|
+
key: schemaIndex
|
|
2562
|
+
})) === null || _b === void 0 ? void 0 : _b.fields;
|
|
2581
2563
|
if (fields) {
|
|
2582
2564
|
const buildTree = BuildTree({
|
|
2583
2565
|
fields,
|
|
2584
|
-
formIndex:
|
|
2566
|
+
formIndex: schemaIndex
|
|
2585
2567
|
});
|
|
2586
|
-
|
|
2568
|
+
return buildTree;
|
|
2587
2569
|
}
|
|
2588
|
-
}, [children]);
|
|
2570
|
+
}, [children, getForm]);
|
|
2589
2571
|
/**
|
|
2590
2572
|
* iVars change tracker to update iVars onto form instance
|
|
2591
2573
|
*/
|
|
@@ -2602,6 +2584,29 @@ function Form({
|
|
|
2602
2584
|
key: schemaIndex
|
|
2603
2585
|
}).setInitialValues(initialValues);
|
|
2604
2586
|
}, [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
|
+
}, []);
|
|
2605
2610
|
/**
|
|
2606
2611
|
* hook usage to keep event bindings updated on callback functions passed as props
|
|
2607
2612
|
*/
|
|
@@ -2619,7 +2624,7 @@ function Form({
|
|
|
2619
2624
|
onFormMount,
|
|
2620
2625
|
onData,
|
|
2621
2626
|
onValid
|
|
2622
|
-
});
|
|
2627
|
+
}, [formInstance]);
|
|
2623
2628
|
/*
|
|
2624
2629
|
@TODO move this logic inside form-core, add action and method onto form element,
|
|
2625
2630
|
might need a ref of the form to collect all the form parameters when there is a
|
|
@@ -2872,40 +2877,42 @@ $({ target: 'RegExp', proto: true, forced: /./.exec !== exec }, {
|
|
|
2872
2877
|
* @returns {ReactElement}
|
|
2873
2878
|
*/
|
|
2874
2879
|
const AsFormFieldBuilder = props => {
|
|
2880
|
+
var _a;
|
|
2875
2881
|
const context = useFormGroupContext({});
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
const
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
*/
|
|
2885
|
-
useEffect(() => {
|
|
2886
|
-
var _a;
|
|
2887
|
-
if (!((_a = context.formGroupInstance) === null || _a === void 0 ? void 0 : _a.forms.has(props.formIndex))) {
|
|
2888
|
-
context.addFormWithIndex(props.formIndex);
|
|
2889
|
-
}
|
|
2890
|
-
const fieldSchema = Object.assign(Object.assign({}, props), {
|
|
2882
|
+
const [render, setRender] = useState(false);
|
|
2883
|
+
const fieldName = props.name;
|
|
2884
|
+
if (!((_a = context.formGroupInstance) === null || _a === void 0 ? void 0 : _a.forms.has(props.formIndex))) context.addFormWithIndex(props.formIndex);
|
|
2885
|
+
const formInstance = context.formGroupInstance.forms.get(props.formIndex);
|
|
2886
|
+
if (!(formInstance === null || formInstance === void 0 ? void 0 : formInstance.fields.has(fieldName))) {
|
|
2887
|
+
const fieldSchema = Object.assign(Object.assign(Object.assign({}, props), {
|
|
2888
|
+
name: fieldName
|
|
2889
|
+
}), {
|
|
2891
2890
|
component: props.mapper.componentName,
|
|
2892
2891
|
children: undefined
|
|
2893
2892
|
});
|
|
2894
|
-
const formInstance = context.formGroupInstance.forms.get(props.formIndex);
|
|
2895
2893
|
formInstance === null || formInstance === void 0 ? void 0 : formInstance.addField({
|
|
2896
2894
|
fieldSchema,
|
|
2897
2895
|
mapperElement: props.mapper
|
|
2898
2896
|
});
|
|
2899
2897
|
const field = formInstance === null || formInstance === void 0 ? void 0 : formInstance.getField({
|
|
2900
|
-
key:
|
|
2898
|
+
key: fieldName
|
|
2901
2899
|
});
|
|
2902
2900
|
if (typeof (props === null || props === void 0 ? void 0 : props.visibility) !== 'undefined' && field) {
|
|
2903
2901
|
field.visibility = props.visibility;
|
|
2904
2902
|
}
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
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
|
+
};
|
|
2909
2916
|
}, []);
|
|
2910
2917
|
/**
|
|
2911
2918
|
* expensive function to allow both external props and templating work
|
|
@@ -2913,8 +2920,7 @@ const AsFormFieldBuilder = props => {
|
|
|
2913
2920
|
*/
|
|
2914
2921
|
useEffect(() => {
|
|
2915
2922
|
var _a;
|
|
2916
|
-
|
|
2917
|
-
const field = (_a = context.formGroupInstance.forms.get(props.formIndex)) === null || _a === void 0 ? void 0 : _a.fields.get(props.name);
|
|
2923
|
+
const field = (_a = context.formGroupInstance.forms.get(props.formIndex)) === null || _a === void 0 ? void 0 : _a.fields.get(fieldName);
|
|
2918
2924
|
const fieldProps = field === null || field === void 0 ? void 0 : field.props;
|
|
2919
2925
|
if (props.props) {
|
|
2920
2926
|
Object.keys(props.props).forEach(propKey => {
|
|
@@ -2929,7 +2935,7 @@ const AsFormFieldBuilder = props => {
|
|
|
2929
2935
|
});
|
|
2930
2936
|
}
|
|
2931
2937
|
field === null || field === void 0 ? void 0 : field.propsSubject$.next(Object.assign(Object.assign({}, fieldProps), props.props));
|
|
2932
|
-
}, [props.props]);
|
|
2938
|
+
}, [props.props, fieldName]);
|
|
2933
2939
|
/**
|
|
2934
2940
|
* allows to control field selected value on each event
|
|
2935
2941
|
*/
|
|
@@ -2946,13 +2952,13 @@ const AsFormFieldBuilder = props => {
|
|
|
2946
2952
|
});
|
|
2947
2953
|
return () => sub === null || sub === void 0 ? void 0 : sub.unsubscribe();
|
|
2948
2954
|
}, [props.onSelected]);
|
|
2949
|
-
return
|
|
2955
|
+
return jsx(FieldWrapper, {
|
|
2950
2956
|
formIndex: props.formIndex,
|
|
2951
|
-
name:
|
|
2957
|
+
name: fieldName,
|
|
2952
2958
|
props: props.props,
|
|
2953
2959
|
context: !context.active ? context : null,
|
|
2954
2960
|
children: props.children && props.children
|
|
2955
|
-
})
|
|
2961
|
+
});
|
|
2956
2962
|
};
|
|
2957
2963
|
|
|
2958
2964
|
function useFormGroup({
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bolttech/form-engine",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0-beta.2",
|
|
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": "0.0
|
|
9
|
+
"@bolttech/form-engine-core": "1.0.0-beta.2",
|
|
10
10
|
"react": "18.2.0",
|
|
11
11
|
"rxjs": "7.8.1"
|
|
12
12
|
},
|