@vaadin/field-base 23.2.0-alpha2 → 23.2.0-dev.48e5e3967

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/field-base",
3
- "version": "23.2.0-alpha2",
3
+ "version": "23.2.0-dev.48e5e3967",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -32,7 +32,7 @@
32
32
  "dependencies": {
33
33
  "@open-wc/dedupe-mixin": "^1.3.0",
34
34
  "@polymer/polymer": "^3.0.0",
35
- "@vaadin/component-base": "23.2.0-alpha2",
35
+ "@vaadin/component-base": "23.2.0-dev.48e5e3967",
36
36
  "lit": "^2.0.0"
37
37
  },
38
38
  "devDependencies": {
@@ -40,5 +40,5 @@
40
40
  "@vaadin/testing-helpers": "^0.3.2",
41
41
  "sinon": "^13.0.2"
42
42
  },
43
- "gitHead": "c9b8113d0fa9a602f8b9cb915c1826355af2e8df"
43
+ "gitHead": "961bc4ae5b707c3c02f12b99819b3c12c9b478aa"
44
44
  }
@@ -30,4 +30,12 @@ export declare class ValidateMixinClass {
30
30
  * Returns true if the field value satisfies all constraints (if any).
31
31
  */
32
32
  checkValidity(): boolean;
33
+
34
+ /**
35
+ * Fired whenever the field is validated.
36
+ *
37
+ * @event validated
38
+ * @param {Object} detail
39
+ * @param {boolean} detail.valid the result of the validation.
40
+ */
33
41
  }
@@ -36,12 +36,17 @@ export const ValidateMixin = dedupingMixin(
36
36
  }
37
37
 
38
38
  /**
39
- * Returns true if field is valid, and sets `invalid` based on the field validity.
39
+ * Validates the field and sets the `invalid` property based on the result.
40
+ *
41
+ * The method fires a `validated` event with the result of the validation.
40
42
  *
41
43
  * @return {boolean} True if the value is valid.
42
44
  */
43
45
  validate() {
44
- return !(this.invalid = !this.checkValidity());
46
+ const isValid = this.checkValidity();
47
+ this.invalid = !isValid;
48
+ this.dispatchEvent(new CustomEvent('validated', { detail: { valid: isValid } }));
49
+ return isValid;
45
50
  }
46
51
 
47
52
  /**
@@ -52,5 +57,13 @@ export const ValidateMixin = dedupingMixin(
52
57
  checkValidity() {
53
58
  return !this.required || !!this.value;
54
59
  }
60
+
61
+ /**
62
+ * Fired whenever the field is validated.
63
+ *
64
+ * @event validated
65
+ * @param {Object} detail
66
+ * @param {boolean} detail.valid the result of the validation.
67
+ */
55
68
  },
56
69
  );