@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 +3 -3
- package/src/validate-mixin.d.ts +8 -0
- package/src/validate-mixin.js +15 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/field-base",
|
|
3
|
-
"version": "23.2.0-
|
|
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-
|
|
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": "
|
|
43
|
+
"gitHead": "961bc4ae5b707c3c02f12b99819b3c12c9b478aa"
|
|
44
44
|
}
|
package/src/validate-mixin.d.ts
CHANGED
|
@@ -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
|
}
|
package/src/validate-mixin.js
CHANGED
|
@@ -36,12 +36,17 @@ export const ValidateMixin = dedupingMixin(
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
*
|
|
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
|
-
|
|
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
|
);
|