@react-typed-forms/schemas 16.0.1 → 16.0.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/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 ? doneSet : doneSet = new Set();
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
- return toControlAndSchema(x, dataSchema != null ? dataSchema : parentSchema, entry, dontRegister);
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,10 @@ function RenderForm(_ref) {
1610
1612
  }),
1611
1613
  formState = _useState[0],
1612
1614
  setFormState = _useState[1];
1613
- var state = formState.getControlState(data, form, options);
1615
+ var effects = [];
1616
+ var state = formState.getControlState(data, form, options, function (cb) {
1617
+ return effects.push(cb);
1618
+ });
1614
1619
  react.useEffect(function () {
1615
1620
  if (!(options != null && options.formState)) {
1616
1621
  return function () {
@@ -1697,7 +1702,9 @@ function RenderForm(_ref) {
1697
1702
  textClass: textClass,
1698
1703
  getChildState: function getChildState(child, parent) {
1699
1704
  var _ref4;
1700
- return formState.getControlState((_ref4 = parent != null ? parent : state.dataNode) != null ? _ref4 : data, child, childOptions);
1705
+ return formState.getControlState((_ref4 = parent != null ? parent : state.dataNode) != null ? _ref4 : data, child, childOptions, function (cb) {
1706
+ return effects.push(cb);
1707
+ });
1701
1708
  },
1702
1709
  runExpression: function runExpression(scope, expr, returnResult) {
1703
1710
  if (expr != null && expr.type) {
@@ -1705,7 +1712,10 @@ function RenderForm(_ref) {
1705
1712
  scope: scope,
1706
1713
  dataNode: data,
1707
1714
  schemaInterface: schemaInterface,
1708
- returnResult: returnResult
1715
+ returnResult: returnResult,
1716
+ runAsync: function runAsync(cb) {
1717
+ return effects.push(cb);
1718
+ }
1709
1719
  });
1710
1720
  }
1711
1721
  }
@@ -1716,9 +1726,15 @@ function RenderForm(_ref) {
1716
1726
  style: state.layoutStyle
1717
1727
  });
1718
1728
  var renderedControl = renderer.renderLayout((_options$adjustLayout = options.adjustLayout == null ? void 0 : options.adjustLayout(dataContext, layoutProps)) != null ? _options$adjustLayout : layoutProps);
1719
- return renderer.renderVisibility(_extends({
1729
+ var rendered = renderer.renderVisibility(_extends({
1720
1730
  visibility: visibility
1721
1731
  }, renderedControl));
1732
+ react.useEffect(function () {
1733
+ effects.forEach(function (cb) {
1734
+ return cb();
1735
+ });
1736
+ }, [effects]);
1737
+ return rendered;
1722
1738
  } finally {
1723
1739
  _effect();
1724
1740
  }