@flowgram.ai/form 0.1.17 → 0.1.21

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/dist/esm/index.js CHANGED
@@ -194,18 +194,15 @@ var Glob;
194
194
  }
195
195
  Glob2.findMatchPaths = findMatchPaths;
196
196
  function findMatchPathsWithEmptyValue(obj, pattern) {
197
+ if (!pattern.includes("*")) {
198
+ return [pattern];
199
+ }
197
200
  return findMatchPaths(obj, pattern, true);
198
201
  }
199
202
  Glob2.findMatchPathsWithEmptyValue = findMatchPathsWithEmptyValue;
200
203
  })(Glob || (Glob = {}));
201
204
 
202
205
  // src/types/validate.ts
203
- function isFieldWarning(f) {
204
- if (f.level === "warning" /* Warning */) {
205
- return true;
206
- }
207
- return false;
208
- }
209
206
  var ValidateTrigger = /* @__PURE__ */ ((ValidateTrigger2) => {
210
207
  ValidateTrigger2["onChange"] = "onChange";
211
208
  ValidateTrigger2["onBlur"] = "onBlur";
@@ -924,21 +921,19 @@ var FieldModel = class {
924
921
  this.form.onValidateEmitter.fire(this.form.state);
925
922
  }
926
923
  async _runAsyncValidate() {
927
- const errors = [];
928
- const warnings = [];
929
- const result = await this.form.validateIn(this.name);
930
- if (!result) {
924
+ let errors = [];
925
+ let warnings = [];
926
+ const results = await this.form.validateIn(this.name);
927
+ if (!results?.length) {
931
928
  return {};
932
929
  } else {
933
- const feedback = toFeedback(result, this.name);
934
- if (!feedback) {
930
+ const feedbacks = results.map((result) => toFeedback(result, this.name)).filter(Boolean);
931
+ if (!feedbacks?.length) {
935
932
  return {};
936
933
  }
937
- if (isFieldWarning(feedback)) {
938
- warnings.push(feedback);
939
- } else {
940
- errors.push(feedback);
941
- }
934
+ const groupedFeedbacks = groupBy(feedbacks, "level");
935
+ warnings = warnings.concat(groupedFeedbacks["warning" /* Warning */]);
936
+ errors = errors.concat(groupedFeedbacks["error" /* Error */]);
942
937
  }
943
938
  return { errors, warnings };
944
939
  }
@@ -1357,10 +1352,10 @@ var FormModel = class {
1357
1352
  if (!this._options.validate) {
1358
1353
  return;
1359
1354
  }
1360
- const validateKey = Object.keys(this._options.validate).find(
1355
+ const validateKeys = Object.keys(this._options.validate).filter(
1361
1356
  (pattern) => Glob.isMatch(pattern, name)
1362
1357
  );
1363
- if (validateKey) {
1358
+ const validatePromises = validateKeys.map(async (validateKey) => {
1364
1359
  const validate = this._options.validate[validateKey];
1365
1360
  return validate({
1366
1361
  value: this.getValueIn(name),
@@ -1368,7 +1363,8 @@ var FormModel = class {
1368
1363
  context: this.context,
1369
1364
  name
1370
1365
  });
1371
- }
1366
+ });
1367
+ return Promise.all(validatePromises);
1372
1368
  }
1373
1369
  async validate() {
1374
1370
  if (!this._options.validate) {