@astroapps/forms-core 1.0.1 → 1.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
@@ -1147,7 +1147,8 @@ const jsonataEval = (expr, {
1147
1147
  scope,
1148
1148
  returnResult,
1149
1149
  dataNode,
1150
- variables
1150
+ variables,
1151
+ runAsync
1151
1152
  }) => {
1152
1153
  const path = getJsonPath(dataNode);
1153
1154
  const pathString = jsonPathString(path, x => `#$i[${x}]`);
@@ -1174,7 +1175,8 @@ const jsonataEval = (expr, {
1174
1175
  // console.log(parsedJsonata.fields.fullExpr.value, evalResult, bindings);
1175
1176
  collectChanges(effect.collectUsage, () => returnResult(evalResult));
1176
1177
  }
1177
- createAsyncEffect(runJsonata, scope);
1178
+ const asyncEffect = createAsyncEffect(runJsonata, scope);
1179
+ runAsync(() => asyncEffect.start());
1178
1180
  };
1179
1181
  const uuidEval = (_, ctx) => {
1180
1182
  ctx.returnResult(v4());
@@ -1197,11 +1199,12 @@ const jsonataValidator = (validation, context) => {
1197
1199
  dataNode: context.parentData,
1198
1200
  returnResult: v => {
1199
1201
  trackControlChange(context.data.control, ControlChange.Validate);
1200
- console.log("Setting jsonata error", v);
1202
+ // console.log("Setting jsonata error", v);
1201
1203
  context.data.control.setError("jsonata", v == null ? void 0 : v.toString());
1202
1204
  },
1203
1205
  schemaInterface: context.schemaInterface,
1204
- variables: context.formContext.fields.variables
1206
+ variables: context.formContext.fields.variables,
1207
+ runAsync: context.runAsync
1205
1208
  });
1206
1209
  };
1207
1210
  const lengthValidator = (lv, context) => {
@@ -1277,7 +1280,7 @@ function createValidators(def, context) {
1277
1280
  });
1278
1281
  }
1279
1282
  }
1280
- function setupValidation(controlImpl, definition, dataNode, schemaInterface, parent, formNode) {
1283
+ function setupValidation(controlImpl, definition, dataNode, schemaInterface, parent, formNode, runAsync) {
1281
1284
  const validationEnabled = createScopedComputed(controlImpl, () => !definition.hidden);
1282
1285
  const validatorsScope = createCleanupScope();
1283
1286
  createEffect(() => {
@@ -1296,7 +1299,8 @@ function setupValidation(controlImpl, definition, dataNode, schemaInterface, par
1296
1299
  addCleanup(cleanup) {
1297
1300
  validatorsScope.addCleanup(cleanup);
1298
1301
  },
1299
- formContext: controlImpl
1302
+ formContext: controlImpl,
1303
+ runAsync
1300
1304
  });
1301
1305
  createEffect(() => {
1302
1306
  if (!validationEnabled.value) return undefined;
@@ -1328,7 +1332,7 @@ function createFormState(schemaInterface, evaluators = defaultEvaluators) {
1328
1332
  // console.log("Cleanup form state");
1329
1333
  controlStates.cleanup();
1330
1334
  },
1331
- getControlState(parent, formNode, context) {
1335
+ getControlState(parent, formNode, context, runAsync) {
1332
1336
  var _context$stateKey;
1333
1337
  const stateId = parent.id + "$" + formNode.id + ((_context$stateKey = context.stateKey) != null ? _context$stateKey : "");
1334
1338
  const controlImpl = controlStates.fields[stateId];
@@ -1343,7 +1347,8 @@ function createFormState(schemaInterface, evaluators = defaultEvaluators) {
1343
1347
  scope,
1344
1348
  dataNode: parent,
1345
1349
  variables: controlImpl.fields.variables,
1346
- schemaInterface
1350
+ schemaInterface,
1351
+ runAsync
1347
1352
  });
1348
1353
  return true;
1349
1354
  }
@@ -1424,7 +1429,7 @@ function createFormState(schemaInterface, evaluators = defaultEvaluators) {
1424
1429
  dn.control.disabled = disabled.value;
1425
1430
  }
1426
1431
  }, scope);
1427
- setupValidation(controlImpl, definition, dataNode, schemaInterface, parent, formNode);
1432
+ setupValidation(controlImpl, definition, dataNode, schemaInterface, parent, formNode, runAsync);
1428
1433
  createSyncEffect(() => {
1429
1434
  var _dataNode$value;
1430
1435
  const dn = (_dataNode$value = dataNode.value) == null ? void 0 : _dataNode$value.control;