@flowgram.ai/form 0.1.18 → 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 +13 -20
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -20
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -262,12 +262,6 @@ var Glob;
|
|
|
262
262
|
})(Glob || (Glob = {}));
|
|
263
263
|
|
|
264
264
|
// src/types/validate.ts
|
|
265
|
-
function isFieldWarning(f) {
|
|
266
|
-
if (f.level === "warning" /* Warning */) {
|
|
267
|
-
return true;
|
|
268
|
-
}
|
|
269
|
-
return false;
|
|
270
|
-
}
|
|
271
265
|
var ValidateTrigger = /* @__PURE__ */ ((ValidateTrigger2) => {
|
|
272
266
|
ValidateTrigger2["onChange"] = "onChange";
|
|
273
267
|
ValidateTrigger2["onBlur"] = "onBlur";
|
|
@@ -986,21 +980,19 @@ var FieldModel = class {
|
|
|
986
980
|
this.form.onValidateEmitter.fire(this.form.state);
|
|
987
981
|
}
|
|
988
982
|
async _runAsyncValidate() {
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
const
|
|
992
|
-
if (!
|
|
983
|
+
let errors = [];
|
|
984
|
+
let warnings = [];
|
|
985
|
+
const results = await this.form.validateIn(this.name);
|
|
986
|
+
if (!results?.length) {
|
|
993
987
|
return {};
|
|
994
988
|
} else {
|
|
995
|
-
const
|
|
996
|
-
if (!
|
|
989
|
+
const feedbacks = results.map((result) => toFeedback(result, this.name)).filter(Boolean);
|
|
990
|
+
if (!feedbacks?.length) {
|
|
997
991
|
return {};
|
|
998
992
|
}
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
errors.push(feedback);
|
|
1003
|
-
}
|
|
993
|
+
const groupedFeedbacks = (0, import_lodash7.groupBy)(feedbacks, "level");
|
|
994
|
+
warnings = warnings.concat(groupedFeedbacks["warning" /* Warning */]);
|
|
995
|
+
errors = errors.concat(groupedFeedbacks["error" /* Error */]);
|
|
1004
996
|
}
|
|
1005
997
|
return { errors, warnings };
|
|
1006
998
|
}
|
|
@@ -1419,10 +1411,10 @@ var FormModel = class {
|
|
|
1419
1411
|
if (!this._options.validate) {
|
|
1420
1412
|
return;
|
|
1421
1413
|
}
|
|
1422
|
-
const
|
|
1414
|
+
const validateKeys = Object.keys(this._options.validate).filter(
|
|
1423
1415
|
(pattern) => Glob.isMatch(pattern, name)
|
|
1424
1416
|
);
|
|
1425
|
-
|
|
1417
|
+
const validatePromises = validateKeys.map(async (validateKey) => {
|
|
1426
1418
|
const validate = this._options.validate[validateKey];
|
|
1427
1419
|
return validate({
|
|
1428
1420
|
value: this.getValueIn(name),
|
|
@@ -1430,7 +1422,8 @@ var FormModel = class {
|
|
|
1430
1422
|
context: this.context,
|
|
1431
1423
|
name
|
|
1432
1424
|
});
|
|
1433
|
-
}
|
|
1425
|
+
});
|
|
1426
|
+
return Promise.all(validatePromises);
|
|
1434
1427
|
}
|
|
1435
1428
|
async validate() {
|
|
1436
1429
|
if (!this._options.validate) {
|