@vaadin/vaadin-text-field 2.8.6 → 2.9.2
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 +12 -11
- package/src/vaadin-email-field.js +1 -1
- package/src/vaadin-integer-field.js +1 -1
- package/src/vaadin-number-field.js +1 -1
- package/src/vaadin-password-field.js +1 -1
- package/src/vaadin-text-area.d.ts +11 -0
- package/src/vaadin-text-area.js +69 -2
- package/src/vaadin-text-field.js +1 -1
- package/theme/material/vaadin-text-area-styles.js +5 -0
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"repository": "vaadin/vaadin-text-field",
|
|
11
11
|
"homepage": "https://vaadin.com/components",
|
|
12
12
|
"name": "@vaadin/vaadin-text-field",
|
|
13
|
-
"version": "2.
|
|
13
|
+
"version": "2.9.2",
|
|
14
14
|
"main": "vaadin-text-field.js",
|
|
15
15
|
"author": "Vaadin Ltd",
|
|
16
16
|
"license": "Apache-2.0",
|
|
@@ -25,8 +25,6 @@
|
|
|
25
25
|
"theme"
|
|
26
26
|
],
|
|
27
27
|
"resolutions": {
|
|
28
|
-
"es-abstract": "1.17.6",
|
|
29
|
-
"@types/doctrine": "0.0.3",
|
|
30
28
|
"inherits": "2.0.3",
|
|
31
29
|
"samsam": "1.1.3",
|
|
32
30
|
"supports-color": "3.1.2",
|
|
@@ -34,22 +32,25 @@
|
|
|
34
32
|
},
|
|
35
33
|
"dependencies": {
|
|
36
34
|
"@polymer/polymer": "^3.0.0",
|
|
35
|
+
"@vaadin/vaadin-themable-mixin": "^1.6.1",
|
|
37
36
|
"@vaadin/vaadin-control-state-mixin": "^2.2.1",
|
|
38
|
-
"@vaadin/vaadin-element-mixin": "^2.4.1",
|
|
39
37
|
"@vaadin/vaadin-lumo-styles": "^1.6.0",
|
|
40
38
|
"@vaadin/vaadin-material-styles": "^1.3.2",
|
|
41
|
-
"@vaadin/vaadin-
|
|
42
|
-
},
|
|
43
|
-
"scripts": {
|
|
44
|
-
"generate-typings": "gen-typescript-declarations --outDir . --verify"
|
|
39
|
+
"@vaadin/vaadin-element-mixin": "^2.4.1"
|
|
45
40
|
},
|
|
46
41
|
"devDependencies": {
|
|
42
|
+
"@web-padawan/gen-typescript-declarations": "^1.6.2",
|
|
43
|
+
"web-component-tester": "6.9.2",
|
|
47
44
|
"@polymer/iron-component-page": "^4.0.0",
|
|
48
45
|
"@polymer/iron-form": "^3.0.0",
|
|
49
46
|
"@polymer/iron-test-helpers": "^3.0.0",
|
|
50
|
-
"@vaadin/vaadin-button": "^2.1.0",
|
|
51
|
-
"@vaadin/vaadin-demo-helpers": "^3.0.0",
|
|
52
47
|
"@webcomponents/webcomponentsjs": "^2.0.0",
|
|
53
|
-
"wct-browser-legacy": "^1.0.1"
|
|
48
|
+
"wct-browser-legacy": "^1.0.1",
|
|
49
|
+
"@vaadin/vaadin-demo-helpers": "^3.0.0",
|
|
50
|
+
"@vaadin/vaadin-button": "^2.1.0"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"generate-typings": "gen-typescript-declarations --outDir . --verify",
|
|
54
|
+
"test": "wct --npm"
|
|
54
55
|
}
|
|
55
56
|
}
|
|
@@ -79,7 +79,18 @@ declare class TextAreaElement extends
|
|
|
79
79
|
ThemableMixin(
|
|
80
80
|
PolymerElement)))) {
|
|
81
81
|
readonly _slottedTagName: string;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* A regular expression that the value is checked against.
|
|
85
|
+
* The pattern must match the entire value, not just some subset.
|
|
86
|
+
*/
|
|
87
|
+
pattern: string|null|undefined;
|
|
82
88
|
ready(): void;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Returns true if the current textarea value satisfies all constraints (if any).
|
|
92
|
+
*/
|
|
93
|
+
checkValidity(): boolean;
|
|
83
94
|
}
|
|
84
95
|
|
|
85
96
|
declare global {
|
package/src/vaadin-text-area.js
CHANGED
|
@@ -110,13 +110,18 @@ class TextAreaElement extends
|
|
|
110
110
|
:host {
|
|
111
111
|
animation: 1ms vaadin-text-area-appear;
|
|
112
112
|
}
|
|
113
|
+
|
|
114
|
+
/* Workaround https://bugzilla.mozilla.org/show_bug.cgi?id=1739079 */
|
|
115
|
+
:host([disabled]) [part='value'] {
|
|
116
|
+
user-select: none;
|
|
117
|
+
}
|
|
113
118
|
</style>
|
|
114
119
|
|
|
115
120
|
<div class="vaadin-text-area-container">
|
|
116
121
|
|
|
117
122
|
<label part="label" on-click="focus" id="[[_labelId]]">[[label]]</label>
|
|
118
123
|
|
|
119
|
-
<div part="input-field" id="[[_inputId]]">
|
|
124
|
+
<div part="input-field" id="[[_inputId]]" on-scroll="__scrollPositionUpdated">
|
|
120
125
|
|
|
121
126
|
<slot name="prefix"></slot>
|
|
122
127
|
|
|
@@ -144,7 +149,19 @@ class TextAreaElement extends
|
|
|
144
149
|
}
|
|
145
150
|
|
|
146
151
|
static get version() {
|
|
147
|
-
return '2.
|
|
152
|
+
return '2.9.2';
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
static get properties() {
|
|
156
|
+
return {
|
|
157
|
+
/**
|
|
158
|
+
* A regular expression that the value is checked against.
|
|
159
|
+
* The pattern must match the entire value, not just some subset.
|
|
160
|
+
*/
|
|
161
|
+
pattern: {
|
|
162
|
+
type: String
|
|
163
|
+
}
|
|
164
|
+
};
|
|
148
165
|
}
|
|
149
166
|
|
|
150
167
|
static get observers() {
|
|
@@ -158,6 +175,29 @@ class TextAreaElement extends
|
|
|
158
175
|
super.ready();
|
|
159
176
|
this._updateHeight();
|
|
160
177
|
this.addEventListener('animationend', this._onAnimationEnd);
|
|
178
|
+
|
|
179
|
+
this._inputField = this.root.querySelector('[part=input-field]');
|
|
180
|
+
// Wheel scrolling results in async scroll events. Preventing the wheel
|
|
181
|
+
// event, scrolling manually and then synchronously updating the scroll position CSS variable
|
|
182
|
+
// allows us to avoid some jumpy behavior that would occur on wheel otherwise.
|
|
183
|
+
this._inputField.addEventListener('wheel', (e) => {
|
|
184
|
+
const scrollTopBefore = this._inputField.scrollTop;
|
|
185
|
+
this._inputField.scrollTop += e.deltaY;
|
|
186
|
+
|
|
187
|
+
if (scrollTopBefore !== this._inputField.scrollTop) {
|
|
188
|
+
e.preventDefault();
|
|
189
|
+
this.__scrollPositionUpdated();
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
this.__scrollPositionUpdated();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** @private */
|
|
197
|
+
__scrollPositionUpdated() {
|
|
198
|
+
this.updateStyles({
|
|
199
|
+
'--_text-area-vertical-scroll-position': this._inputField.scrollTop + 'px',
|
|
200
|
+
});
|
|
161
201
|
}
|
|
162
202
|
|
|
163
203
|
/** @private */
|
|
@@ -222,6 +262,33 @@ class TextAreaElement extends
|
|
|
222
262
|
this._dispatchIronResizeEventIfNeeded('InputHeight', inputHeight);
|
|
223
263
|
}
|
|
224
264
|
|
|
265
|
+
/**
|
|
266
|
+
* Returns true if the current textarea value satisfies all constraints (if any).
|
|
267
|
+
* @return {boolean}
|
|
268
|
+
*/
|
|
269
|
+
checkValidity() {
|
|
270
|
+
if (!super.checkValidity()) {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Native <textarea> does not support pattern attribute, so we have a custom logic
|
|
275
|
+
// according to WHATWG spec for <input>, with tests inspired by web-platform-tests
|
|
276
|
+
// https://html.spec.whatwg.org/multipage/input.html#the-pattern-attribute
|
|
277
|
+
|
|
278
|
+
if (!this.pattern || !this.inputElement.value) {
|
|
279
|
+
// Mark as valid if there is no pattern, or the value is empty
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
try {
|
|
284
|
+
const match = this.inputElement.value.match(this.pattern);
|
|
285
|
+
return match ? match[0] === match.input : false;
|
|
286
|
+
} catch (_) {
|
|
287
|
+
// If the pattern can not be compiled, then report as valid
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
225
292
|
/**
|
|
226
293
|
* Fired when the text-area height changes.
|
|
227
294
|
*
|
package/src/vaadin-text-field.js
CHANGED
|
@@ -20,6 +20,11 @@ const $_documentContainer = html`<dom-module id="material-text-area" theme-for="
|
|
|
20
20
|
white-space: pre-wrap; /* override \`nowrap\` from <vaadin-text-field> */
|
|
21
21
|
align-self: stretch; /* override \`baseline\` from <vaadin-text-field> */
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
[part='input-field']::before,
|
|
25
|
+
[part='input-field']::after {
|
|
26
|
+
bottom: calc(var(--_text-area-vertical-scroll-position) * -1);
|
|
27
|
+
}
|
|
23
28
|
</style>
|
|
24
29
|
</template>
|
|
25
30
|
</dom-module>`;
|