@vaadin/text-area 22.0.2 → 23.0.0-alpha4
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 +9 -8
- package/src/vaadin-text-area.d.ts +13 -3
- package/src/vaadin-text-area.js +31 -4
- package/theme/lumo/vaadin-text-area-styles.js +1 -1
- package/theme/lumo/vaadin-text-area.js +1 -1
- package/theme/material/vaadin-text-area-styles.js +1 -1
- package/theme/material/vaadin-text-area.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/text-area",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "23.0.0-alpha4",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"main": "vaadin-text-area.js",
|
|
20
20
|
"module": "vaadin-text-area.js",
|
|
21
|
+
"type": "module",
|
|
21
22
|
"files": [
|
|
22
23
|
"src",
|
|
23
24
|
"theme",
|
|
@@ -32,17 +33,17 @@
|
|
|
32
33
|
],
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"@polymer/polymer": "^3.0.0",
|
|
35
|
-
"@vaadin/component-base": "
|
|
36
|
-
"@vaadin/field-base": "
|
|
37
|
-
"@vaadin/input-container": "
|
|
38
|
-
"@vaadin/vaadin-lumo-styles": "
|
|
39
|
-
"@vaadin/vaadin-material-styles": "
|
|
40
|
-
"@vaadin/vaadin-themable-mixin": "
|
|
36
|
+
"@vaadin/component-base": "23.0.0-alpha4",
|
|
37
|
+
"@vaadin/field-base": "23.0.0-alpha4",
|
|
38
|
+
"@vaadin/input-container": "23.0.0-alpha4",
|
|
39
|
+
"@vaadin/vaadin-lumo-styles": "23.0.0-alpha4",
|
|
40
|
+
"@vaadin/vaadin-material-styles": "23.0.0-alpha4",
|
|
41
|
+
"@vaadin/vaadin-themable-mixin": "23.0.0-alpha4"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"@esm-bundle/chai": "^4.3.4",
|
|
44
45
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
45
46
|
"sinon": "^9.2.1"
|
|
46
47
|
},
|
|
47
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "81e2deee5147bb7c1f4884760f4598613306f1fb"
|
|
48
49
|
}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 Vaadin Ltd.
|
|
3
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
7
7
|
import { InputFieldMixin } from '@vaadin/field-base/src/input-field-mixin.js';
|
|
8
|
+
import { PatternMixin } from '@vaadin/field-base/src/pattern-mixin.js';
|
|
8
9
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
9
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Fired when the user commits a value change.
|
|
13
|
+
*/
|
|
14
|
+
export type TextAreaChangeEvent = Event & {
|
|
15
|
+
target: TextArea;
|
|
16
|
+
};
|
|
17
|
+
|
|
10
18
|
/**
|
|
11
19
|
* Fired when the `invalid` property changes.
|
|
12
20
|
*/
|
|
@@ -23,7 +31,9 @@ export interface TextAreaCustomEventMap {
|
|
|
23
31
|
'value-changed': TextAreaValueChangedEvent;
|
|
24
32
|
}
|
|
25
33
|
|
|
26
|
-
export interface TextAreaEventMap extends HTMLElementEventMap, TextAreaCustomEventMap {
|
|
34
|
+
export interface TextAreaEventMap extends HTMLElementEventMap, TextAreaCustomEventMap {
|
|
35
|
+
change: TextAreaChangeEvent;
|
|
36
|
+
}
|
|
27
37
|
|
|
28
38
|
/**
|
|
29
39
|
* `<vaadin-text-area>` is a web component for multi-line text input.
|
|
@@ -66,7 +76,7 @@ export interface TextAreaEventMap extends HTMLElementEventMap, TextAreaCustomEve
|
|
|
66
76
|
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
67
77
|
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
68
78
|
*/
|
|
69
|
-
declare class TextArea extends InputFieldMixin(ThemableMixin(ElementMixin(HTMLElement))) {
|
|
79
|
+
declare class TextArea extends PatternMixin(InputFieldMixin(ThemableMixin(ElementMixin(HTMLElement)))) {
|
|
70
80
|
/**
|
|
71
81
|
* Maximum number of characters (in Unicode code points) that the user can enter.
|
|
72
82
|
*/
|
package/src/vaadin-text-area.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2021 Vaadin Ltd.
|
|
3
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import '@vaadin/input-container/src/vaadin-input-container.js';
|
|
@@ -8,6 +8,7 @@ import { html, PolymerElement } from '@polymer/polymer';
|
|
|
8
8
|
import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
|
|
9
9
|
import { InputFieldMixin } from '@vaadin/field-base/src/input-field-mixin.js';
|
|
10
10
|
import { LabelledInputController } from '@vaadin/field-base/src/labelled-input-controller.js';
|
|
11
|
+
import { PatternMixin } from '@vaadin/field-base/src/pattern-mixin.js';
|
|
11
12
|
import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
|
|
12
13
|
import { TextAreaController } from '@vaadin/field-base/src/text-area-controller.js';
|
|
13
14
|
import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
@@ -56,9 +57,10 @@ registerStyles('vaadin-text-area', inputFieldShared, { moduleId: 'vaadin-text-ar
|
|
|
56
57
|
* @extends HTMLElement
|
|
57
58
|
* @mixes InputFieldMixin
|
|
58
59
|
* @mixes ElementMixin
|
|
60
|
+
* @mixes PatternMixin
|
|
59
61
|
* @mixes ThemableMixin
|
|
60
62
|
*/
|
|
61
|
-
export class TextArea extends InputFieldMixin(ThemableMixin(ElementMixin(PolymerElement))) {
|
|
63
|
+
export class TextArea extends PatternMixin(InputFieldMixin(ThemableMixin(ElementMixin(PolymerElement)))) {
|
|
62
64
|
static get is() {
|
|
63
65
|
return 'vaadin-text-area';
|
|
64
66
|
}
|
|
@@ -210,7 +212,7 @@ export class TextArea extends InputFieldMixin(ThemableMixin(ElementMixin(Polymer
|
|
|
210
212
|
this.ariaTarget = input;
|
|
211
213
|
})
|
|
212
214
|
);
|
|
213
|
-
this.addController(new LabelledInputController(this.inputElement, this.
|
|
215
|
+
this.addController(new LabelledInputController(this.inputElement, this._labelController));
|
|
214
216
|
this.addEventListener('animationend', this._onAnimationEnd);
|
|
215
217
|
}
|
|
216
218
|
|
|
@@ -276,8 +278,33 @@ export class TextArea extends InputFieldMixin(ThemableMixin(ElementMixin(Polymer
|
|
|
276
278
|
inputField.style.removeProperty('display');
|
|
277
279
|
inputField.style.removeProperty('height');
|
|
278
280
|
inputField.scrollTop = scrollTop;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Returns true if the current textarea value satisfies all constraints (if any).
|
|
285
|
+
* @return {boolean}
|
|
286
|
+
*/
|
|
287
|
+
checkValidity() {
|
|
288
|
+
if (!super.checkValidity()) {
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
279
291
|
|
|
280
|
-
|
|
292
|
+
// Native <textarea> does not support pattern attribute, so we have a custom logic
|
|
293
|
+
// according to WHATWG spec for <input>, with tests inspired by web-platform-tests
|
|
294
|
+
// https://html.spec.whatwg.org/multipage/input.html#the-pattern-attribute
|
|
295
|
+
|
|
296
|
+
if (!this.pattern || !this.inputElement.value) {
|
|
297
|
+
// Mark as valid if there is no pattern, or the value is empty
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
try {
|
|
302
|
+
const match = this.inputElement.value.match(this.pattern);
|
|
303
|
+
return match ? match[0] === match.input : false;
|
|
304
|
+
} catch (_) {
|
|
305
|
+
// If the pattern can not be compiled, then report as valid
|
|
306
|
+
return true;
|
|
307
|
+
}
|
|
281
308
|
}
|
|
282
309
|
}
|
|
283
310
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import '@vaadin/input-container/theme/lumo/vaadin-input-container.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { inputFieldShared } from '@vaadin/vaadin-material-styles/mixins/input-field-shared.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import '@vaadin/input-container/theme/material/vaadin-input-container.js';
|