@react-typed-forms/schemas 16.0.1 → 16.0.3
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/lib/index.cjs +23 -6
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +23 -6
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
- package/src/RenderForm.tsx +21 -2
package/lib/index.cjs
CHANGED
|
@@ -35,9 +35,10 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
35
35
|
* @returns The record with default values applied.
|
|
36
36
|
*/
|
|
37
37
|
function applyDefaultValues(v, fields, doneSet) {
|
|
38
|
+
var _doneSet;
|
|
38
39
|
if (!v) return defaultValueForFields(fields);
|
|
39
40
|
if (doneSet && doneSet.has(v)) return v;
|
|
40
|
-
doneSet != null ?
|
|
41
|
+
(_doneSet = doneSet) != null ? _doneSet : doneSet = new Set();
|
|
41
42
|
doneSet.add(v);
|
|
42
43
|
var applyValue = fields.filter(function (x) {
|
|
43
44
|
return formsCore.isCompoundField(x) || !(x.field in v);
|
|
@@ -333,7 +334,8 @@ function addMissingControlsForSchema(schema, controls, warning) {
|
|
|
333
334
|
parent: parentNode
|
|
334
335
|
};
|
|
335
336
|
entry.children = (_c$children$map = (_c$children = c.children) == null ? void 0 : _c$children.map(function (x) {
|
|
336
|
-
|
|
337
|
+
var _dataSchema;
|
|
338
|
+
return toControlAndSchema(x, (_dataSchema = dataSchema) != null ? _dataSchema : parentSchema, entry, dontRegister);
|
|
337
339
|
})) != null ? _c$children$map : [];
|
|
338
340
|
if (!dontRegister && c.id) controlMap[c.id] = entry;
|
|
339
341
|
if (dataSchema) {
|
|
@@ -1610,7 +1612,11 @@ function RenderForm(_ref) {
|
|
|
1610
1612
|
}),
|
|
1611
1613
|
formState = _useState[0],
|
|
1612
1614
|
setFormState = _useState[1];
|
|
1613
|
-
var
|
|
1615
|
+
var effects = [];
|
|
1616
|
+
var runAsync = function runAsync(cb) {
|
|
1617
|
+
if (effects) effects.push(cb);else cb();
|
|
1618
|
+
};
|
|
1619
|
+
var state = formState.getControlState(data, form, options, runAsync);
|
|
1614
1620
|
react.useEffect(function () {
|
|
1615
1621
|
if (!(options != null && options.formState)) {
|
|
1616
1622
|
return function () {
|
|
@@ -1697,7 +1703,7 @@ function RenderForm(_ref) {
|
|
|
1697
1703
|
textClass: textClass,
|
|
1698
1704
|
getChildState: function getChildState(child, parent) {
|
|
1699
1705
|
var _ref4;
|
|
1700
|
-
return formState.getControlState((_ref4 = parent != null ? parent : state.dataNode) != null ? _ref4 : data, child, childOptions);
|
|
1706
|
+
return formState.getControlState((_ref4 = parent != null ? parent : state.dataNode) != null ? _ref4 : data, child, childOptions, runAsync);
|
|
1701
1707
|
},
|
|
1702
1708
|
runExpression: function runExpression(scope, expr, returnResult) {
|
|
1703
1709
|
if (expr != null && expr.type) {
|
|
@@ -1705,7 +1711,8 @@ function RenderForm(_ref) {
|
|
|
1705
1711
|
scope: scope,
|
|
1706
1712
|
dataNode: data,
|
|
1707
1713
|
schemaInterface: schemaInterface,
|
|
1708
|
-
returnResult: returnResult
|
|
1714
|
+
returnResult: returnResult,
|
|
1715
|
+
runAsync: runAsync
|
|
1709
1716
|
});
|
|
1710
1717
|
}
|
|
1711
1718
|
}
|
|
@@ -1716,9 +1723,19 @@ function RenderForm(_ref) {
|
|
|
1716
1723
|
style: state.layoutStyle
|
|
1717
1724
|
});
|
|
1718
1725
|
var renderedControl = renderer.renderLayout((_options$adjustLayout = options.adjustLayout == null ? void 0 : options.adjustLayout(dataContext, layoutProps)) != null ? _options$adjustLayout : layoutProps);
|
|
1719
|
-
|
|
1726
|
+
var rendered = renderer.renderVisibility(_extends({
|
|
1720
1727
|
visibility: visibility
|
|
1721
1728
|
}, renderedControl));
|
|
1729
|
+
react.useEffect(function () {
|
|
1730
|
+
if (effects) {
|
|
1731
|
+
var toRun = effects;
|
|
1732
|
+
effects = undefined;
|
|
1733
|
+
toRun.forEach(function (cb) {
|
|
1734
|
+
return cb();
|
|
1735
|
+
});
|
|
1736
|
+
}
|
|
1737
|
+
}, [effects]);
|
|
1738
|
+
return rendered;
|
|
1722
1739
|
} finally {
|
|
1723
1740
|
_effect();
|
|
1724
1741
|
}
|