@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.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,11 @@ 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
+ let effects = [];
1519
+ const runAsync = cb => {
1520
+ if (effects) effects.push(cb);else cb();
1521
+ };
1522
+ const state = formState.getControlState(data, form, options, runAsync);
1515
1523
  useEffect(() => {
1516
1524
  if (!(options != null && options.formState)) {
1517
1525
  return () => formState.cleanup();
@@ -1597,7 +1605,7 @@ function RenderForm({
1597
1605
  textClass: textClass,
1598
1606
  getChildState(child, parent) {
1599
1607
  var _ref3;
1600
- return formState.getControlState((_ref3 = parent != null ? parent : state.dataNode) != null ? _ref3 : data, child, childOptions);
1608
+ return formState.getControlState((_ref3 = parent != null ? parent : state.dataNode) != null ? _ref3 : data, child, childOptions, runAsync);
1601
1609
  },
1602
1610
  runExpression: (scope, expr, returnResult) => {
1603
1611
  if (expr != null && expr.type) {
@@ -1605,7 +1613,8 @@ function RenderForm({
1605
1613
  scope,
1606
1614
  dataNode: data,
1607
1615
  schemaInterface,
1608
- returnResult
1616
+ returnResult,
1617
+ runAsync
1609
1618
  });
1610
1619
  }
1611
1620
  }
@@ -1616,9 +1625,17 @@ function RenderForm({
1616
1625
  style: state.layoutStyle
1617
1626
  });
1618
1627
  const renderedControl = renderer.renderLayout((_options$adjustLayout = options.adjustLayout == null ? void 0 : options.adjustLayout(dataContext, layoutProps)) != null ? _options$adjustLayout : layoutProps);
1619
- return renderer.renderVisibility(_extends({
1628
+ const rendered = renderer.renderVisibility(_extends({
1620
1629
  visibility
1621
1630
  }, renderedControl));
1631
+ useEffect(() => {
1632
+ if (effects) {
1633
+ const toRun = effects;
1634
+ effects = undefined;
1635
+ toRun.forEach(cb => cb());
1636
+ }
1637
+ }, [effects]);
1638
+ return rendered;
1622
1639
  } finally {
1623
1640
  _effect();
1624
1641
  }