@vaadin/field-base 24.6.0-alpha7 → 24.6.0-alpha8

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": "24.6.0-alpha7",
3
+ "version": "24.6.0-alpha8",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -32,14 +32,14 @@
32
32
  "dependencies": {
33
33
  "@open-wc/dedupe-mixin": "^1.3.0",
34
34
  "@polymer/polymer": "^3.0.0",
35
- "@vaadin/a11y-base": "24.6.0-alpha7",
36
- "@vaadin/component-base": "24.6.0-alpha7",
35
+ "@vaadin/a11y-base": "24.6.0-alpha8",
36
+ "@vaadin/component-base": "24.6.0-alpha8",
37
37
  "lit": "^3.0.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@vaadin/chai-plugins": "24.6.0-alpha7",
40
+ "@vaadin/chai-plugins": "24.6.0-alpha8",
41
41
  "@vaadin/testing-helpers": "^1.0.0",
42
42
  "sinon": "^18.0.0"
43
43
  },
44
- "gitHead": "675d6fe0a08b8cc63ac00140c63f28fc3f52e4ea"
44
+ "gitHead": "a11e1510c4caa08775b202714f5fc1198c22132a"
45
45
  }
@@ -90,8 +90,8 @@ export const InputConstraintsMixin = dedupingMixin(
90
90
  const isLastConstraintRemoved = this.__previousHasConstraints && !hasConstraints;
91
91
 
92
92
  if ((this._hasValue || this.invalid) && hasConstraints) {
93
- this.validate();
94
- } else if (isLastConstraintRemoved) {
93
+ this._requestValidation();
94
+ } else if (isLastConstraintRemoved && !this.manualValidation) {
95
95
  this._setInvalid(false);
96
96
  }
97
97
 
@@ -109,7 +109,7 @@ export const InputConstraintsMixin = dedupingMixin(
109
109
  _onChange(event) {
110
110
  event.stopPropagation();
111
111
 
112
- this.validate();
112
+ this._requestValidation();
113
113
 
114
114
  this.dispatchEvent(
115
115
  new CustomEvent('change', {
@@ -97,7 +97,7 @@ export const InputFieldMixin = (superclass) =>
97
97
  // Do not validate when focusout is caused by document
98
98
  // losing focus, which happens on browser tab switch.
99
99
  if (!focused && document.hasFocus()) {
100
- this.validate();
100
+ this._requestValidation();
101
101
  }
102
102
  }
103
103
 
@@ -112,7 +112,7 @@ export const InputFieldMixin = (superclass) =>
112
112
  super._onInput(event);
113
113
 
114
114
  if (this.invalid) {
115
- this.validate();
115
+ this._requestValidation();
116
116
  }
117
117
  }
118
118
 
@@ -133,7 +133,7 @@ export const InputFieldMixin = (superclass) =>
133
133
  }
134
134
 
135
135
  if (this.invalid) {
136
- this.validate();
136
+ this._requestValidation();
137
137
  }
138
138
  }
139
139
  };
@@ -16,6 +16,19 @@ export declare class ValidateMixinClass {
16
16
  */
17
17
  invalid: boolean;
18
18
 
19
+ /**
20
+ * Set to true to enable manual validation mode. This mode disables automatic
21
+ * constraint validation, allowing you to control the validation process yourself.
22
+ * You can still trigger constraint validation manually with the `validate()` method
23
+ * or use `checkValidity()` to assess the component's validity without affecting
24
+ * the invalid state. In manual validation mode, you can also manipulate
25
+ * the `invalid` property directly through your application logic without conflicts
26
+ * with the component's internal validation.
27
+ *
28
+ * @attr {boolean} manual-validation
29
+ */
30
+ manualValidation: boolean;
31
+
19
32
  /**
20
33
  * Specifies that the user must fill in a value.
21
34
  */
@@ -30,4 +43,6 @@ export declare class ValidateMixinClass {
30
43
  * Returns true if the field value satisfies all constraints (if any).
31
44
  */
32
45
  checkValidity(): boolean;
46
+
47
+ protected _requestValidation(): void;
33
48
  }
@@ -25,6 +25,22 @@ export const ValidateMixin = dedupingMixin(
25
25
  value: false,
26
26
  },
27
27
 
28
+ /**
29
+ * Set to true to enable manual validation mode. This mode disables automatic
30
+ * constraint validation, allowing you to control the validation process yourself.
31
+ * You can still trigger constraint validation manually with the `validate()` method
32
+ * or use `checkValidity()` to assess the component's validity without affecting
33
+ * the invalid state. In manual validation mode, you can also manipulate
34
+ * the `invalid` property directly through your application logic without conflicts
35
+ * with the component's internal validation.
36
+ *
37
+ * @attr {boolean} manual-validation
38
+ */
39
+ manualValidation: {
40
+ type: Boolean,
41
+ value: false,
42
+ },
43
+
28
44
  /**
29
45
  * Specifies that the user must fill in a value.
30
46
  */
@@ -79,6 +95,14 @@ export const ValidateMixin = dedupingMixin(
79
95
  return true;
80
96
  }
81
97
 
98
+ /** @protected */
99
+ _requestValidation() {
100
+ if (!this.manualValidation) {
101
+ // eslint-disable-next-line no-restricted-syntax
102
+ this.validate();
103
+ }
104
+ }
105
+
82
106
  /**
83
107
  * Fired whenever the field is validated.
84
108
  *