@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.js CHANGED
@@ -32,9 +32,10 @@ function _objectWithoutPropertiesLoose(r, e) {
32
32
  * @returns The record with default values applied.
33
33
  */
34
34
  function applyDefaultValues(v, fields, doneSet) {
35
+ var _doneSet;
35
36
  if (!v) return defaultValueForFields(fields);
36
37
  if (doneSet && doneSet.has(v)) return v;
37
- doneSet != null ? doneSet : doneSet = new Set();
38
+ (_doneSet = doneSet) != null ? _doneSet : doneSet = new Set();
38
39
  doneSet.add(v);
39
40
  const applyValue = fields.filter(x => isCompoundField(x) || !(x.field in v));
40
41
  if (!applyValue.length) return v;
@@ -311,7 +312,10 @@ function addMissingControlsForSchema(schema, controls, warning) {
311
312
  children: [],
312
313
  parent: parentNode
313
314
  };
314
- entry.children = (_c$children$map = (_c$children = c.children) == null ? void 0 : _c$children.map(x => toControlAndSchema(x, dataSchema != null ? dataSchema : parentSchema, entry, dontRegister))) != null ? _c$children$map : [];
315
+ entry.children = (_c$children$map = (_c$children = c.children) == null ? void 0 : _c$children.map(x => {
316
+ var _dataSchema;
317
+ return toControlAndSchema(x, (_dataSchema = dataSchema) != null ? _dataSchema : parentSchema, entry, dontRegister);
318
+ })) != null ? _c$children$map : [];
315
319
  if (!dontRegister && c.id) controlMap[c.id] = entry;
316
320
  if (dataSchema) {
317
321
  addSchemaMapEntry(dataSchema.id, entry);
@@ -1511,7 +1515,8 @@ function RenderForm({
1511
1515
  var _options$formState;
1512
1516
  return (_options$formState = options == null ? void 0 : options.formState) != null ? _options$formState : createFormState(schemaInterface);
1513
1517
  });
1514
- const state = formState.getControlState(data, form, options);
1518
+ const effects = [];
1519
+ const state = formState.getControlState(data, form, options, cb => effects.push(cb));
1515
1520
  useEffect(() => {
1516
1521
  if (!(options != null && options.formState)) {
1517
1522
  return () => formState.cleanup();
@@ -1597,7 +1602,7 @@ function RenderForm({
1597
1602
  textClass: textClass,
1598
1603
  getChildState(child, parent) {
1599
1604
  var _ref3;
1600
- return formState.getControlState((_ref3 = parent != null ? parent : state.dataNode) != null ? _ref3 : data, child, childOptions);
1605
+ return formState.getControlState((_ref3 = parent != null ? parent : state.dataNode) != null ? _ref3 : data, child, childOptions, cb => effects.push(cb));
1601
1606
  },
1602
1607
  runExpression: (scope, expr, returnResult) => {
1603
1608
  if (expr != null && expr.type) {
@@ -1605,7 +1610,8 @@ function RenderForm({
1605
1610
  scope,
1606
1611
  dataNode: data,
1607
1612
  schemaInterface,
1608
- returnResult
1613
+ returnResult,
1614
+ runAsync: cb => effects.push(cb)
1609
1615
  });
1610
1616
  }
1611
1617
  }
@@ -1616,9 +1622,13 @@ function RenderForm({
1616
1622
  style: state.layoutStyle
1617
1623
  });
1618
1624
  const renderedControl = renderer.renderLayout((_options$adjustLayout = options.adjustLayout == null ? void 0 : options.adjustLayout(dataContext, layoutProps)) != null ? _options$adjustLayout : layoutProps);
1619
- return renderer.renderVisibility(_extends({
1625
+ const rendered = renderer.renderVisibility(_extends({
1620
1626
  visibility
1621
1627
  }, renderedControl));
1628
+ useEffect(() => {
1629
+ effects.forEach(cb => cb());
1630
+ }, [effects]);
1631
+ return rendered;
1622
1632
  } finally {
1623
1633
  _effect();
1624
1634
  }