@vaadin/vaadin-text-field 2.8.3 → 2.9.0
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/README.md +8 -9
- package/package.json +4 -4
- 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 +61 -10
- package/src/vaadin-text-field-mixin.js +1 -1
- package/src/vaadin-text-field.js +2 -2
- package/theme/lumo/vaadin-text-area-styles.js +2 -2
package/README.md
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
[](https://www.webcomponents.org/element/vaadin/vaadin-text-field)
|
|
3
|
-
[](https://travis-ci.org/vaadin/vaadin-text-field)
|
|
4
|
-
[](https://coveralls.io/github/vaadin/vaadin-text-field?branch=master)
|
|
5
|
-
[](https://gitter.im/vaadin/web-components?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
|
1
|
+
# <vaadin-text-field>
|
|
6
2
|
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
> ⚠️ Starting from Vaadin 20, the source code and issues for this component are migrated to the [`vaadin/web-components`](https://github.com/vaadin/web-components/tree/master/packages/vaadin-text-field) monorepository.
|
|
4
|
+
> This repository contains the source code and releases of `<vaadin-text-field>` for the Vaadin versions 10 to 19.
|
|
9
5
|
|
|
10
|
-
|
|
6
|
+
[<vaadin-text-field>](https://vaadin.com/components/vaadin-text-field) is a themable Web Component providing input controls in forms, part of the [Vaadin components](https://vaadin.com/components).
|
|
11
7
|
|
|
12
8
|
[Live Demo ↗](https://vaadin.com/components/vaadin-text-field/html-examples)
|
|
13
9
|
|
|
|
14
10
|
[API documentation ↗](https://vaadin.com/components/vaadin-text-field/html-api)
|
|
15
11
|
|
|
16
|
-
[
|
|
12
|
+
[](https://badge.fury.io/js/%40vaadin%2Fvaadin-text-field)
|
|
13
|
+
[](https://www.webcomponents.org/element/vaadin/vaadin-text-field)
|
|
14
|
+
[](https://vaadin.com/directory/component/vaadinvaadin-text-field)
|
|
15
|
+
[](https://discord.gg/PHmkCKC)
|
|
17
16
|
|
|
18
17
|
<!--
|
|
19
18
|
```
|
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.0",
|
|
14
14
|
"main": "vaadin-text-field.js",
|
|
15
15
|
"author": "Vaadin Ltd",
|
|
16
16
|
"license": "Apache-2.0",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"@vaadin/vaadin-element-mixin": "^2.4.1"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
"generate-typings": "gen-typescript-declarations --outDir . --verify"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
47
|
"@polymer/iron-component-page": "^4.0.0",
|
|
48
48
|
"@polymer/iron-form": "^3.0.0",
|
|
49
49
|
"@polymer/iron-test-helpers": "^3.0.0",
|
|
@@ -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,6 +110,11 @@ 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">
|
|
@@ -129,7 +134,7 @@ class TextAreaElement extends
|
|
|
129
134
|
|
|
130
135
|
</div>
|
|
131
136
|
|
|
132
|
-
<div part="helper-text"
|
|
137
|
+
<div part="helper-text" id="[[_helperTextId]]">
|
|
133
138
|
<slot name="helper">[[helperText]]</slot>
|
|
134
139
|
</div>
|
|
135
140
|
|
|
@@ -144,7 +149,19 @@ class TextAreaElement extends
|
|
|
144
149
|
}
|
|
145
150
|
|
|
146
151
|
static get version() {
|
|
147
|
-
return '2.
|
|
152
|
+
return '2.9.0';
|
|
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,7 +175,6 @@ class TextAreaElement extends
|
|
|
158
175
|
super.ready();
|
|
159
176
|
this._updateHeight();
|
|
160
177
|
this.addEventListener('animationend', this._onAnimationEnd);
|
|
161
|
-
this.__safari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
162
178
|
}
|
|
163
179
|
|
|
164
180
|
/** @private */
|
|
@@ -187,18 +203,25 @@ class TextAreaElement extends
|
|
|
187
203
|
const scrollTop = inputField.scrollTop;
|
|
188
204
|
const input = this.inputElement;
|
|
189
205
|
|
|
190
|
-
const inputWidth = getComputedStyle(input).width;
|
|
191
|
-
|
|
192
|
-
const valueLength = this.value ? this.value.length : 0;
|
|
193
206
|
// Only clear the height when the content shortens to minimize scrollbar flickering.
|
|
207
|
+
const valueLength = this.value ? this.value.length : 0;
|
|
208
|
+
|
|
194
209
|
if (this._oldValueLength >= valueLength) {
|
|
210
|
+
const inputFieldHeight = getComputedStyle(inputField).height;
|
|
211
|
+
const inputWidth = getComputedStyle(input).width;
|
|
212
|
+
|
|
213
|
+
// Temporarily fix the height of the wrapping input field container to prevent changing the browsers scroll
|
|
214
|
+
// position while resetting the textareas height. If the textarea had a large height, then removing its height
|
|
215
|
+
// will reset its height to the default of two rows. That might reduce the height of the page, and the
|
|
216
|
+
// browser might adjust the scroll position before we can restore the measured height of the textarea.
|
|
217
|
+
inputField.style.display = 'block';
|
|
218
|
+
inputField.style.height = inputFieldHeight;
|
|
219
|
+
|
|
195
220
|
// Fix the input element width so its scroll height isn't affected by host's disappearing scrollbars
|
|
196
221
|
input.style.maxWidth = inputWidth;
|
|
222
|
+
|
|
223
|
+
// Clear the height of the textarea to allow measuring a reduced scroll height
|
|
197
224
|
input.style.height = 'auto';
|
|
198
|
-
// Avoid a jumpy Safari rendering issue
|
|
199
|
-
if (this.__safari) {
|
|
200
|
-
inputField.style.display = 'block';
|
|
201
|
-
}
|
|
202
225
|
}
|
|
203
226
|
this._oldValueLength = valueLength;
|
|
204
227
|
|
|
@@ -210,11 +233,39 @@ class TextAreaElement extends
|
|
|
210
233
|
// Restore
|
|
211
234
|
input.style.removeProperty('max-width');
|
|
212
235
|
inputField.style.removeProperty('display');
|
|
236
|
+
inputField.style.removeProperty('height');
|
|
213
237
|
inputField.scrollTop = scrollTop;
|
|
214
238
|
|
|
215
239
|
this._dispatchIronResizeEventIfNeeded('InputHeight', inputHeight);
|
|
216
240
|
}
|
|
217
241
|
|
|
242
|
+
/**
|
|
243
|
+
* Returns true if the current textarea value satisfies all constraints (if any).
|
|
244
|
+
* @return {boolean}
|
|
245
|
+
*/
|
|
246
|
+
checkValidity() {
|
|
247
|
+
if (!super.checkValidity()) {
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// Native <textarea> does not support pattern attribute, so we have a custom logic
|
|
252
|
+
// according to WHATWG spec for <input>, with tests inspired by web-platform-tests
|
|
253
|
+
// https://html.spec.whatwg.org/multipage/input.html#the-pattern-attribute
|
|
254
|
+
|
|
255
|
+
if (!this.pattern || !this.inputElement.value) {
|
|
256
|
+
// Mark as valid if there is no pattern, or the value is empty
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
try {
|
|
261
|
+
const match = this.inputElement.value.match(this.pattern);
|
|
262
|
+
return match ? match[0] === match.input : false;
|
|
263
|
+
} catch (_) {
|
|
264
|
+
// If the pattern can not be compiled, then report as valid
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
218
269
|
/**
|
|
219
270
|
* Fired when the text-area height changes.
|
|
220
271
|
*
|
|
@@ -884,7 +884,7 @@ export const TextFieldMixin = subclass => class VaadinTextFieldMixin extends sub
|
|
|
884
884
|
if (this[previousSizePropertyName] !== undefined
|
|
885
885
|
&& this[previousSizePropertyName] !== value) {
|
|
886
886
|
this.dispatchEvent(
|
|
887
|
-
new CustomEvent('iron-resize', {bubbles: true})
|
|
887
|
+
new CustomEvent('iron-resize', {bubbles: true, composed: true})
|
|
888
888
|
);
|
|
889
889
|
}
|
|
890
890
|
|
package/src/vaadin-text-field.js
CHANGED
|
@@ -101,7 +101,7 @@ class TextFieldElement extends
|
|
|
101
101
|
|
|
102
102
|
</div>
|
|
103
103
|
|
|
104
|
-
<div part="helper-text"
|
|
104
|
+
<div part="helper-text" id="[[_helperTextId]]">
|
|
105
105
|
<slot name="helper">[[helperText]]</slot>
|
|
106
106
|
</div>
|
|
107
107
|
|
|
@@ -116,7 +116,7 @@ class TextFieldElement extends
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
static get version() {
|
|
119
|
-
return '2.
|
|
119
|
+
return '2.9.0';
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
static get properties() {
|
|
@@ -29,12 +29,12 @@ const $_documentContainer = html`<dom-module id="lumo-text-area" theme-for="vaad
|
|
|
29
29
|
border: none;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
:host(:hover:not([readonly]):not([focused])) [part="input-field"] {
|
|
32
|
+
:host(:hover:not([readonly]):not([focused]):not([invalid])) [part="input-field"] {
|
|
33
33
|
background-color: var(--lumo-contrast-20pct);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
@media (pointer: coarse) {
|
|
37
|
-
:host(:hover:not([readonly]):not([focused])) [part="input-field"] {
|
|
37
|
+
:host(:hover:not([readonly]):not([focused]):not([invalid])) [part="input-field"] {
|
|
38
38
|
background-color: var(--lumo-contrast-10pct);
|
|
39
39
|
}
|
|
40
40
|
|