@vaadin/field-base 23.2.0-alpha5 → 23.2.0-alpha6

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-alpha5",
3
+ "version": "23.2.0-alpha6",
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-alpha5",
35
+ "@vaadin/component-base": "23.2.0-alpha6",
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": "c6247fd741d61096d75a71feda4a1faf88b6f0ce"
43
+ "gitHead": "61f1fb56953434e97d34a8819640064301dd3d8a"
44
44
  }
@@ -85,15 +85,17 @@ export const InputFieldMixin = (superclass) =>
85
85
  }
86
86
 
87
87
  /**
88
- * Override an event listener from `DelegateFocusMixin`.
89
- * @param {FocusEvent} event
88
+ * Override an event listener from `FocusMixin`.
89
+ * @param {boolean} focused
90
90
  * @protected
91
91
  * @override
92
92
  */
93
- _onBlur(event) {
94
- super._onBlur(event);
93
+ _setFocused(focused) {
94
+ super._setFocused(focused);
95
95
 
96
- this.validate();
96
+ if (!focused) {
97
+ this.validate();
98
+ }
97
99
  }
98
100
 
99
101
  /**
@@ -52,6 +52,16 @@ export const InputMixin = dedupingMixin(
52
52
  observer: '_valueChanged',
53
53
  notify: true,
54
54
  },
55
+
56
+ /**
57
+ * When true, the input element has a non-empty value entered by the user.
58
+ * @protected
59
+ */
60
+ _hasInputValue: {
61
+ type: Boolean,
62
+ value: false,
63
+ observer: '_hasInputValueChanged',
64
+ },
55
65
  };
56
66
  }
57
67
 
@@ -59,7 +69,7 @@ export const InputMixin = dedupingMixin(
59
69
  super();
60
70
 
61
71
  this._boundOnInput = this._onInput.bind(this);
62
- this._boundOnChange = this._onChange.bind(this);
72
+ this._boundOnChange = this.__onChange.bind(this);
63
73
  }
64
74
 
65
75
  /**
@@ -126,6 +136,17 @@ export const InputMixin = dedupingMixin(
126
136
  }
127
137
  }
128
138
 
139
+ /**
140
+ * Observer to notify about the change of private property.
141
+ *
142
+ * @private
143
+ */
144
+ _hasInputValueChanged(hasValue, oldHasValue) {
145
+ if (hasValue || oldHasValue) {
146
+ this.dispatchEvent(new CustomEvent('has-input-value-changed'));
147
+ }
148
+ }
149
+
129
150
  /**
130
151
  * An input event listener used to update the field value.
131
152
  *
@@ -147,6 +168,18 @@ export const InputMixin = dedupingMixin(
147
168
  */
148
169
  _onChange(_event) {}
149
170
 
171
+ /**
172
+ * A change event listener used to update `_hasInputValue` property.
173
+ * Do not override this method.
174
+ *
175
+ * @param {Event} event
176
+ * @private
177
+ */
178
+ __onChange(event) {
179
+ this._hasInputValue = event.target.value.length > 0;
180
+ this._onChange(event);
181
+ }
182
+
150
183
  /**
151
184
  * Toggle the has-value attribute based on the value property.
152
185
  * @param {boolean} hasValue